From 91ec3a3edd4ed8bd484de8cfb447234a53144a27 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Mon, 17 Mar 2025 00:52:47 +0200 Subject: [PATCH 001/142] Replace WinFormsUI to be taken from the repo - dockpanelsuite --- src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs | 3 ++- src/LogExpert/LogExpert.csproj | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs index 45393abd..7ac34388 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs @@ -886,7 +886,8 @@ private void InitializeComponent() dockPaneStripToolWindowGradient1.InactiveTabGradient = tabGradient7; dockPaneStripSkin1.ToolWindowGradient = dockPaneStripToolWindowGradient1; dockPanelSkin1.DockPaneStripSkin = dockPaneStripSkin1; - dockPanel.Skin = dockPanelSkin1; + dockPanel.Theme = new DockPanelTheme(dockPanelSkin1); + //dockPanel.Theme.Skin = dockPanelSkin1; dockPanel.TabIndex = 14; dockPanel.ActiveContentChanged += OnDockPanelActiveContentChanged; // diff --git a/src/LogExpert/LogExpert.csproj b/src/LogExpert/LogExpert.csproj index c4be38e4..844ccfc8 100644 --- a/src/LogExpert/LogExpert.csproj +++ b/src/LogExpert/LogExpert.csproj @@ -85,9 +85,9 @@ + - From ec8c61ac123c51f75a92abd361cb1cb0d52f0213 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Fri, 21 Mar 2025 16:22:24 +0200 Subject: [PATCH 002/142] Removed the WinFormsUI and using the nuget version instead --- src/Directory.Packages.props | 2 + src/LogExpert.sln | 6 - .../Controls/LogTabWindow/LogTabWindow.cs | 32 +- .../LogTabWindow/LogTabWindow.designer.cs | 8 +- .../Controls/LogWindow/LogWindowsPublic.cs | 2 - src/LogExpert/LogExpert.csproj | 3 +- src/WinFormsUI/Docking/AutoHideStripBase.cs | 684 ------- src/WinFormsUI/Docking/DockAreasEditor.cs | 201 -- src/WinFormsUI/Docking/DockContent.cs | 328 ---- .../Docking/DockContentCollection.cs | 233 --- .../Docking/DockContentEventArgs.cs | 26 - src/WinFormsUI/Docking/DockContentHandler.cs | 1320 ------------- src/WinFormsUI/Docking/DockOutlineBase.cs | 146 -- .../Docking/DockPane.SplitterControl.cs | 199 -- src/WinFormsUI/Docking/DockPane.cs | 1610 ---------------- src/WinFormsUI/Docking/DockPaneCaptionBase.cs | 122 -- src/WinFormsUI/Docking/DockPaneCollection.cs | 63 - src/WinFormsUI/Docking/DockPaneStripBase.cs | 327 ---- .../Docking/DockPanel.AutoHideWindow.cs | 768 -------- .../Docking/DockPanel.DockDragHandler.cs | 1073 ----------- .../Docking/DockPanel.DragHandler.cs | 169 -- .../Docking/DockPanel.FocusManager.cs | 731 ------- .../Docking/DockPanel.MdiClientController.cs | 534 ------ src/WinFormsUI/Docking/DockPanel.Persistor.cs | 816 -------- .../Docking/DockPanel.SplitterDragHandler.cs | 230 --- src/WinFormsUI/Docking/DockPanel.bmp | Bin 822 -> 0 bytes src/WinFormsUI/Docking/DockPanel.cs | 1208 ------------ src/WinFormsUI/Docking/DockPanelExtender.cs | 315 --- src/WinFormsUI/Docking/DockPanelSkin.cs | 482 ----- .../Docking/DockWindow.SplitterControl.cs | 38 - src/WinFormsUI/Docking/DockWindow.cs | 283 --- .../Docking/DockWindowCollection.cs | 56 - src/WinFormsUI/Docking/DragForm.cs | 84 - src/WinFormsUI/Docking/DummyControl.cs | 17 - src/WinFormsUI/Docking/Enums.cs | 60 - src/WinFormsUI/Docking/FloatWindow.cs | 551 ------ .../Docking/FloatWindowCollection.cs | 54 - src/WinFormsUI/Docking/Helpers/DockHelper.cs | 153 -- src/WinFormsUI/Docking/Helpers/DrawHelper.cs | 112 -- .../Docking/Helpers/ResourceHelper.cs | 43 - src/WinFormsUI/Docking/Helpers/Win32Helper.cs | 23 - src/WinFormsUI/Docking/InertButtonBase.cs | 145 -- src/WinFormsUI/Docking/Interfaces.cs | 76 - src/WinFormsUI/Docking/Localization.cs | 68 - src/WinFormsUI/Docking/Measures.cs | 22 - src/WinFormsUI/Docking/NestedDockingStatus.cs | 78 - .../Docking/NestedPaneCollection.cs | 212 -- src/WinFormsUI/Docking/Resources.Designer.cs | 293 --- src/WinFormsUI/Docking/Resources.resx | 190 -- .../Resources/DockIndicator_PaneDiamond.bmp | Bin 23286 -> 0 bytes .../DockIndicator_PaneDiamond_Bottom.bmp | Bin 23286 -> 0 bytes .../DockIndicator_PaneDiamond_Hotspot.bmp | Bin 23286 -> 0 bytes ...DockIndicator_PaneDiamond_HotspotIndex.bmp | Bin 90 -> 0 bytes .../DockIndicator_PaneDiamond_Left.bmp | Bin 23286 -> 0 bytes .../DockIndicator_PaneDiamond_Right.bmp | Bin 23286 -> 0 bytes .../DockIndicator_PaneDiamond_Top.bmp | Bin 23286 -> 0 bytes .../Resources/DockIndicator_PanelBottom.bmp | Bin 2782 -> 0 bytes .../DockIndicator_PanelBottom_Active.bmp | Bin 2782 -> 0 bytes .../Resources/DockIndicator_PanelFill.bmp | Bin 3030 -> 0 bytes .../DockIndicator_PanelFill_Active.bmp | Bin 3030 -> 0 bytes .../Resources/DockIndicator_PanelLeft.bmp | Bin 2838 -> 0 bytes .../DockIndicator_PanelLeft_Active.bmp | Bin 2838 -> 0 bytes .../Resources/DockIndicator_PanelRight.bmp | Bin 2838 -> 0 bytes .../DockIndicator_PanelRight_Active.bmp | Bin 2838 -> 0 bytes .../Resources/DockIndicator_PanelTop.bmp | Bin 2870 -> 0 bytes .../DockIndicator_PanelTop_Active.bmp | Bin 2870 -> 0 bytes .../Docking/Resources/DockPane_AutoHide.bmp | Bin 774 -> 0 bytes .../Docking/Resources/DockPane_Close.bmp | Bin 774 -> 0 bytes .../Docking/Resources/DockPane_Dock.bmp | Bin 774 -> 0 bytes .../Docking/Resources/DockPane_Option.bmp | Bin 774 -> 0 bytes .../Resources/DockPane_OptionOverflow.bmp | Bin 774 -> 0 bytes .../Dockindicator_PaneDiamond_Fill.bmp | Bin 23286 -> 0 bytes src/WinFormsUI/Docking/SplitterBase.cs | 98 - src/WinFormsUI/Docking/Strings.Designer.cs | 774 -------- src/WinFormsUI/Docking/Strings.resx | 357 ---- src/WinFormsUI/Docking/VS2005AutoHideStrip.cs | 604 ------ .../Docking/VS2005DockPaneCaption.cs | 582 ------ src/WinFormsUI/Docking/VS2005DockPaneStrip.cs | 1707 ----------------- .../Docking/VisibleNestedPaneCollection.cs | 203 -- src/WinFormsUI/Docking/Win32/Enums.cs | 369 ---- src/WinFormsUI/Docking/Win32/NativeMethods.cs | 74 - src/WinFormsUI/WinFormsUI.csproj | 113 -- src/WinFormsUI/WinFormsUI.csproj.vspscc | 10 - src/WinFormsUI/license.txt | 9 - 84 files changed, 23 insertions(+), 19073 deletions(-) delete mode 100644 src/WinFormsUI/Docking/AutoHideStripBase.cs delete mode 100644 src/WinFormsUI/Docking/DockAreasEditor.cs delete mode 100644 src/WinFormsUI/Docking/DockContent.cs delete mode 100644 src/WinFormsUI/Docking/DockContentCollection.cs delete mode 100644 src/WinFormsUI/Docking/DockContentEventArgs.cs delete mode 100644 src/WinFormsUI/Docking/DockContentHandler.cs delete mode 100644 src/WinFormsUI/Docking/DockOutlineBase.cs delete mode 100644 src/WinFormsUI/Docking/DockPane.SplitterControl.cs delete mode 100644 src/WinFormsUI/Docking/DockPane.cs delete mode 100644 src/WinFormsUI/Docking/DockPaneCaptionBase.cs delete mode 100644 src/WinFormsUI/Docking/DockPaneCollection.cs delete mode 100644 src/WinFormsUI/Docking/DockPaneStripBase.cs delete mode 100644 src/WinFormsUI/Docking/DockPanel.AutoHideWindow.cs delete mode 100644 src/WinFormsUI/Docking/DockPanel.DockDragHandler.cs delete mode 100644 src/WinFormsUI/Docking/DockPanel.DragHandler.cs delete mode 100644 src/WinFormsUI/Docking/DockPanel.FocusManager.cs delete mode 100644 src/WinFormsUI/Docking/DockPanel.MdiClientController.cs delete mode 100644 src/WinFormsUI/Docking/DockPanel.Persistor.cs delete mode 100644 src/WinFormsUI/Docking/DockPanel.SplitterDragHandler.cs delete mode 100644 src/WinFormsUI/Docking/DockPanel.bmp delete mode 100644 src/WinFormsUI/Docking/DockPanel.cs delete mode 100644 src/WinFormsUI/Docking/DockPanelExtender.cs delete mode 100644 src/WinFormsUI/Docking/DockPanelSkin.cs delete mode 100644 src/WinFormsUI/Docking/DockWindow.SplitterControl.cs delete mode 100644 src/WinFormsUI/Docking/DockWindow.cs delete mode 100644 src/WinFormsUI/Docking/DockWindowCollection.cs delete mode 100644 src/WinFormsUI/Docking/DragForm.cs delete mode 100644 src/WinFormsUI/Docking/DummyControl.cs delete mode 100644 src/WinFormsUI/Docking/Enums.cs delete mode 100644 src/WinFormsUI/Docking/FloatWindow.cs delete mode 100644 src/WinFormsUI/Docking/FloatWindowCollection.cs delete mode 100644 src/WinFormsUI/Docking/Helpers/DockHelper.cs delete mode 100644 src/WinFormsUI/Docking/Helpers/DrawHelper.cs delete mode 100644 src/WinFormsUI/Docking/Helpers/ResourceHelper.cs delete mode 100644 src/WinFormsUI/Docking/Helpers/Win32Helper.cs delete mode 100644 src/WinFormsUI/Docking/InertButtonBase.cs delete mode 100644 src/WinFormsUI/Docking/Interfaces.cs delete mode 100644 src/WinFormsUI/Docking/Localization.cs delete mode 100644 src/WinFormsUI/Docking/Measures.cs delete mode 100644 src/WinFormsUI/Docking/NestedDockingStatus.cs delete mode 100644 src/WinFormsUI/Docking/NestedPaneCollection.cs delete mode 100644 src/WinFormsUI/Docking/Resources.Designer.cs delete mode 100644 src/WinFormsUI/Docking/Resources.resx delete mode 100644 src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond_Bottom.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond_Hotspot.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond_HotspotIndex.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond_Left.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond_Right.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond_Top.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockIndicator_PanelBottom.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockIndicator_PanelBottom_Active.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockIndicator_PanelFill.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockIndicator_PanelFill_Active.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockIndicator_PanelLeft.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockIndicator_PanelLeft_Active.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockIndicator_PanelRight.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockIndicator_PanelRight_Active.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockIndicator_PanelTop.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockIndicator_PanelTop_Active.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockPane_AutoHide.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockPane_Close.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockPane_Dock.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockPane_Option.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/DockPane_OptionOverflow.bmp delete mode 100644 src/WinFormsUI/Docking/Resources/Dockindicator_PaneDiamond_Fill.bmp delete mode 100644 src/WinFormsUI/Docking/SplitterBase.cs delete mode 100644 src/WinFormsUI/Docking/Strings.Designer.cs delete mode 100644 src/WinFormsUI/Docking/Strings.resx delete mode 100644 src/WinFormsUI/Docking/VS2005AutoHideStrip.cs delete mode 100644 src/WinFormsUI/Docking/VS2005DockPaneCaption.cs delete mode 100644 src/WinFormsUI/Docking/VS2005DockPaneStrip.cs delete mode 100644 src/WinFormsUI/Docking/VisibleNestedPaneCollection.cs delete mode 100644 src/WinFormsUI/Docking/Win32/Enums.cs delete mode 100644 src/WinFormsUI/Docking/Win32/NativeMethods.cs delete mode 100644 src/WinFormsUI/WinFormsUI.csproj delete mode 100644 src/WinFormsUI/WinFormsUI.csproj.vspscc delete mode 100644 src/WinFormsUI/license.txt diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 95be07a3..f3d486d1 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -7,6 +7,8 @@ + + diff --git a/src/LogExpert.sln b/src/LogExpert.sln index c5d5aa5a..d04ea3de 100644 --- a/src/LogExpert.sln +++ b/src/LogExpert.sln @@ -21,8 +21,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GlassfishColumnizer", "Glas EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlashIconHighlighter", "FlashIconHighlighter\FlashIconHighlighter.csproj", "{F5E81EBE-3E6F-409F-B510-918E97F59072}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsUI", "WinFormsUI\WinFormsUI.csproj", "{C75532C4-765B-418E-B09B-46D36B2ABDB1}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DE6375A4-B4C4-4620-8FFB-B9D5A4E21144}" ProjectSection(SolutionItems) = preProject Solution Items\AssemblyVersion.cs = Solution Items\AssemblyVersion.cs @@ -93,10 +91,6 @@ Global {F5E81EBE-3E6F-409F-B510-918E97F59072}.Debug|Any CPU.Build.0 = Debug|Any CPU {F5E81EBE-3E6F-409F-B510-918E97F59072}.Release|Any CPU.ActiveCfg = Release|Any CPU {F5E81EBE-3E6F-409F-B510-918E97F59072}.Release|Any CPU.Build.0 = Release|Any CPU - {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Release|Any CPU.Build.0 = Release|Any CPU {4C899885-E361-410A-B6AC-C2F236C436FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4C899885-E361-410A-B6AC-C2F236C436FA}.Debug|Any CPU.Build.0 = Debug|Any CPU {4C899885-E361-410A-B6AC-C2F236C436FA}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs index fdac7b84..843d99fe 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs @@ -237,24 +237,24 @@ public void ChangeTheme(Control.ControlCollection container) } // Tabs line - dockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient.StartColor = ColorMode.TabsBackgroundStripColor; - dockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient.EndColor = ColorMode.TabsBackgroundStripColor; - - dockPanel.Skin.DockPaneStripSkin.DocumentGradient.DockStripGradient.StartColor = ColorMode.TabsBackgroundStripColor; - dockPanel.Skin.DockPaneStripSkin.DocumentGradient.DockStripGradient.EndColor = ColorMode.TabsBackgroundStripColor; + dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient.StartColor = ColorMode.TabsBackgroundStripColor; + dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient.EndColor = ColorMode.TabsBackgroundStripColor; + + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.DockStripGradient.StartColor = ColorMode.TabsBackgroundStripColor; + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.DockStripGradient.EndColor = ColorMode.TabsBackgroundStripColor; // Tabs - dockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.StartColor = ColorMode.ActiveTabColor; - dockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.EndColor = ColorMode.ActiveTabColor; - dockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.TextColor = ColorMode.ForeColor; - - dockPanel.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.StartColor = ColorMode.ActiveTabColor; - dockPanel.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.EndColor = ColorMode.ActiveTabColor; - dockPanel.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.TextColor = ColorMode.ForeColor; - - dockPanel.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.StartColor = ColorMode.InactiveTabColor; - dockPanel.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.EndColor = ColorMode.InactiveTabColor; - dockPanel.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.TextColor = ColorMode.ForeColor; + dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.StartColor = ColorMode.ActiveTabColor; + dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.EndColor = ColorMode.ActiveTabColor; + dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.TextColor = ColorMode.ForeColor; + + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.StartColor = ColorMode.ActiveTabColor; + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.EndColor = ColorMode.ActiveTabColor; + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.TextColor = ColorMode.ForeColor; + + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.StartColor = ColorMode.InactiveTabColor; + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.EndColor = ColorMode.InactiveTabColor; + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.TextColor = ColorMode.ForeColor; #endregion Tabs } #endregion diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs index 7ac34388..be27ac3e 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs @@ -36,7 +36,6 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { components = new System.ComponentModel.Container(); - DockPanelSkin dockPanelSkin1 = new DockPanelSkin(); AutoHideStripSkin autoHideStripSkin1 = new AutoHideStripSkin(); DockPanelGradient dockPanelGradient1 = new DockPanelGradient(); TabGradient tabGradient1 = new TabGradient(); @@ -849,7 +848,6 @@ private void InitializeComponent() tabGradient1.TextColor = System.Drawing.SystemColors.ControlText; autoHideStripSkin1.TabGradient = tabGradient1; autoHideStripSkin1.TextFont = new System.Drawing.Font("Segoe UI", 9F); - dockPanelSkin1.AutoHideStripSkin = autoHideStripSkin1; tabGradient2.EndColor = System.Drawing.SystemColors.Control; tabGradient2.StartColor = System.Drawing.SystemColors.Control; tabGradient2.TextColor = System.Drawing.SystemColors.ControlText; @@ -885,9 +883,9 @@ private void InitializeComponent() tabGradient7.TextColor = System.Drawing.SystemColors.Control; dockPaneStripToolWindowGradient1.InactiveTabGradient = tabGradient7; dockPaneStripSkin1.ToolWindowGradient = dockPaneStripToolWindowGradient1; - dockPanelSkin1.DockPaneStripSkin = dockPaneStripSkin1; - dockPanel.Theme = new DockPanelTheme(dockPanelSkin1); - //dockPanel.Theme.Skin = dockPanelSkin1; + dockPanel.Theme = new VS2015LightTheme(); + dockPanel.Theme.Skin.DockPaneStripSkin = dockPaneStripSkin1; + dockPanel.Theme.Skin.AutoHideStripSkin = autoHideStripSkin1; dockPanel.TabIndex = 14; dockPanel.ActiveContentChanged += OnDockPanelActiveContentChanged; // diff --git a/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs b/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs index 8f8ef767..d1298c77 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs @@ -8,7 +8,6 @@ using LogExpert.Config; using LogExpert.Entities; using LogExpert.Entities.EventArgs; - using System; using System.Collections.Generic; using System.Drawing; @@ -16,7 +15,6 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -//using System.Linq; namespace LogExpert.Controls.LogWindow { diff --git a/src/LogExpert/LogExpert.csproj b/src/LogExpert/LogExpert.csproj index 844ccfc8..8c9d0e78 100644 --- a/src/LogExpert/LogExpert.csproj +++ b/src/LogExpert/LogExpert.csproj @@ -76,6 +76,8 @@ + + @@ -85,7 +87,6 @@ - diff --git a/src/WinFormsUI/Docking/AutoHideStripBase.cs b/src/WinFormsUI/Docking/AutoHideStripBase.cs deleted file mode 100644 index abcfa941..00000000 --- a/src/WinFormsUI/Docking/AutoHideStripBase.cs +++ /dev/null @@ -1,684 +0,0 @@ -using System; -using System.Collections; -using System.Windows.Forms; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; - -namespace WeifenLuo.WinFormsUI.Docking -{ - public abstract partial class AutoHideStripBase : Control - { - #region Fields - - private GraphicsPath m_displayingArea = null; - - #endregion - - #region cTor - - protected AutoHideStripBase(DockPanel panel) - { - DockPanel = panel; - PanesTop = new PaneCollection(panel, DockState.DockTopAutoHide); - PanesBottom = new PaneCollection(panel, DockState.DockBottomAutoHide); - PanesLeft = new PaneCollection(panel, DockState.DockLeftAutoHide); - PanesRight = new PaneCollection(panel, DockState.DockRightAutoHide); - - SetStyle(ControlStyles.OptimizedDoubleBuffer, true); - SetStyle(ControlStyles.Selectable, false); - } - - #endregion - - #region Properties - - protected DockPanel DockPanel { get; } - - protected PaneCollection PanesTop { get; } - - protected PaneCollection PanesBottom { get; } - - protected PaneCollection PanesLeft { get; } - - protected PaneCollection PanesRight { get; } - - protected Rectangle RectangleTopLeft - { - get - { - int height = MeasureHeight(); - return PanesTop.Count > 0 && PanesLeft.Count > 0 - ? new Rectangle(0, 0, height, height) - : Rectangle.Empty; - } - } - - protected Rectangle RectangleTopRight - { - get - { - int height = MeasureHeight(); - return PanesTop.Count > 0 && PanesRight.Count > 0 - ? new Rectangle(Width - height, 0, height, height) - : Rectangle.Empty; - } - } - - protected Rectangle RectangleBottomLeft - { - get - { - int height = MeasureHeight(); - return PanesBottom.Count > 0 && PanesLeft.Count > 0 - ? new Rectangle(0, Height - height, height, height) - : Rectangle.Empty; - } - } - - protected Rectangle RectangleBottomRight - { - get - { - int height = MeasureHeight(); - return PanesBottom.Count > 0 && PanesRight.Count > 0 - ? new Rectangle(Width - height, Height - height, height, height) - : Rectangle.Empty; - } - } - - private GraphicsPath DisplayingArea - { - get - { - if (m_displayingArea == null) - { - m_displayingArea = new GraphicsPath(); - } - - return m_displayingArea; - } - } - - #endregion - - #region Internals - - internal int GetNumberOfPanes(DockState dockState) - { - return GetPanes(dockState).Count; - } - - internal void RefreshChanges() - { - if (IsDisposed) - { - return; - } - - SetRegion(); - OnRefreshChanges(); - } - - #endregion - - #region Overrides - - protected override void OnMouseDown(MouseEventArgs e) - { - base.OnMouseDown(e); - - if (e.Button != MouseButtons.Left) - { - return; - } - - IDockContent content = HitTest(); - if (content == null) - { - return; - } - - content.DockHandler.Activate(); - } - - protected override void OnMouseHover(EventArgs e) - { - base.OnMouseHover(e); - - IDockContent content = HitTest(); - if (content != null && DockPanel.ActiveAutoHideContent != content) - { - DockPanel.ActiveAutoHideContent = content; - } - - // requires further tracking of mouse hover behavior, - ResetMouseEventArgs(); - } - - protected override void OnLayout(LayoutEventArgs levent) - { - RefreshChanges(); - base.OnLayout(levent); - } - - #endregion - - #region Private Methods - - private void SetRegion() - { - DisplayingArea.Reset(); - DisplayingArea.AddRectangle(RectangleTopLeft); - DisplayingArea.AddRectangle(RectangleTopRight); - DisplayingArea.AddRectangle(RectangleBottomLeft); - DisplayingArea.AddRectangle(RectangleBottomRight); - DisplayingArea.AddRectangle(GetTabStripRectangle(DockState.DockTopAutoHide)); - DisplayingArea.AddRectangle(GetTabStripRectangle(DockState.DockBottomAutoHide)); - DisplayingArea.AddRectangle(GetTabStripRectangle(DockState.DockLeftAutoHide)); - DisplayingArea.AddRectangle(GetTabStripRectangle(DockState.DockRightAutoHide)); - Region = new Region(DisplayingArea); - } - - private IDockContent HitTest() - { - Point ptMouse = PointToClient(Control.MousePosition); - return HitTest(ptMouse); - } - - #endregion - - protected PaneCollection GetPanes(DockState dockState) - { - if (dockState == DockState.DockTopAutoHide) - { - return PanesTop; - } - else if (dockState == DockState.DockBottomAutoHide) - { - return PanesBottom; - } - else if (dockState == DockState.DockLeftAutoHide) - { - return PanesLeft; - } - else if (dockState == DockState.DockRightAutoHide) - { - return PanesRight; - } - else - { - throw new ArgumentOutOfRangeException("dockState"); - } - } - - protected internal Rectangle GetTabStripRectangle(DockState dockState) - { - int height = MeasureHeight(); - if (dockState == DockState.DockTopAutoHide && PanesTop.Count > 0) - { - return new Rectangle(RectangleTopLeft.Width, 0, - Width - RectangleTopLeft.Width - RectangleTopRight.Width, height); - } - else if (dockState == DockState.DockBottomAutoHide && PanesBottom.Count > 0) - { - return new Rectangle(RectangleBottomLeft.Width, Height - height, - Width - RectangleBottomLeft.Width - RectangleBottomRight.Width, height); - } - else if (dockState == DockState.DockLeftAutoHide && PanesLeft.Count > 0) - { - return new Rectangle(0, RectangleTopLeft.Width, height, - Height - RectangleTopLeft.Height - RectangleBottomLeft.Height); - } - else if (dockState == DockState.DockRightAutoHide && PanesRight.Count > 0) - { - return new Rectangle(Width - height, RectangleTopRight.Width, height, - Height - RectangleTopRight.Height - RectangleBottomRight.Height); - } - else - { - return Rectangle.Empty; - } - } - - protected virtual void OnRefreshChanges() - { - } - - protected internal abstract int MeasureHeight(); - - protected virtual Tab CreateTab(IDockContent content) - { - return new Tab(content); - } - - protected virtual Pane CreatePane(DockPane dockPane) - { - return new Pane(dockPane); - } - - protected abstract IDockContent HitTest(Point point); - - [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] - protected class Tab : IDisposable - { - #region Fields - - #endregion - - #region cTor - - protected internal Tab(IDockContent content) - { - Content = content; - } - - #endregion - - #region Properties - - public IDockContent Content { get; } - - #endregion - - #region Public methods - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - #endregion - - ~Tab() - { - Dispose(false); - } - - protected virtual void Dispose(bool disposing) - { - } - } - - [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] - protected sealed class TabCollection : IEnumerable - { - #region Fields - - #endregion - - #region cTor - - internal TabCollection(DockPane pane) - { - DockPane = pane; - } - - #endregion - - #region Properties - - public DockPane DockPane { get; } = null; - - public DockPanel DockPanel - { - get { return DockPane.DockPanel; } - } - - public int Count - { - get { return DockPane.DisplayingContents.Count; } - } - - public Tab this[int index] - { - get - { - IDockContent content = DockPane.DisplayingContents[index]; - if (content == null) - { - throw new ArgumentOutOfRangeException("index"); - } - if (content.DockHandler.AutoHideTab == null) - { - content.DockHandler.AutoHideTab = DockPanel.AutoHideStripControl.CreateTab(content); - } - return content.DockHandler.AutoHideTab as Tab; - } - } - - #endregion - - #region Public methods - - public bool Contains(Tab tab) - { - return IndexOf(tab) != -1; - } - - public bool Contains(IDockContent content) - { - return IndexOf(content) != -1; - } - - public int IndexOf(Tab tab) - { - if (tab == null) - { - return -1; - } - - return IndexOf(tab.Content); - } - - public int IndexOf(IDockContent content) - { - return DockPane.DisplayingContents.IndexOf(content); - } - - #endregion - - #region IEnumerable Members - - IEnumerator IEnumerable.GetEnumerator() - { - for (int i = 0; i < Count; i++) - { - yield return this[i]; - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - for (int i = 0; i < Count; i++) - { - yield return this[i]; - } - } - - #endregion - } - - [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] - protected class Pane : IDisposable - { - #region Fields - - #endregion - - #region cTor - - protected internal Pane(DockPane dockPane) - { - DockPane = dockPane; - } - - #endregion - - #region Properties - - public DockPane DockPane { get; } - - public TabCollection AutoHideTabs - { - get - { - if (DockPane.AutoHideTabs == null) - { - DockPane.AutoHideTabs = new TabCollection(DockPane); - } - return DockPane.AutoHideTabs as TabCollection; - } - } - - #endregion - - #region Public methods - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - #endregion - - ~Pane() - { - Dispose(false); - } - - protected virtual void Dispose(bool disposing) - { - } - } - - [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] - protected sealed class PaneCollection : IEnumerable - { - #region Fields - - #endregion - - #region cTor - - internal PaneCollection(DockPanel panel, DockState dockState) - { - DockPanel = panel; - States = new AutoHideStateCollection(); - States[DockState.DockTopAutoHide].Selected = dockState == DockState.DockTopAutoHide; - States[DockState.DockBottomAutoHide].Selected = dockState == DockState.DockBottomAutoHide; - States[DockState.DockLeftAutoHide].Selected = dockState == DockState.DockLeftAutoHide; - States[DockState.DockRightAutoHide].Selected = dockState == DockState.DockRightAutoHide; - } - - #endregion - - #region Properties - - public DockPanel DockPanel { get; } - - private AutoHideStateCollection States { get; } - - public int Count - { - get - { - int count = 0; - foreach (DockPane pane in DockPanel.Panes) - { - if (States.ContainsPane(pane)) - { - count++; - } - } - - return count; - } - } - - public Pane this[int index] - { - get - { - int count = 0; - foreach (DockPane pane in DockPanel.Panes) - { - if (!States.ContainsPane(pane)) - { - continue; - } - - if (count == index) - { - if (pane.AutoHidePane == null) - { - pane.AutoHidePane = DockPanel.AutoHideStripControl.CreatePane(pane); - } - return pane.AutoHidePane as Pane; - } - - count++; - } - throw new ArgumentOutOfRangeException("index"); - } - } - - #endregion - - #region Public methods - - public bool Contains(Pane pane) - { - return IndexOf(pane) != -1; - } - - public int IndexOf(Pane pane) - { - if (pane == null) - { - return -1; - } - - int index = 0; - foreach (DockPane dockPane in DockPanel.Panes) - { - if (!States.ContainsPane(pane.DockPane)) - { - continue; - } - - if (pane == dockPane.AutoHidePane) - { - return index; - } - - index++; - } - return -1; - } - - #endregion - - private class AutoHideState - { - #region Fields - - public readonly DockState m_dockState; - public bool m_selected = false; - - #endregion - - #region cTor - - public AutoHideState(DockState dockState) - { - m_dockState = dockState; - } - - #endregion - - #region Properties - - public DockState DockState - { - get { return m_dockState; } - } - - public bool Selected - { - get { return m_selected; } - set { m_selected = value; } - } - - #endregion - } - - private class AutoHideStateCollection - { - #region Fields - - private readonly AutoHideState[] m_states; - - #endregion - - #region cTor - - public AutoHideStateCollection() - { - m_states = new AutoHideState[] - { - new AutoHideState(DockState.DockTopAutoHide), - new AutoHideState(DockState.DockBottomAutoHide), - new AutoHideState(DockState.DockLeftAutoHide), - new AutoHideState(DockState.DockRightAutoHide) - }; - } - - #endregion - - #region Properties - - public AutoHideState this[DockState dockState] - { - get - { - for (int i = 0; i < m_states.Length; i++) - { - if (m_states[i].DockState == dockState) - { - return m_states[i]; - } - } - throw new ArgumentOutOfRangeException("dockState"); - } - } - - #endregion - - #region Public methods - - public bool ContainsPane(DockPane pane) - { - if (pane.IsHidden) - { - return false; - } - - for (int i = 0; i < m_states.Length; i++) - { - if (m_states[i].DockState == pane.DockState && m_states[i].Selected) - { - return true; - } - } - return false; - } - - #endregion - } - - #region IEnumerable Members - - IEnumerator IEnumerable.GetEnumerator() - { - for (int i = 0; i < Count; i++) - { - yield return this[i]; - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - for (int i = 0; i < Count; i++) - { - yield return this[i]; - } - } - - #endregion - } - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockAreasEditor.cs b/src/WinFormsUI/Docking/DockAreasEditor.cs deleted file mode 100644 index dffde868..00000000 --- a/src/WinFormsUI/Docking/DockAreasEditor.cs +++ /dev/null @@ -1,201 +0,0 @@ -using System; -using System.ComponentModel; -using System.Drawing; -using System.Drawing.Design; -using System.Windows.Forms; -using System.Windows.Forms.Design; - -namespace WeifenLuo.WinFormsUI.Docking -{ - internal class DockAreasEditor : UITypeEditor - { - #region Fields - - private DockAreasEditor.DockAreasEditorControl m_ui = null; - - #endregion - - #region Public methods - - public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) - { - return UITypeEditorEditStyle.DropDown; - } - - public override object EditValue(ITypeDescriptorContext context, IServiceProvider sp, object value) - { - if (m_ui == null) - { - m_ui = new DockAreasEditor.DockAreasEditorControl(); - } - - m_ui.SetStates((DockAreas) value); - - IWindowsFormsEditorService edSvc = - (IWindowsFormsEditorService) sp.GetService(typeof(IWindowsFormsEditorService)); - edSvc.DropDownControl(m_ui); - - return m_ui.DockAreas; - } - - #endregion - - private class DockAreasEditorControl : System.Windows.Forms.UserControl - { - #region Fields - - private readonly CheckBox checkBoxDockBottom; - private readonly CheckBox checkBoxDockFill; - private readonly CheckBox checkBoxDockLeft; - private readonly CheckBox checkBoxDockRight; - private readonly CheckBox checkBoxDockTop; - private readonly CheckBox checkBoxFloat; - private DockAreas m_oldDockAreas; - - #endregion - - #region cTor - - public DockAreasEditorControl() - { - checkBoxFloat = new CheckBox(); - checkBoxDockLeft = new CheckBox(); - checkBoxDockRight = new CheckBox(); - checkBoxDockTop = new CheckBox(); - checkBoxDockBottom = new CheckBox(); - checkBoxDockFill = new CheckBox(); - - SuspendLayout(); - - checkBoxFloat.Appearance = Appearance.Button; - checkBoxFloat.Dock = DockStyle.Top; - checkBoxFloat.Height = 24; - checkBoxFloat.Text = Strings.DockAreaEditor_FloatCheckBoxText; - checkBoxFloat.TextAlign = ContentAlignment.MiddleCenter; - checkBoxFloat.FlatStyle = FlatStyle.System; - - checkBoxDockLeft.Appearance = System.Windows.Forms.Appearance.Button; - checkBoxDockLeft.Dock = System.Windows.Forms.DockStyle.Left; - checkBoxDockLeft.Width = 24; - checkBoxDockLeft.FlatStyle = FlatStyle.System; - - checkBoxDockRight.Appearance = System.Windows.Forms.Appearance.Button; - checkBoxDockRight.Dock = System.Windows.Forms.DockStyle.Right; - checkBoxDockRight.Width = 24; - checkBoxDockRight.FlatStyle = FlatStyle.System; - - checkBoxDockTop.Appearance = System.Windows.Forms.Appearance.Button; - checkBoxDockTop.Dock = System.Windows.Forms.DockStyle.Top; - checkBoxDockTop.Height = 24; - checkBoxDockTop.FlatStyle = FlatStyle.System; - - checkBoxDockBottom.Appearance = System.Windows.Forms.Appearance.Button; - checkBoxDockBottom.Dock = System.Windows.Forms.DockStyle.Bottom; - checkBoxDockBottom.Height = 24; - checkBoxDockBottom.FlatStyle = FlatStyle.System; - - checkBoxDockFill.Appearance = System.Windows.Forms.Appearance.Button; - checkBoxDockFill.Dock = System.Windows.Forms.DockStyle.Fill; - checkBoxDockFill.FlatStyle = FlatStyle.System; - - this.Controls.AddRange(new Control[] - { - checkBoxDockFill, - checkBoxDockBottom, - checkBoxDockTop, - checkBoxDockRight, - checkBoxDockLeft, - checkBoxFloat - }); - - Size = new System.Drawing.Size(160, 144); - BackColor = SystemColors.Control; - ResumeLayout(); - } - - #endregion - - #region Properties - - public DockAreas DockAreas - { - get - { - DockAreas dockAreas = 0; - if (checkBoxFloat.Checked) - { - dockAreas |= DockAreas.Float; - } - if (checkBoxDockLeft.Checked) - { - dockAreas |= DockAreas.DockLeft; - } - if (checkBoxDockRight.Checked) - { - dockAreas |= DockAreas.DockRight; - } - if (checkBoxDockTop.Checked) - { - dockAreas |= DockAreas.DockTop; - } - if (checkBoxDockBottom.Checked) - { - dockAreas |= DockAreas.DockBottom; - } - if (checkBoxDockFill.Checked) - { - dockAreas |= DockAreas.Document; - } - - if (dockAreas == 0) - { - return m_oldDockAreas; - } - else - { - return dockAreas; - } - } - } - - #endregion - - #region Public methods - - public void SetStates(DockAreas dockAreas) - { - m_oldDockAreas = dockAreas; - if ((dockAreas & DockAreas.DockLeft) != 0) - { - checkBoxDockLeft.Checked = true; - } - if ((dockAreas & DockAreas.DockRight) != 0) - { - checkBoxDockRight.Checked = true; - } - if ((dockAreas & DockAreas.DockTop) != 0) - { - checkBoxDockTop.Checked = true; - } - if ((dockAreas & DockAreas.DockTop) != 0) - { - checkBoxDockTop.Checked = true; - } - if ((dockAreas & DockAreas.DockBottom) != 0) - { - checkBoxDockBottom.Checked = true; - } - if ((dockAreas & DockAreas.Document) != 0) - { - checkBoxDockFill.Checked = true; - } - if ((dockAreas & DockAreas.Float) != 0) - { - checkBoxFloat.Checked = true; - } - } - - #endregion - } - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockContent.cs b/src/WinFormsUI/Docking/DockContent.cs deleted file mode 100644 index 76bad264..00000000 --- a/src/WinFormsUI/Docking/DockContent.cs +++ /dev/null @@ -1,328 +0,0 @@ -using System; -using System.ComponentModel; -using System.Drawing; -using System.Windows.Forms; -using System.Diagnostics.CodeAnalysis; - -namespace WeifenLuo.WinFormsUI.Docking -{ - public class DockContent : Form, IDockContent - { - #region Fields - - private static readonly object DockStateChangedEvent = new object(); - - [Localizable(true)] [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockContent_TabText_Description")] [DefaultValue(null)] private string m_tabText = null; - - #endregion - - #region cTor - - public DockContent() - { - DockHandler = new DockContentHandler(this, GetPersistString); - DockHandler.DockStateChanged += DockHandler_DockStateChanged; - //Suggested as a fix by bensty regarding form resize - ParentChanged += DockContent_ParentChanged; - } - - #endregion - - #region Events - - [LocalizedCategory("Category_PropertyChanged")] - [LocalizedDescription("Pane_DockStateChanged_Description")] - public event EventHandler DockStateChanged - { - - add => Events.AddHandler(DockStateChangedEvent, value); - remove => Events.RemoveHandler(DockStateChangedEvent, value); - } - - #endregion - - #region Properties - - [Browsable(false)] - public DockContentHandler DockHandler { get; } = null; - - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockContent_AllowEndUserDocking_Description")] - [DefaultValue(true)] - public bool AllowEndUserDocking - { - get => DockHandler.AllowEndUserDocking; - set => DockHandler.AllowEndUserDocking = value; - } - - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockContent_DockAreas_Description")] - [DefaultValue(DockAreas.DockLeft | DockAreas.DockRight | DockAreas.DockTop | DockAreas.DockBottom | - DockAreas.Document | DockAreas.Float)] - public DockAreas DockAreas - { - get => DockHandler.DockAreas; - set => DockHandler.DockAreas = value; - } - - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockContent_AutoHidePortion_Description")] - [DefaultValue(0.25)] - public double AutoHidePortion - { - get => DockHandler.AutoHidePortion; - set => DockHandler.AutoHidePortion = value; - } - - public string TabText - { - get => m_tabText; - set => DockHandler.TabText = m_tabText = value; - } - - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockContent_CloseButton_Description")] - [DefaultValue(true)] - public bool CloseButton - { - get => DockHandler.CloseButton; - set => DockHandler.CloseButton = value; - } - - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockContent_CloseButtonVisible_Description")] - [DefaultValue(true)] - public bool CloseButtonVisible - { - get => DockHandler.CloseButtonVisible; - set => DockHandler.CloseButtonVisible = value; - } - - [Browsable(false)] - public DockPanel DockPanel - { - get => DockHandler.DockPanel; - set => DockHandler.DockPanel = value; - } - - [Browsable(false)] - public DockState DockState - { - get => DockHandler.DockState; - set => DockHandler.DockState = value; - } - - [Browsable(false)] - public DockPane Pane - { - get => DockHandler.Pane; - set => DockHandler.Pane = value; - } - - [Browsable(false)] - public bool IsHidden - { - get => DockHandler.IsHidden; - set => DockHandler.IsHidden = value; - } - - [Browsable(false)] - public DockState VisibleState - { - get => DockHandler.VisibleState; - set => DockHandler.VisibleState = value; - } - - [Browsable(false)] - public bool IsFloat - { - get => DockHandler.IsFloat; - set => DockHandler.IsFloat = value; - } - - [Browsable(false)] - public DockPane PanelPane - { - get => DockHandler.PanelPane; - set => DockHandler.PanelPane = value; - } - - [Browsable(false)] - public DockPane FloatPane - { - get => DockHandler.FloatPane; - set => DockHandler.FloatPane = value; - } - - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockContent_HideOnClose_Description")] - [DefaultValue(false)] - public bool HideOnClose - { - get => DockHandler.HideOnClose; - set => DockHandler.HideOnClose = value; - } - - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockContent_ShowHint_Description")] - [DefaultValue(DockState.Unknown)] - public DockState ShowHint - { - get => DockHandler.ShowHint; - set => DockHandler.ShowHint = value; - } - - [Browsable(false)] - public bool IsActivated => DockHandler.IsActivated; - - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockContent_TabPageContextMenu_Description")] - [DefaultValue(null)] - public ContextMenuStrip TabPageContextMenu - { - get => DockHandler.TabPageContextMenu; - set => DockHandler.TabPageContextMenu = value; - } - - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockContent_TabPageContextMenuStrip_Description")] - [DefaultValue(null)] - public ContextMenuStrip TabPageContextMenuStrip - { - get => DockHandler.TabPageContextMenuStrip; - set => DockHandler.TabPageContextMenuStrip = value; - } - - [Localizable(true)] - [Category("Appearance")] - [LocalizedDescription("DockContent_ToolTipText_Description")] - [DefaultValue(null)] - public string ToolTipText - { - get => DockHandler.ToolTipText; - set => DockHandler.ToolTipText = value; - } - - #endregion - - #region Public methods - - public bool IsDockStateValid(DockState dockState) - { - return DockHandler.IsDockStateValid(dockState); - } - - public new void Activate() - { - DockHandler.Activate(); - } - - public new void Hide() - { - DockHandler.Hide(); - } - - public new void Show() - { - DockHandler.Show(); - } - - public void Show(DockPanel dockPanel) - { - DockHandler.Show(dockPanel); - } - - public void Show(DockPanel dockPanel, DockState dockState) - { - DockHandler.Show(dockPanel, dockState); - } - - [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters")] - public void Show(DockPanel dockPanel, Rectangle floatWindowBounds) - { - DockHandler.Show(dockPanel, floatWindowBounds); - } - - public void Show(DockPane pane, IDockContent beforeContent) - { - DockHandler.Show(pane, beforeContent); - } - - public void Show(DockPane previousPane, DockAlignment alignment, double proportion) - { - DockHandler.Show(previousPane, alignment, proportion); - } - - [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters")] - public void FloatAt(Rectangle floatWindowBounds) - { - DockHandler.FloatAt(floatWindowBounds); - } - - public void DockTo(DockPane paneTo, DockStyle dockStyle, int contentIndex) - { - DockHandler.DockTo(paneTo, dockStyle, contentIndex); - } - - public void DockTo(DockPanel panel, DockStyle dockStyle) - { - DockHandler.DockTo(panel, dockStyle); - } - - #endregion - - #region Private Methods - - private bool ShouldSerializeTabText() - { - return m_tabText != null; - } - - #endregion - - #region Events handler - - //Suggested as a fix by bensty regarding form resize - private void DockContent_ParentChanged(object Sender, EventArgs e) - { - if (Parent != null) - { - Font = Parent.Font; - } - } - - private void DockHandler_DockStateChanged(object sender, EventArgs e) - { - OnDockStateChanged(e); - } - - #endregion - - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - protected virtual string GetPersistString() - { - return GetType().ToString(); - } - - protected virtual void OnDockStateChanged(EventArgs e) - { - EventHandler handler = (EventHandler) Events[DockStateChangedEvent]; - handler?.Invoke(this, e); - } - - #region IDockContent Members - - void IDockContent.OnActivated(EventArgs e) - { - OnActivated(e); - } - - void IDockContent.OnDeactivate(EventArgs e) - { - OnDeactivate(e); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockContentCollection.cs b/src/WinFormsUI/Docking/DockContentCollection.cs deleted file mode 100644 index 7f0e9151..00000000 --- a/src/WinFormsUI/Docking/DockContentCollection.cs +++ /dev/null @@ -1,233 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; - -namespace WeifenLuo.WinFormsUI.Docking -{ - public class DockContentCollection : ReadOnlyCollection - { - #region Fields - - private static readonly List _emptyList = new List(0); - - #endregion - - #region cTor - - internal DockContentCollection() - : base(new List()) - { - } - - internal DockContentCollection(DockPane pane) - : base(_emptyList) - { - DockPane = pane; - } - - #endregion - - #region Properties - - private DockPane DockPane { get; } = null; - - public new IDockContent this[int index] - { - get - { - if (DockPane == null) - { - return Items[index] as IDockContent; - } - else - { - return GetVisibleContent(index); - } - } - } - - public new int Count - { - get - { - if (DockPane == null) - { - return base.Count; - } - else - { - return CountOfVisibleContents; - } - } - } - - private int CountOfVisibleContents - { - get - { -#if DEBUG - if (DockPane == null) - throw new InvalidOperationException(); -#endif - - int count = 0; - foreach (IDockContent content in DockPane.Contents) - { - if (content.DockHandler.DockState == DockPane.DockState) - { - count++; - } - } - return count; - } - } - - #endregion - - #region Public methods - - public new bool Contains(IDockContent content) - { - if (DockPane == null) - { - return Items.Contains(content); - } - else - { - return GetIndexOfVisibleContents(content) != -1; - } - } - - public new int IndexOf(IDockContent content) - { - if (DockPane == null) - { - if (!Contains(content)) - { - return -1; - } - else - { - return Items.IndexOf(content); - } - } - else - { - return GetIndexOfVisibleContents(content); - } - } - - #endregion - - #region Internals - - internal int Add(IDockContent content) - { -#if DEBUG - if (DockPane != null) - throw new InvalidOperationException(); -#endif - - if (Contains(content)) - { - return IndexOf(content); - } - - Items.Add(content); - return Count - 1; - } - - internal void AddAt(IDockContent content, int index) - { -#if DEBUG - if (DockPane != null) - throw new InvalidOperationException(); -#endif - - if (index < 0 || index > Items.Count - 1) - { - return; - } - - if (Contains(content)) - { - return; - } - - Items.Insert(index, content); - } - - internal void Remove(IDockContent content) - { - if (DockPane != null) - { - throw new InvalidOperationException(); - } - - if (!Contains(content)) - { - return; - } - - Items.Remove(content); - } - - #endregion - - #region Private Methods - - private IDockContent GetVisibleContent(int index) - { -#if DEBUG - if (DockPane == null) - throw new InvalidOperationException(); -#endif - - int currentIndex = -1; - foreach (IDockContent content in DockPane.Contents) - { - if (content.DockHandler.DockState == DockPane.DockState) - { - currentIndex++; - } - - if (currentIndex == index) - { - return content; - } - } - throw new ArgumentOutOfRangeException(); - } - - private int GetIndexOfVisibleContents(IDockContent content) - { -#if DEBUG - if (DockPane == null) - throw new InvalidOperationException(); -#endif - - if (content == null) - { - return -1; - } - - int index = -1; - foreach (IDockContent c in DockPane.Contents) - { - if (c.DockHandler.DockState == DockPane.DockState) - { - index++; - - if (c == content) - { - return index; - } - } - } - return -1; - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockContentEventArgs.cs b/src/WinFormsUI/Docking/DockContentEventArgs.cs deleted file mode 100644 index 4abbd70d..00000000 --- a/src/WinFormsUI/Docking/DockContentEventArgs.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace WeifenLuo.WinFormsUI.Docking -{ - public class DockContentEventArgs : EventArgs - { - #region Fields - - #endregion - - #region cTor - - public DockContentEventArgs(IDockContent content) - { - Content = content; - } - - #endregion - - #region Properties - - public IDockContent Content { get; } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockContentHandler.cs b/src/WinFormsUI/Docking/DockContentHandler.cs deleted file mode 100644 index 8d20156b..00000000 --- a/src/WinFormsUI/Docking/DockContentHandler.cs +++ /dev/null @@ -1,1320 +0,0 @@ -using System; -using System.Windows.Forms; -using System.Drawing; -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; - -namespace WeifenLuo.WinFormsUI.Docking -{ - public delegate string GetPersistStringCallback(); - - public class DockContentHandler : IDisposable, IDockDragSource - { - #region Fields - - private static readonly object DockStateChangedEvent = new object(); - - private DockAreas m_allowedAreas = DockAreas.DockLeft | DockAreas.DockRight | DockAreas.DockTop | - DockAreas.DockBottom | DockAreas.Document | DockAreas.Float; - - private double m_autoHidePortion = 0.25; - - private bool m_closeButton = true; - - private int m_countSetDockState = 0; - - private DockPanel m_dockPanel = null; - - private DockState m_dockState = DockState.Unknown; - - private bool m_flagClipWindow = false; - - private DockPane m_floatPane = null; - - - private bool m_isActivated = false; - - private bool m_isFloat = false; - - private bool m_isHidden = true; - - private DockPane m_panelPane = null; - - private DockState m_showHint = DockState.Unknown; - - private DockPaneStripBase.Tab m_tab = null; - - private string m_tabText = null; - - private DockState m_visibleState = DockState.Unknown; - - #endregion - - #region cTor - - public DockContentHandler(Form form) : this(form, null) - { - } - - public DockContentHandler(Form form, GetPersistStringCallback getPersistStringCallback) - { - if (!(form is IDockContent)) - { - throw new ArgumentException(Strings.DockContent_Constructor_InvalidForm, "form"); - } - - Form = form; - GetPersistStringCallback = getPersistStringCallback; - - Events = new EventHandlerList(); - Form.Disposed += new EventHandler(Form_Disposed); - Form.TextChanged += new EventHandler(Form_TextChanged); - } - - #endregion - - #region Events - - public event EventHandler DockStateChanged - { - add { Events.AddHandler(DockStateChangedEvent, value); } - remove { Events.RemoveHandler(DockStateChangedEvent, value); } - } - - #endregion - - #region Properties - - public Form Form { get; } - - public IDockContent Content - { - get { return Form as IDockContent; } - } - - public IDockContent PreviousActive { get; internal set; } = null; - - public IDockContent NextActive { get; internal set; } = null; - - private EventHandlerList Events { get; } - - public bool AllowEndUserDocking { get; set; } = true; - - public double AutoHidePortion - { - get { return m_autoHidePortion; } - set - { - if (value <= 0) - { - throw new ArgumentOutOfRangeException(Strings.DockContentHandler_AutoHidePortion_OutOfRange); - } - - if (m_autoHidePortion == value) - { - return; - } - - m_autoHidePortion = value; - - if (DockPanel == null) - { - return; - } - - if (DockPanel.ActiveAutoHideContent == Content) - { - DockPanel.PerformLayout(); - } - } - } - - public bool CloseButton - { - get { return m_closeButton; } - set - { - if (m_closeButton == value) - { - return; - } - - m_closeButton = value; - if (Pane != null) - { - if (Pane.ActiveContent.DockHandler == this) - { - Pane.RefreshChanges(); - } - } - } - } - - /// - /// Determines whether the close button is visible on the content - /// - public bool CloseButtonVisible { get; set; } = true; - - private DockState DefaultDockState - { - get - { - if (ShowHint != DockState.Unknown && ShowHint != DockState.Hidden) - { - return ShowHint; - } - - if ((DockAreas & DockAreas.Document) != 0) - { - return DockState.Document; - } - if ((DockAreas & DockAreas.DockRight) != 0) - { - return DockState.DockRight; - } - if ((DockAreas & DockAreas.DockLeft) != 0) - { - return DockState.DockLeft; - } - if ((DockAreas & DockAreas.DockBottom) != 0) - { - return DockState.DockBottom; - } - if ((DockAreas & DockAreas.DockTop) != 0) - { - return DockState.DockTop; - } - - return DockState.Unknown; - } - } - - private DockState DefaultShowState - { - get - { - if (ShowHint != DockState.Unknown) - { - return ShowHint; - } - - if ((DockAreas & DockAreas.Document) != 0) - { - return DockState.Document; - } - if ((DockAreas & DockAreas.DockRight) != 0) - { - return DockState.DockRight; - } - if ((DockAreas & DockAreas.DockLeft) != 0) - { - return DockState.DockLeft; - } - if ((DockAreas & DockAreas.DockBottom) != 0) - { - return DockState.DockBottom; - } - if ((DockAreas & DockAreas.DockTop) != 0) - { - return DockState.DockTop; - } - if ((DockAreas & DockAreas.Float) != 0) - { - return DockState.Float; - } - - return DockState.Unknown; - } - } - - public DockAreas DockAreas - { - get { return m_allowedAreas; } - set - { - if (m_allowedAreas == value) - { - return; - } - - if (!DockHelper.IsDockStateValid(DockState, value)) - { - throw new InvalidOperationException(Strings.DockContentHandler_DockAreas_InvalidValue); - } - - m_allowedAreas = value; - - if (!DockHelper.IsDockStateValid(ShowHint, m_allowedAreas)) - { - ShowHint = DockState.Unknown; - } - } - } - - public DockState DockState - { - get { return m_dockState; } - set - { - if (m_dockState == value) - { - return; - } - - DockPanel.SuspendLayout(true); - - if (value == DockState.Hidden) - { - IsHidden = true; - } - else - { - SetDockState(false, value, Pane); - } - - DockPanel.ResumeLayout(true, true); - } - } - - public DockPanel DockPanel - { - get { return m_dockPanel; } - set - { - if (m_dockPanel == value) - { - return; - } - - Pane = null; - - if (m_dockPanel != null) - { - m_dockPanel.RemoveContent(Content); - } - - if (m_tab != null) - { - m_tab.Dispose(); - m_tab = null; - } - - if (AutoHideTab != null) - { - AutoHideTab.Dispose(); - AutoHideTab = null; - } - - m_dockPanel = value; - - if (m_dockPanel != null) - { - m_dockPanel.AddContent(Content); - Form.TopLevel = false; - Form.FormBorderStyle = FormBorderStyle.None; - Form.ShowInTaskbar = false; - Form.WindowState = FormWindowState.Normal; - NativeMethods.SetWindowPos(Form.Handle, IntPtr.Zero, 0, 0, 0, 0, - Win32.FlagsSetWindowPos.SWP_NOACTIVATE | - Win32.FlagsSetWindowPos.SWP_NOMOVE | - Win32.FlagsSetWindowPos.SWP_NOSIZE | - Win32.FlagsSetWindowPos.SWP_NOZORDER | - Win32.FlagsSetWindowPos.SWP_NOOWNERZORDER | - Win32.FlagsSetWindowPos.SWP_FRAMECHANGED); - } - } - } - - public Icon Icon - { - get { return Form.Icon; } - } - - public DockPane Pane - { - get { return IsFloat ? FloatPane : PanelPane; } - set - { - if (Pane == value) - { - return; - } - - DockPanel.SuspendLayout(true); - - DockPane oldPane = Pane; - - SuspendSetDockState(); - FloatPane = value == null ? null : (value.IsFloat ? value : FloatPane); - PanelPane = value == null ? null : (value.IsFloat ? PanelPane : value); - ResumeSetDockState(IsHidden, value != null ? value.DockState : DockState.Unknown, oldPane); - - DockPanel.ResumeLayout(true, true); - } - } - - public bool IsHidden - { - get { return m_isHidden; } - set - { - if (m_isHidden == value) - { - return; - } - - SetDockState(value, VisibleState, Pane); - } - } - - public string TabText - { - get { return m_tabText == null || m_tabText == "" ? Form.Text : m_tabText; } - set - { - if (m_tabText == value) - { - return; - } - - m_tabText = value; - if (Pane != null) - { - Pane.RefreshChanges(); - } - } - } - - public DockState VisibleState - { - get { return m_visibleState; } - set - { - if (m_visibleState == value) - { - return; - } - - SetDockState(IsHidden, value, Pane); - } - } - - public bool IsFloat - { - get { return m_isFloat; } - set - { - if (m_isFloat == value) - { - return; - } - - DockState visibleState = CheckDockState(value); - - if (visibleState == DockState.Unknown) - { - throw new InvalidOperationException(Strings.DockContentHandler_IsFloat_InvalidValue); - } - - SetDockState(IsHidden, visibleState, Pane); - } - } - - public DockPane PanelPane - { - get { return m_panelPane; } - set - { - if (m_panelPane == value) - { - return; - } - - if (value != null) - { - if (value.IsFloat || value.DockPanel != DockPanel) - { - throw new InvalidOperationException(Strings.DockContentHandler_DockPane_InvalidValue); - } - } - - DockPane oldPane = Pane; - - if (m_panelPane != null) - { - RemoveFromPane(m_panelPane); - } - m_panelPane = value; - if (m_panelPane != null) - { - m_panelPane.AddContent(Content); - SetDockState(IsHidden, IsFloat ? DockState.Float : m_panelPane.DockState, oldPane); - } - else - { - SetDockState(IsHidden, DockState.Unknown, oldPane); - } - } - } - - public DockPane FloatPane - { - get { return m_floatPane; } - set - { - if (m_floatPane == value) - { - return; - } - - if (value != null) - { - if (!value.IsFloat || value.DockPanel != DockPanel) - { - throw new InvalidOperationException(Strings.DockContentHandler_FloatPane_InvalidValue); - } - } - - DockPane oldPane = Pane; - - if (m_floatPane != null) - { - RemoveFromPane(m_floatPane); - } - m_floatPane = value; - if (m_floatPane != null) - { - m_floatPane.AddContent(Content); - SetDockState(IsHidden, IsFloat ? DockState.Float : VisibleState, oldPane); - } - else - { - SetDockState(IsHidden, DockState.Unknown, oldPane); - } - } - } - - internal bool IsSuspendSetDockState - { - get { return m_countSetDockState != 0; } - } - - internal string PersistString - { - get { return GetPersistStringCallback == null ? Form.GetType().ToString() : GetPersistStringCallback(); } - } - - public GetPersistStringCallback GetPersistStringCallback { get; set; } = null; - - public bool HideOnClose { get; set; } = false; - - public DockState ShowHint - { - get { return m_showHint; } - set - { - if (!DockHelper.IsDockStateValid(value, DockAreas)) - { - throw new InvalidOperationException(Strings.DockContentHandler_ShowHint_InvalidValue); - } - - if (m_showHint == value) - { - return; - } - - m_showHint = value; - } - } - - public bool IsActivated - { - get { return m_isActivated; } - internal set - { - if (m_isActivated == value) - { - return; - } - - m_isActivated = value; - } - } - - public ContextMenuStrip TabPageContextMenu { get; set; } = null; - - public string ToolTipText { get; set; } = null; - - internal IntPtr ActiveWindowHandle { get; set; } = IntPtr.Zero; - - internal IDisposable AutoHideTab { get; set; } = null; - - internal bool FlagClipWindow - { - get { return m_flagClipWindow; } - set - { - if (m_flagClipWindow == value) - { - return; - } - - m_flagClipWindow = value; - if (m_flagClipWindow) - { - Form.Region = new Region(Rectangle.Empty); - } - else - { - Form.Region = null; - } - } - } - - public ContextMenuStrip TabPageContextMenuStrip { get; set; } = null; - - #endregion - - #region Public methods - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters")] - public DockState CheckDockState(bool isFloat) - { - DockState dockState; - - if (isFloat) - { - if (!IsDockStateValid(DockState.Float)) - { - dockState = DockState.Unknown; - } - else - { - dockState = DockState.Float; - } - } - else - { - dockState = PanelPane != null ? PanelPane.DockState : DefaultDockState; - if (dockState != DockState.Unknown && !IsDockStateValid(dockState)) - { - dockState = DockState.Unknown; - } - } - - return dockState; - } - - public bool IsDockStateValid(DockState dockState) - { - if (DockPanel != null && dockState == DockState.Document && - DockPanel.DocumentStyle == DocumentStyle.SystemMdi) - { - return false; - } - else - { - return DockHelper.IsDockStateValid(dockState, DockAreas); - } - } - - public void Activate() - { - if (DockPanel == null) - { - Form.Activate(); - } - else if (Pane == null) - { - Show(DockPanel); - } - else - { - IsHidden = false; - Pane.ActiveContent = Content; - if (DockState == DockState.Document && DockPanel.DocumentStyle == DocumentStyle.SystemMdi) - { - Form.Activate(); - return; - } - else if (DockHelper.IsDockStateAutoHide(DockState)) - { - DockPanel.ActiveAutoHideContent = Content; - } - - if (!Form.ContainsFocus) - { - DockPanel.ContentFocusManager.Activate(Content); - } - } - } - - public void GiveUpFocus() - { - DockPanel.ContentFocusManager.GiveUpFocus(Content); - } - - public void Hide() - { - IsHidden = true; - } - - public void Show() - { - if (DockPanel == null) - { - Form.Show(); - } - else - { - Show(DockPanel); - } - } - - public void Show(DockPanel dockPanel) - { - if (dockPanel == null) - { - throw new ArgumentNullException(Strings.DockContentHandler_Show_NullDockPanel); - } - - if (DockState == DockState.Unknown) - { - Show(dockPanel, DefaultShowState); - } - else - { - Activate(); - } - } - - public void Show(DockPanel dockPanel, DockState dockState) - { - if (dockPanel == null) - { - throw new ArgumentNullException(Strings.DockContentHandler_Show_NullDockPanel); - } - - if (dockState == DockState.Unknown || dockState == DockState.Hidden) - { - throw new ArgumentException(Strings.DockContentHandler_Show_InvalidDockState); - } - - dockPanel.SuspendLayout(true); - - DockPanel = dockPanel; - - if (dockState == DockState.Float && FloatPane == null) - { - Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, DockState.Float, true); - } - else if (PanelPane == null) - { - DockPane paneExisting = null; - foreach (DockPane pane in DockPanel.Panes) - { - if (pane.DockState == dockState) - { - paneExisting = pane; - break; - } - } - - if (paneExisting == null) - { - Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, dockState, true); - } - else - { - Pane = paneExisting; - } - } - - DockState = dockState; - dockPanel.ResumeLayout(true, true); //we'll resume the layout before activating to ensure that the position - Activate(); //and size of the form are finally processed before the form is shown - } - - [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters")] - public void Show(DockPanel dockPanel, Rectangle floatWindowBounds) - { - if (dockPanel == null) - { - throw new ArgumentNullException(Strings.DockContentHandler_Show_NullDockPanel); - } - - dockPanel.SuspendLayout(true); - - DockPanel = dockPanel; - if (FloatPane == null) - { - IsHidden = true; // to reduce the screen flicker - FloatPane = DockPanel.DockPaneFactory.CreateDockPane(Content, DockState.Float, false); - FloatPane.FloatWindow.StartPosition = FormStartPosition.Manual; - } - - FloatPane.FloatWindow.Bounds = floatWindowBounds; - - Show(dockPanel, DockState.Float); - Activate(); - - dockPanel.ResumeLayout(true, true); - } - - public void Show(DockPane pane, IDockContent beforeContent) - { - if (pane == null) - { - throw new ArgumentNullException(Strings.DockContentHandler_Show_NullPane); - } - - if (beforeContent != null && pane.Contents.IndexOf(beforeContent) == -1) - { - throw new ArgumentException(Strings.DockContentHandler_Show_InvalidBeforeContent); - } - - pane.DockPanel.SuspendLayout(true); - - DockPanel = pane.DockPanel; - Pane = pane; - pane.SetContentIndex(Content, pane.Contents.IndexOf(beforeContent)); - Show(); - - pane.DockPanel.ResumeLayout(true, true); - } - - public void Show(DockPane previousPane, DockAlignment alignment, double proportion) - { - if (previousPane == null) - { - throw new ArgumentException(Strings.DockContentHandler_Show_InvalidPrevPane); - } - - if (DockHelper.IsDockStateAutoHide(previousPane.DockState)) - { - throw new ArgumentException(Strings.DockContentHandler_Show_InvalidPrevPane); - } - - previousPane.DockPanel.SuspendLayout(true); - - DockPanel = previousPane.DockPanel; - DockPanel.DockPaneFactory.CreateDockPane(Content, previousPane, alignment, proportion, true); - Show(); - - previousPane.DockPanel.ResumeLayout(true, true); - } - - public void Close() - { - DockPanel dockPanel = DockPanel; - if (dockPanel != null) - { - dockPanel.SuspendLayout(true); - } - Form.Close(); - if (dockPanel != null) - { - dockPanel.ResumeLayout(true, true); - } - } - - #endregion - - #region Internals - - internal void SetDockState(bool isHidden, DockState visibleState, DockPane oldPane) - { - if (IsSuspendSetDockState) - { - return; - } - - if (DockPanel == null && visibleState != DockState.Unknown) - { - throw new InvalidOperationException(Strings.DockContentHandler_SetDockState_NullPanel); - } - - if (visibleState == DockState.Hidden || - visibleState != DockState.Unknown && !IsDockStateValid(visibleState)) - { - throw new InvalidOperationException(Strings.DockContentHandler_SetDockState_InvalidState); - } - - DockPanel dockPanel = DockPanel; - if (dockPanel != null) - { - dockPanel.SuspendLayout(true); - } - - SuspendSetDockState(); - - DockState oldDockState = DockState; - - if (m_isHidden != isHidden || oldDockState == DockState.Unknown) - { - m_isHidden = isHidden; - } - m_visibleState = visibleState; - m_dockState = isHidden ? DockState.Hidden : visibleState; - - if (visibleState == DockState.Unknown) - { - Pane = null; - } - else - { - m_isFloat = m_visibleState == DockState.Float; - - if (Pane == null) - { - Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, visibleState, true); - } - else if (Pane.DockState != visibleState) - { - if (Pane.Contents.Count == 1) - { - Pane.SetDockState(visibleState); - } - else - { - Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, visibleState, true); - } - } - } - - if (Form.ContainsFocus) - { - if (DockState == DockState.Hidden || DockState == DockState.Unknown) - { - DockPanel.ContentFocusManager.GiveUpFocus(Content); - } - } - - SetPaneAndVisible(Pane); - - if (oldPane != null && !oldPane.IsDisposed && oldDockState == oldPane.DockState) - { - RefreshDockPane(oldPane); - } - - if (Pane != null && DockState == Pane.DockState) - { - if (Pane != oldPane || - Pane == oldPane && oldDockState != oldPane.DockState) - // Avoid early refresh of hidden AutoHide panes - { - if ((Pane.DockWindow == null || Pane.DockWindow.Visible || Pane.IsHidden) && !Pane.IsAutoHide) - { - RefreshDockPane(Pane); - } - } - } - - if (oldDockState != DockState) - { - if (DockState == DockState.Hidden || DockState == DockState.Unknown || - DockHelper.IsDockStateAutoHide(DockState)) - { - DockPanel.ContentFocusManager.RemoveFromList(Content); - } - else - { - DockPanel.ContentFocusManager.AddToList(Content); - } - - OnDockStateChanged(EventArgs.Empty); - } - ResumeSetDockState(); - - if (dockPanel != null) - { - dockPanel.ResumeLayout(true, true); - } - } - - internal void SetPaneAndVisible(DockPane pane) - { - SetPane(pane); - SetVisible(); - } - - internal void SetVisible() - { - bool visible; - - if (IsHidden) - { - visible = false; - } - else if (Pane != null && Pane.DockState == DockState.Document && - DockPanel.DocumentStyle == DocumentStyle.DockingMdi) - { - visible = true; - } - else if (Pane != null && Pane.ActiveContent == Content) - { - visible = true; - } - else if (Pane != null && Pane.ActiveContent != Content) - { - visible = false; - } - else - { - visible = Form.Visible; - } - - if (Form.Visible != visible) - { - Form.Visible = visible; - } - } - - internal DockPaneStripBase.Tab GetTab(DockPaneStripBase dockPaneStrip) - { - if (m_tab == null) - { - m_tab = dockPaneStrip.CreateTab(Content); - } - - return m_tab; - } - - #endregion - - #region Private Methods - - private void RemoveFromPane(DockPane pane) - { - pane.RemoveContent(Content); - SetPane(null); - if (pane.Contents.Count == 0) - { - pane.Dispose(); - } - } - - private void SuspendSetDockState() - { - m_countSetDockState++; - } - - private void ResumeSetDockState() - { - m_countSetDockState--; - if (m_countSetDockState < 0) - { - m_countSetDockState = 0; - } - } - - private void ResumeSetDockState(bool isHidden, DockState visibleState, DockPane oldPane) - { - ResumeSetDockState(); - SetDockState(isHidden, visibleState, oldPane); - } - - private static void RefreshDockPane(DockPane pane) - { - pane.RefreshChanges(); - pane.ValidateActiveContent(); - } - - private void SetPane(DockPane pane) - { - if (pane != null && pane.DockState == DockState.Document && - DockPanel.DocumentStyle == DocumentStyle.DockingMdi) - { - if (Form.Parent is DockPane) - { - SetParent(null); - } - if (Form.MdiParent != DockPanel.ParentForm) - { - FlagClipWindow = true; - Form.MdiParent = DockPanel.ParentForm; - } - } - else - { - FlagClipWindow = true; - if (Form.MdiParent != null) - { - Form.MdiParent = null; - } - if (Form.TopLevel) - { - Form.TopLevel = false; - } - SetParent(pane); - } - } - - private void SetParent(Control value) - { - if (Form.Parent == value) - { - return; - } - - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // Workaround of .Net Framework bug: - // Change the parent of a control with focus may result in the first - // MDI child form get activated. - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - bool bRestoreFocus = false; - if (Form.ContainsFocus) - { - //Suggested as a fix for a memory leak by bugreports - if (value == null && !IsFloat) - { - DockPanel.ContentFocusManager.GiveUpFocus(this.Content); - } - else - { - DockPanel.SaveFocus(); - bRestoreFocus = true; - } - } - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - Form.Parent = value; - - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // Workaround of .Net Framework bug: - // Change the parent of a control with focus may result in the first - // MDI child form get activated. - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - if (bRestoreFocus) - { - Activate(); - } - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - } - - #endregion - - #region Events handler - - private void Form_Disposed(object sender, EventArgs e) - { - Dispose(); - } - - private void Form_TextChanged(object sender, EventArgs e) - { - if (DockHelper.IsDockStateAutoHide(DockState)) - { - DockPanel.RefreshAutoHideStrip(); - } - else if (Pane != null) - { - if (Pane.FloatWindow != null) - { - Pane.FloatWindow.SetText(); - } - Pane.RefreshChanges(); - } - } - - #endregion - - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - lock (this) - { - DockPanel = null; - if (AutoHideTab != null) - { - AutoHideTab.Dispose(); - } - if (m_tab != null) - { - m_tab.Dispose(); - } - - Form.Disposed -= new EventHandler(Form_Disposed); - Form.TextChanged -= new EventHandler(Form_TextChanged); - Events.Dispose(); - } - } - } - - protected virtual void OnDockStateChanged(EventArgs e) - { - EventHandler handler = (EventHandler) Events[DockStateChangedEvent]; - if (handler != null) - { - handler(this, e); - } - } - - #region IDockDragSource Members - - Control IDragSource.DragControl - { - get { return Form; } - } - - bool IDockDragSource.CanDockTo(DockPane pane) - { - if (!IsDockStateValid(pane.DockState)) - { - return false; - } - - if (Pane == pane && pane.DisplayingContents.Count == 1) - { - return false; - } - - return true; - } - - Rectangle IDockDragSource.BeginDrag(Point ptMouse) - { - Size size; - DockPane floatPane = this.FloatPane; - if (DockState == DockState.Float || floatPane == null || floatPane.FloatWindow.NestedPanes.Count != 1) - { - size = DockPanel.DefaultFloatWindowSize; - } - else - { - size = floatPane.FloatWindow.Size; - } - - Point location; - Rectangle rectPane = Pane.ClientRectangle; - if (DockState == DockState.Document) - { - if (Pane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom) - { - location = new Point(rectPane.Left, rectPane.Bottom - size.Height); - } - else - { - location = new Point(rectPane.Left, rectPane.Top); - } - } - else - { - location = new Point(rectPane.Left, rectPane.Bottom); - location.Y -= size.Height; - } - location = Pane.PointToScreen(location); - - if (ptMouse.X > location.X + size.Width) - { - location.X += ptMouse.X - (location.X + size.Width) + Measures.SplitterSize; - } - - return new Rectangle(location, size); - } - - public void FloatAt(Rectangle floatWindowBounds) - { - DockPane pane = DockPanel.DockPaneFactory.CreateDockPane(Content, floatWindowBounds, true); - } - - public void DockTo(DockPane pane, DockStyle dockStyle, int contentIndex) - { - if (dockStyle == DockStyle.Fill) - { - bool samePane = Pane == pane; - if (!samePane) - { - Pane = pane; - } - - if (contentIndex == -1 || !samePane) - { - pane.SetContentIndex(Content, contentIndex); - } - else - { - DockContentCollection contents = pane.Contents; - int oldIndex = contents.IndexOf(Content); - int newIndex = contentIndex; - if (oldIndex < newIndex) - { - newIndex += 1; - if (newIndex > contents.Count - 1) - { - newIndex = -1; - } - } - pane.SetContentIndex(Content, newIndex); - } - } - else - { - DockPane paneFrom = DockPanel.DockPaneFactory.CreateDockPane(Content, pane.DockState, true); - INestedPanesContainer container = pane.NestedPanesContainer; - if (dockStyle == DockStyle.Left) - { - paneFrom.DockTo(container, pane, DockAlignment.Left, 0.5); - } - else if (dockStyle == DockStyle.Right) - { - paneFrom.DockTo(container, pane, DockAlignment.Right, 0.5); - } - else if (dockStyle == DockStyle.Top) - { - paneFrom.DockTo(container, pane, DockAlignment.Top, 0.5); - } - else if (dockStyle == DockStyle.Bottom) - { - paneFrom.DockTo(container, pane, DockAlignment.Bottom, 0.5); - } - - paneFrom.DockState = pane.DockState; - } - } - - public void DockTo(DockPanel panel, DockStyle dockStyle) - { - if (panel != DockPanel) - { - throw new ArgumentException(Strings.IDockDragSource_DockTo_InvalidPanel, "panel"); - } - - DockPane pane; - - if (dockStyle == DockStyle.Top) - { - pane = DockPanel.DockPaneFactory.CreateDockPane(Content, DockState.DockTop, true); - } - else if (dockStyle == DockStyle.Bottom) - { - pane = DockPanel.DockPaneFactory.CreateDockPane(Content, DockState.DockBottom, true); - } - else if (dockStyle == DockStyle.Left) - { - pane = DockPanel.DockPaneFactory.CreateDockPane(Content, DockState.DockLeft, true); - } - else if (dockStyle == DockStyle.Right) - { - pane = DockPanel.DockPaneFactory.CreateDockPane(Content, DockState.DockRight, true); - } - else if (dockStyle == DockStyle.Fill) - { - pane = DockPanel.DockPaneFactory.CreateDockPane(Content, DockState.Document, true); - } - else - { - return; - } - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockOutlineBase.cs b/src/WinFormsUI/Docking/DockOutlineBase.cs deleted file mode 100644 index 4b817776..00000000 --- a/src/WinFormsUI/Docking/DockOutlineBase.cs +++ /dev/null @@ -1,146 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - internal abstract class DockOutlineBase - { - #region Fields - - #endregion - - #region cTor - - public DockOutlineBase() - { - Init(); - } - - #endregion - - #region Properties - - protected Rectangle OldFloatWindowBounds { get; private set; } - - protected Control OldDockTo { get; private set; } - - protected DockStyle OldDock { get; private set; } - - protected int OldContentIndex { get; private set; } - - protected bool SameAsOldValue - { - get - { - return FloatWindowBounds == OldFloatWindowBounds && - DockTo == OldDockTo && - Dock == OldDock && - ContentIndex == OldContentIndex; - } - } - - public Rectangle FloatWindowBounds { get; private set; } - - public Control DockTo { get; private set; } - - public DockStyle Dock { get; private set; } - - public int ContentIndex { get; private set; } - - public bool FlagFullEdge - { - get { return ContentIndex != 0; } - } - - public bool FlagTestDrop { get; set; } = false; - - #endregion - - #region Public methods - - public void Show() - { - SaveOldValues(); - SetValues(Rectangle.Empty, null, DockStyle.None, -1); - TestChange(); - } - - public void Show(DockPane pane, DockStyle dock) - { - SaveOldValues(); - SetValues(Rectangle.Empty, pane, dock, -1); - TestChange(); - } - - public void Show(DockPane pane, int contentIndex) - { - SaveOldValues(); - SetValues(Rectangle.Empty, pane, DockStyle.Fill, contentIndex); - TestChange(); - } - - public void Show(DockPanel dockPanel, DockStyle dock, bool fullPanelEdge) - { - SaveOldValues(); - SetValues(Rectangle.Empty, dockPanel, dock, fullPanelEdge ? -1 : 0); - TestChange(); - } - - public void Show(Rectangle floatWindowBounds) - { - SaveOldValues(); - SetValues(floatWindowBounds, null, DockStyle.None, -1); - TestChange(); - } - - public void Close() - { - OnClose(); - } - - #endregion - - #region Private Methods - - private void Init() - { - SetValues(Rectangle.Empty, null, DockStyle.None, -1); - SaveOldValues(); - } - - private void SaveOldValues() - { - OldDockTo = DockTo; - OldDock = Dock; - OldContentIndex = ContentIndex; - OldFloatWindowBounds = FloatWindowBounds; - } - - private void SetValues(Rectangle floatWindowBounds, Control dockTo, DockStyle dock, int contentIndex) - { - FloatWindowBounds = floatWindowBounds; - DockTo = dockTo; - Dock = dock; - ContentIndex = contentIndex; - FlagTestDrop = true; - } - - private void TestChange() - { - if (FloatWindowBounds != OldFloatWindowBounds || - DockTo != OldDockTo || - Dock != OldDock || - ContentIndex != OldContentIndex) - { - OnShow(); - } - } - - #endregion - - protected abstract void OnShow(); - - protected abstract void OnClose(); - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockPane.SplitterControl.cs b/src/WinFormsUI/Docking/DockPane.SplitterControl.cs deleted file mode 100644 index 9f3854ac..00000000 --- a/src/WinFormsUI/Docking/DockPane.SplitterControl.cs +++ /dev/null @@ -1,199 +0,0 @@ -using System; -using System.Collections; -using System.ComponentModel; -using System.Drawing; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - partial class DockPane - { - #region Fields - - #endregion - - #region Properties - - private SplitterControl Splitter { get; set; } - - internal Rectangle SplitterBounds - { - set { Splitter.Bounds = value; } - } - - internal DockAlignment SplitterAlignment - { - set { Splitter.Alignment = value; } - } - - #endregion - - private class SplitterControl : Control, ISplitterDragSource - { - #region Fields - - private DockAlignment m_alignment; - - #endregion - - #region cTor - - public SplitterControl(DockPane pane) - { - SetStyle(ControlStyles.Selectable, false); - DockPane = pane; - } - - #endregion - - #region Properties - - public DockPane DockPane { get; } - - public DockAlignment Alignment - { - get { return m_alignment; } - set - { - m_alignment = value; - if (m_alignment == DockAlignment.Left || m_alignment == DockAlignment.Right) - { - Cursor = Cursors.VSplit; - } - else if (m_alignment == DockAlignment.Top || m_alignment == DockAlignment.Bottom) - { - Cursor = Cursors.HSplit; - } - else - { - Cursor = Cursors.Default; - } - - if (DockPane.DockState == DockState.Document) - { - Invalidate(); - } - } - } - - #endregion - - #region Overrides - - protected override void OnPaint(PaintEventArgs e) - { - base.OnPaint(e); - - if (DockPane.DockState != DockState.Document) - { - return; - } - - Graphics g = e.Graphics; - Rectangle rect = ClientRectangle; - if (Alignment == DockAlignment.Top || Alignment == DockAlignment.Bottom) - { - g.DrawLine(SystemPens.ControlDark, rect.Left, rect.Bottom - 1, rect.Right, rect.Bottom - 1); - } - else if (Alignment == DockAlignment.Left || Alignment == DockAlignment.Right) - { - g.DrawLine(SystemPens.ControlDarkDark, rect.Right - 1, rect.Top, rect.Right - 1, rect.Bottom); - } - } - - protected override void OnMouseDown(MouseEventArgs e) - { - base.OnMouseDown(e); - - if (e.Button != MouseButtons.Left) - { - return; - } - - DockPane.DockPanel.BeginDrag(this, Parent.RectangleToScreen(Bounds)); - } - - #endregion - - #region ISplitterDragSource Members - - void ISplitterDragSource.BeginDrag(Rectangle rectSplitter) - { - } - - void ISplitterDragSource.EndDrag() - { - } - - bool ISplitterDragSource.IsVertical - { - get - { - NestedDockingStatus status = DockPane.NestedDockingStatus; - return status.DisplayingAlignment == DockAlignment.Left || - status.DisplayingAlignment == DockAlignment.Right; - } - } - - Rectangle ISplitterDragSource.DragLimitBounds - { - get - { - NestedDockingStatus status = DockPane.NestedDockingStatus; - Rectangle rectLimit = Parent.RectangleToScreen(status.LogicalBounds); - if (((ISplitterDragSource) this).IsVertical) - { - rectLimit.X += MeasurePane.MinSize; - rectLimit.Width -= 2 * MeasurePane.MinSize; - } - else - { - rectLimit.Y += MeasurePane.MinSize; - rectLimit.Height -= 2 * MeasurePane.MinSize; - } - - return rectLimit; - } - } - - void ISplitterDragSource.MoveSplitter(int offset) - { - NestedDockingStatus status = DockPane.NestedDockingStatus; - double proportion = status.Proportion; - if (status.LogicalBounds.Width <= 0 || status.LogicalBounds.Height <= 0) - { - return; - } - else if (status.DisplayingAlignment == DockAlignment.Left) - { - proportion += (double) offset / (double) status.LogicalBounds.Width; - } - else if (status.DisplayingAlignment == DockAlignment.Right) - { - proportion -= (double) offset / (double) status.LogicalBounds.Width; - } - else if (status.DisplayingAlignment == DockAlignment.Top) - { - proportion += (double) offset / (double) status.LogicalBounds.Height; - } - else - { - proportion -= (double) offset / (double) status.LogicalBounds.Height; - } - - DockPane.SetNestedDockingProportion(proportion); - } - - #region IDragSource Members - - Control IDragSource.DragControl - { - get { return this; } - } - - #endregion - - #endregion - } - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockPane.cs b/src/WinFormsUI/Docking/DockPane.cs deleted file mode 100644 index ec395b13..00000000 --- a/src/WinFormsUI/Docking/DockPane.cs +++ /dev/null @@ -1,1610 +0,0 @@ -using System; -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -using System.Drawing; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - [ToolboxItem(false)] - public partial class DockPane : UserControl, IDockDragSource - { - #region Fields - - private static readonly object DockStateChangedEvent = new object(); - - private static readonly object IsActivatedChangedEvent = new object(); - - private static readonly object IsActiveDocumentPaneChangedEvent = new object(); - - private IDockContent m_activeContent = null; - - private int m_countRefreshStateChange = 0; - - private DockState m_dockState = DockState.Unknown; - - #endregion - - #region cTor - - internal protected DockPane(IDockContent content, DockState visibleState, bool show) - { - InternalConstruct(content, visibleState, false, Rectangle.Empty, null, DockAlignment.Right, 0.5, show); - } - - [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters", MessageId = "1#")] - internal protected DockPane(IDockContent content, FloatWindow floatWindow, bool show) - { - if (floatWindow == null) - { - throw new ArgumentNullException("floatWindow"); - } - - InternalConstruct(content, DockState.Float, false, Rectangle.Empty, - floatWindow.NestedPanes.GetDefaultPreviousPane(this), DockAlignment.Right, 0.5, show); - } - - internal protected DockPane(IDockContent content, DockPane previousPane, DockAlignment alignment, - double proportion, bool show) - { - if (previousPane == null) - { - throw new ArgumentNullException("previousPane"); - } - InternalConstruct(content, previousPane.DockState, false, Rectangle.Empty, previousPane, alignment, - proportion, show); - } - - [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters", MessageId = "1#")] - internal protected DockPane(IDockContent content, Rectangle floatWindowBounds, bool show) - { - InternalConstruct(content, DockState.Float, true, floatWindowBounds, null, DockAlignment.Right, 0.5, show); - } - - #endregion - - #region Events - - public event EventHandler DockStateChanged - { - add { Events.AddHandler(DockStateChangedEvent, value); } - remove { Events.RemoveHandler(DockStateChangedEvent, value); } - } - - public event EventHandler IsActivatedChanged - { - add { Events.AddHandler(IsActivatedChangedEvent, value); } - remove { Events.RemoveHandler(IsActivatedChangedEvent, value); } - } - - public event EventHandler IsActiveDocumentPaneChanged - { - add { Events.AddHandler(IsActiveDocumentPaneChangedEvent, value); } - remove { Events.RemoveHandler(IsActiveDocumentPaneChangedEvent, value); } - } - - #endregion - - #region Properties - - private DockPaneCaptionBase CaptionControl { get; set; } - - public DockPaneStripBase TabStripControl { get; private set; } - - public virtual IDockContent ActiveContent - { - get { return m_activeContent; } - set - { - if (ActiveContent == value) - { - return; - } - - if (value != null) - { - if (!DisplayingContents.Contains(value)) - { - throw new InvalidOperationException(Strings.DockPane_ActiveContent_InvalidValue); - } - } - else - { - if (DisplayingContents.Count != 0) - { - throw new InvalidOperationException(Strings.DockPane_ActiveContent_InvalidValue); - } - } - - IDockContent oldValue = m_activeContent; - - if (DockPanel.ActiveAutoHideContent == oldValue) - { - DockPanel.ActiveAutoHideContent = null; - } - - m_activeContent = value; - - if (DockPanel.DocumentStyle == DocumentStyle.DockingMdi && DockState == DockState.Document) - { - if (m_activeContent != null) - { - m_activeContent.DockHandler.Form.BringToFront(); - } - } - else - { - if (m_activeContent != null) - { - m_activeContent.DockHandler.SetVisible(); - } - if (oldValue != null && DisplayingContents.Contains(oldValue)) - { - oldValue.DockHandler.SetVisible(); - } - if (IsActivated && m_activeContent != null) - { - m_activeContent.DockHandler.Activate(); - } - } - - if (FloatWindow != null) - { - FloatWindow.SetText(); - } - - if (DockPanel.DocumentStyle == DocumentStyle.DockingMdi && - DockState == DockState.Document) - { - RefreshChanges(false); // delayed layout to reduce screen flicker - } - else - { - RefreshChanges(); - } - - if (m_activeContent != null) - { - TabStripControl.EnsureTabVisible(m_activeContent); - } - } - } - - public virtual bool AllowDockDragAndDrop { get; set; } = true; - - internal IDisposable AutoHidePane { get; set; } = null; - - internal object AutoHideTabs { get; set; } = null; - - private object TabPageContextMenu - { - get - { - IDockContent content = ActiveContent; - - if (content == null) - { - return null; - } - - if (content.DockHandler.TabPageContextMenuStrip != null) - { - return content.DockHandler.TabPageContextMenuStrip; - } - else if (content.DockHandler.TabPageContextMenu != null) - { - return content.DockHandler.TabPageContextMenu; - } - else - { - return null; - } - } - } - - internal bool HasTabPageContextMenu - { - get { return TabPageContextMenu != null; } - } - - private Rectangle CaptionRectangle - { - get - { - if (!HasCaption) - { - return Rectangle.Empty; - } - - Rectangle rectWindow = DisplayingRectangle; - int x, y, width; - x = rectWindow.X; - y = rectWindow.Y; - width = rectWindow.Width; - int height = CaptionControl.MeasureHeight(); - - return new Rectangle(x, y, width, height); - } - } - - internal Rectangle ContentRectangle - { - get - { - Rectangle rectWindow = DisplayingRectangle; - Rectangle rectCaption = CaptionRectangle; - Rectangle rectTabStrip = TabStripRectangle; - - int x = rectWindow.X; - - int y = rectWindow.Y + (rectCaption.IsEmpty ? 0 : rectCaption.Height); - if (DockState == DockState.Document && - DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Top) - { - y += rectTabStrip.Height; - } - - int width = rectWindow.Width; - int height = rectWindow.Height - rectCaption.Height - rectTabStrip.Height; - - return new Rectangle(x, y, width, height); - } - } - - internal Rectangle TabStripRectangle - { - get - { - if (Appearance == AppearanceStyle.ToolWindow) - { - return TabStripRectangle_ToolWindow; - } - else - { - return TabStripRectangle_Document; - } - } - } - - private Rectangle TabStripRectangle_ToolWindow - { - get - { - if (DisplayingContents.Count <= 1 || IsAutoHide) - { - return Rectangle.Empty; - } - - Rectangle rectWindow = DisplayingRectangle; - - int width = rectWindow.Width; - int height = TabStripControl.MeasureHeight(); - int x = rectWindow.X; - int y = rectWindow.Bottom - height; - Rectangle rectCaption = CaptionRectangle; - if (rectCaption.Contains(x, y)) - { - y = rectCaption.Y + rectCaption.Height; - } - - return new Rectangle(x, y, width, height); - } - } - - private Rectangle TabStripRectangle_Document - { - get - { - if (DisplayingContents.Count == 0) - { - return Rectangle.Empty; - } - - if (DisplayingContents.Count == 1 && DockPanel.DocumentStyle == DocumentStyle.DockingSdi) - { - return Rectangle.Empty; - } - - Rectangle rectWindow = DisplayingRectangle; - int x = rectWindow.X; - int width = rectWindow.Width; - int height = TabStripControl.MeasureHeight(); - - int y = 0; - if (DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom) - { - y = rectWindow.Height - height; - } - else - { - y = rectWindow.Y; - } - - return new Rectangle(x, y, width, height); - } - } - - public virtual string CaptionText - { - get { return ActiveContent == null ? string.Empty : ActiveContent.DockHandler.TabText; } - } - - public DockContentCollection Contents { get; private set; } - - public DockContentCollection DisplayingContents { get; private set; } - - public DockPanel DockPanel { get; private set; } - - private bool HasCaption - { - get - { - if (DockState == DockState.Document || - DockState == DockState.Hidden || - DockState == DockState.Unknown || - DockState == DockState.Float && FloatWindow.VisibleNestedPanes.Count <= 1) - { - return false; - } - else - { - return true; - } - } - } - - public bool IsActivated { get; private set; } = false; - - public bool IsActiveDocumentPane { get; private set; } = false; - - public bool IsAutoHide - { - get { return DockHelper.IsDockStateAutoHide(DockState); } - } - - public AppearanceStyle Appearance - { - get { return DockState == DockState.Document ? AppearanceStyle.Document : AppearanceStyle.ToolWindow; } - } - - internal Rectangle DisplayingRectangle - { - get { return ClientRectangle; } - } - - public bool IsHidden { get; private set; } = true; - - public DockWindow DockWindow - { - get - { - return NestedDockingStatus.NestedPanes == null - ? null - : NestedDockingStatus.NestedPanes.Container as DockWindow; - } - set - { - DockWindow oldValue = DockWindow; - if (oldValue == value) - { - return; - } - - DockTo(value); - } - } - - public FloatWindow FloatWindow - { - get - { - return NestedDockingStatus.NestedPanes == null - ? null - : NestedDockingStatus.NestedPanes.Container as FloatWindow; - } - set - { - FloatWindow oldValue = FloatWindow; - if (oldValue == value) - { - return; - } - - DockTo(value); - } - } - - public NestedDockingStatus NestedDockingStatus { get; private set; } - - public bool IsFloat { get; private set; } - - public INestedPanesContainer NestedPanesContainer - { - get - { - if (NestedDockingStatus.NestedPanes == null) - { - return null; - } - else - { - return NestedDockingStatus.NestedPanes.Container; - } - } - } - - public DockState DockState - { - get { return m_dockState; } - set { SetDockState(value); } - } - - private bool IsRefreshStateChangeSuspended - { - get { return m_countRefreshStateChange != 0; } - } - - #endregion - - #region Public methods - - public bool IsDockStateValid(DockState dockState) - { - foreach (IDockContent content in Contents) - { - if (!content.DockHandler.IsDockStateValid(dockState)) - { - return false; - } - } - - return true; - } - - public void Activate() - { - if (DockHelper.IsDockStateAutoHide(DockState) && DockPanel.ActiveAutoHideContent != ActiveContent) - { - DockPanel.ActiveAutoHideContent = ActiveContent; - } - else if (!IsActivated && ActiveContent != null) - { - ActiveContent.DockHandler.Activate(); - } - } - - public void CloseActiveContent() - { - CloseContent(ActiveContent); - } - - public void SetContentIndex(IDockContent content, int index) - { - int oldIndex = Contents.IndexOf(content); - if (oldIndex == -1) - { - throw new ArgumentException(Strings.DockPane_SetContentIndex_InvalidContent); - } - - if (index < 0 || index > Contents.Count - 1) - { - if (index != -1) - { - throw new ArgumentOutOfRangeException(Strings.DockPane_SetContentIndex_InvalidIndex); - } - } - - if (oldIndex == index) - { - return; - } - if (oldIndex == Contents.Count - 1 && index == -1) - { - return; - } - - Contents.Remove(content); - if (index == -1) - { - Contents.Add(content); - } - else if (oldIndex < index) - { - Contents.AddAt(content, index - 1); - } - else - { - Contents.AddAt(content, index); - } - - RefreshChanges(); - } - - public new void Show() - { - Activate(); - } - - public DockPane SetDockState(DockState value) - { - if (value == DockState.Unknown || value == DockState.Hidden) - { - throw new InvalidOperationException(Strings.DockPane_SetDockState_InvalidState); - } - - if (value == DockState.Float == this.IsFloat) - { - InternalSetDockState(value); - return this; - } - - if (DisplayingContents.Count == 0) - { - return null; - } - - IDockContent firstContent = null; - for (int i = 0; i < DisplayingContents.Count; i++) - { - IDockContent content = DisplayingContents[i]; - if (content.DockHandler.IsDockStateValid(value)) - { - firstContent = content; - break; - } - } - if (firstContent == null) - { - return null; - } - - firstContent.DockHandler.DockState = value; - DockPane pane = firstContent.DockHandler.Pane; - DockPanel.SuspendLayout(true); - for (int i = 0; i < DisplayingContents.Count; i++) - { - IDockContent content = DisplayingContents[i]; - if (content.DockHandler.IsDockStateValid(value)) - { - content.DockHandler.Pane = pane; - } - } - DockPanel.ResumeLayout(true, true); - return pane; - } - - public DockPane DockTo(INestedPanesContainer container) - { - if (container == null) - { - throw new InvalidOperationException(Strings.DockPane_DockTo_NullContainer); - } - - DockAlignment alignment; - if (container.DockState == DockState.DockLeft || container.DockState == DockState.DockRight) - { - alignment = DockAlignment.Bottom; - } - else - { - alignment = DockAlignment.Right; - } - - return DockTo(container, container.NestedPanes.GetDefaultPreviousPane(this), alignment, 0.5); - } - - public DockPane DockTo(INestedPanesContainer container, DockPane previousPane, DockAlignment alignment, - double proportion) - { - if (container == null) - { - throw new InvalidOperationException(Strings.DockPane_DockTo_NullContainer); - } - - if (container.IsFloat == this.IsFloat) - { - InternalAddToDockList(container, previousPane, alignment, proportion); - return this; - } - - IDockContent firstContent = GetFirstContent(container.DockState); - if (firstContent == null) - { - return null; - } - - DockPane pane; - DockPanel.DummyContent.DockPanel = DockPanel; - if (container.IsFloat) - { - pane = DockPanel.DockPaneFactory.CreateDockPane(DockPanel.DummyContent, (FloatWindow) container, true); - } - else - { - pane = DockPanel.DockPaneFactory.CreateDockPane(DockPanel.DummyContent, container.DockState, true); - } - - pane.DockTo(container, previousPane, alignment, proportion); - SetVisibleContentsToPane(pane); - DockPanel.DummyContent.DockPanel = null; - - return pane; - } - - public void SetNestedDockingProportion(double proportion) - { - NestedDockingStatus.SetStatus(NestedDockingStatus.NestedPanes, NestedDockingStatus.PreviousPane, - NestedDockingStatus.Alignment, proportion); - if (NestedPanesContainer != null) - { - ((Control) NestedPanesContainer).PerformLayout(); - } - } - - public DockPane Float() - { - DockPanel.SuspendLayout(true); - - IDockContent activeContent = ActiveContent; - - DockPane floatPane = GetFloatPaneFromContents(); - if (floatPane == null) - { - IDockContent firstContent = GetFirstContent(DockState.Float); - if (firstContent == null) - { - DockPanel.ResumeLayout(true, true); - return null; - } - floatPane = DockPanel.DockPaneFactory.CreateDockPane(firstContent, DockState.Float, true); - } - SetVisibleContentsToPane(floatPane, activeContent); - - DockPanel.ResumeLayout(true, true); - return floatPane; - } - - public void RestoreToPanel() - { - DockPanel.SuspendLayout(true); - - IDockContent activeContent = DockPanel.ActiveContent; - - for (int i = DisplayingContents.Count - 1; i >= 0; i--) - { - IDockContent content = DisplayingContents[i]; - if (content.DockHandler.CheckDockState(false) != DockState.Unknown) - { - content.DockHandler.IsFloat = false; - } - } - - DockPanel.ResumeLayout(true, true); - } - - #endregion - - #region Internals - - internal void ShowTabPageContextMenu(Control control, Point position) - { - object menu = TabPageContextMenu; - - if (menu == null) - { - return; - } - - if (menu is ContextMenuStrip contextMenuStrip) - { - contextMenuStrip.Show(control, position); - return; - } - - if (menu is ContextMenuStrip contextMenu) - { - contextMenu.Show(this, position); - } - } - - internal void SetIsActivated(bool value) - { - if (IsActivated == value) - { - return; - } - - IsActivated = value; - if (DockState != DockState.Document) - { - RefreshChanges(false); - } - OnIsActivatedChanged(EventArgs.Empty); - } - - internal void SetIsActiveDocumentPane(bool value) - { - if (IsActiveDocumentPane == value) - { - return; - } - - IsActiveDocumentPane = value; - if (DockState == DockState.Document) - { - RefreshChanges(); - } - OnIsActiveDocumentPaneChanged(EventArgs.Empty); - } - - internal void AddContent(IDockContent content) - { - if (Contents.Contains(content)) - { - return; - } - - Contents.Add(content); - } - - internal void Close() - { - Dispose(); - } - - internal void CloseContent(IDockContent content) - { - DockPanel dockPanel = DockPanel; - - if (content == null) - { - return; - } - - if (!content.DockHandler.CloseButton) - { - return; - } - - dockPanel.SuspendLayout(true); - - try - { - if (content.DockHandler.HideOnClose) - { - content.DockHandler.Hide(); - NestedDockingStatus.NestedPanes.SwitchPaneWithFirstChild(this); - } - else - { - content.DockHandler.Close(); - } - } - finally - { - dockPanel.ResumeLayout(true, true); - } - } - - internal void SetContentBounds() - { - Rectangle rectContent = ContentRectangle; - if (DockState == DockState.Document && DockPanel.DocumentStyle == DocumentStyle.DockingMdi) - { - rectContent = DockPanel.RectangleToMdiClient(RectangleToScreen(rectContent)); - } - - Rectangle rectInactive = - new Rectangle(-rectContent.Width, rectContent.Y, rectContent.Width, rectContent.Height); - foreach (IDockContent content in Contents) - { - if (content.DockHandler.Pane == this) - { - if (content == ActiveContent) - { - content.DockHandler.Form.Bounds = rectContent; - } - else - { - content.DockHandler.Form.Bounds = rectInactive; - } - } - } - } - - internal void RefreshChanges() - { - RefreshChanges(true); - } - - internal void RemoveContent(IDockContent content) - { - if (!Contents.Contains(content)) - { - return; - } - - Contents.Remove(content); - } - - internal void TestDrop(IDockDragSource dragSource, DockOutlineBase dockOutline) - { - if (!dragSource.CanDockTo(this)) - { - return; - } - - Point ptMouse = Control.MousePosition; - - HitTestResult hitTestResult = GetHitTest(ptMouse); - if (hitTestResult.HitArea == HitTestArea.Caption) - { - dockOutline.Show(this, -1); - } - else if (hitTestResult.HitArea == HitTestArea.TabStrip && hitTestResult.Index != -1) - { - dockOutline.Show(this, hitTestResult.Index); - } - } - - internal void ValidateActiveContent() - { - if (ActiveContent == null) - { - if (DisplayingContents.Count != 0) - { - ActiveContent = DisplayingContents[0]; - } - return; - } - - if (DisplayingContents.IndexOf(ActiveContent) >= 0) - { - return; - } - - IDockContent prevVisible = null; - for (int i = Contents.IndexOf(ActiveContent) - 1; i >= 0; i--) - { - if (Contents[i].DockHandler.DockState == DockState) - { - prevVisible = Contents[i]; - break; - } - } - - IDockContent nextVisible = null; - for (int i = Contents.IndexOf(ActiveContent) + 1; i < Contents.Count; i++) - { - if (Contents[i].DockHandler.DockState == DockState) - { - nextVisible = Contents[i]; - break; - } - } - - if (prevVisible != null) - { - ActiveContent = prevVisible; - } - else if (nextVisible != null) - { - ActiveContent = nextVisible; - } - else - { - ActiveContent = null; - } - } - - #endregion - - #region Overrides - - protected override void Dispose(bool disposing) - { - if (disposing) - { - m_dockState = DockState.Unknown; - - if (NestedPanesContainer != null) - { - NestedPanesContainer.NestedPanes.Remove(this); - } - - if (DockPanel != null) - { - DockPanel.RemovePane(this); - DockPanel = null; - } - - Splitter.Dispose(); - if (AutoHidePane != null) - { - AutoHidePane.Dispose(); - } - } - base.Dispose(disposing); - } - - protected override void OnLayout(LayoutEventArgs levent) - { - SetIsHidden(DisplayingContents.Count == 0); - if (!IsHidden) - { - CaptionControl.Bounds = CaptionRectangle; - TabStripControl.Bounds = TabStripRectangle; - - SetContentBounds(); - - foreach (IDockContent content in Contents) - { - if (DisplayingContents.Contains(content)) - { - if (content.DockHandler.FlagClipWindow && content.DockHandler.Form.Visible) - { - content.DockHandler.FlagClipWindow = false; - } - } - } - } - - base.OnLayout(levent); - } - - protected override void WndProc(ref Message m) - { - if (m.Msg == (int) Win32.Msgs.WM_MOUSEACTIVATE) - { - Activate(); - } - - base.WndProc(ref m); - } - - #endregion - - #region Private Methods - - private void InternalConstruct(IDockContent content, DockState dockState, bool flagBounds, - Rectangle floatWindowBounds, DockPane prevPane, DockAlignment alignment, double proportion, bool show) - { - if (dockState == DockState.Hidden || dockState == DockState.Unknown) - { - throw new ArgumentException(Strings.DockPane_SetDockState_InvalidState); - } - - if (content == null) - { - throw new ArgumentNullException(Strings.DockPane_Constructor_NullContent); - } - - if (content.DockHandler.DockPanel == null) - { - throw new ArgumentException(Strings.DockPane_Constructor_NullDockPanel); - } - - - SuspendLayout(); - SetStyle(ControlStyles.Selectable, false); - - IsFloat = dockState == DockState.Float; - - Contents = new DockContentCollection(); - DisplayingContents = new DockContentCollection(this); - DockPanel = content.DockHandler.DockPanel; - DockPanel.AddPane(this); - - Splitter = new SplitterControl(this); - - NestedDockingStatus = new NestedDockingStatus(this); - - CaptionControl = DockPanel.DockPaneCaptionFactory.CreateDockPaneCaption(this); - TabStripControl = DockPanel.DockPaneStripFactory.CreateDockPaneStrip(this); - Controls.AddRange(new Control[] {CaptionControl, TabStripControl}); - - DockPanel.SuspendLayout(true); - if (flagBounds) - { - FloatWindow = DockPanel.FloatWindowFactory.CreateFloatWindow(DockPanel, this, floatWindowBounds); - } - else if (prevPane != null) - { - DockTo(prevPane.NestedPanesContainer, prevPane, alignment, proportion); - } - - SetDockState(dockState); - if (show) - { - content.DockHandler.Pane = this; - } - else if (this.IsFloat) - { - content.DockHandler.FloatPane = this; - } - else - { - content.DockHandler.PanelPane = this; - } - - ResumeLayout(); - DockPanel.ResumeLayout(true, true); - } - - private HitTestResult GetHitTest(Point ptMouse) - { - Point ptMouseClient = PointToClient(ptMouse); - - Rectangle rectCaption = CaptionRectangle; - if (rectCaption.Contains(ptMouseClient)) - { - return new HitTestResult(HitTestArea.Caption, -1); - } - - Rectangle rectContent = ContentRectangle; - if (rectContent.Contains(ptMouseClient)) - { - return new HitTestResult(HitTestArea.Content, -1); - } - - Rectangle rectTabStrip = TabStripRectangle; - if (rectTabStrip.Contains(ptMouseClient)) - { - return new HitTestResult(HitTestArea.TabStrip, - TabStripControl.HitTest(TabStripControl.PointToClient(ptMouse))); - } - - return new HitTestResult(HitTestArea.None, -1); - } - - private void SetIsHidden(bool value) - { - if (IsHidden == value) - { - return; - } - - IsHidden = value; - if (DockHelper.IsDockStateAutoHide(DockState)) - { - DockPanel.RefreshAutoHideStrip(); - DockPanel.PerformLayout(); - } - else if (NestedPanesContainer != null) - { - ((Control) NestedPanesContainer).PerformLayout(); - } - } - - private void RefreshChanges(bool performLayout) - { - if (IsDisposed) - { - return; - } - - CaptionControl.RefreshChanges(); - TabStripControl.RefreshChanges(); - if (DockState == DockState.Float && FloatWindow != null) - { - FloatWindow.RefreshChanges(); - } - if (DockHelper.IsDockStateAutoHide(DockState) && DockPanel != null) - { - DockPanel.RefreshAutoHideStrip(); - DockPanel.PerformLayout(); - } - - if (performLayout) - { - PerformLayout(); - } - } - - private void SetParent() - { - if (DockState == DockState.Unknown || DockState == DockState.Hidden) - { - SetParent(null); - Splitter.Parent = null; - } - else if (DockState == DockState.Float) - { - SetParent(FloatWindow); - Splitter.Parent = FloatWindow; - } - else if (DockHelper.IsDockStateAutoHide(DockState)) - { - SetParent(DockPanel.AutoHideControl); - Splitter.Parent = null; - } - else - { - SetParent(DockPanel.DockWindows[DockState]); - Splitter.Parent = Parent; - } - } - - private void SetParent(Control value) - { - if (Parent == value) - { - return; - } - - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // Workaround of .Net Framework bug: - // Change the parent of a control with focus may result in the first - // MDI child form get activated. - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - IDockContent contentFocused = GetFocusedContent(); - if (contentFocused != null) - { - DockPanel.SaveFocus(); - } - - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - Parent = value; - - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // Workaround of .Net Framework bug: - // Change the parent of a control with focus may result in the first - // MDI child form get activated. - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - if (contentFocused != null) - { - contentFocused.DockHandler.Activate(); - } - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - } - - private void InternalSetDockState(DockState value) - { - if (m_dockState == value) - { - return; - } - - DockState oldDockState = m_dockState; - INestedPanesContainer oldContainer = NestedPanesContainer; - - m_dockState = value; - - SuspendRefreshStateChange(); - - IDockContent contentFocused = GetFocusedContent(); - if (contentFocused != null) - { - DockPanel.SaveFocus(); - } - - if (!IsFloat) - { - DockWindow = DockPanel.DockWindows[DockState]; - } - else if (FloatWindow == null) - { - FloatWindow = DockPanel.FloatWindowFactory.CreateFloatWindow(DockPanel, this); - } - - if (contentFocused != null) - { - DockPanel.ContentFocusManager.Activate(contentFocused); - } - - ResumeRefreshStateChange(oldContainer, oldDockState); - } - - private void SuspendRefreshStateChange() - { - m_countRefreshStateChange++; - DockPanel.SuspendLayout(true); - } - - private void ResumeRefreshStateChange() - { - m_countRefreshStateChange--; - System.Diagnostics.Debug.Assert(m_countRefreshStateChange >= 0); - DockPanel.ResumeLayout(true, true); - } - - private void ResumeRefreshStateChange(INestedPanesContainer oldContainer, DockState oldDockState) - { - ResumeRefreshStateChange(); - RefreshStateChange(oldContainer, oldDockState); - } - - private void RefreshStateChange(INestedPanesContainer oldContainer, DockState oldDockState) - { - lock (this) - { - if (IsRefreshStateChangeSuspended) - { - return; - } - - SuspendRefreshStateChange(); - } - - DockPanel.SuspendLayout(true); - - IDockContent contentFocused = GetFocusedContent(); - if (contentFocused != null) - { - DockPanel.SaveFocus(); - } - SetParent(); - - if (ActiveContent != null) - { - ActiveContent.DockHandler.SetDockState(ActiveContent.DockHandler.IsHidden, DockState, - ActiveContent.DockHandler.Pane); - } - foreach (IDockContent content in Contents) - { - if (content.DockHandler.Pane == this) - { - content.DockHandler.SetDockState(content.DockHandler.IsHidden, DockState, content.DockHandler.Pane); - } - } - - if (oldContainer != null) - { - Control oldContainerControl = (Control) oldContainer; - if (oldContainer.DockState == oldDockState && !oldContainerControl.IsDisposed) - { - oldContainerControl.PerformLayout(); - } - } - if (DockHelper.IsDockStateAutoHide(oldDockState)) - { - DockPanel.RefreshActiveAutoHideContent(); - } - - if (NestedPanesContainer.DockState == DockState) - { - ((Control) NestedPanesContainer).PerformLayout(); - } - if (DockHelper.IsDockStateAutoHide(DockState)) - { - DockPanel.RefreshActiveAutoHideContent(); - } - - if (DockHelper.IsDockStateAutoHide(oldDockState) || - DockHelper.IsDockStateAutoHide(DockState)) - { - DockPanel.RefreshAutoHideStrip(); - DockPanel.PerformLayout(); - } - - ResumeRefreshStateChange(); - - if (contentFocused != null) - { - contentFocused.DockHandler.Activate(); - } - - DockPanel.ResumeLayout(true, true); - - if (oldDockState != DockState) - { - OnDockStateChanged(EventArgs.Empty); - } - } - - private IDockContent GetFocusedContent() - { - IDockContent contentFocused = null; - foreach (IDockContent content in Contents) - { - if (content.DockHandler.Form.ContainsFocus) - { - contentFocused = content; - break; - } - } - - return contentFocused; - } - - private void SetVisibleContentsToPane(DockPane pane) - { - SetVisibleContentsToPane(pane, ActiveContent); - } - - private void SetVisibleContentsToPane(DockPane pane, IDockContent activeContent) - { - for (int i = 0; i < DisplayingContents.Count; i++) - { - IDockContent content = DisplayingContents[i]; - if (content.DockHandler.IsDockStateValid(pane.DockState)) - { - content.DockHandler.Pane = pane; - i--; - } - } - - if (activeContent.DockHandler.Pane == pane) - { - pane.ActiveContent = activeContent; - } - } - - private void InternalAddToDockList(INestedPanesContainer container, DockPane prevPane, DockAlignment alignment, - double proportion) - { - if (container.DockState == DockState.Float != IsFloat) - { - throw new InvalidOperationException(Strings.DockPane_DockTo_InvalidContainer); - } - - int count = container.NestedPanes.Count; - if (container.NestedPanes.Contains(this)) - { - count--; - } - if (prevPane == null && count > 0) - { - throw new InvalidOperationException(Strings.DockPane_DockTo_NullPrevPane); - } - - if (prevPane != null && !container.NestedPanes.Contains(prevPane)) - { - throw new InvalidOperationException(Strings.DockPane_DockTo_NoPrevPane); - } - - if (prevPane == this) - { - throw new InvalidOperationException(Strings.DockPane_DockTo_SelfPrevPane); - } - - INestedPanesContainer oldContainer = NestedPanesContainer; - DockState oldDockState = DockState; - container.NestedPanes.Add(this); - NestedDockingStatus.SetStatus(container.NestedPanes, prevPane, alignment, proportion); - - if (DockHelper.IsDockWindowState(DockState)) - { - m_dockState = container.DockState; - } - - RefreshStateChange(oldContainer, oldDockState); - } - - private DockPane GetFloatPaneFromContents() - { - DockPane floatPane = null; - for (int i = 0; i < DisplayingContents.Count; i++) - { - IDockContent content = DisplayingContents[i]; - if (!content.DockHandler.IsDockStateValid(DockState.Float)) - { - continue; - } - - if (floatPane != null && content.DockHandler.FloatPane != floatPane) - { - return null; - } - else - { - floatPane = content.DockHandler.FloatPane; - } - } - - return floatPane; - } - - private IDockContent GetFirstContent(DockState dockState) - { - for (int i = 0; i < DisplayingContents.Count; i++) - { - IDockContent content = DisplayingContents[i]; - if (content.DockHandler.IsDockStateValid(dockState)) - { - return content; - } - } - return null; - } - - #endregion - - protected virtual void OnDockStateChanged(EventArgs e) - { - EventHandler handler = (EventHandler) Events[DockStateChangedEvent]; - if (handler != null) - { - handler(this, e); - } - } - - protected virtual void OnIsActivatedChanged(EventArgs e) - { - EventHandler handler = (EventHandler) Events[IsActivatedChangedEvent]; - if (handler != null) - { - handler(this, e); - } - } - - protected virtual void OnIsActiveDocumentPaneChanged(EventArgs e) - { - EventHandler handler = (EventHandler) Events[IsActiveDocumentPaneChangedEvent]; - if (handler != null) - { - handler(this, e); - } - } - - private enum HitTestArea - { - Caption, - TabStrip, - Content, - None - } - - private struct HitTestResult - { - public readonly HitTestArea HitArea; - public readonly int Index; - - public HitTestResult(HitTestArea hitTestArea, int index) - { - HitArea = hitTestArea; - Index = index; - } - } - - public enum AppearanceStyle - { - ToolWindow, - Document - } - - #region IDockDragSource Members - - #region IDragSource Members - - Control IDragSource.DragControl - { - get { return this; } - } - - #endregion - - bool IDockDragSource.IsDockStateValid(DockState dockState) - { - return IsDockStateValid(dockState); - } - - bool IDockDragSource.CanDockTo(DockPane pane) - { - if (!IsDockStateValid(pane.DockState)) - { - return false; - } - - if (pane == this) - { - return false; - } - - return true; - } - - Rectangle IDockDragSource.BeginDrag(Point ptMouse) - { - Point location = PointToScreen(new Point(0, 0)); - Size size; - - DockPane floatPane = ActiveContent.DockHandler.FloatPane; - if (DockState == DockState.Float || floatPane == null || floatPane.FloatWindow.NestedPanes.Count != 1) - { - size = DockPanel.DefaultFloatWindowSize; - } - else - { - size = floatPane.FloatWindow.Size; - } - - if (ptMouse.X > location.X + size.Width) - { - location.X += ptMouse.X - (location.X + size.Width) + Measures.SplitterSize; - } - - return new Rectangle(location, size); - } - - public void FloatAt(Rectangle floatWindowBounds) - { - if (FloatWindow == null || FloatWindow.NestedPanes.Count != 1) - { - FloatWindow = DockPanel.FloatWindowFactory.CreateFloatWindow(DockPanel, this, floatWindowBounds); - } - else - { - FloatWindow.Bounds = floatWindowBounds; - } - - DockState = DockState.Float; - - NestedDockingStatus.NestedPanes.Remove(this); - } - - public void DockTo(DockPane pane, DockStyle dockStyle, int contentIndex) - { - if (dockStyle == DockStyle.Fill) - { - IDockContent activeContent = ActiveContent; - for (int i = Contents.Count - 1; i >= 0; i--) - { - IDockContent c = Contents[i]; - if (c.DockHandler.DockState == DockState) - { - c.DockHandler.Pane = pane; - if (contentIndex != -1) - { - pane.SetContentIndex(c, contentIndex); - } - } - } - pane.ActiveContent = activeContent; - } - else - { - if (dockStyle == DockStyle.Left) - { - DockTo(pane.NestedPanesContainer, pane, DockAlignment.Left, 0.5); - } - else if (dockStyle == DockStyle.Right) - { - DockTo(pane.NestedPanesContainer, pane, DockAlignment.Right, 0.5); - } - else if (dockStyle == DockStyle.Top) - { - DockTo(pane.NestedPanesContainer, pane, DockAlignment.Top, 0.5); - } - else if (dockStyle == DockStyle.Bottom) - { - DockTo(pane.NestedPanesContainer, pane, DockAlignment.Bottom, 0.5); - } - - DockState = pane.DockState; - } - } - - public void DockTo(DockPanel panel, DockStyle dockStyle) - { - if (panel != DockPanel) - { - throw new ArgumentException(Strings.IDockDragSource_DockTo_InvalidPanel, "panel"); - } - - if (dockStyle == DockStyle.Top) - { - DockState = DockState.DockTop; - } - else if (dockStyle == DockStyle.Bottom) - { - DockState = DockState.DockBottom; - } - else if (dockStyle == DockStyle.Left) - { - DockState = DockState.DockLeft; - } - else if (dockStyle == DockStyle.Right) - { - DockState = DockState.DockRight; - } - else if (dockStyle == DockStyle.Fill) - { - DockState = DockState.Document; - } - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockPaneCaptionBase.cs b/src/WinFormsUI/Docking/DockPaneCaptionBase.cs deleted file mode 100644 index 2c2d5f92..00000000 --- a/src/WinFormsUI/Docking/DockPaneCaptionBase.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System.Drawing; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - public abstract class DockPaneCaptionBase : Control - { - #region Fields - - #endregion - - #region cTor - - protected internal DockPaneCaptionBase(DockPane pane) - { - DockPane = pane; - - SetStyle(ControlStyles.OptimizedDoubleBuffer | - ControlStyles.ResizeRedraw | - ControlStyles.UserPaint | - ControlStyles.AllPaintingInWmPaint, true); - SetStyle(ControlStyles.Selectable, false); - } - - #endregion - - #region Properties - - protected DockPane DockPane { get; } - - protected DockPane.AppearanceStyle Appearance - { - get { return DockPane.Appearance; } - } - - protected bool HasTabPageContextMenu - { - get { return DockPane.HasTabPageContextMenu; } - } - - #endregion - - #region Internals - - internal void RefreshChanges() - { - if (IsDisposed) - { - return; - } - - OnRefreshChanges(); - } - - #endregion - - #region Overrides - - protected override void OnMouseUp(MouseEventArgs e) - { - base.OnMouseUp(e); - - if (e.Button == MouseButtons.Right) - { - ShowTabPageContextMenu(new Point(e.X, e.Y)); - } - } - - protected override void OnMouseDown(MouseEventArgs e) - { - base.OnMouseDown(e); - - if (e.Button == MouseButtons.Left && - DockPane.DockPanel.AllowEndUserDocking && - DockPane.AllowDockDragAndDrop && - !DockHelper.IsDockStateAutoHide(DockPane.DockState) && - DockPane.ActiveContent != null) - { - DockPane.DockPanel.BeginDrag(DockPane); - } - } - - protected override void WndProc(ref Message m) - { - if (m.Msg == (int) Win32.Msgs.WM_LBUTTONDBLCLK) - { - if (DockHelper.IsDockStateAutoHide(DockPane.DockState)) - { - DockPane.DockPanel.ActiveAutoHideContent = null; - return; - } - - if (DockPane.IsFloat) - { - DockPane.RestoreToPanel(); - } - else - { - DockPane.Float(); - } - } - base.WndProc(ref m); - } - - #endregion - - protected void ShowTabPageContextMenu(Point position) - { - DockPane.ShowTabPageContextMenu(this, position); - } - - protected virtual void OnRightToLeftLayoutChanged() - { - } - - protected virtual void OnRefreshChanges() - { - } - - protected internal abstract int MeasureHeight(); - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockPaneCollection.cs b/src/WinFormsUI/Docking/DockPaneCollection.cs deleted file mode 100644 index 3ff997c3..00000000 --- a/src/WinFormsUI/Docking/DockPaneCollection.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.ObjectModel; -using System.Collections.Generic; -using System.Drawing; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - public class DockPaneCollection : ReadOnlyCollection - { - #region cTor - - internal DockPaneCollection() - : base(new List()) - { - } - - #endregion - - #region Internals - - internal int Add(DockPane pane) - { - if (Items.Contains(pane)) - { - return Items.IndexOf(pane); - } - - Items.Add(pane); - return Count - 1; - } - - internal void AddAt(DockPane pane, int index) - { - if (index < 0 || index > Items.Count - 1) - { - return; - } - - if (Contains(pane)) - { - return; - } - - Items.Insert(index, pane); - } - - internal void Dispose() - { - for (int i = Count - 1; i >= 0; i--) - { - this[i].Close(); - } - } - - internal void Remove(DockPane pane) - { - Items.Remove(pane); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockPaneStripBase.cs b/src/WinFormsUI/Docking/DockPaneStripBase.cs deleted file mode 100644 index 62fce1bf..00000000 --- a/src/WinFormsUI/Docking/DockPaneStripBase.cs +++ /dev/null @@ -1,327 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - public abstract class DockPaneStripBase : Control - { - #region Fields - - private TabCollection m_tabs = null; - - #endregion - - #region cTor - - protected DockPaneStripBase(DockPane pane) - { - DockPane = pane; - - SetStyle(ControlStyles.OptimizedDoubleBuffer, true); - SetStyle(ControlStyles.Selectable, false); - AllowDrop = true; - } - - #endregion - - #region Properties - - protected DockPane DockPane { get; } - - protected DockPane.AppearanceStyle Appearance - { - get { return DockPane.Appearance; } - } - - protected TabCollection Tabs - { - get - { - if (m_tabs == null) - { - m_tabs = new TabCollection(DockPane); - } - - return m_tabs; - } - } - - protected bool HasTabPageContextMenu - { - get { return DockPane.HasTabPageContextMenu; } - } - - #endregion - - #region Internals - - internal void RefreshChanges() - { - if (IsDisposed) - { - return; - } - - OnRefreshChanges(); - } - - #endregion - - #region Overrides - - protected override void OnMouseDown(MouseEventArgs e) - { - base.OnMouseDown(e); - - int index = HitTest(); - if (index != -1) - { - IDockContent content = Tabs[index].Content; - if (DockPane.ActiveContent != content) - { - DockPane.ActiveContent = content; - } - } - - if (e.Button == MouseButtons.Left) - { - if (DockPane.DockPanel.AllowEndUserDocking && DockPane.AllowDockDragAndDrop && - DockPane.ActiveContent.DockHandler.AllowEndUserDocking) - { - DockPane.DockPanel.BeginDrag(DockPane.ActiveContent.DockHandler); - } - } - } - - protected override void OnMouseUp(MouseEventArgs e) - { - base.OnMouseUp(e); - - if (e.Button == MouseButtons.Right) - { - ShowTabPageContextMenu(new Point(e.X, e.Y)); - } - else if (e.Button == MouseButtons.Middle && - DockPane.Appearance == Docking.DockPane.AppearanceStyle.Document) - { - // Get the content located under the click (if there is one) - int index = HitTest(); - if (index != -1) - { - // Close the specified content. - IDockContent content = Tabs[index].Content; - DockPane.CloseContent(content); - } - } - } - - protected override void WndProc(ref Message m) - { - if (m.Msg == (int) Win32.Msgs.WM_LBUTTONDBLCLK) - { - base.WndProc(ref m); - - int index = HitTest(); - if (DockPane.DockPanel.AllowEndUserDocking && index != -1) - { - IDockContent content = Tabs[index].Content; - if (content.DockHandler.CheckDockState(!content.DockHandler.IsFloat) != DockState.Unknown) - { - content.DockHandler.IsFloat = !content.DockHandler.IsFloat; - } - } - - return; - } - - base.WndProc(ref m); - return; - } - - protected override void OnDragOver(DragEventArgs drgevent) - { - base.OnDragOver(drgevent); - - int index = HitTest(); - if (index != -1) - { - IDockContent content = Tabs[index].Content; - if (DockPane.ActiveContent != content) - { - DockPane.ActiveContent = content; - } - } - } - - #endregion - - protected virtual void OnRefreshChanges() - { - } - - protected internal abstract int MeasureHeight(); - - protected internal abstract void EnsureTabVisible(IDockContent content); - - protected int HitTest() - { - return HitTest(PointToClient(Control.MousePosition)); - } - - protected internal abstract int HitTest(Point point); - - protected internal abstract GraphicsPath GetOutline(int index); - - protected internal virtual Tab CreateTab(IDockContent content) - { - return new Tab(content); - } - - protected void ShowTabPageContextMenu(Point position) - { - DockPane.ShowTabPageContextMenu(this, position); - } - - [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] - protected internal class Tab : IDisposable - { - #region Fields - - #endregion - - #region cTor - - public Tab(IDockContent content) - { - Content = content; - } - - #endregion - - #region Properties - - public IDockContent Content { get; } - - public Form ContentForm - { - get { return Content as Form; } - } - - #endregion - - #region Public methods - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - #endregion - - ~Tab() - { - Dispose(false); - } - - protected virtual void Dispose(bool disposing) - { - } - } - - [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] - protected sealed class TabCollection : IEnumerable - { - #region Fields - - #endregion - - #region cTor - - internal TabCollection(DockPane pane) - { - DockPane = pane; - } - - #endregion - - #region Properties - - public DockPane DockPane { get; } - - public int Count - { - get { return DockPane.DisplayingContents.Count; } - } - - public Tab this[int index] - { - get - { - IDockContent content = DockPane.DisplayingContents[index]; - if (content == null) - { - throw new ArgumentOutOfRangeException("index"); - } - return content.DockHandler.GetTab(DockPane.TabStripControl); - } - } - - #endregion - - #region Public methods - - public bool Contains(Tab tab) - { - return IndexOf(tab) != -1; - } - - public bool Contains(IDockContent content) - { - return IndexOf(content) != -1; - } - - public int IndexOf(Tab tab) - { - if (tab == null) - { - return -1; - } - - return DockPane.DisplayingContents.IndexOf(tab.Content); - } - - public int IndexOf(IDockContent content) - { - return DockPane.DisplayingContents.IndexOf(content); - } - - #endregion - - #region IEnumerable Members - - IEnumerator IEnumerable.GetEnumerator() - { - for (int i = 0; i < Count; i++) - { - yield return this[i]; - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - for (int i = 0; i < Count; i++) - { - yield return this[i]; - } - } - - #endregion - } - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockPanel.AutoHideWindow.cs b/src/WinFormsUI/Docking/DockPanel.AutoHideWindow.cs deleted file mode 100644 index 068dcb29..00000000 --- a/src/WinFormsUI/Docking/DockPanel.AutoHideWindow.cs +++ /dev/null @@ -1,768 +0,0 @@ -using System; -using System.Windows.Forms; -using System.Drawing; -using System.Runtime.InteropServices; - -namespace WeifenLuo.WinFormsUI.Docking -{ - partial class DockPanel - { - #region Properties - - private AutoHideWindowControl AutoHideWindow { get; } - - internal Control AutoHideControl - { - get { return AutoHideWindow; } - } - - internal Rectangle AutoHideWindowRectangle - { - get - { - DockState state = AutoHideWindow.DockState; - Rectangle rectDockArea = DockArea; - if (ActiveAutoHideContent == null) - { - return Rectangle.Empty; - } - - if (Parent == null) - { - return Rectangle.Empty; - } - - Rectangle rect = Rectangle.Empty; - double autoHideSize = ActiveAutoHideContent.DockHandler.AutoHidePortion; - if (state == DockState.DockLeftAutoHide) - { - if (autoHideSize < 1) - { - autoHideSize = rectDockArea.Width * autoHideSize; - } - if (autoHideSize > rectDockArea.Width - MeasurePane.MinSize) - { - autoHideSize = rectDockArea.Width - MeasurePane.MinSize; - } - rect.X = rectDockArea.X; - rect.Y = rectDockArea.Y; - rect.Width = (int) autoHideSize; - rect.Height = rectDockArea.Height; - } - else if (state == DockState.DockRightAutoHide) - { - if (autoHideSize < 1) - { - autoHideSize = rectDockArea.Width * autoHideSize; - } - if (autoHideSize > rectDockArea.Width - MeasurePane.MinSize) - { - autoHideSize = rectDockArea.Width - MeasurePane.MinSize; - } - rect.X = rectDockArea.X + rectDockArea.Width - (int) autoHideSize; - rect.Y = rectDockArea.Y; - rect.Width = (int) autoHideSize; - rect.Height = rectDockArea.Height; - } - else if (state == DockState.DockTopAutoHide) - { - if (autoHideSize < 1) - { - autoHideSize = rectDockArea.Height * autoHideSize; - } - if (autoHideSize > rectDockArea.Height - MeasurePane.MinSize) - { - autoHideSize = rectDockArea.Height - MeasurePane.MinSize; - } - rect.X = rectDockArea.X; - rect.Y = rectDockArea.Y; - rect.Width = rectDockArea.Width; - rect.Height = (int) autoHideSize; - } - else if (state == DockState.DockBottomAutoHide) - { - if (autoHideSize < 1) - { - autoHideSize = rectDockArea.Height * autoHideSize; - } - if (autoHideSize > rectDockArea.Height - MeasurePane.MinSize) - { - autoHideSize = rectDockArea.Height - MeasurePane.MinSize; - } - rect.X = rectDockArea.X; - rect.Y = rectDockArea.Y + rectDockArea.Height - (int) autoHideSize; - rect.Width = rectDockArea.Width; - rect.Height = (int) autoHideSize; - } - - return rect; - } - } - - #endregion - - #region Internals - - internal void RefreshActiveAutoHideContent() - { - AutoHideWindow.RefreshActiveContent(); - } - - internal Rectangle GetAutoHideWindowBounds(Rectangle rectAutoHideWindow) - { - if (DocumentStyle == DocumentStyle.SystemMdi || - DocumentStyle == DocumentStyle.DockingMdi) - { - return Parent == null - ? Rectangle.Empty - : Parent.RectangleToClient(RectangleToScreen(rectAutoHideWindow)); - } - else - { - return rectAutoHideWindow; - } - } - - internal void RefreshAutoHideStrip() - { - AutoHideStripControl.RefreshChanges(); - } - - #endregion - - private class AutoHideWindowControl : Panel, ISplitterDragSource - { - #region Fields - - #region consts - - private const int ANIMATE_TIME = 100; // in mini-seconds - - #endregion - - private IDockContent m_activeContent = null; - - private bool m_flagDragging = false; - private readonly SplitterControl m_splitter; - - private readonly Timer m_timerMouseTrack; - - #endregion - - #region cTor - - public AutoHideWindowControl(DockPanel dockPanel) - { - DockPanel = dockPanel; - - m_timerMouseTrack = new Timer(); - m_timerMouseTrack.Tick += new EventHandler(TimerMouseTrack_Tick); - - Visible = false; - m_splitter = new SplitterControl(this); - Controls.Add(m_splitter); - } - - #endregion - - #region Properties - - public DockPanel DockPanel { get; } = null; - - public DockPane ActivePane { get; private set; } = null; - - public IDockContent ActiveContent - { - get { return m_activeContent; } - set - { - if (value == m_activeContent) - { - return; - } - - if (value != null) - { - if (!DockHelper.IsDockStateAutoHide(value.DockHandler.DockState) || - value.DockHandler.DockPanel != DockPanel) - { - throw new InvalidOperationException(Strings.DockPanel_ActiveAutoHideContent_InvalidValue); - } - } - - DockPanel.SuspendLayout(); - - if (m_activeContent != null) - { - if (m_activeContent.DockHandler.Form.ContainsFocus) - { - DockPanel.ContentFocusManager.GiveUpFocus(m_activeContent); - } - AnimateWindow(false); - } - - m_activeContent = value; - SetActivePane(); - if (ActivePane != null) - { - ActivePane.ActiveContent = m_activeContent; - } - - if (m_activeContent != null) - { - AnimateWindow(true); - } - - DockPanel.ResumeLayout(); - DockPanel.RefreshAutoHideStrip(); - - SetTimerMouseTrack(); - } - } - - public DockState DockState - { - get { return ActiveContent == null ? DockState.Unknown : ActiveContent.DockHandler.DockState; } - } - - private bool FlagAnimate { get; set; } = true; - - internal bool FlagDragging - { - get { return m_flagDragging; } - set - { - if (m_flagDragging == value) - { - return; - } - - m_flagDragging = value; - SetTimerMouseTrack(); - } - } - - protected virtual Rectangle DisplayingRectangle - { - get - { - Rectangle rect = ClientRectangle; - - // exclude the border and the splitter - if (DockState == DockState.DockBottomAutoHide) - { - rect.Y += 2 + Measures.SplitterSize; - rect.Height -= 2 + Measures.SplitterSize; - } - else if (DockState == DockState.DockRightAutoHide) - { - rect.X += 2 + Measures.SplitterSize; - rect.Width -= 2 + Measures.SplitterSize; - } - else if (DockState == DockState.DockTopAutoHide) - { - rect.Height -= 2 + Measures.SplitterSize; - } - else if (DockState == DockState.DockLeftAutoHide) - { - rect.Width -= 2 + Measures.SplitterSize; - } - - return rect; - } - } - - #endregion - - #region Public methods - - public void RefreshActiveContent() - { - if (ActiveContent == null) - { - return; - } - - if (!DockHelper.IsDockStateAutoHide(ActiveContent.DockHandler.DockState)) - { - FlagAnimate = false; - ActiveContent = null; - FlagAnimate = true; - } - } - - public void RefreshActivePane() - { - SetTimerMouseTrack(); - } - - #endregion - - #region Overrides - - protected override void Dispose(bool disposing) - { - if (disposing) - { - m_timerMouseTrack.Dispose(); - } - base.Dispose(disposing); - } - - protected override void OnLayout(LayoutEventArgs levent) - { - DockPadding.All = 0; - if (DockState == DockState.DockLeftAutoHide) - { - DockPadding.Right = 2; - m_splitter.Dock = DockStyle.Right; - } - else if (DockState == DockState.DockRightAutoHide) - { - DockPadding.Left = 2; - m_splitter.Dock = DockStyle.Left; - } - else if (DockState == DockState.DockTopAutoHide) - { - DockPadding.Bottom = 2; - m_splitter.Dock = DockStyle.Bottom; - } - else if (DockState == DockState.DockBottomAutoHide) - { - DockPadding.Top = 2; - m_splitter.Dock = DockStyle.Top; - } - - Rectangle rectDisplaying = DisplayingRectangle; - Rectangle rectHidden = new Rectangle(-rectDisplaying.Width, rectDisplaying.Y, rectDisplaying.Width, - rectDisplaying.Height); - foreach (Control c in Controls) - { - DockPane pane = c as DockPane; - if (pane == null) - { - continue; - } - - - if (pane == ActivePane) - { - pane.Bounds = rectDisplaying; - } - else - { - pane.Bounds = rectHidden; - } - } - - base.OnLayout(levent); - } - - protected override void OnPaint(PaintEventArgs e) - { - // Draw the border - Graphics g = e.Graphics; - - if (DockState == DockState.DockBottomAutoHide) - { - g.DrawLine(SystemPens.ControlLightLight, 0, 1, ClientRectangle.Right, 1); - } - else if (DockState == DockState.DockRightAutoHide) - { - g.DrawLine(SystemPens.ControlLightLight, 1, 0, 1, ClientRectangle.Bottom); - } - else if (DockState == DockState.DockTopAutoHide) - { - g.DrawLine(SystemPens.ControlDark, 0, ClientRectangle.Height - 2, ClientRectangle.Right, - ClientRectangle.Height - 2); - g.DrawLine(SystemPens.ControlDarkDark, 0, ClientRectangle.Height - 1, ClientRectangle.Right, - ClientRectangle.Height - 1); - } - else if (DockState == DockState.DockLeftAutoHide) - { - g.DrawLine(SystemPens.ControlDark, ClientRectangle.Width - 2, 0, ClientRectangle.Width - 2, - ClientRectangle.Bottom); - g.DrawLine(SystemPens.ControlDarkDark, ClientRectangle.Width - 1, 0, ClientRectangle.Width - 1, - ClientRectangle.Bottom); - } - - base.OnPaint(e); - } - - #endregion - - #region Private Methods - - private void SetActivePane() - { - DockPane value = ActiveContent == null ? null : ActiveContent.DockHandler.Pane; - - if (value == ActivePane) - { - return; - } - - ActivePane = value; - } - - private void AnimateWindow(bool show) - { - if (!FlagAnimate && Visible != show) - { - Visible = show; - return; - } - - Parent.SuspendLayout(); - - Rectangle rectSource = GetRectangle(!show); - Rectangle rectTarget = GetRectangle(show); - int dxLoc, dyLoc; - int dWidth, dHeight; - dxLoc = dyLoc = dWidth = dHeight = 0; - if (DockState == DockState.DockTopAutoHide) - { - dHeight = show ? 1 : -1; - } - else if (DockState == DockState.DockLeftAutoHide) - { - dWidth = show ? 1 : -1; - } - else if (DockState == DockState.DockRightAutoHide) - { - dxLoc = show ? -1 : 1; - dWidth = show ? 1 : -1; - } - else if (DockState == DockState.DockBottomAutoHide) - { - dyLoc = show ? -1 : 1; - dHeight = show ? 1 : -1; - } - - if (show) - { - Bounds = DockPanel.GetAutoHideWindowBounds(new Rectangle(-rectTarget.Width, -rectTarget.Height, - rectTarget.Width, rectTarget.Height)); - if (Visible == false) - { - Visible = true; - } - PerformLayout(); - } - - SuspendLayout(); - - LayoutAnimateWindow(rectSource); - if (Visible == false) - { - Visible = true; - } - - int speedFactor = 1; - int totalPixels = rectSource.Width != rectTarget.Width - ? Math.Abs(rectSource.Width - rectTarget.Width) - : Math.Abs(rectSource.Height - rectTarget.Height); - int remainPixels = totalPixels; - DateTime startingTime = DateTime.Now; - while (rectSource != rectTarget) - { - DateTime startPerMove = DateTime.Now; - - rectSource.X += dxLoc * speedFactor; - rectSource.Y += dyLoc * speedFactor; - rectSource.Width += dWidth * speedFactor; - rectSource.Height += dHeight * speedFactor; - if (Math.Sign(rectTarget.X - rectSource.X) != Math.Sign(dxLoc)) - { - rectSource.X = rectTarget.X; - } - if (Math.Sign(rectTarget.Y - rectSource.Y) != Math.Sign(dyLoc)) - { - rectSource.Y = rectTarget.Y; - } - if (Math.Sign(rectTarget.Width - rectSource.Width) != Math.Sign(dWidth)) - { - rectSource.Width = rectTarget.Width; - } - if (Math.Sign(rectTarget.Height - rectSource.Height) != Math.Sign(dHeight)) - { - rectSource.Height = rectTarget.Height; - } - - LayoutAnimateWindow(rectSource); - if (Parent != null) - { - Parent.Update(); - } - - remainPixels -= speedFactor; - - while (true) - { - TimeSpan time = new TimeSpan(0, 0, 0, 0, ANIMATE_TIME); - TimeSpan elapsedPerMove = DateTime.Now - startPerMove; - TimeSpan elapsedTime = DateTime.Now - startingTime; - if ((int) (time - elapsedTime).TotalMilliseconds <= 0) - { - speedFactor = remainPixels; - break; - } - else - { - speedFactor = remainPixels * (int) elapsedPerMove.TotalMilliseconds / - (int) (time - elapsedTime).TotalMilliseconds; - } - if (speedFactor >= 1) - { - break; - } - } - } - ResumeLayout(); - Parent.ResumeLayout(); - } - - private void LayoutAnimateWindow(Rectangle rect) - { - Bounds = DockPanel.GetAutoHideWindowBounds(rect); - - Rectangle rectClient = ClientRectangle; - - if (DockState == DockState.DockLeftAutoHide) - { - ActivePane.Location = new Point(rectClient.Right - 2 - Measures.SplitterSize - ActivePane.Width, - ActivePane.Location.Y); - } - else if (DockState == DockState.DockTopAutoHide) - { - ActivePane.Location = new Point(ActivePane.Location.X, - rectClient.Bottom - 2 - Measures.SplitterSize - ActivePane.Height); - } - } - - private Rectangle GetRectangle(bool show) - { - if (DockState == DockState.Unknown) - { - return Rectangle.Empty; - } - - Rectangle rect = DockPanel.AutoHideWindowRectangle; - - if (show) - { - return rect; - } - - if (DockState == DockState.DockLeftAutoHide) - { - rect.Width = 0; - } - else if (DockState == DockState.DockRightAutoHide) - { - rect.X += rect.Width; - rect.Width = 0; - } - else if (DockState == DockState.DockTopAutoHide) - { - rect.Height = 0; - } - else - { - rect.Y += rect.Height; - rect.Height = 0; - } - - return rect; - } - - private void SetTimerMouseTrack() - { - if (ActivePane == null || ActivePane.IsActivated || FlagDragging) - { - m_timerMouseTrack.Enabled = false; - return; - } - - // start the timer - int hovertime = SystemInformation.MouseHoverTime; - - // assign a default value 400 in case of setting Timer.Interval invalid value exception - if (hovertime <= 0) - { - hovertime = 400; - } - - m_timerMouseTrack.Interval = 2 * (int) hovertime; - m_timerMouseTrack.Enabled = true; - } - - #endregion - - #region Events handler - - private void TimerMouseTrack_Tick(object sender, EventArgs e) - { - if (IsDisposed) - { - return; - } - - if (ActivePane == null || ActivePane.IsActivated) - { - m_timerMouseTrack.Enabled = false; - return; - } - - DockPane pane = ActivePane; - Point ptMouseInAutoHideWindow = PointToClient(Control.MousePosition); - Point ptMouseInDockPanel = DockPanel.PointToClient(Control.MousePosition); - - Rectangle rectTabStrip = DockPanel.GetTabStripRectangle(pane.DockState); - - if (!ClientRectangle.Contains(ptMouseInAutoHideWindow) && !rectTabStrip.Contains(ptMouseInDockPanel)) - { - ActiveContent = null; - m_timerMouseTrack.Enabled = false; - } - } - - #endregion - - private class SplitterControl : SplitterBase - { - #region Fields - - #endregion - - #region cTor - - public SplitterControl(AutoHideWindowControl autoHideWindow) - { - AutoHideWindow = autoHideWindow; - } - - #endregion - - #region Properties - - private AutoHideWindowControl AutoHideWindow { get; } - - protected override int SplitterSize - { - get { return Measures.SplitterSize; } - } - - #endregion - - #region Overrides - - protected override void StartDrag() - { - AutoHideWindow.DockPanel.BeginDrag(AutoHideWindow, AutoHideWindow.RectangleToScreen(Bounds)); - } - - #endregion - } - - #region ISplitterDragSource Members - - void ISplitterDragSource.BeginDrag(Rectangle rectSplitter) - { - FlagDragging = true; - } - - void ISplitterDragSource.EndDrag() - { - FlagDragging = false; - } - - bool ISplitterDragSource.IsVertical - { - get { return DockState == DockState.DockLeftAutoHide || DockState == DockState.DockRightAutoHide; } - } - - Rectangle ISplitterDragSource.DragLimitBounds - { - get - { - Rectangle rectLimit = DockPanel.DockArea; - - if ((this as ISplitterDragSource).IsVertical) - { - rectLimit.X += MeasurePane.MinSize; - rectLimit.Width -= 2 * MeasurePane.MinSize; - } - else - { - rectLimit.Y += MeasurePane.MinSize; - rectLimit.Height -= 2 * MeasurePane.MinSize; - } - - return DockPanel.RectangleToScreen(rectLimit); - } - } - - void ISplitterDragSource.MoveSplitter(int offset) - { - Rectangle rectDockArea = DockPanel.DockArea; - IDockContent content = ActiveContent; - if (DockState == DockState.DockLeftAutoHide && rectDockArea.Width > 0) - { - if (content.DockHandler.AutoHidePortion < 1) - { - content.DockHandler.AutoHidePortion += (double) offset / (double) rectDockArea.Width; - } - else - { - content.DockHandler.AutoHidePortion = Width + offset; - } - } - else if (DockState == DockState.DockRightAutoHide && rectDockArea.Width > 0) - { - if (content.DockHandler.AutoHidePortion < 1) - { - content.DockHandler.AutoHidePortion -= (double) offset / (double) rectDockArea.Width; - } - else - { - content.DockHandler.AutoHidePortion = Width - offset; - } - } - else if (DockState == DockState.DockBottomAutoHide && rectDockArea.Height > 0) - { - if (content.DockHandler.AutoHidePortion < 1) - { - content.DockHandler.AutoHidePortion -= (double) offset / (double) rectDockArea.Height; - } - else - { - content.DockHandler.AutoHidePortion = Height - offset; - } - } - else if (DockState == DockState.DockTopAutoHide && rectDockArea.Height > 0) - { - if (content.DockHandler.AutoHidePortion < 1) - { - content.DockHandler.AutoHidePortion += (double) offset / (double) rectDockArea.Height; - } - else - { - content.DockHandler.AutoHidePortion = Height + offset; - } - } - } - - #region IDragSource Members - - Control IDragSource.DragControl - { - get { return this; } - } - - #endregion - - #endregion - } - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockPanel.DockDragHandler.cs b/src/WinFormsUI/Docking/DockPanel.DockDragHandler.cs deleted file mode 100644 index 3d57c302..00000000 --- a/src/WinFormsUI/Docking/DockPanel.DockDragHandler.cs +++ /dev/null @@ -1,1073 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.ComponentModel; - -namespace WeifenLuo.WinFormsUI.Docking -{ - partial class DockPanel - { - #region Fields - - private DockDragHandler m_dockDragHandler = null; - - #endregion - - #region Internals - - internal void BeginDrag(IDockDragSource dragSource) - { - GetDockDragHandler().BeginDrag(dragSource); - } - - #endregion - - #region Private Methods - - private DockDragHandler GetDockDragHandler() - { - if (m_dockDragHandler == null) - { - m_dockDragHandler = new DockDragHandler(this); - } - return m_dockDragHandler; - } - - #endregion - - private sealed class DockDragHandler : DragHandler - { - #region Fields - - #endregion - - #region cTor - - public DockDragHandler(DockPanel panel) - : base(panel) - { - } - - #endregion - - #region Properties - - public new IDockDragSource DragSource - { - get { return base.DragSource as IDockDragSource; } - set { base.DragSource = value; } - } - - public DockOutlineBase Outline { get; private set; } - - private DockIndicator Indicator { get; set; } - - private Rectangle FloatOutlineBounds { get; set; } - - #endregion - - #region Public methods - - public void BeginDrag(IDockDragSource dragSource) - { - DragSource = dragSource; - - if (!BeginDrag()) - { - DragSource = null; - return; - } - - Outline = new DockOutline(); - Indicator = new DockIndicator(this); - Indicator.Show(false); - - FloatOutlineBounds = DragSource.BeginDrag(StartMousePosition); - } - - #endregion - - #region Overrides - - protected override void OnDragging() - { - TestDrop(); - } - - protected override void OnEndDrag(bool abort) - { - DockPanel.SuspendLayout(true); - - Outline.Close(); - Indicator.Close(); - - EndDrag(abort); - - // Queue a request to layout all children controls - DockPanel.PerformMdiClientLayout(); - - DockPanel.ResumeLayout(true, true); - - DragSource = null; - } - - #endregion - - #region Private Methods - - private void TestDrop() - { - Outline.FlagTestDrop = false; - - Indicator.FullPanelEdge = (Control.ModifierKeys & Keys.Shift) != 0; - - if ((Control.ModifierKeys & Keys.Control) == 0) - { - Indicator.TestDrop(); - - if (!Outline.FlagTestDrop) - { - DockPane pane = DockHelper.PaneAtPoint(Control.MousePosition, DockPanel); - if (pane != null && DragSource.IsDockStateValid(pane.DockState)) - { - pane.TestDrop(DragSource, Outline); - } - } - - if (!Outline.FlagTestDrop && DragSource.IsDockStateValid(DockState.Float)) - { - FloatWindow floatWindow = DockHelper.FloatWindowAtPoint(Control.MousePosition, DockPanel); - if (floatWindow != null) - { - floatWindow.TestDrop(DragSource, Outline); - } - } - } - else - { - Indicator.DockPane = DockHelper.PaneAtPoint(Control.MousePosition, DockPanel); - } - - if (!Outline.FlagTestDrop) - { - if (DragSource.IsDockStateValid(DockState.Float)) - { - Rectangle rect = FloatOutlineBounds; - rect.Offset(Control.MousePosition.X - StartMousePosition.X, - Control.MousePosition.Y - StartMousePosition.Y); - Outline.Show(rect); - } - } - - if (!Outline.FlagTestDrop) - { - Cursor.Current = Cursors.No; - Outline.Show(); - } - else - { - Cursor.Current = DragControl.Cursor; - } - } - - private void EndDrag(bool abort) - { - if (abort) - { - return; - } - - if (!Outline.FloatWindowBounds.IsEmpty) - { - DragSource.FloatAt(Outline.FloatWindowBounds); - } - else if (Outline.DockTo is DockPane) - { - DockPane pane = Outline.DockTo as DockPane; - DragSource.DockTo(pane, Outline.Dock, Outline.ContentIndex); - } - else if (Outline.DockTo is DockPanel) - { - DockPanel panel = Outline.DockTo as DockPanel; - panel.UpdateDockWindowZOrder(Outline.Dock, Outline.FlagFullEdge); - DragSource.DockTo(panel, Outline.Dock); - } - } - - #endregion - - private class DockIndicator : DragForm - { - #region Fields - - #region consts - - private readonly int _PanelIndicatorMargin = 10; - - #endregion - - private DockPane m_dockPane = null; - - private bool m_fullPanelEdge = false; - - private IHitTest m_hitTest = null; - - private PaneIndicator m_paneDiamond = null; - - private PanelIndicator m_panelBottom = null; - - private PanelIndicator m_panelFill = null; - - private PanelIndicator m_panelLeft = null; - - private PanelIndicator m_panelRight = null; - - private PanelIndicator m_panelTop = null; - - #endregion - - #region cTor - - public DockIndicator(DockDragHandler dragHandler) - { - DragHandler = dragHandler; - Controls.AddRange(new Control[] - { - PaneDiamond, - PanelLeft, - PanelRight, - PanelTop, - PanelBottom, - PanelFill - }); - Region = new Region(Rectangle.Empty); - } - - #endregion - - #region Properties - - private PaneIndicator PaneDiamond - { - get - { - if (m_paneDiamond == null) - { - m_paneDiamond = new PaneIndicator(); - } - - return m_paneDiamond; - } - } - - private PanelIndicator PanelLeft - { - get - { - if (m_panelLeft == null) - { - m_panelLeft = new PanelIndicator(DockStyle.Left); - } - - return m_panelLeft; - } - } - - private PanelIndicator PanelRight - { - get - { - if (m_panelRight == null) - { - m_panelRight = new PanelIndicator(DockStyle.Right); - } - - return m_panelRight; - } - } - - private PanelIndicator PanelTop - { - get - { - if (m_panelTop == null) - { - m_panelTop = new PanelIndicator(DockStyle.Top); - } - - return m_panelTop; - } - } - - private PanelIndicator PanelBottom - { - get - { - if (m_panelBottom == null) - { - m_panelBottom = new PanelIndicator(DockStyle.Bottom); - } - - return m_panelBottom; - } - } - - private PanelIndicator PanelFill - { - get - { - if (m_panelFill == null) - { - m_panelFill = new PanelIndicator(DockStyle.Fill); - } - - return m_panelFill; - } - } - - public bool FullPanelEdge - { - get { return m_fullPanelEdge; } - set - { - if (m_fullPanelEdge == value) - { - return; - } - - m_fullPanelEdge = value; - RefreshChanges(); - } - } - - public DockDragHandler DragHandler { get; } - - public DockPanel DockPanel - { - get { return DragHandler.DockPanel; } - } - - public DockPane DockPane - { - get { return m_dockPane; } - internal set - { - if (m_dockPane == value) - { - return; - } - - DockPane oldDisplayingPane = DisplayingPane; - m_dockPane = value; - if (oldDisplayingPane != DisplayingPane) - { - RefreshChanges(); - } - } - } - - private IHitTest HitTestResult - { - get { return m_hitTest; } - set - { - if (m_hitTest == value) - { - return; - } - - if (m_hitTest != null) - { - m_hitTest.Status = DockStyle.None; - } - - m_hitTest = value; - } - } - - private DockPane DisplayingPane - { - get { return ShouldPaneDiamondVisible() ? DockPane : null; } - } - - #endregion - - #region Public methods - - public override void Show(bool bActivate) - { - base.Show(bActivate); - Bounds = SystemInformation.VirtualScreen; - RefreshChanges(); - } - - public void TestDrop() - { - Point pt = Control.MousePosition; - DockPane = DockHelper.PaneAtPoint(pt, DockPanel); - - if (TestDrop(PanelLeft, pt) != DockStyle.None) - { - HitTestResult = PanelLeft; - } - else if (TestDrop(PanelRight, pt) != DockStyle.None) - { - HitTestResult = PanelRight; - } - else if (TestDrop(PanelTop, pt) != DockStyle.None) - { - HitTestResult = PanelTop; - } - else if (TestDrop(PanelBottom, pt) != DockStyle.None) - { - HitTestResult = PanelBottom; - } - else if (TestDrop(PanelFill, pt) != DockStyle.None) - { - HitTestResult = PanelFill; - } - else if (TestDrop(PaneDiamond, pt) != DockStyle.None) - { - HitTestResult = PaneDiamond; - } - else - { - HitTestResult = null; - } - - if (HitTestResult != null) - { - if (HitTestResult is PaneIndicator) - { - DragHandler.Outline.Show(DockPane, HitTestResult.Status); - } - else - { - DragHandler.Outline.Show(DockPanel, HitTestResult.Status, FullPanelEdge); - } - } - } - - #endregion - - #region Private Methods - - private void RefreshChanges() - { - Region region = new Region(Rectangle.Empty); - Rectangle rectDockArea = FullPanelEdge ? DockPanel.DockArea : DockPanel.DocumentWindowBounds; - - rectDockArea = RectangleToClient(DockPanel.RectangleToScreen(rectDockArea)); - if (ShouldPanelIndicatorVisible(DockState.DockLeft)) - { - PanelLeft.Location = new Point(rectDockArea.X + _PanelIndicatorMargin, - rectDockArea.Y + (rectDockArea.Height - PanelRight.Height) / 2); - PanelLeft.Visible = true; - region.Union(PanelLeft.Bounds); - } - else - { - PanelLeft.Visible = false; - } - - if (ShouldPanelIndicatorVisible(DockState.DockRight)) - { - PanelRight.Location = - new Point(rectDockArea.X + rectDockArea.Width - PanelRight.Width - _PanelIndicatorMargin, - rectDockArea.Y + (rectDockArea.Height - PanelRight.Height) / 2); - PanelRight.Visible = true; - region.Union(PanelRight.Bounds); - } - else - { - PanelRight.Visible = false; - } - - if (ShouldPanelIndicatorVisible(DockState.DockTop)) - { - PanelTop.Location = new Point(rectDockArea.X + (rectDockArea.Width - PanelTop.Width) / 2, - rectDockArea.Y + _PanelIndicatorMargin); - PanelTop.Visible = true; - region.Union(PanelTop.Bounds); - } - else - { - PanelTop.Visible = false; - } - - if (ShouldPanelIndicatorVisible(DockState.DockBottom)) - { - PanelBottom.Location = new Point(rectDockArea.X + (rectDockArea.Width - PanelBottom.Width) / 2, - rectDockArea.Y + rectDockArea.Height - PanelBottom.Height - _PanelIndicatorMargin); - PanelBottom.Visible = true; - region.Union(PanelBottom.Bounds); - } - else - { - PanelBottom.Visible = false; - } - - if (ShouldPanelIndicatorVisible(DockState.Document)) - { - Rectangle rectDocumentWindow = - RectangleToClient(DockPanel.RectangleToScreen(DockPanel.DocumentWindowBounds)); - PanelFill.Location = - new Point(rectDocumentWindow.X + (rectDocumentWindow.Width - PanelFill.Width) / 2, - rectDocumentWindow.Y + (rectDocumentWindow.Height - PanelFill.Height) / 2); - PanelFill.Visible = true; - region.Union(PanelFill.Bounds); - } - else - { - PanelFill.Visible = false; - } - - if (ShouldPaneDiamondVisible()) - { - Rectangle rect = RectangleToClient(DockPane.RectangleToScreen(DockPane.ClientRectangle)); - PaneDiamond.Location = new Point(rect.Left + (rect.Width - PaneDiamond.Width) / 2, - rect.Top + (rect.Height - PaneDiamond.Height) / 2); - PaneDiamond.Visible = true; - using (GraphicsPath graphicsPath = PaneIndicator.DisplayingGraphicsPath.Clone() as GraphicsPath) - { - Point[] pts = new Point[] - { - new Point(PaneDiamond.Left, PaneDiamond.Top), - new Point(PaneDiamond.Right, PaneDiamond.Top), - new Point(PaneDiamond.Left, PaneDiamond.Bottom) - }; - using (Matrix matrix = new Matrix(PaneDiamond.ClientRectangle, pts)) - { - graphicsPath.Transform(matrix); - } - region.Union(graphicsPath); - } - } - else - { - PaneDiamond.Visible = false; - } - - Region = region; - } - - private bool ShouldPanelIndicatorVisible(DockState dockState) - { - if (!Visible) - { - return false; - } - - if (DockPanel.DockWindows[dockState].Visible) - { - return false; - } - - return DragHandler.DragSource.IsDockStateValid(dockState); - } - - private bool ShouldPaneDiamondVisible() - { - if (DockPane == null) - { - return false; - } - - if (!DockPanel.AllowEndUserNestedDocking) - { - return false; - } - - return DragHandler.DragSource.CanDockTo(DockPane); - } - - private static DockStyle TestDrop(IHitTest hitTest, Point pt) - { - return hitTest.Status = hitTest.HitTest(pt); - } - - #endregion - - #region IHitTest - - private interface IHitTest - { - #region Properties - - DockStyle Status { get; set; } - - #endregion - - #region Public methods - - DockStyle HitTest(Point pt); - - #endregion - } - - #endregion - - #region PanelIndicator - - private class PanelIndicator : PictureBox, IHitTest - { - #region Fields - - private static readonly Image _imagePanelLeft = Resources.DockIndicator_PanelLeft; - private static readonly Image _imagePanelRight = Resources.DockIndicator_PanelRight; - private static readonly Image _imagePanelTop = Resources.DockIndicator_PanelTop; - private static readonly Image _imagePanelBottom = Resources.DockIndicator_PanelBottom; - private static readonly Image _imagePanelFill = Resources.DockIndicator_PanelFill; - private static readonly Image _imagePanelLeftActive = Resources.DockIndicator_PanelLeft_Active; - private static readonly Image _imagePanelRightActive = Resources.DockIndicator_PanelRight_Active; - private static readonly Image _imagePanelTopActive = Resources.DockIndicator_PanelTop_Active; - private static readonly Image _imagePanelBottomActive = Resources.DockIndicator_PanelBottom_Active; - private static readonly Image _imagePanelFillActive = Resources.DockIndicator_PanelFill_Active; - - private bool m_isActivated = false; - - private DockStyle m_status; - - #endregion - - #region cTor - - public PanelIndicator(DockStyle dockStyle) - { - DockStyle = dockStyle; - SizeMode = PictureBoxSizeMode.AutoSize; - Image = ImageInactive; - } - - #endregion - - #region Properties - - private DockStyle DockStyle { get; } - - public DockStyle Status - { - get { return m_status; } - set - { - if (value != DockStyle && value != DockStyle.None) - { - throw new InvalidEnumArgumentException(); - } - - if (m_status == value) - { - return; - } - - m_status = value; - IsActivated = m_status != DockStyle.None; - } - } - - private Image ImageInactive - { - get - { - if (DockStyle == DockStyle.Left) - { - return _imagePanelLeft; - } - else if (DockStyle == DockStyle.Right) - { - return _imagePanelRight; - } - else if (DockStyle == DockStyle.Top) - { - return _imagePanelTop; - } - else if (DockStyle == DockStyle.Bottom) - { - return _imagePanelBottom; - } - else if (DockStyle == DockStyle.Fill) - { - return _imagePanelFill; - } - else - { - return null; - } - } - } - - private Image ImageActive - { - get - { - if (DockStyle == DockStyle.Left) - { - return _imagePanelLeftActive; - } - else if (DockStyle == DockStyle.Right) - { - return _imagePanelRightActive; - } - else if (DockStyle == DockStyle.Top) - { - return _imagePanelTopActive; - } - else if (DockStyle == DockStyle.Bottom) - { - return _imagePanelBottomActive; - } - else if (DockStyle == DockStyle.Fill) - { - return _imagePanelFillActive; - } - else - { - return null; - } - } - } - - private bool IsActivated - { - get { return m_isActivated; } - set - { - m_isActivated = value; - Image = IsActivated ? ImageActive : ImageInactive; - } - } - - #endregion - - #region Public methods - - public DockStyle HitTest(Point pt) - { - return this.Visible && ClientRectangle.Contains(PointToClient(pt)) ? DockStyle : DockStyle.None; - } - - #endregion - } - - #endregion PanelIndicator - - #region PaneIndicator - - private class PaneIndicator : PictureBox, IHitTest - { - #region Fields - - private static readonly Bitmap _bitmapPaneDiamond = Resources.DockIndicator_PaneDiamond; - private static readonly Bitmap _bitmapPaneDiamondLeft = Resources.DockIndicator_PaneDiamond_Left; - private static readonly Bitmap _bitmapPaneDiamondRight = Resources.DockIndicator_PaneDiamond_Right; - private static readonly Bitmap _bitmapPaneDiamondTop = Resources.DockIndicator_PaneDiamond_Top; - - private static readonly Bitmap _bitmapPaneDiamondBottom = Resources.DockIndicator_PaneDiamond_Bottom - ; - - private static readonly Bitmap _bitmapPaneDiamondFill = Resources.DockIndicator_PaneDiamond_Fill; - - private static readonly Bitmap _bitmapPaneDiamondHotSpot = - Resources.DockIndicator_PaneDiamond_HotSpot; - - private static readonly Bitmap _bitmapPaneDiamondHotSpotIndex = - Resources.DockIndicator_PaneDiamond_HotSpotIndex; - - private static readonly HotSpotIndex[] _hotSpots = new HotSpotIndex[] - { - new HotSpotIndex(1, 0, DockStyle.Top), - new HotSpotIndex(0, 1, DockStyle.Left), - new HotSpotIndex(1, 1, DockStyle.Fill), - new HotSpotIndex(2, 1, DockStyle.Right), - new HotSpotIndex(1, 2, DockStyle.Bottom) - }; - - private DockStyle m_status = DockStyle.None; - - #endregion - - #region cTor - - public PaneIndicator() - { - SizeMode = PictureBoxSizeMode.AutoSize; - Image = _bitmapPaneDiamond; - Region = new Region(DisplayingGraphicsPath); - } - - #endregion - - #region Properties - - public static GraphicsPath DisplayingGraphicsPath { get; } = - DrawHelper.CalculateGraphicsPathFromBitmap(_bitmapPaneDiamond); - - public DockStyle Status - { - get { return m_status; } - set - { - m_status = value; - if (m_status == DockStyle.None) - { - Image = _bitmapPaneDiamond; - } - else if (m_status == DockStyle.Left) - { - Image = _bitmapPaneDiamondLeft; - } - else if (m_status == DockStyle.Right) - { - Image = _bitmapPaneDiamondRight; - } - else if (m_status == DockStyle.Top) - { - Image = _bitmapPaneDiamondTop; - } - else if (m_status == DockStyle.Bottom) - { - Image = _bitmapPaneDiamondBottom; - } - else if (m_status == DockStyle.Fill) - { - Image = _bitmapPaneDiamondFill; - } - } - } - - #endregion - - #region Public methods - - public DockStyle HitTest(Point pt) - { - if (!Visible) - { - return DockStyle.None; - } - - pt = PointToClient(pt); - if (!ClientRectangle.Contains(pt)) - { - return DockStyle.None; - } - - for (int i = _hotSpots.GetLowerBound(0); i <= _hotSpots.GetUpperBound(0); i++) - { - if (_bitmapPaneDiamondHotSpot.GetPixel(pt.X, pt.Y) == - _bitmapPaneDiamondHotSpotIndex.GetPixel(_hotSpots[i].X, _hotSpots[i].Y)) - { - return _hotSpots[i].DockStyle; - } - } - - return DockStyle.None; - } - - #endregion - - private struct HotSpotIndex - { - public HotSpotIndex(int x, int y, DockStyle dockStyle) - { - X = x; - Y = y; - DockStyle = dockStyle; - } - - public int X { get; } - - public int Y { get; } - - public DockStyle DockStyle { get; } - } - } - - #endregion PaneIndicator - } - - private class DockOutline : DockOutlineBase - { - #region Fields - - #endregion - - #region cTor - - public DockOutline() - { - DragForm = new DragForm(); - SetDragForm(Rectangle.Empty); - DragForm.BackColor = SystemColors.ActiveCaption; - DragForm.Opacity = 0.5; - DragForm.Show(false); - } - - #endregion - - #region Properties - - private DragForm DragForm { get; } - - #endregion - - #region Overrides - - protected override void OnShow() - { - CalculateRegion(); - } - - protected override void OnClose() - { - DragForm.Close(); - } - - #endregion - - #region Private Methods - - private void CalculateRegion() - { - if (SameAsOldValue) - { - return; - } - - if (!FloatWindowBounds.IsEmpty) - { - SetOutline(FloatWindowBounds); - } - else if (DockTo is DockPanel) - { - SetOutline(DockTo as DockPanel, Dock, ContentIndex != 0); - } - else if (DockTo is DockPane) - { - SetOutline(DockTo as DockPane, Dock, ContentIndex); - } - else - { - SetOutline(); - } - } - - private void SetOutline() - { - SetDragForm(Rectangle.Empty); - } - - private void SetOutline(Rectangle floatWindowBounds) - { - SetDragForm(floatWindowBounds); - } - - private void SetOutline(DockPanel dockPanel, DockStyle dock, bool fullPanelEdge) - { - Rectangle rect = fullPanelEdge ? dockPanel.DockArea : dockPanel.DocumentWindowBounds; - rect.Location = dockPanel.PointToScreen(rect.Location); - if (dock == DockStyle.Top) - { - int height = dockPanel.GetDockWindowSize(DockState.DockTop); - rect = new Rectangle(rect.X, rect.Y, rect.Width, height); - } - else if (dock == DockStyle.Bottom) - { - int height = dockPanel.GetDockWindowSize(DockState.DockBottom); - rect = new Rectangle(rect.X, rect.Bottom - height, rect.Width, height); - } - else if (dock == DockStyle.Left) - { - int width = dockPanel.GetDockWindowSize(DockState.DockLeft); - rect = new Rectangle(rect.X, rect.Y, width, rect.Height); - } - else if (dock == DockStyle.Right) - { - int width = dockPanel.GetDockWindowSize(DockState.DockRight); - rect = new Rectangle(rect.Right - width, rect.Y, width, rect.Height); - } - else if (dock == DockStyle.Fill) - { - rect = dockPanel.DocumentWindowBounds; - rect.Location = dockPanel.PointToScreen(rect.Location); - } - - SetDragForm(rect); - } - - private void SetOutline(DockPane pane, DockStyle dock, int contentIndex) - { - if (dock != DockStyle.Fill) - { - Rectangle rect = pane.DisplayingRectangle; - if (dock == DockStyle.Right) - { - rect.X += rect.Width / 2; - } - if (dock == DockStyle.Bottom) - { - rect.Y += rect.Height / 2; - } - if (dock == DockStyle.Left || dock == DockStyle.Right) - { - rect.Width -= rect.Width / 2; - } - if (dock == DockStyle.Top || dock == DockStyle.Bottom) - { - rect.Height -= rect.Height / 2; - } - rect.Location = pane.PointToScreen(rect.Location); - - SetDragForm(rect); - } - else if (contentIndex == -1) - { - Rectangle rect = pane.DisplayingRectangle; - rect.Location = pane.PointToScreen(rect.Location); - SetDragForm(rect); - } - else - { - using (GraphicsPath path = pane.TabStripControl.GetOutline(contentIndex)) - { - RectangleF rectF = path.GetBounds(); - Rectangle rect = new Rectangle((int) rectF.X, (int) rectF.Y, (int) rectF.Width, - (int) rectF.Height); - using (Matrix matrix = new Matrix(rect, - new Point[] {new Point(0, 0), new Point(rect.Width, 0), new Point(0, rect.Height)})) - { - path.Transform(matrix); - } - Region region = new Region(path); - SetDragForm(rect, region); - } - } - } - - private void SetDragForm(Rectangle rect) - { - DragForm.Bounds = rect; - if (rect == Rectangle.Empty) - { - DragForm.Region = new Region(Rectangle.Empty); - } - else if (DragForm.Region != null) - { - DragForm.Region = null; - } - } - - private void SetDragForm(Rectangle rect, Region region) - { - DragForm.Bounds = rect; - DragForm.Region = region; - } - - #endregion - } - } - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockPanel.DragHandler.cs b/src/WinFormsUI/Docking/DockPanel.DragHandler.cs deleted file mode 100644 index eb29365b..00000000 --- a/src/WinFormsUI/Docking/DockPanel.DragHandler.cs +++ /dev/null @@ -1,169 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.ComponentModel; - -namespace WeifenLuo.WinFormsUI.Docking -{ - partial class DockPanel - { - /// - /// DragHandlerBase is the base class for drag handlers. The derived class should: - /// 1. Define its public method BeginDrag. From within this public BeginDrag method, - /// DragHandlerBase.BeginDrag should be called to initialize the mouse capture - /// and message filtering. - /// 2. Override the OnDragging and OnEndDrag methods. - /// - private abstract class DragHandlerBase : NativeWindow, IMessageFilter - { - #region Fields - - #endregion - - #region cTor - - protected DragHandlerBase() - { - } - - #endregion - - #region Properties - - protected abstract Control DragControl { get; } - - protected Point StartMousePosition { get; private set; } = Point.Empty; - - #endregion - - #region Overrides - - protected sealed override void WndProc(ref Message m) - { - if (m.Msg == (int) Win32.Msgs.WM_CANCELMODE || m.Msg == (int) Win32.Msgs.WM_CAPTURECHANGED) - { - EndDrag(true); - } - - base.WndProc(ref m); - } - - #endregion - - #region Private Methods - - private void EndDrag(bool abort) - { - ReleaseHandle(); - Application.RemoveMessageFilter(this); - DragControl.FindForm().Capture = false; - - OnEndDrag(abort); - } - - bool IMessageFilter.PreFilterMessage(ref Message m) - { - if (m.Msg == (int) Win32.Msgs.WM_MOUSEMOVE) - { - OnDragging(); - } - else if (m.Msg == (int) Win32.Msgs.WM_LBUTTONUP) - { - EndDrag(false); - } - else if (m.Msg == (int) Win32.Msgs.WM_CAPTURECHANGED) - { - EndDrag(true); - } - else if (m.Msg == (int) Win32.Msgs.WM_KEYDOWN && (int) m.WParam == (int) Keys.Escape) - { - EndDrag(true); - } - - return OnPreFilterMessage(ref m); - } - - #endregion - - protected bool BeginDrag() - { - // Avoid re-entrance; - lock (this) - { - if (DragControl == null) - { - return false; - } - - StartMousePosition = Control.MousePosition; - - if (!NativeMethods.DragDetect(DragControl.Handle, StartMousePosition)) - { - return false; - } - - DragControl.FindForm().Capture = true; - AssignHandle(DragControl.FindForm().Handle); - Application.AddMessageFilter(this); - return true; - } - } - - protected abstract void OnDragging(); - - protected abstract void OnEndDrag(bool abort); - - protected virtual bool OnPreFilterMessage(ref Message m) - { - return false; - } - } - - private abstract class DragHandler : DragHandlerBase - { - #region Fields - - #endregion - - #region cTor - - protected DragHandler(DockPanel dockPanel) - { - DockPanel = dockPanel; - } - - #endregion - - #region Properties - - public DockPanel DockPanel { get; } - - protected IDragSource DragSource { get; set; } - - protected sealed override Control DragControl - { - get { return DragSource == null ? null : DragSource.DragControl; } - } - - #endregion - - #region Overrides - - protected sealed override bool OnPreFilterMessage(ref Message m) - { - if ((m.Msg == (int) Win32.Msgs.WM_KEYDOWN || m.Msg == (int) Win32.Msgs.WM_KEYUP) && - ((int) m.WParam == (int) Keys.ControlKey || (int) m.WParam == (int) Keys.ShiftKey)) - { - OnDragging(); - } - - return base.OnPreFilterMessage(ref m); - } - - #endregion - } - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockPanel.FocusManager.cs b/src/WinFormsUI/Docking/DockPanel.FocusManager.cs deleted file mode 100644 index 1c425557..00000000 --- a/src/WinFormsUI/Docking/DockPanel.FocusManager.cs +++ /dev/null @@ -1,731 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.ComponentModel; -using System.Runtime.InteropServices; -using System.Windows.Forms; -using System.Diagnostics.CodeAnalysis; - -namespace WeifenLuo.WinFormsUI.Docking -{ - internal interface IContentFocusManager - { - #region Public methods - - void Activate(IDockContent content); - void GiveUpFocus(IDockContent content); - void AddToList(IDockContent content); - void RemoveFromList(IDockContent content); - - #endregion - } - - partial class DockPanel - { - #region Fields - - private static readonly object ActiveDocumentChangedEvent = new object(); - - private static readonly object ActiveContentChangedEvent = new object(); - - private static readonly object ActivePaneChangedEvent = new object(); - - #endregion - - #region Events - - [LocalizedCategory("Category_PropertyChanged")] - [LocalizedDescription("DockPanel_ActiveDocumentChanged_Description")] - public event EventHandler ActiveDocumentChanged - { - add { Events.AddHandler(ActiveDocumentChangedEvent, value); } - remove { Events.RemoveHandler(ActiveDocumentChangedEvent, value); } - } - - [LocalizedCategory("Category_PropertyChanged")] - [LocalizedDescription("DockPanel_ActiveContentChanged_Description")] - public event EventHandler ActiveContentChanged - { - add { Events.AddHandler(ActiveContentChangedEvent, value); } - remove { Events.RemoveHandler(ActiveContentChangedEvent, value); } - } - - [LocalizedCategory("Category_PropertyChanged")] - [LocalizedDescription("DockPanel_ActivePaneChanged_Description")] - public event EventHandler ActivePaneChanged - { - add { Events.AddHandler(ActivePaneChangedEvent, value); } - remove { Events.RemoveHandler(ActivePaneChangedEvent, value); } - } - - #endregion - - #region Properties - - private IFocusManager FocusManager - { - get { return m_focusManager; } - } - - internal IContentFocusManager ContentFocusManager - { - get { return m_focusManager; } - } - - [Browsable(false)] - public IDockContent ActiveContent - { - get { return FocusManager.ActiveContent; } - } - - [Browsable(false)] - public DockPane ActivePane - { - get { return FocusManager.ActivePane; } - } - - [Browsable(false)] - public IDockContent ActiveDocument - { - get { return FocusManager.ActiveDocument; } - } - - [Browsable(false)] - public DockPane ActiveDocumentPane - { - get { return FocusManager.ActiveDocumentPane; } - } - - #endregion - - #region Internals - - internal void SaveFocus() - { - DummyControl.Focus(); - } - - #endregion - - protected virtual void OnActiveDocumentChanged(EventArgs e) - { - EventHandler handler = (EventHandler) Events[ActiveDocumentChangedEvent]; - if (handler != null) - { - handler(this, e); - } - } - - protected void OnActiveContentChanged(EventArgs e) - { - EventHandler handler = (EventHandler) Events[ActiveContentChangedEvent]; - if (handler != null) - { - handler(this, e); - } - } - - protected virtual void OnActivePaneChanged(EventArgs e) - { - EventHandler handler = (EventHandler) Events[ActivePaneChangedEvent]; - if (handler != null) - { - handler(this, e); - } - } - - private interface IFocusManager - { - #region Properties - - bool IsFocusTrackingSuspended { get; } - IDockContent ActiveContent { get; } - DockPane ActivePane { get; } - IDockContent ActiveDocument { get; } - DockPane ActiveDocumentPane { get; } - - #endregion - - #region Public methods - - void SuspendFocusTracking(); - void ResumeFocusTracking(); - - #endregion - } - - private class FocusManagerImpl : Component, IContentFocusManager, IFocusManager - { - #region Fields - - private int m_countSuspendFocusTracking = 0; - - private bool m_disposed = false; - - private readonly LocalWindowsHook.HookEventHandler m_hookEventHandler; - - private readonly LocalWindowsHook m_localWindowsHook; - - #endregion - - #region cTor - - public FocusManagerImpl(DockPanel dockPanel) - { - DockPanel = dockPanel; - m_localWindowsHook = new LocalWindowsHook(Win32.HookType.WH_CALLWNDPROCRET); - m_hookEventHandler = new LocalWindowsHook.HookEventHandler(HookEventHandler); - m_localWindowsHook.HookInvoked += m_hookEventHandler; - m_localWindowsHook.Install(); - } - - #endregion - - #region Properties - - public DockPanel DockPanel { get; } - - private IDockContent ContentActivating { get; set; } = null; - - private List ListContent { get; } = new List(); - - private IDockContent LastActiveContent { get; set; } = null; - - public bool IsFocusTrackingSuspended - { - get { return m_countSuspendFocusTracking != 0; } - } - - private bool InRefreshActiveWindow { get; set; } = false; - - public DockPane ActivePane { get; private set; } = null; - - public IDockContent ActiveContent { get; private set; } = null; - - public DockPane ActiveDocumentPane { get; private set; } = null; - - public IDockContent ActiveDocument { get; private set; } = null; - - #endregion - - #region Public methods - - public void Activate(IDockContent content) - { - if (IsFocusTrackingSuspended) - { - ContentActivating = content; - return; - } - - if (content == null) - { - return; - } - DockContentHandler handler = content.DockHandler; - if (handler.Form.IsDisposed) - { - return; // Should not reach here, but better than throwing an exception - } - if (ContentContains(content, handler.ActiveWindowHandle)) - { - NativeMethods.SetFocus(handler.ActiveWindowHandle); - } - if (!handler.Form.ContainsFocus) - { - if (!handler.Form.SelectNextControl(handler.Form.ActiveControl, true, true, true, true)) - // Since DockContent Form is not selectalbe, use Win32 SetFocus instead - { - NativeMethods.SetFocus(handler.Form.Handle); - } - } - } - - public void AddToList(IDockContent content) - { - if (ListContent.Contains(content) || IsInActiveList(content)) - { - return; - } - - ListContent.Add(content); - } - - public void RemoveFromList(IDockContent content) - { - if (IsInActiveList(content)) - { - RemoveFromActiveList(content); - } - if (ListContent.Contains(content)) - { - ListContent.Remove(content); - } - } - - public void GiveUpFocus(IDockContent content) - { - DockContentHandler handler = content.DockHandler; - if (!handler.Form.ContainsFocus) - { - return; - } - - if (IsFocusTrackingSuspended) - { - DockPanel.DummyControl.Focus(); - } - - if (LastActiveContent == content) - { - IDockContent prev = handler.PreviousActive; - if (prev != null) - { - Activate(prev); - } - else if (ListContent.Count > 0) - { - Activate(ListContent[ListContent.Count - 1]); - } - } - else if (LastActiveContent != null) - { - Activate(LastActiveContent); - } - else if (ListContent.Count > 0) - { - Activate(ListContent[ListContent.Count - 1]); - } - } - - public void SuspendFocusTracking() - { - m_countSuspendFocusTracking++; - m_localWindowsHook.HookInvoked -= m_hookEventHandler; - } - - public void ResumeFocusTracking() - { - if (m_countSuspendFocusTracking > 0) - { - m_countSuspendFocusTracking--; - } - - if (m_countSuspendFocusTracking == 0) - { - if (ContentActivating != null) - { - Activate(ContentActivating); - ContentActivating = null; - } - m_localWindowsHook.HookInvoked += m_hookEventHandler; - if (!InRefreshActiveWindow) - { - RefreshActiveWindow(); - } - } - } - - #endregion - - #region Internals - - internal void SetActiveContent() - { - IDockContent value = ActivePane == null ? null : ActivePane.ActiveContent; - - if (ActiveContent == value) - { - return; - } - - if (ActiveContent != null) - { - ActiveContent.DockHandler.IsActivated = false; - } - - ActiveContent = value; - - if (ActiveContent != null) - { - ActiveContent.DockHandler.IsActivated = true; - if (!DockHelper.IsDockStateAutoHide(ActiveContent.DockHandler.DockState)) - { - AddLastToActiveList(ActiveContent); - } - } - } - - #endregion - - #region Overrides - - protected override void Dispose(bool disposing) - { - lock (this) - { - if (!m_disposed && disposing) - { - m_localWindowsHook.Dispose(); - m_disposed = true; - } - - base.Dispose(disposing); - } - } - - #endregion - - #region Private Methods - - private bool IsInActiveList(IDockContent content) - { - return !(content.DockHandler.NextActive == null && LastActiveContent != content); - } - - private void AddLastToActiveList(IDockContent content) - { - IDockContent last = LastActiveContent; - if (last == content) - { - return; - } - - DockContentHandler handler = content.DockHandler; - - if (IsInActiveList(content)) - { - RemoveFromActiveList(content); - } - - handler.PreviousActive = last; - handler.NextActive = null; - LastActiveContent = content; - if (last != null) - { - last.DockHandler.NextActive = LastActiveContent; - } - } - - private void RemoveFromActiveList(IDockContent content) - { - if (LastActiveContent == content) - { - LastActiveContent = content.DockHandler.PreviousActive; - } - - IDockContent prev = content.DockHandler.PreviousActive; - IDockContent next = content.DockHandler.NextActive; - if (prev != null) - { - prev.DockHandler.NextActive = next; - } - if (next != null) - { - next.DockHandler.PreviousActive = prev; - } - - content.DockHandler.PreviousActive = null; - content.DockHandler.NextActive = null; - } - - private static bool ContentContains(IDockContent content, IntPtr hWnd) - { - Control control = Control.FromChildHandle(hWnd); - for (Control parent = control; parent != null; parent = parent.Parent) - { - if (parent == content.DockHandler.Form) - { - return true; - } - } - - return false; - } - - private DockPane GetPaneFromHandle(IntPtr hWnd) - { - Control control = Control.FromChildHandle(hWnd); - - IDockContent content = null; - DockPane pane = null; - for (; control != null; control = control.Parent) - { - content = control as IDockContent; - if (content != null) - { - content.DockHandler.ActiveWindowHandle = hWnd; - } - - if (content != null && content.DockHandler.DockPanel == DockPanel) - { - return content.DockHandler.Pane; - } - - pane = control as DockPane; - if (pane != null && pane.DockPanel == DockPanel) - { - break; - } - } - - return pane; - } - - private void RefreshActiveWindow() - { - SuspendFocusTracking(); - InRefreshActiveWindow = true; - - DockPane oldActivePane = ActivePane; - IDockContent oldActiveContent = ActiveContent; - IDockContent oldActiveDocument = ActiveDocument; - - SetActivePane(); - SetActiveContent(); - SetActiveDocumentPane(); - SetActiveDocument(); - DockPanel.AutoHideWindow.RefreshActivePane(); - - ResumeFocusTracking(); - InRefreshActiveWindow = false; - - if (oldActiveContent != ActiveContent) - { - DockPanel.OnActiveContentChanged(EventArgs.Empty); - } - if (oldActiveDocument != ActiveDocument) - { - DockPanel.OnActiveDocumentChanged(EventArgs.Empty); - } - if (oldActivePane != ActivePane) - { - DockPanel.OnActivePaneChanged(EventArgs.Empty); - } - } - - private void SetActivePane() - { - DockPane value = GetPaneFromHandle(NativeMethods.GetFocus()); - if (ActivePane == value) - { - return; - } - - if (ActivePane != null) - { - ActivePane.SetIsActivated(false); - } - - ActivePane = value; - - if (ActivePane != null) - { - ActivePane.SetIsActivated(true); - } - } - - private void SetActiveDocumentPane() - { - DockPane value = null; - - if (ActivePane != null && ActivePane.DockState == DockState.Document) - { - value = ActivePane; - } - - if (value == null && DockPanel.DockWindows != null) - { - if (ActiveDocumentPane == null) - { - value = DockPanel.DockWindows[DockState.Document].DefaultPane; - } - else if (ActiveDocumentPane.DockPanel != DockPanel || - ActiveDocumentPane.DockState != DockState.Document) - { - value = DockPanel.DockWindows[DockState.Document].DefaultPane; - } - else - { - value = ActiveDocumentPane; - } - } - - if (ActiveDocumentPane == value) - { - return; - } - - if (ActiveDocumentPane != null) - { - ActiveDocumentPane.SetIsActiveDocumentPane(false); - } - - ActiveDocumentPane = value; - - if (ActiveDocumentPane != null) - { - ActiveDocumentPane.SetIsActiveDocumentPane(true); - } - } - - private void SetActiveDocument() - { - IDockContent value = ActiveDocumentPane == null ? null : ActiveDocumentPane.ActiveContent; - - if (ActiveDocument == value) - { - return; - } - - ActiveDocument = value; - } - - #endregion - - #region Events handler - - // Windows hook event handler - private void HookEventHandler(object sender, HookEventArgs e) - { - Win32.Msgs msg = (Win32.Msgs) Marshal.ReadInt32(e.lParam, IntPtr.Size * 3); - - if (msg == Win32.Msgs.WM_KILLFOCUS) - { - IntPtr wParam = Marshal.ReadIntPtr(e.lParam, IntPtr.Size * 2); - DockPane pane = GetPaneFromHandle(wParam); - if (pane == null) - { - RefreshActiveWindow(); - } - } - else if (msg == Win32.Msgs.WM_SETFOCUS) - { - RefreshActiveWindow(); - } - } - - #endregion - - private class HookEventArgs : EventArgs - { - #region Fields - - [SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] public int HookCode; - - public IntPtr lParam; - - [SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] public IntPtr wParam; - - #endregion - } - - private class LocalWindowsHook : IDisposable - { - #region Fields - - private readonly NativeMethods.HookProc m_filterFunc = null; - - // Internal properties - private IntPtr m_hHook = IntPtr.Zero; - - private readonly Win32.HookType m_hookType; - - #endregion - - #region cTor - - public LocalWindowsHook(Win32.HookType hook) - { - m_hookType = hook; - m_filterFunc = new NativeMethods.HookProc(this.CoreHookProc); - } - - #endregion - - #region Delegates - - // Event delegate - public delegate void HookEventHandler(object sender, HookEventArgs e); - - #endregion - - #region Events - - // Event: HookInvoked - public event HookEventHandler HookInvoked; - - #endregion - - #region Public methods - - // Default filter function - public IntPtr CoreHookProc(int code, IntPtr wParam, IntPtr lParam) - { - if (code < 0) - { - return NativeMethods.CallNextHookEx(m_hHook, code, wParam, lParam); - } - - // Let clients determine what to do - HookEventArgs e = new HookEventArgs(); - e.HookCode = code; - e.wParam = wParam; - e.lParam = lParam; - OnHookInvoked(e); - - // Yield to the next hook in the chain - return NativeMethods.CallNextHookEx(m_hHook, code, wParam, lParam); - } - - // Install the hook - public void Install() - { - if (m_hHook != IntPtr.Zero) - { - Uninstall(); - } - - int threadId = NativeMethods.GetCurrentThreadId(); - m_hHook = NativeMethods.SetWindowsHookEx(m_hookType, m_filterFunc, IntPtr.Zero, threadId); - } - - // Uninstall the hook - public void Uninstall() - { - if (m_hHook != IntPtr.Zero) - { - NativeMethods.UnhookWindowsHookEx(m_hHook); - m_hHook = IntPtr.Zero; - } - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - #endregion - - protected void OnHookInvoked(HookEventArgs e) - { - if (HookInvoked != null) - { - HookInvoked(this, e); - } - } - - ~LocalWindowsHook() - { - Dispose(false); - } - - protected virtual void Dispose(bool disposing) - { - Uninstall(); - } - } - } - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockPanel.MdiClientController.cs b/src/WinFormsUI/Docking/DockPanel.MdiClientController.cs deleted file mode 100644 index 996896c8..00000000 --- a/src/WinFormsUI/Docking/DockPanel.MdiClientController.cs +++ /dev/null @@ -1,534 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; -using System.ComponentModel; -using System.ComponentModel.Design; -using System.Runtime.InteropServices; - -namespace WeifenLuo.WinFormsUI.Docking -{ - partial class DockPanel - { - #region Fields - - private MdiClientController m_mdiClientController = null; - - #endregion - - #region Properties - - private bool MdiClientExists - { - get { return GetMdiClientController().MdiClient != null; } - } - - #endregion - - #region Internals - - internal Rectangle RectangleToMdiClient(Rectangle rect) - { - if (MdiClientExists) - { - return GetMdiClientController().MdiClient.RectangleToClient(rect); - } - else - { - return Rectangle.Empty; - } - } - - #endregion - - #region Private Methods - - private MdiClientController GetMdiClientController() - { - if (m_mdiClientController == null) - { - m_mdiClientController = new MdiClientController(); - m_mdiClientController.HandleAssigned += new EventHandler(MdiClientHandleAssigned); - m_mdiClientController.MdiChildActivate += new EventHandler(ParentFormMdiChildActivate); - m_mdiClientController.Layout += new LayoutEventHandler(MdiClient_Layout); - } - - return m_mdiClientController; - } - - private void SetMdiClientBounds(Rectangle bounds) - { - GetMdiClientController().MdiClient.Bounds = bounds; - } - - private void SuspendMdiClientLayout() - { - if (GetMdiClientController().MdiClient != null) - { - GetMdiClientController().MdiClient.SuspendLayout(); - } - } - - private void ResumeMdiClientLayout(bool perform) - { - if (GetMdiClientController().MdiClient != null) - { - GetMdiClientController().MdiClient.ResumeLayout(perform); - } - } - - private void PerformMdiClientLayout() - { - if (GetMdiClientController().MdiClient != null) - { - GetMdiClientController().MdiClient.PerformLayout(); - } - } - - // Called when: - // 1. DockPanel.DocumentStyle changed - // 2. DockPanel.Visible changed - // 3. MdiClientController.Handle assigned - private void SetMdiClient() - { - MdiClientController controller = GetMdiClientController(); - - if (this.DocumentStyle == DocumentStyle.DockingMdi) - { - controller.AutoScroll = false; - controller.BorderStyle = BorderStyle.None; - if (MdiClientExists) - { - controller.MdiClient.Dock = DockStyle.Fill; - } - } - else if (DocumentStyle == DocumentStyle.DockingSdi || DocumentStyle == DocumentStyle.DockingWindow) - { - controller.AutoScroll = true; - controller.BorderStyle = BorderStyle.Fixed3D; - if (MdiClientExists) - { - controller.MdiClient.Dock = DockStyle.Fill; - } - } - else if (this.DocumentStyle == DocumentStyle.SystemMdi) - { - controller.AutoScroll = true; - controller.BorderStyle = BorderStyle.Fixed3D; - if (controller.MdiClient != null) - { - controller.MdiClient.Dock = DockStyle.None; - controller.MdiClient.Bounds = SystemMdiClientBounds; - } - } - } - - #endregion - - #region Events handler - - private void ParentFormMdiChildActivate(object sender, EventArgs e) - { - if (GetMdiClientController().ParentForm == null) - { - return; - } - - IDockContent content = GetMdiClientController().ParentForm.ActiveMdiChild as IDockContent; - if (content == null) - { - return; - } - - if (content.DockHandler.DockPanel == this && content.DockHandler.Pane != null) - { - content.DockHandler.Pane.ActiveContent = content; - } - } - - #endregion - - // This class comes from Jacob Slusser's MdiClientController class: - // http://www.codeproject.com/cs/miscctrl/mdiclientcontroller.asp - private class MdiClientController : NativeWindow, IComponent, IDisposable - { - #region Fields - - private bool m_autoScroll = true; - private BorderStyle m_borderStyle = BorderStyle.Fixed3D; - private Form m_parentForm = null; - private ISite m_site = null; - - #endregion - - #region cTor - - public MdiClientController() - { - } - - #endregion - - #region Events - - public event EventHandler Disposed; - - public event EventHandler HandleAssigned; - - public event EventHandler MdiChildActivate; - - public event LayoutEventHandler Layout; - - public event PaintEventHandler Paint; - - #endregion - - #region Properties - - public bool AutoScroll - { - get { return m_autoScroll; } - set - { - // By default the MdiClient control scrolls. It can appear though that - // there are no scrollbars by turning them off when the non-client - // area is calculated. I decided to expose this method following - // the .NET vernacular of an AutoScroll property. - m_autoScroll = value; - if (MdiClient != null) - { - UpdateStyles(); - } - } - } - - public BorderStyle BorderStyle - { - set - { - // Error-check the enum. - if (!Enum.IsDefined(typeof(BorderStyle), value)) - { - throw new InvalidEnumArgumentException(); - } - - m_borderStyle = value; - - if (MdiClient == null) - { - return; - } - - // This property can actually be visible in design-mode, - // but to keep it consistent with the others, - // prevent this from being show at design-time. - if (Site != null && Site.DesignMode) - { - return; - } - - // There is no BorderStyle property exposed by the MdiClient class, - // but this can be controlled by Win32 functions. A Win32 ExStyle - // of WS_EX_CLIENTEDGE is equivalent to a Fixed3D border and a - // Style of WS_BORDER is equivalent to a FixedSingle border. - - // This code is inspired Jason Dori's article: - // "Adding designable borders to user controls". - // http://www.codeproject.com/cs/miscctrl/CsAddingBorders.asp - - // Get styles using Win32 calls - int style = NativeMethods.GetWindowLong(MdiClient.Handle, (int) Win32.GetWindowLongIndex.GWL_STYLE); - int exStyle = - NativeMethods.GetWindowLong(MdiClient.Handle, (int) Win32.GetWindowLongIndex.GWL_EXSTYLE); - - // Add or remove style flags as necessary. - switch (m_borderStyle) - { - case BorderStyle.Fixed3D: - exStyle |= (int) Win32.WindowExStyles.WS_EX_CLIENTEDGE; - style &= ~(int) Win32.WindowStyles.WS_BORDER; - break; - - case BorderStyle.FixedSingle: - exStyle &= ~(int) Win32.WindowExStyles.WS_EX_CLIENTEDGE; - style |= (int) Win32.WindowStyles.WS_BORDER; - break; - - case BorderStyle.None: - style &= ~(int) Win32.WindowStyles.WS_BORDER; - exStyle &= ~(int) Win32.WindowExStyles.WS_EX_CLIENTEDGE; - break; - } - - // Set the styles using Win32 calls - NativeMethods.SetWindowLong(MdiClient.Handle, (int) Win32.GetWindowLongIndex.GWL_STYLE, style); - NativeMethods.SetWindowLong(MdiClient.Handle, (int) Win32.GetWindowLongIndex.GWL_EXSTYLE, exStyle); - - // Cause an update of the non-client area. - UpdateStyles(); - } - } - - public MdiClient MdiClient { get; private set; } = null; - - [Browsable(false)] - public Form ParentForm - { - get { return m_parentForm; } - set - { - // If the ParentForm has previously been set, - // unwire events connected to the old parent. - if (m_parentForm != null) - { - m_parentForm.HandleCreated -= new EventHandler(ParentFormHandleCreated); - m_parentForm.MdiChildActivate -= new EventHandler(ParentFormMdiChildActivate); - } - - m_parentForm = value; - - if (m_parentForm == null) - { - return; - } - - // If the parent form has not been created yet, - // wait to initialize the MDI client until it is. - if (m_parentForm.IsHandleCreated) - { - InitializeMdiClient(); - RefreshProperties(); - } - else - { - m_parentForm.HandleCreated += new EventHandler(ParentFormHandleCreated); - } - - m_parentForm.MdiChildActivate += new EventHandler(ParentFormMdiChildActivate); - } - } - - public ISite Site - { - get { return m_site; } - set - { - m_site = value; - - if (m_site == null) - { - return; - } - - // If the component is dropped onto a form during design-time, - // set the ParentForm property. - IDesignerHost host = value.GetService(typeof(IDesignerHost)) as IDesignerHost; - if (host != null) - { - Form parent = host.RootComponent as Form; - if (parent != null) - { - ParentForm = parent; - } - } - } - } - - #endregion - - #region Public methods - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - public void RenewMdiClient() - { - // Reinitialize the MdiClient and its properties. - InitializeMdiClient(); - RefreshProperties(); - } - - #endregion - - #region Overrides - - protected override void WndProc(ref Message m) - { - switch (m.Msg) - { - case (int) Win32.Msgs.WM_NCCALCSIZE: - // If AutoScroll is set to false, hide the scrollbars when the control - // calculates its non-client area. - if (!AutoScroll) - { - NativeMethods.ShowScrollBar(m.HWnd, (int) Win32.ScrollBars.SB_BOTH, 0 /*false*/); - } - break; - } - - base.WndProc(ref m); - } - - #endregion - - #region Private Methods - - private void InitializeMdiClient() - { - // If the mdiClient has previously been set, unwire events connected - // to the old MDI. - if (MdiClient != null) - { - MdiClient.HandleDestroyed -= new EventHandler(MdiClientHandleDestroyed); - MdiClient.Layout -= new LayoutEventHandler(MdiClientLayout); - } - - if (ParentForm == null) - { - return; - } - - // Get the MdiClient from the parent form. - foreach (Control control in ParentForm.Controls) - { - // If the form is an MDI container, it will contain an MdiClient control - // just as it would any other control. - - MdiClient = control as MdiClient; - if (MdiClient == null) - { - continue; - } - - // Assign the MdiClient Handle to the NativeWindow. - ReleaseHandle(); - AssignHandle(MdiClient.Handle); - - // Raise the HandleAssigned event. - OnHandleAssigned(EventArgs.Empty); - - // Monitor the MdiClient for when its handle is destroyed. - MdiClient.HandleDestroyed += new EventHandler(MdiClientHandleDestroyed); - MdiClient.Layout += new LayoutEventHandler(MdiClientLayout); - - break; - } - } - - private void RefreshProperties() - { - // Refresh all the properties - BorderStyle = m_borderStyle; - AutoScroll = m_autoScroll; - } - - private void UpdateStyles() - { - // To show style changes, the non-client area must be repainted. Using the - // control's Invalidate method does not affect the non-client area. - // Instead use a Win32 call to signal the style has changed. - NativeMethods.SetWindowPos(MdiClient.Handle, IntPtr.Zero, 0, 0, 0, 0, - Win32.FlagsSetWindowPos.SWP_NOACTIVATE | - Win32.FlagsSetWindowPos.SWP_NOMOVE | - Win32.FlagsSetWindowPos.SWP_NOSIZE | - Win32.FlagsSetWindowPos.SWP_NOZORDER | - Win32.FlagsSetWindowPos.SWP_NOOWNERZORDER | - Win32.FlagsSetWindowPos.SWP_FRAMECHANGED); - } - - #endregion - - #region Events handler - - private void ParentFormHandleCreated(object sender, EventArgs e) - { - // The form has been created, unwire the event, and initialize the MdiClient. - this.m_parentForm.HandleCreated -= new EventHandler(ParentFormHandleCreated); - InitializeMdiClient(); - RefreshProperties(); - } - - private void ParentFormMdiChildActivate(object sender, EventArgs e) - { - OnMdiChildActivate(e); - } - - private void MdiClientLayout(object sender, LayoutEventArgs e) - { - OnLayout(e); - } - - private void MdiClientHandleDestroyed(object sender, EventArgs e) - { - // If the MdiClient handle has been released, drop the reference and - // release the handle. - if (MdiClient != null) - { - MdiClient.HandleDestroyed -= new EventHandler(MdiClientHandleDestroyed); - MdiClient = null; - } - - ReleaseHandle(); - } - - #endregion - - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - lock (this) - { - if (Site != null && Site.Container != null) - { - Site.Container.Remove(this); - } - - if (Disposed != null) - { - Disposed(this, EventArgs.Empty); - } - } - } - } - - protected virtual void OnHandleAssigned(EventArgs e) - { - // Raise the HandleAssigned event. - if (HandleAssigned != null) - { - HandleAssigned(this, e); - } - } - - protected virtual void OnMdiChildActivate(EventArgs e) - { - // Raise the MdiChildActivate event - if (MdiChildActivate != null) - { - MdiChildActivate(this, e); - } - } - - protected virtual void OnLayout(LayoutEventArgs e) - { - // Raise the Layout event - if (Layout != null) - { - Layout(this, e); - } - } - - protected virtual void OnPaint(PaintEventArgs e) - { - // Raise the Paint event. - if (Paint != null) - { - Paint(this, e); - } - } - } - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockPanel.Persistor.cs b/src/WinFormsUI/Docking/DockPanel.Persistor.cs deleted file mode 100644 index 49d54ff2..00000000 --- a/src/WinFormsUI/Docking/DockPanel.Persistor.cs +++ /dev/null @@ -1,816 +0,0 @@ -using System; -using System.ComponentModel; -using System.Windows.Forms; -using System.Drawing; -using WeifenLuo.WinFormsUI.Docking; -using System.IO; -using System.Text; -using System.Xml; -using System.Globalization; - -namespace WeifenLuo.WinFormsUI.Docking -{ - partial class DockPanel - { - #region Public methods - - public void SaveAsXml(string fileName) - { - Persistor.SaveAsXml(this, fileName); - } - - public void SaveAsXml(string fileName, Encoding encoding) - { - Persistor.SaveAsXml(this, fileName, encoding); - } - - public void SaveAsXml(Stream stream, Encoding encoding) - { - Persistor.SaveAsXml(this, stream, encoding); - } - - public void SaveAsXml(Stream stream, Encoding encoding, bool upstream) - { - Persistor.SaveAsXml(this, stream, encoding, upstream); - } - - public void LoadFromXml(string fileName, DeserializeDockContent deserializeContent) - { - Persistor.LoadFromXml(this, fileName, deserializeContent); - } - - public void LoadFromXml(Stream stream, DeserializeDockContent deserializeContent) - { - Persistor.LoadFromXml(this, stream, deserializeContent); - } - - public void LoadFromXml(Stream stream, DeserializeDockContent deserializeContent, bool closeStream) - { - Persistor.LoadFromXml(this, stream, deserializeContent, closeStream); - } - - #endregion - - private static class Persistor - { - #region Fields - - private const string ConfigFileVersion = "1.0"; - private static readonly string[] CompatibleConfigFileVersions = new string[] { }; - - #endregion - - #region Public methods - - public static void SaveAsXml(DockPanel dockPanel, string fileName) - { - SaveAsXml(dockPanel, fileName, Encoding.Unicode); - } - - public static void SaveAsXml(DockPanel dockPanel, string fileName, Encoding encoding) - { - FileStream fs = new FileStream(fileName, FileMode.Create); - try - { - SaveAsXml(dockPanel, fs, encoding); - } - finally - { - fs.Close(); - } - } - - public static void SaveAsXml(DockPanel dockPanel, Stream stream, Encoding encoding) - { - SaveAsXml(dockPanel, stream, encoding, false); - } - - public static void SaveAsXml(DockPanel dockPanel, Stream stream, Encoding encoding, bool upstream) - { - XmlTextWriter xmlOut = new XmlTextWriter(stream, encoding); - - // Use indenting for readability - xmlOut.Formatting = Formatting.Indented; - - if (!upstream) - { - xmlOut.WriteStartDocument(); - } - - // Always begin file with identification and warning - xmlOut.WriteComment(Strings.DockPanel_Persistor_XmlFileComment1); - xmlOut.WriteComment(Strings.DockPanel_Persistor_XmlFileComment2); - - // Associate a version number with the root element so that future version of the code - // will be able to be backwards compatible or at least recognise out of date versions - xmlOut.WriteStartElement("DockPanel"); - xmlOut.WriteAttributeString("FormatVersion", ConfigFileVersion); - xmlOut.WriteAttributeString("DockLeftPortion", - dockPanel.DockLeftPortion.ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteAttributeString("DockRightPortion", - dockPanel.DockRightPortion.ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteAttributeString("DockTopPortion", - dockPanel.DockTopPortion.ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteAttributeString("DockBottomPortion", - dockPanel.DockBottomPortion.ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteAttributeString("ActiveDocumentPane", - dockPanel.Panes.IndexOf(dockPanel.ActiveDocumentPane).ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteAttributeString("ActivePane", - dockPanel.Panes.IndexOf(dockPanel.ActivePane).ToString(CultureInfo.InvariantCulture)); - - // Contents - xmlOut.WriteStartElement("Contents"); - xmlOut.WriteAttributeString("Count", dockPanel.Contents.Count.ToString(CultureInfo.InvariantCulture)); - foreach (IDockContent content in dockPanel.Contents) - { - xmlOut.WriteStartElement("Content"); - xmlOut.WriteAttributeString("ID", - dockPanel.Contents.IndexOf(content).ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteAttributeString("PersistString", content.DockHandler.PersistString); - xmlOut.WriteAttributeString("AutoHidePortion", - content.DockHandler.AutoHidePortion.ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteAttributeString("IsHidden", - content.DockHandler.IsHidden.ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteAttributeString("IsFloat", - content.DockHandler.IsFloat.ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteEndElement(); - } - xmlOut.WriteEndElement(); - - // Panes - xmlOut.WriteStartElement("Panes"); - xmlOut.WriteAttributeString("Count", dockPanel.Panes.Count.ToString(CultureInfo.InvariantCulture)); - foreach (DockPane pane in dockPanel.Panes) - { - xmlOut.WriteStartElement("Pane"); - xmlOut.WriteAttributeString("ID", - dockPanel.Panes.IndexOf(pane).ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteAttributeString("DockState", pane.DockState.ToString()); - xmlOut.WriteAttributeString("ActiveContent", - dockPanel.Contents.IndexOf(pane.ActiveContent).ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteStartElement("Contents"); - xmlOut.WriteAttributeString("Count", pane.Contents.Count.ToString(CultureInfo.InvariantCulture)); - foreach (IDockContent content in pane.Contents) - { - xmlOut.WriteStartElement("Content"); - xmlOut.WriteAttributeString("ID", - pane.Contents.IndexOf(content).ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteAttributeString("RefID", - dockPanel.Contents.IndexOf(content).ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteEndElement(); - } - xmlOut.WriteEndElement(); - xmlOut.WriteEndElement(); - } - xmlOut.WriteEndElement(); - - // DockWindows - xmlOut.WriteStartElement("DockWindows"); - int dockWindowId = 0; - foreach (DockWindow dw in dockPanel.DockWindows) - { - xmlOut.WriteStartElement("DockWindow"); - xmlOut.WriteAttributeString("ID", dockWindowId.ToString(CultureInfo.InvariantCulture)); - dockWindowId++; - xmlOut.WriteAttributeString("DockState", dw.DockState.ToString()); - xmlOut.WriteAttributeString("ZOrderIndex", - dockPanel.Controls.IndexOf(dw).ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteStartElement("NestedPanes"); - xmlOut.WriteAttributeString("Count", dw.NestedPanes.Count.ToString(CultureInfo.InvariantCulture)); - foreach (DockPane pane in dw.NestedPanes) - { - xmlOut.WriteStartElement("Pane"); - xmlOut.WriteAttributeString("ID", - dw.NestedPanes.IndexOf(pane).ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteAttributeString("RefID", - dockPanel.Panes.IndexOf(pane).ToString(CultureInfo.InvariantCulture)); - NestedDockingStatus status = pane.NestedDockingStatus; - xmlOut.WriteAttributeString("PrevPane", - dockPanel.Panes.IndexOf(status.PreviousPane).ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteAttributeString("Alignment", status.Alignment.ToString()); - xmlOut.WriteAttributeString("Proportion", - status.Proportion.ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteEndElement(); - } - xmlOut.WriteEndElement(); - xmlOut.WriteEndElement(); - } - xmlOut.WriteEndElement(); - - // FloatWindows - RectangleConverter rectConverter = new RectangleConverter(); - xmlOut.WriteStartElement("FloatWindows"); - xmlOut.WriteAttributeString("Count", - dockPanel.FloatWindows.Count.ToString(CultureInfo.InvariantCulture)); - foreach (FloatWindow fw in dockPanel.FloatWindows) - { - xmlOut.WriteStartElement("FloatWindow"); - xmlOut.WriteAttributeString("ID", - dockPanel.FloatWindows.IndexOf(fw).ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteAttributeString("Bounds", rectConverter.ConvertToInvariantString(fw.Bounds)); - xmlOut.WriteAttributeString("ZOrderIndex", - fw.DockPanel.FloatWindows.IndexOf(fw).ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteStartElement("NestedPanes"); - xmlOut.WriteAttributeString("Count", fw.NestedPanes.Count.ToString(CultureInfo.InvariantCulture)); - foreach (DockPane pane in fw.NestedPanes) - { - xmlOut.WriteStartElement("Pane"); - xmlOut.WriteAttributeString("ID", - fw.NestedPanes.IndexOf(pane).ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteAttributeString("RefID", - dockPanel.Panes.IndexOf(pane).ToString(CultureInfo.InvariantCulture)); - NestedDockingStatus status = pane.NestedDockingStatus; - xmlOut.WriteAttributeString("PrevPane", - dockPanel.Panes.IndexOf(status.PreviousPane).ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteAttributeString("Alignment", status.Alignment.ToString()); - xmlOut.WriteAttributeString("Proportion", - status.Proportion.ToString(CultureInfo.InvariantCulture)); - xmlOut.WriteEndElement(); - } - xmlOut.WriteEndElement(); - xmlOut.WriteEndElement(); - } - xmlOut.WriteEndElement(); // - - xmlOut.WriteEndElement(); - - if (!upstream) - { - xmlOut.WriteEndDocument(); - xmlOut.Close(); - } - else - { - xmlOut.Flush(); - } - } - - public static void LoadFromXml(DockPanel dockPanel, string fileName, - DeserializeDockContent deserializeContent) - { - FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); - try - { - LoadFromXml(dockPanel, fs, deserializeContent); - } - finally - { - fs.Close(); - } - } - - public static void LoadFromXml(DockPanel dockPanel, Stream stream, - DeserializeDockContent deserializeContent) - { - LoadFromXml(dockPanel, stream, deserializeContent, true); - } - - public static void LoadFromXml(DockPanel dockPanel, Stream stream, - DeserializeDockContent deserializeContent, bool closeStream) - { - if (dockPanel.Contents.Count != 0) - { - //TODO this happens if a session is loaded and the dialog is just closed, this needs to be adressed - throw new InvalidOperationException(Strings.DockPanel_LoadFromXml_AlreadyInitialized); - } - - XmlTextReader xmlIn = new XmlTextReader(stream); - xmlIn.WhitespaceHandling = WhitespaceHandling.None; - xmlIn.MoveToContent(); - - while (!xmlIn.Name.Equals("DockPanel")) - { - if (!MoveToNextElement(xmlIn)) - { - throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); - } - } - - string formatVersion = xmlIn.GetAttribute("FormatVersion"); - if (!IsFormatVersionValid(formatVersion)) - { - throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidFormatVersion); - } - - DockPanelStruct dockPanelStruct = new DockPanelStruct(); - dockPanelStruct.DockLeftPortion = - Convert.ToDouble(xmlIn.GetAttribute("DockLeftPortion"), CultureInfo.InvariantCulture); - dockPanelStruct.DockRightPortion = Convert.ToDouble(xmlIn.GetAttribute("DockRightPortion"), - CultureInfo.InvariantCulture); - dockPanelStruct.DockTopPortion = - Convert.ToDouble(xmlIn.GetAttribute("DockTopPortion"), CultureInfo.InvariantCulture); - dockPanelStruct.DockBottomPortion = Convert.ToDouble(xmlIn.GetAttribute("DockBottomPortion"), - CultureInfo.InvariantCulture); - dockPanelStruct.IndexActiveDocumentPane = Convert.ToInt32(xmlIn.GetAttribute("ActiveDocumentPane"), - CultureInfo.InvariantCulture); - dockPanelStruct.IndexActivePane = - Convert.ToInt32(xmlIn.GetAttribute("ActivePane"), CultureInfo.InvariantCulture); - - // Load Contents - MoveToNextElement(xmlIn); - if (xmlIn.Name != "Contents") - { - throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); - } - ContentStruct[] contents = LoadContents(xmlIn); - - // Load Panes - if (xmlIn.Name != "Panes") - { - throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); - } - PaneStruct[] panes = LoadPanes(xmlIn); - - // Load DockWindows - if (xmlIn.Name != "DockWindows") - { - throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); - } - DockWindowStruct[] dockWindows = LoadDockWindows(xmlIn, dockPanel); - - // Load FloatWindows - if (xmlIn.Name != "FloatWindows") - { - throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); - } - FloatWindowStruct[] floatWindows = LoadFloatWindows(xmlIn); - - if (closeStream) - { - xmlIn.Close(); - } - - dockPanel.SuspendLayout(true); - - dockPanel.DockLeftPortion = dockPanelStruct.DockLeftPortion; - dockPanel.DockRightPortion = dockPanelStruct.DockRightPortion; - dockPanel.DockTopPortion = dockPanelStruct.DockTopPortion; - dockPanel.DockBottomPortion = dockPanelStruct.DockBottomPortion; - - // Set DockWindow ZOrders - int prevMaxDockWindowZOrder = int.MaxValue; - for (int i = 0; i < dockWindows.Length; i++) - { - int maxDockWindowZOrder = -1; - int index = -1; - for (int j = 0; j < dockWindows.Length; j++) - { - if (dockWindows[j].ZOrderIndex > maxDockWindowZOrder && - dockWindows[j].ZOrderIndex < prevMaxDockWindowZOrder) - { - maxDockWindowZOrder = dockWindows[j].ZOrderIndex; - index = j; - } - } - - dockPanel.DockWindows[dockWindows[index].DockState].BringToFront(); - prevMaxDockWindowZOrder = maxDockWindowZOrder; - } - - // Create Contents - for (int i = 0; i < contents.Length; i++) - { - IDockContent content = deserializeContent(contents[i].PersistString); - if (content == null) - { - content = new DummyContent(); - } - content.DockHandler.DockPanel = dockPanel; - content.DockHandler.AutoHidePortion = contents[i].AutoHidePortion; - content.DockHandler.IsHidden = true; - content.DockHandler.IsFloat = contents[i].IsFloat; - } - - // Create panes - for (int i = 0; i < panes.Length; i++) - { - DockPane pane = null; - for (int j = 0; j < panes[i].IndexContents.Length; j++) - { - IDockContent content = dockPanel.Contents[panes[i].IndexContents[j]]; - if (j == 0) - { - pane = dockPanel.DockPaneFactory.CreateDockPane(content, panes[i].DockState, false); - } - else if (panes[i].DockState == DockState.Float) - { - content.DockHandler.FloatPane = pane; - } - else - { - content.DockHandler.PanelPane = pane; - } - } - } - - // Assign Panes to DockWindows - for (int i = 0; i < dockWindows.Length; i++) - { - for (int j = 0; j < dockWindows[i].NestedPanes.Length; j++) - { - DockWindow dw = dockPanel.DockWindows[dockWindows[i].DockState]; - int indexPane = dockWindows[i].NestedPanes[j].IndexPane; - DockPane pane = dockPanel.Panes[indexPane]; - int indexPrevPane = dockWindows[i].NestedPanes[j].IndexPrevPane; - DockPane prevPane = indexPrevPane == -1 - ? dw.NestedPanes.GetDefaultPreviousPane(pane) - : dockPanel.Panes[indexPrevPane]; - DockAlignment alignment = dockWindows[i].NestedPanes[j].Alignment; - double proportion = dockWindows[i].NestedPanes[j].Proportion; - pane.DockTo(dw, prevPane, alignment, proportion); - if (panes[indexPane].DockState == dw.DockState) - { - panes[indexPane].ZOrderIndex = dockWindows[i].ZOrderIndex; - } - } - } - - // Create float windows - for (int i = 0; i < floatWindows.Length; i++) - { - FloatWindow fw = null; - for (int j = 0; j < floatWindows[i].NestedPanes.Length; j++) - { - int indexPane = floatWindows[i].NestedPanes[j].IndexPane; - DockPane pane = dockPanel.Panes[indexPane]; - if (j == 0) - { - fw = dockPanel.FloatWindowFactory.CreateFloatWindow(dockPanel, pane, - floatWindows[i].Bounds); - } - else - { - int indexPrevPane = floatWindows[i].NestedPanes[j].IndexPrevPane; - DockPane prevPane = indexPrevPane == -1 ? null : dockPanel.Panes[indexPrevPane]; - DockAlignment alignment = floatWindows[i].NestedPanes[j].Alignment; - double proportion = floatWindows[i].NestedPanes[j].Proportion; - pane.DockTo(fw, prevPane, alignment, proportion); - } - - if (panes[indexPane].DockState == fw.DockState) - { - panes[indexPane].ZOrderIndex = floatWindows[i].ZOrderIndex; - } - } - } - - // sort IDockContent by its Pane's ZOrder - int[] sortedContents = null; - if (contents.Length > 0) - { - sortedContents = new int[contents.Length]; - for (int i = 0; i < contents.Length; i++) - { - sortedContents[i] = i; - } - - int lastDocument = contents.Length; - for (int i = 0; i < contents.Length - 1; i++) - { - for (int j = i + 1; j < contents.Length; j++) - { - DockPane pane1 = dockPanel.Contents[sortedContents[i]].DockHandler.Pane; - int ZOrderIndex1 = pane1 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane1)].ZOrderIndex; - DockPane pane2 = dockPanel.Contents[sortedContents[j]].DockHandler.Pane; - int ZOrderIndex2 = pane2 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane2)].ZOrderIndex; - if (ZOrderIndex1 > ZOrderIndex2) - { - int temp = sortedContents[i]; - sortedContents[i] = sortedContents[j]; - sortedContents[j] = temp; - } - } - } - } - - // show non-document IDockContent first to avoid screen flickers - for (int i = 0; i < contents.Length; i++) - { - IDockContent content = dockPanel.Contents[sortedContents[i]]; - if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState != DockState.Document) - { - content.DockHandler.IsHidden = contents[sortedContents[i]].IsHidden; - } - } - - // after all non-document IDockContent, show document IDockContent - for (int i = 0; i < contents.Length; i++) - { - IDockContent content = dockPanel.Contents[sortedContents[i]]; - if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState == DockState.Document) - { - content.DockHandler.IsHidden = contents[sortedContents[i]].IsHidden; - } - } - - for (int i = 0; i < panes.Length; i++) - { - dockPanel.Panes[i].ActiveContent = panes[i].IndexActiveContent == -1 - ? null - : dockPanel.Contents[panes[i].IndexActiveContent]; - } - - if (dockPanelStruct.IndexActiveDocumentPane != -1) - { - dockPanel.Panes[dockPanelStruct.IndexActiveDocumentPane].Activate(); - } - - if (dockPanelStruct.IndexActivePane != -1) - { - dockPanel.Panes[dockPanelStruct.IndexActivePane].Activate(); - } - - for (int i = dockPanel.Contents.Count - 1; i >= 0; i--) - { - if (dockPanel.Contents[i] is DummyContent) - { - dockPanel.Contents[i].DockHandler.Form.Close(); - } - } - - dockPanel.ResumeLayout(true, true); - } - - #endregion - - #region Private Methods - - private static ContentStruct[] LoadContents(XmlTextReader xmlIn) - { - int countOfContents = Convert.ToInt32(xmlIn.GetAttribute("Count"), CultureInfo.InvariantCulture); - ContentStruct[] contents = new ContentStruct[countOfContents]; - MoveToNextElement(xmlIn); - for (int i = 0; i < countOfContents; i++) - { - int id = Convert.ToInt32(xmlIn.GetAttribute("ID"), CultureInfo.InvariantCulture); - if (xmlIn.Name != "Content" || id != i) - { - throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); - } - - contents[i].PersistString = xmlIn.GetAttribute("PersistString"); - contents[i].AutoHidePortion = Convert.ToDouble(xmlIn.GetAttribute("AutoHidePortion"), - CultureInfo.InvariantCulture); - contents[i].IsHidden = - Convert.ToBoolean(xmlIn.GetAttribute("IsHidden"), CultureInfo.InvariantCulture); - contents[i].IsFloat = - Convert.ToBoolean(xmlIn.GetAttribute("IsFloat"), CultureInfo.InvariantCulture); - MoveToNextElement(xmlIn); - } - - return contents; - } - - private static PaneStruct[] LoadPanes(XmlTextReader xmlIn) - { - EnumConverter dockStateConverter = new EnumConverter(typeof(DockState)); - int countOfPanes = Convert.ToInt32(xmlIn.GetAttribute("Count"), CultureInfo.InvariantCulture); - PaneStruct[] panes = new PaneStruct[countOfPanes]; - MoveToNextElement(xmlIn); - for (int i = 0; i < countOfPanes; i++) - { - int id = Convert.ToInt32(xmlIn.GetAttribute("ID"), CultureInfo.InvariantCulture); - if (xmlIn.Name != "Pane" || id != i) - { - throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); - } - - panes[i].DockState = (DockState) dockStateConverter.ConvertFrom(xmlIn.GetAttribute("DockState")); - panes[i].IndexActiveContent = Convert.ToInt32(xmlIn.GetAttribute("ActiveContent"), - CultureInfo.InvariantCulture); - panes[i].ZOrderIndex = -1; - - MoveToNextElement(xmlIn); - if (xmlIn.Name != "Contents") - { - throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); - } - int countOfPaneContents = - Convert.ToInt32(xmlIn.GetAttribute("Count"), CultureInfo.InvariantCulture); - panes[i].IndexContents = new int[countOfPaneContents]; - MoveToNextElement(xmlIn); - for (int j = 0; j < countOfPaneContents; j++) - { - int id2 = Convert.ToInt32(xmlIn.GetAttribute("ID"), CultureInfo.InvariantCulture); - if (xmlIn.Name != "Content" || id2 != j) - { - throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); - } - - panes[i].IndexContents[j] = - Convert.ToInt32(xmlIn.GetAttribute("RefID"), CultureInfo.InvariantCulture); - MoveToNextElement(xmlIn); - } - } - - return panes; - } - - private static DockWindowStruct[] LoadDockWindows(XmlTextReader xmlIn, DockPanel dockPanel) - { - EnumConverter dockStateConverter = new EnumConverter(typeof(DockState)); - EnumConverter dockAlignmentConverter = new EnumConverter(typeof(DockAlignment)); - int countOfDockWindows = dockPanel.DockWindows.Count; - DockWindowStruct[] dockWindows = new DockWindowStruct[countOfDockWindows]; - MoveToNextElement(xmlIn); - for (int i = 0; i < countOfDockWindows; i++) - { - int id = Convert.ToInt32(xmlIn.GetAttribute("ID"), CultureInfo.InvariantCulture); - if (xmlIn.Name != "DockWindow" || id != i) - { - throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); - } - - dockWindows[i].DockState = - (DockState) dockStateConverter.ConvertFrom(xmlIn.GetAttribute("DockState")); - dockWindows[i].ZOrderIndex = - Convert.ToInt32(xmlIn.GetAttribute("ZOrderIndex"), CultureInfo.InvariantCulture); - MoveToNextElement(xmlIn); - if (xmlIn.Name != "DockList" && xmlIn.Name != "NestedPanes") - { - throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); - } - int countOfNestedPanes = Convert.ToInt32(xmlIn.GetAttribute("Count"), CultureInfo.InvariantCulture); - dockWindows[i].NestedPanes = new NestedPane[countOfNestedPanes]; - MoveToNextElement(xmlIn); - for (int j = 0; j < countOfNestedPanes; j++) - { - int id2 = Convert.ToInt32(xmlIn.GetAttribute("ID"), CultureInfo.InvariantCulture); - if (xmlIn.Name != "Pane" || id2 != j) - { - throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); - } - dockWindows[i].NestedPanes[j].IndexPane = Convert.ToInt32(xmlIn.GetAttribute("RefID"), - CultureInfo.InvariantCulture); - dockWindows[i].NestedPanes[j].IndexPrevPane = Convert.ToInt32(xmlIn.GetAttribute("PrevPane"), - CultureInfo.InvariantCulture); - dockWindows[i].NestedPanes[j].Alignment = - (DockAlignment) dockAlignmentConverter.ConvertFrom(xmlIn.GetAttribute("Alignment")); - dockWindows[i].NestedPanes[j].Proportion = Convert.ToDouble(xmlIn.GetAttribute("Proportion"), - CultureInfo.InvariantCulture); - MoveToNextElement(xmlIn); - } - } - - return dockWindows; - } - - private static FloatWindowStruct[] LoadFloatWindows(XmlTextReader xmlIn) - { - EnumConverter dockAlignmentConverter = new EnumConverter(typeof(DockAlignment)); - RectangleConverter rectConverter = new RectangleConverter(); - int countOfFloatWindows = Convert.ToInt32(xmlIn.GetAttribute("Count"), CultureInfo.InvariantCulture); - FloatWindowStruct[] floatWindows = new FloatWindowStruct[countOfFloatWindows]; - MoveToNextElement(xmlIn); - for (int i = 0; i < countOfFloatWindows; i++) - { - int id = Convert.ToInt32(xmlIn.GetAttribute("ID"), CultureInfo.InvariantCulture); - if (xmlIn.Name != "FloatWindow" || id != i) - { - throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); - } - - floatWindows[i].Bounds = - (Rectangle) rectConverter.ConvertFromInvariantString(xmlIn.GetAttribute("Bounds")); - floatWindows[i].ZOrderIndex = - Convert.ToInt32(xmlIn.GetAttribute("ZOrderIndex"), CultureInfo.InvariantCulture); - MoveToNextElement(xmlIn); - if (xmlIn.Name != "DockList" && xmlIn.Name != "NestedPanes") - { - throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); - } - int countOfNestedPanes = Convert.ToInt32(xmlIn.GetAttribute("Count"), CultureInfo.InvariantCulture); - floatWindows[i].NestedPanes = new NestedPane[countOfNestedPanes]; - MoveToNextElement(xmlIn); - for (int j = 0; j < countOfNestedPanes; j++) - { - int id2 = Convert.ToInt32(xmlIn.GetAttribute("ID"), CultureInfo.InvariantCulture); - if (xmlIn.Name != "Pane" || id2 != j) - { - throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); - } - floatWindows[i].NestedPanes[j].IndexPane = Convert.ToInt32(xmlIn.GetAttribute("RefID"), - CultureInfo.InvariantCulture); - floatWindows[i].NestedPanes[j].IndexPrevPane = Convert.ToInt32(xmlIn.GetAttribute("PrevPane"), - CultureInfo.InvariantCulture); - floatWindows[i].NestedPanes[j].Alignment = - (DockAlignment) dockAlignmentConverter.ConvertFrom(xmlIn.GetAttribute("Alignment")); - floatWindows[i].NestedPanes[j].Proportion = Convert.ToDouble(xmlIn.GetAttribute("Proportion"), - CultureInfo.InvariantCulture); - MoveToNextElement(xmlIn); - } - } - - return floatWindows; - } - - private static bool MoveToNextElement(XmlTextReader xmlIn) - { - if (!xmlIn.Read()) - { - return false; - } - - while (xmlIn.NodeType == XmlNodeType.EndElement) - { - if (!xmlIn.Read()) - { - return false; - } - } - - return true; - } - - private static bool IsFormatVersionValid(string formatVersion) - { - if (formatVersion == ConfigFileVersion) - { - return true; - } - - foreach (string s in CompatibleConfigFileVersions) - { - if (s == formatVersion) - { - return true; - } - } - - return false; - } - - #endregion - - private class DummyContent : DockContent - { - } - - private struct DockPanelStruct - { - public double DockLeftPortion { get; set; } - - public double DockRightPortion { get; set; } - - public double DockTopPortion { get; set; } - - public double DockBottomPortion { get; set; } - - public int IndexActiveDocumentPane { get; set; } - - public int IndexActivePane { get; set; } - } - - private struct ContentStruct - { - public string PersistString { get; set; } - - public double AutoHidePortion { get; set; } - - public bool IsHidden { get; set; } - - public bool IsFloat { get; set; } - } - - private struct PaneStruct - { - public DockState DockState { get; set; } - - public int IndexActiveContent { get; set; } - - public int[] IndexContents { get; set; } - - public int ZOrderIndex { get; set; } - } - - private struct NestedPane - { - public int IndexPane { get; set; } - - public int IndexPrevPane { get; set; } - - public DockAlignment Alignment { get; set; } - - public double Proportion { get; set; } - } - - private struct DockWindowStruct - { - public DockState DockState { get; set; } - - public int ZOrderIndex { get; set; } - - public NestedPane[] NestedPanes { get; set; } - } - - private struct FloatWindowStruct - { - public Rectangle Bounds { get; set; } - - public int ZOrderIndex { get; set; } - - public NestedPane[] NestedPanes { get; set; } - } - } - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockPanel.SplitterDragHandler.cs b/src/WinFormsUI/Docking/DockPanel.SplitterDragHandler.cs deleted file mode 100644 index 74838ae2..00000000 --- a/src/WinFormsUI/Docking/DockPanel.SplitterDragHandler.cs +++ /dev/null @@ -1,230 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.ComponentModel; - -namespace WeifenLuo.WinFormsUI.Docking -{ - partial class DockPanel - { - #region Fields - - private SplitterDragHandler m_splitterDragHandler = null; - - #endregion - - #region Internals - - internal void BeginDrag(ISplitterDragSource dragSource, Rectangle rectSplitter) - { - GetSplitterDragHandler().BeginDrag(dragSource, rectSplitter); - } - - #endregion - - #region Private Methods - - private SplitterDragHandler GetSplitterDragHandler() - { - if (m_splitterDragHandler == null) - { - m_splitterDragHandler = new SplitterDragHandler(this); - } - return m_splitterDragHandler; - } - - #endregion - - private sealed class SplitterDragHandler : DragHandler - { - #region Fields - - #endregion - - #region cTor - - public SplitterDragHandler(DockPanel dockPanel) - : base(dockPanel) - { - } - - #endregion - - #region Properties - - public new ISplitterDragSource DragSource - { - get { return base.DragSource as ISplitterDragSource; } - private set { base.DragSource = value; } - } - - private SplitterOutline Outline { get; set; } - - private Rectangle RectSplitter { get; set; } - - #endregion - - #region Public methods - - public void BeginDrag(ISplitterDragSource dragSource, Rectangle rectSplitter) - { - DragSource = dragSource; - RectSplitter = rectSplitter; - - if (!BeginDrag()) - { - DragSource = null; - return; - } - - Outline = new SplitterOutline(); - Outline.Show(rectSplitter); - DragSource.BeginDrag(rectSplitter); - } - - #endregion - - #region Overrides - - protected override void OnDragging() - { - Outline.Show(GetSplitterOutlineBounds(Control.MousePosition)); - } - - protected override void OnEndDrag(bool abort) - { - DockPanel.SuspendLayout(true); - - Outline.Close(); - - if (!abort) - { - DragSource.MoveSplitter(GetMovingOffset(Control.MousePosition)); - } - - DragSource.EndDrag(); - DockPanel.ResumeLayout(true, true); - } - - #endregion - - #region Private Methods - - private int GetMovingOffset(Point ptMouse) - { - Rectangle rect = GetSplitterOutlineBounds(ptMouse); - if (DragSource.IsVertical) - { - return rect.X - RectSplitter.X; - } - else - { - return rect.Y - RectSplitter.Y; - } - } - - private Rectangle GetSplitterOutlineBounds(Point ptMouse) - { - Rectangle rectLimit = DragSource.DragLimitBounds; - - Rectangle rect = RectSplitter; - if (rectLimit.Width <= 0 || rectLimit.Height <= 0) - { - return rect; - } - - if (DragSource.IsVertical) - { - rect.X += ptMouse.X - StartMousePosition.X; - rect.Height = rectLimit.Height; - } - else - { - rect.Y += ptMouse.Y - StartMousePosition.Y; - rect.Width = rectLimit.Width; - } - - if (rect.Left < rectLimit.Left) - { - rect.X = rectLimit.X; - } - if (rect.Top < rectLimit.Top) - { - rect.Y = rectLimit.Y; - } - if (rect.Right > rectLimit.Right) - { - rect.X -= rect.Right - rectLimit.Right; - } - if (rect.Bottom > rectLimit.Bottom) - { - rect.Y -= rect.Bottom - rectLimit.Bottom; - } - - return rect; - } - - #endregion - - private class SplitterOutline - { - #region Fields - - #endregion - - #region cTor - - public SplitterOutline() - { - DragForm = new DragForm(); - SetDragForm(Rectangle.Empty); - DragForm.BackColor = Color.Black; - DragForm.Opacity = 0.7; - DragForm.Show(false); - } - - #endregion - - #region Properties - - private DragForm DragForm { get; } - - #endregion - - #region Public methods - - public void Show(Rectangle rect) - { - SetDragForm(rect); - } - - public void Close() - { - DragForm.Close(); - } - - #endregion - - #region Private Methods - - private void SetDragForm(Rectangle rect) - { - DragForm.Bounds = rect; - if (rect == Rectangle.Empty) - { - DragForm.Region = new Region(Rectangle.Empty); - } - else if (DragForm.Region != null) - { - DragForm.Region = null; - } - } - - #endregion - } - } - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockPanel.bmp b/src/WinFormsUI/Docking/DockPanel.bmp deleted file mode 100644 index 10d6858f9490df8c44bc54bb02ab98d05d052484..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 822 zcmbV_(G7qg3~$x7}%dq7e+dr!<0rf4+`axo8$wKBceVOu6aY@k6LOI;(>ATU_|AQ5wMj X8lVvjpaB}em)YQocLrtG_;(y0(ZY@L diff --git a/src/WinFormsUI/Docking/DockPanel.cs b/src/WinFormsUI/Docking/DockPanel.cs deleted file mode 100644 index 6012c27b..00000000 --- a/src/WinFormsUI/Docking/DockPanel.cs +++ /dev/null @@ -1,1208 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -using System.Drawing; -using System.Windows.Forms; - -// To simplify the process of finding the toolbox bitmap resource: -// #1 Create an internal class called "resfinder" outside of the root namespace. -// #2 Use "resfinder" in the toolbox bitmap attribute instead of the control name. -// #3 use the "." string to locate the resource. -// See: http://www.bobpowell.net/toolboxbitmap.htm -#pragma warning disable CS8981 // The type name only contains lower-cased ascii characters. Such names may become reserved for the language. -internal class resfinder -#pragma warning restore CS8981 // The type name only contains lower-cased ascii characters. Such names may become reserved for the language. -{ -} - -namespace WeifenLuo.WinFormsUI.Docking -{ - [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters", MessageId = "0#")] - public delegate IDockContent DeserializeDockContent(string persistString); - - [LocalizedDescription("DockPanel_Description")] - [Designer(typeof(System.Windows.Forms.Design.ControlDesigner))] - [ToolboxBitmap(typeof(resfinder), "WeifenLuo.WinFormsUI.Docking.DockPanel.bmp")] - [DefaultProperty("DocumentStyle")] - [DefaultEvent("ActiveContentChanged")] - public partial class DockPanel : Panel - { - #region Fields - - private static readonly object ContentAddedEvent = new object(); - - private static readonly object ContentRemovedEvent = new object(); - - private AutoHideStripBase m_autoHideStripControl = null; - - private Color m_BackColor; - - private Rectangle[] m_clipRects = null; - - private bool m_disposed = false; - - private double m_dockBottomPortion = 0.25; - - private double m_dockLeftPortion = 0.25; - - private double m_dockRightPortion = 0.25; - - private double m_dockTopPortion = 0.25; - - private DocumentStyle m_documentStyle = DocumentStyle.DockingMdi; - - private PaintEventHandler m_dummyControlPaintEventHandler = null; - private readonly FocusManagerImpl m_focusManager; - - private bool m_rightToLeftLayout = false; - - private bool m_showDocumentIcon = false; - - #endregion - - #region cTor - - public DockPanel() - { - m_focusManager = new FocusManagerImpl(this); - Extender = new DockPanelExtender(this); - Panes = new DockPaneCollection(); - FloatWindows = new FloatWindowCollection(); - - SuspendLayout(); - - AutoHideWindow = new AutoHideWindowControl(this); - AutoHideWindow.Visible = false; - SetAutoHideWindowParent(); - - DummyControl = new DummyControl(); - DummyControl.Bounds = new Rectangle(0, 0, 1, 1); - Controls.Add(DummyControl); - - DockWindows = new DockWindowCollection(this); - Controls.AddRange(new Control[] - { - DockWindows[DockState.Document], - DockWindows[DockState.DockLeft], - DockWindows[DockState.DockRight], - DockWindows[DockState.DockTop], - DockWindows[DockState.DockBottom] - }); - - DummyContent = new DockContent(); - ResumeLayout(); - } - - #endregion - - #region Events - - [LocalizedCategory("Category_DockingNotification")] - [LocalizedDescription("DockPanel_ContentAdded_Description")] - public event EventHandler ContentAdded - { - add { Events.AddHandler(ContentAddedEvent, value); } - remove { Events.RemoveHandler(ContentAddedEvent, value); } - } - - [LocalizedCategory("Category_DockingNotification")] - [LocalizedDescription("DockPanel_ContentRemoved_Description")] - public event EventHandler ContentRemoved - { - add { Events.AddHandler(ContentRemovedEvent, value); } - remove { Events.RemoveHandler(ContentRemovedEvent, value); } - } - - #endregion - - #region Properties - - /// - /// Determines the color with which the client rectangle will be drawn. - /// If this property is used instead of the BackColor it will not have any influence on the borders to the surrounding controls (DockPane). - /// The BackColor property changes the borders of surrounding controls (DockPane). - /// Alternatively both properties may be used (BackColor to draw and define the color of the borders and DockBackColor to define the color of the client rectangle). - /// For Backgroundimages: Set your prefered Image, then set the DockBackColor and the BackColor to the same Color (Control) - /// - [Description("Determines the color with which the client rectangle will be drawn.\r\n" + - "If this property is used instead of the BackColor it will not have any influence on the borders to the surrounding controls (DockPane).\r\n" + - "The BackColor property changes the borders of surrounding controls (DockPane).\r\n" + - "Alternatively both properties may be used (BackColor to draw and define the color of the borders and DockBackColor to define the color of the client rectangle).\r\n" + - "For Backgroundimages: Set your prefered Image, then set the DockBackColor and the BackColor to the same Color (Control).")] - public Color DockBackColor - { - get { return !m_BackColor.IsEmpty ? m_BackColor : base.BackColor; } - set - { - if (m_BackColor != value) - { - m_BackColor = value; - Refresh(); - } - } - } - - internal AutoHideStripBase AutoHideStripControl - { - get - { - if (m_autoHideStripControl == null) - { - m_autoHideStripControl = AutoHideStripFactory.CreateAutoHideStrip(this); - Controls.Add(m_autoHideStripControl); - } - return m_autoHideStripControl; - } - } - - [Browsable(false)] - public IDockContent ActiveAutoHideContent - { - get { return AutoHideWindow.ActiveContent; } - set { AutoHideWindow.ActiveContent = value; } - } - - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockPanel_AllowEndUserDocking_Description")] - [DefaultValue(true)] - public bool AllowEndUserDocking { get; set; } = true; - - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockPanel_AllowEndUserNestedDocking_Description")] - [DefaultValue(true)] - public bool AllowEndUserNestedDocking { get; set; } = true; - - [Browsable(false)] - public DockContentCollection Contents { get; } = new DockContentCollection(); - - internal DockContent DummyContent { get; } - - [DefaultValue(false)] - [LocalizedCategory("Appearance")] - [LocalizedDescription("DockPanel_RightToLeftLayout_Description")] - public bool RightToLeftLayout - { - get { return m_rightToLeftLayout; } - set - { - if (m_rightToLeftLayout == value) - { - return; - } - - m_rightToLeftLayout = value; - foreach (FloatWindow floatWindow in FloatWindows) - { - floatWindow.RightToLeftLayout = value; - } - } - } - - [DefaultValue(false)] - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockPanel_ShowDocumentIcon_Description")] - public bool ShowDocumentIcon - { - get { return m_showDocumentIcon; } - set - { - if (m_showDocumentIcon == value) - { - return; - } - - m_showDocumentIcon = value; - Refresh(); - } - } - - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockPanel_DockPanelSkin")] - public DockPanelSkin Skin { get; set; } = new DockPanelSkin(); - - [DefaultValue(DocumentTabStripLocation.Top)] - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockPanel_DocumentTabStripLocation")] - public DocumentTabStripLocation DocumentTabStripLocation { get; set; } = DocumentTabStripLocation.Top; - - [Browsable(false)] - public DockPanelExtender Extender { get; } - - [Browsable(false)] - public DockPanelExtender.IDockPaneFactory DockPaneFactory - { - get { return Extender.DockPaneFactory; } - } - - [Browsable(false)] - public DockPanelExtender.IFloatWindowFactory FloatWindowFactory - { - get { return Extender.FloatWindowFactory; } - } - - internal DockPanelExtender.IDockPaneCaptionFactory DockPaneCaptionFactory - { - get { return Extender.DockPaneCaptionFactory; } - } - - internal DockPanelExtender.IDockPaneStripFactory DockPaneStripFactory - { - get { return Extender.DockPaneStripFactory; } - } - - internal DockPanelExtender.IAutoHideStripFactory AutoHideStripFactory - { - get { return Extender.AutoHideStripFactory; } - } - - [Browsable(false)] - public DockPaneCollection Panes { get; } - - internal Rectangle DockArea - { - get - { - return new Rectangle(DockPadding.Left, DockPadding.Top, - ClientRectangle.Width - DockPadding.Left - DockPadding.Right, - ClientRectangle.Height - DockPadding.Top - DockPadding.Bottom); - } - } - - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockPanel_DockBottomPortion_Description")] - [DefaultValue(0.25)] - public double DockBottomPortion - { - get { return m_dockBottomPortion; } - set - { - if (value <= 0) - { - throw new ArgumentOutOfRangeException("value"); - } - - if (value == m_dockBottomPortion) - { - return; - } - - m_dockBottomPortion = value; - - if (m_dockBottomPortion < 1 && m_dockTopPortion < 1) - { - if (m_dockTopPortion + m_dockBottomPortion > 1) - { - m_dockTopPortion = 1 - m_dockBottomPortion; - } - } - - PerformLayout(); - } - } - - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockPanel_DockLeftPortion_Description")] - [DefaultValue(0.25)] - public double DockLeftPortion - { - get { return m_dockLeftPortion; } - set - { - if (value <= 0) - { - throw new ArgumentOutOfRangeException("value"); - } - - if (value == m_dockLeftPortion) - { - return; - } - - m_dockLeftPortion = value; - - if (m_dockLeftPortion < 1 && m_dockRightPortion < 1) - { - if (m_dockLeftPortion + m_dockRightPortion > 1) - { - m_dockRightPortion = 1 - m_dockLeftPortion; - } - } - PerformLayout(); - } - } - - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockPanel_DockRightPortion_Description")] - [DefaultValue(0.25)] - public double DockRightPortion - { - get { return m_dockRightPortion; } - set - { - if (value <= 0) - { - throw new ArgumentOutOfRangeException("value"); - } - - if (value == m_dockRightPortion) - { - return; - } - - m_dockRightPortion = value; - - if (m_dockLeftPortion < 1 && m_dockRightPortion < 1) - { - if (m_dockLeftPortion + m_dockRightPortion > 1) - { - m_dockLeftPortion = 1 - m_dockRightPortion; - } - } - PerformLayout(); - } - } - - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockPanel_DockTopPortion_Description")] - [DefaultValue(0.25)] - public double DockTopPortion - { - get { return m_dockTopPortion; } - set - { - if (value <= 0) - { - throw new ArgumentOutOfRangeException("value"); - } - - if (value == m_dockTopPortion) - { - return; - } - - m_dockTopPortion = value; - - if (m_dockTopPortion < 1 && m_dockBottomPortion < 1) - { - if (m_dockTopPortion + m_dockBottomPortion > 1) - { - m_dockBottomPortion = 1 - m_dockTopPortion; - } - } - PerformLayout(); - } - } - - [Browsable(false)] - public DockWindowCollection DockWindows { get; } - - [Browsable(false)] - public int DocumentsCount - { - get - { - int count = 0; - foreach (IDockContent content in Documents) - { - count++; - } - - return count; - } - } - - [Browsable(false)] - public IEnumerable Documents - { - get - { - foreach (IDockContent content in Contents) - { - if (content.DockHandler.DockState == DockState.Document) - { - yield return content; - } - } - } - } - - private Rectangle DocumentRectangle - { - get - { - Rectangle rect = DockArea; - if (DockWindows[DockState.DockLeft].VisibleNestedPanes.Count != 0) - { - rect.X += (int)(DockArea.Width * DockLeftPortion); - rect.Width -= (int)(DockArea.Width * DockLeftPortion); - } - if (DockWindows[DockState.DockRight].VisibleNestedPanes.Count != 0) - { - rect.Width -= (int)(DockArea.Width * DockRightPortion); - } - if (DockWindows[DockState.DockTop].VisibleNestedPanes.Count != 0) - { - rect.Y += (int)(DockArea.Height * DockTopPortion); - rect.Height -= (int)(DockArea.Height * DockTopPortion); - } - if (DockWindows[DockState.DockBottom].VisibleNestedPanes.Count != 0) - { - rect.Height -= (int)(DockArea.Height * DockBottomPortion); - } - - return rect; - } - } - - private Control DummyControl { get; } - - [Browsable(false)] - public FloatWindowCollection FloatWindows { get; } - - [Category("Layout")] - [LocalizedDescription("DockPanel_DefaultFloatWindowSize_Description")] - public Size DefaultFloatWindowSize { get; set; } = new Size(300, 300); - - [LocalizedCategory("Category_Docking")] - [LocalizedDescription("DockPanel_DocumentStyle_Description")] - [DefaultValue(DocumentStyle.DockingMdi)] - public DocumentStyle DocumentStyle - { - get { return m_documentStyle; } - set - { - if (value == m_documentStyle) - { - return; - } - - if (!Enum.IsDefined(typeof(DocumentStyle), value)) - { - throw new InvalidEnumArgumentException(); - } - - if (value == DocumentStyle.SystemMdi && DockWindows[DockState.Document].VisibleNestedPanes.Count > 0) - { - throw new InvalidEnumArgumentException(); - } - - m_documentStyle = value; - - SuspendLayout(true); - - SetAutoHideWindowParent(); - SetMdiClient(); - InvalidateWindowRegion(); - - foreach (IDockContent content in Contents) - { - if (content.DockHandler.DockState == DockState.Document) - { - content.DockHandler.SetPaneAndVisible(content.DockHandler.Pane); - } - } - - PerformMdiClientLayout(); - - ResumeLayout(true, true); - } - } - - internal Form ParentForm - { - get - { - if (!IsParentFormValid()) - { - throw new InvalidOperationException(Strings.DockPanel_ParentForm_Invalid); - } - - return GetMdiClientController().ParentForm; - } - } - - private Rectangle SystemMdiClientBounds - { - get - { - if (!IsParentFormValid() || !Visible) - { - return Rectangle.Empty; - } - - Rectangle rect = ParentForm.RectangleToClient(RectangleToScreen(DocumentWindowBounds)); - return rect; - } - } - - internal Rectangle DocumentWindowBounds - { - get - { - Rectangle rectDocumentBounds = DisplayRectangle; - if (DockWindows[DockState.DockLeft].Visible) - { - rectDocumentBounds.X += DockWindows[DockState.DockLeft].Width; - rectDocumentBounds.Width -= DockWindows[DockState.DockLeft].Width; - } - if (DockWindows[DockState.DockRight].Visible) - { - rectDocumentBounds.Width -= DockWindows[DockState.DockRight].Width; - } - if (DockWindows[DockState.DockTop].Visible) - { - rectDocumentBounds.Y += DockWindows[DockState.DockTop].Height; - rectDocumentBounds.Height -= DockWindows[DockState.DockTop].Height; - } - if (DockWindows[DockState.DockBottom].Visible) - { - rectDocumentBounds.Height -= DockWindows[DockState.DockBottom].Height; - } - - return rectDocumentBounds; - } - } - - #endregion - - #region Public methods - - public void UpdateDockWindowZOrder(DockStyle dockStyle, bool fullPanelEdge) - { - if (dockStyle == DockStyle.Left) - { - if (fullPanelEdge) - { - DockWindows[DockState.DockLeft].SendToBack(); - } - else - { - DockWindows[DockState.DockLeft].BringToFront(); - } - } - else if (dockStyle == DockStyle.Right) - { - if (fullPanelEdge) - { - DockWindows[DockState.DockRight].SendToBack(); - } - else - { - DockWindows[DockState.DockRight].BringToFront(); - } - } - else if (dockStyle == DockStyle.Top) - { - if (fullPanelEdge) - { - DockWindows[DockState.DockTop].SendToBack(); - } - else - { - DockWindows[DockState.DockTop].BringToFront(); - } - } - else if (dockStyle == DockStyle.Bottom) - { - if (fullPanelEdge) - { - DockWindows[DockState.DockBottom].SendToBack(); - } - else - { - DockWindows[DockState.DockBottom].BringToFront(); - } - } - } - - public IDockContent[] DocumentsToArray() - { - int count = DocumentsCount; - IDockContent[] documents = new IDockContent[count]; - int i = 0; - foreach (IDockContent content in Documents) - { - documents[i] = content; - i++; - } - - return documents; - } - - public void SetPaneIndex(DockPane pane, int index) - { - int oldIndex = Panes.IndexOf(pane); - if (oldIndex == -1) - { - throw new ArgumentException(Strings.DockPanel_SetPaneIndex_InvalidPane); - } - - if (index < 0 || index > Panes.Count - 1) - { - if (index != -1) - { - throw new ArgumentOutOfRangeException(Strings.DockPanel_SetPaneIndex_InvalidIndex); - } - } - - if (oldIndex == index) - { - return; - } - if (oldIndex == Panes.Count - 1 && index == -1) - { - return; - } - - Panes.Remove(pane); - if (index == -1) - { - Panes.Add(pane); - } - else if (oldIndex < index) - { - Panes.AddAt(pane, index - 1); - } - else - { - Panes.AddAt(pane, index); - } - } - - public void SuspendLayout(bool allWindows) - { - FocusManager.SuspendFocusTracking(); - SuspendLayout(); - if (allWindows) - { - SuspendMdiClientLayout(); - } - } - - public void ResumeLayout(bool performLayout, bool allWindows) - { - FocusManager.ResumeFocusTracking(); - ResumeLayout(performLayout); - if (allWindows) - { - ResumeMdiClientLayout(performLayout); - } - } - - #endregion - - #region Internals - - internal void ResetAutoHideStripControl() - { - if (m_autoHideStripControl != null) - { - m_autoHideStripControl.Dispose(); - } - - m_autoHideStripControl = null; - } - - internal Rectangle GetTabStripRectangle(DockState dockState) - { - return AutoHideStripControl.GetTabStripRectangle(dockState); - } - - internal void AddContent(IDockContent content) - { - if (content == null) - { - throw new ArgumentNullException(); - } - - if (!Contents.Contains(content)) - { - Contents.Add(content); - OnContentAdded(new DockContentEventArgs(content)); - } - } - - internal void AddPane(DockPane pane) - { - if (Panes.Contains(pane)) - { - return; - } - - Panes.Add(pane); - } - - internal void AddFloatWindow(FloatWindow floatWindow) - { - if (FloatWindows.Contains(floatWindow)) - { - return; - } - - FloatWindows.Add(floatWindow); - } - - internal void RemoveContent(IDockContent content) - { - if (content == null) - { - throw new ArgumentNullException(); - } - - if (Contents.Contains(content)) - { - Contents.Remove(content); - OnContentRemoved(new DockContentEventArgs(content)); - } - } - - internal void RemovePane(DockPane pane) - { - if (!Panes.Contains(pane)) - { - return; - } - - Panes.Remove(pane); - } - - internal void RemoveFloatWindow(FloatWindow floatWindow) - { - if (!FloatWindows.Contains(floatWindow)) - { - return; - } - - FloatWindows.Remove(floatWindow); - } - - #endregion - - #region Overrides - - protected override void Dispose(bool disposing) - { - lock (this) - { - if (!m_disposed && disposing) - { - m_focusManager.Dispose(); - if (m_mdiClientController != null) - { - m_mdiClientController.HandleAssigned -= new EventHandler(MdiClientHandleAssigned); - m_mdiClientController.MdiChildActivate -= new EventHandler(ParentFormMdiChildActivate); - m_mdiClientController.Layout -= new LayoutEventHandler(MdiClient_Layout); - m_mdiClientController.Dispose(); - } - FloatWindows.Dispose(); - Panes.Dispose(); - DummyContent.Dispose(); - - m_disposed = true; - } - - base.Dispose(disposing); - } - } - - protected override void OnRightToLeftChanged(EventArgs e) - { - base.OnRightToLeftChanged(e); - foreach (FloatWindow floatWindow in FloatWindows) - { - if (floatWindow.RightToLeft != RightToLeft) - { - floatWindow.RightToLeft = RightToLeft; - } - } - } - - protected override void OnLayout(LayoutEventArgs levent) - { - SuspendLayout(true); - - AutoHideStripControl.Bounds = ClientRectangle; - - CalculateDockPadding(); - - DockWindows[DockState.DockLeft].Width = GetDockWindowSize(DockState.DockLeft); - DockWindows[DockState.DockRight].Width = GetDockWindowSize(DockState.DockRight); - DockWindows[DockState.DockTop].Height = GetDockWindowSize(DockState.DockTop); - DockWindows[DockState.DockBottom].Height = GetDockWindowSize(DockState.DockBottom); - - AutoHideWindow.Bounds = GetAutoHideWindowBounds(AutoHideWindowRectangle); - - DockWindows[DockState.Document].BringToFront(); - AutoHideWindow.BringToFront(); - - base.OnLayout(levent); - - if (DocumentStyle == DocumentStyle.SystemMdi && MdiClientExists) - { - SetMdiClientBounds(SystemMdiClientBounds); - InvalidateWindowRegion(); - } - else if (DocumentStyle == DocumentStyle.DockingMdi) - { - InvalidateWindowRegion(); - } - - ResumeLayout(true, true); - } - - protected override void OnPaint(PaintEventArgs e) - { - base.OnPaint(e); - - if (DockBackColor == BackColor) - { - return; - } - - Graphics g = e.Graphics; - SolidBrush bgBrush = new SolidBrush(DockBackColor); - g.FillRectangle(bgBrush, ClientRectangle); - } - - protected override void OnParentChanged(EventArgs e) - { - SetAutoHideWindowParent(); - GetMdiClientController().ParentForm = this.Parent as Form; - base.OnParentChanged(e); - } - - protected override void OnVisibleChanged(EventArgs e) - { - base.OnVisibleChanged(e); - - if (Visible) - { - SetMdiClient(); - } - } - - #endregion - - #region Private Methods - - private bool ShouldSerializeDefaultFloatWindowSize() - { - return DefaultFloatWindowSize != new Size(300, 300); - } - - private int GetDockWindowSize(DockState dockState) - { - if (dockState == DockState.DockLeft || dockState == DockState.DockRight) - { - int width = ClientRectangle.Width - DockPadding.Left - DockPadding.Right; - int dockLeftSize = m_dockLeftPortion >= 1 ? (int)m_dockLeftPortion : (int)(width * m_dockLeftPortion); - int dockRightSize = m_dockRightPortion >= 1 - ? (int)m_dockRightPortion - : (int)(width * m_dockRightPortion); - - if (dockLeftSize < MeasurePane.MinSize) - { - dockLeftSize = MeasurePane.MinSize; - } - if (dockRightSize < MeasurePane.MinSize) - { - dockRightSize = MeasurePane.MinSize; - } - - if (dockLeftSize + dockRightSize > width - MeasurePane.MinSize) - { - int adjust = dockLeftSize + dockRightSize - (width - MeasurePane.MinSize); - dockLeftSize -= adjust / 2; - dockRightSize -= adjust / 2; - } - - return dockState == DockState.DockLeft ? dockLeftSize : dockRightSize; - } - else if (dockState == DockState.DockTop || dockState == DockState.DockBottom) - { - int height = ClientRectangle.Height - DockPadding.Top - DockPadding.Bottom; - int dockTopSize = m_dockTopPortion >= 1 ? (int)m_dockTopPortion : (int)(height * m_dockTopPortion); - int dockBottomSize = m_dockBottomPortion >= 1 - ? (int)m_dockBottomPortion - : (int)(height * m_dockBottomPortion); - - if (dockTopSize < MeasurePane.MinSize) - { - dockTopSize = MeasurePane.MinSize; - } - if (dockBottomSize < MeasurePane.MinSize) - { - dockBottomSize = MeasurePane.MinSize; - } - - if (dockTopSize + dockBottomSize > height - MeasurePane.MinSize) - { - int adjust = dockTopSize + dockBottomSize - (height - MeasurePane.MinSize); - dockTopSize -= adjust / 2; - dockBottomSize -= adjust / 2; - } - - return dockState == DockState.DockTop ? dockTopSize : dockBottomSize; - } - else - { - return 0; - } - } - - private void CalculateDockPadding() - { - DockPadding.All = 0; - - int height = AutoHideStripControl.MeasureHeight(); - - if (AutoHideStripControl.GetNumberOfPanes(DockState.DockLeftAutoHide) > 0) - { - DockPadding.Left = height; - } - if (AutoHideStripControl.GetNumberOfPanes(DockState.DockRightAutoHide) > 0) - { - DockPadding.Right = height; - } - if (AutoHideStripControl.GetNumberOfPanes(DockState.DockTopAutoHide) > 0) - { - DockPadding.Top = height; - } - if (AutoHideStripControl.GetNumberOfPanes(DockState.DockBottomAutoHide) > 0) - { - DockPadding.Bottom = height; - } - } - - private bool IsParentFormValid() - { - if (DocumentStyle == DocumentStyle.DockingSdi || DocumentStyle == DocumentStyle.DockingWindow) - { - return true; - } - - if (!MdiClientExists) - { - GetMdiClientController().RenewMdiClient(); - } - - return MdiClientExists; - } - - private void SetAutoHideWindowParent() - { - Control parent; - if (DocumentStyle == DocumentStyle.DockingMdi || - DocumentStyle == DocumentStyle.SystemMdi) - { - parent = this.Parent; - } - else - { - parent = this; - } - if (AutoHideWindow.Parent != parent) - { - AutoHideWindow.Parent = parent; - AutoHideWindow.BringToFront(); - } - } - - private void InvalidateWindowRegion() - { - if (DesignMode) - { - return; - } - - if (m_dummyControlPaintEventHandler == null) - { - m_dummyControlPaintEventHandler = new PaintEventHandler(DummyControl_Paint); - } - - DummyControl.Paint += m_dummyControlPaintEventHandler; - DummyControl.Invalidate(); - } - - private void UpdateWindowRegion() - { - if (this.DocumentStyle == DocumentStyle.DockingMdi) - { - UpdateWindowRegion_ClipContent(); - } - else if (this.DocumentStyle == DocumentStyle.DockingSdi || - this.DocumentStyle == DocumentStyle.DockingWindow) - { - UpdateWindowRegion_FullDocumentArea(); - } - else if (this.DocumentStyle == DocumentStyle.SystemMdi) - { - UpdateWindowRegion_EmptyDocumentArea(); - } - } - - private void UpdateWindowRegion_FullDocumentArea() - { - SetRegion(null); - } - - private void UpdateWindowRegion_EmptyDocumentArea() - { - Rectangle rect = DocumentWindowBounds; - SetRegion(new Rectangle[] { rect }); - } - - private void UpdateWindowRegion_ClipContent() - { - int count = 0; - foreach (DockPane pane in this.Panes) - { - if (!pane.Visible || pane.DockState != DockState.Document) - { - continue; - } - - count++; - } - - if (count == 0) - { - SetRegion(null); - return; - } - - Rectangle[] rects = new Rectangle[count]; - int i = 0; - foreach (DockPane pane in this.Panes) - { - if (!pane.Visible || pane.DockState != DockState.Document) - { - continue; - } - - rects[i] = RectangleToClient(pane.RectangleToScreen(pane.ContentRectangle)); - i++; - } - - SetRegion(rects); - } - - private void SetRegion(Rectangle[] clipRects) - { - if (!IsClipRectsChanged(clipRects)) - { - return; - } - - m_clipRects = clipRects; - - if (m_clipRects == null || m_clipRects.GetLength(0) == 0) - { - Region = null; - } - else - { - Region region = new Region(new Rectangle(0, 0, this.Width, this.Height)); - foreach (Rectangle rect in m_clipRects) - { - region.Exclude(rect); - } - Region = region; - } - } - - private bool IsClipRectsChanged(Rectangle[] clipRects) - { - if (clipRects == null && m_clipRects == null) - { - return false; - } - else if (clipRects == null != (m_clipRects == null)) - { - return true; - } - - foreach (Rectangle rect in clipRects) - { - bool matched = false; - foreach (Rectangle rect2 in m_clipRects) - { - if (rect == rect2) - { - matched = true; - break; - } - } - if (!matched) - { - return true; - } - } - - foreach (Rectangle rect2 in m_clipRects) - { - bool matched = false; - foreach (Rectangle rect in clipRects) - { - if (rect == rect2) - { - matched = true; - break; - } - } - if (!matched) - { - return true; - } - } - return false; - } - - #endregion - - #region Events handler - - private void MdiClientHandleAssigned(object sender, EventArgs e) - { - SetMdiClient(); - PerformLayout(); - } - - private void MdiClient_Layout(object sender, LayoutEventArgs e) - { - if (DocumentStyle != DocumentStyle.DockingMdi) - { - return; - } - - foreach (DockPane pane in Panes) - { - if (pane.DockState == DockState.Document) - { - pane.SetContentBounds(); - } - } - - InvalidateWindowRegion(); - } - - private void DummyControl_Paint(object sender, PaintEventArgs e) - { - DummyControl.Paint -= m_dummyControlPaintEventHandler; - UpdateWindowRegion(); - } - - #endregion - - protected virtual void OnContentAdded(DockContentEventArgs e) - { - ((EventHandler)Events[ContentAddedEvent])?.Invoke(this, e); - } - - protected virtual void OnContentRemoved(DockContentEventArgs e) - { - ((EventHandler)Events[ContentRemovedEvent])?.Invoke(this, e); - } - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockPanelExtender.cs b/src/WinFormsUI/Docking/DockPanelExtender.cs deleted file mode 100644 index ddda208e..00000000 --- a/src/WinFormsUI/Docking/DockPanelExtender.cs +++ /dev/null @@ -1,315 +0,0 @@ -using System; -using System.Drawing; -using System.Diagnostics.CodeAnalysis; - -namespace WeifenLuo.WinFormsUI.Docking -{ - public sealed class DockPanelExtender - { - #region Fields - - private IAutoHideStripFactory m_autoHideStripFactory = null; - - private IDockPaneCaptionFactory m_dockPaneCaptionFactory = null; - - private IDockPaneFactory m_dockPaneFactory = null; - - private IDockPaneStripFactory m_dockPaneStripFactory = null; - - private IFloatWindowFactory m_floatWindowFactory = null; - - #endregion - - #region cTor - - internal DockPanelExtender(DockPanel dockPanel) - { - DockPanel = dockPanel; - } - - #endregion - - #region Properties - - private DockPanel DockPanel { get; } - - public IDockPaneFactory DockPaneFactory - { - get - { - if (m_dockPaneFactory == null) - { - m_dockPaneFactory = new DefaultDockPaneFactory(); - } - - return m_dockPaneFactory; - } - set - { - if (DockPanel.Panes.Count > 0) - { - throw new InvalidOperationException(); - } - - m_dockPaneFactory = value; - } - } - - public IFloatWindowFactory FloatWindowFactory - { - get - { - if (m_floatWindowFactory == null) - { - m_floatWindowFactory = new DefaultFloatWindowFactory(); - } - - return m_floatWindowFactory; - } - set - { - if (DockPanel.FloatWindows.Count > 0) - { - throw new InvalidOperationException(); - } - - m_floatWindowFactory = value; - } - } - - public IDockPaneCaptionFactory DockPaneCaptionFactory - { - get - { - if (m_dockPaneCaptionFactory == null) - { - m_dockPaneCaptionFactory = new DefaultDockPaneCaptionFactory(); - } - - return m_dockPaneCaptionFactory; - } - set - { - if (DockPanel.Panes.Count > 0) - { - throw new InvalidOperationException(); - } - - m_dockPaneCaptionFactory = value; - } - } - - public IDockPaneStripFactory DockPaneStripFactory - { - get - { - if (m_dockPaneStripFactory == null) - { - m_dockPaneStripFactory = new DefaultDockPaneStripFactory(); - } - - return m_dockPaneStripFactory; - } - set - { - if (DockPanel.Contents.Count > 0) - { - throw new InvalidOperationException(); - } - - m_dockPaneStripFactory = value; - } - } - - public IAutoHideStripFactory AutoHideStripFactory - { - get - { - if (m_autoHideStripFactory == null) - { - m_autoHideStripFactory = new DefaultAutoHideStripFactory(); - } - - return m_autoHideStripFactory; - } - set - { - if (DockPanel.Contents.Count > 0) - { - throw new InvalidOperationException(); - } - - if (m_autoHideStripFactory == value) - { - return; - } - - m_autoHideStripFactory = value; - DockPanel.ResetAutoHideStripControl(); - } - } - - #endregion - - [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] - public interface IDockPaneFactory - { - #region Public methods - - DockPane CreateDockPane(IDockContent content, DockState visibleState, bool show); - - [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters", MessageId = "1#")] - DockPane CreateDockPane(IDockContent content, FloatWindow floatWindow, bool show); - - DockPane CreateDockPane(IDockContent content, DockPane previousPane, DockAlignment alignment, - double proportion, bool show); - - [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters", MessageId = "1#")] - DockPane CreateDockPane(IDockContent content, Rectangle floatWindowBounds, bool show); - - #endregion - } - - [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] - public interface IFloatWindowFactory - { - #region Public methods - - FloatWindow CreateFloatWindow(DockPanel dockPanel, DockPane pane); - FloatWindow CreateFloatWindow(DockPanel dockPanel, DockPane pane, Rectangle bounds); - - #endregion - } - - [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] - public interface IDockPaneCaptionFactory - { - #region Public methods - - DockPaneCaptionBase CreateDockPaneCaption(DockPane pane); - - #endregion - } - - [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] - public interface IDockPaneStripFactory - { - #region Public methods - - DockPaneStripBase CreateDockPaneStrip(DockPane pane); - - #endregion - } - - [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] - public interface IAutoHideStripFactory - { - #region Public methods - - AutoHideStripBase CreateAutoHideStrip(DockPanel panel); - - #endregion - } - - #region DefaultDockPaneFactory - - private class DefaultDockPaneFactory : IDockPaneFactory - { - #region Public methods - - public DockPane CreateDockPane(IDockContent content, DockState visibleState, bool show) - { - return new DockPane(content, visibleState, show); - } - - public DockPane CreateDockPane(IDockContent content, FloatWindow floatWindow, bool show) - { - return new DockPane(content, floatWindow, show); - } - - public DockPane CreateDockPane(IDockContent content, DockPane prevPane, DockAlignment alignment, - double proportion, bool show) - { - return new DockPane(content, prevPane, alignment, proportion, show); - } - - public DockPane CreateDockPane(IDockContent content, Rectangle floatWindowBounds, bool show) - { - return new DockPane(content, floatWindowBounds, show); - } - - #endregion - } - - #endregion - - #region DefaultFloatWindowFactory - - private class DefaultFloatWindowFactory : IFloatWindowFactory - { - #region Public methods - - public FloatWindow CreateFloatWindow(DockPanel dockPanel, DockPane pane) - { - return new FloatWindow(dockPanel, pane); - } - - public FloatWindow CreateFloatWindow(DockPanel dockPanel, DockPane pane, Rectangle bounds) - { - return new FloatWindow(dockPanel, pane, bounds); - } - - #endregion - } - - #endregion - - #region DefaultDockPaneCaptionFactory - - private class DefaultDockPaneCaptionFactory : IDockPaneCaptionFactory - { - #region Public methods - - public DockPaneCaptionBase CreateDockPaneCaption(DockPane pane) - { - return new VS2005DockPaneCaption(pane); - } - - #endregion - } - - #endregion - - #region DefaultDockPaneTabStripFactory - - private class DefaultDockPaneStripFactory : IDockPaneStripFactory - { - #region Public methods - - public DockPaneStripBase CreateDockPaneStrip(DockPane pane) - { - return new VS2005DockPaneStrip(pane); - } - - #endregion - } - - #endregion - - #region DefaultAutoHideStripFactory - - private class DefaultAutoHideStripFactory : IAutoHideStripFactory - { - #region Public methods - - public AutoHideStripBase CreateAutoHideStrip(DockPanel panel) - { - return new VS2005AutoHideStrip(panel); - } - - #endregion - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockPanelSkin.cs b/src/WinFormsUI/Docking/DockPanelSkin.cs deleted file mode 100644 index 1ab2758e..00000000 --- a/src/WinFormsUI/Docking/DockPanelSkin.cs +++ /dev/null @@ -1,482 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Drawing.Design; -using System.Windows.Forms.Design; -using System.ComponentModel; - -namespace WeifenLuo.WinFormsUI.Docking -{ - #region DockPanelSkin classes - - /// - /// The skin to use when displaying the DockPanel. - /// The skin allows custom gradient color schemes to be used when drawing the - /// DockStrips and Tabs. - /// - [TypeConverter(typeof(DockPanelSkinConverter))] - public class DockPanelSkin - { - #region Fields - - #endregion - - #region cTor - - public DockPanelSkin() - { - AutoHideStripSkin = new AutoHideStripSkin(); - DockPaneStripSkin = new DockPaneStripSkin(); - } - - #endregion - - #region Properties - - /// - /// The skin used to display the auto hide strips and tabs. - /// - public AutoHideStripSkin AutoHideStripSkin { get; set; } - - /// - /// The skin used to display the Document and ToolWindow style DockStrips and Tabs. - /// - public DockPaneStripSkin DockPaneStripSkin { get; set; } - - #endregion - } - - /// - /// The skin used to display the auto hide strip and tabs. - /// - [TypeConverter(typeof(AutoHideStripConverter))] - public class AutoHideStripSkin - { - #region Fields - - #endregion - - #region cTor - - public AutoHideStripSkin() - { - DockStripGradient = new DockPanelGradient(); - DockStripGradient.StartColor = SystemColors.ControlLight; - DockStripGradient.EndColor = SystemColors.ControlLight; - - TabGradient = new TabGradient(); - TabGradient.TextColor = SystemColors.ControlDarkDark; - - TextFont = SystemFonts.MenuFont; - } - - #endregion - - #region Properties - - /// - /// The gradient color skin for the DockStrips. - /// - public DockPanelGradient DockStripGradient { get; set; } - - /// - /// The gradient color skin for the Tabs. - /// - public TabGradient TabGradient { get; set; } - - /// - /// Font used in AutoHideStrip elements. - /// - public Font TextFont { get; set; } - - #endregion - } - - /// - /// The skin used to display the document and tool strips and tabs. - /// - [TypeConverter(typeof(DockPaneStripConverter))] - public class DockPaneStripSkin - { - #region Fields - - #endregion - - #region cTor - - public DockPaneStripSkin() - { - DocumentGradient = new DockPaneStripGradient(); - DocumentGradient.DockStripGradient.StartColor = SystemColors.Control; - DocumentGradient.DockStripGradient.EndColor = SystemColors.Control; - DocumentGradient.ActiveTabGradient.StartColor = SystemColors.ControlLightLight; - DocumentGradient.ActiveTabGradient.EndColor = SystemColors.ControlLightLight; - DocumentGradient.InactiveTabGradient.StartColor = SystemColors.ControlLight; - DocumentGradient.InactiveTabGradient.EndColor = SystemColors.ControlLight; - - ToolWindowGradient = new DockPaneStripToolWindowGradient(); - ToolWindowGradient.DockStripGradient.StartColor = SystemColors.ControlLight; - ToolWindowGradient.DockStripGradient.EndColor = SystemColors.ControlLight; - - ToolWindowGradient.ActiveTabGradient.StartColor = SystemColors.Control; - ToolWindowGradient.ActiveTabGradient.EndColor = SystemColors.Control; - - ToolWindowGradient.InactiveTabGradient.StartColor = Color.Transparent; - ToolWindowGradient.InactiveTabGradient.EndColor = Color.Transparent; - ToolWindowGradient.InactiveTabGradient.TextColor = SystemColors.ControlDarkDark; - - ToolWindowGradient.ActiveCaptionGradient.StartColor = SystemColors.GradientActiveCaption; - ToolWindowGradient.ActiveCaptionGradient.EndColor = SystemColors.ActiveCaption; - ToolWindowGradient.ActiveCaptionGradient.LinearGradientMode = LinearGradientMode.Vertical; - ToolWindowGradient.ActiveCaptionGradient.TextColor = SystemColors.ActiveCaptionText; - - ToolWindowGradient.InactiveCaptionGradient.StartColor = SystemColors.GradientInactiveCaption; - ToolWindowGradient.InactiveCaptionGradient.EndColor = SystemColors.InactiveCaption; - ToolWindowGradient.InactiveCaptionGradient.LinearGradientMode = LinearGradientMode.Vertical; - ToolWindowGradient.InactiveCaptionGradient.TextColor = SystemColors.InactiveCaptionText; - - TextFont = SystemFonts.MenuFont; - } - - #endregion - - #region Properties - - /// - /// The skin used to display the Document style DockPane strip and tab. - /// - public DockPaneStripGradient DocumentGradient { get; set; } - - /// - /// The skin used to display the ToolWindow style DockPane strip and tab. - /// - public DockPaneStripToolWindowGradient ToolWindowGradient { get; set; } - - /// - /// Font used in DockPaneStrip elements. - /// - public Font TextFont { get; set; } - - #endregion - } - - /// - /// The skin used to display the DockPane ToolWindow strip and tab. - /// - [TypeConverter(typeof(DockPaneStripGradientConverter))] - public class DockPaneStripToolWindowGradient : DockPaneStripGradient - { - #region Fields - - #endregion - - #region cTor - - public DockPaneStripToolWindowGradient() - { - ActiveCaptionGradient = new TabGradient(); - InactiveCaptionGradient = new TabGradient(); - } - - #endregion - - #region Properties - - /// - /// The skin used to display the active ToolWindow caption. - /// - public TabGradient ActiveCaptionGradient { get; set; } - - /// - /// The skin used to display the inactive ToolWindow caption. - /// - public TabGradient InactiveCaptionGradient { get; set; } - - #endregion - } - - /// - /// The skin used to display the DockPane strip and tab. - /// - [TypeConverter(typeof(DockPaneStripGradientConverter))] - public class DockPaneStripGradient - { - #region Fields - - #endregion - - #region cTor - - public DockPaneStripGradient() - { - DockStripGradient = new DockPanelGradient(); - ActiveTabGradient = new TabGradient(); - InactiveTabGradient = new TabGradient(); - } - - #endregion - - #region Properties - - /// - /// The gradient color skin for the DockStrip. - /// - public DockPanelGradient DockStripGradient { get; set; } - - /// - /// The skin used to display the active DockPane tabs. - /// - public TabGradient ActiveTabGradient { get; set; } - - /// - /// The skin used to display the inactive DockPane tabs. - /// - public TabGradient InactiveTabGradient { get; set; } - - #endregion - } - - /// - /// The skin used to display the dock pane tab - /// - [TypeConverter(typeof(DockPaneTabGradientConverter))] - public class TabGradient : DockPanelGradient - { - #region Fields - - #endregion - - #region cTor - - public TabGradient() - { - TextColor = SystemColors.ControlText; - } - - #endregion - - #region Properties - - /// - /// The text color. - /// - [DefaultValue(typeof(SystemColors), "ControlText")] - public Color TextColor { get; set; } - - #endregion - } - - /// - /// The gradient color skin. - /// - [TypeConverter(typeof(DockPanelGradientConverter))] - public class DockPanelGradient - { - #region Fields - - #endregion - - #region cTor - - public DockPanelGradient() - { - StartColor = SystemColors.Control; - EndColor = SystemColors.Control; - LinearGradientMode = LinearGradientMode.Horizontal; - } - - #endregion - - #region Properties - - /// - /// The beginning gradient color. - /// - [DefaultValue(typeof(SystemColors), "Control")] - public Color StartColor { get; set; } - - /// - /// The ending gradient color. - /// - [DefaultValue(typeof(SystemColors), "Control")] - public Color EndColor { get; set; } - - /// - /// The gradient mode to display the colors. - /// - [DefaultValue(LinearGradientMode.Horizontal)] - public LinearGradientMode LinearGradientMode { get; set; } - - #endregion - } - - #endregion - - #region Converters - - public class DockPanelSkinConverter : ExpandableObjectConverter - { - #region Public methods - - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) - { - if (destinationType == typeof(DockPanelSkin)) - { - return true; - } - - return base.CanConvertTo(context, destinationType); - } - - public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, - object value, Type destinationType) - { - if (destinationType == typeof(string) && value is DockPanelSkin) - { - return "DockPanelSkin"; - } - return base.ConvertTo(context, culture, value, destinationType); - } - - #endregion - } - - public class DockPanelGradientConverter : ExpandableObjectConverter - { - #region Public methods - - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) - { - if (destinationType == typeof(DockPanelGradient)) - { - return true; - } - - return base.CanConvertTo(context, destinationType); - } - - public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, - object value, Type destinationType) - { - if (destinationType == typeof(string) && value is DockPanelGradient) - { - return "DockPanelGradient"; - } - return base.ConvertTo(context, culture, value, destinationType); - } - - #endregion - } - - public class AutoHideStripConverter : ExpandableObjectConverter - { - #region Public methods - - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) - { - if (destinationType == typeof(AutoHideStripSkin)) - { - return true; - } - - return base.CanConvertTo(context, destinationType); - } - - public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, - object value, Type destinationType) - { - if (destinationType == typeof(string) && value is AutoHideStripSkin) - { - return "AutoHideStripSkin"; - } - return base.ConvertTo(context, culture, value, destinationType); - } - - #endregion - } - - public class DockPaneStripConverter : ExpandableObjectConverter - { - #region Public methods - - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) - { - if (destinationType == typeof(DockPaneStripSkin)) - { - return true; - } - - return base.CanConvertTo(context, destinationType); - } - - public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, - object value, Type destinationType) - { - if (destinationType == typeof(string) && value is DockPaneStripSkin) - { - return "DockPaneStripSkin"; - } - return base.ConvertTo(context, culture, value, destinationType); - } - - #endregion - } - - public class DockPaneStripGradientConverter : ExpandableObjectConverter - { - #region Public methods - - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) - { - if (destinationType == typeof(DockPaneStripGradient)) - { - return true; - } - - return base.CanConvertTo(context, destinationType); - } - - public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, - object value, Type destinationType) - { - if (destinationType == typeof(string) && value is DockPaneStripGradient) - { - return "DockPaneStripGradient"; - } - return base.ConvertTo(context, culture, value, destinationType); - } - - #endregion - } - - public class DockPaneTabGradientConverter : ExpandableObjectConverter - { - #region Public methods - - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) - { - if (destinationType == typeof(TabGradient)) - { - return true; - } - - return base.CanConvertTo(context, destinationType); - } - - public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, - object value, Type destinationType) - { - if (destinationType == typeof(string) && value is TabGradient) - { - return "DockPaneTabGradient"; - } - return base.ConvertTo(context, culture, value, destinationType); - } - - #endregion - } - - #endregion -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockWindow.SplitterControl.cs b/src/WinFormsUI/Docking/DockWindow.SplitterControl.cs deleted file mode 100644 index 5e8f761d..00000000 --- a/src/WinFormsUI/Docking/DockWindow.SplitterControl.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections; -using System.ComponentModel; -using System.Drawing; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - public partial class DockWindow - { - private class SplitterControl : SplitterBase - { - #region Properties - - protected override int SplitterSize - { - get { return Measures.SplitterSize; } - } - - #endregion - - #region Overrides - - protected override void StartDrag() - { - DockWindow window = Parent as DockWindow; - if (window == null) - { - return; - } - - window.DockPanel.BeginDrag(window, window.RectangleToScreen(Bounds)); - } - - #endregion - } - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockWindow.cs b/src/WinFormsUI/Docking/DockWindow.cs deleted file mode 100644 index a5133b6f..00000000 --- a/src/WinFormsUI/Docking/DockWindow.cs +++ /dev/null @@ -1,283 +0,0 @@ -using System; -using System.Windows.Forms; -using System.Drawing; -using System.Runtime.InteropServices; -using System.ComponentModel; - -namespace WeifenLuo.WinFormsUI.Docking -{ - [ToolboxItem(false)] - public partial class DockWindow : Panel, INestedPanesContainer, ISplitterDragSource - { - #region Fields - - private readonly SplitterControl m_splitter; - - #endregion - - #region cTor - - internal DockWindow(DockPanel dockPanel, DockState dockState) - { - NestedPanes = new NestedPaneCollection(this); - DockPanel = dockPanel; - DockState = dockState; - Visible = false; - - SuspendLayout(); - - if (DockState == DockState.DockLeft || DockState == DockState.DockRight || - DockState == DockState.DockTop || DockState == DockState.DockBottom) - { - m_splitter = new SplitterControl(); - Controls.Add(m_splitter); - } - - if (DockState == DockState.DockLeft) - { - Dock = DockStyle.Left; - m_splitter.Dock = DockStyle.Right; - } - else if (DockState == DockState.DockRight) - { - Dock = DockStyle.Right; - m_splitter.Dock = DockStyle.Left; - } - else if (DockState == DockState.DockTop) - { - Dock = DockStyle.Top; - m_splitter.Dock = DockStyle.Bottom; - } - else if (DockState == DockState.DockBottom) - { - Dock = DockStyle.Bottom; - m_splitter.Dock = DockStyle.Top; - } - else if (DockState == DockState.Document) - { - Dock = DockStyle.Fill; - } - - ResumeLayout(); - } - - #endregion - - #region Properties - - public VisibleNestedPaneCollection VisibleNestedPanes - { - get { return NestedPanes.VisibleNestedPanes; } - } - - public NestedPaneCollection NestedPanes { get; } - - public DockPanel DockPanel { get; } - - public DockState DockState { get; } - - public bool IsFloat - { - get { return DockState == DockState.Float; } - } - - internal DockPane DefaultPane - { - get { return VisibleNestedPanes.Count == 0 ? null : VisibleNestedPanes[0]; } - } - - public virtual Rectangle DisplayingRectangle - { - get - { - Rectangle rect = ClientRectangle; - // if DockWindow is document, exclude the border - if (DockState == DockState.Document) - { - rect.X += 1; - rect.Y += 1; - rect.Width -= 2; - rect.Height -= 2; - } - // exclude the splitter - else if (DockState == DockState.DockLeft) - { - rect.Width -= Measures.SplitterSize; - } - else if (DockState == DockState.DockRight) - { - rect.X += Measures.SplitterSize; - rect.Width -= Measures.SplitterSize; - } - else if (DockState == DockState.DockTop) - { - rect.Height -= Measures.SplitterSize; - } - else if (DockState == DockState.DockBottom) - { - rect.Y += Measures.SplitterSize; - rect.Height -= Measures.SplitterSize; - } - - return rect; - } - } - - #endregion - - #region Overrides - - protected override void OnPaint(PaintEventArgs e) - { - // if DockWindow is document, draw the border - if (DockState == DockState.Document) - { - e.Graphics.DrawRectangle(SystemPens.ControlDark, ClientRectangle.X, ClientRectangle.Y, - ClientRectangle.Width - 1, ClientRectangle.Height - 1); - } - - base.OnPaint(e); - } - - protected override void OnLayout(LayoutEventArgs levent) - { - VisibleNestedPanes.Refresh(); - if (VisibleNestedPanes.Count == 0) - { - if (Visible) - { - Visible = false; - } - } - else if (!Visible) - { - Visible = true; - VisibleNestedPanes.Refresh(); - } - - base.OnLayout(levent); - } - - #endregion - - #region ISplitterDragSource Members - - void ISplitterDragSource.BeginDrag(Rectangle rectSplitter) - { - } - - void ISplitterDragSource.EndDrag() - { - } - - bool ISplitterDragSource.IsVertical - { - get { return DockState == DockState.DockLeft || DockState == DockState.DockRight; } - } - - Rectangle ISplitterDragSource.DragLimitBounds - { - get - { - Rectangle rectLimit = DockPanel.DockArea; - Point location; - if ((Control.ModifierKeys & Keys.Shift) == 0) - { - location = Location; - } - else - { - location = DockPanel.DockArea.Location; - } - - if (((ISplitterDragSource) this).IsVertical) - { - rectLimit.X += MeasurePane.MinSize; - rectLimit.Width -= 2 * MeasurePane.MinSize; - rectLimit.Y = location.Y; - if ((Control.ModifierKeys & Keys.Shift) == 0) - { - rectLimit.Height = Height; - } - } - else - { - rectLimit.Y += MeasurePane.MinSize; - rectLimit.Height -= 2 * MeasurePane.MinSize; - rectLimit.X = location.X; - if ((Control.ModifierKeys & Keys.Shift) == 0) - { - rectLimit.Width = Width; - } - } - - return DockPanel.RectangleToScreen(rectLimit); - } - } - - void ISplitterDragSource.MoveSplitter(int offset) - { - if ((Control.ModifierKeys & Keys.Shift) != 0) - { - SendToBack(); - } - - Rectangle rectDockArea = DockPanel.DockArea; - if (DockState == DockState.DockLeft && rectDockArea.Width > 0) - { - if (DockPanel.DockLeftPortion > 1) - { - DockPanel.DockLeftPortion = Width + offset; - } - else - { - DockPanel.DockLeftPortion += (double) offset / (double) rectDockArea.Width; - } - } - else if (DockState == DockState.DockRight && rectDockArea.Width > 0) - { - if (DockPanel.DockRightPortion > 1) - { - DockPanel.DockRightPortion = Width - offset; - } - else - { - DockPanel.DockRightPortion -= (double) offset / (double) rectDockArea.Width; - } - } - else if (DockState == DockState.DockBottom && rectDockArea.Height > 0) - { - if (DockPanel.DockBottomPortion > 1) - { - DockPanel.DockBottomPortion = Height - offset; - } - else - { - DockPanel.DockBottomPortion -= (double) offset / (double) rectDockArea.Height; - } - } - else if (DockState == DockState.DockTop && rectDockArea.Height > 0) - { - if (DockPanel.DockTopPortion > 1) - { - DockPanel.DockTopPortion = Height + offset; - } - else - { - DockPanel.DockTopPortion += (double) offset / (double) rectDockArea.Height; - } - } - } - - #region IDragSource Members - - Control IDragSource.DragControl - { - get { return this; } - } - - #endregion - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DockWindowCollection.cs b/src/WinFormsUI/Docking/DockWindowCollection.cs deleted file mode 100644 index 0c0af785..00000000 --- a/src/WinFormsUI/Docking/DockWindowCollection.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; - -namespace WeifenLuo.WinFormsUI.Docking -{ - public class DockWindowCollection : ReadOnlyCollection - { - #region cTor - - internal DockWindowCollection(DockPanel dockPanel) - : base(new List()) - { - Items.Add(new DockWindow(dockPanel, DockState.Document)); - Items.Add(new DockWindow(dockPanel, DockState.DockLeft)); - Items.Add(new DockWindow(dockPanel, DockState.DockRight)); - Items.Add(new DockWindow(dockPanel, DockState.DockTop)); - Items.Add(new DockWindow(dockPanel, DockState.DockBottom)); - } - - #endregion - - #region Properties - - public DockWindow this[DockState dockState] - { - get - { - if (dockState == DockState.Document) - { - return Items[0]; - } - else if (dockState == DockState.DockLeft || dockState == DockState.DockLeftAutoHide) - { - return Items[1]; - } - else if (dockState == DockState.DockRight || dockState == DockState.DockRightAutoHide) - { - return Items[2]; - } - else if (dockState == DockState.DockTop || dockState == DockState.DockTopAutoHide) - { - return Items[3]; - } - else if (dockState == DockState.DockBottom || dockState == DockState.DockBottomAutoHide) - { - return Items[4]; - } - - throw new ArgumentOutOfRangeException(); - } - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DragForm.cs b/src/WinFormsUI/Docking/DragForm.cs deleted file mode 100644 index f250e21c..00000000 --- a/src/WinFormsUI/Docking/DragForm.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - // Inspired by Chris Sano's article: - // http://msdn.microsoft.com/smartclient/default.aspx?pull=/library/en-us/dnwinforms/html/colorpicker.asp - // In Sano's article, the DragForm needs to meet the following criteria: - // (1) it was not to show up in the task bar; - // ShowInTaskBar = false - // (2) it needed to be the top-most window; - // TopMost = true (not necessary here) - // (3) its icon could not show up in the ALT+TAB window if the user pressed ALT+TAB during a drag-and-drop; - // FormBorderStyle = FormBorderStyle.None; - // Create with WS_EX_TOOLWINDOW window style. - // Compares with the solution in the artile by setting FormBorderStyle as FixedToolWindow, - // and then clip the window caption and border, this way is much simplier. - // (4) it was not to steal focus from the application when displayed. - // User Win32 ShowWindow API with SW_SHOWNOACTIVATE - // In addition, this form should only for display and therefore should act as transparent, otherwise - // WindowFromPoint will return this form, instead of the control beneath. Need BOTH of the following to - // achieve this (don't know why, spent hours to try it out :( ): - // 1. Enabled = false; - // 2. WM_NCHITTEST returns HTTRANSPARENT - internal class DragForm : Form - { - #region cTor - - public DragForm() - { - FormBorderStyle = FormBorderStyle.None; - ShowInTaskbar = false; - SetStyle(ControlStyles.Selectable, false); - Enabled = false; - } - - #endregion - - #region Properties - - protected override CreateParams CreateParams - { - get - { - CreateParams createParams = base.CreateParams; - createParams.ExStyle |= (int) Win32.WindowExStyles.WS_EX_TOOLWINDOW; - return createParams; - } - } - - #endregion - - #region Public methods - - public virtual void Show(bool bActivate) - { - if (bActivate) - { - Show(); - } - else - { - NativeMethods.ShowWindow(Handle, (int) Win32.ShowWindowStyles.SW_SHOWNOACTIVATE); - } - } - - #endregion - - #region Overrides - - protected override void WndProc(ref Message m) - { - if (m.Msg == (int) Win32.Msgs.WM_NCHITTEST) - { - m.Result = (IntPtr) Win32.HitTest.HTTRANSPARENT; - return; - } - - base.WndProc(ref m); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/DummyControl.cs b/src/WinFormsUI/Docking/DummyControl.cs deleted file mode 100644 index 7933d0ca..00000000 --- a/src/WinFormsUI/Docking/DummyControl.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - internal class DummyControl : Control - { - #region cTor - - public DummyControl() - { - SetStyle(ControlStyles.Selectable, false); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/Enums.cs b/src/WinFormsUI/Docking/Enums.cs deleted file mode 100644 index 4a748031..00000000 --- a/src/WinFormsUI/Docking/Enums.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.ComponentModel; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - [Flags] - [Serializable] - [Editor(typeof(DockAreasEditor), typeof(System.Drawing.Design.UITypeEditor))] - public enum DockAreas - { - Float = 1, - DockLeft = 2, - DockRight = 4, - DockTop = 8, - DockBottom = 16, - Document = 32 - } - - public enum DockState - { - Unknown = 0, - Float = 1, - DockTopAutoHide = 2, - DockLeftAutoHide = 3, - DockBottomAutoHide = 4, - DockRightAutoHide = 5, - Document = 6, - DockTop = 7, - DockLeft = 8, - DockBottom = 9, - DockRight = 10, - Hidden = 11 - } - - public enum DockAlignment - { - Left, - Right, - Top, - Bottom - } - - public enum DocumentStyle - { - DockingMdi, - DockingWindow, - DockingSdi, - SystemMdi, - } - - /// - /// The location to draw the DockPaneStrip for Document style windows. - /// - public enum DocumentTabStripLocation - { - Top, - Bottom - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/FloatWindow.cs b/src/WinFormsUI/Docking/FloatWindow.cs deleted file mode 100644 index e341137a..00000000 --- a/src/WinFormsUI/Docking/FloatWindow.cs +++ /dev/null @@ -1,551 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Drawing; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - public class FloatWindow : Form, INestedPanesContainer, IDockDragSource - { - #region Fields - - internal const int WM_CHECKDISPOSE = (int) (Win32.Msgs.WM_USER + 1); - - #endregion - - #region cTor - - internal protected FloatWindow(DockPanel dockPanel, DockPane pane) - { - InternalConstruct(dockPanel, pane, false, Rectangle.Empty); - } - - internal protected FloatWindow(DockPanel dockPanel, DockPane pane, Rectangle bounds) - { - InternalConstruct(dockPanel, pane, true, bounds); - } - - #endregion - - #region Properties - - public bool AllowEndUserDocking { get; set; } = true; - - public NestedPaneCollection NestedPanes { get; private set; } - - public VisibleNestedPaneCollection VisibleNestedPanes - { - get { return NestedPanes.VisibleNestedPanes; } - } - - public DockPanel DockPanel { get; private set; } - - public DockState DockState - { - get { return DockState.Float; } - } - - public bool IsFloat - { - get { return DockState == DockState.Float; } - } - - public virtual Rectangle DisplayingRectangle - { - get { return ClientRectangle; } - } - - #endregion - - #region Internals - - internal bool IsDockStateValid(DockState dockState) - { - foreach (DockPane pane in NestedPanes) - foreach (IDockContent content in pane.Contents) - { - if (!DockHelper.IsDockStateValid(dockState, content.DockHandler.DockAreas)) - { - return false; - } - } - - return true; - } - - - [SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = - "System.Windows.Forms.Control.set_Text(System.String)")] - internal void SetText() - { - DockPane theOnlyPane = VisibleNestedPanes.Count == 1 ? VisibleNestedPanes[0] : null; - - if (theOnlyPane == null) - { - Text = " "; // use " " instead of string.Empty because the whole title bar will disappear when ControlBox is set to false. - } - else if (theOnlyPane.ActiveContent == null) - { - Text = " "; - } - else - { - Text = theOnlyPane.ActiveContent.DockHandler.TabText; - } - } - - internal void RefreshChanges() - { - if (IsDisposed) - { - return; - } - - if (VisibleNestedPanes.Count == 0) - { - ControlBox = true; - return; - } - - for (int i = VisibleNestedPanes.Count - 1; i >= 0; i--) - { - DockContentCollection contents = VisibleNestedPanes[i].Contents; - for (int j = contents.Count - 1; j >= 0; j--) - { - IDockContent content = contents[j]; - if (content.DockHandler.DockState != DockState.Float) - { - continue; - } - - if (content.DockHandler.CloseButton && content.DockHandler.CloseButtonVisible) - { - ControlBox = true; - return; - } - } - } - //Only if there is a ControlBox do we turn it off - //old code caused a flash of the window. - if (ControlBox) - { - ControlBox = false; - } - } - - internal void TestDrop(IDockDragSource dragSource, DockOutlineBase dockOutline) - { - if (VisibleNestedPanes.Count == 1) - { - DockPane pane = VisibleNestedPanes[0]; - if (!dragSource.CanDockTo(pane)) - { - return; - } - - Point ptMouse = Control.MousePosition; - uint lParam = Win32Helper.MakeLong(ptMouse.X, ptMouse.Y); - if (NativeMethods.SendMessage(Handle, (int) Win32.Msgs.WM_NCHITTEST, 0, lParam) == - (uint) Win32.HitTest.HTCAPTION) - { - dockOutline.Show(VisibleNestedPanes[0], -1); - } - } - } - - #endregion - - #region Overrides - - protected override void Dispose(bool disposing) - { - if (disposing) - { - if (DockPanel != null) - { - DockPanel.RemoveFloatWindow(this); - } - DockPanel = null; - } - base.Dispose(disposing); - } - - protected override void OnActivated(EventArgs e) - { - DockPanel.FloatWindows.BringWindowToFront(this); - base.OnActivated(e); - // Propagate the Activated event to the visible panes content objects - foreach (DockPane pane in VisibleNestedPanes) - foreach (IDockContent content in pane.Contents) - { - content.OnActivated(e); - } - } - - protected override void OnDeactivate(EventArgs e) - { - base.OnDeactivate(e); - // Propagate the Deactivate event to the visible panes content objects - foreach (DockPane pane in VisibleNestedPanes) - foreach (IDockContent content in pane.Contents) - { - content.OnDeactivate(e); - } - } - - protected override void OnLayout(LayoutEventArgs levent) - { - VisibleNestedPanes.Refresh(); - RefreshChanges(); - Visible = VisibleNestedPanes.Count > 0; - SetText(); - - base.OnLayout(levent); - } - - protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) - { - Rectangle rectWorkArea = SystemInformation.VirtualScreen; - - if (y + height > rectWorkArea.Bottom) - { - y -= y + height - rectWorkArea.Bottom; - } - - if (y < rectWorkArea.Top) - { - y += rectWorkArea.Top - y; - } - - base.SetBoundsCore(x, y, width, height, specified); - } - - protected override void WndProc(ref Message m) - { - if (m.Msg == (int) Win32.Msgs.WM_NCLBUTTONDOWN) - { - if (IsDisposed) - { - return; - } - - uint result = NativeMethods.SendMessage(this.Handle, (int) Win32.Msgs.WM_NCHITTEST, 0, (uint) m.LParam); - if (result == 2 && DockPanel.AllowEndUserDocking && this.AllowEndUserDocking) // HITTEST_CAPTION - { - Activate(); - DockPanel.BeginDrag(this); - } - else - { - base.WndProc(ref m); - } - - return; - } - else if (m.Msg == (int) Win32.Msgs.WM_NCRBUTTONDOWN) - { - uint result = NativeMethods.SendMessage(this.Handle, (int) Win32.Msgs.WM_NCHITTEST, 0, (uint) m.LParam); - if (result == 2) // HITTEST_CAPTION - { - DockPane theOnlyPane = VisibleNestedPanes.Count == 1 ? VisibleNestedPanes[0] : null; - if (theOnlyPane != null && theOnlyPane.ActiveContent != null) - { - theOnlyPane.ShowTabPageContextMenu(this, PointToClient(Control.MousePosition)); - return; - } - } - - base.WndProc(ref m); - return; - } - else if (m.Msg == (int) Win32.Msgs.WM_CLOSE) - { - if (NestedPanes.Count == 0) - { - base.WndProc(ref m); - return; - } - - for (int i = NestedPanes.Count - 1; i >= 0; i--) - { - DockContentCollection contents = NestedPanes[i].Contents; - for (int j = contents.Count - 1; j >= 0; j--) - { - IDockContent content = contents[j]; - if (content.DockHandler.DockState != DockState.Float) - { - continue; - } - - if (!content.DockHandler.CloseButton) - { - continue; - } - - if (content.DockHandler.HideOnClose) - { - content.DockHandler.Hide(); - } - else - { - content.DockHandler.Close(); - } - } - } - - return; - } - else if (m.Msg == (int) Win32.Msgs.WM_NCLBUTTONDBLCLK) - { - uint result = NativeMethods.SendMessage(this.Handle, (int) Win32.Msgs.WM_NCHITTEST, 0, (uint) m.LParam); - if (result != 2) // HITTEST_CAPTION - { - base.WndProc(ref m); - return; - } - - DockPanel.SuspendLayout(true); - - // Restore to panel - foreach (DockPane pane in NestedPanes) - { - if (pane.DockState != DockState.Float) - { - continue; - } - pane.RestoreToPanel(); - } - - - DockPanel.ResumeLayout(true, true); - return; - } - else if (m.Msg == WM_CHECKDISPOSE) - { - if (NestedPanes.Count == 0) - { - Dispose(); - } - - return; - } - - base.WndProc(ref m); - } - - #endregion - - #region Private Methods - - private void InternalConstruct(DockPanel dockPanel, DockPane pane, bool boundsSpecified, Rectangle bounds) - { - if (dockPanel == null) - { - throw new ArgumentNullException(Strings.FloatWindow_Constructor_NullDockPanel); - } - - NestedPanes = new NestedPaneCollection(this); - - FormBorderStyle = FormBorderStyle.SizableToolWindow; - ShowInTaskbar = false; - if (dockPanel.RightToLeft != RightToLeft) - { - RightToLeft = dockPanel.RightToLeft; - } - if (RightToLeftLayout != dockPanel.RightToLeftLayout) - { - RightToLeftLayout = dockPanel.RightToLeftLayout; - } - - SuspendLayout(); - if (boundsSpecified) - { - Bounds = bounds; - StartPosition = FormStartPosition.Manual; - } - else - { - StartPosition = FormStartPosition.WindowsDefaultLocation; - Size = dockPanel.DefaultFloatWindowSize; - } - - DockPanel = dockPanel; - Owner = DockPanel.FindForm(); - DockPanel.AddFloatWindow(this); - if (pane != null) - { - pane.FloatWindow = this; - } - - ResumeLayout(); - } - - #endregion - - #region IDockDragSource Members - - #region IDragSource Members - - Control IDragSource.DragControl - { - get { return this; } - } - - #endregion - - bool IDockDragSource.IsDockStateValid(DockState dockState) - { - return IsDockStateValid(dockState); - } - - bool IDockDragSource.CanDockTo(DockPane pane) - { - if (!IsDockStateValid(pane.DockState)) - { - return false; - } - - if (pane.FloatWindow == this) - { - return false; - } - - return true; - } - - Rectangle IDockDragSource.BeginDrag(Point ptMouse) - { - return Bounds; - } - - public void FloatAt(Rectangle floatWindowBounds) - { - Bounds = floatWindowBounds; - } - - public void DockTo(DockPane pane, DockStyle dockStyle, int contentIndex) - { - if (dockStyle == DockStyle.Fill) - { - for (int i = NestedPanes.Count - 1; i >= 0; i--) - { - DockPane paneFrom = NestedPanes[i]; - for (int j = paneFrom.Contents.Count - 1; j >= 0; j--) - { - IDockContent c = paneFrom.Contents[j]; - c.DockHandler.Pane = pane; - if (contentIndex != -1) - { - pane.SetContentIndex(c, contentIndex); - } - c.DockHandler.Activate(); - } - } - } - else - { - DockAlignment alignment = DockAlignment.Left; - if (dockStyle == DockStyle.Left) - { - alignment = DockAlignment.Left; - } - else if (dockStyle == DockStyle.Right) - { - alignment = DockAlignment.Right; - } - else if (dockStyle == DockStyle.Top) - { - alignment = DockAlignment.Top; - } - else if (dockStyle == DockStyle.Bottom) - { - alignment = DockAlignment.Bottom; - } - - MergeNestedPanes(VisibleNestedPanes, pane.NestedPanesContainer.NestedPanes, pane, alignment, 0.5); - } - } - - public void DockTo(DockPanel panel, DockStyle dockStyle) - { - if (panel != DockPanel) - { - throw new ArgumentException(Strings.IDockDragSource_DockTo_InvalidPanel, "panel"); - } - - NestedPaneCollection nestedPanesTo = null; - - if (dockStyle == DockStyle.Top) - { - nestedPanesTo = DockPanel.DockWindows[DockState.DockTop].NestedPanes; - } - else if (dockStyle == DockStyle.Bottom) - { - nestedPanesTo = DockPanel.DockWindows[DockState.DockBottom].NestedPanes; - } - else if (dockStyle == DockStyle.Left) - { - nestedPanesTo = DockPanel.DockWindows[DockState.DockLeft].NestedPanes; - } - else if (dockStyle == DockStyle.Right) - { - nestedPanesTo = DockPanel.DockWindows[DockState.DockRight].NestedPanes; - } - else if (dockStyle == DockStyle.Fill) - { - nestedPanesTo = DockPanel.DockWindows[DockState.Document].NestedPanes; - } - - DockPane prevPane = null; - for (int i = nestedPanesTo.Count - 1; i >= 0; i--) - { - if (nestedPanesTo[i] != VisibleNestedPanes[0]) - { - prevPane = nestedPanesTo[i]; - } - } - MergeNestedPanes(VisibleNestedPanes, nestedPanesTo, prevPane, DockAlignment.Left, 0.5); - } - - private static void MergeNestedPanes(VisibleNestedPaneCollection nestedPanesFrom, - NestedPaneCollection nestedPanesTo, DockPane prevPane, DockAlignment alignment, double proportion) - { - if (nestedPanesFrom.Count == 0) - { - return; - } - - int count = nestedPanesFrom.Count; - DockPane[] panes = new DockPane[count]; - DockPane[] prevPanes = new DockPane[count]; - DockAlignment[] alignments = new DockAlignment[count]; - double[] proportions = new double[count]; - - for (int i = 0; i < count; i++) - { - panes[i] = nestedPanesFrom[i]; - prevPanes[i] = nestedPanesFrom[i].NestedDockingStatus.PreviousPane; - alignments[i] = nestedPanesFrom[i].NestedDockingStatus.Alignment; - proportions[i] = nestedPanesFrom[i].NestedDockingStatus.Proportion; - } - - DockPane pane = panes[0].DockTo(nestedPanesTo.Container, prevPane, alignment, proportion); - panes[0].DockState = nestedPanesTo.DockState; - - for (int i = 1; i < count; i++) - { - for (int j = i; j < count; j++) - { - if (prevPanes[j] == panes[i - 1]) - { - prevPanes[j] = pane; - } - } - pane = panes[i].DockTo(nestedPanesTo.Container, prevPanes[i], alignments[i], proportions[i]); - panes[i].DockState = nestedPanesTo.DockState; - } - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/FloatWindowCollection.cs b/src/WinFormsUI/Docking/FloatWindowCollection.cs deleted file mode 100644 index fa5434b5..00000000 --- a/src/WinFormsUI/Docking/FloatWindowCollection.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Drawing; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - public class FloatWindowCollection : ReadOnlyCollection - { - #region cTor - - internal FloatWindowCollection() - : base(new List()) - { - } - - #endregion - - #region Internals - - internal int Add(FloatWindow fw) - { - if (Items.Contains(fw)) - { - return Items.IndexOf(fw); - } - - Items.Add(fw); - return Count - 1; - } - - internal void Dispose() - { - for (int i = Count - 1; i >= 0; i--) - { - this[i].Close(); - } - } - - internal void Remove(FloatWindow fw) - { - Items.Remove(fw); - } - - internal void BringWindowToFront(FloatWindow fw) - { - Items.Remove(fw); - Items.Add(fw); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/Helpers/DockHelper.cs b/src/WinFormsUI/Docking/Helpers/DockHelper.cs deleted file mode 100644 index 1d7c5112..00000000 --- a/src/WinFormsUI/Docking/Helpers/DockHelper.cs +++ /dev/null @@ -1,153 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - internal static class DockHelper - { - #region Public methods - - public static bool IsDockStateAutoHide(DockState dockState) - { - if (dockState == DockState.DockLeftAutoHide || - dockState == DockState.DockRightAutoHide || - dockState == DockState.DockTopAutoHide || - dockState == DockState.DockBottomAutoHide) - { - return true; - } - else - { - return false; - } - } - - public static bool IsDockStateValid(DockState dockState, DockAreas dockableAreas) - { - if ((dockableAreas & DockAreas.Float) == 0 && - dockState == DockState.Float) - { - return false; - } - else if ((dockableAreas & DockAreas.Document) == 0 && - dockState == DockState.Document) - { - return false; - } - else if ((dockableAreas & DockAreas.DockLeft) == 0 && - (dockState == DockState.DockLeft || dockState == DockState.DockLeftAutoHide)) - { - return false; - } - else if ((dockableAreas & DockAreas.DockRight) == 0 && - (dockState == DockState.DockRight || dockState == DockState.DockRightAutoHide)) - { - return false; - } - else if ((dockableAreas & DockAreas.DockTop) == 0 && - (dockState == DockState.DockTop || dockState == DockState.DockTopAutoHide)) - { - return false; - } - else if ((dockableAreas & DockAreas.DockBottom) == 0 && - (dockState == DockState.DockBottom || dockState == DockState.DockBottomAutoHide)) - { - return false; - } - else - { - return true; - } - } - - public static bool IsDockWindowState(DockState state) - { - if (state == DockState.DockTop || state == DockState.DockBottom || state == DockState.DockLeft || - state == DockState.DockRight || state == DockState.Document) - { - return true; - } - else - { - return false; - } - } - - public static DockState ToggleAutoHideState(DockState state) - { - if (state == DockState.DockLeft) - { - return DockState.DockLeftAutoHide; - } - else if (state == DockState.DockRight) - { - return DockState.DockRightAutoHide; - } - else if (state == DockState.DockTop) - { - return DockState.DockTopAutoHide; - } - else if (state == DockState.DockBottom) - { - return DockState.DockBottomAutoHide; - } - else if (state == DockState.DockLeftAutoHide) - { - return DockState.DockLeft; - } - else if (state == DockState.DockRightAutoHide) - { - return DockState.DockRight; - } - else if (state == DockState.DockTopAutoHide) - { - return DockState.DockTop; - } - else if (state == DockState.DockBottomAutoHide) - { - return DockState.DockBottom; - } - else - { - return state; - } - } - - public static DockPane PaneAtPoint(Point pt, DockPanel dockPanel) - { - for (Control control = Win32Helper.ControlAtPoint(pt); control != null; control = control.Parent) - { - IDockContent content = control as IDockContent; - if (content != null && content.DockHandler.DockPanel == dockPanel) - { - return content.DockHandler.Pane; - } - - DockPane pane = control as DockPane; - if (pane != null && pane.DockPanel == dockPanel) - { - return pane; - } - } - - return null; - } - - public static FloatWindow FloatWindowAtPoint(Point pt, DockPanel dockPanel) - { - for (Control control = Win32Helper.ControlAtPoint(pt); control != null; control = control.Parent) - { - FloatWindow floatWindow = control as FloatWindow; - if (floatWindow != null && floatWindow.DockPanel == dockPanel) - { - return floatWindow; - } - } - - return null; - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/Helpers/DrawHelper.cs b/src/WinFormsUI/Docking/Helpers/DrawHelper.cs deleted file mode 100644 index 742697bb..00000000 --- a/src/WinFormsUI/Docking/Helpers/DrawHelper.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Drawing.Imaging; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - internal static class DrawHelper - { - #region Public methods - - public static Point RtlTransform(Control control, Point point) - { - if (control.RightToLeft != RightToLeft.Yes) - { - return point; - } - else - { - return new Point(control.Right - point.X, point.Y); - } - } - - public static Rectangle RtlTransform(Control control, Rectangle rectangle) - { - if (control.RightToLeft != RightToLeft.Yes) - { - return rectangle; - } - else - { - return new Rectangle(control.ClientRectangle.Right - rectangle.Right, rectangle.Y, rectangle.Width, - rectangle.Height); - } - } - - public static GraphicsPath GetRoundedCornerTab(GraphicsPath graphicsPath, Rectangle rect, bool upCorner) - { - if (graphicsPath == null) - { - graphicsPath = new GraphicsPath(); - } - else - { - graphicsPath.Reset(); - } - - int curveSize = 6; - if (upCorner) - { - graphicsPath.AddLine(rect.Left, rect.Bottom, rect.Left, rect.Top + curveSize / 2); - graphicsPath.AddArc(new Rectangle(rect.Left, rect.Top, curveSize, curveSize), 180, 90); - graphicsPath.AddLine(rect.Left + curveSize / 2, rect.Top, rect.Right - curveSize / 2, rect.Top); - graphicsPath.AddArc(new Rectangle(rect.Right - curveSize, rect.Top, curveSize, curveSize), -90, 90); - graphicsPath.AddLine(rect.Right, rect.Top + curveSize / 2, rect.Right, rect.Bottom); - } - else - { - graphicsPath.AddLine(rect.Right, rect.Top, rect.Right, rect.Bottom - curveSize / 2); - graphicsPath.AddArc( - new Rectangle(rect.Right - curveSize, rect.Bottom - curveSize, curveSize, curveSize), 0, 90); - graphicsPath.AddLine(rect.Right - curveSize / 2, rect.Bottom, rect.Left + curveSize / 2, rect.Bottom); - graphicsPath.AddArc(new Rectangle(rect.Left, rect.Bottom - curveSize, curveSize, curveSize), 90, 90); - graphicsPath.AddLine(rect.Left, rect.Bottom - curveSize / 2, rect.Left, rect.Top); - } - - return graphicsPath; - } - - public static GraphicsPath CalculateGraphicsPathFromBitmap(Bitmap bitmap) - { - return CalculateGraphicsPathFromBitmap(bitmap, Color.Empty); - } - - // From http://edu.cnzz.cn/show_3281.html - public static GraphicsPath CalculateGraphicsPathFromBitmap(Bitmap bitmap, Color colorTransparent) - { - GraphicsPath graphicsPath = new GraphicsPath(); - if (colorTransparent == Color.Empty) - { - colorTransparent = bitmap.GetPixel(0, 0); - } - - for (int row = 0; row < bitmap.Height; row++) - { - int colOpaquePixel = 0; - for (int col = 0; col < bitmap.Width; col++) - { - if (bitmap.GetPixel(col, row) != colorTransparent) - { - colOpaquePixel = col; - int colNext = col; - for (colNext = colOpaquePixel; colNext < bitmap.Width; colNext++) - { - if (bitmap.GetPixel(colNext, row) == colorTransparent) - { - break; - } - } - - graphicsPath.AddRectangle(new Rectangle(colOpaquePixel, row, colNext - colOpaquePixel, 1)); - col = colNext; - } - } - } - return graphicsPath; - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/Helpers/ResourceHelper.cs b/src/WinFormsUI/Docking/Helpers/ResourceHelper.cs deleted file mode 100644 index 2e1759ca..00000000 --- a/src/WinFormsUI/Docking/Helpers/ResourceHelper.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Drawing; -using System.Reflection; -using System.Resources; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - internal static class ResourceHelper - { - #region Fields - - private static ResourceManager _resourceManager = null; - - #endregion - - #region Properties - - private static ResourceManager ResourceManager - { - get - { - if (_resourceManager == null) - { - _resourceManager = new ResourceManager("WeifenLuo.WinFormsUI.Docking.Strings", - typeof(ResourceHelper).Assembly); - } - return _resourceManager; - } - } - - #endregion - - #region Public methods - - public static string GetString(string name) - { - return ResourceManager.GetString(name); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/Helpers/Win32Helper.cs b/src/WinFormsUI/Docking/Helpers/Win32Helper.cs deleted file mode 100644 index f2cb2bcb..00000000 --- a/src/WinFormsUI/Docking/Helpers/Win32Helper.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - internal static class Win32Helper - { - #region Public methods - - public static Control ControlAtPoint(Point pt) - { - return Control.FromChildHandle(NativeMethods.WindowFromPoint(pt)); - } - - public static uint MakeLong(int low, int high) - { - return (uint) ((high << 16) + low); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/InertButtonBase.cs b/src/WinFormsUI/Docking/InertButtonBase.cs deleted file mode 100644 index f7891057..00000000 --- a/src/WinFormsUI/Docking/InertButtonBase.cs +++ /dev/null @@ -1,145 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using System.Drawing; -using System.Drawing.Imaging; - -namespace WeifenLuo.WinFormsUI.Docking -{ - internal abstract class InertButtonBase : Control - { - #region Fields - - private bool m_isMouseOver = false; - - #endregion - - #region cTor - - protected InertButtonBase() - { - SetStyle(ControlStyles.SupportsTransparentBackColor, true); - BackColor = Color.Transparent; - } - - #endregion - - #region Properties - - public abstract Bitmap Image { get; } - - protected bool IsMouseOver - { - get { return m_isMouseOver; } - private set - { - if (m_isMouseOver == value) - { - return; - } - - m_isMouseOver = value; - Invalidate(); - } - } - - protected override Size DefaultSize - { - get { return Resources.DockPane_Close.Size; } - } - - #endregion - - #region Public methods - - public void RefreshChanges() - { - if (IsDisposed) - { - return; - } - - bool mouseOver = ClientRectangle.Contains(PointToClient(Control.MousePosition)); - if (mouseOver != IsMouseOver) - { - IsMouseOver = mouseOver; - } - - OnRefreshChanges(); - } - - #endregion - - #region Overrides - - protected override void OnMouseMove(MouseEventArgs e) - { - base.OnMouseMove(e); - bool over = ClientRectangle.Contains(e.X, e.Y); - if (IsMouseOver != over) - { - IsMouseOver = over; - } - } - - protected override void OnMouseEnter(EventArgs e) - { - base.OnMouseEnter(e); - if (!IsMouseOver) - { - IsMouseOver = true; - } - } - - protected override void OnMouseLeave(EventArgs e) - { - base.OnMouseLeave(e); - if (IsMouseOver) - { - IsMouseOver = false; - } - } - - protected override void OnPaint(PaintEventArgs e) - { - if (IsMouseOver && Enabled) - { - using (Pen pen = new Pen(ForeColor)) - { - e.Graphics.DrawRectangle(pen, Rectangle.Inflate(ClientRectangle, -1, -1)); - } - } - - using (ImageAttributes imageAttributes = new ImageAttributes()) - { - ColorMap[] colorMap = new ColorMap[2]; - colorMap[0] = new ColorMap(); - colorMap[0].OldColor = Color.FromArgb(0, 0, 0); - colorMap[0].NewColor = ForeColor; - colorMap[1] = new ColorMap(); - colorMap[1].OldColor = Image.GetPixel(0, 0); - colorMap[1].NewColor = Color.Transparent; - - imageAttributes.SetRemapTable(colorMap); - - e.Graphics.DrawImage( - Image, - new Rectangle(0, 0, Image.Width, Image.Height), - 0, 0, - Image.Width, - Image.Height, - GraphicsUnit.Pixel, - imageAttributes); - } - - base.OnPaint(e); - } - - #endregion - - protected virtual void OnRefreshChanges() - { - } - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/Interfaces.cs b/src/WinFormsUI/Docking/Interfaces.cs deleted file mode 100644 index 6654370f..00000000 --- a/src/WinFormsUI/Docking/Interfaces.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - public interface IDockContent - { - #region Properties - - DockContentHandler DockHandler { get; } - - #endregion - - #region Public methods - - void OnActivated(EventArgs e); - void OnDeactivate(EventArgs e); - - #endregion - } - - public interface INestedPanesContainer - { - #region Properties - - DockState DockState { get; } - Rectangle DisplayingRectangle { get; } - NestedPaneCollection NestedPanes { get; } - VisibleNestedPaneCollection VisibleNestedPanes { get; } - bool IsFloat { get; } - - #endregion - } - - internal interface IDragSource - { - #region Properties - - Control DragControl { get; } - - #endregion - } - - internal interface IDockDragSource : IDragSource - { - #region Public methods - - Rectangle BeginDrag(Point ptMouse); - bool IsDockStateValid(DockState dockState); - bool CanDockTo(DockPane pane); - void FloatAt(Rectangle floatWindowBounds); - void DockTo(DockPane pane, DockStyle dockStyle, int contentIndex); - void DockTo(DockPanel panel, DockStyle dockStyle); - - #endregion - } - - internal interface ISplitterDragSource : IDragSource - { - #region Properties - - bool IsVertical { get; } - Rectangle DragLimitBounds { get; } - - #endregion - - #region Public methods - - void BeginDrag(Rectangle rectSplitter); - void EndDrag(); - void MoveSplitter(int offset); - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/Localization.cs b/src/WinFormsUI/Docking/Localization.cs deleted file mode 100644 index ddb98192..00000000 --- a/src/WinFormsUI/Docking/Localization.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.ComponentModel; - -namespace WeifenLuo.WinFormsUI.Docking -{ - [AttributeUsage(AttributeTargets.All)] - internal sealed class LocalizedDescriptionAttribute : DescriptionAttribute - { - #region Fields - - private bool m_initialized = false; - - #endregion - - #region cTor - - public LocalizedDescriptionAttribute(string key) : base(key) - { - } - - #endregion - - #region Properties - - public override string Description - { - get - { - if (!m_initialized) - { - string key = base.Description; - DescriptionValue = ResourceHelper.GetString(key); - if (DescriptionValue == null) - { - DescriptionValue = string.Empty; - } - - m_initialized = true; - } - - return DescriptionValue; - } - } - - #endregion - } - - [AttributeUsage(AttributeTargets.All)] - internal sealed class LocalizedCategoryAttribute : CategoryAttribute - { - #region cTor - - public LocalizedCategoryAttribute(string key) : base(key) - { - } - - #endregion - - #region Overrides - - protected override string GetLocalizedString(string key) - { - return ResourceHelper.GetString(key); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/Measures.cs b/src/WinFormsUI/Docking/Measures.cs deleted file mode 100644 index a5607852..00000000 --- a/src/WinFormsUI/Docking/Measures.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -namespace WeifenLuo.WinFormsUI.Docking -{ - internal static class Measures - { - #region Fields - - public const int SplitterSize = 4; - - #endregion - } - - internal static class MeasurePane - { - #region Fields - - public const int MinSize = 24; - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/NestedDockingStatus.cs b/src/WinFormsUI/Docking/NestedDockingStatus.cs deleted file mode 100644 index c65a5f1c..00000000 --- a/src/WinFormsUI/Docking/NestedDockingStatus.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Drawing; - -namespace WeifenLuo.WinFormsUI.Docking -{ - public sealed class NestedDockingStatus - { - #region Fields - - #endregion - - #region cTor - - internal NestedDockingStatus(DockPane pane) - { - DockPane = pane; - } - - #endregion - - #region Properties - - public DockPane DockPane { get; } = null; - - public NestedPaneCollection NestedPanes { get; private set; } = null; - - public DockPane PreviousPane { get; private set; } = null; - - public DockAlignment Alignment { get; private set; } = DockAlignment.Left; - - public double Proportion { get; private set; } = 0.5; - - public bool IsDisplaying { get; private set; } = false; - - public DockPane DisplayingPreviousPane { get; private set; } = null; - - public DockAlignment DisplayingAlignment { get; private set; } = DockAlignment.Left; - - public double DisplayingProportion { get; private set; } = 0.5; - - public Rectangle LogicalBounds { get; private set; } = Rectangle.Empty; - - public Rectangle PaneBounds { get; private set; } = Rectangle.Empty; - - public Rectangle SplitterBounds { get; private set; } = Rectangle.Empty; - - #endregion - - #region Internals - - internal void SetStatus(NestedPaneCollection nestedPanes, DockPane previousPane, DockAlignment alignment, - double proportion) - { - NestedPanes = nestedPanes; - PreviousPane = previousPane; - Alignment = alignment; - Proportion = proportion; - } - - internal void SetDisplayingStatus(bool isDisplaying, DockPane displayingPreviousPane, - DockAlignment displayingAlignment, double displayingProportion) - { - IsDisplaying = isDisplaying; - DisplayingPreviousPane = displayingPreviousPane; - DisplayingAlignment = displayingAlignment; - DisplayingProportion = displayingProportion; - } - - internal void SetDisplayingBounds(Rectangle logicalBounds, Rectangle paneBounds, Rectangle splitterBounds) - { - LogicalBounds = logicalBounds; - PaneBounds = paneBounds; - SplitterBounds = splitterBounds; - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/NestedPaneCollection.cs b/src/WinFormsUI/Docking/NestedPaneCollection.cs deleted file mode 100644 index 61c6eff9..00000000 --- a/src/WinFormsUI/Docking/NestedPaneCollection.cs +++ /dev/null @@ -1,212 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Drawing; - -namespace WeifenLuo.WinFormsUI.Docking -{ - public sealed class NestedPaneCollection : ReadOnlyCollection - { - #region Fields - - #endregion - - #region cTor - - internal NestedPaneCollection(INestedPanesContainer container) - : base(new List()) - { - Container = container; - VisibleNestedPanes = new VisibleNestedPaneCollection(this); - } - - #endregion - - #region Properties - - public INestedPanesContainer Container { get; } - - public VisibleNestedPaneCollection VisibleNestedPanes { get; } - - public DockState DockState - { - get { return Container.DockState; } - } - - public bool IsFloat - { - get { return DockState == DockState.Float; } - } - - #endregion - - #region Public methods - - public DockPane GetDefaultPreviousPane(DockPane pane) - { - for (int i = Count - 1; i >= 0; i--) - { - if (this[i] != pane) - { - return this[i]; - } - } - - return null; - } - - #endregion - - #region Internals - - internal void Add(DockPane pane) - { - if (pane == null) - { - return; - } - - NestedPaneCollection oldNestedPanes = - pane.NestedPanesContainer == null ? null : pane.NestedPanesContainer.NestedPanes; - if (oldNestedPanes != null) - { - oldNestedPanes.InternalRemove(pane); - } - Items.Add(pane); - if (oldNestedPanes != null) - { - oldNestedPanes.CheckFloatWindowDispose(); - } - } - - /// - /// Switches a pane with its first child in the pane hierarchy. (The actual hiding happens elsewhere.) - /// - /// Pane to switch - internal void SwitchPaneWithFirstChild(DockPane pane) - { - if (!Contains(pane)) - { - return; - } - - NestedDockingStatus statusPane = pane.NestedDockingStatus; - DockPane lastNestedPane = null; - for (int i = Count - 1; i > IndexOf(pane); i--) - { - if (this[i].NestedDockingStatus.PreviousPane == pane) - { - lastNestedPane = this[i]; - break; - } - } - - if (lastNestedPane != null) - { - int indexLastNestedPane = IndexOf(lastNestedPane); - Items[IndexOf(pane)] = lastNestedPane; - Items[indexLastNestedPane] = pane; - NestedDockingStatus lastNestedDock = lastNestedPane.NestedDockingStatus; - - DockAlignment newAlignment; - if (lastNestedDock.Alignment == DockAlignment.Left) - { - newAlignment = DockAlignment.Right; - } - else if (lastNestedDock.Alignment == DockAlignment.Right) - { - newAlignment = DockAlignment.Left; - } - else if (lastNestedDock.Alignment == DockAlignment.Top) - { - newAlignment = DockAlignment.Bottom; - } - else - { - newAlignment = DockAlignment.Top; - } - double newProportion = 1 - lastNestedDock.Proportion; - - lastNestedDock.SetStatus(this, statusPane.PreviousPane, statusPane.Alignment, statusPane.Proportion); - for (int i = indexLastNestedPane - 1; i > IndexOf(lastNestedPane); i--) - { - NestedDockingStatus status = this[i].NestedDockingStatus; - if (status.PreviousPane == pane) - { - status.SetStatus(this, lastNestedPane, status.Alignment, status.Proportion); - } - } - - statusPane.SetStatus(this, lastNestedPane, newAlignment, newProportion); - } - } - - internal void Remove(DockPane pane) - { - InternalRemove(pane); - CheckFloatWindowDispose(); - } - - #endregion - - #region Private Methods - - private void CheckFloatWindowDispose() - { - if (Count == 0 && Container.DockState == DockState.Float) - { - FloatWindow floatWindow = (FloatWindow) Container; - if (!floatWindow.Disposing && !floatWindow.IsDisposed) - { - NativeMethods.PostMessage(((FloatWindow) Container).Handle, FloatWindow.WM_CHECKDISPOSE, 0, 0); - } - } - } - - private void InternalRemove(DockPane pane) - { - if (!Contains(pane)) - { - return; - } - - NestedDockingStatus statusPane = pane.NestedDockingStatus; - DockPane lastNestedPane = null; - for (int i = Count - 1; i > IndexOf(pane); i--) - { - if (this[i].NestedDockingStatus.PreviousPane == pane) - { - lastNestedPane = this[i]; - break; - } - } - - if (lastNestedPane != null) - { - int indexLastNestedPane = IndexOf(lastNestedPane); - Items.Remove(lastNestedPane); - Items[IndexOf(pane)] = lastNestedPane; - NestedDockingStatus lastNestedDock = lastNestedPane.NestedDockingStatus; - lastNestedDock.SetStatus(this, statusPane.PreviousPane, statusPane.Alignment, statusPane.Proportion); - for (int i = indexLastNestedPane - 1; i > IndexOf(lastNestedPane); i--) - { - NestedDockingStatus status = this[i].NestedDockingStatus; - if (status.PreviousPane == pane) - { - status.SetStatus(this, lastNestedPane, status.Alignment, status.Proportion); - } - } - } - else - { - Items.Remove(pane); - } - - statusPane.SetStatus(null, null, DockAlignment.Left, 0.5); - statusPane.SetDisplayingStatus(false, null, DockAlignment.Left, 0.5); - statusPane.SetDisplayingBounds(Rectangle.Empty, Rectangle.Empty, Rectangle.Empty); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/Resources.Designer.cs b/src/WinFormsUI/Docking/Resources.Designer.cs deleted file mode 100644 index 38344cce..00000000 --- a/src/WinFormsUI/Docking/Resources.Designer.cs +++ /dev/null @@ -1,293 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace WeifenLuo.WinFormsUI.Docking { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WeifenLuo.WinFormsUI.Docking.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PaneDiamond { - get { - object obj = ResourceManager.GetObject("DockIndicator_PaneDiamond", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PaneDiamond_Bottom { - get { - object obj = ResourceManager.GetObject("DockIndicator_PaneDiamond_Bottom", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PaneDiamond_Fill { - get { - object obj = ResourceManager.GetObject("DockIndicator_PaneDiamond_Fill", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PaneDiamond_HotSpot { - get { - object obj = ResourceManager.GetObject("DockIndicator_PaneDiamond_HotSpot", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PaneDiamond_HotSpotIndex { - get { - object obj = ResourceManager.GetObject("DockIndicator_PaneDiamond_HotSpotIndex", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PaneDiamond_Left { - get { - object obj = ResourceManager.GetObject("DockIndicator_PaneDiamond_Left", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PaneDiamond_Right { - get { - object obj = ResourceManager.GetObject("DockIndicator_PaneDiamond_Right", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PaneDiamond_Top { - get { - object obj = ResourceManager.GetObject("DockIndicator_PaneDiamond_Top", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PanelBottom { - get { - object obj = ResourceManager.GetObject("DockIndicator_PanelBottom", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PanelBottom_Active { - get { - object obj = ResourceManager.GetObject("DockIndicator_PanelBottom_Active", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PanelFill { - get { - object obj = ResourceManager.GetObject("DockIndicator_PanelFill", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PanelFill_Active { - get { - object obj = ResourceManager.GetObject("DockIndicator_PanelFill_Active", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PanelLeft { - get { - object obj = ResourceManager.GetObject("DockIndicator_PanelLeft", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PanelLeft_Active { - get { - object obj = ResourceManager.GetObject("DockIndicator_PanelLeft_Active", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PanelRight { - get { - object obj = ResourceManager.GetObject("DockIndicator_PanelRight", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PanelRight_Active { - get { - object obj = ResourceManager.GetObject("DockIndicator_PanelRight_Active", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PanelTop { - get { - object obj = ResourceManager.GetObject("DockIndicator_PanelTop", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockIndicator_PanelTop_Active { - get { - object obj = ResourceManager.GetObject("DockIndicator_PanelTop_Active", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockPane_AutoHide { - get { - object obj = ResourceManager.GetObject("DockPane_AutoHide", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockPane_Close { - get { - object obj = ResourceManager.GetObject("DockPane_Close", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockPane_Dock { - get { - object obj = ResourceManager.GetObject("DockPane_Dock", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockPane_Option { - get { - object obj = ResourceManager.GetObject("DockPane_Option", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DockPane_OptionOverflow { - get { - object obj = ResourceManager.GetObject("DockPane_OptionOverflow", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - } -} diff --git a/src/WinFormsUI/Docking/Resources.resx b/src/WinFormsUI/Docking/Resources.resx deleted file mode 100644 index 3032913d..00000000 --- a/src/WinFormsUI/Docking/Resources.resx +++ /dev/null @@ -1,190 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - Resources\DockIndicator_PaneDiamond.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockIndicator_PaneDiamond_Bottom.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\Dockindicator_PaneDiamond_Fill.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockIndicator_PaneDiamond_Hotspot.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockIndicator_PaneDiamond_HotspotIndex.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockIndicator_PaneDiamond_Left.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockIndicator_PaneDiamond_Right.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockIndicator_PaneDiamond_Top.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockIndicator_PanelBottom.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockIndicator_PanelBottom_Active.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockIndicator_PanelFill.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockIndicator_PanelFill_Active.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockIndicator_PanelLeft.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockIndicator_PanelLeft_Active.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockIndicator_PanelRight.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockIndicator_PanelRight_Active.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockIndicator_PanelTop.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockIndicator_PanelTop_Active.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockPane_AutoHide.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockPane_Close.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockPane_Dock.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockPane_Option.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\DockPane_OptionOverflow.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - \ No newline at end of file diff --git a/src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond.bmp b/src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond.bmp deleted file mode 100644 index 70e70e288d70741ca264944ab528dd070fae23f0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23286 zcmeI4ZEqFF6@baV=ugNm$d^`0Nfjg_I}T|YP?DxikV6WDmJl$QhCmZAZAhXB0Zj@8 zfk?rhT9ts>VCf>TWyh}X#m1O7`QmF+5NX0ol;lGq(P!rD9uNC+*}HeI#9e1K9?dFG_ z*Ec*oeD2)2%a<=tXK|pjp*A-{xy#|wrAyE_llD-O&CX$LY^+cyP>Xa2c|k#gB6}ll zSwnSVv-XRRe!5`y+^13pRMC|3!C`XXNJQwrTNwChvp_HZ9H?oy?srRa#$jskSj7fS z@RRh^kcqvte~rEJs5v`$EN2|1hd;ey!tpD`Pp1jPCLl3!(FE@TO>m{XAZHw|juftr zoG|eyiNZDW(+2x<=BzK53$Bfv$Qg(0XZx;?_j=)M?{zmI=d5=D347KEjXY-@zPK>> z#YI0j>Hl3AG(k?OoP?jw8HXF?k_i(<6C_9=U|?iqghjbX4&f?CN^-z~#xOoUUM`paQgtMZ ztiB3!zySyo6BCt6g}P|HYE3jX2WEf@fpx{KI5gK1WdMS3xVE?R>Yk1(yH`(t_*!M> zip$%VO}zi|#dlshzx9{nZ$CS>@fRa+JbAjaRpQ|_^Z)buV}q~#?6cp^b=w1~IMCnF z73NHohaq4&b@{%qkMLd3o^Sv4;n$yRzy0@jZ*+HkesJT}zpk75^Q!Xp<(Ia#pX+)- z;;}z08r|@8sk3dkqlLV>Zf`L(0g6Zn*nRMiorD8h*6w|4_3k%U?)v?!+dF>q-m3OL zt$1#vO6#CLkx9)g#38#n;Z`+E5*pYN00S6LUd|D zbtY78n1gtwaV+9i!<~dD1-}F9#XqIF$^CiPG&!!-2ek;=(^& z{c5vRUu=^Y33^iCnMQ`35Q#j1DeAX z4@e?8xCAsU9Jv0TAq591#k7ZsBDd0VC{U>yIhcOowTBCXIGE~e54&uqPy!^71OUeU z41m=(7I(eK$wevLz8Maq1sv-&^o#x@K%*4{Cgota<;e5GvXJ(02f0Bsgkg($6%fbr7?Sb`PmcCsZ zNQ2$9qaNud6VU1MB~C zv05S}!U3Z4WI; z+C%tx5m#|nF3%L#;OZO{g3v>iX%A(~!OS0OeqOMR&Gd^=GmnCUnLosg4|L2V9NgN~ zluptf7@)%LFe$~fhjNi7E%QlkZpv}e&L`<&k?leF2Zrmw?US}jTvPSsV$Dmt)fbj< zzX%v0R!ND{FYNfhy!r$;*Bc)Ol8z5{ob>0_e!svxDWyt`0j}9nmlO~r3k3xfhB-tU zBiXrqG-mUDA^k!*BpxT>VCL2Ge&N4oNu?soRbjwv$wHh0h30j^CgdO`nt7BwFUHM# zRt^2aJ~!z^Oug*$!oFYl^J?m%^^HqlfNQqYB?Sb@LMZ`-2{}l1rokQucm81KNUmB8 z<_JGGz2^nvB=acqzFCy_EU8o+0g=1<)#mW~W)d<9=aZ54UVsBs=; z<`2WiO?yxdG0%&z4Urr$Nl?fGRE&&^_5Ffe=np7Vw&9{(iEy^>S>E_SH@EMbN0YpF zi|Y*^91gflJaN>*H7`Xvl0&w3hWmxM-tfWUfXl=aM=jLmOu$Ne$ktBfFf=rThkDl| zZTq{{6862lM&do2R(=!=5-esLh#x6%OhvB(Z<<+C7_IPj2VSEe|iA|6^VvSeIsrp4D&Rz``JV zS5BWk4GNZm(;e*piF9efL2b^~#R(7&JZSjQC>jIOSxzqDaPs6y9vPsZRq&sN=?-?k zunWlD_8@jPGzJ1&O(>M2F(94ghJFlqo~vUM7wpJS%OzvLMFzeB&+Qo0S;~lp(6FTpIq-)7(yoYXQ%|EE(*6* zFjUqP(Cof!x-B6?`!iJKqRq3kM#}43Zh{D{dkPilRCP7SmW)WNlMJ z-13^Xho*x7iX`oU#Z^DFgdH)`aom29R}R!vpQmxd#Vp|W<+1&SwD%IChv!^|1 zl_L{Ba1bmx(@TnVhAo47JYjK>Y3k^8Ziu$QSkXB^n1 zgkOn(S49$DTrP^ld;`IJ0Ko?5^9VWPfK$u_=K~ieebIaY!+ZzB|LTQzjq}BfoN-|L z0WM>_VL zgM(vZW2a7?I)DEBTppJJ+j5t~;oP}%(D*Ftr6gOO!{p>-sZ{zn>qS~n(4bnK!+Uq# zziY_@nH~ISO2yzXGkh?{4P7gY{Ip4+S9}iC)UW%sl7exV9XVXHP6PZTJUeRqARNZA zF%Ox$BZmvdVQ%b`3&tI}Q2t~NH)b3X*0D`zA6gNY^IMCVA*V*1@eB)wK6oW&#Tt0pJbZo!q ze|qT=$Mr8?io{1z01m^$!{g)QY|6!Q@T(jvDF6o=!_?GNwOai{-H|Z1`YJ2{2OvyO zPuFTS>Z0{(G|hn8R zPXG3qvu{3qdfQK?-gtC!(~rkrz3)U%hxlVJFZ=sT_l&&wgHM0H#BC2`#nlohd-zU!U$^VEH9LRt{EqIQ{bp^~uUG$c%X5!! z>Uwy?Qx9}M{=>Bo-z)y=2bZq8@9t+i?(Dkv`*2V@j&dNdXj?@R1XuZd!;26FDzQ#r ziez@kx3cwf%Mk@x<#J)notc@Lot>?(dG2>}QC>31-7p=gEQsjiv1VT65i4-4Brl73 zL^1st;Sf+;S;n1XET5Iag zbd=Tq;of~4dl>m$w|7JL-}dg=zkh$vIsRG=@dYYM7I-q+oYo-}p-HGj>^Vk?QzA(M|J5=MP`oAQ0YJ*+p{oNr;^1j!)Mh z34W5q%}_Y_-hOv?i9LR@)t_p{<&@W0HIcT^&lr4uTJ5JUeA0qpTu^gnbN+4xG$B_E{BBFpiDJd}+C+Qa_ z2k7QJ+_W6*u^gE%OnV5&2L>EbUP@7)eP*^;^(TQ?4k;_{NAolE+XMT(Y<;^r5SFaw z$H|knJ*4MgPiMiw_KR@dWSq1dsH0mPKjDBH5uy9|BniG>$LmTot(##i2loFZvT7nF z!U3zg87D0V2EAZ>7&=G<&6WU{zF)A8k~xLO!;oUfhd~Y}V3!vTXzmt7Rw+4Lx5`No zD9%+F2nifIh=x=3Bttu2R5)T`I84~}!{}i-oaSbm#KH87V0;)L6Ej~VwukmK?ZKZf zk}B@XWlnJwuFpXs2tBeg?V)NpnDs-$^99G)Ouv{g>nJ#w^+Uq=K*vnO!L40G;WX`m z0m?UrNhzj1RLeAJSx@qCGmevXJxLdfZ4bgfGF(R@-H7)H{Us(Kp5m7+2 zk`kp~*ztjN^-&&fFg^^Y9UtsC8Lq3tet~*YN*x~sT(zYx86Zd!3W{XtbBI+&lJodz z%;x<<`h{{xJx;>GtgGeyB7D!1O2w9|!id_E1U~}`P3wY9$w5jq>nNEorp$X*1O39z zn{*ez0pKH(M0u^5@N9 zzF?eW9cA7(%krKjl}aKYayNg~*?-?mLnh^VGFBhdpa|Ln^M!ryw(~`U>nO8+7&~Ix zgK|iiFMJ(hIiQlDkO@?jO!D>pf>h)m$xzw)MY|H=Y~Qnj@qun`-!~7XdG8j}8#Xu$ zaJg9GsD-OuhHxy0eD(DEg_z#3!C`>Q#S%v?ROej4N_)sxPvtN=I*NsQ=bfD&^sdM4 zdE;gAcW++%-m5RX-Lvv{>sD-EvwYjCCtrW|v5m_gdgY1x*FDy;=AmWculmtF&vh0_5$i;``@#Dvb zhK76;O`4x*x2`cu@M=rQMR_vGFp>F5$S1w z?KQHJ_Rw+=cox^?KpZw#L)Y#bV&s9k{i3KGsHx7UQfuG8NjL}!zxpb>g+E3)U~NGh#|$7v1=^Nqj7B2#q}SgMf{u@`7>TkP>z! z999(x1b($F67vlN^8p0woX;Z^i~~k7Qh;?eN0hM=Vp+p?oc(eRlJILeL4@F^xm&RIzyU4m z%-4`OQGoq@J`jE@3Au6hGfEgDB|^bCU_i%lTp0_pxKMJ<*R=GO1`5U@m;c`^!1#b= zvw7oY>v9nD@t!SNtj4j{*w}Z{#Vq960HQlx@2T(L`K2`&6 Oi*i8i+^>Zj3cdw(sg<(; diff --git a/src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond_Hotspot.bmp b/src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond_Hotspot.bmp deleted file mode 100644 index e801d382d77400616c5ba7c40646e5a387b0c992..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23286 zcmeI3J#K?Q5Joq*$Psda93XxAD5uG#(nm4{9VHC{|D7SN^Vv(#CtA-)Sb8Ijur1Gy zp5IJi)^G2>pXC;>I=|@gF+ZNl^X>JY`Tg6I`E<#N@0`dfHZiL(TuO;Ot~nnq;84FY zIKaVs7a#BeADjR_I1T0lKH!5Bzz3(ne82~Ma02+?G?)+gfDcXpADjmB0Uz+e3Ful) z(f57qkM_!TKA*4c_8?IqjN_QW;Zaa55RS)V5{K=ha0se4kHeNxtRQ4_*d_`=7=~e* zCbfeqtdZ(NT|( z!T}E6SNMPr_}~Qa!D%ob@Bts306sVk<^w+9gA>39r@?%{2Yhe>_~0~{5BPu&P5>XA z2J-1+PLZMj^&O!StwAG}}gg}#%QdKK7 zF2XrztBH2qD1TDr;b~Q>BAi1_8(wW{!Xyri03VzN^8p|5!3p4l(_lW}!^#IK5gxuo?DZdhY962f diff --git a/src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond_HotspotIndex.bmp b/src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond_HotspotIndex.bmp deleted file mode 100644 index e5ef472c56cb9258fdaa5b45bf9df1d5adbcd38c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 90 tcmZ?rjbeZRGa#h_#LQ64$RGihPyv&u#D5@QU;q<93MkhAk%tL`gaEYn5c~iD diff --git a/src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond_Left.bmp b/src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond_Left.bmp deleted file mode 100644 index 1fbda61c089c95635644e4f5d01905477db17842..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23286 zcmeI4?Qc~@8o=?t@K5kB@QX$ljU0zJhW0!*1gKW}b7N4(H|e+;h*>-UBDo$=v6hnR(_n zuV{&Ae-^yx`rpKRoZ(#$2B^=4yIDPswG`>!IDamH%Fg7+;C=@6~x{J7=pg|G6F_qT9RMA=c z#XEnvbNl?eQah5ODdmI1`{aIeckn>YI7|a0!is7^AouVi!%}lmrGYU7!f~k3O;B3;wlGT6?xC9!hssEe)me~7eEjfhvG`;7kk@UyW3j2jc;5eihOV=7Kzw*G?x_d@myyIwRtN6puE&S@)+XkPx^~=A`ciRI=aglzljq105 zJ`4fPDa-!~J8}Q*+3}yx-u~s&t(QJ}{m1UEZ+EXd_wMsk|6Ez#y6p6p_TycP#2qJ6edV`}P(?6QGEMfZn_R)`{D-Y4v*>R&9T2#kLoo+S>7#H&(X4y8O=@ zpL}Rt`+aL3y{qG)Kd!v*cJY_ry;5$bNlT#!a?mg%7MU~Z5444T;;P3&p{NZ z#5#c~lG!2K!d6c$OBD0w{hEctm^(Q+IW;v^UGvQEf+CX(2x@@K$}k-$EXmTxBh9?X z16JTjNrMzqJt66G2&fdPc@m*JvQdOmsnpZc6IpA>dwYA`yO9!7a8XnNn?yZ*M)eGE zsM9d5C3R;y^6L3u*Y35QjQp0k?h{IJ|Nky94{i7b{=0%ZdvWC;SuLG<|gb;H5PJ;jN|ZL|31P z$f>32Y-BEz!Bvo7xmd^W{XvS5{TrGu;Agx!U=}k1N*&f zeY-jkmZWCJ$z!%XBV{Ie0f;oYDbQ2 z4*>;4E6Gv%g&iMQS0AEsz42in>G)vBNq=4K_Y2gMT&nme;HoWUNdZBkkWnDP@c0m^ zj6|pUXw2sQLi&YrNIXu$!K|z0{lb6Gl0rr1tHOZV5(Pg63XSW6O~^rVH0vmtFUHM# zRt^2a&YN^1mR@$guYS~K6Chkz(6FPCH43EDoLIu)@ZrOlazH_=;6Dx1U7UX5 z6p(xDLG)~>4+M^ykSSTCKswEdr5r#(tAIv57bN8@kQ{?)C;@2+0)b4)x*pAi151cH z9qB;w$dM!c{rzDSb()`Ox2`cu@M=pS>rAc`6InP4nglqw9fX3^V}5e2V_^tkWqw~t z0EOEs7%J;=q^#C4w>u#JeTy8IyNg0QNQUPIIaJ_whd4Fnf?QEBRxoyDdybUz6;P$e z&DoaVR)L_9xtQJ&cdpotQYB1>B0=dFjFzkungW892vxb5$e5ZLBr`l$OtMv=&B0r< za$qx!eMR;*)x~YEk(9KDrh`De%*ugh*j)8pOV|)2mFxD4ymFwVI-g3Z!~PY*K~RK? zuaYZ=gBCe5aFv5#xym7z9N0CbX4Cn3nm1+lIEA0Heu144Qv$o_#;=UwV{t=h|-j=83zt2VOPRoRgr+_my04X-#{=QK(NmFJVMSmU=%aX`M`wVg~mNk6G*)QiH@xPYiJ>dN` zcXQSrIG|;n`5F=@3b4P=1pIF$Avex`MhQctJdiUE7|?MXSH^-Y&X-*FH7&iRft+#3 zsy{T7|wg=g=uG4(%nr@qy W11Rb@AFBbkNjac)=2zoJg8u`JR+iHM diff --git a/src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond_Right.bmp b/src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond_Right.bmp deleted file mode 100644 index 1de97a098639b0bb45e11c38ba76ebd8e103e8cf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23286 zcmeI4Yi||R8i4U%_!ImEe$l9CB*C<&-Zkp+Mk*?ZB4V*9!ciz5@thc2_o7kM^N@5$nq)3{;dkQl#coEJd@#IzA|#^KaR;nc`J=e%iX3nl7#J8C8DUc{l0&%4k&+y6pfQY(kC)5kcdL$sk=0jW4mbc| zVq&6FsZbZKSFM4j=D=t6&Lx}+Nl2e_+bcW zPF;R4Y{mW7v*p*%-~Rctjpsgo?Z@t}@3yZ#_1<$+Z!IftTzq^(`{Azp#UK0E-J`2+ zFLkyJceIdJ_w6l)CO{Dh0ll}s(uv!)ZpHgAE#Lg&(oN4lv9aT^|14|&_mYR!K7QZo z_PbU-cx%Uf|5$d{P2w-Pecs}muYa`l+V-2ShJ)I1lmmfT+bZH9xXNc6o`on-iFE=~ zB(p=dm93szhA7A?lM7?+~|AgBQ@E5mf4vSdpik2Lcl4_JXC zB@I$c^@OC$A)r#E=1GL^$VL@PrBY8%Ph_h@-rL*j-i?%ygNvdH*d*#{9Mv)&`{A-C{%Zdi{5-;s170S@`-<0D*; z0X?i|fJ2>zX{{y&!Cchd*Zt8~pMLVgw+A&1|*^_YNI^X5GsPz4C^6PlRCP3R_8!Mj7o;XMCsh5;Xv9zap9kC z{;IQ7Uvv{632DO_MoLm}ARh`kCmfCqVoJlX$iu~moSZ{ta5pwtjEp1)CLGRM4&)rJ zct8@#!6l$!;XwQgx)dCw6w@9iiabiop+Kc-D&#d%}<0b0S$|)VPBw0 z#|dYckb{)M} zB>m!0FWsDno0Nk+mLv0pX%GJRzqprJtXH~PiMiw_6vXBWSq1dsH0mPKjDBH0ipZ&Bnf`Fju(_@S~tT;4($I+ zWYt7UgacM}Gfr9#40_)9(7%fanr+;?N#kKivExG@hZC^N3kNiJ3nHt894=VpxCj*I zDhz}e4y{DPsd|#3oi9opu`nD)?fPM8j~q^OvyJ0m`h_<>^pc60FJjw6OOo~wo-g7m z?#g9OaTTu4K_Lh|vNG+VY&n?qL(TIA$Jk827&YrCIGFWA%=kdZOv1sfT}|O6?STO* zYz~uBOnWF7Y0|Qu_-tN1llUm|N-?Z}bsA)tV0B_&F~ zu;T;k>U}(1Z+sX?IzHHO(qC8m{Q~u*lqx<7xN1vXQb3R-6corXJU&D!BguJuG-mUD zA^k!*BpxT>VAj?0e&N4oNu?soRbfDFNrImOg{F1ECgdO`nst=S7vttVtA>7I=S?~h zOD{WL*!K&6T}@rIzHtE*aMhN&q<|nvC?$|#LJpFgWw6J=T|d}0lAG-X<_pG2)=}nt zvncObQmHrsB6sswox|^&NysEzPe$s48Wcf$V7{>L-FCjHaUEsW55s#+dr%HB^F>&P zNDinZC}aW^CF6X3zaSO)2QpN);i6rMaJKJR-uOT_x9^*~le~9}=?xnk2DnTtan!<9 zFGV<#L$-Q``-Pa^u)$$~%fu2#EmY@Bz)E|_R!`+HG&F>TdegOSA9St2ZGHJ!@wcp5 z_Rb4WzR|hp_2mmUEM2gE@dGbCdheGna`50mP_Px8?&ADU zq)7`7s&lp`PJnP>LBozl(I}8kb5aS1{rmT0$^iwfg8wv3cX9fKQ$X&q2hp>kJ`gx+ zLZK9m0_ij-m2vzaV+wz=8h${xFI< z%}=yj*O(=EwIxu6Y+Q<&ER+O{0S;~lp(6E|pIqx$00QNPborYF0TgblV5qFek+WLI z-0m<7A;>duQD_Ir@Z2DW3bZ@SS_lCYj1`Ps*`6cid<9hLakCtPi$dmNdPm&3;)LCp z4n?h{Uocv-PG|}UiUMt!$e5ZLBr`l$+(Zx*MRg8rrm?Tc-ln>^?KN!=O$PxKN!kOO ztG;Uq8)Af~+b{CUftu=kDzyYPSJ5w5;UE*=hA<;cJ#4ua(phg@=C*OVul&d<}l zDZ9rh{G9a*?2MQa*hM#fWegvS8$u)ZeJ^06sXS*KIHZJK35Qih0-j$kio|>a!F&M0 zI_L8UIpcs)%sA%*7bbknd;!CJ2gCpBg%`*9Vn)t5aQpz1G1f8Tn}GdHihd47gzC?H zK_zeBMd64tRzfUm_>Qw*&OzdTEys)C{WN!T)*d*ZWu5sN5+@3~1zDUgIqz#)dP@U2#?9vCAm-z(YtvYb!`9d) s<&cT_nC(rynv{cVS=VVkc1^d<%K;Sin~&9i+oT*&JM$}Y&ngq)pNSxqvj6}9 diff --git a/src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond_Top.bmp b/src/WinFormsUI/Docking/Resources/DockIndicator_PaneDiamond_Top.bmp deleted file mode 100644 index 95122a0f31b83e03b34977ac7fdea926907d9a83..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23286 zcmeI4?Q<2?8Nk#3qJKjFf_`a7iyfK4NgB0Q9ktfVM64h!A_hZ6s6uGPb~=nwEmTGZ z3;EPe5vG;QTn3U!Ow7F`hVVAIF`A zo|u?8bLPy&ix(I2xX81G8n-5Em&1h%7ohQR)=NpYJBR7%=~AggEwWvt1qBU?5BPjo&C9ZHmCKR%CgXL+1c4ztwvq6UX2FYngcVPLSSDpFAnXsMHzu09Im|6cX@B`r9B%K-g>U~ z=Gu$9R?q(Gsq?Qrd3MM5XI_0|ddv4FU%K~HUzhk3FRb|J`MbxS`}T)FS?0C}vf?8D zMjO@tKfVtE&8f?OOZ#yD8QlBtKfm?Q_jg_Y!|R_7^#Aq1mdn3;asD^!tGm`**x7TY z|8eoBfA;Xy<_9W$-4nf?q}6?Ui=hor#6m#t13&M>?ccufomV#Od3oLLpFX>*_eZ~6 z-}8&LKiu}rV_SM2+VsTzy^noo{X_SNzxILUYwo@4>8?9_?)fGh)Q+PZ2rSuFkp#h2 zKHu;XM1e}I6PO~I9rCSg{oHayK~}k37<1?5=H}<;>ua9--CUHHOw<6Emti_mS+b>% z$C`PON36iHk`^hZdPX=zREpI+jnEz0s6wSu85|speQ?N!hKAg`u@Z7{QPcsOMm>$A zdPX=jX_(fUx-%VR4ZgSkz~(+ie%I~a)ccqH`wkvFIPm(8H=bR^E&M|}cOb!cB>hN$ zLq7WW2sdLu_w|f$XwopP)g)V(i`vHre*fX0{`mJ#E=3kINRS_TZM)tT$${-#Ba%Zq z``rx5Rtst}pxOEy#43$p5wjZRBrGY|9oRR%R{NM;R$Qby{!et%{L%Tnmp2K7H&^$N zTzwKE=egt4HAsS=Bylqo4t}{2iD--3D33LSieNRvdPvozj;@~dIgk*elHo90xjtt& zkTz1B|I^K1b(ZRjZsH>$t)F46Bm)QXp`h!+;rtk;Gz^P8T#U%+In>6EV3WnjNOEAp z;hN<@&VI!sl2{Hd0SyZW;@{L|;2@=#_Ap!KQCbcqD%Btd(=USdaBd6(Q4 zfB=#Rz@(oMu-e9w;)|SAl)~d%<_psv!tsFtN0gUR)MuZWEmr+WAeKYQiu=+04E^@N zelJ_!t`3AHtHp8hv~3URIoQ)#aIpO%oHrRKEeGo87ROIGphiUKK0Zl;@7M9B5>4x7 z7|VhEe~GM`NQrR3s&2+f%Yi{J7#~Is6G5{jz@_gOtfOR3q46-J*zsYQ!wJ~sg#((q z1(8)s4mYiGQUr=~6$U~Ahc2SwR6WVi&KDJqSQrjdcKtAZR1T-P*(Px?{UR72hRDRs z7m4kmGfjK&=ZmC@yKabs+o|IC@M*&xDsY?b3l7xaH z8TuSzm67B;J{q%mzmR^R98!;ya4_p?dA|tXv!qh7<*G2Ewj{yNfI`!{U{i9C63seF z=8GBgp4C9Vu=6IJh^3dEFYNn8xUQxyTHmAq3b<-ZT{1wBB$N`#FeL{`&N4XQ;I1F+ z8p+KTg}MBBGng+JCs{|C_sz1rXGx`!2#DOxUv>81H`9^4g*{+mN;tRs+S=g%OPJq{eB^)H*9bi;Bv9VQ47^M7qHSE^3_v0jE|3F zq27IG_q+WYar<6b??%mIHFI&}lhi{34gX)|MSmB_yLIUq@+qie@^Xc_`s`HMOE55-?1pCr#(X;z4 z9M~A-?8>QAr$E70aJGx{Kd~k)IH=C~nm7T%g#`^e8bzZ(HqA*T98R1#!IS|CS_S`U znC;^93#WkGV-KQdOMM`4)PzDQ8U?axPAcU93R(p;nza6=}x&2@Wg=s0W{}M5T=5qj9c=_5c+edk z^*OMa#=atZo9dFb*R(yrA!RFCLeXx<0ae*t4PB>ih>^Ou{i3KGsHx7UNl)+=;UFlI zAjsXq_lr8!*ITzvd(bM!25xf@ECu7ht|>Lj<`-#vklo`9e!i9AwM7N%OI5 bx@}($plIHFtOndRAe1M3Ss(A#J zSb@8oUU^0+~+#2UDs_Vo=6tmGS@k%nXQrYkOrA%bj#dkgly(N;QIakcs!0zDb6B$ z#y?5QyoXRIluRZmw=`)kPM8*LBZcwdg$IWB*5ldxhtszQQ#bYrqk9vU-TcL#s98&W z_{`4G=^cUL?Qc$Yfa`L(>b}Q3&!P=;{IuPepF?#=asU7T diff --git a/src/WinFormsUI/Docking/Resources/DockIndicator_PanelBottom_Active.bmp b/src/WinFormsUI/Docking/Resources/DockIndicator_PanelBottom_Active.bmp deleted file mode 100644 index 212fb0d366643c01ddb73ad88d5caac25db236fc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2782 zcmds(+iTNc7{=qRe}OmRt$%@6f^1^JvDz^v6PcouiicTrbyn-Cc$#M~3hJP9f(*1* zUO0zrg{(BCwWl;a#I82gwWXyxHWcwfp*~-d)^?4HjTOO{Cok{!yx;pvQYiU4^}Rh4TfP{ zS_88nC~zGey?-J+4_;K6``-UTLB2+F#Znx>1GUb@WHYPLQQ_tS(+i?%1(v9DL6YUV zx<}mkl5_*pD%^Z{ra&}Xh|J`nFcBP*BSi9sT7jM71{H3Rql?@e$uSgki7Z8l%b(q< zFKsAsb1K|&(p%;kSxKf`FZk%n8&HT{ViI44yEq?MOjlJ`f1D2xNv)cXqFSqPm$EF8 z5FwK4EW0egVVB7gKB*-UN2;^zKjMDQ^SHCNyxRYwqBT^02d&tOb}lAYxvNGl#w7g; zt%du{pm!R&og@<}qFd&=26eM_avjjYX-2oqZAK_M{{h$U_s8RLd`j^yitqS4ro!(K z3Wbu%q{J;vSc~J9f@35EaK2X``C)cNCrvl08U=pYW$i_uN)Iih&^%686 z=xm5$pqV5gpe~?ZV$3JWSY*XSnh)_ZvPNRqKwU(dPmF0;)evbuBr36*fJYFhi%9eF z7=mAlNb`rf`$y9cp7IBn2Jj~mJhCGs{m`NOgjfMdsF3W2i-f3ws3$V~fy&4RKxg2u zzn;!1eKND?`P_0Kg0LS=%X=_6`(A(A?e3(T9kJJ2qOLZCUaAeaSmg^L&y{(eEpa_v zMK}_b2Dv=}EoO9tR<> zHbq>n3%O9`f3DmIXg;vzgD3qj?W_W##cdTpG{3oYPJQ9@n%v3dnSI5nU3rPESuqW% z;nfL2!q8_N1 zp!q;&LlgteBnbg^0re7NK1s$RD<;x>h?kKy62k`SBGP%Nb@04iPZ!=f(9UL+iMm7LC z1AqPXbWZ7$nMKd%mID!l{b*X=gUQ+V`qOTAC*ACbz1|XawITFUZNSAUUkG`w%=2uC z>**rrQw5F$&Huf3?)RND{~TBVL=g7Zt&=}(=zYJc{q@p@=kqEb&nUh>IpW%g| z2zj+B;&NTcg)0AZ3?Zw6%Z|Ms{o?;&82hd3#ZrQPA<>vD^BgoOKi=G zX-EyPP6#TG@hcAZf{=M3ZaD!?8NT+ZUN%7UZ``PoPCKLcsPd0CV;=cmMzZ diff --git a/src/WinFormsUI/Docking/Resources/DockIndicator_PanelLeft.bmp b/src/WinFormsUI/Docking/Resources/DockIndicator_PanelLeft.bmp deleted file mode 100644 index 551fd88624747761b970c653d7449ec33dbddc13..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2838 zcmZ?r72{?A12Z700mSk^EDOYp3=%++f#Crcm_i}8(h>k|0vdnf#EHw7FW`yRCc zn)yI0u3o(gw2MLjGz8*WH1mPtM~@!eOECZ%0yGL37-;6taSWmg0y+>F0$9y|cybF6 zJwCnt>ABr6E**Sz?bzGfr{CYd@bS@=&rhxc(SJe!=t3gRe}3t}t7}I==HI*U=^@B` zpk6}8|0l-$N2j+vJ-6ot(ERI1-`)b5{}F6HwcP&*96nI@-#Y!_K2_a+VhhmxC+Bt} zhtJ1HSE(5OAorgKn|~b~zj(ucZ;~5wq!0-I6NvN!az8BmKjBC}tNeZUCX-@5EPaB* z2bMm8@e4K|E&TwwK=b#ImuYzYodo zKe6TU8F2c!49Z_X^Fiq!NBFNKHGI(G7o2}T0MidP_d}8mY3TKr|6z&4-Vm_6^|LL64Co_wl&n<_L5bmRCc@HLM-|J7i-JNu^Bldbr)YXR2OSJ(P zt9&8kxiZhQC9bE7oKF=v;t&7dd*^=NIrGnf1rQR#{knDXrwzUDSGB)h+VFf{<>MK} z_b2Dv=}EoO9tR<>Hbq>n3%O9`f3DmIXg;3$cWGx85G`)2fROW>OXt)VPOr(GT%Ori zoZ6L_*qRm7kQ!c{5L6!HR~+sIA@f4qasr$(eC<=cY=GvYwI7ZhJ9hEn#p~Cv0~;08 s1(5c`kt0XWoH+xug2HAGrgn(=2M!znS^@M0upviX05P9-El{BO02Xyfj{pDw diff --git a/src/WinFormsUI/Docking/Resources/DockIndicator_PanelLeft_Active.bmp b/src/WinFormsUI/Docking/Resources/DockIndicator_PanelLeft_Active.bmp deleted file mode 100644 index 5182318ed3d451f969799e09333f85e60ede5ad8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2838 zcmZ?r72{?A12Z700mSk^EDOYp3=%++f#Crcm_i}`GceE&0c`>re&WQ5%a1 zwE>#>Kr60Zy$ZC8LI5-b;#xHGf#OGx9^FeZ02%@`3K$q@=Ff2qq6z{!5Euej&3|}u z3lKd%z5VIA-7hX3e0A;E+uNt#-@owj(Us3nt^?73LICJOBF%q(>A>?#=LOLG>qp<-0-662Y(BNz{|FpDQ1{W(EKOo zb|Z(+$46JG82%vlp9h%m^^aFA~Ec`#=NI$FmefK7lVm>T= zg2M-vK7sKIHXkkh0J%W(_mJd%u=$AaxpwRgDE*(uO#eW`$u=L9zo6lN^bI8a;B>za z$?iX~tEhk_~C;2NwP)=^vQCaJU~i zWkT4%NFiAMK=K!;e1Mccu<{M47t=sA5n|1U#4pf%VEDtz2Wpi+(DVb0Uts_F-&$A`2r;D6V6*%G#|KEG(e&0Fs&w&LH62kqub@HbTz3*4Gzh2t#d|u__ z8O8S}=iKQ@z0n>AA+I(?T&@ebQ00HF+y`hrp89ubXB7}FZmWQh^P5ZO)E7>#$(>xD z*;ky}m6zC>71NL!UY!tB9^+RW?gb(9Lfmo!oHBgvQ@w0}=A*SAjvYI8@#4kn*RKN` s71RZg_QR1QN6wr%1GIv|W)G%zi1`N&8~|DY^aZdXM_m9hpQi0k0Kv25U;qFB diff --git a/src/WinFormsUI/Docking/Resources/DockIndicator_PanelRight.bmp b/src/WinFormsUI/Docking/Resources/DockIndicator_PanelRight.bmp deleted file mode 100644 index 003cbb02a6df99653e66cf887fff26d684f97f09..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2838 zcmZ?r72{?A12Z700mSk^EDOYp3=%++f#Crcm_i}8(h>k|0vdnf#EHw7FW`yRCc zn)yI0fZ*!Yt3c~00YDRg<^UawWA;h7yC0w4{_x}$AOgCO67zxDf#!dLn1B29 ztLsOfUpn~o-0nwIG9Tgod*|Om%|Gz;+#YI~4{`s;hgaUi&A)u$>3OP!55)bSfaXKP z9~eFdo}4EqeD)@}Va7Jp{qXR=cJu`}e#r=*JxOjW{e97_fVv;ad`S8s&-_*XK0pT} zTLDi$AMRZM#qTvx_yE%nG<}{RA$bIN<{zYD`G812 zK=Xm&4+$T#;ukGsAY5qr0p(wC`ngVi_+T|37XDYE=7ZBGFnmDaPh$GPYChckACSri z>X)C8@BxQEuzUcQpWBEj|DVn&eKND?`P^~{3E@7PmiJ(C_PzeJ+ucbwJ7TZ5L|ttN zy;K`;vC0=ho-6Y_TjF}U$oW)(BhZ6*>X+Yp=YHQg^Ur|=5E8=ux^?oW4ZZJIwZC54 z@O)n7;~B;GC+FPhNxjh?2O+OEMO>~6xlrYQt{haJ;HiI?c2)t=;$$Wa$S%%@!o6lgvGL|{nP diff --git a/src/WinFormsUI/Docking/Resources/DockIndicator_PanelRight_Active.bmp b/src/WinFormsUI/Docking/Resources/DockIndicator_PanelRight_Active.bmp deleted file mode 100644 index dad423551dc270a8fc196ced8f72bf9c9e01ecac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2838 zcmZ?r72{?A12Z700mSk^EDOYp3=%++f#Crcm_i}`GceE&0d3m4b?b=}CoW&UeEat8 zdsGELXQP=9v;qjOUcCymjuHSg0cZ}U`9Sdt7cLw+bZ9SS;ONn#K%+3tpW_%r6$Er0 z(EC`;|4#^fesUd%K0dng{{Drxw@$yhcI^4315eKFetdfS!;@Qp2EP3IyB|@>e1!Y&oqr28|G?98d#GhT#Qh&1UU?5U|MG#S=cyJx5chuq znhyV72iA?b%a^H=%% z03D2M1w8$HxOV{*zt=$F157{A^m&4W^a*tTDt}*~fyh=MrJoCLKdNHkd1Kv{qt`?;RDLQ!1PH*_!CG!(C`PEe~^mh z10wwZ%?E}*Bz(w4re>$i1$;_hXbITzlg!^b(-h;{6_xjUrcPHKKh`rtt zb+sY%Qfcy!1f^k Dd#2bL diff --git a/src/WinFormsUI/Docking/Resources/DockIndicator_PanelTop.bmp b/src/WinFormsUI/Docking/Resources/DockIndicator_PanelTop.bmp deleted file mode 100644 index f6293fd2bc2b474bdb32322ee92ba986f7fa0233..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2870 zcmZ?rHREOg12Z700mQOEtN_G}3=%*R2%z#14uqV!Vht@2!`7`^PnfA?H~^T^+FtnZZ1&b=+UEl$pt{YKofv|MmKkkV-O_>=pLX)v77s! zTmW>?sJXzvBRL%QCb{iRcH5JLKtK`9SRmP4pb@M5ePPIFrN1wxq2#z1VhTL{VKtO| zb0Io$8A_44cnlqW=6-&19T-LAk@)g4&_wbOf%NFttPCzrz})xuFTB48LLXoZ2>1Q{^AM2_Kv|#^1l>FT9*Dqf0_MKGeHw&rff1a2 z`}7+ix&=Z|1rRk51z!l6P=T$zQQG9=L&Yhmr8|`rr@@iAW<+_jyRsQG7eSqfTtml_@RsqrCwu<@9 zrE}^Fr`P08F3;>MPVLG|Y|V;kNDZ$}2r7^9D-QR9ka;0)IRQ=?zV@kJHb8UH+a<@2 z9lLn(;`Qs-fvpv)0BF19$dMyw&YS@nO{89I?YNv{O`%R=bZb?okz%Rv$w1j zsI|av#8{890b`A@4j#tqY{LA!AOxR0Yp%c)Fk-P-Hk(ydHQyww=K?LuGQPu_VJ+KS zJr{*&G#a*QSPKHKxt<$p?OKhnA6)3-+dg%xvw z7gMkG;0KGsuxl$Gm9!pO!<@!(b$ChO^p*xQq^KL z{uP=e;ti~aHPG0ETbYn56VZwiC7uKljge%5k>^#~Ntz`SZaMR|lo87r5&kccBvF

|x4stI={`G#r?zKA$QraVZ|fKHJqqC~2^(}X)6e+6mrmm2XzMur9nR$VC7dQ7#DpB2ayPTOS?#GU6{iJU#uuQwa2Zy5;&XxQBW9;?C^(?s1Foe_ z$^ZG0>ptl5)lda;5~H5(wZ9nFKIIT3r__-t!i6jyUpsgLB8dq_yD2hO1*Ej$+#W)uqO_%To D=uj!( diff --git a/src/WinFormsUI/Docking/Resources/DockPane_AutoHide.bmp b/src/WinFormsUI/Docking/Resources/DockPane_AutoHide.bmp deleted file mode 100644 index 2f395fc0103c27921866c86c1e18e06eb0437c15..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 774 zcmZ?rWn*Rl12Z700mK48%n!tj3=%++f#CuZm_i}`4+Q{pF-guu@gay7ogS!Nx V9KT|q>@ZLd3m6bh(7yw#0058Bb*TUV diff --git a/src/WinFormsUI/Docking/Resources/DockPane_Option.bmp b/src/WinFormsUI/Docking/Resources/DockPane_Option.bmp deleted file mode 100644 index 0d9927a7ce5d055bfc510269000a26a74b54bb24..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 774 zcmZ?rWn*Rl12Z700mK48%n!tj3=%++f#CuZm_i}`4@Us;A(1{q4i17^kQEcO1yeCW NEd(7fssMio006TLlZyZV diff --git a/src/WinFormsUI/Docking/Resources/DockPane_OptionOverflow.bmp b/src/WinFormsUI/Docking/Resources/DockPane_OptionOverflow.bmp deleted file mode 100644 index 02e4bf2905c71009e0a642e171211bf86da659ce..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 774 zcmZ?rWn*Rl12Z700mK48%n!tj3=%++f#CuZm_i}`4@Us;A(1{q4i17^kQEcO1yeCW UEd(8atbkPWNmY+**HB>t0L6i0y8r+H diff --git a/src/WinFormsUI/Docking/Resources/Dockindicator_PaneDiamond_Fill.bmp b/src/WinFormsUI/Docking/Resources/Dockindicator_PaneDiamond_Fill.bmp deleted file mode 100644 index cbe0a156ab38a1bdd969735c4bb24cc1c9865744..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23286 zcmeI4?Qa~#8NjdqMgIi;f_`ZQgo;Q(HU>%o0i}h=gp!apgy7(mkQ5RJ2p|+efF>m( z3Qhc}RYRhdSh^^&Wn<&J*f`FceDT?7qVSp^-~&kTn|XF0kN4%gx3{PIHd&2FbI? zQ>RXyKYxBUi;FaysBv?Wb~&6ocMck#q`j16t8WahMrCT(wRE{3JXx zVtg;`KVzRfWbO_h&KZZ<(GM>ecjQ9p!&%&@aY&3`GR}KI13YOT$Qg%=W5tVOM~y#D zpm@prw9fvVyX(v4flFgYbH?HF$$`t0{hmA7f7x}&x$8YZz}_`NBhML!&(92he%5zR z__H&^#>p*}6Y#@1E;ItPOycO1T+o#f4? z^Yb*1N`SM|*EaTd(nri$swR4y97* z^y$-)?V|6IrAHjsw|ps*Fp3;-7#bQH8yjO&E|NpI$dQs9aG)|wPEJ-TmA}>O2_uWI z!W?h_!qn7MwOXYtTCREnt<9lOPzdZRX2pS|ek>H~CHa4Qem(@@aOvIdi@Uon>{>Vb z_LJ2&SD)Xpa_Y55&%XS~>21H8eBu6yO}`y`_Kp+X?c$FJ16)>y=|EvgmNp(~ z=0zT`0!K=kq?qa%;1EzLQu8E2w`ZdW<#M^NuP^e&A@A?+ckf0@NWn!>18frY^cmGN zz@b6Iw3gHz>By_^{k{7(cGL5_ZtsS!|L)zhfB*j8SGK+J#0qZVAK1PP3BDugK>{4o z(bq?~5d(Ty&j5!84bxgol7+dbeYE!RplS+qyX*Ik3IQ zO^{?YqXq+-Y?y;sr7PcxB?Y?!`^HzQpRmh{3lt~(6Wug@bbkN24FciKm7PRa zpNPnL@AxzgqTt6#+ysR~INyLov_)-{#~MOGu$o~#q-at`SI^oUh=@_iaF{Azoi-eZ z8^|vF(@kG>mg0+U;v*q$IKfCs3J#=0MpuQy*;-#^gdi1Lz)`s_2a#i~CEL~=-2@bF{d1jF@# z{a&`dT^$HZQgi*}Nn0P1bFing;9%Q@KW@@bS`L)a&5oaNK#hRVeSH!IKU~HIB^uXF zFp>lN|MIYEB00hVtGekYEeAS1uYVXk$OD=z0WMu%FprWkg~~&hV*7^y4kuuj7Y=Cd zW<*j6IV@P@xChA2RTu~{9NKvdr|L<9cDyKa#KLeGxATXQ!*V#yO*W2$X%}Aq&`%;} zyojw2ZAt1wc)W-!xGR@2#Z|aA2ZbQ?NXpcQisfMD4|R_h9Ah)>V%*H5;9%wtG5rG# zGYJQ`bajQ3)CW4KusKX}G4-KRqDsqrl9!vZpS1Hynpk9g5dMMgI`I0WuHx5Ke0f;o zQg3y^5^fg(1w<>!QQC#=ADCAk<>h+)!%))x!S<8>yxMOUs3*D9@KL~3Tgs9Gf#RE3g&j9(L`=QxcwyHU{=Ay9XnErTDB!9sWk~@+qL51ZJ%ra>!QCaJvxG8#Xu$aG6-*D23{r30SEQ+3KkrMn*=k zQ185{^h2~e;VobKZMPozl;4ytpuCQg8GVL`)=M%E~hPIF=jhhxW%F=T*(TETxB zrn@-(!YLs4*n{ZVR38W&H6c^7MuBvi6H7UOf?5HMMlMLoSs*zE(^LXd69fX8l651R z3x`a6NFG0ad~k3ujG{sF6ZO_LW(i)c37IHQA}I#4h$w|ZfP>pWC`cpbC)YX_fRLfR zJEBnOMDtO&wSum)5y#7N7n@oW79#{f=b+FAlHs{Q4i&Tjg!w4wE9kqjJx9v<3aHZJ z7H>^(o06>+G8WT1;?5PjF=~WqP}(l&Etw~@1_ZxWpgaQ^Lo=OZmgkCF==`Kbu^VpDu^)d_qoZU~Ls z_q~99OyxP_z#%2?f<_j3+I~e{~ zFT7`*FJ|P71IG_A8DkwYz6sdRr0C~RM5zAU7gX~0T@;QeVAf|E(nC#@Wv(VThCma>fAzI*#MYSdhi}l6ha#(pwtH z8HY^%e=`T`ZY-OP8#h~*gP4!^Y)NA^j -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace WeifenLuo.WinFormsUI.Docking { - using System; - - - ///

- /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Strings { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Strings() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WeifenLuo.WinFormsUI.Docking.Strings", typeof(Strings).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Docking. - /// - internal static string Category_Docking { - get { - return ResourceManager.GetString("Category_Docking", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Docking Notification. - /// - internal static string Category_DockingNotification { - get { - return ResourceManager.GetString("Category_DockingNotification", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Property Changed. - /// - internal static string Category_PropertyChanged { - get { - return ResourceManager.GetString("Category_PropertyChanged", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to (Float). - /// - internal static string DockAreaEditor_FloatCheckBoxText { - get { - return ResourceManager.GetString("DockAreaEditor_FloatCheckBoxText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Determines if end user drag and drop docking is allowed.. - /// - internal static string DockContent_AllowEndUserDocking_Description { - get { - return ResourceManager.GetString("DockContent_AllowEndUserDocking_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The size to display the content in auto hide mode. Value < 1 to specify the size in portion; value >= 1 to specify the size in pixel.. - /// - internal static string DockContent_AutoHidePortion_Description { - get { - return ResourceManager.GetString("DockContent_AutoHidePortion_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Enable/Disable the close button of the content.. - /// - internal static string DockContent_CloseButton_Description { - get { - return ResourceManager.GetString("DockContent_CloseButton_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Shows or hides the close button of the content. This property does not function with System MDI Document Style.. - /// - internal static string DockContent_CloseButtonVisible_Description { - get { - return ResourceManager.GetString("DockContent_CloseButtonVisible_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The form must be of type IDockContent.. - /// - internal static string DockContent_Constructor_InvalidForm { - get { - return ResourceManager.GetString("DockContent_Constructor_InvalidForm", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gets or sets a value indicating in which area of the DockPanel the content allowed to show.. - /// - internal static string DockContent_DockAreas_Description { - get { - return ResourceManager.GetString("DockContent_DockAreas_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Occurs when the value of DockState property changed.. - /// - internal static string DockContent_DockStateChanged_Description { - get { - return ResourceManager.GetString("DockContent_DockStateChanged_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Indicates the content will be hidden instead of being closed.. - /// - internal static string DockContent_HideOnClose_Description { - get { - return ResourceManager.GetString("DockContent_HideOnClose_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The desired docking state when first showing.. - /// - internal static string DockContent_ShowHint_Description { - get { - return ResourceManager.GetString("DockContent_ShowHint_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Context menu displayed for the dock pane tab strip.. - /// - internal static string DockContent_TabPageContextMenu_Description { - get { - return ResourceManager.GetString("DockContent_TabPageContextMenu_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The tab text displayed in the dock pane. If not set, the Text property will be used.. - /// - internal static string DockContent_TabText_Description { - get { - return ResourceManager.GetString("DockContent_TabText_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The text displayed when mouse hovers over the tab.. - /// - internal static string DockContent_ToolTipText_Description { - get { - return ResourceManager.GetString("DockContent_ToolTipText_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The provided value is out of range.. - /// - internal static string DockContentHandler_AutoHidePortion_OutOfRange { - get { - return ResourceManager.GetString("DockContentHandler_AutoHidePortion_OutOfRange", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid Value: The value of DockAreas conflicts with current DockState.. - /// - internal static string DockContentHandler_DockAreas_InvalidValue { - get { - return ResourceManager.GetString("DockContentHandler_DockAreas_InvalidValue", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The pane is invalid. Check the IsFloat and DockPanel properties of this dock pane.. - /// - internal static string DockContentHandler_DockPane_InvalidValue { - get { - return ResourceManager.GetString("DockContentHandler_DockPane_InvalidValue", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The pane is invalid. Check the IsFloat and DockPanel properties of this dock pane.. - /// - internal static string DockContentHandler_FloatPane_InvalidValue { - get { - return ResourceManager.GetString("DockContentHandler_FloatPane_InvalidValue", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid value, conflicts with DockableAreas property.. - /// - internal static string DockContentHandler_IsFloat_InvalidValue { - get { - return ResourceManager.GetString("DockContentHandler_IsFloat_InvalidValue", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The dock state is invalid.. - /// - internal static string DockContentHandler_SetDockState_InvalidState { - get { - return ResourceManager.GetString("DockContentHandler_SetDockState_InvalidState", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The dock panel is null.. - /// - internal static string DockContentHandler_SetDockState_NullPanel { - get { - return ResourceManager.GetString("DockContentHandler_SetDockState_NullPanel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid beforeContent, it must be contained by the pane.. - /// - internal static string DockContentHandler_Show_InvalidBeforeContent { - get { - return ResourceManager.GetString("DockContentHandler_Show_InvalidBeforeContent", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid DockState: Content can not be showed as "Unknown" or "Hidden".. - /// - internal static string DockContentHandler_Show_InvalidDockState { - get { - return ResourceManager.GetString("DockContentHandler_Show_InvalidDockState", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The previous pane is invalid. It can not be null, and its docking state must not be auto-hide.. - /// - internal static string DockContentHandler_Show_InvalidPrevPane { - get { - return ResourceManager.GetString("DockContentHandler_Show_InvalidPrevPane", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to DockPanel can not be null.. - /// - internal static string DockContentHandler_Show_NullDockPanel { - get { - return ResourceManager.GetString("DockContentHandler_Show_NullDockPanel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Pane can not be null.. - /// - internal static string DockContentHandler_Show_NullPane { - get { - return ResourceManager.GetString("DockContentHandler_Show_NullPane", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid value, check DockableAreas property.. - /// - internal static string DockContentHandler_ShowHint_InvalidValue { - get { - return ResourceManager.GetString("DockContentHandler_ShowHint_InvalidValue", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Context menu displayed for the dock pane tab strip.. - /// - internal static string DockHandler_TabPageContextMenuStrip_Description { - get { - return ResourceManager.GetString("DockHandler_TabPageContextMenuStrip_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Press SHIFT for docking to full side.. - /// - internal static string DockIndicator_ToolTipText { - get { - return ResourceManager.GetString("DockIndicator_ToolTipText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid Content: ActiveContent must be one of the visible contents, or null if there is no visible content.. - /// - internal static string DockPane_ActiveContent_InvalidValue { - get { - return ResourceManager.GetString("DockPane_ActiveContent_InvalidValue", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid argument: Content can not be "null".. - /// - internal static string DockPane_Constructor_NullContent { - get { - return ResourceManager.GetString("DockPane_Constructor_NullContent", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid argument: The content's DockPanel can not be "null".. - /// - internal static string DockPane_Constructor_NullDockPanel { - get { - return ResourceManager.GetString("DockPane_Constructor_NullDockPanel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The specified container conflicts with the IsFloat property.. - /// - internal static string DockPane_DockTo_InvalidContainer { - get { - return ResourceManager.GetString("DockPane_DockTo_InvalidContainer", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The previous pane does not exist in the nested docking pane collection.. - /// - internal static string DockPane_DockTo_NoPrevPane { - get { - return ResourceManager.GetString("DockPane_DockTo_NoPrevPane", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The container can not be null.. - /// - internal static string DockPane_DockTo_NullContainer { - get { - return ResourceManager.GetString("DockPane_DockTo_NullContainer", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The previous pane can not be null when the nested docking pane collection is not empty.. - /// - internal static string DockPane_DockTo_NullPrevPane { - get { - return ResourceManager.GetString("DockPane_DockTo_NullPrevPane", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The previous pane can not be itself.. - /// - internal static string DockPane_DockTo_SelfPrevPane { - get { - return ResourceManager.GetString("DockPane_DockTo_SelfPrevPane", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to FloatWindow property can not be set to "null" when DockState is DockState.Float.. - /// - internal static string DockPane_FloatWindow_InvalidValue { - get { - return ResourceManager.GetString("DockPane_FloatWindow_InvalidValue", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid Content: Content not within the collection.. - /// - internal static string DockPane_SetContentIndex_InvalidContent { - get { - return ResourceManager.GetString("DockPane_SetContentIndex_InvalidContent", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid Index: The index is out of range.. - /// - internal static string DockPane_SetContentIndex_InvalidIndex { - get { - return ResourceManager.GetString("DockPane_SetContentIndex_InvalidIndex", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The state for the dock pane is invalid.. - /// - internal static string DockPane_SetDockState_InvalidState { - get { - return ResourceManager.GetString("DockPane_SetDockState_InvalidState", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Auto Hide. - /// - internal static string DockPaneCaption_ToolTipAutoHide { - get { - return ResourceManager.GetString("DockPaneCaption_ToolTipAutoHide", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Close. - /// - internal static string DockPaneCaption_ToolTipClose { - get { - return ResourceManager.GetString("DockPaneCaption_ToolTipClose", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Options. - /// - internal static string DockPaneCaption_ToolTipOptions { - get { - return ResourceManager.GetString("DockPaneCaption_ToolTipOptions", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid Content: The content must be auto-hide state and associates with this DockPanel.. - /// - internal static string DockPanel_ActiveAutoHideContent_InvalidValue { - get { - return ResourceManager.GetString("DockPanel_ActiveAutoHideContent_InvalidValue", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Occurs when the value of ActiveContentProperty changed.. - /// - internal static string DockPanel_ActiveContentChanged_Description { - get { - return ResourceManager.GetString("DockPanel_ActiveContentChanged_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Occurs when the value of ActiveDocument property changed.. - /// - internal static string DockPanel_ActiveDocumentChanged_Description { - get { - return ResourceManager.GetString("DockPanel_ActiveDocumentChanged_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Occurs when the value of ActivePane property changed.. - /// - internal static string DockPanel_ActivePaneChanged_Description { - get { - return ResourceManager.GetString("DockPanel_ActivePaneChanged_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Determines if the drag and drop docking is allowed.. - /// - internal static string DockPanel_AllowEndUserDocking_Description { - get { - return ResourceManager.GetString("DockPanel_AllowEndUserDocking_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Determines if the drag and drop nested docking is allowed.. - /// - internal static string DockPanel_AllowEndUserNestedDocking_Description { - get { - return ResourceManager.GetString("DockPanel_AllowEndUserNestedDocking_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Occurs when a content added to the DockPanel.. - /// - internal static string DockPanel_ContentAdded_Description { - get { - return ResourceManager.GetString("DockPanel_ContentAdded_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Occurs when a content removed from the DockPanel.. - /// - internal static string DockPanel_ContentRemoved_Description { - get { - return ResourceManager.GetString("DockPanel_ContentRemoved_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The default size of float window.. - /// - internal static string DockPanel_DefaultFloatWindowSize_Description { - get { - return ResourceManager.GetString("DockPanel_DefaultFloatWindowSize_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Provides Visual Studio .Net style docking.. - /// - internal static string DockPanel_Description { - get { - return ResourceManager.GetString("DockPanel_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Size of the bottom docking window. Value < 1 to specify the size in portion; value > 1 to specify the size in pixels.. - /// - internal static string DockPanel_DockBottomPortion_Description { - get { - return ResourceManager.GetString("DockPanel_DockBottomPortion_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Size of the left docking window. Value < 1 to specify the size in portion; value > 1 to specify the size in pixels.. - /// - internal static string DockPanel_DockLeftPortion_Description { - get { - return ResourceManager.GetString("DockPanel_DockLeftPortion_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The visual skin to use when displaying the docked windows.. - /// - internal static string DockPanel_DockPanelSkin { - get { - return ResourceManager.GetString("DockPanel_DockPanelSkin", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Size of the right docking window. Value < 1 to specify the size in portion; value > 1 to specify the size in pixels.. - /// - internal static string DockPanel_DockRightPortion_Description { - get { - return ResourceManager.GetString("DockPanel_DockRightPortion_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Size of the top docking window. Value < 1 to specify the size in portion; value > 1 to specify the size in pixels.. - /// - internal static string DockPanel_DockTopPortion_Description { - get { - return ResourceManager.GetString("DockPanel_DockTopPortion_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The style of the document window.. - /// - internal static string DockPanel_DocumentStyle_Description { - get { - return ResourceManager.GetString("DockPanel_DocumentStyle_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Determines where the tab strip for Document style content is drawn.. - /// - internal static string DockPanel_DocumentTabStripLocation { - get { - return ResourceManager.GetString("DockPanel_DocumentTabStripLocation", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The DockPanel has already been initialized.. - /// - internal static string DockPanel_LoadFromXml_AlreadyInitialized { - get { - return ResourceManager.GetString("DockPanel_LoadFromXml_AlreadyInitialized", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The configuration file's version is invalid.. - /// - internal static string DockPanel_LoadFromXml_InvalidFormatVersion { - get { - return ResourceManager.GetString("DockPanel_LoadFromXml_InvalidFormatVersion", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The XML file format is invalid.. - /// - internal static string DockPanel_LoadFromXml_InvalidXmlFormat { - get { - return ResourceManager.GetString("DockPanel_LoadFromXml_InvalidXmlFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid parent form. When using DockingMdi or SystemMdi document style, the DockPanel control must be the child control of the main MDI container form.. - /// - internal static string DockPanel_ParentForm_Invalid { - get { - return ResourceManager.GetString("DockPanel_ParentForm_Invalid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to DockPanel configuration file. Author: Weifen Luo, all rights reserved.. - /// - internal static string DockPanel_Persistor_XmlFileComment1 { - get { - return ResourceManager.GetString("DockPanel_Persistor_XmlFileComment1", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to !!! AUTOMATICALLY GENERATED FILE. DO NOT MODIFY !!!. - /// - internal static string DockPanel_Persistor_XmlFileComment2 { - get { - return ResourceManager.GetString("DockPanel_Persistor_XmlFileComment2", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Indicates whether the control layout is right-to-left when the RightToLeft property is set to Yes.. - /// - internal static string DockPanel_RightToLeftLayout_Description { - get { - return ResourceManager.GetString("DockPanel_RightToLeftLayout_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid Index: The index is out of range.. - /// - internal static string DockPanel_SetPaneIndex_InvalidIndex { - get { - return ResourceManager.GetString("DockPanel_SetPaneIndex_InvalidIndex", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid Pane: DockPane not within the collection.. - /// - internal static string DockPanel_SetPaneIndex_InvalidPane { - get { - return ResourceManager.GetString("DockPanel_SetPaneIndex_InvalidPane", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Determines if the document icon will be displayed in the tab strip.. - /// - internal static string DockPanel_ShowDocumentIcon_Description { - get { - return ResourceManager.GetString("DockPanel_ShowDocumentIcon_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Close. - /// - internal static string DockPaneStrip_ToolTipClose { - get { - return ResourceManager.GetString("DockPaneStrip_ToolTipClose", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Window List. - /// - internal static string DockPaneStrip_ToolTipWindowList { - get { - return ResourceManager.GetString("DockPaneStrip_ToolTipWindowList", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid argument: DockPanel can not be "null".. - /// - internal static string FloatWindow_Constructor_NullDockPanel { - get { - return ResourceManager.GetString("FloatWindow_Constructor_NullDockPanel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid Index: The index is out of range.. - /// - internal static string FloatWindow_SetPaneIndex_InvalidIndex { - get { - return ResourceManager.GetString("FloatWindow_SetPaneIndex_InvalidIndex", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid Pane: DockPane not within the collection.. - /// - internal static string FloatWindow_SetPaneIndex_InvalidPane { - get { - return ResourceManager.GetString("FloatWindow_SetPaneIndex_InvalidPane", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid DockPanel.. - /// - internal static string IDockDragSource_DockTo_InvalidPanel { - get { - return ResourceManager.GetString("IDockDragSource_DockTo_InvalidPanel", resourceCulture); - } - } - } -} diff --git a/src/WinFormsUI/Docking/Strings.resx b/src/WinFormsUI/Docking/Strings.resx deleted file mode 100644 index d5ff49d5..00000000 --- a/src/WinFormsUI/Docking/Strings.resx +++ /dev/null @@ -1,357 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Docking - - - Docking Notification - - - Property Changed - - - (Float) - - - Determines if end user drag and drop docking is allowed. - - - The size to display the content in auto hide mode. Value < 1 to specify the size in portion; value >= 1 to specify the size in pixel. - - - Enable/Disable the close button of the content. - - - The form must be of type IDockContent. - - - Gets or sets a value indicating in which area of the DockPanel the content allowed to show. - - - Occurs when the value of DockState property changed. - - - Indicates the content will be hidden instead of being closed. - - - The desired docking state when first showing. - - - Context menu displayed for the dock pane tab strip. - - - The tab text displayed in the dock pane. If not set, the Text property will be used. - - - The text displayed when mouse hovers over the tab. - - - The provided value is out of range. - - - Invalid Value: The value of DockAreas conflicts with current DockState. - - - The pane is invalid. Check the IsFloat and DockPanel properties of this dock pane. - - - The pane is invalid. Check the IsFloat and DockPanel properties of this dock pane. - - - Invalid value, conflicts with DockableAreas property. - - - The dock state is invalid. - - - The dock panel is null. - - - Invalid beforeContent, it must be contained by the pane. - - - Invalid DockState: Content can not be showed as "Unknown" or "Hidden". - - - The previous pane is invalid. It can not be null, and its docking state must not be auto-hide. - - - DockPanel can not be null. - - - The Pane can not be null. - - - Invalid value, check DockableAreas property. - - - Context menu displayed for the dock pane tab strip. - - - Press SHIFT for docking to full side. - - - Invalid Content: ActiveContent must be one of the visible contents, or null if there is no visible content. - - - Invalid argument: Content can not be "null". - - - Invalid argument: The content's DockPanel can not be "null". - - - The specified container conflicts with the IsFloat property. - - - The previous pane does not exist in the nested docking pane collection. - - - The container can not be null. - - - The previous pane can not be null when the nested docking pane collection is not empty. - - - The previous pane can not be itself. - - - FloatWindow property can not be set to "null" when DockState is DockState.Float. - - - Invalid Content: Content not within the collection. - - - Invalid Index: The index is out of range. - - - The state for the dock pane is invalid. - - - Auto Hide - - - Close - - - Options - - - Invalid Content: The content must be auto-hide state and associates with this DockPanel. - - - Occurs when the value of ActiveContentProperty changed. - - - Occurs when the value of ActiveDocument property changed. - - - Occurs when the value of ActivePane property changed. - - - Determines if the drag and drop docking is allowed. - - - Determines if the drag and drop nested docking is allowed. - - - Occurs when a content added to the DockPanel. - - - Occurs when a content removed from the DockPanel. - - - The default size of float window. - - - Provides Visual Studio .Net style docking. - - - Size of the bottom docking window. Value < 1 to specify the size in portion; value > 1 to specify the size in pixels. - - - Size of the left docking window. Value < 1 to specify the size in portion; value > 1 to specify the size in pixels. - - - Size of the right docking window. Value < 1 to specify the size in portion; value > 1 to specify the size in pixels. - - - Size of the top docking window. Value < 1 to specify the size in portion; value > 1 to specify the size in pixels. - - - The style of the document window. - - - The DockPanel has already been initialized. - - - The configuration file's version is invalid. - - - The XML file format is invalid. - - - Invalid parent form. When using DockingMdi or SystemMdi document style, the DockPanel control must be the child control of the main MDI container form. - - - DockPanel configuration file. Author: Weifen Luo, all rights reserved. - - - !!! AUTOMATICALLY GENERATED FILE. DO NOT MODIFY !!! - - - Indicates whether the control layout is right-to-left when the RightToLeft property is set to Yes. - - - Invalid Index: The index is out of range. - - - Invalid Pane: DockPane not within the collection. - - - Determines if the document icon will be displayed in the tab strip. - - - Close - - - Window List - - - Invalid argument: DockPanel can not be "null". - - - Invalid Index: The index is out of range. - - - Invalid Pane: DockPane not within the collection. - - - Invalid DockPanel. - - - Shows or hides the close button of the content. This property does not function with System MDI Document Style. - - - The visual skin to use when displaying the docked windows. - - - Determines where the tab strip for Document style content is drawn. - - \ No newline at end of file diff --git a/src/WinFormsUI/Docking/VS2005AutoHideStrip.cs b/src/WinFormsUI/Docking/VS2005AutoHideStrip.cs deleted file mode 100644 index 8f2f992d..00000000 --- a/src/WinFormsUI/Docking/VS2005AutoHideStrip.cs +++ /dev/null @@ -1,604 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; -using System.Drawing.Drawing2D; -using System.ComponentModel; - -namespace WeifenLuo.WinFormsUI.Docking -{ - internal class VS2005AutoHideStrip : AutoHideStripBase - { - #region Fields - - private const int _ImageHeight = 16; - private const int _ImageWidth = 16; - private const int _ImageGapTop = 2; - private const int _ImageGapLeft = 4; - private const int _ImageGapRight = 2; - private const int _ImageGapBottom = 2; - private const int _TextGapLeft = 0; - private const int _TextGapRight = 0; - private const int _TabGapTop = 3; - private const int _TabGapLeft = 4; - private const int _TabGapBetween = 10; - - private static StringFormat _stringFormatTabHorizontal; - - private static StringFormat _stringFormatTabVertical; - - private static DockState[] _dockStates; - - private static GraphicsPath _graphicsPath; - - #endregion - - #region cTor - - public VS2005AutoHideStrip(DockPanel panel) - : base(panel) - { - SetStyle(ControlStyles.ResizeRedraw | - ControlStyles.UserPaint | - ControlStyles.AllPaintingInWmPaint | - ControlStyles.OptimizedDoubleBuffer, true); - BackColor = SystemColors.ControlLight; - } - - #endregion - - #region Properties - - public Font TextFont - { - get { return DockPanel.Skin.AutoHideStripSkin.TextFont; } - } - - private StringFormat StringFormatTabHorizontal - { - get - { - if (_stringFormatTabHorizontal == null) - { - _stringFormatTabHorizontal = new StringFormat(); - _stringFormatTabHorizontal.Alignment = StringAlignment.Near; - _stringFormatTabHorizontal.LineAlignment = StringAlignment.Center; - _stringFormatTabHorizontal.FormatFlags = StringFormatFlags.NoWrap; - _stringFormatTabHorizontal.Trimming = StringTrimming.None; - } - - if (RightToLeft == RightToLeft.Yes) - { - _stringFormatTabHorizontal.FormatFlags |= StringFormatFlags.DirectionRightToLeft; - } - else - { - _stringFormatTabHorizontal.FormatFlags &= ~StringFormatFlags.DirectionRightToLeft; - } - - return _stringFormatTabHorizontal; - } - } - - private StringFormat StringFormatTabVertical - { - get - { - if (_stringFormatTabVertical == null) - { - _stringFormatTabVertical = new StringFormat(); - _stringFormatTabVertical.Alignment = StringAlignment.Near; - _stringFormatTabVertical.LineAlignment = StringAlignment.Center; - _stringFormatTabVertical.FormatFlags = - StringFormatFlags.NoWrap | StringFormatFlags.DirectionVertical; - _stringFormatTabVertical.Trimming = StringTrimming.None; - } - if (RightToLeft == RightToLeft.Yes) - { - _stringFormatTabVertical.FormatFlags |= StringFormatFlags.DirectionRightToLeft; - } - else - { - _stringFormatTabVertical.FormatFlags &= ~StringFormatFlags.DirectionRightToLeft; - } - - return _stringFormatTabVertical; - } - } - - private static int ImageHeight - { - get { return _ImageHeight; } - } - - private static int ImageWidth - { - get { return _ImageWidth; } - } - - private static int ImageGapTop - { - get { return _ImageGapTop; } - } - - private static int ImageGapLeft - { - get { return _ImageGapLeft; } - } - - private static int ImageGapRight - { - get { return _ImageGapRight; } - } - - private static int ImageGapBottom - { - get { return _ImageGapBottom; } - } - - private static int TextGapLeft - { - get { return _TextGapLeft; } - } - - private static int TextGapRight - { - get { return _TextGapRight; } - } - - private static int TabGapTop - { - get { return _TabGapTop; } - } - - private static int TabGapLeft - { - get { return _TabGapLeft; } - } - - private static int TabGapBetween - { - get { return _TabGapBetween; } - } - - private static Pen PenTabBorder - { - get { return SystemPens.GrayText; } - } - - private static Matrix MatrixIdentity { get; } = new Matrix(); - - private static DockState[] DockStates - { - get - { - if (_dockStates == null) - { - _dockStates = new DockState[4]; - _dockStates[0] = DockState.DockLeftAutoHide; - _dockStates[1] = DockState.DockRightAutoHide; - _dockStates[2] = DockState.DockTopAutoHide; - _dockStates[3] = DockState.DockBottomAutoHide; - } - return _dockStates; - } - } - - internal static GraphicsPath GraphicsPath - { - get - { - if (_graphicsPath == null) - { - _graphicsPath = new GraphicsPath(); - } - - return _graphicsPath; - } - } - - #endregion - - #region Overrides - - protected override void OnPaint(PaintEventArgs e) - { - Graphics g = e.Graphics; - - Color startColor = DockPanel.Skin.AutoHideStripSkin.DockStripGradient.StartColor; - Color endColor = DockPanel.Skin.AutoHideStripSkin.DockStripGradient.EndColor; - LinearGradientMode gradientMode = DockPanel.Skin.AutoHideStripSkin.DockStripGradient.LinearGradientMode; - using (LinearGradientBrush brush = - new LinearGradientBrush(ClientRectangle, startColor, endColor, gradientMode)) - { - g.FillRectangle(brush, ClientRectangle); - } - - DrawTabStrip(g); - } - - protected override void OnLayout(LayoutEventArgs levent) - { - CalculateTabs(); - base.OnLayout(levent); - } - - protected override IDockContent HitTest(Point ptMouse) - { - foreach (DockState state in DockStates) - { - Rectangle rectTabStrip = GetLogicalTabStripRectangle(state, true); - if (!rectTabStrip.Contains(ptMouse)) - { - continue; - } - - foreach (Pane pane in GetPanes(state)) - { - foreach (TabVS2005 tab in pane.AutoHideTabs) - { - GraphicsPath path = GetTabOutline(tab, true, true); - if (path.IsVisible(ptMouse)) - { - return tab.Content; - } - } - } - } - - return null; - } - - protected internal override int MeasureHeight() - { - return Math.Max(ImageGapBottom + - ImageGapTop + ImageHeight, - TextFont.Height) + TabGapTop; - } - - protected override void OnRefreshChanges() - { - CalculateTabs(); - Invalidate(); - } - - protected override AutoHideStripBase.Tab CreateTab(IDockContent content) - { - return new TabVS2005(content); - } - - #endregion - - #region Private Methods - - private void DrawTabStrip(Graphics g) - { - DrawTabStrip(g, DockState.DockTopAutoHide); - DrawTabStrip(g, DockState.DockBottomAutoHide); - DrawTabStrip(g, DockState.DockLeftAutoHide); - DrawTabStrip(g, DockState.DockRightAutoHide); - } - - private void DrawTabStrip(Graphics g, DockState dockState) - { - Rectangle rectTabStrip = GetLogicalTabStripRectangle(dockState); - - if (rectTabStrip.IsEmpty) - { - return; - } - - Matrix matrixIdentity = g.Transform; - if (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockRightAutoHide) - { - Matrix matrixRotated = new Matrix(); - matrixRotated.RotateAt(90, new PointF((float) rectTabStrip.X + (float) rectTabStrip.Height / 2, - (float) rectTabStrip.Y + (float) rectTabStrip.Height / 2)); - g.Transform = matrixRotated; - } - - foreach (Pane pane in GetPanes(dockState)) - { - foreach (TabVS2005 tab in pane.AutoHideTabs) - { - DrawTab(g, tab); - } - } - g.Transform = matrixIdentity; - } - - private void CalculateTabs() - { - CalculateTabs(DockState.DockTopAutoHide); - CalculateTabs(DockState.DockBottomAutoHide); - CalculateTabs(DockState.DockLeftAutoHide); - CalculateTabs(DockState.DockRightAutoHide); - } - - private void CalculateTabs(DockState dockState) - { - Rectangle rectTabStrip = GetLogicalTabStripRectangle(dockState); - - int imageHeight = rectTabStrip.Height - ImageGapTop - ImageGapBottom; - int imageWidth = ImageWidth; - if (imageHeight > ImageHeight) - { - imageWidth = ImageWidth * (imageHeight / ImageHeight); - } - - int x = TabGapLeft + rectTabStrip.X; - foreach (Pane pane in GetPanes(dockState)) - { - foreach (TabVS2005 tab in pane.AutoHideTabs) - { - int width = imageWidth + ImageGapLeft + ImageGapRight + - TextRenderer.MeasureText(tab.Content.DockHandler.TabText, TextFont).Width + - TextGapLeft + TextGapRight; - tab.TabX = x; - tab.TabWidth = width; - x += width; - } - - x += TabGapBetween; - } - } - - private Rectangle RtlTransform(Rectangle rect, DockState dockState) - { - Rectangle rectTransformed; - if (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockRightAutoHide) - { - rectTransformed = rect; - } - else - { - rectTransformed = DrawHelper.RtlTransform(this, rect); - } - - return rectTransformed; - } - - private GraphicsPath GetTabOutline(TabVS2005 tab, bool transformed, bool rtlTransform) - { - DockState dockState = tab.Content.DockHandler.DockState; - Rectangle rectTab = GetTabRectangle(tab, transformed); - if (rtlTransform) - { - rectTab = RtlTransform(rectTab, dockState); - } - bool upTab = dockState == DockState.DockLeftAutoHide || dockState == DockState.DockBottomAutoHide; - DrawHelper.GetRoundedCornerTab(GraphicsPath, rectTab, upTab); - - return GraphicsPath; - } - - private void DrawTab(Graphics g, TabVS2005 tab) - { - Rectangle rectTabOrigin = GetTabRectangle(tab); - if (rectTabOrigin.IsEmpty) - { - return; - } - - DockState dockState = tab.Content.DockHandler.DockState; - IDockContent content = tab.Content; - - GraphicsPath path = GetTabOutline(tab, false, true); - - Color startColor = DockPanel.Skin.AutoHideStripSkin.TabGradient.StartColor; - Color endColor = DockPanel.Skin.AutoHideStripSkin.TabGradient.EndColor; - LinearGradientMode gradientMode = DockPanel.Skin.AutoHideStripSkin.TabGradient.LinearGradientMode; - g.FillPath(new LinearGradientBrush(rectTabOrigin, startColor, endColor, gradientMode), path); - g.DrawPath(PenTabBorder, path); - - // Set no rotate for drawing icon and text - Matrix matrixRotate = g.Transform; - g.Transform = MatrixIdentity; - - // Draw the icon - Rectangle rectImage = rectTabOrigin; - rectImage.X += ImageGapLeft; - rectImage.Y += ImageGapTop; - int imageHeight = rectTabOrigin.Height - ImageGapTop - ImageGapBottom; - int imageWidth = ImageWidth; - if (imageHeight > ImageHeight) - { - imageWidth = ImageWidth * (imageHeight / ImageHeight); - } - rectImage.Height = imageHeight; - rectImage.Width = imageWidth; - rectImage = GetTransformedRectangle(dockState, rectImage); - - if (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockRightAutoHide) - { - // The DockState is DockLeftAutoHide or DockRightAutoHide, so rotate the image 90 degrees to the right. - Rectangle rectTransform = RtlTransform(rectImage, dockState); - Point[] rotationPoints = - { - new Point(rectTransform.X + rectTransform.Width, rectTransform.Y), - new Point(rectTransform.X + rectTransform.Width, rectTransform.Y + rectTransform.Height), - new Point(rectTransform.X, rectTransform.Y) - }; - - using (Icon rotatedIcon = new Icon(((Form) content).Icon, 16, 16)) - { - g.DrawImage(rotatedIcon.ToBitmap(), rotationPoints); - } - } - else - { - // Draw the icon normally without any rotation. - g.DrawIcon(((Form) content).Icon, RtlTransform(rectImage, dockState)); - } - - // Draw the text - Rectangle rectText = rectTabOrigin; - rectText.X += ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft; - rectText.Width -= ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft; - rectText = RtlTransform(GetTransformedRectangle(dockState, rectText), dockState); - - Color textColor = DockPanel.Skin.AutoHideStripSkin.TabGradient.TextColor; - - if (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockRightAutoHide) - { - g.DrawString(content.DockHandler.TabText, TextFont, new SolidBrush(textColor), rectText, - StringFormatTabVertical); - } - else - { - g.DrawString(content.DockHandler.TabText, TextFont, new SolidBrush(textColor), rectText, - StringFormatTabHorizontal); - } - - // Set rotate back - g.Transform = matrixRotate; - } - - private Rectangle GetLogicalTabStripRectangle(DockState dockState) - { - return GetLogicalTabStripRectangle(dockState, false); - } - - private Rectangle GetLogicalTabStripRectangle(DockState dockState, bool transformed) - { - if (!DockHelper.IsDockStateAutoHide(dockState)) - { - return Rectangle.Empty; - } - - int leftPanes = GetPanes(DockState.DockLeftAutoHide).Count; - int rightPanes = GetPanes(DockState.DockRightAutoHide).Count; - int topPanes = GetPanes(DockState.DockTopAutoHide).Count; - int bottomPanes = GetPanes(DockState.DockBottomAutoHide).Count; - - int x, y, width, height; - - height = MeasureHeight(); - if (dockState == DockState.DockLeftAutoHide && leftPanes > 0) - { - x = 0; - y = topPanes == 0 ? 0 : height; - width = Height - (topPanes == 0 ? 0 : height) - (bottomPanes == 0 ? 0 : height); - } - else if (dockState == DockState.DockRightAutoHide && rightPanes > 0) - { - x = Width - height; - if (leftPanes != 0 && x < height) - { - x = height; - } - y = topPanes == 0 ? 0 : height; - width = Height - (topPanes == 0 ? 0 : height) - (bottomPanes == 0 ? 0 : height); - } - else if (dockState == DockState.DockTopAutoHide && topPanes > 0) - { - x = leftPanes == 0 ? 0 : height; - y = 0; - width = Width - (leftPanes == 0 ? 0 : height) - (rightPanes == 0 ? 0 : height); - } - else if (dockState == DockState.DockBottomAutoHide && bottomPanes > 0) - { - x = leftPanes == 0 ? 0 : height; - y = Height - height; - if (topPanes != 0 && y < height) - { - y = height; - } - width = Width - (leftPanes == 0 ? 0 : height) - (rightPanes == 0 ? 0 : height); - } - else - { - return Rectangle.Empty; - } - - if (!transformed) - { - return new Rectangle(x, y, width, height); - } - else - { - return GetTransformedRectangle(dockState, new Rectangle(x, y, width, height)); - } - } - - private Rectangle GetTabRectangle(TabVS2005 tab) - { - return GetTabRectangle(tab, false); - } - - private Rectangle GetTabRectangle(TabVS2005 tab, bool transformed) - { - DockState dockState = tab.Content.DockHandler.DockState; - Rectangle rectTabStrip = GetLogicalTabStripRectangle(dockState); - - if (rectTabStrip.IsEmpty) - { - return Rectangle.Empty; - } - - int x = tab.TabX; - int y = rectTabStrip.Y + - (dockState == DockState.DockTopAutoHide || dockState == DockState.DockRightAutoHide - ? 0 - : TabGapTop); - int width = tab.TabWidth; - int height = rectTabStrip.Height - TabGapTop; - - if (!transformed) - { - return new Rectangle(x, y, width, height); - } - else - { - return GetTransformedRectangle(dockState, new Rectangle(x, y, width, height)); - } - } - - private Rectangle GetTransformedRectangle(DockState dockState, Rectangle rect) - { - if (dockState != DockState.DockLeftAutoHide && dockState != DockState.DockRightAutoHide) - { - return rect; - } - - PointF[] pts = new PointF[1]; - // the center of the rectangle - pts[0].X = (float) rect.X + (float) rect.Width / 2; - pts[0].Y = (float) rect.Y + (float) rect.Height / 2; - Rectangle rectTabStrip = GetLogicalTabStripRectangle(dockState); - Matrix matrix = new Matrix(); - matrix.RotateAt(90, new PointF((float) rectTabStrip.X + (float) rectTabStrip.Height / 2, - (float) rectTabStrip.Y + (float) rectTabStrip.Height / 2)); - matrix.TransformPoints(pts); - - return new Rectangle((int) (pts[0].X - (float) rect.Height / 2 + .5F), - (int) (pts[0].Y - (float) rect.Width / 2 + .5F), - rect.Height, rect.Width); - } - - #endregion - - private class TabVS2005 : Tab - { - #region Fields - - #endregion - - #region cTor - - internal TabVS2005(IDockContent content) - : base(content) - { - } - - #endregion - - #region Properties - - public int TabX { get; set; } = 0; - - public int TabWidth { get; set; } = 0; - - #endregion - } - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/VS2005DockPaneCaption.cs b/src/WinFormsUI/Docking/VS2005DockPaneCaption.cs deleted file mode 100644 index 04c283c4..00000000 --- a/src/WinFormsUI/Docking/VS2005DockPaneCaption.cs +++ /dev/null @@ -1,582 +0,0 @@ -using System; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Windows.Forms; -using System.ComponentModel; -using System.Windows.Forms.VisualStyles; - -namespace WeifenLuo.WinFormsUI.Docking -{ - internal class VS2005DockPaneCaption : DockPaneCaptionBase - { - #region Fields - - private static Bitmap _imageButtonClose; - - private static Bitmap _imageButtonAutoHide; - - private static Bitmap _imageButtonDock; - - private static Bitmap _imageButtonOptions; - - private static string _toolTipClose; - - private static string _toolTipOptions; - - private static string _toolTipAutoHide; - - private static Blend _activeBackColorGradientBlend; - - private static readonly TextFormatFlags _textFormat = - TextFormatFlags.SingleLine | - TextFormatFlags.EndEllipsis | - TextFormatFlags.VerticalCenter; - - private InertButton m_buttonAutoHide; - - private InertButton m_buttonClose; - - private InertButton m_buttonOptions; - - private readonly ToolTip m_toolTip; - - #endregion - - #region cTor - - public VS2005DockPaneCaption(DockPane pane) : base(pane) - { - SuspendLayout(); - - Components = new Container(); - m_toolTip = new ToolTip(Components); - - ResumeLayout(); - } - - #endregion - - #region Properties - - private static Bitmap ImageButtonClose - { - get - { - if (_imageButtonClose == null) - { - _imageButtonClose = Resources.DockPane_Close; - } - - return _imageButtonClose; - } - } - - private InertButton ButtonClose - { - get - { - if (m_buttonClose == null) - { - m_buttonClose = new InertButton(this, ImageButtonClose, ImageButtonClose); - m_toolTip.SetToolTip(m_buttonClose, ToolTipClose); - m_buttonClose.Click += new EventHandler(Close_Click); - Controls.Add(m_buttonClose); - } - - return m_buttonClose; - } - } - - private static Bitmap ImageButtonAutoHide - { - get - { - if (_imageButtonAutoHide == null) - { - _imageButtonAutoHide = Resources.DockPane_AutoHide; - } - - return _imageButtonAutoHide; - } - } - - private static Bitmap ImageButtonDock - { - get - { - if (_imageButtonDock == null) - { - _imageButtonDock = Resources.DockPane_Dock; - } - - return _imageButtonDock; - } - } - - private InertButton ButtonAutoHide - { - get - { - if (m_buttonAutoHide == null) - { - m_buttonAutoHide = new InertButton(this, ImageButtonDock, ImageButtonAutoHide); - m_toolTip.SetToolTip(m_buttonAutoHide, ToolTipAutoHide); - m_buttonAutoHide.Click += new EventHandler(AutoHide_Click); - Controls.Add(m_buttonAutoHide); - } - - return m_buttonAutoHide; - } - } - - private static Bitmap ImageButtonOptions - { - get - { - if (_imageButtonOptions == null) - { - _imageButtonOptions = Resources.DockPane_Option; - } - - return _imageButtonOptions; - } - } - - private InertButton ButtonOptions - { - get - { - if (m_buttonOptions == null) - { - m_buttonOptions = new InertButton(this, ImageButtonOptions, ImageButtonOptions); - m_toolTip.SetToolTip(m_buttonOptions, ToolTipOptions); - m_buttonOptions.Click += new EventHandler(Options_Click); - Controls.Add(m_buttonOptions); - } - return m_buttonOptions; - } - } - - private IContainer Components { get; } - - private static int TextGapTop - { - get { return _TextGapTop; } - } - - public Font TextFont - { - get { return DockPane.DockPanel.Skin.DockPaneStripSkin.TextFont; } - } - - private static int TextGapBottom - { - get { return _TextGapBottom; } - } - - private static int TextGapLeft - { - get { return _TextGapLeft; } - } - - private static int TextGapRight - { - get { return _TextGapRight; } - } - - private static int ButtonGapTop - { - get { return _ButtonGapTop; } - } - - private static int ButtonGapBottom - { - get { return _ButtonGapBottom; } - } - - private static int ButtonGapLeft - { - get { return _ButtonGapLeft; } - } - - private static int ButtonGapRight - { - get { return _ButtonGapRight; } - } - - private static int ButtonGapBetween - { - get { return _ButtonGapBetween; } - } - - private static string ToolTipClose - { - get - { - if (_toolTipClose == null) - { - _toolTipClose = Strings.DockPaneCaption_ToolTipClose; - } - return _toolTipClose; - } - } - - private static string ToolTipOptions - { - get - { - if (_toolTipOptions == null) - { - _toolTipOptions = Strings.DockPaneCaption_ToolTipOptions; - } - - return _toolTipOptions; - } - } - - private static string ToolTipAutoHide - { - get - { - if (_toolTipAutoHide == null) - { - _toolTipAutoHide = Strings.DockPaneCaption_ToolTipAutoHide; - } - return _toolTipAutoHide; - } - } - - private static Blend ActiveBackColorGradientBlend - { - get - { - if (_activeBackColorGradientBlend == null) - { - Blend blend = new Blend(2); - - blend.Factors = new float[] {0.5F, 1.0F}; - blend.Positions = new float[] {0.0F, 1.0F}; - _activeBackColorGradientBlend = blend; - } - - return _activeBackColorGradientBlend; - } - } - - private Color TextColor - { - get - { - if (DockPane.IsActivated) - { - return DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveCaptionGradient.TextColor; - } - else - { - return DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveCaptionGradient - .TextColor; - } - } - } - - private TextFormatFlags TextFormat - { - get - { - if (RightToLeft == RightToLeft.No) - { - return _textFormat; - } - else - { - return _textFormat | TextFormatFlags.RightToLeft | TextFormatFlags.Right; - } - } - } - - private bool CloseButtonEnabled - { - get { return DockPane.ActiveContent != null ? DockPane.ActiveContent.DockHandler.CloseButton : false; } - } - - /// - /// Determines whether the close button is visible on the content - /// - private bool CloseButtonVisible - { - get - { - return DockPane.ActiveContent != null ? DockPane.ActiveContent.DockHandler.CloseButtonVisible : false; - } - } - - private bool ShouldShowAutoHideButton - { - get { return !DockPane.IsFloat; } - } - - #endregion - - #region Overrides - - protected override void Dispose(bool disposing) - { - if (disposing) - { - Components.Dispose(); - } - base.Dispose(disposing); - } - - protected internal override int MeasureHeight() - { - int height = TextFont.Height + TextGapTop + TextGapBottom; - - if (height < ButtonClose.Image.Height + ButtonGapTop + ButtonGapBottom) - { - height = ButtonClose.Image.Height + ButtonGapTop + ButtonGapBottom; - } - - return height; - } - - protected override void OnPaint(PaintEventArgs e) - { - base.OnPaint(e); - DrawCaption(e.Graphics); - } - - protected override void OnLayout(LayoutEventArgs levent) - { - SetButtonsPosition(); - base.OnLayout(levent); - } - - protected override void OnRefreshChanges() - { - SetButtons(); - Invalidate(); - } - - protected override void OnRightToLeftChanged(EventArgs e) - { - base.OnRightToLeftChanged(e); - PerformLayout(); - } - - #endregion - - #region Private Methods - - private void DrawCaption(Graphics g) - { - if (ClientRectangle.Width == 0 || ClientRectangle.Height == 0) - { - return; - } - - if (DockPane.IsActivated) - { - Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveCaptionGradient - .StartColor; - Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveCaptionGradient - .EndColor; - LinearGradientMode gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient - .ActiveCaptionGradient.LinearGradientMode; - using (LinearGradientBrush brush = - new LinearGradientBrush(ClientRectangle, startColor, endColor, gradientMode)) - { - brush.Blend = ActiveBackColorGradientBlend; - g.FillRectangle(brush, ClientRectangle); - } - } - else - { - Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveCaptionGradient - .StartColor; - Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveCaptionGradient - .EndColor; - LinearGradientMode gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient - .InactiveCaptionGradient.LinearGradientMode; - using (LinearGradientBrush brush = - new LinearGradientBrush(ClientRectangle, startColor, endColor, gradientMode)) - { - g.FillRectangle(brush, ClientRectangle); - } - } - - Rectangle rectCaption = ClientRectangle; - - Rectangle rectCaptionText = rectCaption; - rectCaptionText.X += TextGapLeft; - rectCaptionText.Width -= TextGapLeft + TextGapRight; - rectCaptionText.Width -= ButtonGapLeft + ButtonClose.Width + ButtonGapRight; - if (ShouldShowAutoHideButton) - { - rectCaptionText.Width -= ButtonAutoHide.Width + ButtonGapBetween; - } - if (HasTabPageContextMenu) - { - rectCaptionText.Width -= ButtonOptions.Width + ButtonGapBetween; - } - rectCaptionText.Y += TextGapTop; - rectCaptionText.Height -= TextGapTop + TextGapBottom; - - Color colorText; - if (DockPane.IsActivated) - { - colorText = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveCaptionGradient - .TextColor; - } - else - { - colorText = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveCaptionGradient - .TextColor; - } - - TextRenderer.DrawText(g, DockPane.CaptionText, TextFont, DrawHelper.RtlTransform(this, rectCaptionText), - colorText, TextFormat); - } - - private void SetButtons() - { - ButtonClose.Enabled = CloseButtonEnabled; - ButtonClose.Visible = CloseButtonVisible; - ButtonAutoHide.Visible = ShouldShowAutoHideButton; - ButtonOptions.Visible = HasTabPageContextMenu; - ButtonClose.RefreshChanges(); - ButtonAutoHide.RefreshChanges(); - ButtonOptions.RefreshChanges(); - - SetButtonsPosition(); - } - - private void SetButtonsPosition() - { - // set the size and location for close and auto-hide buttons - Rectangle rectCaption = ClientRectangle; - int buttonWidth = ButtonClose.Image.Width; - int buttonHeight = ButtonClose.Image.Height; - int height = rectCaption.Height - ButtonGapTop - ButtonGapBottom; - if (buttonHeight < height) - { - buttonWidth = buttonWidth * (height / buttonHeight); - buttonHeight = height; - } - Size buttonSize = new Size(buttonWidth, buttonHeight); - int x = rectCaption.X + rectCaption.Width - 1 - ButtonGapRight - m_buttonClose.Width; - int y = rectCaption.Y + ButtonGapTop; - Point point = new Point(x, y); - ButtonClose.Bounds = DrawHelper.RtlTransform(this, new Rectangle(point, buttonSize)); - - // If the close button is not visible draw the auto hide button overtop. - // Otherwise it is drawn to the left of the close button. - if (CloseButtonVisible) - { - point.Offset(-(buttonWidth + ButtonGapBetween), 0); - } - - ButtonAutoHide.Bounds = DrawHelper.RtlTransform(this, new Rectangle(point, buttonSize)); - if (ShouldShowAutoHideButton) - { - point.Offset(-(buttonWidth + ButtonGapBetween), 0); - } - ButtonOptions.Bounds = DrawHelper.RtlTransform(this, new Rectangle(point, buttonSize)); - } - - #endregion - - #region Events handler - - private void Close_Click(object sender, EventArgs e) - { - DockPane.CloseActiveContent(); - } - - private void AutoHide_Click(object sender, EventArgs e) - { - DockPane.DockState = DockHelper.ToggleAutoHideState(DockPane.DockState); - if (DockHelper.IsDockStateAutoHide(DockPane.DockState)) - { - DockPane.DockPanel.ActiveAutoHideContent = null; - DockPane.NestedDockingStatus.NestedPanes.SwitchPaneWithFirstChild(DockPane); - } - } - - private void Options_Click(object sender, EventArgs e) - { - ShowTabPageContextMenu(PointToClient(Control.MousePosition)); - } - - #endregion - - private sealed class InertButton : InertButtonBase - { - #region Fields - - private readonly Bitmap m_image; - private readonly Bitmap m_imageAutoHide; - - #endregion - - #region cTor - - public InertButton(VS2005DockPaneCaption dockPaneCaption, Bitmap image, Bitmap imageAutoHide) - : base() - { - DockPaneCaption = dockPaneCaption; - m_image = image; - m_imageAutoHide = imageAutoHide; - RefreshChanges(); - } - - #endregion - - #region Properties - - private VS2005DockPaneCaption DockPaneCaption { get; } - - public bool IsAutoHide - { - get { return DockPaneCaption.DockPane.IsAutoHide; } - } - - public override Bitmap Image - { - get { return IsAutoHide ? m_imageAutoHide : m_image; } - } - - #endregion - - #region Overrides - - protected override void OnRefreshChanges() - { - if (DockPaneCaption.DockPane.DockPanel != null) - { - if (DockPaneCaption.TextColor != ForeColor) - { - ForeColor = DockPaneCaption.TextColor; - Invalidate(); - } - } - } - - #endregion - } - - #region consts - - private const int _TextGapTop = 2; - private const int _TextGapBottom = 0; - private const int _TextGapLeft = 3; - private const int _TextGapRight = 3; - private const int _ButtonGapTop = 2; - private const int _ButtonGapBottom = 1; - private const int _ButtonGapBetween = 1; - private const int _ButtonGapLeft = 1; - private const int _ButtonGapRight = 2; - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/VS2005DockPaneStrip.cs b/src/WinFormsUI/Docking/VS2005DockPaneStrip.cs deleted file mode 100644 index 27885e55..00000000 --- a/src/WinFormsUI/Docking/VS2005DockPaneStrip.cs +++ /dev/null @@ -1,1707 +0,0 @@ -using System; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Windows.Forms; -using System.ComponentModel; -using System.Collections; -using System.Collections.Generic; - -namespace WeifenLuo.WinFormsUI.Docking -{ - internal class VS2005DockPaneStrip : DockPaneStripBase - { - #region cTor - - public VS2005DockPaneStrip(DockPane pane) - : base(pane) - { - SetStyle(ControlStyles.ResizeRedraw | - ControlStyles.UserPaint | - ControlStyles.AllPaintingInWmPaint | - ControlStyles.OptimizedDoubleBuffer, true); - - SuspendLayout(); - - Components = new Container(); - m_toolTip = new ToolTip(Components); - SelectMenu = new ContextMenuStrip(Components); - - ResumeLayout(); - } - - #endregion - - #region Properties - - private Rectangle TabStripRectangle - { - get - { - if (Appearance == DockPane.AppearanceStyle.Document) - { - return TabStripRectangle_Document; - } - else - { - return TabStripRectangle_ToolWindow; - } - } - } - - private Rectangle TabStripRectangle_ToolWindow - { - get - { - Rectangle rect = ClientRectangle; - return new Rectangle(rect.X, rect.Top + ToolWindowStripGapTop, rect.Width, - rect.Height - ToolWindowStripGapTop - ToolWindowStripGapBottom); - } - } - - private Rectangle TabStripRectangle_Document - { - get - { - Rectangle rect = ClientRectangle; - return new Rectangle(rect.X, rect.Top + DocumentStripGapTop, rect.Width, - rect.Height - DocumentStripGapTop - ToolWindowStripGapBottom); - } - } - - private Rectangle TabsRectangle - { - get - { - if (Appearance == DockPane.AppearanceStyle.ToolWindow) - { - return TabStripRectangle; - } - - Rectangle rectWindow = TabStripRectangle; - int x = rectWindow.X; - int y = rectWindow.Y; - int width = rectWindow.Width; - int height = rectWindow.Height; - - x += DocumentTabGapLeft; - width -= DocumentTabGapLeft + - DocumentTabGapRight + - DocumentButtonGapRight + - ButtonClose.Width + - ButtonWindowList.Width + - 2 * DocumentButtonGapBetween; - - return new Rectangle(x, y, width, height); - } - } - - private ContextMenuStrip SelectMenu { get; } - - private static Bitmap ImageButtonClose - { - get - { - if (m_imageButtonClose == null) - { - m_imageButtonClose = Resources.DockPane_Close; - } - - return m_imageButtonClose; - } - } - - private InertButton ButtonClose - { - get - { - if (m_buttonClose == null) - { - m_buttonClose = new InertButton(ImageButtonClose, ImageButtonClose); - m_toolTip.SetToolTip(m_buttonClose, ToolTipClose); - m_buttonClose.Click += new EventHandler(Close_Click); - Controls.Add(m_buttonClose); - } - - return m_buttonClose; - } - } - - private static Bitmap ImageButtonWindowList - { - get - { - if (m_imageButtonWindowList == null) - { - m_imageButtonWindowList = Resources.DockPane_Option; - } - - return m_imageButtonWindowList; - } - } - - private static Bitmap ImageButtonWindowListOverflow - { - get - { - if (m_imageButtonWindowListOverflow == null) - { - m_imageButtonWindowListOverflow = Resources.DockPane_OptionOverflow; - } - - return m_imageButtonWindowListOverflow; - } - } - - private InertButton ButtonWindowList - { - get - { - if (m_buttonWindowList == null) - { - m_buttonWindowList = new InertButton(ImageButtonWindowList, ImageButtonWindowListOverflow); - m_toolTip.SetToolTip(m_buttonWindowList, ToolTipSelect); - m_buttonWindowList.Click += new EventHandler(WindowList_Click); - Controls.Add(m_buttonWindowList); - } - - return m_buttonWindowList; - } - } - - private static GraphicsPath GraphicsPath - { - get { return VS2005AutoHideStrip.GraphicsPath; } - } - - private IContainer Components { get; } - - public Font TextFont - { - get { return DockPane.DockPanel.Skin.DockPaneStripSkin.TextFont; } - } - - private Font BoldFont - { - get - { - if (IsDisposed) - { - return null; - } - - if (m_boldFont == null) - { - m_font = TextFont; - m_boldFont = new Font(TextFont, FontStyle.Bold); - } - else if (m_font != TextFont) - { - m_boldFont.Dispose(); - m_font = TextFont; - m_boldFont = new Font(TextFont, FontStyle.Bold); - } - - return m_boldFont; - } - } - - private int StartDisplayingTab - { - get { return m_startDisplayingTab; } - set - { - m_startDisplayingTab = value; - Invalidate(); - } - } - - private int EndDisplayingTab { get; set; } = 0; - - private int FirstDisplayingTab { get; set; } = 0; - - private bool DocumentTabsOverflow - { - set - { - if (m_documentTabsOverflow == value) - { - return; - } - - m_documentTabsOverflow = value; - if (value) - { - ButtonWindowList.ImageCategory = 1; - } - else - { - ButtonWindowList.ImageCategory = 0; - } - } - } - - private static int ToolWindowStripGapTop - { - get { return _ToolWindowStripGapTop; } - } - - private static int ToolWindowStripGapBottom - { - get { return _ToolWindowStripGapBottom; } - } - - private static int ToolWindowStripGapLeft - { - get { return _ToolWindowStripGapLeft; } - } - - private static int ToolWindowStripGapRight - { - get { return _ToolWindowStripGapRight; } - } - - private static int ToolWindowImageHeight - { - get { return _ToolWindowImageHeight; } - } - - private static int ToolWindowImageWidth - { - get { return _ToolWindowImageWidth; } - } - - private static int ToolWindowImageGapTop - { - get { return _ToolWindowImageGapTop; } - } - - private static int ToolWindowImageGapBottom - { - get { return _ToolWindowImageGapBottom; } - } - - private static int ToolWindowImageGapLeft - { - get { return _ToolWindowImageGapLeft; } - } - - private static int ToolWindowImageGapRight - { - get { return _ToolWindowImageGapRight; } - } - - private static int ToolWindowTextGapRight - { - get { return _ToolWindowTextGapRight; } - } - - private static int ToolWindowTabSeperatorGapTop - { - get { return _ToolWindowTabSeperatorGapTop; } - } - - private static int ToolWindowTabSeperatorGapBottom - { - get { return _ToolWindowTabSeperatorGapBottom; } - } - - private static string ToolTipClose - { - get - { - if (m_toolTipClose == null) - { - m_toolTipClose = Strings.DockPaneStrip_ToolTipClose; - } - return m_toolTipClose; - } - } - - private static string ToolTipSelect - { - get - { - if (m_toolTipSelect == null) - { - m_toolTipSelect = Strings.DockPaneStrip_ToolTipWindowList; - } - return m_toolTipSelect; - } - } - - private TextFormatFlags ToolWindowTextFormat - { - get - { - TextFormatFlags textFormat = TextFormatFlags.EndEllipsis | - TextFormatFlags.HorizontalCenter | - TextFormatFlags.SingleLine | - TextFormatFlags.VerticalCenter; - if (RightToLeft == RightToLeft.Yes) - { - return textFormat | TextFormatFlags.RightToLeft | TextFormatFlags.Right; - } - else - { - return textFormat; - } - } - } - - private static int DocumentStripGapTop - { - get { return _DocumentStripGapTop; } - } - - private static int DocumentStripGapBottom - { - get { return _DocumentStripGapBottom; } - } - - private TextFormatFlags DocumentTextFormat - { - get - { - TextFormatFlags textFormat = TextFormatFlags.EndEllipsis | - TextFormatFlags.SingleLine | - TextFormatFlags.VerticalCenter | - TextFormatFlags.HorizontalCenter; - if (RightToLeft == RightToLeft.Yes) - { - return textFormat | TextFormatFlags.RightToLeft; - } - else - { - return textFormat; - } - } - } - - private static int DocumentTabMaxWidth - { - get { return _DocumentTabMaxWidth; } - } - - private static int DocumentButtonGapTop - { - get { return _DocumentButtonGapTop; } - } - - private static int DocumentButtonGapBottom - { - get { return _DocumentButtonGapBottom; } - } - - private static int DocumentButtonGapBetween - { - get { return _DocumentButtonGapBetween; } - } - - private static int DocumentButtonGapRight - { - get { return _DocumentButtonGapRight; } - } - - private static int DocumentTabGapTop - { - get { return _DocumentTabGapTop; } - } - - private static int DocumentTabGapLeft - { - get { return _DocumentTabGapLeft; } - } - - private static int DocumentTabGapRight - { - get { return _DocumentTabGapRight; } - } - - private static int DocumentIconGapBottom - { - get { return _DocumentIconGapBottom; } - } - - private static int DocumentIconGapLeft - { - get { return _DocumentIconGapLeft; } - } - - private static int DocumentIconGapRight - { - get { return _DocumentIconGapRight; } - } - - private static int DocumentIconWidth - { - get { return _DocumentIconWidth; } - } - - private static int DocumentIconHeight - { - get { return _DocumentIconHeight; } - } - - private static int DocumentTextGapRight - { - get { return _DocumentTextGapRight; } - } - - private static Pen PenToolWindowTabBorder - { - get { return SystemPens.GrayText; } - } - - private static Pen PenDocumentTabActiveBorder - { - get { return SystemPens.ControlDarkDark; } - } - - private static Pen PenDocumentTabInactiveBorder - { - get { return SystemPens.GrayText; } - } - - #endregion - - #region Overrides - - protected internal override DockPaneStripBase.Tab CreateTab(IDockContent content) - { - return new TabVS2005(content); - } - - protected override void Dispose(bool disposing) - { - if (disposing) - { - Components.Dispose(); - if (m_boldFont != null) - { - m_boldFont.Dispose(); - m_boldFont = null; - } - } - base.Dispose(disposing); - } - - protected internal override int MeasureHeight() - { - if (Appearance == DockPane.AppearanceStyle.ToolWindow) - { - return MeasureHeight_ToolWindow(); - } - else - { - return MeasureHeight_Document(); - } - } - - protected override void OnPaint(PaintEventArgs e) - { - Rectangle rect = TabsRectangle; - - if (Appearance == DockPane.AppearanceStyle.Document) - { - rect.X -= DocumentTabGapLeft; - - // Add these values back in so that the DockStrip color is drawn - // beneath the close button and window list button. - rect.Width += DocumentTabGapLeft + - DocumentTabGapRight + - DocumentButtonGapRight + - ButtonClose.Width + - ButtonWindowList.Width; - - // It is possible depending on the DockPanel DocumentStyle to have - // a Document without a DockStrip. - if (rect.Width > 0 && rect.Height > 0) - { - Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.DockStripGradient - .StartColor; - Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.DockStripGradient - .EndColor; - LinearGradientMode gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient - .DockStripGradient.LinearGradientMode; - using (LinearGradientBrush brush = new LinearGradientBrush(rect, startColor, endColor, gradientMode) - ) - { - e.Graphics.FillRectangle(brush, rect); - } - } - } - else - { - Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient - .StartColor; - Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient - .EndColor; - LinearGradientMode gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient - .DockStripGradient.LinearGradientMode; - using (LinearGradientBrush brush = new LinearGradientBrush(rect, startColor, endColor, gradientMode)) - { - e.Graphics.FillRectangle(brush, rect); - } - } - base.OnPaint(e); - CalculateTabs(); - if (Appearance == DockPane.AppearanceStyle.Document && DockPane.ActiveContent != null) - { - if (EnsureDocumentTabVisible(DockPane.ActiveContent, false)) - { - CalculateTabs(); - } - } - - DrawTabStrip(e.Graphics); - } - - protected override void OnRefreshChanges() - { - SetInertButtons(); - Invalidate(); - } - - protected internal override GraphicsPath GetOutline(int index) - { - if (Appearance == DockPane.AppearanceStyle.Document) - { - return GetOutline_Document(index); - } - else - { - return GetOutline_ToolWindow(index); - } - } - - protected internal override void EnsureTabVisible(IDockContent content) - { - if (Appearance != DockPane.AppearanceStyle.Document || !Tabs.Contains(content)) - { - return; - } - - CalculateTabs(); - EnsureDocumentTabVisible(content, true); - } - - protected override void OnLayout(LayoutEventArgs levent) - { - if (Appearance == DockPane.AppearanceStyle.Document) - { - LayoutButtons(); - OnRefreshChanges(); - } - - base.OnLayout(levent); - } - - protected internal override int HitTest(Point ptMouse) - { - if (!TabsRectangle.Contains(ptMouse)) - { - return -1; - } - - foreach (Tab tab in Tabs) - { - GraphicsPath path = GetTabOutline(tab, true, false); - if (path.IsVisible(ptMouse)) - { - return Tabs.IndexOf(tab); - } - } - return -1; - } - - protected override void OnMouseHover(EventArgs e) - { - int index = HitTest(PointToClient(Control.MousePosition)); - string toolTip = string.Empty; - - base.OnMouseHover(e); - - if (index != -1) - { - TabVS2005 tab = Tabs[index] as TabVS2005; - if (!string.IsNullOrEmpty(tab.Content.DockHandler.ToolTipText)) - { - toolTip = tab.Content.DockHandler.ToolTipText; - } - else if (tab.MaxWidth > tab.TabWidth) - { - toolTip = tab.Content.DockHandler.TabText; - } - } - - if (m_toolTip.GetToolTip(this) != toolTip) - { - m_toolTip.Active = false; - m_toolTip.SetToolTip(this, toolTip); - m_toolTip.Active = true; - } - - // requires further tracking of mouse hover behavior, - ResetMouseEventArgs(); - } - - protected override void OnRightToLeftChanged(EventArgs e) - { - base.OnRightToLeftChanged(e); - PerformLayout(); - } - - #endregion - - #region Private Methods - - private int MeasureHeight_ToolWindow() - { - if (DockPane.IsAutoHide || Tabs.Count <= 1) - { - return 0; - } - - int height = Math.Max(TextFont.Height, - ToolWindowImageHeight + ToolWindowImageGapTop + ToolWindowImageGapBottom) - + ToolWindowStripGapTop + ToolWindowStripGapBottom; - - return height; - } - - private int MeasureHeight_Document() - { - int height = Math.Max(TextFont.Height + DocumentTabGapTop, - ButtonClose.Height + DocumentButtonGapTop + DocumentButtonGapBottom) - + DocumentStripGapBottom + DocumentStripGapTop; - - return height; - } - - private GraphicsPath GetOutline_Document(int index) - { - Rectangle rectTab = GetTabRectangle(index); - rectTab.X -= rectTab.Height / 2; - rectTab.Intersect(TabsRectangle); - rectTab = RectangleToScreen(DrawHelper.RtlTransform(this, rectTab)); - Rectangle rectPaneClient = DockPane.RectangleToScreen(DockPane.ClientRectangle); - - GraphicsPath path = new GraphicsPath(); - GraphicsPath pathTab = GetTabOutline_Document(Tabs[index], true, true, true); - path.AddPath(pathTab, true); - - if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom) - { - path.AddLine(rectTab.Right, rectTab.Top, rectPaneClient.Right, rectTab.Top); - path.AddLine(rectPaneClient.Right, rectTab.Top, rectPaneClient.Right, rectPaneClient.Top); - path.AddLine(rectPaneClient.Right, rectPaneClient.Top, rectPaneClient.Left, rectPaneClient.Top); - path.AddLine(rectPaneClient.Left, rectPaneClient.Top, rectPaneClient.Left, rectTab.Top); - path.AddLine(rectPaneClient.Left, rectTab.Top, rectTab.Right, rectTab.Top); - } - else - { - path.AddLine(rectTab.Right, rectTab.Bottom, rectPaneClient.Right, rectTab.Bottom); - path.AddLine(rectPaneClient.Right, rectTab.Bottom, rectPaneClient.Right, rectPaneClient.Bottom); - path.AddLine(rectPaneClient.Right, rectPaneClient.Bottom, rectPaneClient.Left, rectPaneClient.Bottom); - path.AddLine(rectPaneClient.Left, rectPaneClient.Bottom, rectPaneClient.Left, rectTab.Bottom); - path.AddLine(rectPaneClient.Left, rectTab.Bottom, rectTab.Right, rectTab.Bottom); - } - return path; - } - - private GraphicsPath GetOutline_ToolWindow(int index) - { - Rectangle rectTab = GetTabRectangle(index); - rectTab.Intersect(TabsRectangle); - rectTab = RectangleToScreen(DrawHelper.RtlTransform(this, rectTab)); - Rectangle rectPaneClient = DockPane.RectangleToScreen(DockPane.ClientRectangle); - - GraphicsPath path = new GraphicsPath(); - GraphicsPath pathTab = GetTabOutline(Tabs[index], true, true); - path.AddPath(pathTab, true); - path.AddLine(rectTab.Left, rectTab.Top, rectPaneClient.Left, rectTab.Top); - path.AddLine(rectPaneClient.Left, rectTab.Top, rectPaneClient.Left, rectPaneClient.Top); - path.AddLine(rectPaneClient.Left, rectPaneClient.Top, rectPaneClient.Right, rectPaneClient.Top); - path.AddLine(rectPaneClient.Right, rectPaneClient.Top, rectPaneClient.Right, rectTab.Top); - path.AddLine(rectPaneClient.Right, rectTab.Top, rectTab.Right, rectTab.Top); - return path; - } - - private void CalculateTabs() - { - if (Appearance == DockPane.AppearanceStyle.ToolWindow) - { - CalculateTabs_ToolWindow(); - } - else - { - CalculateTabs_Document(); - } - } - - private void CalculateTabs_ToolWindow() - { - if (Tabs.Count <= 1 || DockPane.IsAutoHide) - { - return; - } - - Rectangle rectTabStrip = TabStripRectangle; - - // Calculate tab widths - int countTabs = Tabs.Count; - foreach (TabVS2005 tab in Tabs) - { - tab.MaxWidth = GetMaxTabWidth(Tabs.IndexOf(tab)); - tab.Flag = false; - } - - // Set tab whose max width less than average width - bool anyWidthWithinAverage = true; - int totalWidth = rectTabStrip.Width - ToolWindowStripGapLeft - ToolWindowStripGapRight; - int totalAllocatedWidth = 0; - int averageWidth = totalWidth / countTabs; - int remainedTabs = countTabs; - for (anyWidthWithinAverage = true; anyWidthWithinAverage && remainedTabs > 0;) - { - anyWidthWithinAverage = false; - foreach (TabVS2005 tab in Tabs) - { - if (tab.Flag) - { - continue; - } - - if (tab.MaxWidth <= averageWidth) - { - tab.Flag = true; - tab.TabWidth = tab.MaxWidth; - totalAllocatedWidth += tab.TabWidth; - anyWidthWithinAverage = true; - remainedTabs--; - } - } - if (remainedTabs != 0) - { - averageWidth = (totalWidth - totalAllocatedWidth) / remainedTabs; - } - } - - // If any tab width not set yet, set it to the average width - if (remainedTabs > 0) - { - int roundUpWidth = totalWidth - totalAllocatedWidth - averageWidth * remainedTabs; - foreach (TabVS2005 tab in Tabs) - { - if (tab.Flag) - { - continue; - } - - tab.Flag = true; - if (roundUpWidth > 0) - { - tab.TabWidth = averageWidth + 1; - roundUpWidth--; - } - else - { - tab.TabWidth = averageWidth; - } - } - } - - // Set the X position of the tabs - int x = rectTabStrip.X + ToolWindowStripGapLeft; - foreach (TabVS2005 tab in Tabs) - { - tab.TabX = x; - x += tab.TabWidth; - } - } - - private bool CalculateDocumentTab(Rectangle rectTabStrip, ref int x, int index) - { - bool overflow = false; - - TabVS2005 tab = Tabs[index] as TabVS2005; - tab.MaxWidth = GetMaxTabWidth(index); - int width = Math.Min(tab.MaxWidth, DocumentTabMaxWidth); - if (x + width < rectTabStrip.Right || index == StartDisplayingTab) - { - tab.TabX = x; - tab.TabWidth = width; - EndDisplayingTab = index; - } - else - { - tab.TabX = 0; - tab.TabWidth = 0; - overflow = true; - } - x += width; - - return overflow; - } - - /// - /// Calculate which tabs are displayed and in what order. - /// - private void CalculateTabs_Document() - { - if (m_startDisplayingTab >= Tabs.Count) - { - m_startDisplayingTab = 0; - } - - Rectangle rectTabStrip = TabsRectangle; - - int x = rectTabStrip.X + rectTabStrip.Height / 2; - bool overflow = false; - - // Originally all new documents that were considered overflow - // (not enough pane strip space to show all tabs) were added to - // the far left (assuming not right to left) and the tabs on the - // right were dropped from view. If StartDisplayingTab is not 0 - // then we are dealing with making sure a specific tab is kept in focus. - if (m_startDisplayingTab > 0) - { - int tempX = x; - TabVS2005 tab = Tabs[m_startDisplayingTab] as TabVS2005; - tab.MaxWidth = GetMaxTabWidth(m_startDisplayingTab); - - // Add the active tab and tabs to the left - for (int i = StartDisplayingTab; i >= 0; i--) - { - CalculateDocumentTab(rectTabStrip, ref tempX, i); - } - - // Store which tab is the first one displayed so that it - // will be drawn correctly (without part of the tab cut off) - FirstDisplayingTab = EndDisplayingTab; - - tempX = x; // Reset X location because we are starting over - - // Start with the first tab displayed - name is a little misleading. - // Loop through each tab and set its location. If there is not enough - // room for all of them overflow will be returned. - for (int i = EndDisplayingTab; i < Tabs.Count; i++) - { - overflow = CalculateDocumentTab(rectTabStrip, ref tempX, i); - } - - // If not all tabs are shown then we have an overflow. - if (FirstDisplayingTab != 0) - { - overflow = true; - } - } - else - { - for (int i = StartDisplayingTab; i < Tabs.Count; i++) - { - overflow = CalculateDocumentTab(rectTabStrip, ref x, i); - } - for (int i = 0; i < StartDisplayingTab; i++) - { - overflow = CalculateDocumentTab(rectTabStrip, ref x, i); - } - - FirstDisplayingTab = StartDisplayingTab; - } - - if (!overflow) - { - m_startDisplayingTab = 0; - FirstDisplayingTab = 0; - x = rectTabStrip.X + rectTabStrip.Height / 2; - foreach (TabVS2005 tab in Tabs) - { - tab.TabX = x; - x += tab.TabWidth; - } - } - DocumentTabsOverflow = overflow; - } - - private bool EnsureDocumentTabVisible(IDockContent content, bool repaint) - { - int index = Tabs.IndexOf(content); - TabVS2005 tab = Tabs[index] as TabVS2005; - if (tab.TabWidth != 0) - { - return false; - } - - StartDisplayingTab = index; - if (repaint) - { - Invalidate(); - } - - return true; - } - - private int GetMaxTabWidth(int index) - { - if (Appearance == DockPane.AppearanceStyle.ToolWindow) - { - return GetMaxTabWidth_ToolWindow(index); - } - else - { - return GetMaxTabWidth_Document(index); - } - } - - private int GetMaxTabWidth_ToolWindow(int index) - { - IDockContent content = Tabs[index].Content; - Size sizeString = TextRenderer.MeasureText(content.DockHandler.TabText, TextFont); - return ToolWindowImageWidth + sizeString.Width + ToolWindowImageGapLeft - + ToolWindowImageGapRight + ToolWindowTextGapRight; - } - - private int GetMaxTabWidth_Document(int index) - { - IDockContent content = Tabs[index].Content; - - int height = GetTabRectangle_Document(index).Height; - - Size sizeText = TextRenderer.MeasureText(content.DockHandler.TabText, BoldFont, - new Size(DocumentTabMaxWidth, height), DocumentTextFormat); - - if (DockPane.DockPanel.ShowDocumentIcon) - { - return sizeText.Width + DocumentIconWidth + DocumentIconGapLeft + DocumentIconGapRight + - DocumentTextGapRight; - } - else - { - return sizeText.Width + DocumentIconGapLeft + DocumentTextGapRight; - } - } - - private void DrawTabStrip(Graphics g) - { - if (Appearance == DockPane.AppearanceStyle.Document) - { - DrawTabStrip_Document(g); - } - else - { - DrawTabStrip_ToolWindow(g); - } - } - - private void DrawTabStrip_Document(Graphics g) - { - int count = Tabs.Count; - if (count == 0) - { - return; - } - - Rectangle rectTabStrip = TabStripRectangle; - - // Draw the tabs - Rectangle rectTabOnly = TabsRectangle; - Rectangle rectTab = Rectangle.Empty; - TabVS2005 tabActive = null; - g.SetClip(DrawHelper.RtlTransform(this, rectTabOnly)); - for (int i = 0; i < count; i++) - { - rectTab = GetTabRectangle(i); - if (Tabs[i].Content == DockPane.ActiveContent) - { - tabActive = Tabs[i] as TabVS2005; - continue; - } - if (rectTab.IntersectsWith(rectTabOnly)) - { - DrawTab(g, Tabs[i] as TabVS2005, rectTab); - } - } - - g.SetClip(rectTabStrip); - - if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom) - { - g.DrawLine(PenDocumentTabActiveBorder, rectTabStrip.Left, rectTabStrip.Top + 1, - rectTabStrip.Right, rectTabStrip.Top + 1); - } - else - { - g.DrawLine(PenDocumentTabActiveBorder, rectTabStrip.Left, rectTabStrip.Bottom - 1, - rectTabStrip.Right, rectTabStrip.Bottom - 1); - } - - g.SetClip(DrawHelper.RtlTransform(this, rectTabOnly)); - if (tabActive != null) - { - rectTab = GetTabRectangle(Tabs.IndexOf(tabActive)); - if (rectTab.IntersectsWith(rectTabOnly)) - { - DrawTab(g, tabActive, rectTab); - } - } - } - - private void DrawTabStrip_ToolWindow(Graphics g) - { - Rectangle rectTabStrip = TabStripRectangle; - - g.DrawLine(PenToolWindowTabBorder, rectTabStrip.Left, rectTabStrip.Top, - rectTabStrip.Right, rectTabStrip.Top); - - for (int i = 0; i < Tabs.Count; i++) - { - DrawTab(g, Tabs[i] as TabVS2005, GetTabRectangle(i)); - } - } - - private Rectangle GetTabRectangle(int index) - { - if (Appearance == DockPane.AppearanceStyle.ToolWindow) - { - return GetTabRectangle_ToolWindow(index); - } - else - { - return GetTabRectangle_Document(index); - } - } - - private Rectangle GetTabRectangle_ToolWindow(int index) - { - Rectangle rectTabStrip = TabStripRectangle; - - TabVS2005 tab = (TabVS2005) Tabs[index]; - return new Rectangle(tab.TabX, rectTabStrip.Y, tab.TabWidth, rectTabStrip.Height); - } - - private Rectangle GetTabRectangle_Document(int index) - { - Rectangle rectTabStrip = TabStripRectangle; - TabVS2005 tab = (TabVS2005) Tabs[index]; - - Rectangle rect = new Rectangle(); - rect.X = tab.TabX; - rect.Width = tab.TabWidth; - rect.Height = rectTabStrip.Height - DocumentTabGapTop; - - if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom) - { - rect.Y = rectTabStrip.Y + DocumentStripGapBottom; - } - else - { - rect.Y = rectTabStrip.Y + DocumentTabGapTop; - } - - return rect; - } - - private void DrawTab(Graphics g, TabVS2005 tab, Rectangle rect) - { - if (Appearance == DockPane.AppearanceStyle.ToolWindow) - { - DrawTab_ToolWindow(g, tab, rect); - } - else - { - DrawTab_Document(g, tab, rect); - } - } - - private GraphicsPath GetTabOutline(Tab tab, bool rtlTransform, bool toScreen) - { - if (Appearance == DockPane.AppearanceStyle.ToolWindow) - { - return GetTabOutline_ToolWindow(tab, rtlTransform, toScreen); - } - else - { - return GetTabOutline_Document(tab, rtlTransform, toScreen, false); - } - } - - private GraphicsPath GetTabOutline_ToolWindow(Tab tab, bool rtlTransform, bool toScreen) - { - Rectangle rect = GetTabRectangle(Tabs.IndexOf(tab)); - if (rtlTransform) - { - rect = DrawHelper.RtlTransform(this, rect); - } - if (toScreen) - { - rect = RectangleToScreen(rect); - } - - DrawHelper.GetRoundedCornerTab(GraphicsPath, rect, false); - return GraphicsPath; - } - - private GraphicsPath GetTabOutline_Document(Tab tab, bool rtlTransform, bool toScreen, bool full) - { - int curveSize = 6; - - GraphicsPath.Reset(); - Rectangle rect = GetTabRectangle(Tabs.IndexOf(tab)); - if (rtlTransform) - { - rect = DrawHelper.RtlTransform(this, rect); - } - if (toScreen) - { - rect = RectangleToScreen(rect); - } - - // Draws the full angle piece for active content (or first tab) - if (tab.Content == DockPane.ActiveContent || full || Tabs.IndexOf(tab) == FirstDisplayingTab) - { - if (RightToLeft == RightToLeft.Yes) - { - if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom) - { - // For some reason the next line draws a line that is not hidden like it is when drawing the tab strip on top. - // It is not needed so it has been commented out. - //GraphicsPath.AddLine(rect.Right, rect.Bottom, rect.Right + rect.Height / 2, rect.Bottom); - GraphicsPath.AddLine(rect.Right + rect.Height / 2, rect.Top, - rect.Right - rect.Height / 2 + curveSize / 2, rect.Bottom - curveSize / 2); - } - else - { - GraphicsPath.AddLine(rect.Right, rect.Bottom, rect.Right + rect.Height / 2, rect.Bottom); - GraphicsPath.AddLine(rect.Right + rect.Height / 2, rect.Bottom, - rect.Right - rect.Height / 2 + curveSize / 2, rect.Top + curveSize / 2); - } - } - else - { - if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom) - { - // For some reason the next line draws a line that is not hidden like it is when drawing the tab strip on top. - // It is not needed so it has been commented out. - //GraphicsPath.AddLine(rect.Left, rect.Top, rect.Left - rect.Height / 2, rect.Top); - GraphicsPath.AddLine(rect.Left - rect.Height / 2, rect.Top, - rect.Left + rect.Height / 2 - curveSize / 2, rect.Bottom - curveSize / 2); - } - else - { - GraphicsPath.AddLine(rect.Left, rect.Bottom, rect.Left - rect.Height / 2, rect.Bottom); - GraphicsPath.AddLine(rect.Left - rect.Height / 2, rect.Bottom, - rect.Left + rect.Height / 2 - curveSize / 2, rect.Top + curveSize / 2); - } - } - } - // Draws the partial angle for non-active content - else - { - if (RightToLeft == RightToLeft.Yes) - { - if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom) - { - GraphicsPath.AddLine(rect.Right, rect.Top, rect.Right, rect.Top + rect.Height / 2); - GraphicsPath.AddLine(rect.Right, rect.Top + rect.Height / 2, - rect.Right - rect.Height / 2 + curveSize / 2, rect.Bottom - curveSize / 2); - } - else - { - GraphicsPath.AddLine(rect.Right, rect.Bottom, rect.Right, rect.Bottom - rect.Height / 2); - GraphicsPath.AddLine(rect.Right, rect.Bottom - rect.Height / 2, - rect.Right - rect.Height / 2 + curveSize / 2, rect.Top + curveSize / 2); - } - } - else - { - if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom) - { - GraphicsPath.AddLine(rect.Left, rect.Top, rect.Left, rect.Top + rect.Height / 2); - GraphicsPath.AddLine(rect.Left, rect.Top + rect.Height / 2, - rect.Left + rect.Height / 2 - curveSize / 2, rect.Bottom - curveSize / 2); - } - else - { - GraphicsPath.AddLine(rect.Left, rect.Bottom, rect.Left, rect.Bottom - rect.Height / 2); - GraphicsPath.AddLine(rect.Left, rect.Bottom - rect.Height / 2, - rect.Left + rect.Height / 2 - curveSize / 2, rect.Top + curveSize / 2); - } - } - } - - if (RightToLeft == RightToLeft.Yes) - { - if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom) - { - // Draws the bottom horizontal line (short side) - GraphicsPath.AddLine(rect.Right - rect.Height / 2 - curveSize / 2, rect.Bottom, - rect.Left + curveSize / 2, rect.Bottom); - - // Drawing the rounded corner is not necessary. The path is automatically connected - //GraphicsPath.AddArc(new Rectangle(rect.Left, rect.Top, curveSize, curveSize), 180, 90); - } - else - { - // Draws the bottom horizontal line (short side) - GraphicsPath.AddLine(rect.Right - rect.Height / 2 - curveSize / 2, rect.Top, - rect.Left + curveSize / 2, rect.Top); - GraphicsPath.AddArc(new Rectangle(rect.Left, rect.Top, curveSize, curveSize), 180, 90); - } - } - else - { - if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom) - { - // Draws the bottom horizontal line (short side) - GraphicsPath.AddLine(rect.Left + rect.Height / 2 + curveSize / 2, rect.Bottom, - rect.Right - curveSize / 2, rect.Bottom); - - // Drawing the rounded corner is not necessary. The path is automatically connected - //GraphicsPath.AddArc(new Rectangle(rect.Right - curveSize, rect.Bottom, curveSize, curveSize), 90, -90); - } - else - { - // Draws the top horizontal line (short side) - GraphicsPath.AddLine(rect.Left + rect.Height / 2 + curveSize / 2, rect.Top, - rect.Right - curveSize / 2, rect.Top); - - // Draws the rounded corner oppposite the angled side - GraphicsPath.AddArc(new Rectangle(rect.Right - curveSize, rect.Top, curveSize, curveSize), -90, 90); - } - } - - if (Tabs.IndexOf(tab) != EndDisplayingTab && Tabs.IndexOf(tab) != Tabs.Count - 1 && - Tabs[Tabs.IndexOf(tab) + 1].Content == DockPane.ActiveContent && !full) - { - if (RightToLeft == RightToLeft.Yes) - { - if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom) - { - GraphicsPath.AddLine(rect.Left, rect.Bottom - curveSize / 2, rect.Left, - rect.Bottom - rect.Height / 2); - GraphicsPath.AddLine(rect.Left, rect.Bottom - rect.Height / 2, rect.Left + rect.Height / 2, - rect.Top); - } - else - { - GraphicsPath.AddLine(rect.Left, rect.Top + curveSize / 2, rect.Left, - rect.Top + rect.Height / 2); - GraphicsPath.AddLine(rect.Left, rect.Top + rect.Height / 2, rect.Left + rect.Height / 2, - rect.Bottom); - } - } - else - { - if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom) - { - GraphicsPath.AddLine(rect.Right, rect.Bottom - curveSize / 2, rect.Right, - rect.Bottom - rect.Height / 2); - GraphicsPath.AddLine(rect.Right, rect.Bottom - rect.Height / 2, rect.Right - rect.Height / 2, - rect.Top); - } - else - { - GraphicsPath.AddLine(rect.Right, rect.Top + curveSize / 2, rect.Right, - rect.Top + rect.Height / 2); - GraphicsPath.AddLine(rect.Right, rect.Top + rect.Height / 2, rect.Right - rect.Height / 2, - rect.Bottom); - } - } - } - else - { - // Draw the vertical line opposite the angled side - if (RightToLeft == RightToLeft.Yes) - { - if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom) - { - GraphicsPath.AddLine(rect.Left, rect.Bottom - curveSize / 2, rect.Left, rect.Top); - } - else - { - GraphicsPath.AddLine(rect.Left, rect.Top + curveSize / 2, rect.Left, rect.Bottom); - } - } - else - { - if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom) - { - GraphicsPath.AddLine(rect.Right, rect.Bottom - curveSize / 2, rect.Right, rect.Top); - } - else - { - GraphicsPath.AddLine(rect.Right, rect.Top + curveSize / 2, rect.Right, rect.Bottom); - } - } - } - - return GraphicsPath; - } - - private void DrawTab_ToolWindow(Graphics g, TabVS2005 tab, Rectangle rect) - { - Rectangle rectIcon = new Rectangle( - rect.X + ToolWindowImageGapLeft, - rect.Y + rect.Height - 1 - ToolWindowImageGapBottom - ToolWindowImageHeight, - ToolWindowImageWidth, ToolWindowImageHeight); - Rectangle rectText = rectIcon; - rectText.X += rectIcon.Width + ToolWindowImageGapRight; - rectText.Width = rect.Width - rectIcon.Width - ToolWindowImageGapLeft - - ToolWindowImageGapRight - ToolWindowTextGapRight; - - Rectangle rectTab = DrawHelper.RtlTransform(this, rect); - rectText = DrawHelper.RtlTransform(this, rectText); - rectIcon = DrawHelper.RtlTransform(this, rectIcon); - GraphicsPath path = GetTabOutline(tab, true, false); - if (DockPane.ActiveContent == tab.Content) - { - Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient - .StartColor; - Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient - .EndColor; - LinearGradientMode gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient - .ActiveTabGradient.LinearGradientMode; - g.FillPath(new LinearGradientBrush(rectTab, startColor, endColor, gradientMode), path); - g.DrawPath(PenToolWindowTabBorder, path); - - Color textColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient - .TextColor; - TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, textColor, - ToolWindowTextFormat); - } - else - { - Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient - .StartColor; - Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient - .EndColor; - LinearGradientMode gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient - .InactiveTabGradient.LinearGradientMode; - g.FillPath(new LinearGradientBrush(rectTab, startColor, endColor, gradientMode), path); - - if (Tabs.IndexOf(DockPane.ActiveContent) != Tabs.IndexOf(tab) + 1) - { - Point pt1 = new Point(rect.Right, rect.Top + ToolWindowTabSeperatorGapTop); - Point pt2 = new Point(rect.Right, rect.Bottom - ToolWindowTabSeperatorGapBottom); - g.DrawLine(PenToolWindowTabBorder, DrawHelper.RtlTransform(this, pt1), - DrawHelper.RtlTransform(this, pt2)); - } - - Color textColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient - .TextColor; - TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, textColor, - ToolWindowTextFormat); - } - - if (rectTab.Contains(rectIcon)) - { - g.DrawIcon(tab.Content.DockHandler.Icon, rectIcon); - } - } - - private void DrawTab_Document(Graphics g, TabVS2005 tab, Rectangle rect) - { - if (tab.TabWidth == 0) - { - return; - } - - Rectangle rectIcon = new Rectangle( - rect.X + DocumentIconGapLeft, - rect.Y + rect.Height - 1 - DocumentIconGapBottom - DocumentIconHeight, - DocumentIconWidth, DocumentIconHeight); - Rectangle rectText = rectIcon; - if (DockPane.DockPanel.ShowDocumentIcon) - { - rectText.X += rectIcon.Width + DocumentIconGapRight; - rectText.Y = rect.Y; - rectText.Width = rect.Width - rectIcon.Width - DocumentIconGapLeft - - DocumentIconGapRight - DocumentTextGapRight; - rectText.Height = rect.Height; - } - else - { - rectText.Width = rect.Width - DocumentIconGapLeft - DocumentTextGapRight; - } - - Rectangle rectTab = DrawHelper.RtlTransform(this, rect); - Rectangle rectBack = DrawHelper.RtlTransform(this, rect); - rectBack.Width += rect.X; - rectBack.X = 0; - - rectText = DrawHelper.RtlTransform(this, rectText); - rectIcon = DrawHelper.RtlTransform(this, rectIcon); - GraphicsPath path = GetTabOutline(tab, true, false); - if (DockPane.ActiveContent == tab.Content) - { - Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient - .StartColor; - Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.EndColor; - LinearGradientMode gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient - .ActiveTabGradient.LinearGradientMode; - g.FillPath(new LinearGradientBrush(rectBack, startColor, endColor, gradientMode), path); - g.DrawPath(PenDocumentTabActiveBorder, path); - - Color textColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient - .TextColor; - if (DockPane.IsActiveDocumentPane) - { - TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, BoldFont, rectText, textColor, - DocumentTextFormat); - } - else - { - TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, textColor, - DocumentTextFormat); - } - } - else - { - Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient - .StartColor; - Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient - .EndColor; - LinearGradientMode gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient - .InactiveTabGradient.LinearGradientMode; - g.FillPath(new LinearGradientBrush(rectBack, startColor, endColor, gradientMode), path); - g.DrawPath(PenDocumentTabInactiveBorder, path); - - Color textColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient - .TextColor; - TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, textColor, - DocumentTextFormat); - } - - if (rectTab.Contains(rectIcon) && DockPane.DockPanel.ShowDocumentIcon) - { - g.DrawIcon(tab.Content.DockHandler.Icon, rectIcon); - } - } - - private void SetInertButtons() - { - if (Appearance == DockPane.AppearanceStyle.ToolWindow) - { - if (m_buttonClose != null) - { - m_buttonClose.Left = -m_buttonClose.Width; - } - - if (m_buttonWindowList != null) - { - m_buttonWindowList.Left = -m_buttonWindowList.Width; - } - } - else - { - ButtonClose.Enabled = DockPane.ActiveContent == null - ? true - : DockPane.ActiveContent.DockHandler.CloseButton; - m_closeButtonVisible = DockPane.ActiveContent == null - ? true - : DockPane.ActiveContent.DockHandler.CloseButtonVisible; - ButtonClose.Visible = m_closeButtonVisible; - ButtonClose.RefreshChanges(); - ButtonWindowList.RefreshChanges(); - } - } - - private void LayoutButtons() - { - Rectangle rectTabStrip = TabStripRectangle; - - // Set position and size of the buttons - int buttonWidth = ButtonClose.Image.Width; - int buttonHeight = ButtonClose.Image.Height; - int height = rectTabStrip.Height - DocumentButtonGapTop - DocumentButtonGapBottom; - if (buttonHeight < height) - { - buttonWidth = buttonWidth * (height / buttonHeight); - buttonHeight = height; - } - Size buttonSize = new Size(buttonWidth, buttonHeight); - - int x = rectTabStrip.X + rectTabStrip.Width - DocumentTabGapLeft - - DocumentButtonGapRight - buttonWidth; - int y = rectTabStrip.Y + DocumentButtonGapTop; - Point point = new Point(x, y); - ButtonClose.Bounds = DrawHelper.RtlTransform(this, new Rectangle(point, buttonSize)); - - // If the close button is not visible draw the window list button overtop. - // Otherwise it is drawn to the left of the close button. - if (m_closeButtonVisible) - { - point.Offset(-(DocumentButtonGapBetween + buttonWidth), 0); - } - - ButtonWindowList.Bounds = DrawHelper.RtlTransform(this, new Rectangle(point, buttonSize)); - } - - #endregion - - #region Events handler - - private void WindowList_Click(object sender, EventArgs e) - { - int x = 0; - int y = ButtonWindowList.Location.Y + ButtonWindowList.Height; - - SelectMenu.Items.Clear(); - foreach (TabVS2005 tab in Tabs) - { - IDockContent content = tab.Content; - ToolStripItem item = - SelectMenu.Items.Add(content.DockHandler.TabText, content.DockHandler.Icon.ToBitmap()); - item.Tag = tab.Content; - item.Click += new EventHandler(ContextMenuItem_Click); - } - SelectMenu.Show(ButtonWindowList, x, y); - } - - private void ContextMenuItem_Click(object sender, EventArgs e) - { - ToolStripMenuItem item = sender as ToolStripMenuItem; - if (item != null) - { - IDockContent content = (IDockContent) item.Tag; - DockPane.ActiveContent = content; - } - } - - private void Close_Click(object sender, EventArgs e) - { - DockPane.CloseActiveContent(); - } - - #endregion - - private class TabVS2005 : Tab - { - #region Fields - - #endregion - - #region cTor - - public TabVS2005(IDockContent content) - : base(content) - { - } - - #endregion - - #region Properties - - public int TabX { get; set; } - - public int TabWidth { get; set; } - - public int MaxWidth { get; set; } - - protected internal bool Flag { get; set; } - - #endregion - } - - private sealed class InertButton : InertButtonBase - { - #region Fields - - private readonly Bitmap m_image0; - private readonly Bitmap m_image1; - - private int m_imageCategory = 0; - - #endregion - - #region cTor - - public InertButton(Bitmap image0, Bitmap image1) - : base() - { - m_image0 = image0; - m_image1 = image1; - } - - #endregion - - #region Properties - - public int ImageCategory - { - get { return m_imageCategory; } - set - { - if (m_imageCategory == value) - { - return; - } - - m_imageCategory = value; - Invalidate(); - } - } - - public override Bitmap Image - { - get { return ImageCategory == 0 ? m_image0 : m_image1; } - } - - #endregion - } - - #region Constants - - private const int _ToolWindowStripGapTop = 0; - private const int _ToolWindowStripGapBottom = 1; - private const int _ToolWindowStripGapLeft = 0; - private const int _ToolWindowStripGapRight = 0; - private const int _ToolWindowImageHeight = 16; - private const int _ToolWindowImageWidth = 16; - private const int _ToolWindowImageGapTop = 3; - private const int _ToolWindowImageGapBottom = 1; - private const int _ToolWindowImageGapLeft = 2; - private const int _ToolWindowImageGapRight = 0; - private const int _ToolWindowTextGapRight = 3; - private const int _ToolWindowTabSeperatorGapTop = 3; - private const int _ToolWindowTabSeperatorGapBottom = 3; - - private const int _DocumentStripGapTop = 0; - private const int _DocumentStripGapBottom = 1; - private const int _DocumentTabMaxWidth = 200; - private const int _DocumentButtonGapTop = 4; - private const int _DocumentButtonGapBottom = 4; - private const int _DocumentButtonGapBetween = 0; - private const int _DocumentButtonGapRight = 3; - private const int _DocumentTabGapTop = 3; - private const int _DocumentTabGapLeft = 3; - private const int _DocumentTabGapRight = 3; - private const int _DocumentIconGapBottom = 2; - private const int _DocumentIconGapLeft = 8; - private const int _DocumentIconGapRight = 0; - private const int _DocumentIconHeight = 16; - private const int _DocumentIconWidth = 16; - private const int _DocumentTextGapRight = 3; - - #endregion - - #region Members - - private static Bitmap m_imageButtonClose; - private InertButton m_buttonClose; - private static Bitmap m_imageButtonWindowList; - private static Bitmap m_imageButtonWindowListOverflow; - private InertButton m_buttonWindowList; - private readonly ToolTip m_toolTip; - private Font m_font; - private Font m_boldFont; - private int m_startDisplayingTab = 0; - private bool m_documentTabsOverflow = false; - private static string m_toolTipSelect; - private static string m_toolTipClose; - private bool m_closeButtonVisible = false; - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/VisibleNestedPaneCollection.cs b/src/WinFormsUI/Docking/VisibleNestedPaneCollection.cs deleted file mode 100644 index 864915d3..00000000 --- a/src/WinFormsUI/Docking/VisibleNestedPaneCollection.cs +++ /dev/null @@ -1,203 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Drawing; -using System.Windows.Forms; - -namespace WeifenLuo.WinFormsUI.Docking -{ - public sealed class VisibleNestedPaneCollection : ReadOnlyCollection - { - #region Fields - - #endregion - - #region cTor - - internal VisibleNestedPaneCollection(NestedPaneCollection nestedPanes) - : base(new List()) - { - NestedPanes = nestedPanes; - } - - #endregion - - #region Properties - - public NestedPaneCollection NestedPanes { get; } - - public INestedPanesContainer Container - { - get { return NestedPanes.Container; } - } - - public DockState DockState - { - get { return NestedPanes.DockState; } - } - - public bool IsFloat - { - get { return NestedPanes.IsFloat; } - } - - #endregion - - #region Internals - - internal void Refresh() - { - Items.Clear(); - for (int i = 0; i < NestedPanes.Count; i++) - { - DockPane pane = NestedPanes[i]; - NestedDockingStatus status = pane.NestedDockingStatus; - status.SetDisplayingStatus(true, status.PreviousPane, status.Alignment, status.Proportion); - Items.Add(pane); - } - - foreach (DockPane pane in NestedPanes) - { - if (pane.DockState != DockState || pane.IsHidden) - { - pane.Bounds = Rectangle.Empty; - pane.SplitterBounds = Rectangle.Empty; - Remove(pane); - } - } - - CalculateBounds(); - - foreach (DockPane pane in this) - { - NestedDockingStatus status = pane.NestedDockingStatus; - pane.Bounds = status.PaneBounds; - pane.SplitterBounds = status.SplitterBounds; - pane.SplitterAlignment = status.Alignment; - } - } - - #endregion - - #region Private Methods - - private void Remove(DockPane pane) - { - if (!Contains(pane)) - { - return; - } - - NestedDockingStatus statusPane = pane.NestedDockingStatus; - DockPane lastNestedPane = null; - for (int i = Count - 1; i > IndexOf(pane); i--) - { - if (this[i].NestedDockingStatus.PreviousPane == pane) - { - lastNestedPane = this[i]; - break; - } - } - - if (lastNestedPane != null) - { - int indexLastNestedPane = IndexOf(lastNestedPane); - Items.Remove(lastNestedPane); - Items[IndexOf(pane)] = lastNestedPane; - NestedDockingStatus lastNestedDock = lastNestedPane.NestedDockingStatus; - lastNestedDock.SetDisplayingStatus(true, statusPane.DisplayingPreviousPane, - statusPane.DisplayingAlignment, statusPane.DisplayingProportion); - for (int i = indexLastNestedPane - 1; i > IndexOf(lastNestedPane); i--) - { - NestedDockingStatus status = this[i].NestedDockingStatus; - if (status.PreviousPane == pane) - { - status.SetDisplayingStatus(true, lastNestedPane, status.DisplayingAlignment, - status.DisplayingProportion); - } - } - } - else - { - Items.Remove(pane); - } - - statusPane.SetDisplayingStatus(false, null, DockAlignment.Left, 0.5); - } - - private void CalculateBounds() - { - if (Count == 0) - { - return; - } - - this[0].NestedDockingStatus.SetDisplayingBounds(Container.DisplayingRectangle, - Container.DisplayingRectangle, Rectangle.Empty); - - for (int i = 1; i < Count; i++) - { - DockPane pane = this[i]; - NestedDockingStatus status = pane.NestedDockingStatus; - DockPane prevPane = status.DisplayingPreviousPane; - NestedDockingStatus statusPrev = prevPane.NestedDockingStatus; - - Rectangle rect = statusPrev.PaneBounds; - bool bVerticalSplitter = status.DisplayingAlignment == DockAlignment.Left || - status.DisplayingAlignment == DockAlignment.Right; - - Rectangle rectThis = rect; - Rectangle rectPrev = rect; - Rectangle rectSplitter = rect; - if (status.DisplayingAlignment == DockAlignment.Left) - { - rectThis.Width = (int) ((double) rect.Width * status.DisplayingProportion) - - Measures.SplitterSize / 2; - rectSplitter.X = rectThis.X + rectThis.Width; - rectSplitter.Width = Measures.SplitterSize; - rectPrev.X = rectSplitter.X + rectSplitter.Width; - rectPrev.Width = rect.Width - rectThis.Width - rectSplitter.Width; - } - else if (status.DisplayingAlignment == DockAlignment.Right) - { - rectPrev.Width = rect.Width - (int) ((double) rect.Width * status.DisplayingProportion) - - Measures.SplitterSize / 2; - rectSplitter.X = rectPrev.X + rectPrev.Width; - rectSplitter.Width = Measures.SplitterSize; - rectThis.X = rectSplitter.X + rectSplitter.Width; - rectThis.Width = rect.Width - rectPrev.Width - rectSplitter.Width; - } - else if (status.DisplayingAlignment == DockAlignment.Top) - { - rectThis.Height = (int) ((double) rect.Height * status.DisplayingProportion) - - Measures.SplitterSize / 2; - rectSplitter.Y = rectThis.Y + rectThis.Height; - rectSplitter.Height = Measures.SplitterSize; - rectPrev.Y = rectSplitter.Y + rectSplitter.Height; - rectPrev.Height = rect.Height - rectThis.Height - rectSplitter.Height; - } - else if (status.DisplayingAlignment == DockAlignment.Bottom) - { - rectPrev.Height = rect.Height - (int) ((double) rect.Height * status.DisplayingProportion) - - Measures.SplitterSize / 2; - rectSplitter.Y = rectPrev.Y + rectPrev.Height; - rectSplitter.Height = Measures.SplitterSize; - rectThis.Y = rectSplitter.Y + rectSplitter.Height; - rectThis.Height = rect.Height - rectPrev.Height - rectSplitter.Height; - } - else - { - rectThis = Rectangle.Empty; - } - - rectSplitter.Intersect(rect); - rectThis.Intersect(rect); - rectPrev.Intersect(rect); - status.SetDisplayingBounds(rect, rectThis, rectSplitter); - statusPrev.SetDisplayingBounds(statusPrev.LogicalBounds, rectPrev, statusPrev.SplitterBounds); - } - } - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/Win32/Enums.cs b/src/WinFormsUI/Docking/Win32/Enums.cs deleted file mode 100644 index bf80c4b4..00000000 --- a/src/WinFormsUI/Docking/Win32/Enums.cs +++ /dev/null @@ -1,369 +0,0 @@ -using System; - -namespace WeifenLuo.WinFormsUI.Docking.Win32 -{ - [Flags] - internal enum FlagsSetWindowPos : uint - { - SWP_NOSIZE = 0x0001, - SWP_NOMOVE = 0x0002, - SWP_NOZORDER = 0x0004, - SWP_NOREDRAW = 0x0008, - SWP_NOACTIVATE = 0x0010, - SWP_FRAMECHANGED = 0x0020, - SWP_SHOWWINDOW = 0x0040, - SWP_HIDEWINDOW = 0x0080, - SWP_NOCOPYBITS = 0x0100, - SWP_NOOWNERZORDER = 0x0200, - SWP_NOSENDCHANGING = 0x0400, - SWP_DRAWFRAME = 0x0020, - SWP_NOREPOSITION = 0x0200, - SWP_DEFERERASE = 0x2000, - SWP_ASYNCWINDOWPOS = 0x4000 - } - - internal enum ShowWindowStyles : short - { - SW_HIDE = 0, - SW_SHOWNORMAL = 1, - SW_NORMAL = 1, - SW_SHOWMINIMIZED = 2, - SW_SHOWMAXIMIZED = 3, - SW_MAXIMIZE = 3, - SW_SHOWNOACTIVATE = 4, - SW_SHOW = 5, - SW_MINIMIZE = 6, - SW_SHOWMINNOACTIVE = 7, - SW_SHOWNA = 8, - SW_RESTORE = 9, - SW_SHOWDEFAULT = 10, - SW_FORCEMINIMIZE = 11, - SW_MAX = 11 - } - - internal enum WindowStyles : uint - { - WS_OVERLAPPED = 0x00000000, - WS_POPUP = 0x80000000, - WS_CHILD = 0x40000000, - WS_MINIMIZE = 0x20000000, - WS_VISIBLE = 0x10000000, - WS_DISABLED = 0x08000000, - WS_CLIPSIBLINGS = 0x04000000, - WS_CLIPCHILDREN = 0x02000000, - WS_MAXIMIZE = 0x01000000, - WS_CAPTION = 0x00C00000, - WS_BORDER = 0x00800000, - WS_DLGFRAME = 0x00400000, - WS_VSCROLL = 0x00200000, - WS_HSCROLL = 0x00100000, - WS_SYSMENU = 0x00080000, - WS_THICKFRAME = 0x00040000, - WS_GROUP = 0x00020000, - WS_TABSTOP = 0x00010000, - WS_MINIMIZEBOX = 0x00020000, - WS_MAXIMIZEBOX = 0x00010000, - WS_TILED = 0x00000000, - WS_ICONIC = 0x20000000, - WS_SIZEBOX = 0x00040000, - WS_POPUPWINDOW = 0x80880000, - WS_OVERLAPPEDWINDOW = 0x00CF0000, - WS_TILEDWINDOW = 0x00CF0000, - WS_CHILDWINDOW = 0x40000000 - } - - internal enum WindowExStyles - { - WS_EX_DLGMODALFRAME = 0x00000001, - WS_EX_NOPARENTNOTIFY = 0x00000004, - WS_EX_TOPMOST = 0x00000008, - WS_EX_ACCEPTFILES = 0x00000010, - WS_EX_TRANSPARENT = 0x00000020, - WS_EX_MDICHILD = 0x00000040, - WS_EX_TOOLWINDOW = 0x00000080, - WS_EX_WINDOWEDGE = 0x00000100, - WS_EX_CLIENTEDGE = 0x00000200, - WS_EX_CONTEXTHELP = 0x00000400, - WS_EX_RIGHT = 0x00001000, - WS_EX_LEFT = 0x00000000, - WS_EX_RTLREADING = 0x00002000, - WS_EX_LTRREADING = 0x00000000, - WS_EX_LEFTSCROLLBAR = 0x00004000, - WS_EX_RIGHTSCROLLBAR = 0x00000000, - WS_EX_CONTROLPARENT = 0x00010000, - WS_EX_STATICEDGE = 0x00020000, - WS_EX_APPWINDOW = 0x00040000, - WS_EX_OVERLAPPEDWINDOW = 0x00000300, - WS_EX_PALETTEWINDOW = 0x00000188, - WS_EX_LAYERED = 0x00080000 - } - - internal enum Msgs - { - WM_NULL = 0x0000, - WM_CREATE = 0x0001, - WM_DESTROY = 0x0002, - WM_MOVE = 0x0003, - WM_SIZE = 0x0005, - WM_ACTIVATE = 0x0006, - WM_SETFOCUS = 0x0007, - WM_KILLFOCUS = 0x0008, - WM_ENABLE = 0x000A, - WM_SETREDRAW = 0x000B, - WM_SETTEXT = 0x000C, - WM_GETTEXT = 0x000D, - WM_GETTEXTLENGTH = 0x000E, - WM_PAINT = 0x000F, - WM_CLOSE = 0x0010, - WM_QUERYENDSESSION = 0x0011, - WM_QUIT = 0x0012, - WM_QUERYOPEN = 0x0013, - WM_ERASEBKGND = 0x0014, - WM_SYSCOLORCHANGE = 0x0015, - WM_ENDSESSION = 0x0016, - WM_SHOWWINDOW = 0x0018, - WM_WININICHANGE = 0x001A, - WM_SETTINGCHANGE = 0x001A, - WM_DEVMODECHANGE = 0x001B, - WM_ACTIVATEAPP = 0x001C, - WM_FONTCHANGE = 0x001D, - WM_TIMECHANGE = 0x001E, - WM_CANCELMODE = 0x001F, - WM_SETCURSOR = 0x0020, - WM_MOUSEACTIVATE = 0x0021, - WM_CHILDACTIVATE = 0x0022, - WM_QUEUESYNC = 0x0023, - WM_GETMINMAXINFO = 0x0024, - WM_PAINTICON = 0x0026, - WM_ICONERASEBKGND = 0x0027, - WM_NEXTDLGCTL = 0x0028, - WM_SPOOLERSTATUS = 0x002A, - WM_DRAWITEM = 0x002B, - WM_MEASUREITEM = 0x002C, - WM_DELETEITEM = 0x002D, - WM_VKEYTOITEM = 0x002E, - WM_CHARTOITEM = 0x002F, - WM_SETFONT = 0x0030, - WM_GETFONT = 0x0031, - WM_SETHOTKEY = 0x0032, - WM_GETHOTKEY = 0x0033, - WM_QUERYDRAGICON = 0x0037, - WM_COMPAREITEM = 0x0039, - WM_GETOBJECT = 0x003D, - WM_COMPACTING = 0x0041, - WM_COMMNOTIFY = 0x0044, - WM_WINDOWPOSCHANGING = 0x0046, - WM_WINDOWPOSCHANGED = 0x0047, - WM_POWER = 0x0048, - WM_COPYDATA = 0x004A, - WM_CANCELJOURNAL = 0x004B, - WM_NOTIFY = 0x004E, - WM_INPUTLANGCHANGEREQUEST = 0x0050, - WM_INPUTLANGCHANGE = 0x0051, - WM_TCARD = 0x0052, - WM_HELP = 0x0053, - WM_USERCHANGED = 0x0054, - WM_NOTIFYFORMAT = 0x0055, - WM_CONTEXTMENU = 0x007B, - WM_STYLECHANGING = 0x007C, - WM_STYLECHANGED = 0x007D, - WM_DISPLAYCHANGE = 0x007E, - WM_GETICON = 0x007F, - WM_SETICON = 0x0080, - WM_NCCREATE = 0x0081, - WM_NCDESTROY = 0x0082, - WM_NCCALCSIZE = 0x0083, - WM_NCHITTEST = 0x0084, - WM_NCPAINT = 0x0085, - WM_NCACTIVATE = 0x0086, - WM_GETDLGCODE = 0x0087, - WM_SYNCPAINT = 0x0088, - WM_NCMOUSEMOVE = 0x00A0, - WM_NCLBUTTONDOWN = 0x00A1, - WM_NCLBUTTONUP = 0x00A2, - WM_NCLBUTTONDBLCLK = 0x00A3, - WM_NCRBUTTONDOWN = 0x00A4, - WM_NCRBUTTONUP = 0x00A5, - WM_NCRBUTTONDBLCLK = 0x00A6, - WM_NCMBUTTONDOWN = 0x00A7, - WM_NCMBUTTONUP = 0x00A8, - WM_NCMBUTTONDBLCLK = 0x00A9, - WM_KEYDOWN = 0x0100, - WM_KEYUP = 0x0101, - WM_CHAR = 0x0102, - WM_DEADCHAR = 0x0103, - WM_SYSKEYDOWN = 0x0104, - WM_SYSKEYUP = 0x0105, - WM_SYSCHAR = 0x0106, - WM_SYSDEADCHAR = 0x0107, - WM_KEYLAST = 0x0108, - WM_IME_STARTCOMPOSITION = 0x010D, - WM_IME_ENDCOMPOSITION = 0x010E, - WM_IME_COMPOSITION = 0x010F, - WM_IME_KEYLAST = 0x010F, - WM_INITDIALOG = 0x0110, - WM_COMMAND = 0x0111, - WM_SYSCOMMAND = 0x0112, - WM_TIMER = 0x0113, - WM_HSCROLL = 0x0114, - WM_VSCROLL = 0x0115, - WM_INITMENU = 0x0116, - WM_INITMENUPOPUP = 0x0117, - WM_MENUSELECT = 0x011F, - WM_MENUCHAR = 0x0120, - WM_ENTERIDLE = 0x0121, - WM_MENURBUTTONUP = 0x0122, - WM_MENUDRAG = 0x0123, - WM_MENUGETOBJECT = 0x0124, - WM_UNINITMENUPOPUP = 0x0125, - WM_MENUCOMMAND = 0x0126, - WM_CTLCOLORMSGBOX = 0x0132, - WM_CTLCOLOREDIT = 0x0133, - WM_CTLCOLORLISTBOX = 0x0134, - WM_CTLCOLORBTN = 0x0135, - WM_CTLCOLORDLG = 0x0136, - WM_CTLCOLORSCROLLBAR = 0x0137, - WM_CTLCOLORSTATIC = 0x0138, - WM_MOUSEMOVE = 0x0200, - WM_LBUTTONDOWN = 0x0201, - WM_LBUTTONUP = 0x0202, - WM_LBUTTONDBLCLK = 0x0203, - WM_RBUTTONDOWN = 0x0204, - WM_RBUTTONUP = 0x0205, - WM_RBUTTONDBLCLK = 0x0206, - WM_MBUTTONDOWN = 0x0207, - WM_MBUTTONUP = 0x0208, - WM_MBUTTONDBLCLK = 0x0209, - WM_MOUSEWHEEL = 0x020A, - WM_PARENTNOTIFY = 0x0210, - WM_ENTERMENULOOP = 0x0211, - WM_EXITMENULOOP = 0x0212, - WM_NEXTMENU = 0x0213, - WM_SIZING = 0x0214, - WM_CAPTURECHANGED = 0x0215, - WM_MOVING = 0x0216, - WM_DEVICECHANGE = 0x0219, - WM_MDICREATE = 0x0220, - WM_MDIDESTROY = 0x0221, - WM_MDIACTIVATE = 0x0222, - WM_MDIRESTORE = 0x0223, - WM_MDINEXT = 0x0224, - WM_MDIMAXIMIZE = 0x0225, - WM_MDITILE = 0x0226, - WM_MDICASCADE = 0x0227, - WM_MDIICONARRANGE = 0x0228, - WM_MDIGETACTIVE = 0x0229, - WM_MDISETMENU = 0x0230, - WM_ENTERSIZEMOVE = 0x0231, - WM_EXITSIZEMOVE = 0x0232, - WM_DROPFILES = 0x0233, - WM_MDIREFRESHMENU = 0x0234, - WM_IME_SETCONTEXT = 0x0281, - WM_IME_NOTIFY = 0x0282, - WM_IME_CONTROL = 0x0283, - WM_IME_COMPOSITIONFULL = 0x0284, - WM_IME_SELECT = 0x0285, - WM_IME_CHAR = 0x0286, - WM_IME_REQUEST = 0x0288, - WM_IME_KEYDOWN = 0x0290, - WM_IME_KEYUP = 0x0291, - WM_MOUSEHOVER = 0x02A1, - WM_MOUSELEAVE = 0x02A3, - WM_CUT = 0x0300, - WM_COPY = 0x0301, - WM_PASTE = 0x0302, - WM_CLEAR = 0x0303, - WM_UNDO = 0x0304, - WM_RENDERFORMAT = 0x0305, - WM_RENDERALLFORMATS = 0x0306, - WM_DESTROYCLIPBOARD = 0x0307, - WM_DRAWCLIPBOARD = 0x0308, - WM_PAINTCLIPBOARD = 0x0309, - WM_VSCROLLCLIPBOARD = 0x030A, - WM_SIZECLIPBOARD = 0x030B, - WM_ASKCBFORMATNAME = 0x030C, - WM_CHANGECBCHAIN = 0x030D, - WM_HSCROLLCLIPBOARD = 0x030E, - WM_QUERYNEWPALETTE = 0x030F, - WM_PALETTEISCHANGING = 0x0310, - WM_PALETTECHANGED = 0x0311, - WM_HOTKEY = 0x0312, - WM_PRINT = 0x0317, - WM_PRINTCLIENT = 0x0318, - WM_HANDHELDFIRST = 0x0358, - WM_HANDHELDLAST = 0x035F, - WM_AFXFIRST = 0x0360, - WM_AFXLAST = 0x037F, - WM_PENWINFIRST = 0x0380, - WM_PENWINLAST = 0x038F, - WM_APP = 0x8000, - WM_USER = 0x0400 - } - - internal enum HitTest - { - HTERROR = -2, - HTTRANSPARENT = -1, - HTNOWHERE = 0, - HTCLIENT = 1, - HTCAPTION = 2, - HTSYSMENU = 3, - HTGROWBOX = 4, - HTSIZE = 4, - HTMENU = 5, - HTHSCROLL = 6, - HTVSCROLL = 7, - HTMINBUTTON = 8, - HTMAXBUTTON = 9, - HTLEFT = 10, - HTRIGHT = 11, - HTTOP = 12, - HTTOPLEFT = 13, - HTTOPRIGHT = 14, - HTBOTTOM = 15, - HTBOTTOMLEFT = 16, - HTBOTTOMRIGHT = 17, - HTBORDER = 18, - HTREDUCE = 8, - HTZOOM = 9, - HTSIZEFIRST = 10, - HTSIZELAST = 17, - HTOBJECT = 19, - HTCLOSE = 20, - HTHELP = 21 - } - - internal enum ScrollBars : uint - { - SB_HORZ = 0, - SB_VERT = 1, - SB_CTL = 2, - SB_BOTH = 3 - } - - internal enum GetWindowLongIndex : int - { - GWL_STYLE = -16, - GWL_EXSTYLE = -20 - } - - // Hook Types - internal enum HookType : int - { - WH_JOURNALRECORD = 0, - WH_JOURNALPLAYBACK = 1, - WH_KEYBOARD = 2, - WH_GETMESSAGE = 3, - WH_CALLWNDPROC = 4, - WH_CBT = 5, - WH_SYSMSGFILTER = 6, - WH_MOUSE = 7, - WH_HARDWARE = 8, - WH_DEBUG = 9, - WH_SHELL = 10, - WH_FOREGROUNDIDLE = 11, - WH_CALLWNDPROCRET = 12, - WH_KEYBOARD_LL = 13, - WH_MOUSE_LL = 14 - } -} \ No newline at end of file diff --git a/src/WinFormsUI/Docking/Win32/NativeMethods.cs b/src/WinFormsUI/Docking/Win32/NativeMethods.cs deleted file mode 100644 index a4c85b62..00000000 --- a/src/WinFormsUI/Docking/Win32/NativeMethods.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Drawing; -using System.Runtime.InteropServices; -using System.Diagnostics.CodeAnalysis; -using WeifenLuo.WinFormsUI.Docking.Win32; - -namespace WeifenLuo.WinFormsUI.Docking -{ - internal static class NativeMethods - { - #region Delegates - - public delegate IntPtr HookProc(int code, IntPtr wParam, IntPtr lParam); - - #endregion - - #region Public methods - - [DllImport("User32.dll", CharSet = CharSet.Auto)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool DragDetect(IntPtr hWnd, Point pt); - - [DllImport("User32.dll", CharSet = CharSet.Auto)] - public static extern IntPtr GetFocus(); - - [DllImport("User32.dll", CharSet = CharSet.Auto)] - public static extern IntPtr SetFocus(IntPtr hWnd); - - [DllImport("User32.dll", CharSet = CharSet.Auto)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool PostMessage(IntPtr hWnd, int Msg, uint wParam, uint lParam); - - [DllImport("User32.dll", CharSet = CharSet.Auto)] - public static extern uint SendMessage(IntPtr hWnd, int Msg, uint wParam, uint lParam); - - [DllImport("User32.dll", CharSet = CharSet.Auto)] - public static extern int ShowWindow(IntPtr hWnd, short cmdShow); - - [DllImport("User32.dll", CharSet = CharSet.Auto)] - public static extern int SetWindowPos(IntPtr hWnd, IntPtr hWndAfter, int X, int Y, int Width, int Height, - FlagsSetWindowPos flags); - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - public static extern int GetWindowLong(IntPtr hWnd, int Index); - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - public static extern int SetWindowLong(IntPtr hWnd, int Index, int Value); - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - public static extern int ShowScrollBar(IntPtr hWnd, int wBar, int bShow); - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - //********************************* - // FxCop bug, suppress the message - //********************************* - [SuppressMessage("Microsoft.Portability", "CA1901:PInvokeDeclarationsShouldBePortable", MessageId = "0")] - public static extern IntPtr WindowFromPoint(Point point); - - [DllImport("Kernel32.dll", CharSet = CharSet.Auto)] - public static extern int GetCurrentThreadId(); - - [DllImport("user32.dll")] - public static extern IntPtr - SetWindowsHookEx(Win32.HookType code, HookProc func, IntPtr hInstance, int threadID); - - [DllImport("user32.dll")] - public static extern int UnhookWindowsHookEx(IntPtr hhook); - - [DllImport("user32.dll")] - public static extern IntPtr CallNextHookEx(IntPtr hhook, int code, IntPtr wParam, IntPtr lParam); - - #endregion - } -} \ No newline at end of file diff --git a/src/WinFormsUI/WinFormsUI.csproj b/src/WinFormsUI/WinFormsUI.csproj deleted file mode 100644 index 664ada6d..00000000 --- a/src/WinFormsUI/WinFormsUI.csproj +++ /dev/null @@ -1,113 +0,0 @@ - - - net8.0-windows - true - Library - WeifenLuo.WinFormsUI - WeifenLuo.WinFormsUI.Docking - true - ..\Solution Items\Key.snk - SAK - SAK - false - SAK - SAK - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - false - true - true - false - $(SolutionDir)..\bin\$(Configuration) - CA1416; - - - False - - - True - - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - UserControl - - - Component - - - Component - - - Component - - - UserControl - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - - - Key.snk - - - - - - diff --git a/src/WinFormsUI/WinFormsUI.csproj.vspscc b/src/WinFormsUI/WinFormsUI.csproj.vspscc deleted file mode 100644 index feffdeca..00000000 --- a/src/WinFormsUI/WinFormsUI.csproj.vspscc +++ /dev/null @@ -1,10 +0,0 @@ -"" -{ -"FILE_VERSION" = "9237" -"ENLISTMENT_CHOICE" = "NEVER" -"PROJECT_FILE_RELATIVE_PATH" = "" -"NUMBER_OF_EXCLUDED_FILES" = "0" -"ORIGINAL_PROJECT_FILE_PATH" = "" -"NUMBER_OF_NESTED_PROJECTS" = "0" -"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" -} diff --git a/src/WinFormsUI/license.txt b/src/WinFormsUI/license.txt deleted file mode 100644 index 290b9a43..00000000 --- a/src/WinFormsUI/license.txt +++ /dev/null @@ -1,9 +0,0 @@ -The MIT License - -Copyright (c) 2007 Weifen Luo (email: weifenluo@yahoo.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 00d6b4a70ee53e1617af2d93fb8381011543c872 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sun, 23 Mar 2025 01:57:10 +0200 Subject: [PATCH 003/142] UI Changes: Aligned all radio boxes and moved the checkbox at the bottom next to the checkbox on the top. --- .../Dialogs/SettingsDialog.Designer.cs | 24 +++++++++---------- src/LogExpert/Dialogs/SettingsDialog.resx | 21 ++++++++++++++++ 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/LogExpert/Dialogs/SettingsDialog.Designer.cs b/src/LogExpert/Dialogs/SettingsDialog.Designer.cs index 3ccc13f5..026961d0 100644 --- a/src/LogExpert/Dialogs/SettingsDialog.Designer.cs +++ b/src/LogExpert/Dialogs/SettingsDialog.Designer.cs @@ -1315,7 +1315,7 @@ private void InitializeComponent() // checkBoxPortableMode // checkBoxPortableMode.AutoSize = true; - checkBoxPortableMode.Location = new System.Drawing.Point(34, 377); + checkBoxPortableMode.Location = new System.Drawing.Point(35, 110); checkBoxPortableMode.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); checkBoxPortableMode.Name = "checkBoxPortableMode"; checkBoxPortableMode.Size = new System.Drawing.Size(150, 19); @@ -1328,7 +1328,7 @@ private void InitializeComponent() // checkBoxSaveFilter // checkBoxSaveFilter.AutoSize = true; - checkBoxSaveFilter.Location = new System.Drawing.Point(34, 74); + checkBoxSaveFilter.Location = new System.Drawing.Point(35, 75); checkBoxSaveFilter.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); checkBoxSaveFilter.Name = "checkBoxSaveFilter"; checkBoxSaveFilter.Size = new System.Drawing.Size(217, 19); @@ -1344,18 +1344,18 @@ private void InitializeComponent() groupBoxPersistantFileLocation.Controls.Add(radioButtonsessionSaveDocuments); groupBoxPersistantFileLocation.Controls.Add(radioButtonSessionSameDir); groupBoxPersistantFileLocation.Controls.Add(radioButtonSessionApplicationStartupDir); - groupBoxPersistantFileLocation.Location = new System.Drawing.Point(34, 134); + groupBoxPersistantFileLocation.Location = new System.Drawing.Point(34, 145); groupBoxPersistantFileLocation.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); groupBoxPersistantFileLocation.Name = "groupBoxPersistantFileLocation"; groupBoxPersistantFileLocation.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxPersistantFileLocation.Size = new System.Drawing.Size(411, 211); + groupBoxPersistantFileLocation.Size = new System.Drawing.Size(411, 190); groupBoxPersistantFileLocation.TabIndex = 1; groupBoxPersistantFileLocation.TabStop = false; groupBoxPersistantFileLocation.Text = "Persistence file location"; // // labelSessionSaveOwnDir // - labelSessionSaveOwnDir.Location = new System.Drawing.Point(39, 142); + labelSessionSaveOwnDir.Location = new System.Drawing.Point(27, 160); labelSessionSaveOwnDir.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); labelSessionSaveOwnDir.Name = "labelSessionSaveOwnDir"; labelSessionSaveOwnDir.Size = new System.Drawing.Size(252, 31); @@ -1364,10 +1364,10 @@ private void InitializeComponent() // // buttonSessionSaveDir // - buttonSessionSaveDir.Location = new System.Drawing.Point(357, 102); + buttonSessionSaveDir.Location = new System.Drawing.Point(358, 135); buttonSessionSaveDir.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); buttonSessionSaveDir.Name = "buttonSessionSaveDir"; - buttonSessionSaveDir.Size = new System.Drawing.Size(45, 31); + buttonSessionSaveDir.Size = new System.Drawing.Size(45, 19); buttonSessionSaveDir.TabIndex = 3; buttonSessionSaveDir.Text = "..."; buttonSessionSaveDir.UseVisualStyleBackColor = true; @@ -1376,7 +1376,7 @@ private void InitializeComponent() // radioButtonSessionSaveOwn // radioButtonSessionSaveOwn.AutoSize = true; - radioButtonSessionSaveOwn.Location = new System.Drawing.Point(10, 105); + radioButtonSessionSaveOwn.Location = new System.Drawing.Point(10, 135); radioButtonSessionSaveOwn.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); radioButtonSessionSaveOwn.Name = "radioButtonSessionSaveOwn"; radioButtonSessionSaveOwn.Size = new System.Drawing.Size(100, 19); @@ -1388,7 +1388,7 @@ private void InitializeComponent() // radioButtonsessionSaveDocuments // radioButtonsessionSaveDocuments.AutoSize = true; - radioButtonsessionSaveDocuments.Location = new System.Drawing.Point(10, 68); + radioButtonsessionSaveDocuments.Location = new System.Drawing.Point(10, 65); radioButtonsessionSaveDocuments.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); radioButtonsessionSaveDocuments.Name = "radioButtonsessionSaveDocuments"; radioButtonsessionSaveDocuments.Size = new System.Drawing.Size(160, 19); @@ -1400,7 +1400,7 @@ private void InitializeComponent() // radioButtonSessionSameDir // radioButtonSessionSameDir.AutoSize = true; - radioButtonSessionSameDir.Location = new System.Drawing.Point(10, 31); + radioButtonSessionSameDir.Location = new System.Drawing.Point(10, 30); radioButtonSessionSameDir.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); radioButtonSessionSameDir.Name = "radioButtonSessionSameDir"; radioButtonSessionSameDir.Size = new System.Drawing.Size(157, 19); @@ -1412,7 +1412,7 @@ private void InitializeComponent() // radioButtonSessionApplicationStartupDir // radioButtonSessionApplicationStartupDir.AutoSize = true; - radioButtonSessionApplicationStartupDir.Location = new System.Drawing.Point(8, 177); + radioButtonSessionApplicationStartupDir.Location = new System.Drawing.Point(10, 100); radioButtonSessionApplicationStartupDir.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); radioButtonSessionApplicationStartupDir.Name = "radioButtonSessionApplicationStartupDir"; radioButtonSessionApplicationStartupDir.Size = new System.Drawing.Size(176, 19); @@ -1425,7 +1425,7 @@ private void InitializeComponent() // checkBoxSaveSessions // checkBoxSaveSessions.AutoSize = true; - checkBoxSaveSessions.Location = new System.Drawing.Point(34, 38); + checkBoxSaveSessions.Location = new System.Drawing.Point(35, 40); checkBoxSaveSessions.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); checkBoxSaveSessions.Name = "checkBoxSaveSessions"; checkBoxSaveSessions.Size = new System.Drawing.Size(241, 19); diff --git a/src/LogExpert/Dialogs/SettingsDialog.resx b/src/LogExpert/Dialogs/SettingsDialog.resx index 2c2d8d82..1ba4e352 100644 --- a/src/LogExpert/Dialogs/SettingsDialog.resx +++ b/src/LogExpert/Dialogs/SettingsDialog.resx @@ -120,12 +120,30 @@ 144, 17 + + 144, 17 + + + 144, 17 + True True + + True + + + True + + + True + + + True + True @@ -138,6 +156,9 @@ Note: You can always load your logfiles as MultiFile automatically if the files names follow the MultiFile naming rule (<filename>, <filename>.1, <filename>.2, ...). Simply choose 'MultiFile' from the File menu after loading the first file. + + 17, 17 + From 9ec920e1b5d9c8e3176c793a2ef3b461cd97abc1 Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Wed, 26 Mar 2025 14:54:32 +0100 Subject: [PATCH 004/142] new projects for refactoring --- src/LogExpert.sln | 12 ++++++++++++ src/LogExpert/Resources/AdvancedIcon2.gif | Bin 827 -> 0 bytes src/LogExpert/Resources/PanelClose.gif | Bin 850 -> 0 bytes src/LogExpert/Resources/PanelOpen.gif | Bin 850 -> 0 bytes src/LogExpert/Resources/check-blue.gif | Bin 345 -> 0 bytes src/LogExpert/Resources/delete-page-red.gif | Bin 341 -> 0 bytes src/LogExpert/Resources/down-blue.gif | Bin 338 -> 0 bytes src/LogExpert/Resources/folder-blue.gif | Bin 330 -> 0 bytes src/LogExpert/Resources/search-blue.gif | Bin 351 -> 0 bytes src/LogExpert/Resources/search-folder-blue.gif | Bin 334 -> 0 bytes src/LogExpert/Resources/up-blue.gif | Bin 340 -> 0 bytes src/Logexpert.Core/Logexpert.Core.csproj | 9 +++++++++ .../Logexpert.Resources.csproj | 15 +++++++++++++++ .../images/bmp/AdvancedIcon.bmp | Bin 0 -> 1198 bytes .../images/bmp/LogExpert.bmp | Bin 0 -> 37114 bytes .../images/gif/LogExpert-Icon.gif | Bin 0 -> 591 bytes src/Logexpert.Resources/images/gif/LogLover.gif | Bin 0 -> 5235 bytes src/Logexpert.Resources/images/icons/Icon1.ico | Bin 0 -> 52334 bytes src/Logexpert.Resources/images/icons/Icon2.ico | Bin 0 -> 1078 bytes src/Logexpert.Resources/images/icons/bubble.ico | Bin 0 -> 2862 bytes .../images/icons/logexpert.ico | Bin 0 -> 318 bytes src/Logexpert.Resources/images/png/48/Add.png | Bin 0 -> 1774 bytes .../images/png/48/ArrowDown.png | Bin 0 -> 322 bytes .../images/png/48/ArrowLeft.png | Bin 0 -> 236 bytes .../images/png/48/ArrowRight.png | Bin 0 -> 240 bytes .../images/png/48/ArrowUp.png | Bin 0 -> 325 bytes .../images/png/48/Arrow_menu_close.png | Bin 0 -> 2457 bytes .../images/png/48/Arrow_menu_open.png | Bin 0 -> 2423 bytes .../images/png/48/Bookmark_add.png | Bin 0 -> 2802 bytes .../images/png/48/Bookmark_added.png | Bin 0 -> 3090 bytes .../images/png/48/Bookmark_manager.png | Bin 0 -> 3092 bytes .../images/png/48/Bookmark_remove.png | Bin 0 -> 2736 bytes .../images/png/48/Bookmarks.png | Bin 0 -> 354 bytes .../images/png/48/Check_circle.png | Bin 0 -> 6610 bytes src/Logexpert.Resources/images/png/48/Close.png | Bin 0 -> 2723 bytes .../images/png/48/Deceased.png | Bin 0 -> 6572 bytes .../images/png/48/Delete.png | Bin 0 -> 2095 bytes src/Logexpert.Resources/images/png/48/Exit.png | Bin 0 -> 2294 bytes .../images/png/48/Favorite.png | Bin 0 -> 6008 bytes .../images/png/48/File_open.png | Bin 0 -> 2896 bytes .../images/png/48/Filter.png | Bin 0 -> 361 bytes .../images/png/48/Folder_open.png | Bin 0 -> 3681 bytes .../images/png/48/Restart_alt.png | Bin 0 -> 5291 bytes .../images/png/48/Search.png | Bin 0 -> 860 bytes .../images/png/48/Settings.png | Bin 0 -> 7315 bytes src/Logexpert.Resources/images/png/48/Star.png | Bin 0 -> 5561 bytes .../images/png/48/bookmark_bubbles.png | Bin 0 -> 2595 bytes 47 files changed, 36 insertions(+) delete mode 100644 src/LogExpert/Resources/AdvancedIcon2.gif delete mode 100644 src/LogExpert/Resources/PanelClose.gif delete mode 100644 src/LogExpert/Resources/PanelOpen.gif delete mode 100644 src/LogExpert/Resources/check-blue.gif delete mode 100644 src/LogExpert/Resources/delete-page-red.gif delete mode 100644 src/LogExpert/Resources/down-blue.gif delete mode 100644 src/LogExpert/Resources/folder-blue.gif delete mode 100644 src/LogExpert/Resources/search-blue.gif delete mode 100644 src/LogExpert/Resources/search-folder-blue.gif delete mode 100644 src/LogExpert/Resources/up-blue.gif create mode 100644 src/Logexpert.Core/Logexpert.Core.csproj create mode 100644 src/Logexpert.Resources/Logexpert.Resources.csproj create mode 100644 src/Logexpert.Resources/images/bmp/AdvancedIcon.bmp create mode 100644 src/Logexpert.Resources/images/bmp/LogExpert.bmp create mode 100644 src/Logexpert.Resources/images/gif/LogExpert-Icon.gif create mode 100644 src/Logexpert.Resources/images/gif/LogLover.gif create mode 100644 src/Logexpert.Resources/images/icons/Icon1.ico create mode 100644 src/Logexpert.Resources/images/icons/Icon2.ico create mode 100644 src/Logexpert.Resources/images/icons/bubble.ico create mode 100644 src/Logexpert.Resources/images/icons/logexpert.ico create mode 100644 src/Logexpert.Resources/images/png/48/Add.png create mode 100644 src/Logexpert.Resources/images/png/48/ArrowDown.png create mode 100644 src/Logexpert.Resources/images/png/48/ArrowLeft.png create mode 100644 src/Logexpert.Resources/images/png/48/ArrowRight.png create mode 100644 src/Logexpert.Resources/images/png/48/ArrowUp.png create mode 100644 src/Logexpert.Resources/images/png/48/Arrow_menu_close.png create mode 100644 src/Logexpert.Resources/images/png/48/Arrow_menu_open.png create mode 100644 src/Logexpert.Resources/images/png/48/Bookmark_add.png create mode 100644 src/Logexpert.Resources/images/png/48/Bookmark_added.png create mode 100644 src/Logexpert.Resources/images/png/48/Bookmark_manager.png create mode 100644 src/Logexpert.Resources/images/png/48/Bookmark_remove.png create mode 100644 src/Logexpert.Resources/images/png/48/Bookmarks.png create mode 100644 src/Logexpert.Resources/images/png/48/Check_circle.png create mode 100644 src/Logexpert.Resources/images/png/48/Close.png create mode 100644 src/Logexpert.Resources/images/png/48/Deceased.png create mode 100644 src/Logexpert.Resources/images/png/48/Delete.png create mode 100644 src/Logexpert.Resources/images/png/48/Exit.png create mode 100644 src/Logexpert.Resources/images/png/48/Favorite.png create mode 100644 src/Logexpert.Resources/images/png/48/File_open.png create mode 100644 src/Logexpert.Resources/images/png/48/Filter.png create mode 100644 src/Logexpert.Resources/images/png/48/Folder_open.png create mode 100644 src/Logexpert.Resources/images/png/48/Restart_alt.png create mode 100644 src/Logexpert.Resources/images/png/48/Search.png create mode 100644 src/Logexpert.Resources/images/png/48/Settings.png create mode 100644 src/Logexpert.Resources/images/png/48/Star.png create mode 100644 src/Logexpert.Resources/images/png/48/bookmark_bubbles.png diff --git a/src/LogExpert.sln b/src/LogExpert.sln index d04ea3de..8c35134f 100644 --- a/src/LogExpert.sln +++ b/src/LogExpert.sln @@ -57,6 +57,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RegexColumnizer.UnitTests", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogexpertgRPCService", "LogexpertgRPCService\LogexpertgRPCService.csproj", "{D31D1721-9DEA-45A4-B813-D5023B2EC2CC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logexpert.Core", "Logexpert.Core\Logexpert.Core.csproj", "{F49C6738-3F62-4890-8FF2-1F53A0F0A2CD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logexpert.Resources", "Logexpert.Resources\Logexpert.Resources.csproj", "{578CC5D5-1DCD-47C2-8BD3-B32C14635BEC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -133,6 +137,14 @@ Global {D31D1721-9DEA-45A4-B813-D5023B2EC2CC}.Debug|Any CPU.Build.0 = Debug|Any CPU {D31D1721-9DEA-45A4-B813-D5023B2EC2CC}.Release|Any CPU.ActiveCfg = Release|Any CPU {D31D1721-9DEA-45A4-B813-D5023B2EC2CC}.Release|Any CPU.Build.0 = Release|Any CPU + {F49C6738-3F62-4890-8FF2-1F53A0F0A2CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F49C6738-3F62-4890-8FF2-1F53A0F0A2CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F49C6738-3F62-4890-8FF2-1F53A0F0A2CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F49C6738-3F62-4890-8FF2-1F53A0F0A2CD}.Release|Any CPU.Build.0 = Release|Any CPU + {578CC5D5-1DCD-47C2-8BD3-B32C14635BEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {578CC5D5-1DCD-47C2-8BD3-B32C14635BEC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {578CC5D5-1DCD-47C2-8BD3-B32C14635BEC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {578CC5D5-1DCD-47C2-8BD3-B32C14635BEC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/LogExpert/Resources/AdvancedIcon2.gif b/src/LogExpert/Resources/AdvancedIcon2.gif deleted file mode 100644 index cf300683ff2934f612e03faab3c0f88e785fb8b6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 827 zcmb`GF-}}z41@=XNK26o4Tu6MqEF{0QJRn1G8gT*l2<2{aysECdj zuO-WjtjLZWv!GZRRZ$%^CPi;&bVYacz>(3IjH#H8VJoZwgETCmMUBN^0}U3#V?oY| z%IwUsKGu>|Wp&nAE-WZ^Wq0rm#Y+5uCezpfCj_Gq)__5pNoc`? z#b5(HK9RdAlM}5247U;I}4KcU@~KJTvY|NpyvJlkI${{DXc@$~WH=i&TZ-`@Zb Ct6`}C diff --git a/src/LogExpert/Resources/PanelClose.gif b/src/LogExpert/Resources/PanelClose.gif deleted file mode 100644 index 41615c3d34d462a14ecebfdb9cf0c383621ad066..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 850 zcmb`Gv5J&&48&)_VnIPcuu^2Lh2w~zA_!OLou!SvO`hYEgDV6(n{*Zymf{nvrI4r4 zR}jQ1{^tJ-29|HLNhULsZ_i)7eDd_|E#1@~IkxrL)?*{v9LM8v_EU}DofeQac_kxRi$dxc(g;E>QcAbOf{iNO=%k11~xQU4AVW{ z7oXN~2;f?`*8XAkNjMQ={!bPn?H1DZ@@2l^p_LRbR^X;{(< z4;F(BG+1NjTqY;FYHTF>SWDJjJ@|@TSWv9#8hpfQ41gEy7>!!2#1CjPjU8}8FbZJ} z7^Inm7CcxCHqhe}xtlUMF*ZJY>>c+k2 h+y3?8#rx|gZytR){dxA`&f}|(7vDbrc(>c>**~V{YuNw* diff --git a/src/LogExpert/Resources/PanelOpen.gif b/src/LogExpert/Resources/PanelOpen.gif deleted file mode 100644 index a826a94cc76f073a72e1330ace36e076c35b314a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 850 zcmb`GKWfx*5XIkukZmN9SO^M|HV7%EP_YyIcZ^ufITiv5h#p`%3yYLF!fGSJfOrcJ zAgI;&dEYZQu>5v*X5PH_=C`ljynOQX{78rTEyr$scI&Yt+d208{qXx})`KVC2!8v2 z5mHJewKtJPC{j_1R*Z`o%2bxJmE+zDRjNwWs_|%tI@P6awV7%{lbX^rv<+-%uo$L$ zyvLCd710snwPcx*71@zv78EO^DypN#r0DI8uIP>)I5HZOF%{D>Y=t#okcK6+sIeGq zpuu8zEXX-gnVmV-$6B(gtj-$Cg$2c~?9Lw4LyF#<%IO^B;RiIC#t!sD0)?;!4AQWq z6&@@G8)&e`&bdrZbk*2M^s$z#yL#{yxv-#E(>3^r(-;6R+A$inScxCdWEwl*gkTiH z8ZbyR2`zZA7;K=&CvrDsa$>j`Mxu|kWW8Q8`?~J!;yR&iURQDNGTN>$?>xHf@DY|m zBQ4Ut$>L$)1h8LYWc zQ8m_Y$?D0oYBY`{Z&Eb0wOL&v_R7gnhwtLitx@WVk`ufZtl1oqqpZm7U82LzuHz|M zQ}3n2%F5NHC!wdqB3LiQBGV8)osofY5ko^xrnU|TGc(8X02f^yHZ~n?|DF2vI~^IU E0n;m_2><{9 diff --git a/src/LogExpert/Resources/delete-page-red.gif b/src/LogExpert/Resources/delete-page-red.gif deleted file mode 100644 index 21a08dced2f3e71e2157916da0484ead1ec2fda5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 341 zcmZ?wbhEHb)wBjZS*+Y`@uV24@B%}OTM(OjHFYiBm`1k+cn>TO1 zefxI*!To2?o<4j2{O{kt-@bkQ{pGS7}lCtmKzrTC$-ltC=mrKYTJb3V}tct3t zYE4bee=uMm3n>0%VPs&?WzYfX2KkABt?0ni0*f5UUhQc`Gh<|__RdZTceKNRO@(E5_IuUkmUdX diff --git a/src/LogExpert/Resources/down-blue.gif b/src/LogExpert/Resources/down-blue.gif deleted file mode 100644 index 7304e2f81185e7d7f946755a8c7ed82ff29e8e52..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 338 zcmZ?wbhEHbM>&CZ#|NgCd_^avk2e-8kU%!5xviIe`|Nq{+dGq)0zwh6_ z|M~Oh+4JW!Z+vCwJpcL2mq(8uy?g&Yb?=LpuU<2BUU>HG>D_zxUc7uMIO&S!{9Ero zd}uoJ{@b^&-@bkO{p)w*>Gywr|9<=SZPV%ZKY#xG`}gnTCr>_p{Gd7i=BG~|1t(qp z@#Fi=Tet2%xc}+%=f*SdfB*h{@Zdo+GqakSn*U(HKnN)QWMO1rFk#REDFpe6fi2%* zW`V^L$=*#fi)K!d%{)1k^^k^2y5EzY&|NJ)N0K)gb#AfRFvDt@Ylhsaa3#0G4GWD$ z(zkG&Nz#-k_vDgO@ivrHZ#Gt_>tJE&VeiNiV#^NiP|{;&mX|j4G+464kb!}hA;-nV Pkcp|>e{+_*BZD;n&W5fY diff --git a/src/LogExpert/Resources/folder-blue.gif b/src/LogExpert/Resources/folder-blue.gif deleted file mode 100644 index 4c92bf71a679869c6f201675077409c2e1e5352d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 330 zcmZ?wbhEHbid7YmG`gw{BOVFe(kCE97V@_E_`N5*tPog-@Cv5tIWP>zv6-N>>ErGTV~w&df@B7 z8P~scU-)FV;(pxDXWbV+tIWQkJnN?2$_L#SKh>UmS9j|D_Rs&gs?P5I^6%!a|BrwF zU;Xe`+|K74KmF6!*Z=?jKLd$C@h1x-1A{(;4oDx!PYi772c{Qz=t%WDO~2Gyvoj<> z^zx6G$hF?7Mn?l(+~zk#7?$cr+%&n|TD0}vhwn?4E}6}-(EDftLn241o)jw|t1OQg skC2jgx=z22Tt6qLH?Jx`GXujc6@hF$5e`Wvc8;ae>Zw_gPL2%L0Q`oGeE(j4)+n@b<_5I(=SFfKvfByIH-v?j*{`m3z=B-=5fB(LF@810f_dosqx8c#R z@87?F{P^Mimp_l6JUQ_4_v_cMfB*XZ^84R|2M?}(_)ADg$lKdnQBkp`rsh8w0PRHs zia%Kx85k@XbU@-DKQXY?9GG2TaYnM&d`{8KJ+j4~lQ@~HR15u7-d&lM5#}^I;`R?4 zC9avdWiM_l*ulbTq;)e$`uc+;?=Tr|9!4`sW+olES_>@$MK3cZB|{CCE-^-LQ!^PB ui+oRxnZ`m%`2~v@OxRf6J&lY^jaRZ6MFu!+T*>O{Z)s{`ve(^_!5RR21HMrJ diff --git a/src/LogExpert/Resources/search-folder-blue.gif b/src/LogExpert/Resources/search-folder-blue.gif deleted file mode 100644 index 363fdea1649afaeebd712f9d00acce7a4d8b63f5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 334 zcmZ?wbhEHbeQ+2+qX01Zu|ZFcUf84FCh5)@6?+=+qP{x@bdSAFMscU z`E&KdpI6`iefsrp`_o@~dU~IJ|9koUF9QR^)enFF{Q0x`;jb4jUi|#|^Uj?+FJHbC z5)$(E_Wt|#@25|n6crW!|NkEs7Y8JP>S+NKf3h$#FeowTfD8xuiGeNKVWNf$4`=_0 zfb^S&O08b~AyFz$+OxdNe!q+}zIuV(Q+vRhI{o{vqTqfM>&CZ#|Nf=!c_}dQvgZ6-?rR_X{{8#y+qaLOJZU`h{>_^= z&z?X3^XJd38()9?`2Ozw`-US7FF$|z(s=sA`wt&9=iPew z>h_?Ag%E%MAq1lfq|DnN5Ifih0!b9P@Hp`r;PVhHKvO2xt*+f3ym{ZW=XOv Sba6IhRU=09_Vz1-? diff --git a/src/Logexpert.Core/Logexpert.Core.csproj b/src/Logexpert.Core/Logexpert.Core.csproj new file mode 100644 index 00000000..fa71b7ae --- /dev/null +++ b/src/Logexpert.Core/Logexpert.Core.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/src/Logexpert.Resources/Logexpert.Resources.csproj b/src/Logexpert.Resources/Logexpert.Resources.csproj new file mode 100644 index 00000000..c4a1ac1d --- /dev/null +++ b/src/Logexpert.Resources/Logexpert.Resources.csproj @@ -0,0 +1,15 @@ + + + + net8.0 + enable + enable + + + + + + + + + diff --git a/src/Logexpert.Resources/images/bmp/AdvancedIcon.bmp b/src/Logexpert.Resources/images/bmp/AdvancedIcon.bmp new file mode 100644 index 0000000000000000000000000000000000000000..efe1532017ae038bbab942b16401e5e700cc5d11 GIT binary patch literal 1198 zcmZwFJ#O4U42EGE2n=@tasrk{+~5c#ghFF>+rr5}LMSw5 zw=|s$B!og^cDs3r6i5h##%w8+lYxX#Xv~&LI~hm_g~nVZq;WEk5DJa4X8vuCKtd>- zZML-B$v{FVG-k^#oD3v{LSwch)5$v+p?jsH3N+Su{R=Z@q5@1C#t=N;!yoBak;2&faH&z}8!x%`O#KYsjoJP2MCTMvUI~?-}G}sH`ak3{r2sBF}zc4?%}LR7!lO2 z;zbqE8_>X%9K(tpUg__uL7J?Erj#;`X0`hq@oG*u>=je z33TEek56TV9v}qAxbtEYS0FKk&)77dXsOso^~7aKf@42QA^HqEN+g|!0EWT@=fWz= z5r(FAs^uQew*H(7Q1}T%05kw1UO`(d4KJ`2hWe19E8PUF+JErLIH4abX6WgPU!fo( zLhhVR*uxnwfXd9#Jb@RXv65%=VII=0+Jcp^RYQ6MqcKR;1c-+M`Nk6bsSahj;!Z_i zw6qEV)t1Ak__^|{J)Ch6HU6B^R3Tf${FZ{{Ph4oo2372|fJnb86r&}pZDhQcSfjX$Rh;+$AC1V@=(X-JQ_FjZ0lb`cM8*Jh#)%;7LDsyrciH7eyi zCLVHC8Jd~4NIQ_lC-bBU47mxI!Vd=~ z8B)GkD~KxmsORv;nSr{Ye-r534mCApE*FO>U$flISscdrP=h=kxF9{_gM}RXTv}Gq zF8mhgfEaRvCBEW85Wr0!2%XrEB|fRf{y?!Y!HRABS35c5ldO2L>+zwf3812p5)fClkO@6&B49#iWM%Bc#0#DH)anL;!H14S z?cL}twyaGEo=8&b!Gu1MfpWAm{TwCim9$s?6#xFPCm0 zJN`UN0=?83nKooyOp_H5uq^fN?%elqw)?OrV5m=wpaiXHmliLMP*{DYZG~lWwiU5Y z4|;n^f*XA_*)s$*Z$6`H(3vxoWX?azlb;yH#Sv7^>(RfoX0n!I@DS<`mK}li*@lbS|H;c^KefD%X%NN5EPkF!os$61A{p3q1^U=OzB$BC7Xqnq`>2;UgqBx?lGP3PA4f+YtTMTfhyz=E~YFMh;^>R1Pa$?v46F^6^ z!cDf+H+jUNd(>@_SDR)<9Ss0-CRRXE)BQCt6~q4oVx7%CI(=s9Y3`Hltrnz`c21TEZs{!D3cZ z1#0dPx^ZS%?Fd~>;xAr=sloxR%)~|<)$AI>5^ZE1&vVI2aY91vkcR8VnT;}LORzQx zRsnV?F1fM?OHqw{gkYZSTdX}wKpfdwFuofLp>@SMZ8)P2px4*M0UxQjy}j)t)&|5odOdhGP1LQ zna^t6>Bbr2Q=siZ(HK3|)YT@=499${*&Bo>nqVbpFDyP{m0k1DzU;}FP7Ea39(2|; z&e|ufjmP|Wv5u*DHrg~KWU4Vo;<~d*?#Y?e_@=l`+3FfVo5Ipk3m+&OxM8K}*JrqS zQ$q`2$omXAw3o0YoR>!brmj_Fi&vUD$6b|A*BxtII>*CA)vl3y_L)^>dvoN3?G*~7 zDnrc732O-UEtY^=byhtq$245E%I7Za^yCaNF(nB3E?Ek?xNi@<;*={IY7CIA`|VpS zTbkHrHLU7GwHVmaW@pY6=ysHg$z-fs8rOO~GgRDJB_O{?(0s+PcWid%tnnq?m{_iE zU{|+Yx_*jO>E`OJ1Fx#z(w+5C`E6&;EU{IH8Fx{zizgtf_=LVTxsrfXinkvvc~=&>vg$>K`^%3u*B6`{;8o%|adhA__^56`QuSv)jv zcIFJ}Da2PkLn6H*Z8!xaMc-uT8AFlXj9UCCrWH#Ko-2*p=sX{1JDoX0H2N36E1w~n z+fo}5=qzmNg9`E4bL{XhSQ_UJxj$!Gv&EmZJF=ol@g6E-%3h&uivXI7V-QDRW@KJl ze6H&B=geSTx=U6wX;E0h7vQ#-@6geT1d;nH!_Mu`8Pd?ge?0h*xgHeqQS-`R)uk5Y zA;Z5vXZB=3hMMrPGUgR&gZ!vHeQf0Ftv_dohB!hvq!Km5rzf9+GadSPD?dGykIm>5 zoY}kl*bJYZw^MLtf9BcrJL&0BvYOE;I0H#~r9J91WEGL~E1ZHez@(hr;Qf7mVk!}y zk+b;>sSx(5zUyD#=3D*M84Y)va|b=;6rAC=t^V4bv$0-Gr{Js};{4VSn4B3P11u+J t1CV4PPR4K;4<7E>bKuC46Zh^tICSXPuV23&K74%c+{K$WZ$EqX z;?0}4ckbNh;o+5#kl45Hz|o^83=NI`{rlJ2+S=9CbMD;v+qds=ad8(HmpV8&iiwH6 zfB#|2mK~2DKjq`&-@0|jlPAx5d;1v~896vOR<2xk;lgDxG4W%^PTahC$HT*`xVY@m zqbF0QOh0w%ytA|OxpNnG@7}MarG5PP>2>Qi`S}I%@bH{DbH1dc{KSdVuCA_o_a0oc zX3go-=eKR!wQbwZs;XKW8|(AuFPWN}UcP+I$jDe%SC@~EkDHtO)vGthkDt=f(Y<>0 z#-&SF_w76U?%n$b4<22q;OZHzN#uduU?5T6q-CmbjS}2r- zMU?NTwZdbzCMG7WqbA0-b~5q?e(daWM-9E)Ld1hg3=W)Zozl#~|7?N60+*>QoN_KR cJqneW*fexPfX-!{(yw6u=|RV0F9il`0FKAe*8l(j literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/gif/LogLover.gif b/src/Logexpert.Resources/images/gif/LogLover.gif new file mode 100644 index 0000000000000000000000000000000000000000..dbf03991834972e3edb8fb9f6c2e8a2023a5278e GIT binary patch literal 5235 zcma)<`#;l*A~D*<7aO)0`#p2XEoE+%Tg@%% zpe?0|YDrR2bB#KcZd9kvzUT8Fd|yAjetSKhkJk^cA6~BRF3ioL1%L#&g9CUx9*f1o z;cz06Xmxd!!C(*w1gTWY;cx^3flMaz@$nG~g(8DKfv4WMH6HOeUR*B00b#&Qh?4Q` zx>tQ|T;L5R0}+g7`YaM;>CtcdI3(OEZ+k3x%soF+TH)kgZlI-?%2!NNeT(=)Lf zn1>m$xjbv(jj)@o1`Y&wo*6f)HCG|jMiX+AnHh{W_+3}z`UnS1$~h#_;`3v2n^|7~ zg9;Zx1{W4p0BN#@#x9(xDvO2q(fbg9ecGv(K!i&X!OG%5eVC>V09Z|mc546;-{<`D zE~qz6{h^u15*3zf2_Hn8Yl{>>?(@>It>rMTqQV|+mUB)|aT6+GeP+q`NQ)xqtw4Et zP#J%9Wk__eZvqK`lWZ0b1eih=3C_7!i|JpP=b87;nlxTW^sD3<|Cp|VsZn9*y_N}+ zn=y5c-;06BzgHpE5&T~SJ@8fBTa!QQphUfG+<;l?mFA!POOAdIefPC@EVaD5+Q0Vp z-8E4fWHfbII{={myn;8shIaB5gl55|ENGvFeTLi^#e~1VPSoa!&QJb%o>y=I&U+$g zFHpx^L={A8`L|~s0n4^22!ZTRH(9LYq<_D*_ixf`rfUud9?rZtWAR@_xrivb zfIhW2tse+6w}Yxi*T3`_v|@=#cQtBRtZI3&1N7YVzY!D(T@TPGq7(t8B(oQ&?e`)W*Qi5}ftsz~rg;!(0L!^XSUbJWr`#{#nadt;?bO#b zzZtUE*6ns~%4v{Hcz-?k5}iU|EN_KQEnABdArxBHr+T5H ztZ)LYso0%H4gSruCV{bUupnPKVVjf9ordObhdN%aWTL`W_PGp};fjr}MsBVQju!bS z4Hk<`e)FpUKeB?);_Q~d`ViLSDnjuC@Ay5kBe+j?`Jz4u%+pHU5Pf=T)}a)6mB54t z+$N2Aq!{7OLdJUwkbD*(OcSAZG3+e$?jviuYO!Zk?`ZH4%4m-0+3Cm%;#t-fI^c{t zq=lorl35(gg%s$>0Qrfirrd{IF;lM+e7JZG5rQGV;9c3o4Bohb6e-em6~d@@iVGtT z46D@o0LDJzja`xTzH4r12kb2E(l|SyKPL^AQ+T@XM#lc@G-zNSp>P+VL=9i3Y8ydz zm674tT{4n&7(CT_RrNimJPlNrg*s-uLMLA1!D$jEi&bc-S_q;Ab*_%Zi^T1)ItVl#u6MLO5Qwi0N^HU)}Sx6rHjK1c!ws7|^ngS^dq_J!ZTGo#ci9ee3{ zC19sFzKmODoxt*4$fg2)VaN45^V~bDOv{c=wAhOlHF6Y0Hq-T+=4DiJuFviI@%c0M zQ)*Llu1^Yz3CHkhte>pIsJ5#Dqr935x3kt{-C#$^&nc*5?36{iU0s`5!udUi2)R}= z5ZP{yG{4TvKgu+5j1-!od3T;_OtiDXP6%zc@p+@=W?%?Ex#lOpH0Eh&)i7a7KP7q` zrqY&t&t@|<)vS>3Kt7J~%pBJOb$~k>4lqj@(l6E_%s6Cg2cFj04F2ttc3u7}4gw;2 zEc4dFjlAtA!)GB`lhtFokCMf@3xxJP(r>V%A$xu=jAGz1j{P^|9P=DK(;A}6F4Z{~ zC3#9O!hLqD_KXgZqvqHt^%^}8k7>dgpWAFS{DMOc{j>|axaHTuYzZL;P!;{*<;YRY zD7l@k5MY>y5MyhcJ}L)wZG3Se)=Hyl_}SRG%ZUv1koHE#QRFOuYzuAMH1$!%8k`x{ z|B)Kwp6cuo5BCn-Ow0%N_m{15gzU@Mm3Fp5h;PaIu&hy&$R%-_t-nPbRK$MQ$!i`C zo_M%!kiVE}_qj7dPtb-Te9QeEHlk2NXeM%BQK=S3_%yA$vEEPeb|utqZ}zj2_>9Q% zflkRZ5zFgi1$q_2_or_w75i-k!Fg=jpTI6s-(EY(z zLa&(*hZfig^#Dpbh5K8o((V0oJ4)o=@-!(zbAs5m$l=+I^{1EAjOePBi~mN)H*qtf zts0&n_Eq0wc+TOs=bZ1tu}J5~;;uh?nYRIW6z#XfON75LxVIP6Vds`$m@E0>?U_Qb+l1E7gSEGb-7 zxGvuJwdw9R)0u^8&0Y4<#7DHi?cXg7f*;`tW3^wQG&#>AT@I@_WO!KgT4%DptcW$) zWx!LlyWto`%SU=ftQ~{zZx}nVWM3vTdtWXC3N@E>_W@pD=hIBzi9!eaz_ITw1EBo` zHCg)h2{ft;-$*_1ejitbekaIqjej4XFZpM~MCyX(74rKZSpd|#vwCUfrTqiJ`}+*k z)#2j%Z%raI3{79BH4N$pxwj07)=CjIfC8L7uZN&KMIA(d5R_lL0IJ1I*3AJaPWG2sy2@8jsI`5NNK1lR ztf^LFZ#hVtr&GnY8?_8kvq4|PamGAl?aJ-9I7qcOzQR(V5@NG4!F*vJY7^;Ud=gBg zo@4^)%MCykJ|muwit0XX#X!`?XTWxK*%-PIQL+F}T#w26 zgksxdj|<^5@zA}}3==-eP83zRdMp`72aIwu7}y-i39E(Vgyk&NV($Ly^kmX*Kdp2| zhbziACrA{3-IiS90{$7PAV-sTl}zb$yV~RuQmc3>1DZNGS@6Jw<;!pOi=A}0PS+B~ zPH}c#W7q-eFgzMXql318&C}~>O7W%H3B6EG>6wquvaNx%5-l_qmnRUq{&{;-2`7Ut zz!r&eEoHpdIhy~hxyb-@#6-620umNdqE(sC`?U5g}vL!B_>N7 zboHg5WS#SUPD<2PL$bC^TVm@_1kTDfOKt2(d9|gm%9LOAaDraj?4a30SGGdyKDXjs zN>#6_NDx&UO~J4C<$rtw#eT2yEwxUKR4|`K=clH5fs7q73{*qLgur7G}$G=e5xV;I_ zBv;G5_NaYuL%F1tQwh3I7qE5K=U95JwJJYctcveCK4fCxupREXv1Y3^!iIxPI0R)` z1`raMST&V=!Ip>vneY};{wJ5M8OrMknxPtm-#<#)LY;2!%ycY0A4J5@W)zEDf#<*( zRCSJ%szw4ort-#y`1+I&tn%;Hz%g!}G2i%Ug?dzXS$HwY%)^m0PuH_7JeKRw?sKu& z&qHyiDP3Ch*ssPYfshUA2k)sp9d~ItlKP{pAktJ_*{$rHe^}P!e@`dwDCMFF-#FmD z$K^v6p`jKrJ3&1XO|R24i|xKna>6BQo;)1=ioZLeuB^VffWd<`tkNtxfzzMt!Ah$ z-Sv&*wppi4LAI1YZ>U2c=3%*weB~L z5(gu8_GxDmy_+1z#n6ZAVJ3ikXC4|-yzQt?^GY8I;AyXg7M#Snq)Mt@6B{9|sG}9- zl_&D1{k-By#H2Zki!$oIQgq6xMk*hPKi{VDkDFP3k$F{z1>ppYrBd8o&@Llo;tl@6 zH>f?=%})e(7^O;XV7t5ZKc++HM1Go`+wJ!9wN~5)Vt6H13b`*Vv{2TH$`zYPyQS9HD{@=+WJ*pU7sM5;`Z%&$z=fOjAtqXaiYC-LzxE1@^no;Qi$R~c6K>ObJwiET)q>nKCH`Z-Lh zmV4znva&_J&-88bQc^L7#~zu4Rt0(bv#z^<#>#(n+%i=o@q&ziY;kX(H946=?j?#X zv+7jiTk!!pF`QcIeIt4aQxHa1e*XXtv{(_#X6Ak#q8i^}} ztx|XTot5|e6DyE~w&rYg31E%a$MnU*g9H9jjvjSe-RS7^cuVhN(w1?f zka6SWaoUA((}D52G-_WkT=5r1*l#Fyg5}pec!8+1VQe0z6(i7(UmS*|6CS#q-&eE4 zzSAWzo<-ltz}~fd($3LuV@Tz7El-x(Dy;zw8|+IOX|Nrt%@$xr>j=3VjeLmes|LV> z%XBWbJ$@WRSu%1b#~PbK!^?2ZGR!i;!Jmhdd^%)68(oS;7g-U~McrO_f&qQ>U>MeM zHr5z+zvf+ZP$>4*XG4FX-*jr-S^JXP;N~sQuhkG$DUDaRE~rV?41JvtF21^>t9iTp zaVDP~X6mqoIC#%SR9DieCyJ1=h|PNY%R-J{s++lYMTyumb8pO6aY=-I1!N_at4lf} zPVzz-CE+ovDm@+WnOUV#KA>?)y%wzscH(Cn_`B(`-+leY%~X01qi^P@js*&PW}CE3 zRbMgUqjSBhI_g(FRczPx-)?C&if3bzPX&ClGRs%7?~O)|5=UD*1`~`t|M-bYWMSiS?vx?@7XOXOq?>exHAe_DuN$Kj41q^5jPq)e2pc_HWD zQ!cH}aYIWRaC+12;A4~`Ob%;L|c(yAV>0ZvNP{98G0ObX@+yDRo literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/icons/Icon1.ico b/src/Logexpert.Resources/images/icons/Icon1.ico new file mode 100644 index 0000000000000000000000000000000000000000..0d4ee969f989fce59f04e04ccb90d50760b339b0 GIT binary patch literal 52334 zcmeHQ3xL(c)t*T*N$$^+Jp_MhYir?11KUtT1Koo!{G*5HpX^VfiXBT- zRgI!MRg-4Z15lhq4^*)a6lYJG4F?kNx29(HsHz(Je@#{9|C%Z|?p+Ok;pgb%1YA_y#y3z%=+!jOf?-*lf+`?^a0efAez`{iegUN@Bbk3eRShcx zG1-B{B)?qaRRQGm&U+U?-9edM!0M*=gAe@yoaX209UCh{b^LnT#88*d0wXa9W zs`b7a{Lj8{OoOjQ&(mug@_cANuYfOfa@g9^Jzx^{H~teN5F-#H5F-#H5F-#H5F-#H z5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H z5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#Hu>T_d^In|L=tu2ZCA_s<7zNlyjc zKBbL!jSpO7laIeog7?yDHIaVUk{Y{TwMCW=(UiWnvCK_v7VzgR09^2%qk$|sU&06O zS5Mvo9tOI-p$~UcAF?gLpR)iJK@@*if7jL5Czbw+bV3Vg^?uR>qV%$iSKRbRbfYBj z@aH0kvjE`llORp173l~2$@A~i$56@nPWo-v+~THT3-He`f;<**we^}B^$Ej&n~#4!5tLgC`z+vU z^{!f{%fFTIL9G&tz20b|^fc2iy7qru8}Mf&@cMr?3s5T{rwH=3F!X=60SVS7<$f|g za<4y4E31%@pV-!0uKizz|9=7&5JgZ(3){w0*La^9Vtf>o8Hjo!h_L`AK}s2+;Nw~u zB73X3lGIMqE_Lh=UFTER0sI*W3W}h_;bWzN6O``PImy+5FT!(2gtRba0hQwKs_&$g z`xSiB-g>51Q;#eko=E)Dbw8sU#sAZQ1p*Ni*21>6g!H-*yu~%%5`;!U$&M58 zgR?p8;tqc3>BJGE0un&~=PZ!X!XExEsk0Oy!MB|Y6y;W_-`*Lf<97D zs6eagqJRhTCv$w;HsvSfw((kEh;c(8qlG~PF%rCOe_KhQkkiuEEVu0I5dK^Qg|)C_ zZ6Mvs(dG{`AZNoa9{J`Q`Kn>2`*a==M76MozpDTVp8vM#0)=!l?HAp$9RdEF1wj6U zMUeAf$6BYHRgOOUtXS{^LP%q(lO68n?zmtS5_iWjTZ|e4Tm%6NFcQ49KM5j2 z&amD0=upSUKPLUJ z0aa-Ang}7JvDHSqdpwV{&jQR4@U$>vfj1cm<`L9dNkGWywo^wPJ0AX}06xc`vjAg< zvK>~NMdXM-r`y%IrC%^#P_gbfVO}`*yu6cqCsp#GcH$k%#g+KZYP4mGM+qgt4`L&LVPKPi@b zMxdC`6kA)AJaCNK{dW1vO1x+po-1LUWY0u2y?~wpR5S2o9*;@U`@xeee9}6%A;o~25$1$>IiJ;3uYk=#Ac$Jl+%bf!nW<-~aYTg!^#3ReIPMnZXSd)P&zNl%vQa1> zh&HN)zYt~w_`I+vf^ur%%|VQGVJ+;%MerGcs5_1s0@M}@@CPnf;i5NeR7=n)EkqD0 z@`-8VVI~c-@%LEZGtzw^oj}>KL+?B~!va(VL=Ay#5oEP_LqB?qcG_sQ_gM0)vC1FE zN&h=exq2MAWQ^K-ly=$({itEdgD0fz$1G!^lX^G90!@jI^FmXCQIIzfVk(%~!dwe8 z7I=e^U=~69K8{F{k1-N=(hylHjRAj70ycrpw6J#EaJ23{&+5^-j?CcSm^;pKw`s?X zz+)b0+zY*RD_XuBS3fBYm>~bpaP_R=iNi))#{4E};YJMsPX%}^;G*Rgnnuv^`;ZGD z4=$;DC9Va5W~9jEjx=jJNEL$N!be~uq|O1^BE z+I6sTz&%a^0^~pi7q5liGWBXlUKkQVffk1T&$i_znyjFGlk_Lywz~Q^nifHW^8@@T z3ozl#R6y#W+4!EvMZ}a}kEQ+JcL#wM7DW(u2T?6-yKm#Wr;ESc_5JnhrQ7aOE*Jum z%1(H35j->~8Xf0}pp`m8p*sBZTPL;Rwb$5;7!MGIArKt} znPeuK?+1F}#mluL%A*6(Km-B)uqDyoWdyGS-WwmHoaGqxG!M?h-zNcxAg+bCC}-Y? zzWOQ~H1NH652|MjF-q@owYU5k0Tvx+D=*_IkMX+j zk~j22ZxsfjAra(}Ac3xsP@6qX03x66Bv;bWHN`(5fhU4|7WhOxX<$CRDGj>EaX)TM z1o`eb`7d{J1orICnmYNKQR>OJq|K?W3ck2^(&?F?zQs!MwAn_RiEJS1+rnH6d-#{2 zWjgxB9>t%?KeUZk>7dTTpR<6Vh4rJxqUEc_mW%t)-yC;iAc7ik$0?VO7k|4K_VK*M z@)bjsOGe7K-JM+>Oy!u##{@0xkAedHK@cs~Q13lN0!2F2GHR$(m*O9gfQlfl1-2R; zs_~5HvRlrN;Hv4ivyRTQ7vYX0zu4RO^LFOjkuMqG$S-^DxQG_^sNkZ7d%{NtxyQTTB&kMzLtB(@%@k6&KhA-hBbPksVP0Lb*0yRTP&=F z0}{MU&}q%c1&VZ>VN9a-3tex7c~pG-JuN`{ziquCUsYKcd^n3Aoo(661pK)O%Atj| z)Be@y4fnwXTehgj^o!WSf(W9+AqPE6Q1fKp%eZqgHJFCeQ~VhTJQ0*(fsdTjdilH? z(Kp{TiUyutYuO7a{vi>R(-8PZ?=r5@8}5?}@RAjYLk0^hu-r2QL@LJkxxI;m>CT0v5<}$0a*Hggz`f=6nxX z3VCjer#_V`ogAnDP{g#`M>Y#RprBn(x5U`djX%)%ZHhl5fiHprEkH*>oAu7a(V8OC zBD@D#yx6p!59WpQXyG6_&McdU7A`7^ta(t{qra7It}^u}0utn40U(EoCMc-Ou5p28 zT;%F&S^T_+e@FzS4w{CiKhuQAT)sSA@>GC7XMx;W*e>0G@1o&YEq0SH9_Zj#vJ8O` zBc#v}1vNSETQ$yiwAIW>0s#Xa3xEjnw1C(DH(B<4sl16M(wa4?wlmqhJe!(tWL|!U z)W78ofyDms)mNnFKV7_xyW=7v$SWG?1{rlMo(qU}rlY;?J4UFV3P>Qb0E~h*I>|bv z&rMD4nf3L?cc#x!kRhO+)e7(j4#f{V znR4$d(Eou8T=WV-T?>#v!UrVW{?q|Wmr7V0;Lnn$1Q7($$W7C^BK{wLoH%3>!=Hx+ z1uQ_LL!%-{Ke=__4vs_rE$5)bhAND#1qAc9QuCF#c9(21Kj z)0{*Fg#ctKO7x9NYP15~(7roBW&bgCB z|Bz5yQ4lHW56r~VGyvO=L={Rho0((&g*4F6DcTz)P5 zl{9ctYr-FNaqX){yU`-r+4~N9kt+f<^-~(|3qij$2T){zj21T9P1$vwE8<^QmufdH zSAeJ}fpOE)x= zD|q$lRNF@b{5cDNJ2V&t@z9jO9Y-#0efR^z%D=hAMT(SAr4<{{URjxJX5 z8FWIEC0*tcL3QMmf9|f%6&auU-=4@0&<%T}MMK~lty`-x0V2Ir>2rGl{DC`Qf*ryqT1F*7^6)he-vG}r#lo!apO z3*etZ72Xg?#Xk;MKomjVKWeV#$8pue zMIl_UgW;#=SgBXU81=9%oZAqP|In;!(G+Z9Gd$x1PngO7b8&WboIm(f(T^kGdqsk~ zI`WdRA>eCaa7RO`I9f+TvUg|0k3VCj<_l>WjcQ?P2#~(52mjALQ;+RmAT%Y7MoOq% zPW<7ZhA$RaK=efb7u1nnH{@GXq)4LRN1w9NuL}4_Gxc&B0_xe#ItJdoE>!qQ<;!n# zqy+;0kGe(<_2x$w;y=w}qox*l0futzTb!E&Jq3xi5r9FDj5GlaPK}xaae; zAcYKRkiY^NcN~k0s81X=4A<_8O@t>@+v!yS{yCCWGoe93fT&qA7rpxGK0&p}N~P<@ zS&3(u>hxEwi3I4H;s`go11~8smr4qw)V|w}Wp=8yikT=vQ=8+3v0Xj!n6p$dw z0uUW!9CVj7>VYOLPAd(+&q>!Y{JnhbqO`E(ypEro(}H0C-~$*)$bT9|&K;&7GdOKM z%uoXS83}y+>8dp}Iux%+*!?ilBJdVdRPlMPvO3?S7$k4niMe{Gp~}w(<4M(M-MU60 z!sDR-FBdZPa*Cknyu9VE!qcB_^yYiyf=!!H?ObW-Wclh5r0;OG*HFF7V58jxo4iOB zqPLDWxQjifna={E2wG{8SxRCT1JPk>I3fL&-aJbSN223weUb5aL3VH>?xrmbm=j1GHobe(*8rrt$Lc zD#_1=s@(@`o$oNdJJC!&<>;$e5T=(b98FfG;CLj6iXdQt6{KC?V!C?1YZTliB~K_Y zFYm|b`Z)rAfUc8xGi^`TI}XuKz5^(tTv93jbtE1?70rJYZQhI@ctW{oh}vUl;_&g7 z^O9?S6wCv$z z$jr-AF7TtX!~oq;jCzo)3TZN{O{*r^VY1$3q}FY;de&HS&Jg*ei>2?JAh$b%w7V=( zHpsT?!qIWm5O7L1!Q!h$;lFJg#0%jWv!y|I$$uKI{CXHUzf$d4sU1I5|K3QW-Bg&% zhE+pdi>;YJ(`LojN*1|xT(PUxr0pq6`{qf9g!gnnN-|p;K@1II0ir^597~f4#i$of zRt*M1z7}@u4_s$!5S`^s3VWlV?fS7}AstWcJzhO$Jj@8IKZTuf>e*w}Ge;|@{Dqt| zLjB=z?HE}0WKycl6PCTiaX0yN++%CU`B9p}s~kivY?C?4p?!+%;l*4QCV|KTL4a;n zjC$c@)uw7;KRUFLRcpQ~{%tbNvUVKP!fbFTh#*U=Q4Tn_7*v~d4Z)|`WF8C9Wrjc_ zG3r5@QYKR`XTE%nRcpc`C}Ri+0lGOCZelB|Ku!nE?}H82&VreRthM8!?{o{+j-ziD z<|0UVtzi>Zt)T-Ui_9eIo_ezqaDk;f%Y6|+j5M%7t~8lE$*RGs9paJ^MHvE776`52 z%AzKsYsayf9ZCY`=q_>vSLiTw^WHBnXyMEYt@x@bOb(ED9I`B>RO!+mReY|3_v~^s zGVTO31*&v`E?)s}`c9LF9Cc|fElks7vhuaXe0jcb5Lf}+5a0t*aZ)VgjtkaN-)C#b zL1vbv)}+XUqTcgYLkRXb6t#)q2ObQbcQBhl2EQO$RJaj<>+s?Nl?Uo zrdZKh7{KTF=XJ*g_~#TsIhU_&T`Vl)vlB?=`tE zJSn_fUcv`97l6%v9|^aC783bXRX$r&exZ@y>g4K#dTl~2H?-mDM73qSV5e3&<_5NK z7GJf7vw%1$7R<{F?l`tsbdV+!B&+%d=?bEt1^ibzFcrYHfGC1s1=p>P`L>msmrl+! z65|tEc|!f0u3iPL)s$bVN^c@}Q>5c%>9A(UXP@5?5^do1){1-zQMwVOmrBl6Ngqx9 zm8M>%X}{OCt91P@x_)gU(JzrGPb3Eltt=XnM&vKVTT)I>Gpn* zQ?|`6eb;hVn$Ci>^-Riq*ho!G8bcDv8xx7^bp0Q?evPjEQPZx_)Js)zAt7ff@(&dG zSV@Xs%G|{6fHg^OFDpkY%83d&8Q$Xt@6l7pNwU&KmOEmcYU1to@#PKiCq|&@2<&Vh z{>^qPT;8UI%e6RMt^j9-_(5oZSloe753#%*p-=_eAW}g*Uk@|qV!0NfP=%Dqg!4OT zc|hg>R2Qlcsza!K<~&pvYCt_L3k|5HWuXBTv@A4$7KH||>V*nf^+JWLI-$aP_VY}I zwO*N5SmBjf^yKh~hyOqn&PB2#7!$`n0B#PWcK2BA5u0YYqL+-BS_+}XJ*!&L3{Xx>Ci{^Qj z^saT1KJk_%QOU%z{kR88vh&bCyI+veu}v#zm_3eW&DzzmCHm!p|vG*#h^L zI+7~3!dCQ_mL5}1oGb+-%Z7D5T(cx1_Cn4ZaEbcHJ|7gHVP(vMd?EdwxZZ(h-P0J@ zof7A0s`~6FJSApGfVsHbZ38Ra#5_a9s6@O$sJ<1|%TWS%Q|G`RBD z1{n7RZ>Pl=@IR&i!eyi3Chq5fClAV~?+xUmKMPL0hl0Up_(<%9PvBcQex#3Ah}ZrD D_6`X| literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/icons/bubble.ico b/src/Logexpert.Resources/images/icons/bubble.ico new file mode 100644 index 0000000000000000000000000000000000000000..c4084837d19f40cba80ba7b11053a197953fd459 GIT binary patch literal 2862 zcmeH}v1?jU6vn^kOI}D!)z+rZrckGnN}-UU9ZJ&dHLOY&b{Z{T+eXM1(x7PC=}vs zV0#I81<(fVRU9q@AGtQMV>mQ`uPeZ|_>dTpIFX_=&KtNRo5kW};z*Sg(d~A*p`1S` zB^u!;OEUZ>ra4{ue(We_J|}a|%oUHRv^3hlg2nKKu@P`F;O$M*OK zV2>#_P!h4H_W;Jc%D6z@0bRd$uIFiWa&_j@715`5JRZl+&JK2WcacaWkW40#PN#8n zbc9SMgKRd-pObg;RxX!OtyXbza)Mf|hI+k@X0wU&^K-OXEwtNhbUGdMdOh^}eOz2z zU@#cq^70a+(Fj*pSMC)S$|3`c4E(Q*H(R-zH1Bqz@~p%Vt_TnFoHpg zqp>DY%U0A12g4krtm(kYeOFk|0W;!?bLi?rSDZ7~H?7&XF8%>4%A*7;AofOdi=Q)W zh#lN=CFs~sTnURE3A+-JT0i06)Y+K)1H3n!>9)bgO}Wh@@|3(F&&gx*fZQYEGf%|t zHF-lmkWVB-K9eMQOJx5gc}8xOy}i95Yrm5DMyFdg*fSLCypnl;fB%oqV82n7N=30x zDA5lN4(>c7l}ZiSqtp!cAtkWSxNEaL@zt---lo`(T+YtU)Qn%(MHgQ^o_$fV*LgyG z^?3GF#UAMi@zvwmixvB;C&X8e=iA50x8(dT#8;1J|95kz=S#Q6SC8l0LGdl%3GvnA t`Q}i3M|eVf_4w1%Q^hxkC&X8eZ!{W1zIT)t#CI0|jkQhQZ+}~7egff)T>1b2 literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/icons/logexpert.ico b/src/Logexpert.Resources/images/icons/logexpert.ico new file mode 100644 index 0000000000000000000000000000000000000000..d616d1e35eff6d687665e3ca096dad63504633bc GIT binary patch literal 318 zcmbVHI~IT-3=8kM!{qG9F?%$Q)Em^KRiBfCDe1ojfJPZ(0N5}au+y8QG6&h17c6xt z)x?5T(JXtU>0+%#O9zn$5%NfiQc@Q>1HvEcD)g_I9a;CBb2xg=R~(G-+L!Aix88Tk L8vpwTn$z=7)>2;; literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/png/48/Add.png b/src/Logexpert.Resources/images/png/48/Add.png new file mode 100644 index 0000000000000000000000000000000000000000..5f96dc4d660ac70a8e67676b6959795756371f90 GIT binary patch literal 1774 zcmeAS@N?(olHy`uVBq!ia0vp^2SAvE4M+yv$zcaljKx9jP7LeL$-HD>U|Zqo;uum9 z_x6@!Uy3;oOW^sx{JHsi4Bs%`nEOUYs%mqZ;ZgpRyI_5X{>(Wp4H6G`G>RwmtP1yNkjuuRxt96MjANcaU47CO zjK@|~wX(d}sOHfB)uNLjIiygLF{$M@FUN-SSIkF^!w7gPhTVhz3J1c))8|j><7~Wa zUG}S>K3LshQ{DXkZ(qt<*IF>u)K!c76;vJflka2Te*OKY*z)o>UmkLN`1v;0;vhtc z&YJtrqvzb)c)4Bq!1L|p4_P2eHf*SypI->kIsg8>R$-`;L%(YG9mQw3o&D~s!Zly_ zm&`b;_3wWkTM^?Y^LV4pnrGOaFr_ekQK&cVWQbS&_P45@sdoO|{=btL?AyM@_i|oH zw)ImwAQ2kl0Ze>#%uH{L|HiswNqKu2Y?l=Z0Tb9`wzvkvRdI@pRco+l{>pnHSxQ|{ z!ObG?0jtE~SE51-j?co9-tUhZhY|3Ugq^CaibF%QbKw#>MquQ5TX{4vu(v<*uw?=k z5YtK~Ffj7*9i3Rk!f_#4_oV_OlZ;H4@>dRl1;?W#;L-@2rkg`=QA zqwk8c1F!({WCxb74+3OXx;Fr$a1x)8!hwSeErR+PfN?)GEd0ajV_0yoB==$+umWT7 MboFyt=akR{0BtDB>Hq)$ literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/png/48/ArrowDown.png b/src/Logexpert.Resources/images/png/48/ArrowDown.png new file mode 100644 index 0000000000000000000000000000000000000000..0553d2e249611cdc96c9c56562601634ea226474 GIT binary patch literal 322 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeE3?v1%WpM*3xd5LKS0IfCY}d%o0!nk01o;Is z{P$+z3C~}BxIag(=rB<9q^FBxNCo5Dvl~rW9YkCM84mGYXfia1glAps;|^(Sf5+p_%z=iQ18@AvHo Og@mW8pUXO@geCw8Y+u9x literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/png/48/ArrowLeft.png b/src/Logexpert.Resources/images/png/48/ArrowLeft.png new file mode 100644 index 0000000000000000000000000000000000000000..ababe7c69c0a37ef6cdf7aaaa2374ee2f3650b3b GIT binary patch literal 236 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeE3?v1%WpM*3xd5LKS0IfCY}d%o0!nk01o;Is z=2-6v8Rh;NCo5Dvm1FE3>cUlFE4Sssle7K(K1g^AUMFtN;qQT z>mR?bE0%g^&UzR+n{$F(;K?+mSpp0@XE68+N33UHWa?pm!Lp#3QK~^gu3Y2qLFETR z0!RKis&RyFag{OXl$P6gaHWQWFw+GWc@NFMbHB&1JD9r^f!yrr>gTe~DWM4f DO{PF6 literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/png/48/ArrowRight.png b/src/Logexpert.Resources/images/png/48/ArrowRight.png new file mode 100644 index 0000000000000000000000000000000000000000..5a42460e577542f72a64b0600500f7269f40cedd GIT binary patch literal 240 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeE3?v1%WpM*3xd5LKS0IfCY}d%o0!nk01o;Is z4QwMwyCQ)2O0 zo|TDl>a*wkCcCUzcq9x2^jVUU99||lC@KVWFc~c3wRmnfCpP9(5RbqWkh?uy{an^L HB{Ts5V>Uyc literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/png/48/ArrowUp.png b/src/Logexpert.Resources/images/png/48/ArrowUp.png new file mode 100644 index 0000000000000000000000000000000000000000..491bf1a8ff236b6ec79a12119e4b26895d7e670d GIT binary patch literal 325 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeE3?v1%WpM*3xd5LKS0IfCY}d%o0!nk01o;Is zokyZSyZqYXM3BBSo-U3d6^w7sZscTg6mh+180fr_`S<~@oC91shnS9d>D+8R z+T8shIq0YP{yAc+S7mLLmigB1xZwL;i3`6I1spUOI9M4LGAM{Jv?xvBY!Kjd;9=_E zQD9?qVd|@W)pX*(PXD_Ck~_YwG*x0=>u>79_Kb02W2Hk%f}DWl40ab5o(={H0Zs!2 zrUVC;0}UJvjDifzN(^mnKX@hT1o#^sPPVA!l?GBf%oQ2fSP~o=csLGBs$d2(FMi{d n5I8^0XhoY;){2Mx?WNS(y1IdV$Ig)*{np7m1wO9Lt&?`^rda7P9v4Cr6dwE zr4J?I6cbsJ^0AbBWo0gvI$LK=RL=W!T$l5=Kh9tNc;Dx`e%JlpAHVze-1ob0l`r!r ztSJ@%@RPR}-5)un@X?!!y!~H9>LLd!+MnqO%3ICe1E9ago9@Ai<9sNXUtzx4U|FpG zQ5?b3bFceBD@VQQQ&T*XJx=qS%?KS!=gvqYZNueaw|eQNW`DuFd_RB30_{m^bZgh= z7V41cnn#qjfpu+v4$3HtqIad`>)6=vA{5bDxit>kP0T$mM6U?BIj;hgCtuLFmC7}V zYHYXZ{{#1wB?|(xB4xTleeT=sUD81;$SDL?EycDN;9(E+s()UNa({>g4Uzl(0q!zd z=$Kz*0CdWJn0)1>PV~u{$XAAc@nHd6Il>P~aYj^YiNE@+ll#~Jq?Q7+7C(}LL#J8d z#cV@i|HaF;yp{*dBqRK5x0=5U!-mB!rj=C^58Mfw@*Q6F(mF@X9-qOB+U$q6%RtLs zM9Pivst<-w0-^!{kHRv-WL>)_SwK?cN7$71mVoXki38RwI(l_1Nzs~o!S0$Js5P7X zkj3J+w^dA}Us+y`1;3;>7fBbAXNld0-nEUBcOa>B+kCR0xLGAJ43Fe@^d24hyO-+f z1C1-sCZ~O78P)Jo9}JDK>0>zjs7J@+vcsilhaDSk@x_e!&ST2hdwwy310ugb-}Uzb zP=PtWmxn%;E^H%c8X99<;*;9CR-&E~s81%ujDq(^58l3Ef_G!wNoN)ZL}{qfL+99< zDwt648P0xDC{d9zD+{{uwN<+sv5Qz@O34fkk-zi z&8xd}x5}RzXSfMQD!L}I^$-hUO%#3R((C@P=9t6yQZ;MdhqC+wfxTZOR%Mtw;&IG`#!qY zMsm1?q2?o{AU;H(4TQ0lK)%@K;#l6>0(LyJgEHCgCF_w2lqHh7Sn|-D2Z`}*|GI65 zZjG5Ce6J4*;|6LVOyJ@q#t6|I>|!i%=)8dNDohJNbQT{jkC}O)UX{k6vY_E*XgG73 zd4kuDj_Jp;*TCq3Fgndd(|%h!dUJ4TXG0HSDonF>cve;=v6h`5Q85eqy$8>QZ!e=A zsh;ONLD-`qJX<5H)k#e0d0zM>l$h9WA`Z*ujadymv#ye5Ez}>u%6#UWbU0MM`+!#^ z*O@b2yLI2dwVor^om8_0>4CzO!vi5gTKp~%WwgJSKV=Kf>iKX^(|GxtBdw7}D8gZK z?;#xxlvIVmQds#kNJN`e0U^d5_v zO(UA3JWP{K67AECr^9{Kc_Bg_rDao4edNe68WSf!Cm?Qfi%4kCvz5+bPaLWX@Znlg z?WNT&pSb?oOXbF=($Hg;Vu5X-~l(%;e zb9&ANBT^3PYS=q&m$9Dral>wJ-`5PfYr^JxPz^awmAq5UMMhbU@|~}j(Opyfi{U+a zK^HWBS!-0Y@xbZb<2FQf{MoNl;TUWw**Jzw95l-yV)V*fXF8cP{NKNmoPpd>u)nlKV5?mVKK?BFR|cz^lenTmFOPN@Q)M`Vi+! zXd%xKq{idL1X}mE!TDpceD}i5G|d*G4|L?sO3^`9&Ng|RjzL&m>j{&&$SPlP<}Rra z^u#FdSfMargXv-m6vm`t(Y&epwm|QRM5SjdjVqum^m0eJ=Pt`+x})y)x9sykBP-u& zI}MF>jJ zLRz}U38?WvA%G)^o>!TG9m;`mRWVDE8=!)e|EjY)CVBGGa*(73H?Y@M6>|ST4s?9jhy;fJlTR7`1D0C8gfrd21~Uak;n><5w&anyn8x znGfn9-94NBS3uYXBUys?e)s*Jh!8yWa-lEULQt{jZZDz&PvIb>JC|)hN?33tE9lLZ z^)c3KASB=%nQcgN?JOG366C}z2DxPbSiVrO2R)-boFPb$|19V$CV=K5JFF%AUzN;e zOrxH)n2dt>t?YFq-VBXC)E^=mb5LVDj*_T~vEj?fL%oBdF|vB)-3Xbg*qr>CG#ZnQ z(I%lc zVc3Ja+m%01xI({*#;@`p_Y+j7=}Qe??AZ32dF;z=)5mLzEA$UqzC2;q_4R^3yUwqf{)fUFeH=9|__@BzW)SdONUaI=5r&GuWxh`kz$rUO2 z4z2B5{?4Qy@~)ZcG48YOF8A(#R`YZFJNCExa>j$d=Q~eaQnRiAE0oP0S{HFwzS(g6 z*q7!bU4M#e{KT%9S;)I0BeHiAg<+L&xkkOr4wBNgGa)lS-YQxhFj{=NQbX3EFr+B? zX8LSwnzPBrn|&+b#E$CpqZ`@=jak^Gz*{T)DSTU1z;I_3Wpv}2X-)Kt=g&Th8iZjn zO`d%pG(@gn?MWx7_WbTk=~wDj+*KYCAJoW4*{-q-uzY=?Pptp?Ej&YxyEf{^u))pP z9Uazkf7YlOCoa@?Z~ zi=y{Ib(`2fhPnCdbk&jAUMwr9@$GtW6%4KMoFEmIR|=7lJ62_d)fc)RW&pSKoUu)A zM>(!INhx9X_OQ#v2{BOI=L#t%?(ICw2yH1Xj<474{Gl8q(irdZDW)CsG+VJ1IDC<7 z^v$pLCb9ncw4M|2%ohH-G<~Qh#YS7w|NWshQ)r%m+O<6*bC3aVG_fwqL+Wx{AsyLW z@zJwUv+>qh$AEQvfT3O2*y<+_vT%aB|%2kyFUFP;VccG{CX z%NLqq4b&SFqZ@XC-aI}==vUm^-e{RMBrF;a*HfSCD^~PS_E|8$`}m_%l&*!dxDu#y ztHfaS&0hPtAQC!GsQ|C~9p3zO?TGv)6+Dk&K-Fc}A64vZ=?+W*g_Du6w5*=TTC8Od zy?3vIBgBr{GjTGz%Dz3Bx7F@k3+U6W9eQdn0C2>&j@l&;uV14B$Z6~U8_U1nCkN#b zi3o(Or(JZ8R6poZTqloI0B4r8n$#kAi3`PKBMm@|fN;GK7#C_v%*r95z}%`j%@#tc zva+8t@l=$sW`ENa01q&jznJ4l65Ky-h3y1TWNE32fZ#(BpT4RsD5&k}d5?o}e@i8E h1`Md+KTeyH3__rwZrj{Du=*zje0_G&#a^MQe*jG}6DnlQ=h9P8vwyd(}gbZmNuHoSdUAM|my^WJY~2agG$R2t86CS2*;Oi=`JjH4+^ z+T()cL1d*+s)_;iy|-TV#bjUtHtYx=oKa2PDUNY+AN|NGCV?5k$OwC1<($07JD{>3%ya5MW!0p zh>tr(8Skp3gxc!!VhX^GJzN~v3&y9^ez4hnKvE(^aEQLH3lev55*Jb~zI@Df5-&0% z$_bE*%%+qpav@yhFuEjQp$$rGC>;pz^$4jD_T^5YLwQI8(mto=op@70t5aspXSTdR z!T~AFgGWER^o#tV0T=cgCfKSXNrWm%OV(K3vcc_f(S1p*t+eD+uqh zz6Vk%YzvfoOp|7KEFNyc6~l*{{K~e|uBw1itJBO}h`KH!_=X~<=r69;B#HjM`)ZXR6w~W-i}H%yQx=NL`>v&ToiyAn80~2} zl((xHFHu7_9wA|!oeeaYB}JJTYIK)NZmFjw>#r8zlyK;vX?KZ{a51YB_Je(d+OBm1 zF~HL5U9D`!B_pkpIeTFbY`SZU{IAv5E7hoZe$E7@m4p{xti}DmNUZ166n5#=Kw-f* z4_ytPnRE9c$p!l(NLa?nNdlwrl@6P4uQ)uUc;BxN^nXo7EIrS>sg)~V0Iu&&lOv+Y zWBL;0pqT4X#cP8CzRk9a`TQkx{u@h>=9+Vhg&Dy&$8`cgP?7}{8_2YkvKMs()){}# zR7V;t$e>$v4_ng-@xcgf4@;f4eG14ZrMyFZ3JOT=N?f2m|6tCQv8}NJ{s86Ly_gDP z25*oi)GosqMp1SCD-c;Wuq!fd|gUi*YV=PQjbJn=Cxn`y) zU&0MJqEBk%e|e<+F%EpU-~KPU{r@jbJ>&d7Sm-nRGU!xqtKGoyoxWtt7?$Z50ZT$; zaX1IhN`~46IqF~;G>$E*r$vWlT*&cSn|V+z1}`JXQt&45q?ep}0#@|kS?JsQSFci9 z73adsNZ2C6dKybhXhi{j4K3>Rd=X(B19!m+<&(!u1Qxc7%^B~2Ot1`1umg+}(?%1( zU4a!NI2qSX-BYe_{HT^F?)$5ZZ1SWbSb`e&GS07e$xCuifdPa;a}4$C#ausEcdV~u zai58g(aOSV+m<(Yt?}|g2{{=Vr+GYuR~S)Wagr{tB3l4dJZ*O0D;QYkp6kyWHYc^s z=OpsflDxk(d5nk)-GXEl!W{1J=WwTzz7i5t;mLkkH`=BcWBZ1M?kc70)|z{_|Mb8w zkej0U=_tR>*n8i-jhaS^!e*q12PGH+Oc`eExOx0`TKNg z5Zc6b!cW5(clO7eHlFdxy`h&$O#(55%1xmyIRnijH&5>Y= zBtHJ5{kiod*~K2$~@X@FUn@e zrm!#T9oH>aWpRZg3((xO)oLk=ELX!2lf5AbDvFbtsIOYMYV5OjdX=Xk$jpqAZPQHN z(b^N46Ut<)Z73uuty_U)s={Lo=Rlt)M{0I?vLb;OWVEz(5H!s697pAUwny0x$hBwL zn9K&DxjczZqreZ5>-k+5V;o0>v*+oCPhM9nzfBlx9n}e{&aTU}sd_cMtXfvJ5_q9p z0qNix{yy4`lQpxtWhK7q*s=IDG1JM%&bO0&qGp)XQb6&~8TXm}Dz7`Up17)W?gg)K zsJ%7u;wT`lI<%hK%FiiKOj2d8j?TyV*EypacilNZL#5QuMfB)YsC`n&@Q};0=V>5w zZyEhgS9S!fNh&4a&cU$ryx^J_eIQUhtF!1KG?rz^Egog+hJK;iF(H>Le*YD7q%BthbV}RHu+9|9llS&~6d3wk5 zY*G1;p;vq@6!n}UoJ-zt`#FQkN;GmVUst^B>GT~rzGw<(ILw3g!_M;A!Q24{8cRcL zJnjhnk&A9UdqkH4K<_5{eQ8=_QDQxB&uEWEYVj5LC*>_x+uHU*5O(Vdl=6Gjq>9zxmBQH_g@gI7SpJ z3IM>^*;=~^koA4+KnrF!PMEL&peVQFmVn-`I1hkWubuVL6BqqI`py3paZ)B;@uv{B zxSf})v;>N#ewS3Wq9UqMUFd=Lj_)MwV<(h;qD|!-lPa*vwY_VL6go#T4Y{*Va@xS3AJ7}KDhSj$f2TV{T6ea35a_Xg|^|sw9w#rYd`?U z^a%(8i@oyrA{NHVVIeFjpemO||H4maS{BKScG!JN#93&m6m0Rac~GcGBzctH7< zWGgb&1u~AbH~6LaJ+0B#-oAF@{-vP84PT(=WVZ;lbtlFWQ3Fq<~LD6U@YV1l0 zy3#fCbD8Q^Nkwgy;mubsP=4tpXexc`#k`Be_QCTRA`P-fFs_xjj@Dhsr5+{Etvw&v z!C>P7Lt*?v6A%CPVZosa-Kl0_I8Oh1>~u9sHNHOELer?L`%7O;tYKdgx{}m2%5H>; zJPhVcU)>l9SDEgrPHmpe;+52jWF5*ycOLEG*Y6cxk^(6nIS<1%s264e0*S~Il`WHO z54^D$OH6CEQToWaM5P1FmK>ja;-W^sEuN|sk1eGY6eaJL;`o^GO`*=ddrgJzQI7SD z%CzPS+CI3$A&ugkK#fYBS7D6cA!`ckEqXb#WC-;*y+kML9IvimQxX5ca)UtB68Vxz zrX)tRxgghNBYH%&9oaVpFPOWWCgCuI8cQodr>eXgKA9>KkLGfdX#y=6cGe`R%tC~? z_QfZ^)Q2|&T2B1IEZT$r;4R=IzeMfyBquHk8UuBr+R{z~pA|srhrwmP64vse??ypOw>cX{dOscA?0smFpg^cJ^eRW#<9VLK)Ig?7*g-gnyie6L$pi+22*{Ga@@m-SnqZibi;D+V&7 zR4t^{t1j`*RuNd%!(uM6dtnEt2+8g2l@ok92o41sCQ;S1^8^^*5E>YZ+#rDx1l0h( zp>TTD2aG^Wfd^y+<|gynJBEL#N91&KSKnWQmSlh|Fs}1^yQ#V<#xjC9%#ez$njEsH z7nUSznUOGV%H4PO{-y;;Aea!$p`T~_@#)-&;pj7K~(su5j|p_5`%t}E1rHZ|Px4Gh#}WqOY`Ch&Dnp8xu} zxz^16V$-1F+|=#C6~4F?vPpTEUtu^G298&jM(kaY2aNKy4=vp*1fm99->L)h#uP?h zWzAdbx2u-r0VErrTe-+VB`ux3PRd_T^l)tJ>k{lPk98Rsy*I{FRgpnRvR z(Q+Br_v-3$(5YMcJ@;@fMKMa)xP|Vjwa?iea4S?)7#($IfMK?k_4Sh}{)y77YsEJg ztt^5}x{fJm@`aae{&WIc3>6~`$VU;s-t`g-R-A+KW3-;J$K1EIk~vvNJDF$ zc}Vru<$9KHZ51bdu}|5wSRGupPn=b$_2{{`bhJ-BG;mw(4S%(_DOa|nw`$a1{_(y% z^fb1V;L^oBQ>gZPR!pRJX8pU{94rO)Z95R#-+lf@a_AG28E*md1N%?L>&ls-k%dycbq`nADWB~;j!;Ma(p~F{80kqYFG24m~>g+{-lw6=D$Ps z@@~G6YMsel{ZPjD(}yxJ`fi2pqV+ca<{In-Y7CRRY(`jS2<*1!0ET5)A-TS?t@!47 zffMq?a#oa7uV80Er`6#PHEiki8~f3uLU)nK_9c!$S|^AZtNLT-_dA>`lkPDB4$-VL zAN-LI`l?VTPOsN}mye30fI5?#MC{Ih5#>Q}lhu>wvFxB)9_Q-++m%)Yl?U&Xi`kmx w_WAU&DmQ~)Bxy3J5YT=4ze=6|<50`eT0exJ;AeL<2tq!vJLYUnwaUy)XG=L(Aj`l$1fQA4742{Yj7LAeQZ5Jc7%AIeD$)LJ57=+0v1N zx4OG|2%r5m`mR;R6cK81f)kWJWhnTZUv$5qmyBw2;?Oy`kY)ui0Wl56dlM|%Q*K$R zsi;JH-Ff_k$OX_DqIjKF`3w+WSGma(rT^hJw_(^W;2n&MT zJj;2nIs4*m*%j2d?xsSZ6mFo}YKApp9_;bHdHzrhS<4iDxt!_q%TMI#y(-9ni({qn zpz~-!a+K!|TV>t3(p%E^3Z}f(8~rXXjGf-;@&HB)agqruW~Wil*3JT779M1vwn@CTYOQf-u==j{kJp`4F4!y^n*INv{V+4h^PWgU->3G z;yVT(ow~e~PPz~bn=lr{r5k5Qvcu>5p{6|+FF^2Py1l#3+pTbsZI?e#+!bljve43a zqG7_9nu(F&K2%)&J9k9kp4XBe-S-QP2fL{oO-SyQ*tnD;3|1j|V`JLc{gI$k>rz%^ z0n@4t7XY9;yFWE68+Kp2R2AhJj`nNb0iW(_I*d>;WWS>}77q!go&wObjZQhFU)rng zivk7}5iA_qXpai>%AwF}Da_l>;IYI1AZsbAdlMQ;N7gN@z1$8xcrsfv5mtNeEmTb4 zB-K@z9c2Mp)E;BILcstSUhM!A4C4Su^qi7<0RWZtw^v?P{9i)69s|^sohEZ!2E$0u zs`)6D;W7#d+6jVB7deJUgAw~;VR+X6OX+2QJlTnw#vDfG>kFPU6A08sCR?j_=(~x3 z<#gzN7fto{R^&8_6de8XOE#Zpvq@|vbXSt#(-kP;4louRHV}m2rTj18KUpSwLJjgUNP?&_|iR*8J_&sG&Axs^FLMat3meMXS#@e z@_SPZ6fHbBY*breVU@O1t-&joZ8Zt;B*rIQ%6+O{%hv$>*J@hP9Rtw zF#9^$oVAXFg0f#c63n-_qTg6eZE;dX+VMSQM|Mf5tu1HF*?aL<9{><$W~!MMSP%a* zw%A0{c|8YKpfC8zfn8t_ul5uxVuW-&CxfWAx3MM$9CNz1R|Zj-W*JZ?b1so?4KwL9 zL2h1-IP#o_8NucvQi9+5)(Br|;(*Mfo-^!4tCM|Os-?8Xn?6Y-h>IL0wi;-*95cbwsT z@>DawxDr3=*if0HE)VHf;!9>_MF(jQSC&d9izVZk05rz{E$K+YR`LA@*Ncavz8r{P z0kW-`*d=~btIa{dHD8c3;nakO%>G2)%+}=S;;>#IaLYFXyG!UZ(BbE|ZJ-k{?X!*Y zFR5(Q@I4@a*Nsuvvo*4pRPNiBGiBncbVen2glooc?aEs4vUdQ+V2@w;Ti?s_C*UI2S3DMEY0Dzru|SQ@DI4ock|~|I z@r3ZItD=16i~Oe4z)hWEVW*jNf29j2PyN&RiTZ#x1^aDc)ca$5wPG#bL_)Pekc!?! zPA#YoKj5v@>zxpX!3jCjvl;7ON7;M`WY=SP^$@<~3DeQyNUxHFir7H@d_{q&u9WSk zErO0DE;$XWk!e0F+~KTe=xP_Safax;Uf&~^FxuFIN2s(qIZ$_4-nzuXn#`-8v6V}q z5E^&>trb!IG-`$o+&v@%uRv{;5Nch5n-h|FG>z_d4R5N~URy#ThuD*h6RUrD>2lfd z@a(|q*HM$7RhE~cDepb0Gq!ZQt|ECW*Syo*nfiI4 zuh#D-3OZ*eUac2Ahj`Wnxh*^-#Yn!ryxRktblW!utY)%ld0i{@?DoQ7uDbI(an#IC z{jGC9fU0{U9WUP$Y$fPaEBV+-$s}^if0sx&7y3TX=P4nzB5ys+_(u39y^iVW3{z}M zl_oAmEt{;2R~?%28cHyVS@0<$@98n4e~1{-hzQUg9kgm(+h6}XJ-evcRNs{0DBhV7 zneQoHjpemZk-Qldn$6Xzxd**(P*MFA_#{v(zsW@MYH4wBdd^`$P9`tA`Y(W6 zeK`i6YQw?WHzsloDL~AdK=alD6M8n^{{k%1y)Vi%x`CPPREypb(XTT18qlR}92k2% zQxf;9{Gj%GjqWFZ%yhZV-#=pnGrYD9Bjo1t>fRP}O(ZX{h{9s8Y}GIrWV}FYBQn`h zygCYP`Ph(s?u9i5+fqz(C;)iJnQQ3+V-(cnWRg%RY@F2G8k22V3+u;HR9jQriU&^gbc{&F3V*6(Jw z-nwrpv4G9dTdJl=21uVGu(Ga03z~M2_8uUpdqpk di+&zhw(SRrhg6h|ands%z@Kn+sI({D{4ZT@n~(qi literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/png/48/Bookmark_remove.png b/src/Logexpert.Resources/images/png/48/Bookmark_remove.png new file mode 100644 index 0000000000000000000000000000000000000000..866094498959cf83686ad3ac273d5b13bebdf74a GIT binary patch literal 2736 zcmeHJ{Xf%t8~@H~3MJ)X9Cjp6o9ANeWFDf}x;?asButZ>iOCk)4lNN9vX&Tms3Cbc z$z$BKoO4>8!mP$79`}GG3GS zBz+X6Zme0r!r`o|oDoY#ONMaRDEUSCq`S=7zZZ2(eoIgW49W%| z(37dxcz~SC-(t(uAa}txBic}ZxzJjdo}OIG88*4of?#gwyuO#X!P>7&zmj}~qZ8zH z{(z3KB(bDY^Ese{rG*P7>x?CrjzKFx%VCBvGsyu=jl+EuHY=rg@|#Js!sA#%TIH)(f^ z-DBJ&?S8G@-QY6g6u|9_wPL5T8)`(y?t!0MwYm~ zA}{A(REO>FpxD}Yv``2gtdFnKKfCq9smQx^82&SVY{qjBlZ@j;JjdW1D)d8P06gkPjY&l3E!icz&Lr~?QIhV=uy^*UBv(-tKPcx zjN&>ijkG-#2WC`vG&WcXYM7I?wLpPBpTmU|0+8oMr`;nJ=%Y?y;Xk+ZFO6+0`C3F^ zt&0Uf%uU+jQ_Lq+gX<&c=4dC-8$K>26by-fW1$&;Hc?x0Nb+<$VbG|Fcp5mH;sHvE zI$L1Pf|UZ=R=W?HDrk=Xr~M-avKafJ{|0qHzUpO?B7N104BcENX`~`9d@3b_(`6iL zBH_bdxiZIC@(xbB$t`5CXhMVw*db&+{gY|)tfk5*q_#yg}_{P+uI+-+(J2S1V_G7~s5%L?VfH%=?v$MQ~{ zP`j~D_<24?IrXhvv~d!X>DahVnA~8>=ctH(&#)+DcI*7H^ecNRwhe#F$uE7sMs=J? z>)h3snBpu#V;6KbqP15hF55D|e@fwRwm6Hr{KzD7VGFO=!&;=yEGrqa4{^btxCuj< zzWte^6sZBX>rCiODo+hR*et9d`_vp->u!mlcw)s3>|w<~aHsKHztO~njSr`S>gDs{ z=jhdo#CtKLELg7frEy#6gj@ZLAF+Q2GY?rQ`(EydvGEZPnyJ1fGBSXp?R3B|i7W^$ zr7pOLhO)n6lX3+IGN?Lmkq;u};_NY+&(OS=E6BHin#l=imo?P5(tE;K@xw*EIAgM&dSevI4Q5qw2iPu227!?1BvWUa0c8cFEj8G&VB90)BKpY}%`o;t z(zB_Y5+qBn0_oS+(@pdxU6U8<4-8j7yC=}IbAvZ!9GK~)Hn)XbM>X$Wco>Zr501|N z22d~tks`J)gV}{reQ7<`^P z>Nc21;DBiqWn` z`|6V;|NnP)56IYaLDg0L-DYi>b+M{p-=&^2JmY8hu^p&uK_MTCdl&eDxeH=hncZ3# zLFmlK$BY~9<=l>y*e3IG5A literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/png/48/Check_circle.png b/src/Logexpert.Resources/images/png/48/Check_circle.png new file mode 100644 index 0000000000000000000000000000000000000000..b831a4be433c49515468af7f5d0b0a62a7dab228 GIT binary patch literal 6610 zcmc(E=QrHl_x5K-8=X<2cM-iu@7#=0qJ%+oq6Q&)!stYc5m6@*A!@|vk;IJNOGFEa zUPBlmM)&jm51x0=i*xo`dtKK#`;@)bIoD3PXQEF{!A1c905!}&*Zjuf{?{O+H@*2! zU$Pqm3NqK%25Lt+wgG@O4W_GQ8RqZ@P1fkAf4}eg4jnO7i9j(D$&)BC_1{NxzF5O8 zP<%3}mpND~LK3bFo*>aPykpKs90N?~FhcIci$Duv!Ovrh79$T2+C%q4_t9#9hLt?_ zo7#hk{C~f`)R1lP$dw%!P^xpHDe~$FB2=o7tpNeN2sttiAk`u2%@-n^yVEz006;9_ z^x0n;AU8%Y2nVX$S|<#s01rr+M?hq_lH5h1eIS7K|BW;_gfoS=)s?2kV>fe-ES5uS zo31ymRaBo`Gr_KTw+ol|&!P|g-((-L!rtT@P5sqz@JppZ9yRHQeU#j$Kt(wlZ_yh2 z%T#T&5YYidSPMb4!1htaoWm9mjUuo@vLYmCZ#NO#xsN)yU-*)k3UL1Cx*0GRM?{1C z#rou6c_`u>UxxkLUAn!BTHxDeLM^CaFbeFoL{2KzW8&L)weaP)k5tGXU~s1sd&W2ABsLH&;e=a4q;%4Oq@WwVH|*yrKc*q@($^X$3f& zrC=xiFiBS2wE^sn<#xC}t*SFU!kUW=t7ejLF9O~cToNib!>ulZh+MJm9_ z;Gy1U>((t3*ZXIz>u{p|hv#Ri9>7n{i6BAyI_~g-HG?briN`UyyEF|YO5mkU0X5@^ z5q(?X-S8`$385}p&WqecI3YCgyf1Vn>SEtNLE1(AaR^KUvrcG0MVU>|cj@KmD@A>= zNYlEe+cRls;~u642vqu9!_2mHj`|KZrmv0`c<>&Udnc->DA>eD8p*F%-tDUN`>m#^ zqhe=k&2;7P0!rZI_hH?kPmcB44r)PQ+deM5J5u1%V*SdcuupZisl@weX;qY3h*aiD3yL~)oH;|8z{TO6@u5z%=q?A@k4Gme z!UcSQgltjpV%vuC{n%wszt_AelnV-mamWpgzPqmw{D z4$nndqpD)Ms?EfAvUjc5HKTvpm6x*cCd-iUx7s@AZ=7!_8cz67Hd%ko7X|@;NOR4e ztbgj(JFe71_hCE+;)NBD%_{D~XZ4*e;u+`(<$GQtK&!jdFLzAfb{ER8MIi2@LE>`% z^_Qh%RvY&|moF?qGhtSKI!!yKARsjBXtzUAG_kAX{oA4e@2D%>cgcKMoc6eL#i@+A-4=I%Rj~24E_pYue^`- z0G4V{pA-I;MVAO5ZuBFkca5e{VH5N@M zAve;SPEL<*A5X1e(p3Jle#!6Dbh}eleOWcIU76**Gxcx%*D}?*x}UKW5m%GU-)NjQ z;v0+=CfNaqj`k$jD9(cX-~2a*x*ss~V%|TlTMN|YefY0*mQ=2t5*0##)6P}t60)h>SNWalda_1>i9=r1%M^nGsf*1*6P8ZPTsdhExxM^bq;<;Wox zChf%w!B|*3%OvYiyowg8%~LSW%e4S)~UU za&>$kAc-}pb>_q5zkZ>ScEsFEierisb$;GUmaEDqznZ@;$3-T=InCoPwDgFyWt5O9 ze<2OhL}-s*3hza-H2mrhzHm($X^wi_qZ^ENF;e*b%*hBSV!5!kusWF5l0=)&>`X4> z{0-0MdAs>uM_94_QI}!{_VSkDhHFXX2&LWi!hogb4sV6BhQ+ZLDKD>%r&x&qj%Udt zcvfmR&NB-I~KyeVMu84=W(dS<0+AE$i^AM}R)_ zyH^{B=8k^6Z|s?E@{3gAK`5Ntc(OPQ`b@c_BcVHZOnRi3k}wD=30QLV<=u;V3TSv# zx{1%bkQtaoMj1fofXoFa`)^T0u64;WUD^VQ%UovZ-b6g>JDKP)Ny3VhS^D9SPhJtJ zXPB5e@h-Ukp8U-89KiEBlc^(5$!Tv%PJ>4EcBx(ca9Tf4x6B7^d5|Wt2UN<=2>t0_ zHgpSHH9XDESxDpwf^oVJ%qMb7o9$HXf^Sf}BN}%Dix8T-Y$k{6I8M@;nOiL7)_*MT zQ37ACo;?aXQBHC$dD*7`bgPWy5*0zzeU6BhbpsITU)-92fNI`%y!kp}y74QFqS|n7 zhmcU3;s$?b{~pe06}lJFqE^3yS?n_k5(uu;0YU8;!I|D7t1Q+lHGB!WCO6!&LRY< z0o#}YLL}@5AIB{G#2Q^Zcst3Kn(rFOIAU&_pwp$c$mhGkp6r&4qzG!~y<7OLcKT%Z z>3eets}t+PjZ#QqwB({)tZ z{K;1nNsVtwJ9YkXMzdILc1>{MKy06e?+(6QB^{v-2OCbX{%6A@vQ%hDRV)D1&D06# zM4F8&T03jOKnP zZC}8%HFXwv`~%)V-McwpU|xiclQN5*)X}Uwf+H^$FB|CwlJ%mbx52Z&q9`1E1qRG; z$)wD1Dpf%_7vFOSlY-~?kJA)zAl2w%?}huu{ZEwk6u?&UfG|5ent!`uw$ovB7zDL0 z;_!_e&Y2OJR6g`)`!1>@b2xjzoWfv70ZcRMhf=0Yy9n*9uP7n$*c2 z7IX)R{X%HHG5}BR+OJa|TiOj7DcA*z%jr! zrZ05L2FhR5(rDu&!T<0cwiM5w_H@z~dd1@?^CWrLW;Mglr=1v(@V+p|$L69;2XTcx zOz1ZJN9MFI{z)uWnT>744hHX`0FQje`h6O>dg|AEf7h7JA4_zO1-@Ox7CHZ_H}*0F zkTZ_(!IE5|+on=@cWJ#%feW!Y(L|(Yg@S8Jm{vEn;mr^@s|!RIi>ek*UKAVTU zOojqW|1zw5_YqcllP@M)cnO_?Oo!Y z3d?W65JPf}jm@85Z3`6;GkK~mv%Edf)76?!eKg*mi2;b$Usnvj#FK-JZHfO*B1yGi z%h-qgqtLDv=^;A7J(Wa|+dNSYfRxX)PEjYU(9dy+QI54(cQi%s3v)}?mZfP}&&TC* z-MEFywT;&+a)ree@^|!4A{A-GZBCXo>JLcboC2KNliyx6mk5Rc%`}j7O7$8>;ca7sx|xDXWOTT(y3$3J2MY>xzWP;3f;B2@?sRr!Szu0mjIC6U>gr+OPz8QBO-_> zFhdL}uA2l8%8J-+G)jLwq?4*+1Qs+-0v&$T@wv9?$#}?Fw@9ajmX}E1a=mq>_+L;_ zc<6&~&&uk#I}E|d2UzBqs{9Dq#H2j`Z1P_+8;o?V_`aInD;Z*=DBGt8&#InCbl6yW zlku!yc2V>5zI?vk?C+`E=K1Ibr!U#l9y^U!rse3oqux8+b39Q71ax&Mou(&tFe+hL z&*m#V#pxc1DK2dm$OW|&?Bqx96gYKzz?MQUJBFxbi^N1okU@!zFps-wq?8kxtb;RR z-qZsv^N*7e@&e^`imSff{;#l+0DL zehcRY9Almi-2InSl^3SKJ@WGTptr~M zY1I^IK`_TFrqBJyfwDyVT*{tO+z;-MW;o<3>W!kg_&3CO~@{o(0j*xFA4K(2g;&)~Kt_%6rBm|36)x*3J*RO9&{ zuA_*tkr_iIirNxumeo;`IGinL0e6@uyb%l^S>g?|=$dm=>8K&xX9N1+oj;XcDP9Fo zc{AM+4SDd=hXm|vgO4wG7vAM?u>m(>Om5h{AMj@}GdrF{wBDm2e#$doNuxvMK5=dCmIOoRmcG>jHzBJvv2`ouE+>MP5jx?piN*J z{8m)hz?|J=zAmA;Vvg|OBOAcO7bke7o`suLN|yO0iVm)`h<>DXbKvm!K3?MIdZd}K zS?Q1*VfZGdbAW%`I&D+AM%JHuzQbVMFb0gN(*%^5_D6i$TKEmWsQBQ#ZjBP*X!?zy9 z*$6mVdJqi$%V)PQev{Kysk^EKDG7%VlO^NJ8{D5LX&$wZ*Nc=G-ab5ID(7kyN9Hqu zpj46=%4-k}1CTpg7q6Wu2(2n|M9Bvpz5X);1~?b3Csqj@9UUZf`@N%)6vU8mngjQ_ zbj1b-$(is-3aS*2Rh`7Z*}sS_b<}ION;q&zG35r!w7%KiYO0GdbP@qq80DInKu<2 zBB+yD4{0j%eFWeqM@~mvw);-1AB2geNxxEyOb%@W--I4QYKva*0;!{r(xOKLem*wr zz|o_B48=6_Yl85w3l zQ9(FkP(+=K;JXVY?b`XWu)v=B=kQ$y7s{l-JGA|(Zm@i}-OgjGM}AK~faiD`wV7Ae zGwqSTa5ryvoI-(oV})A2xJ=OX+;=|=krbJn)*ET>_zD6DR>YaAs4@BQeG4|7NcR^` zzuN`>AHQc*|K)wz{FU~OW-#!~=AFUE*3*|U^n@qN1p;KrOnSq2M0rKWTC5C(7okAf z7@PKEc_Eo`r}S+(P8$4Fv|XqEtMhEZ;fKunwnR(yI?8340#YQI(x{zhB0kLypP0y` z>=fmBzbU+@$@O79ZIcHOz={Txtk;m6+laRIP72+e$z>owX)2RcZ)K%@chB#`ON%Hf z08f=+h4gqVN*|oQI!^e&^z|tN4UcJ__@c<$mXFk+RM?Y+NsXse0FJ%L(VStOz9YS2 zv`3tXfqA5wV>reG*5<=!@q(P=UBLtba6(N7uKN70N_zpl$f$KQ<68(u2hm z%B4X#vt(pN*lGDVqvLan4W$I-r~gjR%IU1Y#D=xChl_HpH;}N_gTq<(6v_s5S`PdV z>Z0CN;M-;LVF4dpHQ?`f3RRl6aGZqNJs-EFe^;N#isi#1wza||%{X{!ctd46Veju5 zJ+FKj@^0q{07wgixQnA0K4*E>O1vwUzZkKqO$*s`TaFGKO&8OG9!@QM5dEsB7!e!%!L3`Jpv|oO^lOYaP z{_^grg#4={PQF(u|Lh)&b2t7sr_3F3lYUEU=xN-rf*Zr{*a#xPh z`yE76j1D)Ef{m_IN*)!R7PiW7P=$y9P8p@nJ>nBkD}RNB7mwn9k?0o+eou(ap2$kb z(_Bz^$&wx5jD`Y;H$zmskVR$B5E{uwgyQszlI-p%I1yMn)WAC|Y5BEYKLM)iJHt-R zEh_WLH1<6ykoVlA;HP=z!^uMCMDap{u_BwzD6@?o&iPBbhb)*!E4-i@#s8KM)mU#d zEhh=-jc>+_t>E$>&XC@-V~R(aKLkGRLewKJCw8vh;``-uDi$o~LAWwB4Mrk2l6r{$e4GAyvne=OqhTNPn*;#Wx|`{ESI?fK~Ali5e}d! zhY1$SWK!aN-!nMC+q)b#4`FZspbYhdU`Cn! z25gmv^cG#sA?Js&_|?xUKDHEqRqB@JtW6R9(~PvdgkcA~weO86JRO7c(_Bd}+lN5Z zMcjrpnfXuPWH|3Dhz9x3jI1ZKHH5Q2*{f-pO5~1DCtFfW%k}`fTZMVY2x%@gmabo= z#ldd=+6mj>R|S$ZR&{PJ59E}9W=V~<6FV{~Irx-?4aGoB+&EV13*2(gPkBTI2yv`V zCF4{y`N#6gI3=v9X9m)t8lopA~D zqa^MSO}g56Pxt04$X>#a10g|l^D(<%zOIeczi$OZ#hJl)v$XD;`hr0k!S8$t`Tx~} bqXm76<+&VA+)=zK(f}|$6Wv;Er`Z1k@e4R} literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/png/48/Close.png b/src/Logexpert.Resources/images/png/48/Close.png new file mode 100644 index 0000000000000000000000000000000000000000..91246b9442df970b6c4425974790f121df06b1e9 GIT binary patch literal 2723 zcmds3`B#(Y5`MElK7&9kl|@;?l?aM#vWSF`fD7b;Y_cdV5D*ZJ3azY(kdOv&FO5s6 zV!#$b5J6nnml!~L3m60igenPKgov1rvc(#co1Xhu-21~jGiT13XU_ASGc)hG;6Ptp z>?SM#K$q&bH&o+=e?LfDV?+Nqfzdd`=}=!EQ2X3e1^_miy4O1_D`w%=Kwo;e$uozL zpM+og9}6yWaeCNowK3pecZ$LHMavkshj|?1^YPcWRw+Vc!gC{Kd3fsav&n(GKzWn%u;zMm*n=OJ8{O{53PyN)?Q+M;Z|X#Dl&F1hDkG4?uZC>Az6G z*Fx(sMNahN~>tMia?7>?WeZ|!A= zsYevOG3z;e5YOSTbHLq;b&>pD;(GfB?%b0l|$Uk1T3j|1dt+}k1`p|oxi>va8LoD^L z@F3hWT9{(>C1R*2Ux4(!P200L1gGqQ$5PLE)Xi$qSCB%7!eK%4P@7wcUXDj&UcySp zZqxL)p-yrPfpjp0^;2~_NS%Q#KU84D$JSMx+m$&pdFso6bZL}Tk!})MZ3F@=@yVrE zYzwZjCXb1)Zb&o8y%`V$vV3Th#;lz^1A7y9C|Q4$Ja}`+X|`50xdp`F+U#V3cz2_f zt5W$!fWLd_m&~vOn^gh?Kw3bdg`JszU8cubmd2t0#ZezABF~LXY#a1yC0+J=bjGpc zxFV47>X^7gQlkaLw}iQrwZ*pll{xxhMJz8Zr^m0A_}-IVOGgTIIGKbu^*#`!*86Hi z8{j^~e1z13le9|!Jk3usP&wD;jbH)p%t;R^8IC(T01^t>aFC+BGXp&INnL@vXai`TP~zz7l{t%Fz@fKezRc9Ggj zR>LSoi_Su7bDNjJ80ncsL{>=XD^ZG={KcDk#~^XoH2wSa40nP#u8r)uyV(`ZRX-@b z;{O0u!mq|?X#P7n$QA-d@6-BmSzNWet6k4m-Q93(@xFr=sC4z*54DL>$TNz}oD(C% zNbq6x&tg1Yshf>rf0;5zp(o#XCaeZst0ZN-?)ts6_b6~@rY~|NMm$w`Q_*3CdWYoN=;zBPZZ`HSy+a2y z{MVDtN#GvVPNdhM$~ ziehtdkKQ2VrM8BEn^!%`W$4vuYmGPu;xWnAwWFD6F!+2+27CWFBcEkzj&s?0-b@&K zNDia&I(=uO&>;4^Z}KgmGdW1MHlsn0jB|0kWG3`|c}Jv=_R6hCxxa5pQ{)L>cxJFY zoPO0L(>pZDxuep?&GD!1CeK^!c|*4ymlPCZ7sn9q&dt{U`J)*7a03i#vc1Aak?il+ zk-ErUc9(BX_2r~iAwc5J21xCW#M>;1?zn&eetn`MkJh4JOF+-Yn+Qu&N4xR*&fn680EbM0up*06Vh;I z18_#9e*2DpJ2RqW^=j1o;?rU=+S6=2ai$TTw3q!l^mXL*UC@V~O{3wDub6ZCiR|9Q zpfE*mf2^G>5ntSiPSB$1N->;I&E!buEg3(1>Gt3qC=erUw78P;l%h**EIrw z)WI4DX%8?kY?xoj`h50fu2K55a_h@4Ynp>VQP}c`VeRovRTYNF)-+{Ju6tkOpe^7| zI@oH4yQSG_R$y*9w*iRcMymQdk8#V|Y+psJMZ~=)rK?xtd0%k^0LFISTFT6BkGe5u zGBfNwr~|mH{Wp$AP_?`rfTxvA_H#khlTN>uprOi*CljiV>pa(7tOzF=#)|aKf7d!K z-m~S?$8?^1i~)l_~Z$f03!3*O&LkwHHm15RN`@Q@Q`v>U|1p z?32nv+t9I8MhzdHC}E<6&y?`Hi9Ty<3Pmw5B992LPx)Q;(Wk54J5O;U7-$+-*f8e5 z)_)B);?jIx?7k_w|M1+gjBAi zm-iv7Wdg2?!x)=&h7S>Ws#ZVrTsL0vLYqCx;K%C{DROg16-5i+gU_^Fjs#$eL__Cc z0i{flW>yD4H&X~9Hv%?gQRWeY0B6_O8_?SU$eS8YZ$ko{9I*uo0|41mIiID$c#GPP zy9)sNe9-8k2BQsg5g&{I(ATB4(;AE{ePi!3O_7aPbgwM{i{_4;|Ix-0^}VLBN#(Ss RNb~Ci)O~?_Ykg>({{Trhy(0hs literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/png/48/Deceased.png b/src/Logexpert.Resources/images/png/48/Deceased.png new file mode 100644 index 0000000000000000000000000000000000000000..ef17ab647fcb14000ae9a3461ff99de55107b35c GIT binary patch literal 6572 zcmb_>XE@wX)b^}ZqisTzAnGQ1jb5Xz6+}(2x`-YYLDW^EL>IjiAvy`s*+fkUB7*3> z_g;d>Kkxhf`SN`D&0N=+`*-G?d*+(!o;l%~8VJ%GcWwXxNRcXv+SfhyzmE|Ay49X= zAh_-zuG$EBP~Jzs3IOeMq~b$ePm|3|f&*!UURP__t%SRTJcC~X-4>YOx5VTK;SUue z9>!|w1}efK0Rt%cx6y$Q0)m0OJOz#_F?((hDT@;9Ryd35P0gXx;6H6W=gop1?$4)t zHzr)CP6_;e9rayo^-Xxmyj-JC5g_OjowweOnG(+-!|>vMT9PBcme#h)`Vhz^2N<~K zK+T57rx{zIIX&1?@c{_``sOzIG-SZaY?yupq#Pa{hi-!vL4JEOH_+>Ke%|H*+-OsT z2_(St=8KD2N#M=}9Z5KVBD4Q&3NA@{6JQU#{W*|)$!?F3vWtaRpYuIbCA0@yAGhY8 z_KiaLH>a*5sSmiyQ;+uJU$BPzOR8f7$S_1H8-;Zl`Hxk{oO%+LRT|3kKNXb_pxbas8p((Ca9Xtm4)z7Aso@fzvTW!}%df+#Xf1^OOmw?+DDi?qJWFH~t59?UU~I{-+hN8*3V zJMHiQ0_inHb#L$Z9sFXuz1J@_18y2>Ve2a*_IhOhEj_d9bc`lvGnWsvd_INeGP-Nb{ zaE1o`sT_YKF+Om=V3kkRt2Ljv)6HaM-xx_CmixE68~yoZYpLw8kw2>Kb!*!>E6HYr z{TL2tVP92M?sJK5F3WEfIwE$wTf9reKpr(fDr6VJ-;G8Xw#Yi77}v&19PM@YrcnTU zr6fo*|EuD89ldMh2_}DCsodVUHU`;HpMRw)#mk4oJ3;-1zSfSm*lX9X%>p9lF#)S= zxwKta;`0c~E>w|V`{~)!*7Pm2o?Kn*sF|%cB-etcCGyQs%A)yro$3?3+q)9=bJ8^3t^52FUmMz5Tm zMkF73^-~p{Ah+i!N_NF3V`ALzhn!fLJB=z6ob{Y`d=`#8@%}BSdpIYAgUP)buZO>b zzxsinEA}$DbGe7O5A7Ll!YqHX^7Yl_3%WB4q;k(8Mclm8`jdZ?^a2`@yQW!)ve>|` ziqorFA`<_rq>(qh)RXrXBJw87cz)u>&GQrcby-fdZ z_X{og(?}0)Kw%vC}SRcrc#~t(v zYoDISXWite3VObhJu$M_e?fiEg-2M*JI2D=9QS-lu2%9g>^Z-sQLP{%sF$vI%c1N4TP?(VGfE7ft$$ zZY^Aur&^qT(MC%TCeNv7ntYbDBX7Sn-s*E~3>=uJeKRIRkV|`3`H9W+fy)l;={6Zg zWofGzwMNQn6THHo@teE7D$ugOLA1oGRNe7ZI}SPKWz?1!j*`%cF^u>5Xj)RoGzuzUY;z~B>?J$a_4tJGV_U*fPk`|afENo>z-3n$)m4w>q zJYXX9jxl25VOu(X_W)fGQH=vb$Vhc2nM*_IgOxKo{-XnrlsN^8zMa=}FYqWaC- z)OFZsXa@mxd~XM(61tN@cw2v&kiqVop))bZ&+1E(3;~u4KKZK>swjUEmwS)cyObnP{i%R%?@uNrgLXKSRZa8trIWLIAr)_J7aKMKJ zi~1pp6=rP4%#Mca9EkSwtTTKzr!l48WGG{J_w!I_Q$zolg8^gm(o>W~Z_Z`~V(3vp zF)3|P$$KgQ_RBgeDHv>`Ke&(VasOpQDz?79RWz3jMa!R4{VKl=oCzwQna`iJ33RU= zYxj1-O$c4EyItCfF~s{&iVDlUSwo1N+BcTcEPr9~uAYoo&cq?{&zcnY9Z!HWIyrH6 zy_0yNVa|h!+2;M`Te$SZ4!@6hQG!mhjyV@F+a@FEB33k03%^kNBqyn`yjNZ)UY45x@<(dLI{I6oQ5{Yz} zz!-^+d=SL*>!lIp2yOh4fXsqu#>nQPFORw9h)a4cA*hQ=BRkAWJZU$5Iw(FIomkyk znjg~`CU#k){Wd_c3i}9PTmHW=Y_>T4iRe6j<|HlPY(z{<*UL-PvXHVdzn)zvkw8V zvs%fLx{fy2)A~9gdhNEhXoGnpfO)babdzdMY08D9A(@T08&2`%AzSI(3B{ui0sg~? z@Q!FLrPg|Y`61Tbdb{fd2`zhfXb_`1QqgCNs4o_g6j_B^p+P69LVB@`3yz?AQ``5( zXl^;gnQv_<&UcUnX+=1^ND6+EzLb{eu`vO#``SM)y7g^QYX}vlRftxq2E*O35(2-+ zD=R#QH$|i+I%@r0HNN32;RBIuYd^oagD}d(nZeV06|b1v(tTdKVUN{6QC`kE zrlh3`M;%KopSbHT;a!!D$eAOsvf+#Z#9~vve~1q*<9U~(tz|cTUz|+;9cVWa+CR&h zua-twXT2MpUH*&LeF0~8|3yvJNj&3Wr*Bh!edPa*{Zt>VP=CbJQTK`Z(hpanf@W4Q zAT5Cn#X~{uru&7a=lSCcVrP?^SpTKlTerN|mEl2YCdcSx|MN@ZEt!@)oqYqeg_uEQJ-;na1NJiMV6;69Q{V zU6~JuNlLM#>Yi}V8^$lJKTF=7<&c5dOxOsmOhU}2pG7MtSamqg=Kj$F)4%Wrw5_F0K#=Q7h(v>P{PT`!uUOw`uz={)6NqWmEz-4a3a8`G|R zoWd;~m|I#9w8tNWL|I)g2Chx7=%p11vDsZeh1`JRC*C?s z0y+MY0;kby+w%YN!w|qc#PA>Ld4&yf zb>!{lIu*d(!~N>j)U2y8E_PsIU<5yFFQav}S@U0pUjf$TvTJeQKQRCP`4!nIlNug|@wnzI z`%IUAvi!d^xUSRC+`V1bc+Qd|Jf^GzfCt_!i`jIYJO3i!#Q~-}L?v5Xt9Mi3kkF<^ zF=L5(QBkcIK(ixjtiy5*C$#bgqAgjaA-|DYS|UHlN$20pgkZqR^WNTH%P9hq`l(2x z*s6RBMHE6DBKKOQT593m_lKS{EuGex=atzQl3#Ud!P-9spB&7wKrr50vfP_w;$Glu zg%u|zAezD42)-c>Fxanuaqoe)E}TuTcMse~a|56;P}+{Olu6rCPC zBEpQQHrVGK&f@gZO&fAWdQ*A?Y0mL>W|ry~Lx5O;`6LOP1zS!(=29-7j z#F@CF;{!3d7v5lHx%$f_Xg|C=AZslqDtA(LZOf9wlU5?T-k214e(H&iEFYJ*%#L8C z)O*rNg*A%|MNzfnZ4zCEiMY_1Ge0jCaC_s5CqBdvx*jIn>KN32m^$|*YcsQf+ZFvp zdUDWQ3AKgWpXfH)jdq{Bn2g_Ap8A{3SPy%)XwMtimnUtx&CaCF{Tl$OJLdVXcdqX( zaJ*dmWeeX+${=;A&iQ74%{R6jz$FCDl-F11MEOV<0AJBDa$0hdXgq#$~m88?&q7E(cyGIep~Htc5Wbu|bwpU#~M3UJvTJr3cUR)`M_yPbmdbj zRlpH(txby$6$?}L$8sed9$=Q~GbSE{BD`PWZ74xAKDWOg!hoOU-_Ph>nY7Gug20z1 zzP$~7AfC zJmz|;uhx2+9!CDIu!t1YaWhiy4)HmAZM_qKP#r`CvUZt1VGoRO| z;GjIcv%rSqX_DZI<6nd*c_w}S_{(yBj0qj^^c0c3N0Y&i{0euybqu2K*N3?ZFRxDo zvod>-a2e$7mRefdnz91+KMEVghg_H-8V$#1Qr$@Z4OfcA6euPxk@;)Pb8L5G%(FZ777 z9X@Dc-GPg2GV8HyXQH85PAdH$9cf!S5h?(axf)UIsAgOvLTy#tWmbl{W}I zAQPTC%7Sq!H(>3s@(B(HD%_gb`m_ao%V;U7Hc?;Dm-0PTps9PX5Du_8s8?JCzg3%h zjd0Z1ed6ZqvAYBpV&(}{b1qKb+FI=#c`08;t()&9joneIwUvn{F^hWOBd3Y?m)W-tW%ndO8_R$(@%yK ziqJ~erisa3q>rSSQiqOE-t6)0sCJ|U{HX^R%9lM# zO}X{=ovpDk_@)fJWj!xzQl{fk*?|*7G#IhIYmxCZ*y#Lk51+@x7pzd}qW+Kc{9y>T zAWoAw(_>38F9Ih}8p4!wkFA73R#0q4h(g}8(LzCPMn|ulDAl8$6v1h4GMw_teb|}| zVCp|yR(e@nY*c4LG1P}Vc*1D~*Ow9X_BCWA*Ycvqx;SNJq1n*0;sWkX$1i{|h-*7nF z?UZQeAtDq`LC0Y2YwQX?kE*8%0sJiE!Es_2{I2$`$K`&6k|EO3LBA!dqs+AlurYO^ zv91&TRK%OeO+Ftt}VO>|37nc;(xkUw^fm1UwvJE0Z1hc#d3MG G!2bdDJWtU8 literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/png/48/Delete.png b/src/Logexpert.Resources/images/png/48/Delete.png new file mode 100644 index 0000000000000000000000000000000000000000..78794d0ff0ddf8f2472c7803f8c6beb691e630e3 GIT binary patch literal 2095 zcmbVNYgAL&6+ZWpKoSrV11>rk3BT)<0@Jb-AB%+W(L;?!&QR@JTEz*G?auY@H z#VA%$Fd8IORD$6#fG841r?iNODPU%#5wSJ|9Rj|9@ZYh46e_#Zo%ZU+OB8Ox6VwLJ?>0N9y?JZ@Ze@{fx4 zqZd{?7sRCV8ta-U9TDWCu4K24h;-**x3oIVF@?T}Bu_m0PX5P_)isTjK-)T&LOv_o zT6KJ^#Vw(J_u1+Dv>t`RcrAAD+>Ok!RXMNP0&d>$3iH*}p`}5$gE#UK3RtW82E|EU zOl0Pum|asm2GT?KFO31?+5r+7Q+GaiP6Y1yL+Zdd;r(^8b`)DW! z99q}-$`*%#nwL+W8i)XK4SLw+Mh2*+KEE)R0dNvMkC`Fz0JAkq=xt6+$y?>yajJ=+ z)fApFXh*p(p5i25KHCwP0rPv%6VEHEChMfV(v?WU4=v*RNufJK&x7qbJ56~t?v3uz z;7ri&_}B4HiB1e4c2ATpx@M;?q+(Ua%lmKj9~ihpLM=XE4l-v4s&C|GE}8nEY4{hl$twe-nBC!33fwX5Q}fN&zU`tRlN z>PruR8_DcC=uZHMkA5^eiqOmW9D0)%eNKc&=vrJ77b~iU=I}n0B-$f%&ee)+l5;5) z@!2;z2Kk8L@?5u=ou;KBn5W}T?)_cUx z`z{x2IS+ffyZKZj3hTU>6YfJI4@hNYU+|q5u*x-vVn+Vrbr6sx-CUb%aK}~i;K$Ne zJ}qs(+fuxPqScj zC@-1>+vdY6*1wdperrZ=d>55N9h}o9Era+UJ`l(h7pQhoN^BYwR1nx_xq^ z%~8+yw$0s7`I%k@h2Td|Er3{Im)BOyp-FNze5yW0caD(_|G`S{t93dOBvn##cfB&Q z04g;kGCN$K=ISbCo0mpemWiIMmu}ECgcdLY%>s)jytEusZIqH?Qo~NYNmkyz{N{)% z&ANNsuxs7-PG+R5_|Mz7!B_PR=?UWSXlafY!a7y}U(;}-0F|7@BdnrmFlt@hDC)X{ z3mh&*V(d#)jNO2NLt-*GFhW)qkKmL&OX%2^1vo98jjLYFMyglX6MiapM1FaBN|f~5 zJxlq;%<6_PiSb13!!~SAaYrf0L-dhq;J# z-Y$Lt)1%$;Xa|zjo`qsQVx6aZw~8?6tMRXF__bpBgB&gh!+o3=almLpMgA}5cK?q26lof%J#?JiinjihK_q*1+zy0k$?|Qy{ zdS`%-F=+(}0ARe$*NbmZ?DHbx4Lg7EFu@>D9N)(i$d$}70EiXayf*Jn44=H_ce_f! zXqWumy2jT#(+hvV+uI^D>(LsIe}rB*&8O^-6xv+b`L@Q(jBkO@yyR5)=+tTRlb8Hb z9w$(TM_)wcHB1j_lKShe56hjChoju}`v2%BKQ>Nzj85#+7U52_xE6Q6E7Aa1NaVY5 zKuNnI5pu+pu;^&t>!5m&BkiLSdE@VF!@(0?3<2SM)Gc)Y2RKzYIP2KlnPtE^YXE|L z-Ba7h=yKml6cn*^Z;-P+_t-vNvs>|$8KS! z*i}p+u)a=0pGjw>v*@$pMN<#MxLTZ+p|#TP6Z;5&Xq|S0Xiw$de$9Y1R$7XlGpozQ ztAX}tA+JC88qNi$@QPs>of z;u4_l%1|p9rJ;VoXDX&EsP(i^6+a9CBNv-4hWz1NqIGnx5#J9&fMmU9=*OFGT2oP^ z-+6bK-Yf76EN>W;4!E=yCmjqv$tIKYwneX~bhgJ|L*pIFXvTu$Fb3b=2ZuOhfdH<-Hwer~IpIn~g72o6d(h zM9^hL_6gYp=;zE+`V2`;E`4IM6i|*Xs0`AjVae!f=9@FRt|6`7J-JCsmbzh0)J!~f z=jAe48(o}Dn1aTuPY!6w&Asy^%zp|}88^|H8%0pgDliI1sE(MB&!w8w#*yRy9qI`V z5P8u_&sf+sbrueG6o8XLx7i=S69#(3Q)?pYAT(5;-BPcMk@5^N}K3;LwW@G z@n%+RGdpjN>0#s`eZSwy|64`(yZ}ev@Y@x8v61$26QySKL$1f|=-`xMY35>nX=8OW_`~XqM^&*~x^q6}VC~)gexE z$!@t+RF1^DjgiNf&yQFnWM`ZjHX7e9+6O55dHf$)l?Y4OU+aS6wu9++)^O)@@2Z(y zHBdKnbvnF}FoCUDX;MBk_Q8jQ2?1l?_4eoFP$Xfx$Gxy45u`VH%)u41sH@>Vii*~s zG8pq8?ZkwfPt=NXZ4(%5{Ao?|Ot0p(Ka{f$q)XyXA;MxXXuRn`n$NYbhCd~=+XH7r zJ$Ise^l!s+UFV|Ey6T-#$~A~E9bCHX(lFOCubiS*yn3;xJ5Z`h!?b#rlmzt3TTpkT z-&3eN$E*cUm}u_fRV|Va6-I`L?~!6!2X-Z(z?c(}q958~f=a<&MEWwqL-;xBEvphq zwU#dxE@e7&Dz60*^1zuwKa_UpLe_`95Mv2im?Xb!2jHEo-17l+05Pn)p9dQ-b7zb5 z(**|1tR8s~eAa-M_=DcAn*ky$+!S=kK&9K%E?-L`3NkN^#@HFkp5ItLh8Spc{(We< z0b=>CU#z~y0k9+gdTEuRYc4>Q)xr9_iiBF9#Sqr02^;@u(|C(%s9bIli0tr&pMP_O0 zqdLjmwIuYOY6Np5B*^x)=Vr%LPhfdiHkKSBud4_(2Sw8NzXk7zjWP3&`@Wbucuafu zli!XYZdu|NVE@=zX^r%Lf!9OjTBgpVmZY<~_re-j%_tGJ5oxkfoFBS$6G&Nhq-{5t z7++i0%)&lm%X?pi#qtS_gibE-vI(3ZLXasaPP-)OFC?$;`B_JUUqXkJ7 zkWQr^e*eSs;=Zr*#dRN7oyT?D$N9|INQa7ol>z_&Dx|Ka>9uY9-+|t^zD?)6$gT}2 z&{RhqC?8^92LPtKNKLf|XosyFvf6MR^KKPLfh$lL4T|E1>Q;bX;)0+QAR1#PF*sOQ zx4`-iFS&q3jIkZE6GvYdE2sxayWKLS%FX%!5-FTebYMF~wSzsFZ$a&31P)~f9y@G& z{3~wuC1b~6_Lm|BIfOB}ErfCI?;3_XpIg-+N{bH;u{zw%~jg$Fu~LLneVrSs7fZq*rtd#0A#(Pj*y9 z))fdt^LuAm1ZA=HuLR}#$_zgwQkD>;gjC^Kf9I*P@aAxsaA`uE5(pQ&3O_n4lV6m6 z2tH3MP(U^&70g;PQzq=0Ag{RBy$KHHZwFo{{+mgjG8FisN_-_EwJk=N=U=ZQ7*!b0 zFKQV)1DH~RoH#ob^zY@PYFl#z`!@Jn?1)(cds^9qY)9g-exvQ>=YZkoS7imVzw_$# zPb+daN=?t{p>4!4^!HDSMnr*8IBR%0lR=hksY&Q3JYgj7dcjNS9EecyykR(N{#2R|b z+Yke71=N!uR^fZtnzzrs%!Xm!6f79cCO=J9oVhK!4m;>^`T2g+I=n{H{TX0zu7h-0 z#@7Ye3XNRpVN5RfFPo$TV-LS@uXl!xnZIqAPr^ZU3T;2E*jm%r@U+z(s2wD>z|>S2 z&dnNm!!+kPkIcTd76#OvDI)(ezpLi_^UqW{9ormVZK(B071yMPi7mL9VKe_|SymU5 zzz-dLvpYdnk@VNRUG-Oh+~u#Z*n7sWR?8n5fQ|o-5s#KrwKu|57_fYf6Rq_Ddy7YD z4}S0H)$FbJG4B7}zyGkIkwKOb)KK_O9~n0ITX-&Vp<>yU)iJd7G_WfvzSgl<{4jbb zUIOYTjr3wDmvFxyUy)ofODAw);yjU!Pv>5gL8%GEz6l>9i|!qPG(0*@Y*A23*_<+i zsqn8;BCiNX7U-0v-=GTy2ZFq!!|khGltb#7ATJ(;e|pSR7yIRPkOb=T_KdQ?`puKM zsCn2us@R zo+Yw)mQ=VJYP zhNVwwzC}9~y$7T8VdaxaywNDtSkn!+HTyVzfZ|bo@i?F0MQ_ORe@oV8+?`*mMbrj8 zt*I-qBUNt=F6%AAMjx6hS`hOJ-W>S`dudF$Ee2N>IF`z_4lo?HV&1%k`l;L4a5=n{ z#b)`c&s)DOyR9{+w84F0_okDBm_K}2CbsSoaS~Gad+C|v6dY_c_h&r4x#t(&xMGVl z3Q&aa?OXD0M#~#l2jO|*bumWD3TcyAUnI6lhi9{*%22pvMMZMM*gsGzZcfC!FL-N< z0)Y~UaCT;4tNCjPv_cH#5AG?n2QOFXW1dN32fd0sD&Jt;)UfU_m@4zzu!xWTX;&cR zv^@G38S;6IxX|p!@3tEEv!)p(B8OLdvrpBqK8W?5oRj)T8>xWZtUqF6C$Q-U&bcXyqNUd(J+39(mnR$BPAO}U?c>%u#Q$#)g+@EZl{ONDb%p|!E;dk?c(%Lo1uRR) zC&NPb!APl|BP9Q=?9wn#?_WM|%aK)nkzI$wc?Q67!_jBYp zE1F(?5Oceuhk$=?j@AIJxD+FS+*WMQG;i3J-!FMtXD1axv-IMNs<>U|&UhEbZRix> z%+~qj8?XE1zKEl!GQTIhR94f$Tl()FwNs|u=5(N4 z5tPZBC6T(sC>JsC?%h7iK2uHyDl{~+#_#Fir$Wt3sbbK%2NFd0?JR0@q}0>w1bufE zttm>|AM@h@O}*Tt=jRPw)*oWpG?-aQ*YLRFJj*6J60V>ZiDZ~iGabXo6^9Lmf8r0D z_TR-#@dEcxV0UXF9C-+4;(hsb*P1+o`&dZbBG^C{j~GKo z%cCL3c4VQh4J)R+ymEl84_&TtvOO(C#Qm`u>?8rQ0%zpRj5QO7{#@hzFS>|j5* zCk=H-%X+&l>s@1;`KXb~I_USpyh=B#`?k>l%peymR}{>UY*$H>9&`1tJm)*%g*gr? zWgmV>hX3-8t}%h=4L0d_mlKCgcRo$qD%;Z{0r9+r_<>v@v7>-bny?Q%y+ zJQFcR)rkX?4R*SkH8+Nf27I!J2AYFx&OI3&?Sr+1h=$Z4%Hlgke?-u2Z6TGm9&li_ z=5>m8dZ*#&<|tKw+h#Hlc`4eim98@&R6ov*GgoQR&e^8c>HbZ_9Hcyvp4`A$UkP`0 zzuBL~Rpss^4KZe_`WNN0UFFeGcmt%IS-U^7xhc}n+HHu@<*s}I1b$t4$?4Rzx38jX0k{i-2ViluUMf~pkBCQ?>Z9R~q#Ko_Ypdp?$%dYRg~ zlA@oOx~Q+Vlsd_tpV`ytG-~mvdV!KWNFve`=SIf4+vt)b7ZdX;n4|?>Pgs}Q7*^p6 zSRri=NBm#q1_xm&Z#P~B-2^jVuKX)0%};dvNvOU7ayHyK-_}gr4O!`m;zPK-@Oc=@z6}-0kOS zD1A^RTBZiDdQt6|4OW?0*7DjPK%F3N{@}Jxvus`~>~}n9+WwGIg~Pz8nt&Jx7){?U zmiSP4*&SH*&~hpEGt<(PslC@ACgXnlPl%fjIp`fS*WC*qQ7DShXkv6s0_a~bN$R@= zJEWWi@cDG!CE$|*|D}l0ksDsddhdcP7QiOl5x%0W$}^XhRMjP4Sp5N!8avZ-CG*QsXP*Dxwipf;_J5~HLz1Mx zNh%fHb{06YTTa#CO*s^|2e-f852~&Sus99Nqz6gI&c#whnMh!pOTw#Ow@N4>=hcKD zaDS}fs0P}<5H8BXyX6Jn?SvvMuxqIRoPsOeQj(I!zoYU`Mrav8!k?sz36Foc$n-qW z6OmG935awa%u3jL&dY+tdm+=**3{q~qb5=?!se$5wfHPs|IRh(jqhOU?L0@n`K3S1 zpcpd>71s%3qW%IIS$rzJ9t}us7tv3WxsoPTlDb^)P+_-LXts)PDwa5{m3>F0Hy!1< z-wIU)Y9s}g4u0^)3%us??S(%UiU(4eVM~llqx2mQrZ_f|fS{q0dA;17pF-Q8W$pBY|axYLe7{vkpNV8tT8-ofQQa z-Ij#i_VD5nIY!f6`MS0a^_~d=RPx5e$2qo#Ut`SknmLYiUf+Y>=}F*O8a-)@<)6Qa zN#%j6u6&$dvEUH=cbpWu5l*iN0q6F^zia(8vD-cr(VziRWpk^@@g6U0YF2)XiDmG5 zOG0-ibY`}6lEqv$`k#+ZJwF-fjpqfZ4mhKf(|oBhvt*ejNtE_*Zg&c`GVw8iJ)6w- z^B!s>aQbZuV6ZA(RPUlqoUn-~sKB>nWuMx2;x)t`!C5ka=HLEoerm2ecd|NzKXsAh zR3+*<(11!)XU!+PLMjB-lM}sXtj0$m!ZQ?mddWhS;*_LD<16ZmMvwbXwJnVvSAHBW z33r9#8mm?hMFYz?~QgO#(W}&&o8csr{yJRB=%F z(ncG-`uOTCfLudt{3k@Z!mym_+WCU*dXkw6m#Os~jiFJ{>Lo~dkJr40xM7D1y{}eu ze>x<;=HHXQay`o%_*QsD7tadcE<3WJ=kS|;YIxg)5{u_gmMoybwEdRIHu2-W60-iT zHbdMjO+!Q&U}fr z4G)mhvAhaJ?Tj!t8&i(`uAwn_Pv)n z+DZl?tcs(G=!>@MBu{-jd@fVMXPLE001ODO0&TzK=lF(&t+W)6#Kd4CqKYo>KJ2`_ z|4Wih1ZJq~2?5d&g_7-L)i7q5u3ZnuMlW-S3@?r?(8B$An{%lH?CWPJuju{~!1WIf zDF`^5uG8?oKy%F~9t|qN4r1a<&g2!oZ@vmHg#akdZ_R2c{^hY>f1rf}ho@wv=FJw`es*BD3Et`coo2=jC{2rJOtt9Hp8n?KxgqvGy~ruvO9#jBX4-r1936un z95mx@@(sNU%Rq@h06H(|bl>hQUuRkum(r4*#<4a|j%w|1_Aoi^KicC&ywSnk|FskW zAV7#H9lybjH;-wfSJs`JIR&pg$9_dmglv`A%%v}$(PazqnDGJm;5#UAsq=-0s#UH$ zUCeA(_y=LZ66QLzkO~uZGaTziE2$zIkO;|N4=ZkP-rY8t(eqdJjKJR;aa)eYy?F8W zzq>Pt)nZy)NF>APEmAs&xkFlYN!;8m_hBpR6OS)lkMmkQ4%}Ko?q>kF;SK(ZG>1q? z!=6>i8*)LFJ!ZvjUBm#F)vn79N4>|%dm{k1t64Zl&i(xZnOF+MAcE3V@rD@UyhO*l zOr}PGQHl&aVqPIs&0vs%+cG|4e!$V=yyhk?cxA?3)f%_GI(hnA9k{3GR25h|8A8KnZx3J$P%QVz{QD?5HN%=o`%;^PdIV|MM5B6IeP$9#>wd5`3MJpE7K zyBl`oZ6q`OgfBc&tS#y|8AZdeL0eV66RW}Wb2**^3L1qS#5&nL*k(}H5{!FFMVmj? zF_nt$F-vRG#RNw_z7?Lk_47kupkP}fr057kK>urh(#&+X&p=5oWXfrFdE!s@ z#ZN~tXpN5!2py-Tt)y~M==|hP(eWg7KiU_6Olm~~qOBBvgxzGIU*!hL zREYID6J8*^Mi2+yFrSBvJOYl1#o*4?^b3hIw~BMr@e^ED8zaOQ4Jj6;VRuw=GQ!*0 zw^{LmED&60ZpZx&?R3(Z-E{biTLKPsmRrgapGCuViGo)iyvg!t*Ga0A8Sxt5V+vbR zT`BD_#CL2MrbuCY_FpzEG*O5CwZzP(zCGv(HS^h{<6#Fi@!v0FqC@cW!`7`^JnS#9#Yyg2JZx|%I4F;EYLI_XyBm>BI&I-EGi?Y}J8kR` zW72f3J1MAtso%#0seFDs5jdjcn?mieVv#V*yieW=D=en_BPRK5vM^>sx5MK4jAjDC57qh_H?RB;mOa|(U1Af)Y{?tHOBU|Sn zpBg^!Z=Y$fUn`F6`5zyuDP^=M#!vH*Vs#os_!UhO=pwmsbPaW0iwUSdWD~c1Ja3`h zBdlPoA8Zl1wo%-wKWIKW=QVxQVo%R&7Be}=%0i-mAAZ#ZB}=((^{2)tWjkV^*z;$# zSu{}ap`^w%#oMR&EgvdttZb3VqcoGE9ZtYUd$GJ17aJ`S|C4rR<5xq$z_%=#1cv;D zVw@3mqtg7H0`%LjUGg_1c$B!|kTuYF9dAX>*Ov~HRuk4Ik)^??=5C+5SBlU(186%5 zmYOf}8T{&Tw>t{HxK=M+c)aO+*^O6)x8ZZ7SG%h9>6R(IXoHfsEu6F;dr!R^BLl^8 zL{N94liTLevhD61VkVntjT@@m&^y4lrU#K^pL;4U6t3c)eog^hS3n6pwlPOsX`CO7 zv}*Ni1iMO;fx0>1^lQeCR!XGYAlJq7;W*7dMPCmnrz+ufGVWUAg^c{y_vD%$wUUgZ z1e$A*3}7D2P+xQENjI;}UGO!aQN@eQs&PX{hO9L8wf`3#yk_!H;d&_FS(4m)q1Qkg zP%7~vi{w^SaHSDr0Y!4RLGyK9ZC!W79VPlsfbSYGgAR+TIj(cqO4h3Ve@kZZ3V4Q5 W*q)xyl(?4C0i>3ZX1Tgk)c*l|HuK;B literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/png/48/File_open.png b/src/Logexpert.Resources/images/png/48/File_open.png new file mode 100644 index 0000000000000000000000000000000000000000..66e0d3365b4c755c41187011d939cd400371b9ba GIT binary patch literal 2896 zcmeH}dpJ~k7sr2lW-w=Jrjgr8qehC#=yIluoG>JGF{XqW8aYK1Lqn1n#wJ4-Z;={B zE-92GmkPOU-BfcjI*OFbq!b~}$SvfZIgRJM&->?jp7+1^kG+4-UVE+Y^I2;>zxDf_ zV9@RGI9(h70KdiFW~Y2b6c1Ka{@&T@rzT&Zpq+NsprD@A1HdfY78|QwM?Ly4Np1`~ z&wG>{m9(?bny5)3`tC&gkiApTMs(c|_6=4TdJGckIfcfj*feBXT|uI((Q3XzOG7#) zk*KMzZWV8jUHoJsJE${aZAEpfWsCC-_`qZBqSE-?VnSK5#^hncTYRn!i{|+zoBj2a(VqvUN4P$rjNsi%GQx z7U;qA>)2H%$@2eTn?9IcVsqGMArvPi)x<-L?s7?N>*t#_R;HNdLDy9p#)a0BOTvjf zmIap{ge9EQ{QV&=zhOu>$=~^bjKwe56fn}Fu0kzB8Go&8@^XJ!6n=p!j-%CX&qr|P zRKwnz-s6Rz&J&`dFEXRF!uC5fIZ0$b8*cbve+UJgdg|6(815!nHV^efrPa4s6imqw zQBQN936(md7vkAs*>9tkd-g2H;P&rTap^8^_WC_cG^b?L`;NDDrl+Bcr!c*ARm&T5 zrUiG@+}U-J(r^4+=-u#3T_s&DjWbj{pJFF|Q8>N7&cY&C$wB32rH6?eC9EzFjinb( zXfZE;!X~lr8i|eaN|*7JXe96AQzPEvHY4lUGx%4Z)(75n z^IsOOWa~_=HvZv7$w;h9voxLo8nRC+3b!3O@`81JrYcGyas5^eWgf~fcCgFI8R|sC zedF7Tk zcC6h^8`z*A)GR(}?!tinO{>R`M$clc6buh)#9U5ZeVb$ZF-84Ev# z(_9?>dTKPk!(7?Z(5pU73j_Y!&V2T8>+m4j{IBK{1^o*s8Fwb~UiRmGDv0|P+}PL+ z^6$TN`2cPQ&M$ukVXyWB%>A|lTs2RF1RekPe}52YrZ0ym)<451i#K_x#|eC3foRnV*@pc^~Hpu&=%jCzd!<9J6zI@Ja1|rL{oh@&Akc zPiwY9$4EM#wwqk4vkifcclEYClAi#bsPZZ%ia?|68CXF_AfnEb{zr2Iz~1q&kU$gx zE~6b>DT2{NadX8fjR5daV$o59s`PK)HG3Ymio%)IjKT1XcU&_P);my_f7C#>0-3MpaxwQc}B69Rcc6YF5LtUW&)|D_)kSKyOeY!;z`bb!`Zs{_XzejTp%7_c}^ z&h^aEE>x#fetLy*3x2Z*Gk_Ws*kDQEt-vIz2~Z})u?WO8uIUX!1PY0G_;oVpgOt8~*zvm3DT1$auP+(n|yDH5PL!iYO zoHS`O19ikooOFaBVy}$Xg9)-nB3q27)tEnsY$IdDb%qvRYXbpuZ*cDwRG~9gBv~*8 zRbCe$I* zSg97+(@W$HH|lF!+c_q$n9_jl4AzaLyUz8zvrr4p?isi=m3=(fPA))vcRd3&7V+?L zJJlbE9@p@(wf=f$EA+#<^M-K{GkrP|NSjVuRh=_Jd@W_Fru4=jjqt-qUAxVP0cC0m zh1@!dugW?`iv_nW^uB4zZzQ7T4{r`A9Geg~UoT;yRWHg7CW9_fyQ> zxeK7d$rgvf>?VBW=|zZdO`TIFSIsS*U{bSh@|AJUWZxi1yMwtcT3C3bqv@Uzn7kZZ z)Vu@3>>ni{zqD2X4^)6yCF%Qo((@zOs}n^%7IMdgnyhfEhnPlK`5uw^N>-ul3X zE1c(t=2I+bUvne)S+jc!D_RlVLJjHu>B;Y5(B_~#tZ5i`SwqF5&CYneEZMa w^>y}h`MUqGhbbCT^HkL`-$aG}S$Nb+AON)uvY3x$@+&gfvYBpEVC@U^MV_aSW+od~>*w^>BcQ!^H&} zK=^{g)m+2M;l2eXjRFAF)_eR!C)@=%FkBcoiiYnQm>(LFA z1nOLSP;AM;uwIiJT@%@&gMTwfCN%IEIIu}5F!M}cWIMsYoYKH(bO1vb?%Sozf`48= Us*)Cn00tq0r>mdKI;Vst02LsI0ssI2 literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/png/48/Folder_open.png b/src/Logexpert.Resources/images/png/48/Folder_open.png new file mode 100644 index 0000000000000000000000000000000000000000..5a0e780b26396b1032be1f5677478e8ec20101fb GIT binary patch literal 3681 zcmd5<`8(8I|39CP560Szv5X}q%Val_trTP53CSHY5iN+4NR~k%OKyeiOWm?$D`Ir3 z`Ls~7wOI;da%U+eYsfOsJlFFVe6Q~h&-24M@9R3}{d!&R^FFWZT<3Mo+0jafUy2_9 zAY@~0?!t-azXyhgGrNoi@p1wb=3-?E>icBA0w64HV@`34Jodx;bdQpS*a1Sup9Ugt z5gTl{xy3n2{n1r#gy+pU2q$JiN$0Pk$Nyc%N=mq6ZH}@M4EE6f5s65Y)~q^?7c5BW zq?-#~`<11?roF_R-8V2WcG!D*JEpZ}w#0KfJba+;a%(~d#w{In7aKYIJ_FbTr-T|D z8LGL+$k2z3cxx5WoK4LBJpTg*%`#1Rx=jzj|1qB|L+6Vc3~RD z(S0Bge8*4+UK}^(MVa{4b9<&%ENH<%24-1<5htFyP%}N4xX>UJ;@hi@ok;}yfq@*V z=|{+ZtK*Q6UUdJIay4J04y~a#cOQ4&_y)G0r!nNG(*oCRoV5)t7}~_3-)7$0HDRVzoUD{bglO3O7;^u@ugT483xqM^dQya$|MTum@S3Y4SmnPc0ft!x#BC- zQw1|00`$AkT#;m|Nc#7OqR3k2DYMj*shQs$wg|v#b?|cWPPP!517ZbP>cGo)m83%Q z>qW}^m=G(4Y4qiK0~{(ty9sTo>B^8yq|6->_8Mr;PRfH!*u+#3k0(lIN4ny-)<0bs zYpXQGctI>&Q&^=U$Oksm_9u7--@6IJ2K^^|b3^L;*(DQ)NGANEA;Zbz$XD&L_Lu#- z@wYDDjZEkJ6YkL1m@h1o^E&eDkugo@(ZNn+CY3eui$sYVelTs^Yx=V-SW1IrviAZ- z$RUB4cRNRzr}5w;U4SnWh&mqZkU%c-ZQeKDM238+LnC>}zJOgCnmlMA{jD!-Znj&0 zFW-q*N2Noz;+EX&l=w*|63e44ksK9Hc%R~WM5MwODE+}{Rw$y(ysB3w0RR6JT#4u{ zVALXjIqN9|-#UAYar**18hO$1_uT>do1}{rRyOJDAVqDzaxvHue7+;PNkIOrrx?5e z8HCv)kuhQSeh3|Id(+8D90c12N^m1l4zKh_x`{N*KpJPKY?ZX)>2oK~E5`DA{CiP- z;{0$n1~tm^32yqtkdBvxH^5p?Hijh_R5DVIAt$bDK%4%y$eJFF_o_VgaSe{T^=+fa ztn5PwXkgzf>3^`$^J*bg1;<(dPl(T1JP+kjcrI+(t~!L)$`$Ef$7~)GfrntaBrWjn zGSAvU+89ERkh(=)NUM`#a6-#9ydBht)t9?dHa=Jr2z-3mGuN4cD)) zGLFhf4Q+X8&+n(!XRq-ixmgvyw;FinTl|A<6==V;=DEPC1f?me1k-qaQ|jEQF z10#(W-(4_`F-t$$$=F2qnMk$|qVBrlC(*H}C8>3UUrz9Tr6^1;?f$xpr}sjve2KV# zw`VvNc_MKxH*7ax2uYq)LDtB$>8pgj?>`S2M?mWS3XQt7xRecc&&KmjV~Ptu+y?dv-fU6pb&R$~K{m=<#@qpLt`SDG5I0?OMRO%Ypb-OY_Bp zf3G(gXV7Eu$kbY;X-q0$Z?5~LEhl$VmE%El#ZKbdVoWcCZHL6%o4N*u z*zN0;C$={-=!dV1V9*~6wpUIYT0F&=W;F9aUP5M=u61R z+l0jhgvFNY3UO zJWCUJd@#W^u*I4e2Mz@Mp;^lPe5yiH$=mT4Vt}9<+;ZASv;VrEok=^oo;)ObX)9}p zsMNJCgo;MmUzJcz-*%l7xbiFT@o^mMiSa6XeJ57cK4+cgJed<^h&S1Rv;`!Si6b#p znn^sC zB%HGa72#@v9tYtf$+VDbcl_>ONOCZ@xsFg(@pqp(znG2Vu8R)O?_ScFn71zYnG#%o zq(2K-!3K`x84(bH<+M=?_6Z{C+*`lGzq%!<(n#LA!)t5${{b&8t zOnQE^mmC&7?>bz|mEmjLoBvhDu0k#Jt##Y+am+k1Z6I3o^O^Y5_&ZAauo2n!K*WA< z%SwTj)J8;WN^7U?ym}0ggQJ?iSb`OWl-766;F-EikQGkpX-Z7iu1y6W6|o(mAsC^foM|;+cUDi4NOV4(^nJ0u};vk(p9^WE! zgyqxL4iS1^y0V-<4_FUYWVoRu)b`piplR-_}>-&Ke6S`nwd1-|=x+z`v+ zbKsM)Tv2%-K=V-(sx4H4dnUGI&z*4jz0~p~j0pVLk^>T|J>pLZSi5x$Ic@b|f~0+R z%e}JkngTB9gZ!(fN@UNv)@Q>QuboHxBlO;Uc_`OO;#^~CS4ciG}?q;{0GF|)> z;)kcL%jl;Nu?D&)tJX00cF+L(m7{10zIZ$IqfRFYgt5uI&Q+0Ha;a|HQC_bP9wtn2 zbF^TYLCU$$hb9c#I!46qy^q|eh(#R zy4m?7lRZ*dZk>ui$5@A}S>DK?&G|HSOdV%Hub%2lxLE#9W$W{UWDYtOs7$7}Z|^A9 zT%WD3XvouWtdkJG@+=RbQuZ^y@rm&`oRjWxIS3!o4FM%HN&HO~OV8ZSOQwO^jqVgj z3%ciDvW03}o)H9OZW!6~pzNW1yK+ZOR+qmz+_-q>XitK~ZhGJe73ugy5N%EVT<}Lr z$_(duE728)Jo;w1VN4IyX8We~%o9uzQ`C6ei6HAbsl0A_wf^Njk**^|pR481-uq6z zGe5-`l$M3Ux8mH)JL%MWosnGg|5$mmd$;NC^T(pwJ9)b zHu?9kH}VXNyy}2tlX1f^ghy}Q{@=1M{|84E&xSP=!Fa#p^$m_^1U43q=Jlr3gnt1% CYLAxy literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/png/48/Restart_alt.png b/src/Logexpert.Resources/images/png/48/Restart_alt.png new file mode 100644 index 0000000000000000000000000000000000000000..b62534e8ecd442c6194be37f55882902511f1006 GIT binary patch literal 5291 zcmb_g_dnI|`+uF|&^ajQka>z@XYXVm2bm$+A{kk6tgK@kD+$TYh|-ai*~wl9nb~Ay z9V0tZNQlpQ{|n#8_lNtwez~9bHSha+T+eu8L+y*S9JBxcT-4RkG@(e+e+x=O*-d62 zUZ4n&pNTdGC?CAC0RWesbv4yZgY161r2Z73#r*glT_c^({XmCCNn_E6w-L-tRGsZC z$Zbp|$-L5-udrXi1}x1 zp>Wg$sT2VP_lF!i{-l7Y{?8!ez~kDC{k;a;7lB*q_>kYNM8c%*H>1(=g9fSH%xK`z zYDCo$>(MTf@0|=n9lz*vula~oWy)ssP2BEalMOwXUg>;G>{1#wb4Jm zrDmIGt&V~Y|5L2{K%lyaoUaanC$ydfTM@fZ=vp-KXn}i!UhI8R=K@&SV+4g~t~xky z+zX8RZZAg-YKT;1iIBf>$xa{sN@b<$XvWd9>@f0B#?4)LnCAk-Xv}((^O+{fB;^Wp#YDpv!hb#KF5M zd1a$f8~&<|OS%;G6Lz$Dhu)hqa(}A`tOQs8J4l<6peVqjBS1iRH_bnR$Mheo!|&52 zO~^A_7ZG**L2>vdpZ!Yf^L@z++D%`fY>+9oV}<7cBxpuOXSCvd*=N0r7eJX*YOIW> zMfEA+g#-)vl#Mgul}tBRinFUe;(S0-@^$$^CB0)uPTA!NTJY3rGIDWd`f1)xBv({c z#ZhaFzOn^TNTvHJ*V&0ls`%s;Tf3Tgcwl~}r*#5Ro;1A%^=PZw7>Wn5Itz71ZVI|_ z@-;VVu~yxVe9hy=-PBBo^0|kW72NR)7EIC2AlQhl3&kWfqM5kbp}_=5mj^Ovk4(R{VkR{SWn9~NaDg$d&H{Z zqBQvCYP7Ci4vQgJd@7Az+K;Op4MQSd*%Y7ey!v+M1L?|1*R6>2Vdo;w%^YEnw^^tz zF$K3mgChR4#1~rQ+&FzjEDei-@QrnJ6xa7_$?7idkh(;|kgUaNE|OFr4Z}w^w-Iwt zjSQabZ4MxzXA1HU53e>MZc5zYLH91*Ga!59S|}CJ7cCw5xqc720YM@85ydmKxX3Nt zWA&M*?pX!2pl_mQ3Mu%i)LODuSM7@RR{9XPs*Lv4mM~ff`Q!T7z}S!WtID@-sQ9C@{+BZeP<-qOLmoaw2J9ff}k25uv>zYT^%a$Aaa;YONCwaNY&-yNlO&p^t6Bo~`+(UETq)Fl%bs^2+UjRfj_yPrKu6Cv2wVNSII zoiQ2J&KWBFQoAl9c*_WTyG3uLiV=AA$2D?ll5g8xfO1V!JcsX~vT7nQG;wJ)u0 zD31%I;ix!irr0x}0^>o$VWkA`GHFLX(m?K;CWhJ`?BjZgvldMUBt}n%w6sOO8-55=cKolW9D};JRz$lDu2gxs=F?;3jS)G zIRyuPc&|ZudDj7Bk&5pea$_*u;Eerp(<^kyd|07h{K?HV^DZ=yKOdTG{e806adT}V zifU6$rvBzxFzLE}P6JN*Wo0IRKkZxL6-95Mc^FBMp+GehY!&0`GHE2=nd$qwQ5Ae5 zr~0+=G7w`V)zT^6sRYVTk7}@P+v@u|{B0-wAehaEHt^9h$|%*}ry}1eABN|>aML}8 zuBs<%tT?&IV11RF)H^u&+w|Nh0m`P??k$)PL#KaSLn4+HIlCFe(=f;C_>;?9f)@)2 zb?-xzzWd^s66N^Yvc;Y9G{A$0WL)y^IYGz?|Vp%kPQ%03m)LhiS2_qG;X5C{6MpKDa zscAgc0>*r2xy7P*Rk};WKO;d;)*Nq*q6yM1VhY$x>?|PF$WnF4UE9Q9UZ5@4&N)xR zA=Fov)#L)mYg4Q|J*dtnYJ~?DCl4lXIO`g8$Aj0tlpC^amUg(8r8@R=kh9Q@FRU$C zjUcEf8Et1vy;a(JEbIrugaNelY{|wmyO#B>zrjJsOY1{T{7aK-estG9p9%i))Uk!k zW9dI0bUKw<)=mzFMlrZ=8|*lsA%1Zte{?itUgtyt0p}N-*2PS{4cjL^92bAck_S}Z zb<0`x_lBg33}x^{qwnhe}A_xSuCJ@m?_<$TYxMso)> zJZC7PdIcuzP8@ zbh>hgyA(2EWOW!GI%v+s0I4gM3ZNHM%N#0lCl6NM_xc`B&JvOE@H*$p_%Iune*xU| zDt`PF(m|fT=H?O|{_av7V5p0gk?kIF%e}(z`0a%G0UGc%Lj(y~91j*`%p?yhiGiJ- zDYpakRs!+L7Ppk)q?`?Ezxe16+$#YIGtItPrN*o2T>c!rjH~an-3mqlQYsP;*(|p~^!8@P{Jab)ioVpg4oYSeT}Q9^ z@@D*EnRxqRjx_N-oJS|Cv<+WPG%28k2tK=>jQ0zP^)K_P=HqXU1+_D$ii+cmsp7pFl#zzBh;O%f~M;9dSaC>w3SeFm=_Py((5j9ke#Kh+C*nevkjzj^)uw#(zyQ%pVnc|WQ+0DcpwjI`9`Iwht0f79_4a( z?~ppOPtv)KP}C5_1K3-JQR#eq9QWdYr%drD(keevh7!k@{kJx3)EKJiBA${7Ba3L>HuEMR>N!6D3N&CmqT)yumfp`9{qwVZ0wI? zU(R-Mx;9wSb&>lcVkzC`hQRbS>}IgW zs#A5|ZN>oAK=Eyc`TK;AkN#~C*=Alq(FOVv4lK(mU>y$3HTbZVv8*g2GE(wgV9_3YubKRS{+v0RimMrM&zpE;UKs-`dK2stsa26&F5ktK8Ai6K~Xu6;w3} zw+J|^k7kzvvGGP$)fIhG94hUK6J&MExztDPwGyIyAm!#ooVG=i!Z({8I~}(nz@M_T zmkKFe-)M1Bafy3oUTim5O(nd-2k&1a=5I1t&kpzxhn@((MFYlluL%sg?Lp;b-lly; zGvm^??S!e{d<^j|i(6Y}O8K^ATYYK@twe#kgKU+j-zC#OW?M>Wa_q;fWAev8-~H%> zop$X{vpl8u)`Qq9Pn~)zjx)o0Lc+a&8J>*ySmJGjitnDn+X*7s{YwQrpkq{-o`C?>g!3USbjud}>YQ@VHmcA!cq3%OVy&`>?-nTy==U5oYGc1FR$5cBWH<8hlk%35k)w(Rpff?5PLwc|F2js$^2Hwos$xqB0Yn45B1j zX4hdzn&Vf024DbpSz*vu4^oiYv{7aR(!4R5#3L7WS^GhVrD%|$WdK(CYHHa$$5Aha z0}CMqJne|Iic5rnPq8q+(e^XE4)n&XznC2q?YlY0;Zj(Y9pJCRmAgp?&SNp(e!wa0 zw)Sjj+Jlk2;xAN()$BVthcSRl&+jgNUN27#@Z7l8;`*8fR2N9PeU+GG6}~Ki^Mrsh zx&8YVV0&@(plAC$1gcG9jYA(Tv literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/png/48/Search.png b/src/Logexpert.Resources/images/png/48/Search.png new file mode 100644 index 0000000000000000000000000000000000000000..9b5f26be8df06bd1cb5314400de4fa350a54b855 GIT binary patch literal 860 zcmV-i1Ec(jP)GKA zihXsCEo4|H?XWh23@a3{?<&|rh8_}86*73JBCO6KgNI`{-!o)rA?&)4VF0HqL54|W zQ<*&-d9LpT*N~xvsH#JT3pm@{ftlMntc~DgdB{*k)HNX=TUSrVmynM)#GwqVv9t!~ zx`TY&A});~A6Ia$N61Ibp|7kaaeLtLsrKAzxQGPpFcEe{K@ z-*V=}=3wuTk1XO+If-AuJjPcLL9ZlU;9S;heTKNyO5%0IJ>=sCacOA&RtM`qJ{E{W zN7z6Q+SY}ibOPp3`=A~n$FgcVT#05hG1Fl`Aeu`1sS{~z84rkux$3U zC$!)}iJg3mGI)Vt`oU+VB}{O5BS3kq0zND4qlloD@c;#|LJo8cA6IvG4?Se?KP7$< zjLMjX^fJDT&*`uT#%nByIvpO(%r zKpQ8p`_~>FSO5S6FaYbv{U6v3V{}Mf$ae`ykbndUNRWU82}qEDgcl@8Xl5idGZLB^ m2@SJ^hFL-b00000z@-D2#7J@ujJA9L0000by$<%`^UGzfQ{}D2afJ80jVL~9Rd;}4FWPs=^8aax+GL2rCVZ@q=x)qp-fN!06?mtjxfCId;U9!2<}?LC3nKR z4(MyBrVOZ=VEzpNFzaX_l#G!!dj*jB$BV{8Sp?+<=or2iDvW8+=*MksF=<*ch8m2@ z^f?fzGHy7BL&CeER34Sq@~A(mcoiSGH8mok8tKO!0W9Zxr(OFUvya^N8h-lD1{LmK zc5hvtVV(DyCKsIdC2r=T*?BnX>><|A2Ye?h-s7{=vf4(NXtC1TeIG4K*8>j+*nOu` z2b-TBZLJ#tkM5f{;Tr-?yKZDIjl)6+O$EY@!%T!;>pr4o{TcrMOluFo0pUk=?KMxk zaKBfcmJ0ddjKkWaLu2BW+H2g*g^*V@bzkWpdh;qS_jT(cYE0)Os^)f7*SG&S^=|;> zWyXK`ST1-GljM~$p)R;iXqN|mBz5Mg6BP1ls8fP6?DRnez%)KSq%^Lx4_mE~;zfnd zk_wzwhNVI6Y==AIhSzqNb5Eoj9I&}WJy)s5fJzMFl_lbj`~Ga%&}71JL9U$319FW! zW%ePKWF`4&ulQmAAjc}RLPOv#Uq3h-<(+bJ4nJy>7oFwPs{k~=={<>uG&=XuBxs0h zJP0=iM5jvT;%@pNvtmz-5U*;T34&JzXnUHOq7*1z6qk=C4BNWi+kZa9@Y<7MEf}%B zMY?CUEPglPMga~#m-4%mro3cPxlYd&9gIcH2xq3yps%$WQ1KG$*>$cc9Yn~oy*}=sN%JA=-6{U%I~s@gU0Q1Wlv)B7e)I?_Ufx5jYs7r&)tUZ?{qT04ns7$%83Ip6ub3!%M?Z3qv-Di>R|?_IRoD3%6KmR@+!;I-a7itE z6o&5qeE$!y=)EJo+jlPB#hP{tJ*fBGgUr7yh;_4v*62yzP8W;o`;?atJsg}m%*fBf z+;|qJcMai3x+>SEI$j*`EDH2ca}ch3>!bvbC3q;vA_VuMM;GzaWssk+vQu7KQeJxC z3EeGq_$hxUFtE|@%G>dp)ME|zvPgWL*MYXhQQwi2Fa$}yBfgkSZsobMAxvB$kJU#&?9^)TA{eq66fb^BIu*3HgC~RbSu?_A_xdA)m2~7!2 z1<~T#k3|P{E!G4!j+5ax3*Iva6fnAU*#x2q!ITVTJ(eEs*Ptc2mj|~L=ptU}lH1L? zRu(q6)cyJ?ne#xWdwgEPZ+LJ9eaOD}49qtxgoVUC7N((wOi`k%JPKAkRbZ+xT~fVX}TAl)a9mH_+F?sm{3K z_@Xu%K(>ON+L`=U;^?ywf=3@CXW z29KCloiZcu5Qa7zpR{aBkXiDD(VDWaavU)q{{<)IAQ(evtOu)A*(iKFAJd}-bvg=~FckD%P{@-YL#80*iOP-!@d=Hf4*x5aqpN5U- zDVkR7e>MU7aJ|Z-cRgIS$a9@E4cImc}nbjNSzYUu`6q0+@M`q192-&%fQq{a!&S zG8|{jXGqZq?bw><$k(4SKZwuEjj&Yf{Ei&^`ii5v7*uNR#R+HEj@B;&*;R6eWcjJ_ zt#CKM^5XP*-%ObGxV}gBoFy7{jHeYX^`w>E&Q}hO zOPG{8r-naHN7UE~Rxn$&AzzFInofPf>j`6;vdcIm!=h;40`fn*X`Ahe&R>^`MYh`3 z;pzO%53U_pS_A4Tx~HH1aoWf;0@{Y>VhSrsh8CnOSXygCqd=YYR5Vb&iG>ulLbt_Z z^QJbOomgns7N(OHuqYqDZ3-HN?Qxhj+Cfp~H$L{s` zoiw;rj*)^^KfdUpU~|SVXXEVp_qfimz#E(>-Y)zz7di`M$46lPG3J17t?o;%sl>D_ z_EG+=PaUw-TqWCevg&v1k0BLcHqk+h5#*jcc94TAxi>FsVDN_UidmtQC$%+TtmkGk zc05d6ONh|eOLRbMl34CdE3vln=&^p7Wy6+6I#+lEs{qy0GE_30%hbv&a@c1AO`>$@;*!dMCW)m>1IC&5MoEhpzQLv-ro=7ef%X=kN7h& zKk$8&K7dp4m&lg9T&E3ww!lPlDkcuf*)~t5V@W+@a@bn%1S!&k{}G~ivhKi)iZd+c z{&a$*T#;ZO4xSOacrB;O({n+=TkS1)R-(YHT~jtpsUyvGs0#Oa&*hr%q1j;-8=#c7 zBa$*lV_;CN(+KLpUm2o79BX1W&&UzbAF93-8VfT`N9|LAGxuwzbppC(YQ zX;MVu=p(FMYR?Vo?g5V@;duJ$MOa>Rjtq_6dP*zH#E}h6nwVvFW%bt`iI!X+>Ga5H zI;CNz93&^`LdsGv0AcQd4(-F0}}y|M|hk5-vU&4qh9 zj38c;=$?iFnel1>(bT9_oJ-o3H5T&+KW#yT>XRrXC*p<-Q8`Oh=&sl%oIbfd_ge`_ z0e5!y{A<)>)s`RB&s2X+?IqgMPpHV6c1z<7eq=zg`mO{N$Q$o zd9!N--Qh&@CzkqiaZMlZr)TuX38yJksy_>KsZg${-msQ+_Wz8f0SxjuX@-ouY+K~B zNU?;&cSC=OX^&L%3`yxZ^ba%0K>rNaQ^7N~5>N2lg^^B^#x-u+4d#Z6Toe zZ2q$M2@;`yAt47*%iHi&awjKZePU1x4U>o+Ru(W| zL<1!B;NQtwZm5V(oJ&;YN1!gsA=4FwB*?_?l_2v;EYYkiAd%TRL0>4`<`H{Z>W6iW zEb&?W(l}`d;y)op)+~;yvl10vPX7@3_$9nrW@o)_*Fkv1o1Qym=_$DHN44qq|9L+k zgMHks=TR@wlH#KdA`0X&*+YXTW92;82Mr1&q%KCXq@RZlU9kkgUq z9Z?p#?QKV0Ugn*=E#&T>USfuemJ=xa%C1FU zf8v|R2xPQa-p7?;>a)I0Mi!!@Sa65caCIBjS{-WI-W7B&-xVCsw_p4|1u9@ri!{`s$ zL)b4g8#9uHtIMFgqVda?3FW?j@y$JNwn3bx#|FdyU2p|Kb z@t!qA2P%bbe#>s2-~c1xKmt6w=i zhw@ToxXCQx43ku=HTMGyJ7BcMoDT?E-RmB9#jE0-US>mnQBCV~{U#m!rTfP?;OLqC zHnNLH(L>WQBd@DDV{69$a98gsbl;xs;`t-Oxc`6)z;Jp(>ToD7&ba(zv!DW zvl<>x&&vIz9`S&2Fi)CpmhRVZ*+upDg9z0XIq1I+QsGY!0&5Os-(sy@^jAAaa!H&2 zhV;Qfe0Wr?-qnuZ>p8;x zEX-VW>N^3Atl+{B0&|;ANTI|kw}kbjUu3Dek!hiaDQhTCB4 zpGwGT{FaUL$Ocww6Ryc_v8GA}Y0H8KDkdUW4Ont-yKnKNwVWnoAl&!tU)5}5Fkk6L ztW=3iGZF5ww)zG1R0T$xid;q=#uu2-@I_ztCY;4afvFT4Ly z5UE!;Vu!yC^)G#hO)TliEtTH~eUcHXSv))T0g&Qn*?#(t)c?5Lg!rjD&=ulFq5n+wUj45x_%#*5D|9J4xtH2wcei6il<*~CR8J0}dU zF%SOsA@V*HF|v6V!lUG}hLW*N)knS*w?V#&T14YV_yi_<`BcHb1=B6)nZ*&O^{@@fnomJ?u{(F#;aor9LuW zqk#t%cRjAIfMI_8-BvQkkAJog`r)Jnx*)(x zXY_Bt>^QI@Qfpx?AYsOrFIF9^qW&%!`cFN4)x56;YPnw$S!CHucBmU7v&5|obR9)S zh$qsY;(0d62C~9wA-1eO?7u;f)L(cQIm#9^LV{(ilQqa{q-)773M5>?g(5;`m?m+D#SrijNcA?Z*@~!+qZ{NX8A#DV0+}QFQ+A&aBOXyXtBs*8@Q(moz|(L3 zT>!t5^0Sb`)03Bf8eWHQ9Xa*2f-voTcYg-jvz+~P)Rb!?(KQ0_03Nbtl^m-jS^ZRp z#M&G<8|a(*_S5s9Y9RuUfgY{fTpn^}_j6OZuZKRAxS_42`xSsrBtp=pUHQ30DvaHp z!m~$Y2ueUaAwL`a>sl?ETe+PgCY%F&+z{<;UP45JB}krDZqgNkKN6z%V{8Lt8gC?3yY48jtzX%biCa?<_QZL^h}}u!8gGS3pc}jQ+GP%_&T5kUZZ`z7=kkO$1|Wua-UZ<|IB?D*Q_!S8Gct{w#{Qb%o~U3MyHTt6_D1-(0HHi zWw$u9z|cK_*g4)b`huTz+KMvVb?uM{Mb1+XSh0)`ATaXhZZZVahfxs7wnhVx@V|RO znYus^CG$b!VXjLCB0ah9=9`&|s4tX*hKJObN8ny&SRpZ16PP_C7zOc^mE zfRw1MMh~_4xU0`D)?*A}^7|{wL3Zyj)6;xa#j5l9E+g}O$;lM~x+Ugd6SIq6YvgVe z^~nrW%i6}6hX&DLC)TPG+DGI=cpt1km0zPjf^4r`DwxaB)WwFcSNQAaiU|rP+DSFX>nij=D!`DgjBSABt(lO`k_> z%n!UaHhEm=EWl#L<{(&DY{B|I`0?UO3j>K%uqUx2890nEnIxpUl*m1VS-kTi?~rf4 zH&7Bg#SPa694rxmZqD>~Co;CWs}es$v{bBV69Dz#czy#Ko|Xc+$#Q^oR2zk_$QgTy zh7SgJ^7Q5j;-9FAF&X&F_k)6^w&+ZHz3sgz*dQtXKv(G0~Cb??j zP_2XD7R*Kd7!03_bVioak{TbZpib3hg%DF?*l_RVSOs7mYA5j^pg7aJX61LtLgw|dC`>IuO(xg5 zcc=5fF6F$&Q@JyJD;x80`TcMWfdkEZ&Wa?A&ZpoxDv^K1?vqsUvhP8x!bf3uAHd)F zM{S%vUrOodP$M-jz1|}kcMpr{kyHaaEE^tn&-BtpcQ?S;=-~MC=t+bZC z_>{EpNn8l8;|E^i*#VJl*!Sl>BIrjU5?gRhr$bdc72Hm{2K#bkzC7P)37|}e$|%y} zXm7)Qw5EyC?9uyTU8%lwYP#M(TNE6AbKONITT2k zT$u>_Bu81sge>;T_DidIEmXMn#r~%YdYnaG4f6TF!rP(k$1j;i#2SqBpu!!(WWr(T zIyS~S z=_qqrEoGTZ3TA(p<0){A%4|*K>#Rc==od%wUuJU!0RzcXcaJr^y{boH&lpW~kMlgT zjR9T1su|Q+MP^u8i!kW#gcJ$orSulJ0!F|SH^lZz-pTlYSP!ZW%&cV@F;~_0F4dGb zOj*4gLRWl#Pq7s+5BHmoPaI6qyQ2)c-T{+ z#T3(zskIEG^7W-l<%U=B!qn|yiyrvZhOfw-d@ zzv6#*q;+2mu5n)e%(c+-zrnhQ{|!bRELW()-Srw<3gt2L6GtKPhCuiF_jUNVT6t<* z@BU6sZy{0(Tvtn=!GUQzS3jUj3Z7Z(tPIoy*P)W3qBTvfd;Gh*Krb3H4MR;S0DN&Z#EkdAk#+UIkM4G~u2W*1k?}6DqcD|xQg{c?GF#rsutnYlBz<4rjixK|_8iTMJ3FQ- z@`fpy|L_a^kG5fRHxo(j0%0P)JVCuXf1_64^3h6n0l`zJZyOqScrMT_S4>o$m9~eq z%Dr9g?n>}`>G(b-xCcTQy3eCpXc1S(a!) z5YamcqL*k9<=Ok3-+%DDn3;2CzBAXH`Ciw&_(bVwsnAkgrvd=bs;MgK5=X*+4N6Yz zb!VI?hy%n!S4AF_4zR2NaLq$a@sYld#a0$YwU^4%?n@}t`cV;5kudZIl^*Pw?;u*8 z4Pnc<5)b5I@+wj}_L|mEt{k515LL!k$hAj0j5@s31y^A5uCGaQ-2!iUEU&E0VeJO{ z-%8sJ%sJu@UvA)e{g3)D`}^OS4{-3L65epRyjo60AlM)bZpSTu4+Tp?91y;~P zZp#m$Abk2TPq71b#e^Iw?*rQh=MQ}-g3DeRYY-qp8*9gH(jb7g--LuN*jT%jeh#wW zXgLOV1O0xdFL&txnzSkf@&$Kdlm8rTf{ED~S(9Nsh2yvc&x38Fx2}V9!L$A6^lGPXI9twO z(rtmb3s;HF{yIYng3HQ<1n2pr`uN%QAolY>fWH^mwB4RZt)&_^u3#nRX{CQ}jY4#S zw&~*!UeV58gyhqY**Ua4kOJ$2=N_D_6*<$ZbjPp$j{a|Q;9Of(%5?Z2anHYKT%gJD z_(rAJ{2UALTD@q)#m)|MJ&P^t8w>FF03#XxHs@Aqe_hx1^Khki)|w8DGF-Lkg8e*# zvh&APyj3P!V^JHOBAg4L2llRF-I43u&xW;kPO9<~qAxy}^tOUecu{J?0VS^#6JPiH zKK0Y29D2d@+Yk!5kRf;x%RPJVo7SIHvhv<|HP=5Op#ymY_-nM>@G4ghNe!%MNJITJ zr2v;&qeg&OCK{@*{iO+a;VIBhQk-4o89RK=Ky*V9%3B4srB9R1huJcusoam@B>Jiv zLi=@2aoF@;Q+-8#on7tXsDvuf)9qoOPRkQ-Ra->0`-gt<=0?)&)9ZxED<2S<=oi1F zKR;NoOPS&EnA&gTgYU9hHgoOSsKxP*oF$TfkL*S~@5?a85gpH5c5B(~?ApVVEsA^* zAh;~(>kv~Uq}}ZKx{lfhCYMtI+(o@xMwROTL}&o+^C5rZn#(CG&c&$y>!idgxYJ5j z%DeVpIb(KwsfH7e&9Aka{6w04R^4heJliMHRMv@5lM49X>}Ivcn$ls^`5-dP9JUuK z^V*DUO$ty^iirO1vD%X@aY|f$zQqu#y?0M#8zcTz8uV(3iC@Z^)_(D*@lMI_i<{|o zO2>kvjP+>^znTh3_O?A;O>^p5mwMP`K|x5WxggPshUC4jupXB>sD-twQ01NkF0j+6 zJGv|(m^8b;^7im&l{b(1Go+7WUH@H=3LPImk9o`hiB)wQ z+EJBiGrBa!-L(Joqto!eq(H-`bMYk`5UdJ2fq{~aU3Ug?6p5@WrCqnM{x{|>W1Tv^y>kTdG!h2l9HDIcxPtu)(4YPd1LPvez-N zx|sTSiYPzq>>0bqX%+F)CMlSdaHm{HhHJ{yX+Juemf7Z^bTFvvHENe)2V>i|?ULHjG8!6BJ-~Ja+M3TmEZ<+qszr{Z;K(vK zzEa0*;!%sgY&LVtmgvBA0DNm}J_ezWGs`YiGf81_F`(<+G4ofN#D+I=tuR~VDi4JNhuSnYHc(*^H%qXd!JI2c6 zt!bX@0Xno-v$*gwEhjBF!30lwOxEZU?+O!^WuK~9q-x$+A4^pHo>y;t6tMS_OM|TP zbd;@kX00o5o_npZOR5UB4I(qVMVhn!*1^_QM{o^E)-N8vPr*i*-Q+P1+6Hpc3hYt? zhi6TvRVVo6nN}kjuF%Pwyp%lG`P^^ael)*?zGyu$zF^HUuvL2i39c{;h*N5At~VZ% z6<>Oj7oH!dyV$QcBT(}B@1U66Bw3~)?UWFUKeu)XDKNj^QkBs%+=q5yy7ayAHbEF} zvLF{UuiSOq8p?5r;J~IEpU^311ojt*&!M!b-x`MTTzJc$ZJ3SU9SMK!8+^B+6m)G+ zA;e%I4g@pHhhD8eRG-XzTn5R-yCZs~5|wFgMEIgK`2`XgzG~(6w9nbI1+cxe23 zdKd(kQEON`E}>+2*d4BX;d>67WbbaYA779yh^vdpI~v!$>soY=9Q@ii!&yk>sTHxN zhdCvnA{$^@s@TK>*#Zg~CcqSc69Pkl^{ z&&o-U6~m$={XRirXu*kXv8{xqp?%c-V!=%tqmDk=;@0=W-(|6++w6VWM#q;*Z==IF zS^2-xHt*J~77vaGi55XX+Ui3B-g2|-yF@MO=dzN;0ZMX;CT3o!XcSMVq~bOc?GEg> zanUJ>3+ykx0t)x;hCVoF4o!y%elYV3@(D0S*|$u*5eOHr5Ys%p-VML z?1S2RGxk3A(%16?&OIAEY6}qxq8o6JFARU;*}8bknn&#sz|!r&zds$t%S(Fcuhz=F z#>bnC*Qz9|mr2}MNX40+JnEFCkyaJs8&Vo?A|d2n{tZ)fZ%8eQ`v)O^;dLEN@)7O3 zw>r+FW2eh1R0!hVcCwPd_z0IEo zzNL-)02G!oi7N88)b)if3CJPao%q^vb+c9voM(EUCVJ^3$H&S+ajw zpfs}uv!2rE=|0!oz{zqqvsNS69~u4L-& zwrE~zY4eE&xzI;u#_Y7TLTGU3f(G-j*rABAlWm=Z{@pNIzn2GpfBoT6(IW@#0?$;( z-#DumTnlr#j9Iiu{>~-MBiPiutA#7117Q}u@uid-9aP01M^r-VuH8gVKH|}M0Kj6Z zNd9M+NV3tynE?(1tA8;ViLwnm2yPH`P?h*XJ$n;azN?6RsY<3=du_2kl-dSy^pyBd zM)47sC6njElTCHKX7V3Ri+5}v9?yYtFV0FJ$j; z6L}F|HJ4sI%?DrySyW2b{Lzr;9`naCh>`b#Ly}RF7EiOYR?>el187s&<=wbv5-u() zOGv4E_tcL$X{MGGD_Zn-faOR71I;_}4pw&979-`HWMlr24b7A;dELi*6hLS!6Ddxi z=4T!ok2ONf>5-6Wo^M~}-){hxZ1LlqiuoLBhe3)O)g>XaZ(%|-=-}xZu{V45Z*KrC zZCG6+w)6kJF5yQrrOyJhHd&eeW zF%UOUt8ZVv`HU;;*-vU?EB>hm#QoawVSF~Im(6m!;}b1i0ujsHma$wmV$o(D9wdMp z5-@2^*_7JU&E(RYDOPf~vVEk%Kb;!fKlZp-y$RE3#rKuZR%j}xaJ>9h#onh&QzLkH zWc#!Fz!hL0IOJjky^(&`w+N-lm4a`~4-y$uvK^D^67WU`2mra`xIpQYo=Xk!4vR?E z-C_lUcef;Hpl@@?x6@Zhzy|Y)s2T-U{CAoM48oBTKWT1Ftz9!?1}sNIWc1;_#eVEG zr@IM}T*JvL%1hB(j&{o{0C4YJRi?x!p9^5J#-itKdYX0(I1*1xg1U_CbURl8u<)21 zz)+$ME#w`CKFjm`l)0HP6ntJ+k$BUh{g`E+1q7eci&>)fNS^x&Mml2~SkONb$t^7; z&)|dn?BdNF1;PrfQ>`sIGL`<>IcGm#4?w_Nac+?unq&Z*Vf_~ot9T*Axc!?r+!%Vbgy84(cS)cnebn~5X zTslI8cTVB0%yz(nbth&n2s+FHK$wfB(hN{V0|0-7e zHW-m-pw8)7>;SE-PSZ<8qLan_$blpQ8i&-#EaSKPF-;@>yIX8Qtm_9;fa%h~kJaWi ze(S8}c&z85eBpa1_aRA{Ln^R2fwqOwB-}cB zalKmtTqS2}WBldJ=02+;A(XLnJ5-Zj`5(Rb?=4Ar4{)QvFB=9>%H=)=>~$O6l4@&a{CzId0+87r?%FWdhB)2%C(62HY<@y`dHQWaoCyU^no83l@ug_S8$uvcI zOKeCjybQs7>wJvwzGh2N9;UuFAXF*=@{xp2{^S!~7Hs+DDm=@&xT=%~=L!4vDl7k> z;!dE={5ZGQGvxRU5b1asm%_|%RvT8cVu3Q}w~to;gUYA5#cZ0lS#Y3Npydi~SAE%g z%84D&+Fe|x+gl|Av=3xR9C38aWZ~AXg74;poai;&xEy2+VuR#Lx0lXQ6QjFkGX}l_Wf*d%lSzO z=80jr`vVBzdpzQgxjM!AVyC6N-JQo9)&Bz@64&KT&a;C zOR@LI^s6O^`;&lLnU9nj@QXG@jHU3hGUm<~Lrv3ueq)#VJ803ukQ`0=KZ(b*b%_67 zbxUkM+D8TzD38;8TYuFJCDptTfW;uksR3Qm!Kr+45{6FYUmU|ERYl4ujS0JVrEU|a zNS)$rpLO7;UOZU%(spoLMGH-N8gOu`C%xSfdqa;wGgr8Hp*>Tf=geJ_wpxc6$Z|aP zr9V~01e!76<%htTC{|g)o+Kktc9yG*QYMMsfyxuMM`)9 zr)bZB=aES(-C0}Ff##ICdTyvGJ}Yq#Hv^O3O=V(UfJMAxN%mO`^1NQp+quNH#>^#4 zvRrYIug}=lQI7(6@5*eVpggW59dM@EIO(_1m;$LqJ!rX-4OG4k6)AbUy@S(X9r(QG zY>$vjTZMm#SzO2oo1WS@rLf2P4yO8$IRu7@*`yQ`z-->|3JFcq@!bG@mJp*RNr%xWZ3ijm~Hw)UVD9Vh8bjn< rLla^5rM-xx@*|(?PRalGGV`QCrQ+Mkn%nI}77Nsrv=mF_EkphfHQ!Zx literal 0 HcmV?d00001 diff --git a/src/Logexpert.Resources/images/png/48/bookmark_bubbles.png b/src/Logexpert.Resources/images/png/48/bookmark_bubbles.png new file mode 100644 index 0000000000000000000000000000000000000000..fbe5335adbc451126bc20fd3547c1b5efaa950c0 GIT binary patch literal 2595 zcmb_eYgkNc8-CYnr5UNF1F4khv_)qrom-7g(`h=0#LjG?gHB4+B&|WFospW*AS0O$ z(!n93lp%#}c4ZnN>7c?Cg_>-$ckI=#@7KP*>pT2d>%HFhe(w8up8HzYdfs1y0=<0L%b=Vu5+0L0OD(^hx_{U$dBhXS5-u5Jp3^d z-ew<=8g*+MdtLDA9L0d$7uP)X&=1b#YlJ9k^55P+R*+k;nlhTKpQ2q@Q4;D!@T3;K zIDNrqf0wZN<;|qo4^r2OtO4nrsVURj8OjsiYNfBb8t*1`F^Y3F5ifuGfo=jbo`PG<>VM+A+W{Gu5@ibw`^b2W-PIdEnQ%l>hiW_fKFtE_P zt3}=!xkVApbqr}KLn?5wFT*}sUj-UCu_q#sB+Nnm;Cia##j$?f9%sa7u>WJRI+Cj2 z%|T@xvljWJIb5>7x7kJ&&Oi%MPB>9DXDk#ZIGv2Bp3}VidO4y_UXQK`uXWV zn%>KXM=mVK4=L2G_IhG@1;;pc4g4QtqlJN&BRV~?bI2`-EkCONy5GE~()FEI z6xYewslHA6lRcyMC6|Un$v@zg1V( zJa!*|$DDbRjjZ0uC{0X95ObHcC$;fT{Fmfbg=5x2Wm;E>OZnKA0}4a?FkPg^4Qi41 zp_TuL2$9{Do*d11&7|Jsv0RYU7R3mzCc@IlfE{J1R(z%;vBFNTg=hp<|fZ3mVG<$<&Z=}u|=O|n9AFmbdFtS(n28KclWIiV`e?I4RMJR+YBft8m z`?2=861iE8ZntQ@3blCqY^8B7Nd`OIH*3&UYPh7XkQzP%(J10S0o=>jC~SVW>b8=c6BDiO3^B+giFP-Mzv9ed5ur8RK}X zkN3+FV2;<)U3VdEu5qKe=*Ex+Vx?AY*?nI?qC>8F$$8pNV`ek*6fn{y%x0;$`*=_yc3VZuM_4ZS@4Wb*$X3RdnLZ3(k&NqLSj{8E7d4ng zPen9QoDC$Ll0&Qa6(Fv~4UX@&+Y*wS`I}ReANSu=OQ(pwIaD6C5S-*pK5-zYDg=;Q zOw-rAJ6tI5vok5aPw#C>;q5jfE5q1w{zr$0M^_0pad<@y(VfFwrx>~IXsU(s^+G+|m z9dsi9?Ze|4=PdF7%dS29*7JMe(aFe7--zepUtbLy5Uy+yIdSq+oE9r89YbYR(~eX( z#`2mZ=#;OoN^y+g{t9&fL|pzaqZ` z-3s&F5;I%BCA20iH2HpWl>1eM*@`@x8?nnfZ?IRtn+5jyH0c{M^4#R~LVx&`sz50z z=;wFcQIkIiVk6K_gPPT=JVD-|i`0xu5R>tf+Pz-nCZLfWeJOhQ{aXCs*xo?$xDxt# zACF;|%a9BDOT5z>ewqmK?uL)QH0i^U(4uyt$8E^u` zOL2r1;KEGHn&*V4!#}^qi~B>YPTx2mk`T5|@Fy;Nnd-u13<3=|+b~_I9?x8FAw@o< z$?<1L8%!#B)kZ_R<<@5;A3TCRR{~VRdOu93v`?&hO94VYl|IsbriNm1q25D!`0PDo zuxq^^fT{y@nVBRMsN~fIo8z Date: Wed, 26 Mar 2025 16:31:37 +0100 Subject: [PATCH 005/142] resources are now their respective own project AboutBox moved to LogExpert.UI --- src/Directory.Packages.props | 2 + src/LogExpert.sln | 10 +- .../Controls/LogTabWindow/LogTabWindow.cs | 9 +- .../LogTabWindow/LogTabWindow.designer.cs | 33 +- src/LogExpert/Controls/LogWindow/LogWindow.cs | 4 +- .../Controls/LogWindow/LogWindow.designer.cs | 9 +- src/LogExpert/Dialogs/AboutBox.Designer.cs | 395 +++++---- src/LogExpert/Dialogs/AboutBox.cs | 260 +++--- .../Dialogs/HighlightDialog.Designer.cs | 3 +- src/LogExpert/LogExpert.csproj | 16 +- src/LogExpert/Properties/Settings.Designer.cs | 26 - src/LogExpert/Properties/Settings.settings | 8 - src/LogExpert/Resources/AdvancedIcon.bmp | Bin 1198 -> 0 bytes src/LogExpert/Resources/Icon1.ico | Bin 52334 -> 0 bytes src/LogExpert/Resources/Icon2.ico | Bin 1078 -> 0 bytes src/LogExpert/Resources/LogExpert-Icon.gif | Bin 591 -> 0 bytes src/LogExpert/Resources/LogExpert-Logo.png | Bin 7812 -> 0 bytes src/LogExpert/Resources/LogExpert.bmp | Bin 37114 -> 0 bytes src/LogExpert/Resources/LogLover.gif | Bin 5235 -> 0 bytes src/LogExpert/Resources/Log_Icon.png | Bin 1343 -> 0 bytes src/LogExpert/Resources/Log_Icon_small.png | Bin 622 -> 0 bytes src/LogExpert/Resources/PNG/48/Add.png | Bin 1774 -> 0 bytes src/LogExpert/Resources/PNG/48/ArrowDown.png | Bin 322 -> 0 bytes src/LogExpert/Resources/PNG/48/ArrowLeft.png | Bin 236 -> 0 bytes src/LogExpert/Resources/PNG/48/ArrowRight.png | Bin 240 -> 0 bytes src/LogExpert/Resources/PNG/48/ArrowUp.png | Bin 325 -> 0 bytes .../Resources/PNG/48/Arrow_menu_close.png | Bin 2457 -> 0 bytes .../Resources/PNG/48/Arrow_menu_open.png | Bin 2423 -> 0 bytes .../Resources/PNG/48/Bookmark_add.png | Bin 2802 -> 0 bytes .../Resources/PNG/48/Bookmark_added.png | Bin 3090 -> 0 bytes .../Resources/PNG/48/Bookmark_manager.png | Bin 3092 -> 0 bytes .../Resources/PNG/48/Bookmark_remove.png | Bin 2736 -> 0 bytes src/LogExpert/Resources/PNG/48/Bookmarks.png | Bin 354 -> 0 bytes .../Resources/PNG/48/Check_circle.png | Bin 6610 -> 0 bytes src/LogExpert/Resources/PNG/48/Close.png | Bin 2723 -> 0 bytes src/LogExpert/Resources/PNG/48/Deceased.png | Bin 6572 -> 0 bytes src/LogExpert/Resources/PNG/48/Delete.png | Bin 2095 -> 0 bytes src/LogExpert/Resources/PNG/48/Exit.png | Bin 2294 -> 0 bytes src/LogExpert/Resources/PNG/48/Favorite.png | Bin 6008 -> 0 bytes src/LogExpert/Resources/PNG/48/File_open.png | Bin 2896 -> 0 bytes src/LogExpert/Resources/PNG/48/Filter.png | Bin 361 -> 0 bytes .../Resources/PNG/48/Folder_open.png | Bin 3681 -> 0 bytes .../Resources/PNG/48/Restart_alt.png | Bin 5291 -> 0 bytes src/LogExpert/Resources/PNG/48/Search.png | Bin 860 -> 0 bytes src/LogExpert/Resources/PNG/48/Settings.png | Bin 7315 -> 0 bytes src/LogExpert/Resources/PNG/48/Star.png | Bin 5561 -> 0 bytes .../Resources/PNG/48/bookmark_bubbles.png | Bin 2595 -> 0 bytes src/LogExpert/Resources/bubble.ico | Bin 2862 -> 0 bytes src/LogExpert/{Resources => }/logexpert.ico | Bin .../Logexpert.Resources.csproj | 20 + .../Resources.Designer.cs | 756 ++++++++---------- .../Resources.resx | 461 +++++------ .../images/bmp/AdvancedIcon.bmp | Bin 1198 -> 0 bytes .../images/bmp}/Pro_Filter.bmp | Bin src/Logexpert.UI/Dialogs/AboutBox.Designer.cs | 203 +++++ src/Logexpert.UI/Dialogs/AboutBox.cs | 140 ++++ src/Logexpert.UI/Dialogs/AboutBox.resx | 120 +++ src/Logexpert.UI/LogExpert.UI.csproj | 29 + 58 files changed, 1430 insertions(+), 1074 deletions(-) delete mode 100644 src/LogExpert/Properties/Settings.Designer.cs delete mode 100644 src/LogExpert/Properties/Settings.settings delete mode 100644 src/LogExpert/Resources/AdvancedIcon.bmp delete mode 100644 src/LogExpert/Resources/Icon1.ico delete mode 100644 src/LogExpert/Resources/Icon2.ico delete mode 100644 src/LogExpert/Resources/LogExpert-Icon.gif delete mode 100644 src/LogExpert/Resources/LogExpert-Logo.png delete mode 100644 src/LogExpert/Resources/LogExpert.bmp delete mode 100644 src/LogExpert/Resources/LogLover.gif delete mode 100644 src/LogExpert/Resources/Log_Icon.png delete mode 100644 src/LogExpert/Resources/Log_Icon_small.png delete mode 100644 src/LogExpert/Resources/PNG/48/Add.png delete mode 100644 src/LogExpert/Resources/PNG/48/ArrowDown.png delete mode 100644 src/LogExpert/Resources/PNG/48/ArrowLeft.png delete mode 100644 src/LogExpert/Resources/PNG/48/ArrowRight.png delete mode 100644 src/LogExpert/Resources/PNG/48/ArrowUp.png delete mode 100644 src/LogExpert/Resources/PNG/48/Arrow_menu_close.png delete mode 100644 src/LogExpert/Resources/PNG/48/Arrow_menu_open.png delete mode 100644 src/LogExpert/Resources/PNG/48/Bookmark_add.png delete mode 100644 src/LogExpert/Resources/PNG/48/Bookmark_added.png delete mode 100644 src/LogExpert/Resources/PNG/48/Bookmark_manager.png delete mode 100644 src/LogExpert/Resources/PNG/48/Bookmark_remove.png delete mode 100644 src/LogExpert/Resources/PNG/48/Bookmarks.png delete mode 100644 src/LogExpert/Resources/PNG/48/Check_circle.png delete mode 100644 src/LogExpert/Resources/PNG/48/Close.png delete mode 100644 src/LogExpert/Resources/PNG/48/Deceased.png delete mode 100644 src/LogExpert/Resources/PNG/48/Delete.png delete mode 100644 src/LogExpert/Resources/PNG/48/Exit.png delete mode 100644 src/LogExpert/Resources/PNG/48/Favorite.png delete mode 100644 src/LogExpert/Resources/PNG/48/File_open.png delete mode 100644 src/LogExpert/Resources/PNG/48/Filter.png delete mode 100644 src/LogExpert/Resources/PNG/48/Folder_open.png delete mode 100644 src/LogExpert/Resources/PNG/48/Restart_alt.png delete mode 100644 src/LogExpert/Resources/PNG/48/Search.png delete mode 100644 src/LogExpert/Resources/PNG/48/Settings.png delete mode 100644 src/LogExpert/Resources/PNG/48/Star.png delete mode 100644 src/LogExpert/Resources/PNG/48/bookmark_bubbles.png delete mode 100644 src/LogExpert/Resources/bubble.ico rename src/LogExpert/{Resources => }/logexpert.ico (100%) rename src/{LogExpert/Properties => Logexpert.Resources}/Resources.Designer.cs (69%) rename src/{LogExpert/Properties => Logexpert.Resources}/Resources.resx (58%) delete mode 100644 src/Logexpert.Resources/images/bmp/AdvancedIcon.bmp rename src/{LogExpert/Resources => Logexpert.Resources/images/bmp}/Pro_Filter.bmp (100%) create mode 100644 src/Logexpert.UI/Dialogs/AboutBox.Designer.cs create mode 100644 src/Logexpert.UI/Dialogs/AboutBox.cs create mode 100644 src/Logexpert.UI/Dialogs/AboutBox.resx create mode 100644 src/Logexpert.UI/LogExpert.UI.csproj diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index f3d486d1..f0f5263e 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -28,6 +28,8 @@ + +
\ No newline at end of file diff --git a/src/LogExpert.sln b/src/LogExpert.sln index 8c35134f..1bc2cf6c 100644 --- a/src/LogExpert.sln +++ b/src/LogExpert.sln @@ -57,9 +57,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RegexColumnizer.UnitTests", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogexpertgRPCService", "LogexpertgRPCService\LogexpertgRPCService.csproj", "{D31D1721-9DEA-45A4-B813-D5023B2EC2CC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logexpert.Core", "Logexpert.Core\Logexpert.Core.csproj", "{F49C6738-3F62-4890-8FF2-1F53A0F0A2CD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.Core", "Logexpert.Core\LogExpert.Core.csproj", "{F49C6738-3F62-4890-8FF2-1F53A0F0A2CD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logexpert.Resources", "Logexpert.Resources\Logexpert.Resources.csproj", "{578CC5D5-1DCD-47C2-8BD3-B32C14635BEC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.Resources", "Logexpert.Resources\LogExpert.Resources.csproj", "{578CC5D5-1DCD-47C2-8BD3-B32C14635BEC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.UI", "Logexpert.UI\LogExpert.UI.csproj", "{5DB0B0F8-3C3E-4805-93A3-7E69AC45CD40}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -145,6 +147,10 @@ Global {578CC5D5-1DCD-47C2-8BD3-B32C14635BEC}.Debug|Any CPU.Build.0 = Debug|Any CPU {578CC5D5-1DCD-47C2-8BD3-B32C14635BEC}.Release|Any CPU.ActiveCfg = Release|Any CPU {578CC5D5-1DCD-47C2-8BD3-B32C14635BEC}.Release|Any CPU.Build.0 = Release|Any CPU + {5DB0B0F8-3C3E-4805-93A3-7E69AC45CD40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5DB0B0F8-3C3E-4805-93A3-7E69AC45CD40}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5DB0B0F8-3C3E-4805-93A3-7E69AC45CD40}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5DB0B0F8-3C3E-4805-93A3-7E69AC45CD40}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs index 843d99fe..b4ef9427 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs @@ -1,7 +1,6 @@ using LogExpert.Config; using LogExpert.Dialogs; using LogExpert.Entities; -using LogExpert.Entities.EventArgs; using LogExpert.Extensions.Forms; using LogExpert.Interface; @@ -150,7 +149,7 @@ public LogTabWindow(string[] fileNames, int instanceNumber, bool showInstanceNum // get a list of resource names from the manifest string[] resNames = a.GetManifestResourceNames(); - Bitmap bmp = Properties.Resources.Deceased; + Bitmap bmp = Resources.Resources.Deceased; _deadIcon = Icon.FromHandle(bmp.GetHicon()); bmp.Dispose(); Closing += OnLogTabWindowClosing; @@ -239,7 +238,7 @@ public void ChangeTheme(Control.ControlCollection container) // Tabs line dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient.StartColor = ColorMode.TabsBackgroundStripColor; dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient.EndColor = ColorMode.TabsBackgroundStripColor; - + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.DockStripGradient.StartColor = ColorMode.TabsBackgroundStripColor; dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.DockStripGradient.EndColor = ColorMode.TabsBackgroundStripColor; @@ -247,11 +246,11 @@ public void ChangeTheme(Control.ControlCollection container) dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.StartColor = ColorMode.ActiveTabColor; dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.EndColor = ColorMode.ActiveTabColor; dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.TextColor = ColorMode.ForeColor; - + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.StartColor = ColorMode.ActiveTabColor; dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.EndColor = ColorMode.ActiveTabColor; dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.TextColor = ColorMode.ForeColor; - + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.StartColor = ColorMode.InactiveTabColor; dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.EndColor = ColorMode.InactiveTabColor; dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.TextColor = ColorMode.ForeColor; diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs index be27ac3e..8f879281 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs @@ -1,7 +1,6 @@ using System.Windows.Forms; using LogExpert.Dialogs; using LogExpert.Extensions.Forms; -using LogExpert.Properties; using WeifenLuo.WinFormsUI.Docking; @@ -241,7 +240,7 @@ private void InitializeComponent() // openToolStripMenuItem // openToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; - openToolStripMenuItem.Image = Resources.File_open; + openToolStripMenuItem.Image = LogExpert.Resources.Resources.File_open; openToolStripMenuItem.Name = "openToolStripMenuItem"; openToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.O; openToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -259,7 +258,7 @@ private void InitializeComponent() // // closeFileToolStripMenuItem // - closeFileToolStripMenuItem.Image = Resources.Close; + closeFileToolStripMenuItem.Image = LogExpert.Resources.Resources.Close; closeFileToolStripMenuItem.Name = "closeFileToolStripMenuItem"; closeFileToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.F4; closeFileToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -268,7 +267,7 @@ private void InitializeComponent() // // reloadToolStripMenuItem // - reloadToolStripMenuItem.Image = Resources.Restart_alt; + reloadToolStripMenuItem.Image = LogExpert.Resources.Resources.Restart_alt; reloadToolStripMenuItem.Name = "reloadToolStripMenuItem"; reloadToolStripMenuItem.ShortcutKeys = Keys.F5; reloadToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -360,7 +359,7 @@ private void InitializeComponent() // // exitToolStripMenuItem // - exitToolStripMenuItem.Image = Resources.Exit; + exitToolStripMenuItem.Image = LogExpert.Resources.Resources.Exit; exitToolStripMenuItem.Name = "exitToolStripMenuItem"; exitToolStripMenuItem.ShortcutKeys = Keys.Alt | Keys.F4; exitToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -392,7 +391,7 @@ private void InitializeComponent() // // filterToolStripMenuItem // - filterToolStripMenuItem.Image = Resources.Filter; + filterToolStripMenuItem.Image = LogExpert.Resources.Resources.Filter; filterToolStripMenuItem.Name = "filterToolStripMenuItem"; filterToolStripMenuItem.ShortcutKeys = Keys.F4; filterToolStripMenuItem.Size = new System.Drawing.Size(189, 30); @@ -410,7 +409,7 @@ private void InitializeComponent() // toggleBookmarkToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; toggleBookmarkToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - toggleBookmarkToolStripMenuItem.Image = Resources.Bookmark_add; + toggleBookmarkToolStripMenuItem.Image = LogExpert.Resources.Resources.Bookmark_add; toggleBookmarkToolStripMenuItem.Name = "toggleBookmarkToolStripMenuItem"; toggleBookmarkToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.F2; toggleBookmarkToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -421,7 +420,7 @@ private void InitializeComponent() // jumpToNextToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; jumpToNextToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - jumpToNextToolStripMenuItem.Image = Resources.ArrowDown; + jumpToNextToolStripMenuItem.Image = LogExpert.Resources.Resources.ArrowDown; jumpToNextToolStripMenuItem.Name = "jumpToNextToolStripMenuItem"; jumpToNextToolStripMenuItem.ShortcutKeys = Keys.F2; jumpToNextToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -432,7 +431,7 @@ private void InitializeComponent() // jumpToPrevToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; jumpToPrevToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - jumpToPrevToolStripMenuItem.Image = Resources.ArrowUp; + jumpToPrevToolStripMenuItem.Image = LogExpert.Resources.Resources.ArrowUp; jumpToPrevToolStripMenuItem.Name = "jumpToPrevToolStripMenuItem"; jumpToPrevToolStripMenuItem.ShortcutKeys = Keys.Shift | Keys.F2; jumpToPrevToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -586,7 +585,7 @@ private void InitializeComponent() // // settingsToolStripMenuItem // - settingsToolStripMenuItem.Image = Resources.Settings; + settingsToolStripMenuItem.Image = LogExpert.Resources.Resources.Settings; settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; settingsToolStripMenuItem.Size = new System.Drawing.Size(224, 30); settingsToolStripMenuItem.Text = "Settings..."; @@ -916,7 +915,7 @@ private void InitializeComponent() // toolStripButtonOpen // toolStripButtonOpen.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonOpen.Image = Resources.File_open; + toolStripButtonOpen.Image = LogExpert.Resources.Resources.File_open; toolStripButtonOpen.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonOpen.Name = "toolStripButtonOpen"; toolStripButtonOpen.Size = new System.Drawing.Size(28, 28); @@ -932,7 +931,7 @@ private void InitializeComponent() // toolStripButtonSearch // toolStripButtonSearch.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonSearch.Image = Resources.Search; + toolStripButtonSearch.Image = LogExpert.Resources.Resources.Search; toolStripButtonSearch.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonSearch.Name = "toolStripButtonSearch"; toolStripButtonSearch.Size = new System.Drawing.Size(28, 28); @@ -943,7 +942,7 @@ private void InitializeComponent() // toolStripButtonFilter // toolStripButtonFilter.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonFilter.Image = Resources.Filter; + toolStripButtonFilter.Image = LogExpert.Resources.Resources.Filter; toolStripButtonFilter.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonFilter.Name = "toolStripButtonFilter"; toolStripButtonFilter.Size = new System.Drawing.Size(28, 28); @@ -960,7 +959,7 @@ private void InitializeComponent() // toolStripButtonBookmark // toolStripButtonBookmark.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonBookmark.Image = Resources.Bookmark_add; + toolStripButtonBookmark.Image = LogExpert.Resources.Resources.Bookmark_add; toolStripButtonBookmark.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonBookmark.Name = "toolStripButtonBookmark"; toolStripButtonBookmark.Size = new System.Drawing.Size(28, 28); @@ -971,7 +970,7 @@ private void InitializeComponent() // toolStripButtonUp // toolStripButtonUp.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonUp.Image = Resources.ArrowUp; + toolStripButtonUp.Image = LogExpert.Resources.Resources.ArrowUp; toolStripButtonUp.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonUp.Name = "toolStripButtonUp"; toolStripButtonUp.Size = new System.Drawing.Size(28, 28); @@ -982,7 +981,7 @@ private void InitializeComponent() // toolStripButtonDown // toolStripButtonDown.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonDown.Image = Resources.ArrowDown; + toolStripButtonDown.Image = LogExpert.Resources.Resources.ArrowDown; toolStripButtonDown.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonDown.Name = "toolStripButtonDown"; toolStripButtonDown.Size = new System.Drawing.Size(28, 28); @@ -999,7 +998,7 @@ private void InitializeComponent() // toolStripButtonBubbles.CheckOnClick = true; toolStripButtonBubbles.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonBubbles.Image = Resources.bookmark_bubbles; + toolStripButtonBubbles.Image = LogExpert.Resources.Resources.bookmark_bubbles; toolStripButtonBubbles.ImageAlign = System.Drawing.ContentAlignment.BottomCenter; toolStripButtonBubbles.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonBubbles.Name = "toolStripButtonBubbles"; diff --git a/src/LogExpert/Controls/LogWindow/LogWindow.cs b/src/LogExpert/Controls/LogWindow/LogWindow.cs index 7cb5c3ca..cb7310d8 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindow.cs @@ -228,8 +228,8 @@ public LogWindow(LogTabWindow.LogTabWindow parent, string fileName, bool isTempF dataGridView.EditModeMenuStrip = editModeContextMenuStrip; markEditModeToolStripMenuItem.Enabled = true; - _panelOpenButtonImage = Properties.Resources.Arrow_menu_open; - _panelCloseButtonImage = Properties.Resources.Arrow_menu_close; + _panelOpenButtonImage = Resources.Resources.Arrow_menu_open; + _panelCloseButtonImage = Resources.Resources.Arrow_menu_close; Settings settings = ConfigManager.Settings; diff --git a/src/LogExpert/Controls/LogWindow/LogWindow.designer.cs b/src/LogExpert/Controls/LogWindow/LogWindow.designer.cs index 25a3091c..7300c4fb 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindow.designer.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindow.designer.cs @@ -1,6 +1,5 @@ using LogExpert.Dialogs; using LogExpert.Extensions.Forms; -using LogExpert.Properties; using System; using System.Drawing; @@ -578,7 +577,7 @@ private void InitializeComponent() // // pnlProFilterLabel // - pnlProFilterLabel.BackgroundImage = Resources.Pro_Filter; + pnlProFilterLabel.BackgroundImage = LogExpert.Resources.Resources.Pro_Filter; pnlProFilterLabel.BackgroundImageLayout = ImageLayout.Center; pnlProFilterLabel.Location = new Point(5, 7); pnlProFilterLabel.Name = "pnlProFilterLabel"; @@ -655,7 +654,7 @@ private void InitializeComponent() // btnToggleHighlightPanel // btnToggleHighlightPanel.Anchor = AnchorStyles.Top | AnchorStyles.Right; - btnToggleHighlightPanel.Image = Resources.Arrow_menu_open; + btnToggleHighlightPanel.Image = LogExpert.Resources.Resources.Arrow_menu_open; btnToggleHighlightPanel.Location = new Point(1832, 1); btnToggleHighlightPanel.Name = "btnToggleHighlightPanel"; btnToggleHighlightPanel.Size = new Size(20, 21); @@ -785,7 +784,7 @@ private void InitializeComponent() // // filterDownButton // - filterDownButton.BackgroundImage = Resources.ArrowDown; + filterDownButton.BackgroundImage = LogExpert.Resources.Resources.ArrowDown; filterDownButton.BackgroundImageLayout = ImageLayout.Stretch; filterDownButton.Location = new Point(296, 85); filterDownButton.Name = "filterDownButton"; @@ -798,7 +797,7 @@ private void InitializeComponent() // // filterUpButton // - filterUpButton.BackgroundImage = Resources.ArrowUp; + filterUpButton.BackgroundImage = LogExpert.Resources.Resources.ArrowUp; filterUpButton.BackgroundImageLayout = ImageLayout.Stretch; filterUpButton.Location = new Point(258, 85); filterUpButton.Name = "filterUpButton"; diff --git a/src/LogExpert/Dialogs/AboutBox.Designer.cs b/src/LogExpert/Dialogs/AboutBox.Designer.cs index f8bf20b6..ca4959da 100644 --- a/src/LogExpert/Dialogs/AboutBox.Designer.cs +++ b/src/LogExpert/Dialogs/AboutBox.Designer.cs @@ -1,203 +1,202 @@ -namespace LogExpert.Dialogs -{ - partial class AboutBox - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; +//namespace LogExpert.Dialogs +//{ +// partial class AboutBox +// { +// /// +// /// Required designer variable. +// /// +// private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } +// /// +// /// Clean up any resources being used. +// /// +// protected override void Dispose(bool disposing) +// { +// if (disposing && (components != null)) +// { +// components.Dispose(); +// } +// base.Dispose(disposing); +// } - #region Windows Form Designer generated code +// #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); - logoPictureBox = new System.Windows.Forms.PictureBox(); - labelProductName = new System.Windows.Forms.Label(); - labelVersion = new System.Windows.Forms.Label(); - labelCopyright = new System.Windows.Forms.Label(); - textBoxDescription = new System.Windows.Forms.TextBox(); - linkLabelURL = new System.Windows.Forms.LinkLabel(); - panel1 = new System.Windows.Forms.Panel(); - okButton = new System.Windows.Forms.Button(); - tableLayoutPanel.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)logoPictureBox).BeginInit(); - panel1.SuspendLayout(); - SuspendLayout(); - // - // tableLayoutPanel - // - tableLayoutPanel.ColumnCount = 2; - tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 34.25484F)); - tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 65.74516F)); - tableLayoutPanel.Controls.Add(logoPictureBox, 0, 0); - tableLayoutPanel.Controls.Add(labelProductName, 1, 0); - tableLayoutPanel.Controls.Add(labelVersion, 1, 1); - tableLayoutPanel.Controls.Add(labelCopyright, 1, 2); - tableLayoutPanel.Controls.Add(textBoxDescription, 1, 4); - tableLayoutPanel.Controls.Add(linkLabelURL, 1, 3); - tableLayoutPanel.Controls.Add(panel1, 1, 5); - tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; - tableLayoutPanel.Location = new System.Drawing.Point(14, 14); - tableLayoutPanel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - tableLayoutPanel.Name = "tableLayoutPanel"; - tableLayoutPanel.RowCount = 6; - tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.912043F)); - tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.912043F)); - tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.47226F)); - tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.84032F)); - tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 46.68471F)); - tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.17862F)); - tableLayoutPanel.Size = new System.Drawing.Size(914, 649); - tableLayoutPanel.TabIndex = 0; - // - // logoPictureBox - // - logoPictureBox.Dock = System.Windows.Forms.DockStyle.Fill; - logoPictureBox.Image = Properties.Resources.LogLover; - logoPictureBox.Location = new System.Drawing.Point(4, 5); - logoPictureBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - logoPictureBox.Name = "logoPictureBox"; - tableLayoutPanel.SetRowSpan(logoPictureBox, 6); - logoPictureBox.Size = new System.Drawing.Size(305, 639); - logoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; - logoPictureBox.TabIndex = 12; - logoPictureBox.TabStop = false; - // - // labelProductName - // - labelProductName.Dock = System.Windows.Forms.DockStyle.Fill; - labelProductName.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0); - labelProductName.Location = new System.Drawing.Point(322, 0); - labelProductName.Margin = new System.Windows.Forms.Padding(9, 0, 4, 0); - labelProductName.MaximumSize = new System.Drawing.Size(0, 26); - labelProductName.Name = "labelProductName"; - labelProductName.Size = new System.Drawing.Size(588, 26); - labelProductName.TabIndex = 19; - labelProductName.Text = "Product Name"; - labelProductName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // labelVersion - // - labelVersion.Dock = System.Windows.Forms.DockStyle.Fill; - labelVersion.Location = new System.Drawing.Point(322, 64); - labelVersion.Margin = new System.Windows.Forms.Padding(9, 0, 4, 0); - labelVersion.MaximumSize = new System.Drawing.Size(0, 26); - labelVersion.Name = "labelVersion"; - labelVersion.Size = new System.Drawing.Size(588, 26); - labelVersion.TabIndex = 0; - labelVersion.Text = "Version"; - labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // labelCopyright - // - labelCopyright.Dock = System.Windows.Forms.DockStyle.Fill; - labelCopyright.Location = new System.Drawing.Point(322, 128); - labelCopyright.Margin = new System.Windows.Forms.Padding(9, 0, 4, 0); - labelCopyright.Name = "labelCopyright"; - labelCopyright.Size = new System.Drawing.Size(588, 61); - labelCopyright.TabIndex = 21; - labelCopyright.Text = "Copyright"; - labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // textBoxDescription - // - textBoxDescription.Dock = System.Windows.Forms.DockStyle.Fill; - textBoxDescription.Location = new System.Drawing.Point(322, 270); - textBoxDescription.Margin = new System.Windows.Forms.Padding(9, 5, 4, 5); - textBoxDescription.Multiline = true; - textBoxDescription.Name = "textBoxDescription"; - textBoxDescription.ReadOnly = true; - textBoxDescription.ScrollBars = System.Windows.Forms.ScrollBars.Both; - textBoxDescription.Size = new System.Drawing.Size(588, 292); - textBoxDescription.TabIndex = 23; - textBoxDescription.TabStop = false; - textBoxDescription.Text = "Description"; - // - // linkLabelURL - // - linkLabelURL.AutoSize = true; - linkLabelURL.Dock = System.Windows.Forms.DockStyle.Fill; - linkLabelURL.Location = new System.Drawing.Point(317, 189); - linkLabelURL.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - linkLabelURL.Name = "linkLabelURL"; - linkLabelURL.Size = new System.Drawing.Size(593, 76); - linkLabelURL.TabIndex = 25; - linkLabelURL.TabStop = true; - linkLabelURL.Text = "https://github.com/LogExperts/LogExpert"; - linkLabelURL.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - linkLabelURL.LinkClicked += OnLinkLabelURLClicked; - // - // panel1 - // - panel1.Controls.Add(okButton); - panel1.Dock = System.Windows.Forms.DockStyle.Fill; - panel1.Location = new System.Drawing.Point(317, 572); - panel1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - panel1.Name = "panel1"; - panel1.Size = new System.Drawing.Size(593, 72); - panel1.TabIndex = 26; - // - // okButton - // - okButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; - okButton.DialogResult = System.Windows.Forms.DialogResult.OK; - okButton.Location = new System.Drawing.Point(475, 32); - okButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - okButton.Name = "okButton"; - okButton.Size = new System.Drawing.Size(114, 35); - okButton.TabIndex = 0; - okButton.Text = "&OK"; - okButton.UseVisualStyleBackColor = true; - // - // AboutBox - // - ClientSize = new System.Drawing.Size(942, 677); - Controls.Add(tableLayoutPanel); - FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - MaximizeBox = false; - MinimizeBox = false; - Name = "AboutBox"; - Padding = new System.Windows.Forms.Padding(14); - ShowIcon = false; - ShowInTaskbar = false; - StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - Text = "AboutBox"; - tableLayoutPanel.ResumeLayout(false); - tableLayoutPanel.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)logoPictureBox).EndInit(); - panel1.ResumeLayout(false); - ResumeLayout(false); +// /// +// /// Required method for Designer support - do not modify +// /// the contents of this method with the code editor. +// /// +// private void InitializeComponent() +// { +// tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); +// logoPictureBox = new System.Windows.Forms.PictureBox(); +// labelProductName = new System.Windows.Forms.Label(); +// labelVersion = new System.Windows.Forms.Label(); +// labelCopyright = new System.Windows.Forms.Label(); +// textBoxDescription = new System.Windows.Forms.TextBox(); +// linkLabelURL = new System.Windows.Forms.LinkLabel(); +// panel1 = new System.Windows.Forms.Panel(); +// okButton = new System.Windows.Forms.Button(); +// tableLayoutPanel.SuspendLayout(); +// ((System.ComponentModel.ISupportInitialize)logoPictureBox).BeginInit(); +// panel1.SuspendLayout(); +// SuspendLayout(); +// // +// // tableLayoutPanel +// // +// tableLayoutPanel.ColumnCount = 2; +// tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 34.25484F)); +// tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 65.74516F)); +// tableLayoutPanel.Controls.Add(logoPictureBox, 0, 0); +// tableLayoutPanel.Controls.Add(labelProductName, 1, 0); +// tableLayoutPanel.Controls.Add(labelVersion, 1, 1); +// tableLayoutPanel.Controls.Add(labelCopyright, 1, 2); +// tableLayoutPanel.Controls.Add(textBoxDescription, 1, 4); +// tableLayoutPanel.Controls.Add(linkLabelURL, 1, 3); +// tableLayoutPanel.Controls.Add(panel1, 1, 5); +// tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; +// tableLayoutPanel.Location = new System.Drawing.Point(14, 14); +// tableLayoutPanel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); +// tableLayoutPanel.Name = "tableLayoutPanel"; +// tableLayoutPanel.RowCount = 6; +// tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.912043F)); +// tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.912043F)); +// tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.47226F)); +// tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.84032F)); +// tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 46.68471F)); +// tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.17862F)); +// tableLayoutPanel.Size = new System.Drawing.Size(914, 649); +// tableLayoutPanel.TabIndex = 0; +// // +// // logoPictureBox +// // +// logoPictureBox.Dock = System.Windows.Forms.DockStyle.Fill; +// logoPictureBox.Image = Properties.Resources.LogLover; +// logoPictureBox.Location = new System.Drawing.Point(4, 5); +// logoPictureBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); +// logoPictureBox.Name = "logoPictureBox"; +// tableLayoutPanel.SetRowSpan(logoPictureBox, 6); +// logoPictureBox.Size = new System.Drawing.Size(305, 639); +// logoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; +// logoPictureBox.TabIndex = 12; +// logoPictureBox.TabStop = false; +// // +// // labelProductName +// // +// labelProductName.Dock = System.Windows.Forms.DockStyle.Fill; +// labelProductName.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0); +// labelProductName.Location = new System.Drawing.Point(322, 0); +// labelProductName.Margin = new System.Windows.Forms.Padding(9, 0, 4, 0); +// labelProductName.MaximumSize = new System.Drawing.Size(0, 26); +// labelProductName.Name = "labelProductName"; +// labelProductName.Size = new System.Drawing.Size(588, 26); +// labelProductName.TabIndex = 19; +// labelProductName.Text = "Product Name"; +// labelProductName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; +// // +// // labelVersion +// // +// labelVersion.Dock = System.Windows.Forms.DockStyle.Fill; +// labelVersion.Location = new System.Drawing.Point(322, 64); +// labelVersion.Margin = new System.Windows.Forms.Padding(9, 0, 4, 0); +// labelVersion.MaximumSize = new System.Drawing.Size(0, 26); +// labelVersion.Name = "labelVersion"; +// labelVersion.Size = new System.Drawing.Size(588, 26); +// labelVersion.TabIndex = 0; +// labelVersion.Text = "Version"; +// labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; +// // +// // labelCopyright +// // +// labelCopyright.Dock = System.Windows.Forms.DockStyle.Fill; +// labelCopyright.Location = new System.Drawing.Point(322, 128); +// labelCopyright.Margin = new System.Windows.Forms.Padding(9, 0, 4, 0); +// labelCopyright.Name = "labelCopyright"; +// labelCopyright.Size = new System.Drawing.Size(588, 61); +// labelCopyright.TabIndex = 21; +// labelCopyright.Text = "Copyright"; +// labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; +// // +// // textBoxDescription +// // +// textBoxDescription.Dock = System.Windows.Forms.DockStyle.Fill; +// textBoxDescription.Location = new System.Drawing.Point(322, 270); +// textBoxDescription.Margin = new System.Windows.Forms.Padding(9, 5, 4, 5); +// textBoxDescription.Multiline = true; +// textBoxDescription.Name = "textBoxDescription"; +// textBoxDescription.ReadOnly = true; +// textBoxDescription.ScrollBars = System.Windows.Forms.ScrollBars.Both; +// textBoxDescription.Size = new System.Drawing.Size(588, 292); +// textBoxDescription.TabIndex = 23; +// textBoxDescription.TabStop = false; +// textBoxDescription.Text = "Description"; +// // +// // linkLabelURL +// // +// linkLabelURL.AutoSize = true; +// linkLabelURL.Dock = System.Windows.Forms.DockStyle.Fill; +// linkLabelURL.Location = new System.Drawing.Point(317, 189); +// linkLabelURL.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); +// linkLabelURL.Name = "linkLabelURL"; +// linkLabelURL.Size = new System.Drawing.Size(593, 76); +// linkLabelURL.TabIndex = 25; +// linkLabelURL.TabStop = true; +// linkLabelURL.Text = "https://github.com/LogExperts/LogExpert"; +// linkLabelURL.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; +// linkLabelURL.LinkClicked += OnLinkLabelURLClicked; +// // +// // panel1 +// // +// panel1.Controls.Add(okButton); +// panel1.Dock = System.Windows.Forms.DockStyle.Fill; +// panel1.Location = new System.Drawing.Point(317, 572); +// panel1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); +// panel1.Name = "panel1"; +// panel1.Size = new System.Drawing.Size(593, 72); +// panel1.TabIndex = 26; +// // +// // okButton +// // +// okButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; +// okButton.DialogResult = System.Windows.Forms.DialogResult.OK; +// okButton.Location = new System.Drawing.Point(475, 32); +// okButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); +// okButton.Name = "okButton"; +// okButton.Size = new System.Drawing.Size(114, 35); +// okButton.TabIndex = 0; +// okButton.Text = "&OK"; +// okButton.UseVisualStyleBackColor = true; +// // +// // AboutBox +// // +// ClientSize = new System.Drawing.Size(942, 677); +// Controls.Add(tableLayoutPanel); +// FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; +// Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); +// MaximizeBox = false; +// MinimizeBox = false; +// Name = "AboutBox"; +// Padding = new System.Windows.Forms.Padding(14); +// ShowIcon = false; +// ShowInTaskbar = false; +// StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; +// Text = "AboutBox"; +// tableLayoutPanel.ResumeLayout(false); +// tableLayoutPanel.PerformLayout(); +// ((System.ComponentModel.ISupportInitialize)logoPictureBox).EndInit(); +// panel1.ResumeLayout(false); +// ResumeLayout(false); +// } - } +// #endregion - #endregion - - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; - private System.Windows.Forms.PictureBox logoPictureBox; - private System.Windows.Forms.Label labelProductName; - private System.Windows.Forms.Label labelVersion; - private System.Windows.Forms.Label labelCopyright; - private System.Windows.Forms.TextBox textBoxDescription; - private System.Windows.Forms.LinkLabel linkLabelURL; - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Button okButton; - } -} +// private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; +// private System.Windows.Forms.PictureBox logoPictureBox; +// private System.Windows.Forms.Label labelProductName; +// private System.Windows.Forms.Label labelVersion; +// private System.Windows.Forms.Label labelCopyright; +// private System.Windows.Forms.TextBox textBoxDescription; +// private System.Windows.Forms.LinkLabel linkLabelURL; +// private System.Windows.Forms.Panel panel1; +// private System.Windows.Forms.Button okButton; +// } +//} diff --git a/src/LogExpert/Dialogs/AboutBox.cs b/src/LogExpert/Dialogs/AboutBox.cs index 77663d42..8b0d801b 100644 --- a/src/LogExpert/Dialogs/AboutBox.cs +++ b/src/LogExpert/Dialogs/AboutBox.cs @@ -1,132 +1,128 @@ -using System.Diagnostics; -using System.IO; -using System.Reflection; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - internal partial class AboutBox : Form - { - #region Fields - - private readonly Assembly _assembly; - - #endregion - - #region cTor - - public AboutBox() - { - InitializeComponent(); - - _assembly = Assembly.GetExecutingAssembly(); - - Text = $@"About {AssemblyTitle}"; - labelProductName.Text = AssemblyProduct; - labelVersion.Text = AssemblyVersion; - labelCopyright.Text = AssemblyCopyright; - //this.labelCompanyName.Text = AssemblyCompany; - textBoxDescription.Text = AssemblyDescription + - "\r\n\r\nCredits:\r\n\r\n" + - "DockPanel control (c) 2007 Weifen Luo \r\n" + - "Early bird test: Mathias Dräger\r\n" + - "\r\n" + - "LogExpert uses modules from:\r\n" + - "http://sourceforge.net/projects/dockpanelsuite/\r\n" + - "http://www.xml-rpc.net/"; - string link = "https://github.com/LogExperts/LogExpert"; - linkLabelURL.Links.Add(new LinkLabel.Link(0, link.Length, link)); - } - - #endregion - - #region Properties - - public string AssemblyTitle - { - get - { - object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); - if (attributes.Length > 0) - { - AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; - if (titleAttribute.Title != "") - { - return titleAttribute.Title; - } - } - return Path.GetFileNameWithoutExtension(_assembly.Location); - } - } - - public string AssemblyVersion - { - get - { - AssemblyName assembly = _assembly.GetName(); - string version = $"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}.{assembly.Version.Revision}"; - if (assembly.Version.Revision >= 9000) - { - version += " Testrelease"; - } - - return version; - } - } - - public string AssemblyDescription - { - get - { - object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); - if (attributes.Length == 0) - { - return string.Empty; - } - return ((AssemblyDescriptionAttribute)attributes[0]).Description; - } - } - - public string AssemblyProduct - { - get - { - object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false); - if (attributes.Length == 0) - { - return string.Empty; - } - return ((AssemblyProductAttribute)attributes[0]).Product; - } - } - - public string AssemblyCopyright - { - get - { - object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); - if (attributes.Length == 0) - { - return string.Empty; - } - return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; - } - } - - #endregion - - #region Events handler - - private void OnLinkLabelURLClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - string target = e.Link.LinkData as string; - Process.Start(new ProcessStartInfo - { - UseShellExecute = true, - FileName = target, - }); - } - - #endregion - } -} \ No newline at end of file +//using System.Diagnostics; +//using System.IO; +//using System.Reflection; +//using System.Windows.Forms; + +//namespace LogExpert.Dialogs +//{ +// internal partial class AboutBox : Form +// { +// #region Fields + +// private readonly Assembly _assembly; + +// #endregion + +// #region cTor + +// public AboutBox() +// { +// InitializeComponent(); + +// _assembly = Assembly.GetExecutingAssembly(); + +// Text = $@"About {AssemblyTitle}"; +// labelProductName.Text = AssemblyProduct; +// labelVersion.Text = AssemblyVersion; +// labelCopyright.Text = AssemblyCopyright; +// //this.labelCompanyName.Text = AssemblyCompany; +// textBoxDescription.Text = AssemblyDescription + +// "\r\n\r\nCredits:\r\n\r\n" + +// "LogExpert uses modules from:\r\n" + +// "https://github.com/dockpanelsuite/dockpanelsuite\r\n"; +// string link = "https://github.com/LogExperts/LogExpert"; +// linkLabelURL.Links.Add(new LinkLabel.Link(0, link.Length, link)); +// } + +// #endregion + +// #region Properties + +// public string AssemblyTitle +// { +// get +// { +// object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); +// if (attributes.Length > 0) +// { +// AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; +// if (titleAttribute.Title != string.Empty) +// { +// return titleAttribute.Title; +// } +// } +// return Path.GetFileNameWithoutExtension(_assembly.Location); +// } +// } + +// public string AssemblyVersion +// { +// get +// { +// AssemblyName assembly = _assembly.GetName(); +// string version = $"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}.{assembly.Version.Revision}"; +// if (assembly.Version.Revision >= 9000) +// { +// version += " Testrelease"; +// } + +// return version; +// } +// } + +// public string AssemblyDescription +// { +// get +// { +// object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); +// if (attributes.Length == 0) +// { +// return string.Empty; +// } +// return ((AssemblyDescriptionAttribute)attributes[0]).Description; +// } +// } + +// public string AssemblyProduct +// { +// get +// { +// object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false); +// if (attributes.Length == 0) +// { +// return string.Empty; +// } +// return ((AssemblyProductAttribute)attributes[0]).Product; +// } +// } + +// public string AssemblyCopyright +// { +// get +// { +// object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); +// if (attributes.Length == 0) +// { +// return string.Empty; +// } +// return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; +// } +// } + +// #endregion + +// #region Events handler + +// private void OnLinkLabelURLClicked(object sender, LinkLabelLinkClickedEventArgs e) +// { +// string target = e.Link.LinkData as string; +// Process.Start(new ProcessStartInfo +// { +// UseShellExecute = true, +// FileName = target, +// }); +// } + +// #endregion +// } +//} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/HighlightDialog.Designer.cs b/src/LogExpert/Dialogs/HighlightDialog.Designer.cs index f3c92b7a..e0e5faec 100644 --- a/src/LogExpert/Dialogs/HighlightDialog.Designer.cs +++ b/src/LogExpert/Dialogs/HighlightDialog.Designer.cs @@ -1,5 +1,4 @@ -using LogExpert.Properties; -using System.Drawing; +using System.Drawing; namespace LogExpert.Dialogs { diff --git a/src/LogExpert/LogExpert.csproj b/src/LogExpert/LogExpert.csproj index 8c9d0e78..e50b597a 100644 --- a/src/LogExpert/LogExpert.csproj +++ b/src/LogExpert/LogExpert.csproj @@ -3,7 +3,7 @@ net8.0-windows true WinExe - Resources\logexpert.ico + logexpert.ico false true true @@ -54,12 +54,6 @@ Component - - PublicResXFileCodeGenerator - True - True - Resources.resx - Key.snk @@ -74,6 +68,7 @@ Always + @@ -88,16 +83,11 @@ + - - - PublicResXFileCodeGenerator - Resources.Designer.cs - - diff --git a/src/LogExpert/Properties/Settings.Designer.cs b/src/LogExpert/Properties/Settings.Designer.cs deleted file mode 100644 index 6f26ca6e..00000000 --- a/src/LogExpert/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace LogExpert.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.8.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/src/LogExpert/Properties/Settings.settings b/src/LogExpert/Properties/Settings.settings deleted file mode 100644 index eeb7df06..00000000 --- a/src/LogExpert/Properties/Settings.settings +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/src/LogExpert/Resources/AdvancedIcon.bmp b/src/LogExpert/Resources/AdvancedIcon.bmp deleted file mode 100644 index efe1532017ae038bbab942b16401e5e700cc5d11..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1198 zcmZwFJ#O4U42EGE2n=@tasrk{+~5c#ghFF>+rr5}LMSw5 zw=|s$B!og^cDs3r6i5h##%w8+lYxX#Xv~&LI~hm_g~nVZq;WEk5DJa4X8vuCKtd>- zZML-B$v{FVG-k^#oD3v{LSwch)5$v+p?jsH3N+Su{R=Z@q5@1C#t=N;!yoBak;2&f^+Jp_MhYir?11KUtT1Koo!{G*5HpX^VfiXBT- zRgI!MRg-4Z15lhq4^*)a6lYJG4F?kNx29(HsHz(Je@#{9|C%Z|?p+Ok;pgb%1YA_y#y3z%=+!jOf?-*lf+`?^a0efAez`{iegUN@Bbk3eRShcx zG1-B{B)?qaRRQGm&U+U?-9edM!0M*=gAe@yoaX209UCh{b^LnT#88*d0wXa9W zs`b7a{Lj8{OoOjQ&(mug@_cANuYfOfa@g9^Jzx^{H~teN5F-#H5F-#H5F-#H5F-#H z5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H z5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#H5F-#Hu>T_d^In|L=tu2ZCA_s<7zNlyjc zKBbL!jSpO7laIeog7?yDHIaVUk{Y{TwMCW=(UiWnvCK_v7VzgR09^2%qk$|sU&06O zS5Mvo9tOI-p$~UcAF?gLpR)iJK@@*if7jL5Czbw+bV3Vg^?uR>qV%$iSKRbRbfYBj z@aH0kvjE`llORp173l~2$@A~i$56@nPWo-v+~THT3-He`f;<**we^}B^$Ej&n~#4!5tLgC`z+vU z^{!f{%fFTIL9G&tz20b|^fc2iy7qru8}Mf&@cMr?3s5T{rwH=3F!X=60SVS7<$f|g za<4y4E31%@pV-!0uKizz|9=7&5JgZ(3){w0*La^9Vtf>o8Hjo!h_L`AK}s2+;Nw~u zB73X3lGIMqE_Lh=UFTER0sI*W3W}h_;bWzN6O``PImy+5FT!(2gtRba0hQwKs_&$g z`xSiB-g>51Q;#eko=E)Dbw8sU#sAZQ1p*Ni*21>6g!H-*yu~%%5`;!U$&M58 zgR?p8;tqc3>BJGE0un&~=PZ!X!XExEsk0Oy!MB|Y6y;W_-`*Lf<97D zs6eagqJRhTCv$w;HsvSfw((kEh;c(8qlG~PF%rCOe_KhQkkiuEEVu0I5dK^Qg|)C_ zZ6Mvs(dG{`AZNoa9{J`Q`Kn>2`*a==M76MozpDTVp8vM#0)=!l?HAp$9RdEF1wj6U zMUeAf$6BYHRgOOUtXS{^LP%q(lO68n?zmtS5_iWjTZ|e4Tm%6NFcQ49KM5j2 z&amD0=upSUKPLUJ z0aa-Ang}7JvDHSqdpwV{&jQR4@U$>vfj1cm<`L9dNkGWywo^wPJ0AX}06xc`vjAg< zvK>~NMdXM-r`y%IrC%^#P_gbfVO}`*yu6cqCsp#GcH$k%#g+KZYP4mGM+qgt4`L&LVPKPi@b zMxdC`6kA)AJaCNK{dW1vO1x+po-1LUWY0u2y?~wpR5S2o9*;@U`@xeee9}6%A;o~25$1$>IiJ;3uYk=#Ac$Jl+%bf!nW<-~aYTg!^#3ReIPMnZXSd)P&zNl%vQa1> zh&HN)zYt~w_`I+vf^ur%%|VQGVJ+;%MerGcs5_1s0@M}@@CPnf;i5NeR7=n)EkqD0 z@`-8VVI~c-@%LEZGtzw^oj}>KL+?B~!va(VL=Ay#5oEP_LqB?qcG_sQ_gM0)vC1FE zN&h=exq2MAWQ^K-ly=$({itEdgD0fz$1G!^lX^G90!@jI^FmXCQIIzfVk(%~!dwe8 z7I=e^U=~69K8{F{k1-N=(hylHjRAj70ycrpw6J#EaJ23{&+5^-j?CcSm^;pKw`s?X zz+)b0+zY*RD_XuBS3fBYm>~bpaP_R=iNi))#{4E};YJMsPX%}^;G*Rgnnuv^`;ZGD z4=$;DC9Va5W~9jEjx=jJNEL$N!be~uq|O1^BE z+I6sTz&%a^0^~pi7q5liGWBXlUKkQVffk1T&$i_znyjFGlk_Lywz~Q^nifHW^8@@T z3ozl#R6y#W+4!EvMZ}a}kEQ+JcL#wM7DW(u2T?6-yKm#Wr;ESc_5JnhrQ7aOE*Jum z%1(H35j->~8Xf0}pp`m8p*sBZTPL;Rwb$5;7!MGIArKt} znPeuK?+1F}#mluL%A*6(Km-B)uqDyoWdyGS-WwmHoaGqxG!M?h-zNcxAg+bCC}-Y? zzWOQ~H1NH652|MjF-q@owYU5k0Tvx+D=*_IkMX+j zk~j22ZxsfjAra(}Ac3xsP@6qX03x66Bv;bWHN`(5fhU4|7WhOxX<$CRDGj>EaX)TM z1o`eb`7d{J1orICnmYNKQR>OJq|K?W3ck2^(&?F?zQs!MwAn_RiEJS1+rnH6d-#{2 zWjgxB9>t%?KeUZk>7dTTpR<6Vh4rJxqUEc_mW%t)-yC;iAc7ik$0?VO7k|4K_VK*M z@)bjsOGe7K-JM+>Oy!u##{@0xkAedHK@cs~Q13lN0!2F2GHR$(m*O9gfQlfl1-2R; zs_~5HvRlrN;Hv4ivyRTQ7vYX0zu4RO^LFOjkuMqG$S-^DxQG_^sNkZ7d%{NtxyQTTB&kMzLtB(@%@k6&KhA-hBbPksVP0Lb*0yRTP&=F z0}{MU&}q%c1&VZ>VN9a-3tex7c~pG-JuN`{ziquCUsYKcd^n3Aoo(661pK)O%Atj| z)Be@y4fnwXTehgj^o!WSf(W9+AqPE6Q1fKp%eZqgHJFCeQ~VhTJQ0*(fsdTjdilH? z(Kp{TiUyutYuO7a{vi>R(-8PZ?=r5@8}5?}@RAjYLk0^hu-r2QL@LJkxxI;m>CT0v5<}$0a*Hggz`f=6nxX z3VCjer#_V`ogAnDP{g#`M>Y#RprBn(x5U`djX%)%ZHhl5fiHprEkH*>oAu7a(V8OC zBD@D#yx6p!59WpQXyG6_&McdU7A`7^ta(t{qra7It}^u}0utn40U(EoCMc-Ou5p28 zT;%F&S^T_+e@FzS4w{CiKhuQAT)sSA@>GC7XMx;W*e>0G@1o&YEq0SH9_Zj#vJ8O` zBc#v}1vNSETQ$yiwAIW>0s#Xa3xEjnw1C(DH(B<4sl16M(wa4?wlmqhJe!(tWL|!U z)W78ofyDms)mNnFKV7_xyW=7v$SWG?1{rlMo(qU}rlY;?J4UFV3P>Qb0E~h*I>|bv z&rMD4nf3L?cc#x!kRhO+)e7(j4#f{V znR4$d(Eou8T=WV-T?>#v!UrVW{?q|Wmr7V0;Lnn$1Q7($$W7C^BK{wLoH%3>!=Hx+ z1uQ_LL!%-{Ke=__4vs_rE$5)bhAND#1qAc9QuCF#c9(21Kj z)0{*Fg#ctKO7x9NYP15~(7roBW&bgCB z|Bz5yQ4lHW56r~VGyvO=L={Rho0((&g*4F6DcTz)P5 zl{9ctYr-FNaqX){yU`-r+4~N9kt+f<^-~(|3qij$2T){zj21T9P1$vwE8<^QmufdH zSAeJ}fpOE)x= zD|q$lRNF@b{5cDNJ2V&t@z9jO9Y-#0efR^z%D=hAMT(SAr4<{{URjxJX5 z8FWIEC0*tcL3QMmf9|f%6&auU-=4@0&<%T}MMK~lty`-x0V2Ir>2rGl{DC`Qf*ryqT1F*7^6)he-vG}r#lo!apO z3*etZ72Xg?#Xk;MKomjVKWeV#$8pue zMIl_UgW;#=SgBXU81=9%oZAqP|In;!(G+Z9Gd$x1PngO7b8&WboIm(f(T^kGdqsk~ zI`WdRA>eCaa7RO`I9f+TvUg|0k3VCj<_l>WjcQ?P2#~(52mjALQ;+RmAT%Y7MoOq% zPW<7ZhA$RaK=efb7u1nnH{@GXq)4LRN1w9NuL}4_Gxc&B0_xe#ItJdoE>!qQ<;!n# zqy+;0kGe(<_2x$w;y=w}qox*l0futzTb!E&Jq3xi5r9FDj5GlaPK}xaae; zAcYKRkiY^NcN~k0s81X=4A<_8O@t>@+v!yS{yCCWGoe93fT&qA7rpxGK0&p}N~P<@ zS&3(u>hxEwi3I4H;s`go11~8smr4qw)V|w}Wp=8yikT=vQ=8+3v0Xj!n6p$dw z0uUW!9CVj7>VYOLPAd(+&q>!Y{JnhbqO`E(ypEro(}H0C-~$*)$bT9|&K;&7GdOKM z%uoXS83}y+>8dp}Iux%+*!?ilBJdVdRPlMPvO3?S7$k4niMe{Gp~}w(<4M(M-MU60 z!sDR-FBdZPa*Cknyu9VE!qcB_^yYiyf=!!H?ObW-Wclh5r0;OG*HFF7V58jxo4iOB zqPLDWxQjifna={E2wG{8SxRCT1JPk>I3fL&-aJbSN223weUb5aL3VH>?xrmbm=j1GHobe(*8rrt$Lc zD#_1=s@(@`o$oNdJJC!&<>;$e5T=(b98FfG;CLj6iXdQt6{KC?V!C?1YZTliB~K_Y zFYm|b`Z)rAfUc8xGi^`TI}XuKz5^(tTv93jbtE1?70rJYZQhI@ctW{oh}vUl;_&g7 z^O9?S6wCv$z z$jr-AF7TtX!~oq;jCzo)3TZN{O{*r^VY1$3q}FY;de&HS&Jg*ei>2?JAh$b%w7V=( zHpsT?!qIWm5O7L1!Q!h$;lFJg#0%jWv!y|I$$uKI{CXHUzf$d4sU1I5|K3QW-Bg&% zhE+pdi>;YJ(`LojN*1|xT(PUxr0pq6`{qf9g!gnnN-|p;K@1II0ir^597~f4#i$of zRt*M1z7}@u4_s$!5S`^s3VWlV?fS7}AstWcJzhO$Jj@8IKZTuf>e*w}Ge;|@{Dqt| zLjB=z?HE}0WKycl6PCTiaX0yN++%CU`B9p}s~kivY?C?4p?!+%;l*4QCV|KTL4a;n zjC$c@)uw7;KRUFLRcpQ~{%tbNvUVKP!fbFTh#*U=Q4Tn_7*v~d4Z)|`WF8C9Wrjc_ zG3r5@QYKR`XTE%nRcpc`C}Ri+0lGOCZelB|Ku!nE?}H82&VreRthM8!?{o{+j-ziD z<|0UVtzi>Zt)T-Ui_9eIo_ezqaDk;f%Y6|+j5M%7t~8lE$*RGs9paJ^MHvE776`52 z%AzKsYsayf9ZCY`=q_>vSLiTw^WHBnXyMEYt@x@bOb(ED9I`B>RO!+mReY|3_v~^s zGVTO31*&v`E?)s}`c9LF9Cc|fElks7vhuaXe0jcb5Lf}+5a0t*aZ)VgjtkaN-)C#b zL1vbv)}+XUqTcgYLkRXb6t#)q2ObQbcQBhl2EQO$RJaj<>+s?Nl?Uo zrdZKh7{KTF=XJ*g_~#TsIhU_&T`Vl)vlB?=`tE zJSn_fUcv`97l6%v9|^aC783bXRX$r&exZ@y>g4K#dTl~2H?-mDM73qSV5e3&<_5NK z7GJf7vw%1$7R<{F?l`tsbdV+!B&+%d=?bEt1^ibzFcrYHfGC1s1=p>P`L>msmrl+! z65|tEc|!f0u3iPL)s$bVN^c@}Q>5c%>9A(UXP@5?5^do1){1-zQMwVOmrBl6Ngqx9 zm8M>%X}{OCt91P@x_)gU(JzrGPb3Eltt=XnM&vKVTT)I>Gpn* zQ?|`6eb;hVn$Ci>^-Riq*ho!G8bcDv8xx7^bp0Q?evPjEQPZx_)Js)zAt7ff@(&dG zSV@Xs%G|{6fHg^OFDpkY%83d&8Q$Xt@6l7pNwU&KmOEmcYU1to@#PKiCq|&@2<&Vh z{>^qPT;8UI%e6RMt^j9-_(5oZSloe753#%*p-=_eAW}g*Uk@|qV!0NfP=%Dqg!4OT zc|hg>R2Qlcsza!K<~&pvYCt_L3k|5HWuXBTv@A4$7KH||>V*nf^+JWLI-$aP_VY}I zwO*N5SmBjf^yKh~hyOqn&PB2#7!$`n0B#PWcK2BA5u0YYqL+-BS_+}XJ*!&L3{Xx>Ci{^Qj z^saT1KJk_%QOU%z{kR88vh&bCyI+veu}v#zm_3eW&DzzmCHm!p|vG*#h^L zI+7~3!dCQ_mL5}1oGb+-%Z7D5T(cx1_Cn4ZaEbcHJ|7gHVP(vMd?EdwxZZ(h-P0J@ zof7A0s`~6FJSApGfVsHbZ38Ra#5_a9s6@O$sJ<1|%TWS%Q|G`RBD z1{n7RZ>Pl=@IR&i!eyi3Chq5fClAV~?+xUmKMPL0hl0Up_(<%9PvBcQex#3Ah}ZrD D_6`X| diff --git a/src/LogExpert/Resources/LogExpert-Icon.gif b/src/LogExpert/Resources/LogExpert-Icon.gif deleted file mode 100644 index 3fcd29d6264d21bff0abb1b0ed38ccfb436c1096..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 591 zcmZ?wbhEHb6krfwcoxcV;>4K;4<7E>bKuC46Zh^tICSXPuV23&K74%c+{K$WZ$EqX z;?0}4ckbNh;o+5#kl45Hz|o^83=NI`{rlJ2+S=9CbMD;v+qds=ad8(HmpV8&iiwH6 zfB#|2mK~2DKjq`&-@0|jlPAx5d;1v~896vOR<2xk;lgDxG4W%^PTahC$HT*`xVY@m zqbF0QOh0w%ytA|OxpNnG@7}MarG5PP>2>Qi`S}I%@bH{DbH1dc{KSdVuCA_o_a0oc zX3go-=eKR!wQbwZs;XKW8|(AuFPWN}UcP+I$jDe%SC@~EkDHtO)vGthkDt=f(Y<>0 z#-&SF_w76U?%n$b4<22q;OZHzN#uduU?5T6q-CmbjS}2r- zMU?NTwZdbzCMG7WqbA0-b~5q?e(daWM-9E)Ld1hg3=W)Zozl#~|7?N60+*>QoN_KR cJqneW*fexPfX-!{(yw6u=|RV0F9il`0FKAe*8l(j diff --git a/src/LogExpert/Resources/LogExpert-Logo.png b/src/LogExpert/Resources/LogExpert-Logo.png deleted file mode 100644 index b94e7cfd443c4f99df289c05d88f51ca2cbb09cd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7812 zcmV-~9(&=5P)HqU+EH1G0v*-Xp~%Wo z%HdSX;Z!(WO4)*fyGq1eE>c}?N=22(p3R1_t5W0uP$nYYmMvB0p<0??rIZWkaI9wO zQ=qh?3zRBotF*ivrSjS+a_mZFS;1jb%3%eERZ+WFjy6g;@-$^{qm;9a!ji2NS(+kS zDXa<cT&3;3wD@5D@k!rtC?L(@4g4-ifT_aNM7OJa6s>?;( zRU&2OV(#81W?_xUK|(i&za{D~8JdM)rIfRW(oX2Ftf%(Wv>xr0)*~0y*{;aXS6WVI zP0Q_|l-^F$uo6K^6iIb{M-v$5cqGALa;5f9tg%bw5gJ z-Hy{N9lIz^r9(=(BqmA=>5*7(pHA9{{Q)uAhUwmInk8zz7I| zAh>NpJ5$3|rqQ|DLTAx%DU~{jWPtEEGQaHN3$8led)3SjgYPz)kO*Xi;Bgk`2U9iI zC`*h=ht$ba3OphdV^W-DaxmAx*T!U{*QBxv3JgU-Kx3%i#z~sBp6s_ec)4ax&7pkb zp}HChcfjs7it0iQvs59a3iF_blqrl-gXvuZMQ=>lD@3^xIX>!7R*X5VPz!VlU2F}*nb-B!!l`PLaqsX>kHCu9U~^`s%h#01&xh-u3$SFMCv+f2R1Gku z%rW3x^amQ7U)ltprRk$5XpZX-xtJ)6@+(+;c{P)s4mMt^G~Kk;_Q)p~ATJ+=KI&sb zK@8)pCEA6?Si5~6B8|MVD zHMT8`(kdkv4M=|Lu;4JRxyRt^i`_B$)rU(tR&$&)NZA@3QKwAsnVNp>M9n!yqwXkF zSf4LD`MBswKTc;uRXGf0A+EI^8p$FC;jN5dfN{_J`J!+9Y3N?2#d#98-!xQyN(2`u zOZ$t_@9K(Hr=t_D;1Y|8i^0 z5T#$$5cw$)e38;;j@Il0fS4Bb=?FJh|4#!W=0sXWFq@3)|+deVo3{02_B?uXI!D|7l*Ts-oDNAbM=f2PiaPL70*paxa-0kgRb2( zt44F7Z2=hPC4L~}N*t#R#ddwVvXc@#R9S!5Plcl9Sf*1p+)s}_>1LZ;t5gH4uwLak z201wy)}tA5>7Rmp+aW&5?a{15uwId_+=K)luWV# z-UDcnNvc7yD06_qig%TVMJH-iSt~%`$Qu;y)h8(2iHAV zcVBOwxRn!ZnqcfqT#rMs<)47{;xA8ymF8)URucRY8sc-$n7kGSjyPDbTQREN z$9L~`32sa`kCdXLgJKrHRus5$Wxn5=XjCa%DF(gaV(!z847y@O(XoQ7FbXm0IVBd48$*UT8=@DKoJ$5cqtS*Y~GAx?v`=s$O0z!AD%ITGsHO zOXA3mM)>@mHU?d~H8{H#!Ha*iaO!*6SQ3=d1RldZe<#}iE~MBqRhgLds2m{$v6!SfoO|B*$GnfMld7SFfu;2S3* z4Q_wZ_NA|t`fvDqPR;Uq4l#=G(VJY%8sEU6D;QPqI75_&(264HRi7&=?{(3=I&rKr zAK#9}_$G=-Wn=P7n_v+MymY{S;Y+!m9}`)YA{2DJct-<*u3(CNUux%1TM5B?cf<0@ z4vycW$DLRJSWck$LwvVxl;G;d=GmZVs7lPT+57$HznSCR1;iZuhuWZPP8Re3k!Ci* z!zLQ@ZHQ>(9r+Qo&j)kH+c{%h;)r=2!SYw}{_zX(&(B1@4Gwp=o57v09rR!RQI@Z` z-pL43diyNMG#6{WN+ak>^f*_9dp`7#c`N7xKXZeP5lgd3^diZ249^RA?q4Fl*_q0> zQT>^fM&P@b%KX>;+Yu;Fl6y&C(X#~04F95MD!sR?u?K7F1VB;DjN0Pl?eTWJsVtHZw%~YfIzqNj zz~14=bMV`4Aq%{nm&0Zf*)4GB(dQ zKj@qJklQnDpJvAF7%4ypE?$_;?Eg*@SsO`$st6Qj8FcN{5RDs$ni_cbNsU>*v$FhO z^{eq<2`u}ygTaONxH1gjacVw#7vHtgL~Che@O3Si8}$8otj*r;AxGAvyvS%M0{JKg z&(2~&?`kf(B~B+f5OHCQzHj6kd?h&sXLih784@8Fge7k)c7JGvuWg*N+m1^VAI|r1 z!Uzv~?R-HX0IyuDbN(7LL47P`CpY&9oBu)W*;a4*H?$5NCx$ zNR)ei5zoqn_GW)K+}53SHy z_(zkYdU)tLAnN|EZOLN=RnbsQG|?{tpS-Eq@s^FY%XCJR>xaznkTb2_YoYhZC@z9I z*V!4lG%MkYj&I>zzX<k7{r|RNd~apQIy(bItGnDn)CLeVg~jhH zc1(3};W}shxBF2n#J_z3{_EFDU~A?ykB=r@C##Re+IfQAzTg&{V^F;198fTOST(Iq_8MzF`61V-0thm+AAp53NbIHx=Te4}ww_hmM&$D2zvtZv~VQ7h+HcBO5 zav|ckU*G^H9VGEm56cMdeHqX7Uy6TG1FJM`H2FekL#(!AZ?xOrzuIQ+8{L-;6YLS; z{jpU{cs9tw*Ayq-o=2`$xBXTse#PxmCW}s~A@^hhdq<(maYEPLLT)bX-3zKKXAW>EGXG5wEI^WeY4cW=|wY+^L)Vx*Vq_UmqQI37REYHb%89jCHV zU7d<1gRWE#%g-3$wfiD51CLVk_m9Na;I{)Cize;wZW@cZAnK-Yr;Po1mVx+F@Qie(XTD0+)6w7%@f<35Cyc>yX01h5S> z7<9Ek$$X7VpKL?t8cS@swFh^L>76DuGZ%^P&P3&EF0=^203Z4NADpM_0aNjh3v^qz zR9y5jdw_-Ay_{5`GkmX(OR1RF8o5u^V%O_IwjCY7HZVw=AqHpv!lYfhP+$4^$ySEW zZbM!`)e#>pcNeDTQK^}+NPK@vUIWd87GLpwq^^&g>~uVLiEir|H@M=kwSCpzPv9Om z-bzK)QY);o(CL7cZXOHmH7#iXRACC+Z3aaJLFj0rx|&#yH5h!k!GNgsZ2W$BX1tAa z-p?jWRKlQYJBH^m)AQIO@!j1F)s`|^oM3>Fx_;J8PWy|a?Ru|N`o1gk19LXF=`$c&$N%tmgx#5!Vy6*z?r)3^vO=gOJg1S(U83FyEZ4l!6|OeyD{^V4JAb| z=PEm+R%D@)c!Vt&?&+rIp+%;z(TkQf1&$bk0fy_glW%c4W?$vdkAXOS&xm82oI!T} z&dsI2&D{DR+tw>S9&hKOwXURn-_01+(@oEVi%j2NGp0a>aYPXeaJp_AaV$~!k=WKN(9H|mulWA1V5YJy0nZAb`opBT5h$9%_ z6x}xHCa3+?@eccOsf;e|vzh$+`fA2K((nf(KAx>nd7qP$i|k29!#0{m)!)Q(|02`( zXk*LT)Hosu1~}1XJ8qKG{@M)=`_EDt{6DCKPp+!smrn-Me!}DByDap0CX3!~Yr>le zfem6*%rHIoEjBazcxzMPh$R?cu+4hRB&TD}M7#ZjWbL64T6p}ubE~=W~BnRIEJJ$vET#d z40SVZj*t9;_;L%k!`xrlxnz0h@tR~43v10_`ApOM=f$S)sirJ%rg6j*3~-Fq+WjVn z{jJFk$4SYi>caaskFDYSfBNXzuYUPfF4oxedk1H3cEq;YC|N&9u=EMTbJr)P{~yg& z=1ieg5Dd`UV(B``;dt|QhvU>_t~9(~*uzVwyS9{ag1=j^KIG!~gSM2W7*|X1 z;1h;t$|t7(x#lf#X3%N~2Iy|FbR4VeZ%%c&&WJU-1oesDq6b+sx`wN!2YK&qE62^w zqKnUx)B_0cwHe&^oZ~dX}i_+q`)<_Ev0t-8P z8NSDkQ&hsXHvE6S;othY>AU?))4!la3YsCbI)VX|QfjoWPoL^=-q=U8xKimWL-I7? z{mX`T^*g5jm#fUcsun3=2GJ@B4&y>yzx8&z^UuR9)()w*%Zc215cpfr^Tk}#|BLNr zu&5=R{naVD^AeXz zJUJif&NrDx^%FtQ1sV%90Q{g8=Fo06ZGRms|WundTt5Yo2qad+ce#h`_d)M$k zu+(V1-JoRnNf8{zP^;~rJEj$)IQU2ZsNSrhM`GNWo8*;4n_N>gSKpY!6PbIZk*l z=-cwX;lKOSpubsP0BcG7R4u^oeP(061a^&V?a=f=Q`<&F&Q#t(2N4 zBGpZ*STka%QbUe`tBYX63i#X&J4B?;ha|0LoW*O}u(vl-dvG*Kh#P+JU1jxbi@A zLg#Fy+O>^nlB%JsRAe(ij#Bw~&^LU}2i{_lACyu~pj}t!+ye&mfLmjouvw3GCV>Qe1mXNoe)bdV?4h;1RGY zr8)s#Yw*y*fpt-n#DbMlmdj!4|H6ck&^fY}cSGPeN-bOhcm5!%W3K_k%kZy1Jl`9olY% z=kI_|C%}+!`Vy%Axl%KJgjc7+`{zNw@HsaGM=JG)U%|wy;OGwE=t#(70KSCLk12KM zY-sm{QWeFpYdO5RNTl93j)p5W=0TWpISdJ}o$3wAxOc2lFTDeIiAbQgQe8&CBb}k0 z1M;7S&c{QinegmoO6?p7XH06)`9E-nFbp~ zglX_YblR_>Y8tGMCFf$e_aXQ;Q8}aX^^J$O0Bcy+OW+SHpgP_)`#^4h*F=OI7`PO? z(P`#EMN#eV=V9-a@NhC+{tAmVBaQ{DkTJx>`AYrbHW-^7FF`HFL!XiGG{A7U?+iF9 zR=Rj^nFM3Fpa}Rp33TiR91V0K6o|QDAA~+O6^;IoeIpErCC3DOkn*Q(x`F;6jJ*sV z02rjy;BoMqz7Y2lXAa;_7<;)=lPY2TDyaAIgEJr}{B6=2@VQfHLOtM%8)T87@=kzj z`a$Avq1NI;7^al!);GfSh2aNYhh0C$X$}HOKhKdm+;9+JIm|6iEcX!p4r{l=^PV&a zh7gmZVVqK`%`mv*g3x_-2rt6-SHi#6up(0kAd9e8p@bYRXi#|6Dy7Y(ByFkzA za|MuhE}WGUrN1-ebOTiFQrE2z)^Y7 zr5kkZ0G+nM(hH$Ybo$M(V=cV78^-sG@VXA56R0gvd=k|0>LZ}jZ{f9}aol4Pg0o#v zZ@qj0&WE*|;7J22+J~a&zNN74pGviNivARjg-hb;U`aeyp5=;R!3vlQ154o_rQqKWRW{IaA?tPcWUx|yoD9## zBNsxxZzf#qfaib-@zRZlQ4c8f{naoq`rICn9q?T#oC(xfzh@5YFNgJBC@qK5H6d5J zemlGtFR!_9@BuizP-JiTm_5b~ZUg=d*PI0BT&+}5T!Q13z7#6gz*;|yjI7-PPz5mp ziBDl|C2Uv-lY2t{$r1g`6c9Ja>H>MrI5&W+cIz6t0S;NvtFUtfJbh&fI^=@78?GCn z)Uu=Fq&XJa91DYEo%<4Y?ttanVXII#U^or(-UuxwoeUkP!!?^D$cu&(WDitD z9*b7enJ)D{-{SQ#F1g6%0J#%+2rOw|7Ge*GB zkh!oI@c$^4jW9UU3Ut0Qo7r<9!HzU@dIC98QZqX9D}c=uF*}_`8D53Ek7k z27pR1=fMjiQkkRFJukqi6C?WG-N5z-7#?}eD)=9z)FKgy*{f+2YVER!2+X`mf<-S> zYbuQ?!~H-xY!(skLb&m-@X7weAA_xf4`BOKaMx!dhrYqr2af9q+Q+cqT6ptvcl_F&y zz|GTP#lZxD-C#KS1UNU|d1uI4>%=gdVa^Ak5x;t<0=7VrbshX`8tn5E>USCtG$3dN ziz763Xt#sI2CiaouBi=IFJ02f;AG2!?dm^^nft&At`R>{y#e zo$@72{8=b^Zl47OLGZevbQkPi0uP0UELX!Dk3d-fFhHzeDGK!h>hzDl6Zv7VQkQ)O zlX^lo3*>mgT?+eG!_sB&O5BmErq~{X6{(B{t%RB@;rGp{TcYjP@JyVMwg+lQ)l^IC z7;kH~Cpwf;Syhl9vw^9F8<-70-UoNRA@W#r>DExxenS(HBlpS0W?OAmMBG_Qowfw7 z=mq`rAwL`PZD0#RWjXBs0e)BtvqZ$*TzaK~{qX&>u)zUVYiNl}iyLsmik8+b8U7E( W_uNB%B>_SJ0000aH&z}8!x%`O#KYsjoJP2MCTMvUI~?-}G}sH`ak3{r2sBF}zc4?%}LR7!lO2 z;zbqE8_>X%9K(tpUg__uL7J?Erj#;`X0`hq@oG*u>=je z33TEek56TV9v}qAxbtEYS0FKk&)77dXsOso^~7aKf@42QA^HqEN+g|!0EWT@=fWz= z5r(FAs^uQew*H(7Q1}T%05kw1UO`(d4KJ`2hWe19E8PUF+JErLIH4abX6WgPU!fo( zLhhVR*uxnwfXd9#Jb@RXv65%=VII=0+Jcp^RYQ6MqcKR;1c-+M`Nk6bsSahj;!Z_i zw6qEV)t1Ak__^|{J)Ch6HU6B^R3Tf${FZ{{Ph4oo2372|fJnb86r&}pZDhQcSfjX$Rh;+$AC1V@=(X-JQ_FjZ0lb`cM8*Jh#)%;7LDsyrciH7eyi zCLVHC8Jd~4NIQ_lC-bBU47mxI!Vd=~ z8B)GkD~KxmsORv;nSr{Ye-r534mCApE*FO>U$flISscdrP=h=kxF9{_gM}RXTv}Gq zF8mhgfEaRvCBEW85Wr0!2%XrEB|fRf{y?!Y!HRABS35c5ldO2L>+zwf3812p5)fClkO@6&B49#iWM%Bc#0#DH)anL;!H14S z?cL}twyaGEo=8&b!Gu1MfpWAm{TwCim9$s?6#xFPCm0 zJN`UN0=?83nKooyOp_H5uq^fN?%elqw)?OrV5m=wpaiXHmliLMP*{DYZG~lWwiU5Y z4|;n^f*XA_*)s$*Z$6`H(3vxoWX?azlb;yH#Sv7^>(RfoX0n!I@DS<`mK}li*@lbS|H;c^KefD%X%NN5EPkF!os$61A{p3q1^U=OzB$BC7Xqnq`>2;UgqBx?lGP3PA4f+YtTMTfhyz=E~YFMh;^>R1Pa$?v46F^6^ z!cDf+H+jUNd(>@_SDR)<9Ss0-CRRXE)BQCt6~q4oVx7%CI(=s9Y3`Hltrnz`c21TEZs{!D3cZ z1#0dPx^ZS%?Fd~>;xAr=sloxR%)~|<)$AI>5^ZE1&vVI2aY91vkcR8VnT;}LORzQx zRsnV?F1fM?OHqw{gkYZSTdX}wKpfdwFuofLp>@SMZ8)P2px4*M0UxQjy}j)t)&|5odOdhGP1LQ zna^t6>Bbr2Q=siZ(HK3|)YT@=499${*&Bo>nqVbpFDyP{m0k1DzU;}FP7Ea39(2|; z&e|ufjmP|Wv5u*DHrg~KWU4Vo;<~d*?#Y?e_@=l`+3FfVo5Ipk3m+&OxM8K}*JrqS zQ$q`2$omXAw3o0YoR>!brmj_Fi&vUD$6b|A*BxtII>*CA)vl3y_L)^>dvoN3?G*~7 zDnrc732O-UEtY^=byhtq$245E%I7Za^yCaNF(nB3E?Ek?xNi@<;*={IY7CIA`|VpS zTbkHrHLU7GwHVmaW@pY6=ysHg$z-fs8rOO~GgRDJB_O{?(0s+PcWid%tnnq?m{_iE zU{|+Yx_*jO>E`OJ1Fx#z(w+5C`E6&;EU{IH8Fx{zizgtf_=LVTxsrfXinkvvc~=&>vg$>K`^%3u*B6`{;8o%|adhA__^56`QuSv)jv zcIFJ}Da2PkLn6H*Z8!xaMc-uT8AFlXj9UCCrWH#Ko-2*p=sX{1JDoX0H2N36E1w~n z+fo}5=qzmNg9`E4bL{XhSQ_UJxj$!Gv&EmZJF=ol@g6E-%3h&uivXI7V-QDRW@KJl ze6H&B=geSTx=U6wX;E0h7vQ#-@6geT1d;nH!_Mu`8Pd?ge?0h*xgHeqQS-`R)uk5Y zA;Z5vXZB=3hMMrPGUgR&gZ!vHeQf0Ftv_dohB!hvq!Km5rzf9+GadSPD?dGykIm>5 zoY}kl*bJYZw^MLtf9BcrJL&0BvYOE;I0H#~r9J91WEGL~E1ZHez@(hr;Qf7mVk!}y zk+b;>sSx(5zUyD#=3D*M84Y)va|b=;6rAC=t^V4bv$0-Gr{Js};{4VSn4B3P11u+J t1CV4PPRA~D*<7aO)0`#p2XEoE+%Tg@%% zpe?0|YDrR2bB#KcZd9kvzUT8Fd|yAjetSKhkJk^cA6~BRF3ioL1%L#&g9CUx9*f1o z;cz06Xmxd!!C(*w1gTWY;cx^3flMaz@$nG~g(8DKfv4WMH6HOeUR*B00b#&Qh?4Q` zx>tQ|T;L5R0}+g7`YaM;>CtcdI3(OEZ+k3x%soF+TH)kgZlI-?%2!NNeT(=)Lf zn1>m$xjbv(jj)@o1`Y&wo*6f)HCG|jMiX+AnHh{W_+3}z`UnS1$~h#_;`3v2n^|7~ zg9;Zx1{W4p0BN#@#x9(xDvO2q(fbg9ecGv(K!i&X!OG%5eVC>V09Z|mc546;-{<`D zE~qz6{h^u15*3zf2_Hn8Yl{>>?(@>It>rMTqQV|+mUB)|aT6+GeP+q`NQ)xqtw4Et zP#J%9Wk__eZvqK`lWZ0b1eih=3C_7!i|JpP=b87;nlxTW^sD3<|Cp|VsZn9*y_N}+ zn=y5c-;06BzgHpE5&T~SJ@8fBTa!QQphUfG+<;l?mFA!POOAdIefPC@EVaD5+Q0Vp z-8E4fWHfbII{={myn;8shIaB5gl55|ENGvFeTLi^#e~1VPSoa!&QJb%o>y=I&U+$g zFHpx^L={A8`L|~s0n4^22!ZTRH(9LYq<_D*_ixf`rfUud9?rZtWAR@_xrivb zfIhW2tse+6w}Yxi*T3`_v|@=#cQtBRtZI3&1N7YVzY!D(T@TPGq7(t8B(oQ&?e`)W*Qi5}ftsz~rg;!(0L!^XSUbJWr`#{#nadt;?bO#b zzZtUE*6ns~%4v{Hcz-?k5}iU|EN_KQEnABdArxBHr+T5H ztZ)LYso0%H4gSruCV{bUupnPKVVjf9ordObhdN%aWTL`W_PGp};fjr}MsBVQju!bS z4Hk<`e)FpUKeB?);_Q~d`ViLSDnjuC@Ay5kBe+j?`Jz4u%+pHU5Pf=T)}a)6mB54t z+$N2Aq!{7OLdJUwkbD*(OcSAZG3+e$?jviuYO!Zk?`ZH4%4m-0+3Cm%;#t-fI^c{t zq=lorl35(gg%s$>0Qrfirrd{IF;lM+e7JZG5rQGV;9c3o4Bohb6e-em6~d@@iVGtT z46D@o0LDJzja`xTzH4r12kb2E(l|SyKPL^AQ+T@XM#lc@G-zNSp>P+VL=9i3Y8ydz zm674tT{4n&7(CT_RrNimJPlNrg*s-uLMLA1!D$jEi&bc-S_q;Ab*_%Zi^T1)ItVl#u6MLO5Qwi0N^HU)}Sx6rHjK1c!ws7|^ngS^dq_J!ZTGo#ci9ee3{ zC19sFzKmODoxt*4$fg2)VaN45^V~bDOv{c=wAhOlHF6Y0Hq-T+=4DiJuFviI@%c0M zQ)*Llu1^Yz3CHkhte>pIsJ5#Dqr935x3kt{-C#$^&nc*5?36{iU0s`5!udUi2)R}= z5ZP{yG{4TvKgu+5j1-!od3T;_OtiDXP6%zc@p+@=W?%?Ex#lOpH0Eh&)i7a7KP7q` zrqY&t&t@|<)vS>3Kt7J~%pBJOb$~k>4lqj@(l6E_%s6Cg2cFj04F2ttc3u7}4gw;2 zEc4dFjlAtA!)GB`lhtFokCMf@3xxJP(r>V%A$xu=jAGz1j{P^|9P=DK(;A}6F4Z{~ zC3#9O!hLqD_KXgZqvqHt^%^}8k7>dgpWAFS{DMOc{j>|axaHTuYzZL;P!;{*<;YRY zD7l@k5MY>y5MyhcJ}L)wZG3Se)=Hyl_}SRG%ZUv1koHE#QRFOuYzuAMH1$!%8k`x{ z|B)Kwp6cuo5BCn-Ow0%N_m{15gzU@Mm3Fp5h;PaIu&hy&$R%-_t-nPbRK$MQ$!i`C zo_M%!kiVE}_qj7dPtb-Te9QeEHlk2NXeM%BQK=S3_%yA$vEEPeb|utqZ}zj2_>9Q% zflkRZ5zFgi1$q_2_or_w75i-k!Fg=jpTI6s-(EY(z zLa&(*hZfig^#Dpbh5K8o((V0oJ4)o=@-!(zbAs5m$l=+I^{1EAjOePBi~mN)H*qtf zts0&n_Eq0wc+TOs=bZ1tu}J5~;;uh?nYRIW6z#XfON75LxVIP6Vds`$m@E0>?U_Qb+l1E7gSEGb-7 zxGvuJwdw9R)0u^8&0Y4<#7DHi?cXg7f*;`tW3^wQG&#>AT@I@_WO!KgT4%DptcW$) zWx!LlyWto`%SU=ftQ~{zZx}nVWM3vTdtWXC3N@E>_W@pD=hIBzi9!eaz_ITw1EBo` zHCg)h2{ft;-$*_1ejitbekaIqjej4XFZpM~MCyX(74rKZSpd|#vwCUfrTqiJ`}+*k z)#2j%Z%raI3{79BH4N$pxwj07)=CjIfC8L7uZN&KMIA(d5R_lL0IJ1I*3AJaPWG2sy2@8jsI`5NNK1lR ztf^LFZ#hVtr&GnY8?_8kvq4|PamGAl?aJ-9I7qcOzQR(V5@NG4!F*vJY7^;Ud=gBg zo@4^)%MCykJ|muwit0XX#X!`?XTWxK*%-PIQL+F}T#w26 zgksxdj|<^5@zA}}3==-eP83zRdMp`72aIwu7}y-i39E(Vgyk&NV($Ly^kmX*Kdp2| zhbziACrA{3-IiS90{$7PAV-sTl}zb$yV~RuQmc3>1DZNGS@6Jw<;!pOi=A}0PS+B~ zPH}c#W7q-eFgzMXql318&C}~>O7W%H3B6EG>6wquvaNx%5-l_qmnRUq{&{;-2`7Ut zz!r&eEoHpdIhy~hxyb-@#6-620umNdqE(sC`?U5g}vL!B_>N7 zboHg5WS#SUPD<2PL$bC^TVm@_1kTDfOKt2(d9|gm%9LOAaDraj?4a30SGGdyKDXjs zN>#6_NDx&UO~J4C<$rtw#eT2yEwxUKR4|`K=clH5fs7q73{*qLgur7G}$G=e5xV;I_ zBv;G5_NaYuL%F1tQwh3I7qE5K=U95JwJJYctcveCK4fCxupREXv1Y3^!iIxPI0R)` z1`raMST&V=!Ip>vneY};{wJ5M8OrMknxPtm-#<#)LY;2!%ycY0A4J5@W)zEDf#<*( zRCSJ%szw4ort-#y`1+I&tn%;Hz%g!}G2i%Ug?dzXS$HwY%)^m0PuH_7JeKRw?sKu& z&qHyiDP3Ch*ssPYfshUA2k)sp9d~ItlKP{pAktJ_*{$rHe^}P!e@`dwDCMFF-#FmD z$K^v6p`jKrJ3&1XO|R24i|xKna>6BQo;)1=ioZLeuB^VffWd<`tkNtxfzzMt!Ah$ z-Sv&*wppi4LAI1YZ>U2c=3%*weB~L z5(gu8_GxDmy_+1z#n6ZAVJ3ikXC4|-yzQt?^GY8I;AyXg7M#Snq)Mt@6B{9|sG}9- zl_&D1{k-By#H2Zki!$oIQgq6xMk*hPKi{VDkDFP3k$F{z1>ppYrBd8o&@Llo;tl@6 zH>f?=%})e(7^O;XV7t5ZKc++HM1Go`+wJ!9wN~5)Vt6H13b`*Vv{2TH$`zYPyQS9HD{@=+WJ*pU7sM5;`Z%&$z=fOjAtqXaiYC-LzxE1@^no;Qi$R~c6K>ObJwiET)q>nKCH`Z-Lh zmV4znva&_J&-88bQc^L7#~zu4Rt0(bv#z^<#>#(n+%i=o@q&ziY;kX(H946=?j?#X zv+7jiTk!!pF`QcIeIt4aQxHa1e*XXtv{(_#X6Ak#q8i^}} ztx|XTot5|e6DyE~w&rYg31E%a$MnU*g9H9jjvjSe-RS7^cuVhN(w1?f zka6SWaoUA((}D52G-_WkT=5r1*l#Fyg5}pec!8+1VQe0z6(i7(UmS*|6CS#q-&eE4 zzSAWzo<-ltz}~fd($3LuV@Tz7El-x(Dy;zw8|+IOX|Nrt%@$xr>j=3VjeLmes|LV> z%XBWbJ$@WRSu%1b#~PbK!^?2ZGR!i;!Jmhdd^%)68(oS;7g-U~McrO_f&qQ>U>MeM zHr5z+zvf+ZP$>4*XG4FX-*jr-S^JXP;N~sQuhkG$DUDaRE~rV?41JvtF21^>t9iTp zaVDP~X6mqoIC#%SR9DieCyJ1=h|PNY%R-J{s++lYMTyumb8pO6aY=-I1!N_at4lf} zPVzz-CE+ovDm@+WnOUV#KA>?)y%wzscH(Cn_`B(`-+leY%~X01qi^P@js*&PW}CE3 zRbMgUqjSBhI_g(FRczPx-)?C&if3bzPX&ClGRs%7?~O)|5=UD*1`~`t|M-bYWMSiS?vx?@7XOXOq?>exHAe_DuN$Kj41q^5jPq)e2pc_HWD zQ!cH}aYIWRaC+12;A4~`Ob%;L|c(yAV>0ZvNP{98G0ObX@+yDRo diff --git a/src/LogExpert/Resources/Log_Icon.png b/src/LogExpert/Resources/Log_Icon.png deleted file mode 100644 index a17747171a58f176045608b639ea8efffc3682e0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1343 zcmV-F1;F}=P)_e$b3wFpKgniOTmu5`IxUyJAUops%=)2`DkBKB>2-wfXrk3RcArK%6QdWx^W#9&TY6CESqS77LY zGzY)60$0HG22;TCAma&FOwTPOBxOhCVn%!CF7$GARY$f#M7%NK>x{^}x|n}|X+ir9 z4TgfWU&u~!$YjClGpNy;OVe$yJtjog?caPEoxx6ka! zEgA)1ZG>kmDfJ(%NE`9q+5)k~MT}}8Im@N({Q&oEjtnVodm+!XhWwaE={V5Qq$vKU zaoRObnl2R5C@fudDz_bgLAW|FvE*!v&yr)aV$yd>i3mg4^kz`f2}^R8 zCH+ZDTGjHC zr>K71CHG7}0F!dYiUleV(>Wzwsr#K?rJ(ey5Usx$V{Cl@tkpn{S2;l25d+`;007y9 z+nz;iy~pc!f9!J}?yRx<;wepPWrWNBs*x)Pp+oA&sl2aC(OMrSoYHhoa5{Hhv=^R` zVnG9JY%cU1^V{=!E1Y7o)ujEEFon!8ws!-3SqoOp-79w;Xsizr|I5#n5;y%_w_UqK z^4-9|g#&n_G2eKq%wC)dd)~z30h(S9F=PS78~;01>Jlrtd)3F+1hMu8Ne4XpK+1k@ zlVs0apVPw&mz~V*J~g@cR?!fuzX)-Dqkj;thLlU$t&hBrgY!F0PS%HM{>J3=hbEDR zFa<60bJ2cvy=3+euODTv0J~;Kw#>g6Tq%A?Z%yHS9-#VQ02FjqxXAW2zJy1AR^jGB z|6`E*-jBV{N215T^`LWZKamrDjH2S8S$uDGF}?O?&X{n3y)&bGAL|O#<}DBHL1|Xw z$$({MT*33eK;aGZb$1L){nfB{EH9>(jK$Dn4FWv*XZESX<;6WE*EI3WKv}mbh(HiU zKq(Lq0Rb*mI&>|~bL62su7C#|)Ana8?DUJbV%$(cyMi1J+_9DzgF+g^6k%Z9&VqvB4+45%NbMz`7JmK4e?X{$*{ z^DbjV+2vLxC+A1xg5Q$AeU^M;#uuJ5)=-D`16x=JiLzC0*RQ{r+lXi0O(@;)_V z8^+UbTyPQL<8bup=8AZ4Pt208h$ZbIOU@(`{S9XHrSbL}H(W$`ClH=`sJ!HGXV{Y8 zs^VAPH6xGSOP_m!iwF;D)Avy*x^}f0nsTo_{s+>9{ils_(Fyc@QND-G6P^$V|s3^`Ym-y?{ntBNU zf|+r%#~2-MbiUAsJz28?&~puazC_`+11kmu>jdvR!7UQpqJWs!usK%0apu0dii-%@ zZx33|(sU;?gR}36t2^VIJrHHj12b>Wr|Ax!+ZXjNb%zo(o}$T+D{oEC+}F2b_IJ+}IW8?3mfsUax`YMogYbMwWXaHDYG} zQL#A~Y|)S0gaN-IKm@SOe_8Vjgu(~H$B7VBuA^{g#T{B@&lRl}t{)5ajYD5hd;D;J zM#uVo548~&&0hlQvxJq=;OGIIFjwwwGzK2B$^!tk4A&Ox-=4W{zp+J|HNjZ3J$Pw} zpe)cxHL=p$z|R<$?rpdyTgw2j?Z^wdX3eL}bpB|Rb8jSU|Zqo;uum9 z_x6@!Uy3;oOW^sx{JHsi4Bs%`nEOUYs%mqZ;ZgpRyI_5X{>(Wp4H6G`G>RwmtP1yNkjuuRxt96MjANcaU47CO zjK@|~wX(d}sOHfB)uNLjIiygLF{$M@FUN-SSIkF^!w7gPhTVhz3J1c))8|j><7~Wa zUG}S>K3LshQ{DXkZ(qt<*IF>u)K!c76;vJflka2Te*OKY*z)o>UmkLN`1v;0;vhtc z&YJtrqvzb)c)4Bq!1L|p4_P2eHf*SypI->kIsg8>R$-`;L%(YG9mQw3o&D~s!Zly_ zm&`b;_3wWkTM^?Y^LV4pnrGOaFr_ekQK&cVWQbS&_P45@sdoO|{=btL?AyM@_i|oH zw)ImwAQ2kl0Ze>#%uH{L|HiswNqKu2Y?l=Z0Tb9`wzvkvRdI@pRco+l{>pnHSxQ|{ z!ObG?0jtE~SE51-j?co9-tUhZhY|3Ugq^CaibF%QbKw#>MquQ5TX{4vu(v<*uw?=k z5YtK~Ffj7*9i3Rk!f_#4_oV_OlZ;H4@>dRl1;?W#;L-@2rkg`=QA zqwk8c1F!({WCxb74+3OXx;Fr$a1x)8!hwSeErR+PfN?)GEd0ajV_0yoB==$+umWT7 MboFyt=akR{0BtDB>Hq)$ diff --git a/src/LogExpert/Resources/PNG/48/ArrowDown.png b/src/LogExpert/Resources/PNG/48/ArrowDown.png deleted file mode 100644 index 0553d2e249611cdc96c9c56562601634ea226474..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 322 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeE3?v1%WpM*3xd5LKS0IfCY}d%o0!nk01o;Is z{P$+z3C~}BxIag(=rB<9q^FBxNCo5Dvl~rW9YkCM84mGYXfia1glAps;|^(Sf5+p_%z=iQ18@AvHo Og@mW8pUXO@geCw8Y+u9x diff --git a/src/LogExpert/Resources/PNG/48/ArrowLeft.png b/src/LogExpert/Resources/PNG/48/ArrowLeft.png deleted file mode 100644 index ababe7c69c0a37ef6cdf7aaaa2374ee2f3650b3b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 236 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeE3?v1%WpM*3xd5LKS0IfCY}d%o0!nk01o;Is z=2-6v8Rh;NCo5Dvm1FE3>cUlFE4Sssle7K(K1g^AUMFtN;qQT z>mR?bE0%g^&UzR+n{$F(;K?+mSpp0@XE68+N33UHWa?pm!Lp#3QK~^gu3Y2qLFETR z0!RKis&RyFag{OXl$P6gaHWQWFw+GWc@NFMbHB&1JD9r^f!yrr>gTe~DWM4f DO{PF6 diff --git a/src/LogExpert/Resources/PNG/48/ArrowRight.png b/src/LogExpert/Resources/PNG/48/ArrowRight.png deleted file mode 100644 index 5a42460e577542f72a64b0600500f7269f40cedd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 240 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeE3?v1%WpM*3xd5LKS0IfCY}d%o0!nk01o;Is z4QwMwyCQ)2O0 zo|TDl>a*wkCcCUzcq9x2^jVUU99||lC@KVWFc~c3wRmnfCpP9(5RbqWkh?uy{an^L HB{Ts5V>Uyc diff --git a/src/LogExpert/Resources/PNG/48/ArrowUp.png b/src/LogExpert/Resources/PNG/48/ArrowUp.png deleted file mode 100644 index 491bf1a8ff236b6ec79a12119e4b26895d7e670d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 325 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeE3?v1%WpM*3xd5LKS0IfCY}d%o0!nk01o;Is zokyZSyZqYXM3BBSo-U3d6^w7sZscTg6mh+180fr_`S<~@oC91shnS9d>D+8R z+T8shIq0YP{yAc+S7mLLmigB1xZwL;i3`6I1spUOI9M4LGAM{Jv?xvBY!Kjd;9=_E zQD9?qVd|@W)pX*(PXD_Ck~_YwG*x0=>u>79_Kb02W2Hk%f}DWl40ab5o(={H0Zs!2 zrUVC;0}UJvjDifzN(^mnKX@hT1o#^sPPVA!l?GBf%oQ2fSP~o=csLGBs$d2(FMi{d n5I8^0XhoY;){2Mx?WNS(y1IdV$Ig)*{np7m1wO9Lt&?`^rda7P9v4Cr6dwE zr4J?I6cbsJ^0AbBWo0gvI$LK=RL=W!T$l5=Kh9tNc;Dx`e%JlpAHVze-1ob0l`r!r ztSJ@%@RPR}-5)un@X?!!y!~H9>LLd!+MnqO%3ICe1E9ago9@Ai<9sNXUtzx4U|FpG zQ5?b3bFceBD@VQQQ&T*XJx=qS%?KS!=gvqYZNueaw|eQNW`DuFd_RB30_{m^bZgh= z7V41cnn#qjfpu+v4$3HtqIad`>)6=vA{5bDxit>kP0T$mM6U?BIj;hgCtuLFmC7}V zYHYXZ{{#1wB?|(xB4xTleeT=sUD81;$SDL?EycDN;9(E+s()UNa({>g4Uzl(0q!zd z=$Kz*0CdWJn0)1>PV~u{$XAAc@nHd6Il>P~aYj^YiNE@+ll#~Jq?Q7+7C(}LL#J8d z#cV@i|HaF;yp{*dBqRK5x0=5U!-mB!rj=C^58Mfw@*Q6F(mF@X9-qOB+U$q6%RtLs zM9Pivst<-w0-^!{kHRv-WL>)_SwK?cN7$71mVoXki38RwI(l_1Nzs~o!S0$Js5P7X zkj3J+w^dA}Us+y`1;3;>7fBbAXNld0-nEUBcOa>B+kCR0xLGAJ43Fe@^d24hyO-+f z1C1-sCZ~O78P)Jo9}JDK>0>zjs7J@+vcsilhaDSk@x_e!&ST2hdwwy310ugb-}Uzb zP=PtWmxn%;E^H%c8X99<;*;9CR-&E~s81%ujDq(^58l3Ef_G!wNoN)ZL}{qfL+99< zDwt648P0xDC{d9zD+{{uwN<+sv5Qz@O34fkk-zi z&8xd}x5}RzXSfMQD!L}I^$-hUO%#3R((C@P=9t6yQZ;MdhqC+wfxTZOR%Mtw;&IG`#!qY zMsm1?q2?o{AU;H(4TQ0lK)%@K;#l6>0(LyJgEHCgCF_w2lqHh7Sn|-D2Z`}*|GI65 zZjG5Ce6J4*;|6LVOyJ@q#t6|I>|!i%=)8dNDohJNbQT{jkC}O)UX{k6vY_E*XgG73 zd4kuDj_Jp;*TCq3Fgndd(|%h!dUJ4TXG0HSDonF>cve;=v6h`5Q85eqy$8>QZ!e=A zsh;ONLD-`qJX<5H)k#e0d0zM>l$h9WA`Z*ujadymv#ye5Ez}>u%6#UWbU0MM`+!#^ z*O@b2yLI2dwVor^om8_0>4CzO!vi5gTKp~%WwgJSKV=Kf>iKX^(|GxtBdw7}D8gZK z?;#xxlvIVmQds#kNJN`e0U^d5_v zO(UA3JWP{K67AECr^9{Kc_Bg_rDao4edNe68WSf!Cm?Qfi%4kCvz5+bPaLWX@Znlg z?WNT&pSb?oOXbF=($Hg;Vu5X-~l(%;e zb9&ANBT^3PYS=q&m$9Dral>wJ-`5PfYr^JxPz^awmAq5UMMhbU@|~}j(Opyfi{U+a zK^HWBS!-0Y@xbZb<2FQf{MoNl;TUWw**Jzw95l-yV)V*fXF8cP{NKNmoPpd>u)nlKV5?mVKK?BFR|cz^lenTmFOPN@Q)M`Vi+! zXd%xKq{idL1X}mE!TDpceD}i5G|d*G4|L?sO3^`9&Ng|RjzL&m>j{&&$SPlP<}Rra z^u#FdSfMargXv-m6vm`t(Y&epwm|QRM5SjdjVqum^m0eJ=Pt`+x})y)x9sykBP-u& zI}MF>jJ zLRz}U38?WvA%G)^o>!TG9m;`mRWVDE8=!)e|EjY)CVBGGa*(73H?Y@M6>|ST4s?9jhy;fJlTR7`1D0C8gfrd21~Uak;n><5w&anyn8x znGfn9-94NBS3uYXBUys?e)s*Jh!8yWa-lEULQt{jZZDz&PvIb>JC|)hN?33tE9lLZ z^)c3KASB=%nQcgN?JOG366C}z2DxPbSiVrO2R)-boFPb$|19V$CV=K5JFF%AUzN;e zOrxH)n2dt>t?YFq-VBXC)E^=mb5LVDj*_T~vEj?fL%oBdF|vB)-3Xbg*qr>CG#ZnQ z(I%lc zVc3Ja+m%01xI({*#;@`p_Y+j7=}Qe??AZ32dF;z=)5mLzEA$UqzC2;q_4R^3yUwqf{)fUFeH=9|__@BzW)SdONUaI=5r&GuWxh`kz$rUO2 z4z2B5{?4Qy@~)ZcG48YOF8A(#R`YZFJNCExa>j$d=Q~eaQnRiAE0oP0S{HFwzS(g6 z*q7!bU4M#e{KT%9S;)I0BeHiAg<+L&xkkOr4wBNgGa)lS-YQxhFj{=NQbX3EFr+B? zX8LSwnzPBrn|&+b#E$CpqZ`@=jak^Gz*{T)DSTU1z;I_3Wpv}2X-)Kt=g&Th8iZjn zO`d%pG(@gn?MWx7_WbTk=~wDj+*KYCAJoW4*{-q-uzY=?Pptp?Ej&YxyEf{^u))pP z9Uazkf7YlOCoa@?Z~ zi=y{Ib(`2fhPnCdbk&jAUMwr9@$GtW6%4KMoFEmIR|=7lJ62_d)fc)RW&pSKoUu)A zM>(!INhx9X_OQ#v2{BOI=L#t%?(ICw2yH1Xj<474{Gl8q(irdZDW)CsG+VJ1IDC<7 z^v$pLCb9ncw4M|2%ohH-G<~Qh#YS7w|NWshQ)r%m+O<6*bC3aVG_fwqL+Wx{AsyLW z@zJwUv+>qh$AEQvfT3O2*y<+_vT%aB|%2kyFUFP;VccG{CX z%NLqq4b&SFqZ@XC-aI}==vUm^-e{RMBrF;a*HfSCD^~PS_E|8$`}m_%l&*!dxDu#y ztHfaS&0hPtAQC!GsQ|C~9p3zO?TGv)6+Dk&K-Fc}A64vZ=?+W*g_Du6w5*=TTC8Od zy?3vIBgBr{GjTGz%Dz3Bx7F@k3+U6W9eQdn0C2>&j@l&;uV14B$Z6~U8_U1nCkN#b zi3o(Or(JZ8R6poZTqloI0B4r8n$#kAi3`PKBMm@|fN;GK7#C_v%*r95z}%`j%@#tc zva+8t@l=$sW`ENa01q&jznJ4l65Ky-h3y1TWNE32fZ#(BpT4RsD5&k}d5?o}e@i8E h1`Md+KTeyH3__rwZrj{Du=*zje0_G&#a^MQe*jG}6DnlQ=h9P8vwyd(}gbZmNuHoSdUAM|my^WJY~2agG$R2t86CS2*;Oi=`JjH4+^ z+T()cL1d*+s)_;iy|-TV#bjUtHtYx=oKa2PDUNY+AN|NGCV?5k$OwC1<($07JD{>3%ya5MW!0p zh>tr(8Skp3gxc!!VhX^GJzN~v3&y9^ez4hnKvE(^aEQLH3lev55*Jb~zI@Df5-&0% z$_bE*%%+qpav@yhFuEjQp$$rGC>;pz^$4jD_T^5YLwQI8(mto=op@70t5aspXSTdR z!T~AFgGWER^o#tV0T=cgCfKSXNrWm%OV(K3vcc_f(S1p*t+eD+uqh zz6Vk%YzvfoOp|7KEFNyc6~l*{{K~e|uBw1itJBO}h`KH!_=X~<=r69;B#HjM`)ZXR6w~W-i}H%yQx=NL`>v&ToiyAn80~2} zl((xHFHu7_9wA|!oeeaYB}JJTYIK)NZmFjw>#r8zlyK;vX?KZ{a51YB_Je(d+OBm1 zF~HL5U9D`!B_pkpIeTFbY`SZU{IAv5E7hoZe$E7@m4p{xti}DmNUZ166n5#=Kw-f* z4_ytPnRE9c$p!l(NLa?nNdlwrl@6P4uQ)uUc;BxN^nXo7EIrS>sg)~V0Iu&&lOv+Y zWBL;0pqT4X#cP8CzRk9a`TQkx{u@h>=9+Vhg&Dy&$8`cgP?7}{8_2YkvKMs()){}# zR7V;t$e>$v4_ng-@xcgf4@;f4eG14ZrMyFZ3JOT=N?f2m|6tCQv8}NJ{s86Ly_gDP z25*oi)GosqMp1SCD-c;Wuq!fd|gUi*YV=PQjbJn=Cxn`y) zU&0MJqEBk%e|e<+F%EpU-~KPU{r@jbJ>&d7Sm-nRGU!xqtKGoyoxWtt7?$Z50ZT$; zaX1IhN`~46IqF~;G>$E*r$vWlT*&cSn|V+z1}`JXQt&45q?ep}0#@|kS?JsQSFci9 z73adsNZ2C6dKybhXhi{j4K3>Rd=X(B19!m+<&(!u1Qxc7%^B~2Ot1`1umg+}(?%1( zU4a!NI2qSX-BYe_{HT^F?)$5ZZ1SWbSb`e&GS07e$xCuifdPa;a}4$C#ausEcdV~u zai58g(aOSV+m<(Yt?}|g2{{=Vr+GYuR~S)Wagr{tB3l4dJZ*O0D;QYkp6kyWHYc^s z=OpsflDxk(d5nk)-GXEl!W{1J=WwTzz7i5t;mLkkH`=BcWBZ1M?kc70)|z{_|Mb8w zkej0U=_tR>*n8i-jhaS^!e*q12PGH+Oc`eExOx0`TKNg z5Zc6b!cW5(clO7eHlFdxy`h&$O#(55%1xmyIRnijH&5>Y= zBtHJ5{kiod*~K2$~@X@FUn@e zrm!#T9oH>aWpRZg3((xO)oLk=ELX!2lf5AbDvFbtsIOYMYV5OjdX=Xk$jpqAZPQHN z(b^N46Ut<)Z73uuty_U)s={Lo=Rlt)M{0I?vLb;OWVEz(5H!s697pAUwny0x$hBwL zn9K&DxjczZqreZ5>-k+5V;o0>v*+oCPhM9nzfBlx9n}e{&aTU}sd_cMtXfvJ5_q9p z0qNix{yy4`lQpxtWhK7q*s=IDG1JM%&bO0&qGp)XQb6&~8TXm}Dz7`Up17)W?gg)K zsJ%7u;wT`lI<%hK%FiiKOj2d8j?TyV*EypacilNZL#5QuMfB)YsC`n&@Q};0=V>5w zZyEhgS9S!fNh&4a&cU$ryx^J_eIQUhtF!1KG?rz^Egog+hJK;iF(H>Le*YD7q%BthbV}RHu+9|9llS&~6d3wk5 zY*G1;p;vq@6!n}UoJ-zt`#FQkN;GmVUst^B>GT~rzGw<(ILw3g!_M;A!Q24{8cRcL zJnjhnk&A9UdqkH4K<_5{eQ8=_QDQxB&uEWEYVj5LC*>_x+uHU*5O(Vdl=6Gjq>9zxmBQH_g@gI7SpJ z3IM>^*;=~^koA4+KnrF!PMEL&peVQFmVn-`I1hkWubuVL6BqqI`py3paZ)B;@uv{B zxSf})v;>N#ewS3Wq9UqMUFd=Lj_)MwV<(h;qD|!-lPa*vwY_VL6go#T4Y{*Va@xS3AJ7}KDhSj$f2TV{T6ea35a_Xg|^|sw9w#rYd`?U z^a%(8i@oyrA{NHVVIeFjpemO||H4maS{BKScG!JN#93&m6m0Rac~GcGBzctH7< zWGgb&1u~AbH~6LaJ+0B#-oAF@{-vP84PT(=WVZ;lbtlFWQ3Fq<~LD6U@YV1l0 zy3#fCbD8Q^Nkwgy;mubsP=4tpXexc`#k`Be_QCTRA`P-fFs_xjj@Dhsr5+{Etvw&v z!C>P7Lt*?v6A%CPVZosa-Kl0_I8Oh1>~u9sHNHOELer?L`%7O;tYKdgx{}m2%5H>; zJPhVcU)>l9SDEgrPHmpe;+52jWF5*ycOLEG*Y6cxk^(6nIS<1%s264e0*S~Il`WHO z54^D$OH6CEQToWaM5P1FmK>ja;-W^sEuN|sk1eGY6eaJL;`o^GO`*=ddrgJzQI7SD z%CzPS+CI3$A&ugkK#fYBS7D6cA!`ckEqXb#WC-;*y+kML9IvimQxX5ca)UtB68Vxz zrX)tRxgghNBYH%&9oaVpFPOWWCgCuI8cQodr>eXgKA9>KkLGfdX#y=6cGe`R%tC~? z_QfZ^)Q2|&T2B1IEZT$r;4R=IzeMfyBquHk8UuBr+R{z~pA|srhrwmP64vse??ypOw>cX{dOscA?0smFpg^cJ^eRW#<9VLK)Ig?7*g-gnyie6L$pi+22*{Ga@@m-SnqZibi;D+V&7 zR4t^{t1j`*RuNd%!(uM6dtnEt2+8g2l@ok92o41sCQ;S1^8^^*5E>YZ+#rDx1l0h( zp>TTD2aG^Wfd^y+<|gynJBEL#N91&KSKnWQmSlh|Fs}1^yQ#V<#xjC9%#ez$njEsH z7nUSznUOGV%H4PO{-y;;Aea!$p`T~_@#)-&;pj7K~(su5j|p_5`%t}E1rHZ|Px4Gh#}WqOY`Ch&Dnp8xu} zxz^16V$-1F+|=#C6~4F?vPpTEUtu^G298&jM(kaY2aNKy4=vp*1fm99->L)h#uP?h zWzAdbx2u-r0VErrTe-+VB`ux3PRd_T^l)tJ>k{lPk98Rsy*I{FRgpnRvR z(Q+Br_v-3$(5YMcJ@;@fMKMa)xP|Vjwa?iea4S?)7#($IfMK?k_4Sh}{)y77YsEJg ztt^5}x{fJm@`aae{&WIc3>6~`$VU;s-t`g-R-A+KW3-;J$K1EIk~vvNJDF$ zc}Vru<$9KHZ51bdu}|5wSRGupPn=b$_2{{`bhJ-BG;mw(4S%(_DOa|nw`$a1{_(y% z^fb1V;L^oBQ>gZPR!pRJX8pU{94rO)Z95R#-+lf@a_AG28E*md1N%?L>&ls-k%dycbq`nADWB~;j!;Ma(p~F{80kqYFG24m~>g+{-lw6=D$Ps z@@~G6YMsel{ZPjD(}yxJ`fi2pqV+ca<{In-Y7CRRY(`jS2<*1!0ET5)A-TS?t@!47 zffMq?a#oa7uV80Er`6#PHEiki8~f3uLU)nK_9c!$S|^AZtNLT-_dA>`lkPDB4$-VL zAN-LI`l?VTPOsN}mye30fI5?#MC{Ih5#>Q}lhu>wvFxB)9_Q-++m%)Yl?U&Xi`kmx w_WAU&DmQ~)Bxy3J5YT=4ze=6|<50`eT0exJ;AeL<2tq!vJLYUnwaUy)XG=L(Aj`l$1fQA4742{Yj7LAeQZ5Jc7%AIeD$)LJ57=+0v1N zx4OG|2%r5m`mR;R6cK81f)kWJWhnTZUv$5qmyBw2;?Oy`kY)ui0Wl56dlM|%Q*K$R zsi;JH-Ff_k$OX_DqIjKF`3w+WSGma(rT^hJw_(^W;2n&MT zJj;2nIs4*m*%j2d?xsSZ6mFo}YKApp9_;bHdHzrhS<4iDxt!_q%TMI#y(-9ni({qn zpz~-!a+K!|TV>t3(p%E^3Z}f(8~rXXjGf-;@&HB)agqruW~Wil*3JT779M1vwn@CTYOQf-u==j{kJp`4F4!y^n*INv{V+4h^PWgU->3G z;yVT(ow~e~PPz~bn=lr{r5k5Qvcu>5p{6|+FF^2Py1l#3+pTbsZI?e#+!bljve43a zqG7_9nu(F&K2%)&J9k9kp4XBe-S-QP2fL{oO-SyQ*tnD;3|1j|V`JLc{gI$k>rz%^ z0n@4t7XY9;yFWE68+Kp2R2AhJj`nNb0iW(_I*d>;WWS>}77q!go&wObjZQhFU)rng zivk7}5iA_qXpai>%AwF}Da_l>;IYI1AZsbAdlMQ;N7gN@z1$8xcrsfv5mtNeEmTb4 zB-K@z9c2Mp)E;BILcstSUhM!A4C4Su^qi7<0RWZtw^v?P{9i)69s|^sohEZ!2E$0u zs`)6D;W7#d+6jVB7deJUgAw~;VR+X6OX+2QJlTnw#vDfG>kFPU6A08sCR?j_=(~x3 z<#gzN7fto{R^&8_6de8XOE#Zpvq@|vbXSt#(-kP;4louRHV}m2rTj18KUpSwLJjgUNP?&_|iR*8J_&sG&Axs^FLMat3meMXS#@e z@_SPZ6fHbBY*breVU@O1t-&joZ8Zt;B*rIQ%6+O{%hv$>*J@hP9Rtw zF#9^$oVAXFg0f#c63n-_qTg6eZE;dX+VMSQM|Mf5tu1HF*?aL<9{><$W~!MMSP%a* zw%A0{c|8YKpfC8zfn8t_ul5uxVuW-&CxfWAx3MM$9CNz1R|Zj-W*JZ?b1so?4KwL9 zL2h1-IP#o_8NucvQi9+5)(Br|;(*Mfo-^!4tCM|Os-?8Xn?6Y-h>IL0wi;-*95cbwsT z@>DawxDr3=*if0HE)VHf;!9>_MF(jQSC&d9izVZk05rz{E$K+YR`LA@*Ncavz8r{P z0kW-`*d=~btIa{dHD8c3;nakO%>G2)%+}=S;;>#IaLYFXyG!UZ(BbE|ZJ-k{?X!*Y zFR5(Q@I4@a*Nsuvvo*4pRPNiBGiBncbVen2glooc?aEs4vUdQ+V2@w;Ti?s_C*UI2S3DMEY0Dzru|SQ@DI4ock|~|I z@r3ZItD=16i~Oe4z)hWEVW*jNf29j2PyN&RiTZ#x1^aDc)ca$5wPG#bL_)Pekc!?! zPA#YoKj5v@>zxpX!3jCjvl;7ON7;M`WY=SP^$@<~3DeQyNUxHFir7H@d_{q&u9WSk zErO0DE;$XWk!e0F+~KTe=xP_Safax;Uf&~^FxuFIN2s(qIZ$_4-nzuXn#`-8v6V}q z5E^&>trb!IG-`$o+&v@%uRv{;5Nch5n-h|FG>z_d4R5N~URy#ThuD*h6RUrD>2lfd z@a(|q*HM$7RhE~cDepb0Gq!ZQt|ECW*Syo*nfiI4 zuh#D-3OZ*eUac2Ahj`Wnxh*^-#Yn!ryxRktblW!utY)%ld0i{@?DoQ7uDbI(an#IC z{jGC9fU0{U9WUP$Y$fPaEBV+-$s}^if0sx&7y3TX=P4nzB5ys+_(u39y^iVW3{z}M zl_oAmEt{;2R~?%28cHyVS@0<$@98n4e~1{-hzQUg9kgm(+h6}XJ-evcRNs{0DBhV7 zneQoHjpemZk-Qldn$6Xzxd**(P*MFA_#{v(zsW@MYH4wBdd^`$P9`tA`Y(W6 zeK`i6YQw?WHzsloDL~AdK=alD6M8n^{{k%1y)Vi%x`CPPREypb(XTT18qlR}92k2% zQxf;9{Gj%GjqWFZ%yhZV-#=pnGrYD9Bjo1t>fRP}O(ZX{h{9s8Y}GIrWV}FYBQn`h zygCYP`Ph(s?u9i5+fqz(C;)iJnQQ3+V-(cnWRg%RY@F2G8k22V3+u;HR9jQriU&^gbc{&F3V*6(Jw z-nwrpv4G9dTdJl=21uVGu(Ga03z~M2_8uUpdqpk di+&zhw(SRrhg6h|ands%z@Kn+sI({D{4ZT@n~(qi diff --git a/src/LogExpert/Resources/PNG/48/Bookmark_remove.png b/src/LogExpert/Resources/PNG/48/Bookmark_remove.png deleted file mode 100644 index 866094498959cf83686ad3ac273d5b13bebdf74a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2736 zcmeHJ{Xf%t8~@H~3MJ)X9Cjp6o9ANeWFDf}x;?asButZ>iOCk)4lNN9vX&Tms3Cbc z$z$BKoO4>8!mP$79`}GG3GS zBz+X6Zme0r!r`o|oDoY#ONMaRDEUSCq`S=7zZZ2(eoIgW49W%| z(37dxcz~SC-(t(uAa}txBic}ZxzJjdo}OIG88*4of?#gwyuO#X!P>7&zmj}~qZ8zH z{(z3KB(bDY^Ese{rG*P7>x?CrjzKFx%VCBvGsyu=jl+EuHY=rg@|#Js!sA#%TIH)(f^ z-DBJ&?S8G@-QY6g6u|9_wPL5T8)`(y?t!0MwYm~ zA}{A(REO>FpxD}Yv``2gtdFnKKfCq9smQx^82&SVY{qjBlZ@j;JjdW1D)d8P06gkPjY&l3E!icz&Lr~?QIhV=uy^*UBv(-tKPcx zjN&>ijkG-#2WC`vG&WcXYM7I?wLpPBpTmU|0+8oMr`;nJ=%Y?y;Xk+ZFO6+0`C3F^ zt&0Uf%uU+jQ_Lq+gX<&c=4dC-8$K>26by-fW1$&;Hc?x0Nb+<$VbG|Fcp5mH;sHvE zI$L1Pf|UZ=R=W?HDrk=Xr~M-avKafJ{|0qHzUpO?B7N104BcENX`~`9d@3b_(`6iL zBH_bdxiZIC@(xbB$t`5CXhMVw*db&+{gY|)tfk5*q_#yg}_{P+uI+-+(J2S1V_G7~s5%L?VfH%=?v$MQ~{ zP`j~D_<24?IrXhvv~d!X>DahVnA~8>=ctH(&#)+DcI*7H^ecNRwhe#F$uE7sMs=J? z>)h3snBpu#V;6KbqP15hF55D|e@fwRwm6Hr{KzD7VGFO=!&;=yEGrqa4{^btxCuj< zzWte^6sZBX>rCiODo+hR*et9d`_vp->u!mlcw)s3>|w<~aHsKHztO~njSr`S>gDs{ z=jhdo#CtKLELg7frEy#6gj@ZLAF+Q2GY?rQ`(EydvGEZPnyJ1fGBSXp?R3B|i7W^$ zr7pOLhO)n6lX3+IGN?Lmkq;u};_NY+&(OS=E6BHin#l=imo?P5(tE;K@xw*EIAgM&dSevI4Q5qw2iPu227!?1BvWUa0c8cFEj8G&VB90)BKpY}%`o;t z(zB_Y5+qBn0_oS+(@pdxU6U8<4-8j7yC=}IbAvZ!9GK~)Hn)XbM>X$Wco>Zr501|N z22d~tks`J)gV}{reQ7<`^P z>Nc21;DBiqWn` z`|6V;|NnP)56IYaLDg0L-DYi>b+M{p-=&^2JmY8hu^p&uK_MTCdl&eDxeH=hncZ3# zLFmlK$BY~9<=l>y*e3IG5A diff --git a/src/LogExpert/Resources/PNG/48/Check_circle.png b/src/LogExpert/Resources/PNG/48/Check_circle.png deleted file mode 100644 index b831a4be433c49515468af7f5d0b0a62a7dab228..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6610 zcmc(E=QrHl_x5K-8=X<2cM-iu@7#=0qJ%+oq6Q&)!stYc5m6@*A!@|vk;IJNOGFEa zUPBlmM)&jm51x0=i*xo`dtKK#`;@)bIoD3PXQEF{!A1c905!}&*Zjuf{?{O+H@*2! zU$Pqm3NqK%25Lt+wgG@O4W_GQ8RqZ@P1fkAf4}eg4jnO7i9j(D$&)BC_1{NxzF5O8 zP<%3}mpND~LK3bFo*>aPykpKs90N?~FhcIci$Duv!Ovrh79$T2+C%q4_t9#9hLt?_ zo7#hk{C~f`)R1lP$dw%!P^xpHDe~$FB2=o7tpNeN2sttiAk`u2%@-n^yVEz006;9_ z^x0n;AU8%Y2nVX$S|<#s01rr+M?hq_lH5h1eIS7K|BW;_gfoS=)s?2kV>fe-ES5uS zo31ymRaBo`Gr_KTw+ol|&!P|g-((-L!rtT@P5sqz@JppZ9yRHQeU#j$Kt(wlZ_yh2 z%T#T&5YYidSPMb4!1htaoWm9mjUuo@vLYmCZ#NO#xsN)yU-*)k3UL1Cx*0GRM?{1C z#rou6c_`u>UxxkLUAn!BTHxDeLM^CaFbeFoL{2KzW8&L)weaP)k5tGXU~s1sd&W2ABsLH&;e=a4q;%4Oq@WwVH|*yrKc*q@($^X$3f& zrC=xiFiBS2wE^sn<#xC}t*SFU!kUW=t7ejLF9O~cToNib!>ulZh+MJm9_ z;Gy1U>((t3*ZXIz>u{p|hv#Ri9>7n{i6BAyI_~g-HG?briN`UyyEF|YO5mkU0X5@^ z5q(?X-S8`$385}p&WqecI3YCgyf1Vn>SEtNLE1(AaR^KUvrcG0MVU>|cj@KmD@A>= zNYlEe+cRls;~u642vqu9!_2mHj`|KZrmv0`c<>&Udnc->DA>eD8p*F%-tDUN`>m#^ zqhe=k&2;7P0!rZI_hH?kPmcB44r)PQ+deM5J5u1%V*SdcuupZisl@weX;qY3h*aiD3yL~)oH;|8z{TO6@u5z%=q?A@k4Gme z!UcSQgltjpV%vuC{n%wszt_AelnV-mamWpgzPqmw{D z4$nndqpD)Ms?EfAvUjc5HKTvpm6x*cCd-iUx7s@AZ=7!_8cz67Hd%ko7X|@;NOR4e ztbgj(JFe71_hCE+;)NBD%_{D~XZ4*e;u+`(<$GQtK&!jdFLzAfb{ER8MIi2@LE>`% z^_Qh%RvY&|moF?qGhtSKI!!yKARsjBXtzUAG_kAX{oA4e@2D%>cgcKMoc6eL#i@+A-4=I%Rj~24E_pYue^`- z0G4V{pA-I;MVAO5ZuBFkca5e{VH5N@M zAve;SPEL<*A5X1e(p3Jle#!6Dbh}eleOWcIU76**Gxcx%*D}?*x}UKW5m%GU-)NjQ z;v0+=CfNaqj`k$jD9(cX-~2a*x*ss~V%|TlTMN|YefY0*mQ=2t5*0##)6P}t60)h>SNWalda_1>i9=r1%M^nGsf*1*6P8ZPTsdhExxM^bq;<;Wox zChf%w!B|*3%OvYiyowg8%~LSW%e4S)~UU za&>$kAc-}pb>_q5zkZ>ScEsFEierisb$;GUmaEDqznZ@;$3-T=InCoPwDgFyWt5O9 ze<2OhL}-s*3hza-H2mrhzHm($X^wi_qZ^ENF;e*b%*hBSV!5!kusWF5l0=)&>`X4> z{0-0MdAs>uM_94_QI}!{_VSkDhHFXX2&LWi!hogb4sV6BhQ+ZLDKD>%r&x&qj%Udt zcvfmR&NB-I~KyeVMu84=W(dS<0+AE$i^AM}R)_ zyH^{B=8k^6Z|s?E@{3gAK`5Ntc(OPQ`b@c_BcVHZOnRi3k}wD=30QLV<=u;V3TSv# zx{1%bkQtaoMj1fofXoFa`)^T0u64;WUD^VQ%UovZ-b6g>JDKP)Ny3VhS^D9SPhJtJ zXPB5e@h-Ukp8U-89KiEBlc^(5$!Tv%PJ>4EcBx(ca9Tf4x6B7^d5|Wt2UN<=2>t0_ zHgpSHH9XDESxDpwf^oVJ%qMb7o9$HXf^Sf}BN}%Dix8T-Y$k{6I8M@;nOiL7)_*MT zQ37ACo;?aXQBHC$dD*7`bgPWy5*0zzeU6BhbpsITU)-92fNI`%y!kp}y74QFqS|n7 zhmcU3;s$?b{~pe06}lJFqE^3yS?n_k5(uu;0YU8;!I|D7t1Q+lHGB!WCO6!&LRY< z0o#}YLL}@5AIB{G#2Q^Zcst3Kn(rFOIAU&_pwp$c$mhGkp6r&4qzG!~y<7OLcKT%Z z>3eets}t+PjZ#QqwB({)tZ z{K;1nNsVtwJ9YkXMzdILc1>{MKy06e?+(6QB^{v-2OCbX{%6A@vQ%hDRV)D1&D06# zM4F8&T03jOKnP zZC}8%HFXwv`~%)V-McwpU|xiclQN5*)X}Uwf+H^$FB|CwlJ%mbx52Z&q9`1E1qRG; z$)wD1Dpf%_7vFOSlY-~?kJA)zAl2w%?}huu{ZEwk6u?&UfG|5ent!`uw$ovB7zDL0 z;_!_e&Y2OJR6g`)`!1>@b2xjzoWfv70ZcRMhf=0Yy9n*9uP7n$*c2 z7IX)R{X%HHG5}BR+OJa|TiOj7DcA*z%jr! zrZ05L2FhR5(rDu&!T<0cwiM5w_H@z~dd1@?^CWrLW;Mglr=1v(@V+p|$L69;2XTcx zOz1ZJN9MFI{z)uWnT>744hHX`0FQje`h6O>dg|AEf7h7JA4_zO1-@Ox7CHZ_H}*0F zkTZ_(!IE5|+on=@cWJ#%feW!Y(L|(Yg@S8Jm{vEn;mr^@s|!RIi>ek*UKAVTU zOojqW|1zw5_YqcllP@M)cnO_?Oo!Y z3d?W65JPf}jm@85Z3`6;GkK~mv%Edf)76?!eKg*mi2;b$Usnvj#FK-JZHfO*B1yGi z%h-qgqtLDv=^;A7J(Wa|+dNSYfRxX)PEjYU(9dy+QI54(cQi%s3v)}?mZfP}&&TC* z-MEFywT;&+a)ree@^|!4A{A-GZBCXo>JLcboC2KNliyx6mk5Rc%`}j7O7$8>;ca7sx|xDXWOTT(y3$3J2MY>xzWP;3f;B2@?sRr!Szu0mjIC6U>gr+OPz8QBO-_> zFhdL}uA2l8%8J-+G)jLwq?4*+1Qs+-0v&$T@wv9?$#}?Fw@9ajmX}E1a=mq>_+L;_ zc<6&~&&uk#I}E|d2UzBqs{9Dq#H2j`Z1P_+8;o?V_`aInD;Z*=DBGt8&#InCbl6yW zlku!yc2V>5zI?vk?C+`E=K1Ibr!U#l9y^U!rse3oqux8+b39Q71ax&Mou(&tFe+hL z&*m#V#pxc1DK2dm$OW|&?Bqx96gYKzz?MQUJBFxbi^N1okU@!zFps-wq?8kxtb;RR z-qZsv^N*7e@&e^`imSff{;#l+0DL zehcRY9Almi-2InSl^3SKJ@WGTptr~M zY1I^IK`_TFrqBJyfwDyVT*{tO+z;-MW;o<3>W!kg_&3CO~@{o(0j*xFA4K(2g;&)~Kt_%6rBm|36)x*3J*RO9&{ zuA_*tkr_iIirNxumeo;`IGinL0e6@uyb%l^S>g?|=$dm=>8K&xX9N1+oj;XcDP9Fo zc{AM+4SDd=hXm|vgO4wG7vAM?u>m(>Om5h{AMj@}GdrF{wBDm2e#$doNuxvMK5=dCmIOoRmcG>jHzBJvv2`ouE+>MP5jx?piN*J z{8m)hz?|J=zAmA;Vvg|OBOAcO7bke7o`suLN|yO0iVm)`h<>DXbKvm!K3?MIdZd}K zS?Q1*VfZGdbAW%`I&D+AM%JHuzQbVMFb0gN(*%^5_D6i$TKEmWsQBQ#ZjBP*X!?zy9 z*$6mVdJqi$%V)PQev{Kysk^EKDG7%VlO^NJ8{D5LX&$wZ*Nc=G-ab5ID(7kyN9Hqu zpj46=%4-k}1CTpg7q6Wu2(2n|M9Bvpz5X);1~?b3Csqj@9UUZf`@N%)6vU8mngjQ_ zbj1b-$(is-3aS*2Rh`7Z*}sS_b<}ION;q&zG35r!w7%KiYO0GdbP@qq80DInKu<2 zBB+yD4{0j%eFWeqM@~mvw);-1AB2geNxxEyOb%@W--I4QYKva*0;!{r(xOKLem*wr zz|o_B48=6_Yl85w3l zQ9(FkP(+=K;JXVY?b`XWu)v=B=kQ$y7s{l-JGA|(Zm@i}-OgjGM}AK~faiD`wV7Ae zGwqSTa5ryvoI-(oV})A2xJ=OX+;=|=krbJn)*ET>_zD6DR>YaAs4@BQeG4|7NcR^` zzuN`>AHQc*|K)wz{FU~OW-#!~=AFUE*3*|U^n@qN1p;KrOnSq2M0rKWTC5C(7okAf z7@PKEc_Eo`r}S+(P8$4Fv|XqEtMhEZ;fKunwnR(yI?8340#YQI(x{zhB0kLypP0y` z>=fmBzbU+@$@O79ZIcHOz={Txtk;m6+laRIP72+e$z>owX)2RcZ)K%@chB#`ON%Hf z08f=+h4gqVN*|oQI!^e&^z|tN4UcJ__@c<$mXFk+RM?Y+NsXse0FJ%L(VStOz9YS2 zv`3tXfqA5wV>reG*5<=!@q(P=UBLtba6(N7uKN70N_zpl$f$KQ<68(u2hm z%B4X#vt(pN*lGDVqvLan4W$I-r~gjR%IU1Y#D=xChl_HpH;}N_gTq<(6v_s5S`PdV z>Z0CN;M-;LVF4dpHQ?`f3RRl6aGZqNJs-EFe^;N#isi#1wza||%{X{!ctd46Veju5 zJ+FKj@^0q{07wgixQnA0K4*E>O1vwUzZkKqO$*s`TaFGKO&8OG9!@QM5dEsB7!e!%!L3`Jpv|oO^lOYaP z{_^grg#4={PQF(u|Lh)&b2t7sr_3F3lYUEU=xN-rf*Zr{*a#xPh z`yE76j1D)Ef{m_IN*)!R7PiW7P=$y9P8p@nJ>nBkD}RNB7mwn9k?0o+eou(ap2$kb z(_Bz^$&wx5jD`Y;H$zmskVR$B5E{uwgyQszlI-p%I1yMn)WAC|Y5BEYKLM)iJHt-R zEh_WLH1<6ykoVlA;HP=z!^uMCMDap{u_BwzD6@?o&iPBbhb)*!E4-i@#s8KM)mU#d zEhh=-jc>+_t>E$>&XC@-V~R(aKLkGRLewKJCw8vh;``-uDi$o~LAWwB4Mrk2l6r{$e4GAyvne=OqhTNPn*;#Wx|`{ESI?fK~Ali5e}d! zhY1$SWK!aN-!nMC+q)b#4`FZspbYhdU`Cn! z25gmv^cG#sA?Js&_|?xUKDHEqRqB@JtW6R9(~PvdgkcA~weO86JRO7c(_Bd}+lN5Z zMcjrpnfXuPWH|3Dhz9x3jI1ZKHH5Q2*{f-pO5~1DCtFfW%k}`fTZMVY2x%@gmabo= z#ldd=+6mj>R|S$ZR&{PJ59E}9W=V~<6FV{~Irx-?4aGoB+&EV13*2(gPkBTI2yv`V zCF4{y`N#6gI3=v9X9m)t8lopA~D zqa^MSO}g56Pxt04$X>#a10g|l^D(<%zOIeczi$OZ#hJl)v$XD;`hr0k!S8$t`Tx~} bqXm76<+&VA+)=zK(f}|$6Wv;Er`Z1k@e4R} diff --git a/src/LogExpert/Resources/PNG/48/Close.png b/src/LogExpert/Resources/PNG/48/Close.png deleted file mode 100644 index 91246b9442df970b6c4425974790f121df06b1e9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2723 zcmds3`B#(Y5`MElK7&9kl|@;?l?aM#vWSF`fD7b;Y_cdV5D*ZJ3azY(kdOv&FO5s6 zV!#$b5J6nnml!~L3m60igenPKgov1rvc(#co1Xhu-21~jGiT13XU_ASGc)hG;6Ptp z>?SM#K$q&bH&o+=e?LfDV?+Nqfzdd`=}=!EQ2X3e1^_miy4O1_D`w%=Kwo;e$uozL zpM+og9}6yWaeCNowK3pecZ$LHMavkshj|?1^YPcWRw+Vc!gC{Kd3fsav&n(GKzWn%u;zMm*n=OJ8{O{53PyN)?Q+M;Z|X#Dl&F1hDkG4?uZC>Az6G z*Fx(sMNahN~>tMia?7>?WeZ|!A= zsYevOG3z;e5YOSTbHLq;b&>pD;(GfB?%b0l|$Uk1T3j|1dt+}k1`p|oxi>va8LoD^L z@F3hWT9{(>C1R*2Ux4(!P200L1gGqQ$5PLE)Xi$qSCB%7!eK%4P@7wcUXDj&UcySp zZqxL)p-yrPfpjp0^;2~_NS%Q#KU84D$JSMx+m$&pdFso6bZL}Tk!})MZ3F@=@yVrE zYzwZjCXb1)Zb&o8y%`V$vV3Th#;lz^1A7y9C|Q4$Ja}`+X|`50xdp`F+U#V3cz2_f zt5W$!fWLd_m&~vOn^gh?Kw3bdg`JszU8cubmd2t0#ZezABF~LXY#a1yC0+J=bjGpc zxFV47>X^7gQlkaLw}iQrwZ*pll{xxhMJz8Zr^m0A_}-IVOGgTIIGKbu^*#`!*86Hi z8{j^~e1z13le9|!Jk3usP&wD;jbH)p%t;R^8IC(T01^t>aFC+BGXp&INnL@vXai`TP~zz7l{t%Fz@fKezRc9Ggj zR>LSoi_Su7bDNjJ80ncsL{>=XD^ZG={KcDk#~^XoH2wSa40nP#u8r)uyV(`ZRX-@b z;{O0u!mq|?X#P7n$QA-d@6-BmSzNWet6k4m-Q93(@xFr=sC4z*54DL>$TNz}oD(C% zNbq6x&tg1Yshf>rf0;5zp(o#XCaeZst0ZN-?)ts6_b6~@rY~|NMm$w`Q_*3CdWYoN=;zBPZZ`HSy+a2y z{MVDtN#GvVPNdhM$~ ziehtdkKQ2VrM8BEn^!%`W$4vuYmGPu;xWnAwWFD6F!+2+27CWFBcEkzj&s?0-b@&K zNDia&I(=uO&>;4^Z}KgmGdW1MHlsn0jB|0kWG3`|c}Jv=_R6hCxxa5pQ{)L>cxJFY zoPO0L(>pZDxuep?&GD!1CeK^!c|*4ymlPCZ7sn9q&dt{U`J)*7a03i#vc1Aak?il+ zk-ErUc9(BX_2r~iAwc5J21xCW#M>;1?zn&eetn`MkJh4JOF+-Yn+Qu&N4xR*&fn680EbM0up*06Vh;I z18_#9e*2DpJ2RqW^=j1o;?rU=+S6=2ai$TTw3q!l^mXL*UC@V~O{3wDub6ZCiR|9Q zpfE*mf2^G>5ntSiPSB$1N->;I&E!buEg3(1>Gt3qC=erUw78P;l%h**EIrw z)WI4DX%8?kY?xoj`h50fu2K55a_h@4Ynp>VQP}c`VeRovRTYNF)-+{Ju6tkOpe^7| zI@oH4yQSG_R$y*9w*iRcMymQdk8#V|Y+psJMZ~=)rK?xtd0%k^0LFISTFT6BkGe5u zGBfNwr~|mH{Wp$AP_?`rfTxvA_H#khlTN>uprOi*CljiV>pa(7tOzF=#)|aKf7d!K z-m~S?$8?^1i~)l_~Z$f03!3*O&LkwHHm15RN`@Q@Q`v>U|1p z?32nv+t9I8MhzdHC}E<6&y?`Hi9Ty<3Pmw5B992LPx)Q;(Wk54J5O;U7-$+-*f8e5 z)_)B);?jIx?7k_w|M1+gjBAi zm-iv7Wdg2?!x)=&h7S>Ws#ZVrTsL0vLYqCx;K%C{DROg16-5i+gU_^Fjs#$eL__Cc z0i{flW>yD4H&X~9Hv%?gQRWeY0B6_O8_?SU$eS8YZ$ko{9I*uo0|41mIiID$c#GPP zy9)sNe9-8k2BQsg5g&{I(ATB4(;AE{ePi!3O_7aPbgwM{i{_4;|Ix-0^}VLBN#(Ss RNb~Ci)O~?_Ykg>({{Trhy(0hs diff --git a/src/LogExpert/Resources/PNG/48/Deceased.png b/src/LogExpert/Resources/PNG/48/Deceased.png deleted file mode 100644 index ef17ab647fcb14000ae9a3461ff99de55107b35c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6572 zcmb_>XE@wX)b^}ZqisTzAnGQ1jb5Xz6+}(2x`-YYLDW^EL>IjiAvy`s*+fkUB7*3> z_g;d>Kkxhf`SN`D&0N=+`*-G?d*+(!o;l%~8VJ%GcWwXxNRcXv+SfhyzmE|Ay49X= zAh_-zuG$EBP~Jzs3IOeMq~b$ePm|3|f&*!UURP__t%SRTJcC~X-4>YOx5VTK;SUue z9>!|w1}efK0Rt%cx6y$Q0)m0OJOz#_F?((hDT@;9Ryd35P0gXx;6H6W=gop1?$4)t zHzr)CP6_;e9rayo^-Xxmyj-JC5g_OjowweOnG(+-!|>vMT9PBcme#h)`Vhz^2N<~K zK+T57rx{zIIX&1?@c{_``sOzIG-SZaY?yupq#Pa{hi-!vL4JEOH_+>Ke%|H*+-OsT z2_(St=8KD2N#M=}9Z5KVBD4Q&3NA@{6JQU#{W*|)$!?F3vWtaRpYuIbCA0@yAGhY8 z_KiaLH>a*5sSmiyQ;+uJU$BPzOR8f7$S_1H8-;Zl`Hxk{oO%+LRT|3kKNXb_pxbas8p((Ca9Xtm4)z7Aso@fzvTW!}%df+#Xf1^OOmw?+DDi?qJWFH~t59?UU~I{-+hN8*3V zJMHiQ0_inHb#L$Z9sFXuz1J@_18y2>Ve2a*_IhOhEj_d9bc`lvGnWsvd_INeGP-Nb{ zaE1o`sT_YKF+Om=V3kkRt2Ljv)6HaM-xx_CmixE68~yoZYpLw8kw2>Kb!*!>E6HYr z{TL2tVP92M?sJK5F3WEfIwE$wTf9reKpr(fDr6VJ-;G8Xw#Yi77}v&19PM@YrcnTU zr6fo*|EuD89ldMh2_}DCsodVUHU`;HpMRw)#mk4oJ3;-1zSfSm*lX9X%>p9lF#)S= zxwKta;`0c~E>w|V`{~)!*7Pm2o?Kn*sF|%cB-etcCGyQs%A)yro$3?3+q)9=bJ8^3t^52FUmMz5Tm zMkF73^-~p{Ah+i!N_NF3V`ALzhn!fLJB=z6ob{Y`d=`#8@%}BSdpIYAgUP)buZO>b zzxsinEA}$DbGe7O5A7Ll!YqHX^7Yl_3%WB4q;k(8Mclm8`jdZ?^a2`@yQW!)ve>|` ziqorFA`<_rq>(qh)RXrXBJw87cz)u>&GQrcby-fdZ z_X{og(?}0)Kw%vC}SRcrc#~t(v zYoDISXWite3VObhJu$M_e?fiEg-2M*JI2D=9QS-lu2%9g>^Z-sQLP{%sF$vI%c1N4TP?(VGfE7ft$$ zZY^Aur&^qT(MC%TCeNv7ntYbDBX7Sn-s*E~3>=uJeKRIRkV|`3`H9W+fy)l;={6Zg zWofGzwMNQn6THHo@teE7D$ugOLA1oGRNe7ZI}SPKWz?1!j*`%cF^u>5Xj)RoGzuzUY;z~B>?J$a_4tJGV_U*fPk`|afENo>z-3n$)m4w>q zJYXX9jxl25VOu(X_W)fGQH=vb$Vhc2nM*_IgOxKo{-XnrlsN^8zMa=}FYqWaC- z)OFZsXa@mxd~XM(61tN@cw2v&kiqVop))bZ&+1E(3;~u4KKZK>swjUEmwS)cyObnP{i%R%?@uNrgLXKSRZa8trIWLIAr)_J7aKMKJ zi~1pp6=rP4%#Mca9EkSwtTTKzr!l48WGG{J_w!I_Q$zolg8^gm(o>W~Z_Z`~V(3vp zF)3|P$$KgQ_RBgeDHv>`Ke&(VasOpQDz?79RWz3jMa!R4{VKl=oCzwQna`iJ33RU= zYxj1-O$c4EyItCfF~s{&iVDlUSwo1N+BcTcEPr9~uAYoo&cq?{&zcnY9Z!HWIyrH6 zy_0yNVa|h!+2;M`Te$SZ4!@6hQG!mhjyV@F+a@FEB33k03%^kNBqyn`yjNZ)UY45x@<(dLI{I6oQ5{Yz} zz!-^+d=SL*>!lIp2yOh4fXsqu#>nQPFORw9h)a4cA*hQ=BRkAWJZU$5Iw(FIomkyk znjg~`CU#k){Wd_c3i}9PTmHW=Y_>T4iRe6j<|HlPY(z{<*UL-PvXHVdzn)zvkw8V zvs%fLx{fy2)A~9gdhNEhXoGnpfO)babdzdMY08D9A(@T08&2`%AzSI(3B{ui0sg~? z@Q!FLrPg|Y`61Tbdb{fd2`zhfXb_`1QqgCNs4o_g6j_B^p+P69LVB@`3yz?AQ``5( zXl^;gnQv_<&UcUnX+=1^ND6+EzLb{eu`vO#``SM)y7g^QYX}vlRftxq2E*O35(2-+ zD=R#QH$|i+I%@r0HNN32;RBIuYd^oagD}d(nZeV06|b1v(tTdKVUN{6QC`kE zrlh3`M;%KopSbHT;a!!D$eAOsvf+#Z#9~vve~1q*<9U~(tz|cTUz|+;9cVWa+CR&h zua-twXT2MpUH*&LeF0~8|3yvJNj&3Wr*Bh!edPa*{Zt>VP=CbJQTK`Z(hpanf@W4Q zAT5Cn#X~{uru&7a=lSCcVrP?^SpTKlTerN|mEl2YCdcSx|MN@ZEt!@)oqYqeg_uEQJ-;na1NJiMV6;69Q{V zU6~JuNlLM#>Yi}V8^$lJKTF=7<&c5dOxOsmOhU}2pG7MtSamqg=Kj$F)4%Wrw5_F0K#=Q7h(v>P{PT`!uUOw`uz={)6NqWmEz-4a3a8`G|R zoWd;~m|I#9w8tNWL|I)g2Chx7=%p11vDsZeh1`JRC*C?s z0y+MY0;kby+w%YN!w|qc#PA>Ld4&yf zb>!{lIu*d(!~N>j)U2y8E_PsIU<5yFFQav}S@U0pUjf$TvTJeQKQRCP`4!nIlNug|@wnzI z`%IUAvi!d^xUSRC+`V1bc+Qd|Jf^GzfCt_!i`jIYJO3i!#Q~-}L?v5Xt9Mi3kkF<^ zF=L5(QBkcIK(ixjtiy5*C$#bgqAgjaA-|DYS|UHlN$20pgkZqR^WNTH%P9hq`l(2x z*s6RBMHE6DBKKOQT593m_lKS{EuGex=atzQl3#Ud!P-9spB&7wKrr50vfP_w;$Glu zg%u|zAezD42)-c>Fxanuaqoe)E}TuTcMse~a|56;P}+{Olu6rCPC zBEpQQHrVGK&f@gZO&fAWdQ*A?Y0mL>W|ry~Lx5O;`6LOP1zS!(=29-7j z#F@CF;{!3d7v5lHx%$f_Xg|C=AZslqDtA(LZOf9wlU5?T-k214e(H&iEFYJ*%#L8C z)O*rNg*A%|MNzfnZ4zCEiMY_1Ge0jCaC_s5CqBdvx*jIn>KN32m^$|*YcsQf+ZFvp zdUDWQ3AKgWpXfH)jdq{Bn2g_Ap8A{3SPy%)XwMtimnUtx&CaCF{Tl$OJLdVXcdqX( zaJ*dmWeeX+${=;A&iQ74%{R6jz$FCDl-F11MEOV<0AJBDa$0hdXgq#$~m88?&q7E(cyGIep~Htc5Wbu|bwpU#~M3UJvTJr3cUR)`M_yPbmdbj zRlpH(txby$6$?}L$8sed9$=Q~GbSE{BD`PWZ74xAKDWOg!hoOU-_Ph>nY7Gug20z1 zzP$~7AfC zJmz|;uhx2+9!CDIu!t1YaWhiy4)HmAZM_qKP#r`CvUZt1VGoRO| z;GjIcv%rSqX_DZI<6nd*c_w}S_{(yBj0qj^^c0c3N0Y&i{0euybqu2K*N3?ZFRxDo zvod>-a2e$7mRefdnz91+KMEVghg_H-8V$#1Qr$@Z4OfcA6euPxk@;)Pb8L5G%(FZ777 z9X@Dc-GPg2GV8HyXQH85PAdH$9cf!S5h?(axf)UIsAgOvLTy#tWmbl{W}I zAQPTC%7Sq!H(>3s@(B(HD%_gb`m_ao%V;U7Hc?;Dm-0PTps9PX5Du_8s8?JCzg3%h zjd0Z1ed6ZqvAYBpV&(}{b1qKb+FI=#c`08;t()&9joneIwUvn{F^hWOBd3Y?m)W-tW%ndO8_R$(@%yK ziqJ~erisa3q>rSSQiqOE-t6)0sCJ|U{HX^R%9lM# zO}X{=ovpDk_@)fJWj!xzQl{fk*?|*7G#IhIYmxCZ*y#Lk51+@x7pzd}qW+Kc{9y>T zAWoAw(_>38F9Ih}8p4!wkFA73R#0q4h(g}8(LzCPMn|ulDAl8$6v1h4GMw_teb|}| zVCp|yR(e@nY*c4LG1P}Vc*1D~*Ow9X_BCWA*Ycvqx;SNJq1n*0;sWkX$1i{|h-*7nF z?UZQeAtDq`LC0Y2YwQX?kE*8%0sJiE!Es_2{I2$`$K`&6k|EO3LBA!dqs+AlurYO^ zv91&TRK%OeO+Ftt}VO>|37nc;(xkUw^fm1UwvJE0Z1hc#d3MG G!2bdDJWtU8 diff --git a/src/LogExpert/Resources/PNG/48/Delete.png b/src/LogExpert/Resources/PNG/48/Delete.png deleted file mode 100644 index 78794d0ff0ddf8f2472c7803f8c6beb691e630e3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2095 zcmbVNYgAL&6+ZWpKoSrV11>rk3BT)<0@Jb-AB%+W(L;?!&QR@JTEz*G?auY@H z#VA%$Fd8IORD$6#fG841r?iNODPU%#5wSJ|9Rj|9@ZYh46e_#Zo%ZU+OB8Ox6VwLJ?>0N9y?JZ@Ze@{fx4 zqZd{?7sRCV8ta-U9TDWCu4K24h;-**x3oIVF@?T}Bu_m0PX5P_)isTjK-)T&LOv_o zT6KJ^#Vw(J_u1+Dv>t`RcrAAD+>Ok!RXMNP0&d>$3iH*}p`}5$gE#UK3RtW82E|EU zOl0Pum|asm2GT?KFO31?+5r+7Q+GaiP6Y1yL+Zdd;r(^8b`)DW! z99q}-$`*%#nwL+W8i)XK4SLw+Mh2*+KEE)R0dNvMkC`Fz0JAkq=xt6+$y?>yajJ=+ z)fApFXh*p(p5i25KHCwP0rPv%6VEHEChMfV(v?WU4=v*RNufJK&x7qbJ56~t?v3uz z;7ri&_}B4HiB1e4c2ATpx@M;?q+(Ua%lmKj9~ihpLM=XE4l-v4s&C|GE}8nEY4{hl$twe-nBC!33fwX5Q}fN&zU`tRlN z>PruR8_DcC=uZHMkA5^eiqOmW9D0)%eNKc&=vrJ77b~iU=I}n0B-$f%&ee)+l5;5) z@!2;z2Kk8L@?5u=ou;KBn5W}T?)_cUx z`z{x2IS+ffyZKZj3hTU>6YfJI4@hNYU+|q5u*x-vVn+Vrbr6sx-CUb%aK}~i;K$Ne zJ}qs(+fuxPqScj zC@-1>+vdY6*1wdperrZ=d>55N9h}o9Era+UJ`l(h7pQhoN^BYwR1nx_xq^ z%~8+yw$0s7`I%k@h2Td|Er3{Im)BOyp-FNze5yW0caD(_|G`S{t93dOBvn##cfB&Q z04g;kGCN$K=ISbCo0mpemWiIMmu}ECgcdLY%>s)jytEusZIqH?Qo~NYNmkyz{N{)% z&ANNsuxs7-PG+R5_|Mz7!B_PR=?UWSXlafY!a7y}U(;}-0F|7@BdnrmFlt@hDC)X{ z3mh&*V(d#)jNO2NLt-*GFhW)qkKmL&OX%2^1vo98jjLYFMyglX6MiapM1FaBN|f~5 zJxlq;%<6_PiSb13!!~SAaYrf0L-dhq;J# z-Y$Lt)1%$;Xa|zjo`qsQVx6aZw~8?6tMRXF__bpBgB&gh!+o3=almLpMgA}5cK?q26lof%J#?JiinjihK_q*1+zy0k$?|Qy{ zdS`%-F=+(}0ARe$*NbmZ?DHbx4Lg7EFu@>D9N)(i$d$}70EiXayf*Jn44=H_ce_f! zXqWumy2jT#(+hvV+uI^D>(LsIe}rB*&8O^-6xv+b`L@Q(jBkO@yyR5)=+tTRlb8Hb z9w$(TM_)wcHB1j_lKShe56hjChoju}`v2%BKQ>Nzj85#+7U52_xE6Q6E7Aa1NaVY5 zKuNnI5pu+pu;^&t>!5m&BkiLSdE@VF!@(0?3<2SM)Gc)Y2RKzYIP2KlnPtE^YXE|L z-Ba7h=yKml6cn*^Z;-P+_t-vNvs>|$8KS! z*i}p+u)a=0pGjw>v*@$pMN<#MxLTZ+p|#TP6Z;5&Xq|S0Xiw$de$9Y1R$7XlGpozQ ztAX}tA+JC88qNi$@QPs>of z;u4_l%1|p9rJ;VoXDX&EsP(i^6+a9CBNv-4hWz1NqIGnx5#J9&fMmU9=*OFGT2oP^ z-+6bK-Yf76EN>W;4!E=yCmjqv$tIKYwneX~bhgJ|L*pIFXvTu$Fb3b=2ZuOhfdH<-Hwer~IpIn~g72o6d(h zM9^hL_6gYp=;zE+`V2`;E`4IM6i|*Xs0`AjVae!f=9@FRt|6`7J-JCsmbzh0)J!~f z=jAe48(o}Dn1aTuPY!6w&Asy^%zp|}88^|H8%0pgDliI1sE(MB&!w8w#*yRy9qI`V z5P8u_&sf+sbrueG6o8XLx7i=S69#(3Q)?pYAT(5;-BPcMk@5^N}K3;LwW@G z@n%+RGdpjN>0#s`eZSwy|64`(yZ}ev@Y@x8v61$26QySKL$1f|=-`xMY35>nX=8OW_`~XqM^&*~x^q6}VC~)gexE z$!@t+RF1^DjgiNf&yQFnWM`ZjHX7e9+6O55dHf$)l?Y4OU+aS6wu9++)^O)@@2Z(y zHBdKnbvnF}FoCUDX;MBk_Q8jQ2?1l?_4eoFP$Xfx$Gxy45u`VH%)u41sH@>Vii*~s zG8pq8?ZkwfPt=NXZ4(%5{Ao?|Ot0p(Ka{f$q)XyXA;MxXXuRn`n$NYbhCd~=+XH7r zJ$Ise^l!s+UFV|Ey6T-#$~A~E9bCHX(lFOCubiS*yn3;xJ5Z`h!?b#rlmzt3TTpkT z-&3eN$E*cUm}u_fRV|Va6-I`L?~!6!2X-Z(z?c(}q958~f=a<&MEWwqL-;xBEvphq zwU#dxE@e7&Dz60*^1zuwKa_UpLe_`95Mv2im?Xb!2jHEo-17l+05Pn)p9dQ-b7zb5 z(**|1tR8s~eAa-M_=DcAn*ky$+!S=kK&9K%E?-L`3NkN^#@HFkp5ItLh8Spc{(We< z0b=>CU#z~y0k9+gdTEuRYc4>Q)xr9_iiBF9#Sqr02^;@u(|C(%s9bIli0tr&pMP_O0 zqdLjmwIuYOY6Np5B*^x)=Vr%LPhfdiHkKSBud4_(2Sw8NzXk7zjWP3&`@Wbucuafu zli!XYZdu|NVE@=zX^r%Lf!9OjTBgpVmZY<~_re-j%_tGJ5oxkfoFBS$6G&Nhq-{5t z7++i0%)&lm%X?pi#qtS_gibE-vI(3ZLXasaPP-)OFC?$;`B_JUUqXkJ7 zkWQr^e*eSs;=Zr*#dRN7oyT?D$N9|INQa7ol>z_&Dx|Ka>9uY9-+|t^zD?)6$gT}2 z&{RhqC?8^92LPtKNKLf|XosyFvf6MR^KKPLfh$lL4T|E1>Q;bX;)0+QAR1#PF*sOQ zx4`-iFS&q3jIkZE6GvYdE2sxayWKLS%FX%!5-FTebYMF~wSzsFZ$a&31P)~f9y@G& z{3~wuC1b~6_Lm|BIfOB}ErfCI?;3_XpIg-+N{bH;u{zw%~jg$Fu~LLneVrSs7fZq*rtd#0A#(Pj*y9 z))fdt^LuAm1ZA=HuLR}#$_zgwQkD>;gjC^Kf9I*P@aAxsaA`uE5(pQ&3O_n4lV6m6 z2tH3MP(U^&70g;PQzq=0Ag{RBy$KHHZwFo{{+mgjG8FisN_-_EwJk=N=U=ZQ7*!b0 zFKQV)1DH~RoH#ob^zY@PYFl#z`!@Jn?1)(cds^9qY)9g-exvQ>=YZkoS7imVzw_$# zPb+daN=?t{p>4!4^!HDSMnr*8IBR%0lR=hksY&Q3JYgj7dcjNS9EecyykR(N{#2R|b z+Yke71=N!uR^fZtnzzrs%!Xm!6f79cCO=J9oVhK!4m;>^`T2g+I=n{H{TX0zu7h-0 z#@7Ye3XNRpVN5RfFPo$TV-LS@uXl!xnZIqAPr^ZU3T;2E*jm%r@U+z(s2wD>z|>S2 z&dnNm!!+kPkIcTd76#OvDI)(ezpLi_^UqW{9ormVZK(B071yMPi7mL9VKe_|SymU5 zzz-dLvpYdnk@VNRUG-Oh+~u#Z*n7sWR?8n5fQ|o-5s#KrwKu|57_fYf6Rq_Ddy7YD z4}S0H)$FbJG4B7}zyGkIkwKOb)KK_O9~n0ITX-&Vp<>yU)iJd7G_WfvzSgl<{4jbb zUIOYTjr3wDmvFxyUy)ofODAw);yjU!Pv>5gL8%GEz6l>9i|!qPG(0*@Y*A23*_<+i zsqn8;BCiNX7U-0v-=GTy2ZFq!!|khGltb#7ATJ(;e|pSR7yIRPkOb=T_KdQ?`puKM zsCn2us@R zo+Yw)mQ=VJYP zhNVwwzC}9~y$7T8VdaxaywNDtSkn!+HTyVzfZ|bo@i?F0MQ_ORe@oV8+?`*mMbrj8 zt*I-qBUNt=F6%AAMjx6hS`hOJ-W>S`dudF$Ee2N>IF`z_4lo?HV&1%k`l;L4a5=n{ z#b)`c&s)DOyR9{+w84F0_okDBm_K}2CbsSoaS~Gad+C|v6dY_c_h&r4x#t(&xMGVl z3Q&aa?OXD0M#~#l2jO|*bumWD3TcyAUnI6lhi9{*%22pvMMZMM*gsGzZcfC!FL-N< z0)Y~UaCT;4tNCjPv_cH#5AG?n2QOFXW1dN32fd0sD&Jt;)UfU_m@4zzu!xWTX;&cR zv^@G38S;6IxX|p!@3tEEv!)p(B8OLdvrpBqK8W?5oRj)T8>xWZtUqF6C$Q-U&bcXyqNUd(J+39(mnR$BPAO}U?c>%u#Q$#)g+@EZl{ONDb%p|!E;dk?c(%Lo1uRR) zC&NPb!APl|BP9Q=?9wn#?_WM|%aK)nkzI$wc?Q67!_jBYp zE1F(?5Oceuhk$=?j@AIJxD+FS+*WMQG;i3J-!FMtXD1axv-IMNs<>U|&UhEbZRix> z%+~qj8?XE1zKEl!GQTIhR94f$Tl()FwNs|u=5(N4 z5tPZBC6T(sC>JsC?%h7iK2uHyDl{~+#_#Fir$Wt3sbbK%2NFd0?JR0@q}0>w1bufE zttm>|AM@h@O}*Tt=jRPw)*oWpG?-aQ*YLRFJj*6J60V>ZiDZ~iGabXo6^9Lmf8r0D z_TR-#@dEcxV0UXF9C-+4;(hsb*P1+o`&dZbBG^C{j~GKo z%cCL3c4VQh4J)R+ymEl84_&TtvOO(C#Qm`u>?8rQ0%zpRj5QO7{#@hzFS>|j5* zCk=H-%X+&l>s@1;`KXb~I_USpyh=B#`?k>l%peymR}{>UY*$H>9&`1tJm)*%g*gr? zWgmV>hX3-8t}%h=4L0d_mlKCgcRo$qD%;Z{0r9+r_<>v@v7>-bny?Q%y+ zJQFcR)rkX?4R*SkH8+Nf27I!J2AYFx&OI3&?Sr+1h=$Z4%Hlgke?-u2Z6TGm9&li_ z=5>m8dZ*#&<|tKw+h#Hlc`4eim98@&R6ov*GgoQR&e^8c>HbZ_9Hcyvp4`A$UkP`0 zzuBL~Rpss^4KZe_`WNN0UFFeGcmt%IS-U^7xhc}n+HHu@<*s}I1b$t4$?4Rzx38jX0k{i-2ViluUMf~pkBCQ?>Z9R~q#Ko_Ypdp?$%dYRg~ zlA@oOx~Q+Vlsd_tpV`ytG-~mvdV!KWNFve`=SIf4+vt)b7ZdX;n4|?>Pgs}Q7*^p6 zSRri=NBm#q1_xm&Z#P~B-2^jVuKX)0%};dvNvOU7ayHyK-_}gr4O!`m;zPK-@Oc=@z6}-0kOS zD1A^RTBZiDdQt6|4OW?0*7DjPK%F3N{@}Jxvus`~>~}n9+WwGIg~Pz8nt&Jx7){?U zmiSP4*&SH*&~hpEGt<(PslC@ACgXnlPl%fjIp`fS*WC*qQ7DShXkv6s0_a~bN$R@= zJEWWi@cDG!CE$|*|D}l0ksDsddhdcP7QiOl5x%0W$}^XhRMjP4Sp5N!8avZ-CG*QsXP*Dxwipf;_J5~HLz1Mx zNh%fHb{06YTTa#CO*s^|2e-f852~&Sus99Nqz6gI&c#whnMh!pOTw#Ow@N4>=hcKD zaDS}fs0P}<5H8BXyX6Jn?SvvMuxqIRoPsOeQj(I!zoYU`Mrav8!k?sz36Foc$n-qW z6OmG935awa%u3jL&dY+tdm+=**3{q~qb5=?!se$5wfHPs|IRh(jqhOU?L0@n`K3S1 zpcpd>71s%3qW%IIS$rzJ9t}us7tv3WxsoPTlDb^)P+_-LXts)PDwa5{m3>F0Hy!1< z-wIU)Y9s}g4u0^)3%us??S(%UiU(4eVM~llqx2mQrZ_f|fS{q0dA;17pF-Q8W$pBY|axYLe7{vkpNV8tT8-ofQQa z-Ij#i_VD5nIY!f6`MS0a^_~d=RPx5e$2qo#Ut`SknmLYiUf+Y>=}F*O8a-)@<)6Qa zN#%j6u6&$dvEUH=cbpWu5l*iN0q6F^zia(8vD-cr(VziRWpk^@@g6U0YF2)XiDmG5 zOG0-ibY`}6lEqv$`k#+ZJwF-fjpqfZ4mhKf(|oBhvt*ejNtE_*Zg&c`GVw8iJ)6w- z^B!s>aQbZuV6ZA(RPUlqoUn-~sKB>nWuMx2;x)t`!C5ka=HLEoerm2ecd|NzKXsAh zR3+*<(11!)XU!+PLMjB-lM}sXtj0$m!ZQ?mddWhS;*_LD<16ZmMvwbXwJnVvSAHBW z33r9#8mm?hMFYz?~QgO#(W}&&o8csr{yJRB=%F z(ncG-`uOTCfLudt{3k@Z!mym_+WCU*dXkw6m#Os~jiFJ{>Lo~dkJr40xM7D1y{}eu ze>x<;=HHXQay`o%_*QsD7tadcE<3WJ=kS|;YIxg)5{u_gmMoybwEdRIHu2-W60-iT zHbdMjO+!Q&U}fr z4G)mhvAhaJ?Tj!t8&i(`uAwn_Pv)n z+DZl?tcs(G=!>@MBu{-jd@fVMXPLE001ODO0&TzK=lF(&t+W)6#Kd4CqKYo>KJ2`_ z|4Wih1ZJq~2?5d&g_7-L)i7q5u3ZnuMlW-S3@?r?(8B$An{%lH?CWPJuju{~!1WIf zDF`^5uG8?oKy%F~9t|qN4r1a<&g2!oZ@vmHg#akdZ_R2c{^hY>f1rf}ho@wv=FJw`es*BD3Et`coo2=jC{2rJOtt9Hp8n?KxgqvGy~ruvO9#jBX4-r1936un z95mx@@(sNU%Rq@h06H(|bl>hQUuRkum(r4*#<4a|j%w|1_Aoi^KicC&ywSnk|FskW zAV7#H9lybjH;-wfSJs`JIR&pg$9_dmglv`A%%v}$(PazqnDGJm;5#UAsq=-0s#UH$ zUCeA(_y=LZ66QLzkO~uZGaTziE2$zIkO;|N4=ZkP-rY8t(eqdJjKJR;aa)eYy?F8W zzq>Pt)nZy)NF>APEmAs&xkFlYN!;8m_hBpR6OS)lkMmkQ4%}Ko?q>kF;SK(ZG>1q? z!=6>i8*)LFJ!ZvjUBm#F)vn79N4>|%dm{k1t64Zl&i(xZnOF+MAcE3V@rD@UyhO*l zOr}PGQHl&aVqPIs&0vs%+cG|4e!$V=yyhk?cxA?3)f%_GI(hnA9k{3GR25h|8A8KnZx3J$P%QVz{QD?5HN%=o`%;^PdIV|MM5B6IeP$9#>wd5`3MJpE7K zyBl`oZ6q`OgfBc&tS#y|8AZdeL0eV66RW}Wb2**^3L1qS#5&nL*k(}H5{!FFMVmj? zF_nt$F-vRG#RNw_z7?Lk_47kupkP}fr057kK>urh(#&+X&p=5oWXfrFdE!s@ z#ZN~tXpN5!2py-Tt)y~M==|hP(eWg7KiU_6Olm~~qOBBvgxzGIU*!hL zREYID6J8*^Mi2+yFrSBvJOYl1#o*4?^b3hIw~BMr@e^ED8zaOQ4Jj6;VRuw=GQ!*0 zw^{LmED&60ZpZx&?R3(Z-E{biTLKPsmRrgapGCuViGo)iyvg!t*Ga0A8Sxt5V+vbR zT`BD_#CL2MrbuCY_FpzEG*O5CwZzP(zCGv(HS^h{<6#Fi@!v0FqC@cW!`7`^JnS#9#Yyg2JZx|%I4F;EYLI_XyBm>BI&I-EGi?Y}J8kR` zW72f3J1MAtso%#0seFDs5jdjcn?mieVv#V*yieW=D=en_BPRK5vM^>sx5MK4jAjDC57qh_H?RB;mOa|(U1Af)Y{?tHOBU|Sn zpBg^!Z=Y$fUn`F6`5zyuDP^=M#!vH*Vs#os_!UhO=pwmsbPaW0iwUSdWD~c1Ja3`h zBdlPoA8Zl1wo%-wKWIKW=QVxQVo%R&7Be}=%0i-mAAZ#ZB}=((^{2)tWjkV^*z;$# zSu{}ap`^w%#oMR&EgvdttZb3VqcoGE9ZtYUd$GJ17aJ`S|C4rR<5xq$z_%=#1cv;D zVw@3mqtg7H0`%LjUGg_1c$B!|kTuYF9dAX>*Ov~HRuk4Ik)^??=5C+5SBlU(186%5 zmYOf}8T{&Tw>t{HxK=M+c)aO+*^O6)x8ZZ7SG%h9>6R(IXoHfsEu6F;dr!R^BLl^8 zL{N94liTLevhD61VkVntjT@@m&^y4lrU#K^pL;4U6t3c)eog^hS3n6pwlPOsX`CO7 zv}*Ni1iMO;fx0>1^lQeCR!XGYAlJq7;W*7dMPCmnrz+ufGVWUAg^c{y_vD%$wUUgZ z1e$A*3}7D2P+xQENjI;}UGO!aQN@eQs&PX{hO9L8wf`3#yk_!H;d&_FS(4m)q1Qkg zP%7~vi{w^SaHSDr0Y!4RLGyK9ZC!W79VPlsfbSYGgAR+TIj(cqO4h3Ve@kZZ3V4Q5 W*q)xyl(?4C0i>3ZX1Tgk)c*l|HuK;B diff --git a/src/LogExpert/Resources/PNG/48/File_open.png b/src/LogExpert/Resources/PNG/48/File_open.png deleted file mode 100644 index 66e0d3365b4c755c41187011d939cd400371b9ba..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2896 zcmeH}dpJ~k7sr2lW-w=Jrjgr8qehC#=yIluoG>JGF{XqW8aYK1Lqn1n#wJ4-Z;={B zE-92GmkPOU-BfcjI*OFbq!b~}$SvfZIgRJM&->?jp7+1^kG+4-UVE+Y^I2;>zxDf_ zV9@RGI9(h70KdiFW~Y2b6c1Ka{@&T@rzT&Zpq+NsprD@A1HdfY78|QwM?Ly4Np1`~ z&wG>{m9(?bny5)3`tC&gkiApTMs(c|_6=4TdJGckIfcfj*feBXT|uI((Q3XzOG7#) zk*KMzZWV8jUHoJsJE${aZAEpfWsCC-_`qZBqSE-?VnSK5#^hncTYRn!i{|+zoBj2a(VqvUN4P$rjNsi%GQx z7U;qA>)2H%$@2eTn?9IcVsqGMArvPi)x<-L?s7?N>*t#_R;HNdLDy9p#)a0BOTvjf zmIap{ge9EQ{QV&=zhOu>$=~^bjKwe56fn}Fu0kzB8Go&8@^XJ!6n=p!j-%CX&qr|P zRKwnz-s6Rz&J&`dFEXRF!uC5fIZ0$b8*cbve+UJgdg|6(815!nHV^efrPa4s6imqw zQBQN936(md7vkAs*>9tkd-g2H;P&rTap^8^_WC_cG^b?L`;NDDrl+Bcr!c*ARm&T5 zrUiG@+}U-J(r^4+=-u#3T_s&DjWbj{pJFF|Q8>N7&cY&C$wB32rH6?eC9EzFjinb( zXfZE;!X~lr8i|eaN|*7JXe96AQzPEvHY4lUGx%4Z)(75n z^IsOOWa~_=HvZv7$w;h9voxLo8nRC+3b!3O@`81JrYcGyas5^eWgf~fcCgFI8R|sC zedF7Tk zcC6h^8`z*A)GR(}?!tinO{>R`M$clc6buh)#9U5ZeVb$ZF-84Ev# z(_9?>dTKPk!(7?Z(5pU73j_Y!&V2T8>+m4j{IBK{1^o*s8Fwb~UiRmGDv0|P+}PL+ z^6$TN`2cPQ&M$ukVXyWB%>A|lTs2RF1RekPe}52YrZ0ym)<451i#K_x#|eC3foRnV*@pc^~Hpu&=%jCzd!<9J6zI@Ja1|rL{oh@&Akc zPiwY9$4EM#wwqk4vkifcclEYClAi#bsPZZ%ia?|68CXF_AfnEb{zr2Iz~1q&kU$gx zE~6b>DT2{NadX8fjR5daV$o59s`PK)HG3Ymio%)IjKT1XcU&_P);my_f7C#>0-3MpaxwQc}B69Rcc6YF5LtUW&)|D_)kSKyOeY!;z`bb!`Zs{_XzejTp%7_c}^ z&h^aEE>x#fetLy*3x2Z*Gk_Ws*kDQEt-vIz2~Z})u?WO8uIUX!1PY0G_;oVpgOt8~*zvm3DT1$auP+(n|yDH5PL!iYO zoHS`O19ikooOFaBVy}$Xg9)-nB3q27)tEnsY$IdDb%qvRYXbpuZ*cDwRG~9gBv~*8 zRbCe$I* zSg97+(@W$HH|lF!+c_q$n9_jl4AzaLyUz8zvrr4p?isi=m3=(fPA))vcRd3&7V+?L zJJlbE9@p@(wf=f$EA+#<^M-K{GkrP|NSjVuRh=_Jd@W_Fru4=jjqt-qUAxVP0cC0m zh1@!dugW?`iv_nW^uB4zZzQ7T4{r`A9Geg~UoT;yRWHg7CW9_fyQ> zxeK7d$rgvf>?VBW=|zZdO`TIFSIsS*U{bSh@|AJUWZxi1yMwtcT3C3bqv@Uzn7kZZ z)Vu@3>>ni{zqD2X4^)6yCF%Qo((@zOs}n^%7IMdgnyhfEhnPlK`5uw^N>-ul3X zE1c(t=2I+bUvne)S+jc!D_RlVLJjHu>B;Y5(B_~#tZ5i`SwqF5&CYneEZMa w^>y}h`MUqGhbbCT^HkL`-$aG}S$Nb+AON)uvY3x$@+&gfvYBpEVC@U^MV_aSW+od~>*w^>BcQ!^H&} zK=^{g)m+2M;l2eXjRFAF)_eR!C)@=%FkBcoiiYnQm>(LFA z1nOLSP;AM;uwIiJT@%@&gMTwfCN%IEIIu}5F!M}cWIMsYoYKH(bO1vb?%Sozf`48= Us*)Cn00tq0r>mdKI;Vst02LsI0ssI2 diff --git a/src/LogExpert/Resources/PNG/48/Folder_open.png b/src/LogExpert/Resources/PNG/48/Folder_open.png deleted file mode 100644 index 5a0e780b26396b1032be1f5677478e8ec20101fb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3681 zcmd5<`8(8I|39CP560Szv5X}q%Val_trTP53CSHY5iN+4NR~k%OKyeiOWm?$D`Ir3 z`Ls~7wOI;da%U+eYsfOsJlFFVe6Q~h&-24M@9R3}{d!&R^FFWZT<3Mo+0jafUy2_9 zAY@~0?!t-azXyhgGrNoi@p1wb=3-?E>icBA0w64HV@`34Jodx;bdQpS*a1Sup9Ugt z5gTl{xy3n2{n1r#gy+pU2q$JiN$0Pk$Nyc%N=mq6ZH}@M4EE6f5s65Y)~q^?7c5BW zq?-#~`<11?roF_R-8V2WcG!D*JEpZ}w#0KfJba+;a%(~d#w{In7aKYIJ_FbTr-T|D z8LGL+$k2z3cxx5WoK4LBJpTg*%`#1Rx=jzj|1qB|L+6Vc3~RD z(S0Bge8*4+UK}^(MVa{4b9<&%ENH<%24-1<5htFyP%}N4xX>UJ;@hi@ok;}yfq@*V z=|{+ZtK*Q6UUdJIay4J04y~a#cOQ4&_y)G0r!nNG(*oCRoV5)t7}~_3-)7$0HDRVzoUD{bglO3O7;^u@ugT483xqM^dQya$|MTum@S3Y4SmnPc0ft!x#BC- zQw1|00`$AkT#;m|Nc#7OqR3k2DYMj*shQs$wg|v#b?|cWPPP!517ZbP>cGo)m83%Q z>qW}^m=G(4Y4qiK0~{(ty9sTo>B^8yq|6->_8Mr;PRfH!*u+#3k0(lIN4ny-)<0bs zYpXQGctI>&Q&^=U$Oksm_9u7--@6IJ2K^^|b3^L;*(DQ)NGANEA;Zbz$XD&L_Lu#- z@wYDDjZEkJ6YkL1m@h1o^E&eDkugo@(ZNn+CY3eui$sYVelTs^Yx=V-SW1IrviAZ- z$RUB4cRNRzr}5w;U4SnWh&mqZkU%c-ZQeKDM238+LnC>}zJOgCnmlMA{jD!-Znj&0 zFW-q*N2Noz;+EX&l=w*|63e44ksK9Hc%R~WM5MwODE+}{Rw$y(ysB3w0RR6JT#4u{ zVALXjIqN9|-#UAYar**18hO$1_uT>do1}{rRyOJDAVqDzaxvHue7+;PNkIOrrx?5e z8HCv)kuhQSeh3|Id(+8D90c12N^m1l4zKh_x`{N*KpJPKY?ZX)>2oK~E5`DA{CiP- z;{0$n1~tm^32yqtkdBvxH^5p?Hijh_R5DVIAt$bDK%4%y$eJFF_o_VgaSe{T^=+fa ztn5PwXkgzf>3^`$^J*bg1;<(dPl(T1JP+kjcrI+(t~!L)$`$Ef$7~)GfrntaBrWjn zGSAvU+89ERkh(=)NUM`#a6-#9ydBht)t9?dHa=Jr2z-3mGuN4cD)) zGLFhf4Q+X8&+n(!XRq-ixmgvyw;FinTl|A<6==V;=DEPC1f?me1k-qaQ|jEQF z10#(W-(4_`F-t$$$=F2qnMk$|qVBrlC(*H}C8>3UUrz9Tr6^1;?f$xpr}sjve2KV# zw`VvNc_MKxH*7ax2uYq)LDtB$>8pgj?>`S2M?mWS3XQt7xRecc&&KmjV~Ptu+y?dv-fU6pb&R$~K{m=<#@qpLt`SDG5I0?OMRO%Ypb-OY_Bp zf3G(gXV7Eu$kbY;X-q0$Z?5~LEhl$VmE%El#ZKbdVoWcCZHL6%o4N*u z*zN0;C$={-=!dV1V9*~6wpUIYT0F&=W;F9aUP5M=u61R z+l0jhgvFNY3UO zJWCUJd@#W^u*I4e2Mz@Mp;^lPe5yiH$=mT4Vt}9<+;ZASv;VrEok=^oo;)ObX)9}p zsMNJCgo;MmUzJcz-*%l7xbiFT@o^mMiSa6XeJ57cK4+cgJed<^h&S1Rv;`!Si6b#p znn^sC zB%HGa72#@v9tYtf$+VDbcl_>ONOCZ@xsFg(@pqp(znG2Vu8R)O?_ScFn71zYnG#%o zq(2K-!3K`x84(bH<+M=?_6Z{C+*`lGzq%!<(n#LA!)t5${{b&8t zOnQE^mmC&7?>bz|mEmjLoBvhDu0k#Jt##Y+am+k1Z6I3o^O^Y5_&ZAauo2n!K*WA< z%SwTj)J8;WN^7U?ym}0ggQJ?iSb`OWl-766;F-EikQGkpX-Z7iu1y6W6|o(mAsC^foM|;+cUDi4NOV4(^nJ0u};vk(p9^WE! zgyqxL4iS1^y0V-<4_FUYWVoRu)b`piplR-_}>-&Ke6S`nwd1-|=x+z`v+ zbKsM)Tv2%-K=V-(sx4H4dnUGI&z*4jz0~p~j0pVLk^>T|J>pLZSi5x$Ic@b|f~0+R z%e}JkngTB9gZ!(fN@UNv)@Q>QuboHxBlO;Uc_`OO;#^~CS4ciG}?q;{0GF|)> z;)kcL%jl;Nu?D&)tJX00cF+L(m7{10zIZ$IqfRFYgt5uI&Q+0Ha;a|HQC_bP9wtn2 zbF^TYLCU$$hb9c#I!46qy^q|eh(#R zy4m?7lRZ*dZk>ui$5@A}S>DK?&G|HSOdV%Hub%2lxLE#9W$W{UWDYtOs7$7}Z|^A9 zT%WD3XvouWtdkJG@+=RbQuZ^y@rm&`oRjWxIS3!o4FM%HN&HO~OV8ZSOQwO^jqVgj z3%ciDvW03}o)H9OZW!6~pzNW1yK+ZOR+qmz+_-q>XitK~ZhGJe73ugy5N%EVT<}Lr z$_(duE728)Jo;w1VN4IyX8We~%o9uzQ`C6ei6HAbsl0A_wf^Njk**^|pR481-uq6z zGe5-`l$M3Ux8mH)JL%MWosnGg|5$mmd$;NC^T(pwJ9)b zHu?9kH}VXNyy}2tlX1f^ghy}Q{@=1M{|84E&xSP=!Fa#p^$m_^1U43q=Jlr3gnt1% CYLAxy diff --git a/src/LogExpert/Resources/PNG/48/Restart_alt.png b/src/LogExpert/Resources/PNG/48/Restart_alt.png deleted file mode 100644 index b62534e8ecd442c6194be37f55882902511f1006..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5291 zcmb_g_dnI|`+uF|&^ajQka>z@XYXVm2bm$+A{kk6tgK@kD+$TYh|-ai*~wl9nb~Ay z9V0tZNQlpQ{|n#8_lNtwez~9bHSha+T+eu8L+y*S9JBxcT-4RkG@(e+e+x=O*-d62 zUZ4n&pNTdGC?CAC0RWesbv4yZgY161r2Z73#r*glT_c^({XmCCNn_E6w-L-tRGsZC z$Zbp|$-L5-udrXi1}x1 zp>Wg$sT2VP_lF!i{-l7Y{?8!ez~kDC{k;a;7lB*q_>kYNM8c%*H>1(=g9fSH%xK`z zYDCo$>(MTf@0|=n9lz*vula~oWy)ssP2BEalMOwXUg>;G>{1#wb4Jm zrDmIGt&V~Y|5L2{K%lyaoUaanC$ydfTM@fZ=vp-KXn}i!UhI8R=K@&SV+4g~t~xky z+zX8RZZAg-YKT;1iIBf>$xa{sN@b<$XvWd9>@f0B#?4)LnCAk-Xv}((^O+{fB;^Wp#YDpv!hb#KF5M zd1a$f8~&<|OS%;G6Lz$Dhu)hqa(}A`tOQs8J4l<6peVqjBS1iRH_bnR$Mheo!|&52 zO~^A_7ZG**L2>vdpZ!Yf^L@z++D%`fY>+9oV}<7cBxpuOXSCvd*=N0r7eJX*YOIW> zMfEA+g#-)vl#Mgul}tBRinFUe;(S0-@^$$^CB0)uPTA!NTJY3rGIDWd`f1)xBv({c z#ZhaFzOn^TNTvHJ*V&0ls`%s;Tf3Tgcwl~}r*#5Ro;1A%^=PZw7>Wn5Itz71ZVI|_ z@-;VVu~yxVe9hy=-PBBo^0|kW72NR)7EIC2AlQhl3&kWfqM5kbp}_=5mj^Ovk4(R{VkR{SWn9~NaDg$d&H{Z zqBQvCYP7Ci4vQgJd@7Az+K;Op4MQSd*%Y7ey!v+M1L?|1*R6>2Vdo;w%^YEnw^^tz zF$K3mgChR4#1~rQ+&FzjEDei-@QrnJ6xa7_$?7idkh(;|kgUaNE|OFr4Z}w^w-Iwt zjSQabZ4MxzXA1HU53e>MZc5zYLH91*Ga!59S|}CJ7cCw5xqc720YM@85ydmKxX3Nt zWA&M*?pX!2pl_mQ3Mu%i)LODuSM7@RR{9XPs*Lv4mM~ff`Q!T7z}S!WtID@-sQ9C@{+BZeP<-qOLmoaw2J9ff}k25uv>zYT^%a$Aaa;YONCwaNY&-yNlO&p^t6Bo~`+(UETq)Fl%bs^2+UjRfj_yPrKu6Cv2wVNSII zoiQ2J&KWBFQoAl9c*_WTyG3uLiV=AA$2D?ll5g8xfO1V!JcsX~vT7nQG;wJ)u0 zD31%I;ix!irr0x}0^>o$VWkA`GHFLX(m?K;CWhJ`?BjZgvldMUBt}n%w6sOO8-55=cKolW9D};JRz$lDu2gxs=F?;3jS)G zIRyuPc&|ZudDj7Bk&5pea$_*u;Eerp(<^kyd|07h{K?HV^DZ=yKOdTG{e806adT}V zifU6$rvBzxFzLE}P6JN*Wo0IRKkZxL6-95Mc^FBMp+GehY!&0`GHE2=nd$qwQ5Ae5 zr~0+=G7w`V)zT^6sRYVTk7}@P+v@u|{B0-wAehaEHt^9h$|%*}ry}1eABN|>aML}8 zuBs<%tT?&IV11RF)H^u&+w|Nh0m`P??k$)PL#KaSLn4+HIlCFe(=f;C_>;?9f)@)2 zb?-xzzWd^s66N^Yvc;Y9G{A$0WL)y^IYGz?|Vp%kPQ%03m)LhiS2_qG;X5C{6MpKDa zscAgc0>*r2xy7P*Rk};WKO;d;)*Nq*q6yM1VhY$x>?|PF$WnF4UE9Q9UZ5@4&N)xR zA=Fov)#L)mYg4Q|J*dtnYJ~?DCl4lXIO`g8$Aj0tlpC^amUg(8r8@R=kh9Q@FRU$C zjUcEf8Et1vy;a(JEbIrugaNelY{|wmyO#B>zrjJsOY1{T{7aK-estG9p9%i))Uk!k zW9dI0bUKw<)=mzFMlrZ=8|*lsA%1Zte{?itUgtyt0p}N-*2PS{4cjL^92bAck_S}Z zb<0`x_lBg33}x^{qwnhe}A_xSuCJ@m?_<$TYxMso)> zJZC7PdIcuzP8@ zbh>hgyA(2EWOW!GI%v+s0I4gM3ZNHM%N#0lCl6NM_xc`B&JvOE@H*$p_%Iune*xU| zDt`PF(m|fT=H?O|{_av7V5p0gk?kIF%e}(z`0a%G0UGc%Lj(y~91j*`%p?yhiGiJ- zDYpakRs!+L7Ppk)q?`?Ezxe16+$#YIGtItPrN*o2T>c!rjH~an-3mqlQYsP;*(|p~^!8@P{Jab)ioVpg4oYSeT}Q9^ z@@D*EnRxqRjx_N-oJS|Cv<+WPG%28k2tK=>jQ0zP^)K_P=HqXU1+_D$ii+cmsp7pFl#zzBh;O%f~M;9dSaC>w3SeFm=_Py((5j9ke#Kh+C*nevkjzj^)uw#(zyQ%pVnc|WQ+0DcpwjI`9`Iwht0f79_4a( z?~ppOPtv)KP}C5_1K3-JQR#eq9QWdYr%drD(keevh7!k@{kJx3)EKJiBA${7Ba3L>HuEMR>N!6D3N&CmqT)yumfp`9{qwVZ0wI? zU(R-Mx;9wSb&>lcVkzC`hQRbS>}IgW zs#A5|ZN>oAK=Eyc`TK;AkN#~C*=Alq(FOVv4lK(mU>y$3HTbZVv8*g2GE(wgV9_3YubKRS{+v0RimMrM&zpE;UKs-`dK2stsa26&F5ktK8Ai6K~Xu6;w3} zw+J|^k7kzvvGGP$)fIhG94hUK6J&MExztDPwGyIyAm!#ooVG=i!Z({8I~}(nz@M_T zmkKFe-)M1Bafy3oUTim5O(nd-2k&1a=5I1t&kpzxhn@((MFYlluL%sg?Lp;b-lly; zGvm^??S!e{d<^j|i(6Y}O8K^ATYYK@twe#kgKU+j-zC#OW?M>Wa_q;fWAev8-~H%> zop$X{vpl8u)`Qq9Pn~)zjx)o0Lc+a&8J>*ySmJGjitnDn+X*7s{YwQrpkq{-o`C?>g!3USbjud}>YQ@VHmcA!cq3%OVy&`>?-nTy==U5oYGc1FR$5cBWH<8hlk%35k)w(Rpff?5PLwc|F2js$^2Hwos$xqB0Yn45B1j zX4hdzn&Vf024DbpSz*vu4^oiYv{7aR(!4R5#3L7WS^GhVrD%|$WdK(CYHHa$$5Aha z0}CMqJne|Iic5rnPq8q+(e^XE4)n&XznC2q?YlY0;Zj(Y9pJCRmAgp?&SNp(e!wa0 zw)Sjj+Jlk2;xAN()$BVthcSRl&+jgNUN27#@Z7l8;`*8fR2N9PeU+GG6}~Ki^Mrsh zx&8YVV0&@(plAC$1gcG9jYA(Tv diff --git a/src/LogExpert/Resources/PNG/48/Search.png b/src/LogExpert/Resources/PNG/48/Search.png deleted file mode 100644 index 9b5f26be8df06bd1cb5314400de4fa350a54b855..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 860 zcmV-i1Ec(jP)GKA zihXsCEo4|H?XWh23@a3{?<&|rh8_}86*73JBCO6KgNI`{-!o)rA?&)4VF0HqL54|W zQ<*&-d9LpT*N~xvsH#JT3pm@{ftlMntc~DgdB{*k)HNX=TUSrVmynM)#GwqVv9t!~ zx`TY&A});~A6Ia$N61Ibp|7kaaeLtLsrKAzxQGPpFcEe{K@ z-*V=}=3wuTk1XO+If-AuJjPcLL9ZlU;9S;heTKNyO5%0IJ>=sCacOA&RtM`qJ{E{W zN7z6Q+SY}ibOPp3`=A~n$FgcVT#05hG1Fl`Aeu`1sS{~z84rkux$3U zC$!)}iJg3mGI)Vt`oU+VB}{O5BS3kq0zND4qlloD@c;#|LJo8cA6IvG4?Se?KP7$< zjLMjX^fJDT&*`uT#%nByIvpO(%r zKpQ8p`_~>FSO5S6FaYbv{U6v3V{}Mf$ae`ykbndUNRWU82}qEDgcl@8Xl5idGZLB^ m2@SJ^hFL-b00000z@-D2#7J@ujJA9L0000by$<%`^UGzfQ{}D2afJ80jVL~9Rd;}4FWPs=^8aax+GL2rCVZ@q=x)qp-fN!06?mtjxfCId;U9!2<}?LC3nKR z4(MyBrVOZ=VEzpNFzaX_l#G!!dj*jB$BV{8Sp?+<=or2iDvW8+=*MksF=<*ch8m2@ z^f?fzGHy7BL&CeER34Sq@~A(mcoiSGH8mok8tKO!0W9Zxr(OFUvya^N8h-lD1{LmK zc5hvtVV(DyCKsIdC2r=T*?BnX>><|A2Ye?h-s7{=vf4(NXtC1TeIG4K*8>j+*nOu` z2b-TBZLJ#tkM5f{;Tr-?yKZDIjl)6+O$EY@!%T!;>pr4o{TcrMOluFo0pUk=?KMxk zaKBfcmJ0ddjKkWaLu2BW+H2g*g^*V@bzkWpdh;qS_jT(cYE0)Os^)f7*SG&S^=|;> zWyXK`ST1-GljM~$p)R;iXqN|mBz5Mg6BP1ls8fP6?DRnez%)KSq%^Lx4_mE~;zfnd zk_wzwhNVI6Y==AIhSzqNb5Eoj9I&}WJy)s5fJzMFl_lbj`~Ga%&}71JL9U$319FW! zW%ePKWF`4&ulQmAAjc}RLPOv#Uq3h-<(+bJ4nJy>7oFwPs{k~=={<>uG&=XuBxs0h zJP0=iM5jvT;%@pNvtmz-5U*;T34&JzXnUHOq7*1z6qk=C4BNWi+kZa9@Y<7MEf}%B zMY?CUEPglPMga~#m-4%mro3cPxlYd&9gIcH2xq3yps%$WQ1KG$*>$cc9Yn~oy*}=sN%JA=-6{U%I~s@gU0Q1Wlv)B7e)I?_Ufx5jYs7r&)tUZ?{qT04ns7$%83Ip6ub3!%M?Z3qv-Di>R|?_IRoD3%6KmR@+!;I-a7itE z6o&5qeE$!y=)EJo+jlPB#hP{tJ*fBGgUr7yh;_4v*62yzP8W;o`;?atJsg}m%*fBf z+;|qJcMai3x+>SEI$j*`EDH2ca}ch3>!bvbC3q;vA_VuMM;GzaWssk+vQu7KQeJxC z3EeGq_$hxUFtE|@%G>dp)ME|zvPgWL*MYXhQQwi2Fa$}yBfgkSZsobMAxvB$kJU#&?9^)TA{eq66fb^BIu*3HgC~RbSu?_A_xdA)m2~7!2 z1<~T#k3|P{E!G4!j+5ax3*Iva6fnAU*#x2q!ITVTJ(eEs*Ptc2mj|~L=ptU}lH1L? zRu(q6)cyJ?ne#xWdwgEPZ+LJ9eaOD}49qtxgoVUC7N((wOi`k%JPKAkRbZ+xT~fVX}TAl)a9mH_+F?sm{3K z_@Xu%K(>ON+L`=U;^?ywf=3@CXW z29KCloiZcu5Qa7zpR{aBkXiDD(VDWaavU)q{{<)IAQ(evtOu)A*(iKFAJd}-bvg=~FckD%P{@-YL#80*iOP-!@d=Hf4*x5aqpN5U- zDVkR7e>MU7aJ|Z-cRgIS$a9@E4cImc}nbjNSzYUu`6q0+@M`q192-&%fQq{a!&S zG8|{jXGqZq?bw><$k(4SKZwuEjj&Yf{Ei&^`ii5v7*uNR#R+HEj@B;&*;R6eWcjJ_ zt#CKM^5XP*-%ObGxV}gBoFy7{jHeYX^`w>E&Q}hO zOPG{8r-naHN7UE~Rxn$&AzzFInofPf>j`6;vdcIm!=h;40`fn*X`Ahe&R>^`MYh`3 z;pzO%53U_pS_A4Tx~HH1aoWf;0@{Y>VhSrsh8CnOSXygCqd=YYR5Vb&iG>ulLbt_Z z^QJbOomgns7N(OHuqYqDZ3-HN?Qxhj+Cfp~H$L{s` zoiw;rj*)^^KfdUpU~|SVXXEVp_qfimz#E(>-Y)zz7di`M$46lPG3J17t?o;%sl>D_ z_EG+=PaUw-TqWCevg&v1k0BLcHqk+h5#*jcc94TAxi>FsVDN_UidmtQC$%+TtmkGk zc05d6ONh|eOLRbMl34CdE3vln=&^p7Wy6+6I#+lEs{qy0GE_30%hbv&a@c1AO`>$@;*!dMCW)m>1IC&5MoEhpzQLv-ro=7ef%X=kN7h& zKk$8&K7dp4m&lg9T&E3ww!lPlDkcuf*)~t5V@W+@a@bn%1S!&k{}G~ivhKi)iZd+c z{&a$*T#;ZO4xSOacrB;O({n+=TkS1)R-(YHT~jtpsUyvGs0#Oa&*hr%q1j;-8=#c7 zBa$*lV_;CN(+KLpUm2o79BX1W&&UzbAF93-8VfT`N9|LAGxuwzbppC(YQ zX;MVu=p(FMYR?Vo?g5V@;duJ$MOa>Rjtq_6dP*zH#E}h6nwVvFW%bt`iI!X+>Ga5H zI;CNz93&^`LdsGv0AcQd4(-F0}}y|M|hk5-vU&4qh9 zj38c;=$?iFnel1>(bT9_oJ-o3H5T&+KW#yT>XRrXC*p<-Q8`Oh=&sl%oIbfd_ge`_ z0e5!y{A<)>)s`RB&s2X+?IqgMPpHV6c1z<7eq=zg`mO{N$Q$o zd9!N--Qh&@CzkqiaZMlZr)TuX38yJksy_>KsZg${-msQ+_Wz8f0SxjuX@-ouY+K~B zNU?;&cSC=OX^&L%3`yxZ^ba%0K>rNaQ^7N~5>N2lg^^B^#x-u+4d#Z6Toe zZ2q$M2@;`yAt47*%iHi&awjKZePU1x4U>o+Ru(W| zL<1!B;NQtwZm5V(oJ&;YN1!gsA=4FwB*?_?l_2v;EYYkiAd%TRL0>4`<`H{Z>W6iW zEb&?W(l}`d;y)op)+~;yvl10vPX7@3_$9nrW@o)_*Fkv1o1Qym=_$DHN44qq|9L+k zgMHks=TR@wlH#KdA`0X&*+YXTW92;82Mr1&q%KCXq@RZlU9kkgUq z9Z?p#?QKV0Ugn*=E#&T>USfuemJ=xa%C1FU zf8v|R2xPQa-p7?;>a)I0Mi!!@Sa65caCIBjS{-WI-W7B&-xVCsw_p4|1u9@ri!{`s$ zL)b4g8#9uHtIMFgqVda?3FW?j@y$JNwn3bx#|FdyU2p|Kb z@t!qA2P%bbe#>s2-~c1xKmt6w=i zhw@ToxXCQx43ku=HTMGyJ7BcMoDT?E-RmB9#jE0-US>mnQBCV~{U#m!rTfP?;OLqC zHnNLH(L>WQBd@DDV{69$a98gsbl;xs;`t-Oxc`6)z;Jp(>ToD7&ba(zv!DW zvl<>x&&vIz9`S&2Fi)CpmhRVZ*+upDg9z0XIq1I+QsGY!0&5Os-(sy@^jAAaa!H&2 zhV;Qfe0Wr?-qnuZ>p8;x zEX-VW>N^3Atl+{B0&|;ANTI|kw}kbjUu3Dek!hiaDQhTCB4 zpGwGT{FaUL$Ocww6Ryc_v8GA}Y0H8KDkdUW4Ont-yKnKNwVWnoAl&!tU)5}5Fkk6L ztW=3iGZF5ww)zG1R0T$xid;q=#uu2-@I_ztCY;4afvFT4Ly z5UE!;Vu!yC^)G#hO)TliEtTH~eUcHXSv))T0g&Qn*?#(t)c?5Lg!rjD&=ulFq5n+wUj45x_%#*5D|9J4xtH2wcei6il<*~CR8J0}dU zF%SOsA@V*HF|v6V!lUG}hLW*N)knS*w?V#&T14YV_yi_<`BcHb1=B6)nZ*&O^{@@fnomJ?u{(F#;aor9LuW zqk#t%cRjAIfMI_8-BvQkkAJog`r)Jnx*)(x zXY_Bt>^QI@Qfpx?AYsOrFIF9^qW&%!`cFN4)x56;YPnw$S!CHucBmU7v&5|obR9)S zh$qsY;(0d62C~9wA-1eO?7u;f)L(cQIm#9^LV{(ilQqa{q-)773M5>?g(5;`m?m+D#SrijNcA?Z*@~!+qZ{NX8A#DV0+}QFQ+A&aBOXyXtBs*8@Q(moz|(L3 zT>!t5^0Sb`)03Bf8eWHQ9Xa*2f-voTcYg-jvz+~P)Rb!?(KQ0_03Nbtl^m-jS^ZRp z#M&G<8|a(*_S5s9Y9RuUfgY{fTpn^}_j6OZuZKRAxS_42`xSsrBtp=pUHQ30DvaHp z!m~$Y2ueUaAwL`a>sl?ETe+PgCY%F&+z{<;UP45JB}krDZqgNkKN6z%V{8Lt8gC?3yY48jtzX%biCa?<_QZL^h}}u!8gGS3pc}jQ+GP%_&T5kUZZ`z7=kkO$1|Wua-UZ<|IB?D*Q_!S8Gct{w#{Qb%o~U3MyHTt6_D1-(0HHi zWw$u9z|cK_*g4)b`huTz+KMvVb?uM{Mb1+XSh0)`ATaXhZZZVahfxs7wnhVx@V|RO znYus^CG$b!VXjLCB0ah9=9`&|s4tX*hKJObN8ny&SRpZ16PP_C7zOc^mE zfRw1MMh~_4xU0`D)?*A}^7|{wL3Zyj)6;xa#j5l9E+g}O$;lM~x+Ugd6SIq6YvgVe z^~nrW%i6}6hX&DLC)TPG+DGI=cpt1km0zPjf^4r`DwxaB)WwFcSNQAaiU|rP+DSFX>nij=D!`DgjBSABt(lO`k_> z%n!UaHhEm=EWl#L<{(&DY{B|I`0?UO3j>K%uqUx2890nEnIxpUl*m1VS-kTi?~rf4 zH&7Bg#SPa694rxmZqD>~Co;CWs}es$v{bBV69Dz#czy#Ko|Xc+$#Q^oR2zk_$QgTy zh7SgJ^7Q5j;-9FAF&X&F_k)6^w&+ZHz3sgz*dQtXKv(G0~Cb??j zP_2XD7R*Kd7!03_bVioak{TbZpib3hg%DF?*l_RVSOs7mYA5j^pg7aJX61LtLgw|dC`>IuO(xg5 zcc=5fF6F$&Q@JyJD;x80`TcMWfdkEZ&Wa?A&ZpoxDv^K1?vqsUvhP8x!bf3uAHd)F zM{S%vUrOodP$M-jz1|}kcMpr{kyHaaEE^tn&-BtpcQ?S;=-~MC=t+bZC z_>{EpNn8l8;|E^i*#VJl*!Sl>BIrjU5?gRhr$bdc72Hm{2K#bkzC7P)37|}e$|%y} zXm7)Qw5EyC?9uyTU8%lwYP#M(TNE6AbKONITT2k zT$u>_Bu81sge>;T_DidIEmXMn#r~%YdYnaG4f6TF!rP(k$1j;i#2SqBpu!!(WWr(T zIyS~S z=_qqrEoGTZ3TA(p<0){A%4|*K>#Rc==od%wUuJU!0RzcXcaJr^y{boH&lpW~kMlgT zjR9T1su|Q+MP^u8i!kW#gcJ$orSulJ0!F|SH^lZz-pTlYSP!ZW%&cV@F;~_0F4dGb zOj*4gLRWl#Pq7s+5BHmoPaI6qyQ2)c-T{+ z#T3(zskIEG^7W-l<%U=B!qn|yiyrvZhOfw-d@ zzv6#*q;+2mu5n)e%(c+-zrnhQ{|!bRELW()-Srw<3gt2L6GtKPhCuiF_jUNVT6t<* z@BU6sZy{0(Tvtn=!GUQzS3jUj3Z7Z(tPIoy*P)W3qBTvfd;Gh*Krb3H4MR;S0DN&Z#EkdAk#+UIkM4G~u2W*1k?}6DqcD|xQg{c?GF#rsutnYlBz<4rjixK|_8iTMJ3FQ- z@`fpy|L_a^kG5fRHxo(j0%0P)JVCuXf1_64^3h6n0l`zJZyOqScrMT_S4>o$m9~eq z%Dr9g?n>}`>G(b-xCcTQy3eCpXc1S(a!) z5YamcqL*k9<=Ok3-+%DDn3;2CzBAXH`Ciw&_(bVwsnAkgrvd=bs;MgK5=X*+4N6Yz zb!VI?hy%n!S4AF_4zR2NaLq$a@sYld#a0$YwU^4%?n@}t`cV;5kudZIl^*Pw?;u*8 z4Pnc<5)b5I@+wj}_L|mEt{k515LL!k$hAj0j5@s31y^A5uCGaQ-2!iUEU&E0VeJO{ z-%8sJ%sJu@UvA)e{g3)D`}^OS4{-3L65epRyjo60AlM)bZpSTu4+Tp?91y;~P zZp#m$Abk2TPq71b#e^Iw?*rQh=MQ}-g3DeRYY-qp8*9gH(jb7g--LuN*jT%jeh#wW zXgLOV1O0xdFL&txnzSkf@&$Kdlm8rTf{ED~S(9Nsh2yvc&x38Fx2}V9!L$A6^lGPXI9twO z(rtmb3s;HF{yIYng3HQ<1n2pr`uN%QAolY>fWH^mwB4RZt)&_^u3#nRX{CQ}jY4#S zw&~*!UeV58gyhqY**Ua4kOJ$2=N_D_6*<$ZbjPp$j{a|Q;9Of(%5?Z2anHYKT%gJD z_(rAJ{2UALTD@q)#m)|MJ&P^t8w>FF03#XxHs@Aqe_hx1^Khki)|w8DGF-Lkg8e*# zvh&APyj3P!V^JHOBAg4L2llRF-I43u&xW;kPO9<~qAxy}^tOUecu{J?0VS^#6JPiH zKK0Y29D2d@+Yk!5kRf;x%RPJVo7SIHvhv<|HP=5Op#ymY_-nM>@G4ghNe!%MNJITJ zr2v;&qeg&OCK{@*{iO+a;VIBhQk-4o89RK=Ky*V9%3B4srB9R1huJcusoam@B>Jiv zLi=@2aoF@;Q+-8#on7tXsDvuf)9qoOPRkQ-Ra->0`-gt<=0?)&)9ZxED<2S<=oi1F zKR;NoOPS&EnA&gTgYU9hHgoOSsKxP*oF$TfkL*S~@5?a85gpH5c5B(~?ApVVEsA^* zAh;~(>kv~Uq}}ZKx{lfhCYMtI+(o@xMwROTL}&o+^C5rZn#(CG&c&$y>!idgxYJ5j z%DeVpIb(KwsfH7e&9Aka{6w04R^4heJliMHRMv@5lM49X>}Ivcn$ls^`5-dP9JUuK z^V*DUO$ty^iirO1vD%X@aY|f$zQqu#y?0M#8zcTz8uV(3iC@Z^)_(D*@lMI_i<{|o zO2>kvjP+>^znTh3_O?A;O>^p5mwMP`K|x5WxggPshUC4jupXB>sD-twQ01NkF0j+6 zJGv|(m^8b;^7im&l{b(1Go+7WUH@H=3LPImk9o`hiB)wQ z+EJBiGrBa!-L(Joqto!eq(H-`bMYk`5UdJ2fq{~aU3Ug?6p5@WrCqnM{x{|>W1Tv^y>kTdG!h2l9HDIcxPtu)(4YPd1LPvez-N zx|sTSiYPzq>>0bqX%+F)CMlSdaHm{HhHJ{yX+Juemf7Z^bTFvvHENe)2V>i|?ULHjG8!6BJ-~Ja+M3TmEZ<+qszr{Z;K(vK zzEa0*;!%sgY&LVtmgvBA0DNm}J_ezWGs`YiGf81_F`(<+G4ofN#D+I=tuR~VDi4JNhuSnYHc(*^H%qXd!JI2c6 zt!bX@0Xno-v$*gwEhjBF!30lwOxEZU?+O!^WuK~9q-x$+A4^pHo>y;t6tMS_OM|TP zbd;@kX00o5o_npZOR5UB4I(qVMVhn!*1^_QM{o^E)-N8vPr*i*-Q+P1+6Hpc3hYt? zhi6TvRVVo6nN}kjuF%Pwyp%lG`P^^ael)*?zGyu$zF^HUuvL2i39c{;h*N5At~VZ% z6<>Oj7oH!dyV$QcBT(}B@1U66Bw3~)?UWFUKeu)XDKNj^QkBs%+=q5yy7ayAHbEF} zvLF{UuiSOq8p?5r;J~IEpU^311ojt*&!M!b-x`MTTzJc$ZJ3SU9SMK!8+^B+6m)G+ zA;e%I4g@pHhhD8eRG-XzTn5R-yCZs~5|wFgMEIgK`2`XgzG~(6w9nbI1+cxe23 zdKd(kQEON`E}>+2*d4BX;d>67WbbaYA779yh^vdpI~v!$>soY=9Q@ii!&yk>sTHxN zhdCvnA{$^@s@TK>*#Zg~CcqSc69Pkl^{ z&&o-U6~m$={XRirXu*kXv8{xqp?%c-V!=%tqmDk=;@0=W-(|6++w6VWM#q;*Z==IF zS^2-xHt*J~77vaGi55XX+Ui3B-g2|-yF@MO=dzN;0ZMX;CT3o!XcSMVq~bOc?GEg> zanUJ>3+ykx0t)x;hCVoF4o!y%elYV3@(D0S*|$u*5eOHr5Ys%p-VML z?1S2RGxk3A(%16?&OIAEY6}qxq8o6JFARU;*}8bknn&#sz|!r&zds$t%S(Fcuhz=F z#>bnC*Qz9|mr2}MNX40+JnEFCkyaJs8&Vo?A|d2n{tZ)fZ%8eQ`v)O^;dLEN@)7O3 zw>r+FW2eh1R0!hVcCwPd_z0IEo zzNL-)02G!oi7N88)b)if3CJPao%q^vb+c9voM(EUCVJ^3$H&S+ajw zpfs}uv!2rE=|0!oz{zqqvsNS69~u4L-& zwrE~zY4eE&xzI;u#_Y7TLTGU3f(G-j*rABAlWm=Z{@pNIzn2GpfBoT6(IW@#0?$;( z-#DumTnlr#j9Iiu{>~-MBiPiutA#7117Q}u@uid-9aP01M^r-VuH8gVKH|}M0Kj6Z zNd9M+NV3tynE?(1tA8;ViLwnm2yPH`P?h*XJ$n;azN?6RsY<3=du_2kl-dSy^pyBd zM)47sC6njElTCHKX7V3Ri+5}v9?yYtFV0FJ$j; z6L}F|HJ4sI%?DrySyW2b{Lzr;9`naCh>`b#Ly}RF7EiOYR?>el187s&<=wbv5-u() zOGv4E_tcL$X{MGGD_Zn-faOR71I;_}4pw&979-`HWMlr24b7A;dELi*6hLS!6Ddxi z=4T!ok2ONf>5-6Wo^M~}-){hxZ1LlqiuoLBhe3)O)g>XaZ(%|-=-}xZu{V45Z*KrC zZCG6+w)6kJF5yQrrOyJhHd&eeW zF%UOUt8ZVv`HU;;*-vU?EB>hm#QoawVSF~Im(6m!;}b1i0ujsHma$wmV$o(D9wdMp z5-@2^*_7JU&E(RYDOPf~vVEk%Kb;!fKlZp-y$RE3#rKuZR%j}xaJ>9h#onh&QzLkH zWc#!Fz!hL0IOJjky^(&`w+N-lm4a`~4-y$uvK^D^67WU`2mra`xIpQYo=Xk!4vR?E z-C_lUcef;Hpl@@?x6@Zhzy|Y)s2T-U{CAoM48oBTKWT1Ftz9!?1}sNIWc1;_#eVEG zr@IM}T*JvL%1hB(j&{o{0C4YJRi?x!p9^5J#-itKdYX0(I1*1xg1U_CbURl8u<)21 zz)+$ME#w`CKFjm`l)0HP6ntJ+k$BUh{g`E+1q7eci&>)fNS^x&Mml2~SkONb$t^7; z&)|dn?BdNF1;PrfQ>`sIGL`<>IcGm#4?w_Nac+?unq&Z*Vf_~ot9T*Axc!?r+!%Vbgy84(cS)cnebn~5X zTslI8cTVB0%yz(nbth&n2s+FHK$wfB(hN{V0|0-7e zHW-m-pw8)7>;SE-PSZ<8qLan_$blpQ8i&-#EaSKPF-;@>yIX8Qtm_9;fa%h~kJaWi ze(S8}c&z85eBpa1_aRA{Ln^R2fwqOwB-}cB zalKmtTqS2}WBldJ=02+;A(XLnJ5-Zj`5(Rb?=4Ar4{)QvFB=9>%H=)=>~$O6l4@&a{CzId0+87r?%FWdhB)2%C(62HY<@y`dHQWaoCyU^no83l@ug_S8$uvcI zOKeCjybQs7>wJvwzGh2N9;UuFAXF*=@{xp2{^S!~7Hs+DDm=@&xT=%~=L!4vDl7k> z;!dE={5ZGQGvxRU5b1asm%_|%RvT8cVu3Q}w~to;gUYA5#cZ0lS#Y3Npydi~SAE%g z%84D&+Fe|x+gl|Av=3xR9C38aWZ~AXg74;poai;&xEy2+VuR#Lx0lXQ6QjFkGX}l_Wf*d%lSzO z=80jr`vVBzdpzQgxjM!AVyC6N-JQo9)&Bz@64&KT&a;C zOR@LI^s6O^`;&lLnU9nj@QXG@jHU3hGUm<~Lrv3ueq)#VJ803ukQ`0=KZ(b*b%_67 zbxUkM+D8TzD38;8TYuFJCDptTfW;uksR3Qm!Kr+45{6FYUmU|ERYl4ujS0JVrEU|a zNS)$rpLO7;UOZU%(spoLMGH-N8gOu`C%xSfdqa;wGgr8Hp*>Tf=geJ_wpxc6$Z|aP zr9V~01e!76<%htTC{|g)o+Kktc9yG*QYMMsfyxuMM`)9 zr)bZB=aES(-C0}Ff##ICdTyvGJ}Yq#Hv^O3O=V(UfJMAxN%mO`^1NQp+quNH#>^#4 zvRrYIug}=lQI7(6@5*eVpggW59dM@EIO(_1m;$LqJ!rX-4OG4k6)AbUy@S(X9r(QG zY>$vjTZMm#SzO2oo1WS@rLf2P4yO8$IRu7@*`yQ`z-->|3JFcq@!bG@mJp*RNr%xWZ3ijm~Hw)UVD9Vh8bjn< rLla^5rM-xx@*|(?PRalGGV`QCrQ+Mkn%nI}77Nsrv=mF_EkphfHQ!Zx diff --git a/src/LogExpert/Resources/PNG/48/bookmark_bubbles.png b/src/LogExpert/Resources/PNG/48/bookmark_bubbles.png deleted file mode 100644 index fbe5335adbc451126bc20fd3547c1b5efaa950c0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2595 zcmb_eYgkNc8-CYnr5UNF1F4khv_)qrom-7g(`h=0#LjG?gHB4+B&|WFospW*AS0O$ z(!n93lp%#}c4ZnN>7c?Cg_>-$ckI=#@7KP*>pT2d>%HFhe(w8up8HzYdfs1y0=<0L%b=Vu5+0L0OD(^hx_{U$dBhXS5-u5Jp3^d z-ew<=8g*+MdtLDA9L0d$7uP)X&=1b#YlJ9k^55P+R*+k;nlhTKpQ2q@Q4;D!@T3;K zIDNrqf0wZN<;|qo4^r2OtO4nrsVURj8OjsiYNfBb8t*1`F^Y3F5ifuGfo=jbo`PG<>VM+A+W{Gu5@ibw`^b2W-PIdEnQ%l>hiW_fKFtE_P zt3}=!xkVApbqr}KLn?5wFT*}sUj-UCu_q#sB+Nnm;Cia##j$?f9%sa7u>WJRI+Cj2 z%|T@xvljWJIb5>7x7kJ&&Oi%MPB>9DXDk#ZIGv2Bp3}VidO4y_UXQK`uXWV zn%>KXM=mVK4=L2G_IhG@1;;pc4g4QtqlJN&BRV~?bI2`-EkCONy5GE~()FEI z6xYewslHA6lRcyMC6|Un$v@zg1V( zJa!*|$DDbRjjZ0uC{0X95ObHcC$;fT{Fmfbg=5x2Wm;E>OZnKA0}4a?FkPg^4Qi41 zp_TuL2$9{Do*d11&7|Jsv0RYU7R3mzCc@IlfE{J1R(z%;vBFNTg=hp<|fZ3mVG<$<&Z=}u|=O|n9AFmbdFtS(n28KclWIiV`e?I4RMJR+YBft8m z`?2=861iE8ZntQ@3blCqY^8B7Nd`OIH*3&UYPh7XkQzP%(J10S0o=>jC~SVW>b8=c6BDiO3^B+giFP-Mzv9ed5ur8RK}X zkN3+FV2;<)U3VdEu5qKe=*Ex+Vx?AY*?nI?qC>8F$$8pNV`ek*6fn{y%x0;$`*=_yc3VZuM_4ZS@4Wb*$X3RdnLZ3(k&NqLSj{8E7d4ng zPen9QoDC$Ll0&Qa6(Fv~4UX@&+Y*wS`I}ReANSu=OQ(pwIaD6C5S-*pK5-zYDg=;Q zOw-rAJ6tI5vok5aPw#C>;q5jfE5q1w{zr$0M^_0pad<@y(VfFwrx>~IXsU(s^+G+|m z9dsi9?Ze|4=PdF7%dS29*7JMe(aFe7--zepUtbLy5Uy+yIdSq+oE9r89YbYR(~eX( z#`2mZ=#;OoN^y+g{t9&fL|pzaqZ` z-3s&F5;I%BCA20iH2HpWl>1eM*@`@x8?nnfZ?IRtn+5jyH0c{M^4#R~LVx&`sz50z z=;wFcQIkIiVk6K_gPPT=JVD-|i`0xu5R>tf+Pz-nCZLfWeJOhQ{aXCs*xo?$xDxt# zACF;|%a9BDOT5z>ewqmK?uL)QH0i^U(4uyt$8E^u` zOL2r1;KEGHn&*V4!#}^qi~B>YPTx2mk`T5|@Fy;Nnd-u13<3=|+b~_I9?x8FAw@o< z$?<1L8%!#B)kZ_R<<@5;A3TCRR{~VRdOu93v`?&hO94VYl|IsbriNm1q25D!`0PDo zuxq^^fT{y@nVBRMsN~fIo8zdHLOY&b{Z{T+eXM1(x7PC=}vs zV0#I81<(fVRU9q@AGtQMV>mQ`uPeZ|_>dTpIFX_=&KtNRo5kW};z*Sg(d~A*p`1S` zB^u!;OEUZ>ra4{ue(We_J|}a|%oUHRv^3hlg2nKKu@P`F;O$M*OK zV2>#_P!h4H_W;Jc%D6z@0bRd$uIFiWa&_j@715`5JRZl+&JK2WcacaWkW40#PN#8n zbc9SMgKRd-pObg;RxX!OtyXbza)Mf|hI+k@X0wU&^K-OXEwtNhbUGdMdOh^}eOz2z zU@#cq^70a+(Fj*pSMC)S$|3`c4E(Q*H(R-zH1Bqz@~p%Vt_TnFoHpg zqp>DY%U0A12g4krtm(kYeOFk|0W;!?bLi?rSDZ7~H?7&XF8%>4%A*7;AofOdi=Q)W zh#lN=CFs~sTnURE3A+-JT0i06)Y+K)1H3n!>9)bgO}Wh@@|3(F&&gx*fZQYEGf%|t zHF-lmkWVB-K9eMQOJx5gc}8xOy}i95Yrm5DMyFdg*fSLCypnl;fB%oqV82n7N=30x zDA5lN4(>c7l}ZiSqtp!cAtkWSxNEaL@zt---lo`(T+YtU)Qn%(MHgQ^o_$fV*LgyG z^?3GF#UAMi@zvwmixvB;C&X8e=iA50x8(dT#8;1J|95kz=S#Q6SC8l0LGdl%3GvnA t`Q}i3M|eVf_4w1%Q^hxkC&X8eZ!{W1zIT)t#CI0|jkQhQZ+}~7egff)T>1b2 diff --git a/src/LogExpert/Resources/logexpert.ico b/src/LogExpert/logexpert.ico similarity index 100% rename from src/LogExpert/Resources/logexpert.ico rename to src/LogExpert/logexpert.ico diff --git a/src/Logexpert.Resources/Logexpert.Resources.csproj b/src/Logexpert.Resources/Logexpert.Resources.csproj index c4a1ac1d..7474599d 100644 --- a/src/Logexpert.Resources/Logexpert.Resources.csproj +++ b/src/Logexpert.Resources/Logexpert.Resources.csproj @@ -12,4 +12,24 @@ + + + + + + + + True + True + Resources.resx + + + + + + PublicResXFileCodeGenerator + Resources.Designer.cs + + + diff --git a/src/LogExpert/Properties/Resources.Designer.cs b/src/Logexpert.Resources/Resources.Designer.cs similarity index 69% rename from src/LogExpert/Properties/Resources.Designer.cs rename to src/Logexpert.Resources/Resources.Designer.cs index b81d26da..81aaf6ae 100644 --- a/src/LogExpert/Properties/Resources.Designer.cs +++ b/src/Logexpert.Resources/Resources.Designer.cs @@ -1,413 +1,343 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace LogExpert.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LogExpert.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Add { - get { - object obj = ResourceManager.GetObject("Add", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Arrow_menu_close { - get { - object obj = ResourceManager.GetObject("Arrow_menu_close", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Arrow_menu_open { - get { - object obj = ResourceManager.GetObject("Arrow_menu_open", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArrowDown { - get { - object obj = ResourceManager.GetObject("ArrowDown", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArrowLeft { - get { - object obj = ResourceManager.GetObject("ArrowLeft", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArrowRight { - get { - object obj = ResourceManager.GetObject("ArrowRight", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArrowUp { - get { - object obj = ResourceManager.GetObject("ArrowUp", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Bookmark_add { - get { - object obj = ResourceManager.GetObject("Bookmark_add", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Bookmark_added { - get { - object obj = ResourceManager.GetObject("Bookmark_added", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap bookmark_bubbles { - get { - object obj = ResourceManager.GetObject("bookmark_bubbles", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Bookmark_manager { - get { - object obj = ResourceManager.GetObject("Bookmark_manager", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Bookmark_remove { - get { - object obj = ResourceManager.GetObject("Bookmark_remove", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Bookmarks { - get { - object obj = ResourceManager.GetObject("Bookmarks", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Check_circle { - get { - object obj = ResourceManager.GetObject("Check_circle", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Close { - get { - object obj = ResourceManager.GetObject("Close", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Deceased { - get { - object obj = ResourceManager.GetObject("Deceased", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Delete { - get { - object obj = ResourceManager.GetObject("Delete", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Exit { - get { - object obj = ResourceManager.GetObject("Exit", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Favorite { - get { - object obj = ResourceManager.GetObject("Favorite", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap File_open { - get { - object obj = ResourceManager.GetObject("File_open", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Filter { - get { - object obj = ResourceManager.GetObject("Filter", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Folder_open { - get { - object obj = ResourceManager.GetObject("Folder_open", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). - /// - internal static System.Drawing.Icon Icon1 { - get { - object obj = ResourceManager.GetObject("Icon1", resourceCulture); - return ((System.Drawing.Icon)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). - /// - internal static System.Drawing.Icon Icon2 { - get { - object obj = ResourceManager.GetObject("Icon2", resourceCulture); - return ((System.Drawing.Icon)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Log_Icon { - get { - object obj = ResourceManager.GetObject("Log_Icon", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Log_Icon_small { - get { - object obj = ResourceManager.GetObject("Log_Icon_small", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap LogExpert { - get { - object obj = ResourceManager.GetObject("LogExpert", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap LogExpert_Icon { - get { - object obj = ResourceManager.GetObject("LogExpert_Icon", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap LogExpert_Logo { - get { - object obj = ResourceManager.GetObject("LogExpert-Logo", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap LogLover { - get { - object obj = ResourceManager.GetObject("LogLover", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Pro_Filter { - get { - object obj = ResourceManager.GetObject("Pro_Filter", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Restart_alt { - get { - object obj = ResourceManager.GetObject("Restart_alt", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Search { - get { - object obj = ResourceManager.GetObject("Search", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Settings { - get { - object obj = ResourceManager.GetObject("Settings", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Star { - get { - object obj = ResourceManager.GetObject("Star", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LogExpert.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LogExpert.Resources.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Add { + get { + object obj = ResourceManager.GetObject("Add", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Arrow_menu_close { + get { + object obj = ResourceManager.GetObject("Arrow_menu_close", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Arrow_menu_open { + get { + object obj = ResourceManager.GetObject("Arrow_menu_open", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap ArrowDown { + get { + object obj = ResourceManager.GetObject("ArrowDown", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap ArrowLeft { + get { + object obj = ResourceManager.GetObject("ArrowLeft", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap ArrowRight { + get { + object obj = ResourceManager.GetObject("ArrowRight", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap ArrowUp { + get { + object obj = ResourceManager.GetObject("ArrowUp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Bookmark_add { + get { + object obj = ResourceManager.GetObject("Bookmark_add", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Bookmark_added { + get { + object obj = ResourceManager.GetObject("Bookmark_added", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap bookmark_bubbles { + get { + object obj = ResourceManager.GetObject("bookmark_bubbles", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Bookmark_manager { + get { + object obj = ResourceManager.GetObject("Bookmark_manager", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Bookmark_remove { + get { + object obj = ResourceManager.GetObject("Bookmark_remove", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Bookmarks { + get { + object obj = ResourceManager.GetObject("Bookmarks", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Check_circle { + get { + object obj = ResourceManager.GetObject("Check_circle", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Close { + get { + object obj = ResourceManager.GetObject("Close", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Deceased { + get { + object obj = ResourceManager.GetObject("Deceased", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Delete { + get { + object obj = ResourceManager.GetObject("Delete", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Exit { + get { + object obj = ResourceManager.GetObject("Exit", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Favorite { + get { + object obj = ResourceManager.GetObject("Favorite", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap File_open { + get { + object obj = ResourceManager.GetObject("File_open", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Filter { + get { + object obj = ResourceManager.GetObject("Filter", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Folder_open { + get { + object obj = ResourceManager.GetObject("Folder_open", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap LogLover { + get { + object obj = ResourceManager.GetObject("LogLover", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Pro_Filter { + get { + object obj = ResourceManager.GetObject("Pro_Filter", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Restart_alt { + get { + object obj = ResourceManager.GetObject("Restart_alt", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Search { + get { + object obj = ResourceManager.GetObject("Search", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Settings { + get { + object obj = ResourceManager.GetObject("Settings", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Star { + get { + object obj = ResourceManager.GetObject("Star", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/src/LogExpert/Properties/Resources.resx b/src/Logexpert.Resources/Resources.resx similarity index 58% rename from src/LogExpert/Properties/Resources.resx rename to src/Logexpert.Resources/Resources.resx index 2085cd03..e9b5affe 100644 --- a/src/LogExpert/Properties/Resources.resx +++ b/src/Logexpert.Resources/Resources.resx @@ -1,252 +1,211 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - ..\Resources\LogExpert-Logo.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\Pro_Filter.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\LogExpert.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\LogLover.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\Icon1.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\Icon2.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\LogExpert-Icon.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\Log_Icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\Log_Icon_small.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\PNG\48\bookmark_bubbles.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Bookmark_Bubbles - - - ..\Resources\PNG\48\Add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Add - - - ..\Resources\PNG\48\ArrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ArrowDown - - - ..\Resources\PNG\48\ArrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ArrowLeft - - - ..\Resources\PNG\48\ArrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ArrowRight - - - ..\Resources\PNG\48\ArrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ArrowUp - - - ..\Resources\PNG\48\Bookmark_add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Bookmark_add - - - ..\Resources\PNG\48\Bookmark_added.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Bookmark_added - - - ..\Resources\PNG\48\Bookmark_manager.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Bookmark_manager - - - ..\Resources\PNG\48\Bookmark_remove.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Bookmark_remove - - - ..\Resources\PNG\48\Bookmarks.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Bookmarks - - - ..\Resources\PNG\48\Delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Delete - - - ..\Resources\PNG\48\Exit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Exit - - - ..\Resources\PNG\48\Favorite.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Favorite - - - ..\Resources\PNG\48\File_open.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - File_open - - - ..\Resources\PNG\48\Filter.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Filter - - - ..\Resources\PNG\48\Folder_open.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Folder_open - - - ..\Resources\PNG\48\Restart_alt.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Restart_alt - - - ..\Resources\PNG\48\Search.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Search - - - ..\Resources\PNG\48\Settings.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Settings - - - ..\Resources\PNG\48\Star.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Star - - - ..\Resources\PNG\48\Arrow_menu_close.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Arrow_menu_close - - - ..\Resources\PNG\48\Arrow_menu_open.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Arrow_menu_open - - - ..\Resources\PNG\48\Close.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Close - - - ..\Resources\PNG\48\Deceased.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Deceased - - - ..\Resources\PNG\48\Check_circle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Check_circle - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + images\png\48\Add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + Add + + + images\png\48\ArrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ArrowDown + + + images\png\48\ArrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\ArrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\ArrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\Arrow_menu_close.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + Arrow_menu_close + + + images\png\48\Arrow_menu_open.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + Arrow_menu_open + + + images\png\48\Bookmarks.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\Bookmark_add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\Bookmark_added.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\bookmark_bubbles.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\Bookmark_manager.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\Bookmark_remove.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\Check_circle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\Close.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\Deceased.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\Delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\Exit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\Favorite.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\File_open.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\Filter.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\Folder_open.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\gif\LogLover.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + Logexpert Logo + + + images\bmp\Pro_Filter.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\Restart_alt.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\Search.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + images\png\48\Settings.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + Settings Logo + + + images\png\48\Star.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/src/Logexpert.Resources/images/bmp/AdvancedIcon.bmp b/src/Logexpert.Resources/images/bmp/AdvancedIcon.bmp deleted file mode 100644 index efe1532017ae038bbab942b16401e5e700cc5d11..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1198 zcmZwFJ#O4U42EGE2n=@tasrk{+~5c#ghFF>+rr5}LMSw5 zw=|s$B!og^cDs3r6i5h##%w8+lYxX#Xv~&LI~hm_g~nVZq;WEk5DJa4X8vuCKtd>- zZML-B$v{FVG-k^#oD3v{LSwch)5$v+p?jsH3N+Su{R=Z@q5@1C#t=N;!yoBak;2&f + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + tableLayoutPanel = new TableLayoutPanel(); + logoPictureBox = new PictureBox(); + labelProductName = new Label(); + labelVersion = new Label(); + labelCopyright = new Label(); + textBoxDescription = new TextBox(); + linkLabelURL = new LinkLabel(); + panel1 = new Panel(); + okButton = new Button(); + tableLayoutPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)logoPictureBox).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // tableLayoutPanel + // + tableLayoutPanel.ColumnCount = 2; + tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 34.25484F)); + tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 65.74516F)); + tableLayoutPanel.Controls.Add(logoPictureBox, 0, 0); + tableLayoutPanel.Controls.Add(labelProductName, 1, 0); + tableLayoutPanel.Controls.Add(labelVersion, 1, 1); + tableLayoutPanel.Controls.Add(labelCopyright, 1, 2); + tableLayoutPanel.Controls.Add(textBoxDescription, 1, 4); + tableLayoutPanel.Controls.Add(linkLabelURL, 1, 3); + tableLayoutPanel.Controls.Add(panel1, 1, 5); + tableLayoutPanel.Dock = DockStyle.Fill; + tableLayoutPanel.Location = new Point(14, 14); + tableLayoutPanel.Margin = new Padding(4, 5, 4, 5); + tableLayoutPanel.Name = "tableLayoutPanel"; + tableLayoutPanel.RowCount = 6; + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 9.912043F)); + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 9.912043F)); + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 9.47226F)); + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 11.84032F)); + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 46.68471F)); + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 12.17862F)); + tableLayoutPanel.Size = new Size(914, 649); + tableLayoutPanel.TabIndex = 0; + // + // logoPictureBox + // + logoPictureBox.Dock = DockStyle.Fill; + logoPictureBox.Location = new Point(4, 5); + logoPictureBox.Margin = new Padding(4, 5, 4, 5); + logoPictureBox.Name = "logoPictureBox"; + tableLayoutPanel.SetRowSpan(logoPictureBox, 6); + logoPictureBox.Size = new Size(305, 639); + logoPictureBox.SizeMode = PictureBoxSizeMode.CenterImage; + logoPictureBox.TabIndex = 12; + logoPictureBox.TabStop = false; + // + // labelProductName + // + labelProductName.Dock = DockStyle.Fill; + labelProductName.Font = new Font("Microsoft Sans Serif", 10F, FontStyle.Bold, GraphicsUnit.Point, 0); + labelProductName.Location = new Point(322, 0); + labelProductName.Margin = new Padding(9, 0, 4, 0); + labelProductName.MaximumSize = new Size(0, 26); + labelProductName.Name = "labelProductName"; + labelProductName.Size = new Size(588, 26); + labelProductName.TabIndex = 19; + labelProductName.Text = "Product Name"; + labelProductName.TextAlign = ContentAlignment.MiddleLeft; + // + // labelVersion + // + labelVersion.Dock = DockStyle.Fill; + labelVersion.Location = new Point(322, 64); + labelVersion.Margin = new Padding(9, 0, 4, 0); + labelVersion.MaximumSize = new Size(0, 26); + labelVersion.Name = "labelVersion"; + labelVersion.Size = new Size(588, 26); + labelVersion.TabIndex = 0; + labelVersion.Text = "Version"; + labelVersion.TextAlign = ContentAlignment.MiddleLeft; + // + // labelCopyright + // + labelCopyright.Dock = DockStyle.Fill; + labelCopyright.Location = new Point(322, 128); + labelCopyright.Margin = new Padding(9, 0, 4, 0); + labelCopyright.Name = "labelCopyright"; + labelCopyright.Size = new Size(588, 61); + labelCopyright.TabIndex = 21; + labelCopyright.Text = "Copyright"; + labelCopyright.TextAlign = ContentAlignment.MiddleLeft; + // + // textBoxDescription + // + textBoxDescription.Dock = DockStyle.Fill; + textBoxDescription.Location = new Point(322, 270); + textBoxDescription.Margin = new Padding(9, 5, 4, 5); + textBoxDescription.Multiline = true; + textBoxDescription.Name = "textBoxDescription"; + textBoxDescription.ReadOnly = true; + textBoxDescription.ScrollBars = ScrollBars.Both; + textBoxDescription.Size = new Size(588, 292); + textBoxDescription.TabIndex = 23; + textBoxDescription.TabStop = false; + textBoxDescription.Text = "Description"; + // + // linkLabelURL + // + linkLabelURL.AutoSize = true; + linkLabelURL.Dock = DockStyle.Fill; + linkLabelURL.Location = new Point(317, 189); + linkLabelURL.Margin = new Padding(4, 0, 4, 0); + linkLabelURL.Name = "linkLabelURL"; + linkLabelURL.Size = new Size(593, 76); + linkLabelURL.TabIndex = 25; + linkLabelURL.TabStop = true; + linkLabelURL.Text = "https://github.com/LogExperts/LogExpert"; + linkLabelURL.TextAlign = ContentAlignment.MiddleLeft; + linkLabelURL.LinkClicked += OnLinkLabelURLClicked; + // + // panel1 + // + panel1.Controls.Add(okButton); + panel1.Dock = DockStyle.Fill; + panel1.Location = new Point(317, 572); + panel1.Margin = new Padding(4, 5, 4, 5); + panel1.Name = "panel1"; + panel1.Size = new Size(593, 72); + panel1.TabIndex = 26; + // + // okButton + // + okButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + okButton.DialogResult = DialogResult.OK; + okButton.Location = new Point(475, 32); + okButton.Margin = new Padding(4, 5, 4, 5); + okButton.Name = "okButton"; + okButton.Size = new Size(114, 35); + okButton.TabIndex = 0; + okButton.Text = "&OK"; + okButton.UseVisualStyleBackColor = true; + // + // AboutBox + // + ClientSize = new Size(942, 677); + Controls.Add(tableLayoutPanel); + FormBorderStyle = FormBorderStyle.FixedDialog; + Margin = new Padding(4, 5, 4, 5); + MaximizeBox = false; + MinimizeBox = false; + Name = "AboutBox"; + Padding = new Padding(14); + ShowIcon = false; + ShowInTaskbar = false; + StartPosition = FormStartPosition.CenterParent; + Text = "AboutBox"; + tableLayoutPanel.ResumeLayout(false); + tableLayoutPanel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)logoPictureBox).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; + private System.Windows.Forms.PictureBox logoPictureBox; + private System.Windows.Forms.Label labelProductName; + private System.Windows.Forms.Label labelVersion; + private System.Windows.Forms.Label labelCopyright; + private System.Windows.Forms.TextBox textBoxDescription; + private System.Windows.Forms.LinkLabel linkLabelURL; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Button okButton; + } +} diff --git a/src/Logexpert.UI/Dialogs/AboutBox.cs b/src/Logexpert.UI/Dialogs/AboutBox.cs new file mode 100644 index 00000000..24784236 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/AboutBox.cs @@ -0,0 +1,140 @@ +using System.Diagnostics; +using System.Reflection; +using System.Runtime.Versioning; + +namespace LogExpert.Dialogs +{ + [SupportedOSPlatform("windows6.1")] + public partial class AboutBox : Form + { + #region Fields + + private readonly Assembly _assembly; + + #endregion + + #region cTor + + public AboutBox() + { + if (DesignMode) + { + return; + } + + InitializeComponent(); + + LoadResources(); + + _assembly = Assembly.GetExecutingAssembly(); + + Text = $@"About {AssemblyTitle}"; + labelProductName.Text = AssemblyProduct; + labelVersion.Text = AssemblyVersion; + labelCopyright.Text = AssemblyCopyright; + //this.labelCompanyName.Text = AssemblyCompany; + textBoxDescription.Text = AssemblyDescription + + "\r\n\r\nCredits:\r\n\r\n" + + "LogExpert uses modules from:\r\n" + + "https://github.com/dockpanelsuite/dockpanelsuite\r\n"; + string link = "https://github.com/LogExperts/LogExpert"; + linkLabelURL.Links.Add(new LinkLabel.Link(0, link.Length, link)); + } + + private void LoadResources() + { + logoPictureBox.Image = Resources.Resources.LogLover; + } + + #endregion + + #region Properties + + public string AssemblyTitle + { + get + { + object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); + if (attributes.Length > 0) + { + AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; + if (titleAttribute.Title != string.Empty) + { + return titleAttribute.Title; + } + } + return Path.GetFileNameWithoutExtension(_assembly.Location); + } + } + + public string AssemblyVersion + { + get + { + AssemblyName assembly = _assembly.GetName(); + string version = $"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}.{assembly.Version.Revision}"; + if (assembly.Version.Revision >= 9000) + { + version += " Testrelease"; + } + + return version; + } + } + + public string AssemblyDescription + { + get + { + object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); + if (attributes.Length == 0) + { + return string.Empty; + } + return ((AssemblyDescriptionAttribute)attributes[0]).Description; + } + } + + public string AssemblyProduct + { + get + { + object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false); + if (attributes.Length == 0) + { + return string.Empty; + } + return ((AssemblyProductAttribute)attributes[0]).Product; + } + } + + public string AssemblyCopyright + { + get + { + object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + if (attributes.Length == 0) + { + return string.Empty; + } + return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + } + } + + #endregion + + #region Events handler + + private void OnLinkLabelURLClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + string target = e.Link.LinkData as string; + Process.Start(new ProcessStartInfo + { + UseShellExecute = true, + FileName = target, + }); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/AboutBox.resx b/src/Logexpert.UI/Dialogs/AboutBox.resx new file mode 100644 index 00000000..8b2ff64a --- /dev/null +++ b/src/Logexpert.UI/Dialogs/AboutBox.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/Logexpert.UI/LogExpert.UI.csproj b/src/Logexpert.UI/LogExpert.UI.csproj new file mode 100644 index 00000000..1d96b7c7 --- /dev/null +++ b/src/Logexpert.UI/LogExpert.UI.csproj @@ -0,0 +1,29 @@ + + + + net8.0-windows + enable + true + enable + false + + + + + + + + + + + + + Form + + + + + + + + From 469bd0341f0008d8743a6cf1ddff08a596552441 Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Wed, 26 Mar 2025 16:32:22 +0100 Subject: [PATCH 006/142] delete old about box --- src/LogExpert/Dialogs/AboutBox.Designer.cs | 202 --------------------- src/LogExpert/Dialogs/AboutBox.cs | 128 ------------- src/LogExpert/Dialogs/AboutBox.resx | 120 ------------ 3 files changed, 450 deletions(-) delete mode 100644 src/LogExpert/Dialogs/AboutBox.Designer.cs delete mode 100644 src/LogExpert/Dialogs/AboutBox.cs delete mode 100644 src/LogExpert/Dialogs/AboutBox.resx diff --git a/src/LogExpert/Dialogs/AboutBox.Designer.cs b/src/LogExpert/Dialogs/AboutBox.Designer.cs deleted file mode 100644 index ca4959da..00000000 --- a/src/LogExpert/Dialogs/AboutBox.Designer.cs +++ /dev/null @@ -1,202 +0,0 @@ -//namespace LogExpert.Dialogs -//{ -// partial class AboutBox -// { -// /// -// /// Required designer variable. -// /// -// private System.ComponentModel.IContainer components = null; - -// /// -// /// Clean up any resources being used. -// /// -// protected override void Dispose(bool disposing) -// { -// if (disposing && (components != null)) -// { -// components.Dispose(); -// } -// base.Dispose(disposing); -// } - -// #region Windows Form Designer generated code - -// /// -// /// Required method for Designer support - do not modify -// /// the contents of this method with the code editor. -// /// -// private void InitializeComponent() -// { -// tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); -// logoPictureBox = new System.Windows.Forms.PictureBox(); -// labelProductName = new System.Windows.Forms.Label(); -// labelVersion = new System.Windows.Forms.Label(); -// labelCopyright = new System.Windows.Forms.Label(); -// textBoxDescription = new System.Windows.Forms.TextBox(); -// linkLabelURL = new System.Windows.Forms.LinkLabel(); -// panel1 = new System.Windows.Forms.Panel(); -// okButton = new System.Windows.Forms.Button(); -// tableLayoutPanel.SuspendLayout(); -// ((System.ComponentModel.ISupportInitialize)logoPictureBox).BeginInit(); -// panel1.SuspendLayout(); -// SuspendLayout(); -// // -// // tableLayoutPanel -// // -// tableLayoutPanel.ColumnCount = 2; -// tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 34.25484F)); -// tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 65.74516F)); -// tableLayoutPanel.Controls.Add(logoPictureBox, 0, 0); -// tableLayoutPanel.Controls.Add(labelProductName, 1, 0); -// tableLayoutPanel.Controls.Add(labelVersion, 1, 1); -// tableLayoutPanel.Controls.Add(labelCopyright, 1, 2); -// tableLayoutPanel.Controls.Add(textBoxDescription, 1, 4); -// tableLayoutPanel.Controls.Add(linkLabelURL, 1, 3); -// tableLayoutPanel.Controls.Add(panel1, 1, 5); -// tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; -// tableLayoutPanel.Location = new System.Drawing.Point(14, 14); -// tableLayoutPanel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); -// tableLayoutPanel.Name = "tableLayoutPanel"; -// tableLayoutPanel.RowCount = 6; -// tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.912043F)); -// tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.912043F)); -// tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.47226F)); -// tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.84032F)); -// tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 46.68471F)); -// tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.17862F)); -// tableLayoutPanel.Size = new System.Drawing.Size(914, 649); -// tableLayoutPanel.TabIndex = 0; -// // -// // logoPictureBox -// // -// logoPictureBox.Dock = System.Windows.Forms.DockStyle.Fill; -// logoPictureBox.Image = Properties.Resources.LogLover; -// logoPictureBox.Location = new System.Drawing.Point(4, 5); -// logoPictureBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); -// logoPictureBox.Name = "logoPictureBox"; -// tableLayoutPanel.SetRowSpan(logoPictureBox, 6); -// logoPictureBox.Size = new System.Drawing.Size(305, 639); -// logoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; -// logoPictureBox.TabIndex = 12; -// logoPictureBox.TabStop = false; -// // -// // labelProductName -// // -// labelProductName.Dock = System.Windows.Forms.DockStyle.Fill; -// labelProductName.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0); -// labelProductName.Location = new System.Drawing.Point(322, 0); -// labelProductName.Margin = new System.Windows.Forms.Padding(9, 0, 4, 0); -// labelProductName.MaximumSize = new System.Drawing.Size(0, 26); -// labelProductName.Name = "labelProductName"; -// labelProductName.Size = new System.Drawing.Size(588, 26); -// labelProductName.TabIndex = 19; -// labelProductName.Text = "Product Name"; -// labelProductName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; -// // -// // labelVersion -// // -// labelVersion.Dock = System.Windows.Forms.DockStyle.Fill; -// labelVersion.Location = new System.Drawing.Point(322, 64); -// labelVersion.Margin = new System.Windows.Forms.Padding(9, 0, 4, 0); -// labelVersion.MaximumSize = new System.Drawing.Size(0, 26); -// labelVersion.Name = "labelVersion"; -// labelVersion.Size = new System.Drawing.Size(588, 26); -// labelVersion.TabIndex = 0; -// labelVersion.Text = "Version"; -// labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; -// // -// // labelCopyright -// // -// labelCopyright.Dock = System.Windows.Forms.DockStyle.Fill; -// labelCopyright.Location = new System.Drawing.Point(322, 128); -// labelCopyright.Margin = new System.Windows.Forms.Padding(9, 0, 4, 0); -// labelCopyright.Name = "labelCopyright"; -// labelCopyright.Size = new System.Drawing.Size(588, 61); -// labelCopyright.TabIndex = 21; -// labelCopyright.Text = "Copyright"; -// labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; -// // -// // textBoxDescription -// // -// textBoxDescription.Dock = System.Windows.Forms.DockStyle.Fill; -// textBoxDescription.Location = new System.Drawing.Point(322, 270); -// textBoxDescription.Margin = new System.Windows.Forms.Padding(9, 5, 4, 5); -// textBoxDescription.Multiline = true; -// textBoxDescription.Name = "textBoxDescription"; -// textBoxDescription.ReadOnly = true; -// textBoxDescription.ScrollBars = System.Windows.Forms.ScrollBars.Both; -// textBoxDescription.Size = new System.Drawing.Size(588, 292); -// textBoxDescription.TabIndex = 23; -// textBoxDescription.TabStop = false; -// textBoxDescription.Text = "Description"; -// // -// // linkLabelURL -// // -// linkLabelURL.AutoSize = true; -// linkLabelURL.Dock = System.Windows.Forms.DockStyle.Fill; -// linkLabelURL.Location = new System.Drawing.Point(317, 189); -// linkLabelURL.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); -// linkLabelURL.Name = "linkLabelURL"; -// linkLabelURL.Size = new System.Drawing.Size(593, 76); -// linkLabelURL.TabIndex = 25; -// linkLabelURL.TabStop = true; -// linkLabelURL.Text = "https://github.com/LogExperts/LogExpert"; -// linkLabelURL.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; -// linkLabelURL.LinkClicked += OnLinkLabelURLClicked; -// // -// // panel1 -// // -// panel1.Controls.Add(okButton); -// panel1.Dock = System.Windows.Forms.DockStyle.Fill; -// panel1.Location = new System.Drawing.Point(317, 572); -// panel1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); -// panel1.Name = "panel1"; -// panel1.Size = new System.Drawing.Size(593, 72); -// panel1.TabIndex = 26; -// // -// // okButton -// // -// okButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; -// okButton.DialogResult = System.Windows.Forms.DialogResult.OK; -// okButton.Location = new System.Drawing.Point(475, 32); -// okButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); -// okButton.Name = "okButton"; -// okButton.Size = new System.Drawing.Size(114, 35); -// okButton.TabIndex = 0; -// okButton.Text = "&OK"; -// okButton.UseVisualStyleBackColor = true; -// // -// // AboutBox -// // -// ClientSize = new System.Drawing.Size(942, 677); -// Controls.Add(tableLayoutPanel); -// FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; -// Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); -// MaximizeBox = false; -// MinimizeBox = false; -// Name = "AboutBox"; -// Padding = new System.Windows.Forms.Padding(14); -// ShowIcon = false; -// ShowInTaskbar = false; -// StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; -// Text = "AboutBox"; -// tableLayoutPanel.ResumeLayout(false); -// tableLayoutPanel.PerformLayout(); -// ((System.ComponentModel.ISupportInitialize)logoPictureBox).EndInit(); -// panel1.ResumeLayout(false); -// ResumeLayout(false); -// } - -// #endregion - -// private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; -// private System.Windows.Forms.PictureBox logoPictureBox; -// private System.Windows.Forms.Label labelProductName; -// private System.Windows.Forms.Label labelVersion; -// private System.Windows.Forms.Label labelCopyright; -// private System.Windows.Forms.TextBox textBoxDescription; -// private System.Windows.Forms.LinkLabel linkLabelURL; -// private System.Windows.Forms.Panel panel1; -// private System.Windows.Forms.Button okButton; -// } -//} diff --git a/src/LogExpert/Dialogs/AboutBox.cs b/src/LogExpert/Dialogs/AboutBox.cs deleted file mode 100644 index 8b0d801b..00000000 --- a/src/LogExpert/Dialogs/AboutBox.cs +++ /dev/null @@ -1,128 +0,0 @@ -//using System.Diagnostics; -//using System.IO; -//using System.Reflection; -//using System.Windows.Forms; - -//namespace LogExpert.Dialogs -//{ -// internal partial class AboutBox : Form -// { -// #region Fields - -// private readonly Assembly _assembly; - -// #endregion - -// #region cTor - -// public AboutBox() -// { -// InitializeComponent(); - -// _assembly = Assembly.GetExecutingAssembly(); - -// Text = $@"About {AssemblyTitle}"; -// labelProductName.Text = AssemblyProduct; -// labelVersion.Text = AssemblyVersion; -// labelCopyright.Text = AssemblyCopyright; -// //this.labelCompanyName.Text = AssemblyCompany; -// textBoxDescription.Text = AssemblyDescription + -// "\r\n\r\nCredits:\r\n\r\n" + -// "LogExpert uses modules from:\r\n" + -// "https://github.com/dockpanelsuite/dockpanelsuite\r\n"; -// string link = "https://github.com/LogExperts/LogExpert"; -// linkLabelURL.Links.Add(new LinkLabel.Link(0, link.Length, link)); -// } - -// #endregion - -// #region Properties - -// public string AssemblyTitle -// { -// get -// { -// object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); -// if (attributes.Length > 0) -// { -// AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; -// if (titleAttribute.Title != string.Empty) -// { -// return titleAttribute.Title; -// } -// } -// return Path.GetFileNameWithoutExtension(_assembly.Location); -// } -// } - -// public string AssemblyVersion -// { -// get -// { -// AssemblyName assembly = _assembly.GetName(); -// string version = $"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}.{assembly.Version.Revision}"; -// if (assembly.Version.Revision >= 9000) -// { -// version += " Testrelease"; -// } - -// return version; -// } -// } - -// public string AssemblyDescription -// { -// get -// { -// object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); -// if (attributes.Length == 0) -// { -// return string.Empty; -// } -// return ((AssemblyDescriptionAttribute)attributes[0]).Description; -// } -// } - -// public string AssemblyProduct -// { -// get -// { -// object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false); -// if (attributes.Length == 0) -// { -// return string.Empty; -// } -// return ((AssemblyProductAttribute)attributes[0]).Product; -// } -// } - -// public string AssemblyCopyright -// { -// get -// { -// object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); -// if (attributes.Length == 0) -// { -// return string.Empty; -// } -// return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; -// } -// } - -// #endregion - -// #region Events handler - -// private void OnLinkLabelURLClicked(object sender, LinkLabelLinkClickedEventArgs e) -// { -// string target = e.Link.LinkData as string; -// Process.Start(new ProcessStartInfo -// { -// UseShellExecute = true, -// FileName = target, -// }); -// } - -// #endregion -// } -//} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/AboutBox.resx b/src/LogExpert/Dialogs/AboutBox.resx deleted file mode 100644 index 4f24d55c..00000000 --- a/src/LogExpert/Dialogs/AboutBox.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file From 6959b30cd19db17f4e37fc24e693cec200f9b0dd Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Wed, 26 Mar 2025 16:43:15 +0100 Subject: [PATCH 007/142] rename dialog moved to LogExpert.UI --- .../LogTabWindow/LogTabWindowEventHandlers.cs | 6 +- src/Logexpert.UI/Dialogs/AboutBox.cs | 7 +- .../Dialogs/TabRenameDialog.Designer.cs} | 202 +++++++-------- .../Dialogs/TabRenameDialog.cs} | 84 +++---- .../Dialogs/TabRenameDialog.resx} | 238 +++++++++--------- src/Logexpert.UI/LogExpert.UI.csproj | 3 + 6 files changed, 270 insertions(+), 270 deletions(-) rename src/{LogExpert/Dialogs/TabRenameDlg.Designer.cs => Logexpert.UI/Dialogs/TabRenameDialog.Designer.cs} (91%) rename src/{LogExpert/Dialogs/TabRenameDlg.cs => Logexpert.UI/Dialogs/TabRenameDialog.cs} (81%) rename src/{LogExpert/Dialogs/TabRenameDlg.resx => Logexpert.UI/Dialogs/TabRenameDialog.resx} (97%) diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs index a8cc552b..8debf55d 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs @@ -1004,8 +1004,10 @@ private void OnTabRenameToolStripMenuItemClick(object sender, EventArgs e) { if (CurrentLogWindow != null) { - TabRenameDlg dlg = new(); - dlg.TabName = CurrentLogWindow.Text; + TabRenameDialog dlg = new() + { + TabName = CurrentLogWindow.Text + }; if (DialogResult.OK == dlg.ShowDialog()) { CurrentLogWindow.Text = dlg.TabName; diff --git a/src/Logexpert.UI/Dialogs/AboutBox.cs b/src/Logexpert.UI/Dialogs/AboutBox.cs index 24784236..0bf70252 100644 --- a/src/Logexpert.UI/Dialogs/AboutBox.cs +++ b/src/Logexpert.UI/Dialogs/AboutBox.cs @@ -4,7 +4,7 @@ namespace LogExpert.Dialogs { - [SupportedOSPlatform("windows6.1")] + [SupportedOSPlatform("windows")] public partial class AboutBox : Form { #region Fields @@ -17,11 +17,6 @@ public partial class AboutBox : Form public AboutBox() { - if (DesignMode) - { - return; - } - InitializeComponent(); LoadResources(); diff --git a/src/LogExpert/Dialogs/TabRenameDlg.Designer.cs b/src/Logexpert.UI/Dialogs/TabRenameDialog.Designer.cs similarity index 91% rename from src/LogExpert/Dialogs/TabRenameDlg.Designer.cs rename to src/Logexpert.UI/Dialogs/TabRenameDialog.Designer.cs index 75fd448f..b6dc6df2 100644 --- a/src/LogExpert/Dialogs/TabRenameDlg.Designer.cs +++ b/src/Logexpert.UI/Dialogs/TabRenameDialog.Designer.cs @@ -1,102 +1,102 @@ -namespace LogExpert.Dialogs -{ - partial class TabRenameDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.textBoxTabName = new System.Windows.Forms.TextBox(); - this.labelName = new System.Windows.Forms.Label(); - this.buttonOk = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // textBoxTabName - // - this.textBoxTabName.Location = new System.Drawing.Point(12, 34); - this.textBoxTabName.Name = "textBoxTabName"; - this.textBoxTabName.Size = new System.Drawing.Size(193, 26); - this.textBoxTabName.TabIndex = 0; - // - // labelName - // - this.labelName.AutoSize = true; - this.labelName.Location = new System.Drawing.Point(13, 11); - this.labelName.Name = "labelName"; - this.labelName.Size = new System.Drawing.Size(55, 20); - this.labelName.TabIndex = 1; - this.labelName.Text = "Name:"; - // - // buttonOk - // - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(49, 73); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 23); - this.buttonOk.TabIndex = 2; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(130, 73); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 3; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // TabRenameDlg - // - this.AcceptButton = this.buttonOk; - this.ClientSize = new System.Drawing.Size(219, 108); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.labelName); - this.Controls.Add(this.textBoxTabName); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "TabRenameDlg"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Rename Tab"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnTabRenameDlgKeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TextBox textBoxTabName; - private System.Windows.Forms.Label labelName; - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.Button buttonCancel; - } +namespace LogExpert.Dialogs +{ + partial class TabRenameDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBoxTabName = new System.Windows.Forms.TextBox(); + this.labelName = new System.Windows.Forms.Label(); + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // textBoxTabName + // + this.textBoxTabName.Location = new System.Drawing.Point(12, 34); + this.textBoxTabName.Name = "textBoxTabName"; + this.textBoxTabName.Size = new System.Drawing.Size(193, 26); + this.textBoxTabName.TabIndex = 0; + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(13, 11); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(55, 20); + this.labelName.TabIndex = 1; + this.labelName.Text = "Name:"; + // + // buttonOk + // + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(49, 73); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 2; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(130, 73); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 3; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // TabRenameDlg + // + this.AcceptButton = this.buttonOk; + this.ClientSize = new System.Drawing.Size(219, 108); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.labelName); + this.Controls.Add(this.textBoxTabName); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "TabRenameDlg"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Rename Tab"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnTabRenameDlgKeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox textBoxTabName; + private System.Windows.Forms.Label labelName; + private System.Windows.Forms.Button buttonOk; + private System.Windows.Forms.Button buttonCancel; + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/TabRenameDlg.cs b/src/Logexpert.UI/Dialogs/TabRenameDialog.cs similarity index 81% rename from src/LogExpert/Dialogs/TabRenameDlg.cs rename to src/Logexpert.UI/Dialogs/TabRenameDialog.cs index 0896cf39..45be12eb 100644 --- a/src/LogExpert/Dialogs/TabRenameDlg.cs +++ b/src/Logexpert.UI/Dialogs/TabRenameDialog.cs @@ -1,43 +1,43 @@ -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public partial class TabRenameDlg : Form - { - #region cTor - - public TabRenameDlg() - { - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - } - - #endregion - - #region Properties - - public string TabName - { - get => textBoxTabName.Text; - set => textBoxTabName.Text = value; - } - - #endregion - - #region Events handler - - private void OnTabRenameDlgKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - Close(); - } - } - - #endregion - } +using System.Runtime.Versioning; + +namespace LogExpert.Dialogs +{ + [SupportedOSPlatform("windows")] + public partial class TabRenameDialog : Form + { + #region cTor + + public TabRenameDialog() + { + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + } + + #endregion + + #region Properties + + public string TabName + { + get => textBoxTabName.Text; + set => textBoxTabName.Text = value; + } + + #endregion + + #region Events handler + + private void OnTabRenameDlgKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/TabRenameDlg.resx b/src/Logexpert.UI/Dialogs/TabRenameDialog.resx similarity index 97% rename from src/LogExpert/Dialogs/TabRenameDlg.resx rename to src/Logexpert.UI/Dialogs/TabRenameDialog.resx index c7e0d4bd..d58980a3 100644 --- a/src/LogExpert/Dialogs/TabRenameDlg.resx +++ b/src/Logexpert.UI/Dialogs/TabRenameDialog.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Logexpert.UI/LogExpert.UI.csproj b/src/Logexpert.UI/LogExpert.UI.csproj index 1d96b7c7..8053fa7c 100644 --- a/src/Logexpert.UI/LogExpert.UI.csproj +++ b/src/Logexpert.UI/LogExpert.UI.csproj @@ -20,6 +20,9 @@ Form + + Form + From ff125e20461ebc9bfdd4c1279b05e0156329ea2f Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Wed, 26 Mar 2025 17:46:10 +0100 Subject: [PATCH 008/142] moved regexHelperDialog to LogExpert.UI --- src/LogExpert/Config/RegexHistory.cs | 7 +- src/LogExpert/Config/Settings.cs | 2 +- .../LogTabWindow/LogTabWindowEventHandlers.cs | 3 +- .../LogWindow/LogWindowEventHandlers.cs | 21 +- src/LogExpert/Dialogs/HighlightDialog.cs | 15 +- src/LogExpert/Dialogs/SearchDialog.cs | 22 +- src/LogExpert/Dialogs/ToolArgsDialog.cs | 12 +- src/Logexpert.UI/Dialogs/AboutBox.Designer.cs | 2 +- src/Logexpert.UI/Dialogs/AboutBox.cs | 2 +- .../Dialogs/RegexHelperDialog.Designer.cs | 388 +++++++++--------- .../Dialogs/RegexHelperDialog.cs | 313 +++++++------- .../Dialogs/RegexHelperDialog.resx | 244 +++++------ .../Dialogs/TabRenameDialog.Designer.cs | 2 +- src/Logexpert.UI/Dialogs/TabRenameDialog.cs | 2 +- src/Logexpert.UI/LogExpert.UI.csproj | 3 + 15 files changed, 516 insertions(+), 522 deletions(-) rename src/{LogExpert => Logexpert.UI}/Dialogs/RegexHelperDialog.Designer.cs (97%) rename src/{LogExpert => Logexpert.UI}/Dialogs/RegexHelperDialog.cs (70%) rename src/{LogExpert => Logexpert.UI}/Dialogs/RegexHelperDialog.resx (97%) diff --git a/src/LogExpert/Config/RegexHistory.cs b/src/LogExpert/Config/RegexHistory.cs index 2cbcde4f..cb24f96e 100644 --- a/src/LogExpert/Config/RegexHistory.cs +++ b/src/LogExpert/Config/RegexHistory.cs @@ -6,11 +6,8 @@ namespace LogExpert.Config [Serializable] public class RegexHistory { - #region Fields + public List ExpressionHistoryList { get; set; } = []; - public List expressionHistoryList = []; - public List testtextHistoryList = []; - - #endregion + public List TesttextHistoryList { get; set; } = []; } } \ No newline at end of file diff --git a/src/LogExpert/Config/Settings.cs b/src/LogExpert/Config/Settings.cs index d21d88a3..b7264b00 100644 --- a/src/LogExpert/Config/Settings.cs +++ b/src/LogExpert/Config/Settings.cs @@ -47,7 +47,7 @@ public class Settings public Preferences Preferences { get; set; } = new(); - public RegexHistory regexHistory = new(); + public RegexHistory RegexHistory { get; set; } = new(); public List searchHistoryList = []; diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs index 8debf55d..598f9804 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs @@ -4,6 +4,7 @@ using LogExpert.Dialogs; using LogExpert.Entities; using LogExpert.Entities.EventArgs; +using LogExpert.UI.Dialogs; using System; using System.Collections.Generic; @@ -977,7 +978,7 @@ private void OnOpenURIToolStripMenuItemClick(object sender, EventArgs e) { ConfigManager.Settings.uriHistoryList = dlg.UriHistory; ConfigManager.Save(SettingsFlags.FileHistory); - LoadFiles(new[] { dlg.Uri }, false); + LoadFiles([dlg.Uri], false); } } } diff --git a/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs index 4892ab3c..f6968434 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs @@ -10,6 +10,7 @@ using LogExpert.Entities.EventArgs; using LogExpert.Extensions; using LogExpert.Interface; +using LogExpert.UI.Dialogs; using System; using System.Collections.Generic; @@ -1301,16 +1302,24 @@ private void OnFilterRegexCheckBoxMouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { - RegexHelperDialog dlg = new(); - dlg.Owner = this; - dlg.CaseSensitive = filterCaseSensitiveCheckBox.Checked; - dlg.Pattern = filterComboBox.Text; - DialogResult res = dlg.ShowDialog(); + RegexHelperDialog dlg = new() + { + ExpressionHistoryList = ConfigManager.Settings.RegexHistory.ExpressionHistoryList, + TesttextHistoryList = ConfigManager.Settings.RegexHistory.TesttextHistoryList, + Owner = this, + CaseSensitive = filterCaseSensitiveCheckBox.Checked, + Pattern = filterComboBox.Text + }; - if (res == DialogResult.OK) + if (dlg.ShowDialog() == DialogResult.OK) { + ConfigManager.Settings.RegexHistory.ExpressionHistoryList = dlg.ExpressionHistoryList; + ConfigManager.Settings.RegexHistory.TesttextHistoryList = dlg.TesttextHistoryList; + filterCaseSensitiveCheckBox.Checked = dlg.CaseSensitive; filterComboBox.Text = dlg.Pattern; + + ConfigManager.Save(SettingsFlags.RegexHistory); } } } diff --git a/src/LogExpert/Dialogs/HighlightDialog.cs b/src/LogExpert/Dialogs/HighlightDialog.cs index e25d12b0..e57baf30 100644 --- a/src/LogExpert/Dialogs/HighlightDialog.cs +++ b/src/LogExpert/Dialogs/HighlightDialog.cs @@ -1,6 +1,7 @@ using LogExpert.Classes.Highlight; using LogExpert.Config; using LogExpert.Entities; +using LogExpert.UI.Dialogs; using NLog; @@ -314,12 +315,14 @@ private void OnChkBoxRegexMouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { - RegexHelperDialog dlg = new(); - dlg.Owner = this; - dlg.CaseSensitive = checkBoxCaseSensitive.Checked; - dlg.Pattern = textBoxSearchString.Text; - DialogResult res = dlg.ShowDialog(); - if (res == DialogResult.OK) + RegexHelperDialog dlg = new() + { + Owner = this, + CaseSensitive = checkBoxCaseSensitive.Checked, + Pattern = textBoxSearchString.Text + }; + + if (dlg.ShowDialog() == DialogResult.OK) { checkBoxCaseSensitive.Checked = dlg.CaseSensitive; textBoxSearchString.Text = dlg.Pattern; diff --git a/src/LogExpert/Dialogs/SearchDialog.cs b/src/LogExpert/Dialogs/SearchDialog.cs index 9e2f90d3..c9db6a6a 100644 --- a/src/LogExpert/Dialogs/SearchDialog.cs +++ b/src/LogExpert/Dialogs/SearchDialog.cs @@ -1,9 +1,12 @@ -using System; +using LogExpert.Entities; +using LogExpert.UI.Dialogs; + +using NLog; + +using System; using System.Drawing; using System.Text.RegularExpressions; using System.Windows.Forms; -using LogExpert.Entities; -using NLog; namespace LogExpert.Dialogs { @@ -82,13 +85,14 @@ private void OnSearchDialogLoad(object sender, EventArgs e) private void OnButtonRegexClick(object sender, EventArgs e) { - RegexHelperDialog dlg = new(); - dlg.Owner = this; - dlg.CaseSensitive = checkBoxCaseSensitive.Checked; - dlg.Pattern = comboBoxSearchFor.Text; + RegexHelperDialog dlg = new() + { + Owner = this, + CaseSensitive = checkBoxCaseSensitive.Checked, + Pattern = comboBoxSearchFor.Text + }; - DialogResult res = dlg.ShowDialog(); - if (res == DialogResult.OK) + if (dlg.ShowDialog() == DialogResult.OK) { checkBoxCaseSensitive.Checked = dlg.CaseSensitive; comboBoxSearchFor.Text = dlg.Pattern; diff --git a/src/LogExpert/Dialogs/ToolArgsDialog.cs b/src/LogExpert/Dialogs/ToolArgsDialog.cs index e69f0375..401604cf 100644 --- a/src/LogExpert/Dialogs/ToolArgsDialog.cs +++ b/src/LogExpert/Dialogs/ToolArgsDialog.cs @@ -1,12 +1,10 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; +using LogExpert.Classes; +using LogExpert.Controls.LogTabWindow; +using LogExpert.UI.Dialogs; + +using System; using System.Drawing; -using System.Text; using System.Windows.Forms; -using LogExpert.Classes; -using LogExpert.Controls.LogTabWindow; namespace LogExpert.Dialogs diff --git a/src/Logexpert.UI/Dialogs/AboutBox.Designer.cs b/src/Logexpert.UI/Dialogs/AboutBox.Designer.cs index b245d9c7..37e82252 100644 --- a/src/Logexpert.UI/Dialogs/AboutBox.Designer.cs +++ b/src/Logexpert.UI/Dialogs/AboutBox.Designer.cs @@ -1,6 +1,6 @@ using System.Runtime.Versioning; -namespace LogExpert.Dialogs +namespace LogExpert.UI.Dialogs { partial class AboutBox { diff --git a/src/Logexpert.UI/Dialogs/AboutBox.cs b/src/Logexpert.UI/Dialogs/AboutBox.cs index 0bf70252..1b51352d 100644 --- a/src/Logexpert.UI/Dialogs/AboutBox.cs +++ b/src/Logexpert.UI/Dialogs/AboutBox.cs @@ -2,7 +2,7 @@ using System.Reflection; using System.Runtime.Versioning; -namespace LogExpert.Dialogs +namespace LogExpert.UI.Dialogs { [SupportedOSPlatform("windows")] public partial class AboutBox : Form diff --git a/src/LogExpert/Dialogs/RegexHelperDialog.Designer.cs b/src/Logexpert.UI/Dialogs/RegexHelperDialog.Designer.cs similarity index 97% rename from src/LogExpert/Dialogs/RegexHelperDialog.Designer.cs rename to src/Logexpert.UI/Dialogs/RegexHelperDialog.Designer.cs index 05fda035..99655fc4 100644 --- a/src/LogExpert/Dialogs/RegexHelperDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/RegexHelperDialog.Designer.cs @@ -1,195 +1,195 @@ -namespace LogExpert.Dialogs -{ - partial class RegexHelperDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOk = new System.Windows.Forms.Button(); - this.labelRegex = new System.Windows.Forms.Label(); - this.labelTestText = new System.Windows.Forms.Label(); - this.labelMatches = new System.Windows.Forms.Label(); - this.textBoxMatches = new System.Windows.Forms.TextBox(); - this.checkBoxCaseSensitive = new System.Windows.Forms.CheckBox(); - this.comboBoxRegex = new System.Windows.Forms.ComboBox(); - this.comboBoxTestText = new System.Windows.Forms.ComboBox(); - this.helpProvider1 = new System.Windows.Forms.HelpProvider(); - this.buttonHelp = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(365, 371); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 0; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // buttonOk - // - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(284, 371); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 23); - this.buttonOk.TabIndex = 1; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.OnButtonOkClick); - // - // labelRegex - // - this.labelRegex.AutoSize = true; - this.labelRegex.Location = new System.Drawing.Point(14, 14); - this.labelRegex.Name = "labelRegex"; - this.labelRegex.Size = new System.Drawing.Size(151, 20); - this.labelRegex.TabIndex = 3; - this.labelRegex.Text = "Regular Expression:"; - // - // labelTestText - // - this.labelTestText.AutoSize = true; - this.labelTestText.Location = new System.Drawing.Point(14, 98); - this.labelTestText.Name = "labelTestText"; - this.labelTestText.Size = new System.Drawing.Size(74, 20); - this.labelTestText.TabIndex = 5; - this.labelTestText.Text = "Test text:"; - // - // labelMatches - // - this.labelMatches.AutoSize = true; - this.labelMatches.Location = new System.Drawing.Point(14, 152); - this.labelMatches.Name = "labelMatches"; - this.labelMatches.Size = new System.Drawing.Size(74, 20); - this.labelMatches.TabIndex = 6; - this.labelMatches.Text = "Matches:"; - // - // textBoxMatches - // - this.textBoxMatches.Location = new System.Drawing.Point(12, 175); - this.textBoxMatches.Multiline = true; - this.textBoxMatches.Name = "textBoxMatches"; - this.textBoxMatches.ReadOnly = true; - this.textBoxMatches.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBoxMatches.Size = new System.Drawing.Size(428, 190); - this.textBoxMatches.TabIndex = 7; - // - // checkBoxCaseSensitive - // - this.checkBoxCaseSensitive.AutoSize = true; - this.checkBoxCaseSensitive.Location = new System.Drawing.Point(12, 71); - this.checkBoxCaseSensitive.Name = "checkBoxCaseSensitive"; - this.checkBoxCaseSensitive.Size = new System.Drawing.Size(137, 24); - this.checkBoxCaseSensitive.TabIndex = 8; - this.checkBoxCaseSensitive.Text = "Case sensitive"; - this.checkBoxCaseSensitive.UseVisualStyleBackColor = true; - this.checkBoxCaseSensitive.CheckedChanged += new System.EventHandler(this.OnCaseSensitiveCheckBoxCheckedChanged); - // - // comboBoxRegex - // - this.comboBoxRegex.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; - this.comboBoxRegex.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - this.comboBoxRegex.FormattingEnabled = true; - this.comboBoxRegex.Location = new System.Drawing.Point(12, 37); - this.comboBoxRegex.Name = "comboBoxRegex"; - this.comboBoxRegex.Size = new System.Drawing.Size(428, 28); - this.comboBoxRegex.TabIndex = 10; - this.comboBoxRegex.TextChanged += new System.EventHandler(this.OnComboBoxRegexTextChanged); - // - // comboBoxTestText - // - this.comboBoxTestText.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; - this.comboBoxTestText.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - this.comboBoxTestText.FormattingEnabled = true; - this.comboBoxTestText.Location = new System.Drawing.Point(12, 121); - this.comboBoxTestText.Name = "comboBoxTestText"; - this.comboBoxTestText.Size = new System.Drawing.Size(428, 28); - this.comboBoxTestText.TabIndex = 11; - this.comboBoxTestText.TextChanged += new System.EventHandler(this.OnComboBoxTestTextTextChanged); - // - // helpProvider1 - // - this.helpProvider1.HelpNamespace = "LogExpert.chm"; - // - // buttonHelp - // - this.helpProvider1.SetHelpKeyword(this.buttonHelp, "RegEx.htm"); - this.helpProvider1.SetHelpNavigator(this.buttonHelp, System.Windows.Forms.HelpNavigator.Topic); - this.buttonHelp.Location = new System.Drawing.Point(13, 371); - this.buttonHelp.Name = "buttonHelp"; - this.helpProvider1.SetShowHelp(this.buttonHelp, true); - this.buttonHelp.Size = new System.Drawing.Size(75, 23); - this.buttonHelp.TabIndex = 12; - this.buttonHelp.Text = "Help"; - this.buttonHelp.UseVisualStyleBackColor = true; - this.buttonHelp.Click += new System.EventHandler(this.OnButtonHelpClick); - // - // RegexHelperDialog - // - this.AcceptButton = this.buttonOk; - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(452, 403); - this.Controls.Add(this.buttonHelp); - this.Controls.Add(this.comboBoxTestText); - this.Controls.Add(this.comboBoxRegex); - this.Controls.Add(this.checkBoxCaseSensitive); - this.Controls.Add(this.textBoxMatches); - this.Controls.Add(this.labelMatches); - this.Controls.Add(this.labelTestText); - this.Controls.Add(this.labelRegex); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.buttonCancel); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.helpProvider1.SetHelpKeyword(this, "RegEx.htm"); - this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "RegexHelperDialog"; - this.helpProvider1.SetShowHelp(this, true); - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Regex-Helper"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.Label labelRegex; - private System.Windows.Forms.Label labelTestText; - private System.Windows.Forms.Label labelMatches; - private System.Windows.Forms.TextBox textBoxMatches; - private System.Windows.Forms.CheckBox checkBoxCaseSensitive; - private System.Windows.Forms.ComboBox comboBoxRegex; - private System.Windows.Forms.ComboBox comboBoxTestText; - private System.Windows.Forms.HelpProvider helpProvider1; - private System.Windows.Forms.Button buttonHelp; - } +namespace LogExpert.UI.Dialogs +{ + partial class RegexHelperDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOk = new System.Windows.Forms.Button(); + this.labelRegex = new System.Windows.Forms.Label(); + this.labelTestText = new System.Windows.Forms.Label(); + this.labelMatches = new System.Windows.Forms.Label(); + this.textBoxMatches = new System.Windows.Forms.TextBox(); + this.checkBoxCaseSensitive = new System.Windows.Forms.CheckBox(); + this.comboBoxRegex = new System.Windows.Forms.ComboBox(); + this.comboBoxTestText = new System.Windows.Forms.ComboBox(); + this.helpProvider1 = new System.Windows.Forms.HelpProvider(); + this.buttonHelp = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(365, 371); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 0; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // buttonOk + // + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(284, 371); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 1; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.OnButtonOkClick); + // + // labelRegex + // + this.labelRegex.AutoSize = true; + this.labelRegex.Location = new System.Drawing.Point(14, 14); + this.labelRegex.Name = "labelRegex"; + this.labelRegex.Size = new System.Drawing.Size(151, 20); + this.labelRegex.TabIndex = 3; + this.labelRegex.Text = "Regular Expression:"; + // + // labelTestText + // + this.labelTestText.AutoSize = true; + this.labelTestText.Location = new System.Drawing.Point(14, 98); + this.labelTestText.Name = "labelTestText"; + this.labelTestText.Size = new System.Drawing.Size(74, 20); + this.labelTestText.TabIndex = 5; + this.labelTestText.Text = "Test text:"; + // + // labelMatches + // + this.labelMatches.AutoSize = true; + this.labelMatches.Location = new System.Drawing.Point(14, 152); + this.labelMatches.Name = "labelMatches"; + this.labelMatches.Size = new System.Drawing.Size(74, 20); + this.labelMatches.TabIndex = 6; + this.labelMatches.Text = "Matches:"; + // + // textBoxMatches + // + this.textBoxMatches.Location = new System.Drawing.Point(12, 175); + this.textBoxMatches.Multiline = true; + this.textBoxMatches.Name = "textBoxMatches"; + this.textBoxMatches.ReadOnly = true; + this.textBoxMatches.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.textBoxMatches.Size = new System.Drawing.Size(428, 190); + this.textBoxMatches.TabIndex = 7; + // + // checkBoxCaseSensitive + // + this.checkBoxCaseSensitive.AutoSize = true; + this.checkBoxCaseSensitive.Location = new System.Drawing.Point(12, 71); + this.checkBoxCaseSensitive.Name = "checkBoxCaseSensitive"; + this.checkBoxCaseSensitive.Size = new System.Drawing.Size(137, 24); + this.checkBoxCaseSensitive.TabIndex = 8; + this.checkBoxCaseSensitive.Text = "Case sensitive"; + this.checkBoxCaseSensitive.UseVisualStyleBackColor = true; + this.checkBoxCaseSensitive.CheckedChanged += new System.EventHandler(this.OnCaseSensitiveCheckBoxCheckedChanged); + // + // comboBoxRegex + // + this.comboBoxRegex.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; + this.comboBoxRegex.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.comboBoxRegex.FormattingEnabled = true; + this.comboBoxRegex.Location = new System.Drawing.Point(12, 37); + this.comboBoxRegex.Name = "comboBoxRegex"; + this.comboBoxRegex.Size = new System.Drawing.Size(428, 28); + this.comboBoxRegex.TabIndex = 10; + this.comboBoxRegex.TextChanged += new System.EventHandler(this.OnComboBoxRegexTextChanged); + // + // comboBoxTestText + // + this.comboBoxTestText.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; + this.comboBoxTestText.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.comboBoxTestText.FormattingEnabled = true; + this.comboBoxTestText.Location = new System.Drawing.Point(12, 121); + this.comboBoxTestText.Name = "comboBoxTestText"; + this.comboBoxTestText.Size = new System.Drawing.Size(428, 28); + this.comboBoxTestText.TabIndex = 11; + this.comboBoxTestText.TextChanged += new System.EventHandler(this.OnComboBoxTestTextTextChanged); + // + // helpProvider1 + // + this.helpProvider1.HelpNamespace = "LogExpert.chm"; + // + // buttonHelp + // + this.helpProvider1.SetHelpKeyword(this.buttonHelp, "RegEx.htm"); + this.helpProvider1.SetHelpNavigator(this.buttonHelp, System.Windows.Forms.HelpNavigator.Topic); + this.buttonHelp.Location = new System.Drawing.Point(13, 371); + this.buttonHelp.Name = "buttonHelp"; + this.helpProvider1.SetShowHelp(this.buttonHelp, true); + this.buttonHelp.Size = new System.Drawing.Size(75, 23); + this.buttonHelp.TabIndex = 12; + this.buttonHelp.Text = "Help"; + this.buttonHelp.UseVisualStyleBackColor = true; + this.buttonHelp.Click += new System.EventHandler(this.OnButtonHelpClick); + // + // RegexHelperDialog + // + this.AcceptButton = this.buttonOk; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(452, 403); + this.Controls.Add(this.buttonHelp); + this.Controls.Add(this.comboBoxTestText); + this.Controls.Add(this.comboBoxRegex); + this.Controls.Add(this.checkBoxCaseSensitive); + this.Controls.Add(this.textBoxMatches); + this.Controls.Add(this.labelMatches); + this.Controls.Add(this.labelTestText); + this.Controls.Add(this.labelRegex); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.buttonCancel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.helpProvider1.SetHelpKeyword(this, "RegEx.htm"); + this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "RegexHelperDialog"; + this.helpProvider1.SetShowHelp(this, true); + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Regex-Helper"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOk; + private System.Windows.Forms.Label labelRegex; + private System.Windows.Forms.Label labelTestText; + private System.Windows.Forms.Label labelMatches; + private System.Windows.Forms.TextBox textBoxMatches; + private System.Windows.Forms.CheckBox checkBoxCaseSensitive; + private System.Windows.Forms.ComboBox comboBoxRegex; + private System.Windows.Forms.ComboBox comboBoxTestText; + private System.Windows.Forms.HelpProvider helpProvider1; + private System.Windows.Forms.Button buttonHelp; + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/RegexHelperDialog.cs b/src/Logexpert.UI/Dialogs/RegexHelperDialog.cs similarity index 70% rename from src/LogExpert/Dialogs/RegexHelperDialog.cs rename to src/Logexpert.UI/Dialogs/RegexHelperDialog.cs index 83921af1..aa539068 100644 --- a/src/LogExpert/Dialogs/RegexHelperDialog.cs +++ b/src/Logexpert.UI/Dialogs/RegexHelperDialog.cs @@ -1,168 +1,147 @@ -using System; -using System.Drawing; -using System.Windows.Forms; -using System.Text.RegularExpressions; -using LogExpert.Config; - -namespace LogExpert.Dialogs -{ - public partial class RegexHelperDialog : Form - { - #region Fields - - private static readonly int MAX_HISTORY = 30; - private bool _caseSensitive; - - #endregion - - #region cTor - - public RegexHelperDialog() - { - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - Load += OnRegexHelperDialogLoad; - } - - #endregion - - #region Properties - - public bool CaseSensitive - { - get => _caseSensitive; - set - { - _caseSensitive = value; - checkBoxCaseSensitive.Checked = value; - } - } - - public string Pattern - { - get => comboBoxRegex.Text; - set => comboBoxRegex.Text = value; - } - - #endregion - - #region Private Methods - - private void UpdateMatches() - { - textBoxMatches.Text = ""; - try - { - Regex rex = new(comboBoxRegex.Text, _caseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); - MatchCollection matches = rex.Matches(comboBoxTestText.Text); - - foreach (Match match in matches) - { - textBoxMatches.Text += $"{match.Value}\r\n"; - } - } - catch (ArgumentException) - { - textBoxMatches.Text = "No valid regex pattern"; - } - } - - private void LoadHistory() - { - RegexHistory history = ConfigManager.Settings.regexHistory; - - if (history == null) - { - return; - } - - comboBoxRegex.Items.Clear(); - foreach (string item in history.expressionHistoryList) - { - comboBoxRegex.Items.Add(item); - } - - comboBoxTestText.Items.Clear(); - foreach (string item in history.testtextHistoryList) - { - comboBoxTestText.Items.Add(item); - } - } - - private void SaveHistory() - { - RegexHistory history = new(); - - foreach (string item in comboBoxRegex.Items) - { - history.expressionHistoryList.Add(item); - } - - foreach (string item in comboBoxTestText.Items) - { - history.testtextHistoryList.Add(item); - } - - ConfigManager.Settings.regexHistory = history; - ConfigManager.Save(SettingsFlags.RegexHistory); - } - - #endregion - - #region Events handler - - private void OnRegexHelperDialogLoad(object sender, EventArgs e) - { - LoadHistory(); - } - - private void OnCaseSensitiveCheckBoxCheckedChanged(object sender, EventArgs e) - { - _caseSensitive = checkBoxCaseSensitive.Checked; - UpdateMatches(); - } - - - private void OnButtonOkClick(object sender, EventArgs e) - { - string text = comboBoxRegex.Text; - comboBoxRegex.Items.Remove(text); - comboBoxRegex.Items.Insert(0, text); - - text = comboBoxTestText.Text; - comboBoxTestText.Items.Remove(text); - comboBoxTestText.Items.Insert(0, text); - - if (comboBoxRegex.Items.Count > MAX_HISTORY) - { - comboBoxRegex.Items.Remove(comboBoxRegex.Items.Count - 1); - } - if (comboBoxTestText.Items.Count > MAX_HISTORY) - { - comboBoxTestText.Items.Remove(comboBoxTestText.Items.Count - 1); - } - - SaveHistory(); - } - - private void OnComboBoxRegexTextChanged(object sender, EventArgs e) - { - UpdateMatches(); - } - - private void OnComboBoxTestTextTextChanged(object sender, EventArgs e) - { - UpdateMatches(); - } - - private void OnButtonHelpClick(object sender, EventArgs e) - { - Help.ShowHelp(this, "LogExpert.chm", HelpNavigator.Topic, "RegEx.htm"); - } - - #endregion - } +using System.Runtime.Versioning; +using System.Text.RegularExpressions; + +namespace LogExpert.UI.Dialogs +{ + [SupportedOSPlatform("windows")] + public partial class RegexHelperDialog : Form + { + #region Fields + + private static readonly int MAX_HISTORY = 30; + private bool _caseSensitive; + private List _expressionHistoryList = []; + private List _testtextHistoryList = []; + + #endregion + + #region cTor + + public RegexHelperDialog() + { + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + Load += OnRegexHelperDialogLoad; + } + + #endregion + + #region Properties + + public bool CaseSensitive + { + get => _caseSensitive; + set + { + _caseSensitive = value; + checkBoxCaseSensitive.Checked = value; + } + } + + public string Pattern + { + get => comboBoxRegex.Text; + set => comboBoxRegex.Text = value; + } + + public List ExpressionHistoryList + { + get => _expressionHistoryList; + set => _expressionHistoryList = value; + } + + public List TesttextHistoryList + { + get => _testtextHistoryList; + set => _testtextHistoryList = value; + } + + #endregion + + #region Private Methods + + private void UpdateMatches() + { + textBoxMatches.Text = ""; + try + { + Regex rex = new(comboBoxRegex.Text, _caseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); + MatchCollection matches = rex.Matches(comboBoxTestText.Text); + + foreach (Match match in matches) + { + textBoxMatches.Text += $"{match.Value}\r\n"; + } + } + catch (ArgumentException) + { + textBoxMatches.Text = "No valid regex pattern"; + } + } + + private void LoadHistory() + { + comboBoxRegex.Items.Clear(); + comboBoxRegex.DataSource = _expressionHistoryList; + + comboBoxTestText.Items.Clear(); + comboBoxTestText.DataSource = _testtextHistoryList; + } + + #endregion + + #region Events handler + + private void OnRegexHelperDialogLoad(object? sender, EventArgs e) + { + LoadHistory(); + } + + private void OnCaseSensitiveCheckBoxCheckedChanged(object sender, EventArgs e) + { + _caseSensitive = checkBoxCaseSensitive.Checked; + UpdateMatches(); + } + + private void OnButtonOkClick(object sender, EventArgs e) + { + string text = comboBoxRegex.Text; + comboBoxRegex.Items.Remove(text); + comboBoxRegex.Items.Insert(0, text); + + text = comboBoxTestText.Text; + comboBoxTestText.Items.Remove(text); + comboBoxTestText.Items.Insert(0, text); + + if (comboBoxRegex.Items.Count > MAX_HISTORY) + { + comboBoxRegex.Items.Remove(comboBoxRegex.Items.Count - 1); + } + + if (comboBoxTestText.Items.Count > MAX_HISTORY) + { + comboBoxTestText.Items.Remove(comboBoxTestText.Items.Count - 1); + } + } + + private void OnComboBoxRegexTextChanged(object sender, EventArgs e) + { + UpdateMatches(); + } + + private void OnComboBoxTestTextTextChanged(object sender, EventArgs e) + { + UpdateMatches(); + } + + private void OnButtonHelpClick(object sender, EventArgs e) + { + Help.ShowHelp(this, "LogExpert.chm", HelpNavigator.Topic, "RegEx.htm"); + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/RegexHelperDialog.resx b/src/Logexpert.UI/Dialogs/RegexHelperDialog.resx similarity index 97% rename from src/LogExpert/Dialogs/RegexHelperDialog.resx rename to src/Logexpert.UI/Dialogs/RegexHelperDialog.resx index 59775d45..9cf9a31f 100644 --- a/src/LogExpert/Dialogs/RegexHelperDialog.resx +++ b/src/Logexpert.UI/Dialogs/RegexHelperDialog.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/TabRenameDialog.Designer.cs b/src/Logexpert.UI/Dialogs/TabRenameDialog.Designer.cs index b6dc6df2..974f8edf 100644 --- a/src/Logexpert.UI/Dialogs/TabRenameDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/TabRenameDialog.Designer.cs @@ -1,4 +1,4 @@ -namespace LogExpert.Dialogs +namespace LogExpert.UI.Dialogs { partial class TabRenameDialog { diff --git a/src/Logexpert.UI/Dialogs/TabRenameDialog.cs b/src/Logexpert.UI/Dialogs/TabRenameDialog.cs index 45be12eb..1ba5abd3 100644 --- a/src/Logexpert.UI/Dialogs/TabRenameDialog.cs +++ b/src/Logexpert.UI/Dialogs/TabRenameDialog.cs @@ -1,6 +1,6 @@ using System.Runtime.Versioning; -namespace LogExpert.Dialogs +namespace LogExpert.UI.Dialogs { [SupportedOSPlatform("windows")] public partial class TabRenameDialog : Form diff --git a/src/Logexpert.UI/LogExpert.UI.csproj b/src/Logexpert.UI/LogExpert.UI.csproj index 8053fa7c..a4adc350 100644 --- a/src/Logexpert.UI/LogExpert.UI.csproj +++ b/src/Logexpert.UI/LogExpert.UI.csproj @@ -20,6 +20,9 @@ Form + + Form + Form From d50d544f656d0b12bdefabf9eef0e3e0697ea565 Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Thu, 27 Mar 2025 17:09:07 +0100 Subject: [PATCH 009/142] updated a lot of files --- src/AutoColumnizer/AutoColumnizer.cs | 6 +- .../Extensions/LogLineExtensionsTests.cs | 2 + .../Extensions/LogLineExtensions.cs | 2 +- src/ColumnizerLib/IFileSystemPlugin.cs | 10 +- src/ColumnizerLib/IXmlLogConfiguration.cs | 8 +- src/CsvColumnizer/CsvColumnizer.cs | 41 +- src/Directory.Packages.props | 2 +- src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs | 6 +- .../Log4jXmlColumnizerConfigDlg.cs | 4 +- src/LogExpert.Tests/BufferShiftTest.cs | 3 + src/LogExpert.Tests/CSVColumnizerTest.cs | 10 +- src/LogExpert.Tests/ColumnizerPickerTest.cs | 25 +- src/LogExpert.Tests/DateFormatParserTest.cs | 4 +- .../Extensions/EnumerableTests.cs | 2 +- src/LogExpert.Tests/JSONSaveTest.cs | 4 + src/LogExpert.Tests/JsonColumnizerTest.cs | 2 +- .../JsonCompactColumnizerTest.cs | 4 +- src/LogExpert.Tests/LocalFileSystemTest.cs | 5 +- src/LogExpert.Tests/LogStreamReaderTest.cs | 6 +- src/LogExpert.Tests/ReaderTest.cs | 8 +- src/LogExpert.Tests/RollingNameTest.cs | 3 +- src/LogExpert.Tests/RolloverHandlerTest.cs | 25 +- .../RolloverHandlerTestBase.cs | 3 +- .../SquareBracketColumnizerTest.cs | 9 +- src/LogExpert.sln | 6 + src/LogExpert/Classes/ArgParser.cs | 8 +- src/LogExpert/Classes/Filter/Filter.cs | 3 + .../Classes/Filter/FilterCancelHandler.cs | 3 +- src/LogExpert/Classes/Filter/FilterPipe.cs | 9 +- src/LogExpert/Classes/Filter/FilterStarter.cs | 3 + .../ColumnizerCallback.cs | 9 +- .../LogExpertCallback.cs | 5 +- src/LogExpert/Classes/Log/LogfileReader.cs | 17 +- .../Classes/Log/RolloverFilenameHandler.cs | 8 +- .../Classes/LogExpertApplicationContext.cs | 1 + src/LogExpert/Classes/LogExpertProxy.cs | 12 +- src/LogExpert/Classes/PaintHelper.cs | 13 +- src/LogExpert/Classes/RangeFinder.cs | 10 +- src/LogExpert/Classes/TimeSyncList.cs | 27 +- src/LogExpert/Config/ConfigManager.cs | 13 +- src/LogExpert/Controls/LogTabPage.cs | 68 +- .../Controls/LogTabWindow/LogTabWindow.cs | 7 +- .../LogTabWindow/LogTabWindow.designer.cs | 4 +- .../LogTabWindow/LogTabWindowEventHandlers.cs | 14 +- .../LogTabWindow/LogTabWindowPrivate.cs | 21 +- .../LogTabWindow/LogTabWindowPublic.cs | 27 +- src/LogExpert/Controls/LogWindow/LogWindow.cs | 17 +- .../LogWindow/LogWindowEventHandlers.cs | 15 +- .../Controls/LogWindow/LogWindowPrivate.cs | 39 +- .../Controls/LogWindow/LogWindowsPublic.cs | 42 +- src/LogExpert/Controls/PatternWindow.cs | 149 +- src/LogExpert/Dialogs/BookmarkWindow.cs | 58 +- src/LogExpert/Dialogs/BufferedDataGridView.cs | 21 +- src/LogExpert/Dialogs/ChooseIconDlg.cs | 15 +- src/LogExpert/Dialogs/DateTimeDragControl.cs | 30 +- src/LogExpert/Dialogs/FilterColumnChooser.cs | 3 +- src/LogExpert/Dialogs/HighlightDialog.cs | 6 +- src/LogExpert/Dialogs/ImportSettingsDialog.cs | 7 +- src/LogExpert/Dialogs/KeywordActionDlg.cs | 2 +- src/LogExpert/Dialogs/OverlayEventArgs.cs | 5 +- src/LogExpert/Dialogs/SettingsDialog.cs | 36 +- src/LogExpert/Dialogs/TimeSpreadigControl.cs | 1 + src/LogExpert/Entities/DebugOptions.cs | 11 - .../CurrentHighlightGroupChangedEventArgs.cs | 7 +- .../EventArgs/FilterListChangedEventArgs.cs | 4 +- src/LogExpert/Entities/LogFileException.cs | 21 - src/LogExpert/Entities/ReloadMemento.cs | 12 - src/LogExpert/Entities/WindowFileEntry.cs | 7 +- src/LogExpert/Entities/WindowTypes.cs | 8 - .../Forms/LineToolStripSeparatorExtension.cs | 8 +- .../Extensions/Forms/MenuSelectedColors.cs | 26 +- .../Forms/MenuToolStripSeparatorExtension.cs | 10 +- src/LogExpert/Interface/ILogExpertProxy.cs | 3 +- src/LogExpert/LogExpert.csproj | 1 + src/LogExpert/Program.cs | 3 + .../Classes/Bookmark/BookmarkDataProvider.cs | 351 +++-- .../Classes/Bookmark/BookmarkExporter.cs | 157 +- .../Classes/Bookmark/BookmarkView.cs | 87 +- .../Classes/CmdLine.cs | 870 +++++------ .../Classes/Columnizer/ClfColumnizer.cs | 396 ++--- .../Classes/Columnizer/ColumnizerPicker.cs | 286 ++-- .../Columnizer/SquareBracketColumnizer.cs | 27 +- .../Columnizer/TimeFormatDeterminer.cs | 2 +- .../Classes/Columnizer/TimestampColumnizer.cs | 438 +++--- .../DateTimeParser/DateFormatPartAdjuster.cs | 2 +- .../Classes/DateTimeParser/Parser.cs | 5 +- .../Classes/DateTimeParser/Section.cs | 2 +- .../Classes/DateTimeParser/Token.cs | 2 +- .../Classes/DateTimeParser/Tokenizer.cs | 2 +- .../Classes/FileSystemCallback.cs | 96 +- .../Classes/Filter/FilterParams.cs | 276 ++-- .../Classes/Highlight/ActionEntry.cs | 52 +- .../Classes/Highlight/HilightEntry.cs | 213 ++- .../Classes/Highlight/HilightMatchEntry.cs | 52 +- .../Classes/Log/LogBuffer.cs | 247 ++- .../Classes/Log/LogBufferCacheEntry.cs | 70 +- .../Classes/Log/LogStreamReaderBase.cs | 5 +- .../Log/PositionAwareStreamReaderBase.cs | 446 +++--- .../Log/PositionAwareStreamReaderLegacy.cs | 219 ++- .../Log/PositionAwareStreamReaderSystem.cs | 9 +- .../Classes/Log/RolloverFilenameBuilder.cs | 473 +++--- .../Classes/ObjectClone.cs | 40 +- .../Classes/ParamParser.cs | 209 ++- .../Classes/PatternBlock.cs | 86 +- .../Classes/Persister/FilterTabData.cs | 26 +- .../Classes/Persister/Persister.cs | 1372 ++++++++--------- .../Classes/Persister/ProjectData.cs | 26 +- .../Classes/Persister/ProjectPersister.cs | 134 +- .../Classes/SysoutPipe.cs | 179 ++- .../Classes/Util.cs | 1233 +++++++-------- .../Classes/Win32.cs | 237 +-- .../Classes/xml/XmlBlockSplitter.cs | 340 ++-- .../Classes/xml/XmlLogReader.cs | 340 ++-- .../Config/ColorEntry.cs | 59 +- .../Config/ColorMode.cs | 18 +- .../Config/ColumnizerHistoryEntry.cs | 58 +- .../Config/ColumnizerMaskEntry.cs | 28 +- .../Config/ExportImportFlags.cs | 34 +- .../Config/HighlightMaskEntry.cs | 28 +- .../Config/MultiFileOption.cs | 22 +- .../Config/Preferences.cs | 218 +-- .../Config/RegexHistory.cs | 24 +- .../Config/SessionSaveLocation.cs | 50 +- .../Config/Settings.cs | 122 +- .../Config/SettingsFlags.cs | 46 +- .../Config/ToolEntry.cs | 93 +- .../Entities/Bookmark.cs | 86 +- .../Entities/BookmarkCollection.cs | 46 +- .../Entities/BookmarkOverlay.cs | 40 +- src/Logexpert.Core/Entities/DebugOptions.cs | 11 + .../Entities/DefaultLogfileColumnizer.cs | 167 +- .../Entities/EncodingOptions.cs | 54 +- .../Entities/EventArgs/BookmarkEventArgs.cs | 46 +- .../Entities/EventArgs/ColumnizerEventArgs.cs | 46 +- .../EventArgs/ConfigChangedEventArgs.cs | 50 +- .../EventArgs/ContextMenuPluginEventArgs.cs | 68 +- .../Entities/EventArgs/GuiStateArgs.cs | 97 +- .../Entities/EventArgs/LoadFileEventArgs.cs | 6 +- .../Entities/EventArgs/PatternArgs.cs | 30 +- .../Entities/EventArgs/ProgressEventArgs.cs | 40 +- .../Entities/EventArgs/StatusEventArgs.cs | 70 +- .../Entities/EventArgs/SyncModeEventArgs.cs | 46 +- .../Entities/FileViewContext.cs | 56 +- .../Entities/HilightGroup.cs | 63 +- .../Entities/LogEventData.cs | 48 +- .../Entities/LogFileException.cs | 19 + .../Entities/MultifileOptions.cs | 60 +- .../Entities/Range.cs | 60 +- src/Logexpert.Core/Entities/ReloadMemento.cs | 12 + .../Entities/RowHeightEntry.cs | 64 +- .../Entities/SearchParams.cs | 47 +- .../Enums/DragOrientationsEnum.cs | 9 + src/Logexpert.Core/Enums/WindowTypes.cs | 8 + .../Extensions/IEnumerable.cs | 51 +- .../BackgroundProcessCancelHandler.cs | 34 +- .../Interface/IBookmarkData.cs | 45 +- .../Interface/IBookmarkView.cs | 51 +- .../Interface/ILogPaintContext.cs | 70 +- .../Interface/ILogStreamReader.cs | 47 +- .../Interface/ILogView.cs | 48 +- .../Interface/ISharedToolWindow.cs | 62 +- src/Logexpert.Core/Logexpert.Core.csproj | 11 + src/Logexpert.UI/Dialogs/AboutBox.cs | 24 +- .../Dialogs/SearchDialog.Designer.cs | 506 +++--- .../Dialogs/SearchDialog.cs | 279 ++-- .../Dialogs/SearchDialog.resx | 244 +-- src/Logexpert.UI/LogExpert.UI.csproj | 4 + .../FileSystem}/LocalFileSystem.cs | 87 +- .../FileSystem}/LogFileInfo.cs | 368 +++-- .../LogExpert.PluginRegistry.csproj | 17 + .../PluginRegistry.cs | 742 ++++----- 171 files changed, 7526 insertions(+), 7369 deletions(-) delete mode 100644 src/LogExpert/Entities/DebugOptions.cs delete mode 100644 src/LogExpert/Entities/LogFileException.cs delete mode 100644 src/LogExpert/Entities/ReloadMemento.cs delete mode 100644 src/LogExpert/Entities/WindowTypes.cs rename src/{LogExpert => Logexpert.Core}/Classes/Bookmark/BookmarkDataProvider.cs (79%) rename src/{LogExpert => Logexpert.Core}/Classes/Bookmark/BookmarkExporter.cs (89%) rename src/{LogExpert => Logexpert.Core}/Classes/Bookmark/BookmarkView.cs (88%) rename src/{LogExpert => Logexpert.Core}/Classes/CmdLine.cs (92%) rename src/{LogExpert => Logexpert.Core}/Classes/Columnizer/ClfColumnizer.cs (90%) rename src/{LogExpert => Logexpert.Core}/Classes/Columnizer/ColumnizerPicker.cs (82%) rename src/{LogExpert => Logexpert.Core}/Classes/Columnizer/SquareBracketColumnizer.cs (92%) rename src/{LogExpert => Logexpert.Core}/Classes/Columnizer/TimeFormatDeterminer.cs (99%) rename src/{LogExpert => Logexpert.Core}/Classes/Columnizer/TimestampColumnizer.cs (92%) rename src/{LogExpert => Logexpert.Core}/Classes/DateTimeParser/DateFormatPartAdjuster.cs (95%) rename src/{LogExpert => Logexpert.Core}/Classes/DateTimeParser/Parser.cs (97%) rename src/{LogExpert => Logexpert.Core}/Classes/DateTimeParser/Section.cs (80%) rename src/{LogExpert => Logexpert.Core}/Classes/DateTimeParser/Token.cs (92%) rename src/{LogExpert => Logexpert.Core}/Classes/DateTimeParser/Tokenizer.cs (98%) rename src/{LogExpert => Logexpert.Core}/Classes/FileSystemCallback.cs (86%) rename src/{LogExpert => Logexpert.Core}/Classes/Filter/FilterParams.cs (94%) rename src/{LogExpert => Logexpert.Core}/Classes/Highlight/ActionEntry.cs (88%) rename src/{LogExpert => Logexpert.Core}/Classes/Highlight/HilightEntry.cs (94%) rename src/{LogExpert => Logexpert.Core}/Classes/Highlight/HilightMatchEntry.cs (89%) rename src/{LogExpert => Logexpert.Core}/Classes/Log/LogBuffer.cs (92%) rename src/{LogExpert => Logexpert.Core}/Classes/Log/LogBufferCacheEntry.cs (60%) rename src/{LogExpert => Logexpert.Core}/Classes/Log/LogStreamReaderBase.cs (95%) rename src/{LogExpert => Logexpert.Core}/Classes/Log/PositionAwareStreamReaderBase.cs (93%) rename src/{LogExpert => Logexpert.Core}/Classes/Log/PositionAwareStreamReaderLegacy.cs (73%) rename src/{LogExpert => Logexpert.Core}/Classes/Log/PositionAwareStreamReaderSystem.cs (96%) rename src/{LogExpert => Logexpert.Core}/Classes/Log/RolloverFilenameBuilder.cs (95%) rename src/{LogExpert => Logexpert.Core}/Classes/ObjectClone.cs (79%) rename src/{LogExpert => Logexpert.Core}/Classes/ParamParser.cs (91%) rename src/{LogExpert => Logexpert.Core}/Classes/PatternBlock.cs (92%) rename src/{LogExpert => Logexpert.Core}/Classes/Persister/FilterTabData.cs (67%) rename src/{LogExpert => Logexpert.Core}/Classes/Persister/Persister.cs (96%) rename src/{LogExpert => Logexpert.Core}/Classes/Persister/ProjectData.cs (80%) rename src/{LogExpert => Logexpert.Core}/Classes/Persister/ProjectPersister.cs (95%) rename src/{LogExpert => Logexpert.Core}/Classes/SysoutPipe.cs (58%) rename src/{LogExpert => Logexpert.Core}/Classes/Util.cs (89%) rename src/{LogExpert => Logexpert.Core}/Classes/Win32.cs (67%) rename src/{LogExpert => Logexpert.Core}/Classes/xml/XmlBlockSplitter.cs (92%) rename src/{LogExpert => Logexpert.Core}/Classes/xml/XmlLogReader.cs (93%) rename src/{LogExpert => Logexpert.Core}/Config/ColorEntry.cs (85%) rename src/{LogExpert => Logexpert.Core}/Config/ColorMode.cs (89%) rename src/{LogExpert => Logexpert.Core}/Config/ColumnizerHistoryEntry.cs (89%) rename src/{LogExpert => Logexpert.Core}/Config/ColumnizerMaskEntry.cs (82%) rename src/{LogExpert => Logexpert.Core}/Config/ExportImportFlags.cs (79%) rename src/{LogExpert => Logexpert.Core}/Config/HighlightMaskEntry.cs (82%) rename src/{LogExpert => Logexpert.Core}/Config/MultiFileOption.cs (77%) rename src/{LogExpert => Logexpert.Core}/Config/Preferences.cs (86%) rename src/{LogExpert => Logexpert.Core}/Config/RegexHistory.cs (86%) rename src/{LogExpert => Logexpert.Core}/Config/SessionSaveLocation.cs (84%) rename src/{LogExpert => Logexpert.Core}/Config/Settings.cs (88%) rename src/{LogExpert => Logexpert.Core}/Config/SettingsFlags.cs (91%) rename src/{LogExpert => Logexpert.Core}/Config/ToolEntry.cs (54%) rename src/{LogExpert => Logexpert.Core}/Entities/Bookmark.cs (92%) rename src/{LogExpert => Logexpert.Core}/Entities/BookmarkCollection.cs (90%) rename src/{LogExpert => Logexpert.Core}/Entities/BookmarkOverlay.cs (86%) create mode 100644 src/Logexpert.Core/Entities/DebugOptions.cs rename src/{LogExpert => Logexpert.Core}/Entities/DefaultLogfileColumnizer.cs (90%) rename src/{LogExpert => Logexpert.Core}/Entities/EncodingOptions.cs (92%) rename src/{LogExpert => Logexpert.Core}/Entities/EventArgs/BookmarkEventArgs.cs (75%) rename src/{LogExpert => Logexpert.Core}/Entities/EventArgs/ColumnizerEventArgs.cs (76%) rename src/{LogExpert => Logexpert.Core}/Entities/EventArgs/ConfigChangedEventArgs.cs (53%) rename src/{LogExpert => Logexpert.Core}/Entities/EventArgs/ContextMenuPluginEventArgs.cs (69%) rename src/{LogExpert => Logexpert.Core}/Entities/EventArgs/GuiStateArgs.cs (82%) rename src/{LogExpert => Logexpert.Core}/Entities/EventArgs/LoadFileEventArgs.cs (70%) rename src/{LogExpert => Logexpert.Core}/Entities/EventArgs/PatternArgs.cs (83%) rename src/{LogExpert => Logexpert.Core}/Entities/EventArgs/ProgressEventArgs.cs (84%) rename src/{LogExpert => Logexpert.Core}/Entities/EventArgs/StatusEventArgs.cs (56%) rename src/{LogExpert => Logexpert.Core}/Entities/EventArgs/SyncModeEventArgs.cs (74%) rename src/{LogExpert => Logexpert.Core}/Entities/FileViewContext.cs (53%) rename src/{LogExpert => Logexpert.Core}/Entities/HilightGroup.cs (80%) rename src/{LogExpert => Logexpert.Core}/Entities/LogEventData.cs (88%) create mode 100644 src/Logexpert.Core/Entities/LogFileException.cs rename src/{LogExpert => Logexpert.Core}/Entities/MultifileOptions.cs (89%) rename src/{LogExpert => Logexpert.Core}/Entities/Range.cs (68%) create mode 100644 src/Logexpert.Core/Entities/ReloadMemento.cs rename src/{LogExpert => Logexpert.Core}/Entities/RowHeightEntry.cs (88%) rename src/{LogExpert => Logexpert.Core}/Entities/SearchParams.cs (75%) create mode 100644 src/Logexpert.Core/Enums/DragOrientationsEnum.cs create mode 100644 src/Logexpert.Core/Enums/WindowTypes.cs rename src/{LogExpert => Logexpert.Core}/Extensions/IEnumerable.cs (80%) rename src/{LogExpert => Logexpert.Core}/Interface/BackgroundProcessCancelHandler.cs (88%) rename src/{LogExpert => Logexpert.Core}/Interface/IBookmarkData.cs (82%) rename src/{LogExpert => Logexpert.Core}/Interface/IBookmarkView.cs (72%) rename src/{LogExpert => Logexpert.Core}/Interface/ILogPaintContext.cs (83%) rename src/{LogExpert => Logexpert.Core}/Interface/ILogStreamReader.cs (78%) rename src/{LogExpert => Logexpert.Core}/Interface/ILogView.cs (75%) rename src/{LogExpert => Logexpert.Core}/Interface/ISharedToolWindow.cs (80%) rename src/{LogExpert => Logexpert.UI}/Dialogs/SearchDialog.Designer.cs (98%) rename src/{LogExpert => Logexpert.UI}/Dialogs/SearchDialog.cs (86%) rename src/{LogExpert => Logexpert.UI}/Dialogs/SearchDialog.resx (97%) rename src/{LogExpert/Classes => PluginRegistry/FileSystem}/LocalFileSystem.cs (70%) rename src/{LogExpert/Classes/Log => PluginRegistry/FileSystem}/LogFileInfo.cs (72%) create mode 100644 src/PluginRegistry/LogExpert.PluginRegistry.csproj rename src/{LogExpert/Classes => PluginRegistry}/PluginRegistry.cs (77%) diff --git a/src/AutoColumnizer/AutoColumnizer.cs b/src/AutoColumnizer/AutoColumnizer.cs index 4e327fc7..d974c3b2 100644 --- a/src/AutoColumnizer/AutoColumnizer.cs +++ b/src/AutoColumnizer/AutoColumnizer.cs @@ -1,9 +1,11 @@ -using System; +using LogExpert; + +using System; using System.Collections.Generic; using System.Linq; using System.Text; -namespace LogExpert +namespace AutoColumnizer { public class AutoColumnizer : ILogLineColumnizer { diff --git a/src/ColumnizerLib.UnitTests/Extensions/LogLineExtensionsTests.cs b/src/ColumnizerLib.UnitTests/Extensions/LogLineExtensionsTests.cs index a412642c..47ace2eb 100644 --- a/src/ColumnizerLib.UnitTests/Extensions/LogLineExtensionsTests.cs +++ b/src/ColumnizerLib.UnitTests/Extensions/LogLineExtensionsTests.cs @@ -1,4 +1,6 @@ using LogExpert; +using LogExpert.Extensions; + using NUnit.Framework; namespace ColumnizerLib.UnitTests.Extensions diff --git a/src/ColumnizerLib/Extensions/LogLineExtensions.cs b/src/ColumnizerLib/Extensions/LogLineExtensions.cs index 01400ea4..44077eb7 100644 --- a/src/ColumnizerLib/Extensions/LogLineExtensions.cs +++ b/src/ColumnizerLib/Extensions/LogLineExtensions.cs @@ -1,4 +1,4 @@ -namespace LogExpert +namespace LogExpert.Extensions { public static class LogLineExtensions { diff --git a/src/ColumnizerLib/IFileSystemPlugin.cs b/src/ColumnizerLib/IFileSystemPlugin.cs index 25c41361..985edf9b 100644 --- a/src/ColumnizerLib/IFileSystemPlugin.cs +++ b/src/ColumnizerLib/IFileSystemPlugin.cs @@ -1,14 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace LogExpert +namespace LogExpert { /// /// Interface for file system plugins. A file system plugin is responsible for feeding file data to LogExpert. /// /// - /// LogExperts file handling is done via file system plugins. The selection if the appropriate plugin for a file is based + /// LogExperts file handling is done via file system plugins. The selection if the appropriate plugin for a file is based /// on URI schemes. If a file system plugin returns true to the method, it will be selected /// to handle a file. /// @@ -31,7 +27,7 @@ public interface IFileSystemPlugin #region Public methods /// - /// Called from LogExpert to determine a file system plugin for a given URI. + /// Called from LogExpert to determine a file system plugin for a given URI. /// /// The URI of the file to be loaded. /// Return true if the file system plugin can handle the URI. diff --git a/src/ColumnizerLib/IXmlLogConfiguration.cs b/src/ColumnizerLib/IXmlLogConfiguration.cs index e6d9c659..b88419b8 100644 --- a/src/ColumnizerLib/IXmlLogConfiguration.cs +++ b/src/ColumnizerLib/IXmlLogConfiguration.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace LogExpert +namespace LogExpert { /// /// This interface declares the configuration data which is needed for XML log file parsing. @@ -32,7 +28,7 @@ public interface IXmlLogConfiguration /// /// A namespace declaration. The returned array must contain 2 strings: The namespace and its declaration.

/// Example: {"log4j", "http://jakarta.apache.org/log4j"} - /// + /// ///
string[] Namespace { get; } diff --git a/src/CsvColumnizer/CsvColumnizer.cs b/src/CsvColumnizer/CsvColumnizer.cs index d2e46764..12c70ff7 100644 --- a/src/CsvColumnizer/CsvColumnizer.cs +++ b/src/CsvColumnizer/CsvColumnizer.cs @@ -1,6 +1,9 @@ using CsvHelper; + using LogExpert; + using Newtonsoft.Json; + using System; using System.Collections.Generic; using System.IO; @@ -157,28 +160,26 @@ public void Selected(ILogLineColumnizerCallback callback) if (line != null) { - using (CsvReader csv = new CsvReader(new StringReader(line.FullLine), _config.ReaderConfiguration)) - { - csv.Read(); - csv.ReadHeader(); - - int fieldCount = csv.Parser.Count; + using CsvReader csv = new(new StringReader(line.FullLine), _config.ReaderConfiguration); + csv.Read(); + csv.ReadHeader(); + + int fieldCount = csv.Parser.Count; - string[] headerRecord = csv.HeaderRecord; + string[] headerRecord = csv.HeaderRecord; - if (_config.HasFieldNames && headerRecord != null) + if (_config.HasFieldNames && headerRecord != null) + { + foreach (string headerColumn in headerRecord) { - foreach (string headerColumn in headerRecord) - { - _columnList.Add(new CsvColumn(headerColumn)); - } + _columnList.Add(new CsvColumn(headerColumn)); } - else + } + else + { + for (int i = 0; i < fieldCount; ++i) { - for (int i = 0; i < fieldCount; ++i) - { - _columnList.Add(new CsvColumn("Column " + i + 1)); - } + _columnList.Add(new CsvColumn("Column " + i + 1)); } } } @@ -187,7 +188,7 @@ public void Selected(ILogLineColumnizerCallback callback) public void DeSelected(ILogLineColumnizerCallback callback) { - // nothing to do + // nothing to do } public void Configure(ILogLineColumnizerCallback callback, string configDir) @@ -257,14 +258,14 @@ private IColumnizedLogLine SplitCsvLine(ILogLine line) { ColumnizedLogLine cLogLine = new ColumnizedLogLine(); cLogLine.LogLine = line; - + using (CsvReader csv = new CsvReader(new StringReader(line.FullLine), _config.ReaderConfiguration)) { csv.Read(); csv.ReadHeader(); //we only read line by line and not the whole file so it is always the header - string[] records = csv.HeaderRecord; + string[] records = csv.HeaderRecord; if (records != null) { diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index f0f5263e..533ca233 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -11,7 +11,7 @@ - + diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs index 88e66fc2..9ed530b8 100644 --- a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json; +using LogExpert; + +using Newtonsoft.Json; using System; using System.Collections.Generic; @@ -10,7 +12,7 @@ using System.Windows.Forms; [assembly: SupportedOSPlatform("windows")] -namespace LogExpert +namespace Log4jXmlColumnizer { /// /// XMl configuration for parsing log4j XML files. The XSL will transform every block of log entries diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs index fae1414d..ac08077b 100644 --- a/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs @@ -1,4 +1,6 @@ -using System; +using Log4jXmlColumnizer; + +using System; using System.Drawing; using System.Windows.Forms; diff --git a/src/LogExpert.Tests/BufferShiftTest.cs b/src/LogExpert.Tests/BufferShiftTest.cs index aeb13fe1..ebc96a2a 100644 --- a/src/LogExpert.Tests/BufferShiftTest.cs +++ b/src/LogExpert.Tests/BufferShiftTest.cs @@ -1,5 +1,8 @@ using LogExpert.Classes.Log; +using LogExpert.Core.Classes.Log; +using LogExpert.Core.Entities; using LogExpert.Entities; +using LogExpert.PluginRegistry.FileSystem; using NUnit.Framework; diff --git a/src/LogExpert.Tests/CSVColumnizerTest.cs b/src/LogExpert.Tests/CSVColumnizerTest.cs index 31ca0b96..85569864 100644 --- a/src/LogExpert.Tests/CSVColumnizerTest.cs +++ b/src/LogExpert.Tests/CSVColumnizerTest.cs @@ -1,6 +1,8 @@ using LogExpert.Classes.Log; -using LogExpert.Entities; +using LogExpert.Core.Entities; + using NUnit.Framework; + using System; using System.IO; @@ -9,9 +11,9 @@ namespace LogExpert.Tests [TestFixture] public class CSVColumnizerTest { - [TestCase(@".\TestData\organizations-10000.csv", new[] {"Index","Organization Id","Name","Website","Country","Description","Founded","Industry","Number of employees"})] - [TestCase(@".\TestData\organizations-1000.csv", new[] {"Index","Organization Id","Name","Website","Country","Description","Founded","Industry","Number of employees"})] - [TestCase(@".\TestData\people-10000.csv", new[] {"Index","User Id","First Name","Last Name","Sex","Email","Phone","Date of birth","Job Title"})] + [TestCase(@".\TestData\organizations-10000.csv", new[] { "Index", "Organization Id", "Name", "Website", "Country", "Description", "Founded", "Industry", "Number of employees" })] + [TestCase(@".\TestData\organizations-1000.csv", new[] { "Index", "Organization Id", "Name", "Website", "Country", "Description", "Founded", "Industry", "Number of employees" })] + [TestCase(@".\TestData\people-10000.csv", new[] { "Index", "User Id", "First Name", "Last Name", "Sex", "Email", "Phone", "Date of birth", "Job Title" })] public void Instantiat_CSVFile_BuildCorrectColumnizer(string filename, string[] expectedHeaders) { CsvColumnizer.CsvColumnizer csvColumnizer = new(); diff --git a/src/LogExpert.Tests/ColumnizerPickerTest.cs b/src/LogExpert.Tests/ColumnizerPickerTest.cs index ae6bedad..608c4234 100644 --- a/src/LogExpert.Tests/ColumnizerPickerTest.cs +++ b/src/LogExpert.Tests/ColumnizerPickerTest.cs @@ -1,10 +1,13 @@ using JsonColumnizer; -using LogExpert.Classes; -using LogExpert.Classes.Columnizer; + using LogExpert.Classes.Log; -using LogExpert.Entities; +using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Entities; + using Moq; + using NUnit.Framework; + using System; using System.IO; @@ -55,7 +58,7 @@ public void FindColumnizer_ReturnCorrectColumnizer(string expectedColumnizerName LineNumber = 4 }); - var result = ColumnizerPicker.FindColumnizer(path, autoLogLineColumnizerCallbackMock.Object); + var result = ColumnizerPicker.FindColumnizer(path, autoLogLineColumnizerCallbackMock.Object, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); Assert.That(result.GetName(), Is.EqualTo(expectedColumnizerName)); } @@ -74,8 +77,8 @@ public void FindReplacementForAutoColumnizer_ValidTextFile_ReturnCorrectColumniz autoColumnizer.Setup(a => a.GetName()).Returns("Auto Columnizer"); // TODO: When DI container is ready, we can mock this set up. - PluginRegistry.Instance.RegisteredColumnizers.Add(new JsonCompactColumnizer()); - var result = ColumnizerPicker.FindReplacementForAutoColumnizer(fileName, reader, autoColumnizer.Object); + PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers.Add(new JsonCompactColumnizer()); + var result = ColumnizerPicker.FindReplacementForAutoColumnizer(fileName, reader, autoColumnizer.Object, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); Assert.That(columnizerType, Is.EqualTo(result.GetType())); } @@ -87,9 +90,8 @@ public void DecideColumnizerByName_WhenReaderIsNotReady_ReturnCorrectColumnizer( string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); // TODO: When DI container is ready, we can mock this set up. - PluginRegistry.Instance.RegisteredColumnizers.Add(new JsonCompactColumnizer()); - var result = ColumnizerPicker.DecideColumnizerByName(fileName, - PluginRegistry.Instance.RegisteredColumnizers); + PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers.Add(new JsonCompactColumnizer()); + var result = ColumnizerPicker.DecideColumnizerByName(fileName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); Assert.That(columnizerType, Is.EqualTo(result.GetType())); } @@ -102,10 +104,9 @@ public void DecideColumnizerByName_ValidTextFile_ReturnCorrectColumnizer( string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, columnizerName); // TODO: When DI container is ready, we can mock this set up. - PluginRegistry.Instance.RegisteredColumnizers.Add(new JsonColumnizer.JsonColumnizer()); + PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers.Add(new JsonColumnizer.JsonColumnizer()); - var result = ColumnizerPicker.DecideColumnizerByName(columnizerName, - PluginRegistry.Instance.RegisteredColumnizers); + var result = ColumnizerPicker.DecideColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); Assert.That(columnizerType, Is.EqualTo(result.GetType())); } diff --git a/src/LogExpert.Tests/DateFormatParserTest.cs b/src/LogExpert.Tests/DateFormatParserTest.cs index c04ff45c..3bbe1af2 100644 --- a/src/LogExpert.Tests/DateFormatParserTest.cs +++ b/src/LogExpert.Tests/DateFormatParserTest.cs @@ -1,5 +1,7 @@ -using LogExpert.Classes.DateTimeParser; +using LogExpert.Core.Classes.DateTimeParser; + using NUnit.Framework; + using System; using System.Collections.Generic; using System.Globalization; diff --git a/src/LogExpert.Tests/Extensions/EnumerableTests.cs b/src/LogExpert.Tests/Extensions/EnumerableTests.cs index 94ae6d49..e6f4e28f 100644 --- a/src/LogExpert.Tests/Extensions/EnumerableTests.cs +++ b/src/LogExpert.Tests/Extensions/EnumerableTests.cs @@ -1,4 +1,4 @@ -using LogExpert.Extensions; +using LogExpert.Core.Extensions; using NUnit.Framework; diff --git a/src/LogExpert.Tests/JSONSaveTest.cs b/src/LogExpert.Tests/JSONSaveTest.cs index e78be754..44f9a532 100644 --- a/src/LogExpert.Tests/JSONSaveTest.cs +++ b/src/LogExpert.Tests/JSONSaveTest.cs @@ -1,6 +1,10 @@ using LogExpert.Config; +using LogExpert.Core.Config; + using Newtonsoft.Json; + using NUnit.Framework; + using System.IO; namespace LogExpert.Tests diff --git a/src/LogExpert.Tests/JsonColumnizerTest.cs b/src/LogExpert.Tests/JsonColumnizerTest.cs index 2ee41a41..6ffb0ff9 100644 --- a/src/LogExpert.Tests/JsonColumnizerTest.cs +++ b/src/LogExpert.Tests/JsonColumnizerTest.cs @@ -1,5 +1,5 @@ using LogExpert.Classes.Log; -using LogExpert.Entities; +using LogExpert.Core.Entities; using NUnit.Framework; diff --git a/src/LogExpert.Tests/JsonCompactColumnizerTest.cs b/src/LogExpert.Tests/JsonCompactColumnizerTest.cs index 8c2756be..8b9bddf4 100644 --- a/src/LogExpert.Tests/JsonCompactColumnizerTest.cs +++ b/src/LogExpert.Tests/JsonCompactColumnizerTest.cs @@ -1,6 +1,8 @@ using LogExpert.Classes.Log; -using LogExpert.Entities; +using LogExpert.Core.Entities; + using NUnit.Framework; + using System; using System.Collections.Generic; using System.IO; diff --git a/src/LogExpert.Tests/LocalFileSystemTest.cs b/src/LogExpert.Tests/LocalFileSystemTest.cs index 88baaa09..eb9aaf8d 100644 --- a/src/LogExpert.Tests/LocalFileSystemTest.cs +++ b/src/LogExpert.Tests/LocalFileSystemTest.cs @@ -1,5 +1,8 @@ -using LogExpert.Classes; +using LogExpert.Classes.Log; +using LogExpert.PluginRegistry.FileSystem; + using NUnit.Framework; + using System; using System.IO; diff --git a/src/LogExpert.Tests/LogStreamReaderTest.cs b/src/LogExpert.Tests/LogStreamReaderTest.cs index 9bb51099..f7e0d6f0 100644 --- a/src/LogExpert.Tests/LogStreamReaderTest.cs +++ b/src/LogExpert.Tests/LogStreamReaderTest.cs @@ -1,8 +1,10 @@ -using LogExpert.Classes.Log; +using LogExpert.Core.Classes.Log; +using LogExpert.Core.Entities; + using NUnit.Framework; + using System.IO; using System.Text; -using LogExpert.Entities; namespace LogExpert.Tests { diff --git a/src/LogExpert.Tests/ReaderTest.cs b/src/LogExpert.Tests/ReaderTest.cs index 6b76076b..4e59a5bd 100644 --- a/src/LogExpert.Tests/ReaderTest.cs +++ b/src/LogExpert.Tests/ReaderTest.cs @@ -1,7 +1,9 @@ -using LogExpert.Classes.Log; -using LogExpert.Entities; -using LogExpert.Interface; +using LogExpert.Core.Classes.Log; +using LogExpert.Core.Entities; +using LogExpert.Core.Interface; + using NUnit.Framework; + using System; using System.IO; using System.Text; diff --git a/src/LogExpert.Tests/RollingNameTest.cs b/src/LogExpert.Tests/RollingNameTest.cs index 51fd14cb..783bd2fa 100644 --- a/src/LogExpert.Tests/RollingNameTest.cs +++ b/src/LogExpert.Tests/RollingNameTest.cs @@ -1,4 +1,5 @@ -using LogExpert.Classes.Log; +using LogExpert.Core.Classes.Log; + using NUnit.Framework; namespace LogExpert.Tests diff --git a/src/LogExpert.Tests/RolloverHandlerTest.cs b/src/LogExpert.Tests/RolloverHandlerTest.cs index 2d4d56ef..594d1290 100644 --- a/src/LogExpert.Tests/RolloverHandlerTest.cs +++ b/src/LogExpert.Tests/RolloverHandlerTest.cs @@ -1,9 +1,12 @@ -using System; -using System.Collections.Generic; -using LogExpert.Classes.Log; -using LogExpert.Entities; +using LogExpert.Classes.Log; +using LogExpert.Core.Entities; +using LogExpert.PluginRegistry.FileSystem; + using NUnit.Framework; +using System; +using System.Collections.Generic; + namespace LogExpert.Tests { [TestFixture] @@ -18,18 +21,18 @@ public void TestFilenameListWithAppendedIndex(string format, int retries) options.MaxDayTry = retries; LinkedList files = CreateTestFilesWithoutDate(); - + string firstFile = files.Last.Value; - + ILogFileInfo info = new LogFileInfo(new Uri(firstFile)); RolloverFilenameHandler handler = new(info, options); LinkedList fileList = handler.GetNameList(); Assert.That(fileList, Is.EqualTo(files)); - + Cleanup(); } - + [Test] [TestCase("*$D(YYYY-mm-DD)_$I.log", 3)] public void TestFilenameListWithDate(string format, int retries) @@ -39,15 +42,15 @@ public void TestFilenameListWithDate(string format, int retries) options.MaxDayTry = retries; LinkedList files = CreateTestFilesWithDate(); - + string firstFile = files.Last.Value; - + ILogFileInfo info = new LogFileInfo(new Uri(firstFile)); RolloverFilenameHandler handler = new(info, options); LinkedList fileList = handler.GetNameList(); Assert.That(fileList, Is.EqualTo(files)); - + Cleanup(); } } diff --git a/src/LogExpert.Tests/RolloverHandlerTestBase.cs b/src/LogExpert.Tests/RolloverHandlerTestBase.cs index d55ae47a..94b8733a 100644 --- a/src/LogExpert.Tests/RolloverHandlerTestBase.cs +++ b/src/LogExpert.Tests/RolloverHandlerTestBase.cs @@ -1,7 +1,8 @@ using System; using System.Collections.Generic; using System.IO; -using LogExpert.Classes.Log; + +using LogExpert.Core.Classes.Log; namespace LogExpert.Tests { diff --git a/src/LogExpert.Tests/SquareBracketColumnizerTest.cs b/src/LogExpert.Tests/SquareBracketColumnizerTest.cs index 3825e46b..21b95f91 100644 --- a/src/LogExpert.Tests/SquareBracketColumnizerTest.cs +++ b/src/LogExpert.Tests/SquareBracketColumnizerTest.cs @@ -1,7 +1,6 @@ - -using LogExpert.Classes.Columnizer; -using LogExpert.Classes.Log; -using LogExpert.Entities; +using LogExpert.Classes.Log; +using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Entities; using NUnit.Framework; @@ -9,7 +8,7 @@ using System.Collections.Generic; using System.IO; -namespace LogExpert +namespace LogExpert.Tests { [TestFixture] public class SquareBracketColumnizerTest diff --git a/src/LogExpert.sln b/src/LogExpert.sln index 1bc2cf6c..e27297e1 100644 --- a/src/LogExpert.sln +++ b/src/LogExpert.sln @@ -63,6 +63,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.Resources", "Loge EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.UI", "Logexpert.UI\LogExpert.UI.csproj", "{5DB0B0F8-3C3E-4805-93A3-7E69AC45CD40}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.PluginRegistry", "PluginRegistry\LogExpert.PluginRegistry.csproj", "{E2D8E653-B7DF-4ACE-8314-8059B1E20751}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -151,6 +153,10 @@ Global {5DB0B0F8-3C3E-4805-93A3-7E69AC45CD40}.Debug|Any CPU.Build.0 = Debug|Any CPU {5DB0B0F8-3C3E-4805-93A3-7E69AC45CD40}.Release|Any CPU.ActiveCfg = Release|Any CPU {5DB0B0F8-3C3E-4805-93A3-7E69AC45CD40}.Release|Any CPU.Build.0 = Release|Any CPU + {E2D8E653-B7DF-4ACE-8314-8059B1E20751}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E2D8E653-B7DF-4ACE-8314-8059B1E20751}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E2D8E653-B7DF-4ACE-8314-8059B1E20751}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E2D8E653-B7DF-4ACE-8314-8059B1E20751}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/LogExpert/Classes/ArgParser.cs b/src/LogExpert/Classes/ArgParser.cs index 3c94c115..a5bfcabc 100644 --- a/src/LogExpert/Classes/ArgParser.cs +++ b/src/LogExpert/Classes/ArgParser.cs @@ -2,6 +2,8 @@ using System.Text; using System.Text.RegularExpressions; using System.Windows.Forms; + +using LogExpert.Core.Classes; using LogExpert.Dialogs; namespace LogExpert.Classes @@ -18,7 +20,7 @@ internal class ArgParser public ArgParser(string argTemplate) { - this.argLine = argTemplate; + argLine = argTemplate; } #endregion @@ -27,7 +29,7 @@ public ArgParser(string argTemplate) public string BuildArgs(ILogLine logLine, int lineNum, ILogFileInfo logFileInfo, Form parent) { - StringBuilder builder = new(this.argLine); + StringBuilder builder = new(argLine); builder.Replace("%L", "" + lineNum); builder.Replace("%P", logFileInfo.DirectoryName); builder.Replace("%N", logFileInfo.FileName); @@ -87,7 +89,7 @@ public string BuildArgs(ILogLine logLine, int lineNum, ILogFileInfo logFileInfo, end2 = builder.Length - 1; } string valueStr = builder.ToString().Substring(end + 2, end2 - end - 2); - values = valueStr.Split(new char[] {','}, StringSplitOptions.None); + values = valueStr.Split(new char[] { ',' }, StringSplitOptions.None); end = end2; } diff --git a/src/LogExpert/Classes/Filter/Filter.cs b/src/LogExpert/Classes/Filter/Filter.cs index c65ddef8..3db9ec01 100644 --- a/src/LogExpert/Classes/Filter/Filter.cs +++ b/src/LogExpert/Classes/Filter/Filter.cs @@ -1,4 +1,6 @@ using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Filter; using NLog; @@ -24,6 +26,7 @@ internal class Filter #region cTor + //TODO Is the callback needed? public Filter(ColumnizerCallback callback) { _callback = callback; diff --git a/src/LogExpert/Classes/Filter/FilterCancelHandler.cs b/src/LogExpert/Classes/Filter/FilterCancelHandler.cs index ef11b340..9db7932d 100644 --- a/src/LogExpert/Classes/Filter/FilterCancelHandler.cs +++ b/src/LogExpert/Classes/Filter/FilterCancelHandler.cs @@ -1,4 +1,5 @@ -using LogExpert.Interface; +using LogExpert.Core.Interface; + using NLog; namespace LogExpert.Classes.Filter diff --git a/src/LogExpert/Classes/Filter/FilterPipe.cs b/src/LogExpert/Classes/Filter/FilterPipe.cs index 3d679795..d31f5cac 100644 --- a/src/LogExpert/Classes/Filter/FilterPipe.cs +++ b/src/LogExpert/Classes/Filter/FilterPipe.cs @@ -1,13 +1,16 @@ +using LogExpert.Controls.LogWindow; +using LogExpert.Core.Classes.Filter; + +using NLog; + using System; using System.Collections.Generic; using System.IO; using System.Text; -using LogExpert.Controls.LogWindow; -using NLog; namespace LogExpert.Classes.Filter { - internal class FilterPipe + public class FilterPipe { #region Fields diff --git a/src/LogExpert/Classes/Filter/FilterStarter.cs b/src/LogExpert/Classes/Filter/FilterStarter.cs index 9ce8d025..71efb9ff 100644 --- a/src/LogExpert/Classes/Filter/FilterStarter.cs +++ b/src/LogExpert/Classes/Filter/FilterStarter.cs @@ -1,5 +1,8 @@ using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Classes.Filter; + using NLog; + using System; using System.Collections.Generic; using System.Threading; diff --git a/src/LogExpert/Classes/ILogLineColumnizerCallback/ColumnizerCallback.cs b/src/LogExpert/Classes/ILogLineColumnizerCallback/ColumnizerCallback.cs index 2abb7c4c..9a1504a3 100644 --- a/src/LogExpert/Classes/ILogLineColumnizerCallback/ColumnizerCallback.cs +++ b/src/LogExpert/Classes/ILogLineColumnizerCallback/ColumnizerCallback.cs @@ -1,9 +1,10 @@ -using System.Collections.Generic; -using LogExpert.Controls.LogWindow; +using LogExpert.Controls.LogWindow; + +using System.Collections.Generic; namespace LogExpert.Classes.ILogLineColumnizerCallback { - internal class ColumnizerCallback : LogExpert.ILogLineColumnizerCallback, IAutoLogLineColumnizerCallback + public class ColumnizerCallback : LogExpert.ILogLineColumnizerCallback, IAutoLogLineColumnizerCallback { #region Fields @@ -56,7 +57,7 @@ public ILogLine GetLogLine(int lineNum) public IList GetRegisteredColumnizers() { - return PluginRegistry.Instance.RegisteredColumnizers; + return PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers; } public int GetLineCount() diff --git a/src/LogExpert/Classes/ILogLineColumnizerCallback/LogExpertCallback.cs b/src/LogExpert/Classes/ILogLineColumnizerCallback/LogExpertCallback.cs index 20a8c89d..914f3c32 100644 --- a/src/LogExpert/Classes/ILogLineColumnizerCallback/LogExpertCallback.cs +++ b/src/LogExpert/Classes/ILogLineColumnizerCallback/LogExpertCallback.cs @@ -1,5 +1,6 @@ -using System.Collections.Generic; -using LogExpert.Controls.LogWindow; +using LogExpert.Controls.LogWindow; + +using System.Collections.Generic; namespace LogExpert.Classes.ILogLineColumnizerCallback { diff --git a/src/LogExpert/Classes/Log/LogfileReader.cs b/src/LogExpert/Classes/Log/LogfileReader.cs index 521edf06..1633c70f 100644 --- a/src/LogExpert/Classes/Log/LogfileReader.cs +++ b/src/LogExpert/Classes/Log/LogfileReader.cs @@ -1,7 +1,9 @@ -using LogExpert.Classes.xml; -using LogExpert.Entities; -using LogExpert.Entities.EventArgs; -using LogExpert.Interface; +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Log; +using LogExpert.Core.Classes.xml; +using LogExpert.Core.Entities; +using LogExpert.Core.Entities.EventArgs; +using LogExpert.Core.Interface; using NLog; @@ -694,7 +696,7 @@ public IList GetBufferList() #if DEBUG - internal void LogBufferInfoForLine(int lineNum) + public void LogBufferInfoForLine(int lineNum) { AcquireBufferListReaderLock(); LogBuffer buffer = GetBufferForLine(lineNum); @@ -717,7 +719,7 @@ internal void LogBufferInfoForLine(int lineNum) #endif #if DEBUG - internal void LogBufferDiagnostic() + public void LogBufferDiagnostic() { _logger.Info("-------- Buffer diagnostics -------"); _lruCacheDictLock.AcquireReaderLock(Timeout.Infinite); @@ -849,7 +851,8 @@ private void CloseFiles() private ILogFileInfo GetLogFileInfo(string fileNameOrUri) { - IFileSystemPlugin fs = PluginRegistry.Instance.FindFileSystemForUri(fileNameOrUri) ?? throw new LogFileException("No file system plugin found for " + fileNameOrUri); + //TODO this must be fixed and should be given to the logfilereader not just called + IFileSystemPlugin fs = PluginRegistry.PluginRegistry.Instance.FindFileSystemForUri(fileNameOrUri) ?? throw new LogFileException("No file system plugin found for " + fileNameOrUri); ILogFileInfo logFileInfo = fs.GetLogfileInfo(fileNameOrUri); return logFileInfo ?? throw new LogFileException("Cannot find " + fileNameOrUri); } diff --git a/src/LogExpert/Classes/Log/RolloverFilenameHandler.cs b/src/LogExpert/Classes/Log/RolloverFilenameHandler.cs index 00553c35..3909c737 100644 --- a/src/LogExpert/Classes/Log/RolloverFilenameHandler.cs +++ b/src/LogExpert/Classes/Log/RolloverFilenameHandler.cs @@ -1,5 +1,7 @@ -using System.Collections.Generic; -using LogExpert.Entities; +using LogExpert.Core.Classes.Log; +using LogExpert.Core.Entities; + +using System.Collections.Generic; namespace LogExpert.Classes.Log { @@ -99,7 +101,7 @@ public LinkedList GetNameList() private bool FileExists(string filePath) { - IFileSystemPlugin fs = PluginRegistry.Instance.FindFileSystemForUri(filePath); + IFileSystemPlugin fs = PluginRegistry.PluginRegistry.Instance.FindFileSystemForUri(filePath); ILogFileInfo info = fs.GetLogfileInfo(filePath); return info.FileExists; } diff --git a/src/LogExpert/Classes/LogExpertApplicationContext.cs b/src/LogExpert/Classes/LogExpertApplicationContext.cs index 0a6b49f4..b0a2af95 100644 --- a/src/LogExpert/Classes/LogExpertApplicationContext.cs +++ b/src/LogExpert/Classes/LogExpertApplicationContext.cs @@ -1,5 +1,6 @@ using System; using System.Windows.Forms; + using LogExpert.Controls.LogTabWindow; namespace LogExpert.Classes diff --git a/src/LogExpert/Classes/LogExpertProxy.cs b/src/LogExpert/Classes/LogExpertProxy.cs index 9109a803..31513af7 100644 --- a/src/LogExpert/Classes/LogExpertProxy.cs +++ b/src/LogExpert/Classes/LogExpertProxy.cs @@ -1,11 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using LogExpert.Controls.LogTabWindow; +using LogExpert.Controls.LogTabWindow; using LogExpert.Grpc; using LogExpert.Interface; + using NLog; +using System; +using System.Collections.Generic; +using System.Windows.Forms; + namespace LogExpert.Classes { internal class LogExpertProxy : LogExpertService.LogExpertServiceBase, ILogExpertProxy @@ -127,7 +129,7 @@ public void WindowClosed(LogTabWindow logWin) if (_windowList.Count == 0) { _logger.Info("Last LogTabWindow was closed"); - PluginRegistry.Instance.CleanupPlugins(); + PluginRegistry.PluginRegistry.Instance.CleanupPlugins(); OnLastWindowClosed(); } else diff --git a/src/LogExpert/Classes/PaintHelper.cs b/src/LogExpert/Classes/PaintHelper.cs index 043f921a..72461705 100644 --- a/src/LogExpert/Classes/PaintHelper.cs +++ b/src/LogExpert/Classes/PaintHelper.cs @@ -1,8 +1,9 @@ -using LogExpert.Classes.Highlight; -using LogExpert.Config; +using LogExpert.Config; +using LogExpert.Core.Classes.Highlight; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.Interface; using LogExpert.Dialogs; -using LogExpert.Entities; -using LogExpert.Interface; using NLog; @@ -63,7 +64,7 @@ public static void CellPainting(ILogPaintContext logPaintCtx, DataGridView gridV } else { - Color bgColor = LogExpert.Config.ColorMode.DockBackgroundColor; + Color bgColor = ColorMode.DockBackgroundColor; if (!DebugOptions.disableWordHighlight) { if (entry != null) @@ -93,7 +94,7 @@ public static void CellPainting(ILogPaintContext logPaintCtx, DataGridView gridV if (e.ColumnIndex == 0) { - Entities.Bookmark bookmark = logPaintCtx.GetBookmarkForLine(rowIndex); + Bookmark bookmark = logPaintCtx.GetBookmarkForLine(rowIndex); if (bookmark != null) { Rectangle r; // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); diff --git a/src/LogExpert/Classes/RangeFinder.cs b/src/LogExpert/Classes/RangeFinder.cs index bf9c456a..30ee6590 100644 --- a/src/LogExpert/Classes/RangeFinder.cs +++ b/src/LogExpert/Classes/RangeFinder.cs @@ -1,6 +1,8 @@ -using LogExpert.Classes.Filter; -using LogExpert.Classes.ILogLineColumnizerCallback; -using LogExpert.Entities; +using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Filter; +using LogExpert.Core.Entities; + using NLog; namespace LogExpert.Classes @@ -8,7 +10,7 @@ namespace LogExpert.Classes /// /// Delivers the range (from..to) that matches the current range filter settings starting from a given line. /// - internal class RangeFinder + public class RangeFinder { #region Fields diff --git a/src/LogExpert/Classes/TimeSyncList.cs b/src/LogExpert/Classes/TimeSyncList.cs index 32ae2199..a5d40d34 100644 --- a/src/LogExpert/Classes/TimeSyncList.cs +++ b/src/LogExpert/Classes/TimeSyncList.cs @@ -1,13 +1,14 @@ -using System; +using LogExpert.Controls.LogWindow; + +using System; using System.Collections.Generic; -using LogExpert.Controls.LogWindow; namespace LogExpert.Classes { /// /// Holds all windows which are in sync via timestamp /// - internal class TimeSyncList + public class TimeSyncList { #region Fields @@ -33,7 +34,7 @@ internal class TimeSyncList public int Count { - get { return this.logWindowList.Count; } + get { return logWindowList.Count; } } #endregion @@ -42,11 +43,11 @@ public int Count public void AddWindow(LogWindow logWindow) { - lock (this.logWindowList) + lock (logWindowList) { - if (!this.logWindowList.Contains(logWindow)) + if (!logWindowList.Contains(logWindow)) { - this.logWindowList.Add(logWindow); + logWindowList.Add(logWindow); } } } @@ -54,9 +55,9 @@ public void AddWindow(LogWindow logWindow) public void RemoveWindow(LogWindow logWindow) { - lock (this.logWindowList) + lock (logWindowList) { - this.logWindowList.Remove(logWindow); + logWindowList.Remove(logWindow); } OnWindowRemoved(); } @@ -69,10 +70,10 @@ public void RemoveWindow(LogWindow logWindow) /// public void NavigateToTimestamp(DateTime timestamp, LogWindow sender) { - this.CurrentTimestamp = timestamp; - lock (this.logWindowList) + CurrentTimestamp = timestamp; + lock (logWindowList) { - foreach (LogWindow logWindow in this.logWindowList) + foreach (LogWindow logWindow in logWindowList) { if (sender != logWindow) { @@ -85,7 +86,7 @@ public void NavigateToTimestamp(DateTime timestamp, LogWindow sender) public bool Contains(LogWindow logWindow) { - return this.logWindowList.Contains(logWindow); + return logWindowList.Contains(logWindow); } #endregion diff --git a/src/LogExpert/Config/ConfigManager.cs b/src/LogExpert/Config/ConfigManager.cs index 96639027..e9ca5d2d 100644 --- a/src/LogExpert/Config/ConfigManager.cs +++ b/src/LogExpert/Config/ConfigManager.cs @@ -1,7 +1,8 @@ -using LogExpert.Classes; -using LogExpert.Classes.Filter; -using LogExpert.Entities; -using LogExpert.Entities.EventArgs; +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Filter; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.Entities.EventArgs; using Newtonsoft.Json; @@ -42,7 +43,7 @@ private ConfigManager() #region Events - internal event ConfigChangedEventHandler ConfigChanged; + public event ConfigChangedEventHandler ConfigChanged; #endregion @@ -432,6 +433,6 @@ protected void OnConfigChanged(SettingsFlags flags) } } - internal delegate void ConfigChangedEventHandler(object sender, ConfigChangedEventArgs e); + public delegate void ConfigChangedEventHandler(object sender, ConfigChangedEventArgs e); } } \ No newline at end of file diff --git a/src/LogExpert/Controls/LogTabPage.cs b/src/LogExpert/Controls/LogTabPage.cs index f679937f..0f8ea3c4 100644 --- a/src/LogExpert/Controls/LogTabPage.cs +++ b/src/LogExpert/Controls/LogTabPage.cs @@ -1,8 +1,9 @@ +using LogExpert.Core.Classes; +using LogExpert.Core.Entities; + using System; using System.Threading; using System.Windows.Forms; -using LogExpert.Classes; -using LogExpert.Entities; namespace LogExpert.Controls { @@ -11,8 +12,8 @@ internal class LogTabPage : TabPage #region Fields private const int DIFF_MAX = 100; - private int diffSum = 0; - private readonly object diffSumLock = new(); + private int _diffSum = 0; + private readonly object _diffSumLock = new(); private readonly Thread ledThread; private bool shouldStop = false; @@ -21,19 +22,16 @@ internal class LogTabPage : TabPage #region cTor public LogTabPage(LogWindow.LogWindow logWindow, string title) - : base("MMi" + (title == null ? Util.GetNameFromPath(logWindow.FileName) : title)) + : base("MMi" + (title ?? Util.GetNameFromPath(logWindow.FileName))) { - this.TabTitle = title; - if (this.TabTitle == null) - { - this.TabTitle = Util.GetNameFromPath(logWindow.FileName); - } - this.LogWindow = logWindow; - this.LogWindow.FileSizeChanged += FileSizeChanged; - this.LogWindow.TailFollowed += TailFollowed; - this.ledThread = new Thread(new ThreadStart(this.LedThreadProc)); - this.ledThread.IsBackground = true; - this.ledThread.Start(); + TabTitle = title; + TabTitle ??= Util.GetNameFromPath(logWindow.FileName); + LogWindow = logWindow; + LogWindow.FileSizeChanged += FileSizeChanged; + LogWindow.TailFollowed += TailFollowed; + ledThread = new Thread(new ThreadStart(LedThreadProc)); + ledThread.IsBackground = true; + ledThread.Start(); } #endregion @@ -47,9 +45,9 @@ public int LineDiff { get { - lock (this.diffSumLock) + lock (_diffSumLock) { - return this.diffSum; + return _diffSum; } } } @@ -66,9 +64,9 @@ public int LineDiff public void Delete() { - this.shouldStop = true; - this.ledThread.Interrupt(); - this.ledThread.Join(); + shouldStop = true; + ledThread.Interrupt(); + ledThread.Join(); } #endregion @@ -77,7 +75,7 @@ public void Delete() private void LedThreadProc() { - while (!this.shouldStop) + while (!shouldStop) { try { @@ -87,19 +85,17 @@ private void LedThreadProc() { return; } - lock (this.diffSumLock) + lock (_diffSumLock) { - if (this.diffSum > 0) + if (_diffSum > 0) { - this.diffSum -= 10; - if (this.diffSum < 0) + _diffSum -= 10; + if (_diffSum < 0) { - this.diffSum = 0; - } - if (Parent != null) - { - Parent.Invalidate(); // redraw LEDs + _diffSum = 0; } + + Parent?.Invalidate(); // redraw LEDs } } } @@ -117,12 +113,12 @@ private void FileSizeChanged(object sender, LogEventArgs e) diff = DIFF_MAX; return; } - lock (this.diffSumLock) + lock (_diffSumLock) { - this.diffSum = this.diffSum + diff; - if (this.diffSum > DIFF_MAX) + _diffSum += diff; + if (_diffSum > DIFF_MAX) { - this.diffSum = DIFF_MAX; + _diffSum = DIFF_MAX; } } Dirty = true; @@ -131,7 +127,7 @@ private void FileSizeChanged(object sender, LogEventArgs e) private void TailFollowed(object sender, EventArgs e) { - if (this.IsActiveTab) + if (IsActiveTab) { Dirty = false; Parent.Invalidate(); diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs index b4ef9427..70d14d9d 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs @@ -1,6 +1,7 @@ using LogExpert.Config; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; using LogExpert.Dialogs; -using LogExpert.Entities; using LogExpert.Extensions.Forms; using LogExpert.Interface; @@ -17,7 +18,7 @@ namespace LogExpert.Controls.LogTabWindow { - internal partial class LogTabWindow : Form + public partial class LogTabWindow : Form { #region Fields @@ -162,7 +163,7 @@ public LogTabWindow(string[] fileNames, int instanceNumber, bool showInstanceNum #region ColorTheme public void ChangeTheme(Control.ControlCollection container) { - ColorMode.LoadColorMode(); + ColorMode.LoadColorMode(ConfigManager.Settings.Preferences.darkMode); ColorMode.UseImmersiveDarkMode(Handle, ColorMode.DarkModeEnabled); #region ApplyColorToAllControls diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs index 8f879281..76eedf44 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs @@ -1,4 +1,6 @@ using System.Windows.Forms; + +using LogExpert.Core.Enums; using LogExpert.Dialogs; using LogExpert.Extensions.Forms; @@ -1119,7 +1121,7 @@ private void InitializeComponent() dragControlDateTime.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; dragControlDateTime.BackColor = System.Drawing.SystemColors.Control; dragControlDateTime.DateTime = new System.DateTime(0L); - dragControlDateTime.DragOrientation = DateTimeDragControl.DragOrientations.Vertical; + dragControlDateTime.DragOrientation = DragOrientationsEnum.Vertical; dragControlDateTime.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0); dragControlDateTime.ForeColor = System.Drawing.SystemColors.ControlDarkDark; dragControlDateTime.HoverColor = System.Drawing.Color.LightGray; diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs index 598f9804..7b837155 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs @@ -1,8 +1,10 @@ -using LogExpert.Classes; -using LogExpert.Classes.Persister; -using LogExpert.Config; +using LogExpert.Config; +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Persister; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.Entities.EventArgs; using LogExpert.Dialogs; -using LogExpert.Entities; using LogExpert.Entities.EventArgs; using LogExpert.UI.Dialogs; @@ -19,7 +21,7 @@ namespace LogExpert.Controls.LogTabWindow { - internal partial class LogTabWindow + public partial class LogTabWindow { #region Events handler @@ -156,7 +158,7 @@ private void OnSelectFilterToolStripMenuItemClick(object sender, EventArgs e) } CurrentLogWindow.ColumnizerCallbackObject.LineNum = CurrentLogWindow.GetCurrentLineNum(); - FilterSelectorForm form = new(PluginRegistry.Instance.RegisteredColumnizers, CurrentLogWindow.CurrentColumnizer, CurrentLogWindow.ColumnizerCallbackObject); + FilterSelectorForm form = new(PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers, CurrentLogWindow.CurrentColumnizer, CurrentLogWindow.ColumnizerCallbackObject); form.Owner = this; form.TopMost = TopMost; DialogResult res = form.ShowDialog(); diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindowPrivate.cs index c3cfac92..723569da 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindowPrivate.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindowPrivate.cs @@ -1,10 +1,14 @@ using LogExpert.Classes; -using LogExpert.Classes.Columnizer; -using LogExpert.Classes.Persister; using LogExpert.Config; +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Classes.Persister; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.Entities.EventArgs; +using LogExpert.Core.Enums; using LogExpert.Dialogs; -using LogExpert.Entities; -using LogExpert.Entities.EventArgs; +using LogExpert.PluginRegistry.FileSystem; using System; using System.Collections.Generic; @@ -22,7 +26,7 @@ namespace LogExpert.Controls.LogTabWindow { - internal partial class LogTabWindow + public partial class LogTabWindow { #region Private Methods @@ -264,7 +268,7 @@ private string FindFilenameForSettings(string fileName) if (!string.IsNullOrEmpty(persistenceData.fileName)) { - IFileSystemPlugin fs = PluginRegistry.Instance.FindFileSystemForUri(persistenceData.fileName); + IFileSystemPlugin fs = PluginRegistry.PluginRegistry.Instance.FindFileSystemForUri(persistenceData.fileName); if (fs != null && !fs.GetType().Equals(typeof(LocalFileSystem))) { return persistenceData.fileName; @@ -330,7 +334,7 @@ private void ShowHighlightSettingsDialog() { HighlightDialog dlg = new() { - KeywordActionList = PluginRegistry.Instance.RegisteredKeywordActions, + KeywordActionList = PluginRegistry.PluginRegistry.Instance.RegisteredKeywordActions, Owner = this, TopMost = TopMost, HighlightGroupList = HilightGroupList, @@ -1073,8 +1077,7 @@ private void StartTool(string cmd, string args, bool sysoutPipe, string columniz if (sysoutPipe) { - ILogLineColumnizer columnizer = ColumnizerPicker.DecideColumnizerByName(columnizerName, - PluginRegistry.Instance.RegisteredColumnizers); + ILogLineColumnizer columnizer = ColumnizerPicker.DecideColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); _logger.Info("Starting external tool with sysout redirection: {0} {1}", cmd, args); startInfo.UseShellExecute = false; diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindowPublic.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindowPublic.cs index ec5d385a..7eed4fe2 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindowPublic.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindowPublic.cs @@ -1,4 +1,12 @@ -using System; +using LogExpert.Classes.Filter; +using LogExpert.Config; +using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Dialogs; +using LogExpert.Entities; + +using System; using System.Collections.Generic; using System.Drawing; using System.Runtime.InteropServices; @@ -6,17 +14,12 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; -using LogExpert.Classes; -using LogExpert.Classes.Columnizer; -using LogExpert.Classes.Filter; -using LogExpert.Config; -using LogExpert.Dialogs; -using LogExpert.Entities; + using WeifenLuo.WinFormsUI.Docking; namespace LogExpert.Controls.LogTabWindow { - internal partial class LogTabWindow + public partial class LogTabWindow { #region Public methods @@ -49,7 +52,7 @@ public LogWindow.LogWindow AddFileTabDeferred(string givenFileName, bool isTempF { return AddFileTab(givenFileName, isTempFile, title, forcePersistenceLoading, preProcessColumnizer, true); } - + public LogWindow.LogWindow AddFileTab(string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer, bool doNotAddToDockPanel = false) { string logFileName = FindFilenameForSettings(givenFileName); @@ -88,7 +91,7 @@ public LogWindow.LogWindow AddFileTab(string givenFileName, bool isTempFile, str AddToFileHistory(givenFileName); } - LogWindowData data = logWindow.Tag as LogWindowData; + LogWindowData data = logWindow.Tag as LogWindowData; data.color = _defaultTabColor; SetTabColor(logWindow, _defaultTabColor); //data.tabPage.BorderColor = this.defaultTabBorderColor; @@ -169,7 +172,7 @@ public ILogLineColumnizer GetColumnizerHistoryEntry(string fileName) ColumnizerHistoryEntry entry = FindColumnizerHistoryEntry(fileName); if (entry != null) { - foreach (ILogLineColumnizer columnizer in PluginRegistry.Instance.RegisteredColumnizers) + foreach (ILogLineColumnizer columnizer in PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers) { if (columnizer.GetName().Equals(entry.ColumnizerName)) { @@ -241,7 +244,7 @@ public ILogLineColumnizer FindColumnizerByFileMask(string fileName) { if (Regex.IsMatch(fileName, entry.mask)) { - ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(entry.columnizerName, PluginRegistry.Instance.RegisteredColumnizers); + ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(entry.columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); return columnizer; } } diff --git a/src/LogExpert/Controls/LogWindow/LogWindow.cs b/src/LogExpert/Controls/LogWindow/LogWindow.cs index cb7310d8..be90897d 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindow.cs @@ -1,16 +1,19 @@ using LogExpert.Classes; -using LogExpert.Classes.Bookmark; using LogExpert.Classes.Filter; -using LogExpert.Classes.Highlight; using LogExpert.Classes.ILogLineColumnizerCallback; using LogExpert.Classes.Log; -using LogExpert.Classes.Persister; using LogExpert.Config; +using LogExpert.Core.Classes.Bookmark; +using LogExpert.Core.Classes.Filter; +using LogExpert.Core.Classes.Highlight; +using LogExpert.Core.Classes.Persister; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.Entities.EventArgs; +using LogExpert.Core.Interface; using LogExpert.Dialogs; -using LogExpert.Entities; using LogExpert.Entities.EventArgs; using LogExpert.Extensions.Forms; -using LogExpert.Interface; using NLog; @@ -25,7 +28,7 @@ namespace LogExpert.Controls.LogWindow { - internal partial class LogWindow : DockContent, ILogPaintContext, ILogView + public partial class LogWindow : DockContent, ILogPaintContext, ILogView { #region Fields @@ -178,7 +181,7 @@ public LogWindow(LogTabWindow.LogTabWindow parent, string fileName, bool isTempF tableLayoutPanel1.ColumnStyles[0].Width = 100; _parentLogTabWin.HighlightSettingsChanged += OnParentHighlightSettingsChanged; - SetColumnizer(PluginRegistry.Instance.RegisteredColumnizers[0]); + SetColumnizer(PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers[0]); _patternArgs.maxMisses = 5; _patternArgs.minWeight = 1; diff --git a/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs index f6968434..f436f5b6 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs @@ -2,14 +2,19 @@ using LogExpert.Classes; using LogExpert.Classes.Filter; -using LogExpert.Classes.Highlight; using LogExpert.Classes.ILogLineColumnizerCallback; using LogExpert.Config; +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Filter; +using LogExpert.Core.Classes.Highlight; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.Entities.EventArgs; +using LogExpert.Core.Interface; using LogExpert.Dialogs; using LogExpert.Entities; using LogExpert.Entities.EventArgs; using LogExpert.Extensions; -using LogExpert.Interface; using LogExpert.UI.Dialogs; using System; @@ -22,7 +27,7 @@ namespace LogExpert.Controls.LogWindow { - internal partial class LogWindow + public partial class LogWindow { private void AutoResizeFilterBox() { @@ -792,11 +797,11 @@ private void OnDataGridContextMenuStripOpening(object sender, CancelEventArgs e) // Add plugin entries bool isAdded = false; - if (PluginRegistry.Instance.RegisteredContextMenuPlugins.Count > 0) + if (PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins.Count > 0) { //string line = this.logFileReader.GetLogLine(lineNum); IList lines = GetSelectedContent(); - foreach (IContextMenuEntry entry in PluginRegistry.Instance.RegisteredContextMenuPlugins) + foreach (IContextMenuEntry entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins) { LogExpertCallback callback = new(this); ContextMenuPluginEventArgs evArgs = new(entry, lines, CurrentColumnizer, callback); diff --git a/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs index cfbb7b65..1fdd4ba2 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs @@ -1,14 +1,18 @@ using LogExpert.Classes; -using LogExpert.Classes.Columnizer; using LogExpert.Classes.Filter; -using LogExpert.Classes.Highlight; using LogExpert.Classes.ILogLineColumnizerCallback; -using LogExpert.Classes.Persister; using LogExpert.Config; +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Classes.Filter; +using LogExpert.Core.Classes.Highlight; +using LogExpert.Core.Classes.Persister; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.Entities.EventArgs; +using LogExpert.Core.Interface; using LogExpert.Dialogs; -using LogExpert.Entities; -using LogExpert.Entities.EventArgs; -using LogExpert.Interface; +using LogExpert.Extensions; using System; using System.Collections.Generic; @@ -25,7 +29,7 @@ namespace LogExpert.Controls.LogWindow { - internal partial class LogWindow + public partial class LogWindow { #region Private Methods @@ -424,13 +428,19 @@ private void SetGuiAfterLoading() { if (_reloadMemento == null) { - columnizer = ColumnizerPicker.CloneColumnizer(columnizer); + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + + columnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); } } else { + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + // Default Columnizers - columnizer = ColumnizerPicker.CloneColumnizer(ColumnizerPicker.FindColumnizer(FileName, _logFileReader)); + columnizer = ColumnizerPicker.CloneColumnizer(ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers), directory); } } @@ -895,8 +905,7 @@ private void LaunchHighlightPlugins(IList matchingList, int lineNu { if (entry.IsActionEntry && entry.ActionEntry.PluginName != null) { - IKeywordAction plugin = - PluginRegistry.Instance.FindKeywordActionPluginByName(entry.ActionEntry.PluginName); + IKeywordAction plugin = PluginRegistry.PluginRegistry.Instance.FindKeywordActionPluginByName(entry.ActionEntry.PluginName); if (plugin != null) { ActionPluginExecuteFx fx = plugin.Execute; @@ -916,13 +925,13 @@ private void PreSelectColumnizer(ILogLineColumnizer columnizer) else { CurrentColumnizer = _forcedColumnizerForLoading = - ColumnizerPicker.FindColumnizer(FileName, _logFileReader); + ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); } } private void SetColumnizer(ILogLineColumnizer columnizer) { - columnizer = ColumnizerPicker.FindReplacementForAutoColumnizer(FileName, _logFileReader, columnizer); + columnizer = ColumnizerPicker.FindReplacementForAutoColumnizer(FileName, _logFileReader, columnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); int timeDiff = 0; if (CurrentColumnizer != null && CurrentColumnizer.IsTimeshiftImplemented()) @@ -2788,7 +2797,7 @@ private void FilterRestore(LogWindow newWin, PersistenceData persistenceData) { newWin.WaitForLoadingFinished(); ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(persistenceData.columnizerName, - PluginRegistry.Instance.RegisteredColumnizers); + PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); if (columnizer != null) { SetColumnizerFx fx = newWin.ForceColumnizer; @@ -3534,7 +3543,7 @@ private void MarkCurrentFilterRange() _filterParams.rangeSearchText = filterRangeComboBox.Text; ColumnizerCallback callback = new(this); RangeFinder rangeFinder = new(_filterParams, callback); - Entities.Range range = rangeFinder.FindRange(dataGridView.CurrentCellAddress.Y); + Core.Entities.Range range = rangeFinder.FindRange(dataGridView.CurrentCellAddress.Y); if (range != null) { SetCellSelectionMode(false); diff --git a/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs b/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs index d1298c77..957188fe 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs @@ -1,13 +1,17 @@ using LogExpert.Classes; -using LogExpert.Classes.Bookmark; -using LogExpert.Classes.Columnizer; using LogExpert.Classes.Filter; -using LogExpert.Classes.Highlight; using LogExpert.Classes.Log; -using LogExpert.Classes.Persister; using LogExpert.Config; -using LogExpert.Entities; -using LogExpert.Entities.EventArgs; +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Bookmark; +using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Classes.Filter; +using LogExpert.Core.Classes.Highlight; +using LogExpert.Core.Classes.Persister; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.Entities.EventArgs; + using System; using System.Collections.Generic; using System.Drawing; @@ -18,7 +22,7 @@ namespace LogExpert.Controls.LogWindow { - internal partial class LogWindow + public partial class LogWindow { #region Public methods @@ -56,7 +60,10 @@ public void LoadFile(string fileName, EncodingOptions encodingOptions) { if (_reloadMemento == null) { - columnizer = ColumnizerPicker.CloneColumnizer(columnizer); + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + + columnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); } } else @@ -121,7 +128,7 @@ public void LoadFile(string fileName, EncodingOptions encodingOptions) { if (Preferences.autoPick) { - ILogLineColumnizer newColumnizer = ColumnizerPicker.FindBetterColumnizer(FileName, _logFileReader, CurrentColumnizer); + ILogLineColumnizer newColumnizer = ColumnizerPicker.FindBetterColumnizer(FileName, _logFileReader, CurrentColumnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); if (newColumnizer != null) { @@ -307,19 +314,28 @@ public void WaitForLoadingFinished() public void ForceColumnizer(ILogLineColumnizer columnizer) { - _forcedColumnizer = ColumnizerPicker.CloneColumnizer(columnizer); + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + + _forcedColumnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); SetColumnizer(_forcedColumnizer); } public void ForceColumnizerForLoading(ILogLineColumnizer columnizer) { - _forcedColumnizerForLoading = ColumnizerPicker.CloneColumnizer(columnizer); + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + + _forcedColumnizerForLoading = ColumnizerPicker.CloneColumnizer(columnizer, directory); } public void PreselectColumnizer(string columnizerName) { - ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(columnizerName, PluginRegistry.Instance.RegisteredColumnizers); - PreSelectColumnizer(ColumnizerPicker.CloneColumnizer(columnizer)); + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + + ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + PreSelectColumnizer(ColumnizerPicker.CloneColumnizer(columnizer, directory)); } public void ColumnizerConfigChanged() diff --git a/src/LogExpert/Controls/PatternWindow.cs b/src/LogExpert/Controls/PatternWindow.cs index d0c3b28d..eefc6d9c 100644 --- a/src/LogExpert/Controls/PatternWindow.cs +++ b/src/LogExpert/Controls/PatternWindow.cs @@ -1,9 +1,10 @@ -using System; +using LogExpert.Core.Classes; +using LogExpert.Core.Entities.EventArgs; + +using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; -using LogExpert.Classes; -using LogExpert.Entities.EventArgs; namespace LogExpert.Controls { @@ -31,7 +32,7 @@ public PatternWindow(LogWindow.LogWindow logWindow) { this.logWindow = logWindow; InitializeComponent(); - this.recalcButton.Enabled = false; + recalcButton.Enabled = false; } #endregion @@ -40,26 +41,26 @@ public PatternWindow(LogWindow.LogWindow logWindow) public int Fuzzy { - set { this.fuzzyKnobControl.Value = value; } - get { return this.fuzzyKnobControl.Value; } + set { fuzzyKnobControl.Value = value; } + get { return fuzzyKnobControl.Value; } } public int MaxDiff { - set { this.maxDiffKnobControl.Value = value; } - get { return this.maxDiffKnobControl.Value; } + set { maxDiffKnobControl.Value = value; } + get { return maxDiffKnobControl.Value; } } public int MaxMisses { - set { this.maxMissesKnobControl.Value = value; } - get { return this.maxMissesKnobControl.Value; } + set { maxMissesKnobControl.Value = value; } + get { return maxMissesKnobControl.Value; } } public int Weight { - set { this.weigthKnobControl.Value = value; } - get { return this.weigthKnobControl.Value; } + set { weigthKnobControl.Value = value; } + get { return weigthKnobControl.Value; } } #endregion @@ -93,17 +94,17 @@ public void SetBlockList(List flatBlockList, PatternArgs patternAr // singeList.Add(block); //} } - this.blockList.Add(singeList); - this.Invoke(new MethodInvoker(SetBlockListGuiStuff)); + blockList.Add(singeList); + Invoke(new MethodInvoker(SetBlockListGuiStuff)); } public void SetColumnizer(ILogLineColumnizer columnizer) { - this.logWindow.SetColumnizer(columnizer, this.patternHitsDataGridView); - this.logWindow.SetColumnizer(columnizer, this.contentDataGridView); - this.patternHitsDataGridView.Columns[0].Width = 20; - this.contentDataGridView.Columns[0].Width = 20; + logWindow.SetColumnizer(columnizer, patternHitsDataGridView); + logWindow.SetColumnizer(columnizer, contentDataGridView); + patternHitsDataGridView.Columns[0].Width = 20; + contentDataGridView.Columns[0].Width = 20; DataGridViewTextBoxColumn blockInfoColumn = new(); blockInfoColumn.HeaderText = "Weight"; @@ -121,8 +122,8 @@ public void SetColumnizer(ILogLineColumnizer columnizer) contentInfoColumn.ReadOnly = true; contentInfoColumn.Width = 50; - this.patternHitsDataGridView.Columns.Insert(1, blockInfoColumn); - this.contentDataGridView.Columns.Insert(1, contentInfoColumn); + patternHitsDataGridView.Columns.Insert(1, blockInfoColumn); + contentDataGridView.Columns.Insert(1, contentInfoColumn); } public void SetFont(string fontName, float fontSize) @@ -131,11 +132,11 @@ public void SetFont(string fontName, float fontSize) int lineSpacing = font.FontFamily.GetLineSpacing(FontStyle.Regular); float lineSpacingPixel = font.Size * lineSpacing / font.FontFamily.GetEmHeight(FontStyle.Regular); - this.patternHitsDataGridView.DefaultCellStyle.Font = font; - this.contentDataGridView.DefaultCellStyle.Font = font; + patternHitsDataGridView.DefaultCellStyle.Font = font; + contentDataGridView.DefaultCellStyle.Font = font; //this.lineHeight = font.Height + 4; - this.patternHitsDataGridView.RowTemplate.Height = font.Height + 4; - this.contentDataGridView.RowTemplate.Height = font.Height + 4; + patternHitsDataGridView.RowTemplate.Height = font.Height + 4; + contentDataGridView.RowTemplate.Height = font.Height + 4; } #endregion @@ -144,25 +145,25 @@ public void SetFont(string fontName, float fontSize) private void SetBlockListGuiStuff() { - this.patternHitsDataGridView.RowCount = 0; - this.blockCountLabel.Text = "0"; - this.contentDataGridView.RowCount = 0; - this.blockLinesLabel.Text = "0"; - this.recalcButton.Enabled = true; - this.setRangeButton.Enabled = true; - if (this.blockList.Count > 0) + patternHitsDataGridView.RowCount = 0; + blockCountLabel.Text = "0"; + contentDataGridView.RowCount = 0; + blockLinesLabel.Text = "0"; + recalcButton.Enabled = true; + setRangeButton.Enabled = true; + if (blockList.Count > 0) { - SetCurrentList(this.blockList[0]); + SetCurrentList(blockList[0]); } } private void SetCurrentList(List patternList) { - this.patternHitsDataGridView.RowCount = 0; - this.currentList = patternList; - this.patternHitsDataGridView.RowCount = this.currentList.Count; - this.patternHitsDataGridView.Refresh(); - this.blockCountLabel.Text = "" + this.currentList.Count; + patternHitsDataGridView.RowCount = 0; + currentList = patternList; + patternHitsDataGridView.RowCount = currentList.Count; + patternHitsDataGridView.Refresh(); + blockCountLabel.Text = "" + currentList.Count; } private int GetLineForHitGrid(int rowIndex) @@ -185,7 +186,7 @@ private int GetLineForContentGrid(int rowIndex) private void patternHitsDataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { - if (this.currentList == null || e.RowIndex < 0) + if (currentList == null || e.RowIndex < 0) { return; } @@ -201,26 +202,26 @@ private void patternHitsDataGridView_CellValueNeeded(object sender, DataGridView { colIndex--; // correct the additional inserted col } - e.Value = this.logWindow.GetCellValue(rowIndex, colIndex); + e.Value = logWindow.GetCellValue(rowIndex, colIndex); } } private void patternHitsDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { - if (this.currentList == null || e.RowIndex < 0) + if (currentList == null || e.RowIndex < 0) { return; } if (e.ColumnIndex == 1) { e.PaintBackground(e.CellBounds, false); - int selCount = this.patternArgs.endLine - this.patternArgs.startLine; - int maxWeight = this.patternArgs.maxDiffInBlock * selCount + selCount; + int selCount = patternArgs.endLine - patternArgs.startLine; + int maxWeight = patternArgs.maxDiffInBlock * selCount + selCount; if (maxWeight > 0) { - int width = (int) ((double) (int) e.Value / (double) maxWeight * (double) e.CellBounds.Width); + int width = (int)((double)(int)e.Value / (double)maxWeight * (double)e.CellBounds.Width); Rectangle rect = new(e.CellBounds.X, e.CellBounds.Y, width, e.CellBounds.Height); - int alpha = 90 + (int) ((double) (int) e.Value / (double) maxWeight * (double) 165); + int alpha = 90 + (int)((double)(int)e.Value / (double)maxWeight * (double)165); Color color = Color.FromArgb(alpha, 170, 180, 150); Brush brush = new SolidBrush(color); rect.Inflate(-2, -1); @@ -232,9 +233,9 @@ private void patternHitsDataGridView_CellPainting(object sender, DataGridViewCel } else { - DataGridView gridView = (DataGridView) sender; + DataGridView gridView = (DataGridView)sender; int rowIndex = GetLineForHitGrid(e.RowIndex); - this.logWindow.CellPainting(gridView, rowIndex, e); + logWindow.CellPainting(gridView, rowIndex, e); } } @@ -249,25 +250,25 @@ private void patternHitsDataGridView_MouseDoubleClick(object sender, MouseEventA private void patternHitsDataGridView_CurrentCellChanged(object sender, EventArgs e) { - if (this.currentList == null || patternHitsDataGridView.CurrentRow == null) + if (currentList == null || patternHitsDataGridView.CurrentRow == null) { return; } - if (patternHitsDataGridView.CurrentRow.Index > this.currentList.Count - 1) + if (patternHitsDataGridView.CurrentRow.Index > currentList.Count - 1) { return; } - this.contentDataGridView.RowCount = 0; - this.currentBlock = this.currentList[patternHitsDataGridView.CurrentRow.Index]; - this.contentDataGridView.RowCount = this.currentBlock.targetEnd - this.currentBlock.targetStart + 1; - this.contentDataGridView.Refresh(); - this.contentDataGridView.CurrentCell = this.contentDataGridView.Rows[0].Cells[0]; - this.blockLinesLabel.Text = "" + this.contentDataGridView.RowCount; + contentDataGridView.RowCount = 0; + currentBlock = currentList[patternHitsDataGridView.CurrentRow.Index]; + contentDataGridView.RowCount = currentBlock.targetEnd - currentBlock.targetStart + 1; + contentDataGridView.Refresh(); + contentDataGridView.CurrentCell = contentDataGridView.Rows[0].Cells[0]; + blockLinesLabel.Text = "" + contentDataGridView.RowCount; } private void contentDataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { - if (this.currentBlock == null || e.RowIndex < 0) + if (currentBlock == null || e.RowIndex < 0) { return; } @@ -276,7 +277,7 @@ private void contentDataGridView_CellValueNeeded(object sender, DataGridViewCell if (colIndex == 1) { QualityInfo qi; - if (this.currentBlock.qualityInfoList.TryGetValue(rowIndex, out qi)) + if (currentBlock.qualityInfoList.TryGetValue(rowIndex, out qi)) { e.Value = qi.quality; } @@ -291,41 +292,41 @@ private void contentDataGridView_CellValueNeeded(object sender, DataGridViewCell { colIndex--; // adjust the inserted column } - e.Value = this.logWindow.GetCellValue(rowIndex, colIndex); + e.Value = logWindow.GetCellValue(rowIndex, colIndex); } } private void contentDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { - if (this.currentBlock == null || e.RowIndex < 0) + if (currentBlock == null || e.RowIndex < 0) { return; } - DataGridView gridView = (DataGridView) sender; + DataGridView gridView = (DataGridView)sender; int rowIndex = GetLineForContentGrid(e.RowIndex); - this.logWindow.CellPainting(gridView, rowIndex, e); + logWindow.CellPainting(gridView, rowIndex, e); } private void contentDataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { - if (this.currentBlock == null || contentDataGridView.CurrentRow == null) + if (currentBlock == null || contentDataGridView.CurrentRow == null) { return; } int rowIndex = GetLineForContentGrid(contentDataGridView.CurrentRow.Index); - this.logWindow.SelectLogLine(rowIndex); + logWindow.SelectLogLine(rowIndex); } private void recalcButton_Click(object sender, EventArgs e) { - patternArgs.fuzzy = this.fuzzyKnobControl.Value; - patternArgs.maxDiffInBlock = this.maxDiffKnobControl.Value; - patternArgs.maxMisses = this.maxMissesKnobControl.Value; - patternArgs.minWeight = this.weigthKnobControl.Value; - this.logWindow.PatternStatistic(patternArgs); - this.recalcButton.Enabled = false; - this.setRangeButton.Enabled = false; + patternArgs.fuzzy = fuzzyKnobControl.Value; + patternArgs.maxDiffInBlock = maxDiffKnobControl.Value; + patternArgs.maxMisses = maxMissesKnobControl.Value; + patternArgs.minWeight = weigthKnobControl.Value; + logWindow.PatternStatistic(patternArgs); + recalcButton.Enabled = false; + setRangeButton.Enabled = false; } private void closeButton_Click(object sender, EventArgs e) @@ -337,21 +338,21 @@ private void contentDataGridView_ColumnDividerDoubleClick(object sender, DataGridViewColumnDividerDoubleClickEventArgs e) { e.Handled = true; - this.contentDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + contentDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); } private void patternHitsDataGridView_ColumnDividerDoubleClick(object sender, DataGridViewColumnDividerDoubleClickEventArgs e) { e.Handled = true; - this.patternHitsDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + patternHitsDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); } private void setRangeButton_Click(object sender, EventArgs e) { - this.logWindow.PatternStatisticSelectRange(patternArgs); - this.recalcButton.Enabled = true; - this.rangeLabel.Text = "Start: " + patternArgs.startLine + "\r\nEnd: " + patternArgs.endLine; + logWindow.PatternStatisticSelectRange(patternArgs); + recalcButton.Enabled = true; + rangeLabel.Text = "Start: " + patternArgs.startLine + "\r\nEnd: " + patternArgs.endLine; } #endregion diff --git a/src/LogExpert/Dialogs/BookmarkWindow.cs b/src/LogExpert/Dialogs/BookmarkWindow.cs index 7f92cee5..5708b7e3 100644 --- a/src/LogExpert/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert/Dialogs/BookmarkWindow.cs @@ -1,13 +1,17 @@ -using System; +using LogExpert.Classes; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.Enums; +using LogExpert.Core.Interface; +using LogExpert.Extensions.Forms; + +using NLog; + +using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; -using LogExpert.Classes; -using LogExpert.Config; -using LogExpert.Entities; -using LogExpert.Extensions.Forms; -using LogExpert.Interface; -using NLog; + using WeifenLuo.WinFormsUI.Docking; namespace LogExpert.Dialogs @@ -51,27 +55,27 @@ public void ChangeTheme(Control.ControlCollection container) if (component.Controls != null && component.Controls.Count > 0) { ChangeTheme(component.Controls); - component.BackColor = LogExpert.Config.ColorMode.BackgroundColor; - component.ForeColor = LogExpert.Config.ColorMode.ForeColor; + component.BackColor = ColorMode.BackgroundColor; + component.ForeColor = ColorMode.ForeColor; } else { - component.BackColor = LogExpert.Config.ColorMode.BackgroundColor; - component.ForeColor = LogExpert.Config.ColorMode.ForeColor; + component.BackColor = ColorMode.BackgroundColor; + component.ForeColor = ColorMode.ForeColor; } } - #endregion + #endregion #region DataGridView - BackColor = LogExpert.Config.ColorMode.DockBackgroundColor; + BackColor = ColorMode.DockBackgroundColor; // Main DataGridView - bookmarkDataGridView.BackgroundColor = LogExpert.Config.ColorMode.DockBackgroundColor; - bookmarkDataGridView.ColumnHeadersDefaultCellStyle.BackColor = LogExpert.Config.ColorMode.BackgroundColor; - bookmarkDataGridView.ColumnHeadersDefaultCellStyle.ForeColor = LogExpert.Config.ColorMode.ForeColor; - bookmarkDataGridView.EnableHeadersVisualStyles = false; + bookmarkDataGridView.BackgroundColor = ColorMode.DockBackgroundColor; + bookmarkDataGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor; + bookmarkDataGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor; + bookmarkDataGridView.EnableHeadersVisualStyles = false; // Colors for menu contextMenuStrip1.Renderer = new ExtendedMenuStripRenderer(); @@ -79,9 +83,9 @@ public void ChangeTheme(Control.ControlCollection container) for (var y = 0; y < contextMenuStrip1.Items.Count; y++) { var item = contextMenuStrip1.Items[y]; - item.ForeColor = LogExpert.Config.ColorMode.ForeColor; - item.BackColor = LogExpert.Config.ColorMode.MenuBackgroundColor; - } + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.MenuBackgroundColor; + } #endregion DataGridView } @@ -248,7 +252,7 @@ protected override void OnPaint(PaintEventArgs e) if (!splitContainer1.Visible) { Rectangle r = ClientRectangle; - e.Graphics.FillRectangle(SystemBrushes.FromSystemColor(LogExpert.Config.ColorMode.BookmarksDefaultBackgroundColor), r); + e.Graphics.FillRectangle(SystemBrushes.FromSystemColor(ColorMode.BookmarksDefaultBackgroundColor), r); RectangleF rect = r; StringFormat sf = new(); sf.Alignment = StringAlignment.Center; @@ -276,10 +280,10 @@ private void SetFont(string fontName, float fontSize) private void CommentPainting(DataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) { - Color backColor = LogExpert.Config.ColorMode.DockBackgroundColor; + Color backColor = ColorMode.DockBackgroundColor; if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) - { + { Brush brush; if (gridView.Focused) { @@ -334,7 +338,7 @@ private void CurrentRowChanged(int rowIndex) // multiple selection or no selection at all bookmarkTextBox.Enabled = false; -// disable the control first so that changes made to it won't propagate to the bookmark item + // disable the control first so that changes made to it won't propagate to the bookmark item bookmarkTextBox.Text = string.Empty; } else @@ -384,7 +388,7 @@ private void boomarkDataGridView_CellPainting(object sender, DataGridViewCellPai // CommentPainting(this.bookmarkDataGridView, lineNum, e); // } { -// else + // else PaintHelper.CellPainting(logPaintContext, bookmarkDataGridView, lineNum, e); } } @@ -551,7 +555,7 @@ private void bookmarkDataGridView_CellDoubleClick(object sender, DataGridViewCel int lineNum = bookmarkData.Bookmarks[bookmarkDataGridView.CurrentRow.Index].LineNum; bookmarkData.ToggleBookmark(lineNum); -// we don't ask for confirmation if the bookmark has an associated comment... + // we don't ask for confirmation if the bookmark has an associated comment... int boomarkCount = bookmarkData.Bookmarks.Count; bookmarkDataGridView.RowCount = boomarkCount; @@ -666,7 +670,7 @@ private void BookmarkWindow_SizeChanged(object sender, EventArgs e) // { // // redraw the "no bookmarks" display // Invalidate(); - // } + // } } #endregion diff --git a/src/LogExpert/Dialogs/BufferedDataGridView.cs b/src/LogExpert/Dialogs/BufferedDataGridView.cs index 749c2c75..81bd8dc1 100644 --- a/src/LogExpert/Dialogs/BufferedDataGridView.cs +++ b/src/LogExpert/Dialogs/BufferedDataGridView.cs @@ -1,13 +1,12 @@ -using System; +using LogExpert.Core.Entities; + +using NLog; + +using System; using System.Collections.Generic; -using System.ComponentModel; using System.Drawing; -using System.Data; -using System.Text; -using System.Windows.Forms; using System.Drawing.Drawing2D; -using LogExpert.Entities; -using NLog; +using System.Windows.Forms; namespace LogExpert.Dialogs { @@ -37,7 +36,7 @@ public partial class BufferedDataGridView : DataGridView public BufferedDataGridView() { - _pen = new Pen(_bubbleColor, (float) 3.0); + _pen = new Pen(_bubbleColor, (float)3.0); _brush = new SolidBrush(_bubbleColor); InitializeComponent(); @@ -61,7 +60,7 @@ public BufferedDataGridView() #region Properties - /* + /* public Graphics Buffer { get { return this.myBuffer.Graphics; } @@ -112,7 +111,7 @@ protected override void OnEditingControlShowing(DataGridViewEditingControlShowin base.OnEditingControlShowing(e); e.Control.KeyDown -= OnControlKeyDown; e.Control.KeyDown += OnControlKeyDown; - DataGridViewTextBoxEditingControl editControl = (DataGridViewTextBoxEditingControl) e.Control; + DataGridViewTextBoxEditingControl editControl = (DataGridViewTextBoxEditingControl)e.Control; e.Control.PreviewKeyDown -= Control_PreviewKeyDown; e.Control.PreviewKeyDown += Control_PreviewKeyDown; @@ -249,7 +248,7 @@ private void PaintOverlays(PaintEventArgs e) { SizeF textSize = myBuffer.Graphics.MeasureString(overlay.Bookmark.Text, _font, 300); Rectangle rectBubble = new(overlay.Position, - new Size((int) textSize.Width, (int) textSize.Height)); + new Size((int)textSize.Width, (int)textSize.Height)); rectBubble.Offset(60, -(rectBubble.Height + 40)); rectBubble.Inflate(3, 3); rectBubble.Location += overlay.Bookmark.OverlayOffset; diff --git a/src/LogExpert/Dialogs/ChooseIconDlg.cs b/src/LogExpert/Dialogs/ChooseIconDlg.cs index 69a8c606..3e9ffba0 100644 --- a/src/LogExpert/Dialogs/ChooseIconDlg.cs +++ b/src/LogExpert/Dialogs/ChooseIconDlg.cs @@ -1,8 +1,9 @@ -using System; +using LogExpert.Core.Classes; + +using System; using System.Drawing; -using System.Windows.Forms; using System.IO; -using LogExpert.Classes; +using System.Windows.Forms; namespace LogExpert.Dialogs { @@ -39,7 +40,7 @@ public ChooseIconDlg(string fileName) private void FillIconList() { iconListView.Items.Clear(); - + Icon[,] icons = Win32.ExtractIcons(FileName); if (icons == null) @@ -48,7 +49,7 @@ private void FillIconList() } ImageList imageList = new(); - + if (icons.GetLength(0) > 0) { imageList.ImageSize = icons[1, 0].Size; @@ -87,7 +88,7 @@ private void OnButtonChooseIconFileClick(object sender, EventArgs e) { OpenFileDialog dlg = new(); dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); - + if (string.IsNullOrEmpty(iconFileLabel.Text) == false) { FileInfo info = new(iconFileLabel.Text); @@ -108,7 +109,7 @@ private void OnButtonChooseIconFileClick(object sender, EventArgs e) private void OnOkButtonClick(object sender, EventArgs e) { IconIndex = iconListView.SelectedIndices.Count > 0 ? iconListView.SelectedIndices[0] : -1; - ; + DisposeIcons(); } diff --git a/src/LogExpert/Dialogs/DateTimeDragControl.cs b/src/LogExpert/Dialogs/DateTimeDragControl.cs index b424e4a2..cadc9b2c 100644 --- a/src/LogExpert/Dialogs/DateTimeDragControl.cs +++ b/src/LogExpert/Dialogs/DateTimeDragControl.cs @@ -1,4 +1,5 @@ -using LogExpert.Classes.DateTimeParser; +using LogExpert.Core.Classes.DateTimeParser; +using LogExpert.Core.Enums; using System; using System.Collections.Generic; @@ -30,7 +31,7 @@ public partial class DateTimeDragControl : UserControl private readonly StringFormat _digitsFormat = new(); private int _draggedDigit; - public DragOrientations dragOrientation = DragOrientations.Vertical; + public DragOrientationsEnum dragOrientation = DragOrientationsEnum.Vertical; private readonly ToolStripItem toolStripItemHorizontalDrag = new ToolStripMenuItem(); private readonly ToolStripItem toolStripItemVerticalDrag = new ToolStripMenuItem(); @@ -88,7 +89,7 @@ public DateTimeDragControl() public DateTime MaxDateTime { get; set; } = DateTime.MaxValue; - public DragOrientations DragOrientation + public DragOrientationsEnum DragOrientation { get => dragOrientation; set @@ -288,13 +289,6 @@ protected void OnValueDragged(EventArgs e) ValueDragged?.Invoke(this, e); } - public enum DragOrientations - { - Horizontal, - Vertical, - InvertedVertical - } - #region Contextual Menu private void BuildContextualMenu() @@ -321,9 +315,9 @@ private void BuildContextualMenu() private void UpdateContextMenu() { - toolStripItemHorizontalDrag.Enabled = DragOrientation != DragOrientations.Horizontal; - toolStripItemVerticalDrag.Enabled = DragOrientation != DragOrientations.Vertical; - toolStripItemVerticalInvertedDrag.Enabled = DragOrientation != DragOrientations.InvertedVertical; + toolStripItemHorizontalDrag.Enabled = DragOrientation != DragOrientationsEnum.Horizontal; + toolStripItemVerticalDrag.Enabled = DragOrientation != DragOrientationsEnum.Vertical; + toolStripItemVerticalInvertedDrag.Enabled = DragOrientation != DragOrientationsEnum.InvertedVertical; } private void OnContextMenuStripOpening(object sender, CancelEventArgs e) @@ -336,7 +330,7 @@ private void OnContextMenuStripOpening(object sender, CancelEventArgs e) private void OnToolStripItemHorizontalDragClick(object sender, EventArgs e) { - DragOrientation = DragOrientations.Horizontal; + DragOrientation = DragOrientationsEnum.Horizontal; toolStripItemHorizontalDrag.Enabled = false; toolStripItemVerticalDrag.Enabled = true; toolStripItemVerticalInvertedDrag.Enabled = true; @@ -344,7 +338,7 @@ private void OnToolStripItemHorizontalDragClick(object sender, EventArgs e) private void OnToolStripItemVerticalDragClick(object sender, EventArgs e) { - DragOrientation = DragOrientations.Vertical; + DragOrientation = DragOrientationsEnum.Vertical; toolStripItemHorizontalDrag.Enabled = true; toolStripItemVerticalDrag.Enabled = false; toolStripItemVerticalInvertedDrag.Enabled = true; @@ -352,7 +346,7 @@ private void OnToolStripItemVerticalDragClick(object sender, EventArgs e) private void OnToolStripItemVerticalInvertedDragClick(object sender, EventArgs e) { - DragOrientation = DragOrientations.InvertedVertical; + DragOrientation = DragOrientationsEnum.InvertedVertical; toolStripItemHorizontalDrag.Enabled = true; toolStripItemVerticalDrag.Enabled = true; toolStripItemVerticalInvertedDrag.Enabled = false; @@ -468,12 +462,12 @@ protected override void OnMouseMove(MouseEventArgs e) int diff; switch (DragOrientation) { - case DragOrientations.Vertical: + case DragOrientationsEnum.Vertical: { diff = _startMouseY - e.Y; break; } - case DragOrientations.InvertedVertical: + case DragOrientationsEnum.InvertedVertical: { diff = _startMouseY + e.Y; break; diff --git a/src/LogExpert/Dialogs/FilterColumnChooser.cs b/src/LogExpert/Dialogs/FilterColumnChooser.cs index dffb2a95..00162ed8 100644 --- a/src/LogExpert/Dialogs/FilterColumnChooser.cs +++ b/src/LogExpert/Dialogs/FilterColumnChooser.cs @@ -1,7 +1,8 @@ using System; using System.Drawing; using System.Windows.Forms; -using LogExpert.Classes.Filter; + +using LogExpert.Core.Classes.Filter; namespace LogExpert.Dialogs { diff --git a/src/LogExpert/Dialogs/HighlightDialog.cs b/src/LogExpert/Dialogs/HighlightDialog.cs index e57baf30..8d9d3491 100644 --- a/src/LogExpert/Dialogs/HighlightDialog.cs +++ b/src/LogExpert/Dialogs/HighlightDialog.cs @@ -1,6 +1,6 @@ -using LogExpert.Classes.Highlight; -using LogExpert.Config; -using LogExpert.Entities; +using LogExpert.Config; +using LogExpert.Core.Classes.Highlight; +using LogExpert.Core.Entities; using LogExpert.UI.Dialogs; using NLog; diff --git a/src/LogExpert/Dialogs/ImportSettingsDialog.cs b/src/LogExpert/Dialogs/ImportSettingsDialog.cs index 985d9d30..6b3c34b0 100644 --- a/src/LogExpert/Dialogs/ImportSettingsDialog.cs +++ b/src/LogExpert/Dialogs/ImportSettingsDialog.cs @@ -1,7 +1,8 @@ -using System; +using LogExpert.Core.Config; + +using System; using System.Drawing; using System.Windows.Forms; -using LogExpert.Config; namespace LogExpert.Dialogs { @@ -63,7 +64,7 @@ private void OnOkButtonClick(object sender, EventArgs e) { if (((CheckBox)ctl).Checked) { - ImportFlags |= (ExportImportFlags) long.Parse(ctl.Tag as string ?? string.Empty); + ImportFlags |= (ExportImportFlags)long.Parse(ctl.Tag as string ?? string.Empty); } } } diff --git a/src/LogExpert/Dialogs/KeywordActionDlg.cs b/src/LogExpert/Dialogs/KeywordActionDlg.cs index 43981c7c..0de5c80f 100644 --- a/src/LogExpert/Dialogs/KeywordActionDlg.cs +++ b/src/LogExpert/Dialogs/KeywordActionDlg.cs @@ -1,4 +1,4 @@ -using LogExpert.Classes.Highlight; +using LogExpert.Core.Classes.Highlight; using System; using System.Collections.Generic; diff --git a/src/LogExpert/Dialogs/OverlayEventArgs.cs b/src/LogExpert/Dialogs/OverlayEventArgs.cs index c2a9d0ca..27d6f877 100644 --- a/src/LogExpert/Dialogs/OverlayEventArgs.cs +++ b/src/LogExpert/Dialogs/OverlayEventArgs.cs @@ -1,5 +1,6 @@ -using System; -using LogExpert.Entities; +using LogExpert.Core.Entities; + +using System; namespace LogExpert.Dialogs { diff --git a/src/LogExpert/Dialogs/SettingsDialog.cs b/src/LogExpert/Dialogs/SettingsDialog.cs index e96346e9..fd826922 100644 --- a/src/LogExpert/Dialogs/SettingsDialog.cs +++ b/src/LogExpert/Dialogs/SettingsDialog.cs @@ -1,8 +1,10 @@ -using LogExpert.Classes; -using LogExpert.Classes.Columnizer; using LogExpert.Config; using LogExpert.Controls.LogTabWindow; -using LogExpert.Entities; +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.Enums; using System; using System.Collections.Generic; @@ -79,9 +81,9 @@ private void FillDialog() checkBoxFilterTail.Checked = Preferences.filterTail; checkBoxFollowTail.Checked = Preferences.followTail; - radioButtonHorizMouseDrag.Checked = Preferences.timestampControlDragOrientation == DateTimeDragControl.DragOrientations.Horizontal; - radioButtonVerticalMouseDrag.Checked = Preferences.timestampControlDragOrientation == DateTimeDragControl.DragOrientations.Vertical; - radioButtonVerticalMouseDragInverted.Checked = Preferences.timestampControlDragOrientation == DateTimeDragControl.DragOrientations.InvertedVertical; + radioButtonHorizMouseDrag.Checked = Preferences.timestampControlDragOrientation == DragOrientationsEnum.Horizontal; + radioButtonVerticalMouseDrag.Checked = Preferences.timestampControlDragOrientation == DragOrientationsEnum.Vertical; + radioButtonVerticalMouseDragInverted.Checked = Preferences.timestampControlDragOrientation == DragOrientationsEnum.InvertedVertical; checkBoxSingleInstance.Checked = Preferences.allowOnlyOneInstance; checkBoxOpenLastFiles.Checked = Preferences.openLastFiles; @@ -275,7 +277,7 @@ private void FillColumnizerForToolsList(ComboBox comboBox, string columnizerName { int selIndex = 0; comboBox.Items.Clear(); - IList columnizers = PluginRegistry.Instance.RegisteredColumnizers; + IList columnizers = PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers; foreach (ILogLineColumnizer columnizer in columnizers) { @@ -301,7 +303,7 @@ private void FillColumnizerList() DataGridViewTextBoxColumn textColumn = (DataGridViewTextBoxColumn)dataGridViewColumnizer.Columns[0]; - IList columnizers = PluginRegistry.Instance.RegisteredColumnizers; + IList columnizers = PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers; foreach (ILogLineColumnizer columnizer in columnizers) { @@ -324,7 +326,7 @@ private void FillColumnizerList() row.Cells.Add(cell); row.Cells[0].Value = maskEntry.mask; ILogLineColumnizer columnizer = ColumnizerPicker.DecideColumnizerByName(maskEntry.columnizerName, - PluginRegistry.Instance.RegisteredColumnizers); + PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); row.Cells[1].Value = columnizer.GetName(); dataGridViewColumnizer.Rows.Add(row); @@ -422,7 +424,7 @@ private void FillPluginList() { listBoxPlugin.Items.Clear(); - foreach (IContextMenuEntry entry in PluginRegistry.Instance.RegisteredContextMenuPlugins) + foreach (IContextMenuEntry entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins) { listBoxPlugin.Items.Add(entry); if (entry is ILogExpertPluginConfigurator configurator) @@ -431,7 +433,7 @@ private void FillPluginList() } } - foreach (IKeywordAction entry in PluginRegistry.Instance.RegisteredKeywordActions) + foreach (IKeywordAction entry in PluginRegistry.PluginRegistry.Instance.RegisteredKeywordActions) { listBoxPlugin.Items.Add(entry); if (entry is ILogExpertPluginConfigurator configurator) @@ -440,7 +442,7 @@ private void FillPluginList() } } - foreach (IFileSystemPlugin entry in PluginRegistry.Instance.RegisteredFileSystemPlugins) + foreach (IFileSystemPlugin entry in PluginRegistry.PluginRegistry.Instance.RegisteredFileSystemPlugins) { listBoxPlugin.Items.Add(entry); if (entry is ILogExpertPluginConfigurator configurator) @@ -456,7 +458,7 @@ private void SavePluginSettings() { _selectedPlugin?.HideConfigForm(); - foreach (IContextMenuEntry entry in PluginRegistry.Instance.RegisteredContextMenuPlugins) + foreach (IContextMenuEntry entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins) { if (entry is ILogExpertPluginConfigurator configurator) { @@ -464,7 +466,7 @@ private void SavePluginSettings() } } - foreach (IKeywordAction entry in PluginRegistry.Instance.RegisteredKeywordActions) + foreach (IKeywordAction entry in PluginRegistry.PluginRegistry.Instance.RegisteredKeywordActions) { if (entry is ILogExpertPluginConfigurator configurator) { @@ -622,15 +624,15 @@ private void OnBtnOkClick(object sender, EventArgs e) if (radioButtonVerticalMouseDrag.Checked) { - Preferences.timestampControlDragOrientation = DateTimeDragControl.DragOrientations.Vertical; + Preferences.timestampControlDragOrientation = DragOrientationsEnum.Vertical; } else if (radioButtonVerticalMouseDragInverted.Checked) { - Preferences.timestampControlDragOrientation = DateTimeDragControl.DragOrientations.InvertedVertical; + Preferences.timestampControlDragOrientation = DragOrientationsEnum.InvertedVertical; } else { - Preferences.timestampControlDragOrientation = DateTimeDragControl.DragOrientations.Horizontal; + Preferences.timestampControlDragOrientation = DragOrientationsEnum.Horizontal; } SaveColumnizerList(); diff --git a/src/LogExpert/Dialogs/TimeSpreadigControl.cs b/src/LogExpert/Dialogs/TimeSpreadigControl.cs index 56a888b4..e9a709ab 100644 --- a/src/LogExpert/Dialogs/TimeSpreadigControl.cs +++ b/src/LogExpert/Dialogs/TimeSpreadigControl.cs @@ -1,4 +1,5 @@ using LogExpert.Classes; +using LogExpert.Core.Classes; using NLog; diff --git a/src/LogExpert/Entities/DebugOptions.cs b/src/LogExpert/Entities/DebugOptions.cs deleted file mode 100644 index 683d20e8..00000000 --- a/src/LogExpert/Entities/DebugOptions.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace LogExpert.Entities -{ - internal class DebugOptions - { - #region Fields - - internal static bool disableWordHighlight = false; - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert/Entities/EventArgs/CurrentHighlightGroupChangedEventArgs.cs b/src/LogExpert/Entities/EventArgs/CurrentHighlightGroupChangedEventArgs.cs index b73c2719..1e8b164c 100644 --- a/src/LogExpert/Entities/EventArgs/CurrentHighlightGroupChangedEventArgs.cs +++ b/src/LogExpert/Entities/EventArgs/CurrentHighlightGroupChangedEventArgs.cs @@ -1,8 +1,9 @@ using LogExpert.Controls.LogWindow; +using LogExpert.Core.Entities; namespace LogExpert.Entities.EventArgs { - internal class CurrentHighlightGroupChangedEventArgs + public class CurrentHighlightGroupChangedEventArgs { #region Fields @@ -12,8 +13,8 @@ internal class CurrentHighlightGroupChangedEventArgs public CurrentHighlightGroupChangedEventArgs(LogWindow logWindow, HilightGroup currentGroup) { - this.LogWindow = logWindow; - this.CurrentGroup = currentGroup; + LogWindow = logWindow; + CurrentGroup = currentGroup; } #endregion diff --git a/src/LogExpert/Entities/EventArgs/FilterListChangedEventArgs.cs b/src/LogExpert/Entities/EventArgs/FilterListChangedEventArgs.cs index af23273b..e5df8ee3 100644 --- a/src/LogExpert/Entities/EventArgs/FilterListChangedEventArgs.cs +++ b/src/LogExpert/Entities/EventArgs/FilterListChangedEventArgs.cs @@ -2,7 +2,7 @@ namespace LogExpert.Entities.EventArgs { - internal class FilterListChangedEventArgs + public class FilterListChangedEventArgs { #region Fields @@ -12,7 +12,7 @@ internal class FilterListChangedEventArgs public FilterListChangedEventArgs(LogWindow logWindow) { - this.LogWindow = logWindow; + LogWindow = logWindow; } #endregion diff --git a/src/LogExpert/Entities/LogFileException.cs b/src/LogExpert/Entities/LogFileException.cs deleted file mode 100644 index 4bd1d5c5..00000000 --- a/src/LogExpert/Entities/LogFileException.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace LogExpert.Entities -{ - internal class LogFileException : ApplicationException - { - #region cTor - - internal LogFileException(string msg) - : base(msg) - { - } - - internal LogFileException(string msg, Exception inner) - : base(msg, inner) - { - } - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert/Entities/ReloadMemento.cs b/src/LogExpert/Entities/ReloadMemento.cs deleted file mode 100644 index 85037581..00000000 --- a/src/LogExpert/Entities/ReloadMemento.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace LogExpert.Entities -{ - internal class ReloadMemento - { - #region Fields - - internal int currentLine; - internal int firstDisplayedLine; - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert/Entities/WindowFileEntry.cs b/src/LogExpert/Entities/WindowFileEntry.cs index 604adbec..8a2074be 100644 --- a/src/LogExpert/Entities/WindowFileEntry.cs +++ b/src/LogExpert/Entities/WindowFileEntry.cs @@ -1,11 +1,13 @@ using LogExpert.Controls.LogWindow; +using System; + namespace LogExpert.Entities { /// /// Represents a log file and its window. Used as a kind of handle for menus or list of open files. /// - internal class WindowFileEntry + public class WindowFileEntry { #region Fields @@ -29,9 +31,10 @@ public string Title get { string title = LogWindow.Text; + if (title.Length > MAX_LEN) { - title = "..." + title.Substring(title.Length - MAX_LEN); + title = string.Concat("...", title.AsSpan(title.Length - MAX_LEN)); } return title; } diff --git a/src/LogExpert/Entities/WindowTypes.cs b/src/LogExpert/Entities/WindowTypes.cs deleted file mode 100644 index fa40e9e2..00000000 --- a/src/LogExpert/Entities/WindowTypes.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace LogExpert.Entities -{ - internal enum WindowTypes - { - BookmarkWindow, - LogWindow, - } -} \ No newline at end of file diff --git a/src/LogExpert/Extensions/Forms/LineToolStripSeparatorExtension.cs b/src/LogExpert/Extensions/Forms/LineToolStripSeparatorExtension.cs index a5239c73..92ca94dc 100644 --- a/src/LogExpert/Extensions/Forms/LineToolStripSeparatorExtension.cs +++ b/src/LogExpert/Extensions/Forms/LineToolStripSeparatorExtension.cs @@ -1,4 +1,6 @@ -using System.Drawing; +using LogExpert.Core.Config; + +using System.Drawing; using System.Windows.Forms; namespace LogExpert.Extensions.Forms @@ -19,9 +21,9 @@ private void OnExtendedToolStripSeparatorPaint(object sender, PaintEventArgs e) // Choose the colors for drawing. // I've used Color.White as the foreColor. - Color foreColor = Config.ColorMode.ForeColor; + Color foreColor = ColorMode.ForeColor; // Color.Teal as the backColor. - Color backColor = Config.ColorMode.BackgroundColor; + Color backColor = ColorMode.BackgroundColor; // Fill the background. using SolidBrush backbrush = new(backColor); diff --git a/src/LogExpert/Extensions/Forms/MenuSelectedColors.cs b/src/LogExpert/Extensions/Forms/MenuSelectedColors.cs index 862a84e0..aaaa5565 100644 --- a/src/LogExpert/Extensions/Forms/MenuSelectedColors.cs +++ b/src/LogExpert/Extensions/Forms/MenuSelectedColors.cs @@ -1,30 +1,32 @@ -using System.Drawing; +using LogExpert.Core.Config; + +using System.Drawing; using System.Windows.Forms; namespace LogExpert.Extensions.Forms { public class MenuSelectedColors : ProfessionalColorTable { - public override Color ImageMarginGradientBegin => Config.ColorMode.MenuBackgroundColor; + public override Color ImageMarginGradientBegin => ColorMode.MenuBackgroundColor; - public override Color ImageMarginGradientMiddle => Config.ColorMode.MenuBackgroundColor; + public override Color ImageMarginGradientMiddle => ColorMode.MenuBackgroundColor; - public override Color ImageMarginGradientEnd => Config.ColorMode.MenuBackgroundColor; + public override Color ImageMarginGradientEnd => ColorMode.MenuBackgroundColor; - public override Color ToolStripDropDownBackground => Config.ColorMode.MenuBackgroundColor; + public override Color ToolStripDropDownBackground => ColorMode.MenuBackgroundColor; - public override Color MenuBorder => Config.ColorMode.MenuBackgroundColor; + public override Color MenuBorder => ColorMode.MenuBackgroundColor; - public override Color MenuItemBorder => Config.ColorMode.MenuBackgroundColor; + public override Color MenuItemBorder => ColorMode.MenuBackgroundColor; - public override Color MenuItemSelected => Config.ColorMode.HoverMenuBackgroundColor; + public override Color MenuItemSelected => ColorMode.HoverMenuBackgroundColor; - public override Color MenuItemSelectedGradientBegin => Config.ColorMode.HoverMenuBackgroundColor; + public override Color MenuItemSelectedGradientBegin => ColorMode.HoverMenuBackgroundColor; - public override Color MenuItemSelectedGradientEnd => Config.ColorMode.HoverMenuBackgroundColor; + public override Color MenuItemSelectedGradientEnd => ColorMode.HoverMenuBackgroundColor; - public override Color MenuItemPressedGradientBegin => Config.ColorMode.MenuBackgroundColor; + public override Color MenuItemPressedGradientBegin => ColorMode.MenuBackgroundColor; - public override Color MenuItemPressedGradientEnd => Config.ColorMode.MenuBackgroundColor; + public override Color MenuItemPressedGradientEnd => ColorMode.MenuBackgroundColor; } } \ No newline at end of file diff --git a/src/LogExpert/Extensions/Forms/MenuToolStripSeparatorExtension.cs b/src/LogExpert/Extensions/Forms/MenuToolStripSeparatorExtension.cs index bf1c666b..0137d680 100644 --- a/src/LogExpert/Extensions/Forms/MenuToolStripSeparatorExtension.cs +++ b/src/LogExpert/Extensions/Forms/MenuToolStripSeparatorExtension.cs @@ -1,4 +1,6 @@ -using System.Drawing; +using LogExpert.Core.Config; + +using System.Drawing; using System.Windows.Forms; namespace LogExpert.Extensions.Forms @@ -19,9 +21,9 @@ private void OnExtendedToolStripSeparatorPaint(object sender, PaintEventArgs e) // Choose the colors for drawing. // I've used Color.White as the foreColor. - Color foreColor = Config.ColorMode.ForeColor; + Color foreColor = ColorMode.ForeColor; // Color.Teal as the backColor. - Color backColor = Config.ColorMode.MenuBackgroundColor; + Color backColor = ColorMode.MenuBackgroundColor; // Fill the background. e.Graphics.FillRectangle(new SolidBrush(backColor), 0, 0, width, height); @@ -29,5 +31,5 @@ private void OnExtendedToolStripSeparatorPaint(object sender, PaintEventArgs e) // Draw the line. e.Graphics.DrawLine(new Pen(foreColor), 4, height / 2, width - 4, height / 2); } - } + } } diff --git a/src/LogExpert/Interface/ILogExpertProxy.cs b/src/LogExpert/Interface/ILogExpertProxy.cs index e9e0554f..313e50be 100644 --- a/src/LogExpert/Interface/ILogExpertProxy.cs +++ b/src/LogExpert/Interface/ILogExpertProxy.cs @@ -1,9 +1,8 @@ using LogExpert.Controls.LogTabWindow; -using LogExpert.Grpc; namespace LogExpert.Interface { - internal interface ILogExpertProxy + public interface ILogExpertProxy { #region Public methods diff --git a/src/LogExpert/LogExpert.csproj b/src/LogExpert/LogExpert.csproj index e50b597a..f21c6774 100644 --- a/src/LogExpert/LogExpert.csproj +++ b/src/LogExpert/LogExpert.csproj @@ -85,6 +85,7 @@ + diff --git a/src/LogExpert/Program.cs b/src/LogExpert/Program.cs index 5f7c6abb..d488fa57 100644 --- a/src/LogExpert/Program.cs +++ b/src/LogExpert/Program.cs @@ -4,6 +4,8 @@ using LogExpert.Classes; using LogExpert.Config; using LogExpert.Controls.LogTabWindow; +using LogExpert.Core.Classes; +using LogExpert.Core.Config; using LogExpert.Dialogs; using LogexpertGRPCService.Services; @@ -99,6 +101,7 @@ private static void Sub_Main(Server server, string[] orgArgs) MessageBox.Show(@"Config file not found", @"LogExpert"); } } + PluginRegistry.PluginRegistry.Instance.Create(ConfigManager.ConfigDir, ConfigManager.Settings.Preferences.pollingInterval); int pId = Process.GetCurrentProcess().SessionId; diff --git a/src/LogExpert/Classes/Bookmark/BookmarkDataProvider.cs b/src/Logexpert.Core/Classes/Bookmark/BookmarkDataProvider.cs similarity index 79% rename from src/LogExpert/Classes/Bookmark/BookmarkDataProvider.cs rename to src/Logexpert.Core/Classes/Bookmark/BookmarkDataProvider.cs index 8fb5cda4..253cd7d5 100644 --- a/src/LogExpert/Classes/Bookmark/BookmarkDataProvider.cs +++ b/src/Logexpert.Core/Classes/Bookmark/BookmarkDataProvider.cs @@ -1,177 +1,176 @@ -using System; -using System.Collections.Generic; -using LogExpert.Entities; -using LogExpert.Interface; -using NLog; - -namespace LogExpert.Classes.Bookmark -{ - internal class BookmarkDataProvider : IBookmarkData - { - #region Fields - - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - - #endregion - - #region cTor - - internal BookmarkDataProvider() - { - BookmarkList = []; - } - - internal BookmarkDataProvider(SortedList bookmarkList) - { - BookmarkList = bookmarkList; - } - - #endregion - - #region Delegates - - public delegate void AllBookmarksRemovedEventHandler(object sender, EventArgs e); - - public delegate void BookmarkAddedEventHandler(object sender, EventArgs e); - - public delegate void BookmarkRemovedEventHandler(object sender, EventArgs e); - - #endregion - - #region Events - - public event BookmarkAddedEventHandler BookmarkAdded; - public event BookmarkRemovedEventHandler BookmarkRemoved; - public event AllBookmarksRemovedEventHandler AllBookmarksRemoved; - - #endregion - - #region Properties - - public BookmarkCollection Bookmarks => new(BookmarkList); - - internal SortedList BookmarkList { get; set; } - - #endregion - - #region Public methods - - public void ToggleBookmark(int lineNum) - { - if (IsBookmarkAtLine(lineNum)) - { - RemoveBookmarkForLine(lineNum); - } - else - { - AddBookmark(new Entities.Bookmark(lineNum)); - } - } - - public bool IsBookmarkAtLine(int lineNum) - { - return BookmarkList.ContainsKey(lineNum); - } - - public int GetBookmarkIndexForLine(int lineNum) - { - return BookmarkList.IndexOfKey(lineNum); - } - - public Entities.Bookmark GetBookmarkForLine(int lineNum) - { - return BookmarkList[lineNum]; - } - - #endregion - - #region Internals - - internal void ShiftBookmarks(int offset) - { - SortedList newBookmarkList = []; - foreach (Entities.Bookmark bookmark in BookmarkList.Values) - { - int line = bookmark.LineNum - offset; - if (line >= 0) - { - bookmark.LineNum = line; - newBookmarkList.Add(line, bookmark); - } - } - BookmarkList = newBookmarkList; - } - - internal int FindPrevBookmarkIndex(int lineNum) - { - IList values = BookmarkList.Values; - for (int i = BookmarkList.Count - 1; i >= 0; --i) - { - if (values[i].LineNum <= lineNum) - { - return i; - } - } - return BookmarkList.Count - 1; - } - - internal int FindNextBookmarkIndex(int lineNum) - { - IList values = BookmarkList.Values; - for (int i = 0; i < BookmarkList.Count; ++i) - { - if (values[i].LineNum >= lineNum) - { - return i; - } - } - return 0; - } - - internal void RemoveBookmarkForLine(int lineNum) - { - BookmarkList.Remove(lineNum); - OnBookmarkRemoved(); - } - - internal void RemoveBookmarksForLines(List lineNumList) - { - foreach (int lineNum in lineNumList) - { - BookmarkList.Remove(lineNum); - } - OnBookmarkRemoved(); - } - - - internal void AddBookmark(Entities.Bookmark bookmark) - { - BookmarkList.Add(bookmark.LineNum, bookmark); - OnBookmarkAdded(); - } - - internal void ClearAllBookmarks() - { - _logger.Debug("Removing all bookmarks"); - BookmarkList.Clear(); - OnAllBookmarksRemoved(); - } - - #endregion - - protected void OnBookmarkAdded() - { - BookmarkAdded?.Invoke(this, EventArgs.Empty); - } - - protected void OnBookmarkRemoved() - { - BookmarkRemoved?.Invoke(this, EventArgs.Empty); - } - - protected void OnAllBookmarksRemoved() - { - AllBookmarksRemoved?.Invoke(this, EventArgs.Empty); - } - } +using LogExpert.Core.Entities; +using LogExpert.Core.Interface; + +using NLog; + +namespace LogExpert.Core.Classes.Bookmark +{ + public class BookmarkDataProvider : IBookmarkData + { + #region Fields + + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + + #endregion + + #region cTor + + public BookmarkDataProvider() + { + BookmarkList = []; + } + + public BookmarkDataProvider(SortedList bookmarkList) + { + BookmarkList = bookmarkList; + } + + #endregion + + #region Delegates + + public delegate void AllBookmarksRemovedEventHandler(object sender, EventArgs e); + + public delegate void BookmarkAddedEventHandler(object sender, EventArgs e); + + public delegate void BookmarkRemovedEventHandler(object sender, EventArgs e); + + #endregion + + #region Events + + public event BookmarkAddedEventHandler BookmarkAdded; + public event BookmarkRemovedEventHandler BookmarkRemoved; + public event AllBookmarksRemovedEventHandler AllBookmarksRemoved; + + #endregion + + #region Properties + + public BookmarkCollection Bookmarks => new(BookmarkList); + + public SortedList BookmarkList { get; set; } + + #endregion + + #region Public methods + + public void ToggleBookmark(int lineNum) + { + if (IsBookmarkAtLine(lineNum)) + { + RemoveBookmarkForLine(lineNum); + } + else + { + AddBookmark(new Entities.Bookmark(lineNum)); + } + } + + public bool IsBookmarkAtLine(int lineNum) + { + return BookmarkList.ContainsKey(lineNum); + } + + public int GetBookmarkIndexForLine(int lineNum) + { + return BookmarkList.IndexOfKey(lineNum); + } + + public Entities.Bookmark GetBookmarkForLine(int lineNum) + { + return BookmarkList[lineNum]; + } + + #endregion + + #region Internals + + public void ShiftBookmarks(int offset) + { + SortedList newBookmarkList = []; + foreach (Entities.Bookmark bookmark in BookmarkList.Values) + { + int line = bookmark.LineNum - offset; + if (line >= 0) + { + bookmark.LineNum = line; + newBookmarkList.Add(line, bookmark); + } + } + BookmarkList = newBookmarkList; + } + + public int FindPrevBookmarkIndex(int lineNum) + { + IList values = BookmarkList.Values; + for (int i = BookmarkList.Count - 1; i >= 0; --i) + { + if (values[i].LineNum <= lineNum) + { + return i; + } + } + return BookmarkList.Count - 1; + } + + public int FindNextBookmarkIndex(int lineNum) + { + IList values = BookmarkList.Values; + for (int i = 0; i < BookmarkList.Count; ++i) + { + if (values[i].LineNum >= lineNum) + { + return i; + } + } + return 0; + } + + public void RemoveBookmarkForLine(int lineNum) + { + BookmarkList.Remove(lineNum); + OnBookmarkRemoved(); + } + + public void RemoveBookmarksForLines(List lineNumList) + { + foreach (int lineNum in lineNumList) + { + BookmarkList.Remove(lineNum); + } + OnBookmarkRemoved(); + } + + + public void AddBookmark(Entities.Bookmark bookmark) + { + BookmarkList.Add(bookmark.LineNum, bookmark); + OnBookmarkAdded(); + } + + public void ClearAllBookmarks() + { + _logger.Debug("Removing all bookmarks"); + BookmarkList.Clear(); + OnAllBookmarksRemoved(); + } + + #endregion + + protected void OnBookmarkAdded() + { + BookmarkAdded?.Invoke(this, EventArgs.Empty); + } + + protected void OnBookmarkRemoved() + { + BookmarkRemoved?.Invoke(this, EventArgs.Empty); + } + + protected void OnAllBookmarksRemoved() + { + AllBookmarksRemoved?.Invoke(this, EventArgs.Empty); + } + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Bookmark/BookmarkExporter.cs b/src/Logexpert.Core/Classes/Bookmark/BookmarkExporter.cs similarity index 89% rename from src/LogExpert/Classes/Bookmark/BookmarkExporter.cs rename to src/Logexpert.Core/Classes/Bookmark/BookmarkExporter.cs index 5ce6b0f6..a3202798 100644 --- a/src/LogExpert/Classes/Bookmark/BookmarkExporter.cs +++ b/src/Logexpert.Core/Classes/Bookmark/BookmarkExporter.cs @@ -1,81 +1,78 @@ -using System.Collections.Generic; -using System.IO; - -namespace LogExpert.Classes.Bookmark -{ - internal static class BookmarkExporter - { - #region Fields - - private const string replacementForNewLine = @"\n"; - - #endregion - - #region Public methods - - public static void ExportBookmarkList(SortedList bookmarkList, string logfileName, - string fileName) - { - FileStream fs = new(fileName, FileMode.Create, FileAccess.Write); - StreamWriter writer = new(fs); - writer.WriteLine("Log file name;Line number;Comment"); - foreach (Entities.Bookmark bookmark in bookmarkList.Values) - { - string line = logfileName + ";" + bookmark.LineNum + ";" + - bookmark.Text.Replace(replacementForNewLine, @"\" + replacementForNewLine).Replace("\r\n", replacementForNewLine); - writer.WriteLine(line); - } - writer.Close(); - fs.Close(); - } - - public static void ImportBookmarkList(string logfileName, string fileName, - SortedList bookmarkList) - { - using (FileStream fs = new(fileName, FileMode.Open, FileAccess.Read)) - { - using (StreamReader reader = new(fs)) - { - if (!reader.EndOfStream) - { - reader.ReadLine(); // skip "Log file name;Line number;Comment" - } - - while (!reader.EndOfStream) - { - try - { - string line = reader.ReadLine(); - line = line.Replace(replacementForNewLine, "\r\n").Replace("\\\r\n", replacementForNewLine); - - // Line is formatted: logfileName ";" bookmark.LineNum ";" bookmark.Text; - int firstSeparator = line.IndexOf(';'); - int secondSeparator = line.IndexOf(';', firstSeparator + 1); - - string fileStr = line.Substring(0, firstSeparator); - string lineStr = line.Substring(firstSeparator + 1, secondSeparator - firstSeparator - 1); - string comment = line.Substring(secondSeparator + 1); - - int lineNum; - if (int.TryParse(lineStr, out lineNum)) - { - Entities.Bookmark bookmark = new(lineNum, comment); - bookmarkList.Add(lineNum, bookmark); - } - else - { - //!!!log error: skipping a line entry - } - } - catch - { - //!!! - } - } - } - } - } - - #endregion - } +namespace LogExpert.Core.Classes.Bookmark +{ + public static class BookmarkExporter + { + #region Fields + + private const string replacementForNewLine = @"\n"; + + #endregion + + #region Public methods + + public static void ExportBookmarkList(SortedList bookmarkList, string logfileName, + string fileName) + { + FileStream fs = new(fileName, FileMode.Create, FileAccess.Write); + StreamWriter writer = new(fs); + writer.WriteLine("Log file name;Line number;Comment"); + foreach (Entities.Bookmark bookmark in bookmarkList.Values) + { + string line = logfileName + ";" + bookmark.LineNum + ";" + + bookmark.Text.Replace(replacementForNewLine, @"\" + replacementForNewLine).Replace("\r\n", replacementForNewLine); + writer.WriteLine(line); + } + writer.Close(); + fs.Close(); + } + + public static void ImportBookmarkList(string logfileName, string fileName, + SortedList bookmarkList) + { + using (FileStream fs = new(fileName, FileMode.Open, FileAccess.Read)) + { + using (StreamReader reader = new(fs)) + { + if (!reader.EndOfStream) + { + reader.ReadLine(); // skip "Log file name;Line number;Comment" + } + + while (!reader.EndOfStream) + { + try + { + string line = reader.ReadLine(); + line = line.Replace(replacementForNewLine, "\r\n").Replace("\\\r\n", replacementForNewLine); + + // Line is formatted: logfileName ";" bookmark.LineNum ";" bookmark.Text; + int firstSeparator = line.IndexOf(';'); + int secondSeparator = line.IndexOf(';', firstSeparator + 1); + + string fileStr = line.Substring(0, firstSeparator); + string lineStr = line.Substring(firstSeparator + 1, secondSeparator - firstSeparator - 1); + string comment = line.Substring(secondSeparator + 1); + + int lineNum; + if (int.TryParse(lineStr, out lineNum)) + { + Entities.Bookmark bookmark = new(lineNum, comment); + bookmarkList.Add(lineNum, bookmark); + } + else + { + //!!!log error: skipping a line entry + } + } + catch + { + //!!! + } + } + } + } + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Bookmark/BookmarkView.cs b/src/Logexpert.Core/Classes/Bookmark/BookmarkView.cs similarity index 88% rename from src/LogExpert/Classes/Bookmark/BookmarkView.cs rename to src/Logexpert.Core/Classes/Bookmark/BookmarkView.cs index f8d54825..c194d5cf 100644 --- a/src/LogExpert/Classes/Bookmark/BookmarkView.cs +++ b/src/Logexpert.Core/Classes/Bookmark/BookmarkView.cs @@ -1,44 +1,45 @@ -using System; -using LogExpert.Interface; - -namespace LogExpert.Classes.Bookmark -{ - internal class BookmarkView : IBookmarkView - { - #region Fields - - #endregion - - - #region IBookmarkView Member - - public void UpdateView() - { - throw new NotImplementedException(); - } - - public void BookmarkTextChanged(Entities.Bookmark bookmark) - { - throw new NotImplementedException(); - } - - public void SelectBookmark(int lineNum) - { - throw new NotImplementedException(); - } - - public bool LineColumnVisible - { - set { throw new NotImplementedException(); } - } - - public bool IsActive { get; set; } = false; - - public void SetBookmarkData(IBookmarkData bookmarkData) - { - throw new NotImplementedException(); - } - - #endregion - } +using System; + +using LogExpert.Core.Interface; + +namespace LogExpert.Core.Classes.Bookmark +{ + internal class BookmarkView : IBookmarkView + { + #region Fields + + #endregion + + + #region IBookmarkView Member + + public void UpdateView() + { + throw new NotImplementedException(); + } + + public void BookmarkTextChanged(Entities.Bookmark bookmark) + { + throw new NotImplementedException(); + } + + public void SelectBookmark(int lineNum) + { + throw new NotImplementedException(); + } + + public bool LineColumnVisible + { + set { throw new NotImplementedException(); } + } + + public bool IsActive { get; set; } = false; + + public void SetBookmarkData(IBookmarkData bookmarkData) + { + throw new NotImplementedException(); + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/CmdLine.cs b/src/Logexpert.Core/Classes/CmdLine.cs similarity index 92% rename from src/LogExpert/Classes/CmdLine.cs rename to src/Logexpert.Core/Classes/CmdLine.cs index f99bffb4..53889d45 100644 --- a/src/LogExpert/Classes/CmdLine.cs +++ b/src/Logexpert.Core/Classes/CmdLine.cs @@ -1,436 +1,436 @@ -using System; -using System.Collections.Generic; - -/* - * Taken from https://cmdline.codeplex.com/ - * - */ - -namespace LogExpert.Classes -{ - /// - /// Represents an error occuring during command line parsing. - /// - public class CmdLineException : Exception - { - #region cTor - - public CmdLineException(string parameter, string message) - : - base(string.Format("Syntax error of parameter -{0}: {1}", parameter, message)) - { - } - - public CmdLineException(string message) - : - base(message) - { - } - - #endregion - } - - /// - /// Represents a command line parameter. - /// Parameters are words in the command line beginning with a hyphen (-). - /// The value of the parameter is the next word in - /// - public class CmdLineParameter - { - #region Fields - - #endregion - - #region cTor - - /// - /// Creates a new instance of this class. - /// - /// Name of parameter. - /// Require that the parameter is present in the command line. - /// The explanation of the parameter to add to the help screen. - public CmdLineParameter(string name, bool required, string helpMessage) - { - Name = name; - Required = required; - Help = helpMessage; - } - - #endregion - - #region Properties - - /// - /// Returns the value of the parameter. - /// - public string Value { get; private set; } = ""; - - /// - /// Returns the help message associated with the parameter. - /// - public string Help { get; } = ""; - - /// - /// Returns true if the parameter was found in the command line. - /// - public bool Exists { get; private set; } = false; - - /// - /// Returns true if the parameter is required in the command line. - /// - public bool Required { get; } = false; - - /// - /// Returns the name of the parameter. - /// - public string Name { get; } - - #endregion - - #region Public methods - - /// - /// Sets the value of the parameter. - /// - /// A string containing a integer expression. - public virtual void SetValue(string value) - { - Value = value; - Exists = true; - } - - #endregion - } - - /// - /// Represents an integer command line parameter. - /// - public class CmdLineInt : CmdLineParameter - { - #region Fields - - private readonly int _max = int.MaxValue; - private readonly int _min = int.MinValue; - - #endregion - - #region cTor - - /// - /// Creates a new instance of this class. - /// - /// Name of parameter. - /// Require that the parameter is present in the command line. - /// The explanation of the parameter to add to the help screen. - public CmdLineInt(string name, bool required, string helpMessage) - : base(name, required, helpMessage) - { - } - - /// - /// Creates a new instance of this class. - /// - /// Name of parameter. - /// Require that the parameter is present in the command line. - /// The explanation of the parameter to add to the help screen. - /// The minimum value of the parameter. - /// The maximum valie of the parameter. - public CmdLineInt(string name, bool required, string helpMessage, int min, int max) - : base(name, required, helpMessage) - { - _min = min; - _max = max; - } - - #endregion - - #region Properties - - /// - /// Returns the current value of the parameter. - /// - new public int Value { get; private set; } - - #endregion - - #region Public methods - - /// - /// Sets the value of the parameter. - /// - /// A string containing a integer expression. - public override void SetValue(string value) - { - base.SetValue(value); - int i = 0; - try - { - i = Convert.ToInt32(value); - } - catch (Exception) - { - throw new CmdLineException(base.Name, "Value is not an integer."); - } - if (i < _min) - { - throw new CmdLineException(base.Name, string.Format("Value must be greather or equal to {0}.", _min)); - } - if (i > _max) - { - throw new CmdLineException(base.Name, string.Format("Value must be less or equal to {0}.", _max)); - } - Value = i; - } - - /// - /// A implicit converion to a int data type. - /// - /// - /// - public static implicit operator int(CmdLineInt s) - { - return s.Value; - } - - #endregion - } - - /// - /// Represents an string command line parameter. - /// - public class CmdLineString : CmdLineParameter - { - #region cTor - - public CmdLineString(string name, bool required, string helpMessage) - : base(name, required, helpMessage) - { - } - - #endregion - - #region Public methods - - public static implicit operator string(CmdLineString s) - { - return s.Value; - } - - #endregion - } - - /// - /// Provides a simple strongly typed interface to work with command line parameters. - /// - public class CmdLine - { - #region Fields - - // A private dictonary containing the parameters. - private readonly Dictionary parameters = []; - - #endregion - - #region cTor - - /// - /// Creats a new empty command line object. - /// - public CmdLine() - { - } - - #endregion - - #region Properties - - /// - /// Returns a command line parameter by the name. - /// - /// The name of the parameter (the word after the initial hyphen (-). - /// A reference to the named comman line object. - public CmdLineParameter this[string name] - { - get - { - if (!parameters.ContainsKey(name)) - { - throw new CmdLineException(name, "Not a registered parameter."); - } - return parameters[name]; - } - } - - #endregion - - #region Public methods - - /// - /// Registers a parameter to be used and adds it to the help screen. - /// - /// The parameter to add. - public void RegisterParameter(CmdLineParameter parameter) - { - if (parameters.ContainsKey(parameter.Name)) - { - throw new CmdLineException(parameter.Name, "Parameter is already registered."); - } - parameters.Add(parameter.Name, parameter); - } - - /// - /// Registers parameters to be used and adds hem to the help screen. - /// - /// The parameter to add. - public void RegisterParameter(CmdLineParameter[] parameters) - { - foreach (CmdLineParameter p in parameters) - { - RegisterParameter(p); - } - } - - - /// - /// Parses the command line and sets the value of each registered parmaters. - /// - /// The arguments array sent to main() - /// Any reminding strings after arguments has been processed. - public string[] Parse(string[] args) - { - int i = 0; - - List new_args = []; - - while (i < args.Length) - { - if (args[i].Length > 1 && args[i][0] == '-') - { - // The current string is a parameter name - string key = args[i].Substring(1, args[i].Length - 1).ToLower(); - string value = ""; - i++; - if (i < args.Length) - { - if (args[i].Length > 0 && args[i][0] == '-') - { - // The next string is a new parameter, do not nothing - } - else - { - // The next string is a value, read the value and move forward - value = args[i]; - i++; - } - } - if (!parameters.ContainsKey(key)) - { - throw new CmdLineException(key, "Parameter is not allowed."); - } - - if (parameters[key].Exists) - { - throw new CmdLineException(key, "Parameter is specified more than once."); - } - - parameters[key].SetValue(value); - } - else - { - new_args.Add(args[i]); - i++; - } - } - - - // Check that required parameters are present in the command line. - foreach (string key in parameters.Keys) - { - if (parameters[key].Required && !parameters[key].Exists) - { - throw new CmdLineException(key, "Required parameter is not found."); - } - } - - return new_args.ToArray(); - } - - /// - /// Generates the help screen. - /// - public string HelpScreen() - { - int len = 0; - foreach (string key in parameters.Keys) - { - len = Math.Max(len, key.Length); - } - - string help = "\nParameters:\n\n"; - foreach (string key in parameters.Keys) - { - string s = "-" + parameters[key].Name; - while (s.Length < len + 3) - { - s += " "; - } - s += parameters[key].Help + "\n"; - help += s; - } - return help; - } - - #endregion - } - - /// - /// Represents a CmdLine object to use with console applications. - /// The -help parameter will be registered automatically. - /// Any errors will be written to the console instead of generating exceptions. - /// - public class ConsoleCmdLine : CmdLine - { - #region cTor - - public ConsoleCmdLine() - { - base.RegisterParameter(new CmdLineString("help", false, "Prints the help screen.")); - } - - #endregion - - #region Public methods - - public new string[] Parse(string[] args) - { - string[] ret = null; - string error = ""; - try - { - ret = base.Parse(args); - } - catch (CmdLineException ex) - { - error = ex.Message; - } - - if (this["help"].Exists) - { - //foreach(string s in base.HelpScreen().Split('\n')) - // Console.WriteLine(s); - Console.WriteLine(base.HelpScreen()); - System.Environment.Exit(0); - } - - if (error != "") - { - Console.WriteLine(error); - Console.WriteLine("Use -help for more information."); - System.Environment.Exit(1); - } - return ret; - } - - #endregion - } +using System; +using System.Collections.Generic; + +/* + * Taken from https://cmdline.codeplex.com/ + * + */ + +namespace LogExpert.Core.Classes +{ + /// + /// Represents an error occuring during command line parsing. + /// + public class CmdLineException : Exception + { + #region cTor + + public CmdLineException(string parameter, string message) + : + base(string.Format("Syntax error of parameter -{0}: {1}", parameter, message)) + { + } + + public CmdLineException(string message) + : + base(message) + { + } + + #endregion + } + + /// + /// Represents a command line parameter. + /// Parameters are words in the command line beginning with a hyphen (-). + /// The value of the parameter is the next word in + /// + public class CmdLineParameter + { + #region Fields + + #endregion + + #region cTor + + /// + /// Creates a new instance of this class. + /// + /// Name of parameter. + /// Require that the parameter is present in the command line. + /// The explanation of the parameter to add to the help screen. + public CmdLineParameter(string name, bool required, string helpMessage) + { + Name = name; + Required = required; + Help = helpMessage; + } + + #endregion + + #region Properties + + /// + /// Returns the value of the parameter. + /// + public string Value { get; private set; } = ""; + + /// + /// Returns the help message associated with the parameter. + /// + public string Help { get; } = ""; + + /// + /// Returns true if the parameter was found in the command line. + /// + public bool Exists { get; private set; } = false; + + /// + /// Returns true if the parameter is required in the command line. + /// + public bool Required { get; } = false; + + /// + /// Returns the name of the parameter. + /// + public string Name { get; } + + #endregion + + #region Public methods + + /// + /// Sets the value of the parameter. + /// + /// A string containing a integer expression. + public virtual void SetValue(string value) + { + Value = value; + Exists = true; + } + + #endregion + } + + /// + /// Represents an integer command line parameter. + /// + public class CmdLineInt : CmdLineParameter + { + #region Fields + + private readonly int _max = int.MaxValue; + private readonly int _min = int.MinValue; + + #endregion + + #region cTor + + /// + /// Creates a new instance of this class. + /// + /// Name of parameter. + /// Require that the parameter is present in the command line. + /// The explanation of the parameter to add to the help screen. + public CmdLineInt(string name, bool required, string helpMessage) + : base(name, required, helpMessage) + { + } + + /// + /// Creates a new instance of this class. + /// + /// Name of parameter. + /// Require that the parameter is present in the command line. + /// The explanation of the parameter to add to the help screen. + /// The minimum value of the parameter. + /// The maximum valie of the parameter. + public CmdLineInt(string name, bool required, string helpMessage, int min, int max) + : base(name, required, helpMessage) + { + _min = min; + _max = max; + } + + #endregion + + #region Properties + + /// + /// Returns the current value of the parameter. + /// + new public int Value { get; private set; } + + #endregion + + #region Public methods + + /// + /// Sets the value of the parameter. + /// + /// A string containing a integer expression. + public override void SetValue(string value) + { + base.SetValue(value); + int i = 0; + try + { + i = Convert.ToInt32(value); + } + catch (Exception) + { + throw new CmdLineException(Name, "Value is not an integer."); + } + if (i < _min) + { + throw new CmdLineException(Name, string.Format("Value must be greather or equal to {0}.", _min)); + } + if (i > _max) + { + throw new CmdLineException(Name, string.Format("Value must be less or equal to {0}.", _max)); + } + Value = i; + } + + /// + /// A implicit converion to a int data type. + /// + /// + /// + public static implicit operator int(CmdLineInt s) + { + return s.Value; + } + + #endregion + } + + /// + /// Represents an string command line parameter. + /// + public class CmdLineString : CmdLineParameter + { + #region cTor + + public CmdLineString(string name, bool required, string helpMessage) + : base(name, required, helpMessage) + { + } + + #endregion + + #region Public methods + + public static implicit operator string(CmdLineString s) + { + return s.Value; + } + + #endregion + } + + /// + /// Provides a simple strongly typed interface to work with command line parameters. + /// + public class CmdLine + { + #region Fields + + // A private dictonary containing the parameters. + private readonly Dictionary parameters = []; + + #endregion + + #region cTor + + /// + /// Creats a new empty command line object. + /// + public CmdLine() + { + } + + #endregion + + #region Properties + + /// + /// Returns a command line parameter by the name. + /// + /// The name of the parameter (the word after the initial hyphen (-). + /// A reference to the named comman line object. + public CmdLineParameter this[string name] + { + get + { + if (!parameters.ContainsKey(name)) + { + throw new CmdLineException(name, "Not a registered parameter."); + } + return parameters[name]; + } + } + + #endregion + + #region Public methods + + /// + /// Registers a parameter to be used and adds it to the help screen. + /// + /// The parameter to add. + public void RegisterParameter(CmdLineParameter parameter) + { + if (parameters.ContainsKey(parameter.Name)) + { + throw new CmdLineException(parameter.Name, "Parameter is already registered."); + } + parameters.Add(parameter.Name, parameter); + } + + /// + /// Registers parameters to be used and adds hem to the help screen. + /// + /// The parameter to add. + public void RegisterParameter(CmdLineParameter[] parameters) + { + foreach (CmdLineParameter p in parameters) + { + RegisterParameter(p); + } + } + + + /// + /// Parses the command line and sets the value of each registered parmaters. + /// + /// The arguments array sent to main() + /// Any reminding strings after arguments has been processed. + public string[] Parse(string[] args) + { + int i = 0; + + List new_args = []; + + while (i < args.Length) + { + if (args[i].Length > 1 && args[i][0] == '-') + { + // The current string is a parameter name + string key = args[i].Substring(1, args[i].Length - 1).ToLower(); + string value = ""; + i++; + if (i < args.Length) + { + if (args[i].Length > 0 && args[i][0] == '-') + { + // The next string is a new parameter, do not nothing + } + else + { + // The next string is a value, read the value and move forward + value = args[i]; + i++; + } + } + if (!parameters.ContainsKey(key)) + { + throw new CmdLineException(key, "Parameter is not allowed."); + } + + if (parameters[key].Exists) + { + throw new CmdLineException(key, "Parameter is specified more than once."); + } + + parameters[key].SetValue(value); + } + else + { + new_args.Add(args[i]); + i++; + } + } + + + // Check that required parameters are present in the command line. + foreach (string key in parameters.Keys) + { + if (parameters[key].Required && !parameters[key].Exists) + { + throw new CmdLineException(key, "Required parameter is not found."); + } + } + + return new_args.ToArray(); + } + + /// + /// Generates the help screen. + /// + public string HelpScreen() + { + int len = 0; + foreach (string key in parameters.Keys) + { + len = Math.Max(len, key.Length); + } + + string help = "\nParameters:\n\n"; + foreach (string key in parameters.Keys) + { + string s = "-" + parameters[key].Name; + while (s.Length < len + 3) + { + s += " "; + } + s += parameters[key].Help + "\n"; + help += s; + } + return help; + } + + #endregion + } + + /// + /// Represents a CmdLine object to use with console applications. + /// The -help parameter will be registered automatically. + /// Any errors will be written to the console instead of generating exceptions. + /// + public class ConsoleCmdLine : CmdLine + { + #region cTor + + public ConsoleCmdLine() + { + RegisterParameter(new CmdLineString("help", false, "Prints the help screen.")); + } + + #endregion + + #region Public methods + + public new string[] Parse(string[] args) + { + string[] ret = null; + string error = ""; + try + { + ret = base.Parse(args); + } + catch (CmdLineException ex) + { + error = ex.Message; + } + + if (this["help"].Exists) + { + //foreach(string s in base.HelpScreen().Split('\n')) + // Console.WriteLine(s); + Console.WriteLine(HelpScreen()); + Environment.Exit(0); + } + + if (error != "") + { + Console.WriteLine(error); + Console.WriteLine("Use -help for more information."); + Environment.Exit(1); + } + return ret; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Columnizer/ClfColumnizer.cs b/src/Logexpert.Core/Classes/Columnizer/ClfColumnizer.cs similarity index 90% rename from src/LogExpert/Classes/Columnizer/ClfColumnizer.cs rename to src/Logexpert.Core/Classes/Columnizer/ClfColumnizer.cs index 20f8b4aa..14dbe3f0 100644 --- a/src/LogExpert/Classes/Columnizer/ClfColumnizer.cs +++ b/src/Logexpert.Core/Classes/Columnizer/ClfColumnizer.cs @@ -1,199 +1,199 @@ -using System; -using System.Globalization; -using System.Linq; -using System.Text.RegularExpressions; - -namespace LogExpert.Classes.Columnizer -{ - public class ClfColumnizer : ILogLineColumnizer - { - #region Fields - - private readonly Regex lineRegex = new("(.*) (-) (.*) (\\[.*\\]) (\".*\") (.*) (.*) (\".*\") (\".*\")"); - - protected CultureInfo cultureInfo = new("de-DE"); - protected int timeOffset = 0; - - #endregion - - #region cTor - - // anon-212-34-174-126.suchen.de - - [08/Mar/2008:00:41:10 +0100] "GET /wiki/index.php?title=Bild:Poster_small.jpg&printable=yes&printable=yes HTTP/1.1" 304 0 "http://www.captain-kloppi.de/wiki/index.php?title=Bild:Poster_small.jpg&printable=yes" "gonzo1[P] +http://www.suchen.de/faq.html" - - public ClfColumnizer() - { - } - - #endregion - - #region Public methods - - public bool IsTimeshiftImplemented() - { - return true; - } - - public void SetTimeOffset(int msecOffset) - { - this.timeOffset = msecOffset; - } - - public int GetTimeOffset() - { - return this.timeOffset; - } - - public DateTime GetTimestamp(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) - { - IColumnizedLogLine cols = SplitLine(callback, line); - if (cols == null || cols.ColumnValues.Length < 8) - { - return DateTime.MinValue; - } - - if (cols.ColumnValues[2].FullValue.Length == 0) - { - return DateTime.MinValue; - } - - try - { - DateTime dateTime = DateTime.ParseExact(cols.ColumnValues[2].FullValue, "dd/MMM/yyyy:HH:mm:ss zzz", - new CultureInfo("en-US")); - return dateTime; - } - catch (Exception) - { - return DateTime.MinValue; - } - } - - public void PushValue(LogExpert.ILogLineColumnizerCallback callback, int column, string value, string oldValue) - { - if (column == 2) - { - try - { - DateTime newDateTime = - DateTime.ParseExact(value, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US")); - DateTime oldDateTime = - DateTime.ParseExact(oldValue, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US")); - long mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; - long mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; - this.timeOffset = (int) (mSecsNew - mSecsOld); - } - catch (FormatException) - { - } - } - } - - public string GetName() - { - return "Webserver CLF Columnizer"; - } - - public string GetDescription() - { - return "Common Logfile Format used by webservers."; - } - - public int GetColumnCount() - { - return 8; - } - - public string[] GetColumnNames() - { - return new string[] {"IP", "User", "Date/Time", "Request", "Status", "Bytes", "Referrer", "User agent"}; - } - - public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) - { - ColumnizedLogLine cLogLine = new() - { - LogLine = line - }; - - Column[] columns = new Column[8] - { - new() {FullValue = "", Parent = cLogLine}, - new() {FullValue = "", Parent = cLogLine}, - new() {FullValue = "", Parent = cLogLine}, - new() {FullValue = "", Parent = cLogLine}, - new() {FullValue = "", Parent = cLogLine}, - new() {FullValue = "", Parent = cLogLine}, - new() {FullValue = "", Parent = cLogLine}, - new() {FullValue = "", Parent = cLogLine} - }; - - cLogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); - - string temp = line.FullLine; - if (temp.Length > 1024) - { - // spam - temp = temp.Substring(0, 1024); - columns[3].FullValue = temp; - return cLogLine; - } - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 - // anon-212-34-174-126.suchen.de - - [08/Mar/2008:00:41:10 +0100] "GET /wiki/index.php?title=Bild:Poster_small.jpg&printable=yes&printable=yes HTTP/1.1" 304 0 "http://www.captain-kloppi.de/wiki/index.php?title=Bild:Poster_small.jpg&printable=yes" "gonzo1[P] +http://www.suchen.de/faq.html" - - if (this.lineRegex.IsMatch(temp)) - { - Match match = this.lineRegex.Match(temp); - GroupCollection groups = match.Groups; - if (groups.Count == 10) - { - columns[0].FullValue = groups[1].Value; - columns[1].FullValue = groups[3].Value; - columns[3].FullValue = groups[5].Value; - columns[4].FullValue = groups[6].Value; - columns[5].FullValue = groups[7].Value; - columns[6].FullValue = groups[8].Value; - columns[7].FullValue = groups[9].Value; - - string dateTimeStr = groups[4].Value.Substring(1, 26); - - // dirty probing of date/time format (much faster than DateTime.ParseExact() - if (dateTimeStr[2] == '/' && dateTimeStr[6] == '/' && dateTimeStr[11] == ':') - { - if (this.timeOffset != 0) - { - try - { - DateTime dateTime = DateTime.ParseExact(dateTimeStr, "dd/MMM/yyyy:HH:mm:ss zzz", - new CultureInfo("en-US")); - dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, this.timeOffset)); - string newDate = dateTime.ToString("dd/MMM/yyyy:HH:mm:ss zzz", - new CultureInfo("en-US")); - columns[2].FullValue = newDate; - } - catch (Exception) - { - columns[2].FullValue = "n/a"; - } - } - else - { - columns[2].FullValue = dateTimeStr; - } - } - else - { - columns[2].FullValue = dateTimeStr; - } - } - } - else - { - columns[3].FullValue = temp; - } - - return cLogLine; - } - - #endregion - } +using System; +using System.Globalization; +using System.Linq; +using System.Text.RegularExpressions; + +namespace LogExpert.Core.Classes.Columnizer +{ + public class ClfColumnizer : ILogLineColumnizer + { + #region Fields + + private readonly Regex lineRegex = new("(.*) (-) (.*) (\\[.*\\]) (\".*\") (.*) (.*) (\".*\") (\".*\")"); + + protected CultureInfo cultureInfo = new("de-DE"); + protected int timeOffset = 0; + + #endregion + + #region cTor + + // anon-212-34-174-126.suchen.de - - [08/Mar/2008:00:41:10 +0100] "GET /wiki/index.php?title=Bild:Poster_small.jpg&printable=yes&printable=yes HTTP/1.1" 304 0 "http://www.captain-kloppi.de/wiki/index.php?title=Bild:Poster_small.jpg&printable=yes" "gonzo1[P] +http://www.suchen.de/faq.html" + + public ClfColumnizer() + { + } + + #endregion + + #region Public methods + + public bool IsTimeshiftImplemented() + { + return true; + } + + public void SetTimeOffset(int msecOffset) + { + timeOffset = msecOffset; + } + + public int GetTimeOffset() + { + return timeOffset; + } + + public DateTime GetTimestamp(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + { + IColumnizedLogLine cols = SplitLine(callback, line); + if (cols == null || cols.ColumnValues.Length < 8) + { + return DateTime.MinValue; + } + + if (cols.ColumnValues[2].FullValue.Length == 0) + { + return DateTime.MinValue; + } + + try + { + DateTime dateTime = DateTime.ParseExact(cols.ColumnValues[2].FullValue, "dd/MMM/yyyy:HH:mm:ss zzz", + new CultureInfo("en-US")); + return dateTime; + } + catch (Exception) + { + return DateTime.MinValue; + } + } + + public void PushValue(LogExpert.ILogLineColumnizerCallback callback, int column, string value, string oldValue) + { + if (column == 2) + { + try + { + DateTime newDateTime = + DateTime.ParseExact(value, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US")); + DateTime oldDateTime = + DateTime.ParseExact(oldValue, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US")); + long mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; + long mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; + timeOffset = (int)(mSecsNew - mSecsOld); + } + catch (FormatException) + { + } + } + } + + public string GetName() + { + return "Webserver CLF Columnizer"; + } + + public string GetDescription() + { + return "Common Logfile Format used by webservers."; + } + + public int GetColumnCount() + { + return 8; + } + + public string[] GetColumnNames() + { + return new string[] { "IP", "User", "Date/Time", "Request", "Status", "Bytes", "Referrer", "User agent" }; + } + + public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + { + ColumnizedLogLine cLogLine = new() + { + LogLine = line + }; + + Column[] columns = new Column[8] + { + new() {FullValue = "", Parent = cLogLine}, + new() {FullValue = "", Parent = cLogLine}, + new() {FullValue = "", Parent = cLogLine}, + new() {FullValue = "", Parent = cLogLine}, + new() {FullValue = "", Parent = cLogLine}, + new() {FullValue = "", Parent = cLogLine}, + new() {FullValue = "", Parent = cLogLine}, + new() {FullValue = "", Parent = cLogLine} + }; + + cLogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); + + string temp = line.FullLine; + if (temp.Length > 1024) + { + // spam + temp = temp.Substring(0, 1024); + columns[3].FullValue = temp; + return cLogLine; + } + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 + // anon-212-34-174-126.suchen.de - - [08/Mar/2008:00:41:10 +0100] "GET /wiki/index.php?title=Bild:Poster_small.jpg&printable=yes&printable=yes HTTP/1.1" 304 0 "http://www.captain-kloppi.de/wiki/index.php?title=Bild:Poster_small.jpg&printable=yes" "gonzo1[P] +http://www.suchen.de/faq.html" + + if (lineRegex.IsMatch(temp)) + { + Match match = lineRegex.Match(temp); + GroupCollection groups = match.Groups; + if (groups.Count == 10) + { + columns[0].FullValue = groups[1].Value; + columns[1].FullValue = groups[3].Value; + columns[3].FullValue = groups[5].Value; + columns[4].FullValue = groups[6].Value; + columns[5].FullValue = groups[7].Value; + columns[6].FullValue = groups[8].Value; + columns[7].FullValue = groups[9].Value; + + string dateTimeStr = groups[4].Value.Substring(1, 26); + + // dirty probing of date/time format (much faster than DateTime.ParseExact() + if (dateTimeStr[2] == '/' && dateTimeStr[6] == '/' && dateTimeStr[11] == ':') + { + if (timeOffset != 0) + { + try + { + DateTime dateTime = DateTime.ParseExact(dateTimeStr, "dd/MMM/yyyy:HH:mm:ss zzz", + new CultureInfo("en-US")); + dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); + string newDate = dateTime.ToString("dd/MMM/yyyy:HH:mm:ss zzz", + new CultureInfo("en-US")); + columns[2].FullValue = newDate; + } + catch (Exception) + { + columns[2].FullValue = "n/a"; + } + } + else + { + columns[2].FullValue = dateTimeStr; + } + } + else + { + columns[2].FullValue = dateTimeStr; + } + } + } + else + { + columns[3].FullValue = temp; + } + + return cLogLine; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Columnizer/ColumnizerPicker.cs b/src/Logexpert.Core/Classes/Columnizer/ColumnizerPicker.cs similarity index 82% rename from src/LogExpert/Classes/Columnizer/ColumnizerPicker.cs rename to src/Logexpert.Core/Classes/Columnizer/ColumnizerPicker.cs index 4ccc4cc9..abb616a0 100644 --- a/src/LogExpert/Classes/Columnizer/ColumnizerPicker.cs +++ b/src/Logexpert.Core/Classes/Columnizer/ColumnizerPicker.cs @@ -1,143 +1,143 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using LogExpert.Config; -using LogExpert.Entities; - -namespace LogExpert.Classes.Columnizer -{ - public class ColumnizerPicker - { - public static ILogLineColumnizer FindColumnizerByName(string name, IList list) - { - foreach (ILogLineColumnizer columnizer in list) - { - if (columnizer.GetName().Equals(name)) - { - return columnizer; - } - } - return null; - } - - public static ILogLineColumnizer DecideColumnizerByName(string name, IList list) - { - foreach (ILogLineColumnizer columnizer in list) - { - if (columnizer.GetName().Equals(name)) - { - return columnizer; - } - } - - return FindColumnizer(null, null); - } - - public static ILogLineColumnizer CloneColumnizer(ILogLineColumnizer columnizer) - { - if (columnizer == null) - { - return null; - } - ConstructorInfo cti = columnizer.GetType().GetConstructor(Type.EmptyTypes); - - if (cti != null) - { - object o = cti.Invoke(new object[] { }); - if (o is IColumnizerConfigurator configurator) - { - configurator.LoadConfig(ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir); - } - return (ILogLineColumnizer)o; - } - return null; - } - - /// - /// This method implemented the "auto columnizer" feature. - /// This method should be called after each columnizer is changed to update the columizer. - /// - /// - /// - /// - /// - public static ILogLineColumnizer FindReplacementForAutoColumnizer(string fileName, - IAutoLogLineColumnizerCallback logFileReader, - ILogLineColumnizer logLineColumnizer) - { - if (logLineColumnizer == null || logLineColumnizer.GetName() == "Auto Columnizer") - { - return FindColumnizer(fileName, logFileReader); - } - return logLineColumnizer; - } - - public static ILogLineColumnizer FindBetterColumnizer(string fileName, - IAutoLogLineColumnizerCallback logFileReader, - ILogLineColumnizer logLineColumnizer) - { - var newColumnizer = FindColumnizer(fileName, logFileReader); - if (newColumnizer.GetType().Equals(logLineColumnizer.GetType())) - { - return null; - } - return newColumnizer; - } - - /// - /// This method will search all registered columnizer and return one according to the priority that returned - /// by the each columnizer. - /// - /// - /// - /// - public static ILogLineColumnizer FindColumnizer(string fileName, IAutoLogLineColumnizerCallback logFileReader) - { - if (string.IsNullOrEmpty(fileName)) - { - return new DefaultLogfileColumnizer(); - } - - List loglines = []; - - if (logFileReader != null) - { - loglines = - [ - // Sampling a few lines to select the correct columnizer - logFileReader.GetLogLine(0), - logFileReader.GetLogLine(1), - logFileReader.GetLogLine(2), - logFileReader.GetLogLine(3), - logFileReader.GetLogLine(4), - logFileReader.GetLogLine(5), - logFileReader.GetLogLine(25), - logFileReader.GetLogLine(100), - logFileReader.GetLogLine(200), - logFileReader.GetLogLine(400) - ]; - } - - var registeredColumnizer = PluginRegistry.Instance.RegisteredColumnizers; - - List> priorityListOfColumnizers = []; - - foreach (ILogLineColumnizer logLineColumnizer in registeredColumnizer) - { - Priority priority = default; - if (logLineColumnizer is IColumnizerPriority columnizerPriority) - { - priority = columnizerPriority.GetPriority(fileName, loglines); - } - - priorityListOfColumnizers.Add(new Tuple(priority, logLineColumnizer)); - } - - ILogLineColumnizer lineColumnizer = priorityListOfColumnizers.OrderByDescending(a => a.Item1).Select(a => a.Item2).First(); - - return lineColumnizer; - } - } -} +using LogExpert.Core.Entities; + +using System.Reflection; + +namespace LogExpert.Core.Classes.Columnizer +{ + public class ColumnizerPicker + { + public static ILogLineColumnizer FindColumnizerByName(string name, IList list) + { + foreach (ILogLineColumnizer columnizer in list) + { + if (columnizer.GetName().Equals(name)) + { + return columnizer; + } + } + return null; + } + + public static ILogLineColumnizer DecideColumnizerByName(string name, IList list) + { + foreach (ILogLineColumnizer columnizer in list) + { + if (columnizer.GetName().Equals(name)) + { + return columnizer; + } + } + + return FindColumnizer(null, null, list); + } + + public static ILogLineColumnizer CloneColumnizer(ILogLineColumnizer columnizer, string directory) + { + if (columnizer == null) + { + return null; + } + ConstructorInfo cti = columnizer.GetType().GetConstructor(Type.EmptyTypes); + + if (cti != null) + { + object o = cti.Invoke([]); + + if (o is IColumnizerConfigurator configurator) + { + configurator.LoadConfig(directory); + } + return (ILogLineColumnizer)o; + } + return null; + } + + /// + /// This method implemented the "auto columnizer" feature. + /// This method should be called after each columnizer is changed to update the columizer. + /// + /// + /// + /// + /// + public static ILogLineColumnizer FindReplacementForAutoColumnizer(string fileName, + IAutoLogLineColumnizerCallback logFileReader, + ILogLineColumnizer logLineColumnizer, + IList list) + { + if (logLineColumnizer == null || logLineColumnizer.GetName() == "Auto Columnizer") + { + return FindColumnizer(fileName, logFileReader, list); + } + return logLineColumnizer; + } + + public static ILogLineColumnizer FindBetterColumnizer(string fileName, + IAutoLogLineColumnizerCallback logFileReader, + ILogLineColumnizer logLineColumnizer, + IList list) + { + var newColumnizer = FindColumnizer(fileName, logFileReader, list); + + if (newColumnizer.GetType().Equals(logLineColumnizer.GetType())) + { + return null; + } + return newColumnizer; + } + + /// + /// This method will search all registered columnizer and return one according to the priority that returned + /// by the each columnizer. + /// + /// + /// + /// + public static ILogLineColumnizer FindColumnizer(string fileName, IAutoLogLineColumnizerCallback logFileReader, IList list) + { + if (string.IsNullOrEmpty(fileName)) + { + return new DefaultLogfileColumnizer(); + } + + List loglines = []; + + if (logFileReader != null) + { + loglines = + [ + // Sampling a few lines to select the correct columnizer + logFileReader.GetLogLine(0), + logFileReader.GetLogLine(1), + logFileReader.GetLogLine(2), + logFileReader.GetLogLine(3), + logFileReader.GetLogLine(4), + logFileReader.GetLogLine(5), + logFileReader.GetLogLine(25), + logFileReader.GetLogLine(100), + logFileReader.GetLogLine(200), + logFileReader.GetLogLine(400) + ]; + } + + var registeredColumnizer = list; + + List> priorityListOfColumnizers = []; + + foreach (ILogLineColumnizer logLineColumnizer in registeredColumnizer) + { + Priority priority = default; + if (logLineColumnizer is IColumnizerPriority columnizerPriority) + { + priority = columnizerPriority.GetPriority(fileName, loglines); + } + + priorityListOfColumnizers.Add(new Tuple(priority, logLineColumnizer)); + } + + ILogLineColumnizer lineColumnizer = priorityListOfColumnizers.OrderByDescending(a => a.Item1).Select(a => a.Item2).First(); + + return lineColumnizer; + } + } +} diff --git a/src/LogExpert/Classes/Columnizer/SquareBracketColumnizer.cs b/src/Logexpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs similarity index 92% rename from src/LogExpert/Classes/Columnizer/SquareBracketColumnizer.cs rename to src/Logexpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs index 6a8be193..58f15b05 100644 --- a/src/LogExpert/Classes/Columnizer/SquareBracketColumnizer.cs +++ b/src/Logexpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs @@ -2,9 +2,10 @@ using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; -using static LogExpert.Classes.Columnizer.TimeFormatDeterminer; -namespace LogExpert.Classes.Columnizer +using static LogExpert.Core.Classes.Columnizer.TimeFormatDeterminer; + +namespace LogExpert.Core.Classes.Columnizer { public class SquareBracketColumnizer : ILogLineColumnizer, IColumnizerPriority { @@ -40,12 +41,12 @@ public bool IsTimeshiftImplemented() public void SetTimeOffset(int msecOffset) { - this.timeOffset = msecOffset; + timeOffset = msecOffset; } public int GetTimeOffset() { - return this.timeOffset; + return timeOffset; } public DateTime GetTimestamp(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) @@ -96,7 +97,7 @@ public void PushValue(LogExpert.ILogLineColumnizerCallback callback, int column, DateTime oldDateTime = DateTime.ParseExact(oldValue, formatInfo.TimeFormat, formatInfo.CultureInfo); long mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; long mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; - this.timeOffset = (int) (mSecsNew - mSecsOld); + timeOffset = (int)(mSecsNew - mSecsOld); } catch (FormatException) { @@ -189,11 +190,11 @@ public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callbac int dateLen = formatInfo.DateFormat.Length; try { - if (this.timeOffset != 0) + if (timeOffset != 0) { DateTime dateTime = DateTime.ParseExact(temp.Substring(0, endPos), formatInfo.DateTimeFormat, formatInfo.CultureInfo); - dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, this.timeOffset)); + dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); string newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); SquareSplit(ref columns, newDate, dateLen, timeLen, endPos, clogLine); @@ -222,8 +223,8 @@ void SquareSplit(ref Column[] columns, string line, int dateLen, int timeLen, in int restColumn = _columnCount; if (_isTimeExists) { - columnList.Add(new Column {FullValue = line.Substring(0, dateLen), Parent = clogLine}); - columnList.Add(new Column {FullValue = line.Substring(dateLen + 1, timeLen), Parent = clogLine}); + columnList.Add(new Column { FullValue = line.Substring(0, dateLen), Parent = clogLine }); + columnList.Add(new Column { FullValue = line.Substring(dateLen + 1, timeLen), Parent = clogLine }); restColumn -= 2; } @@ -235,21 +236,21 @@ void SquareSplit(ref Column[] columns, string line, int dateLen, int timeLen, in { rest = rest.Substring(nextPos); //var fullValue = rest.Substring(0, rest.IndexOf(']')).TrimStart(new char[] {' '}).TrimEnd(new char[] { ' ' }); - var trimmed = rest.TrimStart(new char[] {' '}); + var trimmed = rest.TrimStart(new char[] { ' ' }); if (string.IsNullOrEmpty(trimmed) || trimmed[0] != '[' || rest.IndexOf(']') < 0 || i == restColumn - 1) { - columnList.Add(new Column {FullValue = rest, Parent = clogLine}); + columnList.Add(new Column { FullValue = rest, Parent = clogLine }); break; } nextPos = rest.IndexOf(']') + 1; var fullValue = rest.Substring(0, nextPos); - columnList.Add(new Column {FullValue = fullValue, Parent = clogLine}); + columnList.Add(new Column { FullValue = fullValue, Parent = clogLine }); } while (columnList.Count < _columnCount) { - columnList.Insert(columnList.Count - 1, new Column {FullValue = "", Parent = clogLine}); + columnList.Insert(columnList.Count - 1, new Column { FullValue = "", Parent = clogLine }); } columns = columnList.ToArray(); diff --git a/src/LogExpert/Classes/Columnizer/TimeFormatDeterminer.cs b/src/Logexpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs similarity index 99% rename from src/LogExpert/Classes/Columnizer/TimeFormatDeterminer.cs rename to src/Logexpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs index 8a833047..77da6cbd 100644 --- a/src/LogExpert/Classes/Columnizer/TimeFormatDeterminer.cs +++ b/src/Logexpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs @@ -1,6 +1,6 @@ using System.Globalization; -namespace LogExpert.Classes.Columnizer +namespace LogExpert.Core.Classes.Columnizer { internal class TimeFormatDeterminer { diff --git a/src/LogExpert/Classes/Columnizer/TimestampColumnizer.cs b/src/Logexpert.Core/Classes/Columnizer/TimestampColumnizer.cs similarity index 92% rename from src/LogExpert/Classes/Columnizer/TimestampColumnizer.cs rename to src/Logexpert.Core/Classes/Columnizer/TimestampColumnizer.cs index f7ed13b6..3b9f3624 100644 --- a/src/LogExpert/Classes/Columnizer/TimestampColumnizer.cs +++ b/src/Logexpert.Core/Classes/Columnizer/TimestampColumnizer.cs @@ -1,220 +1,220 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace LogExpert.Classes.Columnizer -{ - using static TimeFormatDeterminer; - - public class TimestampColumnizer : ILogLineColumnizer, IColumnizerPriority - { - - #region ILogLineColumnizer implementation - - protected int timeOffset = 0; - private TimeFormatDeterminer _timeFormatDeterminer = new(); - - public bool IsTimeshiftImplemented() - { - return true; - } - - public void SetTimeOffset(int msecOffset) - { - this.timeOffset = msecOffset; - } - - public int GetTimeOffset() - { - return this.timeOffset; - } - - - public DateTime GetTimestamp(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) - { - IColumnizedLogLine cols = SplitLine(callback, line); - if (cols == null || cols.ColumnValues == null || cols.ColumnValues.Length < 2) - { - return DateTime.MinValue; - } - if (cols.ColumnValues[0].FullValue.Length == 0 || cols.ColumnValues[1].FullValue.Length == 0) - { - return DateTime.MinValue; - } - FormatInfo formatInfo = _timeFormatDeterminer.DetermineDateTimeFormatInfo(line.FullLine); - if (formatInfo == null) - { - return DateTime.MinValue; - } - - try - { - DateTime dateTime = DateTime.ParseExact( - cols.ColumnValues[0].FullValue + " " + cols.ColumnValues[1].FullValue, formatInfo.DateTimeFormat, - formatInfo.CultureInfo); - return dateTime; - } - catch (Exception) - { - return DateTime.MinValue; - } - } - - - public void PushValue(LogExpert.ILogLineColumnizerCallback callback, int column, string value, string oldValue) - { - if (column == 1) - { - try - { - FormatInfo formatInfo = _timeFormatDeterminer.DetermineTimeFormatInfo(oldValue); - if (formatInfo == null) - { - return; - } - DateTime newDateTime = DateTime.ParseExact(value, formatInfo.TimeFormat, formatInfo.CultureInfo); - DateTime oldDateTime = DateTime.ParseExact(oldValue, formatInfo.TimeFormat, formatInfo.CultureInfo); - long mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; - long mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; - this.timeOffset = (int) (mSecsNew - mSecsOld); - } - catch (FormatException) - { - } - } - } - - public string GetName() - { - return "Timestamp Columnizer"; - } - - public string GetDescription() - { - return "Splits every line into 3 fields: Date, Time and the rest of the log message"; - } - - public int GetColumnCount() - { - return 3; - } - - public string[] GetColumnNames() - { - return new string[] {"Date", "Time", "Message"}; - } - - public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) - { - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 - // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 - // 03.01.2008 14:48:00.066 - - ColumnizedLogLine clogLine = new(); - clogLine.LogLine = line; - - Column[] columns = new Column[3] - { - new() {FullValue = "", Parent = clogLine}, - new() {FullValue = "", Parent = clogLine}, - new() {FullValue = "", Parent = clogLine}, - }; - - clogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); - - string temp = line.FullLine; - - FormatInfo formatInfo = _timeFormatDeterminer.DetermineDateTimeFormatInfo(temp); - if (formatInfo == null) - { - columns[2].FullValue = temp; - return clogLine; - } - int endPos = formatInfo.DateTimeFormat.Length; - int timeLen = formatInfo.TimeFormat.Length; - int dateLen = formatInfo.DateFormat.Length; - try - { - if (this.timeOffset != 0) - { - if (formatInfo.IgnoreFirstChar) - { - // First character is a bracket and should be ignored - DateTime dateTime = DateTime.ParseExact(temp.Substring(1, endPos), formatInfo.DateTimeFormat, - formatInfo.CultureInfo); - dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, this.timeOffset)); - string newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); - columns[0].FullValue = newDate.Substring(0, dateLen); // date - columns[1].FullValue = newDate.Substring(dateLen + 1, timeLen); // time - columns[2].FullValue = temp.Substring(endPos + 2); // rest of line - } - else - { - DateTime dateTime = DateTime.ParseExact(temp.Substring(0, endPos), formatInfo.DateTimeFormat, - formatInfo.CultureInfo); - dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, this.timeOffset)); - string newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); - columns[0].FullValue = newDate.Substring(0, dateLen); // date - columns[1].FullValue = newDate.Substring(dateLen + 1, timeLen); // time - columns[2].FullValue = temp.Substring(endPos); // rest of line - } - } - else - { - if (formatInfo.IgnoreFirstChar) - { - // First character is a bracket and should be ignored - columns[0].FullValue = temp.Substring(1, dateLen); // date - columns[1].FullValue = temp.Substring(dateLen + 2, timeLen); // time - columns[2].FullValue = temp.Substring(endPos + 2); // rest of line - } - else - { - columns[0].FullValue = temp.Substring(0, dateLen); // date - columns[1].FullValue = temp.Substring(dateLen + 1, timeLen); // time - columns[2].FullValue = temp.Substring(endPos); // rest of line - } - } - } - catch (Exception) - { - columns[0].FullValue = "n/a"; - columns[1].FullValue = "n/a"; - columns[2].FullValue = temp; - } - return clogLine; - } - - public Priority GetPriority(string fileName, IEnumerable samples) - { - Priority result = Priority.NotSupport; - - int timeStampCount = 0; - foreach (var line in samples) - { - if (line == null || string.IsNullOrEmpty(line.FullLine)) - { - continue; - } - var timeDeterminer = new TimeFormatDeterminer(); - if (null != timeDeterminer.DetermineDateTimeFormatInfo(line.FullLine)) - { - timeStampCount++; - } - else - { - timeStampCount--; - } - } - - if (timeStampCount > 0) - { - result = Priority.WellSupport; - } - - return result; - } - - #endregion - } +using System; +using System.Collections.Generic; +using System.Linq; + +namespace LogExpert.Core.Classes.Columnizer +{ + using static TimeFormatDeterminer; + + public class TimestampColumnizer : ILogLineColumnizer, IColumnizerPriority + { + + #region ILogLineColumnizer implementation + + protected int timeOffset = 0; + private TimeFormatDeterminer _timeFormatDeterminer = new(); + + public bool IsTimeshiftImplemented() + { + return true; + } + + public void SetTimeOffset(int msecOffset) + { + timeOffset = msecOffset; + } + + public int GetTimeOffset() + { + return timeOffset; + } + + + public DateTime GetTimestamp(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + { + IColumnizedLogLine cols = SplitLine(callback, line); + if (cols == null || cols.ColumnValues == null || cols.ColumnValues.Length < 2) + { + return DateTime.MinValue; + } + if (cols.ColumnValues[0].FullValue.Length == 0 || cols.ColumnValues[1].FullValue.Length == 0) + { + return DateTime.MinValue; + } + FormatInfo formatInfo = _timeFormatDeterminer.DetermineDateTimeFormatInfo(line.FullLine); + if (formatInfo == null) + { + return DateTime.MinValue; + } + + try + { + DateTime dateTime = DateTime.ParseExact( + cols.ColumnValues[0].FullValue + " " + cols.ColumnValues[1].FullValue, formatInfo.DateTimeFormat, + formatInfo.CultureInfo); + return dateTime; + } + catch (Exception) + { + return DateTime.MinValue; + } + } + + + public void PushValue(LogExpert.ILogLineColumnizerCallback callback, int column, string value, string oldValue) + { + if (column == 1) + { + try + { + FormatInfo formatInfo = _timeFormatDeterminer.DetermineTimeFormatInfo(oldValue); + if (formatInfo == null) + { + return; + } + DateTime newDateTime = DateTime.ParseExact(value, formatInfo.TimeFormat, formatInfo.CultureInfo); + DateTime oldDateTime = DateTime.ParseExact(oldValue, formatInfo.TimeFormat, formatInfo.CultureInfo); + long mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; + long mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; + timeOffset = (int)(mSecsNew - mSecsOld); + } + catch (FormatException) + { + } + } + } + + public string GetName() + { + return "Timestamp Columnizer"; + } + + public string GetDescription() + { + return "Splits every line into 3 fields: Date, Time and the rest of the log message"; + } + + public int GetColumnCount() + { + return 3; + } + + public string[] GetColumnNames() + { + return new string[] { "Date", "Time", "Message" }; + } + + public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + { + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 + // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + // 03.01.2008 14:48:00.066 + + ColumnizedLogLine clogLine = new(); + clogLine.LogLine = line; + + Column[] columns = new Column[3] + { + new() {FullValue = "", Parent = clogLine}, + new() {FullValue = "", Parent = clogLine}, + new() {FullValue = "", Parent = clogLine}, + }; + + clogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); + + string temp = line.FullLine; + + FormatInfo formatInfo = _timeFormatDeterminer.DetermineDateTimeFormatInfo(temp); + if (formatInfo == null) + { + columns[2].FullValue = temp; + return clogLine; + } + int endPos = formatInfo.DateTimeFormat.Length; + int timeLen = formatInfo.TimeFormat.Length; + int dateLen = formatInfo.DateFormat.Length; + try + { + if (timeOffset != 0) + { + if (formatInfo.IgnoreFirstChar) + { + // First character is a bracket and should be ignored + DateTime dateTime = DateTime.ParseExact(temp.Substring(1, endPos), formatInfo.DateTimeFormat, + formatInfo.CultureInfo); + dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); + string newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); + columns[0].FullValue = newDate.Substring(0, dateLen); // date + columns[1].FullValue = newDate.Substring(dateLen + 1, timeLen); // time + columns[2].FullValue = temp.Substring(endPos + 2); // rest of line + } + else + { + DateTime dateTime = DateTime.ParseExact(temp.Substring(0, endPos), formatInfo.DateTimeFormat, + formatInfo.CultureInfo); + dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); + string newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); + columns[0].FullValue = newDate.Substring(0, dateLen); // date + columns[1].FullValue = newDate.Substring(dateLen + 1, timeLen); // time + columns[2].FullValue = temp.Substring(endPos); // rest of line + } + } + else + { + if (formatInfo.IgnoreFirstChar) + { + // First character is a bracket and should be ignored + columns[0].FullValue = temp.Substring(1, dateLen); // date + columns[1].FullValue = temp.Substring(dateLen + 2, timeLen); // time + columns[2].FullValue = temp.Substring(endPos + 2); // rest of line + } + else + { + columns[0].FullValue = temp.Substring(0, dateLen); // date + columns[1].FullValue = temp.Substring(dateLen + 1, timeLen); // time + columns[2].FullValue = temp.Substring(endPos); // rest of line + } + } + } + catch (Exception) + { + columns[0].FullValue = "n/a"; + columns[1].FullValue = "n/a"; + columns[2].FullValue = temp; + } + return clogLine; + } + + public Priority GetPriority(string fileName, IEnumerable samples) + { + Priority result = Priority.NotSupport; + + int timeStampCount = 0; + foreach (var line in samples) + { + if (line == null || string.IsNullOrEmpty(line.FullLine)) + { + continue; + } + var timeDeterminer = new TimeFormatDeterminer(); + if (null != timeDeterminer.DetermineDateTimeFormatInfo(line.FullLine)) + { + timeStampCount++; + } + else + { + timeStampCount--; + } + } + + if (timeStampCount > 0) + { + result = Priority.WellSupport; + } + + return result; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/DateTimeParser/DateFormatPartAdjuster.cs b/src/Logexpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs similarity index 95% rename from src/LogExpert/Classes/DateTimeParser/DateFormatPartAdjuster.cs rename to src/Logexpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs index c803ea76..0855f9e5 100644 --- a/src/LogExpert/Classes/DateTimeParser/DateFormatPartAdjuster.cs +++ b/src/Logexpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace LogExpert.Classes.DateTimeParser +namespace LogExpert.Core.Classes.DateTimeParser { // Ensures we have constant width (number of characters) date formats public static class DateFormatPartAdjuster diff --git a/src/LogExpert/Classes/DateTimeParser/Parser.cs b/src/Logexpert.Core/Classes/DateTimeParser/Parser.cs similarity index 97% rename from src/LogExpert/Classes/DateTimeParser/Parser.cs rename to src/Logexpert.Core/Classes/DateTimeParser/Parser.cs index 11346954..cb558c06 100644 --- a/src/LogExpert/Classes/DateTimeParser/Parser.cs +++ b/src/Logexpert.Core/Classes/DateTimeParser/Parser.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.Runtime.CompilerServices; - -namespace LogExpert.Classes.DateTimeParser +namespace LogExpert.Core.Classes.DateTimeParser { public static class Parser { diff --git a/src/LogExpert/Classes/DateTimeParser/Section.cs b/src/Logexpert.Core/Classes/DateTimeParser/Section.cs similarity index 80% rename from src/LogExpert/Classes/DateTimeParser/Section.cs rename to src/Logexpert.Core/Classes/DateTimeParser/Section.cs index de17bd55..5f492b0e 100644 --- a/src/LogExpert/Classes/DateTimeParser/Section.cs +++ b/src/Logexpert.Core/Classes/DateTimeParser/Section.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace LogExpert.Classes.DateTimeParser +namespace LogExpert.Core.Classes.DateTimeParser { public class Section { diff --git a/src/LogExpert/Classes/DateTimeParser/Token.cs b/src/Logexpert.Core/Classes/DateTimeParser/Token.cs similarity index 92% rename from src/LogExpert/Classes/DateTimeParser/Token.cs rename to src/Logexpert.Core/Classes/DateTimeParser/Token.cs index bf9794ce..07483b9a 100644 --- a/src/LogExpert/Classes/DateTimeParser/Token.cs +++ b/src/Logexpert.Core/Classes/DateTimeParser/Token.cs @@ -1,6 +1,6 @@ using System; -namespace LogExpert.Classes.DateTimeParser +namespace LogExpert.Core.Classes.DateTimeParser { public static class Token { diff --git a/src/LogExpert/Classes/DateTimeParser/Tokenizer.cs b/src/Logexpert.Core/Classes/DateTimeParser/Tokenizer.cs similarity index 98% rename from src/LogExpert/Classes/DateTimeParser/Tokenizer.cs rename to src/Logexpert.Core/Classes/DateTimeParser/Tokenizer.cs index 39f5c9a2..baf16dba 100644 --- a/src/LogExpert/Classes/DateTimeParser/Tokenizer.cs +++ b/src/Logexpert.Core/Classes/DateTimeParser/Tokenizer.cs @@ -1,6 +1,6 @@ using System; -namespace LogExpert.Classes.DateTimeParser +namespace LogExpert.Core.Classes.DateTimeParser { internal class Tokenizer { diff --git a/src/LogExpert/Classes/FileSystemCallback.cs b/src/Logexpert.Core/Classes/FileSystemCallback.cs similarity index 86% rename from src/LogExpert/Classes/FileSystemCallback.cs rename to src/Logexpert.Core/Classes/FileSystemCallback.cs index f5abfefb..0fe50759 100644 --- a/src/LogExpert/Classes/FileSystemCallback.cs +++ b/src/Logexpert.Core/Classes/FileSystemCallback.cs @@ -1,49 +1,49 @@ -using NLog; - -namespace LogExpert.Classes -{ - internal class FileSystemCallback : IFileSystemCallback - { - #region Public methods - - public ILogExpertLogger GetLogger() - { - return new NLogLogExpertWrapper(); - } - - #endregion - - private class NLogLogExpertWrapper : ILogExpertLogger - { - #region Fields - - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - - #endregion - - #region Public methods - - public void Info(string msg) - { - _logger.Info(msg); - } - - public void Debug(string msg) - { - _logger.Debug(msg); - } - - public void LogWarn(string msg) - { - _logger.Warn(msg); - } - - public void LogError(string msg) - { - _logger.Error(msg); - } - - #endregion - } - } +using NLog; + +namespace LogExpert.Core.Classes +{ + public class FileSystemCallback : IFileSystemCallback + { + #region Public methods + + public ILogExpertLogger GetLogger() + { + return new NLogLogExpertWrapper(); + } + + #endregion + + private class NLogLogExpertWrapper : ILogExpertLogger + { + #region Fields + + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + + #endregion + + #region Public methods + + public void Info(string msg) + { + _logger.Info(msg); + } + + public void Debug(string msg) + { + _logger.Debug(msg); + } + + public void LogWarn(string msg) + { + _logger.Warn(msg); + } + + public void LogError(string msg) + { + _logger.Error(msg); + } + + #endregion + } + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Filter/FilterParams.cs b/src/Logexpert.Core/Classes/Filter/FilterParams.cs similarity index 94% rename from src/LogExpert/Classes/Filter/FilterParams.cs rename to src/Logexpert.Core/Classes/Filter/FilterParams.cs index 84febf51..8594297b 100644 --- a/src/LogExpert/Classes/Filter/FilterParams.cs +++ b/src/Logexpert.Core/Classes/Filter/FilterParams.cs @@ -1,139 +1,139 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Drawing; -using System.Text.RegularExpressions; - -namespace LogExpert.Classes.Filter -{ - [Serializable] - public class FilterParams - { - #region Fields - - public string _rangeSearchText = ""; - public string _searchText = ""; - - public Color color = Color.Black; - - //public List historyList = new List(); - //public List rangeHistoryList = new List(); - public List columnList = []; // list of columns in which to search - - public bool columnRestrict = false; - - [NonSerialized] public ILogLineColumnizer currentColumnizer; - - public bool emptyColumnHit; - public bool emptyColumnUsePrev; - - public bool exactColumnMatch = false; - - //public bool isFuzzy; - public int fuzzyValue = 0; - - public bool isCaseSensitive; - public bool isFilterTail; - - [NonSerialized] public bool isInRange = false; // false=looking for start, true=looking for end - - public bool isInvert; - public bool isRangeSearch = false; - public bool isRegex; - - [NonSerialized] public string lastLine = ""; - - [NonSerialized] public Hashtable lastNonEmptyCols = []; - - [NonSerialized] public bool lastResult; - - [NonSerialized] public string lowerRangeSearchText = ""; - - // transient members: - [NonSerialized] public string lowerSearchText = ""; - - [NonSerialized] public Regex rangeRex; - - [NonSerialized] public Regex rex; - - public int spreadBefore; - public int spreadBehind; - - #endregion - - #region Properties - - public string searchText - { - get => _searchText; - set - { - _searchText = value; - lowerSearchText = _searchText.ToLower(); - } - } - - public string rangeSearchText - { - get => _rangeSearchText; - set - { - _rangeSearchText = value; - lowerRangeSearchText = _rangeSearchText.ToLower(); - } - } - - public bool SpreadEnabled => spreadBefore > 0 || spreadBehind > 0; - - #endregion - - #region Public methods - - public FilterParams CreateCopy2() - { - FilterParams newParams = CreateCopy(); - newParams.Init(); - // removed cloning of columnizer for filtering, because this causes issues with columnizers that hold internal states (like CsvColumnizer) - // newParams.currentColumnizer = Util.CloneColumnizer(this.currentColumnizer); - newParams.currentColumnizer = currentColumnizer; - return newParams; - } - - // call after deserialization! - public void Init() - { - lastNonEmptyCols = []; - lowerRangeSearchText = _rangeSearchText.ToLower(); - lowerSearchText = _searchText.ToLower(); - lastLine = ""; - } - - // Reset before a new search - public void Reset() - { - lastNonEmptyCols.Clear(); - isInRange = false; - } - - public void CreateRegex() - { - if (_searchText != null) - { - rex = new Regex(_searchText, - isCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); - } - if (_rangeSearchText != null && isRangeSearch) - { - rangeRex = new Regex(_rangeSearchText, - isCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); - } - } - - public FilterParams CreateCopy() - { - return (FilterParams) MemberwiseClone(); - } - - #endregion - } +using System; +using System.Collections; +using System.Collections.Generic; +using System.Drawing; +using System.Text.RegularExpressions; + +namespace LogExpert.Core.Classes.Filter +{ + [Serializable] + public class FilterParams + { + #region Fields + + public string _rangeSearchText = ""; + public string _searchText = ""; + + public Color color = Color.Black; + + //public List historyList = new List(); + //public List rangeHistoryList = new List(); + public List columnList = []; // list of columns in which to search + + public bool columnRestrict = false; + + [NonSerialized] public ILogLineColumnizer currentColumnizer; + + public bool emptyColumnHit; + public bool emptyColumnUsePrev; + + public bool exactColumnMatch = false; + + //public bool isFuzzy; + public int fuzzyValue = 0; + + public bool isCaseSensitive; + public bool isFilterTail; + + [NonSerialized] public bool isInRange = false; // false=looking for start, true=looking for end + + public bool isInvert; + public bool isRangeSearch = false; + public bool isRegex; + + [NonSerialized] public string lastLine = ""; + + [NonSerialized] public Hashtable lastNonEmptyCols = []; + + [NonSerialized] public bool lastResult; + + [NonSerialized] public string lowerRangeSearchText = ""; + + // transient members: + [NonSerialized] public string lowerSearchText = ""; + + [NonSerialized] public Regex rangeRex; + + [NonSerialized] public Regex rex; + + public int spreadBefore; + public int spreadBehind; + + #endregion + + #region Properties + + public string searchText + { + get => _searchText; + set + { + _searchText = value; + lowerSearchText = _searchText.ToLower(); + } + } + + public string rangeSearchText + { + get => _rangeSearchText; + set + { + _rangeSearchText = value; + lowerRangeSearchText = _rangeSearchText.ToLower(); + } + } + + public bool SpreadEnabled => spreadBefore > 0 || spreadBehind > 0; + + #endregion + + #region Public methods + + public FilterParams CreateCopy2() + { + FilterParams newParams = CreateCopy(); + newParams.Init(); + // removed cloning of columnizer for filtering, because this causes issues with columnizers that hold internal states (like CsvColumnizer) + // newParams.currentColumnizer = Util.CloneColumnizer(this.currentColumnizer); + newParams.currentColumnizer = currentColumnizer; + return newParams; + } + + // call after deserialization! + public void Init() + { + lastNonEmptyCols = []; + lowerRangeSearchText = _rangeSearchText.ToLower(); + lowerSearchText = _searchText.ToLower(); + lastLine = ""; + } + + // Reset before a new search + public void Reset() + { + lastNonEmptyCols.Clear(); + isInRange = false; + } + + public void CreateRegex() + { + if (_searchText != null) + { + rex = new Regex(_searchText, + isCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); + } + if (_rangeSearchText != null && isRangeSearch) + { + rangeRex = new Regex(_rangeSearchText, + isCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); + } + } + + public FilterParams CreateCopy() + { + return (FilterParams)MemberwiseClone(); + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Highlight/ActionEntry.cs b/src/Logexpert.Core/Classes/Highlight/ActionEntry.cs similarity index 88% rename from src/LogExpert/Classes/Highlight/ActionEntry.cs rename to src/Logexpert.Core/Classes/Highlight/ActionEntry.cs index 1d65712f..f3cf6c5d 100644 --- a/src/LogExpert/Classes/Highlight/ActionEntry.cs +++ b/src/Logexpert.Core/Classes/Highlight/ActionEntry.cs @@ -1,27 +1,27 @@ -using System; - -namespace LogExpert.Classes.Highlight -{ - [Serializable] - public class ActionEntry : ICloneable - { - #region Fields - - public string ActionParam { get; set; } - - public string PluginName { get; set; } - - public object Clone() - { - var actionEntry = new ActionEntry - { - PluginName = PluginName, - ActionParam = ActionParam - }; - - return actionEntry; - } - - #endregion - } +using System; + +namespace LogExpert.Core.Classes.Highlight +{ + [Serializable] + public class ActionEntry : ICloneable + { + #region Fields + + public string ActionParam { get; set; } + + public string PluginName { get; set; } + + public object Clone() + { + var actionEntry = new ActionEntry + { + PluginName = PluginName, + ActionParam = ActionParam + }; + + return actionEntry; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Highlight/HilightEntry.cs b/src/Logexpert.Core/Classes/Highlight/HilightEntry.cs similarity index 94% rename from src/LogExpert/Classes/Highlight/HilightEntry.cs rename to src/Logexpert.Core/Classes/Highlight/HilightEntry.cs index 18e02db9..cb93663a 100644 --- a/src/LogExpert/Classes/Highlight/HilightEntry.cs +++ b/src/Logexpert.Core/Classes/Highlight/HilightEntry.cs @@ -1,108 +1,107 @@ -using Newtonsoft.Json; - -using System; -using System.Drawing; -using System.Text.RegularExpressions; - -namespace LogExpert.Classes.Highlight -{ - [Serializable] - [method: JsonConstructor] - public class HilightEntry() : ICloneable - { - #region Fields - - [NonSerialized] private Regex regex = null; - - private string _searchText = string.Empty; - - #endregion Fields - - #region Properties - - public bool IsStopTail { get; set; } - - public bool IsSetBookmark { get; set; } - - public bool IsRegEx { get; set; } - - public bool IsCaseSensitive { get; set; } - - public Color ForegroundColor { get; set; } - - public Color BackgroundColor { get; set; } - - public string SearchText - { - get => _searchText; - set - { - _searchText = value; - regex = null; - } - } - - public bool IsLedSwitch { get; set; } - - public ActionEntry ActionEntry { get; set; } - - public bool IsActionEntry { get; set; } - - public string BookmarkComment { get; set; } - - public Regex Regex - { - get - { - if (regex == null) - { - if (IsRegEx) - { - regex = new Regex(SearchText, IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); - } - else - { - regex = new Regex(Regex.Escape(SearchText), IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); - } - } - return regex; - } - } - - public bool IsWordMatch { get; set; } - - // highlightes search result - [field: NonSerialized] - public bool IsSearchHit { get; set; } - - public bool IsBold { get; set; } - - public bool NoBackground { get; set; } - - public object Clone() - { - var highLightEntry = new HilightEntry - { - SearchText = SearchText, - ForegroundColor = ForegroundColor, - BackgroundColor = BackgroundColor, - IsRegEx = IsRegEx, - IsCaseSensitive = IsCaseSensitive, - IsLedSwitch = IsLedSwitch, - IsStopTail = IsStopTail, - IsSetBookmark = IsSetBookmark, - IsActionEntry = IsActionEntry, - ActionEntry = ActionEntry != null ? (ActionEntry)ActionEntry.Clone() : null, - IsWordMatch = IsWordMatch, - IsBold = IsBold, - BookmarkComment = BookmarkComment, - NoBackground = NoBackground, - IsSearchHit = IsSearchHit - }; - - return highLightEntry; - } - - #endregion Properties - } +using Newtonsoft.Json; + +using System.Drawing; +using System.Text.RegularExpressions; + +namespace LogExpert.Core.Classes.Highlight +{ + [Serializable] + [method: JsonConstructor] + public class HilightEntry() : ICloneable + { + #region Fields + + [NonSerialized] private Regex regex = null; + + private string _searchText = string.Empty; + + #endregion Fields + + #region Properties + + public bool IsStopTail { get; set; } + + public bool IsSetBookmark { get; set; } + + public bool IsRegEx { get; set; } + + public bool IsCaseSensitive { get; set; } + + public Color ForegroundColor { get; set; } + + public Color BackgroundColor { get; set; } + + public string SearchText + { + get => _searchText; + set + { + _searchText = value; + regex = null; + } + } + + public bool IsLedSwitch { get; set; } + + public ActionEntry ActionEntry { get; set; } + + public bool IsActionEntry { get; set; } + + public string BookmarkComment { get; set; } + + public Regex Regex + { + get + { + if (regex == null) + { + if (IsRegEx) + { + regex = new Regex(SearchText, IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); + } + else + { + regex = new Regex(Regex.Escape(SearchText), IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); + } + } + return regex; + } + } + + public bool IsWordMatch { get; set; } + + // highlightes search result + [field: NonSerialized] + public bool IsSearchHit { get; set; } + + public bool IsBold { get; set; } + + public bool NoBackground { get; set; } + + public object Clone() + { + var highLightEntry = new HilightEntry + { + SearchText = SearchText, + ForegroundColor = ForegroundColor, + BackgroundColor = BackgroundColor, + IsRegEx = IsRegEx, + IsCaseSensitive = IsCaseSensitive, + IsLedSwitch = IsLedSwitch, + IsStopTail = IsStopTail, + IsSetBookmark = IsSetBookmark, + IsActionEntry = IsActionEntry, + ActionEntry = ActionEntry != null ? (ActionEntry)ActionEntry.Clone() : null, + IsWordMatch = IsWordMatch, + IsBold = IsBold, + BookmarkComment = BookmarkComment, + NoBackground = NoBackground, + IsSearchHit = IsSearchHit + }; + + return highLightEntry; + } + + #endregion Properties + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Highlight/HilightMatchEntry.cs b/src/Logexpert.Core/Classes/Highlight/HilightMatchEntry.cs similarity index 89% rename from src/LogExpert/Classes/Highlight/HilightMatchEntry.cs rename to src/Logexpert.Core/Classes/Highlight/HilightMatchEntry.cs index b1e3fcdd..d794e3ab 100644 --- a/src/LogExpert/Classes/Highlight/HilightMatchEntry.cs +++ b/src/Logexpert.Core/Classes/Highlight/HilightMatchEntry.cs @@ -1,27 +1,27 @@ -namespace LogExpert.Classes.Highlight -{ - /// - /// Class for storing word-wise hilight matches. Used for colouring different matches on one line. - /// - public class HilightMatchEntry - { - #region Properties - - public HilightEntry HilightEntry { get; set; } - - public int StartPos { get; set; } - - public int Length { get; set; } - - #endregion - - #region Public methods - - public override string ToString() - { - return $"{HilightEntry.SearchText}/{StartPos}/{Length}"; - } - - #endregion - } +namespace LogExpert.Core.Classes.Highlight +{ + /// + /// Class for storing word-wise hilight matches. Used for colouring different matches on one line. + /// + public class HilightMatchEntry + { + #region Properties + + public HilightEntry HilightEntry { get; set; } + + public int StartPos { get; set; } + + public int Length { get; set; } + + #endregion + + #region Public methods + + public override string ToString() + { + return $"{HilightEntry.SearchText}/{StartPos}/{Length}"; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Log/LogBuffer.cs b/src/Logexpert.Core/Classes/Log/LogBuffer.cs similarity index 92% rename from src/LogExpert/Classes/Log/LogBuffer.cs rename to src/Logexpert.Core/Classes/Log/LogBuffer.cs index d9c07400..896ca8b3 100644 --- a/src/LogExpert/Classes/Log/LogBuffer.cs +++ b/src/Logexpert.Core/Classes/Log/LogBuffer.cs @@ -1,125 +1,124 @@ -using System.Collections.Generic; -using NLog; - -namespace LogExpert.Classes.Log -{ - public class LogBuffer - { - #region Fields - - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - -#if DEBUG - private readonly IList _filePositions = new List(); // file position for every line -#endif - - private readonly IList _logLines = new List(); - private int MAX_LINES = 500; - private long _size; - - #endregion - - #region cTor - - //public LogBuffer() { } - - public LogBuffer(ILogFileInfo fileInfo, int maxLines) - { - FileInfo = fileInfo; - MAX_LINES = maxLines; - } - - #endregion - - #region Properties - - public long StartPos { set; get; } = 0; - - public long Size - { - set - { - _size = value; -#if DEBUG - if (_filePositions.Count > 0) - { - if (_size < _filePositions[_filePositions.Count - 1] - StartPos) - { - _logger.Error("LogBuffer overall Size must be greater than last line file position!"); - } - } -#endif - } - get => _size; - } - - public int StartLine { set; get; } = 0; - - public int LineCount { get; private set; } - - public bool IsDisposed { get; private set; } - - public ILogFileInfo FileInfo { get; set; } - - public int DroppedLinesCount { get; set; } = 0; - - public int PrevBuffersDroppedLinesSum { get; set; } = 0; - - #endregion - - #region Public methods - - public void AddLine(ILogLine line, long filePos) - { - _logLines.Add(line); -#if DEBUG - _filePositions.Add(filePos); -#endif - LineCount++; - IsDisposed = false; - } - - public void ClearLines() - { - _logLines.Clear(); - LineCount = 0; - } - - public void DisposeContent() - { - _logLines.Clear(); - IsDisposed = true; -#if DEBUG - DisposeCount++; -#endif - } - - public ILogLine GetLineOfBlock(int num) - { - if (num < _logLines.Count && num >= 0) - { - return _logLines[num]; - } - - return null; - } - - #endregion - -#if DEBUG - public long DisposeCount { get; private set; } - - - public long GetFilePosForLineOfBlock(int line) - { - if (line >= 0 && line < _filePositions.Count) - { - return _filePositions[line]; - } - - return -1; - } - -#endif - } +using NLog; + +namespace LogExpert.Core.Classes.Log +{ + public class LogBuffer + { + #region Fields + + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + +#if DEBUG + private readonly IList _filePositions = new List(); // file position for every line +#endif + + private readonly IList _logLines = new List(); + private int MAX_LINES = 500; + private long _size; + + #endregion + + #region cTor + + //public LogBuffer() { } + + public LogBuffer(ILogFileInfo fileInfo, int maxLines) + { + FileInfo = fileInfo; + MAX_LINES = maxLines; + } + + #endregion + + #region Properties + + public long StartPos { set; get; } = 0; + + public long Size + { + set + { + _size = value; +#if DEBUG + if (_filePositions.Count > 0) + { + if (_size < _filePositions[_filePositions.Count - 1] - StartPos) + { + _logger.Error("LogBuffer overall Size must be greater than last line file position!"); + } + } +#endif + } + get => _size; + } + + public int StartLine { set; get; } = 0; + + public int LineCount { get; private set; } + + public bool IsDisposed { get; private set; } + + public ILogFileInfo FileInfo { get; set; } + + public int DroppedLinesCount { get; set; } = 0; + + public int PrevBuffersDroppedLinesSum { get; set; } = 0; + + #endregion + + #region Public methods + + public void AddLine(ILogLine line, long filePos) + { + _logLines.Add(line); +#if DEBUG + _filePositions.Add(filePos); +#endif + LineCount++; + IsDisposed = false; + } + + public void ClearLines() + { + _logLines.Clear(); + LineCount = 0; + } + + public void DisposeContent() + { + _logLines.Clear(); + IsDisposed = true; +#if DEBUG + DisposeCount++; +#endif + } + + public ILogLine GetLineOfBlock(int num) + { + if (num < _logLines.Count && num >= 0) + { + return _logLines[num]; + } + + return null; + } + + #endregion + +#if DEBUG + public long DisposeCount { get; private set; } + + + public long GetFilePosForLineOfBlock(int line) + { + if (line >= 0 && line < _filePositions.Count) + { + return _filePositions[line]; + } + + return -1; + } + +#endif + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Log/LogBufferCacheEntry.cs b/src/Logexpert.Core/Classes/Log/LogBufferCacheEntry.cs similarity index 60% rename from src/LogExpert/Classes/Log/LogBufferCacheEntry.cs rename to src/Logexpert.Core/Classes/Log/LogBufferCacheEntry.cs index c80ca6ed..72230efc 100644 --- a/src/LogExpert/Classes/Log/LogBufferCacheEntry.cs +++ b/src/Logexpert.Core/Classes/Log/LogBufferCacheEntry.cs @@ -1,37 +1,35 @@ -using System; - -namespace LogExpert.Classes.Log -{ - internal class LogBufferCacheEntry - { - #region Fields - - #endregion - - #region cTor - - public LogBufferCacheEntry() - { - Touch(); - } - - #endregion - - #region Properties - - internal LogBuffer LogBuffer { get; set; } - - public long LastUseTimeStamp { get; private set; } - - #endregion - - #region Public methods - - public void Touch() - { - LastUseTimeStamp = (long) (Environment.TickCount & int.MaxValue); - } - - #endregion - } +namespace LogExpert.Core.Classes.Log +{ + public class LogBufferCacheEntry + { + #region Fields + + #endregion + + #region cTor + + public LogBufferCacheEntry() + { + Touch(); + } + + #endregion + + #region Properties + + public LogBuffer LogBuffer { get; set; } + + public long LastUseTimeStamp { get; private set; } + + #endregion + + #region Public methods + + public void Touch() + { + LastUseTimeStamp = Environment.TickCount & int.MaxValue; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Log/LogStreamReaderBase.cs b/src/Logexpert.Core/Classes/Log/LogStreamReaderBase.cs similarity index 95% rename from src/LogExpert/Classes/Log/LogStreamReaderBase.cs rename to src/Logexpert.Core/Classes/Log/LogStreamReaderBase.cs index e47bc9af..0b8c649a 100644 --- a/src/LogExpert/Classes/Log/LogStreamReaderBase.cs +++ b/src/Logexpert.Core/Classes/Log/LogStreamReaderBase.cs @@ -1,8 +1,9 @@ using System; using System.Text; -using LogExpert.Interface; -namespace LogExpert.Classes.Log +using LogExpert.Core.Interface; + +namespace LogExpert.Core.Classes.Log { public abstract class LogStreamReaderBase : ILogStreamReader { diff --git a/src/LogExpert/Classes/Log/PositionAwareStreamReaderBase.cs b/src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs similarity index 93% rename from src/LogExpert/Classes/Log/PositionAwareStreamReaderBase.cs rename to src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs index 68e46989..29585492 100644 --- a/src/LogExpert/Classes/Log/PositionAwareStreamReaderBase.cs +++ b/src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs @@ -1,224 +1,224 @@ -using LogExpert.Config; -using LogExpert.Entities; - -using System; -using System.IO; -using System.Text; - -namespace LogExpert.Classes.Log -{ - public abstract class PositionAwareStreamReaderBase : LogStreamReaderBase - { - #region Fields - - private const int MAX_LINE_LEN = 20000; - - private static readonly Encoding[] _preambleEncodings = { Encoding.UTF8, Encoding.Unicode, Encoding.BigEndianUnicode, Encoding.UTF32 }; - - private readonly BufferedStream _stream; - private readonly StreamReader _reader; - - private readonly int _preambleLength; - private readonly int _posIncPrecomputed; - - private long _position; - - #endregion - - #region cTor - - protected PositionAwareStreamReaderBase(Stream stream, EncodingOptions encodingOptions) - { - _stream = new BufferedStream(stream); - - _preambleLength = DetectPreambleLengthAndEncoding(out Encoding detectedEncoding); - - Encoding usedEncoding = GetUsedEncoding(encodingOptions, detectedEncoding); - _posIncPrecomputed = GetPosIncPrecomputed(usedEncoding); - - _reader = new StreamReader(_stream, usedEncoding, true); - - Position = 0; - } - - #endregion - - #region Properties - - /// - /// Current position in the stream. - /// - public sealed override long Position - { - get => _position; - set - { - /* - * 1: Sometime commented (+Encoding.GetPreamble().Length) - * 2: Date 1.1 3207 - * 3: Error Message from Piet because of Unicode-Bugs. - * No Idea, if this is OK. - * 4: 27.07.09: Preamble-Length is now calculated in CT, because Encoding.GetPreamble().Length - * always delivers a fixed length (does not mater what kind of data) - */ - _position = value; // +Encoding.GetPreamble().Length; // 1 - //stream.Seek(pos, SeekOrigin.Begin); // 2 - //stream.Seek(pos + Encoding.GetPreamble().Length, SeekOrigin.Begin); // 3 - _stream.Seek(_position + _preambleLength, SeekOrigin.Begin); // 4 - - ResetReader(); - } - } - - public sealed override Encoding Encoding => _reader.CurrentEncoding; - - public sealed override bool IsBufferComplete => true; - - protected static int MaxLineLen => ConfigManager.Settings.Preferences.MaxLineLength; - - #endregion - - #region Public methods - - /// - /// Destroy and release the current stream reader. - /// - /// Specifies whether or not the managed objects should be released. - protected override void Dispose(bool disposing) - { - if (disposing) - { - _stream.Dispose(); - _reader.Dispose(); - } - } - - public override unsafe int ReadChar() - { - if (IsDisposed) - { - throw new ObjectDisposedException(ToString()); - } - - try - { - int readInt = _reader.Read(); - if (readInt != -1) - { - char readChar = (char)readInt; - if (_posIncPrecomputed != 0) - { - _position += _posIncPrecomputed; - } - else - { - _position += _reader.CurrentEncoding.GetByteCount(&readChar, 1); - } - } - return readInt; - } - catch (IOException) - { - return -1; - } - } - - protected virtual void ResetReader() - { - _reader.DiscardBufferedData(); - } - - protected StreamReader GetStreamReader() - { - return IsDisposed ? throw new ObjectDisposedException(ToString()) : _reader; - } - - protected void MovePosition(int offset) - { - _position += offset; - } - - #endregion - - #region Private Methods - - /// - /// Determines the actual number of preamble bytes in the file. - /// - /// Number of preamble bytes in the file - private int DetectPreambleLengthAndEncoding(out Encoding detectedEncoding) - { - /* - UTF-8: EF BB BF - UTF-16-Big-Endian-Byteorder: FE FF - UTF-16-Little-Endian-Byteorder: FF FE - UTF-32-Big-Endian-Byteorder: 00 00 FE FF - UTF-32-Little-Endian-Byteorder: FF FE 00 00 - */ - - byte[] readPreamble = new byte[4]; - int readLen = _stream.Read(readPreamble, 0, 4); - if (readLen >= 2) - { - foreach (Encoding encoding in _preambleEncodings) - { - byte[] preamble = encoding.GetPreamble(); - bool fail = false; - for (int i = 0; i < readLen && i < preamble.Length; ++i) - { - if (readPreamble[i] != preamble[i]) - { - fail = true; - break; - } - } - - if (!fail) - { - detectedEncoding = encoding; - return preamble.Length; - } - } - } - - // not found or less than 2 byte read - detectedEncoding = null; - return 0; - } - - private Encoding GetUsedEncoding(EncodingOptions encodingOptions, Encoding detectedEncoding) - { - if (encodingOptions.Encoding != null) - { - return encodingOptions.Encoding; - } - - if (detectedEncoding != null) - { - return detectedEncoding; - } - - return encodingOptions.DefaultEncoding ?? Encoding.Default; - } - private int GetPosIncPrecomputed(Encoding usedEncoding) - { - switch (usedEncoding) - { - case UTF8Encoding _: - { - return 0; - } - case UnicodeEncoding _: - { - return 2; - } - default: - { - return 1; - } - } - } - - #endregion - } +using LogExpert.Core.Entities; + +using System.Text; + +namespace LogExpert.Core.Classes.Log +{ + public abstract class PositionAwareStreamReaderBase : LogStreamReaderBase + { + #region Fields + + private const int MAX_LINE_LEN = 20000; + + private static readonly Encoding[] _preambleEncodings = { Encoding.UTF8, Encoding.Unicode, Encoding.BigEndianUnicode, Encoding.UTF32 }; + + private readonly BufferedStream _stream; + private readonly StreamReader _reader; + + private readonly int _preambleLength; + private readonly int _posIncPrecomputed; + + private long _position; + + #endregion + + #region cTor + + protected PositionAwareStreamReaderBase(Stream stream, EncodingOptions encodingOptions) + { + _stream = new BufferedStream(stream); + + _preambleLength = DetectPreambleLengthAndEncoding(out Encoding detectedEncoding); + + Encoding usedEncoding = GetUsedEncoding(encodingOptions, detectedEncoding); + _posIncPrecomputed = GetPosIncPrecomputed(usedEncoding); + + _reader = new StreamReader(_stream, usedEncoding, true); + + Position = 0; + } + + #endregion + + #region Properties + + /// + /// Current position in the stream. + /// + public sealed override long Position + { + get => _position; + set + { + /* + * 1: Sometime commented (+Encoding.GetPreamble().Length) + * 2: Date 1.1 3207 + * 3: Error Message from Piet because of Unicode-Bugs. + * No Idea, if this is OK. + * 4: 27.07.09: Preamble-Length is now calculated in CT, because Encoding.GetPreamble().Length + * always delivers a fixed length (does not mater what kind of data) + */ + _position = value; // +Encoding.GetPreamble().Length; // 1 + //stream.Seek(pos, SeekOrigin.Begin); // 2 + //stream.Seek(pos + Encoding.GetPreamble().Length, SeekOrigin.Begin); // 3 + _stream.Seek(_position + _preambleLength, SeekOrigin.Begin); // 4 + + ResetReader(); + } + } + + public sealed override Encoding Encoding => _reader.CurrentEncoding; + + public sealed override bool IsBufferComplete => true; + + //Refactor this needs to be given and should not be added like this + protected static int MaxLineLen => 500;//ConfigManager.Settings.Preferences.MaxLineLength; + + #endregion + + #region Public methods + + /// + /// Destroy and release the current stream reader. + /// + /// Specifies whether or not the managed objects should be released. + protected override void Dispose(bool disposing) + { + if (disposing) + { + _stream.Dispose(); + _reader.Dispose(); + } + } + + //TODO This is unsafe and should be refactored + public override unsafe int ReadChar() + { + //ObjectDisposedException.ThrowIf + if (IsDisposed) + { + throw new ObjectDisposedException(ToString()); + } + + try + { + int readInt = _reader.Read(); + if (readInt != -1) + { + char readChar = (char)readInt; + if (_posIncPrecomputed != 0) + { + _position += _posIncPrecomputed; + } + else + { + _position += _reader.CurrentEncoding.GetByteCount(&readChar, 1); + } + } + return readInt; + } + catch (IOException) + { + return -1; + } + } + + protected virtual void ResetReader() + { + _reader.DiscardBufferedData(); + } + + protected StreamReader GetStreamReader() + { + return IsDisposed ? throw new ObjectDisposedException(ToString()) : _reader; + } + + protected void MovePosition(int offset) + { + _position += offset; + } + + #endregion + + #region Private Methods + + /// + /// Determines the actual number of preamble bytes in the file. + /// + /// Number of preamble bytes in the file + private int DetectPreambleLengthAndEncoding(out Encoding detectedEncoding) + { + /* + UTF-8: EF BB BF + UTF-16-Big-Endian-Byteorder: FE FF + UTF-16-Little-Endian-Byteorder: FF FE + UTF-32-Big-Endian-Byteorder: 00 00 FE FF + UTF-32-Little-Endian-Byteorder: FF FE 00 00 + */ + + byte[] readPreamble = new byte[4]; + int readLen = _stream.Read(readPreamble, 0, 4); + if (readLen >= 2) + { + foreach (Encoding encoding in _preambleEncodings) + { + byte[] preamble = encoding.GetPreamble(); + bool fail = false; + for (int i = 0; i < readLen && i < preamble.Length; ++i) + { + if (readPreamble[i] != preamble[i]) + { + fail = true; + break; + } + } + + if (!fail) + { + detectedEncoding = encoding; + return preamble.Length; + } + } + } + + // not found or less than 2 byte read + detectedEncoding = null; + return 0; + } + + private Encoding GetUsedEncoding(EncodingOptions encodingOptions, Encoding detectedEncoding) + { + if (encodingOptions.Encoding != null) + { + return encodingOptions.Encoding; + } + + if (detectedEncoding != null) + { + return detectedEncoding; + } + + return encodingOptions.DefaultEncoding ?? Encoding.Default; + } + private int GetPosIncPrecomputed(Encoding usedEncoding) + { + switch (usedEncoding) + { + case UTF8Encoding _: + { + return 0; + } + case UnicodeEncoding _: + { + return 2; + } + default: + { + return 1; + } + } + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Log/PositionAwareStreamReaderLegacy.cs b/src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs similarity index 73% rename from src/LogExpert/Classes/Log/PositionAwareStreamReaderLegacy.cs rename to src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs index 594eccff..c408d15f 100644 --- a/src/LogExpert/Classes/Log/PositionAwareStreamReaderLegacy.cs +++ b/src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs @@ -1,111 +1,110 @@ -using System.IO; -using LogExpert.Entities; - -namespace LogExpert.Classes.Log -{ - public class PositionAwareStreamReaderLegacy : PositionAwareStreamReaderBase - { - #region Fields - - private readonly char[] _charBuffer = new char[MaxLineLen]; - - private int _charBufferPos; - private bool _crDetect; - - #endregion - - #region cTor - - public PositionAwareStreamReaderLegacy(Stream stream, EncodingOptions encodingOptions) : base(stream, encodingOptions) - { - - } - - #endregion - - #region Public methods - - public override string ReadLine() - { - int readInt; - - while (-1 != (readInt = ReadChar())) - { - char readChar = (char)readInt; - - switch (readChar) - { - case '\n': - { - _crDetect = false; - return GetLineAndResetCharBufferPos(); - } - case '\r': - { - if (_crDetect) - { - return GetLineAndResetCharBufferPos(); - } - - _crDetect = true; - break; - } - default: - { - if (_crDetect) - { - _crDetect = false; - string line = GetLineAndResetCharBufferPos(); - AppendToCharBuffer(readChar); - return line; - } - - AppendToCharBuffer(readChar); - break; - } - } - } - - string result = GetLineAndResetCharBufferPos(); - if (readInt == -1 && result.Length == 0 && !_crDetect) - { - return null; // EOF - } - _crDetect = false; - return result; - } - - protected override void ResetReader() - { - ResetCharBufferPos(); - - base.ResetReader(); - } - - #endregion - - #region Private Methods - - private string GetLineAndResetCharBufferPos() - { - string result = new(_charBuffer, 0, _charBufferPos); - ResetCharBufferPos(); - return result; - } - - private void AppendToCharBuffer(char readChar) - { - if (_charBufferPos < MaxLineLen) - { - _charBuffer[_charBufferPos++] = readChar; - } - } - - private void ResetCharBufferPos() - { - _charBufferPos = 0; - } - - #endregion - } +using LogExpert.Core.Entities; + +namespace LogExpert.Core.Classes.Log +{ + public class PositionAwareStreamReaderLegacy : PositionAwareStreamReaderBase + { + #region Fields + + private readonly char[] _charBuffer = new char[MaxLineLen]; + + private int _charBufferPos; + private bool _crDetect; + + #endregion + + #region cTor + + public PositionAwareStreamReaderLegacy(Stream stream, EncodingOptions encodingOptions) : base(stream, encodingOptions) + { + + } + + #endregion + + #region Public methods + + public override string ReadLine() + { + int readInt; + + while (-1 != (readInt = ReadChar())) + { + char readChar = (char)readInt; + + switch (readChar) + { + case '\n': + { + _crDetect = false; + return GetLineAndResetCharBufferPos(); + } + case '\r': + { + if (_crDetect) + { + return GetLineAndResetCharBufferPos(); + } + + _crDetect = true; + break; + } + default: + { + if (_crDetect) + { + _crDetect = false; + string line = GetLineAndResetCharBufferPos(); + AppendToCharBuffer(readChar); + return line; + } + + AppendToCharBuffer(readChar); + break; + } + } + } + + string result = GetLineAndResetCharBufferPos(); + if (readInt == -1 && result.Length == 0 && !_crDetect) + { + return null; // EOF + } + _crDetect = false; + return result; + } + + protected override void ResetReader() + { + ResetCharBufferPos(); + + base.ResetReader(); + } + + #endregion + + #region Private Methods + + private string GetLineAndResetCharBufferPos() + { + string result = new(_charBuffer, 0, _charBufferPos); + ResetCharBufferPos(); + return result; + } + + private void AppendToCharBuffer(char readChar) + { + if (_charBufferPos < MaxLineLen) + { + _charBuffer[_charBufferPos++] = readChar; + } + } + + private void ResetCharBufferPos() + { + _charBufferPos = 0; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Log/PositionAwareStreamReaderSystem.cs b/src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs similarity index 96% rename from src/LogExpert/Classes/Log/PositionAwareStreamReaderSystem.cs rename to src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs index c74b30df..28495436 100644 --- a/src/LogExpert/Classes/Log/PositionAwareStreamReaderSystem.cs +++ b/src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs @@ -1,7 +1,6 @@ -using System.IO; -using LogExpert.Entities; +using LogExpert.Core.Entities; -namespace LogExpert.Classes.Log +namespace LogExpert.Core.Classes.Log { /// /// This class is responsible for reading line from the log file. It also decodes characters with the appropriate charset encoding. @@ -24,7 +23,7 @@ public class PositionAwareStreamReaderSystem : PositionAwareStreamReaderBase public PositionAwareStreamReaderSystem(Stream stream, EncodingOptions encodingOptions) : base(stream, encodingOptions) { - + } #endregion @@ -70,7 +69,7 @@ private int GuessNewLineSequenceLength(StreamReader reader) if (line != null) { Position += Encoding.GetByteCount(line); - + int firstChar = reader.Read(); if (firstChar == CHAR_CR) // check \r { diff --git a/src/LogExpert/Classes/Log/RolloverFilenameBuilder.cs b/src/Logexpert.Core/Classes/Log/RolloverFilenameBuilder.cs similarity index 95% rename from src/LogExpert/Classes/Log/RolloverFilenameBuilder.cs rename to src/Logexpert.Core/Classes/Log/RolloverFilenameBuilder.cs index f2cdc7c9..faca9c2a 100644 --- a/src/LogExpert/Classes/Log/RolloverFilenameBuilder.cs +++ b/src/Logexpert.Core/Classes/Log/RolloverFilenameBuilder.cs @@ -1,238 +1,237 @@ -using System; -using System.Globalization; -using System.Text; -using System.Text.RegularExpressions; - -namespace LogExpert.Classes.Log -{ - /* Needed info: - * - Date/time mask - * - index counters - * - counter direction (up/down) - * - counter limit - * - whether the files are shifted or not - * - whether the indexes start with zero (or n/a) on a new date period - * - * Format: - * *$D(yyyy-MM-dd)$I - * *$J(.) - * - * *(yyyy-MM-dd)[I] - * - */ - - /// - /// This class is responsible for building file names for multifile. - /// - public class RolloverFilenameBuilder - { - #region Fields - - private string _condContent; - private Group _condGroup; - private string _currentFileName; - - private Group _dateGroup; - - //private Regex regexCond; - private DateTime _dateTime; - - //private DateTimeFormatInfo dateFormat; - private string _dateTimeFormat; - - private bool _hideZeroIndex; - private Group _indexGroup; - private Regex _regex; - - #endregion - - #region cTor - - public RolloverFilenameBuilder(string formatString) - { - ParseFormatString(formatString); - } - - #endregion - - #region Properties - - public int Index { get; set; } - - public bool IsDatePattern => _dateGroup != null && _dateGroup.Success; - - public bool IsIndexPattern => _indexGroup != null && _indexGroup.Success; - - #endregion - - #region Public methods - - public void SetFileName(string fileName) - { - _currentFileName = fileName; - Match match = _regex.Match(fileName); - if (match.Success) - { - _dateGroup = match.Groups["date"]; - if (_dateGroup.Success) - { - string date = fileName.Substring(_dateGroup.Index, _dateGroup.Length); - if (DateTime.TryParseExact(date, _dateTimeFormat, DateTimeFormatInfo.InvariantInfo, - DateTimeStyles.None, - out _dateTime)) - { - } - } - _indexGroup = match.Groups["index"]; - if (_indexGroup.Success) - { - Index = _indexGroup.Value.Length > 0 ? int.Parse(_indexGroup.Value) : 0; - } - _condGroup = match.Groups["cond"]; - } - } - - public void IncrementDate() - { - _dateTime = _dateTime.AddDays(1); - } - - public void DecrementDate() - { - _dateTime = _dateTime.AddDays(-1); - } - - - public string BuildFileName() - { - string fileName = _currentFileName; - if (_dateGroup != null && _dateGroup.Success) - { - string newDate = _dateTime.ToString(_dateTimeFormat, DateTimeFormatInfo.InvariantInfo); - fileName = fileName.Remove(_dateGroup.Index, _dateGroup.Length); - fileName = fileName.Insert(_dateGroup.Index, newDate); - } - - if (_indexGroup != null && _indexGroup.Success) - { - fileName = fileName.Remove(_indexGroup.Index, _indexGroup.Length); - - if (!_hideZeroIndex || Index > 0) - { - string format = "D" + _indexGroup.Length; - fileName = fileName.Insert(_indexGroup.Index, Index.ToString(format)); - if (_hideZeroIndex && _condContent != null) - { - fileName = fileName.Insert(_indexGroup.Index, _condContent); - } - } - } - - // this.currentFileName = fileName; - // SetFileName(fileName); - return fileName; - } - - #endregion - - #region Private Methods - - private void ParseFormatString(string formatString) - { - string fmt = EscapeNonvarRegions(formatString); - int datePos = formatString.IndexOf("$D("); - if (datePos != -1) - { - int endPos = formatString.IndexOf(')', datePos); - if (endPos != -1) - { - _dateTimeFormat = formatString.Substring(datePos + 3, endPos - datePos - 3); - _dateTimeFormat = _dateTimeFormat.ToUpper(); - _dateTimeFormat = _dateTimeFormat.Replace('D', 'd').Replace('Y', 'y'); - - string dtf = _dateTimeFormat; - dtf = dtf.ToUpper(); - dtf = dtf.Replace("D", "\\d"); - dtf = dtf.Replace("Y", "\\d"); - dtf = dtf.Replace("M", "\\d"); - fmt = fmt.Remove(datePos, 2); // remove $D - fmt = fmt.Remove(datePos + 1, _dateTimeFormat.Length); // replace with regex version of format - fmt = fmt.Insert(datePos + 1, dtf); - fmt = fmt.Insert(datePos + 1, "?'date'"); // name the regex group - } - } - - int condPos = fmt.IndexOf("$J("); - if (condPos != -1) - { - int endPos = fmt.IndexOf(')', condPos); - if (endPos != -1) - { - _condContent = fmt.Substring(condPos + 3, endPos - condPos - 3); - fmt = fmt.Remove(condPos + 2, endPos - condPos - 1); - } - } - - fmt = fmt.Replace("*", ".*"); - _hideZeroIndex = fmt.Contains("$J"); - fmt = fmt.Replace("$I", "(?'index'[\\d]+)"); - fmt = fmt.Replace("$J", "(?'index'[\\d]*)"); - - _regex = new Regex(fmt); - } - - private string EscapeNonvarRegions(string formatString) - { - string fmt = formatString.Replace('*', '\xFFFD'); - StringBuilder result = new(); - int state = 0; - StringBuilder segment = new(); - for (int i = 0; i < fmt.Length; ++i) - { - switch (state) - { - case 0: // looking for $ - if (fmt[i] == '$') - { - result.Append(Regex.Escape(segment.ToString())); - segment = new StringBuilder(); - state = 1; - } - segment.Append(fmt[i]); - break; - case 1: // the char behind $ - segment.Append(fmt[i]); - result.Append(segment.ToString()); - segment = new StringBuilder(); - state = 2; - break; - case 2: // checking if ( or other char - if (fmt[i] == '(') - { - segment.Append(fmt[i]); - state = 3; - } - else - { - segment.Append(fmt[i]); - state = 0; - } - break; - case 3: // looking for ) - segment.Append(fmt[i]); - if (fmt[i] == ')') - { - result.Append(segment.ToString()); - segment = new StringBuilder(); - state = 0; - } - break; - } - } - fmt = result.ToString().Replace('\xFFFD', '*'); - return fmt; - } - - #endregion - } +using System.Globalization; +using System.Text; +using System.Text.RegularExpressions; + +namespace LogExpert.Core.Classes.Log +{ + /* Needed info: + * - Date/time mask + * - index counters + * - counter direction (up/down) + * - counter limit + * - whether the files are shifted or not + * - whether the indexes start with zero (or n/a) on a new date period + * + * Format: + * *$D(yyyy-MM-dd)$I + * *$J(.) + * + * *(yyyy-MM-dd)[I] + * + */ + + /// + /// This class is responsible for building file names for multifile. + /// + public class RolloverFilenameBuilder + { + #region Fields + + private string _condContent; + private Group _condGroup; + private string _currentFileName; + + private Group _dateGroup; + + //private Regex regexCond; + private DateTime _dateTime; + + //private DateTimeFormatInfo dateFormat; + private string _dateTimeFormat; + + private bool _hideZeroIndex; + private Group _indexGroup; + private Regex _regex; + + #endregion + + #region cTor + + public RolloverFilenameBuilder(string formatString) + { + ParseFormatString(formatString); + } + + #endregion + + #region Properties + + public int Index { get; set; } + + public bool IsDatePattern => _dateGroup != null && _dateGroup.Success; + + public bool IsIndexPattern => _indexGroup != null && _indexGroup.Success; + + #endregion + + #region Public methods + + public void SetFileName(string fileName) + { + _currentFileName = fileName; + Match match = _regex.Match(fileName); + if (match.Success) + { + _dateGroup = match.Groups["date"]; + if (_dateGroup.Success) + { + string date = fileName.Substring(_dateGroup.Index, _dateGroup.Length); + if (DateTime.TryParseExact(date, _dateTimeFormat, DateTimeFormatInfo.InvariantInfo, + DateTimeStyles.None, + out _dateTime)) + { + } + } + _indexGroup = match.Groups["index"]; + if (_indexGroup.Success) + { + Index = _indexGroup.Value.Length > 0 ? int.Parse(_indexGroup.Value) : 0; + } + _condGroup = match.Groups["cond"]; + } + } + + public void IncrementDate() + { + _dateTime = _dateTime.AddDays(1); + } + + public void DecrementDate() + { + _dateTime = _dateTime.AddDays(-1); + } + + + public string BuildFileName() + { + string fileName = _currentFileName; + if (_dateGroup != null && _dateGroup.Success) + { + string newDate = _dateTime.ToString(_dateTimeFormat, DateTimeFormatInfo.InvariantInfo); + fileName = fileName.Remove(_dateGroup.Index, _dateGroup.Length); + fileName = fileName.Insert(_dateGroup.Index, newDate); + } + + if (_indexGroup != null && _indexGroup.Success) + { + fileName = fileName.Remove(_indexGroup.Index, _indexGroup.Length); + + if (!_hideZeroIndex || Index > 0) + { + string format = "D" + _indexGroup.Length; + fileName = fileName.Insert(_indexGroup.Index, Index.ToString(format)); + if (_hideZeroIndex && _condContent != null) + { + fileName = fileName.Insert(_indexGroup.Index, _condContent); + } + } + } + + // this.currentFileName = fileName; + // SetFileName(fileName); + return fileName; + } + + #endregion + + #region Private Methods + + private void ParseFormatString(string formatString) + { + string fmt = EscapeNonvarRegions(formatString); + int datePos = formatString.IndexOf("$D("); + if (datePos != -1) + { + int endPos = formatString.IndexOf(')', datePos); + if (endPos != -1) + { + _dateTimeFormat = formatString.Substring(datePos + 3, endPos - datePos - 3); + _dateTimeFormat = _dateTimeFormat.ToUpper(); + _dateTimeFormat = _dateTimeFormat.Replace('D', 'd').Replace('Y', 'y'); + + string dtf = _dateTimeFormat; + dtf = dtf.ToUpper(); + dtf = dtf.Replace("D", "\\d"); + dtf = dtf.Replace("Y", "\\d"); + dtf = dtf.Replace("M", "\\d"); + fmt = fmt.Remove(datePos, 2); // remove $D + fmt = fmt.Remove(datePos + 1, _dateTimeFormat.Length); // replace with regex version of format + fmt = fmt.Insert(datePos + 1, dtf); + fmt = fmt.Insert(datePos + 1, "?'date'"); // name the regex group + } + } + + int condPos = fmt.IndexOf("$J("); + if (condPos != -1) + { + int endPos = fmt.IndexOf(')', condPos); + if (endPos != -1) + { + _condContent = fmt.Substring(condPos + 3, endPos - condPos - 3); + fmt = fmt.Remove(condPos + 2, endPos - condPos - 1); + } + } + + fmt = fmt.Replace("*", ".*"); + _hideZeroIndex = fmt.Contains("$J"); + fmt = fmt.Replace("$I", "(?'index'[\\d]+)"); + fmt = fmt.Replace("$J", "(?'index'[\\d]*)"); + + _regex = new Regex(fmt); + } + + private string EscapeNonvarRegions(string formatString) + { + string fmt = formatString.Replace('*', '\xFFFD'); + StringBuilder result = new(); + int state = 0; + StringBuilder segment = new(); + for (int i = 0; i < fmt.Length; ++i) + { + switch (state) + { + case 0: // looking for $ + if (fmt[i] == '$') + { + result.Append(Regex.Escape(segment.ToString())); + segment = new StringBuilder(); + state = 1; + } + segment.Append(fmt[i]); + break; + case 1: // the char behind $ + segment.Append(fmt[i]); + result.Append(segment.ToString()); + segment = new StringBuilder(); + state = 2; + break; + case 2: // checking if ( or other char + if (fmt[i] == '(') + { + segment.Append(fmt[i]); + state = 3; + } + else + { + segment.Append(fmt[i]); + state = 0; + } + break; + case 3: // looking for ) + segment.Append(fmt[i]); + if (fmt[i] == ')') + { + result.Append(segment.ToString()); + segment = new StringBuilder(); + state = 0; + } + break; + } + } + fmt = result.ToString().Replace('\xFFFD', '*'); + return fmt; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/ObjectClone.cs b/src/Logexpert.Core/Classes/ObjectClone.cs similarity index 79% rename from src/LogExpert/Classes/ObjectClone.cs rename to src/Logexpert.Core/Classes/ObjectClone.cs index 70176ea4..76cd00c6 100644 --- a/src/LogExpert/Classes/ObjectClone.cs +++ b/src/Logexpert.Core/Classes/ObjectClone.cs @@ -1,21 +1,21 @@ -using System.IO; -using System.Text.Json; - -namespace LogExpert.Classes -{ - public static class ObjectClone - { - #region Public methods - - public static T Clone(T RealObject) - { - using MemoryStream objectStream = new (); - - JsonSerializer.Serialize(objectStream, RealObject); - objectStream.Seek(0, SeekOrigin.Begin); - return JsonSerializer.Deserialize(objectStream); - } - - #endregion - } +using System.IO; +using System.Text.Json; + +namespace LogExpert.Core.Classes +{ + public static class ObjectClone + { + #region Public methods + + public static T Clone(T RealObject) + { + using MemoryStream objectStream = new(); + + JsonSerializer.Serialize(objectStream, RealObject); + objectStream.Seek(0, SeekOrigin.Begin); + return JsonSerializer.Deserialize(objectStream); + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/ParamParser.cs b/src/Logexpert.Core/Classes/ParamParser.cs similarity index 91% rename from src/LogExpert/Classes/ParamParser.cs rename to src/Logexpert.Core/Classes/ParamParser.cs index 9d40665a..10cda0f7 100644 --- a/src/LogExpert/Classes/ParamParser.cs +++ b/src/Logexpert.Core/Classes/ParamParser.cs @@ -1,106 +1,105 @@ -using System.IO; -using System.Text; -using System.Text.RegularExpressions; - -namespace LogExpert.Classes -{ - internal class ParamParser - { - #region Fields - - private readonly string argLine; - - #endregion - - #region cTor - - public ParamParser(string argTemplate) - { - this.argLine = argTemplate; - } - - #endregion - - #region Public methods - - public string ReplaceParams(ILogLine logLine, int lineNum, string fileName) - { - FileInfo fileInfo = new(fileName); - StringBuilder builder = new(this.argLine); - builder.Replace("%L", "" + lineNum); - builder.Replace("%P", - fileInfo.DirectoryName.Contains(" ") ? "\"" + fileInfo.DirectoryName + "\"" : fileInfo.DirectoryName); - builder.Replace("%N", fileInfo.Name.Contains(" ") ? "\"" + fileInfo.Name + "\"" : fileInfo.Name); - builder.Replace("%F", - fileInfo.FullName.Contains(" ") ? "\"" + fileInfo.FullName + "\"" : fileInfo.FullName); - builder.Replace("%E", - fileInfo.Extension.Contains(" ") ? "\"" + fileInfo.Extension + "\"" : fileInfo.Extension); - string stripped = StripExtension(fileInfo.Name); - builder.Replace("%M", stripped.Contains(" ") ? "\"" + stripped + "\"" : stripped); - int sPos = 0; - string reg; - string replace; - do - { - reg = GetNextGroup(builder, ref sPos); - replace = GetNextGroup(builder, ref sPos); - if (reg != null && replace != null) - { - string result = Regex.Replace(logLine.FullLine, reg, replace); - builder.Insert(sPos, result); - } - } while (replace != null); - return builder.ToString(); - } - - public static string StripExtension(string fileName) - { - int i = fileName.LastIndexOf('.'); - if (i < 0) - { - i = fileName.Length - 1; - } - return fileName.Substring(0, i); - } - - #endregion - - #region Private Methods - - private string GetNextGroup(StringBuilder builder, ref int sPos) - { - int count = 0; - int ePos; - while (sPos < builder.Length) - { - if (builder[sPos] == '{') - { - ePos = sPos + 1; - count = 1; - while (ePos < builder.Length) - { - if (builder[ePos] == '{') - { - count++; - } - if (builder[ePos] == '}') - { - count--; - } - if (count == 0) - { - string reg = builder.ToString(sPos + 1, ePos - sPos - 1); - builder.Remove(sPos, ePos - sPos + 1); - return reg; - } - ePos++; - } - } - sPos++; - } - return null; - } - - #endregion - } +using System.Text; +using System.Text.RegularExpressions; + +namespace LogExpert.Core.Classes +{ + public class ParamParser + { + #region Fields + + private readonly string argLine; + + #endregion + + #region cTor + + public ParamParser(string argTemplate) + { + argLine = argTemplate; + } + + #endregion + + #region Public methods + + public string ReplaceParams(ILogLine logLine, int lineNum, string fileName) + { + FileInfo fileInfo = new(fileName); + StringBuilder builder = new(argLine); + builder.Replace("%L", "" + lineNum); + builder.Replace("%P", + fileInfo.DirectoryName.Contains(" ") ? "\"" + fileInfo.DirectoryName + "\"" : fileInfo.DirectoryName); + builder.Replace("%N", fileInfo.Name.Contains(" ") ? "\"" + fileInfo.Name + "\"" : fileInfo.Name); + builder.Replace("%F", + fileInfo.FullName.Contains(" ") ? "\"" + fileInfo.FullName + "\"" : fileInfo.FullName); + builder.Replace("%E", + fileInfo.Extension.Contains(" ") ? "\"" + fileInfo.Extension + "\"" : fileInfo.Extension); + string stripped = StripExtension(fileInfo.Name); + builder.Replace("%M", stripped.Contains(" ") ? "\"" + stripped + "\"" : stripped); + int sPos = 0; + string reg; + string replace; + do + { + reg = GetNextGroup(builder, ref sPos); + replace = GetNextGroup(builder, ref sPos); + if (reg != null && replace != null) + { + string result = Regex.Replace(logLine.FullLine, reg, replace); + builder.Insert(sPos, result); + } + } while (replace != null); + return builder.ToString(); + } + + public static string StripExtension(string fileName) + { + int i = fileName.LastIndexOf('.'); + if (i < 0) + { + i = fileName.Length - 1; + } + return fileName.Substring(0, i); + } + + #endregion + + #region Private Methods + + private string GetNextGroup(StringBuilder builder, ref int sPos) + { + int count = 0; + int ePos; + while (sPos < builder.Length) + { + if (builder[sPos] == '{') + { + ePos = sPos + 1; + count = 1; + while (ePos < builder.Length) + { + if (builder[ePos] == '{') + { + count++; + } + if (builder[ePos] == '}') + { + count--; + } + if (count == 0) + { + string reg = builder.ToString(sPos + 1, ePos - sPos - 1); + builder.Remove(sPos, ePos - sPos + 1); + return reg; + } + ePos++; + } + } + sPos++; + } + return null; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/PatternBlock.cs b/src/Logexpert.Core/Classes/PatternBlock.cs similarity index 92% rename from src/LogExpert/Classes/PatternBlock.cs rename to src/Logexpert.Core/Classes/PatternBlock.cs index e37ccca2..a5a80ebe 100644 --- a/src/LogExpert/Classes/PatternBlock.cs +++ b/src/Logexpert.Core/Classes/PatternBlock.cs @@ -1,44 +1,44 @@ -using System.Collections.Generic; - -namespace LogExpert.Classes -{ - public class QualityInfo - { - #region Fields - - public int quality; - - #endregion - } - - public class PatternBlock - { - #region Fields - - public int blockId; - - public int endLine; - - // key: line num - public Dictionary qualityInfoList = []; - - public SortedDictionary srcLines = []; - public int startLine; - public int targetEnd; - public SortedDictionary targetLines = []; - public int targetStart; - public int weigth; - - #endregion - - #region Public methods - - public override string ToString() - { - return "srcStart=" + startLine + ", srcEnd=" + endLine + ", targetStart=" + targetStart + - ", targetEnd=" + targetEnd + ", weight=" + weigth; - } - - #endregion - } +using System.Collections.Generic; + +namespace LogExpert.Core.Classes +{ + public class QualityInfo + { + #region Fields + + public int quality; + + #endregion + } + + public class PatternBlock + { + #region Fields + + public int blockId; + + public int endLine; + + // key: line num + public Dictionary qualityInfoList = []; + + public SortedDictionary srcLines = []; + public int startLine; + public int targetEnd; + public SortedDictionary targetLines = []; + public int targetStart; + public int weigth; + + #endregion + + #region Public methods + + public override string ToString() + { + return "srcStart=" + startLine + ", srcEnd=" + endLine + ", targetStart=" + targetStart + + ", targetEnd=" + targetEnd + ", weight=" + weigth; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Persister/FilterTabData.cs b/src/Logexpert.Core/Classes/Persister/FilterTabData.cs similarity index 67% rename from src/LogExpert/Classes/Persister/FilterTabData.cs rename to src/Logexpert.Core/Classes/Persister/FilterTabData.cs index 63c571d5..346bd413 100644 --- a/src/LogExpert/Classes/Persister/FilterTabData.cs +++ b/src/Logexpert.Core/Classes/Persister/FilterTabData.cs @@ -1,14 +1,14 @@ -using LogExpert.Classes.Filter; - -namespace LogExpert.Classes.Persister -{ - public class FilterTabData - { - #region Fields - - public FilterParams filterParams; - public PersistenceData persistenceData; - - #endregion - } +using LogExpert.Core.Classes.Filter; + +namespace LogExpert.Core.Classes.Persister +{ + public class FilterTabData + { + #region Fields + + public FilterParams filterParams; + public PersistenceData persistenceData; + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Persister/Persister.cs b/src/Logexpert.Core/Classes/Persister/Persister.cs similarity index 96% rename from src/LogExpert/Classes/Persister/Persister.cs rename to src/Logexpert.Core/Classes/Persister/Persister.cs index 8d951c98..c69996eb 100644 --- a/src/LogExpert/Classes/Persister/Persister.cs +++ b/src/Logexpert.Core/Classes/Persister/Persister.cs @@ -1,688 +1,686 @@ -using LogExpert.Classes.Filter; -using LogExpert.Config; -using LogExpert.Entities; - -using NLog; - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Text; -using System.Text.Json; -using System.Windows.Forms; -using System.Xml; - -namespace LogExpert.Classes.Persister -{ - public class PersistenceData - { - #region Fields - - public SortedList bookmarkList = []; - public int bookmarkListPosition = 300; - public bool bookmarkListVisible = false; - public string columnizerName; - public int currentLine = -1; - public Encoding encoding; - public string fileName = null; - public bool filterAdvanced = false; - public List filterParamsList = []; - public int filterPosition = 222; - public bool filterSaveListVisible = false; - public List filterTabDataList = []; - public bool filterVisible = false; - public int firstDisplayedLine = -1; - public bool followTail = true; - public string highlightGroupName; - public int lineCount; - - public bool multiFile = false; - public int multiFileMaxDays; - public List multiFileNames = []; - public string multiFilePattern; - public SortedList rowHeightList = []; - public string sessionFileName = null; - public bool showBookmarkCommentColumn; - public string tabName = null; - - public string settingsSaveLoadLocation; - - #endregion - } - - public class Persister - { - #region Fields - - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - - #endregion - - #region Public methods - - public static string SavePersistenceData(string logFileName, PersistenceData persistenceData, Preferences preferences) - { - string fileName; - - if (persistenceData.sessionFileName != null) - { - fileName = persistenceData.sessionFileName; - } - else - { - fileName = BuildPersisterFileName(logFileName, preferences); - } - if (preferences.saveLocation == SessionSaveLocation.SameDir) - { - // make to log file in .lxp file relative - string filePart = Path.GetFileName(persistenceData.fileName); - persistenceData.fileName = filePart; - } - - Save(fileName, persistenceData); - return fileName; - } - - public static string SavePersistenceDataWithFixedName(string persistenceFileName, - PersistenceData persistenceData) - { - Save(persistenceFileName, persistenceData); - return persistenceFileName; - } - - - public static PersistenceData LoadPersistenceData(string logFileName, Preferences preferences) - { - string fileName = BuildPersisterFileName(logFileName, preferences); - return Load(fileName); - } - - public static PersistenceData LoadPersistenceDataOptionsOnly(string logFileName, Preferences preferences) - { - string fileName = BuildPersisterFileName(logFileName, preferences); - return LoadOptionsOnly(fileName); - } - - public static PersistenceData LoadPersistenceDataOptionsOnlyFromFixedFile(string persistenceFile) - { - return LoadOptionsOnly(persistenceFile); - } - - public static PersistenceData LoadPersistenceDataFromFixedFile(string persistenceFile) - { - return Load(persistenceFile); - } - - - /// - /// Loads the persistence options out of the given persistence file name. - /// - /// - /// - public static PersistenceData LoadOptionsOnly(string fileName) - { - PersistenceData persistenceData = new(); - XmlDocument xmlDoc = new(); - try - { - xmlDoc.Load(fileName); - } - catch (IOException) - { - return null; - } - XmlNode fileNode = xmlDoc.SelectSingleNode("logexpert/file"); - if (fileNode != null) - { - XmlElement fileElement = fileNode as XmlElement; - ReadOptions(fileElement, persistenceData); - persistenceData.fileName = fileElement.GetAttribute("fileName"); - persistenceData.encoding = ReadEncoding(fileElement); - } - return persistenceData; - } - - #endregion - - #region Private Methods - - private static string BuildPersisterFileName(string logFileName, Preferences preferences) - { - string dir; - string file; - - switch (preferences.saveLocation) - { - case SessionSaveLocation.SameDir: - default: - { - FileInfo fileInfo = new(logFileName); - dir = fileInfo.DirectoryName; - file = fileInfo.DirectoryName + Path.DirectorySeparatorChar + fileInfo.Name + ".lxp"; - break; - } - case SessionSaveLocation.DocumentsDir: - { - dir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + - Path.DirectorySeparatorChar + - "LogExpert"; - file = dir + Path.DirectorySeparatorChar + BuildSessionFileNameFromPath(logFileName); - break; - } - case SessionSaveLocation.OwnDir: - { - dir = preferences.sessionSaveDirectory; - file = dir + Path.DirectorySeparatorChar + BuildSessionFileNameFromPath(logFileName); - break; - } - case SessionSaveLocation.ApplicationStartupDir: - { - dir = Application.StartupPath + Path.DirectorySeparatorChar + "sessionfiles"; - file = dir + Path.DirectorySeparatorChar + BuildSessionFileNameFromPath(logFileName); - break; - } - } - - if (string.IsNullOrWhiteSpace(dir) == false && Directory.Exists(dir) == false) - { - try - { - Directory.CreateDirectory(dir); - } - catch (Exception e) - { - MessageBox.Show(e.Message, "LogExpert"); - } - } - return file; - } - - private static string BuildSessionFileNameFromPath(string logFileName) - { - string result = logFileName; - result = result.Replace(Path.DirectorySeparatorChar, '_'); - result = result.Replace(Path.AltDirectorySeparatorChar, '_'); - result = result.Replace(Path.VolumeSeparatorChar, '_'); - result += ".lxp"; - return result; - } - - private static void Save(string fileName, PersistenceData persistenceData) - { - XmlDocument xmlDoc = new(); - XmlElement rootElement = xmlDoc.CreateElement("logexpert"); - xmlDoc.AppendChild(rootElement); - XmlElement fileElement = xmlDoc.CreateElement("file"); - rootElement.AppendChild(fileElement); - fileElement.SetAttribute("fileName", persistenceData.fileName); - fileElement.SetAttribute("lineCount", "" + persistenceData.lineCount); - WriteBookmarks(xmlDoc, fileElement, persistenceData.bookmarkList); - WriteRowHeightList(xmlDoc, fileElement, persistenceData.rowHeightList); - WriteOptions(xmlDoc, fileElement, persistenceData); - WriteFilter(xmlDoc, fileElement, persistenceData.filterParamsList); - WriteFilterTabs(xmlDoc, fileElement, persistenceData.filterTabDataList); - WriteEncoding(xmlDoc, fileElement, persistenceData.encoding); - if (xmlDoc.HasChildNodes) - { - xmlDoc.Save(fileName); - } - } - - private static void WriteEncoding(XmlDocument xmlDoc, XmlElement rootElement, Encoding encoding) - { - if (encoding != null) - { - XmlElement encodingElement = xmlDoc.CreateElement("encoding"); - rootElement.AppendChild(encodingElement); - encodingElement.SetAttribute("name", encoding.WebName); - } - } - - private static void WriteFilterTabs(XmlDocument xmlDoc, XmlElement rootElement, List dataList) - { - if (dataList.Count > 0) - { - XmlElement filterTabsElement = xmlDoc.CreateElement("filterTabs"); - rootElement.AppendChild(filterTabsElement); - foreach (FilterTabData data in dataList) - { - PersistenceData persistenceData = data.persistenceData; - XmlElement filterTabElement = xmlDoc.CreateElement("filterTab"); - filterTabsElement.AppendChild(filterTabElement); - WriteBookmarks(xmlDoc, filterTabElement, persistenceData.bookmarkList); - WriteRowHeightList(xmlDoc, filterTabElement, persistenceData.rowHeightList); - WriteOptions(xmlDoc, filterTabElement, persistenceData); - WriteFilter(xmlDoc, filterTabElement, persistenceData.filterParamsList); - WriteFilterTabs(xmlDoc, filterTabElement, persistenceData.filterTabDataList); - XmlElement filterElement = xmlDoc.CreateElement("tabFilter"); - filterTabElement.AppendChild(filterElement); - List filterList = [data.filterParams]; - WriteFilter(xmlDoc, filterElement, filterList); - } - } - } - - private static List ReadFilterTabs(XmlElement startNode) - { - List dataList = []; - XmlNode filterTabsNode = startNode.SelectSingleNode("filterTabs"); - if (filterTabsNode != null) - { - XmlNodeList filterTabNodeList = filterTabsNode.ChildNodes; // all "filterTab" nodes - foreach (XmlNode node in filterTabNodeList) - { - PersistenceData persistenceData = ReadPersistenceDataFromNode(node); - XmlNode filterNode = node.SelectSingleNode("tabFilter"); - if (filterNode != null) - { - List filterList = ReadFilter(filterNode as XmlElement); - FilterTabData data = new(); - data.persistenceData = persistenceData; - data.filterParams = filterList[0]; // there's only 1 - dataList.Add(data); - } - } - } - return dataList; - } - - - private static void WriteFilter(XmlDocument xmlDoc, XmlElement rootElement, List filterList) - { - XmlElement filtersElement = xmlDoc.CreateElement("filters"); - rootElement.AppendChild(filtersElement); - foreach (FilterParams filterParams in filterList) - { - XmlElement filterElement = xmlDoc.CreateElement("filter"); - XmlElement paramsElement = xmlDoc.CreateElement("params"); - - MemoryStream stream = new(capacity: 200); - JsonSerializer.Serialize(stream, filterParams); - string base64Data = Convert.ToBase64String(stream.ToArray()); - paramsElement.InnerText = base64Data; - filterElement.AppendChild(paramsElement); - filtersElement.AppendChild(filterElement); - } - } - - - private static List ReadFilter(XmlElement startNode) - { - List filterList = []; - XmlNode filtersNode = startNode.SelectSingleNode("filters"); - if (filtersNode != null) - { - XmlNodeList filterNodeList = filtersNode.ChildNodes; // all "filter" nodes - foreach (XmlNode node in filterNodeList) - { - foreach (XmlNode subNode in node.ChildNodes) - { - if (subNode.Name.Equals("params")) - { - string base64Text = subNode.InnerText; - byte[] data = Convert.FromBase64String(base64Text); - MemoryStream stream = new(data); - FilterParams filterParams = JsonSerializer.Deserialize(stream); - filterParams.Init(); - filterList.Add(filterParams); - } - } - } - } - return filterList; - } - - - private static void WriteBookmarks(XmlDocument xmlDoc, XmlElement rootElement, - SortedList bookmarkList) - { - XmlElement bookmarksElement = xmlDoc.CreateElement("bookmarks"); - rootElement.AppendChild(bookmarksElement); - foreach (Entities.Bookmark bookmark in bookmarkList.Values) - { - XmlElement bookmarkElement = xmlDoc.CreateElement("bookmark"); - bookmarkElement.SetAttribute("line", "" + bookmark.LineNum); - XmlElement textElement = xmlDoc.CreateElement("text"); - textElement.InnerText = bookmark.Text; - XmlElement posXElement = xmlDoc.CreateElement("posX"); - XmlElement posYElement = xmlDoc.CreateElement("posY"); - posXElement.InnerText = "" + bookmark.OverlayOffset.Width; - posYElement.InnerText = "" + bookmark.OverlayOffset.Height; - bookmarkElement.AppendChild(textElement); - bookmarkElement.AppendChild(posXElement); - bookmarkElement.AppendChild(posYElement); - bookmarksElement.AppendChild(bookmarkElement); - } - } - - - private static PersistenceData Load(string fileName) - { - XmlDocument xmlDoc = new(); - xmlDoc.Load(fileName); - XmlNode fileNode = xmlDoc.SelectSingleNode("logexpert/file"); - PersistenceData persistenceData = new(); - if (fileNode != null) - { - persistenceData = ReadPersistenceDataFromNode(fileNode); - } - return persistenceData; - } - - private static PersistenceData ReadPersistenceDataFromNode(XmlNode node) - { - PersistenceData persistenceData = new(); - XmlElement fileElement = node as XmlElement; - persistenceData.bookmarkList = ReadBookmarks(fileElement); - persistenceData.rowHeightList = ReadRowHeightList(fileElement); - ReadOptions(fileElement, persistenceData); - persistenceData.fileName = fileElement.GetAttribute("fileName"); - string sLineCount = fileElement.GetAttribute("lineCount"); - if (sLineCount != null && sLineCount.Length > 0) - { - persistenceData.lineCount = int.Parse(sLineCount); - } - persistenceData.filterParamsList = ReadFilter(fileElement); - persistenceData.filterTabDataList = ReadFilterTabs(fileElement); - persistenceData.encoding = ReadEncoding(fileElement); - return persistenceData; - } - - - private static Encoding ReadEncoding(XmlElement fileElement) - { - XmlNode encodingNode = fileElement.SelectSingleNode("encoding"); - if (encodingNode != null) - { - XmlAttribute encAttr = encodingNode.Attributes["name"]; - try - { - return encAttr == null ? null : Encoding.GetEncoding(encAttr.Value); - } - catch (ArgumentException e) - { - _logger.Error(e); - return Encoding.Default; - } - catch (NotSupportedException e) - { - _logger.Error(e); - return Encoding.Default; - } - } - return null; - } - - - private static SortedList ReadBookmarks(XmlElement startNode) - { - SortedList bookmarkList = []; - XmlNode boomarksNode = startNode.SelectSingleNode("bookmarks"); - if (boomarksNode != null) - { - XmlNodeList bookmarkNodeList = boomarksNode.ChildNodes; // all "bookmark" nodes - foreach (XmlNode node in bookmarkNodeList) - { - string text = null; - string posX = null; - string posY = null; - string line = null; - foreach (XmlAttribute attr in node.Attributes) - { - if (attr.Name.Equals("line")) - { - line = attr.InnerText; - } - } - foreach (XmlNode subNode in node.ChildNodes) - { - if (subNode.Name.Equals("text")) - { - text = subNode.InnerText; - } - else if (subNode.Name.Equals("posX")) - { - posX = subNode.InnerText; - } - else if (subNode.Name.Equals("posY")) - { - posY = subNode.InnerText; - } - } - if (line == null || posX == null || posY == null) - { - _logger.Error("Invalid XML format for bookmark: {0}", node.InnerText); - continue; - } - int lineNum = int.Parse(line); - Entities.Bookmark bookmark = new(lineNum); - bookmark.OverlayOffset = new Size(int.Parse(posX), int.Parse(posY)); - if (text != null) - { - bookmark.Text = text; - } - bookmarkList.Add(lineNum, bookmark); - } - } - return bookmarkList; - } - - private static void WriteRowHeightList(XmlDocument xmlDoc, XmlElement rootElement, - SortedList rowHeightList) - { - XmlElement rowheightElement = xmlDoc.CreateElement("rowheights"); - rootElement.AppendChild(rowheightElement); - foreach (RowHeightEntry entry in rowHeightList.Values) - { - XmlElement entryElement = xmlDoc.CreateElement("rowheight"); - entryElement.SetAttribute("line", "" + entry.LineNum); - entryElement.SetAttribute("height", "" + entry.Height); - rowheightElement.AppendChild(entryElement); - } - } - - private static SortedList ReadRowHeightList(XmlElement startNode) - { - SortedList rowHeightList = []; - XmlNode rowHeightsNode = startNode.SelectSingleNode("rowheights"); - if (rowHeightsNode != null) - { - XmlNodeList rowHeightNodeList = rowHeightsNode.ChildNodes; // all "rowheight" nodes - foreach (XmlNode node in rowHeightNodeList) - { - string height = null; - string line = null; - foreach (XmlAttribute attr in node.Attributes) - { - if (attr.Name.Equals("line")) - { - line = attr.InnerText; - } - else if (attr.Name.Equals("height")) - { - height = attr.InnerText; - } - } - int lineNum = int.Parse(line); - int heightValue = int.Parse(height); - rowHeightList.Add(lineNum, new RowHeightEntry(lineNum, heightValue)); - } - } - return rowHeightList; - } - - - private static void WriteOptions(XmlDocument xmlDoc, XmlElement rootElement, PersistenceData persistenceData) - { - XmlElement optionsElement = xmlDoc.CreateElement("options"); - rootElement.AppendChild(optionsElement); - - XmlElement element = xmlDoc.CreateElement("multifile"); - element.SetAttribute("enabled", persistenceData.multiFile ? "1" : "0"); - element.SetAttribute("pattern", persistenceData.multiFilePattern); - element.SetAttribute("maxDays", "" + persistenceData.multiFileMaxDays); - foreach (string fileName in persistenceData.multiFileNames) - { - XmlElement entryElement = xmlDoc.CreateElement("fileEntry"); - entryElement.SetAttribute("fileName", "" + fileName); - element.AppendChild(entryElement); - } - optionsElement.AppendChild(element); - - element = xmlDoc.CreateElement("currentline"); - element.SetAttribute("line", "" + persistenceData.currentLine); - optionsElement.AppendChild(element); - - element = xmlDoc.CreateElement("firstDisplayedLine"); - element.SetAttribute("line", "" + persistenceData.firstDisplayedLine); - optionsElement.AppendChild(element); - - element = xmlDoc.CreateElement("filter"); - element.SetAttribute("visible", persistenceData.filterVisible ? "1" : "0"); - element.SetAttribute("advanced", persistenceData.filterAdvanced ? "1" : "0"); - element.SetAttribute("position", "" + persistenceData.filterPosition); - optionsElement.AppendChild(element); - - element = xmlDoc.CreateElement("bookmarklist"); - element.SetAttribute("visible", persistenceData.bookmarkListVisible ? "1" : "0"); - element.SetAttribute("position", "" + persistenceData.bookmarkListPosition); - optionsElement.AppendChild(element); - - element = xmlDoc.CreateElement("followTail"); - element.SetAttribute("enabled", persistenceData.followTail ? "1" : "0"); - optionsElement.AppendChild(element); - - element = xmlDoc.CreateElement("tab"); - element.SetAttribute("name", persistenceData.tabName); - rootElement.AppendChild(element); - - element = xmlDoc.CreateElement("columnizer"); - element.SetAttribute("name", persistenceData.columnizerName); - rootElement.AppendChild(element); - - element = xmlDoc.CreateElement("highlightGroup"); - element.SetAttribute("name", persistenceData.highlightGroupName); - rootElement.AppendChild(element); - - element = xmlDoc.CreateElement("bookmarkCommentColumn"); - element.SetAttribute("visible", persistenceData.showBookmarkCommentColumn ? "1" : "0"); - optionsElement.AppendChild(element); - - element = xmlDoc.CreateElement("filterSaveList"); - element.SetAttribute("visible", persistenceData.filterSaveListVisible ? "1" : "0"); - optionsElement.AppendChild(element); - } - - - private static void ReadOptions(XmlElement startNode, PersistenceData persistenceData) - { - XmlNode optionsNode = startNode.SelectSingleNode("options"); - string value = GetOptionsAttribute(optionsNode, "multifile", "enabled"); - persistenceData.multiFile = value != null && value.Equals("1"); - persistenceData.multiFilePattern = GetOptionsAttribute(optionsNode, "multifile", "pattern"); - value = GetOptionsAttribute(optionsNode, "multifile", "maxDays"); - try - { - persistenceData.multiFileMaxDays = value != null ? short.Parse(value) : 0; - } - catch (Exception) - { - persistenceData.multiFileMaxDays = 0; - } - - XmlNode multiFileNode = optionsNode.SelectSingleNode("multifile"); - if (multiFileNode != null) - { - XmlNodeList multiFileNodeList = multiFileNode.ChildNodes; // all "fileEntry" nodes - foreach (XmlNode node in multiFileNodeList) - { - string fileName = null; - foreach (XmlAttribute attr in node.Attributes) - { - if (attr.Name.Equals("fileName")) - { - fileName = attr.InnerText; - } - } - persistenceData.multiFileNames.Add(fileName); - } - } - - value = GetOptionsAttribute(optionsNode, "currentline", "line"); - if (value != null) - { - persistenceData.currentLine = int.Parse(value); - } - value = GetOptionsAttribute(optionsNode, "firstDisplayedLine", "line"); - if (value != null) - { - persistenceData.firstDisplayedLine = int.Parse(value); - } - - value = GetOptionsAttribute(optionsNode, "filter", "visible"); - persistenceData.filterVisible = value != null && value.Equals("1"); - value = GetOptionsAttribute(optionsNode, "filter", "advanced"); - persistenceData.filterAdvanced = value != null && value.Equals("1"); - value = GetOptionsAttribute(optionsNode, "filter", "position"); - if (value != null) - { - persistenceData.filterPosition = int.Parse(value); - } - - value = GetOptionsAttribute(optionsNode, "bookmarklist", "visible"); - persistenceData.bookmarkListVisible = value != null && value.Equals("1"); - value = GetOptionsAttribute(optionsNode, "bookmarklist", "position"); - if (value != null) - { - persistenceData.bookmarkListPosition = int.Parse(value); - } - - value = GetOptionsAttribute(optionsNode, "followTail", "enabled"); - persistenceData.followTail = value != null && value.Equals("1"); - - value = GetOptionsAttribute(optionsNode, "bookmarkCommentColumn", "visible"); - persistenceData.showBookmarkCommentColumn = value != null && value.Equals("1"); - - value = GetOptionsAttribute(optionsNode, "filterSaveList", "visible"); - persistenceData.filterSaveListVisible = value != null && value.Equals("1"); - - XmlNode tabNode = startNode.SelectSingleNode("tab"); - if (tabNode != null) - { - persistenceData.tabName = (tabNode as XmlElement).GetAttribute("name"); - } - XmlNode columnizerNode = startNode.SelectSingleNode("columnizer"); - if (columnizerNode != null) - { - persistenceData.columnizerName = (columnizerNode as XmlElement).GetAttribute("name"); - } - XmlNode highlightGroupNode = startNode.SelectSingleNode("highlightGroup"); - if (highlightGroupNode != null) - { - persistenceData.highlightGroupName = (highlightGroupNode as XmlElement).GetAttribute("name"); - } - } - - - private static string GetOptionsAttribute(XmlNode optionsNode, string elementName, string attrName) - { - XmlNode node = optionsNode.SelectSingleNode(elementName); - if (node == null) - { - return null; - } - if (node is XmlElement) - { - string value = (node as XmlElement).GetAttribute(attrName); - return value; - } - else - { - return null; - } - } - - #endregion - } +using LogExpert.Core.Classes.Filter; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; + +using NLog; + +using System.Drawing; +using System.Text; +using System.Text.Json; +using System.Xml; + +namespace LogExpert.Core.Classes.Persister +{ + public class PersistenceData + { + #region Fields + + public SortedList bookmarkList = []; + public int bookmarkListPosition = 300; + public bool bookmarkListVisible = false; + public string columnizerName; + public int currentLine = -1; + public Encoding encoding; + public string fileName = null; + public bool filterAdvanced = false; + public List filterParamsList = []; + public int filterPosition = 222; + public bool filterSaveListVisible = false; + public List filterTabDataList = []; + public bool filterVisible = false; + public int firstDisplayedLine = -1; + public bool followTail = true; + public string highlightGroupName; + public int lineCount; + + public bool multiFile = false; + public int multiFileMaxDays; + public List multiFileNames = []; + public string multiFilePattern; + public SortedList rowHeightList = []; + public string sessionFileName = null; + public bool showBookmarkCommentColumn; + public string tabName = null; + + public string settingsSaveLoadLocation; + + #endregion + } + + public class Persister + { + #region Fields + + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + + #endregion + + #region Public methods + + public static string SavePersistenceData(string logFileName, PersistenceData persistenceData, Preferences preferences) + { + string fileName; + + if (persistenceData.sessionFileName != null) + { + fileName = persistenceData.sessionFileName; + } + else + { + fileName = BuildPersisterFileName(logFileName, preferences); + } + if (preferences.saveLocation == SessionSaveLocation.SameDir) + { + // make to log file in .lxp file relative + string filePart = Path.GetFileName(persistenceData.fileName); + persistenceData.fileName = filePart; + } + + Save(fileName, persistenceData); + return fileName; + } + + public static string SavePersistenceDataWithFixedName(string persistenceFileName, + PersistenceData persistenceData) + { + Save(persistenceFileName, persistenceData); + return persistenceFileName; + } + + + public static PersistenceData LoadPersistenceData(string logFileName, Preferences preferences) + { + string fileName = BuildPersisterFileName(logFileName, preferences); + return Load(fileName); + } + + public static PersistenceData LoadPersistenceDataOptionsOnly(string logFileName, Preferences preferences) + { + string fileName = BuildPersisterFileName(logFileName, preferences); + return LoadOptionsOnly(fileName); + } + + public static PersistenceData LoadPersistenceDataOptionsOnlyFromFixedFile(string persistenceFile) + { + return LoadOptionsOnly(persistenceFile); + } + + public static PersistenceData LoadPersistenceDataFromFixedFile(string persistenceFile) + { + return Load(persistenceFile); + } + + + /// + /// Loads the persistence options out of the given persistence file name. + /// + /// + /// + public static PersistenceData LoadOptionsOnly(string fileName) + { + PersistenceData persistenceData = new(); + XmlDocument xmlDoc = new(); + try + { + xmlDoc.Load(fileName); + } + catch (IOException) + { + return null; + } + XmlNode fileNode = xmlDoc.SelectSingleNode("logexpert/file"); + if (fileNode != null) + { + XmlElement fileElement = fileNode as XmlElement; + ReadOptions(fileElement, persistenceData); + persistenceData.fileName = fileElement.GetAttribute("fileName"); + persistenceData.encoding = ReadEncoding(fileElement); + } + return persistenceData; + } + + #endregion + + #region Private Methods + + private static string BuildPersisterFileName(string logFileName, Preferences preferences) + { + string dir; + string file; + + switch (preferences.saveLocation) + { + case SessionSaveLocation.SameDir: + default: + { + FileInfo fileInfo = new(logFileName); + dir = fileInfo.DirectoryName; + file = fileInfo.DirectoryName + Path.DirectorySeparatorChar + fileInfo.Name + ".lxp"; + break; + } + case SessionSaveLocation.DocumentsDir: + { + dir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + + Path.DirectorySeparatorChar + + "LogExpert"; + file = dir + Path.DirectorySeparatorChar + BuildSessionFileNameFromPath(logFileName); + break; + } + case SessionSaveLocation.OwnDir: + { + dir = preferences.sessionSaveDirectory; + file = dir + Path.DirectorySeparatorChar + BuildSessionFileNameFromPath(logFileName); + break; + } + case SessionSaveLocation.ApplicationStartupDir: + { + //TODO Add Application.StartupPath as Variable + dir = string.Empty;// Application.StartupPath + Path.DirectorySeparatorChar + "sessionfiles"; + file = dir + Path.DirectorySeparatorChar + BuildSessionFileNameFromPath(logFileName); + break; + } + } + + if (string.IsNullOrWhiteSpace(dir) == false && Directory.Exists(dir) == false) + { + try + { + Directory.CreateDirectory(dir); + } + catch (Exception e) + { + //TODO this needs to be handled differently + //MessageBox.Show(e.Message, "LogExpert"); + } + } + return file; + } + + private static string BuildSessionFileNameFromPath(string logFileName) + { + string result = logFileName; + result = result.Replace(Path.DirectorySeparatorChar, '_'); + result = result.Replace(Path.AltDirectorySeparatorChar, '_'); + result = result.Replace(Path.VolumeSeparatorChar, '_'); + result += ".lxp"; + return result; + } + + private static void Save(string fileName, PersistenceData persistenceData) + { + XmlDocument xmlDoc = new(); + XmlElement rootElement = xmlDoc.CreateElement("logexpert"); + xmlDoc.AppendChild(rootElement); + XmlElement fileElement = xmlDoc.CreateElement("file"); + rootElement.AppendChild(fileElement); + fileElement.SetAttribute("fileName", persistenceData.fileName); + fileElement.SetAttribute("lineCount", "" + persistenceData.lineCount); + WriteBookmarks(xmlDoc, fileElement, persistenceData.bookmarkList); + WriteRowHeightList(xmlDoc, fileElement, persistenceData.rowHeightList); + WriteOptions(xmlDoc, fileElement, persistenceData); + WriteFilter(xmlDoc, fileElement, persistenceData.filterParamsList); + WriteFilterTabs(xmlDoc, fileElement, persistenceData.filterTabDataList); + WriteEncoding(xmlDoc, fileElement, persistenceData.encoding); + if (xmlDoc.HasChildNodes) + { + xmlDoc.Save(fileName); + } + } + + private static void WriteEncoding(XmlDocument xmlDoc, XmlElement rootElement, Encoding encoding) + { + if (encoding != null) + { + XmlElement encodingElement = xmlDoc.CreateElement("encoding"); + rootElement.AppendChild(encodingElement); + encodingElement.SetAttribute("name", encoding.WebName); + } + } + + private static void WriteFilterTabs(XmlDocument xmlDoc, XmlElement rootElement, List dataList) + { + if (dataList.Count > 0) + { + XmlElement filterTabsElement = xmlDoc.CreateElement("filterTabs"); + rootElement.AppendChild(filterTabsElement); + foreach (FilterTabData data in dataList) + { + PersistenceData persistenceData = data.persistenceData; + XmlElement filterTabElement = xmlDoc.CreateElement("filterTab"); + filterTabsElement.AppendChild(filterTabElement); + WriteBookmarks(xmlDoc, filterTabElement, persistenceData.bookmarkList); + WriteRowHeightList(xmlDoc, filterTabElement, persistenceData.rowHeightList); + WriteOptions(xmlDoc, filterTabElement, persistenceData); + WriteFilter(xmlDoc, filterTabElement, persistenceData.filterParamsList); + WriteFilterTabs(xmlDoc, filterTabElement, persistenceData.filterTabDataList); + XmlElement filterElement = xmlDoc.CreateElement("tabFilter"); + filterTabElement.AppendChild(filterElement); + List filterList = [data.filterParams]; + WriteFilter(xmlDoc, filterElement, filterList); + } + } + } + + private static List ReadFilterTabs(XmlElement startNode) + { + List dataList = []; + XmlNode filterTabsNode = startNode.SelectSingleNode("filterTabs"); + if (filterTabsNode != null) + { + XmlNodeList filterTabNodeList = filterTabsNode.ChildNodes; // all "filterTab" nodes + foreach (XmlNode node in filterTabNodeList) + { + PersistenceData persistenceData = ReadPersistenceDataFromNode(node); + XmlNode filterNode = node.SelectSingleNode("tabFilter"); + if (filterNode != null) + { + List filterList = ReadFilter(filterNode as XmlElement); + FilterTabData data = new(); + data.persistenceData = persistenceData; + data.filterParams = filterList[0]; // there's only 1 + dataList.Add(data); + } + } + } + return dataList; + } + + + private static void WriteFilter(XmlDocument xmlDoc, XmlElement rootElement, List filterList) + { + XmlElement filtersElement = xmlDoc.CreateElement("filters"); + rootElement.AppendChild(filtersElement); + foreach (FilterParams filterParams in filterList) + { + XmlElement filterElement = xmlDoc.CreateElement("filter"); + XmlElement paramsElement = xmlDoc.CreateElement("params"); + + MemoryStream stream = new(capacity: 200); + JsonSerializer.Serialize(stream, filterParams); + string base64Data = Convert.ToBase64String(stream.ToArray()); + paramsElement.InnerText = base64Data; + filterElement.AppendChild(paramsElement); + filtersElement.AppendChild(filterElement); + } + } + + + private static List ReadFilter(XmlElement startNode) + { + List filterList = []; + XmlNode filtersNode = startNode.SelectSingleNode("filters"); + if (filtersNode != null) + { + XmlNodeList filterNodeList = filtersNode.ChildNodes; // all "filter" nodes + foreach (XmlNode node in filterNodeList) + { + foreach (XmlNode subNode in node.ChildNodes) + { + if (subNode.Name.Equals("params")) + { + string base64Text = subNode.InnerText; + byte[] data = Convert.FromBase64String(base64Text); + MemoryStream stream = new(data); + FilterParams filterParams = JsonSerializer.Deserialize(stream); + filterParams.Init(); + filterList.Add(filterParams); + } + } + } + } + return filterList; + } + + + private static void WriteBookmarks(XmlDocument xmlDoc, XmlElement rootElement, + SortedList bookmarkList) + { + XmlElement bookmarksElement = xmlDoc.CreateElement("bookmarks"); + rootElement.AppendChild(bookmarksElement); + foreach (Entities.Bookmark bookmark in bookmarkList.Values) + { + XmlElement bookmarkElement = xmlDoc.CreateElement("bookmark"); + bookmarkElement.SetAttribute("line", "" + bookmark.LineNum); + XmlElement textElement = xmlDoc.CreateElement("text"); + textElement.InnerText = bookmark.Text; + XmlElement posXElement = xmlDoc.CreateElement("posX"); + XmlElement posYElement = xmlDoc.CreateElement("posY"); + posXElement.InnerText = "" + bookmark.OverlayOffset.Width; + posYElement.InnerText = "" + bookmark.OverlayOffset.Height; + bookmarkElement.AppendChild(textElement); + bookmarkElement.AppendChild(posXElement); + bookmarkElement.AppendChild(posYElement); + bookmarksElement.AppendChild(bookmarkElement); + } + } + + + private static PersistenceData Load(string fileName) + { + XmlDocument xmlDoc = new(); + xmlDoc.Load(fileName); + XmlNode fileNode = xmlDoc.SelectSingleNode("logexpert/file"); + PersistenceData persistenceData = new(); + if (fileNode != null) + { + persistenceData = ReadPersistenceDataFromNode(fileNode); + } + return persistenceData; + } + + private static PersistenceData ReadPersistenceDataFromNode(XmlNode node) + { + PersistenceData persistenceData = new(); + XmlElement fileElement = node as XmlElement; + persistenceData.bookmarkList = ReadBookmarks(fileElement); + persistenceData.rowHeightList = ReadRowHeightList(fileElement); + ReadOptions(fileElement, persistenceData); + persistenceData.fileName = fileElement.GetAttribute("fileName"); + string sLineCount = fileElement.GetAttribute("lineCount"); + if (sLineCount != null && sLineCount.Length > 0) + { + persistenceData.lineCount = int.Parse(sLineCount); + } + persistenceData.filterParamsList = ReadFilter(fileElement); + persistenceData.filterTabDataList = ReadFilterTabs(fileElement); + persistenceData.encoding = ReadEncoding(fileElement); + return persistenceData; + } + + + private static Encoding ReadEncoding(XmlElement fileElement) + { + XmlNode encodingNode = fileElement.SelectSingleNode("encoding"); + if (encodingNode != null) + { + XmlAttribute encAttr = encodingNode.Attributes["name"]; + try + { + return encAttr == null ? null : Encoding.GetEncoding(encAttr.Value); + } + catch (ArgumentException e) + { + _logger.Error(e); + return Encoding.Default; + } + catch (NotSupportedException e) + { + _logger.Error(e); + return Encoding.Default; + } + } + return null; + } + + + private static SortedList ReadBookmarks(XmlElement startNode) + { + SortedList bookmarkList = []; + XmlNode boomarksNode = startNode.SelectSingleNode("bookmarks"); + if (boomarksNode != null) + { + XmlNodeList bookmarkNodeList = boomarksNode.ChildNodes; // all "bookmark" nodes + foreach (XmlNode node in bookmarkNodeList) + { + string text = null; + string posX = null; + string posY = null; + string line = null; + foreach (XmlAttribute attr in node.Attributes) + { + if (attr.Name.Equals("line")) + { + line = attr.InnerText; + } + } + foreach (XmlNode subNode in node.ChildNodes) + { + if (subNode.Name.Equals("text")) + { + text = subNode.InnerText; + } + else if (subNode.Name.Equals("posX")) + { + posX = subNode.InnerText; + } + else if (subNode.Name.Equals("posY")) + { + posY = subNode.InnerText; + } + } + if (line == null || posX == null || posY == null) + { + _logger.Error("Invalid XML format for bookmark: {0}", node.InnerText); + continue; + } + int lineNum = int.Parse(line); + Entities.Bookmark bookmark = new(lineNum); + bookmark.OverlayOffset = new Size(int.Parse(posX), int.Parse(posY)); + if (text != null) + { + bookmark.Text = text; + } + bookmarkList.Add(lineNum, bookmark); + } + } + return bookmarkList; + } + + private static void WriteRowHeightList(XmlDocument xmlDoc, XmlElement rootElement, + SortedList rowHeightList) + { + XmlElement rowheightElement = xmlDoc.CreateElement("rowheights"); + rootElement.AppendChild(rowheightElement); + foreach (RowHeightEntry entry in rowHeightList.Values) + { + XmlElement entryElement = xmlDoc.CreateElement("rowheight"); + entryElement.SetAttribute("line", "" + entry.LineNum); + entryElement.SetAttribute("height", "" + entry.Height); + rowheightElement.AppendChild(entryElement); + } + } + + private static SortedList ReadRowHeightList(XmlElement startNode) + { + SortedList rowHeightList = []; + XmlNode rowHeightsNode = startNode.SelectSingleNode("rowheights"); + if (rowHeightsNode != null) + { + XmlNodeList rowHeightNodeList = rowHeightsNode.ChildNodes; // all "rowheight" nodes + foreach (XmlNode node in rowHeightNodeList) + { + string height = null; + string line = null; + foreach (XmlAttribute attr in node.Attributes) + { + if (attr.Name.Equals("line")) + { + line = attr.InnerText; + } + else if (attr.Name.Equals("height")) + { + height = attr.InnerText; + } + } + int lineNum = int.Parse(line); + int heightValue = int.Parse(height); + rowHeightList.Add(lineNum, new RowHeightEntry(lineNum, heightValue)); + } + } + return rowHeightList; + } + + + private static void WriteOptions(XmlDocument xmlDoc, XmlElement rootElement, PersistenceData persistenceData) + { + XmlElement optionsElement = xmlDoc.CreateElement("options"); + rootElement.AppendChild(optionsElement); + + XmlElement element = xmlDoc.CreateElement("multifile"); + element.SetAttribute("enabled", persistenceData.multiFile ? "1" : "0"); + element.SetAttribute("pattern", persistenceData.multiFilePattern); + element.SetAttribute("maxDays", "" + persistenceData.multiFileMaxDays); + foreach (string fileName in persistenceData.multiFileNames) + { + XmlElement entryElement = xmlDoc.CreateElement("fileEntry"); + entryElement.SetAttribute("fileName", "" + fileName); + element.AppendChild(entryElement); + } + optionsElement.AppendChild(element); + + element = xmlDoc.CreateElement("currentline"); + element.SetAttribute("line", "" + persistenceData.currentLine); + optionsElement.AppendChild(element); + + element = xmlDoc.CreateElement("firstDisplayedLine"); + element.SetAttribute("line", "" + persistenceData.firstDisplayedLine); + optionsElement.AppendChild(element); + + element = xmlDoc.CreateElement("filter"); + element.SetAttribute("visible", persistenceData.filterVisible ? "1" : "0"); + element.SetAttribute("advanced", persistenceData.filterAdvanced ? "1" : "0"); + element.SetAttribute("position", "" + persistenceData.filterPosition); + optionsElement.AppendChild(element); + + element = xmlDoc.CreateElement("bookmarklist"); + element.SetAttribute("visible", persistenceData.bookmarkListVisible ? "1" : "0"); + element.SetAttribute("position", "" + persistenceData.bookmarkListPosition); + optionsElement.AppendChild(element); + + element = xmlDoc.CreateElement("followTail"); + element.SetAttribute("enabled", persistenceData.followTail ? "1" : "0"); + optionsElement.AppendChild(element); + + element = xmlDoc.CreateElement("tab"); + element.SetAttribute("name", persistenceData.tabName); + rootElement.AppendChild(element); + + element = xmlDoc.CreateElement("columnizer"); + element.SetAttribute("name", persistenceData.columnizerName); + rootElement.AppendChild(element); + + element = xmlDoc.CreateElement("highlightGroup"); + element.SetAttribute("name", persistenceData.highlightGroupName); + rootElement.AppendChild(element); + + element = xmlDoc.CreateElement("bookmarkCommentColumn"); + element.SetAttribute("visible", persistenceData.showBookmarkCommentColumn ? "1" : "0"); + optionsElement.AppendChild(element); + + element = xmlDoc.CreateElement("filterSaveList"); + element.SetAttribute("visible", persistenceData.filterSaveListVisible ? "1" : "0"); + optionsElement.AppendChild(element); + } + + + private static void ReadOptions(XmlElement startNode, PersistenceData persistenceData) + { + XmlNode optionsNode = startNode.SelectSingleNode("options"); + string value = GetOptionsAttribute(optionsNode, "multifile", "enabled"); + persistenceData.multiFile = value != null && value.Equals("1"); + persistenceData.multiFilePattern = GetOptionsAttribute(optionsNode, "multifile", "pattern"); + value = GetOptionsAttribute(optionsNode, "multifile", "maxDays"); + try + { + persistenceData.multiFileMaxDays = value != null ? short.Parse(value) : 0; + } + catch (Exception) + { + persistenceData.multiFileMaxDays = 0; + } + + XmlNode multiFileNode = optionsNode.SelectSingleNode("multifile"); + if (multiFileNode != null) + { + XmlNodeList multiFileNodeList = multiFileNode.ChildNodes; // all "fileEntry" nodes + foreach (XmlNode node in multiFileNodeList) + { + string fileName = null; + foreach (XmlAttribute attr in node.Attributes) + { + if (attr.Name.Equals("fileName")) + { + fileName = attr.InnerText; + } + } + persistenceData.multiFileNames.Add(fileName); + } + } + + value = GetOptionsAttribute(optionsNode, "currentline", "line"); + if (value != null) + { + persistenceData.currentLine = int.Parse(value); + } + value = GetOptionsAttribute(optionsNode, "firstDisplayedLine", "line"); + if (value != null) + { + persistenceData.firstDisplayedLine = int.Parse(value); + } + + value = GetOptionsAttribute(optionsNode, "filter", "visible"); + persistenceData.filterVisible = value != null && value.Equals("1"); + value = GetOptionsAttribute(optionsNode, "filter", "advanced"); + persistenceData.filterAdvanced = value != null && value.Equals("1"); + value = GetOptionsAttribute(optionsNode, "filter", "position"); + if (value != null) + { + persistenceData.filterPosition = int.Parse(value); + } + + value = GetOptionsAttribute(optionsNode, "bookmarklist", "visible"); + persistenceData.bookmarkListVisible = value != null && value.Equals("1"); + value = GetOptionsAttribute(optionsNode, "bookmarklist", "position"); + if (value != null) + { + persistenceData.bookmarkListPosition = int.Parse(value); + } + + value = GetOptionsAttribute(optionsNode, "followTail", "enabled"); + persistenceData.followTail = value != null && value.Equals("1"); + + value = GetOptionsAttribute(optionsNode, "bookmarkCommentColumn", "visible"); + persistenceData.showBookmarkCommentColumn = value != null && value.Equals("1"); + + value = GetOptionsAttribute(optionsNode, "filterSaveList", "visible"); + persistenceData.filterSaveListVisible = value != null && value.Equals("1"); + + XmlNode tabNode = startNode.SelectSingleNode("tab"); + if (tabNode != null) + { + persistenceData.tabName = (tabNode as XmlElement).GetAttribute("name"); + } + XmlNode columnizerNode = startNode.SelectSingleNode("columnizer"); + if (columnizerNode != null) + { + persistenceData.columnizerName = (columnizerNode as XmlElement).GetAttribute("name"); + } + XmlNode highlightGroupNode = startNode.SelectSingleNode("highlightGroup"); + if (highlightGroupNode != null) + { + persistenceData.highlightGroupName = (highlightGroupNode as XmlElement).GetAttribute("name"); + } + } + + + private static string GetOptionsAttribute(XmlNode optionsNode, string elementName, string attrName) + { + XmlNode node = optionsNode.SelectSingleNode(elementName); + if (node == null) + { + return null; + } + if (node is XmlElement) + { + string value = (node as XmlElement).GetAttribute(attrName); + return value; + } + else + { + return null; + } + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Persister/ProjectData.cs b/src/Logexpert.Core/Classes/Persister/ProjectData.cs similarity index 80% rename from src/LogExpert/Classes/Persister/ProjectData.cs rename to src/Logexpert.Core/Classes/Persister/ProjectData.cs index 18823c1e..bc4df6ab 100644 --- a/src/LogExpert/Classes/Persister/ProjectData.cs +++ b/src/Logexpert.Core/Classes/Persister/ProjectData.cs @@ -1,14 +1,14 @@ -using System.Collections.Generic; - -namespace LogExpert.Classes.Persister -{ - public class ProjectData - { - #region Fields - - public List memberList = []; - public string tabLayoutXml = null; - - #endregion - } +using System.Collections.Generic; + +namespace LogExpert.Core.Classes.Persister +{ + public class ProjectData + { + #region Fields + + public List memberList = []; + public string tabLayoutXml = null; + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Persister/ProjectPersister.cs b/src/Logexpert.Core/Classes/Persister/ProjectPersister.cs similarity index 95% rename from src/LogExpert/Classes/Persister/ProjectPersister.cs rename to src/Logexpert.Core/Classes/Persister/ProjectPersister.cs index 128b2ad1..5e0a2948 100644 --- a/src/LogExpert/Classes/Persister/ProjectPersister.cs +++ b/src/Logexpert.Core/Classes/Persister/ProjectPersister.cs @@ -1,68 +1,68 @@ -using System.Collections.Generic; -using System.Xml; - -namespace LogExpert.Classes.Persister -{ - public static class ProjectPersister - { - #region Public methods - - public static ProjectData LoadProjectData(string projectFileName) - { - ProjectData projectData = new(); - XmlDocument xmlDoc = new(); - xmlDoc.Load(projectFileName); - XmlNodeList fileList = xmlDoc.GetElementsByTagName("member"); - foreach (XmlNode fileNode in fileList) - { - XmlElement fileElement = fileNode as XmlElement; - string fileName = fileElement.GetAttribute("fileName"); - projectData.memberList.Add(fileName); - } - XmlNodeList layoutElements = xmlDoc.GetElementsByTagName("layout"); - if (layoutElements.Count > 0) - { - projectData.tabLayoutXml = layoutElements[0].InnerXml; - } - return projectData; - } - - - public static void SaveProjectData(string projectFileName, ProjectData projectData) - { - XmlDocument xmlDoc = new(); - XmlElement rootElement = xmlDoc.CreateElement("logexpert"); - xmlDoc.AppendChild(rootElement); - XmlElement projectElement = xmlDoc.CreateElement("project"); - rootElement.AppendChild(projectElement); - XmlElement membersElement = xmlDoc.CreateElement("members"); - projectElement.AppendChild(membersElement); - SaveProjectMembers(xmlDoc, membersElement, projectData.memberList); - - if (projectData.tabLayoutXml != null) - { - XmlElement layoutElement = xmlDoc.CreateElement("layout"); - layoutElement.InnerXml = projectData.tabLayoutXml; - rootElement.AppendChild(layoutElement); - } - - xmlDoc.Save(projectFileName); - } - - #endregion - - #region Private Methods - - private static void SaveProjectMembers(XmlDocument xmlDoc, XmlNode membersNode, List memberList) - { - foreach (string fileName in memberList) - { - XmlElement memberElement = xmlDoc.CreateElement("member"); - membersNode.AppendChild(memberElement); - memberElement.SetAttribute("fileName", fileName); - } - } - - #endregion - } +using System.Collections.Generic; +using System.Xml; + +namespace LogExpert.Core.Classes.Persister +{ + public static class ProjectPersister + { + #region Public methods + + public static ProjectData LoadProjectData(string projectFileName) + { + ProjectData projectData = new(); + XmlDocument xmlDoc = new(); + xmlDoc.Load(projectFileName); + XmlNodeList fileList = xmlDoc.GetElementsByTagName("member"); + foreach (XmlNode fileNode in fileList) + { + XmlElement fileElement = fileNode as XmlElement; + string fileName = fileElement.GetAttribute("fileName"); + projectData.memberList.Add(fileName); + } + XmlNodeList layoutElements = xmlDoc.GetElementsByTagName("layout"); + if (layoutElements.Count > 0) + { + projectData.tabLayoutXml = layoutElements[0].InnerXml; + } + return projectData; + } + + + public static void SaveProjectData(string projectFileName, ProjectData projectData) + { + XmlDocument xmlDoc = new(); + XmlElement rootElement = xmlDoc.CreateElement("logexpert"); + xmlDoc.AppendChild(rootElement); + XmlElement projectElement = xmlDoc.CreateElement("project"); + rootElement.AppendChild(projectElement); + XmlElement membersElement = xmlDoc.CreateElement("members"); + projectElement.AppendChild(membersElement); + SaveProjectMembers(xmlDoc, membersElement, projectData.memberList); + + if (projectData.tabLayoutXml != null) + { + XmlElement layoutElement = xmlDoc.CreateElement("layout"); + layoutElement.InnerXml = projectData.tabLayoutXml; + rootElement.AppendChild(layoutElement); + } + + xmlDoc.Save(projectFileName); + } + + #endregion + + #region Private Methods + + private static void SaveProjectMembers(XmlDocument xmlDoc, XmlNode membersNode, List memberList) + { + foreach (string fileName in memberList) + { + XmlElement memberElement = xmlDoc.CreateElement("member"); + membersNode.AppendChild(memberElement); + memberElement.SetAttribute("fileName", fileName); + } + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/SysoutPipe.cs b/src/Logexpert.Core/Classes/SysoutPipe.cs similarity index 58% rename from src/LogExpert/Classes/SysoutPipe.cs rename to src/Logexpert.Core/Classes/SysoutPipe.cs index 990a766d..e605d6d5 100644 --- a/src/LogExpert/Classes/SysoutPipe.cs +++ b/src/Logexpert.Core/Classes/SysoutPipe.cs @@ -1,91 +1,90 @@ -using System.Diagnostics; -using System.IO; -using System.Text; -using System.Threading; -using NLog; - -namespace LogExpert.Classes -{ - internal class SysoutPipe - { - #region Fields - - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - - private readonly StreamReader sysout; - private StreamWriter writer; - - #endregion - - #region cTor - - public SysoutPipe(StreamReader sysout) - { - this.sysout = sysout; - this.FileName = Path.GetTempFileName(); - _logger.Info("sysoutPipe created temp file: {0}", this.FileName); - FileStream fStream = new(this.FileName, FileMode.Append, FileAccess.Write, FileShare.Read); - this.writer = new StreamWriter(fStream, Encoding.Unicode); - Thread thread = new(new ThreadStart(this.ReaderThread)); - thread.IsBackground = true; - thread.Start(); - } - - #endregion - - #region Properties - - public string FileName { get; } - - #endregion - - #region Public methods - - public void ClosePipe() - { - this.writer.Close(); - this.writer = null; - } - - - public void DataReceivedEventHandler(object sender, DataReceivedEventArgs e) - { - this.writer.WriteLine(e.Data); - } - - public void ProcessExitedEventHandler(object sender, System.EventArgs e) - { - //ClosePipe(); - if (sender.GetType() == typeof(Process)) - { - ((Process) sender).Exited -= this.ProcessExitedEventHandler; - ((Process) sender).OutputDataReceived -= this.DataReceivedEventHandler; - } - } - - #endregion - - protected void ReaderThread() - { - char[] buff = new char[256]; - while (true) - { - try - { - int read = this.sysout.Read(buff, 0, 256); - if (read == 0) - { - break; - } - writer.Write(buff, 0, read); - } - catch (IOException e) - { - _logger.Error(e); - break; - } - } - ClosePipe(); - } - } +using NLog; + +using System.Diagnostics; +using System.Text; + +namespace LogExpert.Core.Classes +{ + public class SysoutPipe + { + #region Fields + + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + + private readonly StreamReader sysout; + private StreamWriter writer; + + #endregion + + #region cTor + + public SysoutPipe(StreamReader sysout) + { + this.sysout = sysout; + FileName = Path.GetTempFileName(); + _logger.Info("sysoutPipe created temp file: {0}", FileName); + FileStream fStream = new(FileName, FileMode.Append, FileAccess.Write, FileShare.Read); + writer = new StreamWriter(fStream, Encoding.Unicode); + Thread thread = new(new ThreadStart(ReaderThread)); + thread.IsBackground = true; + thread.Start(); + } + + #endregion + + #region Properties + + public string FileName { get; } + + #endregion + + #region Public methods + + public void ClosePipe() + { + writer.Close(); + writer = null; + } + + + public void DataReceivedEventHandler(object sender, DataReceivedEventArgs e) + { + writer.WriteLine(e.Data); + } + + public void ProcessExitedEventHandler(object sender, EventArgs e) + { + //ClosePipe(); + if (sender.GetType() == typeof(Process)) + { + ((Process)sender).Exited -= ProcessExitedEventHandler; + ((Process)sender).OutputDataReceived -= DataReceivedEventHandler; + } + } + + #endregion + + protected void ReaderThread() + { + char[] buff = new char[256]; + while (true) + { + try + { + int read = sysout.Read(buff, 0, 256); + if (read == 0) + { + break; + } + writer.Write(buff, 0, read); + } + catch (IOException e) + { + _logger.Error(e); + break; + } + } + ClosePipe(); + } + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Util.cs b/src/Logexpert.Core/Classes/Util.cs similarity index 89% rename from src/LogExpert/Classes/Util.cs rename to src/Logexpert.Core/Classes/Util.cs index 79d77d75..d2735ff3 100644 --- a/src/LogExpert/Classes/Util.cs +++ b/src/Logexpert.Core/Classes/Util.cs @@ -1,612 +1,623 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Drawing; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using LogExpert.Classes.Filter; - -namespace LogExpert.Classes -{ - public class Util - { - #region Public methods - - public static string GetNameFromPath(string fileName) - { - int i = fileName.LastIndexOf('\\'); - if (i < 0) - { - i = fileName.LastIndexOf('/'); - } - if (i < 0) - { - i = -1; - } - return fileName.Substring(i + 1); - } - - public static string StripExtension(string fileName) - { - int i = fileName.LastIndexOf('.'); - if (i < 0) - { - i = fileName.Length - 1; - } - return fileName.Substring(0, i); - } - - public static string GetExtension(string fileName) - { - int i = fileName.LastIndexOf('.'); - if (i < 0 || i >= fileName.Length - 1) - { - return ""; - } - else - { - return fileName.Substring(i + 1); - } - } - - - public static string GetFileSizeAsText(long size) - { - if (size < 1024) - { - return "" + size + " bytes"; - } - else if (size < 1024 * 1024) - { - return "" + size / 1024 + " KB"; - } - else - { - return "" + string.Format("{0:0.00}", (double) size / 1048576.0) + " MB"; - } - } - - public static bool TestFilterCondition(FilterParams filterParams, ILogLine line, - LogExpert.ILogLineColumnizerCallback columnizerCallback) - { - if (filterParams.lastLine.Equals(line.FullLine)) - { - return filterParams.lastResult; - } - - bool match = TestFilterMatch(filterParams, line, columnizerCallback); - filterParams.lastLine = line.FullLine; - - if (filterParams.isRangeSearch) - { - if (!filterParams.isInRange) - { - if (match) - { - filterParams.isInRange = true; - } - } - else - { - if (!match) - { - match = true; - } - else - { - filterParams.isInRange = false; - } - } - } - if (filterParams.isInvert) - { - match = !match; - } - filterParams.lastResult = match; - return match; - } - - - public static int DamerauLevenshteinDistance(string src, string dest) - { - int[,] d = new int[src.Length + 1, dest.Length + 1]; - int i, j, cost; - char[] str1 = src.ToCharArray(); - char[] str2 = dest.ToCharArray(); - - for (i = 0; i <= str1.Length; i++) - { - d[i, 0] = i; - } - for (j = 0; j <= str2.Length; j++) - { - d[0, j] = j; - } - for (i = 1; i <= str1.Length; i++) - { - for (j = 1; j <= str2.Length; j++) - { - if (str1[i - 1] == str2[j - 1]) - { - cost = 0; - } - else - { - cost = 1; - } - - d[i, j] = - Math.Min(d[i - 1, j] + 1, // Deletion - Math.Min(d[i, j - 1] + 1, // Insertion - d[i - 1, j - 1] + cost)); // Substitution - - if (i > 1 && j > 1 && str1[i - 1] == str2[j - 2] && str1[i - 2] == str2[j - 1]) - { - d[i, j] = Math.Min(d[i, j], d[i - 2, j - 2] + cost); - } - } - } - return d[str1.Length, str2.Length]; - } - - - public static unsafe int YetiLevenshtein(string s1, string s2) - { - fixed (char* p1 = s1) - fixed (char* p2 = s2) - { - return YetiLevenshtein(p1, s1.Length, p2, s2.Length, 0); // substitutionCost = 1 - } - } - - public static unsafe int YetiLevenshtein(string s1, string s2, int substitionCost) - { - int xc = substitionCost - 1; - if (xc < 0 || xc > 1) - { - throw new ArgumentException("", "substitionCost"); - } - - fixed (char* p1 = s1) - fixed (char* p2 = s2) - { - return YetiLevenshtein(p1, s1.Length, p2, s2.Length, xc); - } - } - - /// - /// Cetin Sert, David Necas - /// Source Code - /// - /// - /// - /// - /// - /// - /// - public static unsafe int YetiLevenshtein(char* s1, int l1, char* s2, int l2, int xcost) - { - int i; - //int *row; /* we only need to keep one row of costs */ - int* end; - int half; - - /* strip common prefix */ - while (l1 > 0 && l2 > 0 && *s1 == *s2) - { - l1--; - l2--; - s1++; - s2++; - } - - /* strip common suffix */ - while (l1 > 0 && l2 > 0 && s1[l1 - 1] == s2[l2 - 1]) - { - l1--; - l2--; - } - - /* catch trivial cases */ - if (l1 == 0) - { - return l2; - } - if (l2 == 0) - { - return l1; - } - - /* make the inner cycle (i.e. string2) the longer one */ - if (l1 > l2) - { - int nx = l1; - char* sx = s1; - l1 = l2; - l2 = nx; - s1 = s2; - s2 = sx; - } - - //check len1 == 1 separately - if (l1 == 1) - { - //throw new NotImplementedException(); - if (xcost > 0) - //return l2 + 1 - 2*(memchr(s2, *s1, l2) != NULL); - { - return l2 + 1 - 2 * memchrRPLC(s2, *s1, l2); - } - else - //return l2 - (memchr(s2, *s1, l2) != NULL); - { - return l2 - memchrRPLC(s2, *s1, l2); - } - } - - l1++; - l2++; - half = l1 >> 1; - - /* initalize first row */ - //row = (int*)malloc(l2*sizeof(int)); - int* row = stackalloc int[l2]; - if (l2 < 0) - //if (!row) - { - return (int) -1; - } - end = row + l2 - 1; - for (i = 0; i < l2 - (xcost > 0 ? 0 : half); i++) - { - row[i] = i; - } - - /* go through the matrix and compute the costs. yes, this is an extremely - * obfuscated version, but also extremely memory-conservative and - * relatively fast. - */ - if (xcost > 0) - { - for (i = 1; i < l1; i++) - { - int* p = row + 1; - char char1 = s1[i - 1]; - char* char2p = s2; - int D = i; - int x = i; - while (p <= end) - { - if (char1 == *char2p++) - { - x = --D; - } - else - { - x++; - } - D = *p; - D++; - if (x > D) - { - x = D; - } - *p++ = x; - } - } - } - else - { - /* in this case we don't have to scan two corner triangles (of size len1/2) - * in the matrix because no best path can go throught them. note this - * breaks when len1 == len2 == 2 so the memchr() special case above is - * necessary */ - row[0] = l1 - half - 1; - for (i = 1; i < l1; i++) - { - int* p; - char char1 = s1[i - 1]; - char* char2p; - int D, x; - /* skip the upper triangle */ - if (i >= l1 - half) - { - int offset = i - (l1 - half); - int c3; - - char2p = s2 + offset; - p = row + offset; - c3 = *p++ + (char1 != *char2p++ ? 1 : 0); - x = *p; - x++; - D = x; - if (x > c3) - { - x = c3; - } - *p++ = x; - } - else - { - p = row + 1; - char2p = s2; - D = x = i; - } - /* skip the lower triangle */ - if (i <= half + 1) - { - end = row + l2 + i - half - 2; - } - /* main */ - while (p <= end) - { - int c3 = --D + (char1 != *char2p++ ? 1 : 0); - x++; - if (x > c3) - { - x = c3; - } - D = *p; - D++; - if (x > D) - { - x = D; - } - *p++ = x; - } - /* lower triangle sentinel */ - if (i <= half) - { - int c3 = --D + (char1 != *char2p ? 1 : 0); - x++; - if (x > c3) - { - x = c3; - } - *p = x; - } - } - } - - i = *end; - return i; - } - - /// - /// Returns true, if the given string is null or empty - /// - /// - /// - public static bool IsNull(string toTest) - { - return toTest == null || toTest.Length == 0; - } - - /// - /// Returns true, if the given string is null or empty or contains only spaces - /// - /// - /// - public static bool IsNullOrSpaces(string toTest) - { - return toTest == null || toTest.Trim().Length == 0; - } - - [Conditional("DEBUG")] - public static void AssertTrue(bool condition, string msg) - { - if (!condition) - { - MessageBox.Show("Assertion: " + msg); - throw new Exception(msg); - } - } - - public string GetWordFromPos(int xPos, string text, Graphics g, Font font) - { - string[] words = text.Split(new char[] {' ', '.', ':', ';'}); - int i = 0; - int index = 0; - List crList = []; - for (i = 0; i < words.Length; ++i) - { - crList.Add(new CharacterRange(index, words[i].Length)); - index += words[i].Length; - } - CharacterRange[] crArray = crList.ToArray(); - StringFormat stringFormat = new(StringFormat.GenericTypographic); - stringFormat.Trimming = StringTrimming.None; - stringFormat.FormatFlags = StringFormatFlags.NoClip; - stringFormat.SetMeasurableCharacterRanges(crArray); - RectangleF rect = new(0, 0, 3000, 20); - Region[] stringRegions = g.MeasureCharacterRanges(text, - font, rect, stringFormat); - bool found = false; - i = 0; - foreach (Region regio in stringRegions) - { - if (regio.IsVisible(xPos, 3, g)) - { - found = true; - break; - } - i++; - } - if (found) - { - return words[i]; - } - else - { - return null; - } - } - - #endregion - - #region Private Methods - - private static bool TestFilterMatch(FilterParams filterParams, ILogLine line, - LogExpert.ILogLineColumnizerCallback columnizerCallback) - { - string lowerSearchText; - string searchText; - Regex rex; - if (filterParams.isInRange) - { - lowerSearchText = filterParams.lowerRangeSearchText; - searchText = filterParams.rangeSearchText; - rex = filterParams.rangeRex; - } - else - { - lowerSearchText = filterParams.lowerSearchText; - searchText = filterParams.searchText; - rex = filterParams.rex; - } - - if (searchText == null || lowerSearchText == null || searchText.Length == 0) - { - return false; - } - - if (filterParams.columnRestrict) - { - IColumnizedLogLine columns = filterParams.currentColumnizer.SplitLine(columnizerCallback, line); - bool found = false; - foreach (int colIndex in filterParams.columnList) - { - if (colIndex < columns.ColumnValues.Length - ) // just to be sure, maybe the columnizer has changed anyhow - { - if (columns.ColumnValues[colIndex].FullValue.Trim().Length == 0) - { - if (filterParams.emptyColumnUsePrev) - { - string prevValue = (string) filterParams.lastNonEmptyCols[colIndex]; - if (prevValue != null) - { - if (TestMatchSub(filterParams, prevValue, lowerSearchText, searchText, rex, - filterParams.exactColumnMatch)) - { - found = true; - } - } - } - else if (filterParams.emptyColumnHit) - { - return true; - } - } - else - { - filterParams.lastNonEmptyCols[colIndex] = columns.ColumnValues[colIndex].FullValue; - if (TestMatchSub(filterParams, columns.ColumnValues[colIndex].FullValue, lowerSearchText, - searchText, rex, - filterParams.exactColumnMatch)) - { - found = true; - } - } - } - } - return found; - } - else - { - return TestMatchSub(filterParams, line.FullLine, lowerSearchText, searchText, rex, false); - } - } - - // - private static bool TestMatchSub(FilterParams filterParams, string line, string lowerSearchText, - string searchText, Regex rex, bool exactMatch) - { - if (filterParams.isRegex) - { - if (rex.IsMatch(line)) - { - return true; - } - } - else - { - if (!filterParams.isCaseSensitive) - { - if (exactMatch) - { - if (line.ToLower().Trim().Equals(lowerSearchText)) - { - return true; - } - } - else - { - if (line.ToLower().Contains(lowerSearchText)) - { - return true; - } - } - } - else - { - if (exactMatch) - { - if (line.Equals(searchText)) - { - return true; - } - } - else - { - if (line.Contains(searchText)) - { - return true; - } - } - } - - if (filterParams.fuzzyValue > 0) - { - int range = line.Length - searchText.Length; - if (range > 0) - { - for (int i = 0; i < range; ++i) - { - string src = line.Substring(i, searchText.Length); - if (!filterParams.isCaseSensitive) - { - src = src.ToLower(); - } - string dest = filterParams.isCaseSensitive ? searchText : lowerSearchText; - int dist = DamerauLevenshteinDistance(src, searchText); - if ((float) (searchText.Length + 1) / (float) (dist + 1) >= - 11F / (float) (filterParams.fuzzyValue + 1F)) - { - return true; - } - } - } - return false; - } - } - return false; - } - - private static unsafe int memchrRPLC(char* buffer, char c, int count) - { - char* p = buffer; - char* e = buffer + count; - while (p++ < e) - { - if (*p == c) - { - return 1; - } - } - return 0; - } - - #endregion - } +using LogExpert.Core.Classes.Filter; + +using System.Diagnostics; +using System.Drawing; +using System.Runtime.Versioning; +using System.Text.RegularExpressions; + +namespace LogExpert.Core.Classes +{ + public class Util + { + #region Public methods + + public static string GetNameFromPath(string fileName) + { + int i = fileName.LastIndexOf('\\'); + if (i < 0) + { + i = fileName.LastIndexOf('/'); + } + if (i < 0) + { + i = -1; + } + return fileName[(i + 1)..]; + } + + public static string StripExtension(string fileName) + { + int i = fileName.LastIndexOf('.'); + if (i < 0) + { + i = fileName.Length - 1; + } + return fileName[..i]; + } + + public static string GetExtension(string fileName) + { + int i = fileName.LastIndexOf('.'); + if (i < 0 || i >= fileName.Length - 1) + { + return ""; + } + else + { + return fileName[(i + 1)..]; + } + } + + + public static string GetFileSizeAsText(long size) + { + if (size < 1024) + { + return "" + size + " bytes"; + } + else if (size < 1024 * 1024) + { + return "" + size / 1024 + " KB"; + } + else + { + return "" + string.Format("{0:0.00}", size / 1048576.0) + " MB"; + } + } + + public static bool TestFilterCondition(FilterParams filterParams, ILogLine line, + LogExpert.ILogLineColumnizerCallback columnizerCallback) + { + if (filterParams.lastLine.Equals(line.FullLine)) + { + return filterParams.lastResult; + } + + bool match = TestFilterMatch(filterParams, line, columnizerCallback); + filterParams.lastLine = line.FullLine; + + if (filterParams.isRangeSearch) + { + if (!filterParams.isInRange) + { + if (match) + { + filterParams.isInRange = true; + } + } + else + { + if (!match) + { + match = true; + } + else + { + filterParams.isInRange = false; + } + } + } + if (filterParams.isInvert) + { + match = !match; + } + filterParams.lastResult = match; + return match; + } + + + public static int DamerauLevenshteinDistance(string src, string dest) + { + int[,] d = new int[src.Length + 1, dest.Length + 1]; + int i, j, cost; + char[] str1 = src.ToCharArray(); + char[] str2 = dest.ToCharArray(); + + for (i = 0; i <= str1.Length; i++) + { + d[i, 0] = i; + } + for (j = 0; j <= str2.Length; j++) + { + d[0, j] = j; + } + for (i = 1; i <= str1.Length; i++) + { + for (j = 1; j <= str2.Length; j++) + { + if (str1[i - 1] == str2[j - 1]) + { + cost = 0; + } + else + { + cost = 1; + } + + d[i, j] = + Math.Min(d[i - 1, j] + 1, // Deletion + Math.Min(d[i, j - 1] + 1, // Insertion + d[i - 1, j - 1] + cost)); // Substitution + + if (i > 1 && j > 1 && str1[i - 1] == str2[j - 2] && str1[i - 2] == str2[j - 1]) + { + d[i, j] = Math.Min(d[i, j], d[i - 2, j - 2] + cost); + } + } + } + return d[str1.Length, str2.Length]; + } + + + public static unsafe int YetiLevenshtein(string s1, string s2) + { + fixed (char* p1 = s1) + fixed (char* p2 = s2) + { + return YetiLevenshtein(p1, s1.Length, p2, s2.Length, 0); // substitutionCost = 1 + } + } + + public static unsafe int YetiLevenshtein(string s1, string s2, int substitionCost) + { + int xc = substitionCost - 1; + if (xc < 0 || xc > 1) + { + throw new ArgumentException("", "substitionCost"); + } + + fixed (char* p1 = s1) + fixed (char* p2 = s2) + { + return YetiLevenshtein(p1, s1.Length, p2, s2.Length, xc); + } + } + + /// + /// Cetin Sert, David Necas + /// Source Code + /// + /// + /// + /// + /// + /// + /// + public static unsafe int YetiLevenshtein(char* s1, int l1, char* s2, int l2, int xcost) + { + int i; + //int *row; /* we only need to keep one row of costs */ + int* end; + int half; + + /* strip common prefix */ + while (l1 > 0 && l2 > 0 && *s1 == *s2) + { + l1--; + l2--; + s1++; + s2++; + } + + /* strip common suffix */ + while (l1 > 0 && l2 > 0 && s1[l1 - 1] == s2[l2 - 1]) + { + l1--; + l2--; + } + + /* catch trivial cases */ + if (l1 == 0) + { + return l2; + } + if (l2 == 0) + { + return l1; + } + + /* make the inner cycle (i.e. string2) the longer one */ + if (l1 > l2) + { + int nx = l1; + char* sx = s1; + l1 = l2; + l2 = nx; + s1 = s2; + s2 = sx; + } + + //check len1 == 1 separately + if (l1 == 1) + { + //throw new NotImplementedException(); + if (xcost > 0) + //return l2 + 1 - 2*(memchr(s2, *s1, l2) != NULL); + { + return l2 + 1 - 2 * memchrRPLC(s2, *s1, l2); + } + else + //return l2 - (memchr(s2, *s1, l2) != NULL); + { + return l2 - memchrRPLC(s2, *s1, l2); + } + } + + l1++; + l2++; + half = l1 >> 1; + + /* initalize first row */ + //row = (int*)malloc(l2*sizeof(int)); + int* row = stackalloc int[l2]; + if (l2 < 0) + //if (!row) + { + return -1; + } + end = row + l2 - 1; + for (i = 0; i < l2 - (xcost > 0 ? 0 : half); i++) + { + row[i] = i; + } + + /* go through the matrix and compute the costs. yes, this is an extremely + * obfuscated version, but also extremely memory-conservative and + * relatively fast. + */ + if (xcost > 0) + { + for (i = 1; i < l1; i++) + { + int* p = row + 1; + char char1 = s1[i - 1]; + char* char2p = s2; + int D = i; + int x = i; + while (p <= end) + { + if (char1 == *char2p++) + { + x = --D; + } + else + { + x++; + } + D = *p; + D++; + if (x > D) + { + x = D; + } + *p++ = x; + } + } + } + else + { + /* in this case we don't have to scan two corner triangles (of size len1/2) + * in the matrix because no best path can go throught them. note this + * breaks when len1 == len2 == 2 so the memchr() special case above is + * necessary */ + row[0] = l1 - half - 1; + for (i = 1; i < l1; i++) + { + int* p; + char char1 = s1[i - 1]; + char* char2p; + int D, x; + /* skip the upper triangle */ + if (i >= l1 - half) + { + int offset = i - (l1 - half); + int c3; + + char2p = s2 + offset; + p = row + offset; + c3 = *p++ + (char1 != *char2p++ ? 1 : 0); + x = *p; + x++; + D = x; + if (x > c3) + { + x = c3; + } + *p++ = x; + } + else + { + p = row + 1; + char2p = s2; + D = x = i; + } + /* skip the lower triangle */ + if (i <= half + 1) + { + end = row + l2 + i - half - 2; + } + /* main */ + while (p <= end) + { + int c3 = --D + (char1 != *char2p++ ? 1 : 0); + x++; + if (x > c3) + { + x = c3; + } + D = *p; + D++; + if (x > D) + { + x = D; + } + *p++ = x; + } + /* lower triangle sentinel */ + if (i <= half) + { + int c3 = --D + (char1 != *char2p ? 1 : 0); + x++; + if (x > c3) + { + x = c3; + } + *p = x; + } + } + } + + i = *end; + return i; + } + + /// + /// Returns true, if the given string is null or empty + /// + /// + /// + public static bool IsNull(string toTest) + { + return toTest == null || toTest.Length == 0; + } + + /// + /// Returns true, if the given string is null or empty or contains only spaces + /// + /// + /// + public static bool IsNullOrSpaces(string toTest) + { + return toTest == null || toTest.Trim().Length == 0; + } + + [Conditional("DEBUG")] + public static void AssertTrue(bool condition, string msg) + { + if (!condition) + { + //Todo this should be done differently + //MessageBox.Show("Assertion: " + msg); + throw new Exception(msg); + } + } + + [SupportedOSPlatform("windows")] + public string GetWordFromPos(int xPos, string text, Graphics g, Font font) + { + string[] words = text.Split([' ', '.', ':', ';']); + + int index = 0; + + List crList = []; + + for (int i = 0; i < words.Length; ++i) + { + crList.Add(new CharacterRange(index, words[i].Length)); + index += words[i].Length; + } + + CharacterRange[] crArray = [.. crList]; + + StringFormat stringFormat = new(StringFormat.GenericTypographic) + { + Trimming = StringTrimming.None, + FormatFlags = StringFormatFlags.NoClip + }; + + stringFormat.SetMeasurableCharacterRanges(crArray); + + RectangleF rect = new(0, 0, 3000, 20); + Region[] stringRegions = g.MeasureCharacterRanges(text, font, rect, stringFormat); + + bool found = false; + + int y = 0; + + foreach (Region regio in stringRegions) + { + if (regio.IsVisible(xPos, 3, g)) + { + found = true; + break; + } + + y++; + } + + if (found) + { + return words[y]; + } + else + { + return null; + } + } + + #endregion + + #region Private Methods + + private static bool TestFilterMatch(FilterParams filterParams, ILogLine line, ILogLineColumnizerCallback columnizerCallback) + { + string lowerSearchText; + string searchText; + Regex rex; + + if (filterParams.isInRange) + { + lowerSearchText = filterParams.lowerRangeSearchText; + searchText = filterParams.rangeSearchText; + rex = filterParams.rangeRex; + } + else + { + lowerSearchText = filterParams.lowerSearchText; + searchText = filterParams.searchText; + rex = filterParams.rex; + } + + if (searchText == null || lowerSearchText == null || searchText.Length == 0) + { + return false; + } + + if (filterParams.columnRestrict) + { + IColumnizedLogLine columns = filterParams.currentColumnizer.SplitLine(columnizerCallback, line); + bool found = false; + foreach (int colIndex in filterParams.columnList) + { + if (colIndex < columns.ColumnValues.Length + ) // just to be sure, maybe the columnizer has changed anyhow + { + if (columns.ColumnValues[colIndex].FullValue.Trim().Length == 0) + { + if (filterParams.emptyColumnUsePrev) + { + string prevValue = (string)filterParams.lastNonEmptyCols[colIndex]; + if (prevValue != null) + { + if (TestMatchSub(filterParams, prevValue, lowerSearchText, searchText, rex, + filterParams.exactColumnMatch)) + { + found = true; + } + } + } + else if (filterParams.emptyColumnHit) + { + return true; + } + } + else + { + filterParams.lastNonEmptyCols[colIndex] = columns.ColumnValues[colIndex].FullValue; + if (TestMatchSub(filterParams, columns.ColumnValues[colIndex].FullValue, lowerSearchText, + searchText, rex, + filterParams.exactColumnMatch)) + { + found = true; + } + } + } + } + return found; + } + else + { + return TestMatchSub(filterParams, line.FullLine, lowerSearchText, searchText, rex, false); + } + } + + private static bool TestMatchSub(FilterParams filterParams, string line, string lowerSearchText, string searchText, Regex rex, bool exactMatch) + { + if (filterParams.isRegex) + { + if (rex.IsMatch(line)) + { + return true; + } + } + else + { + if (!filterParams.isCaseSensitive) + { + if (exactMatch) + { + if (line.ToLower().Trim().Equals(lowerSearchText)) + { + return true; + } + } + else + { + if (line.ToLower().Contains(lowerSearchText)) + { + return true; + } + } + } + else + { + if (exactMatch) + { + if (line.Equals(searchText)) + { + return true; + } + } + else + { + if (line.Contains(searchText)) + { + return true; + } + } + } + + if (filterParams.fuzzyValue > 0) + { + int range = line.Length - searchText.Length; + if (range > 0) + { + for (int i = 0; i < range; ++i) + { + string src = line.Substring(i, searchText.Length); + if (!filterParams.isCaseSensitive) + { + src = src.ToLower(); + } + string dest = filterParams.isCaseSensitive ? searchText : lowerSearchText; + int dist = DamerauLevenshteinDistance(src, searchText); + if ((searchText.Length + 1) / (float)(dist + 1) >= + 11F / (float)(filterParams.fuzzyValue + 1F)) + { + return true; + } + } + } + return false; + } + } + return false; + } + + private static unsafe int memchrRPLC(char* buffer, char c, int count) + { + char* p = buffer; + char* e = buffer + count; + while (p++ < e) + { + if (*p == c) + { + return 1; + } + } + return 0; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Win32.cs b/src/Logexpert.Core/Classes/Win32.cs similarity index 67% rename from src/LogExpert/Classes/Win32.cs rename to src/Logexpert.Core/Classes/Win32.cs index def689b1..15134978 100644 --- a/src/LogExpert/Classes/Win32.cs +++ b/src/Logexpert.Core/Classes/Win32.cs @@ -1,119 +1,120 @@ -using System; -using System.Drawing; -using System.Runtime.InteropServices; - -namespace LogExpert.Classes -{ - internal static class Win32 - { - #region Fields - - public const long SM_CYVSCROLL = 20; - public const long SM_CXHSCROLL = 21; - public const long SM_CXVSCROLL = 2; - public const long SM_CYHSCROLL = 3; - - #endregion - - #region Public methods - - [DllImport("user32.dll")] - public static extern bool DestroyIcon(IntPtr hIcon); - - public static Icon LoadIconFromExe(string fileName, int index) - { - //IntPtr[] smallIcons = new IntPtr[1]; - //IntPtr[] largeIcons = new IntPtr[1]; - IntPtr smallIcons = new(); - IntPtr largeIcons = new(); - int num = (int)ExtractIconEx(fileName, index, ref largeIcons, ref smallIcons, 1); - if (num > 0 && smallIcons.ToInt32() != 0) - { - Icon icon = Icon.FromHandle(smallIcons).Clone() as Icon; - DestroyIcon(smallIcons); - return icon; - } - if (num > 0 && largeIcons.ToInt32() != 0) - { - Icon icon = Icon.FromHandle(largeIcons).Clone() as Icon; - DestroyIcon(largeIcons); - return icon; - } - return null; - } - - - public static Icon[,] ExtractIcons(string fileName) - { - IntPtr smallIcon = IntPtr.Zero; - IntPtr largeIcon = IntPtr.Zero; - int iconCount = (int)ExtractIconEx(fileName, -1, ref largeIcon, ref smallIcon, 0); - if (iconCount <= 0) - { - return null; - } - - IntPtr smallIcons = new(); - IntPtr largeIcons = new(); - Icon[,] result = new Icon[2, iconCount]; - - for (int i = 0; i < iconCount; ++i) - { - int num = (int)ExtractIconEx(fileName, i, ref largeIcons, ref smallIcons, 1); - if (smallIcons.ToInt32() != 0) - { - result[0, i] = Icon.FromHandle(smallIcons).Clone() as Icon; - DestroyIcon(smallIcons); - } - else - { - result[0, i] = null; - } - if (num > 0 && largeIcons.ToInt32() != 0) - { - result[1, i] = Icon.FromHandle(largeIcons).Clone() as Icon; - DestroyIcon(largeIcons); - } - else - { - result[1, i] = null; - } - } - return result; - } - - [DllImport("user32.dll")] - public static extern long GetSystemMetricsForDpi(long index); - - - [DllImport("user32.dll")] - public static extern long GetSystemMetrics(long index); - - [DllImport("user32.dll")] - public static extern short GetKeyState(int vKey); - - #endregion - - #region Private Methods - - /* - UINT ExtractIconEx( - LPCTSTR lpszFile, - int nIconIndex, - HICON *phiconLarge, - HICON *phiconSmall, - UINT nIcons - ); - * */ - - [DllImport("shell32.dll")] - private static extern uint ExtractIconEx(string fileName, - int iconIndex, - ref IntPtr iconsLarge, - ref IntPtr iconsSmall, - uint numIcons - ); - - #endregion - } +using System.Drawing; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; + +namespace LogExpert.Core.Classes +{ + [SupportedOSPlatform("windows")] + public static class Win32 + { + #region Fields + + public const long SM_CYVSCROLL = 20; + public const long SM_CXHSCROLL = 21; + public const long SM_CXVSCROLL = 2; + public const long SM_CYHSCROLL = 3; + + #endregion + + #region Public methods + + [DllImport("user32.dll")] + public static extern bool DestroyIcon(nint hIcon); + + public static Icon LoadIconFromExe(string fileName, int index) + { + //IntPtr[] smallIcons = new IntPtr[1]; + //IntPtr[] largeIcons = new IntPtr[1]; + nint smallIcons = new(); + nint largeIcons = new(); + int num = (int)ExtractIconEx(fileName, index, ref largeIcons, ref smallIcons, 1); + if (num > 0 && smallIcons != nint.Zero) + { + Icon icon = (Icon)Icon.FromHandle(smallIcons).Clone(); + DestroyIcon(smallIcons); + return icon; + } + if (num > 0 && largeIcons != nint.Zero) + { + Icon icon = (Icon)Icon.FromHandle(largeIcons).Clone(); + DestroyIcon(largeIcons); + return icon; + } + return null; + } + + + public static Icon[,] ExtractIcons(string fileName) + { + nint smallIcon = nint.Zero; + nint largeIcon = nint.Zero; + int iconCount = (int)ExtractIconEx(fileName, -1, ref largeIcon, ref smallIcon, 0); + if (iconCount <= 0) + { + return null; + } + + nint smallIcons = new(); + nint largeIcons = new(); + Icon[,] result = new Icon[2, iconCount]; + + for (int i = 0; i < iconCount; ++i) + { + int num = (int)ExtractIconEx(fileName, i, ref largeIcons, ref smallIcons, 1); + if (smallIcons != nint.Zero) + { + result[0, i] = (Icon)Icon.FromHandle(smallIcons).Clone(); + DestroyIcon(smallIcons); + } + else + { + result[0, i] = null; + } + if (num > 0 && largeIcons != nint.Zero) + { + result[1, i] = (Icon)Icon.FromHandle(largeIcons).Clone(); + DestroyIcon(largeIcons); + } + else + { + result[1, i] = null; + } + } + return result; + } + + [DllImport("user32.dll")] + public static extern long GetSystemMetricsForDpi(long index); + + + [DllImport("user32.dll")] + public static extern long GetSystemMetrics(long index); + + [DllImport("user32.dll")] + public static extern short GetKeyState(int vKey); + + #endregion + + #region Private Methods + + /* + UINT ExtractIconEx( + LPCTSTR lpszFile, + int nIconIndex, + HICON *phiconLarge, + HICON *phiconSmall, + UINT nIcons + ); + * */ + + [DllImport("shell32.dll")] + private static extern uint ExtractIconEx(string fileName, + int iconIndex, + ref nint iconsLarge, + ref nint iconsSmall, + uint numIcons + ); + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/xml/XmlBlockSplitter.cs b/src/Logexpert.Core/Classes/xml/XmlBlockSplitter.cs similarity index 92% rename from src/LogExpert/Classes/xml/XmlBlockSplitter.cs rename to src/Logexpert.Core/Classes/xml/XmlBlockSplitter.cs index fac013f5..8b8a643c 100644 --- a/src/LogExpert/Classes/xml/XmlBlockSplitter.cs +++ b/src/Logexpert.Core/Classes/xml/XmlBlockSplitter.cs @@ -1,172 +1,170 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Xml; -using System.Xml.Xsl; -using LogExpert.Classes.Log; - -namespace LogExpert.Classes.xml -{ - internal class XmlBlockSplitter : LogStreamReaderBase - { - #region Fields - - private static readonly string[] _splitStrings = { "\r\n", "\n", "\r" }; - - private static readonly char[] _newLineChar = { '\n' }; - - private readonly XmlLogReader _reader; - - private readonly XmlParserContext _context; - private readonly XmlReaderSettings _settings; - - private readonly Queue _lineList = new(); - - private string _stylesheet; - private XslCompiledTransform _xslt; - - #endregion - - #region cTor - - public XmlBlockSplitter(XmlLogReader reader, IXmlLogConfiguration xmlLogConfig) - { - _reader = reader; - _reader.StartTag = xmlLogConfig.XmlStartTag; - _reader.EndTag = xmlLogConfig.XmlEndTag; - - Stylesheet = xmlLogConfig.Stylesheet; - - // Create the XmlNamespaceManager. - NameTable nt = new(); - XmlNamespaceManager nsmgr = new(nt); - if (xmlLogConfig.Namespace != null) - { - nsmgr.AddNamespace(xmlLogConfig.Namespace[0], xmlLogConfig.Namespace[1]); - } - // Create the XmlParserContext. - _context = new XmlParserContext(nt, nsmgr, null, XmlSpace.None); - _settings = new XmlReaderSettings(); - _settings.ConformanceLevel = ConformanceLevel.Fragment; - } - - #endregion - - #region Properties - - public override long Position - { - get => _reader.Position; - set => _reader.Position = value; - } - - public override Encoding Encoding => _reader.Encoding; - - public override bool IsBufferComplete => _lineList.Count == 0; - - public string Stylesheet - { - get => _stylesheet; - set - { - _stylesheet = value; - if (_stylesheet != null) - { - XmlReader stylesheetReader = XmlReader.Create(new StringReader(_stylesheet)); - - _xslt = new XslCompiledTransform(); - _xslt.Load(stylesheetReader); - } - else - { - _xslt = null; - } - } - } - - #endregion - - #region Private Methods - - private void ParseXmlBlock(string block) - { - if (_stylesheet != null) - { - XmlReader xmlReader = XmlReader.Create(new StringReader(block), _settings, _context); - - xmlReader.Read(); - xmlReader.MoveToContent(); - //xmlReader.MoveToContent(); - StringWriter textWriter = new(); - - _xslt.Transform(xmlReader, null, textWriter); - string message = textWriter.ToString(); - SplitToLinesList(message); - } - else - { - SplitToLinesList(block); - //this.lineList.Add(block); // TODO: make configurable, if block has to be splitted - } - } - - private void SplitToLinesList(string message) - { - const int MAX_LEN = 3000; - string[] lines = message.Split(_splitStrings, StringSplitOptions.None); - foreach (string theLine in lines) - { - string line = theLine.Trim(_newLineChar); - while (line.Length > MAX_LEN) - { - string part = line.Substring(0, MAX_LEN); - line = line.Substring(MAX_LEN); - _lineList.Enqueue(part); - } - _lineList.Enqueue(line); - } - } - - #endregion - - #region Public Methods - - protected override void Dispose(bool disposing) - { - if (disposing) - { - _reader.Dispose(); - } - } - - public override int ReadChar() - { - return _reader.ReadChar(); - } - - public override string ReadLine() - { - if (_lineList.Count == 0) - { - string block = _reader.ReadLine(); - if (block == null) - { - return null; - } - - try - { - ParseXmlBlock(block); - } - catch (XmlException) - { - _lineList.Enqueue("[XML Parser error] " + block); - } - } - return _lineList.Dequeue(); - } - - #endregion - } +using LogExpert.Core.Classes.Log; + +using System.Text; +using System.Xml; +using System.Xml.Xsl; + +namespace LogExpert.Core.Classes.xml +{ + public class XmlBlockSplitter : LogStreamReaderBase + { + #region Fields + + private static readonly string[] _splitStrings = { "\r\n", "\n", "\r" }; + + private static readonly char[] _newLineChar = { '\n' }; + + private readonly XmlLogReader _reader; + + private readonly XmlParserContext _context; + private readonly XmlReaderSettings _settings; + + private readonly Queue _lineList = new(); + + private string _stylesheet; + private XslCompiledTransform _xslt; + + #endregion + + #region cTor + + public XmlBlockSplitter(XmlLogReader reader, IXmlLogConfiguration xmlLogConfig) + { + _reader = reader; + _reader.StartTag = xmlLogConfig.XmlStartTag; + _reader.EndTag = xmlLogConfig.XmlEndTag; + + Stylesheet = xmlLogConfig.Stylesheet; + + // Create the XmlNamespaceManager. + NameTable nt = new(); + XmlNamespaceManager nsmgr = new(nt); + if (xmlLogConfig.Namespace != null) + { + nsmgr.AddNamespace(xmlLogConfig.Namespace[0], xmlLogConfig.Namespace[1]); + } + // Create the XmlParserContext. + _context = new XmlParserContext(nt, nsmgr, null, XmlSpace.None); + _settings = new XmlReaderSettings(); + _settings.ConformanceLevel = ConformanceLevel.Fragment; + } + + #endregion + + #region Properties + + public override long Position + { + get => _reader.Position; + set => _reader.Position = value; + } + + public override Encoding Encoding => _reader.Encoding; + + public override bool IsBufferComplete => _lineList.Count == 0; + + public string Stylesheet + { + get => _stylesheet; + set + { + _stylesheet = value; + if (_stylesheet != null) + { + XmlReader stylesheetReader = XmlReader.Create(new StringReader(_stylesheet)); + + _xslt = new XslCompiledTransform(); + _xslt.Load(stylesheetReader); + } + else + { + _xslt = null; + } + } + } + + #endregion + + #region Private Methods + + private void ParseXmlBlock(string block) + { + if (_stylesheet != null) + { + XmlReader xmlReader = XmlReader.Create(new StringReader(block), _settings, _context); + + xmlReader.Read(); + xmlReader.MoveToContent(); + //xmlReader.MoveToContent(); + StringWriter textWriter = new(); + + _xslt.Transform(xmlReader, null, textWriter); + string message = textWriter.ToString(); + SplitToLinesList(message); + } + else + { + SplitToLinesList(block); + //this.lineList.Add(block); // TODO: make configurable, if block has to be splitted + } + } + + private void SplitToLinesList(string message) + { + const int MAX_LEN = 3000; + string[] lines = message.Split(_splitStrings, StringSplitOptions.None); + foreach (string theLine in lines) + { + string line = theLine.Trim(_newLineChar); + while (line.Length > MAX_LEN) + { + string part = line.Substring(0, MAX_LEN); + line = line.Substring(MAX_LEN); + _lineList.Enqueue(part); + } + _lineList.Enqueue(line); + } + } + + #endregion + + #region Public Methods + + protected override void Dispose(bool disposing) + { + if (disposing) + { + _reader.Dispose(); + } + } + + public override int ReadChar() + { + return _reader.ReadChar(); + } + + public override string ReadLine() + { + if (_lineList.Count == 0) + { + string block = _reader.ReadLine(); + if (block == null) + { + return null; + } + + try + { + ParseXmlBlock(block); + } + catch (XmlException) + { + _lineList.Enqueue("[XML Parser error] " + block); + } + } + return _lineList.Dequeue(); + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/xml/XmlLogReader.cs b/src/Logexpert.Core/Classes/xml/XmlLogReader.cs similarity index 93% rename from src/LogExpert/Classes/xml/XmlLogReader.cs rename to src/Logexpert.Core/Classes/xml/XmlLogReader.cs index b64294e9..09da8017 100644 --- a/src/LogExpert/Classes/xml/XmlLogReader.cs +++ b/src/Logexpert.Core/Classes/xml/XmlLogReader.cs @@ -1,171 +1,171 @@ -using System.Text; -using System.Threading; -using LogExpert.Classes.Log; -using LogExpert.Interface; - -namespace LogExpert.Classes.xml -{ - internal class XmlLogReader : LogStreamReaderBase - { - #region Fields - - private readonly ILogStreamReader reader; - - #endregion - - #region cTor - - public XmlLogReader(ILogStreamReader reader) - { - this.reader = reader; - } - - #endregion - - #region Properties - - public override long Position - { - get => reader.Position; - set => reader.Position = value; - } - - public override Encoding Encoding => reader.Encoding; - - public override bool IsBufferComplete => reader.IsBufferComplete; - - public string StartTag { get; set; } = " 0) - { - Thread.Sleep(100); - continue; - } - else - { - eof = true; - break; - } - } - else - { - eof = true; - break; - } - } - - char readChar = (char)readInt; - // state: - // 0 = looking for tag start - // 1 = reading into buffer as long as the read data matches the start tag - // 2 = reading into buffer while waiting for the begin of the end tag - // 3 = reading into buffer as long as data matches the end tag. stopping when tag complete - switch (state) - { - case 0: - if (readChar == StartTag[0]) - { - //_logger.logInfo("state = 1"); - state = 1; - tagIndex = 1; - builder.Append(readChar); - } - //else - //{ - // _logger.logInfo("char: " + readChar); - //} - break; - case 1: - if (readChar == StartTag[tagIndex]) - { - builder.Append(readChar); - - if (++tagIndex >= StartTag.Length) - { - //_logger.logInfo("state = 2"); - state = 2; // start Tag complete - tagIndex = 0; - } - } - else - { - // tag doesn't match anymore - //_logger.logInfo("state = 0 [" + buffer.ToString() + readChar + "]"); - state = 0; - builder.Clear(); - } - break; - case 2: - builder.Append(readChar); - - if (readChar == EndTag[0]) - { - //_logger.logInfo("state = 3"); - state = 3; - tagIndex = 1; - } - break; - case 3: - builder.Append(readChar); - - if (readChar == EndTag[tagIndex]) - { - tagIndex++; - if (tagIndex >= EndTag.Length) - { - blockComplete = true; - break; - } - } - else - { - //_logger.logInfo("state = 2"); - state = 2; - } - break; - } - } - - return blockComplete ? builder.ToString() : null; - } - - #endregion - } +using LogExpert.Core.Classes.Log; +using LogExpert.Core.Interface; + +using System.Text; + +namespace LogExpert.Core.Classes.xml +{ + public class XmlLogReader : LogStreamReaderBase + { + #region Fields + + private readonly ILogStreamReader reader; + + #endregion + + #region cTor + + public XmlLogReader(ILogStreamReader reader) + { + this.reader = reader; + } + + #endregion + + #region Properties + + public override long Position + { + get => reader.Position; + set => reader.Position = value; + } + + public override Encoding Encoding => reader.Encoding; + + public override bool IsBufferComplete => reader.IsBufferComplete; + + public string StartTag { get; set; } = " 0) + { + Thread.Sleep(100); + continue; + } + else + { + eof = true; + break; + } + } + else + { + eof = true; + break; + } + } + + char readChar = (char)readInt; + // state: + // 0 = looking for tag start + // 1 = reading into buffer as long as the read data matches the start tag + // 2 = reading into buffer while waiting for the begin of the end tag + // 3 = reading into buffer as long as data matches the end tag. stopping when tag complete + switch (state) + { + case 0: + if (readChar == StartTag[0]) + { + //_logger.logInfo("state = 1"); + state = 1; + tagIndex = 1; + builder.Append(readChar); + } + //else + //{ + // _logger.logInfo("char: " + readChar); + //} + break; + case 1: + if (readChar == StartTag[tagIndex]) + { + builder.Append(readChar); + + if (++tagIndex >= StartTag.Length) + { + //_logger.logInfo("state = 2"); + state = 2; // start Tag complete + tagIndex = 0; + } + } + else + { + // tag doesn't match anymore + //_logger.logInfo("state = 0 [" + buffer.ToString() + readChar + "]"); + state = 0; + builder.Clear(); + } + break; + case 2: + builder.Append(readChar); + + if (readChar == EndTag[0]) + { + //_logger.logInfo("state = 3"); + state = 3; + tagIndex = 1; + } + break; + case 3: + builder.Append(readChar); + + if (readChar == EndTag[tagIndex]) + { + tagIndex++; + if (tagIndex >= EndTag.Length) + { + blockComplete = true; + break; + } + } + else + { + //_logger.logInfo("state = 2"); + state = 2; + } + break; + } + } + + return blockComplete ? builder.ToString() : null; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Config/ColorEntry.cs b/src/Logexpert.Core/Config/ColorEntry.cs similarity index 85% rename from src/LogExpert/Config/ColorEntry.cs rename to src/Logexpert.Core/Config/ColorEntry.cs index 250b1c11..6a2dc251 100644 --- a/src/LogExpert/Config/ColorEntry.cs +++ b/src/Logexpert.Core/Config/ColorEntry.cs @@ -1,31 +1,30 @@ -#region - -using System; -using System.Drawing; - -#endregion - -namespace LogExpert.Config -{ - [Serializable] - public class ColorEntry - { - #region cTor - - public ColorEntry(string fileName, Color color) - { - FileName = fileName; - Color = color; - } - - #endregion - - public Color Color { get; } - - public string FileName { get; } - - #region Fields - - #endregion - } +#region + +using System.Drawing; + +#endregion + +namespace LogExpert.Core.Config +{ + [Serializable] + public class ColorEntry + { + #region cTor + + public ColorEntry(string fileName, Color color) + { + FileName = fileName; + Color = color; + } + + #endregion + + public Color Color { get; } + + public string FileName { get; } + + #region Fields + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Config/ColorMode.cs b/src/Logexpert.Core/Config/ColorMode.cs similarity index 89% rename from src/LogExpert/Config/ColorMode.cs rename to src/Logexpert.Core/Config/ColorMode.cs index 3e203602..391d16e7 100644 --- a/src/LogExpert/Config/ColorMode.cs +++ b/src/Logexpert.Core/Config/ColorMode.cs @@ -1,8 +1,7 @@ -using System; -using System.Drawing; +using System.Drawing; using System.Runtime.InteropServices; -namespace LogExpert.Config +namespace LogExpert.Core.Config { public static class ColorMode { @@ -34,14 +33,11 @@ public static class ColorMode public static Color InactiveTabColor = LessBrightBackgroundColor; public static Color TabsBackgroundStripColor = LessBrightBackgroundColor; - public static bool DarkModeEnabled; - public static void LoadColorMode() + public static void LoadColorMode(bool darkMode) { - var preferences = ConfigManager.Settings.Preferences; - - if (preferences.darkMode) + if (darkMode) { SetDarkMode(); } @@ -81,12 +77,12 @@ private static void SetBrightMode() #region TitleBarDarkMode [DllImport("dwmapi.dll")] - private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize); + private static extern int DwmSetWindowAttribute(nint hwnd, int attr, ref int attrValue, int attrSize); private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19; private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20; - public static bool UseImmersiveDarkMode(IntPtr handle, bool enabled) + public static bool UseImmersiveDarkMode(nint handle, bool enabled) { var attribute = DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1; @@ -96,7 +92,7 @@ public static bool UseImmersiveDarkMode(IntPtr handle, bool enabled) } int useImmersiveDarkMode = enabled ? 1 : 0; - return DwmSetWindowAttribute(handle, (int)attribute, ref useImmersiveDarkMode, sizeof(int)) == 0; + return DwmSetWindowAttribute(handle, attribute, ref useImmersiveDarkMode, sizeof(int)) == 0; } diff --git a/src/LogExpert/Config/ColumnizerHistoryEntry.cs b/src/Logexpert.Core/Config/ColumnizerHistoryEntry.cs similarity index 89% rename from src/LogExpert/Config/ColumnizerHistoryEntry.cs rename to src/Logexpert.Core/Config/ColumnizerHistoryEntry.cs index dc2a3058..1320bba6 100644 --- a/src/LogExpert/Config/ColumnizerHistoryEntry.cs +++ b/src/Logexpert.Core/Config/ColumnizerHistoryEntry.cs @@ -1,30 +1,30 @@ -#region - -using System; - -#endregion - -namespace LogExpert.Config -{ - [Serializable] - public class ColumnizerHistoryEntry - { - #region cTor - - public ColumnizerHistoryEntry(string fileName, string columnizerName) - { - FileName = fileName; - ColumnizerName = columnizerName; - } - - #endregion - - #region Fields - - public string FileName { get; } - - #endregion - - public string ColumnizerName { get; } - } +#region + +using System; + +#endregion + +namespace LogExpert.Core.Config +{ + [Serializable] + public class ColumnizerHistoryEntry + { + #region cTor + + public ColumnizerHistoryEntry(string fileName, string columnizerName) + { + FileName = fileName; + ColumnizerName = columnizerName; + } + + #endregion + + #region Fields + + public string FileName { get; } + + #endregion + + public string ColumnizerName { get; } + } } \ No newline at end of file diff --git a/src/LogExpert/Config/ColumnizerMaskEntry.cs b/src/Logexpert.Core/Config/ColumnizerMaskEntry.cs similarity index 82% rename from src/LogExpert/Config/ColumnizerMaskEntry.cs rename to src/Logexpert.Core/Config/ColumnizerMaskEntry.cs index ad897b54..d15d0fc1 100644 --- a/src/LogExpert/Config/ColumnizerMaskEntry.cs +++ b/src/Logexpert.Core/Config/ColumnizerMaskEntry.cs @@ -1,15 +1,15 @@ -using System; - -namespace LogExpert.Config -{ - [Serializable] - public class ColumnizerMaskEntry - { - #region Fields - - public string columnizerName; - public string mask; - - #endregion - } +using System; + +namespace LogExpert.Core.Config +{ + [Serializable] + public class ColumnizerMaskEntry + { + #region Fields + + public string columnizerName; + public string mask; + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Config/ExportImportFlags.cs b/src/Logexpert.Core/Config/ExportImportFlags.cs similarity index 79% rename from src/LogExpert/Config/ExportImportFlags.cs rename to src/Logexpert.Core/Config/ExportImportFlags.cs index 7bdae090..ab3aa66e 100644 --- a/src/LogExpert/Config/ExportImportFlags.cs +++ b/src/Logexpert.Core/Config/ExportImportFlags.cs @@ -1,18 +1,18 @@ -using System; - -namespace LogExpert.Config -{ - [Flags] - public enum ExportImportFlags : long - { - None = 0, - HighlightSettings = 1, - ColumnizerMasks = 2, - HighlightMasks = 4, - ToolEntries = 8, - Other = 16, - KeepExisting = 32, - All = HighlightSettings | ColumnizerMasks | HighlightMasks | ToolEntries | Other, - AllKeepExisting = All | KeepExisting - } +using System; + +namespace LogExpert.Core.Config +{ + [Flags] + public enum ExportImportFlags : long + { + None = 0, + HighlightSettings = 1, + ColumnizerMasks = 2, + HighlightMasks = 4, + ToolEntries = 8, + Other = 16, + KeepExisting = 32, + All = HighlightSettings | ColumnizerMasks | HighlightMasks | ToolEntries | Other, + AllKeepExisting = All | KeepExisting + } } \ No newline at end of file diff --git a/src/LogExpert/Config/HighlightMaskEntry.cs b/src/Logexpert.Core/Config/HighlightMaskEntry.cs similarity index 82% rename from src/LogExpert/Config/HighlightMaskEntry.cs rename to src/Logexpert.Core/Config/HighlightMaskEntry.cs index 73fe3217..7435222d 100644 --- a/src/LogExpert/Config/HighlightMaskEntry.cs +++ b/src/Logexpert.Core/Config/HighlightMaskEntry.cs @@ -1,15 +1,15 @@ -using System; - -namespace LogExpert.Config -{ - [Serializable] - public class HighlightMaskEntry - { - #region Fields - - public string highlightGroupName; - public string mask; - - #endregion - } +using System; + +namespace LogExpert.Core.Config +{ + [Serializable] + public class HighlightMaskEntry + { + #region Fields + + public string highlightGroupName; + public string mask; + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Config/MultiFileOption.cs b/src/Logexpert.Core/Config/MultiFileOption.cs similarity index 77% rename from src/LogExpert/Config/MultiFileOption.cs rename to src/Logexpert.Core/Config/MultiFileOption.cs index 249307fd..5dbb3ab8 100644 --- a/src/LogExpert/Config/MultiFileOption.cs +++ b/src/Logexpert.Core/Config/MultiFileOption.cs @@ -1,12 +1,12 @@ -using System; - -namespace LogExpert.Config -{ - [Serializable] - public enum MultiFileOption - { - SingleFiles, - MultiFile, - Ask - } +using System; + +namespace LogExpert.Core.Config +{ + [Serializable] + public enum MultiFileOption + { + SingleFiles, + MultiFile, + Ask + } } \ No newline at end of file diff --git a/src/LogExpert/Config/Preferences.cs b/src/Logexpert.Core/Config/Preferences.cs similarity index 86% rename from src/LogExpert/Config/Preferences.cs rename to src/Logexpert.Core/Config/Preferences.cs index f93647da..62529eac 100644 --- a/src/LogExpert/Config/Preferences.cs +++ b/src/Logexpert.Core/Config/Preferences.cs @@ -1,110 +1,110 @@ -using LogExpert.Dialogs; -using LogExpert.Entities; - -using System; -using System.Collections.Generic; -using System.Drawing; - -namespace LogExpert.Config -{ - [Serializable] - public class Preferences - { - #region Fields - - public bool allowOnlyOneInstance; - - public bool askForClose = false; - - public bool darkMode = false; - - public int bufferCount = 100; - - public List columnizerMaskList = []; - - public string defaultEncoding; - - public bool filterSync = true; - - public bool filterTail = true; - - public bool followTail = true; - - public string fontName = "Courier New"; - - public float fontSize = 9; - - public List highlightMaskList = []; - - public bool isAutoHideFilterList = false; - - public bool isFilterOnLoad; - - public int lastColumnWidth = 2000; - - public int linesPerBuffer = 500; - - public int maximumFilterEntries = 30; - - public int maximumFilterEntriesDisplayed = 20; - - public bool maskPrio; - - public bool autoPick; - - public MultiFileOption multiFileOption; - - public MultiFileOptions multiFileOptions; - - public bool multiThreadFilter = true; - - public bool openLastFiles = true; - - public int pollingInterval = 250; - - public bool reverseAlpha = false; - - public bool PortableMode { get; set; } - - /// - /// Save Directory of the last logfile - /// - public string sessionSaveDirectory = null; - - public bool saveFilters = true; - - public SessionSaveLocation saveLocation = SessionSaveLocation.DocumentsDir; - - public bool saveSessions = true; - - public bool setLastColumnWidth; - - public bool showBubbles = true; - - public bool showColumnFinder; - - public Color showTailColor = Color.FromKnownColor(KnownColor.Blue); - - public bool showTailState = true; - - public bool showTimeSpread = false; - - public Color timeSpreadColor = Color.FromKnownColor(KnownColor.Gray); - - public bool timeSpreadTimeMode; - - public bool timestampControl = true; - - public DateTimeDragControl.DragOrientations timestampControlDragOrientation = DateTimeDragControl.DragOrientations.Horizontal; - - public List toolEntries = []; - - public bool useLegacyReader; - - public bool ShowErrorMessageAllowOnlyOneInstances { get; set; } - - public int MaxLineLength { get; set; } = 20000; - - #endregion - } +using LogExpert.Core.Entities; +using LogExpert.Core.Enums; + +using System.Drawing; + +namespace LogExpert.Core.Config +{ + [Serializable] + public class Preferences + { + #region Fields + + public bool allowOnlyOneInstance; + + public bool askForClose = false; + + public bool darkMode = false; + + public int bufferCount = 100; + + public List columnizerMaskList = []; + + public string defaultEncoding; + + public bool filterSync = true; + + public bool filterTail = true; + + public bool followTail = true; + + public string fontName = "Courier New"; + + public float fontSize = 9; + + public List highlightMaskList = []; + + public bool isAutoHideFilterList = false; + + public bool isFilterOnLoad; + + public int lastColumnWidth = 2000; + + public int linesPerBuffer = 500; + + public int maximumFilterEntries = 30; + + public int maximumFilterEntriesDisplayed = 20; + + public bool maskPrio; + + public bool autoPick; + + //Refactor Enum + public MultiFileOption multiFileOption; + + //Refactor class? + public MultiFileOptions multiFileOptions; + + public bool multiThreadFilter = true; + + public bool openLastFiles = true; + + public int pollingInterval = 250; + + public bool reverseAlpha = false; + + public bool PortableMode { get; set; } + + /// + /// Save Directory of the last logfile + /// + public string sessionSaveDirectory = null; + + public bool saveFilters = true; + + public SessionSaveLocation saveLocation = SessionSaveLocation.DocumentsDir; + + public bool saveSessions = true; + + public bool setLastColumnWidth; + + public bool showBubbles = true; + + public bool showColumnFinder; + + public Color showTailColor = Color.FromKnownColor(KnownColor.Blue); + + public bool showTailState = true; + + public bool showTimeSpread = false; + + public Color timeSpreadColor = Color.FromKnownColor(KnownColor.Gray); + + public bool timeSpreadTimeMode; + + public bool timestampControl = true; + + public DragOrientationsEnum timestampControlDragOrientation = DragOrientationsEnum.Horizontal; + + public List toolEntries = []; + + public bool useLegacyReader; + + public bool ShowErrorMessageAllowOnlyOneInstances { get; set; } + + public int MaxLineLength { get; set; } = 20000; + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Config/RegexHistory.cs b/src/Logexpert.Core/Config/RegexHistory.cs similarity index 86% rename from src/LogExpert/Config/RegexHistory.cs rename to src/Logexpert.Core/Config/RegexHistory.cs index cb24f96e..a00fd630 100644 --- a/src/LogExpert/Config/RegexHistory.cs +++ b/src/Logexpert.Core/Config/RegexHistory.cs @@ -1,13 +1,13 @@ -using System; -using System.Collections.Generic; - -namespace LogExpert.Config -{ - [Serializable] - public class RegexHistory - { - public List ExpressionHistoryList { get; set; } = []; - - public List TesttextHistoryList { get; set; } = []; - } +using System; +using System.Collections.Generic; + +namespace LogExpert.Core.Config +{ + [Serializable] + public class RegexHistory + { + public List ExpressionHistoryList { get; set; } = []; + + public List TesttextHistoryList { get; set; } = []; + } } \ No newline at end of file diff --git a/src/LogExpert/Config/SessionSaveLocation.cs b/src/Logexpert.Core/Config/SessionSaveLocation.cs similarity index 84% rename from src/LogExpert/Config/SessionSaveLocation.cs rename to src/Logexpert.Core/Config/SessionSaveLocation.cs index 540147b8..2b9b6ce8 100644 --- a/src/LogExpert/Config/SessionSaveLocation.cs +++ b/src/Logexpert.Core/Config/SessionSaveLocation.cs @@ -1,26 +1,26 @@ -using System; - -namespace LogExpert.Config -{ - [Serializable] - public enum SessionSaveLocation - { - //Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + Path.DirectorySeparatorChar + "LogExpert" - /// - /// - /// - DocumentsDir, - //same directory as the logfile - SameDir, - //uses configured folder to save the session files - /// - /// - /// - OwnDir, - /// - /// - /// - ApplicationStartupDir, - LoadedSessionFile - } +using System; + +namespace LogExpert.Core.Config +{ + [Serializable] + public enum SessionSaveLocation + { + //Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + Path.DirectorySeparatorChar + "LogExpert" + /// + /// + /// + DocumentsDir, + //same directory as the logfile + SameDir, + //uses configured folder to save the session files + /// + /// + /// + OwnDir, + /// + /// + /// + ApplicationStartupDir, + LoadedSessionFile + } } \ No newline at end of file diff --git a/src/LogExpert/Config/Settings.cs b/src/Logexpert.Core/Config/Settings.cs similarity index 88% rename from src/LogExpert/Config/Settings.cs rename to src/Logexpert.Core/Config/Settings.cs index b7264b00..fda64749 100644 --- a/src/LogExpert/Config/Settings.cs +++ b/src/Logexpert.Core/Config/Settings.cs @@ -1,62 +1,62 @@ -using LogExpert.Classes.Filter; -using LogExpert.Classes.Highlight; -using LogExpert.Entities; - -using System; -using System.Collections.Generic; -using System.Drawing; - -namespace LogExpert.Config -{ - [Serializable] - public class Settings - { - #region Fields - - public bool alwaysOnTop; - - public Rectangle appBounds; - - public Rectangle appBoundsFullscreen; - - public IList columnizerHistoryList = []; - - public List fileColors = []; - - public List fileHistoryList = []; - - public List filterHistoryList = []; - - public List filterList = []; - - public FilterParams filterParams = new(); - - public List filterRangeHistoryList = []; - - public bool hideLineColumn; - - public List hilightEntryList = []; // legacy. is automatically converted to highlight groups on settings load - - public List hilightGroupList = []; // should be in Preferences but is here for mistake. Maybe I migrate it some day. - - public bool isMaximized; - - public string lastDirectory; - - public List lastOpenFilesList = []; - - public Preferences Preferences { get; set; } = new(); - - public RegexHistory RegexHistory { get; set; } = new(); - - public List searchHistoryList = []; - - public SearchParams searchParams = new(); - - public IList uriHistoryList = []; - - public int versionBuild; - - #endregion - } +using LogExpert.Core.Classes.Filter; +using LogExpert.Core.Classes.Highlight; +using LogExpert.Core.Entities; + +using System; +using System.Collections.Generic; +using System.Drawing; + +namespace LogExpert.Core.Config +{ + [Serializable] + public class Settings + { + #region Fields + + public bool alwaysOnTop; + + public Rectangle appBounds; + + public Rectangle appBoundsFullscreen; + + public IList columnizerHistoryList = []; + + public List fileColors = []; + + public List fileHistoryList = []; + + public List filterHistoryList = []; + + public List filterList = []; + + public FilterParams filterParams = new(); + + public List filterRangeHistoryList = []; + + public bool hideLineColumn; + + public List hilightEntryList = []; // legacy. is automatically converted to highlight groups on settings load + + public List hilightGroupList = []; // should be in Preferences but is here for mistake. Maybe I migrate it some day. + + public bool isMaximized; + + public string lastDirectory; + + public List lastOpenFilesList = []; + + public Preferences Preferences { get; set; } = new(); + + public RegexHistory RegexHistory { get; set; } = new(); + + public List searchHistoryList = []; + + public SearchParams searchParams = new(); + + public IList uriHistoryList = []; + + public int versionBuild; + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Config/SettingsFlags.cs b/src/Logexpert.Core/Config/SettingsFlags.cs similarity index 91% rename from src/LogExpert/Config/SettingsFlags.cs rename to src/Logexpert.Core/Config/SettingsFlags.cs index a86a63b4..303874da 100644 --- a/src/LogExpert/Config/SettingsFlags.cs +++ b/src/Logexpert.Core/Config/SettingsFlags.cs @@ -1,24 +1,24 @@ -using System; - -namespace LogExpert.Config -{ - [Flags] - public enum SettingsFlags : long - { - None = 0, - WindowPosition = 1, - FileHistory = 2, - HighlightSettings = 4, - FilterList = 8, - RegexHistory = 16, - ToolSettings = 32, - GuiOrColors = 64, - FilterHistory = 128, - - All = WindowPosition | FileHistory | HighlightSettings | - FilterList | RegexHistory | ToolSettings | GuiOrColors | - FilterHistory, - - Settings = All & ~WindowPosition & ~FileHistory, - } +using System; + +namespace LogExpert.Core.Config +{ + [Flags] + public enum SettingsFlags : long + { + None = 0, + WindowPosition = 1, + FileHistory = 2, + HighlightSettings = 4, + FilterList = 8, + RegexHistory = 16, + ToolSettings = 32, + GuiOrColors = 64, + FilterHistory = 128, + + All = WindowPosition | FileHistory | HighlightSettings | + FilterList | RegexHistory | ToolSettings | GuiOrColors | + FilterHistory, + + Settings = All & ~WindowPosition & ~FileHistory, + } } \ No newline at end of file diff --git a/src/LogExpert/Config/ToolEntry.cs b/src/Logexpert.Core/Config/ToolEntry.cs similarity index 54% rename from src/LogExpert/Config/ToolEntry.cs rename to src/Logexpert.Core/Config/ToolEntry.cs index 64ef026e..137eef32 100644 --- a/src/LogExpert/Config/ToolEntry.cs +++ b/src/Logexpert.Core/Config/ToolEntry.cs @@ -1,47 +1,48 @@ -using System; -using LogExpert.Classes; - -namespace LogExpert.Config -{ - [Serializable] - public class ToolEntry - { - #region Fields - - public string args = ""; - public string cmd = ""; - public string columnizerName = ""; - public string iconFile; - public int iconIndex; - public bool isFavourite; - public string name; - public bool sysout = false; - public string workingDir = ""; - - #endregion - - #region Public methods - - public override string ToString() - { - return Util.IsNull(this.name) ? this.cmd : this.name; - } - - public ToolEntry Clone() - { - ToolEntry clone = new(); - clone.cmd = this.cmd; - clone.args = this.args; - clone.name = this.name; - clone.sysout = this.sysout; - clone.columnizerName = this.columnizerName; - clone.isFavourite = this.isFavourite; - clone.iconFile = this.iconFile; - clone.iconIndex = this.iconIndex; - clone.workingDir = this.workingDir; - return clone; - } - - #endregion - } +using System; + +using LogExpert.Core.Classes; + +namespace LogExpert.Core.Config +{ + [Serializable] + public class ToolEntry + { + #region Fields + + public string args = ""; + public string cmd = ""; + public string columnizerName = ""; + public string iconFile; + public int iconIndex; + public bool isFavourite; + public string name; + public bool sysout = false; + public string workingDir = ""; + + #endregion + + #region Public methods + + public override string ToString() + { + return Util.IsNull(name) ? cmd : name; + } + + public ToolEntry Clone() + { + ToolEntry clone = new(); + clone.cmd = cmd; + clone.args = args; + clone.name = name; + clone.sysout = sysout; + clone.columnizerName = columnizerName; + clone.isFavourite = isFavourite; + clone.iconFile = iconFile; + clone.iconIndex = iconIndex; + clone.workingDir = workingDir; + return clone; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/Bookmark.cs b/src/Logexpert.Core/Entities/Bookmark.cs similarity index 92% rename from src/LogExpert/Entities/Bookmark.cs rename to src/Logexpert.Core/Entities/Bookmark.cs index 81b4787f..e90b5017 100644 --- a/src/LogExpert/Entities/Bookmark.cs +++ b/src/Logexpert.Core/Entities/Bookmark.cs @@ -1,44 +1,44 @@ -using System.Drawing; - -namespace LogExpert.Entities -{ - public class Bookmark - { - #region Fields - - #endregion - - #region cTor - - public Bookmark(int lineNum) - { - LineNum = lineNum; - Text = ""; - Overlay = new BookmarkOverlay(); - } - - public Bookmark(int lineNum, string comment) - { - LineNum = lineNum; - Text = comment; - Overlay = new BookmarkOverlay(); - } - - #endregion - - #region Properties - - public int LineNum { get; set; } - - public string Text { get; set; } - - public BookmarkOverlay Overlay { get; set; } - - /// - /// Position offset of the overlay as set by the user by dragging the overlay with the mouse. - /// - public Size OverlayOffset { get; set; } - - #endregion - } +using System.Drawing; + +namespace LogExpert.Core.Entities +{ + public class Bookmark + { + #region Fields + + #endregion + + #region cTor + + public Bookmark(int lineNum) + { + LineNum = lineNum; + Text = ""; + Overlay = new BookmarkOverlay(); + } + + public Bookmark(int lineNum, string comment) + { + LineNum = lineNum; + Text = comment; + Overlay = new BookmarkOverlay(); + } + + #endregion + + #region Properties + + public int LineNum { get; set; } + + public string Text { get; set; } + + public BookmarkOverlay Overlay { get; set; } + + /// + /// Position offset of the overlay as set by the user by dragging the overlay with the mouse. + /// + public Size OverlayOffset { get; set; } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/BookmarkCollection.cs b/src/Logexpert.Core/Entities/BookmarkCollection.cs similarity index 90% rename from src/LogExpert/Entities/BookmarkCollection.cs rename to src/Logexpert.Core/Entities/BookmarkCollection.cs index 9ddaf068..ae5e187e 100644 --- a/src/LogExpert/Entities/BookmarkCollection.cs +++ b/src/Logexpert.Core/Entities/BookmarkCollection.cs @@ -1,24 +1,24 @@ -using System.Collections.Generic; -using System.Collections.ObjectModel; - -namespace LogExpert.Entities -{ - public class BookmarkCollection : ReadOnlyCollection - { - #region Fields - - private SortedList bookmarkList; - - #endregion - - #region cTor - - internal BookmarkCollection(SortedList bookmarkList) - : base(bookmarkList.Values) - { - this.bookmarkList = bookmarkList; - } - - #endregion - } +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace LogExpert.Core.Entities +{ + public class BookmarkCollection : ReadOnlyCollection + { + #region Fields + + private SortedList bookmarkList; + + #endregion + + #region cTor + + internal BookmarkCollection(SortedList bookmarkList) + : base(bookmarkList.Values) + { + this.bookmarkList = bookmarkList; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/BookmarkOverlay.cs b/src/Logexpert.Core/Entities/BookmarkOverlay.cs similarity index 86% rename from src/LogExpert/Entities/BookmarkOverlay.cs rename to src/Logexpert.Core/Entities/BookmarkOverlay.cs index 614b7d6d..40eff0b3 100644 --- a/src/LogExpert/Entities/BookmarkOverlay.cs +++ b/src/Logexpert.Core/Entities/BookmarkOverlay.cs @@ -1,21 +1,21 @@ -using System.Drawing; - -namespace LogExpert.Entities -{ - public class BookmarkOverlay - { - #region Fields - - #endregion - - #region Properties - - public Bookmark Bookmark { get; set; } - - public Point Position { get; set; } - - public Rectangle BubbleRect { get; set; } - - #endregion - } +using System.Drawing; + +namespace LogExpert.Core.Entities +{ + public class BookmarkOverlay + { + #region Fields + + #endregion + + #region Properties + + public Bookmark Bookmark { get; set; } + + public Point Position { get; set; } + + public Rectangle BubbleRect { get; set; } + + #endregion + } } \ No newline at end of file diff --git a/src/Logexpert.Core/Entities/DebugOptions.cs b/src/Logexpert.Core/Entities/DebugOptions.cs new file mode 100644 index 00000000..4f91448d --- /dev/null +++ b/src/Logexpert.Core/Entities/DebugOptions.cs @@ -0,0 +1,11 @@ +namespace LogExpert.Core.Entities +{ + public class DebugOptions + { + #region Fields + + public static bool disableWordHighlight = false; + + #endregion + } +} \ No newline at end of file diff --git a/src/LogExpert/Entities/DefaultLogfileColumnizer.cs b/src/Logexpert.Core/Entities/DefaultLogfileColumnizer.cs similarity index 90% rename from src/LogExpert/Entities/DefaultLogfileColumnizer.cs rename to src/Logexpert.Core/Entities/DefaultLogfileColumnizer.cs index 6bffc9d2..139aceef 100644 --- a/src/LogExpert/Entities/DefaultLogfileColumnizer.cs +++ b/src/Logexpert.Core/Entities/DefaultLogfileColumnizer.cs @@ -1,86 +1,83 @@ -using System; -using System.Collections.Generic; - -namespace LogExpert.Entities -{ - public class DefaultLogfileColumnizer : ILogLineColumnizer - { - #region ILogLineColumnizer Members - - public string GetName() - { - return "Default (single line)"; - } - - public string GetDescription() - { - return "No column splitting. The whole line is displayed in a single column."; - } - - public int GetColumnCount() - { - return 1; - } - - public string[] GetColumnNames() - { - return new string[] {"Text"}; - } - - public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) - { - ColumnizedLogLine cLogLine = new(); - cLogLine.LogLine = line; - cLogLine.ColumnValues = new IColumn[] - { - new Column - { - FullValue = line.FullLine, - Parent = cLogLine - } - }; - - - return cLogLine; - } - - public string Text - { - get { return GetName(); } - } - - public Priority GetPriority(string fileName, IEnumerable samples) - { - return Priority.CanSupport; - } - #endregion - - #region ILogLineColumnizer Not implemented Members - - public bool IsTimeshiftImplemented() - { - return false; - } - - public void SetTimeOffset(int msecOffset) - { - throw new NotImplementedException(); - } - - public int GetTimeOffset() - { - throw new NotImplementedException(); - } - - public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) - { - throw new NotImplementedException(); - } - - public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) - { - } - - #endregion - } +namespace LogExpert.Core.Entities +{ + public class DefaultLogfileColumnizer : ILogLineColumnizer + { + #region ILogLineColumnizer Members + + public string GetName() + { + return "Default (single line)"; + } + + public string GetDescription() + { + return "No column splitting. The whole line is displayed in a single column."; + } + + public int GetColumnCount() + { + return 1; + } + + public string[] GetColumnNames() + { + return new string[] { "Text" }; + } + + public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) + { + ColumnizedLogLine cLogLine = new(); + cLogLine.LogLine = line; + cLogLine.ColumnValues = new IColumn[] + { + new Column + { + FullValue = line.FullLine, + Parent = cLogLine + } + }; + + + return cLogLine; + } + + public string Text + { + get { return GetName(); } + } + + public Priority GetPriority(string fileName, IEnumerable samples) + { + return Priority.CanSupport; + } + #endregion + + #region ILogLineColumnizer Not implemented Members + + public bool IsTimeshiftImplemented() + { + return false; + } + + public void SetTimeOffset(int msecOffset) + { + throw new NotImplementedException(); + } + + public int GetTimeOffset() + { + throw new NotImplementedException(); + } + + public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) + { + throw new NotImplementedException(); + } + + public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) + { + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/EncodingOptions.cs b/src/Logexpert.Core/Entities/EncodingOptions.cs similarity index 92% rename from src/LogExpert/Entities/EncodingOptions.cs rename to src/Logexpert.Core/Entities/EncodingOptions.cs index 294a30dc..b5196b64 100644 --- a/src/LogExpert/Entities/EncodingOptions.cs +++ b/src/Logexpert.Core/Entities/EncodingOptions.cs @@ -1,28 +1,28 @@ -using System.Text; - -namespace LogExpert.Entities -{ - /// - /// Holds some encoding options. - /// - public class EncodingOptions - { - #region Fields - - #endregion - - #region Properties - - /// - /// Sets or gets the Encoding which shall be used when reading a file. A value of null means 'please autodetect' via BOM. - /// - public Encoding Encoding { get; set; } - - /// - /// The Encoding to be used when autodetect cannot be applied (missing BOM). Only used when Encoding is set to null. - /// - public Encoding DefaultEncoding { get; set; } - - #endregion - } +using System.Text; + +namespace LogExpert.Core.Entities +{ + /// + /// Holds some encoding options. + /// + public class EncodingOptions + { + #region Fields + + #endregion + + #region Properties + + /// + /// Sets or gets the Encoding which shall be used when reading a file. A value of null means 'please autodetect' via BOM. + /// + public Encoding Encoding { get; set; } + + /// + /// The Encoding to be used when autodetect cannot be applied (missing BOM). Only used when Encoding is set to null. + /// + public Encoding DefaultEncoding { get; set; } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/EventArgs/BookmarkEventArgs.cs b/src/Logexpert.Core/Entities/EventArgs/BookmarkEventArgs.cs similarity index 75% rename from src/LogExpert/Entities/EventArgs/BookmarkEventArgs.cs rename to src/Logexpert.Core/Entities/EventArgs/BookmarkEventArgs.cs index 5ab95516..101c7239 100644 --- a/src/LogExpert/Entities/EventArgs/BookmarkEventArgs.cs +++ b/src/Logexpert.Core/Entities/EventArgs/BookmarkEventArgs.cs @@ -1,24 +1,24 @@ -namespace LogExpert.Entities.EventArgs -{ - public class BookmarkEventArgs : System.EventArgs - { - #region Fields - - #endregion - - #region cTor - - public BookmarkEventArgs(Bookmark bookmark) - { - this.Bookmark = bookmark; - } - - #endregion - - #region Properties - - public Bookmark Bookmark { get; } - - #endregion - } +namespace LogExpert.Core.Entities.EventArgs +{ + public class BookmarkEventArgs : System.EventArgs + { + #region Fields + + #endregion + + #region cTor + + public BookmarkEventArgs(Bookmark bookmark) + { + Bookmark = bookmark; + } + + #endregion + + #region Properties + + public Bookmark Bookmark { get; } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/EventArgs/ColumnizerEventArgs.cs b/src/Logexpert.Core/Entities/EventArgs/ColumnizerEventArgs.cs similarity index 76% rename from src/LogExpert/Entities/EventArgs/ColumnizerEventArgs.cs rename to src/Logexpert.Core/Entities/EventArgs/ColumnizerEventArgs.cs index bea2c285..b67f4156 100644 --- a/src/LogExpert/Entities/EventArgs/ColumnizerEventArgs.cs +++ b/src/Logexpert.Core/Entities/EventArgs/ColumnizerEventArgs.cs @@ -1,24 +1,24 @@ -namespace LogExpert.Entities.EventArgs -{ - public class ColumnizerEventArgs : System.EventArgs - { - #region Fields - - #endregion - - #region cTor - - public ColumnizerEventArgs(ILogLineColumnizer columnizer) - { - this.Columnizer = columnizer; - } - - #endregion - - #region Properties - - public ILogLineColumnizer Columnizer { get; } - - #endregion - } +namespace LogExpert.Core.Entities.EventArgs +{ + public class ColumnizerEventArgs : System.EventArgs + { + #region Fields + + #endregion + + #region cTor + + public ColumnizerEventArgs(ILogLineColumnizer columnizer) + { + Columnizer = columnizer; + } + + #endregion + + #region Properties + + public ILogLineColumnizer Columnizer { get; } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/EventArgs/ConfigChangedEventArgs.cs b/src/Logexpert.Core/Entities/EventArgs/ConfigChangedEventArgs.cs similarity index 53% rename from src/LogExpert/Entities/EventArgs/ConfigChangedEventArgs.cs rename to src/Logexpert.Core/Entities/EventArgs/ConfigChangedEventArgs.cs index 6a476cb5..b06a9a37 100644 --- a/src/LogExpert/Entities/EventArgs/ConfigChangedEventArgs.cs +++ b/src/Logexpert.Core/Entities/EventArgs/ConfigChangedEventArgs.cs @@ -1,26 +1,26 @@ -using LogExpert.Config; - -namespace LogExpert.Entities.EventArgs -{ - internal class ConfigChangedEventArgs : System.EventArgs - { - #region Fields - - #endregion - - #region cTor - - internal ConfigChangedEventArgs(SettingsFlags changeFlags) - { - Flags = changeFlags; - } - - #endregion - - #region Properties - - public SettingsFlags Flags { get; } - - #endregion - } +using LogExpert.Core.Config; + +namespace LogExpert.Core.Entities.EventArgs +{ + public class ConfigChangedEventArgs : System.EventArgs + { + #region Fields + + #endregion + + #region cTor + + public ConfigChangedEventArgs(SettingsFlags changeFlags) + { + Flags = changeFlags; + } + + #endregion + + #region Properties + + public SettingsFlags Flags { get; } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/EventArgs/ContextMenuPluginEventArgs.cs b/src/Logexpert.Core/Entities/EventArgs/ContextMenuPluginEventArgs.cs similarity index 69% rename from src/LogExpert/Entities/EventArgs/ContextMenuPluginEventArgs.cs rename to src/Logexpert.Core/Entities/EventArgs/ContextMenuPluginEventArgs.cs index df53d7e0..019bfab7 100644 --- a/src/LogExpert/Entities/EventArgs/ContextMenuPluginEventArgs.cs +++ b/src/Logexpert.Core/Entities/EventArgs/ContextMenuPluginEventArgs.cs @@ -1,36 +1,34 @@ -using System.Collections.Generic; - -namespace LogExpert.Entities.EventArgs -{ - public class ContextMenuPluginEventArgs : System.EventArgs - { - #region Fields - - #endregion - - #region cTor - - public ContextMenuPluginEventArgs(IContextMenuEntry entry, IList logLines, ILogLineColumnizer columnizer, - ILogExpertCallback callback) - { - this.Entry = entry; - this.LogLines = logLines; - this.Columnizer = columnizer; - this.Callback = callback; - } - - #endregion - - #region Properties - - public IContextMenuEntry Entry { get; } - - public IList LogLines { get; } - - public ILogLineColumnizer Columnizer { get; } - - public ILogExpertCallback Callback { get; } - - #endregion - } +namespace LogExpert.Core.Entities.EventArgs +{ + public class ContextMenuPluginEventArgs : System.EventArgs + { + #region Fields + + #endregion + + #region cTor + + public ContextMenuPluginEventArgs(IContextMenuEntry entry, IList logLines, ILogLineColumnizer columnizer, + ILogExpertCallback callback) + { + Entry = entry; + LogLines = logLines; + Columnizer = columnizer; + Callback = callback; + } + + #endregion + + #region Properties + + public IContextMenuEntry Entry { get; } + + public IList LogLines { get; } + + public ILogLineColumnizer Columnizer { get; } + + public ILogExpertCallback Callback { get; } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/EventArgs/GuiStateArgs.cs b/src/Logexpert.Core/Entities/EventArgs/GuiStateArgs.cs similarity index 82% rename from src/LogExpert/Entities/EventArgs/GuiStateArgs.cs rename to src/Logexpert.Core/Entities/EventArgs/GuiStateArgs.cs index cc6a5289..e56400d6 100644 --- a/src/LogExpert/Entities/EventArgs/GuiStateArgs.cs +++ b/src/Logexpert.Core/Entities/EventArgs/GuiStateArgs.cs @@ -1,50 +1,49 @@ -using System; -using System.Text; - -namespace LogExpert.Entities.EventArgs -{ - public class GuiStateArgs : System.EventArgs - { - #region Fields - - #endregion - - #region Properties - - public bool TimeshiftEnabled { get; set; } - - public bool FollowTail { get; set; } - - public bool MenuEnabled { get; set; } = true; - - public string TimeshiftText { get; set; } - - public bool TimeshiftPossible { get; set; } = false; - - public bool MultiFileEnabled { get; set; } = true; - - public bool FilterEnabled { get; set; } = true; - - public bool CellSelectMode { get; set; } = false; - - public Encoding CurrentEncoding { get; set; } - - public DateTime Timestamp { get; set; } - - public DateTime MinTimestamp { get; set; } - - public DateTime MaxTimestamp { get; set; } - - public bool ShowBookmarkBubbles { get; set; } - - public bool IsMultiFileActive { get; set; } - - public bool ShowHiddenLines { get; set; } = true; - - public string HighlightGroupName { get; set; } - - public bool ColumnFinderVisible { get; set; } - - #endregion - } +using System.Text; + +namespace LogExpert.Core.Entities.EventArgs +{ + public class GuiStateArgs : System.EventArgs + { + #region Fields + + #endregion + + #region Properties + + public bool TimeshiftEnabled { get; set; } + + public bool FollowTail { get; set; } + + public bool MenuEnabled { get; set; } = true; + + public string TimeshiftText { get; set; } = string.Empty; + + public bool TimeshiftPossible { get; set; } = false; + + public bool MultiFileEnabled { get; set; } = true; + + public bool FilterEnabled { get; set; } = true; + + public bool CellSelectMode { get; set; } = false; + + public Encoding CurrentEncoding { get; set; } + + public DateTime Timestamp { get; set; } + + public DateTime MinTimestamp { get; set; } + + public DateTime MaxTimestamp { get; set; } + + public bool ShowBookmarkBubbles { get; set; } + + public bool IsMultiFileActive { get; set; } + + public bool ShowHiddenLines { get; set; } = true; + + public string HighlightGroupName { get; set; } = string.Empty; + + public bool ColumnFinderVisible { get; set; } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/EventArgs/LoadFileEventArgs.cs b/src/Logexpert.Core/Entities/EventArgs/LoadFileEventArgs.cs similarity index 70% rename from src/LogExpert/Entities/EventArgs/LoadFileEventArgs.cs rename to src/Logexpert.Core/Entities/EventArgs/LoadFileEventArgs.cs index 8cfe3dfe..1fb69176 100644 --- a/src/LogExpert/Entities/EventArgs/LoadFileEventArgs.cs +++ b/src/Logexpert.Core/Entities/EventArgs/LoadFileEventArgs.cs @@ -1,4 +1,4 @@ -namespace LogExpert.Entities.EventArgs -{ - public record LoadFileEventArgs(string FileName, long ReadPos, bool Finished, long FileSize, bool NewFile); +namespace LogExpert.Core.Entities.EventArgs +{ + public record LoadFileEventArgs(string FileName, long ReadPos, bool Finished, long FileSize, bool NewFile); } \ No newline at end of file diff --git a/src/LogExpert/Entities/EventArgs/PatternArgs.cs b/src/Logexpert.Core/Entities/EventArgs/PatternArgs.cs similarity index 83% rename from src/LogExpert/Entities/EventArgs/PatternArgs.cs rename to src/Logexpert.Core/Entities/EventArgs/PatternArgs.cs index 50eac1f0..d8d05975 100644 --- a/src/LogExpert/Entities/EventArgs/PatternArgs.cs +++ b/src/Logexpert.Core/Entities/EventArgs/PatternArgs.cs @@ -1,16 +1,16 @@ -namespace LogExpert.Entities.EventArgs -{ - public class PatternArgs - { - #region Fields - - public int endLine = 0; - public int fuzzy = 6; - public int maxDiffInBlock = 5; - public int maxMisses = 5; - public int minWeight = 15; - public int startLine = 0; - - #endregion - } +namespace LogExpert.Core.Entities.EventArgs +{ + public class PatternArgs + { + #region Fields + + public int endLine = 0; + public int fuzzy = 6; + public int maxDiffInBlock = 5; + public int maxMisses = 5; + public int minWeight = 15; + public int startLine = 0; + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/EventArgs/ProgressEventArgs.cs b/src/Logexpert.Core/Entities/EventArgs/ProgressEventArgs.cs similarity index 84% rename from src/LogExpert/Entities/EventArgs/ProgressEventArgs.cs rename to src/Logexpert.Core/Entities/EventArgs/ProgressEventArgs.cs index 85df1780..8281f219 100644 --- a/src/LogExpert/Entities/EventArgs/ProgressEventArgs.cs +++ b/src/Logexpert.Core/Entities/EventArgs/ProgressEventArgs.cs @@ -1,21 +1,21 @@ -namespace LogExpert.Entities.EventArgs -{ - public class ProgressEventArgs : System.EventArgs - { - #region Fields - - #endregion - - #region Properties - - public int Value { get; set; } - - public int MinValue { get; set; } - - public int MaxValue { get; set; } - - public bool Visible { get; set; } - - #endregion - } +namespace LogExpert.Core.Entities.EventArgs +{ + public class ProgressEventArgs : System.EventArgs + { + #region Fields + + #endregion + + #region Properties + + public int Value { get; set; } + + public int MinValue { get; set; } + + public int MaxValue { get; set; } + + public bool Visible { get; set; } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/EventArgs/StatusEventArgs.cs b/src/Logexpert.Core/Entities/EventArgs/StatusEventArgs.cs similarity index 56% rename from src/LogExpert/Entities/EventArgs/StatusEventArgs.cs rename to src/Logexpert.Core/Entities/EventArgs/StatusEventArgs.cs index 08cb79dd..a468d03f 100644 --- a/src/LogExpert/Entities/EventArgs/StatusEventArgs.cs +++ b/src/Logexpert.Core/Entities/EventArgs/StatusEventArgs.cs @@ -1,35 +1,37 @@ -namespace LogExpert.Entities.EventArgs -{ - public class StatusLineEventArgs : System.EventArgs - { - #region Fields - - #endregion - - #region Properties - - public long FileSize { get; set; } = 0; - - public string StatusText { get; set; } = null; - - public int LineCount { get; set; } = 0; - - public int CurrentLineNum { get; set; } = 0; - - #endregion - - #region Public methods - - public StatusLineEventArgs Clone() - { - StatusLineEventArgs e = new(); - e.StatusText = StatusText; - e.CurrentLineNum = CurrentLineNum; - e.LineCount = LineCount; - e.FileSize = FileSize; - return e; - } - - #endregion - } +namespace LogExpert.Core.Entities.EventArgs +{ + public class StatusLineEventArgs : System.EventArgs + { + #region Fields + + #endregion + + #region Properties + + public long FileSize { get; set; } = 0; + + public string StatusText { get; set; } = string.Empty; + + public int LineCount { get; set; } = 0; + + public int CurrentLineNum { get; set; } = 0; + + #endregion + + #region Public methods + + public StatusLineEventArgs Clone() + { + StatusLineEventArgs e = new() + { + StatusText = StatusText, + CurrentLineNum = CurrentLineNum, + LineCount = LineCount, + FileSize = FileSize + }; + return e; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/EventArgs/SyncModeEventArgs.cs b/src/Logexpert.Core/Entities/EventArgs/SyncModeEventArgs.cs similarity index 74% rename from src/LogExpert/Entities/EventArgs/SyncModeEventArgs.cs rename to src/Logexpert.Core/Entities/EventArgs/SyncModeEventArgs.cs index 0d65f1ae..c2e13db3 100644 --- a/src/LogExpert/Entities/EventArgs/SyncModeEventArgs.cs +++ b/src/Logexpert.Core/Entities/EventArgs/SyncModeEventArgs.cs @@ -1,24 +1,24 @@ -namespace LogExpert.Entities.EventArgs -{ - public class SyncModeEventArgs : System.EventArgs - { - #region Fields - - #endregion - - #region cTor - - public SyncModeEventArgs(bool isSynced) - { - this.IsTimeSynced = isSynced; - } - - #endregion - - #region Properties - - public bool IsTimeSynced { get; } - - #endregion - } +namespace LogExpert.Core.Entities.EventArgs +{ + public class SyncModeEventArgs : System.EventArgs + { + #region Fields + + #endregion + + #region cTor + + public SyncModeEventArgs(bool isSynced) + { + IsTimeSynced = isSynced; + } + + #endregion + + #region Properties + + public bool IsTimeSynced { get; } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/FileViewContext.cs b/src/Logexpert.Core/Entities/FileViewContext.cs similarity index 53% rename from src/LogExpert/Entities/FileViewContext.cs rename to src/Logexpert.Core/Entities/FileViewContext.cs index a0bc2b2a..676fee60 100644 --- a/src/LogExpert/Entities/FileViewContext.cs +++ b/src/Logexpert.Core/Entities/FileViewContext.cs @@ -1,29 +1,29 @@ -using LogExpert.Interface; - -namespace LogExpert.Entities -{ - public class FileViewContext - { - #region Fields - - #endregion - - #region cTor - - internal FileViewContext(ILogPaintContext logPaintContext, ILogView logView) - { - this.LogPaintContext = logPaintContext; - this.LogView = logView; - } - - #endregion - - #region Properties - - public ILogPaintContext LogPaintContext { get; } - - public ILogView LogView { get; } - - #endregion - } +using LogExpert.Core.Interface; + +namespace LogExpert.Core.Entities +{ + public class FileViewContext + { + #region Fields + + #endregion + + #region cTor + + public FileViewContext(ILogPaintContext logPaintContext, ILogView logView) + { + LogPaintContext = logPaintContext; + LogView = logView; + } + + #endregion + + #region Properties + + public ILogPaintContext LogPaintContext { get; } + + public ILogView LogView { get; } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/HilightGroup.cs b/src/Logexpert.Core/Entities/HilightGroup.cs similarity index 80% rename from src/LogExpert/Entities/HilightGroup.cs rename to src/Logexpert.Core/Entities/HilightGroup.cs index b2115103..e8ef8a9e 100644 --- a/src/LogExpert/Entities/HilightGroup.cs +++ b/src/Logexpert.Core/Entities/HilightGroup.cs @@ -1,34 +1,31 @@ -using LogExpert.Classes.Highlight; - -using System; -using System.Collections.Generic; - -namespace LogExpert.Entities -{ - [Serializable] - public class HilightGroup : ICloneable - { - #region Properties - - public string GroupName { get; set; } = string.Empty; - - public List HilightEntryList { get; set; } = []; - - public object Clone() - { - HilightGroup clone = new() - { - GroupName = GroupName - }; - - foreach (HilightEntry entry in HilightEntryList) - { - clone.HilightEntryList.Add((HilightEntry)entry.Clone()); - } - - return clone; - } - - #endregion - } +using LogExpert.Core.Classes.Highlight; + +namespace LogExpert.Core.Entities +{ + [Serializable] + public class HilightGroup : ICloneable + { + #region Properties + + public string GroupName { get; set; } = string.Empty; + + public List HilightEntryList { get; set; } = []; + + public object Clone() + { + HilightGroup clone = new() + { + GroupName = GroupName + }; + + foreach (HilightEntry entry in HilightEntryList) + { + clone.HilightEntryList.Add((HilightEntry)entry.Clone()); + } + + return clone; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/LogEventData.cs b/src/Logexpert.Core/Entities/LogEventData.cs similarity index 88% rename from src/LogExpert/Entities/LogEventData.cs rename to src/Logexpert.Core/Entities/LogEventData.cs index 3d4f11d1..923b47ab 100644 --- a/src/LogExpert/Entities/LogEventData.cs +++ b/src/Logexpert.Core/Entities/LogEventData.cs @@ -1,25 +1,25 @@ -namespace LogExpert.Entities -{ - public class LogEventArgs : System.EventArgs - { - #region Fields - - #endregion - - #region Properties - - public int RolloverOffset { get; set; } = 0; - - public bool IsRollover { get; set; } = false; - - public long FileSize { get; set; } - - public int LineCount { get; set; } - - public int PrevLineCount { get; set; } - - public long PrevFileSize { get; set; } - - #endregion - } +namespace LogExpert.Core.Entities +{ + public class LogEventArgs : System.EventArgs + { + #region Fields + + #endregion + + #region Properties + + public int RolloverOffset { get; set; } = 0; + + public bool IsRollover { get; set; } = false; + + public long FileSize { get; set; } + + public int LineCount { get; set; } + + public int PrevLineCount { get; set; } + + public long PrevFileSize { get; set; } + + #endregion + } } \ No newline at end of file diff --git a/src/Logexpert.Core/Entities/LogFileException.cs b/src/Logexpert.Core/Entities/LogFileException.cs new file mode 100644 index 00000000..3368e8c3 --- /dev/null +++ b/src/Logexpert.Core/Entities/LogFileException.cs @@ -0,0 +1,19 @@ +namespace LogExpert.Core.Entities +{ + public class LogFileException : ApplicationException + { + #region cTor + + public LogFileException(string msg) + : base(msg) + { + } + + public LogFileException(string msg, Exception inner) + : base(msg, inner) + { + } + + #endregion + } +} \ No newline at end of file diff --git a/src/LogExpert/Entities/MultifileOptions.cs b/src/Logexpert.Core/Entities/MultifileOptions.cs similarity index 89% rename from src/LogExpert/Entities/MultifileOptions.cs rename to src/Logexpert.Core/Entities/MultifileOptions.cs index 9abc66a8..6eadccb7 100644 --- a/src/LogExpert/Entities/MultifileOptions.cs +++ b/src/Logexpert.Core/Entities/MultifileOptions.cs @@ -1,31 +1,31 @@ -using System; - -namespace LogExpert.Entities -{ - [Serializable] - public class MultiFileOptions - { - #region Fields - - private string _formatPattern = "*$J(.)"; - private int _maxDayTry = 3; - - #endregion - - #region Properties - - public int MaxDayTry - { - get => _maxDayTry; - set => _maxDayTry = value; - } - - public string FormatPattern - { - get => _formatPattern; - set => _formatPattern = value; - } - - #endregion - } +using System; + +namespace LogExpert.Core.Entities +{ + [Serializable] + public class MultiFileOptions + { + #region Fields + + private string _formatPattern = "*$J(.)"; + private int _maxDayTry = 3; + + #endregion + + #region Properties + + public int MaxDayTry + { + get => _maxDayTry; + set => _maxDayTry = value; + } + + public string FormatPattern + { + get => _formatPattern; + set => _formatPattern = value; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/Range.cs b/src/Logexpert.Core/Entities/Range.cs similarity index 68% rename from src/LogExpert/Entities/Range.cs rename to src/Logexpert.Core/Entities/Range.cs index b92d243d..c2c9f1b3 100644 --- a/src/LogExpert/Entities/Range.cs +++ b/src/Logexpert.Core/Entities/Range.cs @@ -1,31 +1,31 @@ -namespace LogExpert.Entities -{ - internal class Range - { - #region Fields - - #endregion - - #region cTor - - public Range() - { - } - - public Range(int startLine, int endLine) - { - this.StartLine = startLine; - this.EndLine = endLine; - } - - #endregion - - #region Properties - - public int StartLine { get; set; } - - public int EndLine { get; set; } - - #endregion - } +namespace LogExpert.Core.Entities +{ + public class Range + { + #region Fields + + #endregion + + #region cTor + + public Range() + { + } + + public Range(int startLine, int endLine) + { + StartLine = startLine; + EndLine = endLine; + } + + #endregion + + #region Properties + + public int StartLine { get; set; } + + public int EndLine { get; set; } + + #endregion + } } \ No newline at end of file diff --git a/src/Logexpert.Core/Entities/ReloadMemento.cs b/src/Logexpert.Core/Entities/ReloadMemento.cs new file mode 100644 index 00000000..0566b8d8 --- /dev/null +++ b/src/Logexpert.Core/Entities/ReloadMemento.cs @@ -0,0 +1,12 @@ +namespace LogExpert.Core.Entities +{ + public class ReloadMemento + { + #region Fields + + public int currentLine; + public int firstDisplayedLine; + + #endregion + } +} \ No newline at end of file diff --git a/src/LogExpert/Entities/RowHeightEntry.cs b/src/Logexpert.Core/Entities/RowHeightEntry.cs similarity index 88% rename from src/LogExpert/Entities/RowHeightEntry.cs rename to src/Logexpert.Core/Entities/RowHeightEntry.cs index 4b6291d7..35e82320 100644 --- a/src/LogExpert/Entities/RowHeightEntry.cs +++ b/src/Logexpert.Core/Entities/RowHeightEntry.cs @@ -1,33 +1,33 @@ -namespace LogExpert.Entities -{ - public class RowHeightEntry - { - #region Fields - - #endregion - - #region cTor - - public RowHeightEntry() - { - LineNum = 0; - Height = 0; - } - - public RowHeightEntry(int lineNum, int height) - { - LineNum = lineNum; - Height = height; - } - - #endregion - - #region Properties - - public int LineNum { get; set; } - - public int Height { get; set; } - - #endregion - } +namespace LogExpert.Core.Entities +{ + public class RowHeightEntry + { + #region Fields + + #endregion + + #region cTor + + public RowHeightEntry() + { + LineNum = 0; + Height = 0; + } + + public RowHeightEntry(int lineNum, int height) + { + LineNum = lineNum; + Height = height; + } + + #endregion + + #region Properties + + public int LineNum { get; set; } + + public int Height { get; set; } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/SearchParams.cs b/src/Logexpert.Core/Entities/SearchParams.cs similarity index 75% rename from src/LogExpert/Entities/SearchParams.cs rename to src/Logexpert.Core/Entities/SearchParams.cs index ca79341f..ab7487ba 100644 --- a/src/LogExpert/Entities/SearchParams.cs +++ b/src/Logexpert.Core/Entities/SearchParams.cs @@ -1,26 +1,23 @@ -using System; -using System.Collections.Generic; - -namespace LogExpert.Entities -{ - [Serializable] - public class SearchParams - { - #region Fields - - public int currentLine; - public List historyList = []; - public bool isCaseSensitive = false; - public bool isFindNext; - - public bool isForward = true; - public bool isFromTop = false; - public bool isRegex = false; - - [NonSerialized] public bool isShiftF3Pressed = false; - - public string searchText; - - #endregion - } +namespace LogExpert.Core.Entities +{ + [Serializable] + public class SearchParams + { + #region Fields + + public int currentLine; + public List historyList = []; + public bool isCaseSensitive = false; + public bool isFindNext; + + public bool isForward = true; + public bool isFromTop = false; + public bool isRegex = false; + + [NonSerialized] public bool isShiftF3Pressed = false; + + public string searchText = string.Empty; + + #endregion + } } \ No newline at end of file diff --git a/src/Logexpert.Core/Enums/DragOrientationsEnum.cs b/src/Logexpert.Core/Enums/DragOrientationsEnum.cs new file mode 100644 index 00000000..ccb32aa5 --- /dev/null +++ b/src/Logexpert.Core/Enums/DragOrientationsEnum.cs @@ -0,0 +1,9 @@ +namespace LogExpert.Core.Enums +{ + public enum DragOrientationsEnum + { + Horizontal, + Vertical, + InvertedVertical + } +} diff --git a/src/Logexpert.Core/Enums/WindowTypes.cs b/src/Logexpert.Core/Enums/WindowTypes.cs new file mode 100644 index 00000000..f9ee40b2 --- /dev/null +++ b/src/Logexpert.Core/Enums/WindowTypes.cs @@ -0,0 +1,8 @@ +namespace LogExpert.Core.Enums +{ + public enum WindowTypes + { + BookmarkWindow, + LogWindow, + } +} \ No newline at end of file diff --git a/src/LogExpert/Extensions/IEnumerable.cs b/src/Logexpert.Core/Extensions/IEnumerable.cs similarity index 80% rename from src/LogExpert/Extensions/IEnumerable.cs rename to src/Logexpert.Core/Extensions/IEnumerable.cs index b0a174a8..3a7524d9 100644 --- a/src/LogExpert/Extensions/IEnumerable.cs +++ b/src/Logexpert.Core/Extensions/IEnumerable.cs @@ -1,28 +1,25 @@ -using System.Collections.Generic; -using System.Linq; - -namespace LogExpert.Extensions -{ - public static class Extensions - { - public static bool IsEmpty(this IEnumerable collection) - { - if (collection == null) - { - return true; - } - - return !collection.Any(); - } - - public static bool IsEmpty(this IList list) - { - if (list == null) - { - return true; - } - - return list.Count == 0; - } - } +namespace LogExpert.Core.Extensions +{ + public static class Extensions + { + public static bool IsEmpty(this IEnumerable collection) + { + if (collection == null) + { + return true; + } + + return !collection.Any(); + } + + public static bool IsEmpty(this IList list) + { + if (list == null) + { + return true; + } + + return list.Count == 0; + } + } } \ No newline at end of file diff --git a/src/LogExpert/Interface/BackgroundProcessCancelHandler.cs b/src/Logexpert.Core/Interface/BackgroundProcessCancelHandler.cs similarity index 88% rename from src/LogExpert/Interface/BackgroundProcessCancelHandler.cs rename to src/Logexpert.Core/Interface/BackgroundProcessCancelHandler.cs index ad41fca0..18e23d32 100644 --- a/src/LogExpert/Interface/BackgroundProcessCancelHandler.cs +++ b/src/Logexpert.Core/Interface/BackgroundProcessCancelHandler.cs @@ -1,18 +1,18 @@ -namespace LogExpert.Interface -{ - /// - /// Interface which can register at the LogWindow to be informed of pressing ESC. - /// Used e.g. for cancelling a filter. - /// - public interface BackgroundProcessCancelHandler - { - #region Public methods - - /// - /// Called when ESC was pressed. - /// - void EscapePressed(); - - #endregion - } +namespace LogExpert.Core.Interface +{ + /// + /// Interface which can register at the LogWindow to be informed of pressing ESC. + /// Used e.g. for cancelling a filter. + /// + public interface BackgroundProcessCancelHandler + { + #region Public methods + + /// + /// Called when ESC was pressed. + /// + void EscapePressed(); + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Interface/IBookmarkData.cs b/src/Logexpert.Core/Interface/IBookmarkData.cs similarity index 82% rename from src/LogExpert/Interface/IBookmarkData.cs rename to src/Logexpert.Core/Interface/IBookmarkData.cs index 2e45d796..c855f683 100644 --- a/src/LogExpert/Interface/IBookmarkData.cs +++ b/src/Logexpert.Core/Interface/IBookmarkData.cs @@ -1,22 +1,25 @@ -using LogExpert.Entities; - -namespace LogExpert.Interface -{ - public interface IBookmarkData - { - #region Properties - - BookmarkCollection Bookmarks { get; } - - #endregion - - #region Public methods - - void ToggleBookmark(int lineNum); - bool IsBookmarkAtLine(int lineNum); - int GetBookmarkIndexForLine(int lineNum); - Bookmark GetBookmarkForLine(int lineNum); - - #endregion - } +using LogExpert.Core.Entities; + +namespace LogExpert.Core.Interface +{ + public interface IBookmarkData + { + #region Properties + + BookmarkCollection Bookmarks { get; } + + #endregion + + #region Public methods + + void ToggleBookmark(int lineNum); + + bool IsBookmarkAtLine(int lineNum); + + int GetBookmarkIndexForLine(int lineNum); + + Bookmark GetBookmarkForLine(int lineNum); + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Interface/IBookmarkView.cs b/src/Logexpert.Core/Interface/IBookmarkView.cs similarity index 72% rename from src/LogExpert/Interface/IBookmarkView.cs rename to src/Logexpert.Core/Interface/IBookmarkView.cs index 2a5884c9..c020858c 100644 --- a/src/LogExpert/Interface/IBookmarkView.cs +++ b/src/Logexpert.Core/Interface/IBookmarkView.cs @@ -1,25 +1,28 @@ -using LogExpert.Entities; - -namespace LogExpert.Interface -{ - /// - /// To be implemented by the bookmark window. Will be informed from LogWindow about changes in bookmarks. - /// - internal interface IBookmarkView - { - #region Properties - - bool LineColumnVisible { set; } - - #endregion - - #region Public methods - - void UpdateView(); - void BookmarkTextChanged(Bookmark bookmark); - void SelectBookmark(int lineNum); - void SetBookmarkData(IBookmarkData bookmarkData); - - #endregion - } +using LogExpert.Core.Entities; + +namespace LogExpert.Core.Interface +{ + /// + /// To be implemented by the bookmark window. Will be informed from LogWindow about changes in bookmarks. + /// + public interface IBookmarkView + { + #region Properties + + bool LineColumnVisible { set; } + + #endregion + + #region Public methods + + void UpdateView(); + + void BookmarkTextChanged(Bookmark bookmark); + + void SelectBookmark(int lineNum); + + void SetBookmarkData(IBookmarkData bookmarkData); + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Interface/ILogPaintContext.cs b/src/Logexpert.Core/Interface/ILogPaintContext.cs similarity index 83% rename from src/LogExpert/Interface/ILogPaintContext.cs rename to src/Logexpert.Core/Interface/ILogPaintContext.cs index 367d4ff1..6d5eb456 100644 --- a/src/LogExpert/Interface/ILogPaintContext.cs +++ b/src/Logexpert.Core/Interface/ILogPaintContext.cs @@ -1,36 +1,36 @@ -using System.Collections.Generic; -using System.Drawing; -using LogExpert.Classes.Highlight; -using LogExpert.Entities; - -namespace LogExpert.Interface -{ - /// - /// Declares methods that are needed for drawing log lines. Used by PaintHelper. - /// - public interface ILogPaintContext - { - #region Properties - - Font MonospacedFont { get; } // Font font = new Font("Courier New", this.Preferences.fontSize, FontStyle.Bold); - Font NormalFont { get; } - Font BoldFont { get; } - Color BookmarkColor { get; } - - #endregion - - #region Public methods - - ILogLine GetLogLine(int lineNum); - - IColumn GetCellValue(int rowIndex, int columnIndex); - - Bookmark GetBookmarkForLine(int lineNum); - - HilightEntry FindHighlightEntry(ITextValue line, bool noWordMatches); - - IList FindHighlightMatches(ITextValue line); - - #endregion - } +using LogExpert.Core.Classes.Highlight; +using LogExpert.Core.Entities; + +using System.Drawing; + +namespace LogExpert.Core.Interface +{ + /// + /// Declares methods that are needed for drawing log lines. Used by PaintHelper. + /// + public interface ILogPaintContext + { + #region Properties + + Font MonospacedFont { get; } // Font font = new Font("Courier New", this.Preferences.fontSize, FontStyle.Bold); + Font NormalFont { get; } + Font BoldFont { get; } + Color BookmarkColor { get; } + + #endregion + + #region Public methods + + ILogLine GetLogLine(int lineNum); + + IColumn GetCellValue(int rowIndex, int columnIndex); + + Bookmark GetBookmarkForLine(int lineNum); + + HilightEntry FindHighlightEntry(ITextValue line, bool noWordMatches); + + IList FindHighlightMatches(ITextValue line); + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Interface/ILogStreamReader.cs b/src/Logexpert.Core/Interface/ILogStreamReader.cs similarity index 78% rename from src/LogExpert/Interface/ILogStreamReader.cs rename to src/Logexpert.Core/Interface/ILogStreamReader.cs index b443d14f..11ce40f2 100644 --- a/src/LogExpert/Interface/ILogStreamReader.cs +++ b/src/Logexpert.Core/Interface/ILogStreamReader.cs @@ -1,25 +1,24 @@ -using System; -using System.Text; - -namespace LogExpert.Interface -{ - public interface ILogStreamReader : IDisposable - { - #region Properties - - long Position { get; set; } - - bool IsBufferComplete { get; } - - Encoding Encoding { get; } - - #endregion - - #region Public methods - - int ReadChar(); - string ReadLine(); - - #endregion - } +using System.Text; + +namespace LogExpert.Core.Interface +{ + public interface ILogStreamReader : IDisposable + { + #region Properties + + long Position { get; set; } + + bool IsBufferComplete { get; } + + Encoding Encoding { get; } + + #endregion + + #region Public methods + + int ReadChar(); + string ReadLine(); + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Interface/ILogView.cs b/src/Logexpert.Core/Interface/ILogView.cs similarity index 75% rename from src/LogExpert/Interface/ILogView.cs rename to src/Logexpert.Core/Interface/ILogView.cs index 6af02b3f..c1009b55 100644 --- a/src/LogExpert/Interface/ILogView.cs +++ b/src/Logexpert.Core/Interface/ILogView.cs @@ -1,26 +1,24 @@ -using System.Collections.Generic; - -namespace LogExpert.Interface -{ - /// - /// Methods to control the LogWindow from other views. - /// - public interface ILogView - { - #region Properties - - ILogLineColumnizer CurrentColumnizer { get; } - string FileName { get; } - - #endregion - - #region Public methods - - void SelectLogLine(int lineNumber); - void SelectAndEnsureVisible(int line, bool triggerSyncCall); - void RefreshLogView(); - void DeleteBookmarks(List lineNumList); - - #endregion - } +namespace LogExpert.Core.Interface +{ + /// + /// Methods to control the LogWindow from other views. + /// + public interface ILogView + { + #region Properties + + ILogLineColumnizer CurrentColumnizer { get; } + string FileName { get; } + + #endregion + + #region Public methods + + void SelectLogLine(int lineNumber); + void SelectAndEnsureVisible(int line, bool triggerSyncCall); + void RefreshLogView(); + void DeleteBookmarks(List lineNumList); + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Interface/ISharedToolWindow.cs b/src/Logexpert.Core/Interface/ISharedToolWindow.cs similarity index 80% rename from src/LogExpert/Interface/ISharedToolWindow.cs rename to src/Logexpert.Core/Interface/ISharedToolWindow.cs index 2986d687..d8253b19 100644 --- a/src/LogExpert/Interface/ISharedToolWindow.cs +++ b/src/Logexpert.Core/Interface/ISharedToolWindow.cs @@ -1,32 +1,32 @@ -using LogExpert.Config; -using LogExpert.Entities; - -namespace LogExpert.Interface -{ - /// - /// Interface to be implemented by tools windows that are shared across multiple log files. - /// The implementor will be called whenever the current log file changes. So it can draw new content - /// according to the current active log file. - /// - internal interface ISharedToolWindow - { - #region Public methods - - /// - /// Called when a file becomes the active file (e.g. when user selects a tab). - /// - /// - void SetCurrentFile(FileViewContext ctx); - - /// - /// Called whenever the current file has been changed. - /// - void FileChanged(); - - void SetColumnizer(ILogLineColumnizer columnizer); - - void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags); - - #endregion - } +using LogExpert.Core.Config; +using LogExpert.Core.Entities; + +namespace LogExpert.Core.Interface +{ + /// + /// Interface to be implemented by tools windows that are shared across multiple log files. + /// The implementor will be called whenever the current log file changes. So it can draw new content + /// according to the current active log file. + /// + public interface ISharedToolWindow + { + #region Public methods + + /// + /// Called when a file becomes the active file (e.g. when user selects a tab). + /// + /// + void SetCurrentFile(FileViewContext ctx); + + /// + /// Called whenever the current file has been changed. + /// + void FileChanged(); + + void SetColumnizer(ILogLineColumnizer columnizer); + + void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags); + + #endregion + } } \ No newline at end of file diff --git a/src/Logexpert.Core/Logexpert.Core.csproj b/src/Logexpert.Core/Logexpert.Core.csproj index fa71b7ae..0d7b68b6 100644 --- a/src/Logexpert.Core/Logexpert.Core.csproj +++ b/src/Logexpert.Core/Logexpert.Core.csproj @@ -4,6 +4,17 @@ net8.0 enable enable + true + + + + + + + + + + diff --git a/src/Logexpert.UI/Dialogs/AboutBox.cs b/src/Logexpert.UI/Dialogs/AboutBox.cs index 1b51352d..b8a39b22 100644 --- a/src/Logexpert.UI/Dialogs/AboutBox.cs +++ b/src/Logexpert.UI/Dialogs/AboutBox.cs @@ -67,14 +67,21 @@ public string AssemblyVersion get { AssemblyName assembly = _assembly.GetName(); - string version = $"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}.{assembly.Version.Revision}"; - if (assembly.Version.Revision >= 9000) + + if (assembly.Version != null) { - version += " Testrelease"; + string version = $"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}.{assembly.Version.Revision}"; + if (assembly.Version.Revision >= 9000) + { + version += " Testrelease"; + } + + return version; } - return version; + return "0.0.0.0"; } + } public string AssemblyDescription @@ -82,6 +89,7 @@ public string AssemblyDescription get { object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); + if (attributes.Length == 0) { return string.Empty; @@ -122,7 +130,13 @@ public string AssemblyCopyright private void OnLinkLabelURLClicked(object sender, LinkLabelLinkClickedEventArgs e) { - string target = e.Link.LinkData as string; + string? target = string.Empty; + + if (e.Link != null) + { + target = e.Link.LinkData as string; + } + Process.Start(new ProcessStartInfo { UseShellExecute = true, diff --git a/src/LogExpert/Dialogs/SearchDialog.Designer.cs b/src/Logexpert.UI/Dialogs/SearchDialog.Designer.cs similarity index 98% rename from src/LogExpert/Dialogs/SearchDialog.Designer.cs rename to src/Logexpert.UI/Dialogs/SearchDialog.Designer.cs index 8e93d131..148a6db0 100644 --- a/src/LogExpert/Dialogs/SearchDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/SearchDialog.Designer.cs @@ -1,254 +1,254 @@ -namespace LogExpert.Dialogs -{ - partial class SearchDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonOk = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.labelSearchFor = new System.Windows.Forms.Label(); - this.checkBoxCaseSensitive = new System.Windows.Forms.CheckBox(); - this.checkBoxRegex = new System.Windows.Forms.CheckBox(); - this.buttonRegexHelper = new System.Windows.Forms.Button(); - this.radioButtonFromTop = new System.Windows.Forms.RadioButton(); - this.radioButtonFromSelected = new System.Windows.Forms.RadioButton(); - this.groupBoxSearchStart = new System.Windows.Forms.GroupBox(); - this.groupBoxOptions = new System.Windows.Forms.GroupBox(); - this.groupBoxDirection = new System.Windows.Forms.GroupBox(); - this.radioButtonBackward = new System.Windows.Forms.RadioButton(); - this.radioButtonForward = new System.Windows.Forms.RadioButton(); - this.comboBoxSearchFor = new System.Windows.Forms.ComboBox(); - this.helpProvider1 = new System.Windows.Forms.HelpProvider(); - this.groupBoxSearchStart.SuspendLayout(); - this.groupBoxOptions.SuspendLayout(); - this.groupBoxDirection.SuspendLayout(); - this.SuspendLayout(); - // - // buttonOk - // - this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(317, 215); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 23); - this.buttonOk.TabIndex = 5; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.OnButtonOkClick); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(398, 215); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 6; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.OnButtonCancelClick); - // - // labelSearchFor - // - this.labelSearchFor.AutoSize = true; - this.labelSearchFor.Location = new System.Drawing.Point(10, 9); - this.labelSearchFor.Name = "labelSearchFor"; - this.labelSearchFor.Size = new System.Drawing.Size(87, 20); - this.labelSearchFor.TabIndex = 0; - this.labelSearchFor.Text = "&Search for:"; - // - // checkBoxCaseSensitive - // - this.checkBoxCaseSensitive.AutoSize = true; - this.checkBoxCaseSensitive.Location = new System.Drawing.Point(6, 19); - this.checkBoxCaseSensitive.Name = "checkBoxCaseSensitive"; - this.checkBoxCaseSensitive.Size = new System.Drawing.Size(137, 24); - this.checkBoxCaseSensitive.TabIndex = 4; - this.checkBoxCaseSensitive.Text = "&Case sensitive"; - this.checkBoxCaseSensitive.UseVisualStyleBackColor = true; - // - // checkBoxRegex - // - this.checkBoxRegex.AutoSize = true; - this.checkBoxRegex.Location = new System.Drawing.Point(6, 43); - this.checkBoxRegex.Name = "checkBoxRegex"; - this.checkBoxRegex.Size = new System.Drawing.Size(171, 24); - this.checkBoxRegex.TabIndex = 5; - this.checkBoxRegex.Text = "&Regular expression"; - this.checkBoxRegex.UseVisualStyleBackColor = true; - // - // buttonRegexHelper - // - this.buttonRegexHelper.Location = new System.Drawing.Point(6, 72); - this.buttonRegexHelper.Name = "buttonRegexHelper"; - this.buttonRegexHelper.Size = new System.Drawing.Size(84, 26); - this.buttonRegexHelper.TabIndex = 3; - this.buttonRegexHelper.Text = "Regex-&Helper"; - this.buttonRegexHelper.UseVisualStyleBackColor = true; - this.buttonRegexHelper.Click += new System.EventHandler(this.OnButtonRegexClick); - // - // radioButtonFromTop - // - this.radioButtonFromTop.AutoSize = true; - this.radioButtonFromTop.Location = new System.Drawing.Point(6, 19); - this.radioButtonFromTop.Name = "radioButtonFromTop"; - this.radioButtonFromTop.Size = new System.Drawing.Size(98, 24); - this.radioButtonFromTop.TabIndex = 7; - this.radioButtonFromTop.TabStop = true; - this.radioButtonFromTop.Text = "From top"; - this.radioButtonFromTop.UseVisualStyleBackColor = true; - // - // radioButtonFromSelected - // - this.radioButtonFromSelected.AutoSize = true; - this.radioButtonFromSelected.Location = new System.Drawing.Point(6, 42); - this.radioButtonFromSelected.Name = "radioButtonFromSelected"; - this.radioButtonFromSelected.Size = new System.Drawing.Size(163, 24); - this.radioButtonFromSelected.TabIndex = 8; - this.radioButtonFromSelected.TabStop = true; - this.radioButtonFromSelected.Text = "From selected line"; - this.radioButtonFromSelected.UseVisualStyleBackColor = true; - // - // groupBoxSearchStart - // - this.groupBoxSearchStart.Controls.Add(this.radioButtonFromTop); - this.groupBoxSearchStart.Controls.Add(this.radioButtonFromSelected); - this.groupBoxSearchStart.Location = new System.Drawing.Point(12, 74); - this.groupBoxSearchStart.Name = "groupBoxSearchStart"; - this.groupBoxSearchStart.Size = new System.Drawing.Size(179, 79); - this.groupBoxSearchStart.TabIndex = 1; - this.groupBoxSearchStart.TabStop = false; - this.groupBoxSearchStart.Text = "Search start"; - // - // groupBoxOptions - // - this.groupBoxOptions.Controls.Add(this.checkBoxCaseSensitive); - this.groupBoxOptions.Controls.Add(this.checkBoxRegex); - this.groupBoxOptions.Controls.Add(this.buttonRegexHelper); - this.groupBoxOptions.Location = new System.Drawing.Point(198, 74); - this.groupBoxOptions.Name = "groupBoxOptions"; - this.groupBoxOptions.Size = new System.Drawing.Size(275, 104); - this.groupBoxOptions.TabIndex = 2; - this.groupBoxOptions.TabStop = false; - this.groupBoxOptions.Text = "Options"; - // - // groupBoxDirection - // - this.groupBoxDirection.Controls.Add(this.radioButtonBackward); - this.groupBoxDirection.Controls.Add(this.radioButtonForward); - this.groupBoxDirection.Location = new System.Drawing.Point(13, 159); - this.groupBoxDirection.Name = "groupBoxDirection"; - this.groupBoxDirection.Size = new System.Drawing.Size(122, 79); - this.groupBoxDirection.TabIndex = 4; - this.groupBoxDirection.TabStop = false; - this.groupBoxDirection.Text = "Direction"; - // - // radioButtonBackward - // - this.radioButtonBackward.AutoSize = true; - this.radioButtonBackward.Location = new System.Drawing.Point(7, 44); - this.radioButtonBackward.Name = "radioButtonBackward"; - this.radioButtonBackward.Size = new System.Drawing.Size(104, 24); - this.radioButtonBackward.TabIndex = 1; - this.radioButtonBackward.TabStop = true; - this.radioButtonBackward.Text = "Backward"; - this.radioButtonBackward.UseVisualStyleBackColor = true; - // - // radioButtonForward - // - this.radioButtonForward.AutoSize = true; - this.radioButtonForward.Location = new System.Drawing.Point(7, 20); - this.radioButtonForward.Name = "radioButtonForward"; - this.radioButtonForward.Size = new System.Drawing.Size(92, 24); - this.radioButtonForward.TabIndex = 0; - this.radioButtonForward.TabStop = true; - this.radioButtonForward.Text = "Forward"; - this.radioButtonForward.UseVisualStyleBackColor = true; - // - // comboBoxSearchFor - // - this.comboBoxSearchFor.FormattingEnabled = true; - this.comboBoxSearchFor.Location = new System.Drawing.Point(13, 34); - this.comboBoxSearchFor.Name = "comboBoxSearchFor"; - this.comboBoxSearchFor.Size = new System.Drawing.Size(460, 28); - this.comboBoxSearchFor.TabIndex = 0; - // - // helpProvider1 - // - this.helpProvider1.HelpNamespace = "LogExpert.chm"; - // - // SearchDialog - // - this.AcceptButton = this.buttonOk; - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(488, 250); - this.Controls.Add(this.comboBoxSearchFor); - this.Controls.Add(this.groupBoxDirection); - this.Controls.Add(this.groupBoxOptions); - this.Controls.Add(this.groupBoxSearchStart); - this.Controls.Add(this.labelSearchFor); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOk); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.helpProvider1.SetHelpKeyword(this, "Search and Navigation.htm"); - this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "SearchDialog"; - this.helpProvider1.SetShowHelp(this, true); - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Search"; - this.groupBoxSearchStart.ResumeLayout(false); - this.groupBoxSearchStart.PerformLayout(); - this.groupBoxOptions.ResumeLayout(false); - this.groupBoxOptions.PerformLayout(); - this.groupBoxDirection.ResumeLayout(false); - this.groupBoxDirection.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Label labelSearchFor; - private System.Windows.Forms.CheckBox checkBoxCaseSensitive; - private System.Windows.Forms.CheckBox checkBoxRegex; - private System.Windows.Forms.Button buttonRegexHelper; - private System.Windows.Forms.RadioButton radioButtonFromTop; - private System.Windows.Forms.RadioButton radioButtonFromSelected; - private System.Windows.Forms.GroupBox groupBoxSearchStart; - private System.Windows.Forms.GroupBox groupBoxOptions; - private System.Windows.Forms.GroupBox groupBoxDirection; - private System.Windows.Forms.RadioButton radioButtonBackward; - private System.Windows.Forms.RadioButton radioButtonForward; - private System.Windows.Forms.ComboBox comboBoxSearchFor; - private System.Windows.Forms.HelpProvider helpProvider1; - } +namespace LogExpert.Dialogs +{ + partial class SearchDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.labelSearchFor = new System.Windows.Forms.Label(); + this.checkBoxCaseSensitive = new System.Windows.Forms.CheckBox(); + this.checkBoxRegex = new System.Windows.Forms.CheckBox(); + this.buttonRegexHelper = new System.Windows.Forms.Button(); + this.radioButtonFromTop = new System.Windows.Forms.RadioButton(); + this.radioButtonFromSelected = new System.Windows.Forms.RadioButton(); + this.groupBoxSearchStart = new System.Windows.Forms.GroupBox(); + this.groupBoxOptions = new System.Windows.Forms.GroupBox(); + this.groupBoxDirection = new System.Windows.Forms.GroupBox(); + this.radioButtonBackward = new System.Windows.Forms.RadioButton(); + this.radioButtonForward = new System.Windows.Forms.RadioButton(); + this.comboBoxSearchFor = new System.Windows.Forms.ComboBox(); + this.helpProvider1 = new System.Windows.Forms.HelpProvider(); + this.groupBoxSearchStart.SuspendLayout(); + this.groupBoxOptions.SuspendLayout(); + this.groupBoxDirection.SuspendLayout(); + this.SuspendLayout(); + // + // buttonOk + // + this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(317, 215); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 5; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.OnButtonOkClick); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(398, 215); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 6; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.OnButtonCancelClick); + // + // labelSearchFor + // + this.labelSearchFor.AutoSize = true; + this.labelSearchFor.Location = new System.Drawing.Point(10, 9); + this.labelSearchFor.Name = "labelSearchFor"; + this.labelSearchFor.Size = new System.Drawing.Size(87, 20); + this.labelSearchFor.TabIndex = 0; + this.labelSearchFor.Text = "&Search for:"; + // + // checkBoxCaseSensitive + // + this.checkBoxCaseSensitive.AutoSize = true; + this.checkBoxCaseSensitive.Location = new System.Drawing.Point(6, 19); + this.checkBoxCaseSensitive.Name = "checkBoxCaseSensitive"; + this.checkBoxCaseSensitive.Size = new System.Drawing.Size(137, 24); + this.checkBoxCaseSensitive.TabIndex = 4; + this.checkBoxCaseSensitive.Text = "&Case sensitive"; + this.checkBoxCaseSensitive.UseVisualStyleBackColor = true; + // + // checkBoxRegex + // + this.checkBoxRegex.AutoSize = true; + this.checkBoxRegex.Location = new System.Drawing.Point(6, 43); + this.checkBoxRegex.Name = "checkBoxRegex"; + this.checkBoxRegex.Size = new System.Drawing.Size(171, 24); + this.checkBoxRegex.TabIndex = 5; + this.checkBoxRegex.Text = "&Regular expression"; + this.checkBoxRegex.UseVisualStyleBackColor = true; + // + // buttonRegexHelper + // + this.buttonRegexHelper.Location = new System.Drawing.Point(6, 72); + this.buttonRegexHelper.Name = "buttonRegexHelper"; + this.buttonRegexHelper.Size = new System.Drawing.Size(84, 26); + this.buttonRegexHelper.TabIndex = 3; + this.buttonRegexHelper.Text = "Regex-&Helper"; + this.buttonRegexHelper.UseVisualStyleBackColor = true; + this.buttonRegexHelper.Click += new System.EventHandler(this.OnButtonRegexClick); + // + // radioButtonFromTop + // + this.radioButtonFromTop.AutoSize = true; + this.radioButtonFromTop.Location = new System.Drawing.Point(6, 19); + this.radioButtonFromTop.Name = "radioButtonFromTop"; + this.radioButtonFromTop.Size = new System.Drawing.Size(98, 24); + this.radioButtonFromTop.TabIndex = 7; + this.radioButtonFromTop.TabStop = true; + this.radioButtonFromTop.Text = "From top"; + this.radioButtonFromTop.UseVisualStyleBackColor = true; + // + // radioButtonFromSelected + // + this.radioButtonFromSelected.AutoSize = true; + this.radioButtonFromSelected.Location = new System.Drawing.Point(6, 42); + this.radioButtonFromSelected.Name = "radioButtonFromSelected"; + this.radioButtonFromSelected.Size = new System.Drawing.Size(163, 24); + this.radioButtonFromSelected.TabIndex = 8; + this.radioButtonFromSelected.TabStop = true; + this.radioButtonFromSelected.Text = "From selected line"; + this.radioButtonFromSelected.UseVisualStyleBackColor = true; + // + // groupBoxSearchStart + // + this.groupBoxSearchStart.Controls.Add(this.radioButtonFromTop); + this.groupBoxSearchStart.Controls.Add(this.radioButtonFromSelected); + this.groupBoxSearchStart.Location = new System.Drawing.Point(12, 74); + this.groupBoxSearchStart.Name = "groupBoxSearchStart"; + this.groupBoxSearchStart.Size = new System.Drawing.Size(179, 79); + this.groupBoxSearchStart.TabIndex = 1; + this.groupBoxSearchStart.TabStop = false; + this.groupBoxSearchStart.Text = "Search start"; + // + // groupBoxOptions + // + this.groupBoxOptions.Controls.Add(this.checkBoxCaseSensitive); + this.groupBoxOptions.Controls.Add(this.checkBoxRegex); + this.groupBoxOptions.Controls.Add(this.buttonRegexHelper); + this.groupBoxOptions.Location = new System.Drawing.Point(198, 74); + this.groupBoxOptions.Name = "groupBoxOptions"; + this.groupBoxOptions.Size = new System.Drawing.Size(275, 104); + this.groupBoxOptions.TabIndex = 2; + this.groupBoxOptions.TabStop = false; + this.groupBoxOptions.Text = "Options"; + // + // groupBoxDirection + // + this.groupBoxDirection.Controls.Add(this.radioButtonBackward); + this.groupBoxDirection.Controls.Add(this.radioButtonForward); + this.groupBoxDirection.Location = new System.Drawing.Point(13, 159); + this.groupBoxDirection.Name = "groupBoxDirection"; + this.groupBoxDirection.Size = new System.Drawing.Size(122, 79); + this.groupBoxDirection.TabIndex = 4; + this.groupBoxDirection.TabStop = false; + this.groupBoxDirection.Text = "Direction"; + // + // radioButtonBackward + // + this.radioButtonBackward.AutoSize = true; + this.radioButtonBackward.Location = new System.Drawing.Point(7, 44); + this.radioButtonBackward.Name = "radioButtonBackward"; + this.radioButtonBackward.Size = new System.Drawing.Size(104, 24); + this.radioButtonBackward.TabIndex = 1; + this.radioButtonBackward.TabStop = true; + this.radioButtonBackward.Text = "Backward"; + this.radioButtonBackward.UseVisualStyleBackColor = true; + // + // radioButtonForward + // + this.radioButtonForward.AutoSize = true; + this.radioButtonForward.Location = new System.Drawing.Point(7, 20); + this.radioButtonForward.Name = "radioButtonForward"; + this.radioButtonForward.Size = new System.Drawing.Size(92, 24); + this.radioButtonForward.TabIndex = 0; + this.radioButtonForward.TabStop = true; + this.radioButtonForward.Text = "Forward"; + this.radioButtonForward.UseVisualStyleBackColor = true; + // + // comboBoxSearchFor + // + this.comboBoxSearchFor.FormattingEnabled = true; + this.comboBoxSearchFor.Location = new System.Drawing.Point(13, 34); + this.comboBoxSearchFor.Name = "comboBoxSearchFor"; + this.comboBoxSearchFor.Size = new System.Drawing.Size(460, 28); + this.comboBoxSearchFor.TabIndex = 0; + // + // helpProvider1 + // + this.helpProvider1.HelpNamespace = "LogExpert.chm"; + // + // SearchDialog + // + this.AcceptButton = this.buttonOk; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(488, 250); + this.Controls.Add(this.comboBoxSearchFor); + this.Controls.Add(this.groupBoxDirection); + this.Controls.Add(this.groupBoxOptions); + this.Controls.Add(this.groupBoxSearchStart); + this.Controls.Add(this.labelSearchFor); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.helpProvider1.SetHelpKeyword(this, "Search and Navigation.htm"); + this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "SearchDialog"; + this.helpProvider1.SetShowHelp(this, true); + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Search"; + this.groupBoxSearchStart.ResumeLayout(false); + this.groupBoxSearchStart.PerformLayout(); + this.groupBoxOptions.ResumeLayout(false); + this.groupBoxOptions.PerformLayout(); + this.groupBoxDirection.ResumeLayout(false); + this.groupBoxDirection.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonOk; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Label labelSearchFor; + private System.Windows.Forms.CheckBox checkBoxCaseSensitive; + private System.Windows.Forms.CheckBox checkBoxRegex; + private System.Windows.Forms.Button buttonRegexHelper; + private System.Windows.Forms.RadioButton radioButtonFromTop; + private System.Windows.Forms.RadioButton radioButtonFromSelected; + private System.Windows.Forms.GroupBox groupBoxSearchStart; + private System.Windows.Forms.GroupBox groupBoxOptions; + private System.Windows.Forms.GroupBox groupBoxDirection; + private System.Windows.Forms.RadioButton radioButtonBackward; + private System.Windows.Forms.RadioButton radioButtonForward; + private System.Windows.Forms.ComboBox comboBoxSearchFor; + private System.Windows.Forms.HelpProvider helpProvider1; + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/SearchDialog.cs b/src/Logexpert.UI/Dialogs/SearchDialog.cs similarity index 86% rename from src/LogExpert/Dialogs/SearchDialog.cs rename to src/Logexpert.UI/Dialogs/SearchDialog.cs index c9db6a6a..a75cf5f5 100644 --- a/src/LogExpert/Dialogs/SearchDialog.cs +++ b/src/Logexpert.UI/Dialogs/SearchDialog.cs @@ -1,143 +1,138 @@ -using LogExpert.Entities; -using LogExpert.UI.Dialogs; - -using NLog; - -using System; -using System.Drawing; -using System.Text.RegularExpressions; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public partial class SearchDialog : Form - { - #region Fields - - private static readonly int MAX_HISTORY = 30; - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - - #endregion - - #region cTor - - public SearchDialog() - { - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - Load += OnSearchDialogLoad; - } - - #endregion - - #region Properties - - public SearchParams SearchParams { get; set; } - - #endregion - - #region Events handler - - private void OnSearchDialogLoad(object sender, EventArgs e) - { - if (SearchParams != null) - { - if (SearchParams.isFromTop) - { - radioButtonFromTop.Checked = true; - } - else - { - radioButtonFromSelected.Checked = true; - } - - if (SearchParams.isForward) - { - radioButtonForward.Checked = true; - } - else - { - radioButtonBackward.Checked = true; - } - - checkBoxRegex.Checked = SearchParams.isRegex; - checkBoxCaseSensitive.Checked = SearchParams.isCaseSensitive; - foreach (string item in SearchParams.historyList) - { - comboBoxSearchFor.Items.Add(item); - } - - if (comboBoxSearchFor.Items.Count > 0) - { - comboBoxSearchFor.SelectedIndex = 0; - } - } - else - { - radioButtonFromSelected.Checked = true; - radioButtonForward.Checked = true; - SearchParams = new SearchParams(); - } - } - - private void OnButtonRegexClick(object sender, EventArgs e) - { - RegexHelperDialog dlg = new() - { - Owner = this, - CaseSensitive = checkBoxCaseSensitive.Checked, - Pattern = comboBoxSearchFor.Text - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - checkBoxCaseSensitive.Checked = dlg.CaseSensitive; - comboBoxSearchFor.Text = dlg.Pattern; - } - } - - private void OnButtonOkClick(object sender, EventArgs e) - { - try - { - if (checkBoxRegex.Checked) - { - if (string.IsNullOrWhiteSpace(comboBoxSearchFor.Text)) - { - throw new ArgumentException("Search text is empty"); - } - - // ReSharper disable once ReturnValueOfPureMethodIsNotUsed - Regex.IsMatch("", comboBoxSearchFor.Text); - } - - SearchParams.searchText = comboBoxSearchFor.Text; - SearchParams.isCaseSensitive = checkBoxCaseSensitive.Checked; - SearchParams.isForward = radioButtonForward.Checked; - SearchParams.isFromTop = radioButtonFromTop.Checked; - SearchParams.isRegex = checkBoxRegex.Checked; - SearchParams.historyList.Remove(comboBoxSearchFor.Text); - SearchParams.historyList.Insert(0, comboBoxSearchFor.Text); - if (SearchParams.historyList.Count > MAX_HISTORY) - { - SearchParams.historyList.RemoveAt(SearchParams.historyList.Count - 1); - } - } - catch (Exception ex) - { - _logger.Error(ex, "Error during ok click"); - MessageBox.Show($"Error during creation of search parameter\r\n{ex.Message}"); - } - } - - #endregion - - private void OnButtonCancelClick(object sender, EventArgs e) - { - Close(); - } - } +using LogExpert.Core.Entities; +using LogExpert.UI.Dialogs; + +using System.Runtime.Versioning; +using System.Text.RegularExpressions; + +namespace LogExpert.Dialogs +{ + [SupportedOSPlatform("windows")] + public partial class SearchDialog : Form + { + #region Fields + + private static readonly int MAX_HISTORY = 30; + + #endregion + + #region cTor + + public SearchDialog() + { + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + Load += OnSearchDialogLoad; + } + + #endregion + + #region Properties + + public SearchParams SearchParams { get; set; } = new(); + + #endregion + + #region Events handler + + private void OnSearchDialogLoad(object? sender, EventArgs e) + { + if (SearchParams != null) + { + if (SearchParams.isFromTop) + { + radioButtonFromTop.Checked = true; + } + else + { + radioButtonFromSelected.Checked = true; + } + + if (SearchParams.isForward) + { + radioButtonForward.Checked = true; + } + else + { + radioButtonBackward.Checked = true; + } + + checkBoxRegex.Checked = SearchParams.isRegex; + checkBoxCaseSensitive.Checked = SearchParams.isCaseSensitive; + foreach (string item in SearchParams.historyList) + { + comboBoxSearchFor.Items.Add(item); + } + + if (comboBoxSearchFor.Items.Count > 0) + { + comboBoxSearchFor.SelectedIndex = 0; + } + } + else + { + radioButtonFromSelected.Checked = true; + radioButtonForward.Checked = true; + SearchParams = new SearchParams(); + } + } + + private void OnButtonRegexClick(object sender, EventArgs e) + { + RegexHelperDialog dlg = new() + { + Owner = this, + CaseSensitive = checkBoxCaseSensitive.Checked, + Pattern = comboBoxSearchFor.Text + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + checkBoxCaseSensitive.Checked = dlg.CaseSensitive; + comboBoxSearchFor.Text = dlg.Pattern; + } + } + + private void OnButtonOkClick(object sender, EventArgs e) + { + try + { + if (checkBoxRegex.Checked) + { + if (string.IsNullOrWhiteSpace(comboBoxSearchFor.Text)) + { + throw new ArgumentException("Search text is empty"); + } + + Regex.IsMatch("", comboBoxSearchFor.Text); + } + + SearchParams.searchText = comboBoxSearchFor.Text; + SearchParams.isCaseSensitive = checkBoxCaseSensitive.Checked; + SearchParams.isForward = radioButtonForward.Checked; + SearchParams.isFromTop = radioButtonFromTop.Checked; + SearchParams.isRegex = checkBoxRegex.Checked; + SearchParams.historyList.Remove(comboBoxSearchFor.Text); + SearchParams.historyList.Insert(0, comboBoxSearchFor.Text); + + if (SearchParams.historyList.Count > MAX_HISTORY) + { + SearchParams.historyList.RemoveAt(SearchParams.historyList.Count - 1); + } + } + catch (Exception ex) + { + MessageBox.Show($"Error during creation of search parameter\r\n{ex.Message}"); + } + } + + #endregion + + private void OnButtonCancelClick(object sender, EventArgs e) + { + Close(); + } + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/SearchDialog.resx b/src/Logexpert.UI/Dialogs/SearchDialog.resx similarity index 97% rename from src/LogExpert/Dialogs/SearchDialog.resx rename to src/Logexpert.UI/Dialogs/SearchDialog.resx index 59775d45..9cf9a31f 100644 --- a/src/LogExpert/Dialogs/SearchDialog.resx +++ b/src/Logexpert.UI/Dialogs/SearchDialog.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Logexpert.UI/LogExpert.UI.csproj b/src/Logexpert.UI/LogExpert.UI.csproj index a4adc350..14f84e05 100644 --- a/src/Logexpert.UI/LogExpert.UI.csproj +++ b/src/Logexpert.UI/LogExpert.UI.csproj @@ -13,6 +13,7 @@ + @@ -23,6 +24,9 @@ Form + + Form + Form diff --git a/src/LogExpert/Classes/LocalFileSystem.cs b/src/PluginRegistry/FileSystem/LocalFileSystem.cs similarity index 70% rename from src/LogExpert/Classes/LocalFileSystem.cs rename to src/PluginRegistry/FileSystem/LocalFileSystem.cs index 9594dc6c..aafb3eaf 100644 --- a/src/LogExpert/Classes/LocalFileSystem.cs +++ b/src/PluginRegistry/FileSystem/LocalFileSystem.cs @@ -1,49 +1,40 @@ -using System; -using LogExpert.Classes.Log; - -namespace LogExpert.Classes -{ - public class LocalFileSystem : IFileSystemPlugin - { - #region IFileSystemPlugin Member - - public bool CanHandleUri(string uriString) - { - try - { - Uri uri = new(uriString); - return uri.IsFile; - } - catch (Exception) - { - return false; - } - } - - public ILogFileInfo GetLogfileInfo(string uriString) - { - Uri uri = new(uriString); - if (uri.IsFile) - { - ILogFileInfo logFileInfo = new LogFileInfo(uri); - return logFileInfo; - } - else - { - throw new UriFormatException("Uri " + uriString + " is no file Uri"); - } - } - - public string Text - { - get { return "Local file system"; } - } - - public string Description - { - get { return "Access files from normal file system."; } - } - - #endregion - } +namespace LogExpert.PluginRegistry.FileSystem +{ + public class LocalFileSystem : IFileSystemPlugin + { + #region IFileSystemPlugin Member + + public bool CanHandleUri(string uriString) + { + try + { + Uri uri = new(uriString); + return uri.IsFile; + } + catch (Exception) + { + return false; + } + } + + public ILogFileInfo GetLogfileInfo(string uriString) + { + Uri uri = new(uriString); + if (uri.IsFile) + { + ILogFileInfo logFileInfo = new LogFileInfo(uri); + return logFileInfo; + } + else + { + throw new UriFormatException("Uri " + uriString + " is no file Uri"); + } + } + + public string Text => "Local file system"; + + public string Description => "Access files from normal file system."; + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Log/LogFileInfo.cs b/src/PluginRegistry/FileSystem/LogFileInfo.cs similarity index 72% rename from src/LogExpert/Classes/Log/LogFileInfo.cs rename to src/PluginRegistry/FileSystem/LogFileInfo.cs index 31bd9bc8..d94aef21 100644 --- a/src/LogExpert/Classes/Log/LogFileInfo.cs +++ b/src/PluginRegistry/FileSystem/LogFileInfo.cs @@ -1,188 +1,182 @@ -using System; -using System.IO; -using System.Threading; -using LogExpert.Config; -using NLog; - -namespace LogExpert.Classes.Log -{ - public class LogFileInfo : ILogFileInfo - { - #region Fields - - private const int RETRY_COUNT = 5; - private const int RETRY_SLEEP = 250; - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - - //FileStream fStream; - private readonly FileInfo fInfo; - - private long lastLength; - - #endregion - - #region cTor - - public LogFileInfo(Uri fileUri) - { - this.fInfo = new FileInfo(fileUri.LocalPath); - this.Uri = fileUri; - this.OriginalLength = lastLength = LengthWithoutRetry; - //this.oldLength = 0; - } - - #endregion - - #region Properties - - public string FullName - { - get { return this.fInfo.FullName; } - } - - public string FileName - { - get { return this.fInfo.Name; } - } - - - public string DirectoryName - { - get { return this.fInfo.DirectoryName; } - } - - public char DirectorySeparatorChar - { - get { return Path.DirectorySeparatorChar; } - } - - public Uri Uri { get; } - - - public long Length - { - get - { - if (fInfo == null) - { - return -1; - } - int retry = RETRY_COUNT; - while (retry > 0) - { - try - { - this.fInfo.Refresh(); - return this.fInfo.Length; - } - catch (IOException e) - { - if (--retry <= 0) - { - _logger.Warn(e, "LogFileInfo.Length"); - return -1; - } - Thread.Sleep(RETRY_SLEEP); - } - } - return -1; - } - } - - public long OriginalLength { get; } - - public bool FileExists - { - get - { - this.fInfo.Refresh(); - return this.fInfo.Exists; - } - } - - public int PollInterval - { - get { return ConfigManager.Settings.Preferences.pollingInterval; } - } - - public long LengthWithoutRetry - { - get - { - if (fInfo == null) - { - return -1; - } - try - { - this.fInfo.Refresh(); - return this.fInfo.Length; - } - catch (IOException) - { - return -1; - } - } - } - - #endregion - - #region Public methods - - /// - /// Creates a new FileStream for the file. The caller is responsible for closing. - /// If file opening fails it will be tried RETRY_COUNT times. This may be needed sometimes - /// if the file is locked for a short amount of time or temporarly unaccessible because of - /// rollover situations. - /// - /// - public Stream OpenStream() - { - int retry = RETRY_COUNT; - while (true) - { - try - { - return new FileStream(this.fInfo.FullName, FileMode.Open, FileAccess.Read, - FileShare.ReadWrite | FileShare.Delete); - } - catch (IOException fe) - { - _logger.Debug(fe, "LogFileInfo.OpenFile(): \r\nRetry counter {0}", retry); - if (--retry <= 0) - { - throw; - } - Thread.Sleep(RETRY_SLEEP); - } - catch (UnauthorizedAccessException uae) - { - _logger.Debug(uae, "LogFileInfo.OpenFile(): \r\nRetry counter: {0}", retry); - if (--retry <= 0) - { - throw new IOException("Error opening file", uae); - } - Thread.Sleep(RETRY_SLEEP); - } - } - } - - public bool FileHasChanged() - { - if (this.LengthWithoutRetry != this.lastLength) - { - this.lastLength = this.LengthWithoutRetry; - return true; - } - return false; - } - - - public override string ToString() - { - return this.fInfo.FullName + ", OldLen: " + OriginalLength + ", Len: " + Length; - } - - #endregion - } +using NLog; + +namespace LogExpert.PluginRegistry.FileSystem +{ + public class LogFileInfo : ILogFileInfo + { + #region Fields + + private const int RETRY_COUNT = 5; + private const int RETRY_SLEEP = 250; + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + + //FileStream fStream; + private readonly FileInfo fInfo; + + private long lastLength; + + #endregion + + #region cTor + + public LogFileInfo(Uri fileUri) + { + fInfo = new FileInfo(fileUri.LocalPath); + Uri = fileUri; + OriginalLength = lastLength = LengthWithoutRetry; + //this.oldLength = 0; + } + + #endregion + + #region Properties + + public string FullName + { + get { return fInfo.FullName; } + } + + public string FileName + { + get { return fInfo.Name; } + } + + + public string DirectoryName + { + get { return fInfo.DirectoryName; } + } + + public char DirectorySeparatorChar + { + get { return Path.DirectorySeparatorChar; } + } + + public Uri Uri { get; } + + + public long Length + { + get + { + if (fInfo == null) + { + return -1; + } + int retry = RETRY_COUNT; + while (retry > 0) + { + try + { + fInfo.Refresh(); + return fInfo.Length; + } + catch (IOException e) + { + if (--retry <= 0) + { + _logger.Warn(e, "LogFileInfo.Length"); + return -1; + } + Thread.Sleep(RETRY_SLEEP); + } + } + return -1; + } + } + + public long OriginalLength { get; } + + public bool FileExists + { + get + { + fInfo.Refresh(); + return fInfo.Exists; + } + } + + //TODO this should be set from outside once + public int PollInterval => PluginRegistry.PollingInterval; + + public long LengthWithoutRetry + { + get + { + if (fInfo == null) + { + return -1; + } + try + { + fInfo.Refresh(); + return fInfo.Length; + } + catch (IOException) + { + return -1; + } + } + } + + #endregion + + #region Public methods + + /// + /// Creates a new FileStream for the file. The caller is responsible for closing. + /// If file opening fails it will be tried RETRY_COUNT times. This may be needed sometimes + /// if the file is locked for a short amount of time or temporarly unaccessible because of + /// rollover situations. + /// + /// + public Stream OpenStream() + { + int retry = RETRY_COUNT; + + while (true) + { + try + { + return new FileStream(fInfo.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); + } + catch (IOException fe) + { + _logger.Debug(fe, "LogFileInfo.OpenFile(): \r\nRetry counter {0}", retry); + if (--retry <= 0) + { + throw; + } + Thread.Sleep(RETRY_SLEEP); + } + catch (UnauthorizedAccessException uae) + { + _logger.Debug(uae, "LogFileInfo.OpenFile(): \r\nRetry counter: {0}", retry); + if (--retry <= 0) + { + throw new IOException("Error opening file", uae); + } + Thread.Sleep(RETRY_SLEEP); + } + } + } + + public bool FileHasChanged() + { + if (LengthWithoutRetry != lastLength) + { + lastLength = LengthWithoutRetry; + return true; + } + return false; + } + + + public override string ToString() + { + return fInfo.FullName + ", OldLen: " + OriginalLength + ", Len: " + Length; + } + + #endregion + } } \ No newline at end of file diff --git a/src/PluginRegistry/LogExpert.PluginRegistry.csproj b/src/PluginRegistry/LogExpert.PluginRegistry.csproj new file mode 100644 index 00000000..0440166d --- /dev/null +++ b/src/PluginRegistry/LogExpert.PluginRegistry.csproj @@ -0,0 +1,17 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + diff --git a/src/LogExpert/Classes/PluginRegistry.cs b/src/PluginRegistry/PluginRegistry.cs similarity index 77% rename from src/LogExpert/Classes/PluginRegistry.cs rename to src/PluginRegistry/PluginRegistry.cs index 31cad60e..64605508 100644 --- a/src/LogExpert/Classes/PluginRegistry.cs +++ b/src/PluginRegistry/PluginRegistry.cs @@ -1,359 +1,385 @@ -using LogExpert.Classes.Columnizer; -using LogExpert.Config; -using LogExpert.Entities; -using LogExpert.Extensions; - -using NLog; - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Windows.Forms; - -namespace LogExpert.Classes -{ - /// - /// Holds all registered plugins. - /// - /// - /// It all has started with Columnizers only. So the different types of plugins have no common super interface. I didn't change it - /// to keep existing plugin API stable. In a future version this may change. - /// - public class PluginRegistry - { - #region Fields - - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - private static readonly Lazy _instance = new(() => new PluginRegistry()); - - private readonly IFileSystemCallback _fileSystemCallback = new FileSystemCallback(); - private readonly IList _pluginList = new List(); - private readonly IDictionary _registeredKeywordsDict = new Dictionary(); - - #endregion - - #region cTor - // Private constructor to prevent instantiation - private PluginRegistry() - { - LoadPlugins(); - } - - #endregion - - #region Properties - - public static PluginRegistry Instance => _instance.Value; - - public IList RegisteredColumnizers { get; private set; } - - public IList RegisteredContextMenuPlugins { get; } = new List(); - - public IList RegisteredKeywordActions { get; } = new List(); - - public IList RegisteredFileSystemPlugins { get; } = new List(); - - #endregion - - #region Public methods - #endregion - - #region Internals - - internal void LoadPlugins() - { - _logger.Info("Loading plugins..."); - - RegisteredColumnizers = - [ - //TODO: Remove these plugins and load them as any other plugin - new DefaultLogfileColumnizer(), - new TimestampColumnizer(), - new SquareBracketColumnizer(), - new ClfColumnizer(), - ]; - RegisteredFileSystemPlugins.Add(new LocalFileSystem()); - - string pluginDir = Path.Combine(Application.StartupPath, "plugins"); - //TODO: FIXME: This is a hack for the tests to pass. Need to find a better approach - if (!Directory.Exists(pluginDir)) - { - pluginDir = "."; - } - - AppDomain.CurrentDomain.AssemblyResolve += ColumnizerResolveEventHandler; - - string interfaceName = typeof(ILogLineColumnizer).FullName; - foreach (string dllName in Directory.EnumerateFiles(pluginDir, "*.dll")) - { - try - { - LoadPluginAssembly(dllName, interfaceName); - } - catch (Exception ex) when (ex is BadImageFormatException or FileLoadException) - { - // Can happen when a 32bit-only DLL is loaded on a 64bit system (or vice versa) - // or could be a not columnizer DLL (e.g. A DLL that is needed by a plugin). - _logger.Error(ex, dllName); - } - catch (ReflectionTypeLoadException ex) - { - // can happen when a dll dependency is missing - if (!ex.LoaderExceptions.IsEmpty()) - { - foreach (Exception loaderException in ex.LoaderExceptions) - { - _logger.Error(loaderException, "Plugin load failed with '{0}'", dllName); - } - } - _logger.Error(ex, "Loader exception during load of dll '{0}'", dllName); - throw; - } - catch (Exception ex) - { - _logger.Error(ex, $"General Exception for the file {dllName}, of type: {ex.GetType()}, with the message: {ex.Message}"); - throw; - } - } - - _logger.Info("Plugin loading complete."); - } - - private void LoadPluginAssembly(string dllName, string interfaceName) - { - Assembly assembly = Assembly.LoadFrom(dllName); - var types = assembly.GetTypes(); - - foreach (var type in types) - { - _logger.Info($"Type {type.FullName} in assembly {assembly.FullName} implements {interfaceName}"); - - if (type.GetInterfaces().Any(i => i.FullName == interfaceName)) - { - ConstructorInfo cti = type.GetConstructor(Type.EmptyTypes); - if (cti != null) - { - object instance = cti.Invoke([]); - RegisteredColumnizers.Add((ILogLineColumnizer)instance); - - if (instance is IColumnizerConfigurator configurator) - { - configurator.LoadConfig(ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir); - } - - if (instance is ILogExpertPlugin plugin) - { - _pluginList.Add(plugin); - plugin.PluginLoaded(); - } - - _logger.Info("Added columnizer {0}", type.Name); - } - } - else - { - if (TryAsContextMenu(type)) - { - continue; - } - - if (TryAsKeywordAction(type)) - { - continue; - } - - if (TryAsFileSystem(type)) - { - continue; - } - } - } - } - - internal IKeywordAction FindKeywordActionPluginByName(string name) - { - _registeredKeywordsDict.TryGetValue(name, out IKeywordAction action); - return action; - } - - internal void CleanupPlugins() - { - foreach (ILogExpertPlugin plugin in _pluginList) - { - plugin.AppExiting(); - } - } - - internal IFileSystemPlugin FindFileSystemForUri(string uriString) - { - if (_logger.IsDebugEnabled) - { - _logger.Debug("Trying to find file system plugin for uri {0}", uriString); - } - - foreach (IFileSystemPlugin fs in RegisteredFileSystemPlugins) - { - if (_logger.IsDebugEnabled) - { - _logger.Debug("Checking {0}", fs.Text); - } - - if (fs.CanHandleUri(uriString)) - { - if (_logger.IsDebugEnabled) - { - _logger.Debug("Found match {0}", fs.Text); - } - - return fs; - } - } - - _logger.Error("No file system plugin found for uri {0}", uriString); - return null; - } - - #endregion - - #region Private Methods - //TODO: Can this be delted? - private bool TryAsContextMenu(Type type) - { - IContextMenuEntry me = TryInstantiate(type); - if (me != null) - { - RegisteredContextMenuPlugins.Add(me); - if (me is ILogExpertPluginConfigurator configurator) - { - configurator.LoadConfig(ConfigManager.ConfigDir); - } - - if (me is ILogExpertPlugin) - { - _pluginList.Add(me as ILogExpertPlugin); - (me as ILogExpertPlugin).PluginLoaded(); - } - - _logger.Info("Added context menu plugin {0}", type); - return true; - } - - return false; - } - - //TODO: Can this be delted? - private bool TryAsKeywordAction(Type type) - { - IKeywordAction ka = TryInstantiate(type); - if (ka != null) - { - RegisteredKeywordActions.Add(ka); - _registeredKeywordsDict.Add(ka.GetName(), ka); - if (ka is ILogExpertPluginConfigurator configurator) - { - configurator.LoadConfig(ConfigManager.ConfigDir); - } - - if (ka is ILogExpertPlugin) - { - _pluginList.Add(ka as ILogExpertPlugin); - (ka as ILogExpertPlugin).PluginLoaded(); - } - - _logger.Info("Added keyword plugin {0}", type); - return true; - } - - return false; - } - - //TODO: Can this be delted? - private bool TryAsFileSystem(Type type) - { - // file system plugins can have optional constructor with IFileSystemCallback argument - IFileSystemPlugin fs = TryInstantiate(type, _fileSystemCallback); - fs ??= TryInstantiate(type); - - if (fs != null) - { - RegisteredFileSystemPlugins.Add(fs); - if (fs is ILogExpertPluginConfigurator configurator) - { - configurator.LoadConfig(ConfigManager.ConfigDir); - } - - if (fs is ILogExpertPlugin) - { - _pluginList.Add(fs as ILogExpertPlugin); - (fs as ILogExpertPlugin).PluginLoaded(); - } - - _logger.Info("Added file system plugin {0}", type); - return true; - } - - return false; - } - - private static T TryInstantiate(Type loadedType) where T : class - { - Type t = typeof(T); - Type inter = loadedType.GetInterface(t.Name); - if (inter != null) - { - ConstructorInfo cti = loadedType.GetConstructor(Type.EmptyTypes); - if (cti != null) - { - object o = cti.Invoke([]); - return o as T; - } - } - - return default(T); - } - - private static T TryInstantiate(Type loadedType, IFileSystemCallback fsCallback) where T : class - { - Type t = typeof(T); - Type inter = loadedType.GetInterface(t.Name); - if (inter != null) - { - ConstructorInfo cti = loadedType.GetConstructor([typeof(IFileSystemCallback)]); - if (cti != null) - { - object o = cti.Invoke([fsCallback]); - return o as T; - } - } - - return default; - } - - #endregion - - #region Events handler - - private static Assembly ColumnizerResolveEventHandler(object sender, ResolveEventArgs args) - { - string fileName = new AssemblyName(args.Name).Name + ".dll"; - string mainDir = Path.Combine(Application.StartupPath, fileName); - string pluginDir = Path.Combine(Application.StartupPath, "plugins", fileName); - - if (File.Exists(mainDir)) - { - return Assembly.LoadFrom(mainDir); - } - - if (File.Exists(pluginDir)) - { - return Assembly.LoadFrom(pluginDir); - } - - return null; - } - - #endregion - } +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Entities; +using LogExpert.Core.Extensions; +using LogExpert.PluginRegistry.FileSystem; + +using NLog; + +using System.Reflection; + +namespace LogExpert.PluginRegistry +{ + /// + /// Holds all registered plugins. + /// + /// + /// It all has started with Columnizers only. So the different types of plugins have no common super interface. I didn't change it + /// to keep existing plugin API stable. In a future version this may change. + /// + public class PluginRegistry + { + #region Fields + + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static PluginRegistry? _instance; + private static readonly object _lock = new(); + + private readonly IFileSystemCallback _fileSystemCallback = new FileSystemCallback(); + private readonly IList _pluginList = []; + private readonly IDictionary _registeredKeywordsDict = new Dictionary(); + + #endregion + + private static string _applicationConfigurationFolder = string.Empty; + private static int _pollingInterval = 250; + + #region cTor + // Private constructor to prevent instantiation + private PluginRegistry(string applicationConfigurationFolder, int pollingInterval) + { + _applicationConfigurationFolder = applicationConfigurationFolder; + _pollingInterval = pollingInterval; + } + + public PluginRegistry Create(string applicationConfigurationFolder, int pollingInterval) + { + if (_instance != null) + { + return _instance; + } + + lock (_lock) + { + _instance ??= new PluginRegistry(applicationConfigurationFolder, pollingInterval); + } + + _applicationConfigurationFolder = applicationConfigurationFolder; + _pollingInterval = pollingInterval; + + _instance.LoadPlugins(); + return Instance; + } + + #endregion + + #region Properties + + public static PluginRegistry Instance => _instance ?? new PluginRegistry(_applicationConfigurationFolder, _pollingInterval); + + public IList RegisteredColumnizers { get; private set; } + + public IList RegisteredContextMenuPlugins { get; } = []; + + public IList RegisteredKeywordActions { get; } = []; + + public IList RegisteredFileSystemPlugins { get; } = []; + + #endregion + + #region Public methods + + public static int PollingInterval => _pollingInterval; + + #endregion + + #region Internals + + internal void LoadPlugins() + { + _logger.Info("Loading plugins..."); + + RegisteredColumnizers = + [ + //TODO: Remove these plugins and load them as any other plugin + new DefaultLogfileColumnizer(), + new TimestampColumnizer(), + new SquareBracketColumnizer(), + new ClfColumnizer(), + ]; + RegisteredFileSystemPlugins.Add(new LocalFileSystem()); + + string pluginDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins"); + //TODO: FIXME: This is a hack for the tests to pass. Need to find a better approach + if (!Directory.Exists(pluginDir)) + { + pluginDir = "."; + } + + AppDomain.CurrentDomain.AssemblyResolve += ColumnizerResolveEventHandler; + + string interfaceName = typeof(ILogLineColumnizer).FullName; + foreach (string dllName in Directory.EnumerateFiles(pluginDir, "*.dll")) + { + try + { + LoadPluginAssembly(dllName, interfaceName); + } + catch (Exception ex) when (ex is BadImageFormatException or FileLoadException) + { + // Can happen when a 32bit-only DLL is loaded on a 64bit system (or vice versa) + // or could be a not columnizer DLL (e.g. A DLL that is needed by a plugin). + _logger.Error(ex, dllName); + } + catch (ReflectionTypeLoadException ex) + { + // can happen when a dll dependency is missing + if (!ex.LoaderExceptions.IsEmpty()) + { + foreach (Exception loaderException in ex.LoaderExceptions) + { + _logger.Error(loaderException, "Plugin load failed with '{0}'", dllName); + } + } + _logger.Error(ex, "Loader exception during load of dll '{0}'", dllName); + throw; + } + catch (Exception ex) + { + _logger.Error(ex, $"General Exception for the file {dllName}, of type: {ex.GetType()}, with the message: {ex.Message}"); + throw; + } + } + + _logger.Info("Plugin loading complete."); + } + + private void LoadPluginAssembly(string dllName, string interfaceName) + { + Assembly assembly = Assembly.LoadFrom(dllName); + var types = assembly.GetTypes(); + + foreach (var type in types) + { + _logger.Info($"Type {type.FullName} in assembly {assembly.FullName} implements {interfaceName}"); + + if (type.GetInterfaces().Any(i => i.FullName == interfaceName)) + { + ConstructorInfo cti = type.GetConstructor(Type.EmptyTypes); + if (cti != null) + { + object instance = cti.Invoke([]); + RegisteredColumnizers.Add((ILogLineColumnizer)instance); + + if (instance is IColumnizerConfigurator configurator) + { + configurator.LoadConfig(_applicationConfigurationFolder); + } + + if (instance is ILogExpertPlugin plugin) + { + _pluginList.Add(plugin); + plugin.PluginLoaded(); + } + + _logger.Info("Added columnizer {0}", type.Name); + } + } + else + { + if (TryAsContextMenu(type)) + { + continue; + } + + if (TryAsKeywordAction(type)) + { + continue; + } + + if (TryAsFileSystem(type)) + { + continue; + } + } + } + } + + public IKeywordAction FindKeywordActionPluginByName(string name) + { + _registeredKeywordsDict.TryGetValue(name, out IKeywordAction action); + return action; + } + + public void CleanupPlugins() + { + foreach (ILogExpertPlugin plugin in _pluginList) + { + plugin.AppExiting(); + } + } + + public IFileSystemPlugin FindFileSystemForUri(string uriString) + { + if (_logger.IsDebugEnabled) + { + _logger.Debug("Trying to find file system plugin for uri {0}", uriString); + } + + foreach (IFileSystemPlugin fs in RegisteredFileSystemPlugins) + { + if (_logger.IsDebugEnabled) + { + _logger.Debug("Checking {0}", fs.Text); + } + + if (fs.CanHandleUri(uriString)) + { + if (_logger.IsDebugEnabled) + { + _logger.Debug("Found match {0}", fs.Text); + } + + return fs; + } + } + + _logger.Error("No file system plugin found for uri {0}", uriString); + return null; + } + + #endregion + + #region Private Methods + //TODO: Can this be delted? + private bool TryAsContextMenu(Type type) + { + IContextMenuEntry me = TryInstantiate(type); + + if (me != null) + { + RegisteredContextMenuPlugins.Add(me); + if (me is ILogExpertPluginConfigurator configurator) + { + configurator.LoadConfig(_applicationConfigurationFolder); + } + + if (me is ILogExpertPlugin plugin) + { + _pluginList.Add(plugin); + plugin.PluginLoaded(); + } + + _logger.Info("Added context menu plugin {0}", type); + return true; + } + + return false; + } + + //TODO: Can this be delted? + private bool TryAsKeywordAction(Type type) + { + IKeywordAction ka = TryInstantiate(type); + if (ka != null) + { + RegisteredKeywordActions.Add(ka); + _registeredKeywordsDict.Add(ka.GetName(), ka); + if (ka is ILogExpertPluginConfigurator configurator) + { + configurator.LoadConfig(_applicationConfigurationFolder); + } + + if (ka is ILogExpertPlugin plugin) + { + _pluginList.Add(plugin); + plugin.PluginLoaded(); + } + + _logger.Info("Added keyword plugin {0}", type); + return true; + } + + return false; + } + + //TODO: Can this be delted? + private bool TryAsFileSystem(Type type) + { + // file system plugins can have optional constructor with IFileSystemCallback argument + IFileSystemPlugin fs = TryInstantiate(type, _fileSystemCallback); + fs ??= TryInstantiate(type); + + if (fs != null) + { + RegisteredFileSystemPlugins.Add(fs); + if (fs is ILogExpertPluginConfigurator configurator) + { + //TODO Refactor, this should be set from outside once and not loaded all the time + configurator.LoadConfig(_applicationConfigurationFolder); + } + + if (fs is ILogExpertPlugin plugin) + { + _pluginList.Add(plugin); + plugin.PluginLoaded(); + } + + _logger.Info("Added file system plugin {0}", type); + return true; + } + + return false; + } + + private static T TryInstantiate(Type loadedType) where T : class + { + Type t = typeof(T); + Type inter = loadedType.GetInterface(t.Name); + if (inter != null) + { + ConstructorInfo cti = loadedType.GetConstructor(Type.EmptyTypes); + if (cti != null) + { + object o = cti.Invoke([]); + return o as T; + } + } + + return default; + } + + private static T TryInstantiate(Type loadedType, IFileSystemCallback fsCallback) where T : class + { + Type t = typeof(T); + Type inter = loadedType.GetInterface(t.Name); + if (inter != null) + { + ConstructorInfo cti = loadedType.GetConstructor([typeof(IFileSystemCallback)]); + if (cti != null) + { + object o = cti.Invoke([fsCallback]); + return o as T; + } + } + + return default; + } + + #endregion + + #region Events handler + + private static Assembly ColumnizerResolveEventHandler(object sender, ResolveEventArgs args) + { + string fileName = new AssemblyName(args.Name).Name + ".dll"; + + string mainDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); + string pluginDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins", fileName); + + if (File.Exists(mainDir)) + { + return Assembly.LoadFrom(mainDir); + } + + if (File.Exists(pluginDir)) + { + return Assembly.LoadFrom(pluginDir); + } + + return null; + } + + #endregion + } } \ No newline at end of file From d6b6669ba4f008739f5651e521658e01bd331400 Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Thu, 27 Mar 2025 17:38:57 +0100 Subject: [PATCH 010/142] strongly named and signed --- src/LogExpert.Tests/Extensions/EnumerableTests.cs | 9 ++++----- src/Logexpert.Core/Logexpert.Core.csproj | 11 +++++++++++ src/Logexpert.Resources/Logexpert.Resources.csproj | 11 +++++++++++ src/Logexpert.UI/LogExpert.UI.csproj | 8 +++++++- src/PluginRegistry/LogExpert.PluginRegistry.csproj | 11 +++++++++++ src/PluginRegistry/PluginRegistry.cs | 5 ++--- 6 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/LogExpert.Tests/Extensions/EnumerableTests.cs b/src/LogExpert.Tests/Extensions/EnumerableTests.cs index e6f4e28f..2c7548c1 100644 --- a/src/LogExpert.Tests/Extensions/EnumerableTests.cs +++ b/src/LogExpert.Tests/Extensions/EnumerableTests.cs @@ -2,7 +2,6 @@ using NUnit.Framework; -using System; using System.Collections.Generic; namespace LogExpert.Tests.Extensions @@ -21,7 +20,7 @@ public void Extensions_IsEmpty_NullArray() [Test] public void Extensions_IsEmpty_EmptyArray() { - object[] arrayObject = Array.Empty(); + object[] arrayObject = []; Assert.That(arrayObject.IsEmpty(), Is.True); } @@ -29,7 +28,7 @@ public void Extensions_IsEmpty_EmptyArray() [Test] public void Extensions_IsEmpty_FilledArray() { - object[] arrayObject = { new() }; + object[] arrayObject = [new()]; Assert.That(!arrayObject.IsEmpty(), Is.True); } @@ -45,7 +44,7 @@ public void Extensions_IsEmpty_NullIEnumerable() [Test] public void Extensions_IsEmpty_EmptyIEnumerable() { - IEnumerable arrayObject = new List(); + IEnumerable arrayObject = []; Assert.That(arrayObject.IsEmpty(), Is.True); } @@ -53,7 +52,7 @@ public void Extensions_IsEmpty_EmptyIEnumerable() [Test] public void Extensions_IsEmpty_FilledIEnumerable() { - IEnumerable arrayObject = new List(new[] { new object() }); + IEnumerable arrayObject = new List([new object()]); Assert.That(!arrayObject.IsEmpty(), Is.True); } diff --git a/src/Logexpert.Core/Logexpert.Core.csproj b/src/Logexpert.Core/Logexpert.Core.csproj index 0d7b68b6..8d46cfcc 100644 --- a/src/Logexpert.Core/Logexpert.Core.csproj +++ b/src/Logexpert.Core/Logexpert.Core.csproj @@ -4,9 +4,20 @@ net8.0 enable enable + false true + True + ..\Solution Items\Key.snk + + + + + + + + diff --git a/src/Logexpert.Resources/Logexpert.Resources.csproj b/src/Logexpert.Resources/Logexpert.Resources.csproj index 7474599d..e5048437 100644 --- a/src/Logexpert.Resources/Logexpert.Resources.csproj +++ b/src/Logexpert.Resources/Logexpert.Resources.csproj @@ -4,14 +4,25 @@ net8.0 enable enable + false + True + ..\Solution Items\Key.snk + + + + + + + + diff --git a/src/Logexpert.UI/LogExpert.UI.csproj b/src/Logexpert.UI/LogExpert.UI.csproj index 14f84e05..13f1c365 100644 --- a/src/Logexpert.UI/LogExpert.UI.csproj +++ b/src/Logexpert.UI/LogExpert.UI.csproj @@ -5,7 +5,9 @@ enable true enable - false + false + True + ..\Solution Items\Key.snk @@ -36,4 +38,8 @@ + + + + diff --git a/src/PluginRegistry/LogExpert.PluginRegistry.csproj b/src/PluginRegistry/LogExpert.PluginRegistry.csproj index 0440166d..55e143ec 100644 --- a/src/PluginRegistry/LogExpert.PluginRegistry.csproj +++ b/src/PluginRegistry/LogExpert.PluginRegistry.csproj @@ -3,9 +3,20 @@ net8.0 enable + false enable + True + ..\Solution Items\Key.snk + + + + + + + + diff --git a/src/PluginRegistry/PluginRegistry.cs b/src/PluginRegistry/PluginRegistry.cs index 64605508..1ba393d9 100644 --- a/src/PluginRegistry/PluginRegistry.cs +++ b/src/PluginRegistry/PluginRegistry.cs @@ -1,7 +1,6 @@ using LogExpert.Core.Classes; using LogExpert.Core.Classes.Columnizer; using LogExpert.Core.Entities; -using LogExpert.Core.Extensions; using LogExpert.PluginRegistry.FileSystem; using NLog; @@ -124,7 +123,7 @@ internal void LoadPlugins() catch (ReflectionTypeLoadException ex) { // can happen when a dll dependency is missing - if (!ex.LoaderExceptions.IsEmpty()) + if (ex.LoaderExceptions != null && ex.LoaderExceptions.Length != 0) { foreach (Exception loaderException in ex.LoaderExceptions) { @@ -360,7 +359,7 @@ private static T TryInstantiate(Type loadedType, IFileSystemCallback fsCallba #region Events handler - private static Assembly ColumnizerResolveEventHandler(object sender, ResolveEventArgs args) + private static Assembly ColumnizerResolveEventHandler(object? sender, ResolveEventArgs args) { string fileName = new AssemblyName(args.Name).Name + ".dll"; From 19a5d77cc4dd741690122b003015028182c09b85 Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Thu, 3 Apr 2025 20:05:16 +0200 Subject: [PATCH 011/142] pluginregistry needs too be instantiated --- src/LogExpert.Tests/BufferShiftTest.cs | 3 ++- src/LogExpert.Tests/RolloverHandlerTestBase.cs | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/LogExpert.Tests/BufferShiftTest.cs b/src/LogExpert.Tests/BufferShiftTest.cs index ebc96a2a..b87e1b1e 100644 --- a/src/LogExpert.Tests/BufferShiftTest.cs +++ b/src/LogExpert.Tests/BufferShiftTest.cs @@ -1,7 +1,6 @@ using LogExpert.Classes.Log; using LogExpert.Core.Classes.Log; using LogExpert.Core.Entities; -using LogExpert.Entities; using LogExpert.PluginRegistry.FileSystem; using NUnit.Framework; @@ -42,6 +41,8 @@ public void TestShiftBuffers1() { Encoding = Encoding.Default }; + + PluginRegistry.PluginRegistry.Instance.Create(testDirectory.FullName, 500); LogfileReader reader = new(files.Last.Value, encodingOptions, true, 40, 50, options); reader.ReadFiles(); diff --git a/src/LogExpert.Tests/RolloverHandlerTestBase.cs b/src/LogExpert.Tests/RolloverHandlerTestBase.cs index 94b8733a..06617bf0 100644 --- a/src/LogExpert.Tests/RolloverHandlerTestBase.cs +++ b/src/LogExpert.Tests/RolloverHandlerTestBase.cs @@ -1,16 +1,17 @@ +using LogExpert.Core.Classes.Log; + using System; using System.Collections.Generic; using System.IO; -using LogExpert.Core.Classes.Log; - namespace LogExpert.Tests { internal class RolloverHandlerTestBase { #region Fields - protected const string TEST_DIR_NAME = "test"; + public const string TEST_DIR_NAME = "test"; + public DirectoryInfo testDirectory; #endregion @@ -19,6 +20,7 @@ protected LinkedList CreateTestFilesWithDate() { LinkedList createdFiles = new(); DirectoryInfo dInfo = Directory.CreateDirectory(TEST_DIR_NAME); + testDirectory = dInfo; createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-08_1.log")); createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-08_0.log")); createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-10_0.log")); @@ -34,6 +36,7 @@ protected LinkedList CreateTestFilesWithoutDate() { LinkedList createdFiles = new(); DirectoryInfo dInfo = Directory.CreateDirectory(TEST_DIR_NAME); + testDirectory = dInfo; createdFiles.AddLast(CreateFile(dInfo, "engine.log.6")); createdFiles.AddLast(CreateFile(dInfo, "engine.log.5")); createdFiles.AddLast(CreateFile(dInfo, "engine.log.4")); From a2da828d7a60fa8dfcaa8cf415647e4dda64abfb Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Fri, 11 Apr 2025 08:35:31 +0200 Subject: [PATCH 012/142] optimizations --- src/AutoColumnizer/AutoColumnizer.cs | 3 - src/CsvColumnizer/CsvColumn.cs | 13 +- src/CsvColumnizer/CsvColumnizer.cs | 64 +++---- src/CsvColumnizer/CsvColumnizerConfig.cs | 16 +- src/CsvColumnizer/CsvLogLine.cs | 13 +- src/DefaultPlugins/Eminus.cs | 47 ++--- src/DefaultPlugins/EminusConfig.cs | 10 +- src/DefaultPlugins/EminusConfigDlg.cs | 11 +- src/DefaultPlugins/ProcessLauncher.cs | 24 +-- .../FlashIconHighlighter.csproj | 4 +- src/FlashIconHighlighter/FlashIconPlugin.cs | 13 +- src/FlashIconHighlighter/Win32Stuff.cs | 9 +- src/GlassfishColumnizer/GlassFishLogLine.cs | 17 ++ .../GlassfishColumnizer.cs | 59 ++----- src/GlassfishColumnizer/XmlConfig.cs | 19 +++ src/JsonColumnizer/JsonColumn.cs | 11 ++ src/JsonColumnizer/JsonColumnizer.cs | 50 ++---- .../JsonCompactColumnizer.cs | 18 +- src/Log4jXmlColumnizer/Log4JLogLine.cs | 17 ++ src/Log4jXmlColumnizer/Log4jColumnEntry.cs | 19 +++ src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs | 160 +----------------- .../Log4jXmlColumnizerConfig.cs | 82 +++++++++ src/Log4jXmlColumnizer/XmlConfig.cs | 36 ++++ src/SftpFileSystemx64/ConfigDialog.cs | 5 + src/SftpFileSystemx64/CredentialCache.cs | 4 +- src/SftpFileSystemx64/FailedKeyDialog.cs | 5 + src/SftpFileSystemx64/LoginDialog.cs | 7 + .../PrivateKeyPasswordDialog.cs | 5 + src/SftpFileSystemx64/SftpFileSystem.cs | 24 ++- 29 files changed, 399 insertions(+), 366 deletions(-) create mode 100644 src/GlassfishColumnizer/GlassFishLogLine.cs create mode 100644 src/GlassfishColumnizer/XmlConfig.cs create mode 100644 src/JsonColumnizer/JsonColumn.cs create mode 100644 src/Log4jXmlColumnizer/Log4JLogLine.cs create mode 100644 src/Log4jXmlColumnizer/Log4jColumnEntry.cs create mode 100644 src/Log4jXmlColumnizer/Log4jXmlColumnizerConfig.cs create mode 100644 src/Log4jXmlColumnizer/XmlConfig.cs diff --git a/src/AutoColumnizer/AutoColumnizer.cs b/src/AutoColumnizer/AutoColumnizer.cs index d974c3b2..c699274c 100644 --- a/src/AutoColumnizer/AutoColumnizer.cs +++ b/src/AutoColumnizer/AutoColumnizer.cs @@ -1,9 +1,6 @@ using LogExpert; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace AutoColumnizer { diff --git a/src/CsvColumnizer/CsvColumn.cs b/src/CsvColumnizer/CsvColumn.cs index b2beb5ee..4b209a5c 100644 --- a/src/CsvColumnizer/CsvColumn.cs +++ b/src/CsvColumnizer/CsvColumn.cs @@ -1,19 +1,10 @@ namespace CsvColumnizer { - internal class CsvColumn + internal class CsvColumn(string name) { - #region cTor - - public CsvColumn(string name) - { - Name = name; - } - - #endregion - #region Properties - public string Name { get; } + public string Name { get; } = name; #endregion } diff --git a/src/CsvColumnizer/CsvColumnizer.cs b/src/CsvColumnizer/CsvColumnizer.cs index 12c70ff7..36d509ef 100644 --- a/src/CsvColumnizer/CsvColumnizer.cs +++ b/src/CsvColumnizer/CsvColumnizer.cs @@ -26,7 +26,7 @@ public class CsvColumnizer : ILogLineColumnizer, IInitColumnizer, IColumnizerCon private static readonly string _configFileName = "csvcolumnizer.json"; - private readonly IList _columnList = new List(); + private readonly IList _columnList = []; private CsvColumnizerConfig _config; private ILogLine _firstLine; @@ -47,14 +47,12 @@ public string PreProcessLine(string logLine, int lineNum, int realLineNum) if (_config.MinColumns > 0) { - using (CsvReader csv = new CsvReader(new StringReader(logLine), _config.ReaderConfiguration)) + using CsvReader csv = new(new StringReader(logLine), _config.ReaderConfiguration); + if (csv.Parser.Count < _config.MinColumns) { - if (csv.Parser.Count < _config.MinColumns) - { - // on invalid CSV don't hide the first line from LogExpert, since the file will be displayed in plain mode - _isValidCsv = false; - return logLine; - } + // on invalid CSV don't hide the first line from LogExpert, since the file will be displayed in plain mode + _isValidCsv = false; + return logLine; } } @@ -120,9 +118,11 @@ public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLin private static ColumnizedLogLine CreateColumnizedLogLine(ILogLine line) { - ColumnizedLogLine cLogLine = new ColumnizedLogLine(); - cLogLine.LogLine = line; - cLogLine.ColumnValues = new IColumn[] { new Column { FullValue = line.FullLine, Parent = cLogLine } }; + ColumnizedLogLine cLogLine = new() + { + LogLine = line + }; + cLogLine.ColumnValues = [new Column { FullValue = line.FullLine, Parent = cLogLine }]; return cLogLine; } @@ -194,16 +194,16 @@ public void DeSelected(ILogLineColumnizerCallback callback) public void Configure(ILogLineColumnizerCallback callback, string configDir) { string configPath = configDir + "\\" + _configFileName; - FileInfo fileInfo = new FileInfo(configPath); + FileInfo fileInfo = new(configPath); - CsvColumnizerConfigDlg dlg = new CsvColumnizerConfigDlg(_config); + CsvColumnizerConfigDlg dlg = new(_config); if (dlg.ShowDialog() == DialogResult.OK) { _config.VersionBuild = Assembly.GetExecutingAssembly().GetName().Version.Build; - using (StreamWriter sw = new StreamWriter(fileInfo.Create())) + using (StreamWriter sw = new(fileInfo.Create())) { - JsonSerializer serializer = new JsonSerializer(); + JsonSerializer serializer = new(); serializer.Serialize(sw, _config); } @@ -256,31 +256,31 @@ public Priority GetPriority(string fileName, IEnumerable samples) private IColumnizedLogLine SplitCsvLine(ILogLine line) { - ColumnizedLogLine cLogLine = new ColumnizedLogLine(); - cLogLine.LogLine = line; - - using (CsvReader csv = new CsvReader(new StringReader(line.FullLine), _config.ReaderConfiguration)) + ColumnizedLogLine cLogLine = new() { - csv.Read(); - csv.ReadHeader(); + LogLine = line + }; - //we only read line by line and not the whole file so it is always the header - string[] records = csv.HeaderRecord; + using CsvReader csv = new(new StringReader(line.FullLine), _config.ReaderConfiguration); + csv.Read(); + csv.ReadHeader(); - if (records != null) - { - List columns = new List(); + //we only read line by line and not the whole file so it is always the header + string[] records = csv.HeaderRecord; - foreach (string record in records) - { - columns.Add(new Column { FullValue = record, Parent = cLogLine }); - } + if (records != null) + { + List columns = []; - cLogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); + foreach (string record in records) + { + columns.Add(new Column { FullValue = record, Parent = cLogLine }); } - return cLogLine; + cLogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); } + + return cLogLine; } #endregion diff --git a/src/CsvColumnizer/CsvColumnizerConfig.cs b/src/CsvColumnizer/CsvColumnizerConfig.cs index b0ef0d5d..f9b04908 100644 --- a/src/CsvColumnizer/CsvColumnizerConfig.cs +++ b/src/CsvColumnizer/CsvColumnizerConfig.cs @@ -1,8 +1,10 @@ -using System; -using System.Globalization; -using CsvHelper.Configuration; +using CsvHelper.Configuration; + using Newtonsoft.Json; +using System; +using System.Globalization; + namespace CsvColumnizer { [Serializable] @@ -13,13 +15,13 @@ public class CsvColumnizerConfig public char CommentChar { get; set; } public string DelimiterChar { get; set; } - + public char EscapeChar { get; set; } - + public bool HasFieldNames { get; set; } - + public int MinColumns { get; set; } - + public char QuoteChar { get; set; } public int VersionBuild { get; set; } diff --git a/src/CsvColumnizer/CsvLogLine.cs b/src/CsvColumnizer/CsvLogLine.cs index f2d3917e..6fdef11d 100644 --- a/src/CsvColumnizer/CsvLogLine.cs +++ b/src/CsvColumnizer/CsvLogLine.cs @@ -2,23 +2,16 @@ namespace CsvColumnizer { - public class CsvLogLine : ILogLine + public class CsvLogLine(string fullLine, int lineNumber) : ILogLine { - public CsvLogLine(string fullLine, int lineNumber) - { - FullLine = fullLine; - LineNumber = lineNumber; - } - #region Properties - public string FullLine { get; set; } + public string FullLine { get; set; } = fullLine; - public int LineNumber { get; set; } + public int LineNumber { get; set; } = lineNumber; string ITextValue.Text => FullLine; #endregion } - } \ No newline at end of file diff --git a/src/DefaultPlugins/Eminus.cs b/src/DefaultPlugins/Eminus.cs index d062fd5a..e59f8586 100644 --- a/src/DefaultPlugins/Eminus.cs +++ b/src/DefaultPlugins/Eminus.cs @@ -1,12 +1,13 @@ -using System; +using Newtonsoft.Json; + +using System; using System.Collections.Generic; -using System.Xml; -using System.Windows.Forms; -using System.Net.Sockets; using System.IO; +using System.Net.Sockets; using System.Runtime.Serialization; -using Newtonsoft.Json; using System.Runtime.Versioning; +using System.Windows.Forms; +using System.Xml; [assembly: SupportedOSPlatform("windows")] namespace LogExpert @@ -26,10 +27,7 @@ public class Eminus : IContextMenuEntry, ILogExpertPluginConfigurator #region Properties - public string Text - { - get { return "eminus"; } - } + public string Text => "eminus"; #endregion @@ -49,7 +47,7 @@ private XmlDocument BuildParam(ILogLine line) pos += "created in ".Length; int endPos = temp.IndexOf(dot, pos); - + if (endPos == -1) { return null; @@ -57,7 +55,7 @@ private XmlDocument BuildParam(ILogLine line) string className = temp[pos..endPos]; pos = temp.IndexOf(doubleDot, pos); - + if (pos == -1) { return null; @@ -76,7 +74,7 @@ private XmlDocument BuildParam(ILogLine line) int pos = str.IndexOf("at ") + 3; str = str[pos..]; // remove 'at ' int idx = str.IndexOfAny(['(', '$', '<']); - + if (idx != -1) { if (str[idx] == '$') @@ -94,19 +92,19 @@ private XmlDocument BuildParam(ILogLine line) } idx = str.LastIndexOf(':'); - + if (idx == -1) { return null; } pos = str.IndexOf(')', idx); - + if (pos == -1) { return null; } - + lineNum = str.Substring(idx + 1, pos - idx - 1); } /* @@ -230,9 +228,9 @@ public void SaveConfig(string configDir) FileInfo fileInfo = new(configDir + Path.DirectorySeparatorChar + CFG_FILE_NAME); dlg?.ApplyChanges(); - + _config = tmpConfig.Clone(); - + using StreamWriter sw = new(fileInfo.Create()); JsonSerializer serializer = new(); serializer.Serialize(sw, _config); @@ -245,8 +243,10 @@ public bool HasEmbeddedForm() public void ShowConfigForm(object panel) { - dlg = new EminusConfigDlg(tmpConfig); - dlg.Parent = (Panel)panel; + dlg = new EminusConfigDlg(tmpConfig) + { + Parent = (Panel)panel + }; dlg.Show(); } @@ -257,9 +257,12 @@ public void ShowConfigForm(object panel) /// public void ShowConfigDialog(object owner) { - dlg = new EminusConfigDlg(tmpConfig); - dlg.TopLevel = true; - dlg.Owner = (Form)owner; + dlg = new EminusConfigDlg(tmpConfig) + { + TopLevel = true, + Owner = (Form)owner + }; + dlg.ShowDialog(); dlg.ApplyChanges(); } diff --git a/src/DefaultPlugins/EminusConfig.cs b/src/DefaultPlugins/EminusConfig.cs index 5bfa22f6..f8699a53 100644 --- a/src/DefaultPlugins/EminusConfig.cs +++ b/src/DefaultPlugins/EminusConfig.cs @@ -17,10 +17,12 @@ public class EminusConfig public EminusConfig Clone() { - EminusConfig config = new(); - config.host = host; - config.port = port; - config.password = password; + EminusConfig config = new() + { + host = host, + port = port, + password = password + }; return config; } diff --git a/src/DefaultPlugins/EminusConfigDlg.cs b/src/DefaultPlugins/EminusConfigDlg.cs index d1464a96..672b7fa6 100644 --- a/src/DefaultPlugins/EminusConfigDlg.cs +++ b/src/DefaultPlugins/EminusConfigDlg.cs @@ -1,4 +1,5 @@ using System; +using System.Drawing; using System.Windows.Forms; namespace LogExpert @@ -13,13 +14,21 @@ public partial class EminusConfigDlg : Form public EminusConfigDlg(EminusConfig config) { + SuspendLayout(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + InitializeComponent(); + TopLevel = false; Config = config; hostTextBox.Text = config.host; - portTextBox.Text = "" + config.port; + portTextBox.Text = string.Empty + config.port; passwordTextBox.Text = config.password; + + ResumeLayout(); } #endregion diff --git a/src/DefaultPlugins/ProcessLauncher.cs b/src/DefaultPlugins/ProcessLauncher.cs index 0d916765..29e73229 100644 --- a/src/DefaultPlugins/ProcessLauncher.cs +++ b/src/DefaultPlugins/ProcessLauncher.cs @@ -1,5 +1,4 @@ -using System; -using System.Diagnostics; +using System.Diagnostics; namespace LogExpert { @@ -19,34 +18,37 @@ public void Execute(string keyword, string param, ILogExpertCallback callback, I { int start = 0; int end = 0; - if (param.StartsWith("\"")) + + if (param.StartsWith('"')) { start = 1; - end = param.IndexOf("\"", start, StringComparison.Ordinal); + end = param.IndexOf('"', start); } else { - end = param.IndexOf(" ", StringComparison.Ordinal); + end = param.IndexOf(' '); } + if (end == -1) { end = param.Length; } - string procName = param.Substring(start, end - start); - - lock(_callbackLock) + + string procName = param[start..end]; + + lock (_callbackLock) { - string parameters = param.Substring(end).Trim(); + string parameters = param[end..].Trim(); parameters = parameters.Replace("%F", callback.GetFileName()); parameters = parameters.Replace("%K", keyword); - + int lineNumber = callback.GetLineNum(); //Line Numbers start at 0, but are displayed (+1) string logline = callback.GetLogLine(lineNumber).FullLine; parameters = parameters.Replace("%L", string.Empty + lineNumber); parameters = parameters.Replace("%T", callback.GetTabTitle()); parameters = parameters.Replace("%C", logline); - Process explorer = new Process(); + Process explorer = new(); explorer.StartInfo.FileName = procName; explorer.StartInfo.Arguments = parameters; explorer.StartInfo.UseShellExecute = false; diff --git a/src/FlashIconHighlighter/FlashIconHighlighter.csproj b/src/FlashIconHighlighter/FlashIconHighlighter.csproj index cc54b3b7..f86abe7a 100644 --- a/src/FlashIconHighlighter/FlashIconHighlighter.csproj +++ b/src/FlashIconHighlighter/FlashIconHighlighter.csproj @@ -35,5 +35,7 @@ Key.snk - + + true + diff --git a/src/FlashIconHighlighter/FlashIconPlugin.cs b/src/FlashIconHighlighter/FlashIconPlugin.cs index 9572b4d9..3e4b0341 100644 --- a/src/FlashIconHighlighter/FlashIconPlugin.cs +++ b/src/FlashIconHighlighter/FlashIconPlugin.cs @@ -35,12 +35,13 @@ public void Execute(string keyword, string param, ILogExpertCallback callback, I private void FlashWindow(Form form) { - FLASHWINFO fw = new FLASHWINFO(); - - fw.cbSize = Convert.ToUInt32(Marshal.SizeOf(typeof(FLASHWINFO))); - fw.hwnd = form.Handle; - fw.dwFlags = 14; - fw.uCount = 0; + FLASHWINFO fw = new() + { + cbSize = Convert.ToUInt32(Marshal.SizeOf(typeof(FLASHWINFO))), + hwnd = form.Handle, + dwFlags = 14, + uCount = 0 + }; Win32Stuff.FlashWindowEx(ref fw); } diff --git a/src/FlashIconHighlighter/Win32Stuff.cs b/src/FlashIconHighlighter/Win32Stuff.cs index e807a59b..fbb008f3 100644 --- a/src/FlashIconHighlighter/Win32Stuff.cs +++ b/src/FlashIconHighlighter/Win32Stuff.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Runtime.InteropServices; namespace FlashIconHighlighter @@ -19,13 +17,12 @@ public struct FLASHWINFO public int dwTimeout; } - - public class Win32Stuff + public partial class Win32Stuff { #region Public methods - [DllImport("user32.dll")] - public static extern int FlashWindowEx(ref FLASHWINFO pwfi); + [LibraryImport("user32.dll")] + public static partial int FlashWindowEx(ref FLASHWINFO pwfi); #endregion } diff --git a/src/GlassfishColumnizer/GlassFishLogLine.cs b/src/GlassfishColumnizer/GlassFishLogLine.cs new file mode 100644 index 00000000..4d12c799 --- /dev/null +++ b/src/GlassfishColumnizer/GlassFishLogLine.cs @@ -0,0 +1,17 @@ +using LogExpert; + +namespace GlassfishColumnizer +{ + internal class GlassFishLogLine : ILogLine + { + #region Properties + + public string FullLine { get; set; } + + public int LineNumber { get; set; } + + string ITextValue.Text => FullLine; + + #endregion + } +} \ No newline at end of file diff --git a/src/GlassfishColumnizer/GlassfishColumnizer.cs b/src/GlassfishColumnizer/GlassfishColumnizer.cs index a498e8d5..f5f93951 100644 --- a/src/GlassfishColumnizer/GlassfishColumnizer.cs +++ b/src/GlassfishColumnizer/GlassfishColumnizer.cs @@ -1,27 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Text; -using LogExpert; +using LogExpert; + +using System; using System.Globalization; using System.Linq; namespace GlassfishColumnizer { - internal class XmlConfig : IXmlLogConfiguration - { - #region Properties - - public string XmlStartTag { get; } = "[#|"; - - public string XmlEndTag { get; } = "|#]"; - - public string Stylesheet { get; } = null; - - public string[] Namespace => null; - - #endregion - } - internal class GlassfishColumnizer : ILogLineXmlColumnizer { #region Fields @@ -30,10 +14,10 @@ internal class GlassfishColumnizer : ILogLineXmlColumnizer protected const string DATETIME_FORMAT = "yyyy-MM-ddTHH:mm:ss.fffzzzz"; protected const string DATETIME_FORMAT_OUT = "yyyy-MM-dd HH:mm:ss.fff"; - private static readonly XmlConfig xmlConfig = new XmlConfig(); + private static readonly XmlConfig xmlConfig = new(); private readonly char separatorChar = '|'; - private readonly char[] trimChars = new char[] {'|'}; - protected CultureInfo cultureInfo = new CultureInfo("en-US"); + private readonly char[] trimChars = ['|']; + protected CultureInfo cultureInfo = new("en-US"); protected int timeOffset = 0; #endregion @@ -55,7 +39,7 @@ public IXmlLogConfiguration GetXmlLogConfiguration() public ILogLine GetLineTextForClipboard(ILogLine logLine, ILogLineColumnizerCallback callback) { - GlassFishLogLine line = new GlassFishLogLine + GlassFishLogLine line = new() { FullLine = logLine.FullLine.Replace(separatorChar, '|'), LineNumber = logLine.LineNumber @@ -81,12 +65,12 @@ public int GetColumnCount() public string[] GetColumnNames() { - return new string[] {"Date/Time", "Message"}; + return ["Date/Time", "Message"]; } public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) { - ColumnizedLogLine cLogLine = new ColumnizedLogLine(); + ColumnizedLogLine cLogLine = new(); cLogLine.LogLine = line; string temp = line.FullLine; @@ -97,12 +81,12 @@ public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLin // delete '[#|' and '|#]' if (temp.StartsWith("[#|")) { - temp = temp.Substring(3); + temp = temp[3..]; } if (temp.EndsWith("|#]")) { - temp = temp.Substring(0, temp.Length - 3); + temp = temp[..^3]; } // If the line is too short (i.e. does not follow the format for this columnizer) return the whole line content @@ -171,12 +155,12 @@ public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine logLi // delete '[#|' and '|#]' if (temp.StartsWith("[#|")) { - temp = temp.Substring(3); + temp = temp[3..]; } if (temp.EndsWith("|#]")) { - temp = temp.Substring(0, temp.Length - 3); + temp = temp[..^3]; } if (temp.Length < 28) @@ -190,7 +174,7 @@ public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine logLi return DateTime.MinValue; } - string value = temp.Substring(0, endIndex); + string value = temp[..endIndex]; try { @@ -218,7 +202,7 @@ public void PushValue(ILogLineColumnizerCallback callback, int column, string va DateTime oldDateTime = DateTime.ParseExact(oldValue, DATETIME_FORMAT_OUT, cultureInfo); long mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; long mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; - timeOffset = (int) (mSecsNew - mSecsOld); + timeOffset = (int)(mSecsNew - mSecsOld); } catch (FormatException) { @@ -227,18 +211,5 @@ public void PushValue(ILogLineColumnizerCallback callback, int column, string va } #endregion - - private class GlassFishLogLine : ILogLine - { - #region Properties - - public string FullLine { get; set; } - - public int LineNumber { get; set; } - - string ITextValue.Text => FullLine; - - #endregion - } } } \ No newline at end of file diff --git a/src/GlassfishColumnizer/XmlConfig.cs b/src/GlassfishColumnizer/XmlConfig.cs new file mode 100644 index 00000000..44ecec47 --- /dev/null +++ b/src/GlassfishColumnizer/XmlConfig.cs @@ -0,0 +1,19 @@ +using LogExpert; + +namespace GlassfishColumnizer +{ + internal class XmlConfig : IXmlLogConfiguration + { + #region Properties + + public string XmlStartTag { get; } = "[#|"; + + public string XmlEndTag { get; } = "|#]"; + + public string Stylesheet { get; } = null; + + public string[] Namespace => null; + + #endregion + } +} \ No newline at end of file diff --git a/src/JsonColumnizer/JsonColumn.cs b/src/JsonColumnizer/JsonColumn.cs new file mode 100644 index 00000000..5279533a --- /dev/null +++ b/src/JsonColumnizer/JsonColumn.cs @@ -0,0 +1,11 @@ +namespace JsonColumnizer +{ + public class JsonColumn(string name) + { + #region Properties + + public string Name { get; } = name; + + #endregion + } +} \ No newline at end of file diff --git a/src/JsonColumnizer/JsonColumnizer.cs b/src/JsonColumnizer/JsonColumnizer.cs index 712377fd..c3954844 100644 --- a/src/JsonColumnizer/JsonColumnizer.cs +++ b/src/JsonColumnizer/JsonColumnizer.cs @@ -1,30 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using LogExpert; +using LogExpert; + using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; + namespace JsonColumnizer { - public class JsonColumn - { - #region cTor - - public JsonColumn(string name) - { - Name = name; - } - - #endregion - - #region Properties - - public string Name { get; } - - #endregion - } - /// /// This Columnizer can parse JSON files. /// @@ -34,13 +18,13 @@ public class JsonColumnizer : ILogLineColumnizer, IInitColumnizer, IColumnizerPr private static readonly JsonColumn _initialColumn = new JsonColumn("Text"); - private readonly IList _columnList = new List(new[] {InitialColumn}); + private readonly IList _columnList = new List([InitialColumn]); #endregion #region Properties - public HashSet ColumnSet { get; set; } = new HashSet(); + public HashSet ColumnSet { get; set; } = []; protected IList ColumnList => _columnList; @@ -90,7 +74,7 @@ public virtual void Selected(ILogLineColumnizerCallback callback) public virtual void DeSelected(ILogLineColumnizerCallback callback) { - // nothing to do + // nothing to do } public virtual string GetName() @@ -129,13 +113,13 @@ public virtual IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, return SplitJsonLine(line, json); } - var cLogLine = new ColumnizedLogLine {LogLine = line}; + var cLogLine = new ColumnizedLogLine { LogLine = line }; var columns = Column.CreateColumns(ColumnList.Count, cLogLine); columns.Last().FullValue = line.FullLine; - cLogLine.ColumnValues = columns.Select(a => (IColumn) a).ToArray(); + cLogLine.ColumnValues = columns.Select(a => (IColumn)a).ToArray(); return cLogLine; } @@ -200,9 +184,9 @@ public class ColumnWithName : Column // protected virtual IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) { - var cLogLine = new ColumnizedLogLine {LogLine = line}; + var cLogLine = new ColumnizedLogLine { LogLine = line }; - var columns = json.Properties().Select(property => new ColumnWithName {FullValue = property.Value.ToString(), ColumneName = property.Name.ToString(), Parent = cLogLine}).ToList(); + var columns = json.Properties().Select(property => new ColumnWithName { FullValue = property.Value.ToString(), ColumneName = property.Name.ToString(), Parent = cLogLine }).ToList(); foreach (var jsonColumn in columns) { @@ -223,21 +207,21 @@ protected virtual IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) // Always rearrage the order of all json fields within a line to follow the sequence of columnNameList. // This will make sure the log line displayed correct even the order of json fields changed. // - List returnColumns = new List(); + List returnColumns = []; foreach (var column in ColumnList) { var existingColumn = columns.Find(x => x.ColumneName == column.Name); if (existingColumn != null) { - returnColumns.Add(new Column() {FullValue = existingColumn.FullValue, Parent = cLogLine}); + returnColumns.Add(new Column() { FullValue = existingColumn.FullValue, Parent = cLogLine }); continue; } // Fields that is missing in current line should be shown as empty. - returnColumns.Add(new Column() {FullValue = "", Parent = cLogLine}); + returnColumns.Add(new Column() { FullValue = "", Parent = cLogLine }); } - cLogLine.ColumnValues = returnColumns.ToArray(); + cLogLine.ColumnValues = [.. returnColumns]; return cLogLine; } diff --git a/src/JsonCompactColumnizer/JsonCompactColumnizer.cs b/src/JsonCompactColumnizer/JsonCompactColumnizer.cs index 3630087c..65be9131 100644 --- a/src/JsonCompactColumnizer/JsonCompactColumnizer.cs +++ b/src/JsonCompactColumnizer/JsonCompactColumnizer.cs @@ -1,5 +1,7 @@ using LogExpert; + using Newtonsoft.Json.Linq; + using System; using System.Collections.Generic; using System.Linq; @@ -42,7 +44,7 @@ public override Priority GetPriority(string fileName, IEnumerable samp result = Priority.WellSupport; } - if (samples != null && samples.Count() > 0) + if (samples != null && samples.Any()) { try { @@ -70,7 +72,7 @@ public override Priority GetPriority(string fileName, IEnumerable samp #region Private Methods - protected Dictionary _tagDict = new Dictionary() + protected Dictionary _tagDict = new() { {"@t", "Timestamp"}, {"@l", "Level"}, @@ -83,10 +85,10 @@ public override Priority GetPriority(string fileName, IEnumerable samp protected override IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) { - List returnColumns = new List(); - var cLogLine = new ColumnizedLogLine {LogLine = line}; + List returnColumns = new(); + var cLogLine = new ColumnizedLogLine { LogLine = line }; - var columns = json.Properties().Select(property => new ColumnWithName {FullValue = property.Value.ToString(), ColumneName = property.Name.ToString(), Parent = cLogLine}).ToList(); + var columns = json.Properties().Select(property => new ColumnWithName { FullValue = property.Value.ToString(), ColumneName = property.Name.ToString(), Parent = cLogLine }).ToList(); // // Always rearrage the order of all json fields within a line to follow the sequence of columnNameList. @@ -94,18 +96,18 @@ protected override IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) // foreach (var column in _tagDict.Keys) { - if (column.StartsWith("@")) + if (column.StartsWith('@')) { var existingColumn = columns.Find(x => x.ColumneName == column); if (existingColumn != null) { - returnColumns.Add(new Column() {FullValue = existingColumn.FullValue, Parent = cLogLine}); + returnColumns.Add(new Column() { FullValue = existingColumn.FullValue, Parent = cLogLine }); continue; } // Fields that is missing in current line should be shown as empty. - returnColumns.Add(new Column() {FullValue = "", Parent = cLogLine}); + returnColumns.Add(new Column() { FullValue = "", Parent = cLogLine }); } } diff --git a/src/Log4jXmlColumnizer/Log4JLogLine.cs b/src/Log4jXmlColumnizer/Log4JLogLine.cs new file mode 100644 index 00000000..d6b09125 --- /dev/null +++ b/src/Log4jXmlColumnizer/Log4JLogLine.cs @@ -0,0 +1,17 @@ +using LogExpert; + +namespace Log4jXmlColumnizer +{ + internal class Log4JLogLine : ILogLine + { + #region Properties + + public string FullLine { get; set; } + + public int LineNumber { get; set; } + + string ITextValue.Text => FullLine; + + #endregion + } +} \ No newline at end of file diff --git a/src/Log4jXmlColumnizer/Log4jColumnEntry.cs b/src/Log4jXmlColumnizer/Log4jColumnEntry.cs new file mode 100644 index 00000000..037c8b84 --- /dev/null +++ b/src/Log4jXmlColumnizer/Log4jColumnEntry.cs @@ -0,0 +1,19 @@ +using System; + +namespace Log4jXmlColumnizer +{ + /// + /// Helper class for configuration of the colums. + /// + [Serializable] + public class Log4jColumnEntry(string name, int index, int maxLen) + { + public int ColumnIndex { get; set; } = index; + + public string ColumnName { get; set; } = name; + + public int MaxLen { get; set; } = maxLen; + + public bool Visible { get; set; } + } +} \ No newline at end of file diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs index 9ed530b8..a221c39b 100644 --- a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs @@ -14,146 +14,6 @@ [assembly: SupportedOSPlatform("windows")] namespace Log4jXmlColumnizer { - /// - /// XMl configuration for parsing log4j XML files. The XSL will transform every block of log entries - /// into text lines. The fields in the text lines are separated by a special character (0xFFFD). - /// The special character will be used in the Split() function of the columnizer to split the line - /// into columns. - /// - internal class XmlConfig : IXmlLogConfiguration - { - #region Properties - - public string XmlStartTag { get; } = "" + - "" + - "" + - "" + - "" + - ""; - - public string[] Namespace - { - get { return ["log4j", "http://jakarta.apache.org/log4j"]; } - } - - #endregion - } - - - /// - /// Helper class for configuration of the colums. - /// - [Serializable] - public class Log4jColumnEntry - { - #region Fields - - public int columnIndex; - - public string columnName; - public int maxLen; - public bool visible; - - #endregion - - #region cTor - - public Log4jColumnEntry(string name, int index, int maxLen) - { - columnName = name; - columnIndex = index; - visible = true; - this.maxLen = maxLen; - } - - #endregion - } - - [Serializable] - public class Log4jXmlColumnizerConfig - { - #region Fields - - public List columnList = new(); - public bool localTimestamps = true; - - #endregion - - #region cTor - - public Log4jXmlColumnizerConfig(string[] columnNames) - { - FillDefaults(columnNames); - } - - #endregion - - #region Properties - - /// - /// Returns the column count. Because the user can deactivate columns in the config - /// the actual column count may be smaller than the number of available columns. - /// - public int ActiveColumnCount - { - get - { - int count = 0; - foreach (Log4jColumnEntry entry in columnList) - { - if (entry.visible) - { - count++; - } - } - return count; - } - } - - /// - /// Returns the names of all active columns. - /// - public string[] ActiveColumnNames - { - get - { - string[] names = new string[ActiveColumnCount]; - int index = 0; - foreach (Log4jColumnEntry entry in columnList) - { - if (entry.visible) - { - names[index++] = entry.columnName; - } - } - return names; - } - } - - #endregion - - #region Public methods - - public void FillDefaults(string[] columnNames) - { - columnList.Clear(); - for (int i = 0; i < columnNames.Length; ++i) - { - columnList.Add(new Log4jColumnEntry(columnNames[i], i, 0)); - } - } - - #endregion - } - - public class Log4jXmlColumnizer : ILogLineXmlColumnizer, IColumnizerConfigurator, IColumnizerPriority { #region Fields @@ -418,7 +278,6 @@ public Priority GetPriority(string fileName, IEnumerable samples) private string[] GetAllColumnNames() => ["Timestamp", "Level", "Logger", "Thread", "Class", "Method", "File", "Line", "Message"]; - /// /// Returns only the columns which are "active". The order of the columns depends on the column order in the config /// @@ -430,14 +289,14 @@ private Column[] MapColumns(Column[] cols) int index = 0; foreach (Log4jColumnEntry entry in _config.columnList) { - if (entry.visible) + if (entry.Visible) { Column column = cols[index]; output.Add(column); - if (entry.maxLen > 0 && column.FullValue.Length > entry.maxLen) + if (entry.MaxLen > 0 && column.FullValue.Length > entry.MaxLen) { - column.FullValue = column.FullValue.Substring(column.FullValue.Length - entry.maxLen); + column.FullValue = column.FullValue.Substring(column.FullValue.Length - entry.MaxLen); } } index++; @@ -448,18 +307,5 @@ private Column[] MapColumns(Column[] cols) } #endregion - - private class Log4JLogLine : ILogLine - { - #region Properties - - public string FullLine { get; set; } - - public int LineNumber { get; set; } - - string ITextValue.Text => FullLine; - - #endregion - } } } \ No newline at end of file diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfig.cs b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfig.cs new file mode 100644 index 00000000..7954f47c --- /dev/null +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfig.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; + +namespace Log4jXmlColumnizer +{ + [Serializable] + public class Log4jXmlColumnizerConfig + { + #region Fields + + public List columnList = []; + public bool localTimestamps = true; + + #endregion + + #region cTor + + public Log4jXmlColumnizerConfig(string[] columnNames) + { + FillDefaults(columnNames); + } + + #endregion + + #region Properties + + /// + /// Returns the column count. Because the user can deactivate columns in the config + /// the actual column count may be smaller than the number of available columns. + /// + public int ActiveColumnCount + { + get + { + int count = 0; + foreach (Log4jColumnEntry entry in columnList) + { + if (entry.Visible) + { + count++; + } + } + return count; + } + } + + /// + /// Returns the names of all active columns. + /// + public string[] ActiveColumnNames + { + get + { + string[] names = new string[ActiveColumnCount]; + int index = 0; + foreach (Log4jColumnEntry entry in columnList) + { + if (entry.Visible) + { + names[index++] = entry.ColumnName; + } + } + return names; + } + } + + #endregion + + #region Public methods + + public void FillDefaults(string[] columnNames) + { + columnList.Clear(); + for (int i = 0; i < columnNames.Length; ++i) + { + columnList.Add(new Log4jColumnEntry(columnNames[i], i, 0)); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/src/Log4jXmlColumnizer/XmlConfig.cs b/src/Log4jXmlColumnizer/XmlConfig.cs new file mode 100644 index 00000000..cd84e535 --- /dev/null +++ b/src/Log4jXmlColumnizer/XmlConfig.cs @@ -0,0 +1,36 @@ +using LogExpert; + +namespace Log4jXmlColumnizer +{ + /// + /// XMl configuration for parsing log4j XML files. The XSL will transform every block of log entries + /// into text lines. The fields in the text lines are separated by a special character (0xFFFD). + /// The special character will be used in the Split() function of the columnizer to split the line + /// into columns. + /// + internal class XmlConfig : IXmlLogConfiguration + { + #region Properties + + public string XmlStartTag { get; } = "" + + "" + + "" + + "" + + "" + + ""; + + public string[] Namespace + { + get { return ["log4j", "http://jakarta.apache.org/log4j"]; } + } + + #endregion + } +} \ No newline at end of file diff --git a/src/SftpFileSystemx64/ConfigDialog.cs b/src/SftpFileSystemx64/ConfigDialog.cs index 78f7f5cc..f7f963db 100644 --- a/src/SftpFileSystemx64/ConfigDialog.cs +++ b/src/SftpFileSystemx64/ConfigDialog.cs @@ -1,4 +1,5 @@ using System; +using System.Drawing; using System.Runtime.Versioning; using System.Windows.Forms; @@ -11,6 +12,9 @@ public partial class ConfigDialog : Form public ConfigDialog(ConfigData configData) { + SuspendLayout(); + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; InitializeComponent(); TopLevel = false; ConfigData = configData; @@ -18,6 +22,7 @@ public ConfigDialog(ConfigData configData) radioBtnPuttyKey.Checked = ConfigData.KeyType == KeyType.Putty; radioBtnSSHKey.Checked = ConfigData.KeyType == KeyType.Ssh; lblFile.Text = ConfigData.KeyFile; + ResumeLayout(); } #endregion diff --git a/src/SftpFileSystemx64/CredentialCache.cs b/src/SftpFileSystemx64/CredentialCache.cs index 43043170..5838be12 100644 --- a/src/SftpFileSystemx64/CredentialCache.cs +++ b/src/SftpFileSystemx64/CredentialCache.cs @@ -6,7 +6,7 @@ internal class CredentialCache { #region Private Fields - private readonly IList _credList = new List(); + private readonly IList _credList = []; #endregion @@ -25,7 +25,7 @@ private void RemoveCredentials(string host, string user) internal IList GetUsersForHost(string host) { - IList result = new List(); + IList result = []; foreach (Credentials cred in _credList) { diff --git a/src/SftpFileSystemx64/FailedKeyDialog.cs b/src/SftpFileSystemx64/FailedKeyDialog.cs index cffb91e7..6a728c3e 100644 --- a/src/SftpFileSystemx64/FailedKeyDialog.cs +++ b/src/SftpFileSystemx64/FailedKeyDialog.cs @@ -1,4 +1,5 @@ using System; +using System.Drawing; using System.Windows.Forms; namespace SftpFileSystem @@ -9,7 +10,11 @@ public partial class FailedKeyDialog : Form public FailedKeyDialog() { + SuspendLayout(); + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; InitializeComponent(); + ResumeLayout(); } #endregion diff --git a/src/SftpFileSystemx64/LoginDialog.cs b/src/SftpFileSystemx64/LoginDialog.cs index ef911558..936d0c41 100644 --- a/src/SftpFileSystemx64/LoginDialog.cs +++ b/src/SftpFileSystemx64/LoginDialog.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Windows.Forms; namespace SftpFileSystem @@ -16,6 +17,10 @@ public partial class LoginDialog : Form public LoginDialog(string host, IList userNames, bool hidePasswordField) { + SuspendLayout(); + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + InitializeComponent(); serverNameLabel.Text = host; if (userNames != null) @@ -34,6 +39,8 @@ public LoginDialog(string host, IList userNames, bool hidePasswordField) txtBoxPassword.Enabled = false; lblPassword.Enabled = false; } + + ResumeLayout(); } #endregion diff --git a/src/SftpFileSystemx64/PrivateKeyPasswordDialog.cs b/src/SftpFileSystemx64/PrivateKeyPasswordDialog.cs index 59ea84d8..6184f6ab 100644 --- a/src/SftpFileSystemx64/PrivateKeyPasswordDialog.cs +++ b/src/SftpFileSystemx64/PrivateKeyPasswordDialog.cs @@ -1,4 +1,5 @@ using System; +using System.Drawing; using System.Windows.Forms; namespace SftpFileSystem @@ -9,7 +10,11 @@ public partial class PrivateKeyPasswordDialog : Form public PrivateKeyPasswordDialog() { + SuspendLayout(); + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; InitializeComponent(); + ResumeLayout(); } #endregion diff --git a/src/SftpFileSystemx64/SftpFileSystem.cs b/src/SftpFileSystemx64/SftpFileSystem.cs index e53c0e17..fbefdff0 100644 --- a/src/SftpFileSystemx64/SftpFileSystem.cs +++ b/src/SftpFileSystemx64/SftpFileSystem.cs @@ -1,10 +1,12 @@ -using System; +using LogExpert; + +using Renci.SshNet; + +using System; using System.Collections.Generic; using System.IO; using System.Windows.Forms; using System.Xml.Serialization; -using LogExpert; -using Renci.SshNet; namespace SftpFileSystem { @@ -142,8 +144,11 @@ public void ShowConfigDialog(object owner) public void ShowConfigForm(object parentPanel) { - _configDialog = new ConfigDialog(ConfigData); - _configDialog.Parent = (Panel)parentPanel; + _configDialog = new ConfigDialog(ConfigData) + { + Parent = (Panel)parentPanel + }; + _configDialog.Show(); } @@ -169,7 +174,7 @@ public PrivateKeyFile PrivateKeyFile internal Credentials GetCredentials(Uri uri, bool cacheAllowed, bool hidePasswordField) { - // Synchronized access to the GetCredentials() method prevents multiple login dialogs when loading multiple files at once + // Synchronized access to the GetCredentials() method prevents multiple login dialogs when loading multiple files at once // (e.g. on startup). So the user only needs to enter credentials once for the same host. lock (this) { @@ -209,8 +214,11 @@ internal Credentials GetCredentials(Uri uri, bool cacheAllowed, bool hidePasswor if (userName == null || password == null) { - LoginDialog dlg = new(uri.Host, usersForHost, hidePasswordField); - dlg.Username = userName; + LoginDialog dlg = new(uri.Host, usersForHost, hidePasswordField) + { + Username = userName + }; + if (DialogResult.OK == dlg.ShowDialog()) { password = dlg.Password; From 83e40ac75af577f97e9c4cea963d6af6e5efdf62 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sat, 12 Apr 2025 12:12:50 +0200 Subject: [PATCH 013/142] added used components to the about box --- src/CsvColumnizer/CsvColumnizer.cs | 1 + .../Log4jXmlColumnizerConfigDlg.cs | 12 +- src/LogExpert.sln | 1 + .../LogTabWindow/LogTabWindowEventHandlers.cs | 6 +- .../Controls/LogWindow/LogWindowsPublic.cs | 39 +-- src/LogExpert/Dialogs/SettingsDialog.cs | 1 + .../Classes/Bookmark/BookmarkExporter.cs | 67 +++-- src/Logexpert.Core/Classes/CmdLine.cs | 14 +- src/Logexpert.Core/Classes/UsedComponents.cs | 20 ++ .../Logexpert.Resources.csproj | 7 + src/Logexpert.UI/Dialogs/AboutBox.Designer.cs | 64 ++--- src/Logexpert.UI/Dialogs/AboutBox.cs | 23 +- .../Dialogs/ChooseIconDlg.Designer.cs | 248 ++++++++--------- .../Dialogs/ChooseIconDlg.cs | 237 ++++++++-------- .../Dialogs/ChooseIconDlg.resx | 260 +++++++++--------- .../Dialogs/OpenUriDialog.Designer.cs | 242 ++++++++-------- .../Dialogs/OpenUriDialog.cs | 139 +++++----- .../Dialogs/OpenUriDialog.resx | 260 +++++++++--------- src/Logexpert.UI/LogExpert.UI.csproj | 7 + src/Solution Items/usedComponents.json | Bin 0 -> 19266 bytes src/usedPackages.json | Bin 0 -> 19146 bytes 21 files changed, 852 insertions(+), 796 deletions(-) create mode 100644 src/Logexpert.Core/Classes/UsedComponents.cs rename src/{LogExpert => Logexpert.UI}/Dialogs/ChooseIconDlg.Designer.cs (97%) rename src/{LogExpert => Logexpert.UI}/Dialogs/ChooseIconDlg.cs (85%) rename src/{LogExpert => Logexpert.UI}/Dialogs/ChooseIconDlg.resx (98%) rename src/{LogExpert => Logexpert.UI}/Dialogs/OpenUriDialog.Designer.cs (96%) rename src/{LogExpert => Logexpert.UI}/Dialogs/OpenUriDialog.cs (84%) rename src/{LogExpert => Logexpert.UI}/Dialogs/OpenUriDialog.resx (98%) create mode 100644 src/Solution Items/usedComponents.json create mode 100644 src/usedPackages.json diff --git a/src/CsvColumnizer/CsvColumnizer.cs b/src/CsvColumnizer/CsvColumnizer.cs index 36d509ef..3f5491bc 100644 --- a/src/CsvColumnizer/CsvColumnizer.cs +++ b/src/CsvColumnizer/CsvColumnizer.cs @@ -197,6 +197,7 @@ public void Configure(ILogLineColumnizerCallback callback, string configDir) FileInfo fileInfo = new(configPath); CsvColumnizerConfigDlg dlg = new(_config); + if (dlg.ShowDialog() == DialogResult.OK) { _config.VersionBuild = Assembly.GetExecutingAssembly().GetName().Version.Build; diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs index ac08077b..5ce046d7 100644 --- a/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs @@ -45,9 +45,9 @@ private void FillListBox() row.Cells.Add(new DataGridViewCheckBoxCell()); row.Cells.Add(new DataGridViewTextBoxCell()); row.Cells.Add(new DataGridViewTextBoxCell()); - row.Cells[0].Value = entry.visible; - row.Cells[1].Value = entry.columnName; - row.Cells[2].Value = entry.maxLen > 0 ? "" + entry.maxLen : ""; + row.Cells[0].Value = entry.Visible; + row.Cells[1].Value = entry.ColumnName; + row.Cells[2].Value = entry.MaxLen > 0 ? "" + entry.MaxLen : ""; columnGridView.Rows.Add(row); } } @@ -64,16 +64,16 @@ private void OkButton_Click(object sender, EventArgs e) // } for (int i = 0; i < columnGridView.Rows.Count; ++i) { - _config.columnList[i].visible = (bool)columnGridView.Rows[i].Cells[0].Value; + _config.columnList[i].Visible = (bool)columnGridView.Rows[i].Cells[0].Value; string sLen = (string)columnGridView.Rows[i].Cells[2].Value; if (int.TryParse(sLen, out int len)) { - _config.columnList[i].maxLen = len; + _config.columnList[i].MaxLen = len; } else { - _config.columnList[i].maxLen = 0; + _config.columnList[i].MaxLen = 0; } } _config.localTimestamps = localTimeCheckBox.Checked; diff --git a/src/LogExpert.sln b/src/LogExpert.sln index e27297e1..f8d00794 100644 --- a/src/LogExpert.sln +++ b/src/LogExpert.sln @@ -24,6 +24,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DE6375A4-B4C4-4620-8FFB-B9D5A4E21144}" ProjectSection(SolutionItems) = preProject Solution Items\AssemblyVersion.cs = Solution Items\AssemblyVersion.cs + Solution Items\usedComponents.json = Solution Items\usedComponents.json EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonColumnizer", "JsonColumnizer\JsonColumnizer.csproj", "{4C899885-E361-410A-B6AC-C2F236C436FA}" diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs index 7b837155..32202229 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs @@ -971,8 +971,10 @@ private void OnNewFromClipboardToolStripMenuItemClick(object sender, EventArgs e private void OnOpenURIToolStripMenuItemClick(object sender, EventArgs e) { - OpenUriDialog dlg = new(); - dlg.UriHistory = ConfigManager.Settings.uriHistoryList; + OpenUriDialog dlg = new() + { + UriHistory = ConfigManager.Settings.uriHistoryList + }; if (DialogResult.OK == dlg.ShowDialog()) { diff --git a/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs b/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs index 957188fe..fd159b4a 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs @@ -1634,13 +1634,16 @@ public void PatternStatistic(PatternArgs patternArgs) public void ExportBookmarkList() { - SaveFileDialog dlg = new SaveFileDialog(); - dlg.Title = "Choose a file to save bookmarks into"; - dlg.AddExtension = true; - dlg.DefaultExt = "csv"; - dlg.Filter = "CSV file (*.csv)|*.csv|Bookmark file (*.bmk)|*.bmk"; - dlg.FilterIndex = 1; - dlg.FileName = Path.GetFileNameWithoutExtension(FileName); + SaveFileDialog dlg = new() + { + Title = "Choose a file to save bookmarks into", + AddExtension = true, + DefaultExt = "csv", + Filter = "CSV file (*.csv)|*.csv|Bookmark file (*.bmk)|*.bmk", + FilterIndex = 1, + FileName = Path.GetFileNameWithoutExtension(FileName) + }; + if (dlg.ShowDialog() == DialogResult.OK) { try @@ -1658,20 +1661,22 @@ public void ExportBookmarkList() public void ImportBookmarkList() { - OpenFileDialog dlg = new OpenFileDialog(); - dlg.Title = "Choose a file to load bookmarks from"; - dlg.AddExtension = true; - dlg.DefaultExt = "csv"; - dlg.DefaultExt = "csv"; - dlg.Filter = "CSV file (*.csv)|*.csv|Bookmark file (*.bmk)|*.bmk"; - dlg.FilterIndex = 1; - dlg.FileName = Path.GetFileNameWithoutExtension(FileName); + OpenFileDialog dlg = new() + { + Title = "Choose a file to load bookmarks from", + AddExtension = true, + DefaultExt = "csv", + Filter = "CSV file (*.csv)|*.csv|Bookmark file (*.bmk)|*.bmk", + FilterIndex = 1, + FileName = Path.GetFileNameWithoutExtension(FileName) + }; + if (dlg.ShowDialog() == DialogResult.OK) { try { // add to the existing bookmarks - SortedList newBookmarks = new SortedList(); + SortedList newBookmarks = []; BookmarkExporter.ImportBookmarkList(FileName, dlg.FileName, newBookmarks); // Add (or replace) to existing bookmark list @@ -1703,7 +1708,7 @@ public void ImportBookmarkList() catch (IOException e) { _logger.Error(e); - MessageBox.Show("Error while importing bookmark list: " + e.Message, "LogExpert"); + MessageBox.Show($"Error while importing bookmark list: {e.Message}", "LogExpert"); } } } diff --git a/src/LogExpert/Dialogs/SettingsDialog.cs b/src/LogExpert/Dialogs/SettingsDialog.cs index fd826922..4ec928b9 100644 --- a/src/LogExpert/Dialogs/SettingsDialog.cs +++ b/src/LogExpert/Dialogs/SettingsDialog.cs @@ -5,6 +5,7 @@ using LogExpert.Core.Config; using LogExpert.Core.Entities; using LogExpert.Core.Enums; +using LogExpert.UI.Dialogs; using System; using System.Collections.Generic; diff --git a/src/Logexpert.Core/Classes/Bookmark/BookmarkExporter.cs b/src/Logexpert.Core/Classes/Bookmark/BookmarkExporter.cs index a3202798..ac4a34a5 100644 --- a/src/Logexpert.Core/Classes/Bookmark/BookmarkExporter.cs +++ b/src/Logexpert.Core/Classes/Bookmark/BookmarkExporter.cs @@ -26,50 +26,45 @@ public static void ExportBookmarkList(SortedList bookmar fs.Close(); } - public static void ImportBookmarkList(string logfileName, string fileName, - SortedList bookmarkList) + public static void ImportBookmarkList(string logfileName, string fileName, SortedList bookmarkList) { - using (FileStream fs = new(fileName, FileMode.Open, FileAccess.Read)) + using FileStream fs = new(fileName, FileMode.Open, FileAccess.Read); + using StreamReader reader = new(fs); + if (!reader.EndOfStream) { - using (StreamReader reader = new(fs)) - { - if (!reader.EndOfStream) - { - reader.ReadLine(); // skip "Log file name;Line number;Comment" - } + reader.ReadLine(); // skip "Log file name;Line number;Comment" + } - while (!reader.EndOfStream) - { - try - { - string line = reader.ReadLine(); - line = line.Replace(replacementForNewLine, "\r\n").Replace("\\\r\n", replacementForNewLine); + while (!reader.EndOfStream) + { + try + { + string line = reader.ReadLine(); + line = line.Replace(replacementForNewLine, "\r\n").Replace("\\\r\n", replacementForNewLine); - // Line is formatted: logfileName ";" bookmark.LineNum ";" bookmark.Text; - int firstSeparator = line.IndexOf(';'); - int secondSeparator = line.IndexOf(';', firstSeparator + 1); + // Line is formatted: logfileName ";" bookmark.LineNum ";" bookmark.Text; + int firstSeparator = line.IndexOf(';'); + int secondSeparator = line.IndexOf(';', firstSeparator + 1); - string fileStr = line.Substring(0, firstSeparator); - string lineStr = line.Substring(firstSeparator + 1, secondSeparator - firstSeparator - 1); - string comment = line.Substring(secondSeparator + 1); + string fileStr = line.Substring(0, firstSeparator); + string lineStr = line.Substring(firstSeparator + 1, secondSeparator - firstSeparator - 1); + string comment = line.Substring(secondSeparator + 1); - int lineNum; - if (int.TryParse(lineStr, out lineNum)) - { - Entities.Bookmark bookmark = new(lineNum, comment); - bookmarkList.Add(lineNum, bookmark); - } - else - { - //!!!log error: skipping a line entry - } - } - catch - { - //!!! - } + int lineNum; + if (int.TryParse(lineStr, out lineNum)) + { + Entities.Bookmark bookmark = new(lineNum, comment); + bookmarkList.Add(lineNum, bookmark); + } + else + { + //!!!log error: skipping a line entry } } + catch + { + //!!! + } } } diff --git a/src/Logexpert.Core/Classes/CmdLine.cs b/src/Logexpert.Core/Classes/CmdLine.cs index 53889d45..6f2e151a 100644 --- a/src/Logexpert.Core/Classes/CmdLine.cs +++ b/src/Logexpert.Core/Classes/CmdLine.cs @@ -1,9 +1,6 @@ -using System; -using System.Collections.Generic; - /* * Taken from https://cmdline.codeplex.com/ - * + * */ namespace LogExpert.Core.Classes @@ -31,7 +28,7 @@ public CmdLineException(string message) } /// - /// Represents a command line parameter. + /// Represents a command line parameter. /// Parameters are words in the command line beginning with a hyphen (-). /// The value of the parameter is the next word in /// @@ -103,7 +100,7 @@ public virtual void SetValue(string value) } /// - /// Represents an integer command line parameter. + /// Represents an integer command line parameter. /// public class CmdLineInt : CmdLineParameter { @@ -343,7 +340,7 @@ public string[] Parse(string[] args) } - // Check that required parameters are present in the command line. + // Check that required parameters are present in the command line. foreach (string key in parameters.Keys) { if (parameters[key].Required && !parameters[key].Exists) @@ -404,7 +401,9 @@ public ConsoleCmdLine() public new string[] Parse(string[] args) { string[] ret = null; + string error = ""; + try { ret = base.Parse(args); @@ -428,6 +427,7 @@ public ConsoleCmdLine() Console.WriteLine("Use -help for more information."); Environment.Exit(1); } + return ret; } diff --git a/src/Logexpert.Core/Classes/UsedComponents.cs b/src/Logexpert.Core/Classes/UsedComponents.cs new file mode 100644 index 00000000..39e176f4 --- /dev/null +++ b/src/Logexpert.Core/Classes/UsedComponents.cs @@ -0,0 +1,20 @@ +namespace LogExpert.Core.Classes +{ + [Serializable] + public class UsedComponents + { + public string PackageId { get; set; } + + public string PackageVersion { get; set; } + + public string PackageProjectUrl { get; set; } + + public string Copyright { get; set; } + + public string Authors { get; set; } + + public string License { get; set; } + + public string LicenseUrl { get; set; } + } +} diff --git a/src/Logexpert.Resources/Logexpert.Resources.csproj b/src/Logexpert.Resources/Logexpert.Resources.csproj index e5048437..8786f4f1 100644 --- a/src/Logexpert.Resources/Logexpert.Resources.csproj +++ b/src/Logexpert.Resources/Logexpert.Resources.csproj @@ -14,6 +14,13 @@ + + PreserveNewest + + + + + diff --git a/src/Logexpert.UI/Dialogs/AboutBox.Designer.cs b/src/Logexpert.UI/Dialogs/AboutBox.Designer.cs index 37e82252..b521cfef 100644 --- a/src/Logexpert.UI/Dialogs/AboutBox.Designer.cs +++ b/src/Logexpert.UI/Dialogs/AboutBox.Designer.cs @@ -34,13 +34,14 @@ private void InitializeComponent() labelProductName = new Label(); labelVersion = new Label(); labelCopyright = new Label(); - textBoxDescription = new TextBox(); linkLabelURL = new LinkLabel(); - panel1 = new Panel(); + okPanel = new Panel(); okButton = new Button(); + usedComponentsDataGrid = new DataGridView(); tableLayoutPanel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)logoPictureBox).BeginInit(); - panel1.SuspendLayout(); + okPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)usedComponentsDataGrid).BeginInit(); SuspendLayout(); // // tableLayoutPanel @@ -52,9 +53,9 @@ private void InitializeComponent() tableLayoutPanel.Controls.Add(labelProductName, 1, 0); tableLayoutPanel.Controls.Add(labelVersion, 1, 1); tableLayoutPanel.Controls.Add(labelCopyright, 1, 2); - tableLayoutPanel.Controls.Add(textBoxDescription, 1, 4); tableLayoutPanel.Controls.Add(linkLabelURL, 1, 3); - tableLayoutPanel.Controls.Add(panel1, 1, 5); + tableLayoutPanel.Controls.Add(okPanel, 1, 5); + tableLayoutPanel.Controls.Add(usedComponentsDataGrid, 1, 4); tableLayoutPanel.Dock = DockStyle.Fill; tableLayoutPanel.Location = new Point(14, 14); tableLayoutPanel.Margin = new Padding(4, 5, 4, 5); @@ -117,20 +118,6 @@ private void InitializeComponent() labelCopyright.Text = "Copyright"; labelCopyright.TextAlign = ContentAlignment.MiddleLeft; // - // textBoxDescription - // - textBoxDescription.Dock = DockStyle.Fill; - textBoxDescription.Location = new Point(322, 270); - textBoxDescription.Margin = new Padding(9, 5, 4, 5); - textBoxDescription.Multiline = true; - textBoxDescription.Name = "textBoxDescription"; - textBoxDescription.ReadOnly = true; - textBoxDescription.ScrollBars = ScrollBars.Both; - textBoxDescription.Size = new Size(588, 292); - textBoxDescription.TabIndex = 23; - textBoxDescription.TabStop = false; - textBoxDescription.Text = "Description"; - // // linkLabelURL // linkLabelURL.AutoSize = true; @@ -145,15 +132,15 @@ private void InitializeComponent() linkLabelURL.TextAlign = ContentAlignment.MiddleLeft; linkLabelURL.LinkClicked += OnLinkLabelURLClicked; // - // panel1 + // okPanel // - panel1.Controls.Add(okButton); - panel1.Dock = DockStyle.Fill; - panel1.Location = new Point(317, 572); - panel1.Margin = new Padding(4, 5, 4, 5); - panel1.Name = "panel1"; - panel1.Size = new Size(593, 72); - panel1.TabIndex = 26; + okPanel.Controls.Add(okButton); + okPanel.Dock = DockStyle.Fill; + okPanel.Location = new Point(317, 572); + okPanel.Margin = new Padding(4, 5, 4, 5); + okPanel.Name = "okPanel"; + okPanel.Size = new Size(593, 72); + okPanel.TabIndex = 26; // // okButton // @@ -167,11 +154,23 @@ private void InitializeComponent() okButton.Text = "&OK"; okButton.UseVisualStyleBackColor = true; // + // usedComponentsDataGrid + // + usedComponentsDataGrid.AllowUserToAddRows = false; + usedComponentsDataGrid.AllowUserToDeleteRows = false; + usedComponentsDataGrid.BackgroundColor = SystemColors.Control; + usedComponentsDataGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + usedComponentsDataGrid.Dock = DockStyle.Fill; + usedComponentsDataGrid.Location = new Point(316, 268); + usedComponentsDataGrid.Name = "usedComponentsDataGrid"; + usedComponentsDataGrid.ReadOnly = true; + usedComponentsDataGrid.Size = new Size(595, 296); + usedComponentsDataGrid.TabIndex = 27; + // // AboutBox // ClientSize = new Size(942, 677); Controls.Add(tableLayoutPanel); - FormBorderStyle = FormBorderStyle.FixedDialog; Margin = new Padding(4, 5, 4, 5); MaximizeBox = false; MinimizeBox = false; @@ -184,7 +183,8 @@ private void InitializeComponent() tableLayoutPanel.ResumeLayout(false); tableLayoutPanel.PerformLayout(); ((System.ComponentModel.ISupportInitialize)logoPictureBox).EndInit(); - panel1.ResumeLayout(false); + okPanel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)usedComponentsDataGrid).EndInit(); ResumeLayout(false); } @@ -195,9 +195,9 @@ private void InitializeComponent() private System.Windows.Forms.Label labelProductName; private System.Windows.Forms.Label labelVersion; private System.Windows.Forms.Label labelCopyright; - private System.Windows.Forms.TextBox textBoxDescription; private System.Windows.Forms.LinkLabel linkLabelURL; - private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Panel okPanel; private System.Windows.Forms.Button okButton; - } + private DataGridView usedComponentsDataGrid; + } } diff --git a/src/Logexpert.UI/Dialogs/AboutBox.cs b/src/Logexpert.UI/Dialogs/AboutBox.cs index b8a39b22..b1aa1bc9 100644 --- a/src/Logexpert.UI/Dialogs/AboutBox.cs +++ b/src/Logexpert.UI/Dialogs/AboutBox.cs @@ -1,4 +1,8 @@ -using System.Diagnostics; +using LogExpert.Core.Classes; + +using Newtonsoft.Json; + +using System.Diagnostics; using System.Reflection; using System.Runtime.Versioning; @@ -27,15 +31,22 @@ public AboutBox() labelProductName.Text = AssemblyProduct; labelVersion.Text = AssemblyVersion; labelCopyright.Text = AssemblyCopyright; - //this.labelCompanyName.Text = AssemblyCompany; - textBoxDescription.Text = AssemblyDescription + - "\r\n\r\nCredits:\r\n\r\n" + - "LogExpert uses modules from:\r\n" + - "https://github.com/dockpanelsuite/dockpanelsuite\r\n"; string link = "https://github.com/LogExperts/LogExpert"; linkLabelURL.Links.Add(new LinkLabel.Link(0, link.Length, link)); + LoadUsedComponents(); } + //Name, Version, License, Download, Source + + private void LoadUsedComponents() + { + string json = File.ReadAllText($"{Application.StartupPath}files\\json\\usedComponents.json"); + var usedComponents = JsonConvert.DeserializeObject(json); + usedComponents = usedComponents?.OrderBy(x => x.PackageId).ToArray(); + usedComponentsDataGrid.DataSource = usedComponents; + } + + private void LoadResources() { logoPictureBox.Image = Resources.Resources.LogLover; diff --git a/src/LogExpert/Dialogs/ChooseIconDlg.Designer.cs b/src/Logexpert.UI/Dialogs/ChooseIconDlg.Designer.cs similarity index 97% rename from src/LogExpert/Dialogs/ChooseIconDlg.Designer.cs rename to src/Logexpert.UI/Dialogs/ChooseIconDlg.Designer.cs index 00cf7708..b82d377b 100644 --- a/src/LogExpert/Dialogs/ChooseIconDlg.Designer.cs +++ b/src/Logexpert.UI/Dialogs/ChooseIconDlg.Designer.cs @@ -1,125 +1,125 @@ -namespace LogExpert.Dialogs -{ - partial class ChooseIconDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ChooseIconDlg)); - this.iconListView = new System.Windows.Forms.ListView(); - this.iconFileLabel = new System.Windows.Forms.Label(); - this.buttonChooseIconFile = new System.Windows.Forms.Button(); - this.okButton = new System.Windows.Forms.Button(); - this.cancelButton = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // iconListView - // - this.iconListView.Alignment = System.Windows.Forms.ListViewAlignment.Left; - this.iconListView.AutoArrange = false; - this.iconListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.iconListView.HideSelection = false; - this.iconListView.Location = new System.Drawing.Point(18, 63); - this.iconListView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.iconListView.MultiSelect = false; - this.iconListView.Name = "iconListView"; - this.iconListView.ShowGroups = false; - this.iconListView.Size = new System.Drawing.Size(529, 118); - this.iconListView.TabIndex = 0; - this.iconListView.UseCompatibleStateImageBehavior = false; - // - // iconFileLabel - // - this.iconFileLabel.Location = new System.Drawing.Point(18, 26); - this.iconFileLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.iconFileLabel.Name = "iconFileLabel"; - this.iconFileLabel.Size = new System.Drawing.Size(411, 35); - this.iconFileLabel.TabIndex = 1; - this.iconFileLabel.Text = "label1"; - // - // buttonChooseIconFile - // - this.buttonChooseIconFile.Location = new System.Drawing.Point(438, 18); - this.buttonChooseIconFile.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.buttonChooseIconFile.Name = "buttonChooseIconFile"; - this.buttonChooseIconFile.Size = new System.Drawing.Size(112, 35); - this.buttonChooseIconFile.TabIndex = 2; - this.buttonChooseIconFile.Text = "Icon file..."; - this.buttonChooseIconFile.UseVisualStyleBackColor = true; - this.buttonChooseIconFile.Click += new System.EventHandler(this.OnButtonChooseIconFileClick); - // - // okButton - // - this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.okButton.Location = new System.Drawing.Point(316, 226); - this.okButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(112, 35); - this.okButton.TabIndex = 3; - this.okButton.Text = "OK"; - this.okButton.UseVisualStyleBackColor = true; - this.okButton.Click += new System.EventHandler(this.OnOkButtonClick); - // - // cancelButton - // - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(440, 226); - this.cancelButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(112, 35); - this.cancelButton.TabIndex = 4; - this.cancelButton.Text = "Cancel"; - this.cancelButton.UseVisualStyleBackColor = true; - // - // ChooseIconDlg - // - this.ClientSize = new System.Drawing.Size(568, 278); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.okButton); - this.Controls.Add(this.buttonChooseIconFile); - this.Controls.Add(this.iconFileLabel); - this.Controls.Add(this.iconListView); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ChooseIconDlg"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Choose Icon"; - this.Load += new System.EventHandler(this.ChooseIconDlg_Load); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.ListView iconListView; - private System.Windows.Forms.Label iconFileLabel; - private System.Windows.Forms.Button buttonChooseIconFile; - private System.Windows.Forms.Button okButton; - private System.Windows.Forms.Button cancelButton; - } +namespace LogExpert.UI.Dialogs +{ + partial class ChooseIconDlg + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ChooseIconDlg)); + this.iconListView = new System.Windows.Forms.ListView(); + this.iconFileLabel = new System.Windows.Forms.Label(); + this.buttonChooseIconFile = new System.Windows.Forms.Button(); + this.okButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // iconListView + // + this.iconListView.Alignment = System.Windows.Forms.ListViewAlignment.Left; + this.iconListView.AutoArrange = false; + this.iconListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.iconListView.HideSelection = false; + this.iconListView.Location = new System.Drawing.Point(18, 63); + this.iconListView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.iconListView.MultiSelect = false; + this.iconListView.Name = "iconListView"; + this.iconListView.ShowGroups = false; + this.iconListView.Size = new System.Drawing.Size(529, 118); + this.iconListView.TabIndex = 0; + this.iconListView.UseCompatibleStateImageBehavior = false; + // + // iconFileLabel + // + this.iconFileLabel.Location = new System.Drawing.Point(18, 26); + this.iconFileLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.iconFileLabel.Name = "iconFileLabel"; + this.iconFileLabel.Size = new System.Drawing.Size(411, 35); + this.iconFileLabel.TabIndex = 1; + this.iconFileLabel.Text = "label1"; + // + // buttonChooseIconFile + // + this.buttonChooseIconFile.Location = new System.Drawing.Point(438, 18); + this.buttonChooseIconFile.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.buttonChooseIconFile.Name = "buttonChooseIconFile"; + this.buttonChooseIconFile.Size = new System.Drawing.Size(112, 35); + this.buttonChooseIconFile.TabIndex = 2; + this.buttonChooseIconFile.Text = "Icon file..."; + this.buttonChooseIconFile.UseVisualStyleBackColor = true; + this.buttonChooseIconFile.Click += new System.EventHandler(this.OnButtonChooseIconFileClick); + // + // okButton + // + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.Location = new System.Drawing.Point(316, 226); + this.okButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(112, 35); + this.okButton.TabIndex = 3; + this.okButton.Text = "OK"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.OnOkButtonClick); + // + // cancelButton + // + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(440, 226); + this.cancelButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(112, 35); + this.cancelButton.TabIndex = 4; + this.cancelButton.Text = "Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + // + // ChooseIconDlg + // + this.ClientSize = new System.Drawing.Size(568, 278); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.okButton); + this.Controls.Add(this.buttonChooseIconFile); + this.Controls.Add(this.iconFileLabel); + this.Controls.Add(this.iconListView); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ChooseIconDlg"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Choose Icon"; + this.Load += new System.EventHandler(this.ChooseIconDlg_Load); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.ListView iconListView; + private System.Windows.Forms.Label iconFileLabel; + private System.Windows.Forms.Button buttonChooseIconFile; + private System.Windows.Forms.Button okButton; + private System.Windows.Forms.Button cancelButton; + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/ChooseIconDlg.cs b/src/Logexpert.UI/Dialogs/ChooseIconDlg.cs similarity index 85% rename from src/LogExpert/Dialogs/ChooseIconDlg.cs rename to src/Logexpert.UI/Dialogs/ChooseIconDlg.cs index 3e9ffba0..630406a3 100644 --- a/src/LogExpert/Dialogs/ChooseIconDlg.cs +++ b/src/Logexpert.UI/Dialogs/ChooseIconDlg.cs @@ -1,118 +1,121 @@ -using LogExpert.Core.Classes; - -using System; -using System.Drawing; -using System.IO; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public partial class ChooseIconDlg : Form - { - #region Fields - - #endregion - - #region cTor - - public ChooseIconDlg(string fileName) - { - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - FileName = fileName; - } - - #endregion - - #region Properties - - public string FileName { get; set; } - - public int IconIndex { get; set; } - - #endregion - - #region Private Methods - - private void FillIconList() - { - iconListView.Items.Clear(); - - Icon[,] icons = Win32.ExtractIcons(FileName); - - if (icons == null) - { - return; - } - - ImageList imageList = new(); - - if (icons.GetLength(0) > 0) - { - imageList.ImageSize = icons[1, 0].Size; - iconListView.LargeImageList = imageList; - for (int i = 0; i < icons.GetLength(1); ++i) - { - imageList.Images.Add(icons[1, i]); - ListViewItem item = new(); - item.ImageIndex = i; - iconListView.Items.Add(item); - } - } - } - - private void DisposeIcons() - { - ImageList imageList = iconListView.LargeImageList; - iconListView.LargeImageList = null; - foreach (Image image in imageList.Images) - { - image.Dispose(); - } - } - - #endregion - - #region Events handler - - private void ChooseIconDlg_Load(object sender, EventArgs e) - { - FillIconList(); - iconFileLabel.Text = FileName; - } - - private void OnButtonChooseIconFileClick(object sender, EventArgs e) - { - OpenFileDialog dlg = new(); - dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); - - if (string.IsNullOrEmpty(iconFileLabel.Text) == false) - { - FileInfo info = new(iconFileLabel.Text); - if (info.Directory != null && info.Directory.Exists) - { - dlg.InitialDirectory = info.DirectoryName; - } - } - - if (dlg.ShowDialog() == DialogResult.OK) - { - iconFileLabel.Text = dlg.FileName; - FileName = dlg.FileName; - FillIconList(); - } - } - - private void OnOkButtonClick(object sender, EventArgs e) - { - IconIndex = iconListView.SelectedIndices.Count > 0 ? iconListView.SelectedIndices[0] : -1; - - DisposeIcons(); - } - - #endregion - } +using LogExpert.Core.Classes; + +using System.Runtime.Versioning; + +namespace LogExpert.UI.Dialogs +{ + [SupportedOSPlatform("windows")] + public partial class ChooseIconDlg : Form + { + #region Fields + + #endregion + + #region cTor + + public ChooseIconDlg(string fileName) + { + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + FileName = fileName; + } + + #endregion + + #region Properties + + public string FileName { get; set; } + + public int IconIndex { get; set; } + + #endregion + + #region Private Methods + + private void FillIconList() + { + iconListView.Items.Clear(); + + Icon[,] icons = Win32.ExtractIcons(FileName); + + if (icons == null) + { + return; + } + + ImageList imageList = new(); + + if (icons.GetLength(0) > 0) + { + imageList.ImageSize = icons[1, 0].Size; + iconListView.LargeImageList = imageList; + + for (int i = 0; i < icons.GetLength(1); ++i) + { + imageList.Images.Add(icons[1, i]); + ListViewItem item = new() + { + ImageIndex = i + }; + iconListView.Items.Add(item); + } + } + } + + private void DisposeIcons() + { + ImageList imageList = iconListView.LargeImageList; + iconListView.LargeImageList = null; + foreach (Image image in imageList.Images) + { + image.Dispose(); + } + } + + #endregion + + #region Events handler + + private void ChooseIconDlg_Load(object sender, EventArgs e) + { + FillIconList(); + iconFileLabel.Text = FileName; + } + + private void OnButtonChooseIconFileClick(object sender, EventArgs e) + { + OpenFileDialog dlg = new() + { + InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + }; + + if (string.IsNullOrEmpty(iconFileLabel.Text) == false) + { + FileInfo info = new(iconFileLabel.Text); + if (info.Directory != null && info.Directory.Exists) + { + dlg.InitialDirectory = info.DirectoryName; + } + } + + if (dlg.ShowDialog() == DialogResult.OK) + { + iconFileLabel.Text = dlg.FileName; + FileName = dlg.FileName; + FillIconList(); + } + } + + private void OnOkButtonClick(object sender, EventArgs e) + { + IconIndex = iconListView.SelectedIndices.Count > 0 ? iconListView.SelectedIndices[0] : -1; + + DisposeIcons(); + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/ChooseIconDlg.resx b/src/Logexpert.UI/Dialogs/ChooseIconDlg.resx similarity index 98% rename from src/LogExpert/Dialogs/ChooseIconDlg.resx rename to src/Logexpert.UI/Dialogs/ChooseIconDlg.resx index 2de0ae4d..a43dafee 100644 --- a/src/LogExpert/Dialogs/ChooseIconDlg.resx +++ b/src/Logexpert.UI/Dialogs/ChooseIconDlg.resx @@ -1,131 +1,131 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA - AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// - AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// - //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA - AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAIABAAD//wAA - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// + //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA + AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAIABAAD//wAA + + \ No newline at end of file diff --git a/src/LogExpert/Dialogs/OpenUriDialog.Designer.cs b/src/Logexpert.UI/Dialogs/OpenUriDialog.Designer.cs similarity index 96% rename from src/LogExpert/Dialogs/OpenUriDialog.Designer.cs rename to src/Logexpert.UI/Dialogs/OpenUriDialog.Designer.cs index 1d0235f6..33a3ddb5 100644 --- a/src/LogExpert/Dialogs/OpenUriDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/OpenUriDialog.Designer.cs @@ -1,122 +1,122 @@ -namespace LogExpert.Dialogs -{ - partial class OpenUriDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OpenUriDialog)); - this.cmbUri = new System.Windows.Forms.ComboBox(); - this.label1 = new System.Windows.Forms.Label(); - this.okButton = new System.Windows.Forms.Button(); - this.cancelButton = new System.Windows.Forms.Button(); - this.label2 = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // uriComboBox - // - this.cmbUri.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.cmbUri.FormattingEnabled = true; - this.cmbUri.Location = new System.Drawing.Point(12, 37); - this.cmbUri.Name = "cmbUri"; - this.cmbUri.Size = new System.Drawing.Size(449, 21); - this.cmbUri.TabIndex = 0; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 21); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(32, 13); - this.label1.TabIndex = 1; - this.label1.Text = "URL:"; - // - // okButton - // - this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.okButton.Location = new System.Drawing.Point(305, 127); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(75, 23); - this.okButton.TabIndex = 2; - this.okButton.Text = "OK"; - this.okButton.UseVisualStyleBackColor = true; - this.okButton.Click += new System.EventHandler(this.OnBtnOkClick); - // - // cancelButton - // - this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(386, 127); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(75, 23); - this.cancelButton.TabIndex = 3; - this.cancelButton.Text = "Cancel"; - this.cancelButton.UseVisualStyleBackColor = true; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(12, 84); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(410, 13); - this.label2.TabIndex = 4; - this.label2.Text = "Enter a URL which is supported by an installed file system plugin (e.g. file:// o" + - "r sftp://)"; - // - // OpenUriDialog - // - this.AcceptButton = this.okButton; - this.CancelButton = this.cancelButton; - this.ClientSize = new System.Drawing.Size(475, 162); - this.Controls.Add(this.label2); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.okButton); - this.Controls.Add(this.label1); - this.Controls.Add(this.cmbUri); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MaximumSize = new System.Drawing.Size(800, 260); - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(491, 200); - this.Name = "OpenUriDialog"; - this.Text = "Open URL"; - this.Load += new System.EventHandler(this.OnOpenUriDialogLoad); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.ComboBox cmbUri; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Button okButton; - private System.Windows.Forms.Button cancelButton; - private System.Windows.Forms.Label label2; - } +namespace LogExpert.UI.Dialogs +{ + partial class OpenUriDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OpenUriDialog)); + this.cmbUri = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.okButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // uriComboBox + // + this.cmbUri.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.cmbUri.FormattingEnabled = true; + this.cmbUri.Location = new System.Drawing.Point(12, 37); + this.cmbUri.Name = "cmbUri"; + this.cmbUri.Size = new System.Drawing.Size(449, 21); + this.cmbUri.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 21); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(32, 13); + this.label1.TabIndex = 1; + this.label1.Text = "URL:"; + // + // okButton + // + this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.Location = new System.Drawing.Point(305, 127); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(75, 23); + this.okButton.TabIndex = 2; + this.okButton.Text = "OK"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.OnBtnOkClick); + // + // cancelButton + // + this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(386, 127); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(75, 23); + this.cancelButton.TabIndex = 3; + this.cancelButton.Text = "Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 84); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(410, 13); + this.label2.TabIndex = 4; + this.label2.Text = "Enter a URL which is supported by an installed file system plugin (e.g. file:// o" + + "r sftp://)"; + // + // OpenUriDialog + // + this.AcceptButton = this.okButton; + this.CancelButton = this.cancelButton; + this.ClientSize = new System.Drawing.Size(475, 162); + this.Controls.Add(this.label2); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.okButton); + this.Controls.Add(this.label1); + this.Controls.Add(this.cmbUri); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MaximumSize = new System.Drawing.Size(800, 260); + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(491, 200); + this.Name = "OpenUriDialog"; + this.Text = "Open URL"; + this.Load += new System.EventHandler(this.OnOpenUriDialogLoad); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ComboBox cmbUri; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button okButton; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.Label label2; + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/OpenUriDialog.cs b/src/Logexpert.UI/Dialogs/OpenUriDialog.cs similarity index 84% rename from src/LogExpert/Dialogs/OpenUriDialog.cs rename to src/Logexpert.UI/Dialogs/OpenUriDialog.cs index 9c364f96..707b27cd 100644 --- a/src/LogExpert/Dialogs/OpenUriDialog.cs +++ b/src/Logexpert.UI/Dialogs/OpenUriDialog.cs @@ -1,69 +1,72 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public partial class OpenUriDialog : Form - { - #region Fields - - #endregion - - #region cTor - - public OpenUriDialog() - { - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - } - - #endregion - - #region Properties - - public string Uri => cmbUri.Text; - - public IList UriHistory { get; set; } - - #endregion - - #region Events handler - - private void OnOpenUriDialogLoad(object sender, EventArgs e) - { - if (UriHistory != null) - { - cmbUri.Items.Clear(); - foreach (string uri in UriHistory) - { - cmbUri.Items.Add(uri); - } - } - } - - private void OnBtnOkClick(object sender, EventArgs e) - { - UriHistory = new List(); - foreach (object item in cmbUri.Items) - { - UriHistory.Add(item.ToString()); - } - if (UriHistory.Contains(cmbUri.Text)) - { - UriHistory.Remove(cmbUri.Text); - } - UriHistory.Insert(0, cmbUri.Text); - - while (UriHistory.Count > 20) - { - UriHistory.RemoveAt(UriHistory.Count - 1); - } - } - - #endregion - } +using System.Runtime.Versioning; + +namespace LogExpert.UI.Dialogs +{ + [SupportedOSPlatform("windows")] + public partial class OpenUriDialog : Form + { + #region Fields + + #endregion + + #region cTor + + public OpenUriDialog() + { + SuspendLayout(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + InitializeComponent(); + + ResumeLayout(); + } + + #endregion + + #region Properties + + public string Uri => cmbUri.Text; + + public IList UriHistory { get; set; } + + #endregion + + #region Events handler + + private void OnOpenUriDialogLoad(object sender, EventArgs e) + { + if (UriHistory != null) + { + cmbUri.Items.Clear(); + foreach (string uri in UriHistory) + { + cmbUri.Items.Add(uri); + } + } + } + + private void OnBtnOkClick(object sender, EventArgs e) + { + UriHistory = []; + + foreach (object item in cmbUri.Items) + { + UriHistory.Add(item.ToString()); + } + + if (UriHistory.Contains(cmbUri.Text)) + { + UriHistory.Remove(cmbUri.Text); + } + UriHistory.Insert(0, cmbUri.Text); + + while (UriHistory.Count > 20) + { + UriHistory.RemoveAt(UriHistory.Count - 1); + } + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/OpenUriDialog.resx b/src/Logexpert.UI/Dialogs/OpenUriDialog.resx similarity index 98% rename from src/LogExpert/Dialogs/OpenUriDialog.resx rename to src/Logexpert.UI/Dialogs/OpenUriDialog.resx index 2de0ae4d..a43dafee 100644 --- a/src/LogExpert/Dialogs/OpenUriDialog.resx +++ b/src/Logexpert.UI/Dialogs/OpenUriDialog.resx @@ -1,131 +1,131 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA - AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// - AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// - //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA - AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAIABAAD//wAA - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// + //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA + AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAIABAAD//wAA + + \ No newline at end of file diff --git a/src/Logexpert.UI/LogExpert.UI.csproj b/src/Logexpert.UI/LogExpert.UI.csproj index 13f1c365..82ec1bb4 100644 --- a/src/Logexpert.UI/LogExpert.UI.csproj +++ b/src/Logexpert.UI/LogExpert.UI.csproj @@ -8,6 +8,7 @@ false True ..\Solution Items\Key.snk + true @@ -23,6 +24,12 @@ Form + + Form + + + Form + Form diff --git a/src/Solution Items/usedComponents.json b/src/Solution Items/usedComponents.json new file mode 100644 index 0000000000000000000000000000000000000000..4bfb6a2cb60c36537596f2fb0b2afdbee8dd1032 GIT binary patch literal 19266 zcmeHPZBH9V5Z=#~`X5e6l~O6T!Gw@hswxUJgaC~zff$4q*eZU+vnNw z`fhL5_ErXnMCRHwas3`w@A26; zm!@Zaz`J}~o(#;fDVw_Knl|qCY#%**w(L~}Jq~QoeN)1{Cf?*IeD7QHjrqg=jnMx; zqbq(}GOs{I-CW==>3R-omM}7()Im$vj@TMf`U!U*-q`*P`nbZVO|9u+Gba+7cq+VK8A<);ga*j2OE$sL z4`v5EZ9&$^S-s}ICJJkkRp^j1WUdUUo7BTJy5t-@=mE!d(8sIO6spRWGZi2qJ&#I& z4lT(J!TL!^#+RX6N>;a2p*JJ5JEV>}!qKN^AC|>zZG99wYWIQp5-h|XXm|;I5JBr* z0whz}Z;Rd*FL)$;uX)4M<^3$#<47q(-jtP?Qz*%QK>W3-r^r z64|u)E%0-I`BJxNu4ThNkzW-0#ltumQpuGSDtjX;W4)>A)mV18c>tV#546xaF2h1O zEHC5UZWpIQmNpIv0a4(+HT7XLn+%ItN_A2A`|6RiUGpoaW52Xy9 zNBxvnvp=?4J#0^X37N*PNqWYyE*JV=gWfJ|QV;euG^1%WzP1I?u+MlDu?O^MvhO6) zl*X2VBWAM>z83!4b@ns6>J6+reO$p(ANOcs&t}lhtJW*8PV8ZJ^j<>B=qI??giub8 zf_u;kJXH65+?+I89V+w_x5r@A(chYE0kCc8c@xkf)@p0*>&9j3m0@HcMoj;zr z%K5ztiM-OccpN~`?PItY)H0$vJ=zwibzb%SQ5$=G8Ua4)d@tJR1kt^WbbJ}ztEtYT zZJ#V~Yqb|6cz0Rb?qfe!hn8jJS28r*&D9XUV4mi3qUH=^nERadIUzXdDKN(&Hsj2E z4A4Fv$$oB2b47AgMNZCFmm z;`v@$dP z14IRw!|h;i$M^Q3qdWNJJJbNo+jT${bBGO8JV;Kyg?29U+q3Pssx`FOM!aFm-eEt? z&yd1U)a^Dbz?P-H3A$OEu!(Pfp7M@8F9~DB<+uDxazKsqLnMe>}bD7y0J8kDl`gOL$Ua~*SFrN{YL+O?dyeTROM&d=`xhsnHNLJb9v7v0j`Djq?7y9{0}2Mo7OG@&)G(rAA0w&>Wu)$v*2_MSfaOH>|V1o z)Uze{%gL&?xT-;~s>a_<$nv$~F>%YLr zFF*ln-I!y#fOI^xGSbEq*2mF)i7zL0iXA-P9qM=5n+SPh#`I5c@5;(tNDqbOAg{J9 zLNfA>JwI6)AUDUDvg9n=;H}tq@{&4L<1&jBNd}X9gJQj`BVgwUy|#gt3g~lnu9T|t z0IlO?=zi>P^F&gLz;&K+=ZWbHAU8%d{g`|>eu`eWTX;0F{WLpV;#MeRRU;Y7l-~aEQ?j9~EIGr|1MCT31nXDBTAaPH4*fm)l>GyBIrk572EL9v zp}l~fQ&>l5^B{^qZnlx;k5#E|*a04n14ziCb0xl5wCB>ms&noAGY7O8jQcgPC#1b# z4M7FSa=5;EHX6Oovq^d}Qtuj%6eY&exC&!8YwI_dMGG@Mu~?UC`EAUPzFJ((9-o}x zc?o@j!rfhhbh)-}W(VjgvSY**u91~eU2`4TI_v@X$`cs=ZYv&xT%^pMBC^Z)mtF@f>mt7Mr>z1J-Nb4kX41uTT^d!wI$Az^ciyEa zUcz|Ey56j^RUP%3ug;u$u7i<7vB50z#9ct~9t?HAP*uF|Pfwaz3L^OwXnTeAXM{&i zmmK2y*xuzjO1(&|!5x~?6}F7#h|Xk%ZgL&7S8h#DR~q$c3^}xC)8_ZlZa8d6X@D879=6ByfVFU{>z&n!fqt&^Ow&`X~;qN|AzysPu#?s~V zrmr7eU%vfLYqI%U!_`p+aKrjLmss8W+Jf;i?vRR&m&rL4R{@^3my~a2DR@GQ(O1a? zmh3zjMJi!E=*hX6RqV-1uGdFU%6L~BEw$W__e=E?KO3_G-Q!NSOx8kj{=tvYF(<daLZVl_Q1N=xHU85(9Pbqeao+YcALNcR~=J>9k zr1KGnKu-r!(FBGBW6L8{h9VeY48^_ZIW7>9JQZJqZIq~W8>`8kFe5JURSoOW$6k>8 zGpWCG=dd+rv!I8#5q&$U{WQ@isTYzAT7Swo)GSfd`&K6uj+BhA#;Ra9#_ansc+RN1 zAW5GyXT{F%_|1NfwtVisZcnCm?LLxjIN{LdTl8F>B= zgS79ab+FUUvq-|CUd~05@_NU!p3e3$O$*4nhXK4V?w06>7N^BsPN7(Qe<>}#!0z3` zE`5CZ8$>L9!7la@qMNlg%j$D53L5fN{q_r=L+ZsfpM5*+EQYJQaR1w>3oh#_*Z8FF z8R{omb}cX9G5lnsu^r?Q>5=}3NOcu4yLJ48R?4TqMJ6O;@a5>pD6uTye0#e)JNwMb&dl-OzrUMr%{L~(=b!Nvzpa>;=ET&^C4M)}nR#j& zxcAt$)Xh87MO)Xj&^kctUuavsvHxp4)iZr_fnJ^QNL5od_wlnawf{@>?wa=)rH&bY z!ME0Uly|r@FjpA;v8mwG#4H2QI5ejin{>8uH$-*vu3o_odR}2|J&f1Hc!Tkbx+OAi zFy9(J+vX9tRK?Z0*}_$6^sQ<(akUfRU1VyQ=^W!td9AGbw*~d@Me8BGpXw1D+1BLpx^A9D$2_0S@?--i+A0M=$w*Zg-EX9)RoQ+6%0lNVveYXoK~!)PG87 zfb6p-ecW;;J6O@cy*RSRoQZ; z0wko@Q3=qYCE4jz-4c@VHRzU-)h$)%&B#0(QAZu&=+mnY%VM^^K8hW+hroOZ7UBRj zynsH4p!KeR6YAJAOCk3{Q{s)NOTE&B6vmW%XZb>EC+c@WKW!_K-NA}l;O7wQrEbw&%Z7g|7f)$3z@;Vbm$(;?mHy@= z{ePEm|HSHW-$N-w=TSf9)$9+fRu9`#UqWW_Ym%OEtjmS|SD=??yFTn|XhpMVd~FM& z(U|cpVh`xiWIsuyDUB@!XQXF8-8%SM_-ohMPwcKYvG4S81xvK7w6N!MXy*;Z zFh6>)u;=s>Tx>!pr$<5WpaKuowNF};Myo@GZgFS)O?%ExaxXr+Ye@-vBw2fh5&ILY z=q`Mz4gByNaDpAp@xHHOzQuz8f^Hwf#h{iE)!EUuM6L6x7mwQ5>(dDEQRjQn zPA7=&Wu)Wt=w3~A9&P(@iCe3^7{R;C+V&9VxjM8gBfpZN;c2dh_yzMcS5q}-7{fg0 zY%K`ENl$^BdTbe79qasH*ew;60_R8gu;w&0-NVHt}a!7i1Et6q? z;%kk@X^xfQ2k*ghG8V^uU_`wJuktd0iY!{0*+#~mB?qJT!yjY*lU`fNWd&Iz$<6V% zreKL}N?Q@$aW*MhlxJ}Wjq_(qaQSl%-`4;-Q%x~ZJ z5tD1+fcqPJLC@?ps{qn5fh>~eEJe|kKi8m?bsvn3XqxL-11o{vPo!PT znLBsrmUMpp8F0v)7G)~Qvyyo}l0299d>G(b_)I!|OwIo=!n0}ZBJiATrp2N60K47{ za6Ai6H-RO3>&2cmJ0m??g1?-sYKyBH^sZ|B-GofvHryZQ*%>c6LT;TLiAFJgS5qey zU+GG!JhV>6GQIvw%={b_u-1(^rb|f2s+Ey8T38=P`z5{{H4bAHtEhAl{Z4xmA#co> zegpSMEIbiSKPDfJA6ZL4i!iPK zEGJyzRw!gv@&Y=s0W|9wCZkukxQsgWJ$-#j?_l&-vZ1UjIY;Xe&VP>zVSV(~ z;%fHz%?Z9Qq2HizcUK@?uCH6!5k`va9C3wfWTjNsTt~JJdkDVr4GjOZ70*E~QpV2^ z*=77oGO@e(`v#wVj7{o!o!kw67jJM6{iObSV4sS05uf?PR)L6aVzm%6>EgMrj4NRs zEuXwQZ&MVnV7_EsZ&o`{9gmu?&YXI#gPB9I!7TE`Q$X<^40XRyRlM&{PnuZ@BKZtx zdx`yLgh$>kImY#=y~}-+dXZRzJ2a(hs2I(W^BpU6llz#xa%*G>4vyWb}A8PlzTYB^2LCIcF4VOvrJ zif`Y}gk}(X!a90thS>fvZY4h901;r?g2?=gCy1j6T8b4%5n6aYj9>wVct-Mlv^rm+ zZMs=g_@~bXctD%TSh~Cu>FY-~mT$k)nk=ivD9##gj5C1S*5A3p?&jAPjF&N=Qf$0T z-a~N};AwkF`DT`aZ)h?4Dw)8NT?eB`CF}=1Ik&QkeY2AL^%0aZ-ql7=E%%fCQr+Tb zW7eU2+?y@awUE63;K%5glVJ>ll2-%m^!>ON+UjAlC ziu$G1356pildG{RIE^v;ehQv5>Mlsq@0qh==QsT5J@=(Ct0yt<``c;M%bV;M&^%4x zlUk~nnCl|`LxjIO*U+5tJMbYX)jHT|=XoSySuf`zNqN2FdC${6rfC6L_b`O_#nTe~ z(BibX%PAC#@6V;hm)N~q*rkt8e}jmnFWAL7LUgmXA6b14MnOZqs^5RW@2a;pGw?qR(HL|9 literal 0 HcmV?d00001 From f3c021b7ba97b7da2ff4187f7e51d9ef500a8b20 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 13 Apr 2025 15:28:16 +0200 Subject: [PATCH 014/142] moving UI to Logexpert.UI for better maintainability --- src/LogExpert/Classes/Log/LogfileReader.cs | 2 +- src/LogExpert/Classes/PaintHelper.cs | 13 +- src/LogExpert/Classes/TimeSpreadCalculator.cs | 49 +- src/LogExpert/Config/ConfigManager.cs | 2 +- .../DateTimeDragControl.Designer.cs | 92 +- .../DateTimeDragControl.cs | 1024 ++++++++--------- .../DateTimeDragControl.resx | 238 ++-- .../Controls/KnobControl.Designer.cs | 43 - src/LogExpert/Controls/KnobControl.cs | 184 --- src/LogExpert/Controls/LogTabControl.cs | 44 - src/LogExpert/Controls/LogTabPage.cs | 21 +- .../Controls/LogTabWindow/LogTabWindow.cs | 2 +- .../LogTabWindow/LogTabWindow.designer.cs | 2 +- .../LogTabWindow/LogTabWindowEventHandlers.cs | 2 +- .../LogTabWindow/LogTabWindowPrivate.cs | 14 +- src/LogExpert/Controls/LogWindow/LogWindow.cs | 26 +- .../Controls/LogWindow/LogWindow.designer.cs | 2 +- .../LogWindow/LogWindowEventHandlers.cs | 24 +- .../Controls/LogWindow/LogWindowPrivate.cs | 37 +- .../Controls/LogWindow/LogWindowsPublic.cs | 23 +- src/LogExpert/Controls/PatternWindow.cs | 21 +- .../TimeSpreadigControl.Designer.cs | 98 +- .../TimeSpreadigControl.cs | 609 +++++----- .../TimeSpreadigControl.resx | 238 ++-- .../Dialogs/BookmarkCommentDlg.Designer.cs | 90 -- src/LogExpert/Dialogs/BookmarkCommentDlg.cs | 30 - src/LogExpert/Dialogs/BookmarkWindow.cs | 13 +- src/LogExpert/Dialogs/BufferedDataGridView.cs | 83 +- .../Dialogs/HighlightDialog.Designer.cs | 4 +- src/LogExpert/Dialogs/HighlightDialog.cs | 1 + .../Dialogs/LogCellEditingControl.cs | 31 - src/LogExpert/Dialogs/LogGridCell.cs | 4 +- src/LogExpert/Dialogs/OverlayEventArgs.cs | 28 - .../Dialogs/ProjectLoadDlg.Designer.cs | 120 -- src/LogExpert/Dialogs/ProjectLoadDlg.cs | 65 -- src/LogExpert/Dialogs/SelectLineEventArgs.cs | 26 - src/LogExpert/Dialogs/ToolArgsDialog.cs | 3 +- .../CurrentHighlightGroupChangedEventArgs.cs | 20 +- .../EventArgs/FilterListChangedEventArgs.cs | 17 +- src/LogExpert/Entities/WindowFileEntry.cs | 10 +- .../Extensions/ComboBoxExtensions.cs | 25 - .../Forms/LineToolStripSeparatorExtension.cs | 37 - .../Extensions/Forms/MenuSelectedColors.cs | 32 - .../Extensions/Forms/MenuStripExtension.cs | 9 - .../Forms/MenuToolStripSeparatorExtension.cs | 35 - .../Forms/ToolStripRendererExtension.cs | 15 - src/LogExpert/LogExpert.csproj | 16 +- src/LogExpert/Program.cs | 1 + .../Classes/Bookmark/BookmarkDataProvider.cs | 12 +- .../Classes/Filter/FilterParams.cs | 4 +- .../Classes/Highlight/ActionEntry.cs | 4 +- src/Logexpert.Core/Classes/SpreadEntry.cs | 28 + src/Logexpert.Core/Classes/SysoutPipe.cs | 12 +- .../Entities/EventArgs/BookmarkEventArgs.cs | 24 - .../Entities/EventArgs/ColumnizerEventArgs.cs | 24 - .../EventArgs/ConfigChangedEventArgs.cs | 26 - .../EventArgs/ContextMenuPluginEventArgs.cs | 34 - .../Entities/EventArgs/PatternArgs.cs | 16 - .../Entities/EventArgs/SyncModeEventArgs.cs | 24 - .../Enums/ProjectLoadDlgResult.cs | 10 + .../EventArgs/BookmarkEventArgs.cs | 13 + .../EventArgs/ColumnizerEventArgs.cs | 11 + .../EventArgs/ConfigChangedEventArgs.cs | 13 + .../EventArgs/ContextMenuPluginEventArgs.cs | 19 + .../{Entities => }/EventArgs/GuiStateArgs.cs | 6 +- .../EventArgs/LoadFileEventArgs.cs | 2 +- .../EventArgs/OverlayEventArgs.cs | 13 + src/Logexpert.Core/EventArgs/PatternArgs.cs | 21 + .../EventArgs/ProgressEventArgs.cs | 6 +- .../EventArgs/SelectLineEventArgs.cs | 11 + .../EventArgs/StatusEventArgs.cs | 6 +- .../EventArgs/SyncModeEventArgs.cs | 11 + src/Logexpert.Core/Structs/ActEntry.cs | 9 + .../Controls}/ColorComboBox.cs | 198 ++-- .../Controls/KnobControl.Designer.cs | 42 + src/Logexpert.UI/Controls/KnobControl.cs | 182 +++ .../Controls/KnobControl.resx | 238 ++-- .../Controls/LogCellEditingControl.cs | 31 + src/Logexpert.UI/Controls/LogTabControl.cs | 42 + src/Logexpert.UI/Dialogs/AboutBox.Designer.cs | 343 +++--- src/Logexpert.UI/Dialogs/AboutBox.cs | 197 ++-- .../Dialogs/BookmarkCommentDlg.Designer.cs | 89 ++ .../Dialogs/BookmarkCommentDlg.cs | 29 + .../Dialogs/BookmarkCommentDlg.resx | 260 ++--- .../Dialogs/ChooseIconDlg.Designer.cs | 233 ++-- src/Logexpert.UI/Dialogs/ChooseIconDlg.cs | 155 ++- .../Dialogs/ExceptionWindow.Designer.cs | 214 ++-- .../Dialogs/ExceptionWindow.cs | 100 +- .../Dialogs/ExceptionWindow.resx | 260 ++--- .../Dialogs/FilterColumnChooser.Designer.cs | 434 +++---- .../Dialogs/FilterColumnChooser.cs | 145 +-- .../Dialogs/FilterColumnChooser.resx | 296 ++--- .../Dialogs/GotoLineDialog.Designer.cs | 214 ++-- .../Dialogs/GotoLineDialog.cs | 103 +- .../Dialogs/GotoLineDialog.resx | 238 ++-- .../Dialogs/ImportSettingsDialog.Designer.cs | 450 ++++---- .../Dialogs/ImportSettingsDialog.cs | 149 +-- .../Dialogs/ImportSettingsDialog.resx | 260 ++--- .../Dialogs/KeywordActionDlg.Designer.cs | 276 ++--- .../Dialogs/KeywordActionDlg.cs | 174 ++- .../Dialogs/KeywordActionDlg.resx | 260 ++--- .../Dialogs/MultiFileMaskDialog.Designer.cs | 382 +++--- .../Dialogs/MultiFileMaskDialog.cs | 128 +-- .../Dialogs/MultiFileMaskDialog.resx | 260 ++--- .../MultiLoadRequestDialog.Designer.cs | 176 +-- .../Dialogs/MultiLoadRequestDialog.cs | 38 +- .../Dialogs/MultiLoadRequestDialog.resx | 238 ++-- .../Dialogs/OpenUriDialog.Designer.cs | 227 ++-- src/Logexpert.UI/Dialogs/OpenUriDialog.cs | 91 +- .../Dialogs/ProjectLoadDlg.Designer.cs | 119 ++ src/Logexpert.UI/Dialogs/ProjectLoadDlg.cs | 53 + .../Dialogs/ProjectLoadDlg.resx | 260 ++--- .../Dialogs/RegexHelperDialog.Designer.cs | 373 +++--- src/Logexpert.UI/Dialogs/RegexHelperDialog.cs | 201 ++-- .../Dialogs/SearchDialog.Designer.cs | 491 ++++---- src/Logexpert.UI/Dialogs/SearchDialog.cs | 181 ++- .../Dialogs/SearchProgressDialog.Designer.cs | 148 +-- .../Dialogs/SearchProgressDialog.cs | 81 +- .../Dialogs/SearchProgressDialog.resx | 238 ++-- .../Dialogs/TabRenameDialog.Designer.cs | 187 ++- src/Logexpert.UI/Dialogs/TabRenameDialog.cs | 55 +- .../Extensions/ComboBoxExtensions.cs | 25 + .../Forms/LineToolStripSeparatorExtension.cs | 36 + .../Extensions/Forms/MenuSelectedColors.cs | 31 + .../Extensions/Forms/MenuStripExtension.cs | 9 + .../Forms/MenuToolStripSeparatorExtension.cs | 39 + .../Forms/ToolStripRendererExtension.cs | 15 + src/Logexpert.UI/LogExpert.UI.csproj | 52 + 128 files changed, 6781 insertions(+), 6849 deletions(-) rename src/LogExpert/{Dialogs => Controls}/DateTimeDragControl.Designer.cs (96%) rename src/LogExpert/{Dialogs => Controls}/DateTimeDragControl.cs (96%) rename src/LogExpert/{Dialogs => Controls}/DateTimeDragControl.resx (97%) delete mode 100644 src/LogExpert/Controls/KnobControl.Designer.cs delete mode 100644 src/LogExpert/Controls/KnobControl.cs delete mode 100644 src/LogExpert/Controls/LogTabControl.cs rename src/LogExpert/{Dialogs => Controls}/TimeSpreadigControl.Designer.cs (97%) rename src/LogExpert/{Dialogs => Controls}/TimeSpreadigControl.cs (91%) rename src/LogExpert/{Dialogs => Controls}/TimeSpreadigControl.resx (97%) delete mode 100644 src/LogExpert/Dialogs/BookmarkCommentDlg.Designer.cs delete mode 100644 src/LogExpert/Dialogs/BookmarkCommentDlg.cs delete mode 100644 src/LogExpert/Dialogs/LogCellEditingControl.cs delete mode 100644 src/LogExpert/Dialogs/OverlayEventArgs.cs delete mode 100644 src/LogExpert/Dialogs/ProjectLoadDlg.Designer.cs delete mode 100644 src/LogExpert/Dialogs/ProjectLoadDlg.cs delete mode 100644 src/LogExpert/Dialogs/SelectLineEventArgs.cs delete mode 100644 src/LogExpert/Extensions/ComboBoxExtensions.cs delete mode 100644 src/LogExpert/Extensions/Forms/LineToolStripSeparatorExtension.cs delete mode 100644 src/LogExpert/Extensions/Forms/MenuSelectedColors.cs delete mode 100644 src/LogExpert/Extensions/Forms/MenuStripExtension.cs delete mode 100644 src/LogExpert/Extensions/Forms/MenuToolStripSeparatorExtension.cs delete mode 100644 src/LogExpert/Extensions/Forms/ToolStripRendererExtension.cs create mode 100644 src/Logexpert.Core/Classes/SpreadEntry.cs delete mode 100644 src/Logexpert.Core/Entities/EventArgs/BookmarkEventArgs.cs delete mode 100644 src/Logexpert.Core/Entities/EventArgs/ColumnizerEventArgs.cs delete mode 100644 src/Logexpert.Core/Entities/EventArgs/ConfigChangedEventArgs.cs delete mode 100644 src/Logexpert.Core/Entities/EventArgs/ContextMenuPluginEventArgs.cs delete mode 100644 src/Logexpert.Core/Entities/EventArgs/PatternArgs.cs delete mode 100644 src/Logexpert.Core/Entities/EventArgs/SyncModeEventArgs.cs create mode 100644 src/Logexpert.Core/Enums/ProjectLoadDlgResult.cs create mode 100644 src/Logexpert.Core/EventArgs/BookmarkEventArgs.cs create mode 100644 src/Logexpert.Core/EventArgs/ColumnizerEventArgs.cs create mode 100644 src/Logexpert.Core/EventArgs/ConfigChangedEventArgs.cs create mode 100644 src/Logexpert.Core/EventArgs/ContextMenuPluginEventArgs.cs rename src/Logexpert.Core/{Entities => }/EventArgs/GuiStateArgs.cs (92%) rename src/Logexpert.Core/{Entities => }/EventArgs/LoadFileEventArgs.cs (70%) create mode 100644 src/Logexpert.Core/EventArgs/OverlayEventArgs.cs create mode 100644 src/Logexpert.Core/EventArgs/PatternArgs.cs rename src/Logexpert.Core/{Entities => }/EventArgs/ProgressEventArgs.cs (76%) create mode 100644 src/Logexpert.Core/EventArgs/SelectLineEventArgs.cs rename src/Logexpert.Core/{Entities => }/EventArgs/StatusEventArgs.cs (88%) create mode 100644 src/Logexpert.Core/EventArgs/SyncModeEventArgs.cs create mode 100644 src/Logexpert.Core/Structs/ActEntry.cs rename src/{LogExpert/Dialogs => Logexpert.UI/Controls}/ColorComboBox.cs (85%) create mode 100644 src/Logexpert.UI/Controls/KnobControl.Designer.cs create mode 100644 src/Logexpert.UI/Controls/KnobControl.cs rename src/{LogExpert => Logexpert.UI}/Controls/KnobControl.resx (97%) create mode 100644 src/Logexpert.UI/Controls/LogCellEditingControl.cs create mode 100644 src/Logexpert.UI/Controls/LogTabControl.cs create mode 100644 src/Logexpert.UI/Dialogs/BookmarkCommentDlg.Designer.cs create mode 100644 src/Logexpert.UI/Dialogs/BookmarkCommentDlg.cs rename src/{LogExpert => Logexpert.UI}/Dialogs/BookmarkCommentDlg.resx (98%) rename src/{LogExpert => Logexpert.UI}/Dialogs/ExceptionWindow.Designer.cs (97%) rename src/{LogExpert => Logexpert.UI}/Dialogs/ExceptionWindow.cs (85%) rename src/{LogExpert => Logexpert.UI}/Dialogs/ExceptionWindow.resx (98%) rename src/{LogExpert => Logexpert.UI}/Dialogs/FilterColumnChooser.Designer.cs (97%) rename src/{LogExpert => Logexpert.UI}/Dialogs/FilterColumnChooser.cs (90%) rename src/{LogExpert => Logexpert.UI}/Dialogs/FilterColumnChooser.resx (98%) rename src/{LogExpert => Logexpert.UI}/Dialogs/GotoLineDialog.Designer.cs (97%) rename src/{LogExpert => Logexpert.UI}/Dialogs/GotoLineDialog.cs (85%) rename src/{LogExpert => Logexpert.UI}/Dialogs/GotoLineDialog.resx (97%) rename src/{LogExpert => Logexpert.UI}/Dialogs/ImportSettingsDialog.Designer.cs (97%) rename src/{LogExpert => Logexpert.UI}/Dialogs/ImportSettingsDialog.cs (78%) rename src/{LogExpert => Logexpert.UI}/Dialogs/ImportSettingsDialog.resx (98%) rename src/{LogExpert => Logexpert.UI}/Dialogs/KeywordActionDlg.Designer.cs (97%) rename src/{LogExpert => Logexpert.UI}/Dialogs/KeywordActionDlg.cs (86%) rename src/{LogExpert => Logexpert.UI}/Dialogs/KeywordActionDlg.resx (98%) rename src/{LogExpert => Logexpert.UI}/Dialogs/MultiFileMaskDialog.Designer.cs (97%) rename src/{LogExpert => Logexpert.UI}/Dialogs/MultiFileMaskDialog.cs (85%) rename src/{LogExpert => Logexpert.UI}/Dialogs/MultiFileMaskDialog.resx (98%) rename src/{LogExpert => Logexpert.UI}/Dialogs/MultiLoadRequestDialog.Designer.cs (96%) rename src/{LogExpert => Logexpert.UI}/Dialogs/MultiLoadRequestDialog.cs (74%) rename src/{LogExpert => Logexpert.UI}/Dialogs/MultiLoadRequestDialog.resx (97%) create mode 100644 src/Logexpert.UI/Dialogs/ProjectLoadDlg.Designer.cs create mode 100644 src/Logexpert.UI/Dialogs/ProjectLoadDlg.cs rename src/{LogExpert => Logexpert.UI}/Dialogs/ProjectLoadDlg.resx (98%) rename src/{LogExpert => Logexpert.UI}/Dialogs/SearchProgressDialog.Designer.cs (96%) rename src/{LogExpert => Logexpert.UI}/Dialogs/SearchProgressDialog.cs (82%) rename src/{LogExpert => Logexpert.UI}/Dialogs/SearchProgressDialog.resx (97%) create mode 100644 src/Logexpert.UI/Extensions/ComboBoxExtensions.cs create mode 100644 src/Logexpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs create mode 100644 src/Logexpert.UI/Extensions/Forms/MenuSelectedColors.cs create mode 100644 src/Logexpert.UI/Extensions/Forms/MenuStripExtension.cs create mode 100644 src/Logexpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs create mode 100644 src/Logexpert.UI/Extensions/Forms/ToolStripRendererExtension.cs diff --git a/src/LogExpert/Classes/Log/LogfileReader.cs b/src/LogExpert/Classes/Log/LogfileReader.cs index 1633c70f..3dbde9c0 100644 --- a/src/LogExpert/Classes/Log/LogfileReader.cs +++ b/src/LogExpert/Classes/Log/LogfileReader.cs @@ -2,7 +2,7 @@ using LogExpert.Core.Classes.Log; using LogExpert.Core.Classes.xml; using LogExpert.Core.Entities; -using LogExpert.Core.Entities.EventArgs; +using LogExpert.Core.EventArgs; using LogExpert.Core.Interface; using NLog; diff --git a/src/LogExpert/Classes/PaintHelper.cs b/src/LogExpert/Classes/PaintHelper.cs index 72461705..bc0ce1c6 100644 --- a/src/LogExpert/Classes/PaintHelper.cs +++ b/src/LogExpert/Classes/PaintHelper.cs @@ -33,7 +33,7 @@ internal class PaintHelper #region Public methods - public static void CellPainting(ILogPaintContext logPaintCtx, DataGridView gridView, int rowIndex, + public static void CellPainting(ILogPaintContext logPaintCtx, BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) { if (rowIndex < 0 || e.ColumnIndex < 0) @@ -122,7 +122,6 @@ public static void CellPainting(ILogPaintContext logPaintCtx, DataGridView gridV } } - public static DataGridViewTextBoxColumn CreateMarkerColumn() { DataGridViewTextBoxColumn markerColumn = new(); @@ -161,7 +160,7 @@ public static DataGridViewColumn CreateTitleColumn(string colName) return titleColumn; } - public static void SetColumnizer(ILogLineColumnizer columnizer, DataGridView gridView) + public static void SetColumnizer(ILogLineColumnizer columnizer, BufferedDataGridView gridView) { int rowCount = gridView.RowCount; int currLine = gridView.CurrentCellAddress.Y; @@ -200,7 +199,7 @@ public static void SetColumnizer(ILogLineColumnizer columnizer, DataGridView gri //AutoResizeColumns(gridView); } - public static void AutoResizeColumns(DataGridView gridView) + public static void AutoResizeColumns(BufferedDataGridView gridView) { try { @@ -224,7 +223,7 @@ public static void AutoResizeColumns(DataGridView gridView) } } - public static void ApplyDataGridViewPrefs(DataGridView dataGridView, Preferences prefs) + public static void ApplyDataGridViewPrefs(BufferedDataGridView dataGridView, Preferences prefs) { if (dataGridView.Columns.Count > 1) { @@ -291,12 +290,12 @@ public static Rectangle BorderWidths(DataGridViewAdvancedBorderStyle advancedBor #region Private Methods - private static void PaintCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, DataGridView gridView, bool noBackgroundFill, HilightEntry groundEntry) + private static void PaintCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HilightEntry groundEntry) { PaintHighlightedCell(logPaintCtx, e, gridView, noBackgroundFill, groundEntry); } - private static void PaintHighlightedCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, DataGridView gridView, bool noBackgroundFill, HilightEntry groundEntry) + private static void PaintHighlightedCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HilightEntry groundEntry) { object value = e.Value ?? string.Empty; diff --git a/src/LogExpert/Classes/TimeSpreadCalculator.cs b/src/LogExpert/Classes/TimeSpreadCalculator.cs index 4fed6941..4e609ee7 100644 --- a/src/LogExpert/Classes/TimeSpreadCalculator.cs +++ b/src/LogExpert/Classes/TimeSpreadCalculator.cs @@ -1,5 +1,6 @@ using LogExpert.Classes.ILogLineColumnizerCallback; using LogExpert.Controls.LogWindow; +using LogExpert.Core.Classes; using NLog; @@ -10,7 +11,7 @@ namespace LogExpert.Classes { - internal class TimeSpreadCalculator + internal partial class TimeSpreadCalculator { #region Fields @@ -25,6 +26,7 @@ internal class TimeSpreadCalculator private readonly object _diffListLock = new(); private readonly EventWaitHandle _lineCountEvent = new ManualResetEvent(false); + //TODO Refactor that it does not need LogWindow private readonly LogWindow _logWindow; // for DoCalc_via_Time @@ -211,12 +213,14 @@ private void DoCalc() { OnStartCalc(EventArgs.Empty); _logger.Debug("TimeSpreadCalculator.DoCalc() begin"); + if (_callback.GetLineCount() < 1) { OnCalcDone(EventArgs.Empty); _logger.Debug("TimeSpreadCalculator.DoCalc() end because of line count < 1"); return; } + int lineNum = 0; int lastLineNum = _callback.GetLineCount() - 1; _startTimestamp = _logWindow.GetTimestampForLineForward(ref lineNum, false); @@ -231,6 +235,7 @@ private void DoCalc() _timePerLine = (int)Math.Round(overallSpanMillis / (double)_lineCount); DateTime oldTime = _logWindow.GetTimestampForLineForward(ref lineNum, false); int step; + if (_lineCount > _displayHeight) { step = (int)Math.Round(_lineCount / (double)_displayHeight); @@ -245,6 +250,7 @@ private void DoCalc() List newDiffList = []; List maxList = []; lineNum++; + for (int i = lineNum; i < lastLineNum; i += step) { int currLineNum = i; @@ -259,11 +265,13 @@ private void DoCalc() _logger.Debug("TimeSpreadCalculator.DoCalc() time diff {0}", span); } } + if (maxList.Count > 3) { maxList.Sort(); _maxSpan = maxList[^3]; } + lock (_diffListLock) { DiffList = newDiffList; @@ -280,12 +288,14 @@ private void DoCalc_via_Time() { OnStartCalc(EventArgs.Empty); _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() begin"); + if (_callback.GetLineCount() < 1) { OnCalcDone(EventArgs.Empty); _logger.Debug("TimeSpreadCalculator.DoCalc() end because of line count < 1"); return; } + int lineNum = 0; int lastLineNum = _callback.GetLineCount() - 1; _startTimestamp = _logWindow.GetTimestampForLineForward(ref lineNum, false); @@ -296,8 +306,9 @@ private void DoCalc_via_Time() TimeSpan overallSpan = _endTimestamp - _startTimestamp; long overallSpanMillis = overallSpan.Ticks / TimeSpan.TicksPerMillisecond; //int timePerLine = (int)Math.Round((double)overallSpanMillis / (double)this.lineCount); - DateTime oldTime = _logWindow.GetTimestampForLineForward(ref lineNum, false); + long step; + if (overallSpanMillis > _displayHeight) { step = (long)Math.Round(overallSpanMillis / (double)_displayHeight); @@ -318,6 +329,7 @@ private void DoCalc_via_Time() _maxDiff = 0; List maxList = []; List newDiffList = []; + while (searchTimeStamp.CompareTo(_endTimestamp) <= 0) { lineNum = _logWindow.FindTimestampLine_Internal(lineNum, lineNum, lastLineNum, searchTimeStamp, false); @@ -351,11 +363,13 @@ private void DoCalc_via_Time() oldLineNum = lineNum; //lineNum++; } + if (maxList.Count > 3) { maxList.Sort(); _maxDiff = maxList[^3]; } + _average = lineDiffSum / (double)loopCount; //double average = maxList[maxList.Count / 2]; _logger.Debug("Average diff={0} minDiff={1} maxDiff={2}", _average, minDiff, _maxDiff); @@ -383,9 +397,11 @@ private void DoCalc_via_Time() private DateTime CalcValuesViaLines(int timePerLine, TimeSpan maxSpan) { DateTime oldTime = DateTime.MinValue; + if (DiffList.Count > 0) { oldTime = DiffList[0].Timestamp; + foreach (SpreadEntry entry in DiffList) { TimeSpan span = entry.Timestamp - oldTime; @@ -401,6 +417,7 @@ private DateTime CalcValuesViaLines(int timePerLine, TimeSpan maxSpan) oldTime = entry.Timestamp; } } + return oldTime; } @@ -410,12 +427,14 @@ private void CalcValuesViaTime(int maxDiff, double average) { int lineDiff = entry.Diff; double diffFromAverage = entry.Diff - average; + if (diffFromAverage < 0) { diffFromAverage = 0; } int value = (int)(diffFromAverage / maxDiff * _contrast); entry.Value = 255 - value; + _logger.Debug("TimeSpreadCalculator.DoCalc() test time {0:HH:mm:ss.fff} line diff={1} value={2}", entry.Timestamp, lineDiff, value); } } @@ -431,31 +450,5 @@ private void OnStartCalc(EventArgs e) } #endregion - - public class SpreadEntry - { - #region Fields - - public int Diff { get; set; } - - public DateTime Timestamp { get; set; } - - public int LineNum { get; set; } - - public int Value { get; set; } - - #endregion - - #region cTor - - public SpreadEntry(int lineNum, int diff, DateTime timestamp) - { - LineNum = lineNum; - Diff = diff; - Timestamp = timestamp; - } - - #endregion - } } } \ No newline at end of file diff --git a/src/LogExpert/Config/ConfigManager.cs b/src/LogExpert/Config/ConfigManager.cs index e9ca5d2d..b7e2e5ec 100644 --- a/src/LogExpert/Config/ConfigManager.cs +++ b/src/LogExpert/Config/ConfigManager.cs @@ -2,7 +2,7 @@ using LogExpert.Core.Classes.Filter; using LogExpert.Core.Config; using LogExpert.Core.Entities; -using LogExpert.Core.Entities.EventArgs; +using LogExpert.Core.EventArgs; using Newtonsoft.Json; diff --git a/src/LogExpert/Dialogs/DateTimeDragControl.Designer.cs b/src/LogExpert/Controls/DateTimeDragControl.Designer.cs similarity index 96% rename from src/LogExpert/Dialogs/DateTimeDragControl.Designer.cs rename to src/LogExpert/Controls/DateTimeDragControl.Designer.cs index 9a769909..8f98bac0 100644 --- a/src/LogExpert/Dialogs/DateTimeDragControl.Designer.cs +++ b/src/LogExpert/Controls/DateTimeDragControl.Designer.cs @@ -1,46 +1,46 @@ -namespace LogExpert.Dialogs -{ - partial class DateTimeDragControl - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.SuspendLayout(); - // - // DateTimeDragControl - // - this.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Name = "DateTimeDragControl"; - this.Size = new System.Drawing.Size(142, 57); - this.Load += new System.EventHandler(this.DateTimeDragControl_Load); - this.MouseLeave += new System.EventHandler(this.DateTimeDragControl_MouseLeave); - this.Resize += new System.EventHandler(this.DateTimeDragControl_Resize); - this.ResumeLayout(false); - } - - #endregion - } -} +namespace LogExpert.Dialogs +{ + partial class DateTimeDragControl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // DateTimeDragControl + // + this.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Name = "DateTimeDragControl"; + this.Size = new System.Drawing.Size(142, 57); + this.Load += new System.EventHandler(this.DateTimeDragControl_Load); + this.MouseLeave += new System.EventHandler(this.DateTimeDragControl_MouseLeave); + this.Resize += new System.EventHandler(this.DateTimeDragControl_Resize); + this.ResumeLayout(false); + } + + #endregion + } +} diff --git a/src/LogExpert/Dialogs/DateTimeDragControl.cs b/src/LogExpert/Controls/DateTimeDragControl.cs similarity index 96% rename from src/LogExpert/Dialogs/DateTimeDragControl.cs rename to src/LogExpert/Controls/DateTimeDragControl.cs index cadc9b2c..ad17a7fd 100644 --- a/src/LogExpert/Dialogs/DateTimeDragControl.cs +++ b/src/LogExpert/Controls/DateTimeDragControl.cs @@ -1,512 +1,512 @@ -using LogExpert.Core.Classes.DateTimeParser; -using LogExpert.Core.Enums; - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Globalization; -using System.Linq; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - /// - /// This control displays date and time and allows user to interact with the individual parts using the mouse - /// to increment and decrement the values. The date format displayed is derived from the application UI locale. - /// We currently support only three: US (mm/dd/yyyy), French (yyyy-mm-dd) and German (dd.mm.yyyy). - /// The control raises events (ValueChanged, ValueDragged) when the date/time changes so that owner can react accordingly. - /// - public partial class DateTimeDragControl : UserControl - { - #region Fields - - private const int NO_DIGIT_DRAGGED = -1; - private int _addedValue; - - - private DateTime _dateTime; - private readonly IList _digitRects = new List(); - private readonly StringFormat _digitsFormat = new(); - private int _draggedDigit; - - public DragOrientationsEnum dragOrientation = DragOrientationsEnum.Vertical; - - private readonly ToolStripItem toolStripItemHorizontalDrag = new ToolStripMenuItem(); - private readonly ToolStripItem toolStripItemVerticalDrag = new ToolStripMenuItem(); - private readonly ToolStripItem toolStripItemVerticalInvertedDrag = new ToolStripMenuItem(); - - private int _oldValue; - - private string[] _dateParts; - - private int _startMouseX; - private int _startMouseY; - - #endregion - - #region cTor - - /// - /// Default Constructor - /// - public DateTimeDragControl() - { - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - _digitsFormat.LineAlignment = StringAlignment.Center; - _digitsFormat.Alignment = StringAlignment.Near; - _digitsFormat.Trimming = StringTrimming.None; - _digitsFormat.FormatFlags = StringFormatFlags.FitBlackBox | StringFormatFlags.NoClip | StringFormatFlags.NoWrap; - - _draggedDigit = NO_DIGIT_DRAGGED; - } - - #endregion - - #region Delegates - - public delegate void ValueChangedEventHandler(object sender, EventArgs e); - - public delegate void ValueDraggedEventHandler(object sender, EventArgs e); - - #endregion - - #region Events - - public event ValueChangedEventHandler ValueChanged; - public event ValueDraggedEventHandler ValueDragged; - - #endregion - - #region Properties - - public DateTime MinDateTime { get; set; } = DateTime.MinValue; - - public DateTime MaxDateTime { get; set; } = DateTime.MaxValue; - - public DragOrientationsEnum DragOrientation - { - get => dragOrientation; - set - { - dragOrientation = value; - UpdateContextMenu(); - } - } - - public Color HoverColor { get; set; } - - public DateTime DateTime - { - get => _dateTime.Subtract(TimeSpan.FromMilliseconds(_dateTime.Millisecond)); - set - { - _dateTime = value; - - if (_dateTime < MinDateTime) - { - _dateTime = MinDateTime; - } - if (_dateTime > MaxDateTime) - { - _dateTime = MaxDateTime; - } - } - } - - #endregion - - #region Private Methods - - // Returns the index of the rectangle (digitRects) under the mouse cursor - private int DetermineDraggedDigit(MouseEventArgs e) - { - for (int i = 0; i < _digitRects.Count; ++i) - { - if (_digitRects[i].Contains(e.Location) && Token.IsDatePart(_dateParts[i])) - { - return i; - } - } - - return NO_DIGIT_DRAGGED; - } - - // Return the value corresponding to current dragged digit - private int GetDraggedValue() - { - string datePart = _dateParts[_draggedDigit]; - - if (datePart.StartsWith("y", StringComparison.OrdinalIgnoreCase)) - { - return _dateTime.Year; - } - - if (datePart.StartsWith("M")) - { - return _dateTime.Month; - } - - if (datePart.StartsWith("d", StringComparison.OrdinalIgnoreCase)) - { - return _dateTime.Day; - } - - if (datePart.StartsWith("h", StringComparison.OrdinalIgnoreCase)) - { - return _dateTime.Hour; - } - - if (datePart.StartsWith("m")) - { - return _dateTime.Minute; - } - - return datePart.StartsWith("s", StringComparison.OrdinalIgnoreCase) ? _dateTime.Second : NO_DIGIT_DRAGGED; - } - - private bool SetDraggedValue(int delta) - { - if (_draggedDigit == NO_DIGIT_DRAGGED) - { - return false; - } - - bool changed = true; - try - { - string datePart = _dateParts[_draggedDigit]; - - if (datePart.StartsWith("y", StringComparison.OrdinalIgnoreCase)) - { - _dateTime = _dateTime.AddYears(delta); - } - else if (datePart.StartsWith("M")) - { - _dateTime = _dateTime.AddMonths(delta); - } - else if (datePart.StartsWith("d", StringComparison.OrdinalIgnoreCase)) - { - _dateTime = _dateTime.AddDays(delta); - } - else if (datePart.StartsWith("h", StringComparison.OrdinalIgnoreCase)) - { - _dateTime = _dateTime.AddHours(delta); - } - else if (datePart.StartsWith("m")) - { - _dateTime = _dateTime.AddMinutes(delta); - } - else if (datePart.StartsWith("s", StringComparison.OrdinalIgnoreCase)) - { - _dateTime = _dateTime.AddSeconds(delta); - } - } - catch (Exception) - { - // invalid value dragged - } - - if (_dateTime > MaxDateTime) - { - _dateTime = MaxDateTime; - changed = false; - } - if (_dateTime < MinDateTime) - { - _dateTime = MinDateTime; - changed = false; - } - - return changed; - } - - private void InitCustomRects(Section dateSection) - { - _dateParts = dateSection - .GeneralTextDateDurationParts - .Select(DateFormatPartAdjuster.AdjustDateTimeFormatPart) - .ToArray(); - - Rectangle rect = ClientRectangle; - int oneCharWidth = rect.Width / _dateParts.Sum(s => s.Length); - int left = rect.Left; - - _digitRects.Clear(); - - foreach (string datePart in _dateParts) - { - int s = datePart.Length * oneCharWidth; - _digitRects.Add(new Rectangle(left, rect.Top, s, rect.Height)); - left += s; - } - - } - - private void InitDigitRects() - { - CultureInfo culture = System.Threading.Thread.CurrentThread.CurrentCulture; - - string datePattern = string.Concat(culture.DateTimeFormat.ShortDatePattern, " ", culture.DateTimeFormat.LongTimePattern); - - List
sections = Parser.ParseSections(datePattern, out _); - Section dateSection = sections.FirstOrDefault(); - - if (dateSection == null) - { - sections = Parser.ParseSections("dd.MM.yyyy HH:mm:ss", out bool _); - dateSection = sections.Single(); - } - - InitCustomRects(dateSection); - } - - #endregion - - #region Events handler - - private void DateTimeDragControl_Load(object sender, EventArgs e) - { - InitDigitRects(); - - BuildContextualMenu(); - } - - #endregion - - protected void OnValueChanged(EventArgs e) - { - ValueChanged?.Invoke(this, e); - } - - protected void OnValueDragged(EventArgs e) - { - ValueDragged?.Invoke(this, e); - } - - #region Contextual Menu - - private void BuildContextualMenu() - { - ContextMenuStrip = new ContextMenuStrip(); - ContextMenuStrip.Name = "Timestamp selector"; - ContextMenuStrip.Items.Add(toolStripItemHorizontalDrag); - ContextMenuStrip.Items.Add(toolStripItemVerticalDrag); - ContextMenuStrip.Items.Add(toolStripItemVerticalInvertedDrag); - - toolStripItemHorizontalDrag.Click += OnToolStripItemHorizontalDragClick; - toolStripItemHorizontalDrag.Text = "Drag horizontal"; - - toolStripItemVerticalDrag.Click += OnToolStripItemVerticalDragClick; - toolStripItemVerticalDrag.Text = "Drag vertical"; - - toolStripItemVerticalInvertedDrag.Click += OnToolStripItemVerticalInvertedDragClick; - toolStripItemVerticalInvertedDrag.Text = "Drag vertical inverted"; - - ContextMenuStrip.Opening += OnContextMenuStripOpening; - - UpdateContextMenu(); - } - - private void UpdateContextMenu() - { - toolStripItemHorizontalDrag.Enabled = DragOrientation != DragOrientationsEnum.Horizontal; - toolStripItemVerticalDrag.Enabled = DragOrientation != DragOrientationsEnum.Vertical; - toolStripItemVerticalInvertedDrag.Enabled = DragOrientation != DragOrientationsEnum.InvertedVertical; - } - - private void OnContextMenuStripOpening(object sender, CancelEventArgs e) - { - if (Capture) - { - e.Cancel = true; - } - } - - private void OnToolStripItemHorizontalDragClick(object sender, EventArgs e) - { - DragOrientation = DragOrientationsEnum.Horizontal; - toolStripItemHorizontalDrag.Enabled = false; - toolStripItemVerticalDrag.Enabled = true; - toolStripItemVerticalInvertedDrag.Enabled = true; - } - - private void OnToolStripItemVerticalDragClick(object sender, EventArgs e) - { - DragOrientation = DragOrientationsEnum.Vertical; - toolStripItemHorizontalDrag.Enabled = true; - toolStripItemVerticalDrag.Enabled = false; - toolStripItemVerticalInvertedDrag.Enabled = true; - } - - private void OnToolStripItemVerticalInvertedDragClick(object sender, EventArgs e) - { - DragOrientation = DragOrientationsEnum.InvertedVertical; - toolStripItemHorizontalDrag.Enabled = true; - toolStripItemVerticalDrag.Enabled = true; - toolStripItemVerticalInvertedDrag.Enabled = false; - } - - #endregion - - #region Rendering - - protected override void OnPaint(PaintEventArgs e) - { - base.OnPaint(e); - - // Show what digit is dragged - using (Brush hoverBrush = new SolidBrush(HoverColor)) - { - if (_draggedDigit != NO_DIGIT_DRAGGED) - { - e.Graphics.FillRectangle(hoverBrush, _digitRects[_draggedDigit]); - } - } - - // Display current value with user-defined date format and fixed time format ("HH:mm:ss") - using (Brush brush = new SolidBrush(Color.Black)) - { - for (int i = 0; i < _dateParts.Length; i++) - { - string datePart = _dateParts[i]; - Rectangle rect = _digitRects[i]; - string value; - - if (Token.IsDatePart(datePart)) - { - try - { - value = _dateTime.ToString("-" + datePart + "-"); - value = value.Substring(1, value.Length - 2); - } - catch - { - value = datePart; - } - } - else - { - value = datePart; - } - - e.Graphics.DrawString(value, Font, brush, rect, _digitsFormat); - } - } - } - - private void DateTimeDragControl_Resize(object sender, EventArgs e) - { - InitDigitRects(); - } - - #endregion - - #region Mouse callbacks - - protected override void OnMouseDown(MouseEventArgs e) - { - base.OnMouseDown(e); - - if (e.Button == MouseButtons.Left) - { - _draggedDigit = DetermineDraggedDigit(e); - if (_draggedDigit == NO_DIGIT_DRAGGED) - { - return; - } - Capture = true; - _startMouseY = e.Y; - _startMouseX = e.X; - _oldValue = GetDraggedValue(); - _addedValue = 0; - } - else if (e.Button == MouseButtons.Right && Capture) - { - Capture = false; - SetDraggedValue(0); //undo - } - Invalidate(); // repaint with the selected item (or none) - } - - protected override void OnMouseUp(MouseEventArgs e) - { - if (!Capture) - { - return; - } - - base.OnMouseUp(e); - - Capture = false; - _draggedDigit = NO_DIGIT_DRAGGED; - Invalidate(); // repaint without the selected item - - OnValueChanged(EventArgs.Empty); - } - - protected override void OnMouseMove(MouseEventArgs e) - { - base.OnMouseMove(e); - - if (!Capture) - { - return; - } - - int diff; - switch (DragOrientation) - { - case DragOrientationsEnum.Vertical: - { - diff = _startMouseY - e.Y; - break; - } - case DragOrientationsEnum.InvertedVertical: - { - diff = _startMouseY + e.Y; - break; - } - default: - { - diff = e.X - _startMouseX; - break; - } - } - - int delta = diff / 5 - _addedValue; // one unit per 5 pixels move - - if (delta == 0) - { - return; - } - - if (SetDraggedValue(delta)) - { - _addedValue += delta; - } - - Invalidate(); - - OnValueDragged(EventArgs.Empty); - } - - private void DateTimeDragControl_MouseLeave(object sender, EventArgs e) - { - if (Capture) - { - return; - } - - _draggedDigit = NO_DIGIT_DRAGGED; - Refresh(); - } - - #endregion - } -} +using LogExpert.Core.Classes.DateTimeParser; +using LogExpert.Core.Enums; + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Globalization; +using System.Linq; +using System.Windows.Forms; + +namespace LogExpert.Dialogs +{ + /// + /// This control displays date and time and allows user to interact with the individual parts using the mouse + /// to increment and decrement the values. The date format displayed is derived from the application UI locale. + /// We currently support only three: US (mm/dd/yyyy), French (yyyy-mm-dd) and German (dd.mm.yyyy). + /// The control raises events (ValueChanged, ValueDragged) when the date/time changes so that owner can react accordingly. + /// + public partial class DateTimeDragControl : UserControl + { + #region Fields + + private const int NO_DIGIT_DRAGGED = -1; + private int _addedValue; + + + private DateTime _dateTime; + private readonly IList _digitRects = new List(); + private readonly StringFormat _digitsFormat = new(); + private int _draggedDigit; + + public DragOrientationsEnum dragOrientation = DragOrientationsEnum.Vertical; + + private readonly ToolStripItem toolStripItemHorizontalDrag = new ToolStripMenuItem(); + private readonly ToolStripItem toolStripItemVerticalDrag = new ToolStripMenuItem(); + private readonly ToolStripItem toolStripItemVerticalInvertedDrag = new ToolStripMenuItem(); + + private int _oldValue; + + private string[] _dateParts; + + private int _startMouseX; + private int _startMouseY; + + #endregion + + #region cTor + + /// + /// Default Constructor + /// + public DateTimeDragControl() + { + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + _digitsFormat.LineAlignment = StringAlignment.Center; + _digitsFormat.Alignment = StringAlignment.Near; + _digitsFormat.Trimming = StringTrimming.None; + _digitsFormat.FormatFlags = StringFormatFlags.FitBlackBox | StringFormatFlags.NoClip | StringFormatFlags.NoWrap; + + _draggedDigit = NO_DIGIT_DRAGGED; + } + + #endregion + + #region Delegates + + public delegate void ValueChangedEventHandler(object sender, EventArgs e); + + public delegate void ValueDraggedEventHandler(object sender, EventArgs e); + + #endregion + + #region Events + + public event ValueChangedEventHandler ValueChanged; + public event ValueDraggedEventHandler ValueDragged; + + #endregion + + #region Properties + + public DateTime MinDateTime { get; set; } = DateTime.MinValue; + + public DateTime MaxDateTime { get; set; } = DateTime.MaxValue; + + public DragOrientationsEnum DragOrientation + { + get => dragOrientation; + set + { + dragOrientation = value; + UpdateContextMenu(); + } + } + + public Color HoverColor { get; set; } + + public DateTime DateTime + { + get => _dateTime.Subtract(TimeSpan.FromMilliseconds(_dateTime.Millisecond)); + set + { + _dateTime = value; + + if (_dateTime < MinDateTime) + { + _dateTime = MinDateTime; + } + if (_dateTime > MaxDateTime) + { + _dateTime = MaxDateTime; + } + } + } + + #endregion + + #region Private Methods + + // Returns the index of the rectangle (digitRects) under the mouse cursor + private int DetermineDraggedDigit(MouseEventArgs e) + { + for (int i = 0; i < _digitRects.Count; ++i) + { + if (_digitRects[i].Contains(e.Location) && Token.IsDatePart(_dateParts[i])) + { + return i; + } + } + + return NO_DIGIT_DRAGGED; + } + + // Return the value corresponding to current dragged digit + private int GetDraggedValue() + { + string datePart = _dateParts[_draggedDigit]; + + if (datePart.StartsWith("y", StringComparison.OrdinalIgnoreCase)) + { + return _dateTime.Year; + } + + if (datePart.StartsWith("M")) + { + return _dateTime.Month; + } + + if (datePart.StartsWith("d", StringComparison.OrdinalIgnoreCase)) + { + return _dateTime.Day; + } + + if (datePart.StartsWith("h", StringComparison.OrdinalIgnoreCase)) + { + return _dateTime.Hour; + } + + if (datePart.StartsWith("m")) + { + return _dateTime.Minute; + } + + return datePart.StartsWith("s", StringComparison.OrdinalIgnoreCase) ? _dateTime.Second : NO_DIGIT_DRAGGED; + } + + private bool SetDraggedValue(int delta) + { + if (_draggedDigit == NO_DIGIT_DRAGGED) + { + return false; + } + + bool changed = true; + try + { + string datePart = _dateParts[_draggedDigit]; + + if (datePart.StartsWith("y", StringComparison.OrdinalIgnoreCase)) + { + _dateTime = _dateTime.AddYears(delta); + } + else if (datePart.StartsWith("M")) + { + _dateTime = _dateTime.AddMonths(delta); + } + else if (datePart.StartsWith("d", StringComparison.OrdinalIgnoreCase)) + { + _dateTime = _dateTime.AddDays(delta); + } + else if (datePart.StartsWith("h", StringComparison.OrdinalIgnoreCase)) + { + _dateTime = _dateTime.AddHours(delta); + } + else if (datePart.StartsWith("m")) + { + _dateTime = _dateTime.AddMinutes(delta); + } + else if (datePart.StartsWith("s", StringComparison.OrdinalIgnoreCase)) + { + _dateTime = _dateTime.AddSeconds(delta); + } + } + catch (Exception) + { + // invalid value dragged + } + + if (_dateTime > MaxDateTime) + { + _dateTime = MaxDateTime; + changed = false; + } + if (_dateTime < MinDateTime) + { + _dateTime = MinDateTime; + changed = false; + } + + return changed; + } + + private void InitCustomRects(Section dateSection) + { + _dateParts = dateSection + .GeneralTextDateDurationParts + .Select(DateFormatPartAdjuster.AdjustDateTimeFormatPart) + .ToArray(); + + Rectangle rect = ClientRectangle; + int oneCharWidth = rect.Width / _dateParts.Sum(s => s.Length); + int left = rect.Left; + + _digitRects.Clear(); + + foreach (string datePart in _dateParts) + { + int s = datePart.Length * oneCharWidth; + _digitRects.Add(new Rectangle(left, rect.Top, s, rect.Height)); + left += s; + } + + } + + private void InitDigitRects() + { + CultureInfo culture = System.Threading.Thread.CurrentThread.CurrentCulture; + + string datePattern = string.Concat(culture.DateTimeFormat.ShortDatePattern, " ", culture.DateTimeFormat.LongTimePattern); + + List
sections = Parser.ParseSections(datePattern, out _); + Section dateSection = sections.FirstOrDefault(); + + if (dateSection == null) + { + sections = Parser.ParseSections("dd.MM.yyyy HH:mm:ss", out bool _); + dateSection = sections.Single(); + } + + InitCustomRects(dateSection); + } + + #endregion + + #region Events handler + + private void DateTimeDragControl_Load(object sender, EventArgs e) + { + InitDigitRects(); + + BuildContextualMenu(); + } + + #endregion + + protected void OnValueChanged(EventArgs e) + { + ValueChanged?.Invoke(this, e); + } + + protected void OnValueDragged(EventArgs e) + { + ValueDragged?.Invoke(this, e); + } + + #region Contextual Menu + + private void BuildContextualMenu() + { + ContextMenuStrip = new ContextMenuStrip(); + ContextMenuStrip.Name = "Timestamp selector"; + ContextMenuStrip.Items.Add(toolStripItemHorizontalDrag); + ContextMenuStrip.Items.Add(toolStripItemVerticalDrag); + ContextMenuStrip.Items.Add(toolStripItemVerticalInvertedDrag); + + toolStripItemHorizontalDrag.Click += OnToolStripItemHorizontalDragClick; + toolStripItemHorizontalDrag.Text = "Drag horizontal"; + + toolStripItemVerticalDrag.Click += OnToolStripItemVerticalDragClick; + toolStripItemVerticalDrag.Text = "Drag vertical"; + + toolStripItemVerticalInvertedDrag.Click += OnToolStripItemVerticalInvertedDragClick; + toolStripItemVerticalInvertedDrag.Text = "Drag vertical inverted"; + + ContextMenuStrip.Opening += OnContextMenuStripOpening; + + UpdateContextMenu(); + } + + private void UpdateContextMenu() + { + toolStripItemHorizontalDrag.Enabled = DragOrientation != DragOrientationsEnum.Horizontal; + toolStripItemVerticalDrag.Enabled = DragOrientation != DragOrientationsEnum.Vertical; + toolStripItemVerticalInvertedDrag.Enabled = DragOrientation != DragOrientationsEnum.InvertedVertical; + } + + private void OnContextMenuStripOpening(object sender, CancelEventArgs e) + { + if (Capture) + { + e.Cancel = true; + } + } + + private void OnToolStripItemHorizontalDragClick(object sender, EventArgs e) + { + DragOrientation = DragOrientationsEnum.Horizontal; + toolStripItemHorizontalDrag.Enabled = false; + toolStripItemVerticalDrag.Enabled = true; + toolStripItemVerticalInvertedDrag.Enabled = true; + } + + private void OnToolStripItemVerticalDragClick(object sender, EventArgs e) + { + DragOrientation = DragOrientationsEnum.Vertical; + toolStripItemHorizontalDrag.Enabled = true; + toolStripItemVerticalDrag.Enabled = false; + toolStripItemVerticalInvertedDrag.Enabled = true; + } + + private void OnToolStripItemVerticalInvertedDragClick(object sender, EventArgs e) + { + DragOrientation = DragOrientationsEnum.InvertedVertical; + toolStripItemHorizontalDrag.Enabled = true; + toolStripItemVerticalDrag.Enabled = true; + toolStripItemVerticalInvertedDrag.Enabled = false; + } + + #endregion + + #region Rendering + + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + + // Show what digit is dragged + using (Brush hoverBrush = new SolidBrush(HoverColor)) + { + if (_draggedDigit != NO_DIGIT_DRAGGED) + { + e.Graphics.FillRectangle(hoverBrush, _digitRects[_draggedDigit]); + } + } + + // Display current value with user-defined date format and fixed time format ("HH:mm:ss") + using (Brush brush = new SolidBrush(Color.Black)) + { + for (int i = 0; i < _dateParts.Length; i++) + { + string datePart = _dateParts[i]; + Rectangle rect = _digitRects[i]; + string value; + + if (Token.IsDatePart(datePart)) + { + try + { + value = _dateTime.ToString("-" + datePart + "-"); + value = value.Substring(1, value.Length - 2); + } + catch + { + value = datePart; + } + } + else + { + value = datePart; + } + + e.Graphics.DrawString(value, Font, brush, rect, _digitsFormat); + } + } + } + + private void DateTimeDragControl_Resize(object sender, EventArgs e) + { + InitDigitRects(); + } + + #endregion + + #region Mouse callbacks + + protected override void OnMouseDown(MouseEventArgs e) + { + base.OnMouseDown(e); + + if (e.Button == MouseButtons.Left) + { + _draggedDigit = DetermineDraggedDigit(e); + if (_draggedDigit == NO_DIGIT_DRAGGED) + { + return; + } + Capture = true; + _startMouseY = e.Y; + _startMouseX = e.X; + _oldValue = GetDraggedValue(); + _addedValue = 0; + } + else if (e.Button == MouseButtons.Right && Capture) + { + Capture = false; + SetDraggedValue(0); //undo + } + Invalidate(); // repaint with the selected item (or none) + } + + protected override void OnMouseUp(MouseEventArgs e) + { + if (!Capture) + { + return; + } + + base.OnMouseUp(e); + + Capture = false; + _draggedDigit = NO_DIGIT_DRAGGED; + Invalidate(); // repaint without the selected item + + OnValueChanged(EventArgs.Empty); + } + + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + + if (!Capture) + { + return; + } + + int diff; + switch (DragOrientation) + { + case DragOrientationsEnum.Vertical: + { + diff = _startMouseY - e.Y; + break; + } + case DragOrientationsEnum.InvertedVertical: + { + diff = _startMouseY + e.Y; + break; + } + default: + { + diff = e.X - _startMouseX; + break; + } + } + + int delta = diff / 5 - _addedValue; // one unit per 5 pixels move + + if (delta == 0) + { + return; + } + + if (SetDraggedValue(delta)) + { + _addedValue += delta; + } + + Invalidate(); + + OnValueDragged(EventArgs.Empty); + } + + private void DateTimeDragControl_MouseLeave(object sender, EventArgs e) + { + if (Capture) + { + return; + } + + _draggedDigit = NO_DIGIT_DRAGGED; + Refresh(); + } + + #endregion + } +} diff --git a/src/LogExpert/Dialogs/DateTimeDragControl.resx b/src/LogExpert/Controls/DateTimeDragControl.resx similarity index 97% rename from src/LogExpert/Dialogs/DateTimeDragControl.resx rename to src/LogExpert/Controls/DateTimeDragControl.resx index ff31a6db..19dc0dd8 100644 --- a/src/LogExpert/Dialogs/DateTimeDragControl.resx +++ b/src/LogExpert/Controls/DateTimeDragControl.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/LogExpert/Controls/KnobControl.Designer.cs b/src/LogExpert/Controls/KnobControl.Designer.cs deleted file mode 100644 index 4b897228..00000000 --- a/src/LogExpert/Controls/KnobControl.Designer.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace LogExpert.Controls -{ - partial class KnobControl - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.SuspendLayout(); - // - // KnobControl - // - this.Name = "KnobControl"; - this.Size = new System.Drawing.Size(21, 21); - this.ResumeLayout(false); - - } - - #endregion - } -} diff --git a/src/LogExpert/Controls/KnobControl.cs b/src/LogExpert/Controls/KnobControl.cs deleted file mode 100644 index 3a9846b1..00000000 --- a/src/LogExpert/Controls/KnobControl.cs +++ /dev/null @@ -1,184 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; -using NLog; - -namespace LogExpert.Controls -{ - public partial class KnobControl : UserControl - { - #region Fields - - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - - - private readonly StringFormat stringFormat = new(); - - private bool isShiftPressed = false; - - private int oldValue = 0; - private int startMouseY = 0; - private int value; - - #endregion - - #region cTor - - public KnobControl() - { - InitializeComponent(); - stringFormat.LineAlignment = StringAlignment.Far; - stringFormat.Alignment = StringAlignment.Center; - } - - #endregion - - #region Delegates - - public delegate void ValueChangedEventHandler(object sender, EventArgs e); - - #endregion - - #region Events - - public event ValueChangedEventHandler ValueChanged; - - #endregion - - #region Properties - - public int MinValue { get; set; } - - public int MaxValue { get; set; } - - public int Value - { - get { return this.value; } - set - { - this.value = value; - Refresh(); - } - } - - - public int Range - { - get { return this.MaxValue - this.MinValue; } - } - - public int DragSensitivity { get; set; } = 3; - - #endregion - - #region Overrides - - protected override void OnPaint(PaintEventArgs e) - { - base.OnPaint(e); - - Color foregroundColor = this.Enabled ? Color.Black : Color.Gray; - - Pen blackPen = new(foregroundColor, 1); - Pen greyPen = new(Color.Gray, 1); - - Rectangle rect = this.ClientRectangle; - int height = this.Font.Height + 3; - if (height > rect.Height) - { - height = rect.Height + 3; - } - rect.Inflate(-1, -height / 2); - rect.Offset(0, -height / 2); - e.Graphics.DrawEllipse(greyPen, rect); - - //rect = this.ClientRectangle; - rect.Inflate(-2, -2); - - float startAngle = 135.0F + 270F * ((float) this.value / (float) this.Range); - float sweepAngle = 0.1F; - e.Graphics.DrawPie(blackPen, rect, startAngle, sweepAngle); - - Brush brush = new SolidBrush(foregroundColor); - RectangleF rectF = new(0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height); - e.Graphics.DrawString("" + this.value, this.Font, brush, rectF, this.stringFormat); - - blackPen.Dispose(); - greyPen.Dispose(); - brush.Dispose(); - } - - protected override void OnMouseDown(MouseEventArgs e) - { - base.OnMouseDown(e); - - if (e.Button == MouseButtons.Left) - { - Capture = true; - startMouseY = e.Y; - this.oldValue = this.Value; - } - if (e.Button == MouseButtons.Right) - { - Capture = false; - this.Value = this.oldValue; - this.Invalidate(); - } - } - - protected override void OnMouseUp(MouseEventArgs e) - { - base.OnMouseUp(e); - Capture = false; - this.oldValue = this.Value; - OnValueChanged(new EventArgs()); - } - - protected override void OnMouseMove(MouseEventArgs e) - { - base.OnMouseMove(e); - if (!Capture) - { - return; - } - - int sense = this.isShiftPressed ? this.DragSensitivity * 2 : this.DragSensitivity; - - int diff = this.startMouseY - e.Y; - _logger.Debug("KnobDiff: {0}", diff); - int range = this.MaxValue - this.MinValue; - this.value = this.oldValue + diff / sense; - if (this.value < this.MinValue) - { - this.value = this.MinValue; - } - if (this.value > this.MaxValue) - { - this.value = this.MaxValue; - } - this.Invalidate(); - } - - protected override void OnKeyDown(KeyEventArgs e) - { - this.isShiftPressed = e.Shift; - base.OnKeyDown(e); - } - - protected override void OnKeyUp(KeyEventArgs e) - { - this.isShiftPressed = e.Shift; - base.OnKeyUp(e); - } - - #endregion - - protected void OnValueChanged(EventArgs e) - { - if (ValueChanged != null) - { - ValueChanged(this, e); - } - } - } -} \ No newline at end of file diff --git a/src/LogExpert/Controls/LogTabControl.cs b/src/LogExpert/Controls/LogTabControl.cs deleted file mode 100644 index 8f19e2c2..00000000 --- a/src/LogExpert/Controls/LogTabControl.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert.Controls -{ - internal class LogTabControl : TabControl - { - #region Fields - - private BufferedGraphics myBuffer; - - #endregion - - #region cTor - - public LogTabControl() - : base() - { - //SetStyle(ControlStyles.AllPaintingInWmPaint, true); - //SetStyle(ControlStyles.UserPaint, true); - //SetStyle(ControlStyles.DoubleBuffer, true); - } - - #endregion - - #region Overrides - - protected override void OnPaint(PaintEventArgs e) - { - BufferedGraphicsContext currentContext; - currentContext = BufferedGraphicsManager.Current; - myBuffer = currentContext.Allocate(this.CreateGraphics(), this.DisplayRectangle); - - PaintEventArgs args = new(myBuffer.Graphics, e.ClipRectangle); - - base.OnPaint(args); - - myBuffer.Render(e.Graphics); - myBuffer.Dispose(); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert/Controls/LogTabPage.cs b/src/LogExpert/Controls/LogTabPage.cs index 0f8ea3c4..e80ffa0b 100644 --- a/src/LogExpert/Controls/LogTabPage.cs +++ b/src/LogExpert/Controls/LogTabPage.cs @@ -14,8 +14,8 @@ internal class LogTabPage : TabPage private const int DIFF_MAX = 100; private int _diffSum = 0; private readonly object _diffSumLock = new(); - private readonly Thread ledThread; - private bool shouldStop = false; + private readonly Thread _ledThread; + private bool _shouldStop = false; #endregion @@ -29,9 +29,12 @@ public LogTabPage(LogWindow.LogWindow logWindow, string title) LogWindow = logWindow; LogWindow.FileSizeChanged += FileSizeChanged; LogWindow.TailFollowed += TailFollowed; - ledThread = new Thread(new ThreadStart(LedThreadProc)); - ledThread.IsBackground = true; - ledThread.Start(); + _ledThread = new Thread(new ThreadStart(LedThreadProc)) + { + IsBackground = true + }; + + _ledThread.Start(); } #endregion @@ -64,9 +67,9 @@ public int LineDiff public void Delete() { - shouldStop = true; - ledThread.Interrupt(); - ledThread.Join(); + _shouldStop = true; + _ledThread.Interrupt(); + _ledThread.Join(); } #endregion @@ -75,7 +78,7 @@ public void Delete() private void LedThreadProc() { - while (!shouldStop) + while (!_shouldStop) { try { diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs index 70d14d9d..42f1dbc2 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs @@ -2,8 +2,8 @@ using LogExpert.Core.Config; using LogExpert.Core.Entities; using LogExpert.Dialogs; -using LogExpert.Extensions.Forms; using LogExpert.Interface; +using LogExpert.UI.Extensions.Forms; using NLog; diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs index 76eedf44..e90da425 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs @@ -2,7 +2,7 @@ using LogExpert.Core.Enums; using LogExpert.Dialogs; -using LogExpert.Extensions.Forms; +using LogExpert.UI.Extensions.Forms; using WeifenLuo.WinFormsUI.Docking; diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs index 32202229..b17e897a 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs @@ -3,7 +3,7 @@ using LogExpert.Core.Classes.Persister; using LogExpert.Core.Config; using LogExpert.Core.Entities; -using LogExpert.Core.Entities.EventArgs; +using LogExpert.Core.EventArgs; using LogExpert.Dialogs; using LogExpert.Entities.EventArgs; using LogExpert.UI.Dialogs; diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindowPrivate.cs index 723569da..2c8a697a 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindowPrivate.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindowPrivate.cs @@ -5,10 +5,11 @@ using LogExpert.Core.Classes.Persister; using LogExpert.Core.Config; using LogExpert.Core.Entities; -using LogExpert.Core.Entities.EventArgs; using LogExpert.Core.Enums; +using LogExpert.Core.EventArgs; using LogExpert.Dialogs; using LogExpert.PluginRegistry.FileSystem; +using LogExpert.UI.Dialogs; using System; using System.Collections.Generic; @@ -69,9 +70,12 @@ private void DestroyToolWindows() private void InitBookmarkWindow() { - _bookmarkWindow = new BookmarkWindow(); - _bookmarkWindow.HideOnClose = true; - _bookmarkWindow.ShowHint = DockState.DockBottom; + _bookmarkWindow = new BookmarkWindow + { + HideOnClose = true, + ShowHint = DockState.DockBottom + }; + _bookmarkWindow.PreferencesChanged(ConfigManager.Settings.Preferences, false, SettingsFlags.All); _bookmarkWindow.VisibleChanged += OnBookmarkWindowVisibleChanged; _firstBookmarkWindowShow = true; @@ -1124,7 +1128,7 @@ private void StartTool(string cmd, string args, bool sysoutPipe, string columniz private void CloseAllTabs() { - IList
closeList = new List(); + IList closeList = []; lock (_logWindowList) { foreach (DockContent content in dockPanel.Contents) diff --git a/src/LogExpert/Controls/LogWindow/LogWindow.cs b/src/LogExpert/Controls/LogWindow/LogWindow.cs index be90897d..42bb9fab 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindow.cs @@ -9,11 +9,12 @@ using LogExpert.Core.Classes.Persister; using LogExpert.Core.Config; using LogExpert.Core.Entities; -using LogExpert.Core.Entities.EventArgs; +using LogExpert.Core.EventArgs; using LogExpert.Core.Interface; using LogExpert.Dialogs; using LogExpert.Entities.EventArgs; -using LogExpert.Extensions.Forms; +using LogExpert.UI.Dialogs; +using LogExpert.UI.Extensions.Forms; using NLog; @@ -183,10 +184,10 @@ public LogWindow(LogTabWindow.LogTabWindow parent, string fileName, bool isTempF _parentLogTabWin.HighlightSettingsChanged += OnParentHighlightSettingsChanged; SetColumnizer(PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers[0]); - _patternArgs.maxMisses = 5; - _patternArgs.minWeight = 1; - _patternArgs.maxDiffInBlock = 5; - _patternArgs.fuzzy = 5; + _patternArgs.MaxMisses = 5; + _patternArgs.MinWeight = 1; + _patternArgs.MaxDiffInBlock = 5; + _patternArgs.Fuzzy = 5; //InitPatternWindow(); @@ -559,10 +560,13 @@ internal void RefreshAllGrids() internal void ChangeMultifileMask() { - MultiFileMaskDialog dlg = new(this, FileName); - dlg.Owner = this; - dlg.MaxDays = _multiFileOptions.MaxDayTry; - dlg.FileNamePattern = _multiFileOptions.FormatPattern; + MultiFileMaskDialog dlg = new(this, FileName) + { + Owner = this, + MaxDays = _multiFileOptions.MaxDayTry, + FileNamePattern = _multiFileOptions.FormatPattern + }; + if (dlg.ShowDialog() == DialogResult.OK) { _multiFileOptions.FormatPattern = dlg.FileNamePattern; @@ -638,7 +642,7 @@ private void OnButtonSizeChanged(object sender, EventArgs e) private delegate void PositionAfterReloadFx(ReloadMemento reloadMemento); - private delegate void AutoResizeColumnsFx(DataGridView gridView); + private delegate void AutoResizeColumnsFx(BufferedDataGridView gridView); private delegate bool BoolReturnDelegate(); diff --git a/src/LogExpert/Controls/LogWindow/LogWindow.designer.cs b/src/LogExpert/Controls/LogWindow/LogWindow.designer.cs index 7300c4fb..64ca94ef 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindow.designer.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindow.designer.cs @@ -1,5 +1,5 @@ using LogExpert.Dialogs; -using LogExpert.Extensions.Forms; +using LogExpert.UI.Extensions.Forms; using System; using System.Drawing; diff --git a/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs index f436f5b6..97f372fc 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs @@ -9,13 +9,13 @@ using LogExpert.Core.Classes.Highlight; using LogExpert.Core.Config; using LogExpert.Core.Entities; -using LogExpert.Core.Entities.EventArgs; +using LogExpert.Core.EventArgs; using LogExpert.Core.Interface; using LogExpert.Dialogs; using LogExpert.Entities; using LogExpert.Entities.EventArgs; -using LogExpert.Extensions; using LogExpert.UI.Dialogs; +using LogExpert.UI.Extensions; using System; using System.Collections.Generic; @@ -369,7 +369,7 @@ private void OnFilterSearchButtonClick(object sender, EventArgs e) private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintingEventArgs e) { - DataGridView gridView = (DataGridView)sender; + BufferedDataGridView gridView = (BufferedDataGridView)sender; if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) { @@ -379,6 +379,7 @@ private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintin int lineNum = _filterResultList[e.RowIndex]; ILogLine line = _logFileReader.GetLogLineWithWait(lineNum).Result; + if (line != null) { HilightEntry entry = FindFirstNoWordMatchHilightEntry(line); @@ -387,6 +388,7 @@ private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintin { Color backColor = e.CellStyle.SelectionBackColor; Brush brush; + if (gridView.Focused) { brush = new SolidBrush(e.CellStyle.SelectionBackColor); @@ -1029,7 +1031,7 @@ private void OnFilterGridViewCellContextMenuStripNeeded(object sender, DataGridV private void OnColumnContextMenuStripOpening(object sender, CancelEventArgs e) { Control ctl = columnContextMenuStrip.SourceControl; - DataGridView gridView = ctl as DataGridView; + BufferedDataGridView gridView = ctl as BufferedDataGridView; bool frozen = false; if (_freezeStateMap.ContainsKey(ctl)) { @@ -1044,7 +1046,7 @@ private void OnColumnContextMenuStripOpening(object sender, CancelEventArgs e) } else { - if (ctl is DataGridView) + if (ctl is BufferedDataGridView) { freezeLeftColumnsUntilHereToolStripMenuItem.Text = $"Freeze left columns until here ({gridView.Columns[_selectedCol].HeaderText})"; } @@ -1112,7 +1114,7 @@ private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick(object sender, E _freezeStateMap[ctl] = frozen; DataGridViewColumn senderCol = sender as DataGridViewColumn; - if (ctl is DataGridView gridView) + if (ctl is BufferedDataGridView gridView) { ApplyFrozenState(gridView); } @@ -1120,7 +1122,7 @@ private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick(object sender, E private void OnMoveToLastColumnToolStripMenuItemClick(object sender, EventArgs e) { - DataGridView gridView = columnContextMenuStrip.SourceControl as DataGridView; + BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; DataGridViewColumn col = gridView.Columns[_selectedCol]; if (col != null) { @@ -1130,7 +1132,7 @@ private void OnMoveToLastColumnToolStripMenuItemClick(object sender, EventArgs e private void OnMoveLeftToolStripMenuItemClick(object sender, EventArgs e) { - DataGridView gridView = columnContextMenuStrip.SourceControl as DataGridView; + BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; DataGridViewColumn col = gridView.Columns[_selectedCol]; if (col != null && col.DisplayIndex > 0) { @@ -1140,7 +1142,7 @@ private void OnMoveLeftToolStripMenuItemClick(object sender, EventArgs e) private void OnMoveRightToolStripMenuItemClick(object sender, EventArgs e) { - DataGridView gridView = columnContextMenuStrip.SourceControl as DataGridView; + BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; DataGridViewColumn col = gridView.Columns[_selectedCol]; if (col != null && col.DisplayIndex < gridView.Columns.Count - 1) { @@ -1150,14 +1152,14 @@ private void OnMoveRightToolStripMenuItemClick(object sender, EventArgs e) private void OnHideColumnToolStripMenuItemClick(object sender, EventArgs e) { - DataGridView gridView = columnContextMenuStrip.SourceControl as DataGridView; + BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; DataGridViewColumn col = gridView.Columns[_selectedCol]; col.Visible = false; } private void OnRestoreColumnsToolStripMenuItemClick(object sender, EventArgs e) { - DataGridView gridView = columnContextMenuStrip.SourceControl as DataGridView; + BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; foreach (DataGridViewColumn col in gridView.Columns) { col.Visible = true; diff --git a/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs index 1fdd4ba2..722e85fc 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs @@ -9,10 +9,11 @@ using LogExpert.Core.Classes.Persister; using LogExpert.Core.Config; using LogExpert.Core.Entities; -using LogExpert.Core.Entities.EventArgs; +using LogExpert.Core.EventArgs; using LogExpert.Core.Interface; using LogExpert.Dialogs; using LogExpert.Extensions; +using LogExpert.UI.Controls; using System; using System.Collections.Generic; @@ -1093,7 +1094,7 @@ private void SetColumnizerInternal(ILogLineColumnizer columnizer) OnColumnizerChanged(CurrentColumnizer); } - private void AutoResizeColumns(DataGridView gridView) + private void AutoResizeColumns(BufferedDataGridView gridView) { try { @@ -1117,13 +1118,13 @@ private void AutoResizeColumns(DataGridView gridView) } } - private void PaintCell(DataGridViewCellPaintingEventArgs e, DataGridView gridView, bool noBackgroundFill, + private void PaintCell(DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HilightEntry groundEntry) { PaintHighlightedCell(e, gridView, noBackgroundFill, groundEntry); } - private void PaintHighlightedCell(DataGridViewCellPaintingEventArgs e, DataGridView gridView, + private void PaintHighlightedCell(DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HilightEntry groundEntry) { @@ -2540,7 +2541,7 @@ private void AdjustMinimumGridWith() } } - private void InvalidateCurrentRow(DataGridView gridView) + private void InvalidateCurrentRow(BufferedDataGridView gridView) { if (gridView.CurrentCellAddress.Y > -1) { @@ -2916,7 +2917,7 @@ private void SetExplicitEncoding(Encoding encoding) EncodingOptions.Encoding = encoding; } - private void ApplyDataGridViewPrefs(DataGridView dataGridView, Preferences prefs) + private void ApplyDataGridViewPrefs(BufferedDataGridView dataGridView, Preferences prefs) { if (dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) > 1) { @@ -3031,7 +3032,7 @@ private string CalculateColumnNames(FilterParams filter) return names; } - private void ApplyFrozenState(DataGridView gridView) + private void ApplyFrozenState(BufferedDataGridView gridView) { SortedDictionary dict = []; foreach (DataGridViewColumn col in gridView.Columns) @@ -3076,16 +3077,16 @@ private void InitPatternWindow() _patternWindow.SetColumnizer(CurrentColumnizer); //this.patternWindow.SetBlockList(blockList); _patternWindow.SetFont(Preferences.fontName, Preferences.fontSize); - _patternWindow.Fuzzy = _patternArgs.fuzzy; - _patternWindow.MaxDiff = _patternArgs.maxDiffInBlock; - _patternWindow.MaxMisses = _patternArgs.maxMisses; - _patternWindow.Weight = _patternArgs.minWeight; + _patternWindow.Fuzzy = _patternArgs.Fuzzy; + _patternWindow.MaxDiff = _patternArgs.MaxDiffInBlock; + _patternWindow.MaxMisses = _patternArgs.MaxMisses; + _patternWindow.Weight = _patternArgs.MinWeight; //this.patternWindow.Show(); } private void TestStatistic(PatternArgs patternArgs) { - int beginLine = patternArgs.startLine; + int beginLine = patternArgs.StartLine; _logger.Info("TestStatistics() called with start line {0}", beginLine); _patternArgs = patternArgs; @@ -3115,7 +3116,7 @@ private void TestStatistic(PatternArgs patternArgs) } PatternBlock block; - int maxBlockLen = patternArgs.endLine - patternArgs.startLine; + int maxBlockLen = patternArgs.EndLine - patternArgs.StartLine; //int searchLine = i + 1; _logger.Debug("TestStatistic(): i={0} searchLine={1}", i, searchLine); //bool firstBlock = true; @@ -3123,12 +3124,12 @@ private void TestStatistic(PatternArgs patternArgs) UpdateProgressBar(searchLine); while (!_shouldCancel && (block = - DetectBlock(i, searchLine, maxBlockLen, _patternArgs.maxDiffInBlock, - _patternArgs.maxMisses, + DetectBlock(i, searchLine, maxBlockLen, _patternArgs.MaxDiffInBlock, + _patternArgs.MaxMisses, processedLinesDict)) != null) { _logger.Debug("Found block: {0}", block); - if (block.weigth >= _patternArgs.minWeight) + if (block.weigth >= _patternArgs.MinWeight) { //PatternBlock existingBlock = FindExistingBlock(block, blockList); //if (existingBlock != null) @@ -3366,7 +3367,7 @@ private void ResetCache(int num) private int FindSimilarLine(int srcLine, int startLine, Dictionary processedLinesDict) { - int threshold = _patternArgs.fuzzy; + int threshold = _patternArgs.Fuzzy; bool prepared = false; Regex regex = null; @@ -3718,7 +3719,7 @@ private void RemoveAllSearchHighlightEntries() RefreshAllGrids(); } - private DataGridViewColumn GetColumnByName(DataGridView dataGridView, string name) + private DataGridViewColumn GetColumnByName(BufferedDataGridView dataGridView, string name) { foreach (DataGridViewColumn col in dataGridView.Columns) { diff --git a/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs b/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs index fd159b4a..116eb9e5 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs @@ -10,7 +10,8 @@ using LogExpert.Core.Classes.Persister; using LogExpert.Core.Config; using LogExpert.Core.Entities; -using LogExpert.Core.Entities.EventArgs; +using LogExpert.Core.EventArgs; +using LogExpert.Dialogs; using System; using System.Collections.Generic; @@ -343,7 +344,7 @@ public void ColumnizerConfigChanged() SetColumnizerInternal(CurrentColumnizer); } - public void SetColumnizer(ILogLineColumnizer columnizer, DataGridView gridView) + public void SetColumnizer(ILogLineColumnizer columnizer, BufferedDataGridView gridView) { PaintHelper.SetColumnizer(columnizer, gridView); @@ -399,7 +400,7 @@ public IColumn GetCellValue(int rowIndex, int columnIndex) return Column.EmptyColumn; } - public void CellPainting(DataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) + public void CellPainting(BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) { if (rowIndex < 0 || e.ColumnIndex < 0) { @@ -500,7 +501,7 @@ public void CellPainting(DataGridView gridView, int rowIndex, DataGridViewCellPa public void OnDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { - DataGridView gridView = (DataGridView)sender; + BufferedDataGridView gridView = (BufferedDataGridView)sender; CellPainting(gridView, e.RowIndex, e); } @@ -870,7 +871,7 @@ public void AddBookmarkOverlays() public void ToggleBookmark() { - DataGridView gridView; + BufferedDataGridView gridView; int lineNum; if (filterGridView.Focused) @@ -1600,7 +1601,7 @@ public void PatternStatisticSelectRange(PatternArgs patternArgs) { if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) { - List lineNumList = new List(); + List lineNumList = []; foreach (DataGridViewRow row in dataGridView.SelectedRows) { if (row.Index != -1) @@ -1609,20 +1610,20 @@ public void PatternStatisticSelectRange(PatternArgs patternArgs) } } lineNumList.Sort(); - patternArgs.startLine = lineNumList[0]; - patternArgs.endLine = lineNumList[lineNumList.Count - 1]; + patternArgs.StartLine = lineNumList[0]; + patternArgs.EndLine = lineNumList[^1]; } else { if (dataGridView.CurrentCellAddress.Y != -1) { - patternArgs.startLine = dataGridView.CurrentCellAddress.Y; + patternArgs.StartLine = dataGridView.CurrentCellAddress.Y; } else { - patternArgs.startLine = 0; + patternArgs.StartLine = 0; } - patternArgs.endLine = dataGridView.RowCount - 1; + patternArgs.EndLine = dataGridView.RowCount - 1; } } diff --git a/src/LogExpert/Controls/PatternWindow.cs b/src/LogExpert/Controls/PatternWindow.cs index eefc6d9c..b656331b 100644 --- a/src/LogExpert/Controls/PatternWindow.cs +++ b/src/LogExpert/Controls/PatternWindow.cs @@ -1,5 +1,6 @@ using LogExpert.Core.Classes; -using LogExpert.Core.Entities.EventArgs; +using LogExpert.Core.EventArgs; +using LogExpert.Dialogs; using System; using System.Collections.Generic; @@ -215,8 +216,8 @@ private void patternHitsDataGridView_CellPainting(object sender, DataGridViewCel if (e.ColumnIndex == 1) { e.PaintBackground(e.CellBounds, false); - int selCount = patternArgs.endLine - patternArgs.startLine; - int maxWeight = patternArgs.maxDiffInBlock * selCount + selCount; + int selCount = patternArgs.EndLine - patternArgs.StartLine; + int maxWeight = patternArgs.MaxDiffInBlock * selCount + selCount; if (maxWeight > 0) { int width = (int)((double)(int)e.Value / (double)maxWeight * (double)e.CellBounds.Width); @@ -233,7 +234,7 @@ private void patternHitsDataGridView_CellPainting(object sender, DataGridViewCel } else { - DataGridView gridView = (DataGridView)sender; + BufferedDataGridView gridView = (BufferedDataGridView)sender; int rowIndex = GetLineForHitGrid(e.RowIndex); logWindow.CellPainting(gridView, rowIndex, e); } @@ -302,7 +303,7 @@ private void contentDataGridView_CellPainting(object sender, DataGridViewCellPai { return; } - DataGridView gridView = (DataGridView)sender; + BufferedDataGridView gridView = (BufferedDataGridView)sender; int rowIndex = GetLineForContentGrid(e.RowIndex); logWindow.CellPainting(gridView, rowIndex, e); } @@ -320,10 +321,10 @@ private void contentDataGridView_CellMouseDoubleClick(object sender, DataGridVie private void recalcButton_Click(object sender, EventArgs e) { - patternArgs.fuzzy = fuzzyKnobControl.Value; - patternArgs.maxDiffInBlock = maxDiffKnobControl.Value; - patternArgs.maxMisses = maxMissesKnobControl.Value; - patternArgs.minWeight = weigthKnobControl.Value; + patternArgs.Fuzzy = fuzzyKnobControl.Value; + patternArgs.MaxDiffInBlock = maxDiffKnobControl.Value; + patternArgs.MaxMisses = maxMissesKnobControl.Value; + patternArgs.MinWeight = weigthKnobControl.Value; logWindow.PatternStatistic(patternArgs); recalcButton.Enabled = false; setRangeButton.Enabled = false; @@ -352,7 +353,7 @@ private void setRangeButton_Click(object sender, EventArgs e) { logWindow.PatternStatisticSelectRange(patternArgs); recalcButton.Enabled = true; - rangeLabel.Text = "Start: " + patternArgs.startLine + "\r\nEnd: " + patternArgs.endLine; + rangeLabel.Text = "Start: " + patternArgs.StartLine + "\r\nEnd: " + patternArgs.EndLine; } #endregion diff --git a/src/LogExpert/Dialogs/TimeSpreadigControl.Designer.cs b/src/LogExpert/Controls/TimeSpreadigControl.Designer.cs similarity index 97% rename from src/LogExpert/Dialogs/TimeSpreadigControl.Designer.cs rename to src/LogExpert/Controls/TimeSpreadigControl.Designer.cs index 5f8d1dc8..5ae40aa5 100644 --- a/src/LogExpert/Dialogs/TimeSpreadigControl.Designer.cs +++ b/src/LogExpert/Controls/TimeSpreadigControl.Designer.cs @@ -1,49 +1,49 @@ -namespace LogExpert.Dialogs -{ - partial class TimeSpreadingControl - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.SuspendLayout(); - // - // TimeSpreadingControl - // - this.Name = "TimeSpreadingControl"; - this.Size = new System.Drawing.Size(26, 324); - this.MouseLeave += new System.EventHandler(this.TimeSpreadingControl_MouseLeave); - this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.TimeSpreadingControl_MouseMove); - this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TimeSpreadingControl_MouseDown); - this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.TimeSpreadingControl_MouseUp); - this.SizeChanged += new System.EventHandler(this.TimeSpreadingControl_SizeChanged); - this.MouseEnter += new System.EventHandler(this.TimeSpreadingControl_MouseEnter); - this.ResumeLayout(false); - - } - - #endregion - } -} +namespace LogExpert.Dialogs +{ + partial class TimeSpreadingControl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // TimeSpreadingControl + // + this.Name = "TimeSpreadingControl"; + this.Size = new System.Drawing.Size(26, 324); + this.MouseLeave += new System.EventHandler(this.TimeSpreadingControl_MouseLeave); + this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.TimeSpreadingControl_MouseMove); + this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TimeSpreadingControl_MouseDown); + this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.TimeSpreadingControl_MouseUp); + this.SizeChanged += new System.EventHandler(this.TimeSpreadingControl_SizeChanged); + this.MouseEnter += new System.EventHandler(this.TimeSpreadingControl_MouseEnter); + this.ResumeLayout(false); + + } + + #endregion + } +} diff --git a/src/LogExpert/Dialogs/TimeSpreadigControl.cs b/src/LogExpert/Controls/TimeSpreadigControl.cs similarity index 91% rename from src/LogExpert/Dialogs/TimeSpreadigControl.cs rename to src/LogExpert/Controls/TimeSpreadigControl.cs index e9a709ab..f277b8c9 100644 --- a/src/LogExpert/Dialogs/TimeSpreadigControl.cs +++ b/src/LogExpert/Controls/TimeSpreadigControl.cs @@ -1,299 +1,312 @@ -using LogExpert.Classes; -using LogExpert.Core.Classes; - -using NLog; - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public partial class TimeSpreadingControl : UserControl - { - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - #region Fields - - private Bitmap _bitmap = new(1, 1); - private int _displayHeight = 1; - private readonly int _edgeOffset = (int)Win32.GetSystemMetricsForDpi(Win32.SM_CYVSCROLL); - private int _lastMouseY = 0; - private readonly object _monitor = new(); - private int _rectHeight = 1; - - private TimeSpreadCalculator _timeSpreadCalc; - private readonly ToolTip _toolTip; - - #endregion - - #region cTor - - public TimeSpreadingControl() - { - InitializeComponent(); - _toolTip = new ToolTip(); - Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - _toolTip.InitialDelay = 0; - _toolTip.ReshowDelay = 0; - _toolTip.ShowAlways = true; - DoubleBuffered = false; - } - - #endregion - - #region Delegates - - public delegate void LineSelectedEventHandler(object sender, SelectLineEventArgs e); - - #endregion - - #region Events - - public event LineSelectedEventHandler LineSelected; - - #endregion - - #region Properties - - public bool ReverseAlpha { get; set; } - - internal TimeSpreadCalculator TimeSpreadCalc - { - get => _timeSpreadCalc; - set - { - //timeSpreadCalc.CalcDone -= timeSpreadCalc_CalcDone; - _timeSpreadCalc = value; - _timeSpreadCalc.CalcDone += TimeSpreadCalc_CalcDone; - _timeSpreadCalc.StartCalc += TimeSpreadCalc_StartCalc; - } - } - - #endregion - - #region Overrides - - protected override void OnPaint(PaintEventArgs e) - { - base.OnPaint(e); - lock (_monitor) - { - if (DesignMode) - { - Brush bgBrush = new SolidBrush(Color.FromKnownColor(KnownColor.LightSkyBlue)); - Rectangle rect = ClientRectangle; - rect.Inflate(0, -_edgeOffset); - e.Graphics.FillRectangle(bgBrush, rect); - bgBrush.Dispose(); - } - else - { - e.Graphics.DrawImage(_bitmap, 0, _edgeOffset); - } - } - } - - #endregion - - #region Private Methods - - private TimeSpreadCalculator.SpreadEntry GetEntryForMouse(MouseEventArgs e) - { - List list = TimeSpreadCalc.DiffList; - int y = e.Y - _edgeOffset; - if (y < 0) - { - y = 0; - } - else if (y >= ClientRectangle.Height - _edgeOffset * 3) - { - y = list.Count - 1; - } - else - { - y /= _rectHeight; - } - - lock (_monitor) - { - if (y >= list.Count || y < 0) - { - return null; - } - return list[y]; - } - } - - private void DragContrast(MouseEventArgs e) - { - if (_lastMouseY == 0) - { - _lastMouseY = _lastMouseY = e.Y; - return; - } - _timeSpreadCalc.Contrast += (_lastMouseY - e.Y) * 5; - _lastMouseY = e.Y; - } - - private void OnLineSelected(SelectLineEventArgs e) - { - LineSelected?.Invoke(this, e); - } - - #endregion - - #region Events handler - - private void TimeSpreadCalc_CalcDone(object sender, EventArgs e) - { - _logger.Debug("timeSpreadCalc_CalcDone()"); - lock (_monitor) - { - Invalidate(); - Rectangle rect = ClientRectangle; - rect.Size = new Size(rect.Width, rect.Height - _edgeOffset * 3); - if (rect.Height < 1) - { - return; - } - _bitmap = new Bitmap(rect.Width, rect.Height); - Graphics gfx = Graphics.FromImage(_bitmap); - Brush bgBrush = new SolidBrush(BackColor); - gfx.FillRectangle(bgBrush, rect); - bgBrush.Dispose(); - - List list = TimeSpreadCalc.DiffList; - int step; - if (list.Count >= _displayHeight) - { - step = (int)Math.Round(list.Count / (double)_displayHeight); - _rectHeight = 1; - } - else - { - step = 1; - _rectHeight = (int)Math.Round(_displayHeight / (double)list.Count); - } - Rectangle fillRect = new(0, 0, rect.Width, _rectHeight); - - lock (list) - { - for (int i = 0; i < list.Count; i += step) - { - TimeSpreadCalculator.SpreadEntry entry = list[i]; - int color = ReverseAlpha ? entry.Value : 255 - entry.Value; - if (color > 255) - { - color = 255; - } - if (color < 0) - { - color = 0; - } - Brush brush = new SolidBrush(Color.FromArgb(color, ForeColor)); - //Brush brush = new SolidBrush(Color.FromArgb(color, color, color, color)); - gfx.FillRectangle(brush, fillRect); - brush.Dispose(); - fillRect.Offset(0, _rectHeight); - } - } - } - BeginInvoke(new MethodInvoker(Refresh)); - } - - private void TimeSpreadCalc_StartCalc(object sender, EventArgs e) - { - lock (_monitor) - { - Invalidate(); - Rectangle rect = ClientRectangle; - rect.Size = new Size(rect.Width, rect.Height - _edgeOffset * 3); - if (rect.Height < 1) - { - return; - } - //this.bmp = new Bitmap(rect.Width, rect.Height); - Graphics gfx = Graphics.FromImage(_bitmap); - - Brush bgBrush = new SolidBrush(BackColor); - Brush fgBrush = new SolidBrush(ForeColor); - //gfx.FillRectangle(bgBrush, rect); - - StringFormat format = new(StringFormatFlags.DirectionVertical | StringFormatFlags.NoWrap); - format.LineAlignment = StringAlignment.Center; - format.Alignment = StringAlignment.Center; - - RectangleF rectf = new(rect.Left, rect.Top, rect.Width, rect.Height); - - gfx.DrawString("Calculating time spread view...", Font, fgBrush, rectf, format); - - bgBrush.Dispose(); - fgBrush.Dispose(); - } - - BeginInvoke(new MethodInvoker(Refresh)); - } - - private void TimeSpreadingControl_SizeChanged(object sender, EventArgs e) - { - if (TimeSpreadCalc != null) - { - _displayHeight = ClientRectangle.Height - _edgeOffset * 3; - TimeSpreadCalc.SetDisplayHeight(_displayHeight); - } - } - - private void TimeSpreadingControl_MouseDown(object sender, MouseEventArgs e) - { - } - - private void TimeSpreadingControl_MouseUp(object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Left) - { - TimeSpreadCalculator.SpreadEntry entry = GetEntryForMouse(e); - if (entry == null) - { - return; - } - OnLineSelected(new SelectLineEventArgs(entry.LineNum)); - } - } - - private void TimeSpreadingControl_MouseEnter(object sender, EventArgs e) - { - _toolTip.Active = true; - } - - private void TimeSpreadingControl_MouseLeave(object sender, EventArgs e) - { - _toolTip.Active = false; - } - - private void TimeSpreadingControl_MouseMove(object sender, MouseEventArgs e) - { - if (e.Y == _lastMouseY) - { - return; - } - - if (e.Button == MouseButtons.Right) - { - DragContrast(e); - return; - } - - TimeSpreadCalculator.SpreadEntry entry = GetEntryForMouse(e); - if (entry == null) - { - return; - } - _lastMouseY = e.Y; - string dts = entry.Timestamp.ToString("dd.MM.yyyy HH:mm:ss"); - _toolTip.SetToolTip(this, "Line " + (entry.LineNum + 1) + "\n" + dts); - } - - #endregion - } +using LogExpert.Classes; +using LogExpert.Core.Classes; +using LogExpert.Core.EventArgs; + +using NLog; + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; + +namespace LogExpert.Dialogs +{ + public partial class TimeSpreadingControl : UserControl + { + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + + #region Fields + + private Bitmap _bitmap = new(1, 1); + private int _displayHeight = 1; + private readonly int _edgeOffset = (int)Win32.GetSystemMetricsForDpi(Win32.SM_CYVSCROLL); + private int _lastMouseY = 0; + private readonly object _monitor = new(); + private int _rectHeight = 1; + + private TimeSpreadCalculator _timeSpreadCalc; + private readonly ToolTip _toolTip; + + #endregion + + #region cTor + + public TimeSpreadingControl() + { + InitializeComponent(); + _toolTip = new ToolTip(); + Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); + _toolTip.InitialDelay = 0; + _toolTip.ReshowDelay = 0; + _toolTip.ShowAlways = true; + DoubleBuffered = false; + } + + #endregion + + #region Delegates + + public delegate void LineSelectedEventHandler(object sender, SelectLineEventArgs e); + + #endregion + + #region Events + + public event LineSelectedEventHandler LineSelected; + + #endregion + + #region Properties + + public bool ReverseAlpha { get; set; } + + internal TimeSpreadCalculator TimeSpreadCalc + { + get => _timeSpreadCalc; + set + { + //timeSpreadCalc.CalcDone -= timeSpreadCalc_CalcDone; + _timeSpreadCalc = value; + _timeSpreadCalc.CalcDone += TimeSpreadCalc_CalcDone; + _timeSpreadCalc.StartCalc += TimeSpreadCalc_StartCalc; + } + } + + #endregion + + #region Overrides + + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + lock (_monitor) + { + if (DesignMode) + { + Brush bgBrush = new SolidBrush(Color.FromKnownColor(KnownColor.LightSkyBlue)); + Rectangle rect = ClientRectangle; + rect.Inflate(0, -_edgeOffset); + e.Graphics.FillRectangle(bgBrush, rect); + bgBrush.Dispose(); + } + else + { + e.Graphics.DrawImage(_bitmap, 0, _edgeOffset); + } + } + } + + #endregion + + #region Private Methods + + private SpreadEntry GetEntryForMouse(MouseEventArgs e) + { + List list = TimeSpreadCalc.DiffList; + int y = e.Y - _edgeOffset; + if (y < 0) + { + y = 0; + } + else if (y >= ClientRectangle.Height - _edgeOffset * 3) + { + y = list.Count - 1; + } + else + { + y /= _rectHeight; + } + + lock (_monitor) + { + if (y >= list.Count || y < 0) + { + return null; + } + return list[y]; + } + } + + private void DragContrast(MouseEventArgs e) + { + if (_lastMouseY == 0) + { + _lastMouseY = _lastMouseY = e.Y; + return; + } + _timeSpreadCalc.Contrast += (_lastMouseY - e.Y) * 5; + _lastMouseY = e.Y; + } + + private void OnLineSelected(SelectLineEventArgs e) + { + LineSelected?.Invoke(this, e); + } + + #endregion + + #region Events handler + + private void TimeSpreadCalc_CalcDone(object sender, EventArgs e) + { + _logger.Debug("timeSpreadCalc_CalcDone()"); + + lock (_monitor) + { + Invalidate(); + Rectangle rect = ClientRectangle; + rect.Size = new Size(rect.Width, rect.Height - _edgeOffset * 3); + + if (rect.Height < 1) + { + return; + } + + _bitmap = new Bitmap(rect.Width, rect.Height); + Graphics gfx = Graphics.FromImage(_bitmap); + Brush bgBrush = new SolidBrush(BackColor); + gfx.FillRectangle(bgBrush, rect); + bgBrush.Dispose(); + + List list = TimeSpreadCalc.DiffList; + int step; + + if (list.Count >= _displayHeight) + { + step = (int)Math.Round(list.Count / (double)_displayHeight); + _rectHeight = 1; + } + else + { + step = 1; + _rectHeight = (int)Math.Round(_displayHeight / (double)list.Count); + } + + Rectangle fillRect = new(0, 0, rect.Width, _rectHeight); + + lock (list) + { + for (int i = 0; i < list.Count; i += step) + { + SpreadEntry entry = list[i]; + int color = ReverseAlpha ? entry.Value : 255 - entry.Value; + + if (color > 255) + { + color = 255; + } + + if (color < 0) + { + color = 0; + } + + Brush brush = new SolidBrush(Color.FromArgb(color, ForeColor)); + //Brush brush = new SolidBrush(Color.FromArgb(color, color, color, color)); + gfx.FillRectangle(brush, fillRect); + brush.Dispose(); + fillRect.Offset(0, _rectHeight); + } + } + } + BeginInvoke(new MethodInvoker(Refresh)); + } + + private void TimeSpreadCalc_StartCalc(object sender, EventArgs e) + { + lock (_monitor) + { + Invalidate(); + Rectangle rect = ClientRectangle; + rect.Size = new Size(rect.Width, rect.Height - _edgeOffset * 3); + + if (rect.Height < 1) + { + return; + } + + //this.bmp = new Bitmap(rect.Width, rect.Height); + Graphics gfx = Graphics.FromImage(_bitmap); + + Brush bgBrush = new SolidBrush(BackColor); + Brush fgBrush = new SolidBrush(ForeColor); + //gfx.FillRectangle(bgBrush, rect); + + StringFormat format = new(StringFormatFlags.DirectionVertical | StringFormatFlags.NoWrap); + format.LineAlignment = StringAlignment.Center; + format.Alignment = StringAlignment.Center; + + RectangleF rectf = new(rect.Left, rect.Top, rect.Width, rect.Height); + + gfx.DrawString("Calculating time spread view...", Font, fgBrush, rectf, format); + + bgBrush.Dispose(); + fgBrush.Dispose(); + } + + BeginInvoke(new MethodInvoker(Refresh)); + } + + private void TimeSpreadingControl_SizeChanged(object sender, EventArgs e) + { + if (TimeSpreadCalc != null) + { + _displayHeight = ClientRectangle.Height - _edgeOffset * 3; + TimeSpreadCalc.SetDisplayHeight(_displayHeight); + } + } + + private void TimeSpreadingControl_MouseDown(object sender, MouseEventArgs e) + { + } + + private void TimeSpreadingControl_MouseUp(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + SpreadEntry entry = GetEntryForMouse(e); + if (entry == null) + { + return; + } + OnLineSelected(new SelectLineEventArgs(entry.LineNum)); + } + } + + private void TimeSpreadingControl_MouseEnter(object sender, EventArgs e) + { + _toolTip.Active = true; + } + + private void TimeSpreadingControl_MouseLeave(object sender, EventArgs e) + { + _toolTip.Active = false; + } + + private void TimeSpreadingControl_MouseMove(object sender, MouseEventArgs e) + { + if (e.Y == _lastMouseY) + { + return; + } + + if (e.Button == MouseButtons.Right) + { + DragContrast(e); + return; + } + + SpreadEntry entry = GetEntryForMouse(e); + + if (entry == null) + { + return; + } + _lastMouseY = e.Y; + string dts = entry.Timestamp.ToString("dd.MM.yyyy HH:mm:ss"); + _toolTip.SetToolTip(this, "Line " + (entry.LineNum + 1) + "\n" + dts); + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/TimeSpreadigControl.resx b/src/LogExpert/Controls/TimeSpreadigControl.resx similarity index 97% rename from src/LogExpert/Dialogs/TimeSpreadigControl.resx rename to src/LogExpert/Controls/TimeSpreadigControl.resx index ff31a6db..19dc0dd8 100644 --- a/src/LogExpert/Dialogs/TimeSpreadigControl.resx +++ b/src/LogExpert/Controls/TimeSpreadigControl.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/LogExpert/Dialogs/BookmarkCommentDlg.Designer.cs b/src/LogExpert/Dialogs/BookmarkCommentDlg.Designer.cs deleted file mode 100644 index fbb61e1f..00000000 --- a/src/LogExpert/Dialogs/BookmarkCommentDlg.Designer.cs +++ /dev/null @@ -1,90 +0,0 @@ -namespace LogExpert.Dialogs -{ - partial class BookmarkCommentDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BookmarkCommentDlg)); - this.okButton = new System.Windows.Forms.Button(); - this.cancelButton = new System.Windows.Forms.Button(); - this.commentTextBox = new System.Windows.Forms.TextBox(); - this.SuspendLayout(); - // - // okButton - // - this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.okButton.Location = new System.Drawing.Point(150, 86); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(75, 23); - this.okButton.TabIndex = 1; - this.okButton.Text = "OK"; - this.okButton.UseVisualStyleBackColor = true; - // - // cancelButton - // - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(241, 86); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(75, 23); - this.cancelButton.TabIndex = 2; - this.cancelButton.Text = "&Cancel"; - this.cancelButton.UseVisualStyleBackColor = true; - // - // commentTextBox - // - this.commentTextBox.Dock = System.Windows.Forms.DockStyle.Top; - this.commentTextBox.Location = new System.Drawing.Point(0, 0); - this.commentTextBox.Multiline = true; - this.commentTextBox.Name = "commentTextBox"; - this.commentTextBox.Size = new System.Drawing.Size(324, 80); - this.commentTextBox.TabIndex = 0; - // - // BookmarkCommentDlg - // - this.AcceptButton = this.okButton; - this.CancelButton = this.cancelButton; - this.ClientSize = new System.Drawing.Size(324, 115); - this.Controls.Add(this.commentTextBox); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.okButton); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Name = "BookmarkCommentDlg"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "Bookmark comment"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button okButton; - private System.Windows.Forms.Button cancelButton; - private System.Windows.Forms.TextBox commentTextBox; - } -} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/BookmarkCommentDlg.cs b/src/LogExpert/Dialogs/BookmarkCommentDlg.cs deleted file mode 100644 index bc533cfb..00000000 --- a/src/LogExpert/Dialogs/BookmarkCommentDlg.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public partial class BookmarkCommentDlg : Form - { - #region cTor - - public BookmarkCommentDlg() - { - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - InitializeComponent(); - } - - #endregion - - #region Properties - - public string Comment - { - set => commentTextBox.Text = value; - get => commentTextBox.Text; - } - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/BookmarkWindow.cs b/src/LogExpert/Dialogs/BookmarkWindow.cs index 5708b7e3..321ffe5a 100644 --- a/src/LogExpert/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert/Dialogs/BookmarkWindow.cs @@ -3,7 +3,7 @@ using LogExpert.Core.Entities; using LogExpert.Core.Enums; using LogExpert.Core.Interface; -using LogExpert.Extensions.Forms; +using LogExpert.UI.Extensions.Forms; using NLog; @@ -16,6 +16,7 @@ namespace LogExpert.Dialogs { + //TODO can be moved to Logexpert.UI if the PaintHelper has been refactored public partial class BookmarkWindow : DockContent, ISharedToolWindow, IBookmarkView { #region Fields @@ -37,7 +38,7 @@ public BookmarkWindow() AutoScaleDimensions = new SizeF(96F, 96F); AutoScaleMode = AutoScaleMode.Dpi; - bookmarkDataGridView.CellValueNeeded += boomarkDataGridView_CellValueNeeded; + bookmarkDataGridView.CellValueNeeded += OnBoomarkDataGridViewCellValueNeeded; bookmarkDataGridView.CellPainting += boomarkDataGridView_CellPainting; ChangeTheme(Controls); @@ -277,8 +278,7 @@ private void SetFont(string fontName, float fontSize) bookmarkDataGridView.Refresh(); } - - private void CommentPainting(DataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) + private void CommentPainting(BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) { Color backColor = ColorMode.DockBackgroundColor; @@ -323,7 +323,7 @@ private void DeleteSelectedBookmarks() logView?.DeleteBookmarks(lineNumList); } - private static void InvalidateCurrentRow(DataGridView gridView) + private static void InvalidateCurrentRow(BufferedDataGridView gridView) { if (gridView.CurrentCellAddress.Y > -1) { @@ -349,7 +349,6 @@ private void CurrentRowChanged(int rowIndex) } } - private void ShowCommentColumn(bool show) { bookmarkDataGridView.Columns[1].Visible = show; @@ -399,7 +398,7 @@ private void boomarkDataGridView_CellPainting(object sender, DataGridViewCellPai } } - private void boomarkDataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) + private void OnBoomarkDataGridViewCellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { if (bookmarkData == null) { diff --git a/src/LogExpert/Dialogs/BufferedDataGridView.cs b/src/LogExpert/Dialogs/BufferedDataGridView.cs index 81bd8dc1..2c783f07 100644 --- a/src/LogExpert/Dialogs/BufferedDataGridView.cs +++ b/src/LogExpert/Dialogs/BufferedDataGridView.cs @@ -1,4 +1,6 @@ using LogExpert.Core.Entities; +using LogExpert.Core.EventArgs; +using LogExpert.UI.Controls; using NLog; @@ -216,61 +218,60 @@ private BookmarkOverlay GetOverlayForPosition(Point pos) private void PaintOverlays(PaintEventArgs e) { BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current; - using (BufferedGraphics myBuffer = currentContext.Allocate(CreateGraphics(), ClientRectangle)) + + using BufferedGraphics myBuffer = currentContext.Allocate(CreateGraphics(), ClientRectangle); + lock (_overlayList) { - lock (_overlayList) - { - _overlayList.Clear(); - } + _overlayList.Clear(); + } - myBuffer.Graphics.SetClip(ClientRectangle, CombineMode.Union); - e.Graphics.SetClip(ClientRectangle, CombineMode.Union); + myBuffer.Graphics.SetClip(ClientRectangle, CombineMode.Union); + e.Graphics.SetClip(ClientRectangle, CombineMode.Union); - PaintEventArgs args = new(myBuffer.Graphics, e.ClipRectangle); + PaintEventArgs args = new(myBuffer.Graphics, e.ClipRectangle); - base.OnPaint(args); + base.OnPaint(args); - StringFormat format = new(); - format.LineAlignment = StringAlignment.Center; - format.Alignment = StringAlignment.Near; + StringFormat format = new(); + format.LineAlignment = StringAlignment.Center; + format.Alignment = StringAlignment.Near; - myBuffer.Graphics.SetClip(DisplayRectangle, CombineMode.Intersect); + myBuffer.Graphics.SetClip(DisplayRectangle, CombineMode.Intersect); - // Remove Columnheader from Clippingarea - Rectangle rectTableHeader = new(DisplayRectangle.X, DisplayRectangle.Y, DisplayRectangle.Width, ColumnHeadersHeight); - myBuffer.Graphics.SetClip(rectTableHeader, CombineMode.Exclude); + // Remove Columnheader from Clippingarea + Rectangle rectTableHeader = new(DisplayRectangle.X, DisplayRectangle.Y, DisplayRectangle.Width, ColumnHeadersHeight); + myBuffer.Graphics.SetClip(rectTableHeader, CombineMode.Exclude); - //e.Graphics.SetClip(rect, CombineMode.Union); + //e.Graphics.SetClip(rect, CombineMode.Union); - lock (_overlayList) + lock (_overlayList) + { + foreach (BookmarkOverlay overlay in _overlayList.Values) { - foreach (BookmarkOverlay overlay in _overlayList.Values) + SizeF textSize = myBuffer.Graphics.MeasureString(overlay.Bookmark.Text, _font, 300); + Rectangle rectBubble = new(overlay.Position, + new Size((int)textSize.Width, (int)textSize.Height)); + rectBubble.Offset(60, -(rectBubble.Height + 40)); + rectBubble.Inflate(3, 3); + rectBubble.Location += overlay.Bookmark.OverlayOffset; + overlay.BubbleRect = rectBubble; + myBuffer.Graphics.SetClip(rectBubble, CombineMode.Union); // Bubble to clip + myBuffer.Graphics.SetClip(rectTableHeader, CombineMode.Exclude); + e.Graphics.SetClip(rectBubble, CombineMode.Union); + RectangleF textRect = new(rectBubble.X, rectBubble.Y, rectBubble.Width, rectBubble.Height); + myBuffer.Graphics.FillRectangle(_brush, rectBubble); + //myBuffer.Graphics.DrawLine(_pen, overlay.Position, new Point(rect.X, rect.Y + rect.Height / 2)); + myBuffer.Graphics.DrawLine(_pen, overlay.Position, new Point(rectBubble.X, rectBubble.Y + rectBubble.Height)); + myBuffer.Graphics.DrawString(overlay.Bookmark.Text, _font, _textBrush, textRect, format); + + if (_logger.IsDebugEnabled) { - SizeF textSize = myBuffer.Graphics.MeasureString(overlay.Bookmark.Text, _font, 300); - Rectangle rectBubble = new(overlay.Position, - new Size((int)textSize.Width, (int)textSize.Height)); - rectBubble.Offset(60, -(rectBubble.Height + 40)); - rectBubble.Inflate(3, 3); - rectBubble.Location += overlay.Bookmark.OverlayOffset; - overlay.BubbleRect = rectBubble; - myBuffer.Graphics.SetClip(rectBubble, CombineMode.Union); // Bubble to clip - myBuffer.Graphics.SetClip(rectTableHeader, CombineMode.Exclude); - e.Graphics.SetClip(rectBubble, CombineMode.Union); - RectangleF textRect = new(rectBubble.X, rectBubble.Y, rectBubble.Width, rectBubble.Height); - myBuffer.Graphics.FillRectangle(_brush, rectBubble); - //myBuffer.Graphics.DrawLine(_pen, overlay.Position, new Point(rect.X, rect.Y + rect.Height / 2)); - myBuffer.Graphics.DrawLine(_pen, overlay.Position, new Point(rectBubble.X, rectBubble.Y + rectBubble.Height)); - myBuffer.Graphics.DrawString(overlay.Bookmark.Text, _font, _textBrush, textRect, format); - - if (_logger.IsDebugEnabled) - { - _logger.Debug("ClipRgn: {0},{1},{2},{3}", myBuffer.Graphics.ClipBounds.Left, myBuffer.Graphics.ClipBounds.Top, myBuffer.Graphics.ClipBounds.Width, myBuffer.Graphics.ClipBounds.Height); - } + _logger.Debug("ClipRgn: {0},{1},{2},{3}", myBuffer.Graphics.ClipBounds.Left, myBuffer.Graphics.ClipBounds.Top, myBuffer.Graphics.ClipBounds.Width, myBuffer.Graphics.ClipBounds.Height); } } - - myBuffer.Render(e.Graphics); } + + myBuffer.Render(e.Graphics); } #endregion diff --git a/src/LogExpert/Dialogs/HighlightDialog.Designer.cs b/src/LogExpert/Dialogs/HighlightDialog.Designer.cs index e0e5faec..a2b56959 100644 --- a/src/LogExpert/Dialogs/HighlightDialog.Designer.cs +++ b/src/LogExpert/Dialogs/HighlightDialog.Designer.cs @@ -1,4 +1,6 @@ -using System.Drawing; +using LogExpert.UI.Controls; + +using System.Drawing; namespace LogExpert.Dialogs { diff --git a/src/LogExpert/Dialogs/HighlightDialog.cs b/src/LogExpert/Dialogs/HighlightDialog.cs index 8d9d3491..bdb790c0 100644 --- a/src/LogExpert/Dialogs/HighlightDialog.cs +++ b/src/LogExpert/Dialogs/HighlightDialog.cs @@ -1,6 +1,7 @@ using LogExpert.Config; using LogExpert.Core.Classes.Highlight; using LogExpert.Core.Entities; +using LogExpert.UI.Controls; using LogExpert.UI.Dialogs; using NLog; diff --git a/src/LogExpert/Dialogs/LogCellEditingControl.cs b/src/LogExpert/Dialogs/LogCellEditingControl.cs deleted file mode 100644 index 24a68ae0..00000000 --- a/src/LogExpert/Dialogs/LogCellEditingControl.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public class LogCellEditingControl : DataGridViewTextBoxEditingControl - { - #region Public methods - - public override bool EditingControlWantsInputKey(Keys key, bool dataGridViewWantsInputKey) - { - switch (key & Keys.KeyCode) - { - case Keys.Left: - case Keys.Up: - case Keys.Down: - case Keys.Right: - case Keys.Home: - case Keys.End: - case Keys.PageDown: - case Keys.PageUp: - { - return true; - } - } - - return !dataGridViewWantsInputKey; - } - - #endregion - } -} diff --git a/src/LogExpert/Dialogs/LogGridCell.cs b/src/LogExpert/Dialogs/LogGridCell.cs index c63cb1f8..3f0b4222 100644 --- a/src/LogExpert/Dialogs/LogGridCell.cs +++ b/src/LogExpert/Dialogs/LogGridCell.cs @@ -1,4 +1,6 @@ -using System; +using LogExpert.UI.Controls; + +using System; using System.Windows.Forms; namespace LogExpert.Dialogs diff --git a/src/LogExpert/Dialogs/OverlayEventArgs.cs b/src/LogExpert/Dialogs/OverlayEventArgs.cs deleted file mode 100644 index 27d6f877..00000000 --- a/src/LogExpert/Dialogs/OverlayEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -using LogExpert.Core.Entities; - -using System; - -namespace LogExpert.Dialogs -{ - public class OverlayEventArgs : EventArgs - { - #region Fields - - #endregion - - #region cTor - - public OverlayEventArgs(BookmarkOverlay overlay) - { - BookmarkOverlay = overlay; - } - - #endregion - - #region Properties - - public BookmarkOverlay BookmarkOverlay { get; set; } - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/ProjectLoadDlg.Designer.cs b/src/LogExpert/Dialogs/ProjectLoadDlg.Designer.cs deleted file mode 100644 index 66d59c89..00000000 --- a/src/LogExpert/Dialogs/ProjectLoadDlg.Designer.cs +++ /dev/null @@ -1,120 +0,0 @@ -namespace LogExpert.Dialogs -{ - partial class ProjectLoadDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ProjectLoadDlg)); - this.labelInformational = new System.Windows.Forms.Label(); - this.buttonCloseTabs = new System.Windows.Forms.Button(); - this.buttonNewWindow = new System.Windows.Forms.Button(); - this.buttonIgnore = new System.Windows.Forms.Button(); - this.labelChooseHowToProceed = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // labelInformational - // - this.labelInformational.Location = new System.Drawing.Point(12, 9); - this.labelInformational.Name = "labelInformational"; - this.labelInformational.Size = new System.Drawing.Size(178, 41); - this.labelInformational.TabIndex = 0; - this.labelInformational.Text = "Restoring layout requires an empty workbench. \r\n\r\n"; - // - // buttonCloseTabs - // - this.buttonCloseTabs.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonCloseTabs.Location = new System.Drawing.Point(43, 94); - this.buttonCloseTabs.Name = "buttonCloseTabs"; - this.buttonCloseTabs.Size = new System.Drawing.Size(113, 23); - this.buttonCloseTabs.TabIndex = 1; - this.buttonCloseTabs.Text = "Close existing tabs"; - this.buttonCloseTabs.UseVisualStyleBackColor = true; - this.buttonCloseTabs.Click += new System.EventHandler(this.OnButtonCloseTabsClick); - // - // buttonNewWindow - // - this.buttonNewWindow.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonNewWindow.Location = new System.Drawing.Point(43, 124); - this.buttonNewWindow.Name = "buttonNewWindow"; - this.buttonNewWindow.Size = new System.Drawing.Size(113, 23); - this.buttonNewWindow.TabIndex = 2; - this.buttonNewWindow.Text = "Open new window"; - this.buttonNewWindow.UseVisualStyleBackColor = true; - this.buttonNewWindow.Click += new System.EventHandler(this.OnButtonNewWindowClick); - // - // buttonIgnore - // - this.buttonIgnore.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonIgnore.Location = new System.Drawing.Point(43, 154); - this.buttonIgnore.Name = "buttonIgnore"; - this.buttonIgnore.Size = new System.Drawing.Size(113, 23); - this.buttonIgnore.TabIndex = 3; - this.buttonIgnore.Text = "Ignore layout data"; - this.buttonIgnore.UseVisualStyleBackColor = true; - this.buttonIgnore.Click += new System.EventHandler(this.OnButtonIgnoreClick); - // - // labelChooseHowToProceed - // - this.labelChooseHowToProceed.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.labelChooseHowToProceed.AutoSize = true; - this.labelChooseHowToProceed.Location = new System.Drawing.Point(21, 66); - this.labelChooseHowToProceed.Name = "labelChooseHowToProceed"; - this.labelChooseHowToProceed.Size = new System.Drawing.Size(230, 20); - this.labelChooseHowToProceed.TabIndex = 4; - this.labelChooseHowToProceed.Text = "Please choose how to proceed:"; - // - // ProjectLoadDlg - // - this.ClientSize = new System.Drawing.Size(258, 196); - this.Controls.Add(this.labelChooseHowToProceed); - this.Controls.Add(this.buttonIgnore); - this.Controls.Add(this.buttonNewWindow); - this.Controls.Add(this.buttonCloseTabs); - this.Controls.Add(this.labelInformational); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ProjectLoadDlg"; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Loading Session"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label labelInformational; - private System.Windows.Forms.Button buttonCloseTabs; - private System.Windows.Forms.Button buttonNewWindow; - private System.Windows.Forms.Button buttonIgnore; - private System.Windows.Forms.Label labelChooseHowToProceed; - } -} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/ProjectLoadDlg.cs b/src/LogExpert/Dialogs/ProjectLoadDlg.cs deleted file mode 100644 index 2a53437b..00000000 --- a/src/LogExpert/Dialogs/ProjectLoadDlg.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public enum ProjectLoadDlgResult - { - Cancel, - CloseTabs, - NewWindow, - IgnoreLayout - } - - public partial class ProjectLoadDlg : Form - { - #region Fields - - #endregion - - #region cTor - - public ProjectLoadDlg() - { - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - } - - #endregion - - #region Properties - - public ProjectLoadDlgResult ProjectLoadResult { get; set; } = ProjectLoadDlgResult.Cancel; - - #endregion - - #region Events handler - - private void OnButtonCloseTabsClick(object sender, EventArgs e) - { - ProjectLoadResult = ProjectLoadDlgResult.CloseTabs; - Close(); - } - - private void OnButtonNewWindowClick(object sender, EventArgs e) - { - ProjectLoadResult = ProjectLoadDlgResult.NewWindow; - Close(); - } - - private void OnButtonIgnoreClick(object sender, EventArgs e) - { - ProjectLoadResult = ProjectLoadDlgResult.IgnoreLayout; - Close(); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/SelectLineEventArgs.cs b/src/LogExpert/Dialogs/SelectLineEventArgs.cs deleted file mode 100644 index 4f2fa88b..00000000 --- a/src/LogExpert/Dialogs/SelectLineEventArgs.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace LogExpert.Dialogs -{ - public class SelectLineEventArgs : EventArgs - { - #region Fields - - #endregion - - #region cTor - - public SelectLineEventArgs(int line) - { - Line = line; - } - - #endregion - - #region Properties - - public int Line { get; } - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/ToolArgsDialog.cs b/src/LogExpert/Dialogs/ToolArgsDialog.cs index 401604cf..9428c9be 100644 --- a/src/LogExpert/Dialogs/ToolArgsDialog.cs +++ b/src/LogExpert/Dialogs/ToolArgsDialog.cs @@ -81,8 +81,7 @@ private void OnButtonTestClick(object sender, EventArgs e) if (line != null && info != null) { ArgParser parser = new(textBoxArguments.Text); - string args = parser.BuildArgs(line, logTabWin.CurrentLogWindow.GetRealLineNum() + 1, info, - this); + string args = parser.BuildArgs(line, logTabWin.CurrentLogWindow.GetRealLineNum() + 1, info, this); labelTestResult.Text = args; } } diff --git a/src/LogExpert/Entities/EventArgs/CurrentHighlightGroupChangedEventArgs.cs b/src/LogExpert/Entities/EventArgs/CurrentHighlightGroupChangedEventArgs.cs index 1e8b164c..a61a90e6 100644 --- a/src/LogExpert/Entities/EventArgs/CurrentHighlightGroupChangedEventArgs.cs +++ b/src/LogExpert/Entities/EventArgs/CurrentHighlightGroupChangedEventArgs.cs @@ -3,27 +3,13 @@ namespace LogExpert.Entities.EventArgs { - public class CurrentHighlightGroupChangedEventArgs + public class CurrentHighlightGroupChangedEventArgs(LogWindow logWindow, HilightGroup currentGroup) { - #region Fields - - #endregion - - #region cTor - - public CurrentHighlightGroupChangedEventArgs(LogWindow logWindow, HilightGroup currentGroup) - { - LogWindow = logWindow; - CurrentGroup = currentGroup; - } - - #endregion - #region Properties - public LogWindow LogWindow { get; } + public LogWindow LogWindow { get; } = logWindow; - public HilightGroup CurrentGroup { get; } + public HilightGroup CurrentGroup { get; } = currentGroup; #endregion } diff --git a/src/LogExpert/Entities/EventArgs/FilterListChangedEventArgs.cs b/src/LogExpert/Entities/EventArgs/FilterListChangedEventArgs.cs index e5df8ee3..6e664ec8 100644 --- a/src/LogExpert/Entities/EventArgs/FilterListChangedEventArgs.cs +++ b/src/LogExpert/Entities/EventArgs/FilterListChangedEventArgs.cs @@ -2,24 +2,11 @@ namespace LogExpert.Entities.EventArgs { - public class FilterListChangedEventArgs + public class FilterListChangedEventArgs(LogWindow logWindow) { - #region Fields - - #endregion - - #region cTor - - public FilterListChangedEventArgs(LogWindow logWindow) - { - LogWindow = logWindow; - } - - #endregion - #region Properties - public LogWindow LogWindow { get; } + public LogWindow LogWindow { get; } = logWindow; #endregion } diff --git a/src/LogExpert/Entities/WindowFileEntry.cs b/src/LogExpert/Entities/WindowFileEntry.cs index 8a2074be..31a36c81 100644 --- a/src/LogExpert/Entities/WindowFileEntry.cs +++ b/src/LogExpert/Entities/WindowFileEntry.cs @@ -7,21 +7,15 @@ namespace LogExpert.Entities /// /// Represents a log file and its window. Used as a kind of handle for menus or list of open files. /// - public class WindowFileEntry + public class WindowFileEntry(LogWindow logWindow) { #region Fields private const int MAX_LEN = 40; #endregion - #region cTor - public WindowFileEntry(LogWindow logWindow) - { - LogWindow = logWindow; - } - #endregion #region Properties @@ -43,7 +37,7 @@ public string Title public string FileName => LogWindow.FileName; - public LogWindow LogWindow { get; } + public LogWindow LogWindow { get; } = logWindow; #endregion } diff --git a/src/LogExpert/Extensions/ComboBoxExtensions.cs b/src/LogExpert/Extensions/ComboBoxExtensions.cs deleted file mode 100644 index b7488e55..00000000 --- a/src/LogExpert/Extensions/ComboBoxExtensions.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Windows.Forms; - -namespace LogExpert.Extensions -{ - public static class ComboBoxExtensions - { - /// - public static int GetMaxTextWidth(this ComboBox comboBox) - { - var maxTextWidth = comboBox.Width; - - foreach (var item in comboBox.Items) - { - var textWidthInPixels = TextRenderer.MeasureText(item.ToString(), comboBox.Font).Width; - - if (textWidthInPixels > maxTextWidth) - { - maxTextWidth = textWidthInPixels; - } - } - - return maxTextWidth; - } - } -} diff --git a/src/LogExpert/Extensions/Forms/LineToolStripSeparatorExtension.cs b/src/LogExpert/Extensions/Forms/LineToolStripSeparatorExtension.cs deleted file mode 100644 index 92ca94dc..00000000 --- a/src/LogExpert/Extensions/Forms/LineToolStripSeparatorExtension.cs +++ /dev/null @@ -1,37 +0,0 @@ -using LogExpert.Core.Config; - -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert.Extensions.Forms -{ - public class LineToolStripSeparatorExtension : ToolStripSeparator - { - public LineToolStripSeparatorExtension() - { - Paint += OnExtendedToolStripSeparatorPaint; - } - - private void OnExtendedToolStripSeparatorPaint(object sender, PaintEventArgs e) - { - // Get the separator's width and height. - ToolStripSeparator toolStripSeparator = (ToolStripSeparator)sender; - int width = toolStripSeparator.Width; - int height = toolStripSeparator.Height; - - // Choose the colors for drawing. - // I've used Color.White as the foreColor. - Color foreColor = ColorMode.ForeColor; - // Color.Teal as the backColor. - Color backColor = ColorMode.BackgroundColor; - - // Fill the background. - using SolidBrush backbrush = new(backColor); - e.Graphics.FillRectangle(backbrush, 0, 0, width, height); - - // Draw the line. - using Pen pen = new(foreColor); - e.Graphics.DrawLine(pen, width / 2, 4, width / 2, height - 4); - } - } -} diff --git a/src/LogExpert/Extensions/Forms/MenuSelectedColors.cs b/src/LogExpert/Extensions/Forms/MenuSelectedColors.cs deleted file mode 100644 index aaaa5565..00000000 --- a/src/LogExpert/Extensions/Forms/MenuSelectedColors.cs +++ /dev/null @@ -1,32 +0,0 @@ -using LogExpert.Core.Config; - -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert.Extensions.Forms -{ - public class MenuSelectedColors : ProfessionalColorTable - { - public override Color ImageMarginGradientBegin => ColorMode.MenuBackgroundColor; - - public override Color ImageMarginGradientMiddle => ColorMode.MenuBackgroundColor; - - public override Color ImageMarginGradientEnd => ColorMode.MenuBackgroundColor; - - public override Color ToolStripDropDownBackground => ColorMode.MenuBackgroundColor; - - public override Color MenuBorder => ColorMode.MenuBackgroundColor; - - public override Color MenuItemBorder => ColorMode.MenuBackgroundColor; - - public override Color MenuItemSelected => ColorMode.HoverMenuBackgroundColor; - - public override Color MenuItemSelectedGradientBegin => ColorMode.HoverMenuBackgroundColor; - - public override Color MenuItemSelectedGradientEnd => ColorMode.HoverMenuBackgroundColor; - - public override Color MenuItemPressedGradientBegin => ColorMode.MenuBackgroundColor; - - public override Color MenuItemPressedGradientEnd => ColorMode.MenuBackgroundColor; - } -} \ No newline at end of file diff --git a/src/LogExpert/Extensions/Forms/MenuStripExtension.cs b/src/LogExpert/Extensions/Forms/MenuStripExtension.cs deleted file mode 100644 index a3865655..00000000 --- a/src/LogExpert/Extensions/Forms/MenuStripExtension.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Windows.Forms; - -namespace LogExpert.Extensions.Forms -{ - public class ExtendedMenuStripRenderer : ToolStripProfessionalRenderer - { - public ExtendedMenuStripRenderer() : base(new MenuSelectedColors()) { } - } -} diff --git a/src/LogExpert/Extensions/Forms/MenuToolStripSeparatorExtension.cs b/src/LogExpert/Extensions/Forms/MenuToolStripSeparatorExtension.cs deleted file mode 100644 index 0137d680..00000000 --- a/src/LogExpert/Extensions/Forms/MenuToolStripSeparatorExtension.cs +++ /dev/null @@ -1,35 +0,0 @@ -using LogExpert.Core.Config; - -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert.Extensions.Forms -{ - public class MenuToolStripSeparatorExtension : ToolStripSeparator - { - public MenuToolStripSeparatorExtension() - { - Paint += OnExtendedToolStripSeparatorPaint; - } - - private void OnExtendedToolStripSeparatorPaint(object sender, PaintEventArgs e) - { - // Get the separator's width and height. - ToolStripSeparator toolStripSeparator = (ToolStripSeparator)sender; - int width = toolStripSeparator.Width; - int height = toolStripSeparator.Height; - - // Choose the colors for drawing. - // I've used Color.White as the foreColor. - Color foreColor = ColorMode.ForeColor; - // Color.Teal as the backColor. - Color backColor = ColorMode.MenuBackgroundColor; - - // Fill the background. - e.Graphics.FillRectangle(new SolidBrush(backColor), 0, 0, width, height); - - // Draw the line. - e.Graphics.DrawLine(new Pen(foreColor), 4, height / 2, width - 4, height / 2); - } - } -} diff --git a/src/LogExpert/Extensions/Forms/ToolStripRendererExtension.cs b/src/LogExpert/Extensions/Forms/ToolStripRendererExtension.cs deleted file mode 100644 index 6d7f9477..00000000 --- a/src/LogExpert/Extensions/Forms/ToolStripRendererExtension.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Windows.Forms; - -namespace LogExpert.Extensions.Forms -{ - public class ToolStripRendererExtension : ToolStripSystemRenderer - { - public ToolStripRendererExtension() { } - - protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) - { - // Commented on purpose to avoid drawing the border that appears visible in Dark Mode (not visible in Bright mode) - //base.OnRenderToolStripBorder(e); - } - } -} diff --git a/src/LogExpert/LogExpert.csproj b/src/LogExpert/LogExpert.csproj index f21c6774..9d3c42b9 100644 --- a/src/LogExpert/LogExpert.csproj +++ b/src/LogExpert/LogExpert.csproj @@ -30,30 +30,18 @@ Properties\AssemblyVersion.cs - - Component - - - UserControl - - + UserControl - + UserControl - - Component - Component Component - - Component - Key.snk diff --git a/src/LogExpert/Program.cs b/src/LogExpert/Program.cs index d488fa57..27d21ec5 100644 --- a/src/LogExpert/Program.cs +++ b/src/LogExpert/Program.cs @@ -7,6 +7,7 @@ using LogExpert.Core.Classes; using LogExpert.Core.Config; using LogExpert.Dialogs; +using LogExpert.UI.Dialogs; using LogexpertGRPCService.Services; diff --git a/src/Logexpert.Core/Classes/Bookmark/BookmarkDataProvider.cs b/src/Logexpert.Core/Classes/Bookmark/BookmarkDataProvider.cs index 253cd7d5..30a2d94b 100644 --- a/src/Logexpert.Core/Classes/Bookmark/BookmarkDataProvider.cs +++ b/src/Logexpert.Core/Classes/Bookmark/BookmarkDataProvider.cs @@ -29,11 +29,11 @@ public BookmarkDataProvider(SortedList bookmarkList) #region Delegates - public delegate void AllBookmarksRemovedEventHandler(object sender, EventArgs e); + public delegate void AllBookmarksRemovedEventHandler(object sender, System.EventArgs e); - public delegate void BookmarkAddedEventHandler(object sender, EventArgs e); + public delegate void BookmarkAddedEventHandler(object sender, System.EventArgs e); - public delegate void BookmarkRemovedEventHandler(object sender, EventArgs e); + public delegate void BookmarkRemovedEventHandler(object sender, System.EventArgs e); #endregion @@ -160,17 +160,17 @@ public void ClearAllBookmarks() protected void OnBookmarkAdded() { - BookmarkAdded?.Invoke(this, EventArgs.Empty); + BookmarkAdded?.Invoke(this, System.EventArgs.Empty); } protected void OnBookmarkRemoved() { - BookmarkRemoved?.Invoke(this, EventArgs.Empty); + BookmarkRemoved?.Invoke(this, System.EventArgs.Empty); } protected void OnAllBookmarksRemoved() { - AllBookmarksRemoved?.Invoke(this, EventArgs.Empty); + AllBookmarksRemoved?.Invoke(this, System.EventArgs.Empty); } } } \ No newline at end of file diff --git a/src/Logexpert.Core/Classes/Filter/FilterParams.cs b/src/Logexpert.Core/Classes/Filter/FilterParams.cs index 8594297b..d0a8854b 100644 --- a/src/Logexpert.Core/Classes/Filter/FilterParams.cs +++ b/src/Logexpert.Core/Classes/Filter/FilterParams.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections; -using System.Collections.Generic; +using System.Collections; using System.Drawing; using System.Text.RegularExpressions; diff --git a/src/Logexpert.Core/Classes/Highlight/ActionEntry.cs b/src/Logexpert.Core/Classes/Highlight/ActionEntry.cs index f3cf6c5d..85442e15 100644 --- a/src/Logexpert.Core/Classes/Highlight/ActionEntry.cs +++ b/src/Logexpert.Core/Classes/Highlight/ActionEntry.cs @@ -1,6 +1,4 @@ -using System; - -namespace LogExpert.Core.Classes.Highlight +namespace LogExpert.Core.Classes.Highlight { [Serializable] public class ActionEntry : ICloneable diff --git a/src/Logexpert.Core/Classes/SpreadEntry.cs b/src/Logexpert.Core/Classes/SpreadEntry.cs new file mode 100644 index 00000000..f83c81c2 --- /dev/null +++ b/src/Logexpert.Core/Classes/SpreadEntry.cs @@ -0,0 +1,28 @@ +namespace LogExpert.Core.Classes +{ + public class SpreadEntry + { + #region Fields + + public int Diff { get; set; } + + public DateTime Timestamp { get; set; } + + public int LineNum { get; set; } + + public int Value { get; set; } + + #endregion + + #region cTor + + public SpreadEntry(int lineNum, int diff, DateTime timestamp) + { + LineNum = lineNum; + Diff = diff; + Timestamp = timestamp; + } + + #endregion + } +} \ No newline at end of file diff --git a/src/Logexpert.Core/Classes/SysoutPipe.cs b/src/Logexpert.Core/Classes/SysoutPipe.cs index e605d6d5..fbe40830 100644 --- a/src/Logexpert.Core/Classes/SysoutPipe.cs +++ b/src/Logexpert.Core/Classes/SysoutPipe.cs @@ -23,10 +23,14 @@ public SysoutPipe(StreamReader sysout) this.sysout = sysout; FileName = Path.GetTempFileName(); _logger.Info("sysoutPipe created temp file: {0}", FileName); + FileStream fStream = new(FileName, FileMode.Append, FileAccess.Write, FileShare.Read); writer = new StreamWriter(fStream, Encoding.Unicode); - Thread thread = new(new ThreadStart(ReaderThread)); - thread.IsBackground = true; + + Thread thread = new(new ThreadStart(ReaderThread)) + { + IsBackground = true + }; thread.Start(); } @@ -52,7 +56,7 @@ public void DataReceivedEventHandler(object sender, DataReceivedEventArgs e) writer.WriteLine(e.Data); } - public void ProcessExitedEventHandler(object sender, EventArgs e) + public void ProcessExitedEventHandler(object sender, System.EventArgs e) { //ClosePipe(); if (sender.GetType() == typeof(Process)) @@ -67,6 +71,7 @@ public void ProcessExitedEventHandler(object sender, EventArgs e) protected void ReaderThread() { char[] buff = new char[256]; + while (true) { try @@ -84,6 +89,7 @@ protected void ReaderThread() break; } } + ClosePipe(); } } diff --git a/src/Logexpert.Core/Entities/EventArgs/BookmarkEventArgs.cs b/src/Logexpert.Core/Entities/EventArgs/BookmarkEventArgs.cs deleted file mode 100644 index 101c7239..00000000 --- a/src/Logexpert.Core/Entities/EventArgs/BookmarkEventArgs.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace LogExpert.Core.Entities.EventArgs -{ - public class BookmarkEventArgs : System.EventArgs - { - #region Fields - - #endregion - - #region cTor - - public BookmarkEventArgs(Bookmark bookmark) - { - Bookmark = bookmark; - } - - #endregion - - #region Properties - - public Bookmark Bookmark { get; } - - #endregion - } -} \ No newline at end of file diff --git a/src/Logexpert.Core/Entities/EventArgs/ColumnizerEventArgs.cs b/src/Logexpert.Core/Entities/EventArgs/ColumnizerEventArgs.cs deleted file mode 100644 index b67f4156..00000000 --- a/src/Logexpert.Core/Entities/EventArgs/ColumnizerEventArgs.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace LogExpert.Core.Entities.EventArgs -{ - public class ColumnizerEventArgs : System.EventArgs - { - #region Fields - - #endregion - - #region cTor - - public ColumnizerEventArgs(ILogLineColumnizer columnizer) - { - Columnizer = columnizer; - } - - #endregion - - #region Properties - - public ILogLineColumnizer Columnizer { get; } - - #endregion - } -} \ No newline at end of file diff --git a/src/Logexpert.Core/Entities/EventArgs/ConfigChangedEventArgs.cs b/src/Logexpert.Core/Entities/EventArgs/ConfigChangedEventArgs.cs deleted file mode 100644 index b06a9a37..00000000 --- a/src/Logexpert.Core/Entities/EventArgs/ConfigChangedEventArgs.cs +++ /dev/null @@ -1,26 +0,0 @@ -using LogExpert.Core.Config; - -namespace LogExpert.Core.Entities.EventArgs -{ - public class ConfigChangedEventArgs : System.EventArgs - { - #region Fields - - #endregion - - #region cTor - - public ConfigChangedEventArgs(SettingsFlags changeFlags) - { - Flags = changeFlags; - } - - #endregion - - #region Properties - - public SettingsFlags Flags { get; } - - #endregion - } -} \ No newline at end of file diff --git a/src/Logexpert.Core/Entities/EventArgs/ContextMenuPluginEventArgs.cs b/src/Logexpert.Core/Entities/EventArgs/ContextMenuPluginEventArgs.cs deleted file mode 100644 index 019bfab7..00000000 --- a/src/Logexpert.Core/Entities/EventArgs/ContextMenuPluginEventArgs.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace LogExpert.Core.Entities.EventArgs -{ - public class ContextMenuPluginEventArgs : System.EventArgs - { - #region Fields - - #endregion - - #region cTor - - public ContextMenuPluginEventArgs(IContextMenuEntry entry, IList logLines, ILogLineColumnizer columnizer, - ILogExpertCallback callback) - { - Entry = entry; - LogLines = logLines; - Columnizer = columnizer; - Callback = callback; - } - - #endregion - - #region Properties - - public IContextMenuEntry Entry { get; } - - public IList LogLines { get; } - - public ILogLineColumnizer Columnizer { get; } - - public ILogExpertCallback Callback { get; } - - #endregion - } -} \ No newline at end of file diff --git a/src/Logexpert.Core/Entities/EventArgs/PatternArgs.cs b/src/Logexpert.Core/Entities/EventArgs/PatternArgs.cs deleted file mode 100644 index d8d05975..00000000 --- a/src/Logexpert.Core/Entities/EventArgs/PatternArgs.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace LogExpert.Core.Entities.EventArgs -{ - public class PatternArgs - { - #region Fields - - public int endLine = 0; - public int fuzzy = 6; - public int maxDiffInBlock = 5; - public int maxMisses = 5; - public int minWeight = 15; - public int startLine = 0; - - #endregion - } -} \ No newline at end of file diff --git a/src/Logexpert.Core/Entities/EventArgs/SyncModeEventArgs.cs b/src/Logexpert.Core/Entities/EventArgs/SyncModeEventArgs.cs deleted file mode 100644 index c2e13db3..00000000 --- a/src/Logexpert.Core/Entities/EventArgs/SyncModeEventArgs.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace LogExpert.Core.Entities.EventArgs -{ - public class SyncModeEventArgs : System.EventArgs - { - #region Fields - - #endregion - - #region cTor - - public SyncModeEventArgs(bool isSynced) - { - IsTimeSynced = isSynced; - } - - #endregion - - #region Properties - - public bool IsTimeSynced { get; } - - #endregion - } -} \ No newline at end of file diff --git a/src/Logexpert.Core/Enums/ProjectLoadDlgResult.cs b/src/Logexpert.Core/Enums/ProjectLoadDlgResult.cs new file mode 100644 index 00000000..aa1f648b --- /dev/null +++ b/src/Logexpert.Core/Enums/ProjectLoadDlgResult.cs @@ -0,0 +1,10 @@ +namespace LogExpert.Core.Enums +{ + public enum ProjectLoadDlgResult + { + Cancel, + CloseTabs, + NewWindow, + IgnoreLayout + } +} \ No newline at end of file diff --git a/src/Logexpert.Core/EventArgs/BookmarkEventArgs.cs b/src/Logexpert.Core/EventArgs/BookmarkEventArgs.cs new file mode 100644 index 00000000..40456151 --- /dev/null +++ b/src/Logexpert.Core/EventArgs/BookmarkEventArgs.cs @@ -0,0 +1,13 @@ +using LogExpert.Core.Entities; + +namespace LogExpert.Core.EventArgs +{ + public class BookmarkEventArgs(Bookmark bookmark) : System.EventArgs + { + #region Properties + + public Bookmark Bookmark { get; } = bookmark; + + #endregion + } +} \ No newline at end of file diff --git a/src/Logexpert.Core/EventArgs/ColumnizerEventArgs.cs b/src/Logexpert.Core/EventArgs/ColumnizerEventArgs.cs new file mode 100644 index 00000000..d440d769 --- /dev/null +++ b/src/Logexpert.Core/EventArgs/ColumnizerEventArgs.cs @@ -0,0 +1,11 @@ +namespace LogExpert.Core.EventArgs +{ + public class ColumnizerEventArgs(ILogLineColumnizer columnizer) : System.EventArgs + { + #region Properties + + public ILogLineColumnizer Columnizer { get; } = columnizer; + + #endregion + } +} \ No newline at end of file diff --git a/src/Logexpert.Core/EventArgs/ConfigChangedEventArgs.cs b/src/Logexpert.Core/EventArgs/ConfigChangedEventArgs.cs new file mode 100644 index 00000000..2247fdab --- /dev/null +++ b/src/Logexpert.Core/EventArgs/ConfigChangedEventArgs.cs @@ -0,0 +1,13 @@ +using LogExpert.Core.Config; + +namespace LogExpert.Core.EventArgs +{ + public class ConfigChangedEventArgs(SettingsFlags changeFlags) : System.EventArgs + { + #region Properties + + public SettingsFlags Flags { get; } = changeFlags; + + #endregion + } +} \ No newline at end of file diff --git a/src/Logexpert.Core/EventArgs/ContextMenuPluginEventArgs.cs b/src/Logexpert.Core/EventArgs/ContextMenuPluginEventArgs.cs new file mode 100644 index 00000000..86aca2a8 --- /dev/null +++ b/src/Logexpert.Core/EventArgs/ContextMenuPluginEventArgs.cs @@ -0,0 +1,19 @@ +namespace LogExpert.Core.EventArgs +{ + public class ContextMenuPluginEventArgs(IContextMenuEntry entry, IList logLines, ILogLineColumnizer columnizer, + ILogExpertCallback callback) : System.EventArgs + { + + #region Properties + + public IContextMenuEntry Entry { get; } = entry; + + public IList LogLines { get; } = logLines; + + public ILogLineColumnizer Columnizer { get; } = columnizer; + + public ILogExpertCallback Callback { get; } = callback; + + #endregion + } +} \ No newline at end of file diff --git a/src/Logexpert.Core/Entities/EventArgs/GuiStateArgs.cs b/src/Logexpert.Core/EventArgs/GuiStateArgs.cs similarity index 92% rename from src/Logexpert.Core/Entities/EventArgs/GuiStateArgs.cs rename to src/Logexpert.Core/EventArgs/GuiStateArgs.cs index e56400d6..17bb96f3 100644 --- a/src/Logexpert.Core/Entities/EventArgs/GuiStateArgs.cs +++ b/src/Logexpert.Core/EventArgs/GuiStateArgs.cs @@ -1,13 +1,9 @@ using System.Text; -namespace LogExpert.Core.Entities.EventArgs +namespace LogExpert.Core.EventArgs { public class GuiStateArgs : System.EventArgs { - #region Fields - - #endregion - #region Properties public bool TimeshiftEnabled { get; set; } diff --git a/src/Logexpert.Core/Entities/EventArgs/LoadFileEventArgs.cs b/src/Logexpert.Core/EventArgs/LoadFileEventArgs.cs similarity index 70% rename from src/Logexpert.Core/Entities/EventArgs/LoadFileEventArgs.cs rename to src/Logexpert.Core/EventArgs/LoadFileEventArgs.cs index 1fb69176..3ae24ce6 100644 --- a/src/Logexpert.Core/Entities/EventArgs/LoadFileEventArgs.cs +++ b/src/Logexpert.Core/EventArgs/LoadFileEventArgs.cs @@ -1,4 +1,4 @@ -namespace LogExpert.Core.Entities.EventArgs +namespace LogExpert.Core.EventArgs { public record LoadFileEventArgs(string FileName, long ReadPos, bool Finished, long FileSize, bool NewFile); } \ No newline at end of file diff --git a/src/Logexpert.Core/EventArgs/OverlayEventArgs.cs b/src/Logexpert.Core/EventArgs/OverlayEventArgs.cs new file mode 100644 index 00000000..efae4ce9 --- /dev/null +++ b/src/Logexpert.Core/EventArgs/OverlayEventArgs.cs @@ -0,0 +1,13 @@ +using LogExpert.Core.Entities; + +namespace LogExpert.Core.EventArgs +{ + public class OverlayEventArgs(BookmarkOverlay overlay) : System.EventArgs + { + #region Properties + + public BookmarkOverlay BookmarkOverlay { get; set; } = overlay; + + #endregion + } +} \ No newline at end of file diff --git a/src/Logexpert.Core/EventArgs/PatternArgs.cs b/src/Logexpert.Core/EventArgs/PatternArgs.cs new file mode 100644 index 00000000..5d69421d --- /dev/null +++ b/src/Logexpert.Core/EventArgs/PatternArgs.cs @@ -0,0 +1,21 @@ +namespace LogExpert.Core.EventArgs +{ + public class PatternArgs + { + #region Properties + + public int EndLine { get; set; } = 0; + + public int Fuzzy { get; set; } = 6; + + public int MaxDiffInBlock { get; set; } = 5; + + public int MaxMisses { get; set; } = 5; + + public int MinWeight { get; set; } = 15; + + public int StartLine { get; set; } = 0; + + #endregion + } +} \ No newline at end of file diff --git a/src/Logexpert.Core/Entities/EventArgs/ProgressEventArgs.cs b/src/Logexpert.Core/EventArgs/ProgressEventArgs.cs similarity index 76% rename from src/Logexpert.Core/Entities/EventArgs/ProgressEventArgs.cs rename to src/Logexpert.Core/EventArgs/ProgressEventArgs.cs index 8281f219..7edbb77c 100644 --- a/src/Logexpert.Core/Entities/EventArgs/ProgressEventArgs.cs +++ b/src/Logexpert.Core/EventArgs/ProgressEventArgs.cs @@ -1,11 +1,7 @@ -namespace LogExpert.Core.Entities.EventArgs +namespace LogExpert.Core.EventArgs { public class ProgressEventArgs : System.EventArgs { - #region Fields - - #endregion - #region Properties public int Value { get; set; } diff --git a/src/Logexpert.Core/EventArgs/SelectLineEventArgs.cs b/src/Logexpert.Core/EventArgs/SelectLineEventArgs.cs new file mode 100644 index 00000000..380ebe4b --- /dev/null +++ b/src/Logexpert.Core/EventArgs/SelectLineEventArgs.cs @@ -0,0 +1,11 @@ +namespace LogExpert.Core.EventArgs +{ + public class SelectLineEventArgs(int line) : System.EventArgs + { + #region Properties + + public int Line { get; } = line; + + #endregion + } +} \ No newline at end of file diff --git a/src/Logexpert.Core/Entities/EventArgs/StatusEventArgs.cs b/src/Logexpert.Core/EventArgs/StatusEventArgs.cs similarity index 88% rename from src/Logexpert.Core/Entities/EventArgs/StatusEventArgs.cs rename to src/Logexpert.Core/EventArgs/StatusEventArgs.cs index a468d03f..47a1d50a 100644 --- a/src/Logexpert.Core/Entities/EventArgs/StatusEventArgs.cs +++ b/src/Logexpert.Core/EventArgs/StatusEventArgs.cs @@ -1,11 +1,7 @@ -namespace LogExpert.Core.Entities.EventArgs +namespace LogExpert.Core.EventArgs { public class StatusLineEventArgs : System.EventArgs { - #region Fields - - #endregion - #region Properties public long FileSize { get; set; } = 0; diff --git a/src/Logexpert.Core/EventArgs/SyncModeEventArgs.cs b/src/Logexpert.Core/EventArgs/SyncModeEventArgs.cs new file mode 100644 index 00000000..838aaae1 --- /dev/null +++ b/src/Logexpert.Core/EventArgs/SyncModeEventArgs.cs @@ -0,0 +1,11 @@ +namespace LogExpert.Core.EventArgs +{ + public class SyncModeEventArgs(bool isSynced) : System.EventArgs + { + #region Properties + + public bool IsTimeSynced { get; } = isSynced; + + #endregion + } +} \ No newline at end of file diff --git a/src/Logexpert.Core/Structs/ActEntry.cs b/src/Logexpert.Core/Structs/ActEntry.cs new file mode 100644 index 00000000..b3ea1331 --- /dev/null +++ b/src/Logexpert.Core/Structs/ActEntry.cs @@ -0,0 +1,9 @@ +namespace LogExpert.Core.Structs +{ + public struct ActEntry + { + public string Name { get; set; } + + public IKeywordAction Plugin { get; set; } + } +} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/ColorComboBox.cs b/src/Logexpert.UI/Controls/ColorComboBox.cs similarity index 85% rename from src/LogExpert/Dialogs/ColorComboBox.cs rename to src/Logexpert.UI/Controls/ColorComboBox.cs index 434529b1..2d4c6e96 100644 --- a/src/LogExpert/Dialogs/ColorComboBox.cs +++ b/src/Logexpert.UI/Controls/ColorComboBox.cs @@ -1,100 +1,100 @@ -using System.Windows.Forms; -using System.Drawing; -using System.Drawing.Drawing2D; - -namespace LogExpert.Dialogs -{ - public class ColorComboBox : ComboBox - { - #region Fields - - private Color _customColor = Color.FromKnownColor(KnownColor.Black); - - #endregion - - #region cTor - - public ColorComboBox() - { - DrawMode = DrawMode.OwnerDrawFixed; - DrawItem += OnColorComboBoxDrawItem; - // add color presets - if (!DesignMode) - { - Items.Add(_customColor); - Items.Add(Color.Black); - Items.Add(Color.White); - Items.Add(Color.Gray); - Items.Add(Color.DarkGray); - Items.Add(Color.Blue); - Items.Add(Color.LightBlue); - Items.Add(Color.DarkBlue); - Items.Add(Color.Green); - Items.Add(Color.LightGreen); - Items.Add(Color.DarkGreen); - Items.Add(Color.Olive); - Items.Add(Color.Red); - Items.Add(Color.Pink); - Items.Add(Color.Purple); - Items.Add(Color.IndianRed); - Items.Add(Color.DarkCyan); - Items.Add(Color.Yellow); - } - } - - #endregion - - #region Properties - - public Color CustomColor - { - get => _customColor; - set - { - _customColor = value; - Items.RemoveAt(0); - Items.Insert(0, _customColor); - } - } - - public Color SelectedColor => (Color) (SelectedIndex != -1 ? Items[SelectedIndex] : null); - - #endregion - - #region Events handler - - private void OnColorComboBoxDrawItem(object sender, DrawItemEventArgs e) - { - e.DrawBackground(); - if (e.Index >= 0) - { - Rectangle rectangle = new(4, e.Bounds.Top + 2, 30, e.Bounds.Height - 4); - Color rectColor = (Color) Items[e.Index]; - e.Graphics.FillRectangle(new SolidBrush(rectColor), rectangle); - e.Graphics.DrawRectangle(Pens.Black, rectangle); - - if (e.Index == 0) - { - e.Graphics.DrawString("Custom", e.Font, Brushes.Black, - new PointF(42, e.Bounds.Top + 2)); - } - else - { - e.Graphics.DrawString(((Color) Items[e.Index]).Name, e.Font, Brushes.Black, - new PointF(42, e.Bounds.Top + 2)); - } - - if (!Enabled) - { - HatchBrush brush = new(HatchStyle.Percent50, Color.LightGray, Color.FromArgb(10, Color.LightGray)); - rectangle.Inflate(1, 1); - e.Graphics.FillRectangle(brush, rectangle); - brush.Dispose(); - } - e.DrawFocusRectangle(); - } - } - - #endregion - } +using System.Drawing.Drawing2D; +using System.Runtime.Versioning; + +namespace LogExpert.UI.Controls +{ + [SupportedOSPlatform("windows")] + public class ColorComboBox : ComboBox + { + #region Fields + + private Color _customColor = Color.FromKnownColor(KnownColor.Black); + + #endregion + + #region cTor + + public ColorComboBox() + { + DrawMode = DrawMode.OwnerDrawFixed; + DrawItem += OnColorComboBoxDrawItem; + // add color presets + if (!DesignMode) + { + Items.Add(_customColor); + Items.Add(Color.Black); + Items.Add(Color.White); + Items.Add(Color.Gray); + Items.Add(Color.DarkGray); + Items.Add(Color.Blue); + Items.Add(Color.LightBlue); + Items.Add(Color.DarkBlue); + Items.Add(Color.Green); + Items.Add(Color.LightGreen); + Items.Add(Color.DarkGreen); + Items.Add(Color.Olive); + Items.Add(Color.Red); + Items.Add(Color.Pink); + Items.Add(Color.Purple); + Items.Add(Color.IndianRed); + Items.Add(Color.DarkCyan); + Items.Add(Color.Yellow); + } + } + + #endregion + + #region Properties + + public Color CustomColor + { + get => _customColor; + set + { + _customColor = value; + Items.RemoveAt(0); + Items.Insert(0, _customColor); + } + } + + public Color SelectedColor => (Color)(SelectedIndex != -1 ? Items[SelectedIndex] : null); + + #endregion + + #region Events handler + + private void OnColorComboBoxDrawItem(object sender, DrawItemEventArgs e) + { + e.DrawBackground(); + if (e.Index >= 0) + { + Rectangle rectangle = new(4, e.Bounds.Top + 2, 30, e.Bounds.Height - 4); + Color rectColor = (Color)Items[e.Index]; + e.Graphics.FillRectangle(new SolidBrush(rectColor), rectangle); + e.Graphics.DrawRectangle(Pens.Black, rectangle); + + if (e.Index == 0) + { + e.Graphics.DrawString("Custom", e.Font, Brushes.Black, + new PointF(42, e.Bounds.Top + 2)); + } + else + { + e.Graphics.DrawString(((Color)Items[e.Index]).Name, e.Font, Brushes.Black, + new PointF(42, e.Bounds.Top + 2)); + } + + if (!Enabled) + { + HatchBrush brush = new(HatchStyle.Percent50, Color.LightGray, Color.FromArgb(10, Color.LightGray)); + rectangle.Inflate(1, 1); + e.Graphics.FillRectangle(brush, rectangle); + brush.Dispose(); + } + e.DrawFocusRectangle(); + } + } + + #endregion + } } \ No newline at end of file diff --git a/src/Logexpert.UI/Controls/KnobControl.Designer.cs b/src/Logexpert.UI/Controls/KnobControl.Designer.cs new file mode 100644 index 00000000..8b780d80 --- /dev/null +++ b/src/Logexpert.UI/Controls/KnobControl.Designer.cs @@ -0,0 +1,42 @@ +namespace LogExpert.Controls; + +partial class KnobControl +{ +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; + +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} + +#region Component Designer generated code + +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + this.SuspendLayout(); + // + // KnobControl + // + this.Name = "KnobControl"; + this.Size = new System.Drawing.Size(21, 21); + this.ResumeLayout(false); + +} + +#endregion +} diff --git a/src/Logexpert.UI/Controls/KnobControl.cs b/src/Logexpert.UI/Controls/KnobControl.cs new file mode 100644 index 00000000..0350ac36 --- /dev/null +++ b/src/Logexpert.UI/Controls/KnobControl.cs @@ -0,0 +1,182 @@ +using NLog; + +using System.Runtime.Versioning; + +namespace LogExpert.Controls; + +[SupportedOSPlatform("windows")] +public partial class KnobControl : UserControl +{ + #region Fields + + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + + + private readonly StringFormat _stringFormat = new(); + + private bool _isShiftPressed = false; + + private int _oldValue = 0; + private int _startMouseY = 0; + private int _value; + + #endregion + + #region cTor + + public KnobControl() + { + InitializeComponent(); + _stringFormat.LineAlignment = StringAlignment.Far; + _stringFormat.Alignment = StringAlignment.Center; + } + + #endregion + + #region Delegates + + public delegate void ValueChangedEventHandler(object sender, EventArgs e); + + #endregion + + #region Events + + public event ValueChangedEventHandler ValueChanged; + + #endregion + + #region Properties + + public int MinValue { get; set; } + + public int MaxValue { get; set; } + + public int Value + { + get { return _value; } + set + { + _value = value; + Refresh(); + } + } + + + public int Range + { + get { return MaxValue - MinValue; } + } + + public int DragSensitivity { get; set; } = 3; + + #endregion + + #region Overrides + + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + + Color foregroundColor = Enabled ? Color.Black : Color.Gray; + + Pen blackPen = new(foregroundColor, 1); + Pen greyPen = new(Color.Gray, 1); + + Rectangle rect = ClientRectangle; + int height = Font.Height + 3; + if (height > rect.Height) + { + height = rect.Height + 3; + } + rect.Inflate(-1, -height / 2); + rect.Offset(0, -height / 2); + e.Graphics.DrawEllipse(greyPen, rect); + + //rect = this.ClientRectangle; + rect.Inflate(-2, -2); + + float startAngle = 135.0F + 270F * ((float)_value / (float)Range); + float sweepAngle = 0.1F; + e.Graphics.DrawPie(blackPen, rect, startAngle, sweepAngle); + + Brush brush = new SolidBrush(foregroundColor); + RectangleF rectF = new(0, 0, ClientRectangle.Width, ClientRectangle.Height); + e.Graphics.DrawString("" + _value, Font, brush, rectF, _stringFormat); + + blackPen.Dispose(); + greyPen.Dispose(); + brush.Dispose(); + } + + protected override void OnMouseDown(MouseEventArgs e) + { + base.OnMouseDown(e); + + if (e.Button == MouseButtons.Left) + { + Capture = true; + _startMouseY = e.Y; + _oldValue = Value; + } + if (e.Button == MouseButtons.Right) + { + Capture = false; + Value = _oldValue; + Invalidate(); + } + } + + protected override void OnMouseUp(MouseEventArgs e) + { + base.OnMouseUp(e); + Capture = false; + _oldValue = Value; + OnValueChanged(new EventArgs()); + } + + protected void OnValueChanged(EventArgs e) + { + ValueChanged?.Invoke(this, e); + } + + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + if (!Capture) + { + return; + } + + int sense = _isShiftPressed ? DragSensitivity * 2 : DragSensitivity; + + int diff = _startMouseY - e.Y; + _logger.Debug("KnobDiff: {0}", diff); + int range = MaxValue - MinValue; + _value = _oldValue + diff / sense; + + if (_value < MinValue) + { + _value = MinValue; + } + + if (_value > MaxValue) + { + _value = MaxValue; + } + Invalidate(); + } + + protected override void OnKeyDown(KeyEventArgs e) + { + _isShiftPressed = e.Shift; + base.OnKeyDown(e); + } + + protected override void OnKeyUp(KeyEventArgs e) + { + _isShiftPressed = e.Shift; + base.OnKeyUp(e); + } + + #endregion +} \ No newline at end of file diff --git a/src/LogExpert/Controls/KnobControl.resx b/src/Logexpert.UI/Controls/KnobControl.resx similarity index 97% rename from src/LogExpert/Controls/KnobControl.resx rename to src/Logexpert.UI/Controls/KnobControl.resx index ff31a6db..19dc0dd8 100644 --- a/src/LogExpert/Controls/KnobControl.resx +++ b/src/Logexpert.UI/Controls/KnobControl.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Logexpert.UI/Controls/LogCellEditingControl.cs b/src/Logexpert.UI/Controls/LogCellEditingControl.cs new file mode 100644 index 00000000..316ed197 --- /dev/null +++ b/src/Logexpert.UI/Controls/LogCellEditingControl.cs @@ -0,0 +1,31 @@ +using System.Runtime.Versioning; + +namespace LogExpert.UI.Controls; + +[SupportedOSPlatform("windows")] +public class LogCellEditingControl : DataGridViewTextBoxEditingControl +{ + #region Public methods + + public override bool EditingControlWantsInputKey(Keys key, bool dataGridViewWantsInputKey) + { + switch (key & Keys.KeyCode) + { + case Keys.Left: + case Keys.Up: + case Keys.Down: + case Keys.Right: + case Keys.Home: + case Keys.End: + case Keys.PageDown: + case Keys.PageUp: + { + return true; + } + } + + return !dataGridViewWantsInputKey; + } + + #endregion +} diff --git a/src/Logexpert.UI/Controls/LogTabControl.cs b/src/Logexpert.UI/Controls/LogTabControl.cs new file mode 100644 index 00000000..611d9fe5 --- /dev/null +++ b/src/Logexpert.UI/Controls/LogTabControl.cs @@ -0,0 +1,42 @@ +using System.Runtime.Versioning; + +namespace LogExpert.UI.Controls; + +[SupportedOSPlatform("windows")] +internal class LogTabControl : TabControl +{ + #region Fields + + private BufferedGraphics myBuffer; + + #endregion + + #region cTor + + public LogTabControl() : base() + { + //SetStyle(ControlStyles.AllPaintingInWmPaint, true); + //SetStyle(ControlStyles.UserPaint, true); + //SetStyle(ControlStyles.DoubleBuffer, true); + } + + #endregion + + #region Overrides + + protected override void OnPaint(PaintEventArgs e) + { + BufferedGraphicsContext currentContext; + currentContext = BufferedGraphicsManager.Current; + myBuffer = currentContext.Allocate(CreateGraphics(), DisplayRectangle); + + PaintEventArgs args = new(myBuffer.Graphics, e.ClipRectangle); + + base.OnPaint(args); + + myBuffer.Render(e.Graphics); + myBuffer.Dispose(); + } + + #endregion +} \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/AboutBox.Designer.cs b/src/Logexpert.UI/Dialogs/AboutBox.Designer.cs index b521cfef..03671028 100644 --- a/src/Logexpert.UI/Dialogs/AboutBox.Designer.cs +++ b/src/Logexpert.UI/Dialogs/AboutBox.Designer.cs @@ -1,8 +1,8 @@ using System.Runtime.Versioning; -namespace LogExpert.UI.Dialogs -{ - partial class AboutBox +namespace LogExpert.UI.Dialogs; + +partial class AboutBox { /// /// Required designer variable. @@ -21,176 +21,176 @@ protected override void Dispose(bool disposing) base.Dispose(disposing); } - #region Windows Form Designer generated code + #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - tableLayoutPanel = new TableLayoutPanel(); - logoPictureBox = new PictureBox(); - labelProductName = new Label(); - labelVersion = new Label(); - labelCopyright = new Label(); - linkLabelURL = new LinkLabel(); - okPanel = new Panel(); - okButton = new Button(); - usedComponentsDataGrid = new DataGridView(); - tableLayoutPanel.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)logoPictureBox).BeginInit(); - okPanel.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)usedComponentsDataGrid).BeginInit(); - SuspendLayout(); - // - // tableLayoutPanel - // - tableLayoutPanel.ColumnCount = 2; - tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 34.25484F)); - tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 65.74516F)); - tableLayoutPanel.Controls.Add(logoPictureBox, 0, 0); - tableLayoutPanel.Controls.Add(labelProductName, 1, 0); - tableLayoutPanel.Controls.Add(labelVersion, 1, 1); - tableLayoutPanel.Controls.Add(labelCopyright, 1, 2); - tableLayoutPanel.Controls.Add(linkLabelURL, 1, 3); - tableLayoutPanel.Controls.Add(okPanel, 1, 5); - tableLayoutPanel.Controls.Add(usedComponentsDataGrid, 1, 4); - tableLayoutPanel.Dock = DockStyle.Fill; - tableLayoutPanel.Location = new Point(14, 14); - tableLayoutPanel.Margin = new Padding(4, 5, 4, 5); - tableLayoutPanel.Name = "tableLayoutPanel"; - tableLayoutPanel.RowCount = 6; - tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 9.912043F)); - tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 9.912043F)); - tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 9.47226F)); - tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 11.84032F)); - tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 46.68471F)); - tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 12.17862F)); - tableLayoutPanel.Size = new Size(914, 649); - tableLayoutPanel.TabIndex = 0; - // - // logoPictureBox - // - logoPictureBox.Dock = DockStyle.Fill; - logoPictureBox.Location = new Point(4, 5); - logoPictureBox.Margin = new Padding(4, 5, 4, 5); - logoPictureBox.Name = "logoPictureBox"; - tableLayoutPanel.SetRowSpan(logoPictureBox, 6); - logoPictureBox.Size = new Size(305, 639); - logoPictureBox.SizeMode = PictureBoxSizeMode.CenterImage; - logoPictureBox.TabIndex = 12; - logoPictureBox.TabStop = false; - // - // labelProductName - // - labelProductName.Dock = DockStyle.Fill; - labelProductName.Font = new Font("Microsoft Sans Serif", 10F, FontStyle.Bold, GraphicsUnit.Point, 0); - labelProductName.Location = new Point(322, 0); - labelProductName.Margin = new Padding(9, 0, 4, 0); - labelProductName.MaximumSize = new Size(0, 26); - labelProductName.Name = "labelProductName"; - labelProductName.Size = new Size(588, 26); - labelProductName.TabIndex = 19; - labelProductName.Text = "Product Name"; - labelProductName.TextAlign = ContentAlignment.MiddleLeft; - // - // labelVersion - // - labelVersion.Dock = DockStyle.Fill; - labelVersion.Location = new Point(322, 64); - labelVersion.Margin = new Padding(9, 0, 4, 0); - labelVersion.MaximumSize = new Size(0, 26); - labelVersion.Name = "labelVersion"; - labelVersion.Size = new Size(588, 26); - labelVersion.TabIndex = 0; - labelVersion.Text = "Version"; - labelVersion.TextAlign = ContentAlignment.MiddleLeft; - // - // labelCopyright - // - labelCopyright.Dock = DockStyle.Fill; - labelCopyright.Location = new Point(322, 128); - labelCopyright.Margin = new Padding(9, 0, 4, 0); - labelCopyright.Name = "labelCopyright"; - labelCopyright.Size = new Size(588, 61); - labelCopyright.TabIndex = 21; - labelCopyright.Text = "Copyright"; - labelCopyright.TextAlign = ContentAlignment.MiddleLeft; - // - // linkLabelURL - // - linkLabelURL.AutoSize = true; - linkLabelURL.Dock = DockStyle.Fill; - linkLabelURL.Location = new Point(317, 189); - linkLabelURL.Margin = new Padding(4, 0, 4, 0); - linkLabelURL.Name = "linkLabelURL"; - linkLabelURL.Size = new Size(593, 76); - linkLabelURL.TabIndex = 25; - linkLabelURL.TabStop = true; - linkLabelURL.Text = "https://github.com/LogExperts/LogExpert"; - linkLabelURL.TextAlign = ContentAlignment.MiddleLeft; - linkLabelURL.LinkClicked += OnLinkLabelURLClicked; - // - // okPanel - // - okPanel.Controls.Add(okButton); - okPanel.Dock = DockStyle.Fill; - okPanel.Location = new Point(317, 572); - okPanel.Margin = new Padding(4, 5, 4, 5); - okPanel.Name = "okPanel"; - okPanel.Size = new Size(593, 72); - okPanel.TabIndex = 26; - // - // okButton - // - okButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - okButton.DialogResult = DialogResult.OK; - okButton.Location = new Point(475, 32); - okButton.Margin = new Padding(4, 5, 4, 5); - okButton.Name = "okButton"; - okButton.Size = new Size(114, 35); - okButton.TabIndex = 0; - okButton.Text = "&OK"; - okButton.UseVisualStyleBackColor = true; - // - // usedComponentsDataGrid - // - usedComponentsDataGrid.AllowUserToAddRows = false; - usedComponentsDataGrid.AllowUserToDeleteRows = false; - usedComponentsDataGrid.BackgroundColor = SystemColors.Control; - usedComponentsDataGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - usedComponentsDataGrid.Dock = DockStyle.Fill; - usedComponentsDataGrid.Location = new Point(316, 268); - usedComponentsDataGrid.Name = "usedComponentsDataGrid"; - usedComponentsDataGrid.ReadOnly = true; - usedComponentsDataGrid.Size = new Size(595, 296); - usedComponentsDataGrid.TabIndex = 27; - // - // AboutBox - // - ClientSize = new Size(942, 677); - Controls.Add(tableLayoutPanel); - Margin = new Padding(4, 5, 4, 5); - MaximizeBox = false; - MinimizeBox = false; - Name = "AboutBox"; - Padding = new Padding(14); - ShowIcon = false; - ShowInTaskbar = false; - StartPosition = FormStartPosition.CenterParent; - Text = "AboutBox"; - tableLayoutPanel.ResumeLayout(false); - tableLayoutPanel.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)logoPictureBox).EndInit(); - okPanel.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)usedComponentsDataGrid).EndInit(); - ResumeLayout(false); - } + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + tableLayoutPanel = new TableLayoutPanel(); + logoPictureBox = new PictureBox(); + labelProductName = new Label(); + labelVersion = new Label(); + labelCopyright = new Label(); + linkLabelURL = new LinkLabel(); + okPanel = new Panel(); + okButton = new Button(); + usedComponentsDataGrid = new DataGridView(); + tableLayoutPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)logoPictureBox).BeginInit(); + okPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)usedComponentsDataGrid).BeginInit(); + SuspendLayout(); + // + // tableLayoutPanel + // + tableLayoutPanel.ColumnCount = 2; + tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 34.25484F)); + tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 65.74516F)); + tableLayoutPanel.Controls.Add(logoPictureBox, 0, 0); + tableLayoutPanel.Controls.Add(labelProductName, 1, 0); + tableLayoutPanel.Controls.Add(labelVersion, 1, 1); + tableLayoutPanel.Controls.Add(labelCopyright, 1, 2); + tableLayoutPanel.Controls.Add(linkLabelURL, 1, 3); + tableLayoutPanel.Controls.Add(okPanel, 1, 5); + tableLayoutPanel.Controls.Add(usedComponentsDataGrid, 1, 4); + tableLayoutPanel.Dock = DockStyle.Fill; + tableLayoutPanel.Location = new Point(14, 14); + tableLayoutPanel.Margin = new Padding(4, 5, 4, 5); + tableLayoutPanel.Name = "tableLayoutPanel"; + tableLayoutPanel.RowCount = 6; + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 9.912043F)); + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 9.912043F)); + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 9.47226F)); + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 11.84032F)); + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 46.68471F)); + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 12.17862F)); + tableLayoutPanel.Size = new Size(914, 649); + tableLayoutPanel.TabIndex = 0; + // + // logoPictureBox + // + logoPictureBox.Dock = DockStyle.Fill; + logoPictureBox.Location = new Point(4, 5); + logoPictureBox.Margin = new Padding(4, 5, 4, 5); + logoPictureBox.Name = "logoPictureBox"; + tableLayoutPanel.SetRowSpan(logoPictureBox, 6); + logoPictureBox.Size = new Size(305, 639); + logoPictureBox.SizeMode = PictureBoxSizeMode.CenterImage; + logoPictureBox.TabIndex = 12; + logoPictureBox.TabStop = false; + // + // labelProductName + // + labelProductName.Dock = DockStyle.Fill; + labelProductName.Font = new Font("Microsoft Sans Serif", 10F, FontStyle.Bold, GraphicsUnit.Point, 0); + labelProductName.Location = new Point(322, 0); + labelProductName.Margin = new Padding(9, 0, 4, 0); + labelProductName.MaximumSize = new Size(0, 26); + labelProductName.Name = "labelProductName"; + labelProductName.Size = new Size(588, 26); + labelProductName.TabIndex = 19; + labelProductName.Text = "Product Name"; + labelProductName.TextAlign = ContentAlignment.MiddleLeft; + // + // labelVersion + // + labelVersion.Dock = DockStyle.Fill; + labelVersion.Location = new Point(322, 64); + labelVersion.Margin = new Padding(9, 0, 4, 0); + labelVersion.MaximumSize = new Size(0, 26); + labelVersion.Name = "labelVersion"; + labelVersion.Size = new Size(588, 26); + labelVersion.TabIndex = 0; + labelVersion.Text = "Version"; + labelVersion.TextAlign = ContentAlignment.MiddleLeft; + // + // labelCopyright + // + labelCopyright.Dock = DockStyle.Fill; + labelCopyright.Location = new Point(322, 128); + labelCopyright.Margin = new Padding(9, 0, 4, 0); + labelCopyright.Name = "labelCopyright"; + labelCopyright.Size = new Size(588, 61); + labelCopyright.TabIndex = 21; + labelCopyright.Text = "Copyright"; + labelCopyright.TextAlign = ContentAlignment.MiddleLeft; + // + // linkLabelURL + // + linkLabelURL.AutoSize = true; + linkLabelURL.Dock = DockStyle.Fill; + linkLabelURL.Location = new Point(317, 189); + linkLabelURL.Margin = new Padding(4, 0, 4, 0); + linkLabelURL.Name = "linkLabelURL"; + linkLabelURL.Size = new Size(593, 76); + linkLabelURL.TabIndex = 25; + linkLabelURL.TabStop = true; + linkLabelURL.Text = "https://github.com/LogExperts/LogExpert"; + linkLabelURL.TextAlign = ContentAlignment.MiddleLeft; + linkLabelURL.LinkClicked += OnLinkLabelURLClicked; + // + // okPanel + // + okPanel.Controls.Add(okButton); + okPanel.Dock = DockStyle.Fill; + okPanel.Location = new Point(317, 572); + okPanel.Margin = new Padding(4, 5, 4, 5); + okPanel.Name = "okPanel"; + okPanel.Size = new Size(593, 72); + okPanel.TabIndex = 26; + // + // okButton + // + okButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + okButton.DialogResult = DialogResult.OK; + okButton.Location = new Point(475, 32); + okButton.Margin = new Padding(4, 5, 4, 5); + okButton.Name = "okButton"; + okButton.Size = new Size(114, 35); + okButton.TabIndex = 0; + okButton.Text = "&OK"; + okButton.UseVisualStyleBackColor = true; + // + // usedComponentsDataGrid + // + usedComponentsDataGrid.AllowUserToAddRows = false; + usedComponentsDataGrid.AllowUserToDeleteRows = false; + usedComponentsDataGrid.BackgroundColor = SystemColors.Control; + usedComponentsDataGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + usedComponentsDataGrid.Dock = DockStyle.Fill; + usedComponentsDataGrid.Location = new Point(316, 268); + usedComponentsDataGrid.Name = "usedComponentsDataGrid"; + usedComponentsDataGrid.ReadOnly = true; + usedComponentsDataGrid.Size = new Size(595, 296); + usedComponentsDataGrid.TabIndex = 27; + // + // AboutBox + // + ClientSize = new Size(942, 677); + Controls.Add(tableLayoutPanel); + Margin = new Padding(4, 5, 4, 5); + MaximizeBox = false; + MinimizeBox = false; + Name = "AboutBox"; + Padding = new Padding(14); + ShowIcon = false; + ShowInTaskbar = false; + StartPosition = FormStartPosition.CenterParent; + Text = "AboutBox"; + tableLayoutPanel.ResumeLayout(false); + tableLayoutPanel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)logoPictureBox).EndInit(); + okPanel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)usedComponentsDataGrid).EndInit(); + ResumeLayout(false); + } - #endregion + #endregion - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; private System.Windows.Forms.PictureBox logoPictureBox; private System.Windows.Forms.Label labelProductName; private System.Windows.Forms.Label labelVersion; @@ -198,6 +198,5 @@ private void InitializeComponent() private System.Windows.Forms.LinkLabel linkLabelURL; private System.Windows.Forms.Panel okPanel; private System.Windows.Forms.Button okButton; - private DataGridView usedComponentsDataGrid; - } + private DataGridView usedComponentsDataGrid; } diff --git a/src/Logexpert.UI/Dialogs/AboutBox.cs b/src/Logexpert.UI/Dialogs/AboutBox.cs index b1aa1bc9..129ff99b 100644 --- a/src/Logexpert.UI/Dialogs/AboutBox.cs +++ b/src/Logexpert.UI/Dialogs/AboutBox.cs @@ -6,155 +6,154 @@ using System.Reflection; using System.Runtime.Versioning; -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +[SupportedOSPlatform("windows")] +public partial class AboutBox : Form { - [SupportedOSPlatform("windows")] - public partial class AboutBox : Form - { - #region Fields + #region Fields - private readonly Assembly _assembly; + private readonly Assembly _assembly; - #endregion + #endregion - #region cTor + #region cTor - public AboutBox() - { - InitializeComponent(); + public AboutBox() + { + InitializeComponent(); - LoadResources(); + LoadResources(); - _assembly = Assembly.GetExecutingAssembly(); + _assembly = Assembly.GetExecutingAssembly(); - Text = $@"About {AssemblyTitle}"; - labelProductName.Text = AssemblyProduct; - labelVersion.Text = AssemblyVersion; - labelCopyright.Text = AssemblyCopyright; - string link = "https://github.com/LogExperts/LogExpert"; - linkLabelURL.Links.Add(new LinkLabel.Link(0, link.Length, link)); - LoadUsedComponents(); - } + Text = $@"About {AssemblyTitle}"; + labelProductName.Text = AssemblyProduct; + labelVersion.Text = AssemblyVersion; + labelCopyright.Text = AssemblyCopyright; + string link = "https://github.com/LogExperts/LogExpert"; + linkLabelURL.Links.Add(new LinkLabel.Link(0, link.Length, link)); + LoadUsedComponents(); + } - //Name, Version, License, Download, Source + //Name, Version, License, Download, Source - private void LoadUsedComponents() - { - string json = File.ReadAllText($"{Application.StartupPath}files\\json\\usedComponents.json"); - var usedComponents = JsonConvert.DeserializeObject(json); - usedComponents = usedComponents?.OrderBy(x => x.PackageId).ToArray(); - usedComponentsDataGrid.DataSource = usedComponents; - } + private void LoadUsedComponents() + { + string json = File.ReadAllText($"{Application.StartupPath}files\\json\\usedComponents.json"); + var usedComponents = JsonConvert.DeserializeObject(json); + usedComponents = usedComponents?.OrderBy(x => x.PackageId).ToArray(); + usedComponentsDataGrid.DataSource = usedComponents; + } - private void LoadResources() - { - logoPictureBox.Image = Resources.Resources.LogLover; - } + private void LoadResources() + { + logoPictureBox.Image = Resources.Resources.LogLover; + } - #endregion + #endregion - #region Properties + #region Properties - public string AssemblyTitle + public string AssemblyTitle + { + get { - get + object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); + if (attributes.Length > 0) { - object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); - if (attributes.Length > 0) + AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; + if (titleAttribute.Title != string.Empty) { - AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; - if (titleAttribute.Title != string.Empty) - { - return titleAttribute.Title; - } + return titleAttribute.Title; } - return Path.GetFileNameWithoutExtension(_assembly.Location); } + return Path.GetFileNameWithoutExtension(_assembly.Location); } + } - public string AssemblyVersion + public string AssemblyVersion + { + get { - get - { - AssemblyName assembly = _assembly.GetName(); + AssemblyName assembly = _assembly.GetName(); - if (assembly.Version != null) + if (assembly.Version != null) + { + string version = $"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}.{assembly.Version.Revision}"; + if (assembly.Version.Revision >= 9000) { - string version = $"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}.{assembly.Version.Revision}"; - if (assembly.Version.Revision >= 9000) - { - version += " Testrelease"; - } - - return version; + version += " Testrelease"; } - return "0.0.0.0"; + return version; } + return "0.0.0.0"; } - public string AssemblyDescription + } + + public string AssemblyDescription + { + get { - get - { - object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); + object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); - if (attributes.Length == 0) - { - return string.Empty; - } - return ((AssemblyDescriptionAttribute)attributes[0]).Description; + if (attributes.Length == 0) + { + return string.Empty; } + return ((AssemblyDescriptionAttribute)attributes[0]).Description; } + } - public string AssemblyProduct + public string AssemblyProduct + { + get { - get + object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false); + if (attributes.Length == 0) { - object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false); - if (attributes.Length == 0) - { - return string.Empty; - } - return ((AssemblyProductAttribute)attributes[0]).Product; + return string.Empty; } + return ((AssemblyProductAttribute)attributes[0]).Product; } + } - public string AssemblyCopyright + public string AssemblyCopyright + { + get { - get + object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + if (attributes.Length == 0) { - object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); - if (attributes.Length == 0) - { - return string.Empty; - } - return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + return string.Empty; } + return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; } + } - #endregion - - #region Events handler + #endregion - private void OnLinkLabelURLClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - string? target = string.Empty; + #region Events handler - if (e.Link != null) - { - target = e.Link.LinkData as string; - } + private void OnLinkLabelURLClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + string? target = string.Empty; - Process.Start(new ProcessStartInfo - { - UseShellExecute = true, - FileName = target, - }); + if (e.Link != null) + { + target = e.Link.LinkData as string; } - #endregion + Process.Start(new ProcessStartInfo + { + UseShellExecute = true, + FileName = target, + }); } + + #endregion } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/BookmarkCommentDlg.Designer.cs b/src/Logexpert.UI/Dialogs/BookmarkCommentDlg.Designer.cs new file mode 100644 index 00000000..06aa2968 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/BookmarkCommentDlg.Designer.cs @@ -0,0 +1,89 @@ +namespace LogExpert.Dialogs; + +partial class BookmarkCommentDlg +{ +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; + +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} + +#region Windows Form Designer generated code + +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BookmarkCommentDlg)); + this.okButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); + this.commentTextBox = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // okButton + // + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.Location = new System.Drawing.Point(150, 86); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(75, 23); + this.okButton.TabIndex = 1; + this.okButton.Text = "OK"; + this.okButton.UseVisualStyleBackColor = true; + // + // cancelButton + // + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(241, 86); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(75, 23); + this.cancelButton.TabIndex = 2; + this.cancelButton.Text = "&Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + // + // commentTextBox + // + this.commentTextBox.Dock = System.Windows.Forms.DockStyle.Top; + this.commentTextBox.Location = new System.Drawing.Point(0, 0); + this.commentTextBox.Multiline = true; + this.commentTextBox.Name = "commentTextBox"; + this.commentTextBox.Size = new System.Drawing.Size(324, 80); + this.commentTextBox.TabIndex = 0; + // + // BookmarkCommentDlg + // + this.AcceptButton = this.okButton; + this.CancelButton = this.cancelButton; + this.ClientSize = new System.Drawing.Size(324, 115); + this.Controls.Add(this.commentTextBox); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.okButton); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Name = "BookmarkCommentDlg"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Bookmark comment"; + this.ResumeLayout(false); + this.PerformLayout(); + +} + +#endregion + +private System.Windows.Forms.Button okButton; +private System.Windows.Forms.Button cancelButton; +private System.Windows.Forms.TextBox commentTextBox; +} \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/BookmarkCommentDlg.cs b/src/Logexpert.UI/Dialogs/BookmarkCommentDlg.cs new file mode 100644 index 00000000..ece0c852 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/BookmarkCommentDlg.cs @@ -0,0 +1,29 @@ +using System.Runtime.Versioning; + +namespace LogExpert.Dialogs; + +[SupportedOSPlatform("windows")] +public partial class BookmarkCommentDlg : Form +{ + #region cTor + + public BookmarkCommentDlg() + { + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + InitializeComponent(); + } + + #endregion + + #region Properties + + public string Comment + { + set => commentTextBox.Text = value; + get => commentTextBox.Text; + } + + #endregion +} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/BookmarkCommentDlg.resx b/src/Logexpert.UI/Dialogs/BookmarkCommentDlg.resx similarity index 98% rename from src/LogExpert/Dialogs/BookmarkCommentDlg.resx rename to src/Logexpert.UI/Dialogs/BookmarkCommentDlg.resx index 20cf2a6f..e97451d5 100644 --- a/src/LogExpert/Dialogs/BookmarkCommentDlg.resx +++ b/src/Logexpert.UI/Dialogs/BookmarkCommentDlg.resx @@ -1,131 +1,131 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA - AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// - AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// - //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA - AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAIABAAD//wAA - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// + //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA + AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAIABAAD//wAA + + \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/ChooseIconDlg.Designer.cs b/src/Logexpert.UI/Dialogs/ChooseIconDlg.Designer.cs index b82d377b..6700865c 100644 --- a/src/Logexpert.UI/Dialogs/ChooseIconDlg.Designer.cs +++ b/src/Logexpert.UI/Dialogs/ChooseIconDlg.Designer.cs @@ -1,125 +1,124 @@ -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +partial class ChooseIconDlg { - partial class ChooseIconDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} - #region Windows Form Designer generated code +#region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ChooseIconDlg)); - this.iconListView = new System.Windows.Forms.ListView(); - this.iconFileLabel = new System.Windows.Forms.Label(); - this.buttonChooseIconFile = new System.Windows.Forms.Button(); - this.okButton = new System.Windows.Forms.Button(); - this.cancelButton = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // iconListView - // - this.iconListView.Alignment = System.Windows.Forms.ListViewAlignment.Left; - this.iconListView.AutoArrange = false; - this.iconListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.iconListView.HideSelection = false; - this.iconListView.Location = new System.Drawing.Point(18, 63); - this.iconListView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.iconListView.MultiSelect = false; - this.iconListView.Name = "iconListView"; - this.iconListView.ShowGroups = false; - this.iconListView.Size = new System.Drawing.Size(529, 118); - this.iconListView.TabIndex = 0; - this.iconListView.UseCompatibleStateImageBehavior = false; - // - // iconFileLabel - // - this.iconFileLabel.Location = new System.Drawing.Point(18, 26); - this.iconFileLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.iconFileLabel.Name = "iconFileLabel"; - this.iconFileLabel.Size = new System.Drawing.Size(411, 35); - this.iconFileLabel.TabIndex = 1; - this.iconFileLabel.Text = "label1"; - // - // buttonChooseIconFile - // - this.buttonChooseIconFile.Location = new System.Drawing.Point(438, 18); - this.buttonChooseIconFile.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.buttonChooseIconFile.Name = "buttonChooseIconFile"; - this.buttonChooseIconFile.Size = new System.Drawing.Size(112, 35); - this.buttonChooseIconFile.TabIndex = 2; - this.buttonChooseIconFile.Text = "Icon file..."; - this.buttonChooseIconFile.UseVisualStyleBackColor = true; - this.buttonChooseIconFile.Click += new System.EventHandler(this.OnButtonChooseIconFileClick); - // - // okButton - // - this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.okButton.Location = new System.Drawing.Point(316, 226); - this.okButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(112, 35); - this.okButton.TabIndex = 3; - this.okButton.Text = "OK"; - this.okButton.UseVisualStyleBackColor = true; - this.okButton.Click += new System.EventHandler(this.OnOkButtonClick); - // - // cancelButton - // - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(440, 226); - this.cancelButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(112, 35); - this.cancelButton.TabIndex = 4; - this.cancelButton.Text = "Cancel"; - this.cancelButton.UseVisualStyleBackColor = true; - // - // ChooseIconDlg - // - this.ClientSize = new System.Drawing.Size(568, 278); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.okButton); - this.Controls.Add(this.buttonChooseIconFile); - this.Controls.Add(this.iconFileLabel); - this.Controls.Add(this.iconListView); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ChooseIconDlg"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Choose Icon"; - this.Load += new System.EventHandler(this.ChooseIconDlg_Load); - this.ResumeLayout(false); +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ChooseIconDlg)); + this.iconListView = new System.Windows.Forms.ListView(); + this.iconFileLabel = new System.Windows.Forms.Label(); + this.buttonChooseIconFile = new System.Windows.Forms.Button(); + this.okButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // iconListView + // + this.iconListView.Alignment = System.Windows.Forms.ListViewAlignment.Left; + this.iconListView.AutoArrange = false; + this.iconListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.iconListView.HideSelection = false; + this.iconListView.Location = new System.Drawing.Point(18, 63); + this.iconListView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.iconListView.MultiSelect = false; + this.iconListView.Name = "iconListView"; + this.iconListView.ShowGroups = false; + this.iconListView.Size = new System.Drawing.Size(529, 118); + this.iconListView.TabIndex = 0; + this.iconListView.UseCompatibleStateImageBehavior = false; + // + // iconFileLabel + // + this.iconFileLabel.Location = new System.Drawing.Point(18, 26); + this.iconFileLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.iconFileLabel.Name = "iconFileLabel"; + this.iconFileLabel.Size = new System.Drawing.Size(411, 35); + this.iconFileLabel.TabIndex = 1; + this.iconFileLabel.Text = "label1"; + // + // buttonChooseIconFile + // + this.buttonChooseIconFile.Location = new System.Drawing.Point(438, 18); + this.buttonChooseIconFile.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.buttonChooseIconFile.Name = "buttonChooseIconFile"; + this.buttonChooseIconFile.Size = new System.Drawing.Size(112, 35); + this.buttonChooseIconFile.TabIndex = 2; + this.buttonChooseIconFile.Text = "Icon file..."; + this.buttonChooseIconFile.UseVisualStyleBackColor = true; + this.buttonChooseIconFile.Click += new System.EventHandler(this.OnButtonChooseIconFileClick); + // + // okButton + // + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.Location = new System.Drawing.Point(316, 226); + this.okButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(112, 35); + this.okButton.TabIndex = 3; + this.okButton.Text = "OK"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.OnOkButtonClick); + // + // cancelButton + // + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(440, 226); + this.cancelButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(112, 35); + this.cancelButton.TabIndex = 4; + this.cancelButton.Text = "Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + // + // ChooseIconDlg + // + this.ClientSize = new System.Drawing.Size(568, 278); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.okButton); + this.Controls.Add(this.buttonChooseIconFile); + this.Controls.Add(this.iconFileLabel); + this.Controls.Add(this.iconListView); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ChooseIconDlg"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Choose Icon"; + this.Load += new System.EventHandler(this.ChooseIconDlg_Load); + this.ResumeLayout(false); - } +} - #endregion +#endregion - private System.Windows.Forms.ListView iconListView; - private System.Windows.Forms.Label iconFileLabel; - private System.Windows.Forms.Button buttonChooseIconFile; - private System.Windows.Forms.Button okButton; - private System.Windows.Forms.Button cancelButton; - } +private System.Windows.Forms.ListView iconListView; +private System.Windows.Forms.Label iconFileLabel; +private System.Windows.Forms.Button buttonChooseIconFile; +private System.Windows.Forms.Button okButton; +private System.Windows.Forms.Button cancelButton; } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/ChooseIconDlg.cs b/src/Logexpert.UI/Dialogs/ChooseIconDlg.cs index 630406a3..bfc8cfad 100644 --- a/src/Logexpert.UI/Dialogs/ChooseIconDlg.cs +++ b/src/Logexpert.UI/Dialogs/ChooseIconDlg.cs @@ -2,120 +2,119 @@ using System.Runtime.Versioning; -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +[SupportedOSPlatform("windows")] +public partial class ChooseIconDlg : Form { - [SupportedOSPlatform("windows")] - public partial class ChooseIconDlg : Form - { - #region Fields + #region Fields - #endregion + #endregion - #region cTor + #region cTor - public ChooseIconDlg(string fileName) - { - InitializeComponent(); + public ChooseIconDlg(string fileName) + { + InitializeComponent(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; - FileName = fileName; - } + FileName = fileName; + } - #endregion + #endregion - #region Properties + #region Properties - public string FileName { get; set; } + public string FileName { get; set; } - public int IconIndex { get; set; } + public int IconIndex { get; set; } - #endregion + #endregion - #region Private Methods + #region Private Methods - private void FillIconList() - { - iconListView.Items.Clear(); + private void FillIconList() + { + iconListView.Items.Clear(); - Icon[,] icons = Win32.ExtractIcons(FileName); + Icon[,] icons = Win32.ExtractIcons(FileName); - if (icons == null) - { - return; - } + if (icons == null) + { + return; + } - ImageList imageList = new(); + ImageList imageList = new(); - if (icons.GetLength(0) > 0) - { - imageList.ImageSize = icons[1, 0].Size; - iconListView.LargeImageList = imageList; + if (icons.GetLength(0) > 0) + { + imageList.ImageSize = icons[1, 0].Size; + iconListView.LargeImageList = imageList; - for (int i = 0; i < icons.GetLength(1); ++i) + for (int i = 0; i < icons.GetLength(1); ++i) + { + imageList.Images.Add(icons[1, i]); + ListViewItem item = new() { - imageList.Images.Add(icons[1, i]); - ListViewItem item = new() - { - ImageIndex = i - }; - iconListView.Items.Add(item); - } + ImageIndex = i + }; + iconListView.Items.Add(item); } } + } - private void DisposeIcons() + private void DisposeIcons() + { + ImageList imageList = iconListView.LargeImageList; + iconListView.LargeImageList = null; + foreach (Image image in imageList.Images) { - ImageList imageList = iconListView.LargeImageList; - iconListView.LargeImageList = null; - foreach (Image image in imageList.Images) - { - image.Dispose(); - } + image.Dispose(); } + } - #endregion + #endregion - #region Events handler + #region Events handler - private void ChooseIconDlg_Load(object sender, EventArgs e) - { - FillIconList(); - iconFileLabel.Text = FileName; - } + private void ChooseIconDlg_Load(object sender, EventArgs e) + { + FillIconList(); + iconFileLabel.Text = FileName; + } - private void OnButtonChooseIconFileClick(object sender, EventArgs e) + private void OnButtonChooseIconFileClick(object sender, EventArgs e) + { + OpenFileDialog dlg = new() { - OpenFileDialog dlg = new() - { - InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) - }; + InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + }; - if (string.IsNullOrEmpty(iconFileLabel.Text) == false) - { - FileInfo info = new(iconFileLabel.Text); - if (info.Directory != null && info.Directory.Exists) - { - dlg.InitialDirectory = info.DirectoryName; - } - } - - if (dlg.ShowDialog() == DialogResult.OK) + if (string.IsNullOrEmpty(iconFileLabel.Text) == false) + { + FileInfo info = new(iconFileLabel.Text); + if (info.Directory != null && info.Directory.Exists) { - iconFileLabel.Text = dlg.FileName; - FileName = dlg.FileName; - FillIconList(); + dlg.InitialDirectory = info.DirectoryName; } } - private void OnOkButtonClick(object sender, EventArgs e) + if (dlg.ShowDialog() == DialogResult.OK) { - IconIndex = iconListView.SelectedIndices.Count > 0 ? iconListView.SelectedIndices[0] : -1; - - DisposeIcons(); + iconFileLabel.Text = dlg.FileName; + FileName = dlg.FileName; + FillIconList(); } + } + + private void OnOkButtonClick(object sender, EventArgs e) + { + IconIndex = iconListView.SelectedIndices.Count > 0 ? iconListView.SelectedIndices[0] : -1; - #endregion + DisposeIcons(); } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/ExceptionWindow.Designer.cs b/src/Logexpert.UI/Dialogs/ExceptionWindow.Designer.cs similarity index 97% rename from src/LogExpert/Dialogs/ExceptionWindow.Designer.cs rename to src/Logexpert.UI/Dialogs/ExceptionWindow.Designer.cs index 3fbdc6e0..f3aa0fc6 100644 --- a/src/LogExpert/Dialogs/ExceptionWindow.Designer.cs +++ b/src/Logexpert.UI/Dialogs/ExceptionWindow.Designer.cs @@ -1,108 +1,108 @@ -namespace LogExpert.Dialogs -{ - partial class ExceptionWindow - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ExceptionWindow)); - this.stackTraceTextBox = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); - this.okButton = new System.Windows.Forms.Button(); - this.copyButton = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // stackTraceTextBox - // - this.stackTraceTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.stackTraceTextBox.Location = new System.Drawing.Point(12, 42); - this.stackTraceTextBox.Multiline = true; - this.stackTraceTextBox.Name = "stackTraceTextBox"; - this.stackTraceTextBox.ReadOnly = true; - this.stackTraceTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.stackTraceTextBox.Size = new System.Drawing.Size(439, 205); - this.stackTraceTextBox.TabIndex = 0; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(13, 13); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(310, 13); - this.label1.TabIndex = 1; - this.label1.Text = "An unhandled error has occured. Please report to the developer."; - // - // okButton - // - this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.okButton.Location = new System.Drawing.Point(376, 265); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(75, 23); - this.okButton.TabIndex = 2; - this.okButton.Text = "Close"; - this.okButton.UseVisualStyleBackColor = true; - // - // copyButton - // - this.copyButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.copyButton.Location = new System.Drawing.Point(12, 265); - this.copyButton.Name = "copyButton"; - this.copyButton.Size = new System.Drawing.Size(117, 23); - this.copyButton.TabIndex = 4; - this.copyButton.Text = "Copy to clipboard"; - this.copyButton.UseVisualStyleBackColor = true; - this.copyButton.Click += new System.EventHandler(this.copyButton_Click); - // - // ExceptionWindow - // - this.CancelButton = this.okButton; - this.ClientSize = new System.Drawing.Size(464, 300); - this.Controls.Add(this.copyButton); - this.Controls.Add(this.okButton); - this.Controls.Add(this.label1); - this.Controls.Add(this.stackTraceTextBox); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ExceptionWindow"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "LogExpert Error"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TextBox stackTraceTextBox; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Button okButton; - private System.Windows.Forms.Button copyButton; - } +namespace LogExpert.UI.Dialogs +{ + partial class ExceptionWindow + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ExceptionWindow)); + this.stackTraceTextBox = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.okButton = new System.Windows.Forms.Button(); + this.copyButton = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // stackTraceTextBox + // + this.stackTraceTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.stackTraceTextBox.Location = new System.Drawing.Point(12, 42); + this.stackTraceTextBox.Multiline = true; + this.stackTraceTextBox.Name = "stackTraceTextBox"; + this.stackTraceTextBox.ReadOnly = true; + this.stackTraceTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.stackTraceTextBox.Size = new System.Drawing.Size(439, 205); + this.stackTraceTextBox.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(13, 13); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(310, 13); + this.label1.TabIndex = 1; + this.label1.Text = "An unhandled error has occured. Please report to the developer."; + // + // okButton + // + this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.Location = new System.Drawing.Point(376, 265); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(75, 23); + this.okButton.TabIndex = 2; + this.okButton.Text = "Close"; + this.okButton.UseVisualStyleBackColor = true; + // + // copyButton + // + this.copyButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.copyButton.Location = new System.Drawing.Point(12, 265); + this.copyButton.Name = "copyButton"; + this.copyButton.Size = new System.Drawing.Size(117, 23); + this.copyButton.TabIndex = 4; + this.copyButton.Text = "Copy to clipboard"; + this.copyButton.UseVisualStyleBackColor = true; + this.copyButton.Click += new System.EventHandler(this.copyButton_Click); + // + // ExceptionWindow + // + this.CancelButton = this.okButton; + this.ClientSize = new System.Drawing.Size(464, 300); + this.Controls.Add(this.copyButton); + this.Controls.Add(this.okButton); + this.Controls.Add(this.label1); + this.Controls.Add(this.stackTraceTextBox); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ExceptionWindow"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "LogExpert Error"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox stackTraceTextBox; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button okButton; + private System.Windows.Forms.Button copyButton; + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/ExceptionWindow.cs b/src/Logexpert.UI/Dialogs/ExceptionWindow.cs similarity index 85% rename from src/LogExpert/Dialogs/ExceptionWindow.cs rename to src/Logexpert.UI/Dialogs/ExceptionWindow.cs index 4d557602..4ada46c7 100644 --- a/src/LogExpert/Dialogs/ExceptionWindow.cs +++ b/src/Logexpert.UI/Dialogs/ExceptionWindow.cs @@ -1,53 +1,49 @@ -using System; -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public partial class ExceptionWindow : Form - { - #region Fields - - private readonly string _errorText; - - private readonly string _stackTrace; - - #endregion - - #region cTor - - public ExceptionWindow(string errorText, string stackTrace) - { - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - _errorText = errorText; - _stackTrace = stackTrace; - - stackTraceTextBox.Text = _errorText + @"\n\n" + _stackTrace; - stackTraceTextBox.Select(0, 0); - } - - #endregion - - #region Private Methods - - private void CopyToClipboard() - { - Clipboard.SetText(_errorText + @"\n\n" + _stackTrace); - } - - #endregion - - #region Events handler - - private void copyButton_Click(object sender, EventArgs e) - { - CopyToClipboard(); - } - - #endregion - } +namespace LogExpert.UI.Dialogs +{ + public partial class ExceptionWindow : Form + { + #region Fields + + private readonly string _errorText; + + private readonly string _stackTrace; + + #endregion + + #region cTor + + public ExceptionWindow(string errorText, string stackTrace) + { + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + _errorText = errorText; + _stackTrace = stackTrace; + + stackTraceTextBox.Text = _errorText + @"\n\n" + _stackTrace; + stackTraceTextBox.Select(0, 0); + } + + #endregion + + #region Private Methods + + private void CopyToClipboard() + { + Clipboard.SetText(_errorText + @"\n\n" + _stackTrace); + } + + #endregion + + #region Events handler + + private void copyButton_Click(object sender, EventArgs e) + { + CopyToClipboard(); + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/ExceptionWindow.resx b/src/Logexpert.UI/Dialogs/ExceptionWindow.resx similarity index 98% rename from src/LogExpert/Dialogs/ExceptionWindow.resx rename to src/Logexpert.UI/Dialogs/ExceptionWindow.resx index 2de0ae4d..a43dafee 100644 --- a/src/LogExpert/Dialogs/ExceptionWindow.resx +++ b/src/Logexpert.UI/Dialogs/ExceptionWindow.resx @@ -1,131 +1,131 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA - AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// - AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// - //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA - AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAIABAAD//wAA - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// + //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA + AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAIABAAD//wAA + + \ No newline at end of file diff --git a/src/LogExpert/Dialogs/FilterColumnChooser.Designer.cs b/src/Logexpert.UI/Dialogs/FilterColumnChooser.Designer.cs similarity index 97% rename from src/LogExpert/Dialogs/FilterColumnChooser.Designer.cs rename to src/Logexpert.UI/Dialogs/FilterColumnChooser.Designer.cs index 6936b914..1fe5b69e 100644 --- a/src/LogExpert/Dialogs/FilterColumnChooser.Designer.cs +++ b/src/Logexpert.UI/Dialogs/FilterColumnChooser.Designer.cs @@ -1,218 +1,218 @@ -namespace LogExpert.Dialogs -{ - partial class FilterColumnChooser - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FilterColumnChooser)); - this.columnListBox = new System.Windows.Forms.CheckedListBox(); - this.buttonOk = new System.Windows.Forms.Button(); - this.toolTipEmptyColumnNoHit = new System.Windows.Forms.ToolTip(this.components); - this.emptyColumnNoHitRadioButton = new System.Windows.Forms.RadioButton(); - this.toolTipListBox = new System.Windows.Forms.ToolTip(this.components); - this.checkBoxExactMatch = new System.Windows.Forms.CheckBox(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.emptyColumnUsePrevRadioButton = new System.Windows.Forms.RadioButton(); - this.emptyColumnHitRadioButton = new System.Windows.Forms.RadioButton(); - this.groupBoxExectMatch = new System.Windows.Forms.GroupBox(); - this.toolTipSearchHit = new System.Windows.Forms.ToolTip(this.components); - this.toolTipPrevContent = new System.Windows.Forms.ToolTip(this.components); - this.toolTipExactMatch = new System.Windows.Forms.ToolTip(this.components); - this.buttonCancel = new System.Windows.Forms.Button(); - this.groupBox1.SuspendLayout(); - this.groupBoxExectMatch.SuspendLayout(); - this.SuspendLayout(); - // - // columnListBox - // - this.columnListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.columnListBox.CheckOnClick = true; - this.columnListBox.Font = new System.Drawing.Font("Courier New", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.columnListBox.FormattingEnabled = true; - this.columnListBox.Location = new System.Drawing.Point(3, 3); - this.columnListBox.Name = "columnListBox"; - this.columnListBox.Size = new System.Drawing.Size(177, 119); - this.columnListBox.TabIndex = 0; - this.toolTipListBox.SetToolTip(this.columnListBox, "Choose one ore more columns to restrict the search operations to the selected col" + - "umns."); - // - // buttonOk - // - this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(3, 309); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 23); - this.buttonOk.TabIndex = 2; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.OnOkButtonClick); - // - // toolTipEmptyColumnNoHit - // - this.toolTipEmptyColumnNoHit.ToolTipTitle = "Empty column"; - // - // emptyColumnNoHitRadioButton - // - this.emptyColumnNoHitRadioButton.AutoSize = true; - this.emptyColumnNoHitRadioButton.Location = new System.Drawing.Point(6, 21); - this.emptyColumnNoHitRadioButton.Name = "emptyColumnNoHitRadioButton"; - this.emptyColumnNoHitRadioButton.Size = new System.Drawing.Size(75, 24); - this.emptyColumnNoHitRadioButton.TabIndex = 0; - this.emptyColumnNoHitRadioButton.TabStop = true; - this.emptyColumnNoHitRadioButton.Text = "No hit"; - this.toolTipEmptyColumnNoHit.SetToolTip(this.emptyColumnNoHitRadioButton, "No search hit on empty columns"); - this.emptyColumnNoHitRadioButton.UseVisualStyleBackColor = true; - // - // toolTipListBox - // - this.toolTipListBox.ToolTipTitle = "Columns"; - // - // checkBoxExactMatch - // - this.checkBoxExactMatch.AutoSize = true; - this.checkBoxExactMatch.Location = new System.Drawing.Point(9, 11); - this.checkBoxExactMatch.Name = "checkBoxExactMatch"; - this.checkBoxExactMatch.Size = new System.Drawing.Size(123, 24); - this.checkBoxExactMatch.TabIndex = 4; - this.checkBoxExactMatch.Text = "Exact match"; - this.toolTipExactMatch.SetToolTip(this.checkBoxExactMatch, "If selected, the search string must match exactly (no substring search)"); - this.checkBoxExactMatch.UseVisualStyleBackColor = true; - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.emptyColumnUsePrevRadioButton); - this.groupBox1.Controls.Add(this.emptyColumnHitRadioButton); - this.groupBox1.Controls.Add(this.emptyColumnNoHitRadioButton); - this.groupBox1.Location = new System.Drawing.Point(3, 177); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(177, 108); - this.groupBox1.TabIndex = 5; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "On empty columns"; - // - // emptyColumnUsePrevRadioButton - // - this.emptyColumnUsePrevRadioButton.AutoSize = true; - this.emptyColumnUsePrevRadioButton.Location = new System.Drawing.Point(6, 76); - this.emptyColumnUsePrevRadioButton.Name = "emptyColumnUsePrevRadioButton"; - this.emptyColumnUsePrevRadioButton.Size = new System.Drawing.Size(155, 24); - this.emptyColumnUsePrevRadioButton.TabIndex = 2; - this.emptyColumnUsePrevRadioButton.TabStop = true; - this.emptyColumnUsePrevRadioButton.Text = "Use prev content"; - this.toolTipPrevContent.SetToolTip(this.emptyColumnUsePrevRadioButton, "An empty column will be a search hit if the previous non-empty column was a searc" + - "h hit"); - this.emptyColumnUsePrevRadioButton.UseVisualStyleBackColor = true; - // - // emptyColumnHitRadioButton - // - this.emptyColumnHitRadioButton.AutoSize = true; - this.emptyColumnHitRadioButton.Location = new System.Drawing.Point(6, 49); - this.emptyColumnHitRadioButton.Name = "emptyColumnHitRadioButton"; - this.emptyColumnHitRadioButton.Size = new System.Drawing.Size(106, 24); - this.emptyColumnHitRadioButton.TabIndex = 1; - this.emptyColumnHitRadioButton.TabStop = true; - this.emptyColumnHitRadioButton.Text = "Search hit"; - this.toolTipSearchHit.SetToolTip(this.emptyColumnHitRadioButton, "An empty column will always be a search hit"); - this.emptyColumnHitRadioButton.UseVisualStyleBackColor = true; - // - // groupBoxExectMatch - // - this.groupBoxExectMatch.Controls.Add(this.checkBoxExactMatch); - this.groupBoxExectMatch.Location = new System.Drawing.Point(3, 130); - this.groupBoxExectMatch.Name = "groupBoxExectMatch"; - this.groupBoxExectMatch.Size = new System.Drawing.Size(177, 41); - this.groupBoxExectMatch.TabIndex = 6; - this.groupBoxExectMatch.TabStop = false; - // - // toolTipSearchHit - // - this.toolTipSearchHit.ToolTipTitle = "Empty column"; - // - // toolTipPrevContent - // - this.toolTipPrevContent.ToolTipTitle = "Empty column"; - // - // toolTipExactMatch - // - this.toolTipExactMatch.ToolTipTitle = "Exact match"; - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(104, 309); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 7; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // FilterColumnChooser - // - this.AcceptButton = this.buttonOk; - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(184, 335); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.groupBoxExectMatch); - this.Controls.Add(this.groupBox1); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.columnListBox); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Name = "FilterColumnChooser"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Columns"; - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - this.groupBoxExectMatch.ResumeLayout(false); - this.groupBoxExectMatch.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.CheckedListBox columnListBox; - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.ToolTip toolTipEmptyColumnNoHit; - private System.Windows.Forms.ToolTip toolTipListBox; - private System.Windows.Forms.CheckBox checkBoxExactMatch; - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.RadioButton emptyColumnUsePrevRadioButton; - private System.Windows.Forms.RadioButton emptyColumnHitRadioButton; - private System.Windows.Forms.RadioButton emptyColumnNoHitRadioButton; - private System.Windows.Forms.GroupBox groupBoxExectMatch; - private System.Windows.Forms.ToolTip toolTipExactMatch; - private System.Windows.Forms.ToolTip toolTipSearchHit; - private System.Windows.Forms.ToolTip toolTipPrevContent; - private System.Windows.Forms.Button buttonCancel; - } +namespace LogExpert.UI.Dialogs +{ + partial class FilterColumnChooser + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FilterColumnChooser)); + this.columnListBox = new System.Windows.Forms.CheckedListBox(); + this.buttonOk = new System.Windows.Forms.Button(); + this.toolTipEmptyColumnNoHit = new System.Windows.Forms.ToolTip(this.components); + this.emptyColumnNoHitRadioButton = new System.Windows.Forms.RadioButton(); + this.toolTipListBox = new System.Windows.Forms.ToolTip(this.components); + this.checkBoxExactMatch = new System.Windows.Forms.CheckBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.emptyColumnUsePrevRadioButton = new System.Windows.Forms.RadioButton(); + this.emptyColumnHitRadioButton = new System.Windows.Forms.RadioButton(); + this.groupBoxExectMatch = new System.Windows.Forms.GroupBox(); + this.toolTipSearchHit = new System.Windows.Forms.ToolTip(this.components); + this.toolTipPrevContent = new System.Windows.Forms.ToolTip(this.components); + this.toolTipExactMatch = new System.Windows.Forms.ToolTip(this.components); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBox1.SuspendLayout(); + this.groupBoxExectMatch.SuspendLayout(); + this.SuspendLayout(); + // + // columnListBox + // + this.columnListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.columnListBox.CheckOnClick = true; + this.columnListBox.Font = new System.Drawing.Font("Courier New", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.columnListBox.FormattingEnabled = true; + this.columnListBox.Location = new System.Drawing.Point(3, 3); + this.columnListBox.Name = "columnListBox"; + this.columnListBox.Size = new System.Drawing.Size(177, 119); + this.columnListBox.TabIndex = 0; + this.toolTipListBox.SetToolTip(this.columnListBox, "Choose one ore more columns to restrict the search operations to the selected col" + + "umns."); + // + // buttonOk + // + this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(3, 309); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 2; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.OnOkButtonClick); + // + // toolTipEmptyColumnNoHit + // + this.toolTipEmptyColumnNoHit.ToolTipTitle = "Empty column"; + // + // emptyColumnNoHitRadioButton + // + this.emptyColumnNoHitRadioButton.AutoSize = true; + this.emptyColumnNoHitRadioButton.Location = new System.Drawing.Point(6, 21); + this.emptyColumnNoHitRadioButton.Name = "emptyColumnNoHitRadioButton"; + this.emptyColumnNoHitRadioButton.Size = new System.Drawing.Size(75, 24); + this.emptyColumnNoHitRadioButton.TabIndex = 0; + this.emptyColumnNoHitRadioButton.TabStop = true; + this.emptyColumnNoHitRadioButton.Text = "No hit"; + this.toolTipEmptyColumnNoHit.SetToolTip(this.emptyColumnNoHitRadioButton, "No search hit on empty columns"); + this.emptyColumnNoHitRadioButton.UseVisualStyleBackColor = true; + // + // toolTipListBox + // + this.toolTipListBox.ToolTipTitle = "Columns"; + // + // checkBoxExactMatch + // + this.checkBoxExactMatch.AutoSize = true; + this.checkBoxExactMatch.Location = new System.Drawing.Point(9, 11); + this.checkBoxExactMatch.Name = "checkBoxExactMatch"; + this.checkBoxExactMatch.Size = new System.Drawing.Size(123, 24); + this.checkBoxExactMatch.TabIndex = 4; + this.checkBoxExactMatch.Text = "Exact match"; + this.toolTipExactMatch.SetToolTip(this.checkBoxExactMatch, "If selected, the search string must match exactly (no substring search)"); + this.checkBoxExactMatch.UseVisualStyleBackColor = true; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.emptyColumnUsePrevRadioButton); + this.groupBox1.Controls.Add(this.emptyColumnHitRadioButton); + this.groupBox1.Controls.Add(this.emptyColumnNoHitRadioButton); + this.groupBox1.Location = new System.Drawing.Point(3, 177); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(177, 108); + this.groupBox1.TabIndex = 5; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "On empty columns"; + // + // emptyColumnUsePrevRadioButton + // + this.emptyColumnUsePrevRadioButton.AutoSize = true; + this.emptyColumnUsePrevRadioButton.Location = new System.Drawing.Point(6, 76); + this.emptyColumnUsePrevRadioButton.Name = "emptyColumnUsePrevRadioButton"; + this.emptyColumnUsePrevRadioButton.Size = new System.Drawing.Size(155, 24); + this.emptyColumnUsePrevRadioButton.TabIndex = 2; + this.emptyColumnUsePrevRadioButton.TabStop = true; + this.emptyColumnUsePrevRadioButton.Text = "Use prev content"; + this.toolTipPrevContent.SetToolTip(this.emptyColumnUsePrevRadioButton, "An empty column will be a search hit if the previous non-empty column was a searc" + + "h hit"); + this.emptyColumnUsePrevRadioButton.UseVisualStyleBackColor = true; + // + // emptyColumnHitRadioButton + // + this.emptyColumnHitRadioButton.AutoSize = true; + this.emptyColumnHitRadioButton.Location = new System.Drawing.Point(6, 49); + this.emptyColumnHitRadioButton.Name = "emptyColumnHitRadioButton"; + this.emptyColumnHitRadioButton.Size = new System.Drawing.Size(106, 24); + this.emptyColumnHitRadioButton.TabIndex = 1; + this.emptyColumnHitRadioButton.TabStop = true; + this.emptyColumnHitRadioButton.Text = "Search hit"; + this.toolTipSearchHit.SetToolTip(this.emptyColumnHitRadioButton, "An empty column will always be a search hit"); + this.emptyColumnHitRadioButton.UseVisualStyleBackColor = true; + // + // groupBoxExectMatch + // + this.groupBoxExectMatch.Controls.Add(this.checkBoxExactMatch); + this.groupBoxExectMatch.Location = new System.Drawing.Point(3, 130); + this.groupBoxExectMatch.Name = "groupBoxExectMatch"; + this.groupBoxExectMatch.Size = new System.Drawing.Size(177, 41); + this.groupBoxExectMatch.TabIndex = 6; + this.groupBoxExectMatch.TabStop = false; + // + // toolTipSearchHit + // + this.toolTipSearchHit.ToolTipTitle = "Empty column"; + // + // toolTipPrevContent + // + this.toolTipPrevContent.ToolTipTitle = "Empty column"; + // + // toolTipExactMatch + // + this.toolTipExactMatch.ToolTipTitle = "Exact match"; + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(104, 309); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 7; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // FilterColumnChooser + // + this.AcceptButton = this.buttonOk; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(184, 335); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.groupBoxExectMatch); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.columnListBox); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Name = "FilterColumnChooser"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Columns"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBoxExectMatch.ResumeLayout(false); + this.groupBoxExectMatch.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.CheckedListBox columnListBox; + private System.Windows.Forms.Button buttonOk; + private System.Windows.Forms.ToolTip toolTipEmptyColumnNoHit; + private System.Windows.Forms.ToolTip toolTipListBox; + private System.Windows.Forms.CheckBox checkBoxExactMatch; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.RadioButton emptyColumnUsePrevRadioButton; + private System.Windows.Forms.RadioButton emptyColumnHitRadioButton; + private System.Windows.Forms.RadioButton emptyColumnNoHitRadioButton; + private System.Windows.Forms.GroupBox groupBoxExectMatch; + private System.Windows.Forms.ToolTip toolTipExactMatch; + private System.Windows.Forms.ToolTip toolTipSearchHit; + private System.Windows.Forms.ToolTip toolTipPrevContent; + private System.Windows.Forms.Button buttonCancel; + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/FilterColumnChooser.cs b/src/Logexpert.UI/Dialogs/FilterColumnChooser.cs similarity index 90% rename from src/LogExpert/Dialogs/FilterColumnChooser.cs rename to src/Logexpert.UI/Dialogs/FilterColumnChooser.cs index 00162ed8..e063524e 100644 --- a/src/LogExpert/Dialogs/FilterColumnChooser.cs +++ b/src/Logexpert.UI/Dialogs/FilterColumnChooser.cs @@ -1,73 +1,74 @@ -using System; -using System.Drawing; -using System.Windows.Forms; - -using LogExpert.Core.Classes.Filter; - -namespace LogExpert.Dialogs -{ - public partial class FilterColumnChooser : Form - { - #region Fields - - private readonly ILogLineColumnizer _columnizer; - private readonly FilterParams _filterParams; - - #endregion - - #region cTor - - public FilterColumnChooser(FilterParams filterParams) - { - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - columnListBox.ItemHeight = columnListBox.Font.Height; - - _columnizer = filterParams.currentColumnizer; - _filterParams = filterParams; - - Init(); - } - - #endregion - - #region Private Methods - - private void Init() - { - int count = _columnizer.GetColumnCount(); - string[] names = _columnizer.GetColumnNames(); - - for (int i = 0; i < count; ++i) - { - columnListBox.Items.Add(names[i], _filterParams.columnList.Contains(i)); - } - - emptyColumnUsePrevRadioButton.Checked = _filterParams.emptyColumnUsePrev; - emptyColumnHitRadioButton.Checked = _filterParams.emptyColumnHit; - emptyColumnNoHitRadioButton.Checked = _filterParams.emptyColumnHit == false && _filterParams.emptyColumnUsePrev == false; - checkBoxExactMatch.Checked = _filterParams.exactColumnMatch; - } - - #endregion - - #region Events handler - - private void OnOkButtonClick(object sender, EventArgs e) - { - _filterParams.columnList.Clear(); - foreach (int colNum in columnListBox.CheckedIndices) - { - _filterParams.columnList.Add(colNum); - } - _filterParams.emptyColumnUsePrev = emptyColumnUsePrevRadioButton.Checked; - _filterParams.emptyColumnHit = emptyColumnHitRadioButton.Checked; - _filterParams.exactColumnMatch = checkBoxExactMatch.Checked; - } - - #endregion - } +using LogExpert.Core.Classes.Filter; + +using System.Runtime.Versioning; + +namespace LogExpert.UI.Dialogs +{ + [SupportedOSPlatform("windows")] + public partial class FilterColumnChooser : Form + { + #region Fields + + private readonly ILogLineColumnizer _columnizer; + private readonly FilterParams _filterParams; + + #endregion + + #region cTor + + public FilterColumnChooser(FilterParams filterParams) + { + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + columnListBox.ItemHeight = columnListBox.Font.Height; + + _columnizer = filterParams.currentColumnizer; + _filterParams = filterParams; + + Init(); + } + + #endregion + + #region Private Methods + + private void Init() + { + int count = _columnizer.GetColumnCount(); + string[] names = _columnizer.GetColumnNames(); + + for (int i = 0; i < count; ++i) + { + columnListBox.Items.Add(names[i], _filterParams.columnList.Contains(i)); + } + + emptyColumnUsePrevRadioButton.Checked = _filterParams.emptyColumnUsePrev; + emptyColumnHitRadioButton.Checked = _filterParams.emptyColumnHit; + emptyColumnNoHitRadioButton.Checked = _filterParams.emptyColumnHit == false && _filterParams.emptyColumnUsePrev == false; + checkBoxExactMatch.Checked = _filterParams.exactColumnMatch; + } + + #endregion + + #region Events handler + + private void OnOkButtonClick(object sender, EventArgs e) + { + _filterParams.columnList.Clear(); + + foreach (int colNum in columnListBox.CheckedIndices) + { + _filterParams.columnList.Add(colNum); + } + + _filterParams.emptyColumnUsePrev = emptyColumnUsePrevRadioButton.Checked; + _filterParams.emptyColumnHit = emptyColumnHitRadioButton.Checked; + _filterParams.exactColumnMatch = checkBoxExactMatch.Checked; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/FilterColumnChooser.resx b/src/Logexpert.UI/Dialogs/FilterColumnChooser.resx similarity index 98% rename from src/LogExpert/Dialogs/FilterColumnChooser.resx rename to src/Logexpert.UI/Dialogs/FilterColumnChooser.resx index bfab700f..a80b2c8f 100644 --- a/src/LogExpert/Dialogs/FilterColumnChooser.resx +++ b/src/Logexpert.UI/Dialogs/FilterColumnChooser.resx @@ -1,149 +1,149 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 184, 17 - - - 17, 17 - - - 611, 17 - - - 454, 17 - - - 312, 17 - - - 71 - - - - - AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA - AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// - AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// - //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA - AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAIABAAD//wAA - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 184, 17 + + + 17, 17 + + + 611, 17 + + + 454, 17 + + + 312, 17 + + + 71 + + + + + AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// + //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA + AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAIABAAD//wAA + + \ No newline at end of file diff --git a/src/LogExpert/Dialogs/GotoLineDialog.Designer.cs b/src/Logexpert.UI/Dialogs/GotoLineDialog.Designer.cs similarity index 97% rename from src/LogExpert/Dialogs/GotoLineDialog.Designer.cs rename to src/Logexpert.UI/Dialogs/GotoLineDialog.Designer.cs index 7e99ca2d..dd708615 100644 --- a/src/LogExpert/Dialogs/GotoLineDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/GotoLineDialog.Designer.cs @@ -1,108 +1,108 @@ -namespace LogExpert.Dialogs -{ - partial class GotoLineDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.labelLineNumber = new System.Windows.Forms.Label(); - this.buttonOk = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.lineNumberTextBox = new System.Windows.Forms.TextBox(); - this.SuspendLayout(); - // - // labelLineNumber - // - this.labelLineNumber.AutoSize = true; - this.labelLineNumber.Location = new System.Drawing.Point(12, 30); - this.labelLineNumber.Name = "labelLineNumber"; - this.labelLineNumber.Size = new System.Drawing.Size(101, 20); - this.labelLineNumber.TabIndex = 0; - this.labelLineNumber.Text = "Line number:"; - // - // buttonOk - // - this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonOk.AutoSize = true; - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(15, 90); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 30); - this.buttonOk.TabIndex = 2; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.okButton_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.AutoSize = true; - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(149, 90); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 30); - this.buttonCancel.TabIndex = 3; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // lineNumberTextBox - // - this.lineNumberTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.lineNumberTextBox.Location = new System.Drawing.Point(124, 27); - this.lineNumberTextBox.Name = "lineNumberTextBox"; - this.lineNumberTextBox.Size = new System.Drawing.Size(100, 26); - this.lineNumberTextBox.TabIndex = 0; - // - // GotoLineDialog - // - this.AcceptButton = this.buttonOk; - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(243, 130); - this.Controls.Add(this.lineNumberTextBox); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.labelLineNumber); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "GotoLineDialog"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Go to line"; - this.Load += new System.EventHandler(this.GotoLineDialog_Load); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label labelLineNumber; - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.TextBox lineNumberTextBox; - } +namespace LogExpert.UI.Dialogs +{ + partial class GotoLineDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.labelLineNumber = new System.Windows.Forms.Label(); + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.lineNumberTextBox = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // labelLineNumber + // + this.labelLineNumber.AutoSize = true; + this.labelLineNumber.Location = new System.Drawing.Point(12, 30); + this.labelLineNumber.Name = "labelLineNumber"; + this.labelLineNumber.Size = new System.Drawing.Size(101, 20); + this.labelLineNumber.TabIndex = 0; + this.labelLineNumber.Text = "Line number:"; + // + // buttonOk + // + this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonOk.AutoSize = true; + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(15, 90); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 30); + this.buttonOk.TabIndex = 2; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.okButton_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.AutoSize = true; + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(149, 90); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 30); + this.buttonCancel.TabIndex = 3; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // lineNumberTextBox + // + this.lineNumberTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.lineNumberTextBox.Location = new System.Drawing.Point(124, 27); + this.lineNumberTextBox.Name = "lineNumberTextBox"; + this.lineNumberTextBox.Size = new System.Drawing.Size(100, 26); + this.lineNumberTextBox.TabIndex = 0; + // + // GotoLineDialog + // + this.AcceptButton = this.buttonOk; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(243, 130); + this.Controls.Add(this.lineNumberTextBox); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.labelLineNumber); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "GotoLineDialog"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Go to line"; + this.Load += new System.EventHandler(this.GotoLineDialog_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label labelLineNumber; + private System.Windows.Forms.Button buttonOk; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.TextBox lineNumberTextBox; + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/GotoLineDialog.cs b/src/Logexpert.UI/Dialogs/GotoLineDialog.cs similarity index 85% rename from src/LogExpert/Dialogs/GotoLineDialog.cs rename to src/Logexpert.UI/Dialogs/GotoLineDialog.cs index 622a1ccb..7ebe8bef 100644 --- a/src/LogExpert/Dialogs/GotoLineDialog.cs +++ b/src/Logexpert.UI/Dialogs/GotoLineDialog.cs @@ -1,53 +1,52 @@ -using System; -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public partial class GotoLineDialog : Form - { - #region Fields - - #endregion - - #region cTor - - public GotoLineDialog(Form parent) - { - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - Owner = parent; - } - - #endregion - - #region Properties - - public int Line { get; private set; } - - #endregion - - #region Events handler - - private void GotoLineDialog_Load(object sender, EventArgs e) - { - } - - private void okButton_Click(object sender, EventArgs e) - { - try - { - Line = int.Parse(lineNumberTextBox.Text); - } - catch (Exception) - { - Line = -1; - } - } - - #endregion - } +using System.Runtime.Versioning; + +namespace LogExpert.UI.Dialogs +{ + [SupportedOSPlatform("windows")] + public partial class GotoLineDialog : Form + { + #region Fields + + #endregion + + #region cTor + + public GotoLineDialog(Form parent) + { + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + Owner = parent; + } + + #endregion + + #region Properties + + public int Line { get; private set; } + + #endregion + + #region Events handler + + private void GotoLineDialog_Load(object sender, EventArgs e) + { + } + + private void okButton_Click(object sender, EventArgs e) + { + try + { + Line = int.Parse(lineNumberTextBox.Text); + } + catch (Exception) + { + Line = -1; + } + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/GotoLineDialog.resx b/src/Logexpert.UI/Dialogs/GotoLineDialog.resx similarity index 97% rename from src/LogExpert/Dialogs/GotoLineDialog.resx rename to src/Logexpert.UI/Dialogs/GotoLineDialog.resx index c7e0d4bd..d58980a3 100644 --- a/src/LogExpert/Dialogs/GotoLineDialog.resx +++ b/src/Logexpert.UI/Dialogs/GotoLineDialog.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/LogExpert/Dialogs/ImportSettingsDialog.Designer.cs b/src/Logexpert.UI/Dialogs/ImportSettingsDialog.Designer.cs similarity index 97% rename from src/LogExpert/Dialogs/ImportSettingsDialog.Designer.cs rename to src/Logexpert.UI/Dialogs/ImportSettingsDialog.Designer.cs index 2203a049..2c420493 100644 --- a/src/LogExpert/Dialogs/ImportSettingsDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/ImportSettingsDialog.Designer.cs @@ -1,226 +1,226 @@ -namespace LogExpert.Dialogs -{ - partial class ImportSettingsDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImportSettingsDialog)); - this.buttonFile = new System.Windows.Forms.Button(); - this.textBoxFileName = new System.Windows.Forms.TextBox(); - this.labelSettingsFileToImport = new System.Windows.Forms.Label(); - this.groupBoxImportOptions = new System.Windows.Forms.GroupBox(); - this.checkBoxKeepExistingSettings = new System.Windows.Forms.CheckBox(); - this.checkBoxOther = new System.Windows.Forms.CheckBox(); - this.checkBoxExternalTools = new System.Windows.Forms.CheckBox(); - this.checkBoxColumnizerFileMasks = new System.Windows.Forms.CheckBox(); - this.checkBoxHighlightFileMasks = new System.Windows.Forms.CheckBox(); - this.checkBoxHighlightSettings = new System.Windows.Forms.CheckBox(); - this.buttonOk = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.groupBoxImportOptions.SuspendLayout(); - this.SuspendLayout(); - // - // buttonFile - // - this.buttonFile.Location = new System.Drawing.Point(306, 25); - this.buttonFile.Name = "buttonFile"; - this.buttonFile.Size = new System.Drawing.Size(94, 23); - this.buttonFile.TabIndex = 0; - this.buttonFile.Text = "Choose file..."; - this.buttonFile.UseVisualStyleBackColor = true; - this.buttonFile.Click += new System.EventHandler(this.OnFileButtonClick); - // - // textBoxFileName - // - this.textBoxFileName.Location = new System.Drawing.Point(13, 27); - this.textBoxFileName.Name = "textBoxFileName"; - this.textBoxFileName.Size = new System.Drawing.Size(287, 20); - this.textBoxFileName.TabIndex = 1; - // - // labelSettingsFileToImport - // - this.labelSettingsFileToImport.AutoSize = true; - this.labelSettingsFileToImport.Location = new System.Drawing.Point(13, 8); - this.labelSettingsFileToImport.Name = "labelSettingsFileToImport"; - this.labelSettingsFileToImport.Size = new System.Drawing.Size(107, 13); - this.labelSettingsFileToImport.TabIndex = 2; - this.labelSettingsFileToImport.Text = "Settings file to import:"; - // - // groupBoxImportOptions - // - this.groupBoxImportOptions.Controls.Add(this.checkBoxKeepExistingSettings); - this.groupBoxImportOptions.Controls.Add(this.checkBoxOther); - this.groupBoxImportOptions.Controls.Add(this.checkBoxExternalTools); - this.groupBoxImportOptions.Controls.Add(this.checkBoxColumnizerFileMasks); - this.groupBoxImportOptions.Controls.Add(this.checkBoxHighlightFileMasks); - this.groupBoxImportOptions.Controls.Add(this.checkBoxHighlightSettings); - this.groupBoxImportOptions.Location = new System.Drawing.Point(16, 67); - this.groupBoxImportOptions.Name = "groupBoxImportOptions"; - this.groupBoxImportOptions.Size = new System.Drawing.Size(284, 143); - this.groupBoxImportOptions.TabIndex = 3; - this.groupBoxImportOptions.TabStop = false; - this.groupBoxImportOptions.Text = "Import options"; - // - // checkBoxKeepExistingSettings - // - this.checkBoxKeepExistingSettings.AutoSize = true; - this.checkBoxKeepExistingSettings.Location = new System.Drawing.Point(141, 20); - this.checkBoxKeepExistingSettings.Name = "checkBoxKeepExistingSettings"; - this.checkBoxKeepExistingSettings.Size = new System.Drawing.Size(128, 17); - this.checkBoxKeepExistingSettings.TabIndex = 1; - this.checkBoxKeepExistingSettings.Tag = "32"; - this.checkBoxKeepExistingSettings.Text = "Keep existing settings"; - this.checkBoxKeepExistingSettings.UseVisualStyleBackColor = true; - // - // checkBoxOther - // - this.checkBoxOther.AutoSize = true; - this.checkBoxOther.Checked = true; - this.checkBoxOther.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxOther.Location = new System.Drawing.Point(7, 112); - this.checkBoxOther.Name = "checkBoxOther"; - this.checkBoxOther.Size = new System.Drawing.Size(52, 17); - this.checkBoxOther.TabIndex = 0; - this.checkBoxOther.Tag = "16"; - this.checkBoxOther.Text = "Other"; - this.checkBoxOther.UseVisualStyleBackColor = true; - // - // checkBoxExternalTools - // - this.checkBoxExternalTools.AutoSize = true; - this.checkBoxExternalTools.Checked = true; - this.checkBoxExternalTools.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxExternalTools.Location = new System.Drawing.Point(7, 89); - this.checkBoxExternalTools.Name = "checkBoxExternalTools"; - this.checkBoxExternalTools.Size = new System.Drawing.Size(89, 17); - this.checkBoxExternalTools.TabIndex = 0; - this.checkBoxExternalTools.Tag = "8"; - this.checkBoxExternalTools.Text = "External tools"; - this.checkBoxExternalTools.UseVisualStyleBackColor = true; - // - // checkBoxColumnizerFileMasks - // - this.checkBoxColumnizerFileMasks.AutoSize = true; - this.checkBoxColumnizerFileMasks.Checked = true; - this.checkBoxColumnizerFileMasks.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxColumnizerFileMasks.Location = new System.Drawing.Point(7, 66); - this.checkBoxColumnizerFileMasks.Name = "checkBoxColumnizerFileMasks"; - this.checkBoxColumnizerFileMasks.Size = new System.Drawing.Size(126, 17); - this.checkBoxColumnizerFileMasks.TabIndex = 0; - this.checkBoxColumnizerFileMasks.Tag = "2"; - this.checkBoxColumnizerFileMasks.Text = "Columnizer file masks"; - this.checkBoxColumnizerFileMasks.UseVisualStyleBackColor = true; - // - // checkBoxHighlightFileMasks - // - this.checkBoxHighlightFileMasks.AutoSize = true; - this.checkBoxHighlightFileMasks.Checked = true; - this.checkBoxHighlightFileMasks.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxHighlightFileMasks.Location = new System.Drawing.Point(7, 43); - this.checkBoxHighlightFileMasks.Name = "checkBoxHighlightFileMasks"; - this.checkBoxHighlightFileMasks.Size = new System.Drawing.Size(116, 17); - this.checkBoxHighlightFileMasks.TabIndex = 0; - this.checkBoxHighlightFileMasks.Tag = "4"; - this.checkBoxHighlightFileMasks.Text = "Highlight file masks"; - this.checkBoxHighlightFileMasks.UseVisualStyleBackColor = true; - // - // checkBoxHighlightSettings - // - this.checkBoxHighlightSettings.AutoSize = true; - this.checkBoxHighlightSettings.Checked = true; - this.checkBoxHighlightSettings.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxHighlightSettings.Location = new System.Drawing.Point(7, 20); - this.checkBoxHighlightSettings.Name = "checkBoxHighlightSettings"; - this.checkBoxHighlightSettings.Size = new System.Drawing.Size(106, 17); - this.checkBoxHighlightSettings.TabIndex = 0; - this.checkBoxHighlightSettings.Tag = "1"; - this.checkBoxHighlightSettings.Text = "Highlight settings"; - this.checkBoxHighlightSettings.UseVisualStyleBackColor = true; - // - // buttonOk - // - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(325, 187); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 23); - this.buttonOk.TabIndex = 4; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.OnOkButtonClick); - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(325, 154); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // ImportSettingsDialog - // - this.AcceptButton = this.buttonOk; - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(412, 224); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.groupBoxImportOptions); - this.Controls.Add(this.labelSettingsFileToImport); - this.Controls.Add(this.textBoxFileName); - this.Controls.Add(this.buttonFile); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ImportSettingsDialog"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Import Settings"; - this.Load += new System.EventHandler(this.OnImportSettingsDialogLoad); - this.groupBoxImportOptions.ResumeLayout(false); - this.groupBoxImportOptions.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonFile; - private System.Windows.Forms.TextBox textBoxFileName; - private System.Windows.Forms.Label labelSettingsFileToImport; - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.Button buttonCancel; - public System.Windows.Forms.CheckBox checkBoxExternalTools; - public System.Windows.Forms.CheckBox checkBoxColumnizerFileMasks; - public System.Windows.Forms.CheckBox checkBoxHighlightFileMasks; - public System.Windows.Forms.CheckBox checkBoxHighlightSettings; - public System.Windows.Forms.CheckBox checkBoxOther; - public System.Windows.Forms.CheckBox checkBoxKeepExistingSettings; - public System.Windows.Forms.GroupBox groupBoxImportOptions; - } +namespace LogExpert.UI.Dialogs +{ + partial class ImportSettingsDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImportSettingsDialog)); + this.buttonFile = new System.Windows.Forms.Button(); + this.textBoxFileName = new System.Windows.Forms.TextBox(); + this.labelSettingsFileToImport = new System.Windows.Forms.Label(); + this.groupBoxImportOptions = new System.Windows.Forms.GroupBox(); + this.checkBoxKeepExistingSettings = new System.Windows.Forms.CheckBox(); + this.checkBoxOther = new System.Windows.Forms.CheckBox(); + this.checkBoxExternalTools = new System.Windows.Forms.CheckBox(); + this.checkBoxColumnizerFileMasks = new System.Windows.Forms.CheckBox(); + this.checkBoxHighlightFileMasks = new System.Windows.Forms.CheckBox(); + this.checkBoxHighlightSettings = new System.Windows.Forms.CheckBox(); + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBoxImportOptions.SuspendLayout(); + this.SuspendLayout(); + // + // buttonFile + // + this.buttonFile.Location = new System.Drawing.Point(306, 25); + this.buttonFile.Name = "buttonFile"; + this.buttonFile.Size = new System.Drawing.Size(94, 23); + this.buttonFile.TabIndex = 0; + this.buttonFile.Text = "Choose file..."; + this.buttonFile.UseVisualStyleBackColor = true; + this.buttonFile.Click += new System.EventHandler(this.OnFileButtonClick); + // + // textBoxFileName + // + this.textBoxFileName.Location = new System.Drawing.Point(13, 27); + this.textBoxFileName.Name = "textBoxFileName"; + this.textBoxFileName.Size = new System.Drawing.Size(287, 20); + this.textBoxFileName.TabIndex = 1; + // + // labelSettingsFileToImport + // + this.labelSettingsFileToImport.AutoSize = true; + this.labelSettingsFileToImport.Location = new System.Drawing.Point(13, 8); + this.labelSettingsFileToImport.Name = "labelSettingsFileToImport"; + this.labelSettingsFileToImport.Size = new System.Drawing.Size(107, 13); + this.labelSettingsFileToImport.TabIndex = 2; + this.labelSettingsFileToImport.Text = "Settings file to import:"; + // + // groupBoxImportOptions + // + this.groupBoxImportOptions.Controls.Add(this.checkBoxKeepExistingSettings); + this.groupBoxImportOptions.Controls.Add(this.checkBoxOther); + this.groupBoxImportOptions.Controls.Add(this.checkBoxExternalTools); + this.groupBoxImportOptions.Controls.Add(this.checkBoxColumnizerFileMasks); + this.groupBoxImportOptions.Controls.Add(this.checkBoxHighlightFileMasks); + this.groupBoxImportOptions.Controls.Add(this.checkBoxHighlightSettings); + this.groupBoxImportOptions.Location = new System.Drawing.Point(16, 67); + this.groupBoxImportOptions.Name = "groupBoxImportOptions"; + this.groupBoxImportOptions.Size = new System.Drawing.Size(284, 143); + this.groupBoxImportOptions.TabIndex = 3; + this.groupBoxImportOptions.TabStop = false; + this.groupBoxImportOptions.Text = "Import options"; + // + // checkBoxKeepExistingSettings + // + this.checkBoxKeepExistingSettings.AutoSize = true; + this.checkBoxKeepExistingSettings.Location = new System.Drawing.Point(141, 20); + this.checkBoxKeepExistingSettings.Name = "checkBoxKeepExistingSettings"; + this.checkBoxKeepExistingSettings.Size = new System.Drawing.Size(128, 17); + this.checkBoxKeepExistingSettings.TabIndex = 1; + this.checkBoxKeepExistingSettings.Tag = "32"; + this.checkBoxKeepExistingSettings.Text = "Keep existing settings"; + this.checkBoxKeepExistingSettings.UseVisualStyleBackColor = true; + // + // checkBoxOther + // + this.checkBoxOther.AutoSize = true; + this.checkBoxOther.Checked = true; + this.checkBoxOther.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxOther.Location = new System.Drawing.Point(7, 112); + this.checkBoxOther.Name = "checkBoxOther"; + this.checkBoxOther.Size = new System.Drawing.Size(52, 17); + this.checkBoxOther.TabIndex = 0; + this.checkBoxOther.Tag = "16"; + this.checkBoxOther.Text = "Other"; + this.checkBoxOther.UseVisualStyleBackColor = true; + // + // checkBoxExternalTools + // + this.checkBoxExternalTools.AutoSize = true; + this.checkBoxExternalTools.Checked = true; + this.checkBoxExternalTools.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxExternalTools.Location = new System.Drawing.Point(7, 89); + this.checkBoxExternalTools.Name = "checkBoxExternalTools"; + this.checkBoxExternalTools.Size = new System.Drawing.Size(89, 17); + this.checkBoxExternalTools.TabIndex = 0; + this.checkBoxExternalTools.Tag = "8"; + this.checkBoxExternalTools.Text = "External tools"; + this.checkBoxExternalTools.UseVisualStyleBackColor = true; + // + // checkBoxColumnizerFileMasks + // + this.checkBoxColumnizerFileMasks.AutoSize = true; + this.checkBoxColumnizerFileMasks.Checked = true; + this.checkBoxColumnizerFileMasks.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxColumnizerFileMasks.Location = new System.Drawing.Point(7, 66); + this.checkBoxColumnizerFileMasks.Name = "checkBoxColumnizerFileMasks"; + this.checkBoxColumnizerFileMasks.Size = new System.Drawing.Size(126, 17); + this.checkBoxColumnizerFileMasks.TabIndex = 0; + this.checkBoxColumnizerFileMasks.Tag = "2"; + this.checkBoxColumnizerFileMasks.Text = "Columnizer file masks"; + this.checkBoxColumnizerFileMasks.UseVisualStyleBackColor = true; + // + // checkBoxHighlightFileMasks + // + this.checkBoxHighlightFileMasks.AutoSize = true; + this.checkBoxHighlightFileMasks.Checked = true; + this.checkBoxHighlightFileMasks.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxHighlightFileMasks.Location = new System.Drawing.Point(7, 43); + this.checkBoxHighlightFileMasks.Name = "checkBoxHighlightFileMasks"; + this.checkBoxHighlightFileMasks.Size = new System.Drawing.Size(116, 17); + this.checkBoxHighlightFileMasks.TabIndex = 0; + this.checkBoxHighlightFileMasks.Tag = "4"; + this.checkBoxHighlightFileMasks.Text = "Highlight file masks"; + this.checkBoxHighlightFileMasks.UseVisualStyleBackColor = true; + // + // checkBoxHighlightSettings + // + this.checkBoxHighlightSettings.AutoSize = true; + this.checkBoxHighlightSettings.Checked = true; + this.checkBoxHighlightSettings.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxHighlightSettings.Location = new System.Drawing.Point(7, 20); + this.checkBoxHighlightSettings.Name = "checkBoxHighlightSettings"; + this.checkBoxHighlightSettings.Size = new System.Drawing.Size(106, 17); + this.checkBoxHighlightSettings.TabIndex = 0; + this.checkBoxHighlightSettings.Tag = "1"; + this.checkBoxHighlightSettings.Text = "Highlight settings"; + this.checkBoxHighlightSettings.UseVisualStyleBackColor = true; + // + // buttonOk + // + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(325, 187); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 4; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.OnOkButtonClick); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(325, 154); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // ImportSettingsDialog + // + this.AcceptButton = this.buttonOk; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(412, 224); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.groupBoxImportOptions); + this.Controls.Add(this.labelSettingsFileToImport); + this.Controls.Add(this.textBoxFileName); + this.Controls.Add(this.buttonFile); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ImportSettingsDialog"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Import Settings"; + this.Load += new System.EventHandler(this.OnImportSettingsDialogLoad); + this.groupBoxImportOptions.ResumeLayout(false); + this.groupBoxImportOptions.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonFile; + private System.Windows.Forms.TextBox textBoxFileName; + private System.Windows.Forms.Label labelSettingsFileToImport; + private System.Windows.Forms.Button buttonOk; + private System.Windows.Forms.Button buttonCancel; + public System.Windows.Forms.CheckBox checkBoxExternalTools; + public System.Windows.Forms.CheckBox checkBoxColumnizerFileMasks; + public System.Windows.Forms.CheckBox checkBoxHighlightFileMasks; + public System.Windows.Forms.CheckBox checkBoxHighlightSettings; + public System.Windows.Forms.CheckBox checkBoxOther; + public System.Windows.Forms.CheckBox checkBoxKeepExistingSettings; + public System.Windows.Forms.GroupBox groupBoxImportOptions; + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/ImportSettingsDialog.cs b/src/Logexpert.UI/Dialogs/ImportSettingsDialog.cs similarity index 78% rename from src/LogExpert/Dialogs/ImportSettingsDialog.cs rename to src/Logexpert.UI/Dialogs/ImportSettingsDialog.cs index 6b3c34b0..fa679014 100644 --- a/src/LogExpert/Dialogs/ImportSettingsDialog.cs +++ b/src/Logexpert.UI/Dialogs/ImportSettingsDialog.cs @@ -1,75 +1,76 @@ -using LogExpert.Core.Config; - -using System; -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public partial class ImportSettingsDialog : Form - { - #region Fields - - #endregion - - #region cTor - - public ImportSettingsDialog() - { - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - } - - #endregion - - #region Properties - - public string FileName { get; private set; } - - public ExportImportFlags ImportFlags { get; private set; } - - #endregion - - #region Events handler - - private void OnImportSettingsDialogLoad(object sender, EventArgs e) - { - } - - private void OnFileButtonClick(object sender, EventArgs e) - { - OpenFileDialog dlg = new(); - dlg.Title = "Load Settings from file"; - dlg.DefaultExt = "json"; - dlg.AddExtension = false; - dlg.Filter = "Settings (*.json)|*.json|All files (*.*)|*.*"; - - if (dlg.ShowDialog() == DialogResult.OK) - { - textBoxFileName.Text = dlg.FileName; - } - } - - private void OnOkButtonClick(object sender, EventArgs e) - { - ImportFlags = ExportImportFlags.None; - FileName = textBoxFileName.Text; - - foreach (Control ctl in groupBoxImportOptions.Controls) - { - if (ctl.Tag != null) - { - if (((CheckBox)ctl).Checked) - { - ImportFlags |= (ExportImportFlags)long.Parse(ctl.Tag as string ?? string.Empty); - } - } - } - } - - #endregion - } +using LogExpert.Core.Config; + +using System.Runtime.Versioning; + +namespace LogExpert.UI.Dialogs +{ + [SupportedOSPlatform("windows")] + public partial class ImportSettingsDialog : Form + { + #region Fields + + #endregion + + #region cTor + + public ImportSettingsDialog() + { + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + } + + #endregion + + #region Properties + + public string FileName { get; private set; } + + public ExportImportFlags ImportFlags { get; private set; } + + #endregion + + #region Events handler + + private void OnImportSettingsDialogLoad(object sender, EventArgs e) + { + } + + private void OnFileButtonClick(object sender, EventArgs e) + { + OpenFileDialog dlg = new() + { + Title = "Load Settings from file", + DefaultExt = "json", + AddExtension = false, + Filter = "Settings (*.json)|*.json|All files (*.*)|*.*" + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + textBoxFileName.Text = dlg.FileName; + } + } + + private void OnOkButtonClick(object sender, EventArgs e) + { + ImportFlags = ExportImportFlags.None; + FileName = textBoxFileName.Text; + + foreach (Control ctl in groupBoxImportOptions.Controls) + { + if (ctl.Tag != null) + { + if (((CheckBox)ctl).Checked) + { + ImportFlags |= (ExportImportFlags)long.Parse(ctl.Tag as string ?? string.Empty); + } + } + } + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/ImportSettingsDialog.resx b/src/Logexpert.UI/Dialogs/ImportSettingsDialog.resx similarity index 98% rename from src/LogExpert/Dialogs/ImportSettingsDialog.resx rename to src/Logexpert.UI/Dialogs/ImportSettingsDialog.resx index 2de0ae4d..a43dafee 100644 --- a/src/LogExpert/Dialogs/ImportSettingsDialog.resx +++ b/src/Logexpert.UI/Dialogs/ImportSettingsDialog.resx @@ -1,131 +1,131 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA - AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// - AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// - //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA - AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAIABAAD//wAA - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// + //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA + AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAIABAAD//wAA + + \ No newline at end of file diff --git a/src/LogExpert/Dialogs/KeywordActionDlg.Designer.cs b/src/Logexpert.UI/Dialogs/KeywordActionDlg.Designer.cs similarity index 97% rename from src/LogExpert/Dialogs/KeywordActionDlg.Designer.cs rename to src/Logexpert.UI/Dialogs/KeywordActionDlg.Designer.cs index 6788e495..3a776b37 100644 --- a/src/LogExpert/Dialogs/KeywordActionDlg.Designer.cs +++ b/src/Logexpert.UI/Dialogs/KeywordActionDlg.Designer.cs @@ -1,139 +1,139 @@ -namespace LogExpert.Dialogs -{ - partial class KeywordActionDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(KeywordActionDlg)); - this.actionComboBox = new System.Windows.Forms.ComboBox(); - this.label1 = new System.Windows.Forms.Label(); - this.parameterTextBox = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.buttonOk = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.commentTextBox = new System.Windows.Forms.TextBox(); - this.SuspendLayout(); - // - // actionComboBox - // - this.actionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.actionComboBox.FormattingEnabled = true; - this.actionComboBox.Location = new System.Drawing.Point(12, 36); - this.actionComboBox.Name = "actionComboBox"; - this.actionComboBox.Size = new System.Drawing.Size(329, 28); - this.actionComboBox.TabIndex = 0; - this.actionComboBox.SelectedIndexChanged += new System.EventHandler(this.OnActionComboBoxSelectedIndexChanged); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 20); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(166, 20); - this.label1.TabIndex = 1; - this.label1.Text = "Keyword action plugin:"; - // - // parameterTextBox - // - this.parameterTextBox.Location = new System.Drawing.Point(12, 188); - this.parameterTextBox.Name = "parameterTextBox"; - this.parameterTextBox.Size = new System.Drawing.Size(331, 26); - this.parameterTextBox.TabIndex = 2; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(12, 172); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(83, 20); - this.label2.TabIndex = 3; - this.label2.Text = "Parameter"; - // - // buttonOk - // - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(166, 223); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 23); - this.buttonOk.TabIndex = 4; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.OnOkButtonClick); - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(264, 223); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // commentTextBox - // - this.commentTextBox.Location = new System.Drawing.Point(15, 64); - this.commentTextBox.Multiline = true; - this.commentTextBox.Name = "commentTextBox"; - this.commentTextBox.ReadOnly = true; - this.commentTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.commentTextBox.Size = new System.Drawing.Size(326, 95); - this.commentTextBox.TabIndex = 6; - // - // KeywordActionDlg - // - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(353, 258); - this.Controls.Add(this.commentTextBox); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.label2); - this.Controls.Add(this.parameterTextBox); - this.Controls.Add(this.label1); - this.Controls.Add(this.actionComboBox); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "KeywordActionDlg"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Keyword Action"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.ComboBox actionComboBox; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox parameterTextBox; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.TextBox commentTextBox; - } +namespace LogExpert.UI.Dialogs +{ + partial class KeywordActionDlg + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(KeywordActionDlg)); + this.actionComboBox = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.parameterTextBox = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.commentTextBox = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // actionComboBox + // + this.actionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.actionComboBox.FormattingEnabled = true; + this.actionComboBox.Location = new System.Drawing.Point(12, 36); + this.actionComboBox.Name = "actionComboBox"; + this.actionComboBox.Size = new System.Drawing.Size(329, 28); + this.actionComboBox.TabIndex = 0; + this.actionComboBox.SelectedIndexChanged += new System.EventHandler(this.OnActionComboBoxSelectedIndexChanged); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 20); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(166, 20); + this.label1.TabIndex = 1; + this.label1.Text = "Keyword action plugin:"; + // + // parameterTextBox + // + this.parameterTextBox.Location = new System.Drawing.Point(12, 188); + this.parameterTextBox.Name = "parameterTextBox"; + this.parameterTextBox.Size = new System.Drawing.Size(331, 26); + this.parameterTextBox.TabIndex = 2; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 172); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(83, 20); + this.label2.TabIndex = 3; + this.label2.Text = "Parameter"; + // + // buttonOk + // + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(166, 223); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 4; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.OnOkButtonClick); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(264, 223); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // commentTextBox + // + this.commentTextBox.Location = new System.Drawing.Point(15, 64); + this.commentTextBox.Multiline = true; + this.commentTextBox.Name = "commentTextBox"; + this.commentTextBox.ReadOnly = true; + this.commentTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.commentTextBox.Size = new System.Drawing.Size(326, 95); + this.commentTextBox.TabIndex = 6; + // + // KeywordActionDlg + // + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(353, 258); + this.Controls.Add(this.commentTextBox); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.label2); + this.Controls.Add(this.parameterTextBox); + this.Controls.Add(this.label1); + this.Controls.Add(this.actionComboBox); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "KeywordActionDlg"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Keyword Action"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ComboBox actionComboBox; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox parameterTextBox; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button buttonOk; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.TextBox commentTextBox; + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/KeywordActionDlg.cs b/src/Logexpert.UI/Dialogs/KeywordActionDlg.cs similarity index 86% rename from src/LogExpert/Dialogs/KeywordActionDlg.cs rename to src/Logexpert.UI/Dialogs/KeywordActionDlg.cs index 0de5c80f..c933850b 100644 --- a/src/LogExpert/Dialogs/KeywordActionDlg.cs +++ b/src/Logexpert.UI/Dialogs/KeywordActionDlg.cs @@ -1,93 +1,83 @@ -using LogExpert.Core.Classes.Highlight; - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public struct ActEntry - { - public string Name { get; set; } - - public IKeywordAction Plugin { get; set; } - } - - - public partial class KeywordActionDlg : Form - { - #region Fields - - private readonly IDictionary _actionDict = new Dictionary(); - - private IList _keywordActionList; - - #endregion - - #region cTor - - public KeywordActionDlg(ActionEntry entry, IList actionList) - { - _keywordActionList = actionList; - ActionEntry = entry; - - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - actionComboBox.Items.Clear(); - - foreach (IKeywordAction action in actionList) - { - actionComboBox.Items.Add(action.GetName()); - _actionDict[action.GetName()] = action; - } - - if (actionComboBox.Items.Count > 0) - { - if (ActionEntry.PluginName != null && _actionDict.ContainsKey(ActionEntry.PluginName)) - { - actionComboBox.SelectedItem = ActionEntry.PluginName; - } - else - { - actionComboBox.SelectedIndex = 0; - } - } - - parameterTextBox.Text = ActionEntry.ActionParam; - } - - #endregion - - #region Properties - - public ActionEntry ActionEntry { get; private set; } - - #endregion - - #region Events handler - - private void OnOkButtonClick(object sender, EventArgs e) - { - ActionEntry = new ActionEntry - { - ActionParam = parameterTextBox.Text - }; - - if (_actionDict.ContainsKey((string)actionComboBox.SelectedItem)) - { - ActionEntry.PluginName = (string)actionComboBox.SelectedItem; - } - } - - private void OnActionComboBoxSelectedIndexChanged(object sender, EventArgs e) - { - commentTextBox.Text = _actionDict[(string)actionComboBox.SelectedItem].GetDescription(); - } - - #endregion - } +using LogExpert.Core.Classes.Highlight; + +using System.Runtime.Versioning; + +namespace LogExpert.UI.Dialogs +{ + [SupportedOSPlatform("windows")] + public partial class KeywordActionDlg : Form + { + #region Fields + + private readonly IDictionary _actionDict = new Dictionary(); + + private IList _keywordActionList; + + #endregion + + #region cTor + + public KeywordActionDlg(ActionEntry entry, IList actionList) + { + _keywordActionList = actionList; + ActionEntry = entry; + + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + actionComboBox.Items.Clear(); + + foreach (IKeywordAction action in actionList) + { + actionComboBox.Items.Add(action.GetName()); + _actionDict[action.GetName()] = action; + } + + if (actionComboBox.Items.Count > 0) + { + if (ActionEntry.PluginName != null && _actionDict.ContainsKey(ActionEntry.PluginName)) + { + actionComboBox.SelectedItem = ActionEntry.PluginName; + } + else + { + actionComboBox.SelectedIndex = 0; + } + } + + parameterTextBox.Text = ActionEntry.ActionParam; + } + + #endregion + + #region Properties + + public ActionEntry ActionEntry { get; private set; } + + #endregion + + #region Events handler + + private void OnOkButtonClick(object sender, EventArgs e) + { + ActionEntry = new ActionEntry + { + ActionParam = parameterTextBox.Text + }; + + if (_actionDict.ContainsKey((string)actionComboBox.SelectedItem)) + { + ActionEntry.PluginName = (string)actionComboBox.SelectedItem; + } + } + + private void OnActionComboBoxSelectedIndexChanged(object sender, EventArgs e) + { + commentTextBox.Text = _actionDict[(string)actionComboBox.SelectedItem].GetDescription(); + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/KeywordActionDlg.resx b/src/Logexpert.UI/Dialogs/KeywordActionDlg.resx similarity index 98% rename from src/LogExpert/Dialogs/KeywordActionDlg.resx rename to src/Logexpert.UI/Dialogs/KeywordActionDlg.resx index 2de0ae4d..a43dafee 100644 --- a/src/LogExpert/Dialogs/KeywordActionDlg.resx +++ b/src/Logexpert.UI/Dialogs/KeywordActionDlg.resx @@ -1,131 +1,131 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA - AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// - AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// - //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA - AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAIABAAD//wAA - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// + //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA + AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAIABAAD//wAA + + \ No newline at end of file diff --git a/src/LogExpert/Dialogs/MultiFileMaskDialog.Designer.cs b/src/Logexpert.UI/Dialogs/MultiFileMaskDialog.Designer.cs similarity index 97% rename from src/LogExpert/Dialogs/MultiFileMaskDialog.Designer.cs rename to src/Logexpert.UI/Dialogs/MultiFileMaskDialog.Designer.cs index c6f7f554..1caf30cc 100644 --- a/src/LogExpert/Dialogs/MultiFileMaskDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/MultiFileMaskDialog.Designer.cs @@ -1,192 +1,192 @@ -namespace LogExpert.Dialogs -{ - partial class MultiFileMaskDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MultiFileMaskDialog)); - this.labelMultiSettingsFor = new System.Windows.Forms.Label(); - this.labelFileName = new System.Windows.Forms.Label(); - this.labelFileNamePattern = new System.Windows.Forms.Label(); - this.upDownMaxDays = new System.Windows.Forms.NumericUpDown(); - this.fileNamePatternTextBox = new System.Windows.Forms.TextBox(); - this.labelMaxDays = new System.Windows.Forms.Label(); - this.Settings = new System.Windows.Forms.GroupBox(); - this.syntaxHelpLabel = new System.Windows.Forms.Label(); - this.buttonOk = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.upDownMaxDays)).BeginInit(); - this.Settings.SuspendLayout(); - this.SuspendLayout(); - // - // labelMultiSettingsFor - // - this.labelMultiSettingsFor.AutoSize = true; - this.labelMultiSettingsFor.Location = new System.Drawing.Point(12, 13); - this.labelMultiSettingsFor.Name = "labelMultiSettingsFor"; - this.labelMultiSettingsFor.Size = new System.Drawing.Size(154, 20); - this.labelMultiSettingsFor.TabIndex = 0; - this.labelMultiSettingsFor.Text = "MultiFile settings for:"; - // - // labelFileName - // - this.labelFileName.AutoSize = true; - this.labelFileName.Location = new System.Drawing.Point(172, 13); - this.labelFileName.Name = "labelFileName"; - this.labelFileName.Size = new System.Drawing.Size(91, 20); - this.labelFileName.TabIndex = 1; - this.labelFileName.Text = ""; - // - // labelFileNamePattern - // - this.labelFileNamePattern.AutoSize = true; - this.labelFileNamePattern.Location = new System.Drawing.Point(6, 28); - this.labelFileNamePattern.Name = "labelFileNamePattern"; - this.labelFileNamePattern.Size = new System.Drawing.Size(137, 20); - this.labelFileNamePattern.TabIndex = 2; - this.labelFileNamePattern.Text = "File name pattern:"; - // - // upDownMaxDays - // - this.upDownMaxDays.Location = new System.Drawing.Point(91, 55); - this.upDownMaxDays.Maximum = new decimal(new int[] { - 40, - 0, - 0, - 0}); - this.upDownMaxDays.Name = "upDownMaxDays"; - this.upDownMaxDays.Size = new System.Drawing.Size(49, 26); - this.upDownMaxDays.TabIndex = 3; - this.upDownMaxDays.Value = new decimal(new int[] { - 1, - 0, - 0, - 0}); - // - // fileNamePatternTextBox - // - this.fileNamePatternTextBox.Location = new System.Drawing.Point(149, 25); - this.fileNamePatternTextBox.Name = "fileNamePatternTextBox"; - this.fileNamePatternTextBox.Size = new System.Drawing.Size(247, 26); - this.fileNamePatternTextBox.TabIndex = 4; - // - // labelMaxDays - // - this.labelMaxDays.AutoSize = true; - this.labelMaxDays.Location = new System.Drawing.Point(6, 57); - this.labelMaxDays.Name = "labelMaxDays"; - this.labelMaxDays.Size = new System.Drawing.Size(79, 20); - this.labelMaxDays.TabIndex = 5; - this.labelMaxDays.Text = "Max days:"; - // - // Settings - // - this.Settings.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.Settings.Controls.Add(this.labelFileNamePattern); - this.Settings.Controls.Add(this.labelMaxDays); - this.Settings.Controls.Add(this.upDownMaxDays); - this.Settings.Controls.Add(this.fileNamePatternTextBox); - this.Settings.Location = new System.Drawing.Point(15, 39); - this.Settings.Name = "Settings"; - this.Settings.Size = new System.Drawing.Size(402, 98); - this.Settings.TabIndex = 6; - this.Settings.TabStop = false; - // - // syntaxHelpLabel - // - this.syntaxHelpLabel.Location = new System.Drawing.Point(15, 140); - this.syntaxHelpLabel.Name = "syntaxHelpLabel"; - this.syntaxHelpLabel.Size = new System.Drawing.Size(402, 194); - this.syntaxHelpLabel.TabIndex = 7; - this.syntaxHelpLabel.Text = "Syntax Help Label"; - // - // buttonOk - // - this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(261, 347); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 23); - this.buttonOk.TabIndex = 8; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.OnButtonOKClick); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(342, 347); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 9; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // MultiFileMaskDialog - // - this.AcceptButton = this.buttonOk; - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(434, 386); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.syntaxHelpLabel); - this.Controls.Add(this.Settings); - this.Controls.Add(this.labelFileName); - this.Controls.Add(this.labelMultiSettingsFor); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(329, 420); - this.Name = "MultiFileMaskDialog"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "MultiFile settings"; - this.TopMost = true; - this.Load += new System.EventHandler(this.OnMultiFileMaskDialogLoad); - ((System.ComponentModel.ISupportInitialize)(this.upDownMaxDays)).EndInit(); - this.Settings.ResumeLayout(false); - this.Settings.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label labelMultiSettingsFor; - private System.Windows.Forms.Label labelFileName; - private System.Windows.Forms.Label labelFileNamePattern; - private System.Windows.Forms.NumericUpDown upDownMaxDays; - private System.Windows.Forms.TextBox fileNamePatternTextBox; - private System.Windows.Forms.Label labelMaxDays; - private System.Windows.Forms.GroupBox Settings; - private System.Windows.Forms.Label syntaxHelpLabel; - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.Button buttonCancel; - } +namespace LogExpert.UI.Dialogs +{ + partial class MultiFileMaskDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MultiFileMaskDialog)); + this.labelMultiSettingsFor = new System.Windows.Forms.Label(); + this.labelFileName = new System.Windows.Forms.Label(); + this.labelFileNamePattern = new System.Windows.Forms.Label(); + this.upDownMaxDays = new System.Windows.Forms.NumericUpDown(); + this.fileNamePatternTextBox = new System.Windows.Forms.TextBox(); + this.labelMaxDays = new System.Windows.Forms.Label(); + this.Settings = new System.Windows.Forms.GroupBox(); + this.syntaxHelpLabel = new System.Windows.Forms.Label(); + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.upDownMaxDays)).BeginInit(); + this.Settings.SuspendLayout(); + this.SuspendLayout(); + // + // labelMultiSettingsFor + // + this.labelMultiSettingsFor.AutoSize = true; + this.labelMultiSettingsFor.Location = new System.Drawing.Point(12, 13); + this.labelMultiSettingsFor.Name = "labelMultiSettingsFor"; + this.labelMultiSettingsFor.Size = new System.Drawing.Size(154, 20); + this.labelMultiSettingsFor.TabIndex = 0; + this.labelMultiSettingsFor.Text = "MultiFile settings for:"; + // + // labelFileName + // + this.labelFileName.AutoSize = true; + this.labelFileName.Location = new System.Drawing.Point(172, 13); + this.labelFileName.Name = "labelFileName"; + this.labelFileName.Size = new System.Drawing.Size(91, 20); + this.labelFileName.TabIndex = 1; + this.labelFileName.Text = ""; + // + // labelFileNamePattern + // + this.labelFileNamePattern.AutoSize = true; + this.labelFileNamePattern.Location = new System.Drawing.Point(6, 28); + this.labelFileNamePattern.Name = "labelFileNamePattern"; + this.labelFileNamePattern.Size = new System.Drawing.Size(137, 20); + this.labelFileNamePattern.TabIndex = 2; + this.labelFileNamePattern.Text = "File name pattern:"; + // + // upDownMaxDays + // + this.upDownMaxDays.Location = new System.Drawing.Point(91, 55); + this.upDownMaxDays.Maximum = new decimal(new int[] { + 40, + 0, + 0, + 0}); + this.upDownMaxDays.Name = "upDownMaxDays"; + this.upDownMaxDays.Size = new System.Drawing.Size(49, 26); + this.upDownMaxDays.TabIndex = 3; + this.upDownMaxDays.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + // + // fileNamePatternTextBox + // + this.fileNamePatternTextBox.Location = new System.Drawing.Point(149, 25); + this.fileNamePatternTextBox.Name = "fileNamePatternTextBox"; + this.fileNamePatternTextBox.Size = new System.Drawing.Size(247, 26); + this.fileNamePatternTextBox.TabIndex = 4; + // + // labelMaxDays + // + this.labelMaxDays.AutoSize = true; + this.labelMaxDays.Location = new System.Drawing.Point(6, 57); + this.labelMaxDays.Name = "labelMaxDays"; + this.labelMaxDays.Size = new System.Drawing.Size(79, 20); + this.labelMaxDays.TabIndex = 5; + this.labelMaxDays.Text = "Max days:"; + // + // Settings + // + this.Settings.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.Settings.Controls.Add(this.labelFileNamePattern); + this.Settings.Controls.Add(this.labelMaxDays); + this.Settings.Controls.Add(this.upDownMaxDays); + this.Settings.Controls.Add(this.fileNamePatternTextBox); + this.Settings.Location = new System.Drawing.Point(15, 39); + this.Settings.Name = "Settings"; + this.Settings.Size = new System.Drawing.Size(402, 98); + this.Settings.TabIndex = 6; + this.Settings.TabStop = false; + // + // syntaxHelpLabel + // + this.syntaxHelpLabel.Location = new System.Drawing.Point(15, 140); + this.syntaxHelpLabel.Name = "syntaxHelpLabel"; + this.syntaxHelpLabel.Size = new System.Drawing.Size(402, 194); + this.syntaxHelpLabel.TabIndex = 7; + this.syntaxHelpLabel.Text = "Syntax Help Label"; + // + // buttonOk + // + this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(261, 347); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 8; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.OnButtonOKClick); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(342, 347); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 9; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // MultiFileMaskDialog + // + this.AcceptButton = this.buttonOk; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(434, 386); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.syntaxHelpLabel); + this.Controls.Add(this.Settings); + this.Controls.Add(this.labelFileName); + this.Controls.Add(this.labelMultiSettingsFor); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(329, 420); + this.Name = "MultiFileMaskDialog"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "MultiFile settings"; + this.TopMost = true; + this.Load += new System.EventHandler(this.OnMultiFileMaskDialogLoad); + ((System.ComponentModel.ISupportInitialize)(this.upDownMaxDays)).EndInit(); + this.Settings.ResumeLayout(false); + this.Settings.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label labelMultiSettingsFor; + private System.Windows.Forms.Label labelFileName; + private System.Windows.Forms.Label labelFileNamePattern; + private System.Windows.Forms.NumericUpDown upDownMaxDays; + private System.Windows.Forms.TextBox fileNamePatternTextBox; + private System.Windows.Forms.Label labelMaxDays; + private System.Windows.Forms.GroupBox Settings; + private System.Windows.Forms.Label syntaxHelpLabel; + private System.Windows.Forms.Button buttonOk; + private System.Windows.Forms.Button buttonCancel; + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/MultiFileMaskDialog.cs b/src/Logexpert.UI/Dialogs/MultiFileMaskDialog.cs similarity index 85% rename from src/LogExpert/Dialogs/MultiFileMaskDialog.cs rename to src/Logexpert.UI/Dialogs/MultiFileMaskDialog.cs index c8c7ff8b..d82a5592 100644 --- a/src/LogExpert/Dialogs/MultiFileMaskDialog.cs +++ b/src/Logexpert.UI/Dialogs/MultiFileMaskDialog.cs @@ -1,67 +1,63 @@ -using System; -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public partial class MultiFileMaskDialog : Form - { - #region Fields - - #endregion - - #region cTor - - public MultiFileMaskDialog(Form parent, string fileName) - { - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - syntaxHelpLabel.Text = "" + - "Pattern syntax:\n\n" + - "* = any characters (wildcard)\n" + - "$D() = Date pattern\n" + - "$I = File index number\n" + - "$J = File index number, hidden when zero\n" + - "$J() = Like $J, but adding when non-zero\n" + - "\n" + - ":\n" + - "DD = day\n" + - "MM = month\n" + - "YY[YY] = year\n" + - "all other chars will be used as given"; - labelFileName.Text = fileName; - } - - #endregion - - #region Properties - - public string FileNamePattern { get; set; } - - public int MaxDays { get; set; } - - #endregion - - #region Events handler - - private void OnButtonOKClick(object sender, EventArgs e) - { - FileNamePattern = fileNamePatternTextBox.Text; - MaxDays = (int) upDownMaxDays.Value; - } - - private void OnMultiFileMaskDialogLoad(object sender, EventArgs e) - { - fileNamePatternTextBox.Text = FileNamePattern; - upDownMaxDays.Value = MaxDays; - } - - #endregion - } +using System.Runtime.Versioning; + +namespace LogExpert.UI.Dialogs +{ + [SupportedOSPlatform("windows")] + public partial class MultiFileMaskDialog : Form + { + #region Fields + + #endregion + + #region cTor + + public MultiFileMaskDialog(Form parent, string fileName) + { + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + syntaxHelpLabel.Text = "" + + "Pattern syntax:\n\n" + + "* = any characters (wildcard)\n" + + "$D() = Date pattern\n" + + "$I = File index number\n" + + "$J = File index number, hidden when zero\n" + + "$J() = Like $J, but adding when non-zero\n" + + "\n" + + ":\n" + + "DD = day\n" + + "MM = month\n" + + "YY[YY] = year\n" + + "all other chars will be used as given"; + labelFileName.Text = fileName; + } + + #endregion + + #region Properties + + public string FileNamePattern { get; set; } + + public int MaxDays { get; set; } + + #endregion + + #region Events handler + + private void OnButtonOKClick(object sender, EventArgs e) + { + FileNamePattern = fileNamePatternTextBox.Text; + MaxDays = (int)upDownMaxDays.Value; + } + + private void OnMultiFileMaskDialogLoad(object sender, EventArgs e) + { + fileNamePatternTextBox.Text = FileNamePattern; + upDownMaxDays.Value = MaxDays; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/MultiFileMaskDialog.resx b/src/Logexpert.UI/Dialogs/MultiFileMaskDialog.resx similarity index 98% rename from src/LogExpert/Dialogs/MultiFileMaskDialog.resx rename to src/Logexpert.UI/Dialogs/MultiFileMaskDialog.resx index 2de0ae4d..a43dafee 100644 --- a/src/LogExpert/Dialogs/MultiFileMaskDialog.resx +++ b/src/Logexpert.UI/Dialogs/MultiFileMaskDialog.resx @@ -1,131 +1,131 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA - AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// - AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// - //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA - AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAIABAAD//wAA - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// + //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA + AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAIABAAD//wAA + + \ No newline at end of file diff --git a/src/LogExpert/Dialogs/MultiLoadRequestDialog.Designer.cs b/src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.Designer.cs similarity index 96% rename from src/LogExpert/Dialogs/MultiLoadRequestDialog.Designer.cs rename to src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.Designer.cs index e6dadd63..2bd65f3f 100644 --- a/src/LogExpert/Dialogs/MultiLoadRequestDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.Designer.cs @@ -1,89 +1,89 @@ -namespace LogExpert.Dialogs -{ - partial class MultiLoadRequestDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonSingleMode = new System.Windows.Forms.Button(); - this.buttonMultiMode = new System.Windows.Forms.Button(); - this.labelChooseLoadingMode = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // buttonSingleMode - // - this.buttonSingleMode.DialogResult = System.Windows.Forms.DialogResult.Yes; - this.buttonSingleMode.Location = new System.Drawing.Point(12, 59); - this.buttonSingleMode.Name = "buttonSingleMode"; - this.buttonSingleMode.Size = new System.Drawing.Size(75, 23); - this.buttonSingleMode.TabIndex = 1; - this.buttonSingleMode.Text = "Single files"; - this.buttonSingleMode.UseVisualStyleBackColor = true; - // - // buttonMultiMode - // - this.buttonMultiMode.DialogResult = System.Windows.Forms.DialogResult.No; - this.buttonMultiMode.Location = new System.Drawing.Point(114, 59); - this.buttonMultiMode.Name = "buttonMultiMode"; - this.buttonMultiMode.Size = new System.Drawing.Size(75, 23); - this.buttonMultiMode.TabIndex = 2; - this.buttonMultiMode.Text = "Multi file"; - this.buttonMultiMode.UseVisualStyleBackColor = true; - // - // labelChooseLoadingMode - // - this.labelChooseLoadingMode.AutoSize = true; - this.labelChooseLoadingMode.Location = new System.Drawing.Point(48, 18); - this.labelChooseLoadingMode.Name = "labelChooseLoadingMode"; - this.labelChooseLoadingMode.Size = new System.Drawing.Size(167, 20); - this.labelChooseLoadingMode.TabIndex = 4; - this.labelChooseLoadingMode.Text = "Choose loading mode:"; - // - // MultiLoadRequestDialog - // - this.ClientSize = new System.Drawing.Size(237, 103); - this.Controls.Add(this.labelChooseLoadingMode); - this.Controls.Add(this.buttonMultiMode); - this.Controls.Add(this.buttonSingleMode); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "MultiLoadRequestDialog"; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Loading multiple files"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonSingleMode; - private System.Windows.Forms.Button buttonMultiMode; - private System.Windows.Forms.Label labelChooseLoadingMode; - } +namespace LogExpert.UI.Dialogs +{ + partial class MultiLoadRequestDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonSingleMode = new System.Windows.Forms.Button(); + this.buttonMultiMode = new System.Windows.Forms.Button(); + this.labelChooseLoadingMode = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonSingleMode + // + this.buttonSingleMode.DialogResult = System.Windows.Forms.DialogResult.Yes; + this.buttonSingleMode.Location = new System.Drawing.Point(12, 59); + this.buttonSingleMode.Name = "buttonSingleMode"; + this.buttonSingleMode.Size = new System.Drawing.Size(75, 23); + this.buttonSingleMode.TabIndex = 1; + this.buttonSingleMode.Text = "Single files"; + this.buttonSingleMode.UseVisualStyleBackColor = true; + // + // buttonMultiMode + // + this.buttonMultiMode.DialogResult = System.Windows.Forms.DialogResult.No; + this.buttonMultiMode.Location = new System.Drawing.Point(114, 59); + this.buttonMultiMode.Name = "buttonMultiMode"; + this.buttonMultiMode.Size = new System.Drawing.Size(75, 23); + this.buttonMultiMode.TabIndex = 2; + this.buttonMultiMode.Text = "Multi file"; + this.buttonMultiMode.UseVisualStyleBackColor = true; + // + // labelChooseLoadingMode + // + this.labelChooseLoadingMode.AutoSize = true; + this.labelChooseLoadingMode.Location = new System.Drawing.Point(48, 18); + this.labelChooseLoadingMode.Name = "labelChooseLoadingMode"; + this.labelChooseLoadingMode.Size = new System.Drawing.Size(167, 20); + this.labelChooseLoadingMode.TabIndex = 4; + this.labelChooseLoadingMode.Text = "Choose loading mode:"; + // + // MultiLoadRequestDialog + // + this.ClientSize = new System.Drawing.Size(237, 103); + this.Controls.Add(this.labelChooseLoadingMode); + this.Controls.Add(this.buttonMultiMode); + this.Controls.Add(this.buttonSingleMode); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "MultiLoadRequestDialog"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Loading multiple files"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonSingleMode; + private System.Windows.Forms.Button buttonMultiMode; + private System.Windows.Forms.Label labelChooseLoadingMode; + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/MultiLoadRequestDialog.cs b/src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.cs similarity index 74% rename from src/LogExpert/Dialogs/MultiLoadRequestDialog.cs rename to src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.cs index 1e9c94fb..31fe8d93 100644 --- a/src/LogExpert/Dialogs/MultiLoadRequestDialog.cs +++ b/src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.cs @@ -1,20 +1,20 @@ -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public partial class MultiLoadRequestDialog : Form - { - #region cTor - - public MultiLoadRequestDialog() - { - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - } - - #endregion - } +using System.Runtime.Versioning; + +namespace LogExpert.UI.Dialogs +{ + [SupportedOSPlatform("windows")] + public partial class MultiLoadRequestDialog : Form + { + #region cTor + + public MultiLoadRequestDialog() + { + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/MultiLoadRequestDialog.resx b/src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.resx similarity index 97% rename from src/LogExpert/Dialogs/MultiLoadRequestDialog.resx rename to src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.resx index c7e0d4bd..d58980a3 100644 --- a/src/LogExpert/Dialogs/MultiLoadRequestDialog.resx +++ b/src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/OpenUriDialog.Designer.cs b/src/Logexpert.UI/Dialogs/OpenUriDialog.Designer.cs index 33a3ddb5..0f54eb31 100644 --- a/src/Logexpert.UI/Dialogs/OpenUriDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/OpenUriDialog.Designer.cs @@ -1,122 +1,121 @@ -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +partial class OpenUriDialog { - partial class OpenUriDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} - #region Windows Form Designer generated code +#region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OpenUriDialog)); - this.cmbUri = new System.Windows.Forms.ComboBox(); - this.label1 = new System.Windows.Forms.Label(); - this.okButton = new System.Windows.Forms.Button(); - this.cancelButton = new System.Windows.Forms.Button(); - this.label2 = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // uriComboBox - // - this.cmbUri.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.cmbUri.FormattingEnabled = true; - this.cmbUri.Location = new System.Drawing.Point(12, 37); - this.cmbUri.Name = "cmbUri"; - this.cmbUri.Size = new System.Drawing.Size(449, 21); - this.cmbUri.TabIndex = 0; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 21); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(32, 13); - this.label1.TabIndex = 1; - this.label1.Text = "URL:"; - // - // okButton - // - this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.okButton.Location = new System.Drawing.Point(305, 127); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(75, 23); - this.okButton.TabIndex = 2; - this.okButton.Text = "OK"; - this.okButton.UseVisualStyleBackColor = true; - this.okButton.Click += new System.EventHandler(this.OnBtnOkClick); - // - // cancelButton - // - this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(386, 127); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(75, 23); - this.cancelButton.TabIndex = 3; - this.cancelButton.Text = "Cancel"; - this.cancelButton.UseVisualStyleBackColor = true; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(12, 84); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(410, 13); - this.label2.TabIndex = 4; - this.label2.Text = "Enter a URL which is supported by an installed file system plugin (e.g. file:// o" + - "r sftp://)"; - // - // OpenUriDialog - // - this.AcceptButton = this.okButton; - this.CancelButton = this.cancelButton; - this.ClientSize = new System.Drawing.Size(475, 162); - this.Controls.Add(this.label2); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.okButton); - this.Controls.Add(this.label1); - this.Controls.Add(this.cmbUri); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MaximumSize = new System.Drawing.Size(800, 260); - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(491, 200); - this.Name = "OpenUriDialog"; - this.Text = "Open URL"; - this.Load += new System.EventHandler(this.OnOpenUriDialogLoad); - this.ResumeLayout(false); - this.PerformLayout(); +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OpenUriDialog)); + this.cmbUri = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.okButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // uriComboBox + // + this.cmbUri.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.cmbUri.FormattingEnabled = true; + this.cmbUri.Location = new System.Drawing.Point(12, 37); + this.cmbUri.Name = "cmbUri"; + this.cmbUri.Size = new System.Drawing.Size(449, 21); + this.cmbUri.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 21); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(32, 13); + this.label1.TabIndex = 1; + this.label1.Text = "URL:"; + // + // okButton + // + this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.Location = new System.Drawing.Point(305, 127); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(75, 23); + this.okButton.TabIndex = 2; + this.okButton.Text = "OK"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.OnBtnOkClick); + // + // cancelButton + // + this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(386, 127); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(75, 23); + this.cancelButton.TabIndex = 3; + this.cancelButton.Text = "Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 84); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(410, 13); + this.label2.TabIndex = 4; + this.label2.Text = "Enter a URL which is supported by an installed file system plugin (e.g. file:// o" + + "r sftp://)"; + // + // OpenUriDialog + // + this.AcceptButton = this.okButton; + this.CancelButton = this.cancelButton; + this.ClientSize = new System.Drawing.Size(475, 162); + this.Controls.Add(this.label2); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.okButton); + this.Controls.Add(this.label1); + this.Controls.Add(this.cmbUri); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MaximumSize = new System.Drawing.Size(800, 260); + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(491, 200); + this.Name = "OpenUriDialog"; + this.Text = "Open URL"; + this.Load += new System.EventHandler(this.OnOpenUriDialogLoad); + this.ResumeLayout(false); + this.PerformLayout(); - } +} - #endregion +#endregion - private System.Windows.Forms.ComboBox cmbUri; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Button okButton; - private System.Windows.Forms.Button cancelButton; - private System.Windows.Forms.Label label2; - } +private System.Windows.Forms.ComboBox cmbUri; +private System.Windows.Forms.Label label1; +private System.Windows.Forms.Button okButton; +private System.Windows.Forms.Button cancelButton; +private System.Windows.Forms.Label label2; } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/OpenUriDialog.cs b/src/Logexpert.UI/Dialogs/OpenUriDialog.cs index 707b27cd..fc079883 100644 --- a/src/Logexpert.UI/Dialogs/OpenUriDialog.cs +++ b/src/Logexpert.UI/Dialogs/OpenUriDialog.cs @@ -1,72 +1,71 @@ using System.Runtime.Versioning; -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +[SupportedOSPlatform("windows")] +public partial class OpenUriDialog : Form { - [SupportedOSPlatform("windows")] - public partial class OpenUriDialog : Form - { - #region Fields + #region Fields - #endregion + #endregion - #region cTor + #region cTor - public OpenUriDialog() - { - SuspendLayout(); + public OpenUriDialog() + { + SuspendLayout(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - InitializeComponent(); + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + InitializeComponent(); - ResumeLayout(); - } + ResumeLayout(); + } - #endregion + #endregion - #region Properties + #region Properties - public string Uri => cmbUri.Text; + public string Uri => cmbUri.Text; - public IList UriHistory { get; set; } + public IList UriHistory { get; set; } - #endregion + #endregion - #region Events handler + #region Events handler - private void OnOpenUriDialogLoad(object sender, EventArgs e) + private void OnOpenUriDialogLoad(object sender, EventArgs e) + { + if (UriHistory != null) { - if (UriHistory != null) + cmbUri.Items.Clear(); + foreach (string uri in UriHistory) { - cmbUri.Items.Clear(); - foreach (string uri in UriHistory) - { - cmbUri.Items.Add(uri); - } + cmbUri.Items.Add(uri); } } + } - private void OnBtnOkClick(object sender, EventArgs e) - { - UriHistory = []; - - foreach (object item in cmbUri.Items) - { - UriHistory.Add(item.ToString()); - } + private void OnBtnOkClick(object sender, EventArgs e) + { + UriHistory = []; - if (UriHistory.Contains(cmbUri.Text)) - { - UriHistory.Remove(cmbUri.Text); - } - UriHistory.Insert(0, cmbUri.Text); + foreach (object item in cmbUri.Items) + { + UriHistory.Add(item.ToString()); + } - while (UriHistory.Count > 20) - { - UriHistory.RemoveAt(UriHistory.Count - 1); - } + if (UriHistory.Contains(cmbUri.Text)) + { + UriHistory.Remove(cmbUri.Text); } + UriHistory.Insert(0, cmbUri.Text); - #endregion + while (UriHistory.Count > 20) + { + UriHistory.RemoveAt(UriHistory.Count - 1); + } } + + #endregion } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/ProjectLoadDlg.Designer.cs b/src/Logexpert.UI/Dialogs/ProjectLoadDlg.Designer.cs new file mode 100644 index 00000000..3e5677c3 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/ProjectLoadDlg.Designer.cs @@ -0,0 +1,119 @@ +namespace LogExpert.Dialogs; + +partial class ProjectLoadDlg +{ +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; + +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} + +#region Windows Form Designer generated code + +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ProjectLoadDlg)); + this.labelInformational = new System.Windows.Forms.Label(); + this.buttonCloseTabs = new System.Windows.Forms.Button(); + this.buttonNewWindow = new System.Windows.Forms.Button(); + this.buttonIgnore = new System.Windows.Forms.Button(); + this.labelChooseHowToProceed = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // labelInformational + // + this.labelInformational.Location = new System.Drawing.Point(12, 9); + this.labelInformational.Name = "labelInformational"; + this.labelInformational.Size = new System.Drawing.Size(178, 41); + this.labelInformational.TabIndex = 0; + this.labelInformational.Text = "Restoring layout requires an empty workbench. \r\n\r\n"; + // + // buttonCloseTabs + // + this.buttonCloseTabs.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonCloseTabs.Location = new System.Drawing.Point(43, 94); + this.buttonCloseTabs.Name = "buttonCloseTabs"; + this.buttonCloseTabs.Size = new System.Drawing.Size(113, 23); + this.buttonCloseTabs.TabIndex = 1; + this.buttonCloseTabs.Text = "Close existing tabs"; + this.buttonCloseTabs.UseVisualStyleBackColor = true; + this.buttonCloseTabs.Click += new System.EventHandler(this.OnButtonCloseTabsClick); + // + // buttonNewWindow + // + this.buttonNewWindow.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonNewWindow.Location = new System.Drawing.Point(43, 124); + this.buttonNewWindow.Name = "buttonNewWindow"; + this.buttonNewWindow.Size = new System.Drawing.Size(113, 23); + this.buttonNewWindow.TabIndex = 2; + this.buttonNewWindow.Text = "Open new window"; + this.buttonNewWindow.UseVisualStyleBackColor = true; + this.buttonNewWindow.Click += new System.EventHandler(this.OnButtonNewWindowClick); + // + // buttonIgnore + // + this.buttonIgnore.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonIgnore.Location = new System.Drawing.Point(43, 154); + this.buttonIgnore.Name = "buttonIgnore"; + this.buttonIgnore.Size = new System.Drawing.Size(113, 23); + this.buttonIgnore.TabIndex = 3; + this.buttonIgnore.Text = "Ignore layout data"; + this.buttonIgnore.UseVisualStyleBackColor = true; + this.buttonIgnore.Click += new System.EventHandler(this.OnButtonIgnoreClick); + // + // labelChooseHowToProceed + // + this.labelChooseHowToProceed.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.labelChooseHowToProceed.AutoSize = true; + this.labelChooseHowToProceed.Location = new System.Drawing.Point(21, 66); + this.labelChooseHowToProceed.Name = "labelChooseHowToProceed"; + this.labelChooseHowToProceed.Size = new System.Drawing.Size(230, 20); + this.labelChooseHowToProceed.TabIndex = 4; + this.labelChooseHowToProceed.Text = "Please choose how to proceed:"; + // + // ProjectLoadDlg + // + this.ClientSize = new System.Drawing.Size(258, 196); + this.Controls.Add(this.labelChooseHowToProceed); + this.Controls.Add(this.buttonIgnore); + this.Controls.Add(this.buttonNewWindow); + this.Controls.Add(this.buttonCloseTabs); + this.Controls.Add(this.labelInformational); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ProjectLoadDlg"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Loading Session"; + this.ResumeLayout(false); + this.PerformLayout(); + +} + +#endregion + +private System.Windows.Forms.Label labelInformational; +private System.Windows.Forms.Button buttonCloseTabs; +private System.Windows.Forms.Button buttonNewWindow; +private System.Windows.Forms.Button buttonIgnore; +private System.Windows.Forms.Label labelChooseHowToProceed; +} \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/ProjectLoadDlg.cs b/src/Logexpert.UI/Dialogs/ProjectLoadDlg.cs new file mode 100644 index 00000000..95ca661d --- /dev/null +++ b/src/Logexpert.UI/Dialogs/ProjectLoadDlg.cs @@ -0,0 +1,53 @@ +using LogExpert.Core.Enums; + +using System.Runtime.Versioning; + +namespace LogExpert.Dialogs; + +[SupportedOSPlatform("windows")] +public partial class ProjectLoadDlg : Form +{ + #region Fields + + #endregion + + #region cTor + + public ProjectLoadDlg() + { + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + } + + #endregion + + #region Properties + + public ProjectLoadDlgResult ProjectLoadResult { get; set; } = ProjectLoadDlgResult.Cancel; + + #endregion + + #region Events handler + + private void OnButtonCloseTabsClick(object sender, EventArgs e) + { + ProjectLoadResult = ProjectLoadDlgResult.CloseTabs; + Close(); + } + + private void OnButtonNewWindowClick(object sender, EventArgs e) + { + ProjectLoadResult = ProjectLoadDlgResult.NewWindow; + Close(); + } + + private void OnButtonIgnoreClick(object sender, EventArgs e) + { + ProjectLoadResult = ProjectLoadDlgResult.IgnoreLayout; + Close(); + } + + #endregion +} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/ProjectLoadDlg.resx b/src/Logexpert.UI/Dialogs/ProjectLoadDlg.resx similarity index 98% rename from src/LogExpert/Dialogs/ProjectLoadDlg.resx rename to src/Logexpert.UI/Dialogs/ProjectLoadDlg.resx index 2de0ae4d..a43dafee 100644 --- a/src/LogExpert/Dialogs/ProjectLoadDlg.resx +++ b/src/Logexpert.UI/Dialogs/ProjectLoadDlg.resx @@ -1,131 +1,131 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA - AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// - AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// - //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA - AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAIABAAD//wAA - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// + //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA + AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAIABAAD//wAA + + \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/RegexHelperDialog.Designer.cs b/src/Logexpert.UI/Dialogs/RegexHelperDialog.Designer.cs index 99655fc4..03e622b5 100644 --- a/src/Logexpert.UI/Dialogs/RegexHelperDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/RegexHelperDialog.Designer.cs @@ -1,195 +1,194 @@ -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +partial class RegexHelperDialog { - partial class RegexHelperDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} - #region Windows Form Designer generated code +#region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOk = new System.Windows.Forms.Button(); - this.labelRegex = new System.Windows.Forms.Label(); - this.labelTestText = new System.Windows.Forms.Label(); - this.labelMatches = new System.Windows.Forms.Label(); - this.textBoxMatches = new System.Windows.Forms.TextBox(); - this.checkBoxCaseSensitive = new System.Windows.Forms.CheckBox(); - this.comboBoxRegex = new System.Windows.Forms.ComboBox(); - this.comboBoxTestText = new System.Windows.Forms.ComboBox(); - this.helpProvider1 = new System.Windows.Forms.HelpProvider(); - this.buttonHelp = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(365, 371); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 0; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // buttonOk - // - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(284, 371); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 23); - this.buttonOk.TabIndex = 1; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.OnButtonOkClick); - // - // labelRegex - // - this.labelRegex.AutoSize = true; - this.labelRegex.Location = new System.Drawing.Point(14, 14); - this.labelRegex.Name = "labelRegex"; - this.labelRegex.Size = new System.Drawing.Size(151, 20); - this.labelRegex.TabIndex = 3; - this.labelRegex.Text = "Regular Expression:"; - // - // labelTestText - // - this.labelTestText.AutoSize = true; - this.labelTestText.Location = new System.Drawing.Point(14, 98); - this.labelTestText.Name = "labelTestText"; - this.labelTestText.Size = new System.Drawing.Size(74, 20); - this.labelTestText.TabIndex = 5; - this.labelTestText.Text = "Test text:"; - // - // labelMatches - // - this.labelMatches.AutoSize = true; - this.labelMatches.Location = new System.Drawing.Point(14, 152); - this.labelMatches.Name = "labelMatches"; - this.labelMatches.Size = new System.Drawing.Size(74, 20); - this.labelMatches.TabIndex = 6; - this.labelMatches.Text = "Matches:"; - // - // textBoxMatches - // - this.textBoxMatches.Location = new System.Drawing.Point(12, 175); - this.textBoxMatches.Multiline = true; - this.textBoxMatches.Name = "textBoxMatches"; - this.textBoxMatches.ReadOnly = true; - this.textBoxMatches.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBoxMatches.Size = new System.Drawing.Size(428, 190); - this.textBoxMatches.TabIndex = 7; - // - // checkBoxCaseSensitive - // - this.checkBoxCaseSensitive.AutoSize = true; - this.checkBoxCaseSensitive.Location = new System.Drawing.Point(12, 71); - this.checkBoxCaseSensitive.Name = "checkBoxCaseSensitive"; - this.checkBoxCaseSensitive.Size = new System.Drawing.Size(137, 24); - this.checkBoxCaseSensitive.TabIndex = 8; - this.checkBoxCaseSensitive.Text = "Case sensitive"; - this.checkBoxCaseSensitive.UseVisualStyleBackColor = true; - this.checkBoxCaseSensitive.CheckedChanged += new System.EventHandler(this.OnCaseSensitiveCheckBoxCheckedChanged); - // - // comboBoxRegex - // - this.comboBoxRegex.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; - this.comboBoxRegex.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - this.comboBoxRegex.FormattingEnabled = true; - this.comboBoxRegex.Location = new System.Drawing.Point(12, 37); - this.comboBoxRegex.Name = "comboBoxRegex"; - this.comboBoxRegex.Size = new System.Drawing.Size(428, 28); - this.comboBoxRegex.TabIndex = 10; - this.comboBoxRegex.TextChanged += new System.EventHandler(this.OnComboBoxRegexTextChanged); - // - // comboBoxTestText - // - this.comboBoxTestText.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; - this.comboBoxTestText.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - this.comboBoxTestText.FormattingEnabled = true; - this.comboBoxTestText.Location = new System.Drawing.Point(12, 121); - this.comboBoxTestText.Name = "comboBoxTestText"; - this.comboBoxTestText.Size = new System.Drawing.Size(428, 28); - this.comboBoxTestText.TabIndex = 11; - this.comboBoxTestText.TextChanged += new System.EventHandler(this.OnComboBoxTestTextTextChanged); - // - // helpProvider1 - // - this.helpProvider1.HelpNamespace = "LogExpert.chm"; - // - // buttonHelp - // - this.helpProvider1.SetHelpKeyword(this.buttonHelp, "RegEx.htm"); - this.helpProvider1.SetHelpNavigator(this.buttonHelp, System.Windows.Forms.HelpNavigator.Topic); - this.buttonHelp.Location = new System.Drawing.Point(13, 371); - this.buttonHelp.Name = "buttonHelp"; - this.helpProvider1.SetShowHelp(this.buttonHelp, true); - this.buttonHelp.Size = new System.Drawing.Size(75, 23); - this.buttonHelp.TabIndex = 12; - this.buttonHelp.Text = "Help"; - this.buttonHelp.UseVisualStyleBackColor = true; - this.buttonHelp.Click += new System.EventHandler(this.OnButtonHelpClick); - // - // RegexHelperDialog - // - this.AcceptButton = this.buttonOk; - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(452, 403); - this.Controls.Add(this.buttonHelp); - this.Controls.Add(this.comboBoxTestText); - this.Controls.Add(this.comboBoxRegex); - this.Controls.Add(this.checkBoxCaseSensitive); - this.Controls.Add(this.textBoxMatches); - this.Controls.Add(this.labelMatches); - this.Controls.Add(this.labelTestText); - this.Controls.Add(this.labelRegex); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.buttonCancel); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.helpProvider1.SetHelpKeyword(this, "RegEx.htm"); - this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "RegexHelperDialog"; - this.helpProvider1.SetShowHelp(this, true); - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Regex-Helper"; - this.ResumeLayout(false); - this.PerformLayout(); +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOk = new System.Windows.Forms.Button(); + this.labelRegex = new System.Windows.Forms.Label(); + this.labelTestText = new System.Windows.Forms.Label(); + this.labelMatches = new System.Windows.Forms.Label(); + this.textBoxMatches = new System.Windows.Forms.TextBox(); + this.checkBoxCaseSensitive = new System.Windows.Forms.CheckBox(); + this.comboBoxRegex = new System.Windows.Forms.ComboBox(); + this.comboBoxTestText = new System.Windows.Forms.ComboBox(); + this.helpProvider1 = new System.Windows.Forms.HelpProvider(); + this.buttonHelp = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(365, 371); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 0; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // buttonOk + // + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(284, 371); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 1; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.OnButtonOkClick); + // + // labelRegex + // + this.labelRegex.AutoSize = true; + this.labelRegex.Location = new System.Drawing.Point(14, 14); + this.labelRegex.Name = "labelRegex"; + this.labelRegex.Size = new System.Drawing.Size(151, 20); + this.labelRegex.TabIndex = 3; + this.labelRegex.Text = "Regular Expression:"; + // + // labelTestText + // + this.labelTestText.AutoSize = true; + this.labelTestText.Location = new System.Drawing.Point(14, 98); + this.labelTestText.Name = "labelTestText"; + this.labelTestText.Size = new System.Drawing.Size(74, 20); + this.labelTestText.TabIndex = 5; + this.labelTestText.Text = "Test text:"; + // + // labelMatches + // + this.labelMatches.AutoSize = true; + this.labelMatches.Location = new System.Drawing.Point(14, 152); + this.labelMatches.Name = "labelMatches"; + this.labelMatches.Size = new System.Drawing.Size(74, 20); + this.labelMatches.TabIndex = 6; + this.labelMatches.Text = "Matches:"; + // + // textBoxMatches + // + this.textBoxMatches.Location = new System.Drawing.Point(12, 175); + this.textBoxMatches.Multiline = true; + this.textBoxMatches.Name = "textBoxMatches"; + this.textBoxMatches.ReadOnly = true; + this.textBoxMatches.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.textBoxMatches.Size = new System.Drawing.Size(428, 190); + this.textBoxMatches.TabIndex = 7; + // + // checkBoxCaseSensitive + // + this.checkBoxCaseSensitive.AutoSize = true; + this.checkBoxCaseSensitive.Location = new System.Drawing.Point(12, 71); + this.checkBoxCaseSensitive.Name = "checkBoxCaseSensitive"; + this.checkBoxCaseSensitive.Size = new System.Drawing.Size(137, 24); + this.checkBoxCaseSensitive.TabIndex = 8; + this.checkBoxCaseSensitive.Text = "Case sensitive"; + this.checkBoxCaseSensitive.UseVisualStyleBackColor = true; + this.checkBoxCaseSensitive.CheckedChanged += new System.EventHandler(this.OnCaseSensitiveCheckBoxCheckedChanged); + // + // comboBoxRegex + // + this.comboBoxRegex.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; + this.comboBoxRegex.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.comboBoxRegex.FormattingEnabled = true; + this.comboBoxRegex.Location = new System.Drawing.Point(12, 37); + this.comboBoxRegex.Name = "comboBoxRegex"; + this.comboBoxRegex.Size = new System.Drawing.Size(428, 28); + this.comboBoxRegex.TabIndex = 10; + this.comboBoxRegex.TextChanged += new System.EventHandler(this.OnComboBoxRegexTextChanged); + // + // comboBoxTestText + // + this.comboBoxTestText.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; + this.comboBoxTestText.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.comboBoxTestText.FormattingEnabled = true; + this.comboBoxTestText.Location = new System.Drawing.Point(12, 121); + this.comboBoxTestText.Name = "comboBoxTestText"; + this.comboBoxTestText.Size = new System.Drawing.Size(428, 28); + this.comboBoxTestText.TabIndex = 11; + this.comboBoxTestText.TextChanged += new System.EventHandler(this.OnComboBoxTestTextTextChanged); + // + // helpProvider1 + // + this.helpProvider1.HelpNamespace = "LogExpert.chm"; + // + // buttonHelp + // + this.helpProvider1.SetHelpKeyword(this.buttonHelp, "RegEx.htm"); + this.helpProvider1.SetHelpNavigator(this.buttonHelp, System.Windows.Forms.HelpNavigator.Topic); + this.buttonHelp.Location = new System.Drawing.Point(13, 371); + this.buttonHelp.Name = "buttonHelp"; + this.helpProvider1.SetShowHelp(this.buttonHelp, true); + this.buttonHelp.Size = new System.Drawing.Size(75, 23); + this.buttonHelp.TabIndex = 12; + this.buttonHelp.Text = "Help"; + this.buttonHelp.UseVisualStyleBackColor = true; + this.buttonHelp.Click += new System.EventHandler(this.OnButtonHelpClick); + // + // RegexHelperDialog + // + this.AcceptButton = this.buttonOk; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(452, 403); + this.Controls.Add(this.buttonHelp); + this.Controls.Add(this.comboBoxTestText); + this.Controls.Add(this.comboBoxRegex); + this.Controls.Add(this.checkBoxCaseSensitive); + this.Controls.Add(this.textBoxMatches); + this.Controls.Add(this.labelMatches); + this.Controls.Add(this.labelTestText); + this.Controls.Add(this.labelRegex); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.buttonCancel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.helpProvider1.SetHelpKeyword(this, "RegEx.htm"); + this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "RegexHelperDialog"; + this.helpProvider1.SetShowHelp(this, true); + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Regex-Helper"; + this.ResumeLayout(false); + this.PerformLayout(); - } +} - #endregion +#endregion - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.Label labelRegex; - private System.Windows.Forms.Label labelTestText; - private System.Windows.Forms.Label labelMatches; - private System.Windows.Forms.TextBox textBoxMatches; - private System.Windows.Forms.CheckBox checkBoxCaseSensitive; - private System.Windows.Forms.ComboBox comboBoxRegex; - private System.Windows.Forms.ComboBox comboBoxTestText; - private System.Windows.Forms.HelpProvider helpProvider1; - private System.Windows.Forms.Button buttonHelp; - } +private System.Windows.Forms.Button buttonCancel; +private System.Windows.Forms.Button buttonOk; +private System.Windows.Forms.Label labelRegex; +private System.Windows.Forms.Label labelTestText; +private System.Windows.Forms.Label labelMatches; +private System.Windows.Forms.TextBox textBoxMatches; +private System.Windows.Forms.CheckBox checkBoxCaseSensitive; +private System.Windows.Forms.ComboBox comboBoxRegex; +private System.Windows.Forms.ComboBox comboBoxTestText; +private System.Windows.Forms.HelpProvider helpProvider1; +private System.Windows.Forms.Button buttonHelp; } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/RegexHelperDialog.cs b/src/Logexpert.UI/Dialogs/RegexHelperDialog.cs index aa539068..36c2749a 100644 --- a/src/Logexpert.UI/Dialogs/RegexHelperDialog.cs +++ b/src/Logexpert.UI/Dialogs/RegexHelperDialog.cs @@ -1,147 +1,146 @@ using System.Runtime.Versioning; using System.Text.RegularExpressions; -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +[SupportedOSPlatform("windows")] +public partial class RegexHelperDialog : Form { - [SupportedOSPlatform("windows")] - public partial class RegexHelperDialog : Form - { - #region Fields + #region Fields - private static readonly int MAX_HISTORY = 30; - private bool _caseSensitive; - private List _expressionHistoryList = []; - private List _testtextHistoryList = []; + private static readonly int MAX_HISTORY = 30; + private bool _caseSensitive; + private List _expressionHistoryList = []; + private List _testtextHistoryList = []; - #endregion + #endregion - #region cTor + #region cTor - public RegexHelperDialog() - { - InitializeComponent(); + public RegexHelperDialog() + { + InitializeComponent(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; - Load += OnRegexHelperDialogLoad; - } + Load += OnRegexHelperDialogLoad; + } - #endregion + #endregion - #region Properties + #region Properties - public bool CaseSensitive + public bool CaseSensitive + { + get => _caseSensitive; + set { - get => _caseSensitive; - set - { - _caseSensitive = value; - checkBoxCaseSensitive.Checked = value; - } + _caseSensitive = value; + checkBoxCaseSensitive.Checked = value; } + } - public string Pattern - { - get => comboBoxRegex.Text; - set => comboBoxRegex.Text = value; - } + public string Pattern + { + get => comboBoxRegex.Text; + set => comboBoxRegex.Text = value; + } - public List ExpressionHistoryList - { - get => _expressionHistoryList; - set => _expressionHistoryList = value; - } + public List ExpressionHistoryList + { + get => _expressionHistoryList; + set => _expressionHistoryList = value; + } - public List TesttextHistoryList - { - get => _testtextHistoryList; - set => _testtextHistoryList = value; - } + public List TesttextHistoryList + { + get => _testtextHistoryList; + set => _testtextHistoryList = value; + } - #endregion + #endregion - #region Private Methods + #region Private Methods - private void UpdateMatches() + private void UpdateMatches() + { + textBoxMatches.Text = ""; + try { - textBoxMatches.Text = ""; - try - { - Regex rex = new(comboBoxRegex.Text, _caseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); - MatchCollection matches = rex.Matches(comboBoxTestText.Text); + Regex rex = new(comboBoxRegex.Text, _caseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); + MatchCollection matches = rex.Matches(comboBoxTestText.Text); - foreach (Match match in matches) - { - textBoxMatches.Text += $"{match.Value}\r\n"; - } - } - catch (ArgumentException) + foreach (Match match in matches) { - textBoxMatches.Text = "No valid regex pattern"; + textBoxMatches.Text += $"{match.Value}\r\n"; } } - - private void LoadHistory() + catch (ArgumentException) { - comboBoxRegex.Items.Clear(); - comboBoxRegex.DataSource = _expressionHistoryList; - - comboBoxTestText.Items.Clear(); - comboBoxTestText.DataSource = _testtextHistoryList; + textBoxMatches.Text = "No valid regex pattern"; } + } - #endregion + private void LoadHistory() + { + comboBoxRegex.Items.Clear(); + comboBoxRegex.DataSource = _expressionHistoryList; - #region Events handler + comboBoxTestText.Items.Clear(); + comboBoxTestText.DataSource = _testtextHistoryList; + } - private void OnRegexHelperDialogLoad(object? sender, EventArgs e) - { - LoadHistory(); - } + #endregion - private void OnCaseSensitiveCheckBoxCheckedChanged(object sender, EventArgs e) - { - _caseSensitive = checkBoxCaseSensitive.Checked; - UpdateMatches(); - } + #region Events handler - private void OnButtonOkClick(object sender, EventArgs e) - { - string text = comboBoxRegex.Text; - comboBoxRegex.Items.Remove(text); - comboBoxRegex.Items.Insert(0, text); + private void OnRegexHelperDialogLoad(object? sender, EventArgs e) + { + LoadHistory(); + } - text = comboBoxTestText.Text; - comboBoxTestText.Items.Remove(text); - comboBoxTestText.Items.Insert(0, text); + private void OnCaseSensitiveCheckBoxCheckedChanged(object sender, EventArgs e) + { + _caseSensitive = checkBoxCaseSensitive.Checked; + UpdateMatches(); + } - if (comboBoxRegex.Items.Count > MAX_HISTORY) - { - comboBoxRegex.Items.Remove(comboBoxRegex.Items.Count - 1); - } + private void OnButtonOkClick(object sender, EventArgs e) + { + string text = comboBoxRegex.Text; + comboBoxRegex.Items.Remove(text); + comboBoxRegex.Items.Insert(0, text); - if (comboBoxTestText.Items.Count > MAX_HISTORY) - { - comboBoxTestText.Items.Remove(comboBoxTestText.Items.Count - 1); - } - } + text = comboBoxTestText.Text; + comboBoxTestText.Items.Remove(text); + comboBoxTestText.Items.Insert(0, text); - private void OnComboBoxRegexTextChanged(object sender, EventArgs e) + if (comboBoxRegex.Items.Count > MAX_HISTORY) { - UpdateMatches(); + comboBoxRegex.Items.Remove(comboBoxRegex.Items.Count - 1); } - private void OnComboBoxTestTextTextChanged(object sender, EventArgs e) + if (comboBoxTestText.Items.Count > MAX_HISTORY) { - UpdateMatches(); + comboBoxTestText.Items.Remove(comboBoxTestText.Items.Count - 1); } + } - private void OnButtonHelpClick(object sender, EventArgs e) - { - Help.ShowHelp(this, "LogExpert.chm", HelpNavigator.Topic, "RegEx.htm"); - } + private void OnComboBoxRegexTextChanged(object sender, EventArgs e) + { + UpdateMatches(); + } + + private void OnComboBoxTestTextTextChanged(object sender, EventArgs e) + { + UpdateMatches(); + } - #endregion + private void OnButtonHelpClick(object sender, EventArgs e) + { + Help.ShowHelp(this, "LogExpert.chm", HelpNavigator.Topic, "RegEx.htm"); } + + #endregion } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/SearchDialog.Designer.cs b/src/Logexpert.UI/Dialogs/SearchDialog.Designer.cs index 148a6db0..8a0e20dc 100644 --- a/src/Logexpert.UI/Dialogs/SearchDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/SearchDialog.Designer.cs @@ -1,254 +1,253 @@ -namespace LogExpert.Dialogs +namespace LogExpert.Dialogs; + +partial class SearchDialog { - partial class SearchDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} - #region Windows Form Designer generated code +#region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonOk = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.labelSearchFor = new System.Windows.Forms.Label(); - this.checkBoxCaseSensitive = new System.Windows.Forms.CheckBox(); - this.checkBoxRegex = new System.Windows.Forms.CheckBox(); - this.buttonRegexHelper = new System.Windows.Forms.Button(); - this.radioButtonFromTop = new System.Windows.Forms.RadioButton(); - this.radioButtonFromSelected = new System.Windows.Forms.RadioButton(); - this.groupBoxSearchStart = new System.Windows.Forms.GroupBox(); - this.groupBoxOptions = new System.Windows.Forms.GroupBox(); - this.groupBoxDirection = new System.Windows.Forms.GroupBox(); - this.radioButtonBackward = new System.Windows.Forms.RadioButton(); - this.radioButtonForward = new System.Windows.Forms.RadioButton(); - this.comboBoxSearchFor = new System.Windows.Forms.ComboBox(); - this.helpProvider1 = new System.Windows.Forms.HelpProvider(); - this.groupBoxSearchStart.SuspendLayout(); - this.groupBoxOptions.SuspendLayout(); - this.groupBoxDirection.SuspendLayout(); - this.SuspendLayout(); - // - // buttonOk - // - this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(317, 215); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 23); - this.buttonOk.TabIndex = 5; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.OnButtonOkClick); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(398, 215); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 6; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.OnButtonCancelClick); - // - // labelSearchFor - // - this.labelSearchFor.AutoSize = true; - this.labelSearchFor.Location = new System.Drawing.Point(10, 9); - this.labelSearchFor.Name = "labelSearchFor"; - this.labelSearchFor.Size = new System.Drawing.Size(87, 20); - this.labelSearchFor.TabIndex = 0; - this.labelSearchFor.Text = "&Search for:"; - // - // checkBoxCaseSensitive - // - this.checkBoxCaseSensitive.AutoSize = true; - this.checkBoxCaseSensitive.Location = new System.Drawing.Point(6, 19); - this.checkBoxCaseSensitive.Name = "checkBoxCaseSensitive"; - this.checkBoxCaseSensitive.Size = new System.Drawing.Size(137, 24); - this.checkBoxCaseSensitive.TabIndex = 4; - this.checkBoxCaseSensitive.Text = "&Case sensitive"; - this.checkBoxCaseSensitive.UseVisualStyleBackColor = true; - // - // checkBoxRegex - // - this.checkBoxRegex.AutoSize = true; - this.checkBoxRegex.Location = new System.Drawing.Point(6, 43); - this.checkBoxRegex.Name = "checkBoxRegex"; - this.checkBoxRegex.Size = new System.Drawing.Size(171, 24); - this.checkBoxRegex.TabIndex = 5; - this.checkBoxRegex.Text = "&Regular expression"; - this.checkBoxRegex.UseVisualStyleBackColor = true; - // - // buttonRegexHelper - // - this.buttonRegexHelper.Location = new System.Drawing.Point(6, 72); - this.buttonRegexHelper.Name = "buttonRegexHelper"; - this.buttonRegexHelper.Size = new System.Drawing.Size(84, 26); - this.buttonRegexHelper.TabIndex = 3; - this.buttonRegexHelper.Text = "Regex-&Helper"; - this.buttonRegexHelper.UseVisualStyleBackColor = true; - this.buttonRegexHelper.Click += new System.EventHandler(this.OnButtonRegexClick); - // - // radioButtonFromTop - // - this.radioButtonFromTop.AutoSize = true; - this.radioButtonFromTop.Location = new System.Drawing.Point(6, 19); - this.radioButtonFromTop.Name = "radioButtonFromTop"; - this.radioButtonFromTop.Size = new System.Drawing.Size(98, 24); - this.radioButtonFromTop.TabIndex = 7; - this.radioButtonFromTop.TabStop = true; - this.radioButtonFromTop.Text = "From top"; - this.radioButtonFromTop.UseVisualStyleBackColor = true; - // - // radioButtonFromSelected - // - this.radioButtonFromSelected.AutoSize = true; - this.radioButtonFromSelected.Location = new System.Drawing.Point(6, 42); - this.radioButtonFromSelected.Name = "radioButtonFromSelected"; - this.radioButtonFromSelected.Size = new System.Drawing.Size(163, 24); - this.radioButtonFromSelected.TabIndex = 8; - this.radioButtonFromSelected.TabStop = true; - this.radioButtonFromSelected.Text = "From selected line"; - this.radioButtonFromSelected.UseVisualStyleBackColor = true; - // - // groupBoxSearchStart - // - this.groupBoxSearchStart.Controls.Add(this.radioButtonFromTop); - this.groupBoxSearchStart.Controls.Add(this.radioButtonFromSelected); - this.groupBoxSearchStart.Location = new System.Drawing.Point(12, 74); - this.groupBoxSearchStart.Name = "groupBoxSearchStart"; - this.groupBoxSearchStart.Size = new System.Drawing.Size(179, 79); - this.groupBoxSearchStart.TabIndex = 1; - this.groupBoxSearchStart.TabStop = false; - this.groupBoxSearchStart.Text = "Search start"; - // - // groupBoxOptions - // - this.groupBoxOptions.Controls.Add(this.checkBoxCaseSensitive); - this.groupBoxOptions.Controls.Add(this.checkBoxRegex); - this.groupBoxOptions.Controls.Add(this.buttonRegexHelper); - this.groupBoxOptions.Location = new System.Drawing.Point(198, 74); - this.groupBoxOptions.Name = "groupBoxOptions"; - this.groupBoxOptions.Size = new System.Drawing.Size(275, 104); - this.groupBoxOptions.TabIndex = 2; - this.groupBoxOptions.TabStop = false; - this.groupBoxOptions.Text = "Options"; - // - // groupBoxDirection - // - this.groupBoxDirection.Controls.Add(this.radioButtonBackward); - this.groupBoxDirection.Controls.Add(this.radioButtonForward); - this.groupBoxDirection.Location = new System.Drawing.Point(13, 159); - this.groupBoxDirection.Name = "groupBoxDirection"; - this.groupBoxDirection.Size = new System.Drawing.Size(122, 79); - this.groupBoxDirection.TabIndex = 4; - this.groupBoxDirection.TabStop = false; - this.groupBoxDirection.Text = "Direction"; - // - // radioButtonBackward - // - this.radioButtonBackward.AutoSize = true; - this.radioButtonBackward.Location = new System.Drawing.Point(7, 44); - this.radioButtonBackward.Name = "radioButtonBackward"; - this.radioButtonBackward.Size = new System.Drawing.Size(104, 24); - this.radioButtonBackward.TabIndex = 1; - this.radioButtonBackward.TabStop = true; - this.radioButtonBackward.Text = "Backward"; - this.radioButtonBackward.UseVisualStyleBackColor = true; - // - // radioButtonForward - // - this.radioButtonForward.AutoSize = true; - this.radioButtonForward.Location = new System.Drawing.Point(7, 20); - this.radioButtonForward.Name = "radioButtonForward"; - this.radioButtonForward.Size = new System.Drawing.Size(92, 24); - this.radioButtonForward.TabIndex = 0; - this.radioButtonForward.TabStop = true; - this.radioButtonForward.Text = "Forward"; - this.radioButtonForward.UseVisualStyleBackColor = true; - // - // comboBoxSearchFor - // - this.comboBoxSearchFor.FormattingEnabled = true; - this.comboBoxSearchFor.Location = new System.Drawing.Point(13, 34); - this.comboBoxSearchFor.Name = "comboBoxSearchFor"; - this.comboBoxSearchFor.Size = new System.Drawing.Size(460, 28); - this.comboBoxSearchFor.TabIndex = 0; - // - // helpProvider1 - // - this.helpProvider1.HelpNamespace = "LogExpert.chm"; - // - // SearchDialog - // - this.AcceptButton = this.buttonOk; - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(488, 250); - this.Controls.Add(this.comboBoxSearchFor); - this.Controls.Add(this.groupBoxDirection); - this.Controls.Add(this.groupBoxOptions); - this.Controls.Add(this.groupBoxSearchStart); - this.Controls.Add(this.labelSearchFor); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOk); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.helpProvider1.SetHelpKeyword(this, "Search and Navigation.htm"); - this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "SearchDialog"; - this.helpProvider1.SetShowHelp(this, true); - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Search"; - this.groupBoxSearchStart.ResumeLayout(false); - this.groupBoxSearchStart.PerformLayout(); - this.groupBoxOptions.ResumeLayout(false); - this.groupBoxOptions.PerformLayout(); - this.groupBoxDirection.ResumeLayout(false); - this.groupBoxDirection.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.labelSearchFor = new System.Windows.Forms.Label(); + this.checkBoxCaseSensitive = new System.Windows.Forms.CheckBox(); + this.checkBoxRegex = new System.Windows.Forms.CheckBox(); + this.buttonRegexHelper = new System.Windows.Forms.Button(); + this.radioButtonFromTop = new System.Windows.Forms.RadioButton(); + this.radioButtonFromSelected = new System.Windows.Forms.RadioButton(); + this.groupBoxSearchStart = new System.Windows.Forms.GroupBox(); + this.groupBoxOptions = new System.Windows.Forms.GroupBox(); + this.groupBoxDirection = new System.Windows.Forms.GroupBox(); + this.radioButtonBackward = new System.Windows.Forms.RadioButton(); + this.radioButtonForward = new System.Windows.Forms.RadioButton(); + this.comboBoxSearchFor = new System.Windows.Forms.ComboBox(); + this.helpProvider1 = new System.Windows.Forms.HelpProvider(); + this.groupBoxSearchStart.SuspendLayout(); + this.groupBoxOptions.SuspendLayout(); + this.groupBoxDirection.SuspendLayout(); + this.SuspendLayout(); + // + // buttonOk + // + this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(317, 215); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 5; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.OnButtonOkClick); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(398, 215); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 6; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.OnButtonCancelClick); + // + // labelSearchFor + // + this.labelSearchFor.AutoSize = true; + this.labelSearchFor.Location = new System.Drawing.Point(10, 9); + this.labelSearchFor.Name = "labelSearchFor"; + this.labelSearchFor.Size = new System.Drawing.Size(87, 20); + this.labelSearchFor.TabIndex = 0; + this.labelSearchFor.Text = "&Search for:"; + // + // checkBoxCaseSensitive + // + this.checkBoxCaseSensitive.AutoSize = true; + this.checkBoxCaseSensitive.Location = new System.Drawing.Point(6, 19); + this.checkBoxCaseSensitive.Name = "checkBoxCaseSensitive"; + this.checkBoxCaseSensitive.Size = new System.Drawing.Size(137, 24); + this.checkBoxCaseSensitive.TabIndex = 4; + this.checkBoxCaseSensitive.Text = "&Case sensitive"; + this.checkBoxCaseSensitive.UseVisualStyleBackColor = true; + // + // checkBoxRegex + // + this.checkBoxRegex.AutoSize = true; + this.checkBoxRegex.Location = new System.Drawing.Point(6, 43); + this.checkBoxRegex.Name = "checkBoxRegex"; + this.checkBoxRegex.Size = new System.Drawing.Size(171, 24); + this.checkBoxRegex.TabIndex = 5; + this.checkBoxRegex.Text = "&Regular expression"; + this.checkBoxRegex.UseVisualStyleBackColor = true; + // + // buttonRegexHelper + // + this.buttonRegexHelper.Location = new System.Drawing.Point(6, 72); + this.buttonRegexHelper.Name = "buttonRegexHelper"; + this.buttonRegexHelper.Size = new System.Drawing.Size(84, 26); + this.buttonRegexHelper.TabIndex = 3; + this.buttonRegexHelper.Text = "Regex-&Helper"; + this.buttonRegexHelper.UseVisualStyleBackColor = true; + this.buttonRegexHelper.Click += new System.EventHandler(this.OnButtonRegexClick); + // + // radioButtonFromTop + // + this.radioButtonFromTop.AutoSize = true; + this.radioButtonFromTop.Location = new System.Drawing.Point(6, 19); + this.radioButtonFromTop.Name = "radioButtonFromTop"; + this.radioButtonFromTop.Size = new System.Drawing.Size(98, 24); + this.radioButtonFromTop.TabIndex = 7; + this.radioButtonFromTop.TabStop = true; + this.radioButtonFromTop.Text = "From top"; + this.radioButtonFromTop.UseVisualStyleBackColor = true; + // + // radioButtonFromSelected + // + this.radioButtonFromSelected.AutoSize = true; + this.radioButtonFromSelected.Location = new System.Drawing.Point(6, 42); + this.radioButtonFromSelected.Name = "radioButtonFromSelected"; + this.radioButtonFromSelected.Size = new System.Drawing.Size(163, 24); + this.radioButtonFromSelected.TabIndex = 8; + this.radioButtonFromSelected.TabStop = true; + this.radioButtonFromSelected.Text = "From selected line"; + this.radioButtonFromSelected.UseVisualStyleBackColor = true; + // + // groupBoxSearchStart + // + this.groupBoxSearchStart.Controls.Add(this.radioButtonFromTop); + this.groupBoxSearchStart.Controls.Add(this.radioButtonFromSelected); + this.groupBoxSearchStart.Location = new System.Drawing.Point(12, 74); + this.groupBoxSearchStart.Name = "groupBoxSearchStart"; + this.groupBoxSearchStart.Size = new System.Drawing.Size(179, 79); + this.groupBoxSearchStart.TabIndex = 1; + this.groupBoxSearchStart.TabStop = false; + this.groupBoxSearchStart.Text = "Search start"; + // + // groupBoxOptions + // + this.groupBoxOptions.Controls.Add(this.checkBoxCaseSensitive); + this.groupBoxOptions.Controls.Add(this.checkBoxRegex); + this.groupBoxOptions.Controls.Add(this.buttonRegexHelper); + this.groupBoxOptions.Location = new System.Drawing.Point(198, 74); + this.groupBoxOptions.Name = "groupBoxOptions"; + this.groupBoxOptions.Size = new System.Drawing.Size(275, 104); + this.groupBoxOptions.TabIndex = 2; + this.groupBoxOptions.TabStop = false; + this.groupBoxOptions.Text = "Options"; + // + // groupBoxDirection + // + this.groupBoxDirection.Controls.Add(this.radioButtonBackward); + this.groupBoxDirection.Controls.Add(this.radioButtonForward); + this.groupBoxDirection.Location = new System.Drawing.Point(13, 159); + this.groupBoxDirection.Name = "groupBoxDirection"; + this.groupBoxDirection.Size = new System.Drawing.Size(122, 79); + this.groupBoxDirection.TabIndex = 4; + this.groupBoxDirection.TabStop = false; + this.groupBoxDirection.Text = "Direction"; + // + // radioButtonBackward + // + this.radioButtonBackward.AutoSize = true; + this.radioButtonBackward.Location = new System.Drawing.Point(7, 44); + this.radioButtonBackward.Name = "radioButtonBackward"; + this.radioButtonBackward.Size = new System.Drawing.Size(104, 24); + this.radioButtonBackward.TabIndex = 1; + this.radioButtonBackward.TabStop = true; + this.radioButtonBackward.Text = "Backward"; + this.radioButtonBackward.UseVisualStyleBackColor = true; + // + // radioButtonForward + // + this.radioButtonForward.AutoSize = true; + this.radioButtonForward.Location = new System.Drawing.Point(7, 20); + this.radioButtonForward.Name = "radioButtonForward"; + this.radioButtonForward.Size = new System.Drawing.Size(92, 24); + this.radioButtonForward.TabIndex = 0; + this.radioButtonForward.TabStop = true; + this.radioButtonForward.Text = "Forward"; + this.radioButtonForward.UseVisualStyleBackColor = true; + // + // comboBoxSearchFor + // + this.comboBoxSearchFor.FormattingEnabled = true; + this.comboBoxSearchFor.Location = new System.Drawing.Point(13, 34); + this.comboBoxSearchFor.Name = "comboBoxSearchFor"; + this.comboBoxSearchFor.Size = new System.Drawing.Size(460, 28); + this.comboBoxSearchFor.TabIndex = 0; + // + // helpProvider1 + // + this.helpProvider1.HelpNamespace = "LogExpert.chm"; + // + // SearchDialog + // + this.AcceptButton = this.buttonOk; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(488, 250); + this.Controls.Add(this.comboBoxSearchFor); + this.Controls.Add(this.groupBoxDirection); + this.Controls.Add(this.groupBoxOptions); + this.Controls.Add(this.groupBoxSearchStart); + this.Controls.Add(this.labelSearchFor); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.helpProvider1.SetHelpKeyword(this, "Search and Navigation.htm"); + this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "SearchDialog"; + this.helpProvider1.SetShowHelp(this, true); + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Search"; + this.groupBoxSearchStart.ResumeLayout(false); + this.groupBoxSearchStart.PerformLayout(); + this.groupBoxOptions.ResumeLayout(false); + this.groupBoxOptions.PerformLayout(); + this.groupBoxDirection.ResumeLayout(false); + this.groupBoxDirection.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); - } +} - #endregion +#endregion - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Label labelSearchFor; - private System.Windows.Forms.CheckBox checkBoxCaseSensitive; - private System.Windows.Forms.CheckBox checkBoxRegex; - private System.Windows.Forms.Button buttonRegexHelper; - private System.Windows.Forms.RadioButton radioButtonFromTop; - private System.Windows.Forms.RadioButton radioButtonFromSelected; - private System.Windows.Forms.GroupBox groupBoxSearchStart; - private System.Windows.Forms.GroupBox groupBoxOptions; - private System.Windows.Forms.GroupBox groupBoxDirection; - private System.Windows.Forms.RadioButton radioButtonBackward; - private System.Windows.Forms.RadioButton radioButtonForward; - private System.Windows.Forms.ComboBox comboBoxSearchFor; - private System.Windows.Forms.HelpProvider helpProvider1; - } +private System.Windows.Forms.Button buttonOk; +private System.Windows.Forms.Button buttonCancel; +private System.Windows.Forms.Label labelSearchFor; +private System.Windows.Forms.CheckBox checkBoxCaseSensitive; +private System.Windows.Forms.CheckBox checkBoxRegex; +private System.Windows.Forms.Button buttonRegexHelper; +private System.Windows.Forms.RadioButton radioButtonFromTop; +private System.Windows.Forms.RadioButton radioButtonFromSelected; +private System.Windows.Forms.GroupBox groupBoxSearchStart; +private System.Windows.Forms.GroupBox groupBoxOptions; +private System.Windows.Forms.GroupBox groupBoxDirection; +private System.Windows.Forms.RadioButton radioButtonBackward; +private System.Windows.Forms.RadioButton radioButtonForward; +private System.Windows.Forms.ComboBox comboBoxSearchFor; +private System.Windows.Forms.HelpProvider helpProvider1; } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/SearchDialog.cs b/src/Logexpert.UI/Dialogs/SearchDialog.cs index a75cf5f5..418425e9 100644 --- a/src/Logexpert.UI/Dialogs/SearchDialog.cs +++ b/src/Logexpert.UI/Dialogs/SearchDialog.cs @@ -4,135 +4,134 @@ using System.Runtime.Versioning; using System.Text.RegularExpressions; -namespace LogExpert.Dialogs +namespace LogExpert.Dialogs; + +[SupportedOSPlatform("windows")] +public partial class SearchDialog : Form { - [SupportedOSPlatform("windows")] - public partial class SearchDialog : Form - { - #region Fields + #region Fields - private static readonly int MAX_HISTORY = 30; + private static readonly int MAX_HISTORY = 30; - #endregion + #endregion - #region cTor + #region cTor - public SearchDialog() - { - InitializeComponent(); + public SearchDialog() + { + InitializeComponent(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; - Load += OnSearchDialogLoad; - } + Load += OnSearchDialogLoad; + } - #endregion + #endregion - #region Properties + #region Properties - public SearchParams SearchParams { get; set; } = new(); + public SearchParams SearchParams { get; set; } = new(); - #endregion + #endregion - #region Events handler + #region Events handler - private void OnSearchDialogLoad(object? sender, EventArgs e) + private void OnSearchDialogLoad(object? sender, EventArgs e) + { + if (SearchParams != null) { - if (SearchParams != null) + if (SearchParams.isFromTop) { - if (SearchParams.isFromTop) - { - radioButtonFromTop.Checked = true; - } - else - { - radioButtonFromSelected.Checked = true; - } - - if (SearchParams.isForward) - { - radioButtonForward.Checked = true; - } - else - { - radioButtonBackward.Checked = true; - } - - checkBoxRegex.Checked = SearchParams.isRegex; - checkBoxCaseSensitive.Checked = SearchParams.isCaseSensitive; - foreach (string item in SearchParams.historyList) - { - comboBoxSearchFor.Items.Add(item); - } - - if (comboBoxSearchFor.Items.Count > 0) - { - comboBoxSearchFor.SelectedIndex = 0; - } + radioButtonFromTop.Checked = true; } else { radioButtonFromSelected.Checked = true; + } + + if (SearchParams.isForward) + { radioButtonForward.Checked = true; - SearchParams = new SearchParams(); } - } + else + { + radioButtonBackward.Checked = true; + } - private void OnButtonRegexClick(object sender, EventArgs e) - { - RegexHelperDialog dlg = new() + checkBoxRegex.Checked = SearchParams.isRegex; + checkBoxCaseSensitive.Checked = SearchParams.isCaseSensitive; + foreach (string item in SearchParams.historyList) { - Owner = this, - CaseSensitive = checkBoxCaseSensitive.Checked, - Pattern = comboBoxSearchFor.Text - }; + comboBoxSearchFor.Items.Add(item); + } - if (dlg.ShowDialog() == DialogResult.OK) + if (comboBoxSearchFor.Items.Count > 0) { - checkBoxCaseSensitive.Checked = dlg.CaseSensitive; - comboBoxSearchFor.Text = dlg.Pattern; + comboBoxSearchFor.SelectedIndex = 0; } } - - private void OnButtonOkClick(object sender, EventArgs e) + else { - try - { - if (checkBoxRegex.Checked) - { - if (string.IsNullOrWhiteSpace(comboBoxSearchFor.Text)) - { - throw new ArgumentException("Search text is empty"); - } + radioButtonFromSelected.Checked = true; + radioButtonForward.Checked = true; + SearchParams = new SearchParams(); + } + } - Regex.IsMatch("", comboBoxSearchFor.Text); - } + private void OnButtonRegexClick(object sender, EventArgs e) + { + RegexHelperDialog dlg = new() + { + Owner = this, + CaseSensitive = checkBoxCaseSensitive.Checked, + Pattern = comboBoxSearchFor.Text + }; - SearchParams.searchText = comboBoxSearchFor.Text; - SearchParams.isCaseSensitive = checkBoxCaseSensitive.Checked; - SearchParams.isForward = radioButtonForward.Checked; - SearchParams.isFromTop = radioButtonFromTop.Checked; - SearchParams.isRegex = checkBoxRegex.Checked; - SearchParams.historyList.Remove(comboBoxSearchFor.Text); - SearchParams.historyList.Insert(0, comboBoxSearchFor.Text); + if (dlg.ShowDialog() == DialogResult.OK) + { + checkBoxCaseSensitive.Checked = dlg.CaseSensitive; + comboBoxSearchFor.Text = dlg.Pattern; + } + } - if (SearchParams.historyList.Count > MAX_HISTORY) + private void OnButtonOkClick(object sender, EventArgs e) + { + try + { + if (checkBoxRegex.Checked) + { + if (string.IsNullOrWhiteSpace(comboBoxSearchFor.Text)) { - SearchParams.historyList.RemoveAt(SearchParams.historyList.Count - 1); + throw new ArgumentException("Search text is empty"); } + + Regex.IsMatch("", comboBoxSearchFor.Text); } - catch (Exception ex) + + SearchParams.searchText = comboBoxSearchFor.Text; + SearchParams.isCaseSensitive = checkBoxCaseSensitive.Checked; + SearchParams.isForward = radioButtonForward.Checked; + SearchParams.isFromTop = radioButtonFromTop.Checked; + SearchParams.isRegex = checkBoxRegex.Checked; + SearchParams.historyList.Remove(comboBoxSearchFor.Text); + SearchParams.historyList.Insert(0, comboBoxSearchFor.Text); + + if (SearchParams.historyList.Count > MAX_HISTORY) { - MessageBox.Show($"Error during creation of search parameter\r\n{ex.Message}"); + SearchParams.historyList.RemoveAt(SearchParams.historyList.Count - 1); } } - - #endregion - - private void OnButtonCancelClick(object sender, EventArgs e) + catch (Exception ex) { - Close(); + MessageBox.Show($"Error during creation of search parameter\r\n{ex.Message}"); } } + + #endregion + + private void OnButtonCancelClick(object sender, EventArgs e) + { + Close(); + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/SearchProgressDialog.Designer.cs b/src/Logexpert.UI/Dialogs/SearchProgressDialog.Designer.cs similarity index 96% rename from src/LogExpert/Dialogs/SearchProgressDialog.Designer.cs rename to src/Logexpert.UI/Dialogs/SearchProgressDialog.Designer.cs index c0532607..87c05e64 100644 --- a/src/LogExpert/Dialogs/SearchProgressDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/SearchProgressDialog.Designer.cs @@ -1,75 +1,75 @@ -namespace LogExpert.Dialogs -{ - partial class SearchProgressDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.labelSearchProgress = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(159, 40); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(90, 23); - this.buttonCancel.TabIndex = 0; - this.buttonCancel.Text = "Cancel search"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.OnButtonCancelClick); - // - // labelSearchProgress - // - this.labelSearchProgress.AutoSize = true; - this.labelSearchProgress.Location = new System.Drawing.Point(13, 13); - this.labelSearchProgress.Name = "labelSearchProgress"; - this.labelSearchProgress.Size = new System.Drawing.Size(175, 20); - this.labelSearchProgress.TabIndex = 1; - this.labelSearchProgress.Text = "Searching in progress..."; - // - // SearchProgressDialog - // - this.ClientSize = new System.Drawing.Size(261, 80); - this.ControlBox = false; - this.Controls.Add(this.labelSearchProgress); - this.Controls.Add(this.buttonCancel); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Name = "SearchProgressDialog"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Searching..."; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Label labelSearchProgress; - } +namespace LogExpert.UI.Dialogs +{ + partial class SearchProgressDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.labelSearchProgress = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(159, 40); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(90, 23); + this.buttonCancel.TabIndex = 0; + this.buttonCancel.Text = "Cancel search"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.OnButtonCancelClick); + // + // labelSearchProgress + // + this.labelSearchProgress.AutoSize = true; + this.labelSearchProgress.Location = new System.Drawing.Point(13, 13); + this.labelSearchProgress.Name = "labelSearchProgress"; + this.labelSearchProgress.Size = new System.Drawing.Size(175, 20); + this.labelSearchProgress.TabIndex = 1; + this.labelSearchProgress.Text = "Searching in progress..."; + // + // SearchProgressDialog + // + this.ClientSize = new System.Drawing.Size(261, 80); + this.ControlBox = false; + this.Controls.Add(this.labelSearchProgress); + this.Controls.Add(this.buttonCancel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Name = "SearchProgressDialog"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Searching..."; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Label labelSearchProgress; + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/SearchProgressDialog.cs b/src/Logexpert.UI/Dialogs/SearchProgressDialog.cs similarity index 82% rename from src/LogExpert/Dialogs/SearchProgressDialog.cs rename to src/Logexpert.UI/Dialogs/SearchProgressDialog.cs index 8e4ea303..56223ebe 100644 --- a/src/LogExpert/Dialogs/SearchProgressDialog.cs +++ b/src/Logexpert.UI/Dialogs/SearchProgressDialog.cs @@ -1,42 +1,41 @@ -using System; -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public partial class SearchProgressDialog : Form - { - #region Fields - - #endregion - - #region cTor - - public SearchProgressDialog() - { - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - ShouldStop = false; - } - - #endregion - - #region Properties - - public bool ShouldStop { get; private set; } - - #endregion - - #region Events handler - - private void OnButtonCancelClick(object sender, EventArgs e) - { - ShouldStop = true; - } - - #endregion - } +using System.Runtime.Versioning; + +namespace LogExpert.UI.Dialogs +{ + [SupportedOSPlatform("windows")] + public partial class SearchProgressDialog : Form + { + #region Fields + + #endregion + + #region cTor + + public SearchProgressDialog() + { + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + ShouldStop = false; + } + + #endregion + + #region Properties + + public bool ShouldStop { get; private set; } + + #endregion + + #region Events handler + + private void OnButtonCancelClick(object sender, EventArgs e) + { + ShouldStop = true; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Dialogs/SearchProgressDialog.resx b/src/Logexpert.UI/Dialogs/SearchProgressDialog.resx similarity index 97% rename from src/LogExpert/Dialogs/SearchProgressDialog.resx rename to src/Logexpert.UI/Dialogs/SearchProgressDialog.resx index c7e0d4bd..d58980a3 100644 --- a/src/LogExpert/Dialogs/SearchProgressDialog.resx +++ b/src/Logexpert.UI/Dialogs/SearchProgressDialog.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/TabRenameDialog.Designer.cs b/src/Logexpert.UI/Dialogs/TabRenameDialog.Designer.cs index 974f8edf..1911909c 100644 --- a/src/Logexpert.UI/Dialogs/TabRenameDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/TabRenameDialog.Designer.cs @@ -1,102 +1,101 @@ -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +partial class TabRenameDialog { - partial class TabRenameDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} - #region Windows Form Designer generated code +#region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.textBoxTabName = new System.Windows.Forms.TextBox(); - this.labelName = new System.Windows.Forms.Label(); - this.buttonOk = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // textBoxTabName - // - this.textBoxTabName.Location = new System.Drawing.Point(12, 34); - this.textBoxTabName.Name = "textBoxTabName"; - this.textBoxTabName.Size = new System.Drawing.Size(193, 26); - this.textBoxTabName.TabIndex = 0; - // - // labelName - // - this.labelName.AutoSize = true; - this.labelName.Location = new System.Drawing.Point(13, 11); - this.labelName.Name = "labelName"; - this.labelName.Size = new System.Drawing.Size(55, 20); - this.labelName.TabIndex = 1; - this.labelName.Text = "Name:"; - // - // buttonOk - // - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(49, 73); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 23); - this.buttonOk.TabIndex = 2; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(130, 73); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 3; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // TabRenameDlg - // - this.AcceptButton = this.buttonOk; - this.ClientSize = new System.Drawing.Size(219, 108); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.labelName); - this.Controls.Add(this.textBoxTabName); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "TabRenameDlg"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Rename Tab"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnTabRenameDlgKeyDown); - this.ResumeLayout(false); - this.PerformLayout(); +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + this.textBoxTabName = new System.Windows.Forms.TextBox(); + this.labelName = new System.Windows.Forms.Label(); + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // textBoxTabName + // + this.textBoxTabName.Location = new System.Drawing.Point(12, 34); + this.textBoxTabName.Name = "textBoxTabName"; + this.textBoxTabName.Size = new System.Drawing.Size(193, 26); + this.textBoxTabName.TabIndex = 0; + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(13, 11); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(55, 20); + this.labelName.TabIndex = 1; + this.labelName.Text = "Name:"; + // + // buttonOk + // + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(49, 73); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 2; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(130, 73); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 3; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // TabRenameDlg + // + this.AcceptButton = this.buttonOk; + this.ClientSize = new System.Drawing.Size(219, 108); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.labelName); + this.Controls.Add(this.textBoxTabName); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "TabRenameDlg"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Rename Tab"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnTabRenameDlgKeyDown); + this.ResumeLayout(false); + this.PerformLayout(); - } +} - #endregion +#endregion - private System.Windows.Forms.TextBox textBoxTabName; - private System.Windows.Forms.Label labelName; - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.Button buttonCancel; - } + private System.Windows.Forms.TextBox textBoxTabName; + private System.Windows.Forms.Label labelName; + private System.Windows.Forms.Button buttonOk; + private System.Windows.Forms.Button buttonCancel; } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/TabRenameDialog.cs b/src/Logexpert.UI/Dialogs/TabRenameDialog.cs index 1ba5abd3..3a7a5391 100644 --- a/src/Logexpert.UI/Dialogs/TabRenameDialog.cs +++ b/src/Logexpert.UI/Dialogs/TabRenameDialog.cs @@ -1,43 +1,42 @@ using System.Runtime.Versioning; -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +[SupportedOSPlatform("windows")] +public partial class TabRenameDialog : Form { - [SupportedOSPlatform("windows")] - public partial class TabRenameDialog : Form - { - #region cTor + #region cTor - public TabRenameDialog() - { - InitializeComponent(); + public TabRenameDialog() + { + InitializeComponent(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - } + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + } - #endregion + #endregion - #region Properties + #region Properties - public string TabName - { - get => textBoxTabName.Text; - set => textBoxTabName.Text = value; - } + public string TabName + { + get => textBoxTabName.Text; + set => textBoxTabName.Text = value; + } - #endregion + #endregion - #region Events handler + #region Events handler - private void OnTabRenameDlgKeyDown(object sender, KeyEventArgs e) + private void OnTabRenameDlgKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - Close(); - } + DialogResult = DialogResult.Cancel; + Close(); } - - #endregion } + + #endregion } \ No newline at end of file diff --git a/src/Logexpert.UI/Extensions/ComboBoxExtensions.cs b/src/Logexpert.UI/Extensions/ComboBoxExtensions.cs new file mode 100644 index 00000000..90d7d31e --- /dev/null +++ b/src/Logexpert.UI/Extensions/ComboBoxExtensions.cs @@ -0,0 +1,25 @@ +using System.Runtime.Versioning; + +namespace LogExpert.UI.Extensions; + +[SupportedOSPlatform("windows")] +public static class ComboBoxExtensions +{ + /// + public static int GetMaxTextWidth(this ComboBox comboBox) + { + var maxTextWidth = comboBox.Width; + + foreach (var item in comboBox.Items) + { + var textWidthInPixels = TextRenderer.MeasureText(item.ToString(), comboBox.Font).Width; + + if (textWidthInPixels > maxTextWidth) + { + maxTextWidth = textWidthInPixels; + } + } + + return maxTextWidth; + } +} diff --git a/src/Logexpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs b/src/Logexpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs new file mode 100644 index 00000000..f63b4bb1 --- /dev/null +++ b/src/Logexpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs @@ -0,0 +1,36 @@ +using LogExpert.Core.Config; + +using System.Runtime.Versioning; + +namespace LogExpert.UI.Extensions.Forms; + +[SupportedOSPlatform("windows")] +public class LineToolStripSeparatorExtension : ToolStripSeparator +{ + public LineToolStripSeparatorExtension() + { + Paint += OnExtendedToolStripSeparatorPaint; + } + + private void OnExtendedToolStripSeparatorPaint(object sender, PaintEventArgs e) + { + // Get the separator's width and height. + ToolStripSeparator toolStripSeparator = (ToolStripSeparator)sender; + int width = toolStripSeparator.Width; + int height = toolStripSeparator.Height; + + // Choose the colors for drawing. + // I've used Color.White as the foreColor. + Color foreColor = ColorMode.ForeColor; + // Color.Teal as the backColor. + Color backColor = ColorMode.BackgroundColor; + + // Fill the background. + using SolidBrush backbrush = new(backColor); + e.Graphics.FillRectangle(backbrush, 0, 0, width, height); + + // Draw the line. + using Pen pen = new(foreColor); + e.Graphics.DrawLine(pen, width / 2, 4, width / 2, height - 4); + } +} diff --git a/src/Logexpert.UI/Extensions/Forms/MenuSelectedColors.cs b/src/Logexpert.UI/Extensions/Forms/MenuSelectedColors.cs new file mode 100644 index 00000000..5e6a81bd --- /dev/null +++ b/src/Logexpert.UI/Extensions/Forms/MenuSelectedColors.cs @@ -0,0 +1,31 @@ +using LogExpert.Core.Config; + +using System.Runtime.Versioning; + +namespace LogExpert.UI.Extensions.Forms; + +[SupportedOSPlatform("windows")] +public class MenuSelectedColors : ProfessionalColorTable +{ + public override Color ImageMarginGradientBegin => ColorMode.MenuBackgroundColor; + + public override Color ImageMarginGradientMiddle => ColorMode.MenuBackgroundColor; + + public override Color ImageMarginGradientEnd => ColorMode.MenuBackgroundColor; + + public override Color ToolStripDropDownBackground => ColorMode.MenuBackgroundColor; + + public override Color MenuBorder => ColorMode.MenuBackgroundColor; + + public override Color MenuItemBorder => ColorMode.MenuBackgroundColor; + + public override Color MenuItemSelected => ColorMode.HoverMenuBackgroundColor; + + public override Color MenuItemSelectedGradientBegin => ColorMode.HoverMenuBackgroundColor; + + public override Color MenuItemSelectedGradientEnd => ColorMode.HoverMenuBackgroundColor; + + public override Color MenuItemPressedGradientBegin => ColorMode.MenuBackgroundColor; + + public override Color MenuItemPressedGradientEnd => ColorMode.MenuBackgroundColor; +} \ No newline at end of file diff --git a/src/Logexpert.UI/Extensions/Forms/MenuStripExtension.cs b/src/Logexpert.UI/Extensions/Forms/MenuStripExtension.cs new file mode 100644 index 00000000..1d4d16ca --- /dev/null +++ b/src/Logexpert.UI/Extensions/Forms/MenuStripExtension.cs @@ -0,0 +1,9 @@ +using System.Runtime.Versioning; + +namespace LogExpert.UI.Extensions.Forms; + +[SupportedOSPlatform("windows")] +public class ExtendedMenuStripRenderer : ToolStripProfessionalRenderer +{ + public ExtendedMenuStripRenderer() : base(new MenuSelectedColors()) { } +} diff --git a/src/Logexpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs b/src/Logexpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs new file mode 100644 index 00000000..b2dc6af7 --- /dev/null +++ b/src/Logexpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs @@ -0,0 +1,39 @@ +using LogExpert.Core.Config; + +using System.Runtime.Versioning; + +namespace LogExpert.UI.Extensions.Forms; + +[SupportedOSPlatform("windows")] +public class MenuToolStripSeparatorExtension : ToolStripSeparator +{ + public MenuToolStripSeparatorExtension() + { + Paint += OnExtendedToolStripSeparatorPaint; + } + + private void OnExtendedToolStripSeparatorPaint(object? sender, PaintEventArgs e) + { + if (sender == null) + { + return; + } + + // Get the separator's width and height. + ToolStripSeparator toolStripSeparator = sender as ToolStripSeparator; + int width = toolStripSeparator.Width; + int height = toolStripSeparator.Height; + + // Choose the colors for drawing. + // I've used Color.White as the foreColor. + Color foreColor = ColorMode.ForeColor; + // Color.Teal as the backColor. + Color backColor = ColorMode.MenuBackgroundColor; + + // Fill the background. + e.Graphics.FillRectangle(new SolidBrush(backColor), 0, 0, width, height); + + // Draw the line. + e.Graphics.DrawLine(new Pen(foreColor), 4, height / 2, width - 4, height / 2); + } +} diff --git a/src/Logexpert.UI/Extensions/Forms/ToolStripRendererExtension.cs b/src/Logexpert.UI/Extensions/Forms/ToolStripRendererExtension.cs new file mode 100644 index 00000000..5b85f845 --- /dev/null +++ b/src/Logexpert.UI/Extensions/Forms/ToolStripRendererExtension.cs @@ -0,0 +1,15 @@ +using System.Runtime.Versioning; + +namespace LogExpert.UI.Extensions.Forms; + +[SupportedOSPlatform("windows")] +public class ToolStripRendererExtension : ToolStripSystemRenderer +{ + public ToolStripRendererExtension() { } + + protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) + { + // Commented on purpose to avoid drawing the border that appears visible in Dark Mode (not visible in Bright mode) + //base.OnRenderToolStripBorder(e); + } +} diff --git a/src/Logexpert.UI/LogExpert.UI.csproj b/src/Logexpert.UI/LogExpert.UI.csproj index 82ec1bb4..67b86a95 100644 --- a/src/Logexpert.UI/LogExpert.UI.csproj +++ b/src/Logexpert.UI/LogExpert.UI.csproj @@ -21,24 +21,72 @@ + + Component + + + UserControl + + + Component + + + Component + Form + + Form + Form + + Form + + + Form + + + Form + + + Form + + + Form + + + Form + + + Form + Form + + Form + Form Form + + Form + Form + + Component + + + Component + @@ -49,4 +97,8 @@ + + + + From 4b697b5a0171e986ae5c9be5be61ee7c1c19b5ee Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 13 Apr 2025 17:52:10 +0200 Subject: [PATCH 015/142] Erros Removed --- src/JsonColumnizer/JsonColumnizer.cs | 12 ++++++------ src/JsonCompactColumnizer/JsonCompactColumnizer.cs | 10 +++++----- src/Log4jXmlColumnizer/Log4jColumnEntry.cs | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/JsonColumnizer/JsonColumnizer.cs b/src/JsonColumnizer/JsonColumnizer.cs index c3954844..c77b45d6 100644 --- a/src/JsonColumnizer/JsonColumnizer.cs +++ b/src/JsonColumnizer/JsonColumnizer.cs @@ -174,7 +174,7 @@ protected static JObject ParseJson(ILogLine line) public class ColumnWithName : Column { - public string ColumneName { get; set; } + public string ColumnName { get; set; } } // @@ -186,20 +186,20 @@ protected virtual IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) { var cLogLine = new ColumnizedLogLine { LogLine = line }; - var columns = json.Properties().Select(property => new ColumnWithName { FullValue = property.Value.ToString(), ColumneName = property.Name.ToString(), Parent = cLogLine }).ToList(); + var columns = json.Properties().Select(property => new ColumnWithName { FullValue = property.Value.ToString(), ColumnName = property.Name.ToString(), Parent = cLogLine }).ToList(); foreach (var jsonColumn in columns) { // When find new column in a log line, add a new column in the end of the list. - if (!ColumnSet.Contains(jsonColumn.ColumneName)) + if (!ColumnSet.Contains(jsonColumn.ColumnName)) { if (ColumnList.Count == 1 && !ColumnSet.Contains(ColumnList[0].Name)) { ColumnList.Clear(); } - ColumnSet.Add(jsonColumn.ColumneName); - ColumnList.Add(new JsonColumn(jsonColumn.ColumneName)); + ColumnSet.Add(jsonColumn.ColumnName); + ColumnList.Add(new JsonColumn(jsonColumn.ColumnName)); } } @@ -210,7 +210,7 @@ protected virtual IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) List returnColumns = []; foreach (var column in ColumnList) { - var existingColumn = columns.Find(x => x.ColumneName == column.Name); + var existingColumn = columns.Find(x => x.ColumnName == column.Name); if (existingColumn != null) { returnColumns.Add(new Column() { FullValue = existingColumn.FullValue, Parent = cLogLine }); diff --git a/src/JsonCompactColumnizer/JsonCompactColumnizer.cs b/src/JsonCompactColumnizer/JsonCompactColumnizer.cs index 65be9131..32acccf8 100644 --- a/src/JsonCompactColumnizer/JsonCompactColumnizer.cs +++ b/src/JsonCompactColumnizer/JsonCompactColumnizer.cs @@ -53,7 +53,7 @@ public override Priority GetPriority(string fileName, IEnumerable samp if (json != null) { var columns = SplitJsonLine(samples.First(), json); - if (columns.ColumnValues.Count() > 0 && Array.Exists(columns.ColumnValues, x => !string.IsNullOrEmpty(x.FullValue))) + if (columns.ColumnValues.Length > 0 && Array.Exists(columns.ColumnValues, x => !string.IsNullOrEmpty(x.FullValue))) { result = Priority.PerfectlySupport; } @@ -85,10 +85,10 @@ public override Priority GetPriority(string fileName, IEnumerable samp protected override IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) { - List returnColumns = new(); + List returnColumns = []; var cLogLine = new ColumnizedLogLine { LogLine = line }; - var columns = json.Properties().Select(property => new ColumnWithName { FullValue = property.Value.ToString(), ColumneName = property.Name.ToString(), Parent = cLogLine }).ToList(); + var columns = json.Properties().Select(property => new ColumnWithName { FullValue = property.Value.ToString(), ColumnName = property.Name.ToString(), Parent = cLogLine }).ToList(); // // Always rearrage the order of all json fields within a line to follow the sequence of columnNameList. @@ -98,7 +98,7 @@ protected override IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) { if (column.StartsWith('@')) { - var existingColumn = columns.Find(x => x.ColumneName == column); + var existingColumn = columns.Find(x => x.ColumnName == column); if (existingColumn != null) { @@ -111,7 +111,7 @@ protected override IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) } } - cLogLine.ColumnValues = returnColumns.ToArray(); + cLogLine.ColumnValues = [.. returnColumns]; return cLogLine; } diff --git a/src/Log4jXmlColumnizer/Log4jColumnEntry.cs b/src/Log4jXmlColumnizer/Log4jColumnEntry.cs index 037c8b84..b1d7869a 100644 --- a/src/Log4jXmlColumnizer/Log4jColumnEntry.cs +++ b/src/Log4jXmlColumnizer/Log4jColumnEntry.cs @@ -3,7 +3,7 @@ namespace Log4jXmlColumnizer { /// - /// Helper class for configuration of the colums. + /// Helper class for configuration of the columns. /// [Serializable] public class Log4jColumnEntry(string name, int index, int maxLen) From 813a3ad8398a538e747368a391430c47dc2d1fc4 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Fri, 16 May 2025 15:57:18 +0200 Subject: [PATCH 016/142] 382-foreground-and-background-dropdowns-on-highlightdialog-have-duplicate-entries: removed, added by colorcombobox --- src/LogExpert/Dialogs/HighlightDialog.Designer.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/LogExpert/Dialogs/HighlightDialog.Designer.cs b/src/LogExpert/Dialogs/HighlightDialog.Designer.cs index a2b56959..4048062a 100644 --- a/src/LogExpert/Dialogs/HighlightDialog.Designer.cs +++ b/src/LogExpert/Dialogs/HighlightDialog.Designer.cs @@ -379,7 +379,6 @@ private void InitializeComponent() colorBoxForeground.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; colorBoxForeground.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; colorBoxForeground.FormattingEnabled = true; - colorBoxForeground.Items.AddRange(new object[] { Color.Black, Color.Black, Color.White, Color.Gray, Color.DarkGray, Color.Blue, Color.LightBlue, Color.DarkBlue, Color.Green, Color.LightGreen, Color.DarkGreen, Color.Olive, Color.Red, Color.Pink, Color.Purple, Color.IndianRed, Color.DarkCyan, Color.Yellow, Color.Black, Color.Black, Color.White, Color.Gray, Color.DarkGray, Color.Blue, Color.LightBlue, Color.DarkBlue, Color.Green, Color.LightGreen, Color.DarkGreen, Color.Olive, Color.Red, Color.Pink, Color.Purple, Color.IndianRed, Color.DarkCyan, Color.Yellow, Color.Black, Color.Black, Color.White, Color.Gray, Color.DarkGray, Color.Blue, Color.LightBlue, Color.DarkBlue, Color.Green, Color.LightGreen, Color.DarkGreen, Color.Olive, Color.Red, Color.Pink, Color.Purple, Color.IndianRed, Color.DarkCyan, Color.Yellow, Color.Black, Color.Black, Color.White, Color.Gray, Color.DarkGray, Color.Blue, Color.LightBlue, Color.DarkBlue, Color.Green, Color.LightGreen, Color.DarkGreen, Color.Olive, Color.Red, Color.Pink, Color.Purple, Color.IndianRed, Color.DarkCyan, Color.Yellow }); colorBoxForeground.Location = new Point(8, 63); colorBoxForeground.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); colorBoxForeground.Name = "colorBoxForeground"; @@ -394,7 +393,6 @@ private void InitializeComponent() colorBoxBackground.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; colorBoxBackground.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; colorBoxBackground.FormattingEnabled = true; - colorBoxBackground.Items.AddRange(new object[] { Color.Black, Color.Black, Color.White, Color.Gray, Color.DarkGray, Color.Blue, Color.LightBlue, Color.DarkBlue, Color.Green, Color.LightGreen, Color.DarkGreen, Color.Olive, Color.Red, Color.Pink, Color.Purple, Color.IndianRed, Color.DarkCyan, Color.Yellow, Color.Black, Color.Black, Color.White, Color.Gray, Color.DarkGray, Color.Blue, Color.LightBlue, Color.DarkBlue, Color.Green, Color.LightGreen, Color.DarkGreen, Color.Olive, Color.Red, Color.Pink, Color.Purple, Color.IndianRed, Color.DarkCyan, Color.Yellow, Color.Black, Color.Black, Color.White, Color.Gray, Color.DarkGray, Color.Blue, Color.LightBlue, Color.DarkBlue, Color.Green, Color.LightGreen, Color.DarkGreen, Color.Olive, Color.Red, Color.Pink, Color.Purple, Color.IndianRed, Color.DarkCyan, Color.Yellow, Color.Black, Color.Black, Color.White, Color.Gray, Color.DarkGray, Color.Blue, Color.LightBlue, Color.DarkBlue, Color.Green, Color.LightGreen, Color.DarkGreen, Color.Olive, Color.Red, Color.Pink, Color.Purple, Color.IndianRed, Color.DarkCyan, Color.Yellow }); colorBoxBackground.Location = new Point(9, 140); colorBoxBackground.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); colorBoxBackground.Name = "colorBoxBackground"; From 67cfe210eb6757af10dc4698df0ff5e9f29a997e Mon Sep 17 00:00:00 2001 From: Hirogen Date: Fri, 16 May 2025 18:45:51 +0200 Subject: [PATCH 017/142] 373-v1120---importing-highlighting-config-is-broken: fixed --- src/LogExpert/Classes/PaintHelper.cs | 12 +- src/LogExpert/Config/ConfigManager.cs | 105 ++++++------------ .../Controls/LogTabWindow/LogTabWindow.cs | 10 +- .../LogTabWindow/LogTabWindowEventHandlers.cs | 2 +- .../LogTabWindow/LogTabWindowPrivate.cs | 10 +- .../LogTabWindow/LogTabWindowPublic.cs | 8 +- src/LogExpert/Controls/LogWindow/LogWindow.cs | 4 +- .../LogWindow/LogWindowEventHandlers.cs | 8 +- .../Controls/LogWindow/LogWindowPrivate.cs | 50 ++++----- .../Controls/LogWindow/LogWindowsPublic.cs | 16 +-- src/LogExpert/Dialogs/HighlightDialog.cs | 72 ++++++------ src/LogExpert/Dialogs/SettingsDialog.cs | 12 +- .../CurrentHighlightGroupChangedEventArgs.cs | 4 +- .../{HilightEntry.cs => HighlightEntry.cs} | 4 +- .../Classes/Highlight/HilightMatchEntry.cs | 2 +- .../Config/ExportImportFlags.cs | 2 - src/Logexpert.Core/Config/Preferences.cs | 2 + src/Logexpert.Core/Config/Settings.cs | 7 -- .../{HilightGroup.cs => HighlightGroup.cs} | 10 +- .../Interface/ILogPaintContext.cs | 2 +- .../Dialogs/ImportSettingsDialog.cs | 45 ++++++-- 21 files changed, 185 insertions(+), 202 deletions(-) rename src/Logexpert.Core/Classes/Highlight/{HilightEntry.cs => HighlightEntry.cs} (96%) rename src/Logexpert.Core/Entities/{HilightGroup.cs => HighlightGroup.cs} (56%) diff --git a/src/LogExpert/Classes/PaintHelper.cs b/src/LogExpert/Classes/PaintHelper.cs index bc0ce1c6..37eb718c 100644 --- a/src/LogExpert/Classes/PaintHelper.cs +++ b/src/LogExpert/Classes/PaintHelper.cs @@ -44,7 +44,7 @@ public static void CellPainting(ILogPaintContext logPaintCtx, BufferedDataGridVi ILogLine line = logPaintCtx.GetLogLine(rowIndex); if (line != null) { - HilightEntry entry = logPaintCtx.FindHighlightEntry(line, true); + HighlightEntry entry = logPaintCtx.FindHighlightEntry(line, true); e.Graphics.SetClip(e.CellBounds); if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) { @@ -290,12 +290,12 @@ public static Rectangle BorderWidths(DataGridViewAdvancedBorderStyle advancedBor #region Private Methods - private static void PaintCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HilightEntry groundEntry) + private static void PaintCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) { PaintHighlightedCell(logPaintCtx, e, gridView, noBackgroundFill, groundEntry); } - private static void PaintHighlightedCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HilightEntry groundEntry) + private static void PaintHighlightedCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) { object value = e.Value ?? string.Empty; @@ -314,7 +314,7 @@ private static void PaintHighlightedCell(ILogPaintContext logPaintCtx, DataGridV hme.StartPos = 0; hme.Length = column.FullValue.Length; - var he = new HilightEntry + var he = new HighlightEntry { SearchText = column.FullValue, ForegroundColor = groundEntry?.ForegroundColor ?? ColorMode.ForeColor, @@ -427,7 +427,7 @@ private static void PaintHighlightedCell(ILogPaintContext logPaintCtx, DataGridV private static IList MergeHighlightMatchEntries(IList matchList, HilightMatchEntry groundEntry) { // Fill an area with lenth of whole text with a default hilight entry - HilightEntry[] entryArray = new HilightEntry[groundEntry.Length]; + HighlightEntry[] entryArray = new HighlightEntry[groundEntry.Length]; for (int i = 0; i < entryArray.Length; ++i) { entryArray[i] = groundEntry.HilightEntry; @@ -455,7 +455,7 @@ private static IList MergeHighlightMatchEntries(IList mergedList = new List(); if (entryArray.Length > 0) { - HilightEntry currentEntry = entryArray[0]; + HighlightEntry currentEntry = entryArray[0]; int lastStartPos = 0; int pos = 0; for (; pos < entryArray.Length; ++pos) diff --git a/src/LogExpert/Config/ConfigManager.cs b/src/LogExpert/Config/ConfigManager.cs index b7e2e5ec..2c3b3e6e 100644 --- a/src/LogExpert/Config/ConfigManager.cs +++ b/src/LogExpert/Config/ConfigManager.cs @@ -95,6 +95,12 @@ public static void Import(FileInfo fileInfo, ExportImportFlags flags) Save(SettingsFlags.All); } + public static void ImportHighlightSettings(FileInfo fileInfo, ExportImportFlags flags) + { + Instance._settings.Preferences.HighlightGroupList = Instance.Import(Instance._settings.Preferences.HighlightGroupList, fileInfo, flags); + Save(SettingsFlags.All); + } + #endregion #region Private Methods @@ -144,7 +150,7 @@ private Settings Load() /// /// file that has settings saved /// loaded or created settings - private Settings LoadOrCreateNew(FileSystemInfo fileInfo) + private Settings LoadOrCreateNew(FileInfo fileInfo) { lock (_loadSaveLock) { @@ -212,17 +218,9 @@ private Settings LoadOrCreateNew(FileSystemInfo fileInfo) filterParams.Init(); } - if (settings.hilightGroupList == null) + if (settings.Preferences.HighlightGroupList == null) { - settings.hilightGroupList = []; - // migrate old non-grouped entries - HilightGroup defaultGroup = new() - { - GroupName = "[Default]", - HilightEntryList = settings.hilightEntryList - }; - - settings.hilightGroupList.Add(defaultGroup); + settings.Preferences.HighlightGroupList = []; } settings.Preferences.highlightMaskList ??= []; @@ -248,8 +246,6 @@ private Settings LoadOrCreateNew(FileSystemInfo fileInfo) SetBoundsWithinVirtualScreen(settings); - ConvertSettings(settings); - return settings; } } @@ -301,55 +297,32 @@ private void SaveAsJSON(FileInfo fileInfo, Settings settings) serializer.Serialize(sw, settings); } - /// - /// Convert settings loaded from previous versions. - /// - /// - private void ConvertSettings(Settings settings) + private List Import(List currentGroups, FileInfo fileInfo, ExportImportFlags flags) { - //int oldBuildNumber = settings.versionBuild; - - //// All Versions before 3583 - //if (oldBuildNumber < 3584) - //{ - // // External tools - // List newList = []; - // foreach (ToolEntry tool in settings.preferences.toolEntries) - // { - // // set favourite to true only when name is empty, because there are always version released without this conversion fx - // // remove empty tool entries (there were always 3 entries before, which can be empty if not used) - // if (Util.IsNull(tool.name)) - // { - // if (!Util.IsNull(tool.cmd)) - // { - // tool.name = tool.cmd; - // tool.isFavourite = true; - // newList.Add(tool); - // } - // } - // else - // { - // newList.Add(tool); - // } - // if (Util.IsNull(tool.iconFile)) - // { - // tool.iconFile = tool.cmd; - // tool.iconIndex = 0; - // } - // } - // settings.preferences.toolEntries = newList; - //} - - //if (oldBuildNumber < 3584) - //{ - // // Set the color for the FilterList entries to default (black) - // foreach (FilterParams filterParam in settings.filterList) - // { - // filterParam.color = Color.FromKnownColor(KnownColor.Black); - // } - //} - } + List newGroups; + try + { + newGroups = JsonConvert.DeserializeObject>(File.ReadAllText($"{fileInfo.FullName}")); + } + catch (Exception e) + { + _logger.Error($"Error while deserializing config data: {e}"); + newGroups = []; + } + + if (flags.HasFlag(ExportImportFlags.KeepExisting)) + { + currentGroups.AddRange(newGroups); + } + else + { + currentGroups.Clear(); + currentGroups.AddRange(newGroups); + } + + return currentGroups; + } /// /// Imports all or some of the settings/prefs stored in the input stream. @@ -371,7 +344,7 @@ private Settings Import(Settings currentSettings, FileInfo fileInfo, ExportImpor newSettings.Preferences = ObjectClone.Clone(importSettings.Preferences); newSettings.Preferences.columnizerMaskList = ownSettings.Preferences.columnizerMaskList; newSettings.Preferences.highlightMaskList = ownSettings.Preferences.highlightMaskList; - newSettings.hilightGroupList = ownSettings.hilightGroupList; + newSettings.Preferences.HighlightGroupList = ownSettings.Preferences.HighlightGroupList; newSettings.Preferences.toolEntries = ownSettings.Preferences.toolEntries; } else @@ -389,7 +362,7 @@ private Settings Import(Settings currentSettings, FileInfo fileInfo, ExportImpor } if ((flags & ExportImportFlags.HighlightSettings) == ExportImportFlags.HighlightSettings) { - newSettings.hilightGroupList = ReplaceOrKeepExisting(flags, ownSettings.hilightGroupList, importSettings.hilightGroupList); + newSettings.Preferences.HighlightGroupList = ReplaceOrKeepExisting(flags, ownSettings.Preferences.HighlightGroupList, importSettings.Preferences.HighlightGroupList); } if ((flags & ExportImportFlags.ToolEntries) == ExportImportFlags.ToolEntries) { @@ -424,13 +397,7 @@ private void SetBoundsWithinVirtualScreen(Settings settings) protected void OnConfigChanged(SettingsFlags flags) { - ConfigChangedEventHandler handler = ConfigChanged; - - if (handler != null) - { - _logger.Info("Fire config changed event"); - handler(this, new ConfigChangedEventArgs(flags)); - } + ConfigChanged?.Invoke(this, new ConfigChangedEventArgs(flags)); } public delegate void ConfigChangedEventHandler(object sender, ConfigChangedEventArgs e); diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs index 42f1dbc2..8d8709d6 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs @@ -89,7 +89,7 @@ public LogTabWindow(string[] fileNames, int instanceNumber, bool showInstanceNum Load += OnLogTabWindowLoad; ConfigManager.Instance.ConfigChanged += OnConfigChanged; - HilightGroupList = ConfigManager.Settings.hilightGroupList; + HighlightGroupList = ConfigManager.Settings.Preferences.HighlightGroupList; Rectangle led = new(0, 0, 8, 2); @@ -297,7 +297,7 @@ public LogWindow.LogWindow CurrentLogWindow public Preferences Preferences => ConfigManager.Settings.Preferences; - public List HilightGroupList { get; private set; } = []; + public List HighlightGroupList { get; private set; } = []; //public Settings Settings //{ @@ -312,11 +312,11 @@ public LogWindow.LogWindow CurrentLogWindow #region Internals - internal HilightGroup FindHighlightGroup(string groupName) + internal HighlightGroup FindHighlightGroup(string groupName) { - lock (HilightGroupList) + lock (HighlightGroupList) { - foreach (HilightGroup group in HilightGroupList) + foreach (HighlightGroup group in HighlightGroupList) { if (group.GroupName.Equals(groupName)) { diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs index b17e897a..c1bc2677 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs @@ -481,7 +481,7 @@ private void OnLogWindowFilterListChanged(object sender, FilterListChangedEventA private void OnLogWindowCurrentHighlightGroupChanged(object sender, CurrentHighlightGroupChangedEventArgs e) { OnHighlightSettingsChanged(); - ConfigManager.Settings.hilightGroupList = HilightGroupList; + ConfigManager.Settings.Preferences.HighlightGroupList = HighlightGroupList; ConfigManager.Save(SettingsFlags.HighlightSettings); } diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindowPrivate.cs index 2c8a697a..02639847 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindowPrivate.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindowPrivate.cs @@ -341,7 +341,7 @@ private void ShowHighlightSettingsDialog() KeywordActionList = PluginRegistry.PluginRegistry.Instance.RegisteredKeywordActions, Owner = this, TopMost = TopMost, - HighlightGroupList = HilightGroupList, + HighlightGroupList = HighlightGroupList, PreSelectedGroupName = groupsComboBoxHighlightGroups.Text }; @@ -349,9 +349,9 @@ private void ShowHighlightSettingsDialog() if (res == DialogResult.OK) { - HilightGroupList = dlg.HighlightGroupList; + HighlightGroupList = dlg.HighlightGroupList; FillHighlightComboBox(); - ConfigManager.Settings.hilightGroupList = HilightGroupList; + ConfigManager.Settings.Preferences.HighlightGroupList = HighlightGroupList; ConfigManager.Save(SettingsFlags.HighlightSettings); OnHighlightSettingsChanged(); } @@ -361,7 +361,7 @@ private void FillHighlightComboBox() { string currentGroupName = groupsComboBoxHighlightGroups.Text; groupsComboBoxHighlightGroups.Items.Clear(); - foreach (HilightGroup group in HilightGroupList) + foreach (HighlightGroup group in HighlightGroupList) { groupsComboBoxHighlightGroups.Items.Add(group.GroupName); if (group.GroupName.Equals(currentGroupName)) @@ -956,7 +956,7 @@ private void NotifyWindowsForChangedPrefs(SettingsFlags flags) _bookmarkWindow.PreferencesChanged(ConfigManager.Settings.Preferences, false, flags); - HilightGroupList = ConfigManager.Settings.hilightGroupList; + HighlightGroupList = ConfigManager.Settings.Preferences.HighlightGroupList; if ((flags & SettingsFlags.HighlightSettings) == SettingsFlags.HighlightSettings) { OnHighlightSettingsChanged(); diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindowPublic.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindowPublic.cs index 7eed4fe2..c2569798 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindowPublic.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindowPublic.cs @@ -259,7 +259,7 @@ public ILogLineColumnizer FindColumnizerByFileMask(string fileName) return null; } - public HilightGroup FindHighlightGroupByFileMask(string fileName) + public HighlightGroup FindHighlightGroupByFileMask(string fileName) { foreach (HighlightMaskEntry entry in ConfigManager.Settings.Preferences.highlightMaskList) { @@ -269,7 +269,7 @@ public HilightGroup FindHighlightGroupByFileMask(string fileName) { if (Regex.IsMatch(fileName, entry.mask)) { - HilightGroup group = FindHighlightGroup(entry.highlightGroupName); + HighlightGroup group = FindHighlightGroup(entry.highlightGroupName); return group; } } @@ -333,9 +333,9 @@ public void FollowTailChanged(LogWindow.LogWindow logWindow, bool isEnabled, boo } } - public void NotifySettingsChanged(object cookie, SettingsFlags flags) + public void NotifySettingsChanged(object sender, SettingsFlags flags) { - if (cookie != this) + if (sender != this) { NotifyWindowsForChangedPrefs(flags); } diff --git a/src/LogExpert/Controls/LogWindow/LogWindow.cs b/src/LogExpert/Controls/LogWindow/LogWindow.cs index 42bb9fab..e39393f2 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindow.cs @@ -92,7 +92,7 @@ public partial class LogWindow : DockContent, ILogPaintContext, ILogView private ILogLineColumnizer _currentColumnizer; //List currentHilightEntryList = new List(); - private HilightGroup _currentHighlightGroup = new(); + private HighlightGroup _currentHighlightGroup = new(); private SearchParams _currentSearchParams; @@ -131,7 +131,7 @@ public partial class LogWindow : DockContent, ILogPaintContext, ILogView private bool _shouldCancel; private bool _shouldTimestampDisplaySyncingCancel; private bool _showAdvanced; - private List _tempHighlightEntryList = []; + private List _tempHighlightEntryList = []; private int _timeShiftSyncLine = 0; private bool _waitingForClose; diff --git a/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs index 97f372fc..b73d4c49 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs @@ -382,7 +382,7 @@ private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintin if (line != null) { - HilightEntry entry = FindFirstNoWordMatchHilightEntry(line); + HighlightEntry entry = FindFirstNoWordMatchHilightEntry(line); e.Graphics.SetClip(e.CellBounds); if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) { @@ -1180,7 +1180,7 @@ private void OnHighlightSelectionInLogFileToolStripMenuItemClick(object sender, { if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) { - var he = new HilightEntry() + var he = new HighlightEntry() { SearchText = ctl.SelectedText, ForegroundColor = Color.Red, @@ -1209,7 +1209,7 @@ private void OnHighlightSelectionInLogFilewordModeToolStripMenuItemClick(object { if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) { - HilightEntry he = new() + HighlightEntry he = new() { SearchText = ctl.SelectedText, ForegroundColor = Color.Red, @@ -1257,7 +1257,7 @@ private void OnMakePermanentToolStripMenuItemClick(object sender, EventArgs e) { lock (_currentHighlightGroupLock) { - _currentHighlightGroup.HilightEntryList.AddRange(_tempHighlightEntryList); + _currentHighlightGroup.HighlightEntryList.AddRange(_tempHighlightEntryList); RemoveTempHighlights(); OnCurrentHighlightListChanged(); } diff --git a/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs index 722e85fc..1621bd96 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs @@ -812,7 +812,7 @@ private void CheckFilterAndHighlight(LogEventArgs e) //pipeFx.BeginInvoke(i, null, null); ProcessFilterPipes(i); - IList matchingList = FindMatchingHilightEntries(line); + IList matchingList = FindMatchingHilightEntries(line); LaunchHighlightPlugins(matchingList, i); GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, out bookmarkComment); if (setBookmark) @@ -860,7 +860,7 @@ private void CheckFilterAndHighlight(LogEventArgs e) ILogLine line = _logFileReader.GetLogLine(i); if (line != null) { - IList matchingList = FindMatchingHilightEntries(line); + IList matchingList = FindMatchingHilightEntries(line); LaunchHighlightPlugins(matchingList, i); GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, out bookmarkComment); @@ -895,14 +895,14 @@ private void CheckFilterAndHighlight(LogEventArgs e) } } - private void LaunchHighlightPlugins(IList matchingList, int lineNum) + private void LaunchHighlightPlugins(IList matchingList, int lineNum) { LogExpertCallback callback = new(this) { LineNum = lineNum }; - foreach (HilightEntry entry in matchingList) + foreach (HighlightEntry entry in matchingList) { if (entry.IsActionEntry && entry.ActionEntry.PluginName != null) { @@ -1119,14 +1119,14 @@ private void AutoResizeColumns(BufferedDataGridView gridView) } private void PaintCell(DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, - HilightEntry groundEntry) + HighlightEntry groundEntry) { PaintHighlightedCell(e, gridView, noBackgroundFill, groundEntry); } private void PaintHighlightedCell(DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, - HilightEntry groundEntry) + HighlightEntry groundEntry) { var column = e.Value as IColumn; @@ -1139,7 +1139,7 @@ private void PaintHighlightedCell(DataGridViewCellPaintingEventArgs e, BufferedD matchList.RemoveAt(50); } - var he = new HilightEntry + var he = new HighlightEntry { SearchText = column.DisplayValue, ForegroundColor = groundEntry?.ForegroundColor ?? Color.FromKnownColor(KnownColor.Black), @@ -1244,7 +1244,7 @@ private IList MergeHighlightMatchEntries(IList MergeHighlightMatchEntries(IList 0) { - HilightEntry currentEntry = entryArray[0]; + HighlightEntry currentEntry = entryArray[0]; int lastStartPos = 0; int pos = 0; @@ -1310,17 +1310,17 @@ private IList MergeHighlightMatchEntries(IList /// Returns the first HilightEntry that matches the given line /// - private HilightEntry FindHilightEntry(ITextValue line) + private HighlightEntry FindHilightEntry(ITextValue line) { return FindHighlightEntry(line, false); } - private HilightEntry FindFirstNoWordMatchHilightEntry(ITextValue line) + private HighlightEntry FindFirstNoWordMatchHilightEntry(ITextValue line) { return FindHighlightEntry(line, true); } - private bool CheckHighlightEntryMatch(HilightEntry entry, ITextValue column) + private bool CheckHighlightEntryMatch(HighlightEntry entry, ITextValue column) { if (entry.IsRegEx) { @@ -1354,14 +1354,14 @@ private bool CheckHighlightEntryMatch(HilightEntry entry, ITextValue column) /// /// Returns all HilightEntry entries which matches the given line /// - private IList FindMatchingHilightEntries(ITextValue line) + private IList FindMatchingHilightEntries(ITextValue line) { - IList resultList = []; + IList resultList = []; if (line != null) { lock (_currentHighlightGroupLock) { - foreach (HilightEntry entry in _currentHighlightGroup.HilightEntryList) + foreach (HighlightEntry entry in _currentHighlightGroup.HighlightEntryList) { if (CheckHighlightEntryMatch(entry, line)) { @@ -1374,9 +1374,9 @@ private IList FindMatchingHilightEntries(ITextValue line) return resultList; } - private void GetHighlightEntryMatches(ITextValue line, IList hilightEntryList, IList resultList) + private void GetHighlightEntryMatches(ITextValue line, IList hilightEntryList, IList resultList) { - foreach (HilightEntry entry in hilightEntryList) + foreach (HighlightEntry entry in hilightEntryList) { if (entry.IsWordMatch) { @@ -1404,13 +1404,13 @@ private void GetHighlightEntryMatches(ITextValue line, IList hilig } } - private void GetHilightActions(IList matchingList, out bool noLed, out bool stopTail, + private void GetHilightActions(IList matchingList, out bool noLed, out bool stopTail, out bool setBookmark, out string bookmarkComment) { noLed = stopTail = setBookmark = false; bookmarkComment = string.Empty; - foreach (HilightEntry entry in matchingList) + foreach (HighlightEntry entry in matchingList) { if (entry.IsLedSwitch) { @@ -1797,7 +1797,7 @@ private void SelectPrevHighlightLine() ILogLine line = _logFileReader.GetLogLine(lineNum); if (line != null) { - HilightEntry entry = FindHilightEntry(line); + HighlightEntry entry = FindHilightEntry(line); if (entry != null) { SelectLine(lineNum, false, true); @@ -1816,7 +1816,7 @@ private void SelectNextHighlightLine() ILogLine line = _logFileReader.GetLogLine(lineNum); if (line != null) { - HilightEntry entry = FindHilightEntry(line); + HighlightEntry entry = FindHilightEntry(line); if (entry != null) { SelectLine(lineNum, false, true); @@ -3595,7 +3595,7 @@ private void SetBookmarksForSelectedFilterLines() private void SetDefaultHighlightGroup() { - HilightGroup group = _parentLogTabWin.FindHighlightGroupByFileMask(FileName); + HighlightGroup group = _parentLogTabWin.FindHighlightGroupByFileMask(FileName); if (group != null) { SetCurrentHighlightGroup(group.GroupName); @@ -3676,7 +3676,7 @@ private void OnSyncModeChanged() private void AddSearchHitHighlightEntry(SearchParams para) { - HilightEntry he = new() + HighlightEntry he = new() { SearchText = para.searchText, ForegroundColor = Color.Red, @@ -3704,8 +3704,8 @@ private void RemoveAllSearchHighlightEntries() { lock (_tempHighlightEntryListLock) { - List newList = []; - foreach (HilightEntry he in _tempHighlightEntryList) + List newList = []; + foreach (HighlightEntry he in _tempHighlightEntryList) { if (!he.IsSearchHit) { diff --git a/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs b/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs index 116eb9e5..f0f90eb2 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs @@ -412,7 +412,7 @@ public void CellPainting(BufferedDataGridView gridView, int rowIndex, DataGridVi if (line != null) { - HilightEntry entry = FindFirstNoWordMatchHilightEntry(line); + HighlightEntry entry = FindFirstNoWordMatchHilightEntry(line); e.Graphics.SetClip(e.CellBounds); if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) @@ -511,12 +511,12 @@ public void OnDataGridView_CellPainting(object sender, DataGridViewCellPaintingE /// /// /// - public HilightEntry FindHighlightEntry(ITextValue line, bool noWordMatches) + public HighlightEntry FindHighlightEntry(ITextValue line, bool noWordMatches) { // first check the temp entries lock (_tempHighlightEntryListLock) { - foreach (HilightEntry entry in _tempHighlightEntryList) + foreach (HighlightEntry entry in _tempHighlightEntryList) { if (noWordMatches && entry.IsWordMatch) { @@ -531,7 +531,7 @@ public HilightEntry FindHighlightEntry(ITextValue line, bool noWordMatches) lock (_currentHighlightGroupLock) { - foreach (HilightEntry entry in _currentHighlightGroup.HilightEntryList) + foreach (HighlightEntry entry in _currentHighlightGroup.HighlightEntryList) { if (noWordMatches && entry.IsWordMatch) { @@ -553,7 +553,7 @@ public IList FindHighlightMatches(ITextValue column) { lock (_currentHighlightGroupLock) { - GetHighlightEntryMatches(column, _currentHighlightGroup.HilightEntryList, resultList); + GetHighlightEntryMatches(column, _currentHighlightGroup.HighlightEntryList, resultList); } lock (_tempHighlightEntryList) { @@ -1754,13 +1754,13 @@ public void SetCurrentHighlightGroup(string groupName) _currentHighlightGroup = _parentLogTabWin.FindHighlightGroup(groupName); if (_currentHighlightGroup == null) { - if (_parentLogTabWin.HilightGroupList.Count > 0) + if (_parentLogTabWin.HighlightGroupList.Count > 0) { - _currentHighlightGroup = _parentLogTabWin.HilightGroupList[0]; + _currentHighlightGroup = _parentLogTabWin.HighlightGroupList[0]; } else { - _currentHighlightGroup = new HilightGroup(); + _currentHighlightGroup = new HighlightGroup(); } } _guiStateArgs.HighlightGroupName = _currentHighlightGroup.GroupName; diff --git a/src/LogExpert/Dialogs/HighlightDialog.cs b/src/LogExpert/Dialogs/HighlightDialog.cs index bdb790c0..3aabbaa5 100644 --- a/src/LogExpert/Dialogs/HighlightDialog.cs +++ b/src/LogExpert/Dialogs/HighlightDialog.cs @@ -25,8 +25,8 @@ public partial class HighlightDialog : Form private readonly Image _applyButtonImage; private string _bookmarkComment; private ActionEntry _currentActionEntry = new(); - private HilightGroup _currentGroup; - private List _highlightGroupList; + private HighlightGroup _currentGroup; + private List _highlightGroupList; #endregion @@ -48,7 +48,7 @@ public HighlightDialog() #region Properties / Indexers - public List HighlightGroupList + public List HighlightGroupList { get => _highlightGroupList; set @@ -57,7 +57,7 @@ public List HighlightGroupList foreach (var group in value) { - _highlightGroupList.Add((HilightGroup)group.Clone()); + _highlightGroupList.Add((HighlightGroup)group.Clone()); } } } @@ -98,7 +98,7 @@ private void OnBtnCopyGroupClick(object sender, EventArgs e) { if (comboBoxGroups.SelectedIndex >= 0 && comboBoxGroups.SelectedIndex < HighlightGroupList.Count) { - HilightGroup newGroup = (HilightGroup)HighlightGroupList[comboBoxGroups.SelectedIndex].Clone(); + HighlightGroup newGroup = (HighlightGroup)HighlightGroupList[comboBoxGroups.SelectedIndex].Clone(); newGroup.GroupName = "Copy of " + newGroup.GroupName; HighlightGroupList.Add(newGroup); @@ -145,19 +145,19 @@ private void OnBtnDelGroupClick(object sender, EventArgs e) private void OnBtnExportGroupClick(object sender, EventArgs e) { - //SaveFileDialog dlg = new SaveFileDialog(); - //dlg.Title = @"Export Settings to file"; - //dlg.DefaultExt = "json"; - //dlg.AddExtension = true; - //dlg.Filter = @"Settings (*.json)|*.json|All files (*.*)|*.*"; - - //DialogResult result = dlg.ShowDialog(); + SaveFileDialog dlg = new() + { + Title = @"Export Settings to file", + DefaultExt = "json", + AddExtension = true, + Filter = @"Settings (*.json)|*.json|All files (*.*)|*.*" + }; - //if (result == DialogResult.OK) - //{ - // FileInfo fileInfo = new FileInfo(dlg.FileName); - // ConfigManager.Export(fileInfo); - //} + if (dlg.ShowDialog() == DialogResult.OK) + { + FileInfo fileInfo = new(dlg.FileName); + ConfigManager.Export(fileInfo); + } } private void OnBtnGroupDownClick(object sender, EventArgs e) @@ -186,7 +186,7 @@ private void OnBtnGroupUpClick(object sender, EventArgs e) private void OnBtnImportGroupClick(object sender, EventArgs e) { - ImportSettingsDialog dlg = new(); + ImportSettingsDialog dlg = new(Core.Config.ExportImportFlags.HighlightSettings); foreach (Control ctl in dlg.groupBoxImportOptions.Controls) { @@ -224,10 +224,10 @@ private void OnBtnImportGroupClick(object sender, EventArgs e) return; } - ConfigManager.Import(fileInfo, dlg.ImportFlags); + ConfigManager.ImportHighlightSettings(fileInfo, dlg.ImportFlags); Cursor.Current = Cursors.Default; - _highlightGroupList = ConfigManager.Settings.hilightGroupList; + _highlightGroupList = ConfigManager.Settings.Preferences.HighlightGroupList; FillGroupComboBox(); @@ -244,7 +244,7 @@ private void OnBtnMoveDownClick(object sender, EventArgs e) listBoxHighlight.Items.RemoveAt(index); listBoxHighlight.Items.Insert(index + 1, item); listBoxHighlight.SelectedIndex = index + 1; - _currentGroup.HilightEntryList.Reverse(index, 2); + _currentGroup.HighlightEntryList.Reverse(index, 2); } } @@ -257,7 +257,7 @@ private void OnBtnMoveUpClick(object sender, EventArgs e) listBoxHighlight.Items.RemoveAt(index); // will also clear the selection listBoxHighlight.Items.Insert(index - 1, item); listBoxHighlight.SelectedIndex = index - 1; // restore the selection - _currentGroup.HilightEntryList.Reverse(index - 1, 2); + _currentGroup.HighlightEntryList.Reverse(index - 1, 2); } } @@ -270,7 +270,7 @@ private void OnBtnNewGroupClick(object sender, EventArgs e) int i = 1; while (!uniqueName) { - uniqueName = HighlightGroupList.FindIndex(delegate (HilightGroup g) { return g.GroupName == name; }) < 0; + uniqueName = HighlightGroupList.FindIndex(delegate (HighlightGroup g) { return g.GroupName == name; }) < 0; if (!uniqueName) { @@ -278,7 +278,7 @@ private void OnBtnNewGroupClick(object sender, EventArgs e) } } - HilightGroup newGroup = new() { GroupName = name }; + HighlightGroup newGroup = new() { GroupName = name }; HighlightGroupList.Add(newGroup); FillGroupComboBox(); SelectGroup(HighlightGroupList.Count - 1); @@ -342,7 +342,7 @@ private void OnCmbBoxGroupDrawItem(object sender, DrawItemEventArgs e) e.DrawBackground(); if (e.Index >= 0) { - HilightGroup group = HighlightGroupList[e.Index]; + HighlightGroup group = HighlightGroupList[e.Index]; Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); Brush brush = new SolidBrush(SystemColors.ControlText); @@ -367,7 +367,7 @@ private void OnDeleteButtonClick(object sender, EventArgs e) if (listBoxHighlight.SelectedIndex >= 0) { int removeIndex = listBoxHighlight.SelectedIndex; - _currentGroup.HilightEntryList.RemoveAt(removeIndex); + _currentGroup.HighlightEntryList.RemoveAt(removeIndex); listBoxHighlight.Items.RemoveAt(removeIndex); // Select previous (or first if none before) @@ -408,7 +408,7 @@ private void OnHighlightListBoxDrawItem(object sender, DrawItemEventArgs e) e.DrawBackground(); if (e.Index >= 0) { - HilightEntry entry = (HilightEntry)listBoxHighlight.Items[e.Index]; + HighlightEntry entry = (HighlightEntry)listBoxHighlight.Items[e.Index]; Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); if ((e.State & DrawItemState.Selected) != DrawItemState.Selected) @@ -450,7 +450,7 @@ private void AddNewEntry() { CheckRegex(); - HilightEntry entry = new() + HighlightEntry entry = new() { SearchText = textBoxSearchString.Text, ForegroundColor = colorBoxForeground.SelectedColor, @@ -470,7 +470,7 @@ private void AddNewEntry() listBoxHighlight.Items.Add(entry); // Select the newly created item - _currentGroup.HilightEntryList.Add(entry); + _currentGroup.HighlightEntryList.Add(entry); listBoxHighlight.SelectedItem = entry; } catch (Exception ex) @@ -531,7 +531,7 @@ private void FillGroupComboBox() comboBoxGroups.Items.Clear(); - foreach (HilightGroup group in HighlightGroupList) + foreach (HighlightGroup group in HighlightGroupList) { comboBoxGroups.Items.Add(group); } @@ -544,7 +544,7 @@ private void FillHighlightListBox() listBoxHighlight.Items.Clear(); if (_currentGroup != null) { - foreach (HilightEntry entry in _currentGroup.HilightEntryList) + foreach (HighlightEntry entry in _currentGroup.HighlightEntryList) { listBoxHighlight.Items.Add(entry); } @@ -558,10 +558,10 @@ private void InitData() if (HighlightGroupList.Count == 0) { - HilightGroup highlightGroup = new() + HighlightGroup highlightGroup = new() { GroupName = def, - HilightEntryList = [] + HighlightEntryList = [] }; HighlightGroupList.Add(highlightGroup); @@ -576,7 +576,7 @@ private void InitData() groupToSelect = def; } - foreach (HilightGroup group in HighlightGroupList) + foreach (HighlightGroup group in HighlightGroupList) { if (group.GroupName.Equals(groupToSelect)) { @@ -625,7 +625,7 @@ private void SaveEntry() { CheckRegex(); - HilightEntry entry = (HilightEntry)listBoxHighlight.SelectedItem; + HighlightEntry entry = (HighlightEntry)listBoxHighlight.SelectedItem; entry.ForegroundColor = (Color)colorBoxForeground.SelectedItem; entry.BackgroundColor = (Color)colorBoxBackground.SelectedItem; @@ -675,7 +675,7 @@ private void SelectGroup(int index) private void StartEditEntry() { - HilightEntry entry = (HilightEntry)listBoxHighlight.SelectedItem; + HighlightEntry entry = (HighlightEntry)listBoxHighlight.SelectedItem; if (entry != null) { diff --git a/src/LogExpert/Dialogs/SettingsDialog.cs b/src/LogExpert/Dialogs/SettingsDialog.cs index 4ec928b9..b8c3476b 100644 --- a/src/LogExpert/Dialogs/SettingsDialog.cs +++ b/src/LogExpert/Dialogs/SettingsDialog.cs @@ -352,7 +352,7 @@ private void FillHighlightMaskList() //TODO Remove if not necessary DataGridViewTextBoxColumn textColumn = (DataGridViewTextBoxColumn)dataGridViewHighlightMask.Columns[0]; - foreach (HilightGroup group in (IList)_logTabWin.HilightGroupList) + foreach (HighlightGroup group in (IList)_logTabWin.HighlightGroupList) { comboColumn.Items.Add(group.GroupName); } @@ -363,7 +363,7 @@ private void FillHighlightMaskList() row.Cells.Add(new DataGridViewTextBoxCell()); DataGridViewComboBoxCell cell = new(); - foreach (HilightGroup group in (IList)_logTabWin.HilightGroupList) + foreach (HighlightGroup group in (IList)_logTabWin.HighlightGroupList) { cell.Items.Add(group.GroupName); } @@ -371,9 +371,9 @@ private void FillHighlightMaskList() row.Cells.Add(cell); row.Cells[0].Value = maskEntry.mask; - HilightGroup currentGroup = _logTabWin.FindHighlightGroup(maskEntry.highlightGroupName); - currentGroup ??= ((IList)_logTabWin.HilightGroupList)[0]; - currentGroup ??= new HilightGroup(); + HighlightGroup currentGroup = _logTabWin.FindHighlightGroup(maskEntry.highlightGroupName); + currentGroup ??= ((IList)_logTabWin.HighlightGroupList)[0]; + currentGroup ??= new HighlightGroup(); row.Cells[1].Value = currentGroup.GroupName; dataGridViewHighlightMask.Rows.Add(row); @@ -1006,7 +1006,7 @@ private void OnBtnExportClick(object sender, EventArgs e) /// private void OnBtnImportClick(object sender, EventArgs e) { - ImportSettingsDialog dlg = new(); + ImportSettingsDialog dlg = new(ExportImportFlags.All); if (dlg.ShowDialog() == DialogResult.OK) { diff --git a/src/LogExpert/Entities/EventArgs/CurrentHighlightGroupChangedEventArgs.cs b/src/LogExpert/Entities/EventArgs/CurrentHighlightGroupChangedEventArgs.cs index a61a90e6..f919def5 100644 --- a/src/LogExpert/Entities/EventArgs/CurrentHighlightGroupChangedEventArgs.cs +++ b/src/LogExpert/Entities/EventArgs/CurrentHighlightGroupChangedEventArgs.cs @@ -3,13 +3,13 @@ namespace LogExpert.Entities.EventArgs { - public class CurrentHighlightGroupChangedEventArgs(LogWindow logWindow, HilightGroup currentGroup) + public class CurrentHighlightGroupChangedEventArgs(LogWindow logWindow, HighlightGroup currentGroup) { #region Properties public LogWindow LogWindow { get; } = logWindow; - public HilightGroup CurrentGroup { get; } = currentGroup; + public HighlightGroup CurrentGroup { get; } = currentGroup; #endregion } diff --git a/src/Logexpert.Core/Classes/Highlight/HilightEntry.cs b/src/Logexpert.Core/Classes/Highlight/HighlightEntry.cs similarity index 96% rename from src/Logexpert.Core/Classes/Highlight/HilightEntry.cs rename to src/Logexpert.Core/Classes/Highlight/HighlightEntry.cs index cb93663a..19701967 100644 --- a/src/Logexpert.Core/Classes/Highlight/HilightEntry.cs +++ b/src/Logexpert.Core/Classes/Highlight/HighlightEntry.cs @@ -7,7 +7,7 @@ namespace LogExpert.Core.Classes.Highlight { [Serializable] [method: JsonConstructor] - public class HilightEntry() : ICloneable + public class HighlightEntry() : ICloneable { #region Fields @@ -80,7 +80,7 @@ public Regex Regex public object Clone() { - var highLightEntry = new HilightEntry + var highLightEntry = new HighlightEntry { SearchText = SearchText, ForegroundColor = ForegroundColor, diff --git a/src/Logexpert.Core/Classes/Highlight/HilightMatchEntry.cs b/src/Logexpert.Core/Classes/Highlight/HilightMatchEntry.cs index d794e3ab..21bda173 100644 --- a/src/Logexpert.Core/Classes/Highlight/HilightMatchEntry.cs +++ b/src/Logexpert.Core/Classes/Highlight/HilightMatchEntry.cs @@ -7,7 +7,7 @@ public class HilightMatchEntry { #region Properties - public HilightEntry HilightEntry { get; set; } + public HighlightEntry HilightEntry { get; set; } public int StartPos { get; set; } diff --git a/src/Logexpert.Core/Config/ExportImportFlags.cs b/src/Logexpert.Core/Config/ExportImportFlags.cs index ab3aa66e..7eea55a7 100644 --- a/src/Logexpert.Core/Config/ExportImportFlags.cs +++ b/src/Logexpert.Core/Config/ExportImportFlags.cs @@ -1,5 +1,3 @@ -using System; - namespace LogExpert.Core.Config { [Flags] diff --git a/src/Logexpert.Core/Config/Preferences.cs b/src/Logexpert.Core/Config/Preferences.cs index 62529eac..a757b1bb 100644 --- a/src/Logexpert.Core/Config/Preferences.cs +++ b/src/Logexpert.Core/Config/Preferences.cs @@ -34,6 +34,8 @@ public class Preferences public List highlightMaskList = []; + public List HighlightGroupList { get; set; } = []; + public bool isAutoHideFilterList = false; public bool isFilterOnLoad; diff --git a/src/Logexpert.Core/Config/Settings.cs b/src/Logexpert.Core/Config/Settings.cs index fda64749..275bd2c1 100644 --- a/src/Logexpert.Core/Config/Settings.cs +++ b/src/Logexpert.Core/Config/Settings.cs @@ -1,9 +1,6 @@ using LogExpert.Core.Classes.Filter; -using LogExpert.Core.Classes.Highlight; using LogExpert.Core.Entities; -using System; -using System.Collections.Generic; using System.Drawing; namespace LogExpert.Core.Config @@ -35,10 +32,6 @@ public class Settings public bool hideLineColumn; - public List hilightEntryList = []; // legacy. is automatically converted to highlight groups on settings load - - public List hilightGroupList = []; // should be in Preferences but is here for mistake. Maybe I migrate it some day. - public bool isMaximized; public string lastDirectory; diff --git a/src/Logexpert.Core/Entities/HilightGroup.cs b/src/Logexpert.Core/Entities/HighlightGroup.cs similarity index 56% rename from src/Logexpert.Core/Entities/HilightGroup.cs rename to src/Logexpert.Core/Entities/HighlightGroup.cs index e8ef8a9e..1ce4471b 100644 --- a/src/Logexpert.Core/Entities/HilightGroup.cs +++ b/src/Logexpert.Core/Entities/HighlightGroup.cs @@ -3,24 +3,24 @@ namespace LogExpert.Core.Entities { [Serializable] - public class HilightGroup : ICloneable + public class HighlightGroup : ICloneable { #region Properties public string GroupName { get; set; } = string.Empty; - public List HilightEntryList { get; set; } = []; + public List HighlightEntryList { get; set; } = []; public object Clone() { - HilightGroup clone = new() + HighlightGroup clone = new() { GroupName = GroupName }; - foreach (HilightEntry entry in HilightEntryList) + foreach (HighlightEntry entry in HighlightEntryList) { - clone.HilightEntryList.Add((HilightEntry)entry.Clone()); + clone.HighlightEntryList.Add((HighlightEntry)entry.Clone()); } return clone; diff --git a/src/Logexpert.Core/Interface/ILogPaintContext.cs b/src/Logexpert.Core/Interface/ILogPaintContext.cs index 6d5eb456..e123d5f3 100644 --- a/src/Logexpert.Core/Interface/ILogPaintContext.cs +++ b/src/Logexpert.Core/Interface/ILogPaintContext.cs @@ -27,7 +27,7 @@ public interface ILogPaintContext Bookmark GetBookmarkForLine(int lineNum); - HilightEntry FindHighlightEntry(ITextValue line, bool noWordMatches); + HighlightEntry FindHighlightEntry(ITextValue line, bool noWordMatches); IList FindHighlightMatches(ITextValue line); diff --git a/src/Logexpert.UI/Dialogs/ImportSettingsDialog.cs b/src/Logexpert.UI/Dialogs/ImportSettingsDialog.cs index fa679014..cfd97e0f 100644 --- a/src/Logexpert.UI/Dialogs/ImportSettingsDialog.cs +++ b/src/Logexpert.UI/Dialogs/ImportSettingsDialog.cs @@ -7,19 +7,33 @@ namespace LogExpert.UI.Dialogs [SupportedOSPlatform("windows")] public partial class ImportSettingsDialog : Form { - #region Fields - - #endregion - #region cTor - public ImportSettingsDialog() + public ImportSettingsDialog(ExportImportFlags importFlags) { InitializeComponent(); - + SuspendLayout(); AutoScaleDimensions = new SizeF(96F, 96F); AutoScaleMode = AutoScaleMode.Dpi; + ImportFlags = importFlags; + FileName = string.Empty; + + if (ImportFlags == ExportImportFlags.HighlightSettings) + { + checkBoxHighlightSettings.Checked = true; + checkBoxHighlightSettings.Enabled = false; + checkBoxHighlightFileMasks.Checked = false; + checkBoxHighlightFileMasks.Enabled = false; + checkBoxColumnizerFileMasks.Checked = false; + checkBoxColumnizerFileMasks.Enabled = false; + checkBoxExternalTools.Checked = false; + checkBoxExternalTools.Enabled = false; + checkBoxOther.Checked = false; + checkBoxOther.Enabled = false; + } + + ResumeLayout(); } #endregion @@ -56,19 +70,28 @@ private void OnFileButtonClick(object sender, EventArgs e) private void OnOkButtonClick(object sender, EventArgs e) { - ImportFlags = ExportImportFlags.None; FileName = textBoxFileName.Text; - foreach (Control ctl in groupBoxImportOptions.Controls) + if (ImportFlags != ExportImportFlags.HighlightSettings) { - if (ctl.Tag != null) + foreach (Control ctl in groupBoxImportOptions.Controls) { - if (((CheckBox)ctl).Checked) + if (ctl.Tag != null) { - ImportFlags |= (ExportImportFlags)long.Parse(ctl.Tag as string ?? string.Empty); + if (((CheckBox)ctl).Checked) + { + ImportFlags |= (ExportImportFlags)long.Parse(ctl.Tag as string ?? string.Empty); + } } } } + else + { + if (checkBoxKeepExistingSettings.Checked) + { + ImportFlags |= ExportImportFlags.KeepExisting; + } + } } #endregion From 3084f8e72d2dcbbe316406986485eb8b7c150775 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Fri, 16 May 2025 19:08:26 +0200 Subject: [PATCH 018/142] 373-v1120---importing-highlighting-config-is-broken: export added --- src/LogExpert/Config/ConfigManager.cs | 26 +++++++++++++++++++++++- src/LogExpert/Dialogs/HighlightDialog.cs | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/LogExpert/Config/ConfigManager.cs b/src/LogExpert/Config/ConfigManager.cs index 2c3b3e6e..cc775e0c 100644 --- a/src/LogExpert/Config/ConfigManager.cs +++ b/src/LogExpert/Config/ConfigManager.cs @@ -89,6 +89,11 @@ public static void Export(FileInfo fileInfo) Instance.Save(fileInfo, Settings); } + public static void Export(FileInfo fileInfo, SettingsFlags flags) + { + Instance.Save(fileInfo, Settings, flags); + } + public static void Import(FileInfo fileInfo, ExportImportFlags flags) { Instance._settings = Instance.Import(Instance._settings, fileInfo, flags); @@ -288,7 +293,19 @@ private void Save(FileInfo fileInfo, Settings settings) SaveAsJSON(fileInfo, settings); } - private void SaveAsJSON(FileInfo fileInfo, Settings settings) + private void Save(FileInfo fileInfo, Settings settings, SettingsFlags flags) + { + switch (flags) + { + case SettingsFlags.HighlightSettings: + SaveHighlightgroupsAsJSON(fileInfo, settings.Preferences.HighlightGroupList); + break; + } + + OnConfigChanged(flags); + } + + private static void SaveAsJSON(FileInfo fileInfo, Settings settings) { settings.versionBuild = Assembly.GetExecutingAssembly().GetName().Version.Build; @@ -297,6 +314,13 @@ private void SaveAsJSON(FileInfo fileInfo, Settings settings) serializer.Serialize(sw, settings); } + private static void SaveHighlightgroupsAsJSON(FileInfo fileInfo, List groups) + { + using StreamWriter sw = new(fileInfo.Create()); + JsonSerializer serializer = new(); + serializer.Serialize(sw, groups); + } + private List Import(List currentGroups, FileInfo fileInfo, ExportImportFlags flags) { List newGroups; diff --git a/src/LogExpert/Dialogs/HighlightDialog.cs b/src/LogExpert/Dialogs/HighlightDialog.cs index 3aabbaa5..3be35f39 100644 --- a/src/LogExpert/Dialogs/HighlightDialog.cs +++ b/src/LogExpert/Dialogs/HighlightDialog.cs @@ -156,7 +156,7 @@ private void OnBtnExportGroupClick(object sender, EventArgs e) if (dlg.ShowDialog() == DialogResult.OK) { FileInfo fileInfo = new(dlg.FileName); - ConfigManager.Export(fileInfo); + ConfigManager.Export(fileInfo, Core.Config.SettingsFlags.HighlightSettings); } } From 90da07a27dcd30028e44b3f7ae5d62f3f8807264 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Tue, 20 May 2025 09:38:58 +0200 Subject: [PATCH 019/142] small optimizations --- src/ColumnizerLib/IContextMenuEntry.cs | 12 +- src/ColumnizerLib/ILogExpertCallback.cs | 10 +- src/ColumnizerLib/ILogFileInfo.cs | 2 +- .../ILogLineColumnizerCallback.cs | 6 +- src/DefaultPlugins/Eminus.cs | 52 +++--- src/LogExpert/Classes/Filter/Filter.cs | 8 +- src/LogExpert/Classes/Filter/FilterStarter.cs | 2 +- .../ColumnizerCallback.cs | 12 +- .../LogExpertCallback.cs | 17 +- src/LogExpert/Classes/Log/LogfileReader.cs | 45 ++++++ src/LogExpert/Classes/PaintHelper.cs | 4 +- src/LogExpert/Classes/RangeFinder.cs | 20 +-- .../LogTabWindow/LogTabWindowEventHandlers.cs | 2 +- .../LogTabWindow/LogTabWindowPublic.cs | 14 +- src/LogExpert/Controls/LogWindow/LogWindow.cs | 6 +- .../LogWindow/LogWindowEventHandlers.cs | 71 ++++---- .../Controls/LogWindow/LogWindowPrivate.cs | 151 +++++++++--------- .../Controls/LogWindow/LogWindowsPublic.cs | 69 ++++---- .../Classes/Filter/FilterParams.cs | 146 +++++++++-------- .../Log/PositionAwareStreamReaderBase.cs | 3 + src/Logexpert.Core/Classes/Util.cs | 67 ++++---- src/Logexpert.Core/Entities/Bookmark.cs | 6 +- .../Entities/BookmarkCollection.cs | 3 +- .../Entities/BookmarkOverlay.cs | 4 - src/Logexpert.Core/Entities/DebugOptions.cs | 6 +- .../Entities/DefaultLogfileColumnizer.cs | 13 +- .../Entities/EncodingOptions.cs | 4 - .../Entities/FileViewContext.cs | 20 +-- .../Entities/MultifileOptions.cs | 23 +-- src/Logexpert.Core/Entities/ReloadMemento.cs | 7 +- src/Logexpert.Core/Entities/RowHeightEntry.cs | 4 - src/Logexpert.Core/Entities/SearchParams.cs | 24 +-- .../Dialogs/FilterColumnChooser.cs | 22 +-- src/Logexpert.UI/Dialogs/SearchDialog.cs | 28 ++-- src/PluginRegistry/FileSystem/LogFileInfo.cs | 6 +- 35 files changed, 461 insertions(+), 428 deletions(-) diff --git a/src/ColumnizerLib/IContextMenuEntry.cs b/src/ColumnizerLib/IContextMenuEntry.cs index 80fd9443..c23f78c7 100644 --- a/src/ColumnizerLib/IContextMenuEntry.cs +++ b/src/ColumnizerLib/IContextMenuEntry.cs @@ -4,7 +4,7 @@ namespace LogExpert { /// - /// Implement this interface to add a menu entry to the context menu of LogExpert. + /// Implement this interface to add a menu entry to the context menu of LogExpert. /// /// /// @@ -17,12 +17,12 @@ public interface IContextMenuEntry #region Public methods /// - /// This function is called from LogExpert if the context menu is about to be displayed. + /// This function is called from LogExpert if the context menu is about to be displayed. /// Your implementation can control whether LogExpert will show a menu entry by returning /// an appropriate value.

///
/// A list containing all selected line numbers. - /// The currently selected Columnizer. You can use it to split log lines, + /// The currently selected Columnizer. You can use it to split log lines, /// if necessary. /// The callback interface implemented by LogExpert. You can use the functions /// for retrieving log lines or pass it along to functions of the Columnizer if needed. @@ -37,18 +37,22 @@ public interface IContextMenuEntry /// string GetMenuText(IList lines, ILogLineColumnizer columnizer, ILogExpertCallback callback); + string GetMenuText(int linesCount, ILogLineColumnizer columnizer, ILogLine line); + /// /// This function is called from LogExpert if the menu entry is choosen by the user.

/// Note that this function is called from the GUI thread. So try to avoid time consuming operations. ///
/// A list containing all selected line numbers. - /// The currently selected Columnizer. You can use it to split log lines, + /// The currently selected Columnizer. You can use it to split log lines, /// if necessary. /// The callback interface implemented by LogExpert. You can use the functions /// for retrieving log lines or pass it along to functions of the Columnizer if needed. void MenuSelected(IList lines, ILogLineColumnizer columnizer, ILogExpertCallback callback); + void MenuSelected(int linesCount, ILogLineColumnizer columnizer, ILogLine line); + #endregion } } \ No newline at end of file diff --git a/src/ColumnizerLib/ILogExpertCallback.cs b/src/ColumnizerLib/ILogExpertCallback.cs index aae48283..9f1a96d9 100644 --- a/src/ColumnizerLib/ILogExpertCallback.cs +++ b/src/ColumnizerLib/ILogExpertCallback.cs @@ -17,7 +17,7 @@ public interface ILogExpertCallback : ILogLineColumnizerCallback /// Path of the file to be loaded. /// Title shown on the tab. /// - /// The file tab is internally handled like the temp file tabs which LogExpert uses for + /// The file tab is internally handled like the temp file tabs which LogExpert uses for /// FilterTabs or clipboard copy tabs. /// This has some implications: ///
    @@ -29,24 +29,23 @@ public interface ILogExpertCallback : ILogLineColumnizerCallback /// void AddTempFileTab(string fileName, string title); - /// /// With this function you can create a new tab and add a bunch of text lines to it. /// - /// A list with LineEntry items containing text and an + /// A list with LineEntry items containing text and an /// optional reference to the original file location. /// The title for the new tab. /// /// /// The lines are given by a list of . If you set the lineNumber field - /// in each LineEntry to a lineNumber of the original logfile (the logfile for which the context + /// in each LineEntry to a lineNumber of the original logfile (the logfile for which the context /// menu is called for), you can create a 'link' from the line of your 'target output' to a line /// in the 'source tab'. /// /// /// The user can then navigate from the line in the new tab to the referenced /// line in the original file (by using "locate in original file" from the context menu). - /// This is especially useful for plugins that generate output lines which are directly associated + /// This is especially useful for plugins that generate output lines which are directly associated /// to the selected input lines. /// /// @@ -56,7 +55,6 @@ public interface ILogExpertCallback : ILogLineColumnizerCallback /// void AddPipedTab(IList lineEntryList, string title); - /// /// Returns the title of the current tab (the tab for which the context menu plugin was called for). /// diff --git a/src/ColumnizerLib/ILogFileInfo.cs b/src/ColumnizerLib/ILogFileInfo.cs index 39392fb0..8a028472 100644 --- a/src/ColumnizerLib/ILogFileInfo.cs +++ b/src/ColumnizerLib/ILogFileInfo.cs @@ -1,5 +1,5 @@ -using System.IO; using System; +using System.IO; namespace LogExpert { diff --git a/src/ColumnizerLib/ILogLineColumnizerCallback.cs b/src/ColumnizerLib/ILogLineColumnizerCallback.cs index 1b72fb2b..270b9b40 100644 --- a/src/ColumnizerLib/ILogLineColumnizerCallback.cs +++ b/src/ColumnizerLib/ILogLineColumnizerCallback.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace LogExpert +namespace LogExpert { /// ///This is a callback interface. Some of the ILogLineColumnizer functions diff --git a/src/DefaultPlugins/Eminus.cs b/src/DefaultPlugins/Eminus.cs index e59f8586..27110d08 100644 --- a/src/DefaultPlugins/Eminus.cs +++ b/src/DefaultPlugins/Eminus.cs @@ -17,8 +17,10 @@ public class Eminus : IContextMenuEntry, ILogExpertPluginConfigurator #region Fields private const string CFG_FILE_NAME = "eminus.json"; - private const string dot = "."; - private const string doubleDot = ":"; + private const string DOT = "."; + private const string DOUBLE_DOT = ":"; + private const string DISABLED = "_"; + private EminusConfig _config = new(); private EminusConfigDlg dlg; private EminusConfig tmpConfig = new(); @@ -27,7 +29,7 @@ public class Eminus : IContextMenuEntry, ILogExpertPluginConfigurator #region Properties - public string Text => "eminus"; + public static string Text => "eminus"; #endregion @@ -35,40 +37,42 @@ public class Eminus : IContextMenuEntry, ILogExpertPluginConfigurator private XmlDocument BuildParam(ILogLine line) { - string temp = line.FullLine; + string fullLogLine = line.FullLine; // no Java stacktrace but some special logging of our applications at work: - if (temp.Contains("Exception of type", StringComparison.CurrentCulture) || temp.Contains("Nested:", StringComparison.CurrentCulture)) + if (fullLogLine.Contains("Exception of type", StringComparison.CurrentCulture) || + fullLogLine.Contains("Nested:", StringComparison.CurrentCulture)) { - int pos = temp.IndexOf("created in "); + int pos = fullLogLine.IndexOf("created in "); + if (pos == -1) { return null; } pos += "created in ".Length; - int endPos = temp.IndexOf(dot, pos); + int endPos = fullLogLine.IndexOf(DOT, pos); if (endPos == -1) { return null; } - string className = temp[pos..endPos]; - pos = temp.IndexOf(doubleDot, pos); + string className = fullLogLine[pos..endPos]; + pos = fullLogLine.IndexOf(DOUBLE_DOT, pos); if (pos == -1) { return null; } - string lineNum = temp[(pos + 1)..]; + string lineNum = fullLogLine[(pos + 1)..]; XmlDocument doc = BuildXmlDocument(className, lineNum); return doc; } - if (temp.Contains("at ", StringComparison.CurrentCulture)) + if (fullLogLine.Contains("at ", StringComparison.CurrentCulture)) { - string str = temp.Trim(); + string str = fullLogLine.Trim(); string className = null; string lineNum = null; int pos = str.IndexOf("at ") + 3; @@ -83,7 +87,7 @@ private XmlDocument BuildParam(ILogLine line) } else { - pos = str.LastIndexOf('.', idx); + pos = str.LastIndexOf(DOT, idx); if (pos == -1) { return null; @@ -91,7 +95,7 @@ private XmlDocument BuildParam(ILogLine line) className = str[..pos]; } - idx = str.LastIndexOf(':'); + idx = str.LastIndexOf(DOUBLE_DOT); if (idx == -1) { @@ -150,24 +154,36 @@ private XmlDocument BuildXmlDocument(string className, string lineNum) public string GetMenuText(IList logLines, ILogLineColumnizer columnizer, ILogExpertCallback callback) { - if (logLines.Count == 1 && BuildParam(callback.GetLogLine(logLines[0])) != null) + //not used + return string.Empty; + } + + public string GetMenuText(int logLinesCount, ILogLineColumnizer columnizer, ILogLine logline) + { + if (logLinesCount == 1 && BuildParam(logline) != null) { return "Load class in Eclipse"; } else { - return "_Load class in Eclipse"; + return $"{DISABLED}Load class in Eclipse"; } } public void MenuSelected(IList logLines, ILogLineColumnizer columnizer, ILogExpertCallback callback) { - if (logLines.Count != 1) + //Not used + } + + public void MenuSelected(int logLinesCount, ILogLineColumnizer columnizer, ILogLine logline) + { + if (logLinesCount != 1) { return; } - XmlDocument doc = BuildParam(callback.GetLogLine(logLines[0])); + XmlDocument doc = BuildParam(logline); + if (doc == null) { MessageBox.Show("Cannot parse Java stack trace line", "LogExpert"); diff --git a/src/LogExpert/Classes/Filter/Filter.cs b/src/LogExpert/Classes/Filter/Filter.cs index 3db9ec01..12581e06 100644 --- a/src/LogExpert/Classes/Filter/Filter.cs +++ b/src/LogExpert/Classes/Filter/Filter.cs @@ -70,7 +70,7 @@ private int DoFilter(FilterParams filterParams, int startLine, int maxCount, Lis try { filterParams.Reset(); - while ((count++ < maxCount || filterParams.isInRange) && !ShouldCancel) + while ((count++ < maxCount || filterParams.IsInRange) && !ShouldCancel) { if (lineNum >= _callback.GetLineCount()) { @@ -140,14 +140,14 @@ private IList GetAdditionalFilterResults(FilterParams filterParams, int lin { IList resultList = []; - if (filterParams.spreadBefore == 0 && filterParams.spreadBehind == 0) + if (filterParams.SpreadBefore == 0 && filterParams.SpreadBehind == 0) { resultList.Add(lineNum); return resultList; } // back spread - for (int i = filterParams.spreadBefore; i > 0; --i) + for (int i = filterParams.SpreadBefore; i > 0; --i) { if (lineNum - i > 0) { @@ -163,7 +163,7 @@ private IList GetAdditionalFilterResults(FilterParams filterParams, int lin resultList.Add(lineNum); } // after spread - for (int i = 1; i <= filterParams.spreadBehind; ++i) + for (int i = 1; i <= filterParams.SpreadBehind; ++i) { if (lineNum + i < _callback.GetLineCount()) { diff --git a/src/LogExpert/Classes/Filter/FilterStarter.cs b/src/LogExpert/Classes/Filter/FilterStarter.cs index 71efb9ff..36b5ead8 100644 --- a/src/LogExpert/Classes/Filter/FilterStarter.cs +++ b/src/LogExpert/Classes/Filter/FilterStarter.cs @@ -149,7 +149,7 @@ private Filter DoWork(FilterParams filterParams, int startLine, int maxCount, Pr _logger.Info("Started Filter worker [{0}] for line {1}", Environment.CurrentManagedThreadId, startLine); // Give every thread own copies of ColumnizerCallback and FilterParams, because the state of the objects changes while filtering - FilterParams threadFilterParams = filterParams.CreateCopy2(); + FilterParams threadFilterParams = filterParams.Copy(); ColumnizerCallback threadColumnizerCallback = _callback.CreateCopy(); Filter filter = new(threadColumnizerCallback); diff --git a/src/LogExpert/Classes/ILogLineColumnizerCallback/ColumnizerCallback.cs b/src/LogExpert/Classes/ILogLineColumnizerCallback/ColumnizerCallback.cs index 9a1504a3..788a17a0 100644 --- a/src/LogExpert/Classes/ILogLineColumnizerCallback/ColumnizerCallback.cs +++ b/src/LogExpert/Classes/ILogLineColumnizerCallback/ColumnizerCallback.cs @@ -8,7 +8,7 @@ public class ColumnizerCallback : LogExpert.ILogLineColumnizerCallback, IAutoLog { #region Fields - protected LogWindow logWindow; + protected LogWindow _logWindow; #endregion @@ -16,12 +16,12 @@ public class ColumnizerCallback : LogExpert.ILogLineColumnizerCallback, IAutoLog public ColumnizerCallback(LogWindow logWindow) { - this.logWindow = logWindow; + _logWindow = logWindow; } private ColumnizerCallback(ColumnizerCallback original) { - logWindow = original.logWindow; + _logWindow = original._logWindow; LineNum = original.LineNum; } @@ -47,12 +47,12 @@ public int GetLineNum() public string GetFileName() { - return logWindow.GetCurrentFileName(LineNum); + return _logWindow.GetCurrentFileName(LineNum); } public ILogLine GetLogLine(int lineNum) { - return logWindow.GetLine(lineNum); + return _logWindow.GetLine(lineNum); } public IList GetRegisteredColumnizers() @@ -62,7 +62,7 @@ public IList GetRegisteredColumnizers() public int GetLineCount() { - return logWindow._logFileReader.LineCount; + return _logWindow._logFileReader.LineCount; } #endregion diff --git a/src/LogExpert/Classes/ILogLineColumnizerCallback/LogExpertCallback.cs b/src/LogExpert/Classes/ILogLineColumnizerCallback/LogExpertCallback.cs index 914f3c32..8fd463cc 100644 --- a/src/LogExpert/Classes/ILogLineColumnizerCallback/LogExpertCallback.cs +++ b/src/LogExpert/Classes/ILogLineColumnizerCallback/LogExpertCallback.cs @@ -4,32 +4,23 @@ namespace LogExpert.Classes.ILogLineColumnizerCallback { - internal class LogExpertCallback : ColumnizerCallback, ILogExpertCallback + internal class LogExpertCallback(LogWindow logWindow) : ColumnizerCallback(logWindow), ILogExpertCallback { - #region cTor - - public LogExpertCallback(LogWindow logWindow) - : base(logWindow) - { - } - - #endregion - #region Public methods public void AddTempFileTab(string fileName, string title) { - logWindow.AddTempFileTab(fileName, title); + _logWindow.AddTempFileTab(fileName, title); } public void AddPipedTab(IList lineEntryList, string title) { - logWindow.WritePipeTab(lineEntryList, title); + _logWindow.WritePipeTab(lineEntryList, title); } public string GetTabTitle() { - return logWindow.Text; + return _logWindow.Text; } #endregion diff --git a/src/LogExpert/Classes/Log/LogfileReader.cs b/src/LogExpert/Classes/Log/LogfileReader.cs index 3dbde9c0..b0cc13dd 100644 --- a/src/LogExpert/Classes/Log/LogfileReader.cs +++ b/src/LogExpert/Classes/Log/LogfileReader.cs @@ -53,6 +53,7 @@ public class LogfileReader : IAutoLogLineColumnizerCallback private ReaderWriterLock _lruCacheDictLock; + private readonly FileSystemWatcher _fileWatcher; private bool _shouldStop; private ILogFileInfo _watchedILogFileInfo; @@ -77,6 +78,22 @@ public LogfileReader(string fileName, EncodingOptions encodingOptions, bool mult _logLineFx = GetLogLineInternal; InitLruBuffers(); + + + _fileWatcher = new FileSystemWatcher + { + Path = Path.GetDirectoryName(fileName), + Filter = Path.GetFileName(fileName), + NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size + }; + + _fileWatcher.Changed += OnChanged; + _fileWatcher.Deleted += OnDeleted; + _fileWatcher.Renamed += OnRenamed; + _fileWatcher.Error += OnError; + + _fileWatcher.EnableRaisingEvents = true; + if (multiFile) { ILogFileInfo info = GetLogFileInfo(fileName); @@ -99,6 +116,34 @@ public LogfileReader(string fileName, EncodingOptions encodingOptions, bool mult StartGCThread(); } + private void OnChanged(object sender, FileSystemEventArgs e) + { + if (e.ChangeType != WatcherChangeTypes.Changed) + { + return; + } + } + + private void OnCreated(object sender, FileSystemEventArgs e) + { + string value = $"Created: {e.FullPath}"; + } + + private void OnDeleted(object sender, FileSystemEventArgs e) + { + _isDeleted = true; + + } + + private void OnRenamed(object sender, RenamedEventArgs e) + { + } + + private void OnError(object sender, ErrorEventArgs e) + { + + } + public LogfileReader(string[] fileNames, EncodingOptions encodingOptions, int bufferCount, int linesPerBuffer, MultiFileOptions multiFileOptions) { if (fileNames == null || fileNames.Length < 1) diff --git a/src/LogExpert/Classes/PaintHelper.cs b/src/LogExpert/Classes/PaintHelper.cs index 37eb718c..84297564 100644 --- a/src/LogExpert/Classes/PaintHelper.cs +++ b/src/LogExpert/Classes/PaintHelper.cs @@ -65,7 +65,7 @@ public static void CellPainting(ILogPaintContext logPaintCtx, BufferedDataGridVi else { Color bgColor = ColorMode.DockBackgroundColor; - if (!DebugOptions.disableWordHighlight) + if (!DebugOptions.DisableWordHighlight) { if (entry != null) { @@ -83,7 +83,7 @@ public static void CellPainting(ILogPaintContext logPaintCtx, BufferedDataGridVi e.PaintBackground(e.ClipBounds, false); } - if (DebugOptions.disableWordHighlight) + if (DebugOptions.DisableWordHighlight) { e.PaintContent(e.CellBounds); } diff --git a/src/LogExpert/Classes/RangeFinder.cs b/src/LogExpert/Classes/RangeFinder.cs index 30ee6590..b8807746 100644 --- a/src/LogExpert/Classes/RangeFinder.cs +++ b/src/LogExpert/Classes/RangeFinder.cs @@ -25,7 +25,7 @@ public class RangeFinder public RangeFinder(FilterParams filterParams, ColumnizerCallback callback) { - _filterParams = filterParams.CreateCopy2(); + _filterParams = filterParams.Copy(); _callback = callback; } @@ -35,26 +35,26 @@ public RangeFinder(FilterParams filterParams, ColumnizerCallback callback) public Range FindRange(int startLine) { - _logger.Info($"Starting range search for {_filterParams.searchText} ... {_filterParams.rangeSearchText}"); - if (_filterParams.rangeSearchText == null || _filterParams.rangeSearchText.Trim().Length == 0) + _logger.Info($"Starting range search for {_filterParams.SearchText} ... {_filterParams.RangeSearchText}"); + if (_filterParams.RangeSearchText == null || _filterParams.RangeSearchText.Trim().Length == 0) { _logger.Info("Range search text not set. Cancelling range search."); return null; } - if (_filterParams.searchText == null || _filterParams.searchText.Trim().Length == 0) + if (_filterParams.SearchText == null || _filterParams.SearchText.Trim().Length == 0) { _logger.Info("Search text not set. Cancelling range search."); return null; } - _filterParams.isRangeSearch = false; - _filterParams.isInRange = false; + _filterParams.IsRangeSearch = false; + _filterParams.IsInRange = false; int lineCount = _callback.GetLineCount(); int lineNum = startLine; bool foundStartLine = false; Range range = new(); - FilterParams tmpParam = _filterParams.CreateCopy2(); - tmpParam.searchText = _filterParams.rangeSearchText; + FilterParams tmpParam = _filterParams.Copy(); + tmpParam.SearchText = _filterParams.RangeSearchText; // search backward for starting keyword var line = _callback.GetLogLine(lineNum); @@ -81,8 +81,8 @@ public Range FindRange(int startLine) return null; } range.StartLine = lineNum; - _filterParams.isRangeSearch = true; - _filterParams.isInRange = true; + _filterParams.IsRangeSearch = true; + _filterParams.IsInRange = true; lineNum++; while (lineNum < lineCount) { diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs index c1bc2677..9d9822cd 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs @@ -934,7 +934,7 @@ private void OnLogLevelToolStripMenuItemDropDownOpening(object sender, EventArgs private void OnDisableWordHighlightModeToolStripMenuItemClick(object sender, EventArgs e) { - DebugOptions.disableWordHighlight = disableWordHighlightModeToolStripMenuItem.Checked; + DebugOptions.DisableWordHighlight = disableWordHighlightModeToolStripMenuItem.Checked; CurrentLogWindow?.RefreshAllGrids(); } diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindowPublic.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindowPublic.cs index c2569798..3d12b3b4 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindowPublic.cs +++ b/src/LogExpert/Controls/LogTabWindow/LogTabWindowPublic.cs @@ -31,13 +31,13 @@ public LogWindow.LogWindow AddTempFileTab(string fileName, string title) public LogWindow.LogWindow AddFilterTab(FilterPipe pipe, string title, ILogLineColumnizer preProcessColumnizer) { LogWindow.LogWindow logWin = AddFileTab(pipe.FileName, true, title, false, preProcessColumnizer); - if (pipe.FilterParams.searchText.Length > 0) + if (pipe.FilterParams.SearchText.Length > 0) { ToolTip tip = new(components); tip.SetToolTip(logWin, - "Filter: \"" + pipe.FilterParams.searchText + "\"" + - (pipe.FilterParams.isInvert ? " (Invert match)" : "") + - (pipe.FilterParams.columnRestrict ? "\nColumn restrict" : "") + "Filter: \"" + pipe.FilterParams.SearchText + "\"" + + (pipe.FilterParams.IsInvert ? " (Invert match)" : "") + + (pipe.FilterParams.ColumnRestrict ? "\nColumn restrict" : "") ); tip.AutomaticDelay = 10; tip.AutoPopDelay = 5000; @@ -156,13 +156,13 @@ public void OpenSearchDialog() SearchDialog dlg = new(); AddOwnedForm(dlg); dlg.TopMost = TopMost; - SearchParams.historyList = ConfigManager.Settings.searchHistoryList; + SearchParams.HistoryList = ConfigManager.Settings.searchHistoryList; dlg.SearchParams = SearchParams; DialogResult res = dlg.ShowDialog(); - if (res == DialogResult.OK && dlg.SearchParams != null && !string.IsNullOrWhiteSpace(dlg.SearchParams.searchText)) + if (res == DialogResult.OK && dlg.SearchParams != null && !string.IsNullOrWhiteSpace(dlg.SearchParams.SearchText)) { SearchParams = dlg.SearchParams; - SearchParams.isFindNext = false; + SearchParams.IsFindNext = false; CurrentLogWindow.StartSearch(); } } diff --git a/src/LogExpert/Controls/LogWindow/LogWindow.cs b/src/LogExpert/Controls/LogWindow/LogWindow.cs index e39393f2..f150ebbc 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindow.cs @@ -203,9 +203,9 @@ public LogWindow(LogTabWindow.LogTabWindow parent, string fileName, bool isTempF filterComboBox.DropDownHeight = filterComboBox.ItemHeight * ConfigManager.Settings.Preferences.maximumFilterEntriesDisplayed; AutoResizeFilterBox(); - filterRegexCheckBox.Checked = _filterParams.isRegex; - filterCaseSensitiveCheckBox.Checked = _filterParams.isCaseSensitive; - filterTailCheckBox.Checked = _filterParams.isFilterTail; + filterRegexCheckBox.Checked = _filterParams.IsRegex; + filterCaseSensitiveCheckBox.Checked = _filterParams.IsCaseSensitive; + filterTailCheckBox.Checked = _filterParams.IsFilterTail; splitContainerLogWindow.Panel2Collapsed = true; advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; diff --git a/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs index b73d4c49..1cf9318c 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs @@ -386,9 +386,7 @@ private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintin e.Graphics.SetClip(e.CellBounds); if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) { - Color backColor = e.CellStyle.SelectionBackColor; Brush brush; - if (gridView.Focused) { brush = new SolidBrush(e.CellStyle.SelectionBackColor); @@ -410,7 +408,7 @@ private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintin //{ // bgColor = Color.FromArgb(255, 220, 220, 220); //} - if (!DebugOptions.disableWordHighlight) + if (!DebugOptions.DisableWordHighlight) { if (entry != null) { @@ -429,7 +427,7 @@ private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintin e.PaintBackground(e.ClipBounds, false); } - if (DebugOptions.disableWordHighlight) + if (DebugOptions.DisableWordHighlight) { e.PaintContent(e.CellBounds); } @@ -448,16 +446,20 @@ private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintin Brush brush = new SolidBrush(BookmarkColor); e.Graphics.FillRectangle(brush, r); brush.Dispose(); + Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); + if (bookmark.Text.Length > 0) { - StringFormat format = new(); - format.LineAlignment = StringAlignment.Center; - format.Alignment = StringAlignment.Center; + StringFormat format = new() + { + LineAlignment = StringAlignment.Center, + Alignment = StringAlignment.Center + }; + Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); Font font = new("Verdana", Preferences.fontSize, FontStyle.Bold); - e.Graphics.DrawString("!", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), - format); + e.Graphics.DrawString("!", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); font.Dispose(); brush2.Dispose(); } @@ -781,9 +783,11 @@ private void OnDataGridContextMenuStripOpening(object sender, CancelEventArgs e) && GetTimestampForLine(ref refLineNum, false) != DateTime.MinValue; + locateLineInOriginalFileToolStripMenuItem.Enabled = IsTempFile && FilterPipe != null && FilterPipe.GetOriginalLineNum(lineNum) != -1; + markEditModeToolStripMenuItem.Enabled = !dataGridView.CurrentCell.ReadOnly; // Remove all "old" plugin entries @@ -801,15 +805,12 @@ private void OnDataGridContextMenuStripOpening(object sender, CancelEventArgs e) bool isAdded = false; if (PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins.Count > 0) { - //string line = this.logFileReader.GetLogLine(lineNum); IList lines = GetSelectedContent(); foreach (IContextMenuEntry entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins) { LogExpertCallback callback = new(this); - ContextMenuPluginEventArgs evArgs = new(entry, lines, CurrentColumnizer, callback); - EventHandler ev = OnHandlePluginContextMenu; - //MenuItem item = this.dataGridView.ContextMenu.MenuItems.Add(entry.GetMenuText(line, this.CurrentColumnizer, callback), ev); - string menuText = entry.GetMenuText(lines, CurrentColumnizer, callback); + string menuText = entry.GetMenuText(lines.Count, CurrentColumnizer, callback.GetLogLine(lines[0])); + if (menuText != null) { bool disabled = menuText.StartsWith('_'); @@ -818,8 +819,8 @@ private void OnDataGridContextMenuStripOpening(object sender, CancelEventArgs e) menuText = menuText[1..]; } - ToolStripItem item = dataGridContextMenuStrip.Items.Add(menuText, null, ev); - item.Tag = evArgs; + ToolStripItem item = dataGridContextMenuStrip.Items.Add(menuText, null, OnHandlePluginContextMenu); + item.Tag = new ContextMenuPluginEventArgs(entry, lines, CurrentColumnizer, callback); item.Enabled = !disabled; isAdded = true; } @@ -872,7 +873,8 @@ private void OnHandlePluginContextMenu(object sender, EventArgs args) if (sender is ToolStripItem item) { ContextMenuPluginEventArgs menuArgs = item.Tag as ContextMenuPluginEventArgs; - menuArgs.Entry.MenuSelected(menuArgs.LogLines, menuArgs.Columnizer, menuArgs.Callback); + var logLines = menuArgs.LogLines; + menuArgs.Entry.MenuSelected(logLines.Count, menuArgs.Columnizer, menuArgs.Callback.GetLogLine(logLines[0])); } } @@ -960,7 +962,7 @@ private void OnColumnRestrictCheckBoxCheckedChanged(object sender, EventArgs e) if (columnRestrictCheckBox.Checked) // disable when nothing to filter { columnNamesLabel.Visible = true; - _filterParams.columnRestrict = true; + _filterParams.ColumnRestrict = true; columnNamesLabel.Text = CalculateColumnNames(_filterParams); } else @@ -973,7 +975,7 @@ private void OnColumnRestrictCheckBoxCheckedChanged(object sender, EventArgs e) private void OnColumnButtonClick(object sender, EventArgs e) { - _filterParams.currentColumnizer = _currentColumnizer; + _filterParams.CurrentColumnizer = _currentColumnizer; FilterColumnChooser chooser = new(_filterParams); if (chooser.ShowDialog() == DialogResult.OK) { @@ -1033,9 +1035,9 @@ private void OnColumnContextMenuStripOpening(object sender, CancelEventArgs e) Control ctl = columnContextMenuStrip.SourceControl; BufferedDataGridView gridView = ctl as BufferedDataGridView; bool frozen = false; - if (_freezeStateMap.ContainsKey(ctl)) + if (_freezeStateMap.TryGetValue(ctl, out bool value)) { - frozen = _freezeStateMap[ctl]; + frozen = value; } freezeLeftColumnsUntilHereToolStripMenuItem.Checked = frozen; @@ -1105,15 +1107,14 @@ private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick(object sender, E Control ctl = columnContextMenuStrip.SourceControl; bool frozen = false; - if (_freezeStateMap.ContainsKey(ctl)) + if (_freezeStateMap.TryGetValue(ctl, out bool value)) { - frozen = _freezeStateMap[ctl]; + frozen = value; } frozen = !frozen; _freezeStateMap[ctl] = frozen; - DataGridViewColumn senderCol = sender as DataGridViewColumn; if (ctl is BufferedDataGridView gridView) { ApplyFrozenState(gridView); @@ -1342,8 +1343,8 @@ private void OnToggleHighlightPanelButtonClick(object sender, EventArgs e) private void OnSaveFilterButtonClick(object sender, EventArgs e) { - FilterParams newParams = _filterParams.CreateCopy(); - newParams.color = Color.FromKnownColor(KnownColor.Black); + FilterParams newParams = _filterParams.MemberwiseCopy(); + newParams.Color = Color.FromKnownColor(KnownColor.Black); ConfigManager.Settings.filterList.Add(newParams); OnFilterListChanged(this); } @@ -1401,7 +1402,7 @@ private void OnFilterListBoxMouseDoubleClick(object sender, MouseEventArgs e) if (filterListBox.SelectedIndex >= 0) { FilterParams filterParams = (FilterParams)filterListBox.Items[filterListBox.SelectedIndex]; - FilterParams newParams = filterParams.CreateCopy(); + FilterParams newParams = filterParams.MemberwiseCopy(); //newParams.historyList = ConfigManager.Settings.filterHistoryList; this._filterParams = newParams; ReInitFilterParams(this._filterParams); @@ -1438,10 +1439,10 @@ private void OnFilterListBoxDrawItem(object sender, DrawItemEventArgs e) } else { - brush = new SolidBrush(filterParams.color); + brush = new SolidBrush(filterParams.Color); } - e.Graphics.DrawString(filterParams.searchText, e.Font, brush, + e.Graphics.DrawString(filterParams.SearchText, e.Font, brush, new PointF(rectangle.Left, rectangle.Top)); e.DrawFocusRectangle(); brush.Dispose(); @@ -1456,11 +1457,11 @@ private void OnColorToolStripMenuItemClick(object sender, EventArgs e) { FilterParams filterParams = (FilterParams)filterListBox.Items[i]; ColorDialog dlg = new(); - dlg.CustomColors = new[] { filterParams.color.ToArgb() }; - dlg.Color = filterParams.color; + dlg.CustomColors = new[] { filterParams.Color.ToArgb() }; + dlg.Color = filterParams.Color; if (dlg.ShowDialog() == DialogResult.OK) { - filterParams.color = dlg.Color; + filterParams.Color = dlg.Color; filterListBox.Refresh(); } } @@ -1558,9 +1559,9 @@ private void OnSplitContainerSplitterMoved(object sender, SplitterEventArgs e) private void OnMarkFilterHitsInLogViewToolStripMenuItemClick(object sender, EventArgs e) { SearchParams p = new(); - p.searchText = _filterParams.searchText; - p.isRegex = _filterParams.isRegex; - p.isCaseSensitive = _filterParams.isCaseSensitive; + p.SearchText = _filterParams.SearchText; + p.IsRegex = _filterParams.IsRegex; + p.IsCaseSensitive = _filterParams.IsCaseSensitive; AddSearchHitHighlightEntry(p); } diff --git a/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs index 1621bd96..e06c226a 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs @@ -297,17 +297,17 @@ private void RestoreFilterTabs(PersistenceData persistenceData) //List lastFilterResultList = new List(); List filterHitList = []; Filter(persistFilterParams, filterResultList, _lastFilterLinesList, filterHitList); - FilterPipe pipe = new(persistFilterParams.CreateCopy(), this); + FilterPipe pipe = new(persistFilterParams.MemberwiseCopy(), this); WritePipeToTab(pipe, filterResultList, data.persistenceData.tabName, data.persistenceData); } } private void ReInitFilterParams(FilterParams filterParams) { - filterParams.searchText = filterParams.searchText; // init "lowerSearchText" - filterParams.rangeSearchText = filterParams.rangeSearchText; // init "lowerRangesearchText" - filterParams.currentColumnizer = CurrentColumnizer; - if (filterParams.isRegex) + filterParams.SearchText = filterParams.SearchText; // init "lowerSearchText" + filterParams.RangeSearchText = filterParams.RangeSearchText; // init "lowerRangesearchText" + filterParams.CurrentColumnizer = CurrentColumnizer; + if (filterParams.IsRegex) { try { @@ -352,14 +352,14 @@ private void EnterLoadFileStatus() private void PositionAfterReload(ReloadMemento reloadMemento) { - if (_reloadMemento.currentLine < dataGridView.RowCount && _reloadMemento.currentLine >= 0) + if (_reloadMemento.CurrentLine < dataGridView.RowCount && _reloadMemento.CurrentLine >= 0) { - dataGridView.CurrentCell = dataGridView.Rows[_reloadMemento.currentLine].Cells[0]; + dataGridView.CurrentCell = dataGridView.Rows[_reloadMemento.CurrentLine].Cells[0]; } - if (_reloadMemento.firstDisplayedLine < dataGridView.RowCount && _reloadMemento.firstDisplayedLine >= 0) + if (_reloadMemento.FirstDisplayedLine < dataGridView.RowCount && _reloadMemento.FirstDisplayedLine >= 0) { - dataGridView.FirstDisplayedScrollingRowIndex = _reloadMemento.firstDisplayedLine; + dataGridView.FirstDisplayedScrollingRowIndex = _reloadMemento.FirstDisplayedLine; } } @@ -958,7 +958,7 @@ private void SetColumnizerInternal(ILogLineColumnizer columnizer) bool mustReload = false; // Check if the filtered columns disappeared, if so must refresh the UI - if (_filterParams.columnRestrict) + if (_filterParams.ColumnRestrict) { string[] newColumns = columnizer != null ? columnizer.GetColumnNames() : Array.Empty(); bool colChanged = false; @@ -986,12 +986,12 @@ private void SetColumnizerInternal(ILogLineColumnizer columnizer) } } - Type oldColType = _filterParams.currentColumnizer?.GetType(); + Type oldColType = _filterParams.CurrentColumnizer?.GetType(); Type newColType = columnizer?.GetType(); - if (oldColType != newColType && _filterParams.columnRestrict && _filterParams.isFilterTail) + if (oldColType != newColType && _filterParams.ColumnRestrict && _filterParams.IsFilterTail) { - _filterParams.columnList.Clear(); + _filterParams.ColumnList.Clear(); } if (CurrentColumnizer == null || CurrentColumnizer.GetType() != columnizer.GetType()) @@ -1591,24 +1591,28 @@ private void StatusLineFileSize(long size) private int Search(SearchParams searchParams) { - if (searchParams.searchText == null) + if (searchParams.SearchText == null) { return -1; } - int lineNum = searchParams.isFromTop && !searchParams.isFindNext ? 0 : searchParams.currentLine; - string lowerSearchText = searchParams.searchText.ToLower(); + int lineNum = searchParams.IsFromTop && !searchParams.IsFindNext + ? 0 + : searchParams.CurrentLine; + + string lowerSearchText = searchParams.SearchText.ToLower(); int count = 0; bool hasWrapped = false; + while (true) { - if ((searchParams.isForward || searchParams.isFindNext) && !searchParams.isShiftF3Pressed) + if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) { if (lineNum >= _logFileReader.LineCount) { if (hasWrapped) { - StatusLineError("Not found: " + searchParams.searchText); + StatusLineError("Not found: " + searchParams.SearchText); return -1; } @@ -1624,7 +1628,7 @@ private int Search(SearchParams searchParams) { if (hasWrapped) { - StatusLineError("Not found: " + searchParams.searchText); + StatusLineError("Not found: " + searchParams.SearchText); return -1; } @@ -1641,10 +1645,9 @@ private int Search(SearchParams searchParams) return -1; } - if (searchParams.isRegex) + if (searchParams.IsRegex) { - Regex rex = new(searchParams.searchText, - searchParams.isCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); + Regex rex = new(searchParams.SearchText, searchParams.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); if (rex.IsMatch(line.FullLine)) { return lineNum; @@ -1652,7 +1655,7 @@ private int Search(SearchParams searchParams) } else { - if (!searchParams.isCaseSensitive) + if (!searchParams.IsCaseSensitive) { if (line.FullLine.Contains(lowerSearchText, StringComparison.CurrentCultureIgnoreCase)) { @@ -1661,14 +1664,14 @@ private int Search(SearchParams searchParams) } else { - if (line.FullLine.Contains(searchParams.searchText)) + if (line.FullLine.Contains(searchParams.SearchText)) { return lineNum; } } } - if ((searchParams.isForward || searchParams.isFindNext) && !searchParams.isShiftF3Pressed) + if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) { lineNum++; } @@ -1716,6 +1719,7 @@ private void SelectLine(int line, bool triggerSyncCall, bool shouldScroll) _isSearching = false; StatusLineText(""); _guiStateArgs.MenuEnabled = true; + if (wasCancelled) { return; @@ -1923,17 +1927,17 @@ private void DisconnectFilterPipes() private void ApplyFilterParams() { - filterComboBox.Text = _filterParams.searchText; - filterCaseSensitiveCheckBox.Checked = _filterParams.isCaseSensitive; - filterRegexCheckBox.Checked = _filterParams.isRegex; - filterTailCheckBox.Checked = _filterParams.isFilterTail; - invertFilterCheckBox.Checked = _filterParams.isInvert; - filterKnobBackSpread.Value = _filterParams.spreadBefore; - filterKnobForeSpread.Value = _filterParams.spreadBehind; - rangeCheckBox.Checked = _filterParams.isRangeSearch; - columnRestrictCheckBox.Checked = _filterParams.columnRestrict; - fuzzyKnobControl.Value = _filterParams.fuzzyValue; - filterRangeComboBox.Text = _filterParams.rangeSearchText; + filterComboBox.Text = _filterParams.SearchText; + filterCaseSensitiveCheckBox.Checked = _filterParams.IsCaseSensitive; + filterRegexCheckBox.Checked = _filterParams.IsRegex; + filterTailCheckBox.Checked = _filterParams.IsFilterTail; + invertFilterCheckBox.Checked = _filterParams.IsInvert; + filterKnobBackSpread.Value = _filterParams.SpreadBefore; + filterKnobForeSpread.Value = _filterParams.SpreadBehind; + rangeCheckBox.Checked = _filterParams.IsRangeSearch; + columnRestrictCheckBox.Checked = _filterParams.ColumnRestrict; + fuzzyKnobControl.Value = _filterParams.FuzzyValue; + filterRangeComboBox.Text = _filterParams.RangeSearchText; } private void ResetFilterControls() @@ -1955,9 +1959,9 @@ private void FilterSearch() { if (filterComboBox.Text.Length == 0) { - _filterParams.searchText = ""; - _filterParams.lowerSearchText = ""; - _filterParams.isRangeSearch = false; + _filterParams.SearchText = ""; + _filterParams.LowerSearchText = ""; + _filterParams.IsRangeSearch = false; ClearFilterList(); filterSearchButton.Image = null; ResetFilterControls(); @@ -1972,8 +1976,8 @@ private async void FilterSearch(string text) { FireCancelHandlers(); // make sure that there's no other filter running (maybe from filter restore) - _filterParams.searchText = text; - _filterParams.lowerSearchText = text.ToLower(); + _filterParams.SearchText = text; + _filterParams.LowerSearchText = text.ToLower(); ConfigManager.Settings.filterHistoryList.Remove(text); ConfigManager.Settings.filterHistoryList.Insert(0, text); int maxHistory = ConfigManager.Settings.Preferences.maximumFilterEntries; @@ -1991,9 +1995,9 @@ private async void FilterSearch(string text) filterComboBox.Text = text; - _filterParams.isRangeSearch = rangeCheckBox.Checked; - _filterParams.rangeSearchText = filterRangeComboBox.Text; - if (_filterParams.isRangeSearch) + _filterParams.IsRangeSearch = rangeCheckBox.Checked; + _filterParams.RangeSearchText = filterRangeComboBox.Text; + if (_filterParams.IsRangeSearch) { ConfigManager.Settings.filterRangeHistoryList.Remove(filterRangeComboBox.Text); ConfigManager.Settings.filterRangeHistoryList.Insert(0, filterRangeComboBox.Text); @@ -2011,11 +2015,11 @@ private async void FilterSearch(string text) ConfigManager.Save(SettingsFlags.FilterHistory); - _filterParams.isCaseSensitive = filterCaseSensitiveCheckBox.Checked; - _filterParams.isRegex = filterRegexCheckBox.Checked; - _filterParams.isFilterTail = filterTailCheckBox.Checked; - _filterParams.isInvert = invertFilterCheckBox.Checked; - if (_filterParams.isRegex) + _filterParams.IsCaseSensitive = filterCaseSensitiveCheckBox.Checked; + _filterParams.IsRegex = filterRegexCheckBox.Checked; + _filterParams.IsFilterTail = filterTailCheckBox.Checked; + _filterParams.IsInvert = invertFilterCheckBox.Checked; + if (_filterParams.IsRegex) { try { @@ -2028,10 +2032,10 @@ private async void FilterSearch(string text) } } - _filterParams.fuzzyValue = fuzzyKnobControl.Value; - _filterParams.spreadBefore = filterKnobBackSpread.Value; - _filterParams.spreadBehind = filterKnobForeSpread.Value; - _filterParams.columnRestrict = columnRestrictCheckBox.Checked; + _filterParams.FuzzyValue = fuzzyKnobControl.Value; + _filterParams.SpreadBefore = filterKnobBackSpread.Value; + _filterParams.SpreadBehind = filterKnobForeSpread.Value; + _filterParams.ColumnRestrict = columnRestrictCheckBox.Checked; //ConfigManager.SaveFilterParams(this.filterParams); ConfigManager.Settings.filterParams = _filterParams; // wozu eigentlich? sinnlos seit MDI? @@ -2158,14 +2162,14 @@ private IList GetAdditionalFilterResults(FilterParams filterParams, int lin //ColumnizerCallback callback = new ColumnizerCallback(this); //callback.LineNum = lineNum; - if (filterParams.spreadBefore == 0 && filterParams.spreadBehind == 0) + if (filterParams.SpreadBefore == 0 && filterParams.SpreadBehind == 0) { resultList.Add(lineNum); return resultList; } // back spread - for (int i = filterParams.spreadBefore; i > 0; --i) + for (int i = filterParams.SpreadBefore; i > 0; --i) { if (lineNum - i > 0) { @@ -2183,7 +2187,7 @@ private IList GetAdditionalFilterResults(FilterParams filterParams, int lin } // after spread - for (int i = 1; i <= filterParams.spreadBehind; ++i) + for (int i = 1; i <= filterParams.SpreadBehind; ++i) { if (lineNum + i < _logFileReader.LineCount) { @@ -2470,52 +2474,52 @@ private void CheckForFilterDirty() private bool IsFilterSearchDirty(FilterParams filterParams) { - if (!filterParams.searchText.Equals(filterComboBox.Text)) + if (!filterParams.SearchText.Equals(filterComboBox.Text)) { return true; } - if (filterParams.isRangeSearch != rangeCheckBox.Checked) + if (filterParams.IsRangeSearch != rangeCheckBox.Checked) { return true; } - if (filterParams.isRangeSearch && !filterParams.rangeSearchText.Equals(filterRangeComboBox.Text)) + if (filterParams.IsRangeSearch && !filterParams.RangeSearchText.Equals(filterRangeComboBox.Text)) { return true; } - if (filterParams.isRegex != filterRegexCheckBox.Checked) + if (filterParams.IsRegex != filterRegexCheckBox.Checked) { return true; } - if (filterParams.isInvert != invertFilterCheckBox.Checked) + if (filterParams.IsInvert != invertFilterCheckBox.Checked) { return true; } - if (filterParams.spreadBefore != filterKnobBackSpread.Value) + if (filterParams.SpreadBefore != filterKnobBackSpread.Value) { return true; } - if (filterParams.spreadBehind != filterKnobForeSpread.Value) + if (filterParams.SpreadBehind != filterKnobForeSpread.Value) { return true; } - if (filterParams.fuzzyValue != fuzzyKnobControl.Value) + if (filterParams.FuzzyValue != fuzzyKnobControl.Value) { return true; } - if (filterParams.columnRestrict != columnRestrictCheckBox.Checked) + if (filterParams.ColumnRestrict != columnRestrictCheckBox.Checked) { return true; } - if (filterParams.isCaseSensitive != filterCaseSensitiveCheckBox.Checked) + if (filterParams.IsCaseSensitive != filterCaseSensitiveCheckBox.Checked) { return true; } @@ -2676,7 +2680,7 @@ private void FilterToTab() private void WriteFilterToTab() { - FilterPipe pipe = new(_filterParams.CreateCopy(), this); + FilterPipe pipe = new(_filterParams.MemberwiseCopy(), this); lock (_filterResultList) { string namePrefix = "->F"; @@ -2949,6 +2953,7 @@ private IList GetSelectedContent() if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) { List lineNumList = []; + foreach (DataGridViewRow row in dataGridView.SelectedRows) { if (row.Index != -1) @@ -3012,9 +3017,9 @@ private string CalculateColumnNames(FilterParams filter) { string names = string.Empty; - if (filter.columnRestrict) + if (filter.ColumnRestrict) { - foreach (int colIndex in filter.columnList) + foreach (int colIndex in filter.ColumnList) { if (colIndex < dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 2) { @@ -3541,7 +3546,7 @@ private void AddBookmarkComment(string text) private void MarkCurrentFilterRange() { - _filterParams.rangeSearchText = filterRangeComboBox.Text; + _filterParams.RangeSearchText = filterRangeComboBox.Text; ColumnizerCallback callback = new(this); RangeFinder rangeFinder = new(_filterParams, callback); Core.Entities.Range range = rangeFinder.FindRange(dataGridView.CurrentCellAddress.Y); @@ -3678,11 +3683,11 @@ private void AddSearchHitHighlightEntry(SearchParams para) { HighlightEntry he = new() { - SearchText = para.searchText, + SearchText = para.SearchText, ForegroundColor = Color.Red, BackgroundColor = Color.Yellow, - IsRegEx = para.isRegex, - IsCaseSensitive = para.isCaseSensitive, + IsRegEx = para.IsRegex, + IsCaseSensitive = para.IsCaseSensitive, IsLedSwitch = false, IsStopTail = false, IsSetBookmark = false, diff --git a/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs b/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs index f0f90eb2..b94b40d2 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs @@ -1,6 +1,5 @@ using LogExpert.Classes; using LogExpert.Classes.Filter; -using LogExpert.Classes.Log; using LogExpert.Config; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Bookmark; @@ -87,7 +86,7 @@ public void LoadFile(string fileName, EncodingOptions encodingOptions) try { - _logFileReader = new LogfileReader(fileName, EncodingOptions, IsMultiFile, Preferences.bufferCount, Preferences.linesPerBuffer, _multiFileOptions) + _logFileReader = new(fileName, EncodingOptions, IsMultiFile, Preferences.bufferCount, Preferences.linesPerBuffer, _multiFileOptions) { UseNewReader = !Preferences.useLegacyReader }; @@ -162,8 +161,11 @@ public void LoadFilesAsMulti(string[] fileNames, EncodingOptions encodingOptions EncodingOptions = encodingOptions; _columnCache = new ColumnCache(); - _logFileReader = new LogfileReader(fileNames, EncodingOptions, Preferences.bufferCount, Preferences.linesPerBuffer, _multiFileOptions); - _logFileReader.UseNewReader = !Preferences.useLegacyReader; + _logFileReader = new(fileNames, EncodingOptions, Preferences.bufferCount, Preferences.linesPerBuffer, _multiFileOptions) + { + UseNewReader = !Preferences.useLegacyReader + }; + RegisterLogFileReaderEvents(); _logFileReader.StartMonitoring(); FileName = fileNames[^1]; @@ -215,24 +217,27 @@ public string SavePersistenceData(bool force) public PersistenceData GetPersistenceData() { - PersistenceData persistenceData = new(); - persistenceData.bookmarkList = _bookmarkProvider.BookmarkList; - persistenceData.rowHeightList = _rowHeightList; - persistenceData.multiFile = IsMultiFile; - persistenceData.multiFilePattern = _multiFileOptions.FormatPattern; - persistenceData.multiFileMaxDays = _multiFileOptions.MaxDayTry; - persistenceData.currentLine = dataGridView.CurrentCellAddress.Y; - persistenceData.firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex; - persistenceData.filterVisible = !splitContainerLogWindow.Panel2Collapsed; - persistenceData.filterAdvanced = !advancedFilterSplitContainer.Panel1Collapsed; - persistenceData.filterPosition = splitContainerLogWindow.SplitterDistance; - persistenceData.followTail = _guiStateArgs.FollowTail; - persistenceData.fileName = FileName; - persistenceData.tabName = Text; - persistenceData.sessionFileName = SessionFileName; - persistenceData.columnizerName = CurrentColumnizer.GetName(); - persistenceData.lineCount = _logFileReader.LineCount; - _filterParams.isFilterTail = filterTailCheckBox.Checked; // this option doesnt need a press on 'search' + PersistenceData persistenceData = new() + { + bookmarkList = _bookmarkProvider.BookmarkList, + rowHeightList = _rowHeightList, + multiFile = IsMultiFile, + multiFilePattern = _multiFileOptions.FormatPattern, + multiFileMaxDays = _multiFileOptions.MaxDayTry, + currentLine = dataGridView.CurrentCellAddress.Y, + firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex, + filterVisible = !splitContainerLogWindow.Panel2Collapsed, + filterAdvanced = !advancedFilterSplitContainer.Panel1Collapsed, + filterPosition = splitContainerLogWindow.SplitterDistance, + followTail = _guiStateArgs.FollowTail, + fileName = FileName, + tabName = Text, + sessionFileName = SessionFileName, + columnizerName = CurrentColumnizer.GetName(), + lineCount = _logFileReader.LineCount + }; + + _filterParams.IsFilterTail = filterTailCheckBox.Checked; // this option doesnt need a press on 'search' if (Preferences.saveFilters) { @@ -438,7 +443,7 @@ public void CellPainting(BufferedDataGridView gridView, int rowIndex, DataGridVi { Color bgColor = ColorMode.DockBackgroundColor; - if (!DebugOptions.disableWordHighlight) + if (!DebugOptions.DisableWordHighlight) { if (entry != null) { @@ -458,7 +463,7 @@ public void CellPainting(BufferedDataGridView gridView, int rowIndex, DataGridVi e.PaintBackground(e.ClipBounds, false); } - if (DebugOptions.disableWordHighlight) + if (DebugOptions.DisableWordHighlight) { e.PaintContent(e.CellBounds); } @@ -602,13 +607,13 @@ public void StartSearch() GuiStateUpdate(this, _guiStateArgs); SearchParams searchParams = _parentLogTabWin.SearchParams; - if ((searchParams.isForward || searchParams.isFindNext) && !searchParams.isShiftF3Pressed) + if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) { - searchParams.currentLine = dataGridView.CurrentCellAddress.Y + 1; + searchParams.CurrentLine = dataGridView.CurrentCellAddress.Y + 1; } else { - searchParams.currentLine = dataGridView.CurrentCellAddress.Y - 1; + searchParams.CurrentLine = dataGridView.CurrentCellAddress.Y - 1; } _currentSearchParams = searchParams; // remember for async "not found" messages @@ -699,14 +704,14 @@ public void OnLogWindowKeyDown(object sender, KeyEventArgs e) switch (e.KeyCode) { - case Keys.F3 when _parentLogTabWin.SearchParams?.searchText == null || _parentLogTabWin.SearchParams.searchText.Length == 0: + case Keys.F3 when _parentLogTabWin.SearchParams?.SearchText == null || _parentLogTabWin.SearchParams.SearchText.Length == 0: { return; } case Keys.F3: { - _parentLogTabWin.SearchParams.isFindNext = true; - _parentLogTabWin.SearchParams.isShiftF3Pressed = (e.Modifiers & Keys.Shift) == Keys.Shift; + _parentLogTabWin.SearchParams.IsFindNext = true; + _parentLogTabWin.SearchParams.IsShiftF3Pressed = (e.Modifiers & Keys.Shift) == Keys.Shift; StartSearch(); break; } @@ -1231,8 +1236,8 @@ public void Reload() SavePersistenceData(false); _reloadMemento = new ReloadMemento(); - _reloadMemento.currentLine = dataGridView.CurrentCellAddress.Y; - _reloadMemento.firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex; + _reloadMemento.CurrentLine = dataGridView.CurrentCellAddress.Y; + _reloadMemento.FirstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex; _forcedColumnizerForLoading = CurrentColumnizer; if (_fileNames == null || !IsMultiFile) diff --git a/src/Logexpert.Core/Classes/Filter/FilterParams.cs b/src/Logexpert.Core/Classes/Filter/FilterParams.cs index d0a8854b..f7b89a6f 100644 --- a/src/Logexpert.Core/Classes/Filter/FilterParams.cs +++ b/src/Logexpert.Core/Classes/Filter/FilterParams.cs @@ -9,125 +9,141 @@ public class FilterParams { #region Fields - public string _rangeSearchText = ""; - public string _searchText = ""; - - public Color color = Color.Black; + private string _rangeSearchText = ""; + private string _searchText = ""; //public List historyList = new List(); //public List rangeHistoryList = new List(); - public List columnList = []; // list of columns in which to search - - public bool columnRestrict = false; - - [NonSerialized] public ILogLineColumnizer currentColumnizer; - - public bool emptyColumnHit; - public bool emptyColumnUsePrev; - - public bool exactColumnMatch = false; - - //public bool isFuzzy; - public int fuzzyValue = 0; - - public bool isCaseSensitive; - public bool isFilterTail; - - [NonSerialized] public bool isInRange = false; // false=looking for start, true=looking for end - - public bool isInvert; - public bool isRangeSearch = false; - public bool isRegex; - - [NonSerialized] public string lastLine = ""; - - [NonSerialized] public Hashtable lastNonEmptyCols = []; - - [NonSerialized] public bool lastResult; - - [NonSerialized] public string lowerRangeSearchText = ""; - - // transient members: - [NonSerialized] public string lowerSearchText = ""; - - [NonSerialized] public Regex rangeRex; - - [NonSerialized] public Regex rex; - - public int spreadBefore; - public int spreadBehind; #endregion #region Properties - public string searchText + public string SearchText { get => _searchText; set { _searchText = value; - lowerSearchText = _searchText.ToLower(); + LowerSearchText = _searchText.ToLower(); } } - public string rangeSearchText + public string RangeSearchText { get => _rangeSearchText; set { _rangeSearchText = value; - lowerRangeSearchText = _rangeSearchText.ToLower(); + LowerRangeSearchText = _rangeSearchText.ToLower(); } } - public bool SpreadEnabled => spreadBefore > 0 || spreadBehind > 0; + public bool SpreadEnabled => SpreadBefore > 0 || SpreadBehind > 0; + + public bool IsCaseSensitive { get; set; } + + public bool IsFilterTail { get; set; } + + public int FuzzyValue { get; set; } + + public bool EmptyColumnUsePrev { get; set; } + + public bool EmptyColumnHit { get; set; } + + public bool ExactColumnMatch { get; set; } = false; + + public bool ColumnRestrict { get; set; } + + public Color Color { get; set; } = Color.Black; + + public int SpreadBefore { get; set; } + + public int SpreadBehind { get; set; } + + public bool IsInvert { get; set; } + + public bool IsRangeSearch { get; set; } = false; + + public bool IsRegex { get; set; } + + // list of columns in which to search + public List ColumnList { get; set; } = []; + + [field: NonSerialized] + public ILogLineColumnizer CurrentColumnizer { get; set; } + + /// + /// false=looking for start + /// true=looking for end + /// + [field: NonSerialized] + public bool IsInRange { get; set; } = false; + + [field: NonSerialized] + public string LastLine { get; set; } = string.Empty; + + [field: NonSerialized] + public Hashtable LastNonEmptyCols { get; set; } = []; + + [field: NonSerialized] + public bool LastResult { get; set; } + + [field: NonSerialized] + public string LowerRangeSearchText { get; set; } = string.Empty; + + [field: NonSerialized] + public string LowerSearchText { get; set; } = string.Empty; + + [field: NonSerialized] + public Regex RangeRex { get; set; } + + [field: NonSerialized] + public Regex Rex { get; set; } #endregion #region Public methods - public FilterParams CreateCopy2() + public FilterParams Copy() { - FilterParams newParams = CreateCopy(); + FilterParams newParams = MemberwiseCopy(); newParams.Init(); // removed cloning of columnizer for filtering, because this causes issues with columnizers that hold internal states (like CsvColumnizer) // newParams.currentColumnizer = Util.CloneColumnizer(this.currentColumnizer); - newParams.currentColumnizer = currentColumnizer; + newParams.CurrentColumnizer = CurrentColumnizer; return newParams; } // call after deserialization! public void Init() { - lastNonEmptyCols = []; - lowerRangeSearchText = _rangeSearchText.ToLower(); - lowerSearchText = _searchText.ToLower(); - lastLine = ""; + LastNonEmptyCols = []; + LowerRangeSearchText = RangeSearchText.ToLower(); + LowerSearchText = SearchText.ToLower(); + LastLine = string.Empty; } // Reset before a new search public void Reset() { - lastNonEmptyCols.Clear(); - isInRange = false; + LastNonEmptyCols.Clear(); + IsInRange = false; } public void CreateRegex() { - if (_searchText != null) + if (SearchText != null) { - rex = new Regex(_searchText, - isCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); + Rex = new Regex(SearchText, IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); } - if (_rangeSearchText != null && isRangeSearch) + if (RangeSearchText != null && IsRangeSearch) { - rangeRex = new Regex(_rangeSearchText, - isCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); + RangeRex = new Regex(RangeSearchText, IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); } } - public FilterParams CreateCopy() + public FilterParams MemberwiseCopy() { return (FilterParams)MemberwiseClone(); } diff --git a/src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs b/src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs index 29585492..7d567301 100644 --- a/src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs +++ b/src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs @@ -157,7 +157,9 @@ private int DetectPreambleLengthAndEncoding(out Encoding detectedEncoding) */ byte[] readPreamble = new byte[4]; + int readLen = _stream.Read(readPreamble, 0, 4); + if (readLen >= 2) { foreach (Encoding encoding in _preambleEncodings) @@ -183,6 +185,7 @@ private int DetectPreambleLengthAndEncoding(out Encoding detectedEncoding) // not found or less than 2 byte read detectedEncoding = null; + return 0; } diff --git a/src/Logexpert.Core/Classes/Util.cs b/src/Logexpert.Core/Classes/Util.cs index d2735ff3..935f15b1 100644 --- a/src/Logexpert.Core/Classes/Util.cs +++ b/src/Logexpert.Core/Classes/Util.cs @@ -68,21 +68,21 @@ public static string GetFileSizeAsText(long size) public static bool TestFilterCondition(FilterParams filterParams, ILogLine line, LogExpert.ILogLineColumnizerCallback columnizerCallback) { - if (filterParams.lastLine.Equals(line.FullLine)) + if (filterParams.LastLine.Equals(line.FullLine)) { - return filterParams.lastResult; + return filterParams.LastResult; } bool match = TestFilterMatch(filterParams, line, columnizerCallback); - filterParams.lastLine = line.FullLine; + filterParams.LastLine = line.FullLine; - if (filterParams.isRangeSearch) + if (filterParams.IsRangeSearch) { - if (!filterParams.isInRange) + if (!filterParams.IsInRange) { if (match) { - filterParams.isInRange = true; + filterParams.IsInRange = true; } } else @@ -93,15 +93,15 @@ public static bool TestFilterCondition(FilterParams filterParams, ILogLine line, } else { - filterParams.isInRange = false; + filterParams.IsInRange = false; } } } - if (filterParams.isInvert) + if (filterParams.IsInvert) { match = !match; } - filterParams.lastResult = match; + filterParams.LastResult = match; return match; } @@ -465,17 +465,17 @@ private static bool TestFilterMatch(FilterParams filterParams, ILogLine line, IL string searchText; Regex rex; - if (filterParams.isInRange) + if (filterParams.IsInRange) { - lowerSearchText = filterParams.lowerRangeSearchText; - searchText = filterParams.rangeSearchText; - rex = filterParams.rangeRex; + lowerSearchText = filterParams.LowerRangeSearchText; + searchText = filterParams.RangeSearchText; + rex = filterParams.RangeRex; } else { - lowerSearchText = filterParams.lowerSearchText; - searchText = filterParams.searchText; - rex = filterParams.rex; + lowerSearchText = filterParams.LowerSearchText; + searchText = filterParams.SearchText; + rex = filterParams.Rex; } if (searchText == null || lowerSearchText == null || searchText.Length == 0) @@ -483,40 +483,40 @@ private static bool TestFilterMatch(FilterParams filterParams, ILogLine line, IL return false; } - if (filterParams.columnRestrict) + if (filterParams.ColumnRestrict) { - IColumnizedLogLine columns = filterParams.currentColumnizer.SplitLine(columnizerCallback, line); + IColumnizedLogLine columns = filterParams.CurrentColumnizer.SplitLine(columnizerCallback, line); bool found = false; - foreach (int colIndex in filterParams.columnList) + foreach (int colIndex in filterParams.ColumnList) { if (colIndex < columns.ColumnValues.Length ) // just to be sure, maybe the columnizer has changed anyhow { if (columns.ColumnValues[colIndex].FullValue.Trim().Length == 0) { - if (filterParams.emptyColumnUsePrev) + if (filterParams.EmptyColumnUsePrev) { - string prevValue = (string)filterParams.lastNonEmptyCols[colIndex]; + string prevValue = (string)filterParams.LastNonEmptyCols[colIndex]; if (prevValue != null) { if (TestMatchSub(filterParams, prevValue, lowerSearchText, searchText, rex, - filterParams.exactColumnMatch)) + filterParams.ExactColumnMatch)) { found = true; } } } - else if (filterParams.emptyColumnHit) + else if (filterParams.EmptyColumnHit) { return true; } } else { - filterParams.lastNonEmptyCols[colIndex] = columns.ColumnValues[colIndex].FullValue; + filterParams.LastNonEmptyCols[colIndex] = columns.ColumnValues[colIndex].FullValue; if (TestMatchSub(filterParams, columns.ColumnValues[colIndex].FullValue, lowerSearchText, searchText, rex, - filterParams.exactColumnMatch)) + filterParams.ExactColumnMatch)) { found = true; } @@ -533,7 +533,7 @@ private static bool TestFilterMatch(FilterParams filterParams, ILogLine line, IL private static bool TestMatchSub(FilterParams filterParams, string line, string lowerSearchText, string searchText, Regex rex, bool exactMatch) { - if (filterParams.isRegex) + if (filterParams.IsRegex) { if (rex.IsMatch(line)) { @@ -542,7 +542,7 @@ private static bool TestMatchSub(FilterParams filterParams, string line, string } else { - if (!filterParams.isCaseSensitive) + if (!filterParams.IsCaseSensitive) { if (exactMatch) { @@ -553,7 +553,7 @@ private static bool TestMatchSub(FilterParams filterParams, string line, string } else { - if (line.ToLower().Contains(lowerSearchText)) + if (line.Contains(lowerSearchText, StringComparison.CurrentCultureIgnoreCase)) { return true; } @@ -577,7 +577,7 @@ private static bool TestMatchSub(FilterParams filterParams, string line, string } } - if (filterParams.fuzzyValue > 0) + if (filterParams.FuzzyValue > 0) { int range = line.Length - searchText.Length; if (range > 0) @@ -585,14 +585,15 @@ private static bool TestMatchSub(FilterParams filterParams, string line, string for (int i = 0; i < range; ++i) { string src = line.Substring(i, searchText.Length); - if (!filterParams.isCaseSensitive) + + if (!filterParams.IsCaseSensitive) { src = src.ToLower(); } - string dest = filterParams.isCaseSensitive ? searchText : lowerSearchText; + int dist = DamerauLevenshteinDistance(src, searchText); - if ((searchText.Length + 1) / (float)(dist + 1) >= - 11F / (float)(filterParams.fuzzyValue + 1F)) + + if ((searchText.Length + 1) / (float)(dist + 1) >= 11F / (float)(filterParams.FuzzyValue + 1F)) { return true; } diff --git a/src/Logexpert.Core/Entities/Bookmark.cs b/src/Logexpert.Core/Entities/Bookmark.cs index e90b5017..a150b8f3 100644 --- a/src/Logexpert.Core/Entities/Bookmark.cs +++ b/src/Logexpert.Core/Entities/Bookmark.cs @@ -4,16 +4,12 @@ namespace LogExpert.Core.Entities { public class Bookmark { - #region Fields - - #endregion - #region cTor public Bookmark(int lineNum) { LineNum = lineNum; - Text = ""; + Text = string.Empty; Overlay = new BookmarkOverlay(); } diff --git a/src/Logexpert.Core/Entities/BookmarkCollection.cs b/src/Logexpert.Core/Entities/BookmarkCollection.cs index ae5e187e..a5d48b8a 100644 --- a/src/Logexpert.Core/Entities/BookmarkCollection.cs +++ b/src/Logexpert.Core/Entities/BookmarkCollection.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; namespace LogExpert.Core.Entities { diff --git a/src/Logexpert.Core/Entities/BookmarkOverlay.cs b/src/Logexpert.Core/Entities/BookmarkOverlay.cs index 40eff0b3..b4ccff75 100644 --- a/src/Logexpert.Core/Entities/BookmarkOverlay.cs +++ b/src/Logexpert.Core/Entities/BookmarkOverlay.cs @@ -4,10 +4,6 @@ namespace LogExpert.Core.Entities { public class BookmarkOverlay { - #region Fields - - #endregion - #region Properties public Bookmark Bookmark { get; set; } diff --git a/src/Logexpert.Core/Entities/DebugOptions.cs b/src/Logexpert.Core/Entities/DebugOptions.cs index 4f91448d..10f0b768 100644 --- a/src/Logexpert.Core/Entities/DebugOptions.cs +++ b/src/Logexpert.Core/Entities/DebugOptions.cs @@ -2,10 +2,6 @@ { public class DebugOptions { - #region Fields - - public static bool disableWordHighlight = false; - - #endregion + public static bool DisableWordHighlight { get; set; } = false; } } \ No newline at end of file diff --git a/src/Logexpert.Core/Entities/DefaultLogfileColumnizer.cs b/src/Logexpert.Core/Entities/DefaultLogfileColumnizer.cs index 139aceef..9f1a327e 100644 --- a/src/Logexpert.Core/Entities/DefaultLogfileColumnizer.cs +++ b/src/Logexpert.Core/Entities/DefaultLogfileColumnizer.cs @@ -21,21 +21,24 @@ public int GetColumnCount() public string[] GetColumnNames() { - return new string[] { "Text" }; + return ["Text"]; } public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) { - ColumnizedLogLine cLogLine = new(); - cLogLine.LogLine = line; - cLogLine.ColumnValues = new IColumn[] + ColumnizedLogLine cLogLine = new() { + LogLine = line + }; + + cLogLine.ColumnValues = + [ new Column { FullValue = line.FullLine, Parent = cLogLine } - }; + ]; return cLogLine; diff --git a/src/Logexpert.Core/Entities/EncodingOptions.cs b/src/Logexpert.Core/Entities/EncodingOptions.cs index b5196b64..d66bd336 100644 --- a/src/Logexpert.Core/Entities/EncodingOptions.cs +++ b/src/Logexpert.Core/Entities/EncodingOptions.cs @@ -7,10 +7,6 @@ namespace LogExpert.Core.Entities /// public class EncodingOptions { - #region Fields - - #endregion - #region Properties /// diff --git a/src/Logexpert.Core/Entities/FileViewContext.cs b/src/Logexpert.Core/Entities/FileViewContext.cs index 676fee60..07f4d20f 100644 --- a/src/Logexpert.Core/Entities/FileViewContext.cs +++ b/src/Logexpert.Core/Entities/FileViewContext.cs @@ -2,27 +2,13 @@ namespace LogExpert.Core.Entities { - public class FileViewContext + public class FileViewContext(ILogPaintContext logPaintContext, ILogView logView) { - #region Fields - - #endregion - - #region cTor - - public FileViewContext(ILogPaintContext logPaintContext, ILogView logView) - { - LogPaintContext = logPaintContext; - LogView = logView; - } - - #endregion - #region Properties - public ILogPaintContext LogPaintContext { get; } + public ILogPaintContext LogPaintContext { get; } = logPaintContext; - public ILogView LogView { get; } + public ILogView LogView { get; } = logView; #endregion } diff --git a/src/Logexpert.Core/Entities/MultifileOptions.cs b/src/Logexpert.Core/Entities/MultifileOptions.cs index 6eadccb7..04858e4e 100644 --- a/src/Logexpert.Core/Entities/MultifileOptions.cs +++ b/src/Logexpert.Core/Entities/MultifileOptions.cs @@ -1,30 +1,13 @@ -using System; - -namespace LogExpert.Core.Entities +namespace LogExpert.Core.Entities { [Serializable] public class MultiFileOptions { - #region Fields - - private string _formatPattern = "*$J(.)"; - private int _maxDayTry = 3; - - #endregion - #region Properties - public int MaxDayTry - { - get => _maxDayTry; - set => _maxDayTry = value; - } + public int MaxDayTry { get; set; } = 3; - public string FormatPattern - { - get => _formatPattern; - set => _formatPattern = value; - } + public string FormatPattern { get; set; } = "*$J(.)"; #endregion } diff --git a/src/Logexpert.Core/Entities/ReloadMemento.cs b/src/Logexpert.Core/Entities/ReloadMemento.cs index 0566b8d8..03f9cfa9 100644 --- a/src/Logexpert.Core/Entities/ReloadMemento.cs +++ b/src/Logexpert.Core/Entities/ReloadMemento.cs @@ -2,11 +2,8 @@ { public class ReloadMemento { - #region Fields + public int CurrentLine { get; set; } - public int currentLine; - public int firstDisplayedLine; - - #endregion + public int FirstDisplayedLine { get; set; } } } \ No newline at end of file diff --git a/src/Logexpert.Core/Entities/RowHeightEntry.cs b/src/Logexpert.Core/Entities/RowHeightEntry.cs index 35e82320..26c879a2 100644 --- a/src/Logexpert.Core/Entities/RowHeightEntry.cs +++ b/src/Logexpert.Core/Entities/RowHeightEntry.cs @@ -2,10 +2,6 @@ { public class RowHeightEntry { - #region Fields - - #endregion - #region cTor public RowHeightEntry() diff --git a/src/Logexpert.Core/Entities/SearchParams.cs b/src/Logexpert.Core/Entities/SearchParams.cs index ab7487ba..a3e8e75f 100644 --- a/src/Logexpert.Core/Entities/SearchParams.cs +++ b/src/Logexpert.Core/Entities/SearchParams.cs @@ -3,21 +3,23 @@ [Serializable] public class SearchParams { - #region Fields + public int CurrentLine { get; set; } - public int currentLine; - public List historyList = []; - public bool isCaseSensitive = false; - public bool isFindNext; + public List HistoryList { get; set; } = []; - public bool isForward = true; - public bool isFromTop = false; - public bool isRegex = false; + public bool IsCaseSensitive { get; set; } = false; - [NonSerialized] public bool isShiftF3Pressed = false; + public bool IsFindNext { get; set; } - public string searchText = string.Empty; + public bool IsForward { get; set; } = true; - #endregion + public bool IsFromTop { get; set; } = false; + + public bool IsRegex { get; set; } = false; + + public string SearchText { get; set; } = string.Empty; + + [field: NonSerialized] + public bool IsShiftF3Pressed { get; set; } } } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/FilterColumnChooser.cs b/src/Logexpert.UI/Dialogs/FilterColumnChooser.cs index e063524e..d5c1330d 100644 --- a/src/Logexpert.UI/Dialogs/FilterColumnChooser.cs +++ b/src/Logexpert.UI/Dialogs/FilterColumnChooser.cs @@ -25,7 +25,7 @@ public FilterColumnChooser(FilterParams filterParams) columnListBox.ItemHeight = columnListBox.Font.Height; - _columnizer = filterParams.currentColumnizer; + _columnizer = filterParams.CurrentColumnizer; _filterParams = filterParams; Init(); @@ -42,13 +42,13 @@ private void Init() for (int i = 0; i < count; ++i) { - columnListBox.Items.Add(names[i], _filterParams.columnList.Contains(i)); + columnListBox.Items.Add(names[i], _filterParams.ColumnList.Contains(i)); } - emptyColumnUsePrevRadioButton.Checked = _filterParams.emptyColumnUsePrev; - emptyColumnHitRadioButton.Checked = _filterParams.emptyColumnHit; - emptyColumnNoHitRadioButton.Checked = _filterParams.emptyColumnHit == false && _filterParams.emptyColumnUsePrev == false; - checkBoxExactMatch.Checked = _filterParams.exactColumnMatch; + emptyColumnUsePrevRadioButton.Checked = _filterParams.EmptyColumnUsePrev; + emptyColumnHitRadioButton.Checked = _filterParams.EmptyColumnHit; + emptyColumnNoHitRadioButton.Checked = _filterParams.EmptyColumnHit == false && _filterParams.EmptyColumnUsePrev == false; + checkBoxExactMatch.Checked = _filterParams.ExactColumnMatch; } #endregion @@ -57,16 +57,16 @@ private void Init() private void OnOkButtonClick(object sender, EventArgs e) { - _filterParams.columnList.Clear(); + _filterParams.ColumnList.Clear(); foreach (int colNum in columnListBox.CheckedIndices) { - _filterParams.columnList.Add(colNum); + _filterParams.ColumnList.Add(colNum); } - _filterParams.emptyColumnUsePrev = emptyColumnUsePrevRadioButton.Checked; - _filterParams.emptyColumnHit = emptyColumnHitRadioButton.Checked; - _filterParams.exactColumnMatch = checkBoxExactMatch.Checked; + _filterParams.EmptyColumnUsePrev = emptyColumnUsePrevRadioButton.Checked; + _filterParams.EmptyColumnHit = emptyColumnHitRadioButton.Checked; + _filterParams.ExactColumnMatch = checkBoxExactMatch.Checked; } #endregion diff --git a/src/Logexpert.UI/Dialogs/SearchDialog.cs b/src/Logexpert.UI/Dialogs/SearchDialog.cs index 418425e9..b74ee792 100644 --- a/src/Logexpert.UI/Dialogs/SearchDialog.cs +++ b/src/Logexpert.UI/Dialogs/SearchDialog.cs @@ -41,7 +41,7 @@ private void OnSearchDialogLoad(object? sender, EventArgs e) { if (SearchParams != null) { - if (SearchParams.isFromTop) + if (SearchParams.IsFromTop) { radioButtonFromTop.Checked = true; } @@ -50,7 +50,7 @@ private void OnSearchDialogLoad(object? sender, EventArgs e) radioButtonFromSelected.Checked = true; } - if (SearchParams.isForward) + if (SearchParams.IsForward) { radioButtonForward.Checked = true; } @@ -59,9 +59,9 @@ private void OnSearchDialogLoad(object? sender, EventArgs e) radioButtonBackward.Checked = true; } - checkBoxRegex.Checked = SearchParams.isRegex; - checkBoxCaseSensitive.Checked = SearchParams.isCaseSensitive; - foreach (string item in SearchParams.historyList) + checkBoxRegex.Checked = SearchParams.IsRegex; + checkBoxCaseSensitive.Checked = SearchParams.IsCaseSensitive; + foreach (string item in SearchParams.HistoryList) { comboBoxSearchFor.Items.Add(item); } @@ -109,17 +109,17 @@ private void OnButtonOkClick(object sender, EventArgs e) Regex.IsMatch("", comboBoxSearchFor.Text); } - SearchParams.searchText = comboBoxSearchFor.Text; - SearchParams.isCaseSensitive = checkBoxCaseSensitive.Checked; - SearchParams.isForward = radioButtonForward.Checked; - SearchParams.isFromTop = radioButtonFromTop.Checked; - SearchParams.isRegex = checkBoxRegex.Checked; - SearchParams.historyList.Remove(comboBoxSearchFor.Text); - SearchParams.historyList.Insert(0, comboBoxSearchFor.Text); + SearchParams.SearchText = comboBoxSearchFor.Text; + SearchParams.IsCaseSensitive = checkBoxCaseSensitive.Checked; + SearchParams.IsForward = radioButtonForward.Checked; + SearchParams.IsFromTop = radioButtonFromTop.Checked; + SearchParams.IsRegex = checkBoxRegex.Checked; + SearchParams.HistoryList.Remove(comboBoxSearchFor.Text); + SearchParams.HistoryList.Insert(0, comboBoxSearchFor.Text); - if (SearchParams.historyList.Count > MAX_HISTORY) + if (SearchParams.HistoryList.Count > MAX_HISTORY) { - SearchParams.historyList.RemoveAt(SearchParams.historyList.Count - 1); + SearchParams.HistoryList.RemoveAt(SearchParams.HistoryList.Count - 1); } } catch (Exception ex) diff --git a/src/PluginRegistry/FileSystem/LogFileInfo.cs b/src/PluginRegistry/FileSystem/LogFileInfo.cs index d94aef21..7c8c4438 100644 --- a/src/PluginRegistry/FileSystem/LogFileInfo.cs +++ b/src/PluginRegistry/FileSystem/LogFileInfo.cs @@ -54,7 +54,6 @@ public char DirectorySeparatorChar public Uri Uri { get; } - public long Length { get @@ -63,7 +62,9 @@ public long Length { return -1; } + int retry = RETRY_COUNT; + while (retry > 0) { try @@ -81,6 +82,7 @@ public long Length Thread.Sleep(RETRY_SLEEP); } } + return -1; } } @@ -161,6 +163,7 @@ public Stream OpenStream() } } + //TODO Replace with Event from FileSystemWatcher public bool FileHasChanged() { if (LengthWithoutRetry != lastLength) @@ -171,7 +174,6 @@ public bool FileHasChanged() return false; } - public override string ToString() { return fInfo.FullName + ", OldLen: " + OriginalLength + ", Len: " + Length; From 54431dc9ccedaac0000ccb4d21a102ba05071b05 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Tue, 20 May 2025 09:44:29 +0200 Subject: [PATCH 020/142] wrong branche --- src/LogExpert/Classes/Log/LogfileReader.cs | 46 ---------------------- 1 file changed, 46 deletions(-) diff --git a/src/LogExpert/Classes/Log/LogfileReader.cs b/src/LogExpert/Classes/Log/LogfileReader.cs index b0cc13dd..f55f6373 100644 --- a/src/LogExpert/Classes/Log/LogfileReader.cs +++ b/src/LogExpert/Classes/Log/LogfileReader.cs @@ -53,8 +53,6 @@ public class LogfileReader : IAutoLogLineColumnizerCallback private ReaderWriterLock _lruCacheDictLock; - private readonly FileSystemWatcher _fileWatcher; - private bool _shouldStop; private ILogFileInfo _watchedILogFileInfo; @@ -78,22 +76,6 @@ public LogfileReader(string fileName, EncodingOptions encodingOptions, bool mult _logLineFx = GetLogLineInternal; InitLruBuffers(); - - - _fileWatcher = new FileSystemWatcher - { - Path = Path.GetDirectoryName(fileName), - Filter = Path.GetFileName(fileName), - NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size - }; - - _fileWatcher.Changed += OnChanged; - _fileWatcher.Deleted += OnDeleted; - _fileWatcher.Renamed += OnRenamed; - _fileWatcher.Error += OnError; - - _fileWatcher.EnableRaisingEvents = true; - if (multiFile) { ILogFileInfo info = GetLogFileInfo(fileName); @@ -116,34 +98,6 @@ public LogfileReader(string fileName, EncodingOptions encodingOptions, bool mult StartGCThread(); } - private void OnChanged(object sender, FileSystemEventArgs e) - { - if (e.ChangeType != WatcherChangeTypes.Changed) - { - return; - } - } - - private void OnCreated(object sender, FileSystemEventArgs e) - { - string value = $"Created: {e.FullPath}"; - } - - private void OnDeleted(object sender, FileSystemEventArgs e) - { - _isDeleted = true; - - } - - private void OnRenamed(object sender, RenamedEventArgs e) - { - } - - private void OnError(object sender, ErrorEventArgs e) - { - - } - public LogfileReader(string[] fileNames, EncodingOptions encodingOptions, int bufferCount, int linesPerBuffer, MultiFileOptions multiFileOptions) { if (fileNames == null || fileNames.Length < 1) From fb44d16b6449bb661a969e86706ca1307e4cd59a Mon Sep 17 00:00:00 2001 From: Hirogen Date: Wed, 21 May 2025 08:10:23 +0200 Subject: [PATCH 021/142] review comments --- src/LogExpert/Classes/Filter/FilterStarter.cs | 2 +- src/LogExpert/Classes/RangeFinder.cs | 47 +++++++++---------- .../Classes/Filter/FilterParams.cs | 14 ++++-- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/LogExpert/Classes/Filter/FilterStarter.cs b/src/LogExpert/Classes/Filter/FilterStarter.cs index 36b5ead8..2f57e509 100644 --- a/src/LogExpert/Classes/Filter/FilterStarter.cs +++ b/src/LogExpert/Classes/Filter/FilterStarter.cs @@ -149,7 +149,7 @@ private Filter DoWork(FilterParams filterParams, int startLine, int maxCount, Pr _logger.Info("Started Filter worker [{0}] for line {1}", Environment.CurrentManagedThreadId, startLine); // Give every thread own copies of ColumnizerCallback and FilterParams, because the state of the objects changes while filtering - FilterParams threadFilterParams = filterParams.Copy(); + FilterParams threadFilterParams = filterParams.CopyCurrentColumnizer(); ColumnizerCallback threadColumnizerCallback = _callback.CreateCopy(); Filter filter = new(threadColumnizerCallback); diff --git a/src/LogExpert/Classes/RangeFinder.cs b/src/LogExpert/Classes/RangeFinder.cs index b8807746..9a2fb546 100644 --- a/src/LogExpert/Classes/RangeFinder.cs +++ b/src/LogExpert/Classes/RangeFinder.cs @@ -10,24 +10,12 @@ namespace LogExpert.Classes /// /// Delivers the range (from..to) that matches the current range filter settings starting from a given line. /// - public class RangeFinder + public class RangeFinder(FilterParams filterParams, ColumnizerCallback callback) { #region Fields private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - - private readonly ColumnizerCallback _callback; - private readonly FilterParams _filterParams; - - #endregion - - #region cTor - - public RangeFinder(FilterParams filterParams, ColumnizerCallback callback) - { - _filterParams = filterParams.Copy(); - _callback = callback; - } + private readonly FilterParams _filterParams = filterParams.CopyCurrentColumnizer(); #endregion @@ -36,6 +24,7 @@ public RangeFinder(FilterParams filterParams, ColumnizerCallback callback) public Range FindRange(int startLine) { _logger.Info($"Starting range search for {_filterParams.SearchText} ... {_filterParams.RangeSearchText}"); + if (_filterParams.RangeSearchText == null || _filterParams.RangeSearchText.Trim().Length == 0) { _logger.Info("Range search text not set. Cancelling range search."); @@ -49,46 +38,54 @@ public Range FindRange(int startLine) _filterParams.IsRangeSearch = false; _filterParams.IsInRange = false; - int lineCount = _callback.GetLineCount(); + + int lineCount = callback.GetLineCount(); int lineNum = startLine; bool foundStartLine = false; + Range range = new(); - FilterParams tmpParam = _filterParams.Copy(); + FilterParams tmpParam = _filterParams.CopyCurrentColumnizer(); + tmpParam.SearchText = _filterParams.RangeSearchText; // search backward for starting keyword - var line = _callback.GetLogLine(lineNum); + var line = callback.GetLogLine(lineNum); + while (lineNum >= 0) { - _callback.LineNum = lineNum; - if (Util.TestFilterCondition(_filterParams, line, _callback)) + callback.LineNum = lineNum; + + if (Util.TestFilterCondition(_filterParams, line, callback)) { foundStartLine = true; break; } lineNum--; - line = _callback.GetLogLine(lineNum); - if (lineNum < 0 || Util.TestFilterCondition(tmpParam, line, _callback) - ) // do not crash on Ctrl+R when there is not start line found + line = callback.GetLogLine(lineNum); + + if (lineNum < 0 || Util.TestFilterCondition(tmpParam, line, callback)) // do not crash on Ctrl+R when there is not start line found { // lower range bound found --> we are not in between a valid range break; } } + if (!foundStartLine) { _logger.Info("Range start not found"); return null; } + range.StartLine = lineNum; _filterParams.IsRangeSearch = true; _filterParams.IsInRange = true; lineNum++; + while (lineNum < lineCount) { - line = _callback.GetLogLine(lineNum); - _callback.LineNum = lineNum; - if (!Util.TestFilterCondition(_filterParams, line, _callback)) + line = callback.GetLogLine(lineNum); + callback.LineNum = lineNum; + if (!Util.TestFilterCondition(_filterParams, line, callback)) { break; } diff --git a/src/Logexpert.Core/Classes/Filter/FilterParams.cs b/src/Logexpert.Core/Classes/Filter/FilterParams.cs index f7b89a6f..c004d828 100644 --- a/src/Logexpert.Core/Classes/Filter/FilterParams.cs +++ b/src/Logexpert.Core/Classes/Filter/FilterParams.cs @@ -9,8 +9,8 @@ public class FilterParams { #region Fields - private string _rangeSearchText = ""; - private string _searchText = ""; + private string _rangeSearchText = string.Empty; + private string _searchText = string.Empty; //public List historyList = new List(); //public List rangeHistoryList = new List(); @@ -25,7 +25,7 @@ public string SearchText set { _searchText = value; - LowerSearchText = _searchText.ToLower(); + LowerSearchText = _searchText.ToLowerInvariant(); } } @@ -35,7 +35,7 @@ public string RangeSearchText set { _rangeSearchText = value; - LowerRangeSearchText = _rangeSearchText.ToLower(); + LowerRangeSearchText = _rangeSearchText.ToLowerInvariant(); } } @@ -105,7 +105,7 @@ public string RangeSearchText #region Public methods - public FilterParams Copy() + public FilterParams CopyCurrentColumnizer() { FilterParams newParams = MemberwiseCopy(); newParams.Init(); @@ -143,6 +143,10 @@ public void CreateRegex() } } + /// + /// Shallow Copy + /// + /// public FilterParams MemberwiseCopy() { return (FilterParams)MemberwiseClone(); From 3b97d5d055a519d11c4adba4eccd5954c456dec1 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Wed, 21 May 2025 08:57:47 +0200 Subject: [PATCH 022/142] review comments --- src/LogExpert/Classes/Filter/FilterStarter.cs | 2 +- src/LogExpert/Classes/RangeFinder.cs | 4 +-- .../LogWindow/LogWindowEventHandlers.cs | 4 +-- .../Controls/LogWindow/LogWindowPrivate.cs | 8 ++--- .../Controls/LogWindow/LogWindowsPublic.cs | 30 ++++++++++++------- .../Classes/Filter/FilterParams.cs | 21 ++++++++++--- .../Classes/Persister/FilterTabData.cs | 7 ++--- .../Classes/Persister/Persister.cs | 21 ++++++++----- 8 files changed, 60 insertions(+), 37 deletions(-) diff --git a/src/LogExpert/Classes/Filter/FilterStarter.cs b/src/LogExpert/Classes/Filter/FilterStarter.cs index 2f57e509..cbce334b 100644 --- a/src/LogExpert/Classes/Filter/FilterStarter.cs +++ b/src/LogExpert/Classes/Filter/FilterStarter.cs @@ -149,7 +149,7 @@ private Filter DoWork(FilterParams filterParams, int startLine, int maxCount, Pr _logger.Info("Started Filter worker [{0}] for line {1}", Environment.CurrentManagedThreadId, startLine); // Give every thread own copies of ColumnizerCallback and FilterParams, because the state of the objects changes while filtering - FilterParams threadFilterParams = filterParams.CopyCurrentColumnizer(); + FilterParams threadFilterParams = filterParams.CloneWithCurrentColumnizer(); ColumnizerCallback threadColumnizerCallback = _callback.CreateCopy(); Filter filter = new(threadColumnizerCallback); diff --git a/src/LogExpert/Classes/RangeFinder.cs b/src/LogExpert/Classes/RangeFinder.cs index 9a2fb546..63538a2c 100644 --- a/src/LogExpert/Classes/RangeFinder.cs +++ b/src/LogExpert/Classes/RangeFinder.cs @@ -15,7 +15,7 @@ public class RangeFinder(FilterParams filterParams, ColumnizerCallback callback) #region Fields private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - private readonly FilterParams _filterParams = filterParams.CopyCurrentColumnizer(); + private readonly FilterParams _filterParams = filterParams.CloneWithCurrentColumnizer(); #endregion @@ -44,7 +44,7 @@ public Range FindRange(int startLine) bool foundStartLine = false; Range range = new(); - FilterParams tmpParam = _filterParams.CopyCurrentColumnizer(); + FilterParams tmpParam = _filterParams.CloneWithCurrentColumnizer(); tmpParam.SearchText = _filterParams.RangeSearchText; diff --git a/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs index 1cf9318c..78d8da1b 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs @@ -1343,7 +1343,7 @@ private void OnToggleHighlightPanelButtonClick(object sender, EventArgs e) private void OnSaveFilterButtonClick(object sender, EventArgs e) { - FilterParams newParams = _filterParams.MemberwiseCopy(); + FilterParams newParams = _filterParams.Clone(); newParams.Color = Color.FromKnownColor(KnownColor.Black); ConfigManager.Settings.filterList.Add(newParams); OnFilterListChanged(this); @@ -1402,7 +1402,7 @@ private void OnFilterListBoxMouseDoubleClick(object sender, MouseEventArgs e) if (filterListBox.SelectedIndex >= 0) { FilterParams filterParams = (FilterParams)filterListBox.Items[filterListBox.SelectedIndex]; - FilterParams newParams = filterParams.MemberwiseCopy(); + FilterParams newParams = filterParams.Clone(); //newParams.historyList = ConfigManager.Settings.filterHistoryList; this._filterParams = newParams; ReInitFilterParams(this._filterParams); diff --git a/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs index e06c226a..41e2d047 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs @@ -291,14 +291,14 @@ private void RestoreFilterTabs(PersistenceData persistenceData) { foreach (FilterTabData data in persistenceData.filterTabDataList) { - FilterParams persistFilterParams = data.filterParams; + FilterParams persistFilterParams = data.FilterParams; ReInitFilterParams(persistFilterParams); List filterResultList = []; //List lastFilterResultList = new List(); List filterHitList = []; Filter(persistFilterParams, filterResultList, _lastFilterLinesList, filterHitList); - FilterPipe pipe = new(persistFilterParams.MemberwiseCopy(), this); - WritePipeToTab(pipe, filterResultList, data.persistenceData.tabName, data.persistenceData); + FilterPipe pipe = new(persistFilterParams.Clone(), this); + WritePipeToTab(pipe, filterResultList, data.PersistenceData.tabName, data.PersistenceData); } } @@ -2680,7 +2680,7 @@ private void FilterToTab() private void WriteFilterToTab() { - FilterPipe pipe = new(_filterParams.MemberwiseCopy(), this); + FilterPipe pipe = new(_filterParams.Clone(), this); lock (_filterResultList) { string namePrefix = "->F"; diff --git a/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs b/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs index b94b40d2..18dd68e6 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs +++ b/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs @@ -246,9 +246,11 @@ public PersistenceData GetPersistenceData() foreach (FilterPipe filterPipe in _filterPipeList) { - FilterTabData data = new(); - data.persistenceData = filterPipe.OwnLogWindow.GetPersistenceData(); - data.filterParams = filterPipe.FilterParams; + FilterTabData data = new() + { + PersistenceData = filterPipe.OwnLogWindow.GetPersistenceData(), + FilterParams = filterPipe.FilterParams + }; persistenceData.filterTabDataList.Add(data); } } @@ -486,9 +488,11 @@ public void CellPainting(BufferedDataGridView gridView, int rowIndex, DataGridVi if (bookmark.Text.Length > 0) { - StringFormat format = new(); - format.LineAlignment = StringAlignment.Center; - format.Alignment = StringAlignment.Center; + StringFormat format = new() + { + LineAlignment = StringAlignment.Center, + Alignment = StringAlignment.Center + }; Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); Font font = new("Courier New", Preferences.fontSize, FontStyle.Bold); e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), @@ -1190,8 +1194,10 @@ public void CopyMarkedLinesToTab() lineNumList.Sort(); // create dummy FilterPipe for connecting line numbers to original window // setting IsStopped to true prevents further filter processing - FilterPipe pipe = new FilterPipe(new FilterParams(), this); - pipe.IsStopped = true; + FilterPipe pipe = new FilterPipe(new FilterParams(), this) + { + IsStopped = true + }; WritePipeToTab(pipe, lineNumList, Text + "->C", null); } else @@ -1235,9 +1241,11 @@ public void Reload() { SavePersistenceData(false); - _reloadMemento = new ReloadMemento(); - _reloadMemento.CurrentLine = dataGridView.CurrentCellAddress.Y; - _reloadMemento.FirstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex; + _reloadMemento = new ReloadMemento + { + CurrentLine = dataGridView.CurrentCellAddress.Y, + FirstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex + }; _forcedColumnizerForLoading = CurrentColumnizer; if (_fileNames == null || !IsMultiFile) diff --git a/src/Logexpert.Core/Classes/Filter/FilterParams.cs b/src/Logexpert.Core/Classes/Filter/FilterParams.cs index c004d828..c195a46e 100644 --- a/src/Logexpert.Core/Classes/Filter/FilterParams.cs +++ b/src/Logexpert.Core/Classes/Filter/FilterParams.cs @@ -5,7 +5,7 @@ namespace LogExpert.Core.Classes.Filter { [Serializable] - public class FilterParams + public class FilterParams : ICloneable { #region Fields @@ -105,9 +105,13 @@ public string RangeSearchText #region Public methods - public FilterParams CopyCurrentColumnizer() + /// + /// Returns a new FilterParams object with the current columnizer set to the one used in this object. + /// + /// + public FilterParams CloneWithCurrentColumnizer() { - FilterParams newParams = MemberwiseCopy(); + FilterParams newParams = Clone(); newParams.Init(); // removed cloning of columnizer for filtering, because this causes issues with columnizers that hold internal states (like CsvColumnizer) // newParams.currentColumnizer = Util.CloneColumnizer(this.currentColumnizer); @@ -147,11 +151,20 @@ public void CreateRegex() /// Shallow Copy /// /// - public FilterParams MemberwiseCopy() + public FilterParams Clone() { return (FilterParams)MemberwiseClone(); } + /// + /// Shallow Copy + /// + /// + object ICloneable.Clone() + { + return Clone(); + } + #endregion } } \ No newline at end of file diff --git a/src/Logexpert.Core/Classes/Persister/FilterTabData.cs b/src/Logexpert.Core/Classes/Persister/FilterTabData.cs index 346bd413..99ba728a 100644 --- a/src/Logexpert.Core/Classes/Persister/FilterTabData.cs +++ b/src/Logexpert.Core/Classes/Persister/FilterTabData.cs @@ -4,11 +4,8 @@ namespace LogExpert.Core.Classes.Persister { public class FilterTabData { - #region Fields + public FilterParams FilterParams { get; set; } = new(); - public FilterParams filterParams; - public PersistenceData persistenceData; - - #endregion + public PersistenceData PersistenceData { get; set; } = new(); } } \ No newline at end of file diff --git a/src/Logexpert.Core/Classes/Persister/Persister.cs b/src/Logexpert.Core/Classes/Persister/Persister.cs index c69996eb..33eb710d 100644 --- a/src/Logexpert.Core/Classes/Persister/Persister.cs +++ b/src/Logexpert.Core/Classes/Persister/Persister.cs @@ -47,6 +47,7 @@ public class PersistenceData #endregion } + //TODO Rewrite as json Persister, xml is outdated and difficult to parse and write public class Persister { #region Fields @@ -245,7 +246,7 @@ private static void WriteFilterTabs(XmlDocument xmlDoc, XmlElement rootElement, rootElement.AppendChild(filterTabsElement); foreach (FilterTabData data in dataList) { - PersistenceData persistenceData = data.persistenceData; + PersistenceData persistenceData = data.PersistenceData; XmlElement filterTabElement = xmlDoc.CreateElement("filterTab"); filterTabsElement.AppendChild(filterTabElement); WriteBookmarks(xmlDoc, filterTabElement, persistenceData.bookmarkList); @@ -255,7 +256,7 @@ private static void WriteFilterTabs(XmlDocument xmlDoc, XmlElement rootElement, WriteFilterTabs(xmlDoc, filterTabElement, persistenceData.filterTabDataList); XmlElement filterElement = xmlDoc.CreateElement("tabFilter"); filterTabElement.AppendChild(filterElement); - List filterList = [data.filterParams]; + List filterList = [data.FilterParams]; WriteFilter(xmlDoc, filterElement, filterList); } } @@ -276,8 +277,8 @@ private static List ReadFilterTabs(XmlElement startNode) { List filterList = ReadFilter(filterNode as XmlElement); FilterTabData data = new(); - data.persistenceData = persistenceData; - data.filterParams = filterList[0]; // there's only 1 + data.PersistenceData = persistenceData; + data.FilterParams = filterList[0]; // there's only 1 dataList.Add(data); } } @@ -426,6 +427,7 @@ private static Encoding ReadEncoding(XmlElement fileElement) string posX = null; string posY = null; string line = null; + foreach (XmlAttribute attr in node.Attributes) { if (attr.Name.Equals("line")) @@ -454,8 +456,12 @@ private static Encoding ReadEncoding(XmlElement fileElement) continue; } int lineNum = int.Parse(line); - Entities.Bookmark bookmark = new(lineNum); - bookmark.OverlayOffset = new Size(int.Parse(posX), int.Parse(posY)); + + Entities.Bookmark bookmark = new(lineNum) + { + OverlayOffset = new Size(int.Parse(posX), int.Parse(posY)) + }; + if (text != null) { bookmark.Text = text; @@ -466,8 +472,7 @@ private static Encoding ReadEncoding(XmlElement fileElement) return bookmarkList; } - private static void WriteRowHeightList(XmlDocument xmlDoc, XmlElement rootElement, - SortedList rowHeightList) + private static void WriteRowHeightList(XmlDocument xmlDoc, XmlElement rootElement, SortedList rowHeightList) { XmlElement rowheightElement = xmlDoc.CreateElement("rowheights"); rootElement.AppendChild(rowheightElement); From a191e65cc6efa5e7163077fcd778c4de5cd9cf0f Mon Sep 17 00:00:00 2001 From: Hirogen Date: Fri, 23 May 2025 12:50:49 +0200 Subject: [PATCH 023/142] replaced grpc with namedpipes --- src/LogExpert.sln | 6 - .../Classes/LogExpertApplicationContext.cs | 6 +- src/LogExpert/Classes/LogExpertProxy.cs | 7 +- src/LogExpert/LogExpert.csproj | 5 - src/LogExpert/Program.cs | 235 ++++++++++++------ src/LogExpert/gRPC/LogExpert.proto | 45 ---- src/Logexpert.Core/Classes/CmdLine.cs | 72 ++---- src/Logexpert.Core/Classes/IPC/IpcMessage.cs | 13 + .../Classes/IPC/IpcMessageType.cs | 9 + src/Logexpert.Core/Classes/IPC/LoadPayload.cs | 7 + .../Classes/Persister/Persister.cs | 15 +- 11 files changed, 233 insertions(+), 187 deletions(-) delete mode 100644 src/LogExpert/gRPC/LogExpert.proto create mode 100644 src/Logexpert.Core/Classes/IPC/IpcMessage.cs create mode 100644 src/Logexpert.Core/Classes/IPC/IpcMessageType.cs create mode 100644 src/Logexpert.Core/Classes/IPC/LoadPayload.cs diff --git a/src/LogExpert.sln b/src/LogExpert.sln index f8d00794..81360b89 100644 --- a/src/LogExpert.sln +++ b/src/LogExpert.sln @@ -56,8 +56,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "setup", "setup", "{C625E7C2 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RegexColumnizer.UnitTests", "RegexColumnizer.UnitTests\RegexColumnizer.UnitTests.csproj", "{FBFB598D-B94A-4AD3-A355-0D5A618CEEE3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogexpertgRPCService", "LogexpertgRPCService\LogexpertgRPCService.csproj", "{D31D1721-9DEA-45A4-B813-D5023B2EC2CC}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.Core", "Logexpert.Core\LogExpert.Core.csproj", "{F49C6738-3F62-4890-8FF2-1F53A0F0A2CD}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.Resources", "Logexpert.Resources\LogExpert.Resources.csproj", "{578CC5D5-1DCD-47C2-8BD3-B32C14635BEC}" @@ -138,10 +136,6 @@ Global {FBFB598D-B94A-4AD3-A355-0D5A618CEEE3}.Debug|Any CPU.Build.0 = Debug|Any CPU {FBFB598D-B94A-4AD3-A355-0D5A618CEEE3}.Release|Any CPU.ActiveCfg = Release|Any CPU {FBFB598D-B94A-4AD3-A355-0D5A618CEEE3}.Release|Any CPU.Build.0 = Release|Any CPU - {D31D1721-9DEA-45A4-B813-D5023B2EC2CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D31D1721-9DEA-45A4-B813-D5023B2EC2CC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D31D1721-9DEA-45A4-B813-D5023B2EC2CC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D31D1721-9DEA-45A4-B813-D5023B2EC2CC}.Release|Any CPU.Build.0 = Release|Any CPU {F49C6738-3F62-4890-8FF2-1F53A0F0A2CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F49C6738-3F62-4890-8FF2-1F53A0F0A2CD}.Debug|Any CPU.Build.0 = Debug|Any CPU {F49C6738-3F62-4890-8FF2-1F53A0F0A2CD}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/src/LogExpert/Classes/LogExpertApplicationContext.cs b/src/LogExpert/Classes/LogExpertApplicationContext.cs index b0a2af95..28099012 100644 --- a/src/LogExpert/Classes/LogExpertApplicationContext.cs +++ b/src/LogExpert/Classes/LogExpertApplicationContext.cs @@ -1,7 +1,7 @@ -using System; -using System.Windows.Forms; +using LogExpert.Controls.LogTabWindow; -using LogExpert.Controls.LogTabWindow; +using System; +using System.Windows.Forms; namespace LogExpert.Classes { diff --git a/src/LogExpert/Classes/LogExpertProxy.cs b/src/LogExpert/Classes/LogExpertProxy.cs index 31513af7..40f97257 100644 --- a/src/LogExpert/Classes/LogExpertProxy.cs +++ b/src/LogExpert/Classes/LogExpertProxy.cs @@ -1,5 +1,4 @@ using LogExpert.Controls.LogTabWindow; -using LogExpert.Grpc; using LogExpert.Interface; using NLog; @@ -10,11 +9,11 @@ namespace LogExpert.Classes { - internal class LogExpertProxy : LogExpertService.LogExpertServiceBase, ILogExpertProxy + internal class LogExpertProxy : ILogExpertProxy { #region Fields - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); [NonSerialized] private readonly List _windowList = []; @@ -113,7 +112,7 @@ public void NewWindowOrLockedWindow(string[] fileNames) public void NewWindowWorker(string[] fileNames) { _logger.Info("Creating new LogTabWindow"); - LogTabWindow logWin = new(fileNames.Length > 0 ? fileNames : null, _logWindowIndex++, true) + LogTabWindow logWin = new(fileNames?.Length > 0 ? fileNames : null, _logWindowIndex++, true) { LogExpertProxy = this }; diff --git a/src/LogExpert/LogExpert.csproj b/src/LogExpert/LogExpert.csproj index 9d3c42b9..d57155ce 100644 --- a/src/LogExpert/LogExpert.csproj +++ b/src/LogExpert/LogExpert.csproj @@ -61,10 +61,6 @@ - - - - @@ -72,7 +68,6 @@ - diff --git a/src/LogExpert/Program.cs b/src/LogExpert/Program.cs index 27d21ec5..d025673a 100644 --- a/src/LogExpert/Program.cs +++ b/src/LogExpert/Program.cs @@ -1,15 +1,14 @@ -using Grpc.Core; -using Grpc.Net.Client; - -using LogExpert.Classes; +using LogExpert.Classes; using LogExpert.Config; using LogExpert.Controls.LogTabWindow; using LogExpert.Core.Classes; +using LogExpert.Core.Classes.IPC; using LogExpert.Core.Config; using LogExpert.Dialogs; using LogExpert.UI.Dialogs; -using LogexpertGRPCService.Services; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using NLog; @@ -17,10 +16,13 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.IO.Pipes; using System.Reflection; using System.Security; using System.Security.Principal; +using System.Text; using System.Threading; +using System.Threading.Tasks; using System.Windows.Forms; namespace LogExpert @@ -28,7 +30,11 @@ namespace LogExpert internal static class Program { #region Fields - private static readonly ILogger _logger = LogManager.GetLogger("Program"); + + private static readonly Logger _logger = LogManager.GetLogger("Program"); + private const string PIPE_SERVER_NAME = "LogExpert_IPC"; + private static readonly CancellationTokenSource _cts = new(); + #endregion #region Private Methods @@ -41,13 +47,7 @@ private static void Main(string[] orgArgs) { try { - var server = new Server() - { - Services = { Grpc.LogExpertService.BindService(new LogExpertServiceImpl()) }, - Ports = { new ServerPort("localhost", 5001, ServerCredentials.Insecure) } - }; - - Sub_Main(server, orgArgs); + Sub_Main(orgArgs); } catch (SecurityException se) { @@ -55,7 +55,7 @@ private static void Main(string[] orgArgs) } } - private static void Sub_Main(Server server, string[] orgArgs) + private static void Sub_Main(string[] orgArgs) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.ThreadException += Application_ThreadException; @@ -70,25 +70,8 @@ private static void Sub_Main(Server server, string[] orgArgs) CmdLineString configFile = new("config", false, "A configuration (settings) file"); cmdLine.RegisterParameter(configFile); string[] remainingArgs = cmdLine.Parse(orgArgs); + string[] absoluteFilePaths = GenerateAbsoluteFilePaths(remainingArgs); - List argsList = []; - - // This loop tries to convert relative file names into absolute file names (assuming that platform file names are given). - // It tolerates errors, to give file system plugins (e.g. sftp) a change later. - // TODO: possibly should be moved to LocalFileSystem plugin - foreach (string fileArg in remainingArgs) - { - try - { - FileInfo info = new(fileArg); - argsList.Add(info.Exists ? info.FullName : fileArg); - } - catch (Exception) - { - argsList.Add(fileArg); - } - } - string[] args = [.. argsList]; if (configFile.Exists) { FileInfo cfgFileInfo = new(configFile.Value); @@ -102,6 +85,7 @@ private static void Sub_Main(Server server, string[] orgArgs) MessageBox.Show(@"Config file not found", @"LogExpert"); } } + PluginRegistry.PluginRegistry.Instance.Create(ConfigManager.ConfigDir, ConfigManager.Settings.Preferences.pollingInterval); int pId = Process.GetCurrentProcess().SessionId; @@ -117,52 +101,29 @@ private static void Sub_Main(Server server, string[] orgArgs) // first application instance Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - LogTabWindow logWin = new(args.Length > 0 ? args : null, 1, false); + LogTabWindow logWin = new(absoluteFilePaths.Length > 0 ? absoluteFilePaths : null, 1, false); // first instance WindowsIdentity wi = WindowsIdentity.GetCurrent(); - - server.Start(); - - //IpcServerChannel ipcChannel = new IpcServerChannel("LogExpert" + pId); - //ChannelServices.RegisterChannel(ipcChannel, false); - //RemotingConfiguration.RegisterWellKnownServiceType(typeof(LogExpertProxy), "LogExpertProxy", WellKnownObjectMode.Singleton); LogExpertProxy proxy = new(logWin); - //RemotingServices.Marshal(proxy, "LogExpertProxy"); - LogExpertApplicationContext context = new(proxy, logWin); - Application.Run(context); - //ChannelServices.UnregisterChannel(ipcChannel); - server.ShutdownAsync().Wait(); + Task.Run(() => RunServerLoopAsync(SendCommandToServer, proxy, _cts.Token)); + + Application.Run(context); } else { int counter = 3; Exception errMsg = null; - //IpcClientChannel ipcChannel = new IpcClientChannel("LogExpertClient#" + pId, null); - //ChannelServices.RegisterChannel(ipcChannel, false); while (counter > 0) { try { - using var channel = GrpcChannel.ForAddress("https://localhost:5001"); - var client = new Grpc.LogExpertService.LogExpertServiceClient(channel); - - //Console.WriteLine("Greeting: " + reply.Result); - // another instance already exists WindowsIdentity wi = WindowsIdentity.GetCurrent(); - //LogExpertProxy proxy = (LogExpertProxy)Activator.GetObject(typeof(LogExpertProxy), "ipc://LogExpert" + pId + "/LogExpertProxy"); - if (settings.Preferences.allowOnlyOneInstance) - { - client.LoadFiles(new Grpc.FileNames { FileNames_ = { args } }); - } - else - { - client.NewWindowOrLockedWindow(new Grpc.FileNames { FileNames_ = { args } }); - } - + var command = SerializeCommandIntoNonFormattedJSON(absoluteFilePaths, settings.Preferences.allowOnlyOneInstance); + SendCommandToServer(command); break; } catch (Exception e) @@ -188,8 +149,6 @@ private static void Sub_Main(Server server, string[] orgArgs) settings.Preferences.ShowErrorMessageAllowOnlyOneInstances = !a.DoNotShowThisMessageAgain; ConfigManager.Save(SettingsFlags.All); } - - //MessageBox.Show($"Only one instance allowed, uncheck \"View Settings => Allow only 1 Instances\" to start multiple instances!", "Logexpert"); } } @@ -202,26 +161,153 @@ private static void Sub_Main(Server server, string[] orgArgs) } } + private static string SerializeCommandIntoNonFormattedJSON(string[] fileNames, bool allowOnlyOneInstance) + { + var message = new IpcMessage() + { + Type = allowOnlyOneInstance ? IpcMessageType.NewWindowOrLockedWindow : IpcMessageType.NewWindow, + Payload = JObject.FromObject(new LoadPayload { Files = [.. fileNames] }) + }; + + return JsonConvert.SerializeObject(message, Formatting.None); + } + + // This loop tries to convert relative file names into absolute file names (assuming that platform file names are given). + // It tolerates errors, to give file system plugins (e.g. sftp) a change later. + // TODO: possibly should be moved to LocalFileSystem plugin + private static string[] GenerateAbsoluteFilePaths(string[] remainingArgs) + { + List argsList = []; + + foreach (string fileArg in remainingArgs) + { + try + { + FileInfo info = new(fileArg); + argsList.Add(info.Exists ? info.FullName : fileArg); + } + catch (Exception) + { + argsList.Add(fileArg); + } + } + + return [.. argsList]; + } + + private static void SendCommandToServer(IpcMessage message, LogExpertProxy proxy) + { + switch (message.Type) + { + case IpcMessageType.Load: + { + var payLoad = message.Payload.ToObject(); + + if (CheckPayload(payLoad)) + { + proxy.LoadFiles([.. payLoad.Files]); + } + } + break; + case IpcMessageType.NewWindow: + { + var payLoad = message.Payload.ToObject(); + if (CheckPayload(payLoad)) + { + proxy.NewWindow([.. payLoad.Files]); + } + } + break; + case IpcMessageType.NewWindowOrLockedWindow: + { + var payLoad = message.Payload.ToObject(); + if (CheckPayload(payLoad)) + { + proxy.NewWindowOrLockedWindow([.. payLoad.Files]); + } + } + break; + default: + _logger.Error($"Unknown IPC Message Type {message.Type}"); + break; + } + } + + private static bool CheckPayload(LoadPayload payLoad) + { + if (payLoad == null) + { + _logger.Error("Invalid payload for NewWindow command"); + return false; + } + + return true; + } + + private static void SendCommandToServer(string command) + { + using var client = new NamedPipeClientStream(".", PIPE_SERVER_NAME, PipeDirection.Out); + client.Connect(5000); // 5 seconds timeout + using var writer = new StreamWriter(client, Encoding.UTF8) { AutoFlush = true }; + writer.WriteLine(command); + } + + private static async Task RunServerLoopAsync(Action onCommand, LogExpertProxy proxy, CancellationToken cancellationToken) + { + while (cancellationToken.IsCancellationRequested == false) + { + using var server = new NamedPipeServerStream( + PIPE_SERVER_NAME, + PipeDirection.In, + 1, + PipeTransmissionMode.Message, + PipeOptions.Asynchronous); + + try + { + await server.WaitForConnectionAsync(cancellationToken); + using var reader = new StreamReader(server, Encoding.UTF8); + string line = await reader.ReadLineAsync(cancellationToken); + + if (line != null) + { + var message = JsonConvert.DeserializeObject(line); + onCommand(message, proxy); + } + } + catch (OperationCanceledException) + { + break; + } + catch (Exception ex) + { + _logger.Warn(ex, "Pipe server error"); + } + } + } + [STAThread] private static void ShowUnhandledException(object exceptionObject) { string errorText = string.Empty; - string stackTrace = string.Empty; + string stackTrace; + if (exceptionObject is Exception exception) { errorText = exception.Message; - stackTrace = "\r\n" + exception.GetType().Name + "\r\n" + - exception.StackTrace; + stackTrace = $"\r\n{exception.GetType().Name}\r\n{exception.StackTrace}"; } else { stackTrace = exceptionObject.ToString(); string[] lines = stackTrace.Split('\n'); + if (lines != null && lines.Length > 0) { errorText = lines[0]; } } + ExceptionWindow win = new(errorText, stackTrace); _ = win.ShowDialog(); } @@ -234,9 +320,11 @@ private static void Application_ThreadException(object sender, ThreadExceptionEv { _logger.Fatal(e); - //ShowUnhandledException(e.Exception); - Thread thread = new(ShowUnhandledException); - thread.IsBackground = true; + Thread thread = new(ShowUnhandledException) + { + IsBackground = true + }; + thread.SetApartmentState(ApartmentState.STA); thread.Start(e.Exception); thread.Join(); @@ -247,9 +335,12 @@ private static void CurrentDomain_UnhandledException(object sender, UnhandledExc _logger.Fatal(e); object exceptionObject = e.ExceptionObject; - //ShowUnhandledException(exceptionObject); - Thread thread = new(ShowUnhandledException); - thread.IsBackground = true; + + Thread thread = new(ShowUnhandledException) + { + IsBackground = true + }; + thread.SetApartmentState(ApartmentState.STA); thread.Start(exceptionObject); thread.Join(); diff --git a/src/LogExpert/gRPC/LogExpert.proto b/src/LogExpert/gRPC/LogExpert.proto deleted file mode 100644 index 3a082a08..00000000 --- a/src/LogExpert/gRPC/LogExpert.proto +++ /dev/null @@ -1,45 +0,0 @@ -syntax = "proto3"; - -option csharp_namespace = "LogExpert.Grpc"; - -package logexpert; - -// The log service definition. -service LogExpertService { - // Sends a log message - rpc SendLog (LogRequest) returns (LogReply) {} - rpc LoadFiles (FileNames); - rpc NewWindow (FileNames); - rpc NewWindowOrLockedWindow (FileNames); - rpc WindowClosed(); - rpc GetLogWindowCount() returns (Count); -} - -message FileNames -{ - repeated string FileNames = 4; -} - -message Count -{ - int32 count = 0; -} - -message FilesReply -{ - bool success = false; -} - -// The request message containing the log message. -message LogRequest -{ - string message = 1; -} - -message LoadFiles(repeated ) - -// The response message containing the response. -message LogReply -{ - string result = 1; -} \ No newline at end of file diff --git a/src/Logexpert.Core/Classes/CmdLine.cs b/src/Logexpert.Core/Classes/CmdLine.cs index 6f2e151a..cea24b31 100644 --- a/src/Logexpert.Core/Classes/CmdLine.cs +++ b/src/Logexpert.Core/Classes/CmdLine.cs @@ -3,6 +3,7 @@ * */ +//TODO Replace with https://github.com/commandlineparser/commandline namespace LogExpert.Core.Classes { /// @@ -32,29 +33,14 @@ public CmdLineException(string message) /// Parameters are words in the command line beginning with a hyphen (-). /// The value of the parameter is the next word in /// - public class CmdLineParameter + /// + /// Creates a new instance of this class. + /// + /// Name of parameter. + /// Require that the parameter is present in the command line. + /// The explanation of the parameter to add to the help screen. + public class CmdLineParameter(string name, bool required, string helpMessage) { - #region Fields - - #endregion - - #region cTor - - /// - /// Creates a new instance of this class. - /// - /// Name of parameter. - /// Require that the parameter is present in the command line. - /// The explanation of the parameter to add to the help screen. - public CmdLineParameter(string name, bool required, string helpMessage) - { - Name = name; - Required = required; - Help = helpMessage; - } - - #endregion - #region Properties /// @@ -65,7 +51,7 @@ public CmdLineParameter(string name, bool required, string helpMessage) /// /// Returns the help message associated with the parameter. /// - public string Help { get; } = ""; + public string Help { get; } = helpMessage; /// /// Returns true if the parameter was found in the command line. @@ -75,12 +61,12 @@ public CmdLineParameter(string name, bool required, string helpMessage) /// /// Returns true if the parameter is required in the command line. /// - public bool Required { get; } = false; + public bool Required { get; } = required; /// /// Returns the name of the parameter. /// - public string Name { get; } + public string Name { get; } = name; #endregion @@ -195,16 +181,8 @@ public static implicit operator int(CmdLineInt s) /// /// Represents an string command line parameter. /// - public class CmdLineString : CmdLineParameter + public class CmdLineString(string name, bool required, string helpMessage) : CmdLineParameter(name, required, helpMessage) { - #region cTor - - public CmdLineString(string name, bool required, string helpMessage) - : base(name, required, helpMessage) - { - } - - #endregion #region Public methods @@ -250,11 +228,11 @@ public CmdLineParameter this[string name] { get { - if (!parameters.ContainsKey(name)) + if (parameters.TryGetValue(name, out CmdLineParameter? value) == false) { throw new CmdLineException(name, "Not a registered parameter."); } - return parameters[name]; + return value; } } @@ -304,8 +282,8 @@ public string[] Parse(string[] args) if (args[i].Length > 1 && args[i][0] == '-') { // The current string is a parameter name - string key = args[i].Substring(1, args[i].Length - 1).ToLower(); - string value = ""; + string key = args[i][1..].ToLower(); + string argsValue = string.Empty; i++; if (i < args.Length) { @@ -316,21 +294,21 @@ public string[] Parse(string[] args) else { // The next string is a value, read the value and move forward - value = args[i]; + argsValue = args[i]; i++; } } - if (!parameters.ContainsKey(key)) + if (parameters.TryGetValue(key, out CmdLineParameter? cmdLineParameter) == false) { throw new CmdLineException(key, "Parameter is not allowed."); } - if (parameters[key].Exists) + if (cmdLineParameter.Exists) { throw new CmdLineException(key, "Parameter is specified more than once."); } - parameters[key].SetValue(value); + cmdLineParameter.SetValue(argsValue); } else { @@ -343,7 +321,7 @@ public string[] Parse(string[] args) // Check that required parameters are present in the command line. foreach (string key in parameters.Keys) { - if (parameters[key].Required && !parameters[key].Exists) + if (parameters[key].Required && parameters[key].Exists == false) { throw new CmdLineException(key, "Required parameter is not found."); } @@ -400,9 +378,9 @@ public ConsoleCmdLine() public new string[] Parse(string[] args) { - string[] ret = null; + string[] ret = []; - string error = ""; + string error = string.Empty; try { @@ -415,13 +393,11 @@ public ConsoleCmdLine() if (this["help"].Exists) { - //foreach(string s in base.HelpScreen().Split('\n')) - // Console.WriteLine(s); Console.WriteLine(HelpScreen()); Environment.Exit(0); } - if (error != "") + if (error != string.Empty) { Console.WriteLine(error); Console.WriteLine("Use -help for more information."); diff --git a/src/Logexpert.Core/Classes/IPC/IpcMessage.cs b/src/Logexpert.Core/Classes/IPC/IpcMessage.cs new file mode 100644 index 00000000..2549ed89 --- /dev/null +++ b/src/Logexpert.Core/Classes/IPC/IpcMessage.cs @@ -0,0 +1,13 @@ +using Newtonsoft.Json.Linq; + +namespace LogExpert.Core.Classes.IPC +{ + public class IpcMessage + { + public int Version { get; set; } + + public IpcMessageType Type { get; set; } = IpcMessageType.Load; + + public JObject Payload { get; set; } = []; + } +} diff --git a/src/Logexpert.Core/Classes/IPC/IpcMessageType.cs b/src/Logexpert.Core/Classes/IPC/IpcMessageType.cs new file mode 100644 index 00000000..cd4a4f7f --- /dev/null +++ b/src/Logexpert.Core/Classes/IPC/IpcMessageType.cs @@ -0,0 +1,9 @@ +namespace LogExpert.Core.Classes.IPC +{ + public enum IpcMessageType + { + Load, + NewWindow, + NewWindowOrLockedWindow + } +} diff --git a/src/Logexpert.Core/Classes/IPC/LoadPayload.cs b/src/Logexpert.Core/Classes/IPC/LoadPayload.cs new file mode 100644 index 00000000..6d5252a3 --- /dev/null +++ b/src/Logexpert.Core/Classes/IPC/LoadPayload.cs @@ -0,0 +1,7 @@ +namespace LogExpert.Core.Classes.IPC +{ + public class LoadPayload + { + public List Files { get; set; } = []; + } +} diff --git a/src/Logexpert.Core/Classes/Persister/Persister.cs b/src/Logexpert.Core/Classes/Persister/Persister.cs index 33eb710d..2b5ef94f 100644 --- a/src/Logexpert.Core/Classes/Persister/Persister.cs +++ b/src/Logexpert.Core/Classes/Persister/Persister.cs @@ -52,7 +52,7 @@ public class Persister { #region Fields - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); #endregion @@ -322,9 +322,16 @@ private static List ReadFilter(XmlElement startNode) string base64Text = subNode.InnerText; byte[] data = Convert.FromBase64String(base64Text); MemoryStream stream = new(data); - FilterParams filterParams = JsonSerializer.Deserialize(stream); - filterParams.Init(); - filterList.Add(filterParams); + try + { + FilterParams filterParams = JsonSerializer.Deserialize(stream); + filterParams.Init(); + filterList.Add(filterParams); + } + catch (Exception ex) + { + _logger.Error("Error while deserializing filter params"); + } } } } From 78d8aa8780775a0f99369afdcc136832b882f7d2 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Fri, 23 May 2025 12:52:08 +0200 Subject: [PATCH 024/142] removed grpc project --- .../LogexpertgRPCService.csproj | 18 ------- src/LogexpertgRPCService/Program.cs | 14 ------ .../Properties/launchSettings.json | 23 --------- .../Protos/Logexpert.proto | 47 ------------------- .../Services/LogExpertServiceImpl.cs | 34 -------------- .../appsettings.Development.json | 8 ---- src/LogexpertgRPCService/appsettings.json | 14 ------ 7 files changed, 158 deletions(-) delete mode 100644 src/LogexpertgRPCService/LogexpertgRPCService.csproj delete mode 100644 src/LogexpertgRPCService/Program.cs delete mode 100644 src/LogexpertgRPCService/Properties/launchSettings.json delete mode 100644 src/LogexpertgRPCService/Protos/Logexpert.proto delete mode 100644 src/LogexpertgRPCService/Services/LogExpertServiceImpl.cs delete mode 100644 src/LogexpertgRPCService/appsettings.Development.json delete mode 100644 src/LogexpertgRPCService/appsettings.json diff --git a/src/LogexpertgRPCService/LogexpertgRPCService.csproj b/src/LogexpertgRPCService/LogexpertgRPCService.csproj deleted file mode 100644 index a5d0b2bf..00000000 --- a/src/LogexpertgRPCService/LogexpertgRPCService.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - net8.0 - enable - false - enable - - - true - ..\Solution Items\Key.snk - - - - - - - - \ No newline at end of file diff --git a/src/LogexpertgRPCService/Program.cs b/src/LogexpertgRPCService/Program.cs deleted file mode 100644 index 7ecdb775..00000000 --- a/src/LogexpertgRPCService/Program.cs +++ /dev/null @@ -1,14 +0,0 @@ -using LogexpertGRPCService.Services; - -var builder = WebApplication.CreateBuilder(args); - -// Add services to the container. -builder.Services.AddGrpc(); - -var app = builder.Build(); - -// Configure the HTTP request pipeline. -app.MapGrpcService(); -app.MapGet("/", () => "Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909"); - -app.Run(); diff --git a/src/LogexpertgRPCService/Properties/launchSettings.json b/src/LogexpertgRPCService/Properties/launchSettings.json deleted file mode 100644 index 25ca2150..00000000 --- a/src/LogexpertgRPCService/Properties/launchSettings.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "profiles": { - "http": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": false, - "applicationUrl": "http://localhost:5282", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "https": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": false, - "applicationUrl": "https://localhost:7125;http://localhost:5282", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} diff --git a/src/LogexpertgRPCService/Protos/Logexpert.proto b/src/LogexpertgRPCService/Protos/Logexpert.proto deleted file mode 100644 index 838357a7..00000000 --- a/src/LogexpertgRPCService/Protos/Logexpert.proto +++ /dev/null @@ -1,47 +0,0 @@ -syntax = "proto3"; - -option csharp_namespace = "LogExpert.Grpc"; - -import "google/protobuf/empty.proto"; - -package logexpert; - -// The log service definition. -service LogExpertService -{ - // Sends a log message - rpc SendLog (LogRequest) returns (LogReply) ; - rpc LoadFiles (FileNames) returns (FilesReply); - rpc NewWindow (FileNames) returns (FilesReply); - rpc NewWindowOrLockedWindow (FileNames) returns (FilesReply); - //is this really needed? - rpc WindowClosed(google.protobuf.Empty) returns (google.protobuf.Empty); - rpc GetLogWindowCount(google.protobuf.Empty) returns (Count); -} - -message FileNames -{ - repeated string fileNames = 1; -} - -message Count -{ - int32 count = 1; -} - -message FilesReply -{ - bool success = 1; -} - -// The request message containing the log message. -message LogRequest -{ - string message = 1; -} - -// The response message containing the response. -message LogReply -{ - string result = 1; -} \ No newline at end of file diff --git a/src/LogexpertgRPCService/Services/LogExpertServiceImpl.cs b/src/LogexpertgRPCService/Services/LogExpertServiceImpl.cs deleted file mode 100644 index 86a237d4..00000000 --- a/src/LogexpertgRPCService/Services/LogExpertServiceImpl.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Grpc.Core; - -using LogExpert.Grpc; - -namespace LogexpertGRPCService.Services -{ - public class LogExpertServiceImpl : LogExpertService.LogExpertServiceBase - { - public override Task SendLog(LogRequest request, ServerCallContext context) - { - return Task.FromResult(new LogReply { Result = "Hello " + request.Message }); - } - - public override Task LoadFiles(FileNames fileNames, ServerCallContext context) - { - return Task.FromResult(new FilesReply { Success = true }); - } - - public override Task NewWindow(FileNames fileNames, ServerCallContext context) - { - return Task.FromResult(new FilesReply { Success = true }); - } - - public override Task NewWindowOrLockedWindow(FileNames fileNames, ServerCallContext context) - { - return Task.FromResult(new FilesReply { Success = true }); - } - - //public override void WindowClosed() - //{ - - //} - } -} diff --git a/src/LogexpertgRPCService/appsettings.Development.json b/src/LogexpertgRPCService/appsettings.Development.json deleted file mode 100644 index 0c208ae9..00000000 --- a/src/LogexpertgRPCService/appsettings.Development.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - } -} diff --git a/src/LogexpertgRPCService/appsettings.json b/src/LogexpertgRPCService/appsettings.json deleted file mode 100644 index 1aef5074..00000000 --- a/src/LogexpertgRPCService/appsettings.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "AllowedHosts": "*", - "Kestrel": { - "EndpointDefaults": { - "Protocols": "Http2" - } - } -} From dcdaa4b29626e9b6a190e46cb7292e3ba78febab Mon Sep 17 00:00:00 2001 From: Hirogen Date: Fri, 23 May 2025 14:05:16 +0200 Subject: [PATCH 025/142] review comments --- src/LogExpert/Program.cs | 23 ++++++++++++++++++- .../Classes/Persister/Persister.cs | 3 ++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/LogExpert/Program.cs b/src/LogExpert/Program.cs index d025673a..009d8feb 100644 --- a/src/LogExpert/Program.cs +++ b/src/LogExpert/Program.cs @@ -33,6 +33,7 @@ internal static class Program private static readonly Logger _logger = LogManager.GetLogger("Program"); private const string PIPE_SERVER_NAME = "LogExpert_IPC"; + private const int PIPE_CONNECTION_TIMEOUT_IN_MS = 5000; private static readonly CancellationTokenSource _cts = new(); #endregion @@ -247,7 +248,27 @@ private static bool CheckPayload(LoadPayload payLoad) private static void SendCommandToServer(string command) { using var client = new NamedPipeClientStream(".", PIPE_SERVER_NAME, PipeDirection.Out); - client.Connect(5000); // 5 seconds timeout + + try + { + client.Connect(PIPE_CONNECTION_TIMEOUT_IN_MS); + } + catch (TimeoutException) + { + _logger.Error("Timeout connecting to pipe server"); + return; + } + catch (IOException ex) + { + _logger.Warn(ex, "An I/O error occurred while connecting to the pipe server."); + return; + } + catch (UnauthorizedAccessException ex) + { + _logger.Warn(ex, "Unauthorized access while connecting to the pipe server."); + return; + } + using var writer = new StreamWriter(client, Encoding.UTF8) { AutoFlush = true }; writer.WriteLine(command); } diff --git a/src/Logexpert.Core/Classes/Persister/Persister.cs b/src/Logexpert.Core/Classes/Persister/Persister.cs index 2b5ef94f..1dbc6e2a 100644 --- a/src/Logexpert.Core/Classes/Persister/Persister.cs +++ b/src/Logexpert.Core/Classes/Persister/Persister.cs @@ -322,6 +322,7 @@ private static List ReadFilter(XmlElement startNode) string base64Text = subNode.InnerText; byte[] data = Convert.FromBase64String(base64Text); MemoryStream stream = new(data); + try { FilterParams filterParams = JsonSerializer.Deserialize(stream); @@ -330,7 +331,7 @@ private static List ReadFilter(XmlElement startNode) } catch (Exception ex) { - _logger.Error("Error while deserializing filter params"); + _logger.Error($"Error while deserializing filter params. {ex}"); } } } From 0681205ffa217d1ccbf49d8cd0eb8420f9a2d6e6 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Fri, 23 May 2025 14:13:47 +0200 Subject: [PATCH 026/142] review comment --- src/Logexpert.Core/Classes/Persister/Persister.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Logexpert.Core/Classes/Persister/Persister.cs b/src/Logexpert.Core/Classes/Persister/Persister.cs index 1dbc6e2a..c5057224 100644 --- a/src/Logexpert.Core/Classes/Persister/Persister.cs +++ b/src/Logexpert.Core/Classes/Persister/Persister.cs @@ -269,16 +269,21 @@ private static List ReadFilterTabs(XmlElement startNode) if (filterTabsNode != null) { XmlNodeList filterTabNodeList = filterTabsNode.ChildNodes; // all "filterTab" nodes + foreach (XmlNode node in filterTabNodeList) { PersistenceData persistenceData = ReadPersistenceDataFromNode(node); XmlNode filterNode = node.SelectSingleNode("tabFilter"); + if (filterNode != null) { List filterList = ReadFilter(filterNode as XmlElement); - FilterTabData data = new(); - data.PersistenceData = persistenceData; - data.FilterParams = filterList[0]; // there's only 1 + FilterTabData data = new() + { + PersistenceData = persistenceData, + FilterParams = filterList[0] // there's only 1 + }; + dataList.Add(data); } } @@ -329,9 +334,9 @@ private static List ReadFilter(XmlElement startNode) filterParams.Init(); filterList.Add(filterParams); } - catch (Exception ex) + catch (JsonException ex) { - _logger.Error($"Error while deserializing filter params. {ex}"); + _logger.Error($"Error while deserializing filter params. Exception Message: {ex.Message}"); } } } From a7d83ed6b5af463341900d8cf23d4179e58993e1 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Fri, 23 May 2025 14:25:19 +0200 Subject: [PATCH 027/142] review comments --- src/LogExpert/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LogExpert/Program.cs b/src/LogExpert/Program.cs index 009d8feb..910b1b39 100644 --- a/src/LogExpert/Program.cs +++ b/src/LogExpert/Program.cs @@ -109,7 +109,7 @@ private static void Sub_Main(string[] orgArgs) LogExpertProxy proxy = new(logWin); LogExpertApplicationContext context = new(proxy, logWin); - Task.Run(() => RunServerLoopAsync(SendCommandToServer, proxy, _cts.Token)); + Task.Run(() => RunServerLoopAsync(SendMessageToProxy, proxy, _cts.Token)); Application.Run(context); } @@ -196,7 +196,7 @@ private static string[] GenerateAbsoluteFilePaths(string[] remainingArgs) return [.. argsList]; } - private static void SendCommandToServer(IpcMessage message, LogExpertProxy proxy) + private static void SendMessageToProxy(IpcMessage message, LogExpertProxy proxy) { switch (message.Type) { From 1345a7d8fb0d8e11199c409eea7d5fd28c2425ab Mon Sep 17 00:00:00 2001 From: Hirogen Date: Fri, 23 May 2025 14:27:40 +0200 Subject: [PATCH 028/142] cancel token --- src/LogExpert/Program.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/LogExpert/Program.cs b/src/LogExpert/Program.cs index 910b1b39..4dbdac5e 100644 --- a/src/LogExpert/Program.cs +++ b/src/LogExpert/Program.cs @@ -53,6 +53,7 @@ private static void Main(string[] orgArgs) catch (SecurityException se) { MessageBox.Show("Insufficient system rights for LogExpert. Maybe you have started it from a network drive. Please start LogExpert from a local drive.\n(" + se.Message + ")", "LogExpert Error"); + _cts.Cancel(); } } @@ -154,10 +155,12 @@ private static void Sub_Main(string[] orgArgs) } mutex.Close(); + _cts.Cancel(); } catch (Exception ex) { _logger.Error(ex, "Mutex error, giving up: "); + _cts.Cancel(); MessageBox.Show($"Cannot open connection to first instance ({ex.Message})", "LogExpert"); } } From 8e706abd8211066d29a952f7dcf65f9782be1311 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Fri, 23 May 2025 04:18:59 +0300 Subject: [PATCH 029/142] Moved all the UI controls from LogExpert to LogExpert.UI. Fixed a logic bug where taking the first element in an array but the array might be empty. Removed some warnings. Licenses moved to a more central place Removed the auto generated .resx files from the LogExpert.UI project in order to prevent an error of duplication in resources. This might happen when opening the files in design mode inside VS. --- .../Licenses => Licenses}/Nlog.license.txt | 60 +- .../WinformsUI.Docking.license.txt | 18 +- src/LogExpert.Tests/BufferShiftTest.cs | 7 +- src/LogExpert.Tests/CSVColumnizerTest.cs | 4 +- src/LogExpert.Tests/ColumnizerPickerTest.cs | 8 +- src/LogExpert.Tests/JSONSaveTest.cs | 10 +- src/LogExpert.Tests/JsonColumnizerTest.cs | 4 +- .../JsonCompactColumnizerTest.cs | 4 +- src/LogExpert.Tests/LocalFileSystemTest.cs | 3 +- src/LogExpert.Tests/RolloverHandlerTest.cs | 6 +- .../SquareBracketColumnizerTest.cs | 6 +- .../Classes/LogExpertApplicationContext.cs | 5 +- src/LogExpert/Classes/LogExpertProxy.cs | 32 +- src/LogExpert/Config/ConfigManager.cs | 33 +- src/LogExpert/Controls/LogTabPage.cs | 7 +- .../Controls/LogTabWindow/LogTabWindow.cs | 358 - .../LogTabWindow/LogTabWindowEventHandlers.cs | 1026 --- .../LogTabWindow/LogTabWindowPrivate.cs | 1336 --- .../LogTabWindow/LogTabWindowPublic.cs | 360 - ...llowOnlyOneInstanceErrorDialog.Designer.cs | 100 - .../AllowOnlyOneInstanceErrorDialog.cs | 25 - .../Dialogs/BookmarkWindow.Designer.cs | 196 - src/LogExpert/Dialogs/BookmarkWindow.cs | 677 -- .../Dialogs/BufferedDataGridView.Designer.cs | 36 - src/LogExpert/Dialogs/BufferedDataGridView.cs | 343 - .../Dialogs/FilterSelectorForm.Designer.cs | 156 - src/LogExpert/Dialogs/FilterSelectorForm.cs | 99 - .../Dialogs/HighlightDialog.Designer.cs | 726 -- src/LogExpert/Dialogs/HighlightDialog.cs | 728 -- .../Dialogs/ParamRequesterDialog.Designer.cs | 105 - src/LogExpert/Dialogs/ParamRequesterDialog.cs | 62 - .../Dialogs/SettingsDialog.Designer.cs | 1846 ---- src/LogExpert/Dialogs/SettingsDialog.cs | 1038 --- .../Dialogs/ToolArgsDialog.Designer.cs | 151 - src/LogExpert/Dialogs/ToolArgsDialog.cs | 97 - .../CurrentHighlightGroupChangedEventArgs.cs | 16 - .../EventArgs/FilterListChangedEventArgs.cs | 13 - src/LogExpert/LogExpert.csproj | 39 +- src/LogExpert/Program.cs | 23 +- .../Callback}/ColumnizerCallback.cs | 11 +- .../Classes/Bookmark/BookmarkView.cs | 1 + .../Classes/Columnizer/TimestampColumnizer.cs | 7 +- .../Classes/Filter/Filter.cs | 361 +- .../Classes/Filter/FilterCancelHandler.cs | 68 +- .../Classes/Filter/FilterParams.cs | 2 + .../Classes/Filter/FilterPipe.cs | 397 +- .../Classes/Filter/FilterStarter.cs | 448 +- .../Classes/Log/LogfileReader.cs | 3677 ++++---- .../Classes/Log/RolloverFilenameHandler.cs | 219 +- .../BookmarkEventArgs.cs | 2 +- .../ColumnizerEventArgs.cs | 2 +- .../ConfigChangedEventArgs.cs | 2 +- .../ContextMenuPluginEventArgs.cs | 2 +- .../CurrentHighlightGroupChangedEventArgs.cs | 16 + .../FilterListChangedEventArgs.cs | 14 + .../GuiStateArgs.cs | 2 +- .../LoadFileEventArgs.cs | 2 +- .../OverlayEventArgs.cs | 2 +- .../PatternArgs.cs | 2 +- .../ProgressEventArgs.cs | 2 +- .../SelectLineEventArgs.cs | 2 +- .../StatusEventArgs.cs | 2 +- .../SyncModeEventArgs.cs | 2 +- .../EventHandlers/EventHandlers.cs | 8 + ....cs => IBackgroundProcessCancelHandler.cs} | 2 +- src/Logexpert.Core/Interface/IBookmarkView.cs | 1 + .../Interface/IConfigManager.cs | 21 + .../Interface/ILogExpertProxy.cs | 76 +- src/Logexpert.Core/Interface/ILogTabWindow.cs | 14 + src/Logexpert.Core/Interface/ILogWindow.cs | 29 + .../Interface/IPluginRegistry.cs | 9 + src/Logexpert.Core/Logexpert.Core.csproj | 8 +- .../Controls/BufferedDataGridView.Designer.cs | 35 + .../Controls/BufferedDataGridView.cs | 341 + src/Logexpert.UI/Controls/ColorComboBox.cs | 149 +- .../Controls/DateTimeDragControl.Designer.cs | 0 .../Controls/DateTimeDragControl.cs | 0 .../Controls/DateTimeDragControl.resx | 0 .../Controls/KnobControl.Designer.cs | 2 +- src/Logexpert.UI/Controls/KnobControl.cs | 2 +- .../Controls}/LogGridCell.cs | 6 +- .../Controls}/LogTextColumn.cs | 2 +- .../Controls/LogWindow}/ColumnCache.cs | 78 +- .../Controls/LogWindow}/LogExpertCallback.cs | 6 +- .../Controls/LogWindow/LogWindow.cs | 1364 +-- .../Controls/LogWindow/LogWindow.designer.cs | 2611 +++--- .../Controls/LogWindow/LogWindow.resx | 344 +- .../LogWindow/LogWindowEventHandlers.cs | 3281 ++++--- .../Controls/LogWindow/LogWindowPrivate.cs | 7501 ++++++++--------- .../Controls/LogWindow/LogWindowPublic.cs} | 3692 ++++---- .../LogWindow}/PatternWindow.Designer.cs | 858 +- .../Controls/LogWindow}/PatternWindow.cs | 719 +- .../Controls/LogWindow}/PatternWindow.resx | 260 +- .../Controls/LogWindow}/RangeFinder.cs | 207 +- .../LogWindow}/TimeSpreadCalculator.cs | 905 +- .../TimeSpreadigControl.Designer.cs | 2 +- .../LogWindow}/TimeSpreadigControl.cs | 8 +- .../LogWindow}/TimeSpreadigControl.resx | 0 .../Controls/LogWindow}/TimeSyncList.cs | 205 +- ...llowOnlyOneInstanceErrorDialog.Designer.cs | 98 + .../AllowOnlyOneInstanceErrorDialog.cs | 24 + .../AllowOnlyOneInstanceErrorDialog.resx | 0 .../Dialogs/BookmarkWindow.Designer.cs | 195 + src/Logexpert.UI/Dialogs/BookmarkWindow.cs | 682 ++ .../Dialogs/BookmarkWindow.resx | 300 +- .../Dialogs/ExceptionWindow.Designer.cs | 199 +- src/Logexpert.UI/Dialogs/ExceptionWindow.cs | 63 +- .../Dialogs/FilterColumnChooser.Designer.cs | 419 +- .../Dialogs/FilterColumnChooser.cs | 93 +- .../Dialogs/GotoLineDialog.Designer.cs | 199 +- src/Logexpert.UI/Dialogs/GotoLineDialog.cs | 63 +- .../Dialogs/ImportSettingsDialog.Designer.cs | 435 +- .../Dialogs/ImportSettingsDialog.cs | 129 +- .../Dialogs/KeywordActionDlg.Designer.cs | 261 +- src/Logexpert.UI/Dialogs/KeywordActionDlg.cs | 101 +- .../FilterSelectorForm.Designer.cs | 155 + .../LogTabWindow/FilterSelectorForm.cs | 102 + .../LogTabWindow}/FilterSelectorForm.resx | 266 +- .../LogTabWindow/HighlightDialog.Designer.cs | 725 ++ .../Dialogs/LogTabWindow/HighlightDialog.cs | 731 ++ .../LogTabWindow}/HighlightDialog.resx | 0 .../Dialogs/LogTabWindow/LogTabWindow.cs | 361 + .../LogTabWindow/LogTabWindow.designer.cs | 2570 +++--- .../Dialogs}/LogTabWindow/LogTabWindow.resx | 326 +- .../LogTabWindow/LogTabWindowEventHandlers.cs | 1015 +++ .../LogTabWindow/LogTabWindowPrivate.cs | 1327 +++ .../LogTabWindow/LogTabWindowPublic.cs | 351 + .../LogTabWindow/SettingsDialog.Designer.cs | 1845 ++++ .../Dialogs/LogTabWindow/SettingsDialog.cs | 1043 +++ .../Dialogs/LogTabWindow}/SettingsDialog.resx | 344 +- .../Dialogs/MultiFileMaskDialog.Designer.cs | 297 +- .../Dialogs/MultiFileMaskDialog.cs | 93 +- .../MultiLoadRequestDialog.Designer.cs | 161 +- .../Dialogs/MultiLoadRequestDialog.cs | 25 +- .../Dialogs/ParamRequesterDialog.Designer.cs | 104 + .../Dialogs/ParamRequesterDialog.cs | 61 + .../Dialogs/ParamRequesterDialog.resx | 238 +- .../Dialogs/SearchProgressDialog.Designer.cs | 133 +- .../Dialogs/SearchProgressDialog.cs | 49 +- .../Dialogs/ToolArgsDialog.Designer.cs | 150 + src/Logexpert.UI/Dialogs/ToolArgsDialog.cs | 96 + .../Dialogs/ToolArgsDialog.resx | 238 +- .../Entities}/ArgParser.cs | 310 +- .../Entities}/PaintHelper.cs | 971 +-- .../Entities/WindowFileEntry.cs | 84 +- src/Logexpert.UI/LogExpert.UI.csproj | 103 +- .../LogExpert.PluginRegistry.csproj | 2 +- src/PluginRegistry/PluginRegistry.cs | 8 +- 148 files changed, 27623 insertions(+), 27676 deletions(-) rename {src/LogExpert/Licenses => Licenses}/Nlog.license.txt (98%) rename {src/LogExpert/Licenses => Licenses}/WinformsUI.Docking.license.txt (99%) delete mode 100644 src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs delete mode 100644 src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs delete mode 100644 src/LogExpert/Controls/LogTabWindow/LogTabWindowPrivate.cs delete mode 100644 src/LogExpert/Controls/LogTabWindow/LogTabWindowPublic.cs delete mode 100644 src/LogExpert/Dialogs/AllowOnlyOneInstanceErrorDialog.Designer.cs delete mode 100644 src/LogExpert/Dialogs/AllowOnlyOneInstanceErrorDialog.cs delete mode 100644 src/LogExpert/Dialogs/BookmarkWindow.Designer.cs delete mode 100644 src/LogExpert/Dialogs/BookmarkWindow.cs delete mode 100644 src/LogExpert/Dialogs/BufferedDataGridView.Designer.cs delete mode 100644 src/LogExpert/Dialogs/BufferedDataGridView.cs delete mode 100644 src/LogExpert/Dialogs/FilterSelectorForm.Designer.cs delete mode 100644 src/LogExpert/Dialogs/FilterSelectorForm.cs delete mode 100644 src/LogExpert/Dialogs/HighlightDialog.Designer.cs delete mode 100644 src/LogExpert/Dialogs/HighlightDialog.cs delete mode 100644 src/LogExpert/Dialogs/ParamRequesterDialog.Designer.cs delete mode 100644 src/LogExpert/Dialogs/ParamRequesterDialog.cs delete mode 100644 src/LogExpert/Dialogs/SettingsDialog.Designer.cs delete mode 100644 src/LogExpert/Dialogs/SettingsDialog.cs delete mode 100644 src/LogExpert/Dialogs/ToolArgsDialog.Designer.cs delete mode 100644 src/LogExpert/Dialogs/ToolArgsDialog.cs delete mode 100644 src/LogExpert/Entities/EventArgs/CurrentHighlightGroupChangedEventArgs.cs delete mode 100644 src/LogExpert/Entities/EventArgs/FilterListChangedEventArgs.cs rename src/{LogExpert/Classes/ILogLineColumnizerCallback => Logexpert.Core/Callback}/ColumnizerCallback.cs (83%) rename src/{LogExpert => Logexpert.Core}/Classes/Filter/Filter.cs (94%) rename src/{LogExpert => Logexpert.Core}/Classes/Filter/FilterCancelHandler.cs (86%) rename src/{LogExpert => Logexpert.Core}/Classes/Filter/FilterPipe.cs (92%) rename src/{LogExpert => Logexpert.Core}/Classes/Filter/FilterStarter.cs (96%) rename src/{LogExpert => Logexpert.Core}/Classes/Log/LogfileReader.cs (96%) rename src/{LogExpert => Logexpert.Core}/Classes/Log/RolloverFilenameHandler.cs (85%) rename src/Logexpert.Core/{EventArgs => EventArguments}/BookmarkEventArgs.cs (84%) rename src/Logexpert.Core/{EventArgs => EventArguments}/ColumnizerEventArgs.cs (83%) rename src/Logexpert.Core/{EventArgs => EventArguments}/ConfigChangedEventArgs.cs (85%) rename src/Logexpert.Core/{EventArgs => EventArguments}/ContextMenuPluginEventArgs.cs (91%) create mode 100644 src/Logexpert.Core/EventArguments/CurrentHighlightGroupChangedEventArgs.cs create mode 100644 src/Logexpert.Core/EventArguments/FilterListChangedEventArgs.cs rename src/Logexpert.Core/{EventArgs => EventArguments}/GuiStateArgs.cs (96%) rename src/Logexpert.Core/{EventArgs => EventArguments}/LoadFileEventArgs.cs (72%) rename src/Logexpert.Core/{EventArgs => EventArguments}/OverlayEventArgs.cs (86%) rename src/Logexpert.Core/{EventArgs => EventArguments}/PatternArgs.cs (89%) rename src/Logexpert.Core/{EventArgs => EventArguments}/ProgressEventArgs.cs (87%) rename src/Logexpert.Core/{EventArgs => EventArguments}/SelectLineEventArgs.cs (79%) rename src/Logexpert.Core/{EventArgs => EventArguments}/StatusEventArgs.cs (94%) rename src/Logexpert.Core/{EventArgs => EventArguments}/SyncModeEventArgs.cs (81%) create mode 100644 src/Logexpert.Core/EventHandlers/EventHandlers.cs rename src/Logexpert.Core/Interface/{BackgroundProcessCancelHandler.cs => IBackgroundProcessCancelHandler.cs} (87%) create mode 100644 src/Logexpert.Core/Interface/IConfigManager.cs rename src/{LogExpert => Logexpert.Core}/Interface/ILogExpertProxy.cs (86%) create mode 100644 src/Logexpert.Core/Interface/ILogTabWindow.cs create mode 100644 src/Logexpert.Core/Interface/ILogWindow.cs create mode 100644 src/Logexpert.Core/Interface/IPluginRegistry.cs create mode 100644 src/Logexpert.UI/Controls/BufferedDataGridView.Designer.cs create mode 100644 src/Logexpert.UI/Controls/BufferedDataGridView.cs rename src/{LogExpert => Logexpert.UI}/Controls/DateTimeDragControl.Designer.cs (100%) rename src/{LogExpert => Logexpert.UI}/Controls/DateTimeDragControl.cs (100%) rename src/{LogExpert => Logexpert.UI}/Controls/DateTimeDragControl.resx (100%) rename src/{LogExpert/Dialogs => Logexpert.UI/Controls}/LogGridCell.cs (74%) rename src/{LogExpert/Dialogs => Logexpert.UI/Controls}/LogTextColumn.cs (87%) rename src/{LogExpert/Classes => Logexpert.UI/Controls/LogWindow}/ColumnCache.cs (92%) rename src/{LogExpert/Classes/ILogLineColumnizerCallback => Logexpert.UI/Controls/LogWindow}/LogExpertCallback.cs (81%) rename src/{LogExpert => Logexpert.UI}/Controls/LogWindow/LogWindow.cs (90%) rename src/{LogExpert => Logexpert.UI}/Controls/LogWindow/LogWindow.designer.cs (98%) rename src/{LogExpert => Logexpert.UI}/Controls/LogWindow/LogWindow.resx (98%) rename src/{LogExpert => Logexpert.UI}/Controls/LogWindow/LogWindowEventHandlers.cs (96%) rename src/{LogExpert => Logexpert.UI}/Controls/LogWindow/LogWindowPrivate.cs (96%) rename src/{LogExpert/Controls/LogWindow/LogWindowsPublic.cs => Logexpert.UI/Controls/LogWindow/LogWindowPublic.cs} (96%) rename src/{LogExpert/Controls => Logexpert.UI/Controls/LogWindow}/PatternWindow.Designer.cs (97%) rename src/{LogExpert/Controls => Logexpert.UI/Controls/LogWindow}/PatternWindow.cs (93%) rename src/{LogExpert/Controls => Logexpert.UI/Controls/LogWindow}/PatternWindow.resx (98%) rename src/{LogExpert/Classes => Logexpert.UI/Controls/LogWindow}/RangeFinder.cs (96%) rename src/{LogExpert/Classes => Logexpert.UI/Controls/LogWindow}/TimeSpreadCalculator.cs (95%) rename src/{LogExpert/Controls => Logexpert.UI/Controls/LogWindow}/TimeSpreadigControl.Designer.cs (97%) rename src/{LogExpert/Controls => Logexpert.UI/Controls/LogWindow}/TimeSpreadigControl.cs (98%) rename src/{LogExpert/Controls => Logexpert.UI/Controls/LogWindow}/TimeSpreadigControl.resx (100%) rename src/{LogExpert/Classes => Logexpert.UI/Controls/LogWindow}/TimeSyncList.cs (89%) create mode 100644 src/Logexpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.Designer.cs create mode 100644 src/Logexpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.cs rename src/{LogExpert => Logexpert.UI}/Dialogs/AllowOnlyOneInstanceErrorDialog.resx (100%) create mode 100644 src/Logexpert.UI/Dialogs/BookmarkWindow.Designer.cs create mode 100644 src/Logexpert.UI/Dialogs/BookmarkWindow.cs rename src/{LogExpert => Logexpert.UI}/Dialogs/BookmarkWindow.resx (98%) create mode 100644 src/Logexpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.Designer.cs create mode 100644 src/Logexpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.cs rename src/{LogExpert/Dialogs => Logexpert.UI/Dialogs/LogTabWindow}/FilterSelectorForm.resx (98%) create mode 100644 src/Logexpert.UI/Dialogs/LogTabWindow/HighlightDialog.Designer.cs create mode 100644 src/Logexpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs rename src/{LogExpert/Dialogs => Logexpert.UI/Dialogs/LogTabWindow}/HighlightDialog.resx (100%) create mode 100644 src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs rename src/{LogExpert/Controls => Logexpert.UI/Dialogs}/LogTabWindow/LogTabWindow.designer.cs (98%) rename src/{LogExpert/Controls => Logexpert.UI/Dialogs}/LogTabWindow/LogTabWindow.resx (98%) create mode 100644 src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs create mode 100644 src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs create mode 100644 src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs create mode 100644 src/Logexpert.UI/Dialogs/LogTabWindow/SettingsDialog.Designer.cs create mode 100644 src/Logexpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs rename src/{LogExpert/Dialogs => Logexpert.UI/Dialogs/LogTabWindow}/SettingsDialog.resx (98%) create mode 100644 src/Logexpert.UI/Dialogs/ParamRequesterDialog.Designer.cs create mode 100644 src/Logexpert.UI/Dialogs/ParamRequesterDialog.cs rename src/{LogExpert => Logexpert.UI}/Dialogs/ParamRequesterDialog.resx (97%) create mode 100644 src/Logexpert.UI/Dialogs/ToolArgsDialog.Designer.cs create mode 100644 src/Logexpert.UI/Dialogs/ToolArgsDialog.cs rename src/{LogExpert => Logexpert.UI}/Dialogs/ToolArgsDialog.resx (97%) rename src/{LogExpert/Classes => Logexpert.UI/Entities}/ArgParser.cs (97%) rename src/{LogExpert/Classes => Logexpert.UI/Entities}/PaintHelper.cs (95%) rename src/{LogExpert => Logexpert.UI}/Entities/WindowFileEntry.cs (81%) diff --git a/src/LogExpert/Licenses/Nlog.license.txt b/Licenses/Nlog.license.txt similarity index 98% rename from src/LogExpert/Licenses/Nlog.license.txt rename to Licenses/Nlog.license.txt index bfb68fb1..5002772d 100644 --- a/src/LogExpert/Licenses/Nlog.license.txt +++ b/Licenses/Nlog.license.txt @@ -1,30 +1,30 @@ -Copyright (c) 2004-2017 Jaroslaw Kowalski , Kim Christensen, Julian Verdurmen - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -* Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -* Neither the name of Jaroslaw Kowalski nor the names of its - contributors may be used to endorse or promote products derived from this - software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -THE POSSIBILITY OF SUCH DAMAGE. +Copyright (c) 2004-2017 Jaroslaw Kowalski , Kim Christensen, Julian Verdurmen + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of Jaroslaw Kowalski nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. diff --git a/src/LogExpert/Licenses/WinformsUI.Docking.license.txt b/Licenses/WinformsUI.Docking.license.txt similarity index 99% rename from src/LogExpert/Licenses/WinformsUI.Docking.license.txt rename to Licenses/WinformsUI.Docking.license.txt index 95e396c3..0d8a18ba 100644 --- a/src/LogExpert/Licenses/WinformsUI.Docking.license.txt +++ b/Licenses/WinformsUI.Docking.license.txt @@ -1,9 +1,9 @@ -The MIT License - -Copyright (c) 2007 Weifen Luo (email: weifenluo@yahoo.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +The MIT License + +Copyright (c) 2007 Weifen Luo (email: weifenluo@yahoo.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/LogExpert.Tests/BufferShiftTest.cs b/src/LogExpert.Tests/BufferShiftTest.cs index b87e1b1e..cde669e0 100644 --- a/src/LogExpert.Tests/BufferShiftTest.cs +++ b/src/LogExpert.Tests/BufferShiftTest.cs @@ -1,10 +1,7 @@ -using LogExpert.Classes.Log; -using LogExpert.Core.Classes.Log; +using LogExpert.Core.Classes.Log; using LogExpert.Core.Entities; using LogExpert.PluginRegistry.FileSystem; - using NUnit.Framework; - using System.Collections.Generic; using System.Linq; using System.Text; @@ -43,7 +40,7 @@ public void TestShiftBuffers1() }; PluginRegistry.PluginRegistry.Instance.Create(testDirectory.FullName, 500); - LogfileReader reader = new(files.Last.Value, encodingOptions, true, 40, 50, options); + LogfileReader reader = new(files.Last.Value, encodingOptions, true, 40, 50, options, PluginRegistry.PluginRegistry.Instance); reader.ReadFiles(); IList lil = reader.GetLogFileInfoList(); diff --git a/src/LogExpert.Tests/CSVColumnizerTest.cs b/src/LogExpert.Tests/CSVColumnizerTest.cs index 85569864..5e9c2de0 100644 --- a/src/LogExpert.Tests/CSVColumnizerTest.cs +++ b/src/LogExpert.Tests/CSVColumnizerTest.cs @@ -1,4 +1,4 @@ -using LogExpert.Classes.Log; +using LogExpert.Core.Classes.Log; using LogExpert.Core.Entities; using NUnit.Framework; @@ -18,7 +18,7 @@ public void Instantiat_CSVFile_BuildCorrectColumnizer(string filename, string[] { CsvColumnizer.CsvColumnizer csvColumnizer = new(); string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename); - LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions()); + LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); reader.ReadFiles(); ILogLine line = reader.GetLogLine(0); IColumnizedLogLine logline = new ColumnizedLogLine(); diff --git a/src/LogExpert.Tests/ColumnizerPickerTest.cs b/src/LogExpert.Tests/ColumnizerPickerTest.cs index 608c4234..585a99e3 100644 --- a/src/LogExpert.Tests/ColumnizerPickerTest.cs +++ b/src/LogExpert.Tests/ColumnizerPickerTest.cs @@ -1,13 +1,9 @@ using JsonColumnizer; - -using LogExpert.Classes.Log; using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Classes.Log; using LogExpert.Core.Entities; - using Moq; - using NUnit.Framework; - using System; using System.IO; @@ -70,7 +66,7 @@ public void FindReplacementForAutoColumnizer_ValidTextFile_ReturnCorrectColumniz string fileName, Type columnizerType) { string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions()); + LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); reader.ReadFiles(); Mock autoColumnizer = new(); diff --git a/src/LogExpert.Tests/JSONSaveTest.cs b/src/LogExpert.Tests/JSONSaveTest.cs index 44f9a532..35b4834c 100644 --- a/src/LogExpert.Tests/JSONSaveTest.cs +++ b/src/LogExpert.Tests/JSONSaveTest.cs @@ -15,9 +15,9 @@ public class JSONSaveTest [Test(Author = "Hirogen", Description = "Save Options as JSON and Check if the written file can be cast again into the settings object")] public void SaveOptionsAsJSON() { - ConfigManager.Settings.alwaysOnTop = true; - ConfigManager.Save(SettingsFlags.All); - string configDir = ConfigManager.ConfigDir; + ConfigManager.Instance.Settings.alwaysOnTop = true; + ConfigManager.Instance.Save(SettingsFlags.All); + string configDir = ConfigManager.Instance.ConfigDir; string settingsFile = configDir + "\\settings.json"; Settings settings = null; @@ -26,8 +26,8 @@ public void SaveOptionsAsJSON() Assert.That(settings, Is.Not.Null); Assert.That(settings.alwaysOnTop, Is.True); - ConfigManager.Settings.alwaysOnTop = false; - ConfigManager.Save(SettingsFlags.All); + ConfigManager.Instance.Settings.alwaysOnTop = false; + ConfigManager.Instance.Save(SettingsFlags.All); settings = null; Assert.DoesNotThrow(CastSettings); diff --git a/src/LogExpert.Tests/JsonColumnizerTest.cs b/src/LogExpert.Tests/JsonColumnizerTest.cs index 6ffb0ff9..72a85d60 100644 --- a/src/LogExpert.Tests/JsonColumnizerTest.cs +++ b/src/LogExpert.Tests/JsonColumnizerTest.cs @@ -1,4 +1,4 @@ -using LogExpert.Classes.Log; +using LogExpert.Core.Classes.Log; using LogExpert.Core.Entities; using NUnit.Framework; @@ -16,7 +16,7 @@ public void GetColumnNames_HappyFile_ColumnNameMatches(string fileName, string e { var jsonColumnizer = new JsonColumnizer.JsonColumnizer(); string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions()); + LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); reader.ReadFiles(); ILogLine line = reader.GetLogLine(0); diff --git a/src/LogExpert.Tests/JsonCompactColumnizerTest.cs b/src/LogExpert.Tests/JsonCompactColumnizerTest.cs index 8b9bddf4..73e49d09 100644 --- a/src/LogExpert.Tests/JsonCompactColumnizerTest.cs +++ b/src/LogExpert.Tests/JsonCompactColumnizerTest.cs @@ -1,4 +1,4 @@ -using LogExpert.Classes.Log; +using LogExpert.Core.Classes.Log; using LogExpert.Core.Entities; using NUnit.Framework; @@ -20,7 +20,7 @@ public void GetPriority_HappyFile_PriorityMatches(string fileName, Priority prio { var jsonCompactColumnizer = new JsonColumnizer.JsonCompactColumnizer(); string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - LogfileReader logFileReader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions()); + LogfileReader logFileReader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); logFileReader.ReadFiles(); List loglines = new() { diff --git a/src/LogExpert.Tests/LocalFileSystemTest.cs b/src/LogExpert.Tests/LocalFileSystemTest.cs index eb9aaf8d..ab765ef3 100644 --- a/src/LogExpert.Tests/LocalFileSystemTest.cs +++ b/src/LogExpert.Tests/LocalFileSystemTest.cs @@ -1,5 +1,4 @@ -using LogExpert.Classes.Log; -using LogExpert.PluginRegistry.FileSystem; +using LogExpert.PluginRegistry.FileSystem; using NUnit.Framework; diff --git a/src/LogExpert.Tests/RolloverHandlerTest.cs b/src/LogExpert.Tests/RolloverHandlerTest.cs index 594d1290..9c4e7557 100644 --- a/src/LogExpert.Tests/RolloverHandlerTest.cs +++ b/src/LogExpert.Tests/RolloverHandlerTest.cs @@ -1,4 +1,4 @@ -using LogExpert.Classes.Log; +using LogExpert.Core.Classes.Log; using LogExpert.Core.Entities; using LogExpert.PluginRegistry.FileSystem; @@ -26,7 +26,7 @@ public void TestFilenameListWithAppendedIndex(string format, int retries) ILogFileInfo info = new LogFileInfo(new Uri(firstFile)); RolloverFilenameHandler handler = new(info, options); - LinkedList fileList = handler.GetNameList(); + LinkedList fileList = handler.GetNameList(PluginRegistry.PluginRegistry.Instance); Assert.That(fileList, Is.EqualTo(files)); @@ -47,7 +47,7 @@ public void TestFilenameListWithDate(string format, int retries) ILogFileInfo info = new LogFileInfo(new Uri(firstFile)); RolloverFilenameHandler handler = new(info, options); - LinkedList fileList = handler.GetNameList(); + LinkedList fileList = handler.GetNameList(PluginRegistry.PluginRegistry.Instance); Assert.That(fileList, Is.EqualTo(files)); diff --git a/src/LogExpert.Tests/SquareBracketColumnizerTest.cs b/src/LogExpert.Tests/SquareBracketColumnizerTest.cs index 21b95f91..e972f658 100644 --- a/src/LogExpert.Tests/SquareBracketColumnizerTest.cs +++ b/src/LogExpert.Tests/SquareBracketColumnizerTest.cs @@ -1,5 +1,5 @@ -using LogExpert.Classes.Log; -using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Classes.Log; using LogExpert.Core.Entities; using NUnit.Framework; @@ -22,7 +22,7 @@ public void GetPriority_HappyFile_ColumnCountMatches(string fileName, int count) SquareBracketColumnizer squareBracketColumnizer = new(); string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - LogfileReader logFileReader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions()); + LogfileReader logFileReader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); logFileReader.ReadFiles(); List loglines = new() { diff --git a/src/LogExpert/Classes/LogExpertApplicationContext.cs b/src/LogExpert/Classes/LogExpertApplicationContext.cs index 28099012..1dfc04e1 100644 --- a/src/LogExpert/Classes/LogExpertApplicationContext.cs +++ b/src/LogExpert/Classes/LogExpertApplicationContext.cs @@ -1,5 +1,4 @@ -using LogExpert.Controls.LogTabWindow; - +using LogExpert.Core.Interface; using System; using System.Windows.Forms; @@ -15,7 +14,7 @@ internal class LogExpertApplicationContext : ApplicationContext #region cTor - public LogExpertApplicationContext(LogExpertProxy proxy, LogTabWindow firstLogWin) + public LogExpertApplicationContext(LogExpertProxy proxy, ILogTabWindow firstLogWin) { _proxy = proxy; _proxy.LastWindowClosed += new LogExpertProxy.LastWindowClosedEventHandler(OnProxyLastWindowClosed); diff --git a/src/LogExpert/Classes/LogExpertProxy.cs b/src/LogExpert/Classes/LogExpertProxy.cs index 40f97257..9fda5004 100644 --- a/src/LogExpert/Classes/LogExpertProxy.cs +++ b/src/LogExpert/Classes/LogExpertProxy.cs @@ -1,8 +1,7 @@ -using LogExpert.Controls.LogTabWindow; -using LogExpert.Interface; - +using LogExpert.Config; +using LogExpert.Core.Interface; +using LogExpert.UI.Controls.LogTabWindow; using NLog; - using System; using System.Collections.Generic; using System.Windows.Forms; @@ -15,9 +14,9 @@ internal class LogExpertProxy : ILogExpertProxy private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); - [NonSerialized] private readonly List _windowList = []; + [NonSerialized] private readonly List _windowList = []; - [NonSerialized] private LogTabWindow _firstLogTabWindow; + [NonSerialized] private ILogTabWindow _firstLogTabWindow; [NonSerialized] private int _logWindowIndex = 1; @@ -25,7 +24,7 @@ internal class LogExpertProxy : ILogExpertProxy #region cTor - public LogExpertProxy(LogTabWindow logTabWindow) + public LogExpertProxy(ILogTabWindow logTabWindow) { AddWindow(logTabWindow); logTabWindow.LogExpertProxy = this; @@ -63,7 +62,7 @@ public LogExpertProxy(LogTabWindow logTabWindow) public void LoadFiles(string[] fileNames) { _logger.Info("Loading files into existing LogTabWindow"); - LogTabWindow logWin = _windowList[^1]; + ILogTabWindow logWin = _windowList[^1]; _ = logWin.Invoke(new MethodInvoker(logWin.SetForeground)); logWin.LoadFiles(fileNames); } @@ -95,9 +94,9 @@ public void NewWindow(string[] fileNames) public void NewWindowOrLockedWindow(string[] fileNames) { - foreach (LogTabWindow logWin in _windowList) + foreach (var logWin in _windowList) { - if (LogTabWindow.StaticData.CurrentLockedMainWindow == logWin) + if (AbstractLogTabWindow.StaticData.CurrentLockedMainWindow == logWin) { _ = logWin.Invoke(new MethodInvoker(logWin.SetForeground)); logWin.LoadFiles(fileNames); @@ -112,17 +111,16 @@ public void NewWindowOrLockedWindow(string[] fileNames) public void NewWindowWorker(string[] fileNames) { _logger.Info("Creating new LogTabWindow"); - LogTabWindow logWin = new(fileNames?.Length > 0 ? fileNames : null, _logWindowIndex++, true) - { - LogExpertProxy = this - }; + IConfigManager configManager = ConfigManager.Instance; + ILogTabWindow logWin = AbstractLogTabWindow.Create(fileNames.Length > 0 ? fileNames : null, _logWindowIndex++, true, configManager); + logWin.LogExpertProxy = this; AddWindow(logWin); logWin.Show(); logWin.Activate(); } - public void WindowClosed(LogTabWindow logWin) + public void WindowClosed(ILogTabWindow logWin) { RemoveWindow(logWin); if (_windowList.Count == 0) @@ -155,13 +153,13 @@ public int GetLogWindowCount() #region Private Methods - private void AddWindow(LogTabWindow window) + private void AddWindow(ILogTabWindow window) { _logger.Info("Adding window to list"); _windowList.Add(window); } - private void RemoveWindow(LogTabWindow window) + private void RemoveWindow(ILogTabWindow window) { _logger.Info("Removing window from list"); _ = _windowList.Remove(window); diff --git a/src/LogExpert/Config/ConfigManager.cs b/src/LogExpert/Config/ConfigManager.cs index cc775e0c..28efa83f 100644 --- a/src/LogExpert/Config/ConfigManager.cs +++ b/src/LogExpert/Config/ConfigManager.cs @@ -2,8 +2,9 @@ using LogExpert.Core.Classes.Filter; using LogExpert.Core.Config; using LogExpert.Core.Entities; -using LogExpert.Core.EventArgs; - +using LogExpert.Core.EventArguments; +using LogExpert.Core.EventHandlers; +using LogExpert.Core.Interface; using Newtonsoft.Json; using NLog; @@ -19,7 +20,7 @@ namespace LogExpert.Config { - public class ConfigManager + public class ConfigManager : IConfigManager { #region Fields @@ -61,46 +62,52 @@ public static ConfigManager Instance } } - public static string ConfigDir => Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + Path.DirectorySeparatorChar + "LogExpert"; + public string ConfigDir => Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + Path.DirectorySeparatorChar + "LogExpert"; //TODO: change to Path.Combine /// /// Application.StartupPath + portable /// - public static string PortableModeDir => Application.StartupPath + Path.DirectorySeparatorChar + "portable"; + public string PortableModeDir => Application.StartupPath + Path.DirectorySeparatorChar + "portable"; /// /// portableMode.json /// - public static string PortableModeSettingsFileName => "portableMode.json"; + public string PortableModeSettingsFileName => "portableMode.json"; + + public Settings Settings => Instance._settings; + + IConfigManager IConfigManager.Instance => Instance; - public static Settings Settings => Instance._settings; +// Action IConfigManager.ConfigChanged { get => ((IConfigManager)_instance).ConfigChanged; set => ((IConfigManager)_instance).ConfigChanged = value; } + + //public string PortableModeSettingsFileName => ((IConfigManager)_instance).PortableModeSettingsFileName; #endregion #region Public methods - public static void Save(SettingsFlags flags) + public void Save(SettingsFlags flags) { Instance.Save(Settings, flags); } - public static void Export(FileInfo fileInfo) + public void Export(FileInfo fileInfo) { Instance.Save(fileInfo, Settings); } - public static void Export(FileInfo fileInfo, SettingsFlags flags) + public void Export(FileInfo fileInfo, SettingsFlags flags) { Instance.Save(fileInfo, Settings, flags); } - public static void Import(FileInfo fileInfo, ExportImportFlags flags) + public void Import(FileInfo fileInfo, ExportImportFlags flags) { Instance._settings = Instance.Import(Instance._settings, fileInfo, flags); Save(SettingsFlags.All); } - public static void ImportHighlightSettings(FileInfo fileInfo, ExportImportFlags flags) + public void ImportHighlightSettings(FileInfo fileInfo, ExportImportFlags flags) { Instance._settings.Preferences.HighlightGroupList = Instance.Import(Instance._settings.Preferences.HighlightGroupList, fileInfo, flags); Save(SettingsFlags.All); @@ -423,7 +430,5 @@ protected void OnConfigChanged(SettingsFlags flags) { ConfigChanged?.Invoke(this, new ConfigChangedEventArgs(flags)); } - - public delegate void ConfigChangedEventHandler(object sender, ConfigChangedEventArgs e); } } \ No newline at end of file diff --git a/src/LogExpert/Controls/LogTabPage.cs b/src/LogExpert/Controls/LogTabPage.cs index e80ffa0b..9308bf8f 100644 --- a/src/LogExpert/Controls/LogTabPage.cs +++ b/src/LogExpert/Controls/LogTabPage.cs @@ -1,12 +1,13 @@ using LogExpert.Core.Classes; using LogExpert.Core.Entities; - +using LogExpert.Core.Interface; using System; using System.Threading; using System.Windows.Forms; namespace LogExpert.Controls { + //TODO: Not in use! internal class LogTabPage : TabPage { #region Fields @@ -21,7 +22,7 @@ internal class LogTabPage : TabPage #region cTor - public LogTabPage(LogWindow.LogWindow logWindow, string title) + public LogTabPage(ILogWindow logWindow, string title) : base("MMi" + (title ?? Util.GetNameFromPath(logWindow.FileName))) { TabTitle = title; @@ -41,7 +42,7 @@ public LogTabPage(LogWindow.LogWindow logWindow, string title) #region Properties - public LogWindow.LogWindow LogWindow { get; } + public ILogWindow LogWindow { get; } public int LineDiff diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs deleted file mode 100644 index 8d8709d6..00000000 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs +++ /dev/null @@ -1,358 +0,0 @@ -using LogExpert.Config; -using LogExpert.Core.Config; -using LogExpert.Core.Entities; -using LogExpert.Dialogs; -using LogExpert.Interface; -using LogExpert.UI.Extensions.Forms; - -using NLog; - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Reflection; -using System.Text; -using System.Threading; -using System.Windows.Forms; -//using System.Linq; - -namespace LogExpert.Controls.LogTabWindow -{ - public partial class LogTabWindow : Form - { - #region Fields - - private const int MAX_COLUMNIZER_HISTORY = 40; - private const int MAX_COLOR_HISTORY = 40; - private const int DIFF_MAX = 100; - private const int MAX_FILE_HISTORY = 10; - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - private readonly Icon _deadIcon; - - private readonly Color _defaultTabColor = Color.FromArgb(255, 192, 192, 192); - private readonly Brush _dirtyLedBrush; - - private readonly int _instanceNumber; - private readonly Brush[] _ledBrushes = new Brush[5]; - private readonly Icon[,,,] _ledIcons = new Icon[6, 2, 4, 2]; - - private readonly Rectangle[] _leds = new Rectangle[5]; - - private readonly IList _logWindowList = new List(); - private readonly Brush _offLedBrush; - private readonly bool _showInstanceNumbers; - - private readonly string[] _startupFileNames; - - private readonly EventWaitHandle _statusLineEventHandle = new AutoResetEvent(false); - private readonly EventWaitHandle _statusLineEventWakeupHandle = new ManualResetEvent(false); - private readonly Brush _syncLedBrush; - private readonly StringFormat _tabStringFormat = new(); - private readonly Brush[] _tailLedBrush = new Brush[3]; - - private BookmarkWindow _bookmarkWindow; - - private LogWindow.LogWindow _currentLogWindow; - private bool _firstBookmarkWindowShow = true; - - private Thread _ledThread; - - //Settings settings; - - private bool _shouldStop; - - private bool _skipEvents; - - private bool _wasMaximized; - - #endregion - - #region cTor - - public LogTabWindow(string[] fileNames, int instanceNumber, bool showInstanceNumbers) - { - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - InitializeComponent(); - - //Fix MainMenu and externalToolsToolStrip.Location, if the location has unintentionally been changed in the designer - mainMenuStrip.Location = new Point(0, 0); - externalToolsToolStrip.Location = new Point(0, 54); - - ChangeTheme(Controls); - - _startupFileNames = fileNames; - _instanceNumber = instanceNumber; - _showInstanceNumbers = showInstanceNumbers; - - Load += OnLogTabWindowLoad; - - ConfigManager.Instance.ConfigChanged += OnConfigChanged; - HighlightGroupList = ConfigManager.Settings.Preferences.HighlightGroupList; - - Rectangle led = new(0, 0, 8, 2); - - for (int i = 0; i < _leds.Length; ++i) - { - _leds[i] = led; - led.Offset(0, led.Height + 0); - } - - int grayAlpha = 50; - - _ledBrushes[0] = new SolidBrush(Color.FromArgb(255, 220, 0, 0)); - _ledBrushes[1] = new SolidBrush(Color.FromArgb(255, 220, 220, 0)); - _ledBrushes[2] = new SolidBrush(Color.FromArgb(255, 0, 220, 0)); - _ledBrushes[3] = new SolidBrush(Color.FromArgb(255, 0, 220, 0)); - _ledBrushes[4] = new SolidBrush(Color.FromArgb(255, 0, 220, 0)); - - _offLedBrush = new SolidBrush(Color.FromArgb(grayAlpha, 160, 160, 160)); - - _dirtyLedBrush = new SolidBrush(Color.FromArgb(255, 220, 0, 00)); - - _tailLedBrush[0] = new SolidBrush(Color.FromArgb(255, 50, 100, 250)); // Follow tail: blue-ish - _tailLedBrush[1] = new SolidBrush(Color.FromArgb(grayAlpha, 160, 160, 160)); // Don't follow tail: gray - _tailLedBrush[2] = new SolidBrush(Color.FromArgb(255, 220, 220, 0)); // Stop follow tail (trigger): yellow-ish - - _syncLedBrush = new SolidBrush(Color.FromArgb(255, 250, 145, 30)); - - CreateIcons(); - - _tabStringFormat.LineAlignment = StringAlignment.Center; - _tabStringFormat.Alignment = StringAlignment.Near; - - ToolStripControlHost host = new(checkBoxFollowTail); - - host.Padding = new Padding(20, 0, 0, 0); - host.BackColor = Color.FromKnownColor(KnownColor.Transparent); - - int index = buttonToolStrip.Items.IndexOfKey("toolStripButtonTail"); - - toolStripEncodingASCIIItem.Text = Encoding.ASCII.HeaderName; - toolStripEncodingANSIItem.Text = Encoding.Default.HeaderName; - toolStripEncodingISO88591Item.Text = Encoding.GetEncoding("iso-8859-1").HeaderName; - toolStripEncodingUTF8Item.Text = Encoding.UTF8.HeaderName; - toolStripEncodingUTF16Item.Text = Encoding.Unicode.HeaderName; - - if (index != -1) - { - buttonToolStrip.Items.RemoveAt(index); - buttonToolStrip.Items.Insert(index, host); - } - - dragControlDateTime.Visible = false; - loadProgessBar.Visible = false; - - // get a reference to the current assembly - Assembly a = Assembly.GetExecutingAssembly(); - - // get a list of resource names from the manifest - string[] resNames = a.GetManifestResourceNames(); - - Bitmap bmp = Resources.Resources.Deceased; - _deadIcon = Icon.FromHandle(bmp.GetHicon()); - bmp.Dispose(); - Closing += OnLogTabWindowClosing; - - InitToolWindows(); - } - - #endregion - - #region ColorTheme - public void ChangeTheme(Control.ControlCollection container) - { - ColorMode.LoadColorMode(ConfigManager.Settings.Preferences.darkMode); - ColorMode.UseImmersiveDarkMode(Handle, ColorMode.DarkModeEnabled); - - #region ApplyColorToAllControls - foreach (Control component in container) - { - if (component.Controls != null && component.Controls.Count > 0) - { - ChangeTheme(component.Controls); - component.BackColor = ColorMode.BackgroundColor; - component.ForeColor = ColorMode.ForeColor; - } - else - { - component.BackColor = ColorMode.BackgroundColor; - component.ForeColor = ColorMode.ForeColor; - } - - if (component is MenuStrip menu) - { - foreach (ToolStripMenuItem item in menu.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.BackgroundColor; - - try - { - for (var x = 0; x < item.DropDownItems.Count; x++) - { - var children = item.DropDownItems[x]; - children.ForeColor = ColorMode.ForeColor; - children.BackColor = ColorMode.MenuBackgroundColor; - - if (children is ToolStripDropDownItem toolstripDropDownItem) - { - for (var y = 0; y < toolstripDropDownItem.DropDownItems.Count; y++) - { - var subChildren = toolstripDropDownItem.DropDownItems[y]; - subChildren.ForeColor = ColorMode.ForeColor; - subChildren.BackColor = ColorMode.MenuBackgroundColor; - } - } - } - } - catch (Exception ex) - { - _logger.Error(ex, "An error occured while applying style dynamically to all Controls under LogTabWindow:"); - } - } - } - } - #endregion - - // Colors for selected menus - mainMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - - // Dock special color - dockPanel.DockBackColor = ColorMode.DockBackgroundColor; - - // Remove toolstrip bottom border - buttonToolStrip.Renderer = new ToolStripRendererExtension(); - - #region Tabs - tabContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - - // Tabs menu - for (var y = 0; y < tabContextMenuStrip.Items.Count; y++) - { - var item = tabContextMenuStrip.Items[y]; - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - // Tabs line - dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient.StartColor = ColorMode.TabsBackgroundStripColor; - dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient.EndColor = ColorMode.TabsBackgroundStripColor; - - dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.DockStripGradient.StartColor = ColorMode.TabsBackgroundStripColor; - dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.DockStripGradient.EndColor = ColorMode.TabsBackgroundStripColor; - - // Tabs - dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.StartColor = ColorMode.ActiveTabColor; - dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.EndColor = ColorMode.ActiveTabColor; - dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.TextColor = ColorMode.ForeColor; - - dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.StartColor = ColorMode.ActiveTabColor; - dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.EndColor = ColorMode.ActiveTabColor; - dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.TextColor = ColorMode.ForeColor; - - dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.StartColor = ColorMode.InactiveTabColor; - dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.EndColor = ColorMode.InactiveTabColor; - dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.TextColor = ColorMode.ForeColor; - #endregion Tabs - } - #endregion - - #region Delegates - - private delegate void AddFileTabsDelegate(string[] fileNames); - - private delegate void ExceptionFx(); - - private delegate void FileNotFoundDelegate(LogWindow.LogWindow logWin); - - private delegate void FileRespawnedDelegate(LogWindow.LogWindow logWin); - - public delegate void HighlightSettingsChangedEventHandler(object sender, EventArgs e); - - private delegate void LoadMultiFilesDelegate(string[] fileName, EncodingOptions encodingOptions); - - private delegate void SetColumnizerFx(ILogLineColumnizer columnizer); - - private delegate void SetTabIconDelegate(LogWindow.LogWindow logWindow, Icon icon); - - #endregion - - #region Events - - public event HighlightSettingsChangedEventHandler HighlightSettingsChanged; - - #endregion - - #region Properties - - public LogWindow.LogWindow CurrentLogWindow - { - get => _currentLogWindow; - set => ChangeCurrentLogWindow(value); - } - - public SearchParams SearchParams { get; private set; } = new SearchParams(); - - public Preferences Preferences => ConfigManager.Settings.Preferences; - - public List HighlightGroupList { get; private set; } = []; - - //public Settings Settings - //{ - // get { return ConfigManager.Settings; } - //} - - public ILogExpertProxy LogExpertProxy { get; set; } - - internal static StaticLogTabWindowData StaticData { get; set; } = new StaticLogTabWindowData(); - - #endregion - - #region Internals - - internal HighlightGroup FindHighlightGroup(string groupName) - { - lock (HighlightGroupList) - { - foreach (HighlightGroup group in HighlightGroupList) - { - if (group.GroupName.Equals(groupName)) - { - return group; - } - } - return null; - } - } - - #endregion - - private class LogWindowData - { - #region Fields - - // public MdiTabControl.TabPage tabPage; - public Color color = Color.FromKnownColor(KnownColor.Gray); - - public int diffSum; - public bool dirty; - public int syncMode; // 0 = off, 1 = timeSynced - public int tailState; // tailState: 0,1,2 = on/off/off by Trigger - public ToolTip toolTip; - - #endregion - } - - // Data shared over all LogTabWindow instances - internal class StaticLogTabWindowData - { - #region Properties - - public LogTabWindow CurrentLockedMainWindow { get; set; } - - #endregion - } - } -} diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs deleted file mode 100644 index 9d9822cd..00000000 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs +++ /dev/null @@ -1,1026 +0,0 @@ -using LogExpert.Config; -using LogExpert.Core.Classes; -using LogExpert.Core.Classes.Persister; -using LogExpert.Core.Config; -using LogExpert.Core.Entities; -using LogExpert.Core.EventArgs; -using LogExpert.Dialogs; -using LogExpert.Entities.EventArgs; -using LogExpert.UI.Dialogs; - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.Drawing; -using System.Text; -using System.Threading; -using System.Windows.Forms; - -using WeifenLuo.WinFormsUI.Docking; - -namespace LogExpert.Controls.LogTabWindow -{ - public partial class LogTabWindow - { - #region Events handler - - private void OnBookmarkWindowVisibleChanged(object sender, EventArgs e) - { - _firstBookmarkWindowShow = false; - } - - private void OnLogTabWindowLoad(object sender, EventArgs e) - { - ApplySettings(ConfigManager.Settings, SettingsFlags.All); - if (ConfigManager.Settings.isMaximized) - { - Bounds = ConfigManager.Settings.appBoundsFullscreen; - WindowState = FormWindowState.Maximized; - Bounds = ConfigManager.Settings.appBounds; - } - else - { - if (ConfigManager.Settings.appBounds.Right > 0) - { - Bounds = ConfigManager.Settings.appBounds; - } - } - - if (ConfigManager.Settings.Preferences.openLastFiles && _startupFileNames == null) - { - List tmpList = ObjectClone.Clone(ConfigManager.Settings.lastOpenFilesList); - - foreach (string name in tmpList) - { - if (string.IsNullOrEmpty(name) == false) - { - AddFileTab(name, false, null, false, null); - } - } - } - if (_startupFileNames != null) - { - LoadFiles(_startupFileNames, false); - } - _ledThread = new Thread(LedThreadProc); - _ledThread.IsBackground = true; - _ledThread.Start(); - - FillHighlightComboBox(); - FillToolLauncherBar(); -#if !DEBUG - debugToolStripMenuItem.Visible = false; -#endif - } - - private void OnLogTabWindowClosing(object sender, CancelEventArgs e) - { - try - { - _shouldStop = true; - _statusLineEventHandle.Set(); - _statusLineEventWakeupHandle.Set(); - _ledThread.Join(); - - IList deleteLogWindowList = new List(); - ConfigManager.Settings.alwaysOnTop = TopMost && ConfigManager.Settings.Preferences.allowOnlyOneInstance; - SaveLastOpenFilesList(); - - foreach (LogWindow.LogWindow logWindow in _logWindowList) - { - deleteLogWindowList.Add(logWindow); - } - - foreach (LogWindow.LogWindow logWindow in deleteLogWindowList) - { - RemoveAndDisposeLogWindow(logWindow, true); - } - - DestroyBookmarkWindow(); - - ConfigManager.Instance.ConfigChanged -= OnConfigChanged; - - SaveWindowPosition(); - ConfigManager.Save(SettingsFlags.WindowPosition | SettingsFlags.FileHistory); - } - catch (Exception) - { - // ignore error (can occur then multipe instances are closed simultaneously or if the - // window was not constructed completely because of errors) - } - finally - { - LogExpertProxy?.WindowClosed(this); - } - } - - private void OnStripMouseUp(object sender, MouseEventArgs e) - { - if (sender is ToolStripDropDown dropDown) - { - AddFileTab(dropDown.Text, false, null, false, null); - } - } - - private void OnHistoryItemClicked(object sender, ToolStripItemClickedEventArgs e) - { - if (string.IsNullOrEmpty(e.ClickedItem.Text) == false) - { - AddFileTab(e.ClickedItem.Text, false, null, false, null); - } - } - - private void OnLogWindowDisposed(object sender, EventArgs e) - { - LogWindow.LogWindow logWindow = sender as LogWindow.LogWindow; - - if (sender == CurrentLogWindow) - { - ChangeCurrentLogWindow(null); - } - - RemoveLogWindow(logWindow); - - logWindow.Tag = null; - } - - private void OnExitToolStripMenuItemClick(object sender, EventArgs e) - { - Close(); - } - - private void OnSelectFilterToolStripMenuItemClick(object sender, EventArgs e) - { - if (CurrentLogWindow == null) - { - return; - } - - CurrentLogWindow.ColumnizerCallbackObject.LineNum = CurrentLogWindow.GetCurrentLineNum(); - FilterSelectorForm form = new(PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers, CurrentLogWindow.CurrentColumnizer, CurrentLogWindow.ColumnizerCallbackObject); - form.Owner = this; - form.TopMost = TopMost; - DialogResult res = form.ShowDialog(); - - if (res == DialogResult.OK) - { - if (form.ApplyToAll) - { - lock (_logWindowList) - { - foreach (LogWindow.LogWindow logWindow in _logWindowList) - { - if (logWindow.CurrentColumnizer.GetType() != form.SelectedColumnizer.GetType()) - { - //logWindow.SetColumnizer(form.SelectedColumnizer); - SetColumnizerFx fx = logWindow.ForceColumnizer; - logWindow.Invoke(fx, form.SelectedColumnizer); - SetColumnizerHistoryEntry(logWindow.FileName, form.SelectedColumnizer); - } - else - { - if (form.IsConfigPressed) - { - logWindow.ColumnizerConfigChanged(); - } - } - } - } - } - else - { - if (CurrentLogWindow.CurrentColumnizer.GetType() != form.SelectedColumnizer.GetType()) - { - SetColumnizerFx fx = CurrentLogWindow.ForceColumnizer; - CurrentLogWindow.Invoke(fx, form.SelectedColumnizer); - SetColumnizerHistoryEntry(CurrentLogWindow.FileName, form.SelectedColumnizer); - } - - if (form.IsConfigPressed) - { - lock (_logWindowList) - { - foreach (LogWindow.LogWindow logWindow in _logWindowList) - { - if (logWindow.CurrentColumnizer.GetType() == form.SelectedColumnizer.GetType()) - { - logWindow.ColumnizerConfigChanged(); - } - } - } - } - } - } - } - - private void OnGoToLineToolStripMenuItemClick(object sender, EventArgs e) - { - if (CurrentLogWindow == null) - { - return; - } - - GotoLineDialog dlg = new(this); - DialogResult res = dlg.ShowDialog(); - if (res == DialogResult.OK) - { - int line = dlg.Line - 1; - if (line >= 0) - { - CurrentLogWindow.GotoLine(line); - } - } - } - - private void OnHighlightingToolStripMenuItemClick(object sender, EventArgs e) - { - ShowHighlightSettingsDialog(); - } - - private void OnSearchToolStripMenuItemClick(object sender, EventArgs e) - { - OpenSearchDialog(); - } - - private void OnOpenToolStripMenuItemClick(object sender, EventArgs e) - { - OpenFileDialog(); - } - - private void OnLogTabWindowDragEnter(object sender, DragEventArgs e) - { -#if DEBUG - string[] formats = e.Data.GetFormats(); - string s = "Dragging something over LogExpert. Formats: "; - foreach (string format in formats) - { - s += format; - s += " , "; - } - s = s.Substring(0, s.Length - 3); - _logger.Info(s); -#endif - } - - private void OnLogWindowDragOver(object sender, DragEventArgs e) - { - if (!e.Data.GetDataPresent(DataFormats.FileDrop)) - { - e.Effect = DragDropEffects.None; - } - else - { - e.Effect = DragDropEffects.Copy; - } - } - - private void OnLogWindowDragDrop(object sender, DragEventArgs e) - { -#if DEBUG - string[] formats = e.Data.GetFormats(); - string s = "Dropped formats: "; - foreach (string format in formats) - { - s += format; - s += " , "; - } - s = s[..^3]; - _logger.Debug(s); -#endif - - if (e.Data.GetDataPresent(DataFormats.FileDrop)) - { - object o = e.Data.GetData(DataFormats.FileDrop); - if (o is string[] names) - { - LoadFiles(names, (e.KeyState & 4) == 4); // (shift pressed?) - e.Effect = DragDropEffects.Copy; - } - } - } - - private void OnTimeShiftToolStripMenuItemCheckStateChanged(object sender, EventArgs e) - { - if (!_skipEvents && CurrentLogWindow != null) - { - CurrentLogWindow.SetTimeshiftValue(timeshiftMenuTextBox.Text); - timeshiftMenuTextBox.Enabled = timeshiftToolStripMenuItem.Checked; - CurrentLogWindow.TimeshiftEnabled(timeshiftToolStripMenuItem.Checked, - timeshiftMenuTextBox.Text); - } - } - - private void OnAboutToolStripMenuItemClick(object sender, EventArgs e) - { - AboutBox aboutBox = new(); - aboutBox.TopMost = TopMost; - aboutBox.ShowDialog(); - } - - private void OnFilterToolStripMenuItemClick(object sender, EventArgs e) - { - CurrentLogWindow?.ToggleFilterPanel(); - } - - private void OnMultiFileToolStripMenuItemClick(object sender, EventArgs e) - { - ToggleMultiFile(); - fileToolStripMenuItem.HideDropDown(); - } - - private void OnGuiStateUpdate(object sender, GuiStateArgs e) - { - BeginInvoke(GuiStateUpdateWorker, e); - } - - private void OnColumnizerChanged(object sender, ColumnizerEventArgs e) - { - _bookmarkWindow?.SetColumnizer(e.Columnizer); - } - - private void OnBookmarkAdded(object sender, EventArgs e) - { - _bookmarkWindow.UpdateView(); - } - - private void OnBookmarkTextChanged(object sender, BookmarkEventArgs e) - { - _bookmarkWindow.BookmarkTextChanged(e.Bookmark); - } - - private void OnBookmarkRemoved(object sender, EventArgs e) - { - _bookmarkWindow.UpdateView(); - } - - private void OnProgressBarUpdate(object sender, ProgressEventArgs e) - { - Invoke(ProgressBarUpdateWorker, e); - } - - private void OnStatusLineEvent(object sender, StatusLineEventArgs e) - { - StatusLineEventWorker(e); - } - - private void OnFollowTailCheckBoxClick(object sender, EventArgs e) - { - CurrentLogWindow?.FollowTailChanged(checkBoxFollowTail.Checked, false); - } - - private void OnLogTabWindowKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.W && e.Control) - { - CurrentLogWindow?.Close(); - } - else if (e.KeyCode == Keys.Tab && e.Control) - { - SwitchTab(e.Shift); - } - else - { - CurrentLogWindow?.OnLogWindowKeyDown(sender, e); - } - } - - private void OnCloseFileToolStripMenuItemClick(object sender, EventArgs e) - { - CurrentLogWindow?.Close(); - } - - private void OnCellSelectModeToolStripMenuItemClick(object sender, EventArgs e) - { - CurrentLogWindow?.SetCellSelectionMode(cellSelectModeToolStripMenuItem.Checked); - } - - private void OnCopyMarkedLinesIntoNewTabToolStripMenuItemClick(object sender, EventArgs e) - { - CurrentLogWindow?.CopyMarkedLinesToTab(); - } - - private void OnTimeShiftMenuTextBoxKeyDown(object sender, KeyEventArgs e) - { - if (CurrentLogWindow == null) - { - return; - } - - if (e.KeyCode == Keys.Enter) - { - e.Handled = true; - CurrentLogWindow.SetTimeshiftValue(timeshiftMenuTextBox.Text); - } - } - - private void OnAlwaysOnTopToolStripMenuItemClick(object sender, EventArgs e) - { - TopMost = alwaysOnTopToolStripMenuItem.Checked; - } - - private void OnFileSizeChanged(object sender, LogEventArgs e) - { - if (sender.GetType().IsAssignableFrom(typeof(LogWindow.LogWindow))) - { - int diff = e.LineCount - e.PrevLineCount; - if (diff < 0) - { - return; - } - - if (((LogWindow.LogWindow)sender).Tag is LogWindowData data) - { - lock (data) - { - data.diffSum += diff; - if (data.diffSum > DIFF_MAX) - { - data.diffSum = DIFF_MAX; - } - } - - //if (this.dockPanel.ActiveContent != null && - // this.dockPanel.ActiveContent != sender || data.tailState != 0) - if (CurrentLogWindow != null && - CurrentLogWindow != sender || data.tailState != 0) - { - data.dirty = true; - } - Icon icon = GetIcon(diff, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); - } - } - } - - private void OnLogWindowFileNotFound(object sender, EventArgs e) - { - Invoke(new FileNotFoundDelegate(FileNotFound), sender); - } - - private void OnLogWindowFileRespawned(object sender, EventArgs e) - { - Invoke(new FileRespawnedDelegate(FileRespawned), sender); - } - - private void OnLogWindowFilterListChanged(object sender, FilterListChangedEventArgs e) - { - lock (_logWindowList) - { - foreach (LogWindow.LogWindow logWindow in _logWindowList) - { - if (logWindow != e.LogWindow) - { - logWindow.HandleChangedFilterList(); - } - } - } - ConfigManager.Save(SettingsFlags.FilterList); - } - - private void OnLogWindowCurrentHighlightGroupChanged(object sender, CurrentHighlightGroupChangedEventArgs e) - { - OnHighlightSettingsChanged(); - ConfigManager.Settings.Preferences.HighlightGroupList = HighlightGroupList; - ConfigManager.Save(SettingsFlags.HighlightSettings); - } - - private void OnTailFollowed(object sender, EventArgs e) - { - if (dockPanel.ActiveContent == null) - { - return; - } - if (sender.GetType().IsAssignableFrom(typeof(LogWindow.LogWindow))) - { - if (dockPanel.ActiveContent == sender) - { - LogWindowData data = ((LogWindow.LogWindow)sender).Tag as LogWindowData; - data.dirty = false; - Icon icon = GetIcon(data.diffSum, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); - } - } - } - - private void OnLogWindowSyncModeChanged(object sender, SyncModeEventArgs e) - { - if (!Disposing) - { - LogWindowData data = ((LogWindow.LogWindow)sender).Tag as LogWindowData; - data.syncMode = e.IsTimeSynced ? 1 : 0; - Icon icon = GetIcon(data.diffSum, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); - } - else - { - _logger.Warn("Received SyncModeChanged event while disposing. Event ignored."); - } - } - - private void OnToggleBookmarkToolStripMenuItemClick(object sender, EventArgs e) - { - CurrentLogWindow?.ToggleBookmark(); - } - - private void OnJumpToNextToolStripMenuItemClick(object sender, EventArgs e) - { - CurrentLogWindow?.JumpNextBookmark(); - } - - private void OnJumpToPrevToolStripMenuItemClick(object sender, EventArgs e) - { - CurrentLogWindow?.JumpPrevBookmark(); - } - - private void OnASCIIToolStripMenuItemClick(object sender, EventArgs e) - { - CurrentLogWindow?.ChangeEncoding(Encoding.ASCII); - } - - private void OnANSIToolStripMenuItemClick(object sender, EventArgs e) - { - CurrentLogWindow?.ChangeEncoding(Encoding.Default); - } - - private void OnUTF8ToolStripMenuItemClick(object sender, EventArgs e) - { - CurrentLogWindow?.ChangeEncoding(new UTF8Encoding(false)); - } - - private void OnUTF16ToolStripMenuItemClick(object sender, EventArgs e) - { - CurrentLogWindow?.ChangeEncoding(Encoding.Unicode); - } - - private void OnISO88591ToolStripMenuItemClick(object sender, EventArgs e) - { - CurrentLogWindow?.ChangeEncoding(Encoding.GetEncoding("iso-8859-1")); - } - - private void OnReloadToolStripMenuItemClick(object sender, EventArgs e) - { - if (CurrentLogWindow != null) - { - LogWindowData data = CurrentLogWindow.Tag as LogWindowData; - Icon icon = GetIcon(0, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), CurrentLogWindow, icon); - CurrentLogWindow.Reload(); - } - } - - private void OnSettingsToolStripMenuItemClick(object sender, EventArgs e) - { - OpenSettings(0); - } - - private void OnDateTimeDragControlValueDragged(object sender, EventArgs e) - { - if (CurrentLogWindow != null) - { - //this.CurrentLogWindow.ScrollToTimestamp(this.dateTimeDragControl.DateTime); - } - } - - private void OnDateTimeDragControlValueChanged(object sender, EventArgs e) - { - CurrentLogWindow?.ScrollToTimestamp(dragControlDateTime.DateTime, true, true); - } - - private void OnLogTabWindowDeactivate(object sender, EventArgs e) - { - CurrentLogWindow?.AppFocusLost(); - } - - private void OnLogTabWindowActivated(object sender, EventArgs e) - { - CurrentLogWindow?.AppFocusGained(); - } - - private void OnShowBookmarkListToolStripMenuItemClick(object sender, EventArgs e) - { - if (_bookmarkWindow.Visible) - { - _bookmarkWindow.Hide(); - } - else - { - // strange: on very first Show() now bookmarks are displayed. after a hide it will work. - if (_firstBookmarkWindowShow) - { - _bookmarkWindow.Show(dockPanel); - _bookmarkWindow.Hide(); - } - - _bookmarkWindow.Show(dockPanel); - } - } - - private void OnToolStripButtonOpenClick(object sender, EventArgs e) - { - OpenFileDialog(); - } - - private void OnToolStripButtonSearchClick(object sender, EventArgs e) - { - OpenSearchDialog(); - } - - private void OnToolStripButtonFilterClick(object sender, EventArgs e) - { - CurrentLogWindow?.ToggleFilterPanel(); - } - - private void OnToolStripButtonBookmarkClick(object sender, EventArgs e) - { - CurrentLogWindow?.ToggleBookmark(); - } - - private void OnToolStripButtonUpClick(object sender, EventArgs e) - { - CurrentLogWindow?.JumpPrevBookmark(); - } - - private void OnToolStripButtonDownClick(object sender, EventArgs e) - { - CurrentLogWindow?.JumpNextBookmark(); - } - - private void OnShowHelpToolStripMenuItemClick(object sender, EventArgs e) - { - Help.ShowHelp(this, "LogExpert.chm"); - } - - private void OnHideLineColumnToolStripMenuItemClick(object sender, EventArgs e) - { - ConfigManager.Settings.hideLineColumn = hideLineColumnToolStripMenuItem.Checked; - lock (_logWindowList) - { - foreach (LogWindow.LogWindow logWin in _logWindowList) - { - logWin.ShowLineColumn(!ConfigManager.Settings.hideLineColumn); - } - } - _bookmarkWindow.LineColumnVisible = ConfigManager.Settings.hideLineColumn; - } - - // ================================================================== - // Tab context menu stuff - // ================================================================== - - private void OnCloseThisTabToolStripMenuItemClick(object sender, EventArgs e) - { - (dockPanel.ActiveContent as LogWindow.LogWindow).Close(); - } - - private void OnCloseOtherTabsToolStripMenuItemClick(object sender, EventArgs e) - { - IList closeList = new List(); - lock (_logWindowList) - { - foreach (DockContent content in dockPanel.Contents) - { - if (content != dockPanel.ActiveContent && content is LogWindow.LogWindow) - { - closeList.Add(content as Form); - } - } - } - foreach (Form form in closeList) - { - form.Close(); - } - } - - private void OnCloseAllTabsToolStripMenuItemClick(object sender, EventArgs e) - { - CloseAllTabs(); - } - - private void OnTabColorToolStripMenuItemClick(object sender, EventArgs e) - { - LogWindow.LogWindow logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; - - LogWindowData data = logWindow.Tag as LogWindowData; - - if (data == null) - { - return; - } - - ColorDialog dlg = new(); - dlg.Color = data.color; - if (dlg.ShowDialog() == DialogResult.OK) - { - data.color = dlg.Color; - SetTabColor(logWindow, data.color); - } - List delList = []; - - foreach (ColorEntry entry in ConfigManager.Settings.fileColors) - { - if (entry.FileName.ToLower().Equals(logWindow.FileName.ToLower())) - { - delList.Add(entry); - } - } - - foreach (ColorEntry entry in delList) - { - ConfigManager.Settings.fileColors.Remove(entry); - } - ConfigManager.Settings.fileColors.Add(new ColorEntry(logWindow.FileName, dlg.Color)); - - while (ConfigManager.Settings.fileColors.Count > MAX_COLOR_HISTORY) - { - ConfigManager.Settings.fileColors.RemoveAt(0); - } - } - - private void OnLogTabWindowSizeChanged(object sender, EventArgs e) - { - if (WindowState != FormWindowState.Minimized) - { - _wasMaximized = WindowState == FormWindowState.Maximized; - } - } - - private void OnSaveProjectToolStripMenuItemClick(object sender, EventArgs e) - { - SaveFileDialog dlg = new(); - dlg.DefaultExt = "lxj"; - dlg.Filter = @"LogExpert session (*.lxj)|*.lxj"; - - if (dlg.ShowDialog() == DialogResult.OK) - { - string fileName = dlg.FileName; - List fileNames = []; - - lock (_logWindowList) - { - foreach (DockContent content in dockPanel.Contents) - { - LogWindow.LogWindow logWindow = content as LogWindow.LogWindow; - string persistenceFileName = logWindow?.SavePersistenceData(true); - if (persistenceFileName != null) - { - fileNames.Add(persistenceFileName); - } - } - } - - ProjectData projectData = new(); - projectData.memberList = fileNames; - projectData.tabLayoutXml = SaveLayout(); - ProjectPersister.SaveProjectData(fileName, projectData); - } - } - - private void OnLoadProjectToolStripMenuItemClick(object sender, EventArgs e) - { - OpenFileDialog dlg = new(); - dlg.DefaultExt = "lxj"; - dlg.Filter = @"LogExpert sessions (*.lxj)|*.lxj"; - - if (dlg.ShowDialog() == DialogResult.OK) - { - string projectFileName = dlg.FileName; - LoadProject(projectFileName, true); - } - } - - private void OnToolStripButtonBubblesClick(object sender, EventArgs e) - { - if (CurrentLogWindow != null) - { - CurrentLogWindow.ShowBookmarkBubbles = toolStripButtonBubbles.Checked; - } - } - - private void OnCopyPathToClipboardToolStripMenuItemClick(object sender, EventArgs e) - { - LogWindow.LogWindow logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; - Clipboard.SetText(logWindow.Title); - } - - private void OnFindInExplorerToolStripMenuItemClick(object sender, EventArgs e) - { - LogWindow.LogWindow logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; - - Process explorer = new(); - explorer.StartInfo.FileName = "explorer.exe"; - explorer.StartInfo.Arguments = "/e,/select," + logWindow.Title; - explorer.StartInfo.UseShellExecute = false; - explorer.Start(); - } - - private void OnExportBookmarksToolStripMenuItemClick(object sender, EventArgs e) - { - CurrentLogWindow?.ExportBookmarkList(); - } - - private void OnHighlightGroupsComboBoxDropDownClosed(object sender, EventArgs e) - { - ApplySelectedHighlightGroup(); - } - - private void OnHighlightGroupsComboBoxSelectedIndexChanged(object sender, EventArgs e) - { - ApplySelectedHighlightGroup(); - } - - private void OnHighlightGroupsComboBoxMouseUp(object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Right) - { - ShowHighlightSettingsDialog(); - } - } - - - private void OnConfigChanged(object sender, ConfigChangedEventArgs e) - { - if (LogExpertProxy != null) - { - NotifySettingsChanged(null, e.Flags); - } - } - - private void OnDumpLogBufferInfoToolStripMenuItemClick(object sender, EventArgs e) - { -#if DEBUG - CurrentLogWindow?.DumpBufferInfo(); -#endif - } - - private void OnDumpBufferDiagnosticToolStripMenuItemClick(object sender, EventArgs e) - { -#if DEBUG - CurrentLogWindow?.DumpBufferDiagnostic(); -#endif - } - - private void OnRunGCToolStripMenuItemClick(object sender, EventArgs e) - { - RunGC(); - } - - private void OnGCInfoToolStripMenuItemClick(object sender, EventArgs e) - { - DumpGCInfo(); - } - - private void OnToolsToolStripMenuItemDropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) - { - if (e.ClickedItem.Tag is ToolEntry tag) - { - ToolButtonClick(tag); - } - } - - private void OnExternalToolsToolStripItemClicked(object sender, ToolStripItemClickedEventArgs e) - { - ToolButtonClick(e.ClickedItem.Tag as ToolEntry); - } - - private void OnConfigureToolStripMenuItemClick(object sender, EventArgs e) - { - OpenSettings(2); - } - - private void OnThrowExceptionGUIThreadToolStripMenuItemClick(object sender, EventArgs e) - { - throw new Exception("This is a test exception thrown by the GUI thread"); - } - - private void OnThrowExceptionBackgroundThToolStripMenuItemClick(object sender, EventArgs e) - { - ExceptionFx fx = ThrowExceptionFx; - fx.BeginInvoke(null, null); - } - - private void OnThrowExceptionBackgroundThreadToolStripMenuItemClick(object sender, EventArgs e) - { - Thread thread = new(ThrowExceptionThreadFx); - thread.IsBackground = true; - thread.Start(); - } - - private void OnWarnToolStripMenuItemClick(object sender, EventArgs e) - { - //_logger.GetLogger().LogLevel = _logger.Level.WARN; - } - - private void OnInfoToolStripMenuItemClick(object sender, EventArgs e) - { - //_logger.Get_logger().LogLevel = _logger.Level.INFO; - } - - private void OnDebugToolStripMenuItemClick(object sender, EventArgs e) - { - //_logger.Get_logger().LogLevel = _logger.Level.DEBUG; - } - - private void OnLogLevelToolStripMenuItemClick(object sender, EventArgs e) - { - } - - private void OnLogLevelToolStripMenuItemDropDownOpening(object sender, EventArgs e) - { - //warnToolStripMenuItem.Checked = _logger.Get_logger().LogLevel == _logger.Level.WARN; - //infoToolStripMenuItem.Checked = _logger.Get_logger().LogLevel == _logger.Level.INFO; - //debugToolStripMenuItem1.Checked = _logger.Get_logger().LogLevel == _logger.Level.DEBUG; - } - - private void OnDisableWordHighlightModeToolStripMenuItemClick(object sender, EventArgs e) - { - DebugOptions.DisableWordHighlight = disableWordHighlightModeToolStripMenuItem.Checked; - CurrentLogWindow?.RefreshAllGrids(); - } - - private void OnMultiFileMaskToolStripMenuItemClick(object sender, EventArgs e) - { - CurrentLogWindow?.ChangeMultifileMask(); - } - - private void OnMultiFileEnabledStripMenuItemClick(object sender, EventArgs e) - { - ToggleMultiFile(); - } - - private void OnLockInstanceToolStripMenuItemClick(object sender, EventArgs e) - { - StaticData.CurrentLockedMainWindow = lockInstanceToolStripMenuItem.Checked ? null : this; - } - - private void OnOptionToolStripMenuItemDropDownOpening(object sender, EventArgs e) - { - lockInstanceToolStripMenuItem.Enabled = !ConfigManager.Settings.Preferences.allowOnlyOneInstance; - lockInstanceToolStripMenuItem.Checked = StaticData.CurrentLockedMainWindow == this; - } - - private void OnFileToolStripMenuItemDropDownOpening(object sender, EventArgs e) - { - newFromClipboardToolStripMenuItem.Enabled = Clipboard.ContainsText(); - } - - private void OnNewFromClipboardToolStripMenuItemClick(object sender, EventArgs e) - { - PasteFromClipboard(); - } - - private void OnOpenURIToolStripMenuItemClick(object sender, EventArgs e) - { - OpenUriDialog dlg = new() - { - UriHistory = ConfigManager.Settings.uriHistoryList - }; - - if (DialogResult.OK == dlg.ShowDialog()) - { - if (dlg.Uri.Trim().Length > 0) - { - ConfigManager.Settings.uriHistoryList = dlg.UriHistory; - ConfigManager.Save(SettingsFlags.FileHistory); - LoadFiles([dlg.Uri], false); - } - } - } - - private void OnColumnFinderToolStripMenuItemClick(object sender, EventArgs e) - { - if (CurrentLogWindow != null && !_skipEvents) - { - CurrentLogWindow.ToggleColumnFinder(columnFinderToolStripMenuItem.Checked, true); - } - } - - private void OnDockPanelActiveContentChanged(object sender, EventArgs e) - { - if (dockPanel.ActiveContent is LogWindow.LogWindow window) - { - CurrentLogWindow = window; - CurrentLogWindow.LogWindowActivated(); - ConnectToolWindows(CurrentLogWindow); - } - } - - private void OnTabRenameToolStripMenuItemClick(object sender, EventArgs e) - { - if (CurrentLogWindow != null) - { - TabRenameDialog dlg = new() - { - TabName = CurrentLogWindow.Text - }; - if (DialogResult.OK == dlg.ShowDialog()) - { - CurrentLogWindow.Text = dlg.TabName; - } - dlg.Dispose(); - } - } - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindowPrivate.cs deleted file mode 100644 index 02639847..00000000 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindowPrivate.cs +++ /dev/null @@ -1,1336 +0,0 @@ -using LogExpert.Classes; -using LogExpert.Config; -using LogExpert.Core.Classes; -using LogExpert.Core.Classes.Columnizer; -using LogExpert.Core.Classes.Persister; -using LogExpert.Core.Config; -using LogExpert.Core.Entities; -using LogExpert.Core.Enums; -using LogExpert.Core.EventArgs; -using LogExpert.Dialogs; -using LogExpert.PluginRegistry.FileSystem; -using LogExpert.UI.Dialogs; - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.Drawing; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; -using System.Threading; -using System.Windows.Forms; - -using WeifenLuo.WinFormsUI.Docking; - -namespace LogExpert.Controls.LogTabWindow -{ - public partial class LogTabWindow - { - #region Private Methods - - /// - /// Creates a temp file with the text content of the clipboard and opens the temp file in a new tab. - /// - private void PasteFromClipboard() - { - if (Clipboard.ContainsText()) - { - string text = Clipboard.GetText(); - string fileName = Path.GetTempFileName(); - - using (FileStream fStream = new(fileName, FileMode.Append, FileAccess.Write, FileShare.Read)) - using (StreamWriter writer = new(fStream, Encoding.Unicode)) - { - writer.Write(text); - writer.Close(); - } - - string title = "Clipboard"; - LogWindow.LogWindow logWindow = AddTempFileTab(fileName, title); - LogWindowData data = logWindow.Tag as LogWindowData; - if (data != null) - { - SetTooltipText(logWindow, "Pasted on " + DateTime.Now); - } - } - } - - private void InitToolWindows() - { - InitBookmarkWindow(); - } - - private void DestroyToolWindows() - { - DestroyBookmarkWindow(); - } - - private void InitBookmarkWindow() - { - _bookmarkWindow = new BookmarkWindow - { - HideOnClose = true, - ShowHint = DockState.DockBottom - }; - - _bookmarkWindow.PreferencesChanged(ConfigManager.Settings.Preferences, false, SettingsFlags.All); - _bookmarkWindow.VisibleChanged += OnBookmarkWindowVisibleChanged; - _firstBookmarkWindowShow = true; - } - - private void DestroyBookmarkWindow() - { - _bookmarkWindow.HideOnClose = false; - _bookmarkWindow.Close(); - } - - private void SaveLastOpenFilesList() - { - ConfigManager.Settings.lastOpenFilesList.Clear(); - foreach (DockContent content in dockPanel.Contents) - { - if (content is LogWindow.LogWindow logWin) - { - if (!logWin.IsTempFile) - { - ConfigManager.Settings.lastOpenFilesList.Add(logWin.GivenFileName); - } - } - } - } - - private void SaveWindowPosition() - { - SuspendLayout(); - if (WindowState == FormWindowState.Normal) - { - ConfigManager.Settings.appBounds = Bounds; - ConfigManager.Settings.isMaximized = false; - } - else - { - ConfigManager.Settings.appBoundsFullscreen = Bounds; - ConfigManager.Settings.isMaximized = true; - WindowState = FormWindowState.Normal; - ConfigManager.Settings.appBounds = Bounds; - } - - ResumeLayout(); - } - - private void SetTooltipText(LogWindow.LogWindow logWindow, string logFileName) - { - logWindow.ToolTipText = logFileName; - } - - private void FillDefaultEncodingFromSettings(EncodingOptions encodingOptions) - { - if (ConfigManager.Settings.Preferences.defaultEncoding != null) - { - try - { - encodingOptions.DefaultEncoding = Encoding.GetEncoding(ConfigManager.Settings.Preferences.defaultEncoding); - } - catch (ArgumentException) - { - _logger.Warn("Encoding " + ConfigManager.Settings.Preferences.defaultEncoding + " is not a valid encoding"); - encodingOptions.DefaultEncoding = null; - } - } - } - - private void AddFileTabs(string[] fileNames) - { - foreach (string fileName in fileNames) - { - if (!string.IsNullOrEmpty(fileName)) - { - if (fileName.EndsWith(".lxj")) - { - LoadProject(fileName, false); - } - else - { - AddFileTab(fileName, false, null, false, null); - } - } - } - - Activate(); - } - - private void AddLogWindow(LogWindow.LogWindow logWindow, string title, bool doNotAddToPanel) - { - logWindow.CloseButton = true; - logWindow.TabPageContextMenuStrip = tabContextMenuStrip; - SetTooltipText(logWindow, title); - logWindow.DockAreas = DockAreas.Document | DockAreas.Float; - - if (!doNotAddToPanel) - { - logWindow.Show(dockPanel); - } - - LogWindowData data = new(); - data.diffSum = 0; - logWindow.Tag = data; - lock (_logWindowList) - { - _logWindowList.Add(logWindow); - } - - logWindow.FileSizeChanged += OnFileSizeChanged; - logWindow.TailFollowed += OnTailFollowed; - logWindow.Disposed += OnLogWindowDisposed; - logWindow.FileNotFound += OnLogWindowFileNotFound; - logWindow.FileRespawned += OnLogWindowFileRespawned; - logWindow.FilterListChanged += OnLogWindowFilterListChanged; - logWindow.CurrentHighlightGroupChanged += OnLogWindowCurrentHighlightGroupChanged; - logWindow.SyncModeChanged += OnLogWindowSyncModeChanged; - - logWindow.Visible = true; - } - - private void DisconnectEventHandlers(LogWindow.LogWindow logWindow) - { - logWindow.FileSizeChanged -= OnFileSizeChanged; - logWindow.TailFollowed -= OnTailFollowed; - logWindow.Disposed -= OnLogWindowDisposed; - logWindow.FileNotFound -= OnLogWindowFileNotFound; - logWindow.FileRespawned -= OnLogWindowFileRespawned; - logWindow.FilterListChanged -= OnLogWindowFilterListChanged; - logWindow.CurrentHighlightGroupChanged -= OnLogWindowCurrentHighlightGroupChanged; - logWindow.SyncModeChanged -= OnLogWindowSyncModeChanged; - - LogWindowData data = logWindow.Tag as LogWindowData; - //data.tabPage.MouseClick -= tabPage_MouseClick; - //data.tabPage.TabDoubleClick -= tabPage_TabDoubleClick; - //data.tabPage.ContextMenuStrip = null; - //data.tabPage = null; - } - - private void AddToFileHistory(string fileName) - { - bool FindName(string s) - { - return s.ToLower().Equals(fileName.ToLower()); - } - - int index = ConfigManager.Settings.fileHistoryList.FindIndex(FindName); - - if (index != -1) - { - ConfigManager.Settings.fileHistoryList.RemoveAt(index); - } - - ConfigManager.Settings.fileHistoryList.Insert(0, fileName); - - while (ConfigManager.Settings.fileHistoryList.Count > MAX_FILE_HISTORY) - { - ConfigManager.Settings.fileHistoryList.RemoveAt(ConfigManager.Settings.fileHistoryList.Count - 1); - } - - ConfigManager.Save(SettingsFlags.FileHistory); - - FillHistoryMenu(); - } - - private LogWindow.LogWindow FindWindowForFile(string fileName) - { - lock (_logWindowList) - { - foreach (LogWindow.LogWindow logWindow in _logWindowList) - { - if (logWindow.FileName.ToLower().Equals(fileName.ToLower())) - { - return logWindow; - } - } - } - - return null; - } - - /// - /// Checks if the file name is a settings file. If so, the contained logfile name - /// is returned. If not, the given file name is returned unchanged. - /// - /// - /// - private string FindFilenameForSettings(string fileName) - { - if (fileName.EndsWith(".lxp")) - { - PersistenceData persistenceData = Persister.LoadOptionsOnly(fileName); - if (persistenceData == null) - { - return fileName; - } - - if (!string.IsNullOrEmpty(persistenceData.fileName)) - { - IFileSystemPlugin fs = PluginRegistry.PluginRegistry.Instance.FindFileSystemForUri(persistenceData.fileName); - if (fs != null && !fs.GetType().Equals(typeof(LocalFileSystem))) - { - return persistenceData.fileName; - } - - // On relative paths the URI check (and therefore the file system plugin check) will fail. - // So fs == null and fs == LocalFileSystem are handled here like normal files. - if (Path.IsPathRooted(persistenceData.fileName)) - { - return persistenceData.fileName; - } - - // handle relative paths in .lxp files - string dir = Path.GetDirectoryName(fileName); - return Path.Combine(dir, persistenceData.fileName); - } - } - - return fileName; - } - - private void FillHistoryMenu() - { - ToolStripDropDown strip = new ToolStripDropDownMenu(); - - foreach (string file in ConfigManager.Settings.fileHistoryList) - { - ToolStripItem item = new ToolStripMenuItem(file); - strip.Items.Add(item); - } - - strip.ItemClicked += OnHistoryItemClicked; - strip.MouseUp += OnStripMouseUp; - lastUsedToolStripMenuItem.DropDown = strip; - } - - private void RemoveLogWindow(LogWindow.LogWindow logWindow) - { - lock (_logWindowList) - { - _logWindowList.Remove(logWindow); - } - - DisconnectEventHandlers(logWindow); - } - - private void RemoveAndDisposeLogWindow(LogWindow.LogWindow logWindow, bool dontAsk) - { - if (CurrentLogWindow == logWindow) - { - ChangeCurrentLogWindow(null); - } - - lock (_logWindowList) - { - _logWindowList.Remove(logWindow); - } - - logWindow.Close(dontAsk); - } - - private void ShowHighlightSettingsDialog() - { - HighlightDialog dlg = new() - { - KeywordActionList = PluginRegistry.PluginRegistry.Instance.RegisteredKeywordActions, - Owner = this, - TopMost = TopMost, - HighlightGroupList = HighlightGroupList, - PreSelectedGroupName = groupsComboBoxHighlightGroups.Text - }; - - DialogResult res = dlg.ShowDialog(); - - if (res == DialogResult.OK) - { - HighlightGroupList = dlg.HighlightGroupList; - FillHighlightComboBox(); - ConfigManager.Settings.Preferences.HighlightGroupList = HighlightGroupList; - ConfigManager.Save(SettingsFlags.HighlightSettings); - OnHighlightSettingsChanged(); - } - } - - private void FillHighlightComboBox() - { - string currentGroupName = groupsComboBoxHighlightGroups.Text; - groupsComboBoxHighlightGroups.Items.Clear(); - foreach (HighlightGroup group in HighlightGroupList) - { - groupsComboBoxHighlightGroups.Items.Add(group.GroupName); - if (group.GroupName.Equals(currentGroupName)) - { - groupsComboBoxHighlightGroups.Text = group.GroupName; - } - } - } - - private void OpenFileDialog() - { - OpenFileDialog openFileDialog = new(); - - if (CurrentLogWindow != null) - { - FileInfo info = new(CurrentLogWindow.FileName); - openFileDialog.InitialDirectory = info.DirectoryName; - } - else - { - if (!string.IsNullOrEmpty(ConfigManager.Settings.lastDirectory)) - { - openFileDialog.InitialDirectory = ConfigManager.Settings.lastDirectory; - } - else - { - try - { - openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); - } - catch (SecurityException e) - { - _logger.Warn(e, "Insufficient rights for GetFolderPath(): "); - // no initial directory if insufficient rights - } - } - } - - openFileDialog.Multiselect = true; - - if (DialogResult.OK == openFileDialog.ShowDialog(this)) - { - FileInfo info = new(openFileDialog.FileName); - if (info.Directory.Exists) - { - ConfigManager.Settings.lastDirectory = info.DirectoryName; - ConfigManager.Save(SettingsFlags.FileHistory); - } - - if (info.Exists) - { - LoadFiles(openFileDialog.FileNames, false); - } - } - } - - private void LoadFiles(string[] names, bool invertLogic) - { - Array.Sort(names); - - if (names.Length == 1) - { - if (names[0].EndsWith(".lxj")) - { - LoadProject(names[0], true); - return; - } - - AddFileTab(names[0], false, null, false, null); - return; - } - - MultiFileOption option = ConfigManager.Settings.Preferences.multiFileOption; - if (option == MultiFileOption.Ask) - { - MultiLoadRequestDialog dlg = new(); - DialogResult res = dlg.ShowDialog(); - - if (res == DialogResult.Yes) - { - option = MultiFileOption.SingleFiles; - } - else if (res == DialogResult.No) - { - option = MultiFileOption.MultiFile; - } - else - { - return; - } - } - else - { - if (invertLogic) - { - if (option == MultiFileOption.SingleFiles) - { - option = MultiFileOption.MultiFile; - } - else - { - option = MultiFileOption.SingleFiles; - } - } - } - - if (option == MultiFileOption.SingleFiles) - { - AddFileTabs(names); - } - else - { - AddMultiFileTab(names); - } - } - - private void SetColumnizerHistoryEntry(string fileName, ILogLineColumnizer columnizer) - { - ColumnizerHistoryEntry entry = FindColumnizerHistoryEntry(fileName); - if (entry != null) - { - ConfigManager.Settings.columnizerHistoryList.Remove(entry); - } - - ConfigManager.Settings.columnizerHistoryList.Add(new ColumnizerHistoryEntry(fileName, columnizer.GetName())); - - if (ConfigManager.Settings.columnizerHistoryList.Count > MAX_COLUMNIZER_HISTORY) - { - ConfigManager.Settings.columnizerHistoryList.RemoveAt(0); - } - } - - private ColumnizerHistoryEntry FindColumnizerHistoryEntry(string fileName) - { - foreach (ColumnizerHistoryEntry entry in ConfigManager.Settings.columnizerHistoryList) - { - if (entry.FileName.Equals(fileName)) - { - return entry; - } - } - - return null; - } - - private void ToggleMultiFile() - { - if (CurrentLogWindow != null) - { - CurrentLogWindow.SwitchMultiFile(!CurrentLogWindow.IsMultiFile); - multiFileToolStripMenuItem.Checked = CurrentLogWindow.IsMultiFile; - multiFileEnabledStripMenuItem.Checked = CurrentLogWindow.IsMultiFile; - } - } - - private void ChangeCurrentLogWindow(LogWindow.LogWindow newLogWindow) - { - if (newLogWindow == _currentLogWindow) - { - return; // do nothing if wishing to set the same window - } - - LogWindow.LogWindow oldLogWindow = _currentLogWindow; - _currentLogWindow = newLogWindow; - string titleName = _showInstanceNumbers ? "LogExpert #" + _instanceNumber : "LogExpert"; - - if (oldLogWindow != null) - { - oldLogWindow.StatusLineEvent -= OnStatusLineEvent; - oldLogWindow.ProgressBarUpdate -= OnProgressBarUpdate; - oldLogWindow.GuiStateUpdate -= OnGuiStateUpdate; - oldLogWindow.ColumnizerChanged -= OnColumnizerChanged; - oldLogWindow.BookmarkAdded -= OnBookmarkAdded; - oldLogWindow.BookmarkRemoved -= OnBookmarkRemoved; - oldLogWindow.BookmarkTextChanged -= OnBookmarkTextChanged; - DisconnectToolWindows(oldLogWindow); - } - - if (newLogWindow != null) - { - newLogWindow.StatusLineEvent += OnStatusLineEvent; - newLogWindow.ProgressBarUpdate += OnProgressBarUpdate; - newLogWindow.GuiStateUpdate += OnGuiStateUpdate; - newLogWindow.ColumnizerChanged += OnColumnizerChanged; - newLogWindow.BookmarkAdded += OnBookmarkAdded; - newLogWindow.BookmarkRemoved += OnBookmarkRemoved; - newLogWindow.BookmarkTextChanged += OnBookmarkTextChanged; - - if (newLogWindow.IsTempFile) - { - Text = titleName + @" - " + newLogWindow.TempTitleName; - } - else - { - Text = titleName + @" - " + newLogWindow.FileName; - } - - multiFileToolStripMenuItem.Checked = CurrentLogWindow.IsMultiFile; - multiFileToolStripMenuItem.Enabled = true; - multiFileEnabledStripMenuItem.Checked = CurrentLogWindow.IsMultiFile; - cellSelectModeToolStripMenuItem.Checked = true; - cellSelectModeToolStripMenuItem.Enabled = true; - closeFileToolStripMenuItem.Enabled = true; - searchToolStripMenuItem.Enabled = true; - filterToolStripMenuItem.Enabled = true; - goToLineToolStripMenuItem.Enabled = true; - //ConnectToolWindows(newLogWindow); - } - else - { - Text = titleName; - multiFileToolStripMenuItem.Checked = false; - multiFileEnabledStripMenuItem.Checked = false; - checkBoxFollowTail.Checked = false; - mainMenuStrip.Enabled = true; - timeshiftToolStripMenuItem.Enabled = false; - timeshiftToolStripMenuItem.Checked = false; - timeshiftMenuTextBox.Text = ""; - timeshiftMenuTextBox.Enabled = false; - multiFileToolStripMenuItem.Enabled = false; - cellSelectModeToolStripMenuItem.Checked = false; - cellSelectModeToolStripMenuItem.Enabled = false; - closeFileToolStripMenuItem.Enabled = false; - searchToolStripMenuItem.Enabled = false; - filterToolStripMenuItem.Enabled = false; - goToLineToolStripMenuItem.Enabled = false; - dragControlDateTime.Visible = false; - } - } - - private void ConnectToolWindows(LogWindow.LogWindow logWindow) - { - ConnectBookmarkWindow(logWindow); - } - - private void ConnectBookmarkWindow(LogWindow.LogWindow logWindow) - { - FileViewContext ctx = new(logWindow, logWindow); - _bookmarkWindow.SetBookmarkData(logWindow.BookmarkData); - _bookmarkWindow.SetCurrentFile(ctx); - } - - private void DisconnectToolWindows(LogWindow.LogWindow logWindow) - { - DisconnectBookmarkWindow(logWindow); - } - - private void DisconnectBookmarkWindow(LogWindow.LogWindow logWindow) - { - _bookmarkWindow.SetBookmarkData(null); - _bookmarkWindow.SetCurrentFile(null); - } - - private void GuiStateUpdateWorker(GuiStateArgs e) - { - _skipEvents = true; - checkBoxFollowTail.Checked = e.FollowTail; - mainMenuStrip.Enabled = e.MenuEnabled; - timeshiftToolStripMenuItem.Enabled = e.TimeshiftPossible; - timeshiftToolStripMenuItem.Checked = e.TimeshiftEnabled; - timeshiftMenuTextBox.Text = e.TimeshiftText; - timeshiftMenuTextBox.Enabled = e.TimeshiftEnabled; - multiFileToolStripMenuItem.Enabled = e.MultiFileEnabled; // disabled for temp files - multiFileToolStripMenuItem.Checked = e.IsMultiFileActive; - multiFileEnabledStripMenuItem.Checked = e.IsMultiFileActive; - cellSelectModeToolStripMenuItem.Checked = e.CellSelectMode; - RefreshEncodingMenuBar(e.CurrentEncoding); - - if (e.TimeshiftPossible && ConfigManager.Settings.Preferences.timestampControl) - { - dragControlDateTime.MinDateTime = e.MinTimestamp; - dragControlDateTime.MaxDateTime = e.MaxTimestamp; - dragControlDateTime.DateTime = e.Timestamp; - dragControlDateTime.Visible = true; - dragControlDateTime.Enabled = true; - dragControlDateTime.Refresh(); - } - else - { - dragControlDateTime.Visible = false; - dragControlDateTime.Enabled = false; - } - - toolStripButtonBubbles.Checked = e.ShowBookmarkBubbles; - groupsComboBoxHighlightGroups.Text = e.HighlightGroupName; - columnFinderToolStripMenuItem.Checked = e.ColumnFinderVisible; - - _skipEvents = false; - } - - private void ProgressBarUpdateWorker(ProgressEventArgs e) - { - if (e.Value <= e.MaxValue && e.Value >= e.MinValue) - { - try - { - loadProgessBar.Minimum = e.MinValue; - loadProgessBar.Maximum = e.MaxValue; - loadProgessBar.Value = e.Value; - loadProgessBar.Visible = e.Visible; - } - catch (Exception ex) - { - _logger.Error(ex, "Error during ProgressBarUpdateWorker value {0}, min {1}, max {2}, visible {3}", e.Value, e.MinValue, e.MaxValue, e.Visible); - } - - Invoke(new MethodInvoker(statusStrip.Refresh)); - } - } - - private void StatusLineEventWorker(StatusLineEventArgs e) - { - if (e != null) - { - //_logger.logDebug("StatusLineEvent: text = " + e.StatusText); - labelStatus.Text = e.StatusText; - labelStatus.Size = TextRenderer.MeasureText(labelStatus.Text, labelStatus.Font); - labelLines.Text = $" {e.LineCount} lines"; - labelLines.Size = TextRenderer.MeasureText(labelLines.Text, labelLines.Font); - labelSize.Text = Util.GetFileSizeAsText(e.FileSize); - labelSize.Size = TextRenderer.MeasureText(labelSize.Text, labelSize.Font); - labelCurrentLine.Text = $"Line: {e.CurrentLineNum}"; - labelCurrentLine.Size = TextRenderer.MeasureText(labelCurrentLine.Text, labelCurrentLine.Font); - if (statusStrip.InvokeRequired) - { - statusStrip.BeginInvoke(new MethodInvoker(delegate { statusStrip.Refresh(); })); - } - else - { - statusStrip.Refresh(); - } - } - } - - // tailState: 0,1,2 = on/off/off by Trigger - // syncMode: 0 = normal (no), 1 = time synced - private Icon CreateLedIcon(int level, bool dirty, int tailState, int syncMode) - { - Rectangle iconRect = _leds[0]; - iconRect.Height = 16; // (DockPanel's damn hardcoded height) // this.leds[this.leds.Length - 1].Bottom; - iconRect.Width = iconRect.Right + 6; - Bitmap bmp = new(iconRect.Width, iconRect.Height); - Graphics gfx = Graphics.FromImage(bmp); - - int offsetFromTop = 4; - - for (int i = 0; i < _leds.Length; ++i) - { - Rectangle ledRect = _leds[i]; - ledRect.Offset(0, offsetFromTop); - - if (level >= _leds.Length - i) - { - gfx.FillRectangle(_ledBrushes[i], ledRect); - } - else - { - gfx.FillRectangle(_offLedBrush, ledRect); - } - } - - int ledSize = 3; - int ledGap = 1; - Rectangle lastLed = _leds[^1]; - Rectangle dirtyLed = new(lastLed.Right + 2, lastLed.Bottom - ledSize, ledSize, ledSize); - Rectangle tailLed = new(dirtyLed.Location, dirtyLed.Size); - tailLed.Offset(0, -(ledSize + ledGap)); - Rectangle syncLed = new(tailLed.Location, dirtyLed.Size); - syncLed.Offset(0, -(ledSize + ledGap)); - - syncLed.Offset(0, offsetFromTop); - tailLed.Offset(0, offsetFromTop); - dirtyLed.Offset(0, offsetFromTop); - - if (dirty) - { - gfx.FillRectangle(_dirtyLedBrush, dirtyLed); - } - else - { - gfx.FillRectangle(_offLedBrush, dirtyLed); - } - - // tailMode 4 means: don't show - if (tailState < 3) - { - gfx.FillRectangle(_tailLedBrush[tailState], tailLed); - } - - if (syncMode == 1) - { - gfx.FillRectangle(_syncLedBrush, syncLed); - } - //else - //{ - // gfx.FillRectangle(this.offLedBrush, syncLed); - //} - - // see http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=345656 - // GetHicon() creates an unmanaged handle which must be destroyed. The Clone() workaround creates - // a managed copy of icon. then the unmanaged win32 handle is destroyed - IntPtr iconHandle = bmp.GetHicon(); - Icon icon = Icon.FromHandle(iconHandle).Clone() as Icon; - Win32.DestroyIcon(iconHandle); - - gfx.Dispose(); - bmp.Dispose(); - return icon; - } - - private void CreateIcons() - { - for (int syncMode = 0; syncMode <= 1; syncMode++) // LED indicating time synced tabs - { - for (int tailMode = 0; tailMode < 4; tailMode++) - { - for (int i = 0; i < 6; ++i) - { - _ledIcons[i, 0, tailMode, syncMode] = CreateLedIcon(i, false, tailMode, syncMode); - } - - for (int i = 0; i < 6; ++i) - { - _ledIcons[i, 1, tailMode, syncMode] = CreateLedIcon(i, true, tailMode, syncMode); - } - } - } - } - - private void FileNotFound(LogWindow.LogWindow logWin) - { - LogWindowData data = logWin.Tag as LogWindowData; - BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, _deadIcon); - dragControlDateTime.Visible = false; - } - - private void FileRespawned(LogWindow.LogWindow logWin) - { - LogWindowData data = logWin.Tag as LogWindowData; - Icon icon = GetIcon(0, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, icon); - } - - private void ShowLedPeak(LogWindow.LogWindow logWin) - { - LogWindowData data = logWin.Tag as LogWindowData; - lock (data) - { - data.diffSum = DIFF_MAX; - } - - Icon icon = GetIcon(data.diffSum, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, icon); - } - - private int GetLevelFromDiff(int diff) - { - if (diff > 60) - { - diff = 60; - } - - int level = diff / 10; - if (diff > 0 && level == 0) - { - level = 2; - } - else if (level == 0) - { - level = 1; - } - - return level - 1; - } - - private void LedThreadProc() - { - Thread.CurrentThread.Name = "LED Thread"; - while (!_shouldStop) - { - try - { - Thread.Sleep(200); - } - catch - { - return; - } - - lock (_logWindowList) - { - foreach (LogWindow.LogWindow logWindow in _logWindowList) - { - LogWindowData data = logWindow.Tag as LogWindowData; - if (data.diffSum > 0) - { - data.diffSum -= 10; - if (data.diffSum < 0) - { - data.diffSum = 0; - } - - Icon icon = GetIcon(data.diffSum, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); - } - } - } - } - } - - private void SetTabIcon(LogWindow.LogWindow logWindow, Icon icon) - { - if (logWindow != null) - { - logWindow.Icon = icon; - logWindow.DockHandler.Pane?.TabStripControl.Invalidate(false); - } - } - - private Icon GetIcon(int diff, LogWindowData data) - { - Icon icon = - _ledIcons[ - GetLevelFromDiff(diff), data.dirty ? 1 : 0, Preferences.showTailState ? data.tailState : 3, - data.syncMode - ]; - return icon; - } - - private void RefreshEncodingMenuBar(Encoding encoding) - { - toolStripEncodingASCIIItem.Checked = false; - toolStripEncodingANSIItem.Checked = false; - toolStripEncodingUTF8Item.Checked = false; - toolStripEncodingUTF16Item.Checked = false; - toolStripEncodingISO88591Item.Checked = false; - - if (encoding == null) - { - return; - } - - if (encoding is ASCIIEncoding) - { - toolStripEncodingASCIIItem.Checked = true; - } - else if (encoding.Equals(Encoding.Default)) - { - toolStripEncodingANSIItem.Checked = true; - } - else if (encoding is UTF8Encoding) - { - toolStripEncodingUTF8Item.Checked = true; - } - else if (encoding is UnicodeEncoding) - { - toolStripEncodingUTF16Item.Checked = true; - } - else if (encoding.Equals(Encoding.GetEncoding("iso-8859-1"))) - { - toolStripEncodingISO88591Item.Checked = true; - } - - toolStripEncodingANSIItem.Text = Encoding.Default.HeaderName; - } - - private void OpenSettings(int tabToOpen) - { - SettingsDialog dlg = new(ConfigManager.Settings.Preferences, this, tabToOpen); - dlg.TopMost = TopMost; - - if (DialogResult.OK == dlg.ShowDialog()) - { - ConfigManager.Settings.Preferences = dlg.Preferences; - ConfigManager.Save(SettingsFlags.Settings); - NotifyWindowsForChangedPrefs(SettingsFlags.Settings); - } - } - - private void NotifyWindowsForChangedPrefs(SettingsFlags flags) - { - _logger.Info("The preferences have changed"); - ApplySettings(ConfigManager.Settings, flags); - - lock (_logWindowList) - { - foreach (LogWindow.LogWindow logWindow in _logWindowList) - { - logWindow.PreferencesChanged(ConfigManager.Settings.Preferences, false, flags); - } - } - - _bookmarkWindow.PreferencesChanged(ConfigManager.Settings.Preferences, false, flags); - - HighlightGroupList = ConfigManager.Settings.Preferences.HighlightGroupList; - if ((flags & SettingsFlags.HighlightSettings) == SettingsFlags.HighlightSettings) - { - OnHighlightSettingsChanged(); - } - } - - private void ApplySettings(Settings settings, SettingsFlags flags) - { - if ((flags & SettingsFlags.WindowPosition) == SettingsFlags.WindowPosition) - { - TopMost = alwaysOnTopToolStripMenuItem.Checked = settings.alwaysOnTop; - dragControlDateTime.DragOrientation = settings.Preferences.timestampControlDragOrientation; - hideLineColumnToolStripMenuItem.Checked = settings.hideLineColumn; - } - - if ((flags & SettingsFlags.FileHistory) == SettingsFlags.FileHistory) - { - FillHistoryMenu(); - } - - if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors) - { - SetTabIcons(settings.Preferences); - } - - if ((flags & SettingsFlags.ToolSettings) == SettingsFlags.ToolSettings) - { - FillToolLauncherBar(); - } - - if ((flags & SettingsFlags.HighlightSettings) == SettingsFlags.HighlightSettings) - { - FillHighlightComboBox(); - } - } - - private void SetTabIcons(Preferences preferences) - { - _tailLedBrush[0] = new SolidBrush(preferences.showTailColor); - CreateIcons(); - lock (_logWindowList) - { - foreach (LogWindow.LogWindow logWindow in _logWindowList) - { - LogWindowData data = logWindow.Tag as LogWindowData; - Icon icon = GetIcon(data.diffSum, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); - } - } - } - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - private static extern bool DestroyIcon(IntPtr handle); - - private void SetToolIcon(ToolEntry entry, ToolStripItem item) - { - Icon icon = Win32.LoadIconFromExe(entry.iconFile, entry.iconIndex); - if (icon != null) - { - item.Image = icon.ToBitmap(); - if (item is ToolStripMenuItem) - { - item.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; - } - else - { - item.DisplayStyle = ToolStripItemDisplayStyle.Image; - } - - DestroyIcon(icon.Handle); - icon.Dispose(); - } - - if (!string.IsNullOrEmpty(entry.cmd)) - { - item.ToolTipText = entry.name; - } - } - - private void ToolButtonClick(ToolEntry toolEntry) - { - if (string.IsNullOrEmpty(toolEntry.cmd)) - { - //TODO TabIndex => To Enum - OpenSettings(2); - return; - } - - if (CurrentLogWindow != null) - { - ILogLine line = CurrentLogWindow.GetCurrentLine(); - ILogFileInfo info = CurrentLogWindow.GetCurrentFileInfo(); - if (line != null && info != null) - { - ArgParser parser = new(toolEntry.args); - string argLine = parser.BuildArgs(line, CurrentLogWindow.GetRealLineNum() + 1, info, this); - if (argLine != null) - { - StartTool(toolEntry.cmd, argLine, toolEntry.sysout, toolEntry.columnizerName, - toolEntry.workingDir); - } - } - } - } - - private void StartTool(string cmd, string args, bool sysoutPipe, string columnizerName, string workingDir) - { - if (string.IsNullOrEmpty(cmd)) - { - return; - } - - Process process = new(); - ProcessStartInfo startInfo = new(cmd, args); - if (!Util.IsNull(workingDir)) - { - startInfo.WorkingDirectory = workingDir; - } - - process.StartInfo = startInfo; - process.EnableRaisingEvents = true; - - if (sysoutPipe) - { - ILogLineColumnizer columnizer = ColumnizerPicker.DecideColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - - _logger.Info("Starting external tool with sysout redirection: {0} {1}", cmd, args); - startInfo.UseShellExecute = false; - startInfo.RedirectStandardOutput = true; - //process.OutputDataReceived += pipe.DataReceivedEventHandler; - try - { - process.Start(); - } - catch (Win32Exception e) - { - _logger.Error(e); - MessageBox.Show(e.Message); - return; - } - - SysoutPipe pipe = new(process.StandardOutput); - - LogWindow.LogWindow logWin = AddTempFileTab(pipe.FileName, - CurrentLogWindow.IsTempFile - ? CurrentLogWindow.TempTitleName - : Util.GetNameFromPath(CurrentLogWindow.FileName) + "->E"); - logWin.ForceColumnizer(columnizer); - - process.Exited += pipe.ProcessExitedEventHandler; - //process.BeginOutputReadLine(); - } - else - { - _logger.Info("Starting external tool: {0} {1}", cmd, args); - - try - { - startInfo.UseShellExecute = false; - process.Start(); - } - catch (Exception e) - { - _logger.Error(e); - MessageBox.Show(e.Message); - } - } - } - - private void CloseAllTabs() - { - IList closeList = []; - lock (_logWindowList) - { - foreach (DockContent content in dockPanel.Contents) - { - if (content is LogWindow.LogWindow window) - { - closeList.Add(window); - } - } - } - - foreach (Form form in closeList) - { - form.Close(); - } - } - - private void SetTabColor(LogWindow.LogWindow logWindow, Color color) - { - //tabPage.BackLowColor = color; - //tabPage.BackLowColorDisabled = Color.FromArgb(255, - // Math.Max(0, color.R - 50), - // Math.Max(0, color.G - 50), - // Math.Max(0, color.B - 50) - // ); - } - - private void LoadProject(string projectFileName, bool restoreLayout) - { - ProjectData projectData = ProjectPersister.LoadProjectData(projectFileName); - bool hasLayoutData = projectData.tabLayoutXml != null; - - if (hasLayoutData && restoreLayout && _logWindowList.Count > 0) - { - ProjectLoadDlg dlg = new(); - if (DialogResult.Cancel != dlg.ShowDialog()) - { - switch (dlg.ProjectLoadResult) - { - case ProjectLoadDlgResult.IgnoreLayout: - hasLayoutData = false; - break; - case ProjectLoadDlgResult.CloseTabs: - CloseAllTabs(); - break; - case ProjectLoadDlgResult.NewWindow: - LogExpertProxy.NewWindow([projectFileName]); - return; - } - } - } - - if (projectData != null) - { - foreach (string fileName in projectData.memberList) - { - if (hasLayoutData) - { - AddFileTabDeferred(fileName, false, null, true, null); - } - else - { - AddFileTab(fileName, false, null, true, null); - } - } - - if (hasLayoutData && restoreLayout) - { - // Re-creating tool (non-document) windows is needed because the DockPanel control would throw strange errors - DestroyToolWindows(); - InitToolWindows(); - RestoreLayout(projectData.tabLayoutXml); - } - } - } - - private void ApplySelectedHighlightGroup() - { - string groupName = groupsComboBoxHighlightGroups.Text; - CurrentLogWindow?.SetCurrentHighlightGroup(groupName); - } - - private void FillToolLauncherBar() - { - char[] labels = - { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', - 'U', 'V', 'W', 'X', 'Y', 'Z' - }; - toolsToolStripMenuItem.DropDownItems.Clear(); - toolsToolStripMenuItem.DropDownItems.Add(configureToolStripMenuItem); - toolsToolStripMenuItem.DropDownItems.Add(configureToolStripSeparator); - externalToolsToolStrip.Items.Clear(); - int num = 0; - externalToolsToolStrip.SuspendLayout(); - foreach (ToolEntry tool in Preferences.toolEntries) - { - if (tool.isFavourite) - { - ToolStripButton button = new("" + labels[num % 26]) - { - Alignment = ToolStripItemAlignment.Left, - Tag = tool - }; - - SetToolIcon(tool, button); - externalToolsToolStrip.Items.Add(button); - } - - num++; - ToolStripMenuItem menuItem = new(tool.name); - menuItem.Tag = tool; - SetToolIcon(tool, menuItem); - toolsToolStripMenuItem.DropDownItems.Add(menuItem); - } - - externalToolsToolStrip.ResumeLayout(); - - externalToolsToolStrip.Visible = num > 0; // do not show bar if no tool uses it - } - - private void RunGC() - { - _logger.Info("Running GC. Used mem before: {0:N0}", GC.GetTotalMemory(false)); - GC.Collect(); - _logger.Info("GC done. Used mem after: {0:N0}", GC.GetTotalMemory(true)); - } - - private void DumpGCInfo() - { - _logger.Info("-------- GC info -----------\r\nUsed mem: {0:N0}", GC.GetTotalMemory(false)); - for (int i = 0; i < GC.MaxGeneration; ++i) - { - _logger.Info("Generation {0} collect count: {1}", i, GC.CollectionCount(i)); - } - - _logger.Info("----------------------------"); - } - - private void ThrowExceptionFx() - { - throw new Exception("This is a test exception thrown by an async delegate"); - } - - private void ThrowExceptionThreadFx() - { - throw new Exception("This is a test exception thrown by a background thread"); - } - - private string SaveLayout() - { - using MemoryStream memStream = new(2000); - using StreamReader r = new(memStream); - dockPanel.SaveAsXml(memStream, Encoding.UTF8, true); - - memStream.Seek(0, SeekOrigin.Begin); - string resultXml = r.ReadToEnd(); - - r.Close(); - - return resultXml; - } - - private void RestoreLayout(string layoutXml) - { - using MemoryStream memStream = new(2000); - using StreamWriter w = new(memStream); - w.Write(layoutXml); - w.Flush(); - - memStream.Seek(0, SeekOrigin.Begin); - - dockPanel.LoadFromXml(memStream, DeserializeDockContent, true); - } - - private IDockContent DeserializeDockContent(string persistString) - { - if (persistString.Equals(WindowTypes.BookmarkWindow.ToString())) - { - return _bookmarkWindow; - } - - if (persistString.StartsWith(WindowTypes.LogWindow.ToString())) - { - string fileName = persistString.Substring(WindowTypes.LogWindow.ToString().Length + 1); - LogWindow.LogWindow win = FindWindowForFile(fileName); - if (win != null) - { - return win; - } - - _logger.Warn("Layout data contains non-existing LogWindow for {0}", fileName); - } - - return null; - } - - private void OnHighlightSettingsChanged() - { - HighlightSettingsChanged?.Invoke(this, EventArgs.Empty); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindowPublic.cs b/src/LogExpert/Controls/LogTabWindow/LogTabWindowPublic.cs deleted file mode 100644 index 3d12b3b4..00000000 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindowPublic.cs +++ /dev/null @@ -1,360 +0,0 @@ -using LogExpert.Classes.Filter; -using LogExpert.Config; -using LogExpert.Core.Classes.Columnizer; -using LogExpert.Core.Config; -using LogExpert.Core.Entities; -using LogExpert.Dialogs; -using LogExpert.Entities; - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Runtime.InteropServices; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using System.Windows.Forms; - -using WeifenLuo.WinFormsUI.Docking; - -namespace LogExpert.Controls.LogTabWindow -{ - public partial class LogTabWindow - { - #region Public methods - - public LogWindow.LogWindow AddTempFileTab(string fileName, string title) - { - return AddFileTab(fileName, true, title, false, null); - } - - public LogWindow.LogWindow AddFilterTab(FilterPipe pipe, string title, ILogLineColumnizer preProcessColumnizer) - { - LogWindow.LogWindow logWin = AddFileTab(pipe.FileName, true, title, false, preProcessColumnizer); - if (pipe.FilterParams.SearchText.Length > 0) - { - ToolTip tip = new(components); - tip.SetToolTip(logWin, - "Filter: \"" + pipe.FilterParams.SearchText + "\"" + - (pipe.FilterParams.IsInvert ? " (Invert match)" : "") + - (pipe.FilterParams.ColumnRestrict ? "\nColumn restrict" : "") - ); - tip.AutomaticDelay = 10; - tip.AutoPopDelay = 5000; - LogWindowData data = logWin.Tag as LogWindowData; - data.toolTip = tip; - } - - return logWin; - } - - public LogWindow.LogWindow AddFileTabDeferred(string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer) - { - return AddFileTab(givenFileName, isTempFile, title, forcePersistenceLoading, preProcessColumnizer, true); - } - - public LogWindow.LogWindow AddFileTab(string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer, bool doNotAddToDockPanel = false) - { - string logFileName = FindFilenameForSettings(givenFileName); - LogWindow.LogWindow win = FindWindowForFile(logFileName); - if (win != null) - { - if (!isTempFile) - { - AddToFileHistory(givenFileName); - } - - SelectTab(win); - return win; - } - - EncodingOptions encodingOptions = new(); - FillDefaultEncodingFromSettings(encodingOptions); - LogWindow.LogWindow logWindow = new(this, logFileName, isTempFile, forcePersistenceLoading); - - logWindow.GivenFileName = givenFileName; - - if (preProcessColumnizer != null) - { - logWindow.ForceColumnizerForLoading(preProcessColumnizer); - } - - if (isTempFile) - { - logWindow.TempTitleName = title; - encodingOptions.Encoding = new UnicodeEncoding(false, false); - } - - AddLogWindow(logWindow, title, doNotAddToDockPanel); - if (!isTempFile) - { - AddToFileHistory(givenFileName); - } - - LogWindowData data = logWindow.Tag as LogWindowData; - data.color = _defaultTabColor; - SetTabColor(logWindow, _defaultTabColor); - //data.tabPage.BorderColor = this.defaultTabBorderColor; - if (!isTempFile) - { - foreach (ColorEntry colorEntry in ConfigManager.Settings.fileColors) - { - if (colorEntry.FileName.ToLower().Equals(logFileName.ToLower())) - { - data.color = colorEntry.Color; - SetTabColor(logWindow, colorEntry.Color); - break; - } - } - } - - if (!isTempFile) - { - SetTooltipText(logWindow, logFileName); - } - - if (givenFileName.EndsWith(".lxp")) - { - logWindow.ForcedPersistenceFileName = givenFileName; - } - - // this.BeginInvoke(new LoadFileDelegate(logWindow.LoadFile), new object[] { logFileName, encoding }); - Task.Run(() => logWindow.LoadFile(logFileName, encodingOptions)); - return logWindow; - } - - public LogWindow.LogWindow AddMultiFileTab(string[] fileNames) - { - if (fileNames.Length < 1) - { - return null; - } - - LogWindow.LogWindow logWindow = new(this, fileNames[fileNames.Length - 1], false, false); - AddLogWindow(logWindow, fileNames[fileNames.Length - 1], false); - multiFileToolStripMenuItem.Checked = true; - multiFileEnabledStripMenuItem.Checked = true; - EncodingOptions encodingOptions = new(); - FillDefaultEncodingFromSettings(encodingOptions); - BeginInvoke(new LoadMultiFilesDelegate(logWindow.LoadFilesAsMulti), fileNames, encodingOptions); - AddToFileHistory(fileNames[0]); - return logWindow; - } - - public void LoadFiles(string[] fileNames) - { - Invoke(new AddFileTabsDelegate(AddFileTabs), [fileNames]); - } - - public void OpenSearchDialog() - { - if (CurrentLogWindow == null) - { - return; - } - - SearchDialog dlg = new(); - AddOwnedForm(dlg); - dlg.TopMost = TopMost; - SearchParams.HistoryList = ConfigManager.Settings.searchHistoryList; - dlg.SearchParams = SearchParams; - DialogResult res = dlg.ShowDialog(); - if (res == DialogResult.OK && dlg.SearchParams != null && !string.IsNullOrWhiteSpace(dlg.SearchParams.SearchText)) - { - SearchParams = dlg.SearchParams; - SearchParams.IsFindNext = false; - CurrentLogWindow.StartSearch(); - } - } - - public ILogLineColumnizer GetColumnizerHistoryEntry(string fileName) - { - ColumnizerHistoryEntry entry = FindColumnizerHistoryEntry(fileName); - if (entry != null) - { - foreach (ILogLineColumnizer columnizer in PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers) - { - if (columnizer.GetName().Equals(entry.ColumnizerName)) - { - return columnizer; - } - } - - ConfigManager.Settings.columnizerHistoryList.Remove(entry); // no valid name -> remove entry - } - - return null; - } - - public void SwitchTab(bool shiftPressed) - { - int index = dockPanel.Contents.IndexOf(dockPanel.ActiveContent); - if (shiftPressed) - { - index--; - if (index < 0) - { - index = dockPanel.Contents.Count - 1; - } - - if (index < 0) - { - return; - } - } - else - { - index++; - if (index >= dockPanel.Contents.Count) - { - index = 0; - } - } - - if (index < dockPanel.Contents.Count) - { - (dockPanel.Contents[index] as DockContent).Activate(); - } - } - - public void ScrollAllTabsToTimestamp(DateTime timestamp, LogWindow.LogWindow senderWindow) - { - lock (_logWindowList) - { - foreach (LogWindow.LogWindow logWindow in _logWindowList) - { - if (logWindow != senderWindow) - { - if (logWindow.ScrollToTimestamp(timestamp, false, false)) - { - ShowLedPeak(logWindow); - } - } - } - } - } - - public ILogLineColumnizer FindColumnizerByFileMask(string fileName) - { - foreach (ColumnizerMaskEntry entry in ConfigManager.Settings.Preferences.columnizerMaskList) - { - if (entry.mask != null) - { - try - { - if (Regex.IsMatch(fileName, entry.mask)) - { - ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(entry.columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - return columnizer; - } - } - catch (ArgumentException e) - { - _logger.Error(e, "RegEx-error while finding columnizer: "); - // occurs on invalid regex patterns - } - } - } - - return null; - } - - public HighlightGroup FindHighlightGroupByFileMask(string fileName) - { - foreach (HighlightMaskEntry entry in ConfigManager.Settings.Preferences.highlightMaskList) - { - if (entry.mask != null) - { - try - { - if (Regex.IsMatch(fileName, entry.mask)) - { - HighlightGroup group = FindHighlightGroup(entry.highlightGroupName); - return group; - } - } - catch (ArgumentException e) - { - _logger.Error(e, "RegEx-error while finding columnizer: "); - // occurs on invalid regex patterns - } - } - } - - return null; - } - - public void SelectTab(LogWindow.LogWindow logWindow) - { - logWindow.Activate(); - } - - public void SetForeground() - { - SetForegroundWindow(Handle); - if (WindowState == FormWindowState.Minimized) - { - if (_wasMaximized) - { - WindowState = FormWindowState.Maximized; - } - else - { - WindowState = FormWindowState.Normal; - } - } - } - - [DllImport("User32.dll")] - public static extern int SetForegroundWindow(IntPtr hWnd); - - // called from LogWindow when follow tail was changed - public void FollowTailChanged(LogWindow.LogWindow logWindow, bool isEnabled, bool offByTrigger) - { - LogWindowData data = logWindow.Tag as LogWindowData; - if (data == null) - { - return; - } - - if (isEnabled) - { - data.tailState = 0; - } - else - { - data.tailState = offByTrigger ? 2 : 1; - } - - if (Preferences.showTailState) - { - Icon icon = GetIcon(data.diffSum, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); - } - } - - public void NotifySettingsChanged(object sender, SettingsFlags flags) - { - if (sender != this) - { - NotifyWindowsForChangedPrefs(flags); - } - } - - public IList GetListOfOpenFiles() - { - IList list = new List(); - lock (_logWindowList) - { - foreach (LogWindow.LogWindow logWindow in _logWindowList) - { - list.Add(new WindowFileEntry(logWindow)); - } - } - - return list; - } - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/AllowOnlyOneInstanceErrorDialog.Designer.cs b/src/LogExpert/Dialogs/AllowOnlyOneInstanceErrorDialog.Designer.cs deleted file mode 100644 index e9f7f27f..00000000 --- a/src/LogExpert/Dialogs/AllowOnlyOneInstanceErrorDialog.Designer.cs +++ /dev/null @@ -1,100 +0,0 @@ - -namespace LogExpert.Dialogs -{ - partial class AllowOnlyOneInstanceErrorDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.checkBoxIgnoreMessage = new System.Windows.Forms.CheckBox(); - this.buttonOk = new System.Windows.Forms.Button(); - this.labelErrorText = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // checkBoxIgnoreMessage - // - this.checkBoxIgnoreMessage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.checkBoxIgnoreMessage.AutoSize = true; - this.checkBoxIgnoreMessage.Location = new System.Drawing.Point(9, 56); - this.checkBoxIgnoreMessage.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); - this.checkBoxIgnoreMessage.Name = "checkBoxIgnoreMessage"; - this.checkBoxIgnoreMessage.Size = new System.Drawing.Size(177, 17); - this.checkBoxIgnoreMessage.TabIndex = 0; - this.checkBoxIgnoreMessage.Text = "Show this message only once\\?"; - this.checkBoxIgnoreMessage.UseVisualStyleBackColor = true; - // - // buttonOk - // - this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(209, 53); - this.buttonOk.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(74, 23); - this.buttonOk.TabIndex = 1; - this.buttonOk.Text = "Ok"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.OnButtonOkClick); - // - // labelErrorText - // - this.labelErrorText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.labelErrorText.AutoEllipsis = true; - this.labelErrorText.Location = new System.Drawing.Point(9, 8); - this.labelErrorText.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.labelErrorText.Name = "labelErrorText"; - this.labelErrorText.Size = new System.Drawing.Size(273, 43); - this.labelErrorText.TabIndex = 2; - this.labelErrorText.Text = "Only one instance allowed, uncheck \\\"View Settings => Allow only 1 Instances\\\" to" + - " start multiple instances!"; - // - // AllowOnlyOneInstanceErrorDialog - // - this.ClientSize = new System.Drawing.Size(293, 84); - this.Controls.Add(this.labelErrorText); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.checkBoxIgnoreMessage); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); - this.MaximizeBox = false; - this.Name = "AllowOnlyOneInstanceErrorDialog"; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.Text = "AllowOnlyOneInstanceErrorDialog"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.CheckBox checkBoxIgnoreMessage; - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.Label labelErrorText; - } -} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/AllowOnlyOneInstanceErrorDialog.cs b/src/LogExpert/Dialogs/AllowOnlyOneInstanceErrorDialog.cs deleted file mode 100644 index 2c2c29f1..00000000 --- a/src/LogExpert/Dialogs/AllowOnlyOneInstanceErrorDialog.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public partial class AllowOnlyOneInstanceErrorDialog : Form - { - public bool DoNotShowThisMessageAgain { get; private set; } - - public AllowOnlyOneInstanceErrorDialog() - { - InitializeComponent(); - SetText(); - } - - private void SetText() - { - labelErrorText.Text = @"Only one instance allowed, uncheck ""View Settings => Allow only 1 Instances"" to start multiple instances!"; - } - - private void OnButtonOkClick(object sender, System.EventArgs e) - { - DoNotShowThisMessageAgain = checkBoxIgnoreMessage.Checked; - } - } -} diff --git a/src/LogExpert/Dialogs/BookmarkWindow.Designer.cs b/src/LogExpert/Dialogs/BookmarkWindow.Designer.cs deleted file mode 100644 index e0931cdd..00000000 --- a/src/LogExpert/Dialogs/BookmarkWindow.Designer.cs +++ /dev/null @@ -1,196 +0,0 @@ -namespace LogExpert.Dialogs { - partial class BookmarkWindow { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) { - if (disposing && (components != null)) { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BookmarkWindow)); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.deleteBookmarkssToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.removeCommentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.bookmarkTextBox = new System.Windows.Forms.TextBox(); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.bookmarkDataGridView = new LogExpert.Dialogs.BufferedDataGridView(); - this.commentColumnCheckBox = new System.Windows.Forms.CheckBox(); - this.label1 = new System.Windows.Forms.Label(); - this.contextMenuStrip1.SuspendLayout(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.bookmarkDataGridView)).BeginInit(); - this.SuspendLayout(); - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.deleteBookmarkssToolStripMenuItem, - this.removeCommentsToolStripMenuItem}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(186, 48); - // - // deleteBookmarkssToolStripMenuItem - // - this.deleteBookmarkssToolStripMenuItem.Name = "deleteBookmarkssToolStripMenuItem"; - this.deleteBookmarkssToolStripMenuItem.Size = new System.Drawing.Size(185, 22); - this.deleteBookmarkssToolStripMenuItem.Text = "Delete bookmarks(s)"; - this.deleteBookmarkssToolStripMenuItem.Click += new System.EventHandler(this.deleteBookmarksToolStripMenuItem_Click); - // - // removeCommentsToolStripMenuItem - // - this.removeCommentsToolStripMenuItem.Name = "removeCommentsToolStripMenuItem"; - this.removeCommentsToolStripMenuItem.Size = new System.Drawing.Size(185, 22); - this.removeCommentsToolStripMenuItem.Text = "Remove comment(s)"; - this.removeCommentsToolStripMenuItem.Click += new System.EventHandler(this.removeCommentsToolStripMenuItem_Click); - // - // bookmarkTextBox - // - this.bookmarkTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.bookmarkTextBox.Location = new System.Drawing.Point(0, 20); - this.bookmarkTextBox.Multiline = true; - this.bookmarkTextBox.Name = "bookmarkTextBox"; - this.bookmarkTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.bookmarkTextBox.Size = new System.Drawing.Size(194, 114); - this.bookmarkTextBox.TabIndex = 0; - this.bookmarkTextBox.TextChanged += new System.EventHandler(this.bookmarkTextBox_TextChanged); - // - // splitContainer1 - // - this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer1.Location = new System.Drawing.Point(0, 0); - this.splitContainer1.Name = "splitContainer1"; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.bookmarkDataGridView); - this.splitContainer1.Panel1MinSize = 40; - // - // splitContainer1.Panel2 - // - this.splitContainer1.Panel2.Controls.Add(this.commentColumnCheckBox); - this.splitContainer1.Panel2.Controls.Add(this.label1); - this.splitContainer1.Panel2.Controls.Add(this.bookmarkTextBox); - this.splitContainer1.Size = new System.Drawing.Size(717, 158); - this.splitContainer1.SplitterDistance = 517; - this.splitContainer1.TabIndex = 7; - // - // bookmarkDataGridView - // - this.bookmarkDataGridView.AllowUserToAddRows = false; - this.bookmarkDataGridView.AllowUserToDeleteRows = false; - this.bookmarkDataGridView.AllowUserToOrderColumns = true; - this.bookmarkDataGridView.AllowUserToResizeRows = false; - this.bookmarkDataGridView.BackgroundColor = System.Drawing.SystemColors.Window; - this.bookmarkDataGridView.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.bookmarkDataGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; - this.bookmarkDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.bookmarkDataGridView.ContextMenuStrip = this.contextMenuStrip1; - this.bookmarkDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; - this.bookmarkDataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; - this.bookmarkDataGridView.EditModeMenuStrip = null; - this.bookmarkDataGridView.Location = new System.Drawing.Point(0, 0); - this.bookmarkDataGridView.Margin = new System.Windows.Forms.Padding(0); - this.bookmarkDataGridView.Name = "bookmarkDataGridView"; - this.bookmarkDataGridView.PaintWithOverlays = false; - this.bookmarkDataGridView.ReadOnly = true; - this.bookmarkDataGridView.RowHeadersVisible = false; - this.bookmarkDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.bookmarkDataGridView.Size = new System.Drawing.Size(517, 158); - this.bookmarkDataGridView.TabIndex = 0; - this.bookmarkDataGridView.VirtualMode = true; - this.bookmarkDataGridView.Enter += new System.EventHandler(this.bookmarkGridView_Enter); - this.bookmarkDataGridView.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.bookmarkDataGridView_CellDoubleClick); - this.bookmarkDataGridView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.boomarkDataGridView_MouseDoubleClick); - this.bookmarkDataGridView.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.bookmarkDataGridView_PreviewKeyDown); - this.bookmarkDataGridView.Leave += new System.EventHandler(this.bookmarkGridView_Leave); - this.bookmarkDataGridView.ColumnDividerDoubleClick += new System.Windows.Forms.DataGridViewColumnDividerDoubleClickEventHandler(this.boomarkDataGridView_ColumnDividerDoubleClick); - this.bookmarkDataGridView.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(this.bookmarkDataGridView_RowsAdded); - this.bookmarkDataGridView.SelectionChanged += new System.EventHandler(bookmarkDataGridView_SelectionChanged); - this.bookmarkDataGridView.CellToolTipTextNeeded += new System.Windows.Forms.DataGridViewCellToolTipTextNeededEventHandler(this.bookmarkDataGridView_CellToolTipTextNeeded); - this.bookmarkDataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.bookmarkGridView_KeyDown); - this.bookmarkDataGridView.RowsRemoved += new System.Windows.Forms.DataGridViewRowsRemovedEventHandler(this.bookmarkDataGridView_RowsRemoved); - // - // commentColumnCheckBox - // - this.commentColumnCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.commentColumnCheckBox.AutoSize = true; - this.commentColumnCheckBox.Location = new System.Drawing.Point(7, 138); - this.commentColumnCheckBox.Name = "commentColumnCheckBox"; - this.commentColumnCheckBox.Size = new System.Drawing.Size(136, 17); - this.commentColumnCheckBox.TabIndex = 8; - this.commentColumnCheckBox.Text = "Show comment column"; - this.commentColumnCheckBox.UseVisualStyleBackColor = true; - this.commentColumnCheckBox.CheckedChanged += new System.EventHandler(this.commentColumnCheckBox_CheckedChanged); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(4, 4); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(104, 13); - this.label1.TabIndex = 7; - this.label1.Text = "Bookmark comment:"; - // - // BookmarkWindow - // - this.ClientSize = new System.Drawing.Size(717, 158); - this.ControlBox = false; - this.Controls.Add(this.splitContainer1); - this.DockAreas = ((WeifenLuo.WinFormsUI.Docking.DockAreas)(((((WeifenLuo.WinFormsUI.Docking.DockAreas.Float | WeifenLuo.WinFormsUI.Docking.DockAreas.DockLeft) - | WeifenLuo.WinFormsUI.Docking.DockAreas.DockRight) - | WeifenLuo.WinFormsUI.Docking.DockAreas.DockTop) - | WeifenLuo.WinFormsUI.Docking.DockAreas.DockBottom))); - this.DoubleBuffered = true; - this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "BookmarkWindow"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.Text = "Bookmarks"; - this.ClientSizeChanged += new System.EventHandler(this.BookmarkWindow_ClientSizeChanged); - this.SizeChanged += new System.EventHandler(this.BookmarkWindow_SizeChanged); - this.contextMenuStrip1.ResumeLayout(false); - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel2.ResumeLayout(false); - this.splitContainer1.Panel2.PerformLayout(); - this.splitContainer1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.bookmarkDataGridView)).EndInit(); - this.ResumeLayout(false); - } - - #endregion - - private BufferedDataGridView bookmarkDataGridView; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem deleteBookmarkssToolStripMenuItem; - private System.Windows.Forms.TextBox bookmarkTextBox; - private System.Windows.Forms.SplitContainer splitContainer1; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.ToolStripMenuItem removeCommentsToolStripMenuItem; - private System.Windows.Forms.CheckBox commentColumnCheckBox; - } -} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/BookmarkWindow.cs b/src/LogExpert/Dialogs/BookmarkWindow.cs deleted file mode 100644 index 321ffe5a..00000000 --- a/src/LogExpert/Dialogs/BookmarkWindow.cs +++ /dev/null @@ -1,677 +0,0 @@ -using LogExpert.Classes; -using LogExpert.Core.Config; -using LogExpert.Core.Entities; -using LogExpert.Core.Enums; -using LogExpert.Core.Interface; -using LogExpert.UI.Extensions.Forms; - -using NLog; - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Windows.Forms; - -using WeifenLuo.WinFormsUI.Docking; - -namespace LogExpert.Dialogs -{ - //TODO can be moved to Logexpert.UI if the PaintHelper has been refactored - public partial class BookmarkWindow : DockContent, ISharedToolWindow, IBookmarkView - { - #region Fields - - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - private readonly object paintLock = new(); - - private IBookmarkData bookmarkData; - private ILogPaintContext logPaintContext; - private ILogView logView; - - #endregion - - #region cTor - - public BookmarkWindow() - { - InitializeComponent(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - bookmarkDataGridView.CellValueNeeded += OnBoomarkDataGridViewCellValueNeeded; - bookmarkDataGridView.CellPainting += boomarkDataGridView_CellPainting; - - ChangeTheme(Controls); - } - - #endregion - - #region ColorTheme - - public void ChangeTheme(Control.ControlCollection container) - { - #region ApplyColorToAllControls - foreach (Control component in container) - { - if (component.Controls != null && component.Controls.Count > 0) - { - ChangeTheme(component.Controls); - component.BackColor = ColorMode.BackgroundColor; - component.ForeColor = ColorMode.ForeColor; - } - else - { - component.BackColor = ColorMode.BackgroundColor; - component.ForeColor = ColorMode.ForeColor; - } - - } - #endregion - - #region DataGridView - - BackColor = ColorMode.DockBackgroundColor; - - // Main DataGridView - bookmarkDataGridView.BackgroundColor = ColorMode.DockBackgroundColor; - bookmarkDataGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor; - bookmarkDataGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor; - bookmarkDataGridView.EnableHeadersVisualStyles = false; - - // Colors for menu - contextMenuStrip1.Renderer = new ExtendedMenuStripRenderer(); - - for (var y = 0; y < contextMenuStrip1.Items.Count; y++) - { - var item = contextMenuStrip1.Items[y]; - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - #endregion DataGridView - } - - #endregion - - #region Properties - - public bool LineColumnVisible - { - set => bookmarkDataGridView.Columns[2].Visible = value; - } - - public bool ShowBookmarkCommentColumn - { - get => commentColumnCheckBox.Checked; - set - { - commentColumnCheckBox.Checked = value; - ShowCommentColumn(value); - } - } - - #endregion - - #region Public methods - - public void SetColumnizer(ILogLineColumnizer columnizer) - { - PaintHelper.SetColumnizer(columnizer, bookmarkDataGridView); - - if (bookmarkDataGridView.ColumnCount > 0) - { - bookmarkDataGridView.Columns[0].Width = 20; - } - - DataGridViewTextBoxColumn commentColumn = new(); - commentColumn.HeaderText = "Bookmark Comment"; - commentColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; - commentColumn.Resizable = DataGridViewTriState.NotSet; - commentColumn.DividerWidth = 1; - commentColumn.ReadOnly = true; - commentColumn.Width = 250; - commentColumn.MinimumWidth = 130; - bookmarkDataGridView.Columns.Insert(1, commentColumn); - ShowCommentColumn(commentColumnCheckBox.Checked); - ResizeColumns(); - } - - /// - /// Called from LogWindow after reloading and when double clicking a header divider. - /// - public void ResizeColumns() - { - // this.bookmarkDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - for (int i = 2; i < bookmarkDataGridView.ColumnCount; ++i) - { - bookmarkDataGridView.AutoResizeColumn(i, DataGridViewAutoSizeColumnMode.DisplayedCells); - } - } - - public void UpdateView() - { - bookmarkDataGridView.RowCount = bookmarkData?.Bookmarks.Count ?? 0; - ResizeColumns(); - bookmarkDataGridView.Refresh(); - } - - /// - /// Called from LogWindow if the bookmark text was changed via popup window - /// - /// - public void BookmarkTextChanged(Bookmark bookmark) - { - int rowIndex = bookmarkDataGridView.CurrentCellAddress.Y; - if (rowIndex == -1) - { - return; - } - - if (bookmarkData.Bookmarks[rowIndex] == bookmark) - { - bookmarkTextBox.Text = bookmark.Text; - } - - bookmarkDataGridView.Refresh(); - } - - public void SelectBookmark(int lineNum) - { - if (bookmarkData.IsBookmarkAtLine(lineNum)) - { - if (bookmarkDataGridView.Rows.GetRowCount(DataGridViewElementStates.None) < bookmarkData.Bookmarks.Count) - { - // just for the case... There was an exception but I cannot find the cause - UpdateView(); - } - - int row = bookmarkData.GetBookmarkIndexForLine(lineNum); - bookmarkDataGridView.CurrentCell = bookmarkDataGridView.Rows[row].Cells[0]; - } - } - - public void SetBookmarkData(IBookmarkData bookmarkData) - { - this.bookmarkData = bookmarkData; - bookmarkDataGridView.RowCount = bookmarkData?.Bookmarks.Count ?? 0; - HideIfNeeded(); - } - - public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags) - { - if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors) - { - SetFont(newPreferences.fontName, newPreferences.fontSize); - if (bookmarkDataGridView.Columns.Count > 1 && newPreferences.setLastColumnWidth) - { - bookmarkDataGridView.Columns[bookmarkDataGridView.Columns.Count - 1].MinimumWidth = - newPreferences.lastColumnWidth; - } - - PaintHelper.ApplyDataGridViewPrefs(bookmarkDataGridView, newPreferences); - } - } - - public void SetCurrentFile(FileViewContext ctx) - { - if (ctx != null) - { - _logger.Debug("Current file changed to {0}", ctx.LogView.FileName); - lock (paintLock) - { - logView = ctx.LogView; - logPaintContext = ctx.LogPaintContext; - } - - SetColumnizer(ctx.LogView.CurrentColumnizer); - } - else - { - logView = null; - logPaintContext = null; - } - - UpdateView(); - } - - public void FileChanged() - { - // nothing to do - } - - #endregion - - #region Overrides - - protected override string GetPersistString() - { - return WindowTypes.BookmarkWindow.ToString(); - } - - protected override void OnPaint(PaintEventArgs e) - { - if (!splitContainer1.Visible) - { - Rectangle r = ClientRectangle; - e.Graphics.FillRectangle(SystemBrushes.FromSystemColor(ColorMode.BookmarksDefaultBackgroundColor), r); - RectangleF rect = r; - StringFormat sf = new(); - sf.Alignment = StringAlignment.Center; - sf.LineAlignment = StringAlignment.Center; - e.Graphics.DrawString("No bookmarks in current file", SystemFonts.DialogFont, SystemBrushes.WindowText, r, sf); - } - else - { - base.OnPaint(e); - } - } - - #endregion - - #region Private Methods - - private void SetFont(string fontName, float fontSize) - { - Font font = new(new FontFamily(fontName), fontSize); - bookmarkDataGridView.DefaultCellStyle.Font = font; - bookmarkDataGridView.RowTemplate.Height = font.Height + 4; - bookmarkDataGridView.Refresh(); - } - - private void CommentPainting(BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) - { - Color backColor = ColorMode.DockBackgroundColor; - - if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) - { - Brush brush; - if (gridView.Focused) - { - // _logger.logDebug("CellPaint Focus"); - brush = new SolidBrush(backColor); - } - else - { - // _logger.logDebug("CellPaint No Focus"); - Color color = Color.FromArgb(255, 170, 170, 170); - brush = new SolidBrush(color); - } - - e.Graphics.FillRectangle(brush, e.CellBounds); - brush.Dispose(); - } - else - { - e.CellStyle.BackColor = backColor; - e.PaintBackground(e.CellBounds, false); - } - - e.PaintContent(e.CellBounds); - } - - private void DeleteSelectedBookmarks() - { - List lineNumList = []; - foreach (DataGridViewRow row in bookmarkDataGridView.SelectedRows) - { - if (row.Index != -1) - { - lineNumList.Add(bookmarkData.Bookmarks[row.Index].LineNum); - } - } - - logView?.DeleteBookmarks(lineNumList); - } - - private static void InvalidateCurrentRow(BufferedDataGridView gridView) - { - if (gridView.CurrentCellAddress.Y > -1) - { - gridView.InvalidateRow(gridView.CurrentCellAddress.Y); - } - } - - private void CurrentRowChanged(int rowIndex) - { - if (rowIndex == -1) - { - // multiple selection or no selection at all - bookmarkTextBox.Enabled = false; - - // disable the control first so that changes made to it won't propagate to the bookmark item - bookmarkTextBox.Text = string.Empty; - } - else - { - Bookmark bookmark = bookmarkData.Bookmarks[rowIndex]; - bookmarkTextBox.Text = bookmark.Text; - bookmarkTextBox.Enabled = true; - } - } - - private void ShowCommentColumn(bool show) - { - bookmarkDataGridView.Columns[1].Visible = show; - } - - private void HideIfNeeded() - { - splitContainer1.Visible = bookmarkDataGridView.RowCount > 0; - } - - #endregion - - #region Events handler - - private void boomarkDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) - { - if (bookmarkData == null) - { - return; - } - - lock (paintLock) - { - try - { - if (e.RowIndex < 0 || e.ColumnIndex < 0 || bookmarkData.Bookmarks.Count <= e.RowIndex) - { - e.Handled = false; - return; - } - - int lineNum = bookmarkData.Bookmarks[e.RowIndex].LineNum; - - // if (e.ColumnIndex == 1) - // { - // CommentPainting(this.bookmarkDataGridView, lineNum, e); - // } - { - // else - PaintHelper.CellPainting(logPaintContext, bookmarkDataGridView, lineNum, e); - } - } - catch (Exception ex) - { - _logger.Error(ex); - } - } - } - - private void OnBoomarkDataGridViewCellValueNeeded(object sender, DataGridViewCellValueEventArgs e) - { - if (bookmarkData == null) - { - return; - } - - if (e.RowIndex < 0 || e.ColumnIndex < 0 || bookmarkData.Bookmarks.Count <= e.RowIndex) - { - e.Value = string.Empty; - return; - } - - Bookmark bookmarkForLine = bookmarkData.Bookmarks[e.RowIndex]; - int lineNum = bookmarkForLine.LineNum; - if (e.ColumnIndex == 1) - { - e.Value = bookmarkForLine.Text?.Replace('\n', ' ').Replace('\r', ' '); - } - else - { - int columnIndex = e.ColumnIndex > 1 ? e.ColumnIndex - 1 : e.ColumnIndex; - e.Value = logPaintContext.GetCellValue(lineNum, columnIndex); - } - } - - - private void boomarkDataGridView_MouseDoubleClick(object sender, MouseEventArgs e) - { - // if (this.bookmarkDataGridView.CurrentRow != null) - // { - // int lineNum = this.BookmarkList.Values[this.bookmarkDataGridView.CurrentRow.Index].LineNum; - // this.logWindow.SelectLogLine(lineNum); - // } - } - - private void boomarkDataGridView_ColumnDividerDoubleClick(object sender, - DataGridViewColumnDividerDoubleClickEventArgs e) - { - e.Handled = true; - ResizeColumns(); - } - - private void bookmarkGridView_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - if (bookmarkDataGridView.CurrentCellAddress.Y >= 0 && - bookmarkDataGridView.CurrentCellAddress.Y < bookmarkData.Bookmarks.Count) - { - int lineNum = bookmarkData.Bookmarks[bookmarkDataGridView.CurrentCellAddress.Y].LineNum; - logView.SelectLogLine(lineNum); - } - - e.Handled = true; - } - - if (e.KeyCode == Keys.Delete && e.Modifiers == Keys.None) - { - DeleteSelectedBookmarks(); - } - - if (e.KeyCode == Keys.Tab) - { - if (bookmarkDataGridView.Focused) - { - bookmarkTextBox.Focus(); - e.Handled = true; - } - } - } - - private void bookmarkGridView_Enter(object sender, EventArgs e) - { - InvalidateCurrentRow(bookmarkDataGridView); - } - - private void bookmarkGridView_Leave(object sender, EventArgs e) - { - InvalidateCurrentRow(bookmarkDataGridView); - } - - private void deleteBookmarksToolStripMenuItem_Click(object sender, EventArgs e) - { - DeleteSelectedBookmarks(); - } - - private void bookmarkTextBox_TextChanged(object sender, EventArgs e) - { - if (!bookmarkTextBox.Enabled) - { - return; // ignore all changes done while the control is disabled - } - - int rowIndex = bookmarkDataGridView.CurrentCellAddress.Y; - if (rowIndex == -1) - { - return; - } - - if (bookmarkData.Bookmarks.Count <= rowIndex) - { - return; - } - - Bookmark bookmark = bookmarkData.Bookmarks[rowIndex]; - bookmark.Text = bookmarkTextBox.Text; - logView?.RefreshLogView(); - } - - private void bookmarkDataGridView_SelectionChanged(object sender, EventArgs e) - { - if (bookmarkDataGridView.SelectedRows.Count != 1 - || bookmarkDataGridView.SelectedRows[0].Index >= bookmarkData.Bookmarks.Count) - { - CurrentRowChanged(-1); - } - else - { - CurrentRowChanged(bookmarkDataGridView.SelectedRows[0].Index); - } - } - - private void bookmarkDataGridView_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) - { - if (e.KeyCode == Keys.Tab) - { - e.IsInputKey = true; - } - } - - private void bookmarkDataGridView_CellToolTipTextNeeded(object sender, - DataGridViewCellToolTipTextNeededEventArgs e) - { - if (e.ColumnIndex != 0 || e.RowIndex <= -1 || e.RowIndex >= bookmarkData.Bookmarks.Count) - { - return; - } - - Bookmark bookmark = bookmarkData.Bookmarks[e.RowIndex]; - if (!string.IsNullOrEmpty(bookmark.Text)) - { - e.ToolTipText = bookmark.Text; - return; - } - } - - private void bookmarkDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) - { - // Toggle bookmark when double-clicking on the first column - if (e.ColumnIndex == 0 && e.RowIndex >= 0 && bookmarkDataGridView.CurrentRow != null) - { - int index = bookmarkDataGridView.CurrentRow.Index; - int lineNum = bookmarkData.Bookmarks[bookmarkDataGridView.CurrentRow.Index].LineNum; - bookmarkData.ToggleBookmark(lineNum); - - // we don't ask for confirmation if the bookmark has an associated comment... - int boomarkCount = bookmarkData.Bookmarks.Count; - bookmarkDataGridView.RowCount = boomarkCount; - - if (index < boomarkCount) - { - bookmarkDataGridView.CurrentCell = bookmarkDataGridView.Rows[index].Cells[0]; - } - else - { - if (boomarkCount > 0) - { - bookmarkDataGridView.CurrentCell = - bookmarkDataGridView.Rows[boomarkCount - 1].Cells[0]; - } - } - - if (boomarkCount > index) - { - CurrentRowChanged(index); - } - else - { - if (boomarkCount > 0) - { - CurrentRowChanged(bookmarkDataGridView.RowCount - 1); - } - else - { - CurrentRowChanged(-1); - } - } - - return; - } - - if (bookmarkDataGridView.CurrentRow != null && e.RowIndex >= 0) - { - int lineNum = bookmarkData.Bookmarks[bookmarkDataGridView.CurrentRow.Index].LineNum; - logView.SelectAndEnsureVisible(lineNum, true); - } - } - - private void removeCommentsToolStripMenuItem_Click(object sender, EventArgs e) - { - if ( - MessageBox.Show("Really remove bookmark comments for selected lines?", "LogExpert", - MessageBoxButtons.YesNo) == - DialogResult.Yes) - { - List lineNumList = []; - foreach (DataGridViewRow row in bookmarkDataGridView.SelectedRows) - { - if (row.Index != -1) - { - bookmarkData.Bookmarks[row.Index].Text = string.Empty; - } - } - - bookmarkTextBox.Text = string.Empty; - bookmarkDataGridView.Refresh(); - logView.RefreshLogView(); - } - } - - private void commentColumnCheckBox_CheckedChanged(object sender, EventArgs e) - { - ShowCommentColumn(commentColumnCheckBox.Checked); - } - - private void BookmarkWindow_ClientSizeChanged(object sender, EventArgs e) - { - if (Width > 0 && Height > 0) - { - if (Width > Height) - { - splitContainer1.Orientation = Orientation.Vertical; - int distance = Width - 200; - splitContainer1.SplitterDistance = distance > splitContainer1.Panel1MinSize - ? distance - : splitContainer1.Panel1MinSize; - } - else - { - splitContainer1.Orientation = Orientation.Horizontal; - int distance = Height - 200; - splitContainer1.SplitterDistance = distance > splitContainer1.Panel1MinSize - ? distance - : splitContainer1.Panel1MinSize; - } - } - - if (!splitContainer1.Visible) - { - // redraw the "no bookmarks" display - Invalidate(); - } - } - - private void bookmarkDataGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) - { - HideIfNeeded(); - } - - private void bookmarkDataGridView_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e) - { - HideIfNeeded(); - } - - private void BookmarkWindow_SizeChanged(object sender, EventArgs e) - { - // if (!this.splitContainer1.Visible) - // { - // // redraw the "no bookmarks" display - // Invalidate(); - // } - } - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/BufferedDataGridView.Designer.cs b/src/LogExpert/Dialogs/BufferedDataGridView.Designer.cs deleted file mode 100644 index 73c2d006..00000000 --- a/src/LogExpert/Dialogs/BufferedDataGridView.Designer.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace LogExpert.Dialogs -{ - partial class BufferedDataGridView - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - components = new System.ComponentModel.Container(); - } - - #endregion - } -} diff --git a/src/LogExpert/Dialogs/BufferedDataGridView.cs b/src/LogExpert/Dialogs/BufferedDataGridView.cs deleted file mode 100644 index 2c783f07..00000000 --- a/src/LogExpert/Dialogs/BufferedDataGridView.cs +++ /dev/null @@ -1,343 +0,0 @@ -using LogExpert.Core.Entities; -using LogExpert.Core.EventArgs; -using LogExpert.UI.Controls; - -using NLog; - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public partial class BufferedDataGridView : DataGridView - { - #region Fields - - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - private readonly Brush _brush; - - private readonly Color _bubbleColor = Color.FromArgb(160, 250, 250, 00); - private readonly Font _font = new("Arial", 10); - - private readonly SortedList _overlayList = []; - - private readonly Pen _pen; - private readonly Brush _textBrush = new SolidBrush(Color.FromArgb(200, 0, 0, 90)); - - private BookmarkOverlay _draggedOverlay; - private Point _dragStartPoint; - private bool _isDrag; - private Size _oldOverlayOffset; - - #endregion - - #region cTor - - public BufferedDataGridView() - { - _pen = new Pen(_bubbleColor, (float)3.0); - _brush = new SolidBrush(_bubbleColor); - - InitializeComponent(); - DoubleBuffered = true; - VirtualMode = true; - } - - #endregion - - #region Delegates - - public delegate void OverlayDoubleClickedEventHandler(object sender, OverlayEventArgs e); - - #endregion - - #region Events - - public event OverlayDoubleClickedEventHandler OverlayDoubleClicked; - - #endregion - - #region Properties - - /* - public Graphics Buffer - { - get { return this.myBuffer.Graphics; } - } - */ - - public ContextMenuStrip EditModeMenuStrip { get; set; } = null; - - public bool PaintWithOverlays { get; set; } = false; - - #endregion - - #region Public methods - - public void AddOverlay(BookmarkOverlay overlay) - { - lock (_overlayList) - { - _overlayList.Add(overlay.Position.Y, overlay); - } - } - - #endregion - - #region Overrides - - protected override void OnPaint(PaintEventArgs e) - { - try - { - if (PaintWithOverlays) - { - PaintOverlays(e); - } - else - { - base.OnPaint(e); - } - } - catch (Exception ex) - { - _logger.Error(ex); - } - } - - protected override void OnEditingControlShowing(DataGridViewEditingControlShowingEventArgs e) - { - base.OnEditingControlShowing(e); - e.Control.KeyDown -= OnControlKeyDown; - e.Control.KeyDown += OnControlKeyDown; - DataGridViewTextBoxEditingControl editControl = (DataGridViewTextBoxEditingControl)e.Control; - e.Control.PreviewKeyDown -= Control_PreviewKeyDown; - e.Control.PreviewKeyDown += Control_PreviewKeyDown; - - editControl.ContextMenuStrip = EditModeMenuStrip; - } - - protected override void OnMouseDown(MouseEventArgs e) - { - BookmarkOverlay overlay = GetOverlayForPosition(e.Location); - if (overlay != null) - { - if (e.Button == MouseButtons.Right) - { - if (_isDrag) - { - _isDrag = false; - overlay.Bookmark.OverlayOffset = _oldOverlayOffset; - Refresh(); - } - } - else - { - _dragStartPoint = e.Location; - _isDrag = true; - _draggedOverlay = overlay; - _oldOverlayOffset = overlay.Bookmark.OverlayOffset; - } - } - else - { - _isDrag = false; - base.OnMouseDown(e); - } - } - - protected override void OnMouseUp(MouseEventArgs e) - { - if (_isDrag) - { - _isDrag = false; - Refresh(); - } - else - { - base.OnMouseUp(e); - } - } - - protected override void OnMouseMove(MouseEventArgs e) - { - if (_isDrag) - { - Cursor = Cursors.Hand; - Size offset = new(e.X - _dragStartPoint.X, e.Y - _dragStartPoint.Y); - _draggedOverlay.Bookmark.OverlayOffset = _oldOverlayOffset + offset; - Refresh(); - } - else - { - BookmarkOverlay overlay = GetOverlayForPosition(e.Location); - Cursor = overlay != null ? Cursors.Hand : Cursors.Default; - base.OnMouseMove(e); - } - } - - protected override void OnMouseDoubleClick(MouseEventArgs e) - { - BookmarkOverlay overlay = GetOverlayForPosition(e.Location); - if (overlay != null) - { - if (e.Button == MouseButtons.Left) - { - OnOverlayDoubleClicked(new OverlayEventArgs(overlay)); - } - } - else - { - base.OnMouseDoubleClick(e); - } - } - - #endregion - - #region Private Methods - - private BookmarkOverlay GetOverlayForPosition(Point pos) - { - lock (_overlayList) - { - foreach (BookmarkOverlay overlay in _overlayList.Values) - { - if (overlay.BubbleRect.Contains(pos)) - { - return overlay; - } - } - } - - return null; - } - - private void PaintOverlays(PaintEventArgs e) - { - BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current; - - using BufferedGraphics myBuffer = currentContext.Allocate(CreateGraphics(), ClientRectangle); - lock (_overlayList) - { - _overlayList.Clear(); - } - - myBuffer.Graphics.SetClip(ClientRectangle, CombineMode.Union); - e.Graphics.SetClip(ClientRectangle, CombineMode.Union); - - PaintEventArgs args = new(myBuffer.Graphics, e.ClipRectangle); - - base.OnPaint(args); - - StringFormat format = new(); - format.LineAlignment = StringAlignment.Center; - format.Alignment = StringAlignment.Near; - - myBuffer.Graphics.SetClip(DisplayRectangle, CombineMode.Intersect); - - // Remove Columnheader from Clippingarea - Rectangle rectTableHeader = new(DisplayRectangle.X, DisplayRectangle.Y, DisplayRectangle.Width, ColumnHeadersHeight); - myBuffer.Graphics.SetClip(rectTableHeader, CombineMode.Exclude); - - //e.Graphics.SetClip(rect, CombineMode.Union); - - lock (_overlayList) - { - foreach (BookmarkOverlay overlay in _overlayList.Values) - { - SizeF textSize = myBuffer.Graphics.MeasureString(overlay.Bookmark.Text, _font, 300); - Rectangle rectBubble = new(overlay.Position, - new Size((int)textSize.Width, (int)textSize.Height)); - rectBubble.Offset(60, -(rectBubble.Height + 40)); - rectBubble.Inflate(3, 3); - rectBubble.Location += overlay.Bookmark.OverlayOffset; - overlay.BubbleRect = rectBubble; - myBuffer.Graphics.SetClip(rectBubble, CombineMode.Union); // Bubble to clip - myBuffer.Graphics.SetClip(rectTableHeader, CombineMode.Exclude); - e.Graphics.SetClip(rectBubble, CombineMode.Union); - RectangleF textRect = new(rectBubble.X, rectBubble.Y, rectBubble.Width, rectBubble.Height); - myBuffer.Graphics.FillRectangle(_brush, rectBubble); - //myBuffer.Graphics.DrawLine(_pen, overlay.Position, new Point(rect.X, rect.Y + rect.Height / 2)); - myBuffer.Graphics.DrawLine(_pen, overlay.Position, new Point(rectBubble.X, rectBubble.Y + rectBubble.Height)); - myBuffer.Graphics.DrawString(overlay.Bookmark.Text, _font, _textBrush, textRect, format); - - if (_logger.IsDebugEnabled) - { - _logger.Debug("ClipRgn: {0},{1},{2},{3}", myBuffer.Graphics.ClipBounds.Left, myBuffer.Graphics.ClipBounds.Top, myBuffer.Graphics.ClipBounds.Width, myBuffer.Graphics.ClipBounds.Height); - } - } - } - - myBuffer.Render(e.Graphics); - } - - #endregion - - #region Events handler - - private void Control_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) - { - if ((e.KeyCode == Keys.C || e.KeyCode == Keys.Insert) && e.Control) - { - if (EditingControl != null) - { - e.IsInputKey = true; - } - } - } - - private void OnControlKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down) - { - if (EditingControl != null) - { - if (EditingControl is LogCellEditingControl editControl) - { - editControl.EditingControlDataGridView.EndEdit(); - int line = editControl.EditingControlDataGridView.CurrentCellAddress.Y; - if (e.KeyCode == Keys.Up) - { - if (line > 0) - { - line--; - } - } - - if (e.KeyCode == Keys.Down) - { - if (line < editControl.EditingControlDataGridView.RowCount - 1) - { - line++; - } - } - - int col = editControl.EditingControlDataGridView.CurrentCellAddress.X; - int scrollIndex = editControl.EditingControlDataGridView.HorizontalScrollingOffset; - int selStart = editControl.SelectionStart; - editControl.EditingControlDataGridView.CurrentCell = editControl.EditingControlDataGridView.Rows[line].Cells[col]; - editControl.EditingControlDataGridView.BeginEdit(false); - editControl.SelectionStart = selStart; - editControl.ScrollToCaret(); - editControl.EditingControlDataGridView.HorizontalScrollingOffset = scrollIndex; - e.Handled = true; - } - else - { - _logger.Warn("Edit control was null, to be checked"); - } - } - } - } - - #endregion - - protected virtual void OnOverlayDoubleClicked(OverlayEventArgs e) - { - OverlayDoubleClicked?.Invoke(this, e); - } - } -} diff --git a/src/LogExpert/Dialogs/FilterSelectorForm.Designer.cs b/src/LogExpert/Dialogs/FilterSelectorForm.Designer.cs deleted file mode 100644 index 6b01e99f..00000000 --- a/src/LogExpert/Dialogs/FilterSelectorForm.Designer.cs +++ /dev/null @@ -1,156 +0,0 @@ -namespace LogExpert.Dialogs -{ - partial class FilterSelectorForm - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FilterSelectorForm)); - this.filterComboBox = new System.Windows.Forms.ComboBox(); - this.label1 = new System.Windows.Forms.Label(); - this.okButton = new System.Windows.Forms.Button(); - this.cancelButton = new System.Windows.Forms.Button(); - this.commentTextBox = new System.Windows.Forms.TextBox(); - this.applyToAllCheckBox = new System.Windows.Forms.CheckBox(); - this.helpProvider1 = new System.Windows.Forms.HelpProvider(); - this.configButton = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // filterComboBox - // - this.filterComboBox.DisplayMember = "Text"; - this.filterComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.filterComboBox.FormattingEnabled = true; - this.filterComboBox.Location = new System.Drawing.Point(12, 25); - this.filterComboBox.Name = "filterComboBox"; - this.filterComboBox.Size = new System.Drawing.Size(298, 21); - this.filterComboBox.TabIndex = 0; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(13, 6); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(108, 13); - this.label1.TabIndex = 1; - this.label1.Text = "Choose a columnizer:"; - // - // okButton - // - this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.okButton.Location = new System.Drawing.Point(154, 194); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(75, 23); - this.okButton.TabIndex = 2; - this.okButton.Text = "OK"; - this.okButton.UseVisualStyleBackColor = true; - // - // cancelButton - // - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(235, 194); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(75, 23); - this.cancelButton.TabIndex = 3; - this.cancelButton.Text = "Cancel"; - this.cancelButton.UseVisualStyleBackColor = true; - // - // commentTextBox - // - this.commentTextBox.Location = new System.Drawing.Point(12, 81); - this.commentTextBox.Multiline = true; - this.commentTextBox.Name = "commentTextBox"; - this.commentTextBox.ReadOnly = true; - this.commentTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.commentTextBox.Size = new System.Drawing.Size(298, 89); - this.commentTextBox.TabIndex = 4; - // - // applyToAllCheckBox - // - this.applyToAllCheckBox.AutoSize = true; - this.applyToAllCheckBox.Location = new System.Drawing.Point(12, 176); - this.applyToAllCheckBox.Name = "applyToAllCheckBox"; - this.applyToAllCheckBox.Size = new System.Drawing.Size(125, 17); - this.applyToAllCheckBox.TabIndex = 6; - this.applyToAllCheckBox.Text = "Apply to all open files"; - this.applyToAllCheckBox.UseVisualStyleBackColor = true; - // - // helpProvider1 - // - this.helpProvider1.HelpNamespace = "LogExpert.chm"; - // - // configButton - // - this.configButton.Location = new System.Drawing.Point(235, 52); - this.configButton.Name = "configButton"; - this.configButton.Size = new System.Drawing.Size(75, 23); - this.configButton.TabIndex = 7; - this.configButton.Text = "Config..."; - this.configButton.UseVisualStyleBackColor = true; - this.configButton.Click += new System.EventHandler(this.OnConfigButtonClick); - // - // FilterSelectorForm - // - this.AcceptButton = this.okButton; - this.CancelButton = this.cancelButton; - this.ClientSize = new System.Drawing.Size(322, 232); - this.Controls.Add(this.configButton); - this.Controls.Add(this.applyToAllCheckBox); - this.Controls.Add(this.commentTextBox); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.okButton); - this.Controls.Add(this.label1); - this.Controls.Add(this.filterComboBox); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.helpProvider1.SetHelpKeyword(this, "Columnizers.htm"); - this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "FilterSelectorForm"; - this.helpProvider1.SetShowHelp(this, true); - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Columnizer"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.ComboBox filterComboBox; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Button okButton; - private System.Windows.Forms.Button cancelButton; - private System.Windows.Forms.TextBox commentTextBox; - private System.Windows.Forms.CheckBox applyToAllCheckBox; - private System.Windows.Forms.HelpProvider helpProvider1; - private System.Windows.Forms.Button configButton; - } -} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/FilterSelectorForm.cs b/src/LogExpert/Dialogs/FilterSelectorForm.cs deleted file mode 100644 index 9410c479..00000000 --- a/src/LogExpert/Dialogs/FilterSelectorForm.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Windows.Forms; -using LogExpert.Config; - -namespace LogExpert.Dialogs -{ - public partial class FilterSelectorForm : Form - { - #region Fields - - private readonly ILogLineColumnizerCallback _callback; - private readonly IList _columnizerList; - - #endregion - - #region cTor - - public FilterSelectorForm(IList existingColumnizerList, ILogLineColumnizer currentColumnizer, ILogLineColumnizerCallback callback) - { - SelectedColumnizer = currentColumnizer; - _callback = callback; - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - filterComboBox.SelectedIndexChanged += OnFilterComboBoxSelectedIndexChanged; - - // for the currently selected columnizer use the current instance and not the template instance from - // columnizer registry. This ensures that changes made in columnizer config dialogs - // will apply to the current instance - _columnizerList = new List(); - - foreach (ILogLineColumnizer col in existingColumnizerList) - { - _columnizerList.Add(col.GetType() == SelectedColumnizer.GetType() ? SelectedColumnizer : col); - } - - foreach (ILogLineColumnizer col in _columnizerList) - { - filterComboBox.Items.Add(col); - } - - foreach (ILogLineColumnizer columnizer in _columnizerList) - { - if (columnizer.GetType() == SelectedColumnizer.GetType()) - { - filterComboBox.SelectedItem = columnizer; - break; - } - } - } - - #endregion - - #region Properties - - public ILogLineColumnizer SelectedColumnizer { get; private set; } - - public bool ApplyToAll => applyToAllCheckBox.Checked; - - public bool IsConfigPressed { get; private set; } - - #endregion - - #region Events handler - - private void OnFilterComboBoxSelectedIndexChanged(object sender, EventArgs e) - { - ILogLineColumnizer col = _columnizerList[filterComboBox.SelectedIndex]; - SelectedColumnizer = col; - string description = col.GetDescription(); - description += "\r\nSupports timeshift: " + (SelectedColumnizer.IsTimeshiftImplemented() ? "Yes" : "No"); - commentTextBox.Text = description; - configButton.Enabled = SelectedColumnizer is IColumnizerConfigurator; - } - - - private void OnConfigButtonClick(object sender, EventArgs e) - { - if (SelectedColumnizer is IColumnizerConfigurator configurator) - { - string configDir = ConfigManager.ConfigDir; - - if (ConfigManager.Settings.Preferences.PortableMode) - { - configDir = ConfigManager.PortableModeDir; - } - - configurator.Configure(_callback, configDir); - IsConfigPressed = true; - } - } - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/HighlightDialog.Designer.cs b/src/LogExpert/Dialogs/HighlightDialog.Designer.cs deleted file mode 100644 index 4048062a..00000000 --- a/src/LogExpert/Dialogs/HighlightDialog.Designer.cs +++ /dev/null @@ -1,726 +0,0 @@ -using LogExpert.UI.Controls; - -using System.Drawing; - -namespace LogExpert.Dialogs -{ - partial class HighlightDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HighlightDialog)); - listBoxHighlight = new System.Windows.Forms.ListBox(); - btnAdd = new System.Windows.Forms.Button(); - btnDelete = new System.Windows.Forms.Button(); - btnMoveUp = new System.Windows.Forms.Button(); - btnMoveDown = new System.Windows.Forms.Button(); - labelForgroundColor = new System.Windows.Forms.Label(); - labelBackgroundColor = new System.Windows.Forms.Label(); - btnOk = new System.Windows.Forms.Button(); - btnCancel = new System.Windows.Forms.Button(); - textBoxSearchString = new System.Windows.Forms.TextBox(); - labelSearchString = new System.Windows.Forms.Label(); - btnApply = new System.Windows.Forms.Button(); - btnCustomForeColor = new System.Windows.Forms.Button(); - btnCustomBackColor = new System.Windows.Forms.Button(); - checkBoxRegex = new System.Windows.Forms.CheckBox(); - checkBoxCaseSensitive = new System.Windows.Forms.CheckBox(); - checkBoxDontDirtyLed = new System.Windows.Forms.CheckBox(); - groupBoxLineMatchCriteria = new System.Windows.Forms.GroupBox(); - groupBoxColoring = new System.Windows.Forms.GroupBox(); - checkBoxNoBackground = new System.Windows.Forms.CheckBox(); - checkBoxBold = new System.Windows.Forms.CheckBox(); - checkBoxWordMatch = new System.Windows.Forms.CheckBox(); - colorBoxForeground = new ColorComboBox(); - colorBoxBackground = new ColorComboBox(); - groupBoxActions = new System.Windows.Forms.GroupBox(); - btnBookmarkComment = new System.Windows.Forms.Button(); - btnSelectPlugin = new System.Windows.Forms.Button(); - checkBoxPlugin = new System.Windows.Forms.CheckBox(); - checkBoxStopTail = new System.Windows.Forms.CheckBox(); - checkBoxBookmark = new System.Windows.Forms.CheckBox(); - helpProvider = new System.Windows.Forms.HelpProvider(); - groupBox4 = new System.Windows.Forms.GroupBox(); - btnImportGroup = new System.Windows.Forms.Button(); - btnExportGroup = new System.Windows.Forms.Button(); - btnMoveGroupDown = new System.Windows.Forms.Button(); - btnMoveGroupUp = new System.Windows.Forms.Button(); - labelAssignNamesToGroups = new System.Windows.Forms.Label(); - btnCopyGroup = new System.Windows.Forms.Button(); - btnDeleteGroup = new System.Windows.Forms.Button(); - btnNewGroup = new System.Windows.Forms.Button(); - comboBoxGroups = new System.Windows.Forms.ComboBox(); - toolTip = new System.Windows.Forms.ToolTip(components); - pnlBackground = new System.Windows.Forms.Panel(); - groupBoxLineMatchCriteria.SuspendLayout(); - groupBoxColoring.SuspendLayout(); - groupBoxActions.SuspendLayout(); - groupBox4.SuspendLayout(); - pnlBackground.SuspendLayout(); - SuspendLayout(); - // - // listBoxHighlight - // - listBoxHighlight.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - listBoxHighlight.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; - listBoxHighlight.FormattingEnabled = true; - listBoxHighlight.Location = new Point(32, 160); - listBoxHighlight.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - listBoxHighlight.Name = "listBoxHighlight"; - listBoxHighlight.Size = new Size(487, 228); - listBoxHighlight.TabIndex = 0; - listBoxHighlight.SelectedIndexChanged += OnListBoxHighlightSelectedIndexChanged; - // - // btnAdd - // - btnAdd.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - btnAdd.Location = new Point(529, 218); - btnAdd.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnAdd.Name = "btnAdd"; - btnAdd.Size = new Size(158, 35); - btnAdd.TabIndex = 1; - btnAdd.Text = "&Add"; - toolTip.SetToolTip(btnAdd, "Create a new hilight item from information below"); - btnAdd.UseVisualStyleBackColor = true; - btnAdd.Click += OnAddButtonClick; - // - // btnDelete - // - btnDelete.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - btnDelete.Location = new Point(529, 263); - btnDelete.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnDelete.Name = "btnDelete"; - btnDelete.Size = new Size(158, 35); - btnDelete.TabIndex = 2; - btnDelete.Text = "D&elete"; - toolTip.SetToolTip(btnDelete, "Delete the current hilight"); - btnDelete.UseVisualStyleBackColor = true; - btnDelete.Click += OnDeleteButtonClick; - // - // btnMoveUp - // - btnMoveUp.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - btnMoveUp.Location = new Point(529, 160); - btnMoveUp.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnMoveUp.Name = "btnMoveUp"; - btnMoveUp.Size = new Size(75, 35); - btnMoveUp.TabIndex = 3; - btnMoveUp.Text = "&Up"; - toolTip.SetToolTip(btnMoveUp, "Move the current hilight one position up"); - btnMoveUp.UseVisualStyleBackColor = true; - btnMoveUp.Click += OnBtnMoveUpClick; - // - // btnMoveDown - // - btnMoveDown.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - btnMoveDown.Location = new Point(612, 160); - btnMoveDown.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnMoveDown.Name = "btnMoveDown"; - btnMoveDown.Size = new Size(75, 35); - btnMoveDown.TabIndex = 4; - btnMoveDown.Text = "&Down"; - toolTip.SetToolTip(btnMoveDown, "Move the current hilight one position down"); - btnMoveDown.UseVisualStyleBackColor = true; - btnMoveDown.Click += OnBtnMoveDownClick; - // - // labelForgroundColor - // - labelForgroundColor.AutoSize = true; - labelForgroundColor.Location = new Point(9, 38); - labelForgroundColor.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelForgroundColor.Name = "labelForgroundColor"; - labelForgroundColor.Size = new Size(99, 15); - labelForgroundColor.TabIndex = 6; - labelForgroundColor.Text = "Foreground color"; - // - // labelBackgroundColor - // - labelBackgroundColor.AutoSize = true; - labelBackgroundColor.Location = new Point(9, 115); - labelBackgroundColor.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelBackgroundColor.Name = "labelBackgroundColor"; - labelBackgroundColor.Size = new Size(101, 15); - labelBackgroundColor.TabIndex = 8; - labelBackgroundColor.Text = "Background color"; - // - // btnOk - // - btnOk.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; - btnOk.DialogResult = System.Windows.Forms.DialogResult.OK; - btnOk.Location = new Point(449, 832); - btnOk.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnOk.Name = "btnOk"; - btnOk.Size = new Size(112, 35); - btnOk.TabIndex = 9; - btnOk.Text = "OK"; - btnOk.UseVisualStyleBackColor = true; - btnOk.Click += OnBtnOkClick; - // - // btnCancel - // - btnCancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; - btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - btnCancel.Location = new Point(576, 832); - btnCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnCancel.Name = "btnCancel"; - btnCancel.Size = new Size(112, 35); - btnCancel.TabIndex = 10; - btnCancel.Text = "Cancel"; - btnCancel.UseVisualStyleBackColor = true; - // - // textBoxSearchString - // - textBoxSearchString.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - textBoxSearchString.Location = new Point(9, 55); - textBoxSearchString.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - textBoxSearchString.Name = "textBoxSearchString"; - textBoxSearchString.Size = new Size(639, 23); - textBoxSearchString.TabIndex = 11; - textBoxSearchString.TextChanged += ChangeToDirty; - // - // labelSearchString - // - labelSearchString.AutoSize = true; - labelSearchString.Location = new Point(9, 31); - labelSearchString.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelSearchString.Name = "labelSearchString"; - labelSearchString.Size = new Size(78, 15); - labelSearchString.TabIndex = 12; - labelSearchString.Text = "Search string:"; - // - // btnApply - // - btnApply.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - btnApply.Enabled = false; - btnApply.Image = (Image)resources.GetObject("btnApply.Image"); - btnApply.ImageAlign = ContentAlignment.MiddleRight; - btnApply.Location = new Point(529, 308); - btnApply.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnApply.Name = "btnApply"; - btnApply.Size = new Size(158, 35); - btnApply.TabIndex = 13; - btnApply.Text = "A&pply"; - toolTip.SetToolTip(btnApply, "Apply changes below to current hiligth"); - btnApply.UseVisualStyleBackColor = true; - btnApply.Click += OnBtnApplyClick; - // - // btnCustomForeColor - // - btnCustomForeColor.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - btnCustomForeColor.Location = new Point(247, 60); - btnCustomForeColor.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnCustomForeColor.Name = "btnCustomForeColor"; - btnCustomForeColor.Size = new Size(78, 35); - btnCustomForeColor.TabIndex = 14; - btnCustomForeColor.Text = "Custom"; - toolTip.SetToolTip(btnCustomForeColor, "Pick a custom foreground color"); - btnCustomForeColor.UseVisualStyleBackColor = true; - btnCustomForeColor.Click += OnBtnCustomForeColorClick; - // - // btnCustomBackColor - // - btnCustomBackColor.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - btnCustomBackColor.Location = new Point(247, 137); - btnCustomBackColor.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnCustomBackColor.Name = "btnCustomBackColor"; - btnCustomBackColor.Size = new Size(78, 35); - btnCustomBackColor.TabIndex = 15; - btnCustomBackColor.Text = "Custom"; - toolTip.SetToolTip(btnCustomBackColor, "Pick a custom background color"); - btnCustomBackColor.UseVisualStyleBackColor = true; - btnCustomBackColor.Click += OnBtnCustomBackColorClick; - // - // checkBoxRegex - // - checkBoxRegex.AutoSize = true; - checkBoxRegex.Location = new Point(180, 95); - checkBoxRegex.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxRegex.Name = "checkBoxRegex"; - checkBoxRegex.Size = new Size(57, 19); - checkBoxRegex.TabIndex = 16; - checkBoxRegex.Text = "RegEx"; - toolTip.SetToolTip(checkBoxRegex, "Whether the string is a regular expresion"); - checkBoxRegex.UseVisualStyleBackColor = true; - checkBoxRegex.CheckedChanged += ChangeToDirty; - checkBoxRegex.MouseUp += OnChkBoxRegexMouseUp; - // - // checkBoxCaseSensitive - // - checkBoxCaseSensitive.AutoSize = true; - checkBoxCaseSensitive.Location = new Point(14, 95); - checkBoxCaseSensitive.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxCaseSensitive.Name = "checkBoxCaseSensitive"; - checkBoxCaseSensitive.Size = new Size(99, 19); - checkBoxCaseSensitive.TabIndex = 17; - checkBoxCaseSensitive.Text = "Case sensitive"; - toolTip.SetToolTip(checkBoxCaseSensitive, "Whether the string will match uppercases and lowercases"); - checkBoxCaseSensitive.UseVisualStyleBackColor = true; - checkBoxCaseSensitive.CheckedChanged += ChangeToDirty; - // - // checkBoxDontDirtyLed - // - checkBoxDontDirtyLed.AutoSize = true; - checkBoxDontDirtyLed.Location = new Point(15, 38); - checkBoxDontDirtyLed.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxDontDirtyLed.Name = "checkBoxDontDirtyLed"; - checkBoxDontDirtyLed.Size = new Size(118, 19); - checkBoxDontDirtyLed.TabIndex = 18; - checkBoxDontDirtyLed.Text = "Don't lit dirty LED"; - toolTip.SetToolTip(checkBoxDontDirtyLed, "When matching a line, don't mark the page as \"dirty\""); - checkBoxDontDirtyLed.UseVisualStyleBackColor = true; - checkBoxDontDirtyLed.CheckedChanged += ChangeToDirty; - // - // groupBoxLineMatchCriteria - // - groupBoxLineMatchCriteria.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - groupBoxLineMatchCriteria.Controls.Add(textBoxSearchString); - groupBoxLineMatchCriteria.Controls.Add(labelSearchString); - groupBoxLineMatchCriteria.Controls.Add(checkBoxRegex); - groupBoxLineMatchCriteria.Controls.Add(checkBoxCaseSensitive); - groupBoxLineMatchCriteria.Location = new Point(18, 437); - groupBoxLineMatchCriteria.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxLineMatchCriteria.Name = "groupBoxLineMatchCriteria"; - groupBoxLineMatchCriteria.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxLineMatchCriteria.Size = new Size(671, 135); - groupBoxLineMatchCriteria.TabIndex = 19; - groupBoxLineMatchCriteria.TabStop = false; - groupBoxLineMatchCriteria.Text = "Line match criteria"; - // - // groupBoxColoring - // - groupBoxColoring.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - groupBoxColoring.Controls.Add(checkBoxNoBackground); - groupBoxColoring.Controls.Add(checkBoxBold); - groupBoxColoring.Controls.Add(checkBoxWordMatch); - groupBoxColoring.Controls.Add(labelForgroundColor); - groupBoxColoring.Controls.Add(colorBoxForeground); - groupBoxColoring.Controls.Add(btnCustomForeColor); - groupBoxColoring.Controls.Add(btnCustomBackColor); - groupBoxColoring.Controls.Add(labelBackgroundColor); - groupBoxColoring.Controls.Add(colorBoxBackground); - groupBoxColoring.Location = new Point(18, 581); - groupBoxColoring.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxColoring.Name = "groupBoxColoring"; - groupBoxColoring.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxColoring.Size = new Size(349, 286); - groupBoxColoring.TabIndex = 20; - groupBoxColoring.TabStop = false; - groupBoxColoring.Text = "Coloring"; - // - // checkBoxNoBackground - // - checkBoxNoBackground.AutoSize = true; - checkBoxNoBackground.Enabled = false; - checkBoxNoBackground.Location = new Point(141, 240); - checkBoxNoBackground.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxNoBackground.Name = "checkBoxNoBackground"; - checkBoxNoBackground.Size = new Size(109, 19); - checkBoxNoBackground.TabIndex = 18; - checkBoxNoBackground.Text = "No Background"; - toolTip.SetToolTip(checkBoxNoBackground, "Don't set the background color"); - checkBoxNoBackground.UseVisualStyleBackColor = true; - checkBoxNoBackground.CheckedChanged += OnChkBoxNoBackgroundCheckedChanged; - // - // checkBoxBold - // - checkBoxBold.AutoSize = true; - checkBoxBold.Location = new Point(9, 205); - checkBoxBold.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxBold.Name = "checkBoxBold"; - checkBoxBold.Size = new Size(50, 19); - checkBoxBold.TabIndex = 17; - checkBoxBold.Text = "Bold"; - toolTip.SetToolTip(checkBoxBold, "Display the line in bold characters"); - checkBoxBold.UseVisualStyleBackColor = true; - checkBoxBold.CheckedChanged += OnChkBoxBoldCheckedChanged; - // - // checkBoxWordMatch - // - checkBoxWordMatch.AutoSize = true; - checkBoxWordMatch.Location = new Point(9, 240); - checkBoxWordMatch.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxWordMatch.Name = "checkBoxWordMatch"; - checkBoxWordMatch.Size = new Size(89, 19); - checkBoxWordMatch.TabIndex = 16; - checkBoxWordMatch.Text = "Word mode"; - toolTip.SetToolTip(checkBoxWordMatch, "Don't highlight the whole line but only the matching keywords"); - checkBoxWordMatch.UseVisualStyleBackColor = true; - checkBoxWordMatch.CheckedChanged += OnChkBoxWordMatchCheckedChanged; - // - // colorBoxForeground - // - colorBoxForeground.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - colorBoxForeground.CustomColor = Color.Black; - colorBoxForeground.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; - colorBoxForeground.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - colorBoxForeground.FormattingEnabled = true; - colorBoxForeground.Location = new Point(8, 63); - colorBoxForeground.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - colorBoxForeground.Name = "colorBoxForeground"; - colorBoxForeground.Size = new Size(229, 24); - colorBoxForeground.TabIndex = 5; - colorBoxForeground.SelectedIndexChanged += ChangeToDirty; - // - // colorBoxBackground - // - colorBoxBackground.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - colorBoxBackground.CustomColor = Color.Black; - colorBoxBackground.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; - colorBoxBackground.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - colorBoxBackground.FormattingEnabled = true; - colorBoxBackground.Location = new Point(9, 140); - colorBoxBackground.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - colorBoxBackground.Name = "colorBoxBackground"; - colorBoxBackground.Size = new Size(229, 24); - colorBoxBackground.TabIndex = 7; - colorBoxBackground.SelectedIndexChanged += ChangeToDirty; - // - // groupBoxActions - // - groupBoxActions.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; - groupBoxActions.Controls.Add(btnBookmarkComment); - groupBoxActions.Controls.Add(btnSelectPlugin); - groupBoxActions.Controls.Add(checkBoxPlugin); - groupBoxActions.Controls.Add(checkBoxStopTail); - groupBoxActions.Controls.Add(checkBoxBookmark); - groupBoxActions.Controls.Add(checkBoxDontDirtyLed); - groupBoxActions.Location = new Point(377, 581); - groupBoxActions.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxActions.Name = "groupBoxActions"; - groupBoxActions.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxActions.Size = new Size(312, 195); - groupBoxActions.TabIndex = 21; - groupBoxActions.TabStop = false; - groupBoxActions.Text = "Actions"; - // - // btnBookmarkComment - // - btnBookmarkComment.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - btnBookmarkComment.Location = new Point(210, 69); - btnBookmarkComment.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnBookmarkComment.Name = "btnBookmarkComment"; - btnBookmarkComment.Size = new Size(81, 31); - btnBookmarkComment.TabIndex = 23; - btnBookmarkComment.Text = "Text..."; - btnBookmarkComment.UseVisualStyleBackColor = true; - btnBookmarkComment.Click += OnBtnBookmarkCommentClick; - // - // btnSelectPlugin - // - btnSelectPlugin.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - btnSelectPlugin.Location = new Point(210, 143); - btnSelectPlugin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnSelectPlugin.Name = "btnSelectPlugin"; - btnSelectPlugin.Size = new Size(81, 31); - btnSelectPlugin.TabIndex = 22; - btnSelectPlugin.Text = "Select..."; - btnSelectPlugin.UseVisualStyleBackColor = true; - btnSelectPlugin.Click += OnPluginButtonClick; - // - // checkBoxPlugin - // - checkBoxPlugin.AutoSize = true; - checkBoxPlugin.Location = new Point(15, 148); - checkBoxPlugin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxPlugin.Name = "checkBoxPlugin"; - checkBoxPlugin.Size = new Size(60, 19); - checkBoxPlugin.TabIndex = 21; - checkBoxPlugin.Text = "Plugin"; - toolTip.SetToolTip(checkBoxPlugin, "When matching a line, call a keyword action plugin"); - checkBoxPlugin.UseVisualStyleBackColor = true; - checkBoxPlugin.CheckedChanged += OnChkBoxPluginCheckedChanged; - // - // checkBoxStopTail - // - checkBoxStopTail.AutoSize = true; - checkBoxStopTail.Location = new Point(15, 111); - checkBoxStopTail.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxStopTail.Name = "checkBoxStopTail"; - checkBoxStopTail.Size = new Size(109, 19); - checkBoxStopTail.TabIndex = 20; - checkBoxStopTail.Text = "Stop Follow Tail"; - toolTip.SetToolTip(checkBoxStopTail, "When matching a line, stop automatic scrolling"); - checkBoxStopTail.UseVisualStyleBackColor = true; - checkBoxStopTail.CheckedChanged += ChangeToDirty; - // - // checkBoxBookmark - // - checkBoxBookmark.AutoSize = true; - checkBoxBookmark.Location = new Point(15, 74); - checkBoxBookmark.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxBookmark.Name = "checkBoxBookmark"; - checkBoxBookmark.Size = new Size(99, 19); - checkBoxBookmark.TabIndex = 19; - checkBoxBookmark.Text = "Set bookmark"; - toolTip.SetToolTip(checkBoxBookmark, "When matching a line, create a new bookmark for it"); - checkBoxBookmark.UseVisualStyleBackColor = true; - checkBoxBookmark.CheckedChanged += ChangeToDirty; - // - // helpProvider - // - helpProvider.HelpNamespace = "LogExpert.chm"; - helpProvider.Tag = ""; - // - // groupBox4 - // - groupBox4.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - groupBox4.Controls.Add(btnImportGroup); - groupBox4.Controls.Add(btnExportGroup); - groupBox4.Controls.Add(btnMoveGroupDown); - groupBox4.Controls.Add(btnMoveGroupUp); - groupBox4.Controls.Add(labelAssignNamesToGroups); - groupBox4.Controls.Add(btnCopyGroup); - groupBox4.Controls.Add(btnDeleteGroup); - groupBox4.Controls.Add(btnNewGroup); - groupBox4.Controls.Add(comboBoxGroups); - groupBox4.Location = new Point(18, 5); - groupBox4.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBox4.Name = "groupBox4"; - groupBox4.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBox4.Size = new Size(671, 129); - groupBox4.TabIndex = 22; - groupBox4.TabStop = false; - groupBox4.Text = "Groups"; - // - // btnImportGroup - // - btnImportGroup.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; - btnImportGroup.Location = new Point(333, 26); - btnImportGroup.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnImportGroup.Name = "btnImportGroup"; - btnImportGroup.Size = new Size(75, 35); - btnImportGroup.TabIndex = 7; - btnImportGroup.Text = "Import"; - toolTip.SetToolTip(btnImportGroup, "Import highlight groups"); - btnImportGroup.UseVisualStyleBackColor = true; - btnImportGroup.Click += OnBtnImportGroupClick; - // - // btnExportGroup - // - btnExportGroup.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; - btnExportGroup.Location = new Point(333, 75); - btnExportGroup.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnExportGroup.Name = "btnExportGroup"; - btnExportGroup.Size = new Size(75, 35); - btnExportGroup.TabIndex = 8; - btnExportGroup.Text = "Export"; - toolTip.SetToolTip(btnExportGroup, "Export highlight groups"); - btnExportGroup.UseVisualStyleBackColor = true; - btnExportGroup.Click += OnBtnExportGroupClick; - // - // btnMoveGroupDown - // - btnMoveGroupDown.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - btnMoveGroupDown.Location = new Point(582, 75); - btnMoveGroupDown.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnMoveGroupDown.Name = "btnMoveGroupDown"; - btnMoveGroupDown.Size = new Size(75, 35); - btnMoveGroupDown.TabIndex = 6; - btnMoveGroupDown.Text = "Down"; - toolTip.SetToolTip(btnMoveGroupDown, "Move the current hilight group one position down"); - btnMoveGroupDown.UseVisualStyleBackColor = true; - btnMoveGroupDown.Click += OnBtnGroupDownClick; - // - // btnMoveGroupUp - // - btnMoveGroupUp.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - btnMoveGroupUp.Location = new Point(499, 75); - btnMoveGroupUp.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnMoveGroupUp.Name = "btnMoveGroupUp"; - btnMoveGroupUp.Size = new Size(75, 35); - btnMoveGroupUp.TabIndex = 5; - btnMoveGroupUp.Text = "Up"; - toolTip.SetToolTip(btnMoveGroupUp, "Move the current hilight group one position up"); - btnMoveGroupUp.UseVisualStyleBackColor = true; - btnMoveGroupUp.Click += OnBtnGroupUpClick; - // - // labelAssignNamesToGroups - // - labelAssignNamesToGroups.AutoSize = true; - labelAssignNamesToGroups.Location = new Point(9, 88); - labelAssignNamesToGroups.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelAssignNamesToGroups.Name = "labelAssignNamesToGroups"; - labelAssignNamesToGroups.Size = new Size(276, 15); - labelAssignNamesToGroups.TabIndex = 4; - labelAssignNamesToGroups.Text = "You can assign groups to file names in the settings."; - // - // btnCopyGroup - // - btnCopyGroup.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; - btnCopyGroup.Location = new Point(582, 26); - btnCopyGroup.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnCopyGroup.Name = "btnCopyGroup"; - btnCopyGroup.Size = new Size(75, 35); - btnCopyGroup.TabIndex = 3; - btnCopyGroup.Text = "Copy"; - toolTip.SetToolTip(btnCopyGroup, "Copy the current hilight group into a new one"); - btnCopyGroup.UseVisualStyleBackColor = true; - btnCopyGroup.Click += OnBtnCopyGroupClick; - // - // btnDeleteGroup - // - btnDeleteGroup.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; - btnDeleteGroup.Location = new Point(499, 26); - btnDeleteGroup.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnDeleteGroup.Name = "btnDeleteGroup"; - btnDeleteGroup.Size = new Size(75, 35); - btnDeleteGroup.TabIndex = 2; - btnDeleteGroup.Text = "Del"; - toolTip.SetToolTip(btnDeleteGroup, "Delete the current hilight group"); - btnDeleteGroup.UseVisualStyleBackColor = true; - btnDeleteGroup.Click += OnBtnDelGroupClick; - // - // btnNewGroup - // - btnNewGroup.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; - btnNewGroup.Location = new Point(416, 26); - btnNewGroup.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - btnNewGroup.Name = "btnNewGroup"; - btnNewGroup.Size = new Size(75, 35); - btnNewGroup.TabIndex = 1; - btnNewGroup.Text = "New group"; - btnNewGroup.TextAlign = ContentAlignment.MiddleLeft; - toolTip.SetToolTip(btnNewGroup, "Create a new empty hilight group"); - btnNewGroup.UseVisualStyleBackColor = true; - btnNewGroup.Click += OnBtnNewGroupClick; - // - // comboBoxGroups - // - comboBoxGroups.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - comboBoxGroups.DisplayMember = "GroupName"; - comboBoxGroups.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; - comboBoxGroups.Location = new Point(14, 32); - comboBoxGroups.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - comboBoxGroups.Name = "comboBoxGroups"; - comboBoxGroups.Size = new Size(311, 24); - comboBoxGroups.TabIndex = 0; - toolTip.SetToolTip(comboBoxGroups, "Choose a group to create different highlight settings. Type in a name to change in the name of a group."); - comboBoxGroups.DrawItem += OnCmbBoxGroupDrawItem; - comboBoxGroups.SelectionChangeCommitted += OnCmbBoxGroupSelectionChangeCommitted; - comboBoxGroups.TextUpdate += OnCmbBoxGroupTextUpdate; - // - // pnlBackground - // - pnlBackground.AutoScroll = true; - pnlBackground.Controls.Add(listBoxHighlight); - pnlBackground.Controls.Add(btnAdd); - pnlBackground.Controls.Add(btnDelete); - pnlBackground.Controls.Add(btnMoveUp); - pnlBackground.Controls.Add(btnMoveDown); - pnlBackground.Controls.Add(btnOk); - pnlBackground.Controls.Add(btnCancel); - pnlBackground.Controls.Add(btnApply); - pnlBackground.Controls.Add(groupBoxLineMatchCriteria); - pnlBackground.Controls.Add(groupBoxColoring); - pnlBackground.Controls.Add(groupBoxActions); - pnlBackground.Controls.Add(groupBox4); - pnlBackground.Dock = System.Windows.Forms.DockStyle.Fill; - pnlBackground.Location = new Point(0, 0); - pnlBackground.Name = "pnlBackground"; - pnlBackground.Size = new Size(708, 895); - pnlBackground.TabIndex = 23; - // - // HighlightDialog - // - AcceptButton = btnOk; - CancelButton = btnCancel; - ClientSize = new Size(708, 895); - Controls.Add(pnlBackground); - DoubleBuffered = true; - helpProvider.SetHelpKeyword(this, "Highlighting.htm"); - helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); - helpProvider.SetHelpString(this, ""); - Icon = (Icon)resources.GetObject("$this.Icon"); - Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - MaximizeBox = false; - MinimizeBox = false; - MinimumSize = new Size(660, 934); - Name = "HighlightDialog"; - helpProvider.SetShowHelp(this, true); - StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - Text = "Highlighting and action triggers"; - Shown += OnHighlightDialogShown; - groupBoxLineMatchCriteria.ResumeLayout(false); - groupBoxLineMatchCriteria.PerformLayout(); - groupBoxColoring.ResumeLayout(false); - groupBoxColoring.PerformLayout(); - groupBoxActions.ResumeLayout(false); - groupBoxActions.PerformLayout(); - groupBox4.ResumeLayout(false); - groupBox4.PerformLayout(); - pnlBackground.ResumeLayout(false); - ResumeLayout(false); - } - - #endregion - - private System.Windows.Forms.ListBox listBoxHighlight; - private System.Windows.Forms.Button btnAdd; - private System.Windows.Forms.Button btnDelete; - private System.Windows.Forms.Button btnMoveUp; - private System.Windows.Forms.Button btnMoveDown; - private ColorComboBox colorBoxForeground; - private System.Windows.Forms.Label labelForgroundColor; - private ColorComboBox colorBoxBackground; - private System.Windows.Forms.Label labelBackgroundColor; - private System.Windows.Forms.Button btnOk; - private System.Windows.Forms.Button btnCancel; - private System.Windows.Forms.TextBox textBoxSearchString; - private System.Windows.Forms.Label labelSearchString; - private System.Windows.Forms.Button btnApply; - private System.Windows.Forms.Button btnCustomForeColor; - private System.Windows.Forms.Button btnCustomBackColor; - private System.Windows.Forms.CheckBox checkBoxRegex; - private System.Windows.Forms.CheckBox checkBoxCaseSensitive; - private System.Windows.Forms.CheckBox checkBoxDontDirtyLed; - private System.Windows.Forms.GroupBox groupBoxLineMatchCriteria; - private System.Windows.Forms.GroupBox groupBoxColoring; - private System.Windows.Forms.GroupBox groupBoxActions; - private System.Windows.Forms.CheckBox checkBoxBookmark; - private System.Windows.Forms.CheckBox checkBoxStopTail; - private System.Windows.Forms.HelpProvider helpProvider; - private System.Windows.Forms.CheckBox checkBoxPlugin; - private System.Windows.Forms.Button btnSelectPlugin; - private System.Windows.Forms.Button btnBookmarkComment; - private System.Windows.Forms.GroupBox groupBox4; - private System.Windows.Forms.ComboBox comboBoxGroups; - private System.Windows.Forms.Button btnDeleteGroup; - private System.Windows.Forms.Button btnNewGroup; - private System.Windows.Forms.Button btnCopyGroup; - private System.Windows.Forms.ToolTip toolTip; - private System.Windows.Forms.Label labelAssignNamesToGroups; - private System.Windows.Forms.Button btnMoveGroupUp; - private System.Windows.Forms.Button btnMoveGroupDown; - private System.Windows.Forms.CheckBox checkBoxWordMatch; - private System.Windows.Forms.CheckBox checkBoxBold; - private System.Windows.Forms.CheckBox checkBoxNoBackground; - private System.Windows.Forms.Button btnImportGroup; - private System.Windows.Forms.Button btnExportGroup; - private System.Windows.Forms.Panel pnlBackground; - } -} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/HighlightDialog.cs b/src/LogExpert/Dialogs/HighlightDialog.cs deleted file mode 100644 index 3be35f39..00000000 --- a/src/LogExpert/Dialogs/HighlightDialog.cs +++ /dev/null @@ -1,728 +0,0 @@ -using LogExpert.Config; -using LogExpert.Core.Classes.Highlight; -using LogExpert.Core.Entities; -using LogExpert.UI.Controls; -using LogExpert.UI.Dialogs; - -using NLog; - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Text.RegularExpressions; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public partial class HighlightDialog : Form - { - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - - #region Private Fields - - private readonly Image _applyButtonImage; - private string _bookmarkComment; - private ActionEntry _currentActionEntry = new(); - private HighlightGroup _currentGroup; - private List _highlightGroupList; - - #endregion - - #region Ctor - - public HighlightDialog() - { - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - Load += OnHighlightDialogLoad; - listBoxHighlight.DrawItem += OnHighlightListBoxDrawItem; - _applyButtonImage = btnApply.Image; - btnApply.Image = null; - } - - #endregion - - #region Properties / Indexers - - public List HighlightGroupList - { - get => _highlightGroupList; - set - { - _highlightGroupList ??= []; - - foreach (var group in value) - { - _highlightGroupList.Add((HighlightGroup)group.Clone()); - } - } - } - - public IList KeywordActionList { get; set; } - - public string PreSelectedGroupName { get; set; } - - private bool IsDirty => btnApply.Image == _applyButtonImage; - - #endregion - - #region Event handling Methods - - private void OnAddButtonClick(object sender, EventArgs e) - { - AddNewEntry(); - Dirty(); - } - - private void OnBtnApplyClick(object sender, EventArgs e) - { - SaveEntry(); - } - - private void OnBtnBookmarkCommentClick(object sender, EventArgs e) - { - BookmarkCommentDlg dlg = new(); - dlg.Comment = _bookmarkComment; - if (dlg.ShowDialog() == DialogResult.OK) - { - _bookmarkComment = dlg.Comment; - Dirty(); - } - } - - private void OnBtnCopyGroupClick(object sender, EventArgs e) - { - if (comboBoxGroups.SelectedIndex >= 0 && comboBoxGroups.SelectedIndex < HighlightGroupList.Count) - { - HighlightGroup newGroup = (HighlightGroup)HighlightGroupList[comboBoxGroups.SelectedIndex].Clone(); - newGroup.GroupName = "Copy of " + newGroup.GroupName; - - HighlightGroupList.Add(newGroup); - FillGroupComboBox(); - SelectGroup(HighlightGroupList.Count - 1); - } - } - - private void OnBtnCustomBackColorClick(object sender, EventArgs e) - { - ChooseColor(colorBoxBackground); - Dirty(); - } - - private void OnBtnCustomForeColorClick(object sender, EventArgs e) - { - ChooseColor(colorBoxForeground); - Dirty(); - } - - private void OnBtnDelGroupClick(object sender, EventArgs e) - { - // the last group cannot be deleted - if (HighlightGroupList.Count == 1) - { - return; - } - - if (comboBoxGroups.SelectedIndex >= 0 && comboBoxGroups.SelectedIndex < HighlightGroupList.Count) - { - int index = comboBoxGroups.SelectedIndex; - HighlightGroupList.RemoveAt(comboBoxGroups.SelectedIndex); - FillGroupComboBox(); - if (index < HighlightGroupList.Count) - { - SelectGroup(index); - } - else - { - SelectGroup(HighlightGroupList.Count - 1); - } - } - } - - private void OnBtnExportGroupClick(object sender, EventArgs e) - { - SaveFileDialog dlg = new() - { - Title = @"Export Settings to file", - DefaultExt = "json", - AddExtension = true, - Filter = @"Settings (*.json)|*.json|All files (*.*)|*.*" - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - FileInfo fileInfo = new(dlg.FileName); - ConfigManager.Export(fileInfo, Core.Config.SettingsFlags.HighlightSettings); - } - } - - private void OnBtnGroupDownClick(object sender, EventArgs e) - { - int index = comboBoxGroups.SelectedIndex; - if (index > -1 && index < _highlightGroupList.Count - 1) - { - _highlightGroupList.Reverse(index, 2); - comboBoxGroups.Refresh(); - FillGroupComboBox(); - SelectGroup(index + 1); - } - } - - private void OnBtnGroupUpClick(object sender, EventArgs e) - { - int index = comboBoxGroups.SelectedIndex; - if (index > 0) - { - _highlightGroupList.Reverse(index - 1, 2); - comboBoxGroups.Refresh(); - FillGroupComboBox(); - SelectGroup(index - 1); - } - } - - private void OnBtnImportGroupClick(object sender, EventArgs e) - { - ImportSettingsDialog dlg = new(Core.Config.ExportImportFlags.HighlightSettings); - - foreach (Control ctl in dlg.groupBoxImportOptions.Controls) - { - if (ctl.Tag != null) - { - ((CheckBox)ctl).Checked = false; - } - } - - dlg.checkBoxHighlightSettings.Checked = true; - dlg.checkBoxKeepExistingSettings.Checked = true; - - if (dlg.ShowDialog() != DialogResult.OK) - { - return; - } - - if (string.IsNullOrWhiteSpace(dlg.FileName)) - { - return; - } - - Cursor.Current = Cursors.WaitCursor; - - FileInfo fileInfo; - - try - { - fileInfo = new FileInfo(dlg.FileName); - } - catch (Exception ex) - { - MessageBox.Show(this, $@"Settings could not be imported: {ex}", @"LogExpert"); - _logger.Error($"Error while trying to access file: {dlg.FileName}: {ex}"); - return; - } - - ConfigManager.ImportHighlightSettings(fileInfo, dlg.ImportFlags); - Cursor.Current = Cursors.Default; - - _highlightGroupList = ConfigManager.Settings.Preferences.HighlightGroupList; - - FillGroupComboBox(); - - MessageBox.Show(this, @"Settings imported", @"LogExpert"); - } - - private void OnBtnMoveDownClick(object sender, EventArgs e) - { - int index = listBoxHighlight.SelectedIndex; - - if (index > -1 && index < listBoxHighlight.Items.Count - 1) - { - object item = listBoxHighlight.SelectedItem; - listBoxHighlight.Items.RemoveAt(index); - listBoxHighlight.Items.Insert(index + 1, item); - listBoxHighlight.SelectedIndex = index + 1; - _currentGroup.HighlightEntryList.Reverse(index, 2); - } - } - - private void OnBtnMoveUpClick(object sender, EventArgs e) - { - int index = listBoxHighlight.SelectedIndex; - if (index > 0) - { - object item = listBoxHighlight.SelectedItem; - listBoxHighlight.Items.RemoveAt(index); // will also clear the selection - listBoxHighlight.Items.Insert(index - 1, item); - listBoxHighlight.SelectedIndex = index - 1; // restore the selection - _currentGroup.HighlightEntryList.Reverse(index - 1, 2); - } - } - - private void OnBtnNewGroupClick(object sender, EventArgs e) - { - // Propose a unique name - const string baseName = "New group"; - string name = baseName; - bool uniqueName = false; - int i = 1; - while (!uniqueName) - { - uniqueName = HighlightGroupList.FindIndex(delegate (HighlightGroup g) { return g.GroupName == name; }) < 0; - - if (!uniqueName) - { - name = $"{baseName} #{i++}"; - } - } - - HighlightGroup newGroup = new() { GroupName = name }; - HighlightGroupList.Add(newGroup); - FillGroupComboBox(); - SelectGroup(HighlightGroupList.Count - 1); - } - - private void OnBtnOkClick(object sender, EventArgs e) - { - // Apply pending changes if closing the form. - if (IsDirty) - { - // cannot call 'this.applyButton.PerformClick();' because it prohibits the OK button to terminate the dialog - OnBtnApplyClick(btnApply, EventArgs.Empty); - } - } - - private void OnChkBoxBoldCheckedChanged(object sender, EventArgs e) - { - Dirty(); - } - - private void OnChkBoxNoBackgroundCheckedChanged(object sender, EventArgs e) - { - colorBoxBackground.Enabled = !checkBoxNoBackground.Checked; - btnCustomBackColor.Enabled = !checkBoxNoBackground.Checked; - Dirty(); - } - - private void OnChkBoxPluginCheckedChanged(object sender, EventArgs e) - { - Dirty(); - btnSelectPlugin.Enabled = checkBoxPlugin.Checked; - } - - private void OnChkBoxRegexMouseUp(object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Right) - { - RegexHelperDialog dlg = new() - { - Owner = this, - CaseSensitive = checkBoxCaseSensitive.Checked, - Pattern = textBoxSearchString.Text - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - checkBoxCaseSensitive.Checked = dlg.CaseSensitive; - textBoxSearchString.Text = dlg.Pattern; - } - } - } - - private void OnChkBoxWordMatchCheckedChanged(object sender, EventArgs e) - { - Dirty(); - checkBoxNoBackground.Enabled = checkBoxWordMatch.Checked; - } - - private void OnCmbBoxGroupDrawItem(object sender, DrawItemEventArgs e) - { - e.DrawBackground(); - if (e.Index >= 0) - { - HighlightGroup group = HighlightGroupList[e.Index]; - Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); - - Brush brush = new SolidBrush(SystemColors.ControlText); - e.Graphics.DrawString(group.GroupName, e.Font, brush, new PointF(rectangle.Left, rectangle.Top)); - e.DrawFocusRectangle(); - brush.Dispose(); - } - } - - private void OnCmbBoxGroupSelectionChangeCommitted(object sender, EventArgs e) - { - SelectGroup(comboBoxGroups.SelectedIndex); - } - - private void OnCmbBoxGroupTextUpdate(object sender, EventArgs e) - { - _currentGroup.GroupName = comboBoxGroups.Text; - } - - private void OnDeleteButtonClick(object sender, EventArgs e) - { - if (listBoxHighlight.SelectedIndex >= 0) - { - int removeIndex = listBoxHighlight.SelectedIndex; - _currentGroup.HighlightEntryList.RemoveAt(removeIndex); - listBoxHighlight.Items.RemoveAt(removeIndex); - - // Select previous (or first if none before) - int nextSelectIndex = removeIndex; - if (nextSelectIndex >= listBoxHighlight.Items.Count) - { - nextSelectIndex--; // if last item was removed, go one up - } - - if (nextSelectIndex >= 0) - { - listBoxHighlight.SelectedIndex = nextSelectIndex; // if still some item, select it - } - - ReEvaluateHighlightButtonStates(); - } - } - - private void OnHighlightDialogLoad(object sender, EventArgs e) - { - colorBoxForeground.SelectedIndex = 1; - colorBoxBackground.SelectedIndex = 2; - btnApply.Enabled = false; - btnApply.Image = null; - btnBookmarkComment.Enabled = false; - btnSelectPlugin.Enabled = false; - - ReEvaluateHighlightButtonStates(); - } - - private void OnHighlightDialogShown(object sender, EventArgs e) - { - InitData(); - } - - private void OnHighlightListBoxDrawItem(object sender, DrawItemEventArgs e) - { - e.DrawBackground(); - if (e.Index >= 0) - { - HighlightEntry entry = (HighlightEntry)listBoxHighlight.Items[e.Index]; - Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); - - if ((e.State & DrawItemState.Selected) != DrawItemState.Selected) - { - e.Graphics.FillRectangle(new SolidBrush(entry.BackgroundColor), rectangle); - } - - e.Graphics.DrawString(entry.SearchText, e.Font, new SolidBrush(entry.ForegroundColor), - new PointF(rectangle.Left, rectangle.Top)); - - e.DrawFocusRectangle(); - } - } - - private void OnListBoxHighlightSelectedIndexChanged(object sender, EventArgs e) - { - StartEditEntry(); - } - - private void OnPluginButtonClick(object sender, EventArgs e) - { - KeywordActionDlg dlg = new(_currentActionEntry, KeywordActionList); - - if (dlg.ShowDialog() == DialogResult.OK) - { - _currentActionEntry = dlg.ActionEntry; - Dirty(); - } - } - - #endregion - - #region Private Methods - - private void AddNewEntry() - { - { - try - { - CheckRegex(); - - HighlightEntry entry = new() - { - SearchText = textBoxSearchString.Text, - ForegroundColor = colorBoxForeground.SelectedColor, - BackgroundColor = colorBoxBackground.SelectedColor, - IsRegEx = checkBoxRegex.Checked, - IsCaseSensitive = checkBoxCaseSensitive.Checked, - IsLedSwitch = checkBoxDontDirtyLed.Checked, - IsStopTail = checkBoxStopTail.Checked, - IsSetBookmark = checkBoxBookmark.Checked, - IsActionEntry = checkBoxPlugin.Checked, - ActionEntry = _currentActionEntry, - IsWordMatch = checkBoxWordMatch.Checked, - IsBold = checkBoxBold.Checked, - NoBackground = checkBoxNoBackground.Checked - }; - - listBoxHighlight.Items.Add(entry); - - // Select the newly created item - _currentGroup.HighlightEntryList.Add(entry); - listBoxHighlight.SelectedItem = entry; - } - catch (Exception ex) - { - _logger.Error(ex, "Error during add of highlight entry"); - MessageBox.Show($"Error during add of entry.\r\n{ex.Message}"); - } - } - } - - private void ChangeToDirty(object sender, EventArgs e) - { - Dirty(); - } - - private void CheckRegex() - { - if (checkBoxRegex.Checked) - { - if (string.IsNullOrWhiteSpace(textBoxSearchString.Text)) - { - throw new ArgumentException("Regex value is null or whitespace"); - } - - // ReSharper disable once ReturnValueOfPureMethodIsNotUsed - Regex.IsMatch("", textBoxSearchString.Text); - } - } - - private void ChooseColor(ColorComboBox comboBox) - { - ColorDialog colorDialog = new(); - colorDialog.AllowFullOpen = true; - colorDialog.ShowHelp = false; - colorDialog.Color = comboBox.CustomColor; - if (colorDialog.ShowDialog() == DialogResult.OK) - { - comboBox.CustomColor = colorDialog.Color; - comboBox.SelectedIndex = 0; - } - } - - private void Dirty() - { - int index = listBoxHighlight.SelectedIndex; - if (index > -1) - { - btnApply.Enabled = true; - btnApply.Image = _applyButtonImage; - } - - btnAdd.Enabled = textBoxSearchString.Text.Length > 0; - } - - private void FillGroupComboBox() - { - SelectGroup(-1); - - comboBoxGroups.Items.Clear(); - - foreach (HighlightGroup group in HighlightGroupList) - { - comboBoxGroups.Items.Add(group); - } - - ReEvaluateGroupButtonStates(); - } - - private void FillHighlightListBox() - { - listBoxHighlight.Items.Clear(); - if (_currentGroup != null) - { - foreach (HighlightEntry entry in _currentGroup.HighlightEntryList) - { - listBoxHighlight.Items.Add(entry); - } - } - } - - private void InitData() - { - const string def = "[Default]"; - HighlightGroupList ??= []; - - if (HighlightGroupList.Count == 0) - { - HighlightGroup highlightGroup = new() - { - GroupName = def, - HighlightEntryList = [] - }; - - HighlightGroupList.Add(highlightGroup); - } - - FillGroupComboBox(); - - _currentGroup = null; - string groupToSelect = PreSelectedGroupName; - if (string.IsNullOrEmpty(groupToSelect)) - { - groupToSelect = def; - } - - foreach (HighlightGroup group in HighlightGroupList) - { - if (group.GroupName.Equals(groupToSelect)) - { - _currentGroup = group; - comboBoxGroups.SelectedValue = group; - comboBoxGroups.SelectedIndex = HighlightGroupList.IndexOf(group); - break; - } - } - - ReEvaluateGroupButtonStates(); - - FillHighlightListBox(); - } - - private void ReEvaluateGroupButtonStates() - { - // Refresh button states based on the selection in the combobox - bool atLeastOneSelected = comboBoxGroups.SelectedItem != null; - bool moreThanOne = comboBoxGroups.Items.Count > 1; - bool firstSelected = atLeastOneSelected && comboBoxGroups.SelectedIndex == 0; - bool lastSelected = atLeastOneSelected && comboBoxGroups.SelectedIndex == comboBoxGroups.Items.Count - 1; - - btnDeleteGroup.Enabled = atLeastOneSelected; - btnCopyGroup.Enabled = atLeastOneSelected; - btnMoveGroupUp.Enabled = atLeastOneSelected && moreThanOne && !firstSelected; - btnMoveGroupDown.Enabled = atLeastOneSelected && moreThanOne && !lastSelected; - } - - private void ReEvaluateHighlightButtonStates() - { - // Refresh button states based on the selection in the combobox - bool atLeastOneSelected = listBoxHighlight.SelectedItem != null; - bool moreThanOne = listBoxHighlight.Items.Count > 1; - bool firstSelected = atLeastOneSelected && listBoxHighlight.SelectedIndex == 0; - bool lastSelected = atLeastOneSelected && listBoxHighlight.SelectedIndex == listBoxHighlight.Items.Count - 1; - - btnDelete.Enabled = atLeastOneSelected; - btnMoveUp.Enabled = atLeastOneSelected && moreThanOne && !firstSelected; - btnMoveDown.Enabled = atLeastOneSelected && moreThanOne && !lastSelected; - } - - private void SaveEntry() - { - try - { - CheckRegex(); - - HighlightEntry entry = (HighlightEntry)listBoxHighlight.SelectedItem; - - entry.ForegroundColor = (Color)colorBoxForeground.SelectedItem; - entry.BackgroundColor = (Color)colorBoxBackground.SelectedItem; - entry.SearchText = textBoxSearchString.Text; - entry.IsRegEx = checkBoxRegex.Checked; - entry.IsCaseSensitive = checkBoxCaseSensitive.Checked; - btnApply.Enabled = false; - btnApply.Image = null; - entry.IsLedSwitch = checkBoxDontDirtyLed.Checked; - entry.IsSetBookmark = checkBoxBookmark.Checked; - entry.IsStopTail = checkBoxStopTail.Checked; - entry.IsActionEntry = checkBoxPlugin.Checked; - entry.ActionEntry = (ActionEntry)_currentActionEntry.Clone(); - entry.BookmarkComment = _bookmarkComment; - entry.IsWordMatch = checkBoxWordMatch.Checked; - entry.IsBold = checkBoxBold.Checked; - entry.NoBackground = checkBoxNoBackground.Checked; - listBoxHighlight.Refresh(); - } - catch (Exception ex) - { - _logger.Error(ex, "Error during save of save highlight entry"); - MessageBox.Show($"Error during save of entry.\r\n{ex.Message}"); - } - } - - private void SelectGroup(int index) - { - if (index >= 0 && index < HighlightGroupList.Count) - { - _currentGroup = HighlightGroupList[index]; - comboBoxGroups.Items[index] = _currentGroup; - comboBoxGroups.SelectedIndex = index; - comboBoxGroups.SelectedItem = _currentGroup; - FillHighlightListBox(); - } - else - { - comboBoxGroups.SelectedItem = null; - _currentGroup = null; - listBoxHighlight.Items.Clear(); - } - - ReEvaluateHighlightButtonStates(); - ReEvaluateGroupButtonStates(); - } - - private void StartEditEntry() - { - HighlightEntry entry = (HighlightEntry)listBoxHighlight.SelectedItem; - - if (entry != null) - { - textBoxSearchString.Text = entry.SearchText; - - colorBoxForeground.CustomColor = entry.ForegroundColor; - colorBoxBackground.CustomColor = entry.BackgroundColor; - - if (colorBoxForeground.Items.Contains(entry.ForegroundColor)) - { - colorBoxForeground.SelectedIndex = colorBoxForeground.Items.Cast().ToList().LastIndexOf(entry.ForegroundColor); - } - else - { - colorBoxForeground.SelectedItem = entry.ForegroundColor; - } - - if (colorBoxForeground.Items.Contains(entry.ForegroundColor)) - { - colorBoxBackground.SelectedIndex = colorBoxBackground.Items.Cast().ToList().LastIndexOf(entry.BackgroundColor); - } - else - { - colorBoxBackground.SelectedItem = entry.BackgroundColor; - } - - checkBoxRegex.Checked = entry.IsRegEx; - checkBoxCaseSensitive.Checked = entry.IsCaseSensitive; - checkBoxDontDirtyLed.Checked = entry.IsLedSwitch; - checkBoxBookmark.Checked = entry.IsSetBookmark; - checkBoxStopTail.Checked = entry.IsStopTail; - checkBoxPlugin.Checked = entry.IsActionEntry; - btnSelectPlugin.Enabled = checkBoxPlugin.Checked; - btnBookmarkComment.Enabled = checkBoxBookmark.Checked; - _currentActionEntry = entry.ActionEntry != null ? (ActionEntry)entry.ActionEntry.Clone() : new ActionEntry(); - _bookmarkComment = entry.BookmarkComment; - checkBoxWordMatch.Checked = entry.IsWordMatch; - checkBoxBold.Checked = entry.IsBold; - checkBoxNoBackground.Checked = entry.NoBackground; - } - - btnApply.Enabled = false; - btnApply.Image = null; - - ReEvaluateHighlightButtonStates(); - } - - #endregion - } -} diff --git a/src/LogExpert/Dialogs/ParamRequesterDialog.Designer.cs b/src/LogExpert/Dialogs/ParamRequesterDialog.Designer.cs deleted file mode 100644 index 48fbbbba..00000000 --- a/src/LogExpert/Dialogs/ParamRequesterDialog.Designer.cs +++ /dev/null @@ -1,105 +0,0 @@ -namespace LogExpert.Dialogs -{ - partial class ParamRequesterDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.labelValueForParameter = new System.Windows.Forms.Label(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOk = new System.Windows.Forms.Button(); - this.comboBoxValue = new System.Windows.Forms.ComboBox(); - this.SuspendLayout(); - // - // labelValueForParameter - // - this.labelValueForParameter.AutoSize = true; - this.labelValueForParameter.Location = new System.Drawing.Point(13, 25); - this.labelValueForParameter.Name = "labelValueForParameter"; - this.labelValueForParameter.Size = new System.Drawing.Size(154, 20); - this.labelValueForParameter.TabIndex = 0; - this.labelValueForParameter.Text = "&Value for parameter:"; - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(238, 88); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 3; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // buttonOk - // - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(148, 88); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 23); - this.buttonOk.TabIndex = 2; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.okButton_Click); - // - // comboBoxValue - // - this.comboBoxValue.FormattingEnabled = true; - this.comboBoxValue.Location = new System.Drawing.Point(16, 48); - this.comboBoxValue.Name = "comboBoxValue"; - this.comboBoxValue.Size = new System.Drawing.Size(297, 28); - this.comboBoxValue.TabIndex = 1; - // - // ParamRequesterDialog - // - this.AcceptButton = this.buttonOk; - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(332, 130); - this.Controls.Add(this.comboBoxValue); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.labelValueForParameter); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ParamRequesterDialog"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Tool parameter"; - this.Shown += new System.EventHandler(this.ParamRequesterDialog_Shown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label labelValueForParameter; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.ComboBox comboBoxValue; - } -} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/ParamRequesterDialog.cs b/src/LogExpert/Dialogs/ParamRequesterDialog.cs deleted file mode 100644 index 21dca01e..00000000 --- a/src/LogExpert/Dialogs/ParamRequesterDialog.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - public partial class ParamRequesterDialog : Form - { - #region Fields - - #endregion - - #region cTor - - public ParamRequesterDialog() - { - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - } - - #endregion - - #region Properties - - public string ParamName { get; set; } - - public string ParamValue { get; set; } - - public string[] Values { get; set; } - - #endregion - - #region Events handler - - private void ParamRequesterDialog_Shown(object sender, EventArgs e) - { - labelValueForParameter.Text = ParamName; - - if (Values != null) - { - foreach (string value in Values) - { - comboBoxValue.Items.Add(value); - } - comboBoxValue.SelectedIndex = 0; - } - } - - private void okButton_Click(object sender, EventArgs e) - { - ParamValue = comboBoxValue.Text; - } - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/SettingsDialog.Designer.cs b/src/LogExpert/Dialogs/SettingsDialog.Designer.cs deleted file mode 100644 index 026961d0..00000000 --- a/src/LogExpert/Dialogs/SettingsDialog.Designer.cs +++ /dev/null @@ -1,1846 +0,0 @@ -namespace LogExpert.Dialogs -{ - partial class SettingsDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SettingsDialog)); - tabControlSettings = new System.Windows.Forms.TabControl(); - tabPageViewSettings = new System.Windows.Forms.TabPage(); - labelWarningMaximumLineLenght = new System.Windows.Forms.Label(); - upDownMaximumLineLength = new System.Windows.Forms.NumericUpDown(); - labelMaximumLineLength = new System.Windows.Forms.Label(); - upDownMaximumFilterEntriesDisplayed = new System.Windows.Forms.NumericUpDown(); - labelMaximumFilterEntriesDisplayed = new System.Windows.Forms.Label(); - upDownMaximumFilterEntries = new System.Windows.Forms.NumericUpDown(); - labelMaximumFilterEntries = new System.Windows.Forms.Label(); - labelDefaultEncoding = new System.Windows.Forms.Label(); - comboBoxEncoding = new System.Windows.Forms.ComboBox(); - groupBoxMisc = new System.Windows.Forms.GroupBox(); - checkBoxShowErrorMessageOnlyOneInstance = new System.Windows.Forms.CheckBox(); - cpDownColumnWidth = new System.Windows.Forms.NumericUpDown(); - checkBoxColumnSize = new System.Windows.Forms.CheckBox(); - buttonTailColor = new System.Windows.Forms.Button(); - checkBoxTailState = new System.Windows.Forms.CheckBox(); - checkBoxOpenLastFiles = new System.Windows.Forms.CheckBox(); - checkBoxSingleInstance = new System.Windows.Forms.CheckBox(); - checkBoxAskCloseTabs = new System.Windows.Forms.CheckBox(); - groupBoxDefaults = new System.Windows.Forms.GroupBox(); - checkBoxDarkMode = new System.Windows.Forms.CheckBox(); - checkBoxFollowTail = new System.Windows.Forms.CheckBox(); - checkBoxColumnFinder = new System.Windows.Forms.CheckBox(); - checkBoxSyncFilter = new System.Windows.Forms.CheckBox(); - checkBoxFilterTail = new System.Windows.Forms.CheckBox(); - groupBoxFont = new System.Windows.Forms.GroupBox(); - buttonChangeFont = new System.Windows.Forms.Button(); - labelFont = new System.Windows.Forms.Label(); - tabPageTimeStampFeatures = new System.Windows.Forms.TabPage(); - groupBoxTimeSpreadDisplay = new System.Windows.Forms.GroupBox(); - groupBoxDisplayMode = new System.Windows.Forms.GroupBox(); - radioButtonLineView = new System.Windows.Forms.RadioButton(); - radioButtonTimeView = new System.Windows.Forms.RadioButton(); - checkBoxReverseAlpha = new System.Windows.Forms.CheckBox(); - buttonTimespreadColor = new System.Windows.Forms.Button(); - checkBoxTimeSpread = new System.Windows.Forms.CheckBox(); - groupBoxTimeStampNavigationControl = new System.Windows.Forms.GroupBox(); - checkBoxTimestamp = new System.Windows.Forms.CheckBox(); - groupBoxMouseDragDefaults = new System.Windows.Forms.GroupBox(); - radioButtonVerticalMouseDragInverted = new System.Windows.Forms.RadioButton(); - radioButtonHorizMouseDrag = new System.Windows.Forms.RadioButton(); - radioButtonVerticalMouseDrag = new System.Windows.Forms.RadioButton(); - tabPageExternalTools = new System.Windows.Forms.TabPage(); - labelToolsDescription = new System.Windows.Forms.Label(); - buttonToolDelete = new System.Windows.Forms.Button(); - buttonToolAdd = new System.Windows.Forms.Button(); - buttonToolDown = new System.Windows.Forms.Button(); - buttonToolUp = new System.Windows.Forms.Button(); - listBoxTools = new System.Windows.Forms.CheckedListBox(); - groupBoxToolSettings = new System.Windows.Forms.GroupBox(); - labelWorkingDir = new System.Windows.Forms.Label(); - buttonWorkingDir = new System.Windows.Forms.Button(); - textBoxWorkingDir = new System.Windows.Forms.TextBox(); - buttonIcon = new System.Windows.Forms.Button(); - labelToolName = new System.Windows.Forms.Label(); - labelToolColumnizerForOutput = new System.Windows.Forms.Label(); - comboBoxColumnizer = new System.Windows.Forms.ComboBox(); - textBoxToolName = new System.Windows.Forms.TextBox(); - checkBoxSysout = new System.Windows.Forms.CheckBox(); - buttonArguments = new System.Windows.Forms.Button(); - labelTool = new System.Windows.Forms.Label(); - buttonTool = new System.Windows.Forms.Button(); - textBoxTool = new System.Windows.Forms.TextBox(); - labelArguments = new System.Windows.Forms.Label(); - textBoxArguments = new System.Windows.Forms.TextBox(); - tabPageColumnizers = new System.Windows.Forms.TabPage(); - checkBoxAutoPick = new System.Windows.Forms.CheckBox(); - checkBoxMaskPrio = new System.Windows.Forms.CheckBox(); - buttonDelete = new System.Windows.Forms.Button(); - dataGridViewColumnizer = new System.Windows.Forms.DataGridView(); - columnFileMask = new System.Windows.Forms.DataGridViewTextBoxColumn(); - columnColumnizer = new System.Windows.Forms.DataGridViewComboBoxColumn(); - tabPageHighlightMask = new System.Windows.Forms.TabPage(); - dataGridViewHighlightMask = new System.Windows.Forms.DataGridView(); - columnFileName = new System.Windows.Forms.DataGridViewTextBoxColumn(); - columnHighlightGroup = new System.Windows.Forms.DataGridViewComboBoxColumn(); - tabPageMultiFile = new System.Windows.Forms.TabPage(); - groupBoxDefaultFileNamePattern = new System.Windows.Forms.GroupBox(); - labelMaxDays = new System.Windows.Forms.Label(); - labelPattern = new System.Windows.Forms.Label(); - upDownMultifileDays = new System.Windows.Forms.NumericUpDown(); - textBoxMultifilePattern = new System.Windows.Forms.TextBox(); - labelHintMultiFile = new System.Windows.Forms.Label(); - labelNoteMultiFile = new System.Windows.Forms.Label(); - groupBoxWhenOpeningMultiFile = new System.Windows.Forms.GroupBox(); - radioButtonAskWhatToDo = new System.Windows.Forms.RadioButton(); - radioButtonTreatAllFilesAsOneMultifile = new System.Windows.Forms.RadioButton(); - radioButtonLoadEveryFileIntoSeperatedTab = new System.Windows.Forms.RadioButton(); - tabPagePlugins = new System.Windows.Forms.TabPage(); - groupBoxPlugins = new System.Windows.Forms.GroupBox(); - listBoxPlugin = new System.Windows.Forms.ListBox(); - groupBoxSettings = new System.Windows.Forms.GroupBox(); - panelPlugin = new System.Windows.Forms.Panel(); - buttonConfigPlugin = new System.Windows.Forms.Button(); - tabPageSessions = new System.Windows.Forms.TabPage(); - checkBoxPortableMode = new System.Windows.Forms.CheckBox(); - checkBoxSaveFilter = new System.Windows.Forms.CheckBox(); - groupBoxPersistantFileLocation = new System.Windows.Forms.GroupBox(); - labelSessionSaveOwnDir = new System.Windows.Forms.Label(); - buttonSessionSaveDir = new System.Windows.Forms.Button(); - radioButtonSessionSaveOwn = new System.Windows.Forms.RadioButton(); - radioButtonsessionSaveDocuments = new System.Windows.Forms.RadioButton(); - radioButtonSessionSameDir = new System.Windows.Forms.RadioButton(); - radioButtonSessionApplicationStartupDir = new System.Windows.Forms.RadioButton(); - checkBoxSaveSessions = new System.Windows.Forms.CheckBox(); - tabPageMemory = new System.Windows.Forms.TabPage(); - groupBoxCPUAndStuff = new System.Windows.Forms.GroupBox(); - checkBoxLegacyReader = new System.Windows.Forms.CheckBox(); - checkBoxMultiThread = new System.Windows.Forms.CheckBox(); - labelFilePollingInterval = new System.Windows.Forms.Label(); - upDownPollingInterval = new System.Windows.Forms.NumericUpDown(); - groupBoxLineBufferUsage = new System.Windows.Forms.GroupBox(); - labelInfo = new System.Windows.Forms.Label(); - labelNumberOfBlocks = new System.Windows.Forms.Label(); - upDownLinesPerBlock = new System.Windows.Forms.NumericUpDown(); - upDownBlockCount = new System.Windows.Forms.NumericUpDown(); - labelLinesPerBlock = new System.Windows.Forms.Label(); - buttonCancel = new System.Windows.Forms.Button(); - buttonOk = new System.Windows.Forms.Button(); - helpProvider = new System.Windows.Forms.HelpProvider(); - toolTip = new System.Windows.Forms.ToolTip(components); - buttonExport = new System.Windows.Forms.Button(); - buttonImport = new System.Windows.Forms.Button(); - dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - tabControlSettings.SuspendLayout(); - tabPageViewSettings.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)upDownMaximumLineLength).BeginInit(); - ((System.ComponentModel.ISupportInitialize)upDownMaximumFilterEntriesDisplayed).BeginInit(); - ((System.ComponentModel.ISupportInitialize)upDownMaximumFilterEntries).BeginInit(); - groupBoxMisc.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)cpDownColumnWidth).BeginInit(); - groupBoxDefaults.SuspendLayout(); - groupBoxFont.SuspendLayout(); - tabPageTimeStampFeatures.SuspendLayout(); - groupBoxTimeSpreadDisplay.SuspendLayout(); - groupBoxDisplayMode.SuspendLayout(); - groupBoxTimeStampNavigationControl.SuspendLayout(); - groupBoxMouseDragDefaults.SuspendLayout(); - tabPageExternalTools.SuspendLayout(); - groupBoxToolSettings.SuspendLayout(); - tabPageColumnizers.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridViewColumnizer).BeginInit(); - tabPageHighlightMask.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridViewHighlightMask).BeginInit(); - tabPageMultiFile.SuspendLayout(); - groupBoxDefaultFileNamePattern.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)upDownMultifileDays).BeginInit(); - groupBoxWhenOpeningMultiFile.SuspendLayout(); - tabPagePlugins.SuspendLayout(); - groupBoxPlugins.SuspendLayout(); - groupBoxSettings.SuspendLayout(); - panelPlugin.SuspendLayout(); - tabPageSessions.SuspendLayout(); - groupBoxPersistantFileLocation.SuspendLayout(); - tabPageMemory.SuspendLayout(); - groupBoxCPUAndStuff.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)upDownPollingInterval).BeginInit(); - groupBoxLineBufferUsage.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)upDownLinesPerBlock).BeginInit(); - ((System.ComponentModel.ISupportInitialize)upDownBlockCount).BeginInit(); - SuspendLayout(); - // - // tabControlSettings - // - tabControlSettings.Controls.Add(tabPageViewSettings); - tabControlSettings.Controls.Add(tabPageTimeStampFeatures); - tabControlSettings.Controls.Add(tabPageExternalTools); - tabControlSettings.Controls.Add(tabPageColumnizers); - tabControlSettings.Controls.Add(tabPageHighlightMask); - tabControlSettings.Controls.Add(tabPageMultiFile); - tabControlSettings.Controls.Add(tabPagePlugins); - tabControlSettings.Controls.Add(tabPageSessions); - tabControlSettings.Controls.Add(tabPageMemory); - tabControlSettings.Location = new System.Drawing.Point(2, 3); - tabControlSettings.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabControlSettings.Name = "tabControlSettings"; - tabControlSettings.SelectedIndex = 0; - tabControlSettings.Size = new System.Drawing.Size(950, 468); - tabControlSettings.TabIndex = 0; - // - // tabPageViewSettings - // - tabPageViewSettings.Controls.Add(labelWarningMaximumLineLenght); - tabPageViewSettings.Controls.Add(upDownMaximumLineLength); - tabPageViewSettings.Controls.Add(labelMaximumLineLength); - tabPageViewSettings.Controls.Add(upDownMaximumFilterEntriesDisplayed); - tabPageViewSettings.Controls.Add(labelMaximumFilterEntriesDisplayed); - tabPageViewSettings.Controls.Add(upDownMaximumFilterEntries); - tabPageViewSettings.Controls.Add(labelMaximumFilterEntries); - tabPageViewSettings.Controls.Add(labelDefaultEncoding); - tabPageViewSettings.Controls.Add(comboBoxEncoding); - tabPageViewSettings.Controls.Add(groupBoxMisc); - tabPageViewSettings.Controls.Add(groupBoxDefaults); - tabPageViewSettings.Controls.Add(groupBoxFont); - tabPageViewSettings.Location = new System.Drawing.Point(4, 24); - tabPageViewSettings.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPageViewSettings.Name = "tabPageViewSettings"; - tabPageViewSettings.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPageViewSettings.Size = new System.Drawing.Size(942, 440); - tabPageViewSettings.TabIndex = 0; - tabPageViewSettings.Text = "View settings"; - tabPageViewSettings.UseVisualStyleBackColor = true; - // - // labelWarningMaximumLineLenght - // - labelWarningMaximumLineLenght.AutoSize = true; - labelWarningMaximumLineLenght.Location = new System.Drawing.Point(446, 118); - labelWarningMaximumLineLenght.Name = "labelWarningMaximumLineLenght"; - labelWarningMaximumLineLenght.Size = new System.Drawing.Size(482, 15); - labelWarningMaximumLineLenght.TabIndex = 16; - labelWarningMaximumLineLenght.Text = "! Changing the Maximum Line Length can impact performance and is not recommended !"; - // - // upDownMaximumLineLength - // - upDownMaximumLineLength.Location = new System.Drawing.Point(762, 138); - upDownMaximumLineLength.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - upDownMaximumLineLength.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 }); - upDownMaximumLineLength.Minimum = new decimal(new int[] { 20000, 0, 0, 0 }); - upDownMaximumLineLength.Name = "upDownMaximumLineLength"; - upDownMaximumLineLength.Size = new System.Drawing.Size(106, 23); - upDownMaximumLineLength.TabIndex = 15; - upDownMaximumLineLength.Value = new decimal(new int[] { 20000, 0, 0, 0 }); - // - // labelMaximumLineLength - // - labelMaximumLineLength.AutoSize = true; - labelMaximumLineLength.Location = new System.Drawing.Point(467, 140); - labelMaximumLineLength.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelMaximumLineLength.Name = "labelMaximumLineLength"; - labelMaximumLineLength.Size = new System.Drawing.Size(217, 15); - labelMaximumLineLength.TabIndex = 14; - labelMaximumLineLength.Text = "Maximum Line Length (restart required)"; - // - // upDownMaximumFilterEntriesDisplayed - // - upDownMaximumFilterEntriesDisplayed.Location = new System.Drawing.Point(762, 86); - upDownMaximumFilterEntriesDisplayed.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - upDownMaximumFilterEntriesDisplayed.Maximum = new decimal(new int[] { 30, 0, 0, 0 }); - upDownMaximumFilterEntriesDisplayed.Minimum = new decimal(new int[] { 10, 0, 0, 0 }); - upDownMaximumFilterEntriesDisplayed.Name = "upDownMaximumFilterEntriesDisplayed"; - upDownMaximumFilterEntriesDisplayed.Size = new System.Drawing.Size(106, 23); - upDownMaximumFilterEntriesDisplayed.TabIndex = 13; - upDownMaximumFilterEntriesDisplayed.Value = new decimal(new int[] { 20, 0, 0, 0 }); - // - // labelMaximumFilterEntriesDisplayed - // - labelMaximumFilterEntriesDisplayed.AutoSize = true; - labelMaximumFilterEntriesDisplayed.Location = new System.Drawing.Point(467, 88); - labelMaximumFilterEntriesDisplayed.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelMaximumFilterEntriesDisplayed.Name = "labelMaximumFilterEntriesDisplayed"; - labelMaximumFilterEntriesDisplayed.Size = new System.Drawing.Size(179, 15); - labelMaximumFilterEntriesDisplayed.TabIndex = 12; - labelMaximumFilterEntriesDisplayed.Text = "Maximum filter entries displayed"; - // - // upDownMaximumFilterEntries - // - upDownMaximumFilterEntries.Location = new System.Drawing.Point(762, 59); - upDownMaximumFilterEntries.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - upDownMaximumFilterEntries.Minimum = new decimal(new int[] { 10, 0, 0, 0 }); - upDownMaximumFilterEntries.Name = "upDownMaximumFilterEntries"; - upDownMaximumFilterEntries.Size = new System.Drawing.Size(106, 23); - upDownMaximumFilterEntries.TabIndex = 11; - upDownMaximumFilterEntries.Value = new decimal(new int[] { 30, 0, 0, 0 }); - // - // labelMaximumFilterEntries - // - labelMaximumFilterEntries.AutoSize = true; - labelMaximumFilterEntries.Location = new System.Drawing.Point(467, 61); - labelMaximumFilterEntries.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelMaximumFilterEntries.Name = "labelMaximumFilterEntries"; - labelMaximumFilterEntries.Size = new System.Drawing.Size(126, 15); - labelMaximumFilterEntries.TabIndex = 10; - labelMaximumFilterEntries.Text = "Maximum filter entries"; - // - // labelDefaultEncoding - // - labelDefaultEncoding.AutoSize = true; - labelDefaultEncoding.Location = new System.Drawing.Point(467, 34); - labelDefaultEncoding.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelDefaultEncoding.Name = "labelDefaultEncoding"; - labelDefaultEncoding.Size = new System.Drawing.Size(98, 15); - labelDefaultEncoding.TabIndex = 9; - labelDefaultEncoding.Text = "Default encoding"; - // - // comboBoxEncoding - // - comboBoxEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - comboBoxEncoding.FormattingEnabled = true; - comboBoxEncoding.Location = new System.Drawing.Point(691, 26); - comboBoxEncoding.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - comboBoxEncoding.Name = "comboBoxEncoding"; - comboBoxEncoding.Size = new System.Drawing.Size(177, 23); - comboBoxEncoding.TabIndex = 8; - toolTip.SetToolTip(comboBoxEncoding, "Encoding to be used when no BOM header and no persistence data is available."); - // - // groupBoxMisc - // - groupBoxMisc.Controls.Add(checkBoxShowErrorMessageOnlyOneInstance); - groupBoxMisc.Controls.Add(cpDownColumnWidth); - groupBoxMisc.Controls.Add(checkBoxColumnSize); - groupBoxMisc.Controls.Add(buttonTailColor); - groupBoxMisc.Controls.Add(checkBoxTailState); - groupBoxMisc.Controls.Add(checkBoxOpenLastFiles); - groupBoxMisc.Controls.Add(checkBoxSingleInstance); - groupBoxMisc.Controls.Add(checkBoxAskCloseTabs); - groupBoxMisc.Location = new System.Drawing.Point(458, 171); - groupBoxMisc.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxMisc.Name = "groupBoxMisc"; - groupBoxMisc.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxMisc.Size = new System.Drawing.Size(410, 226); - groupBoxMisc.TabIndex = 7; - groupBoxMisc.TabStop = false; - groupBoxMisc.Text = "Misc"; - // - // checkBoxShowErrorMessageOnlyOneInstance - // - checkBoxShowErrorMessageOnlyOneInstance.AutoSize = true; - checkBoxShowErrorMessageOnlyOneInstance.Location = new System.Drawing.Point(210, 66); - checkBoxShowErrorMessageOnlyOneInstance.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxShowErrorMessageOnlyOneInstance.Name = "checkBoxShowErrorMessageOnlyOneInstance"; - checkBoxShowErrorMessageOnlyOneInstance.Size = new System.Drawing.Size(137, 19); - checkBoxShowErrorMessageOnlyOneInstance.TabIndex = 7; - checkBoxShowErrorMessageOnlyOneInstance.Text = "Show Error Message?"; - checkBoxShowErrorMessageOnlyOneInstance.UseVisualStyleBackColor = true; - // - // cpDownColumnWidth - // - cpDownColumnWidth.Location = new System.Drawing.Point(304, 175); - cpDownColumnWidth.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - cpDownColumnWidth.Maximum = new decimal(new int[] { 9000, 0, 0, 0 }); - cpDownColumnWidth.Minimum = new decimal(new int[] { 300, 0, 0, 0 }); - cpDownColumnWidth.Name = "cpDownColumnWidth"; - cpDownColumnWidth.Size = new System.Drawing.Size(84, 23); - cpDownColumnWidth.TabIndex = 6; - cpDownColumnWidth.Value = new decimal(new int[] { 2000, 0, 0, 0 }); - // - // checkBoxColumnSize - // - checkBoxColumnSize.AutoSize = true; - checkBoxColumnSize.Location = new System.Drawing.Point(9, 177); - checkBoxColumnSize.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxColumnSize.Name = "checkBoxColumnSize"; - checkBoxColumnSize.Size = new System.Drawing.Size(140, 19); - checkBoxColumnSize.TabIndex = 5; - checkBoxColumnSize.Text = "Set last column width"; - checkBoxColumnSize.UseVisualStyleBackColor = true; - checkBoxColumnSize.CheckedChanged += OnChkBoxColumnSizeCheckedChanged; - // - // buttonTailColor - // - buttonTailColor.Location = new System.Drawing.Point(304, 135); - buttonTailColor.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonTailColor.Name = "buttonTailColor"; - buttonTailColor.Size = new System.Drawing.Size(84, 32); - buttonTailColor.TabIndex = 4; - buttonTailColor.Text = "Color..."; - buttonTailColor.UseVisualStyleBackColor = true; - buttonTailColor.Click += OnBtnTailColorClick; - // - // checkBoxTailState - // - checkBoxTailState.AutoSize = true; - checkBoxTailState.Location = new System.Drawing.Point(9, 140); - checkBoxTailState.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxTailState.Name = "checkBoxTailState"; - checkBoxTailState.Size = new System.Drawing.Size(144, 19); - checkBoxTailState.TabIndex = 3; - checkBoxTailState.Text = "Show tail state on tabs"; - checkBoxTailState.UseVisualStyleBackColor = true; - // - // checkBoxOpenLastFiles - // - checkBoxOpenLastFiles.AutoSize = true; - checkBoxOpenLastFiles.Location = new System.Drawing.Point(9, 103); - checkBoxOpenLastFiles.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxOpenLastFiles.Name = "checkBoxOpenLastFiles"; - checkBoxOpenLastFiles.Size = new System.Drawing.Size(144, 19); - checkBoxOpenLastFiles.TabIndex = 2; - checkBoxOpenLastFiles.Text = "Re-open last used files"; - checkBoxOpenLastFiles.UseVisualStyleBackColor = true; - // - // checkBoxSingleInstance - // - checkBoxSingleInstance.AutoSize = true; - checkBoxSingleInstance.Location = new System.Drawing.Point(9, 66); - checkBoxSingleInstance.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxSingleInstance.Name = "checkBoxSingleInstance"; - checkBoxSingleInstance.Size = new System.Drawing.Size(138, 19); - checkBoxSingleInstance.TabIndex = 1; - checkBoxSingleInstance.Text = "Allow only 1 Instance"; - checkBoxSingleInstance.UseVisualStyleBackColor = true; - // - // checkBoxAskCloseTabs - // - checkBoxAskCloseTabs.AutoSize = true; - checkBoxAskCloseTabs.Location = new System.Drawing.Point(9, 29); - checkBoxAskCloseTabs.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxAskCloseTabs.Name = "checkBoxAskCloseTabs"; - checkBoxAskCloseTabs.Size = new System.Drawing.Size(148, 19); - checkBoxAskCloseTabs.TabIndex = 0; - checkBoxAskCloseTabs.Text = "Ask before closing tabs"; - checkBoxAskCloseTabs.UseVisualStyleBackColor = true; - // - // groupBoxDefaults - // - groupBoxDefaults.Controls.Add(checkBoxDarkMode); - groupBoxDefaults.Controls.Add(checkBoxFollowTail); - groupBoxDefaults.Controls.Add(checkBoxColumnFinder); - groupBoxDefaults.Controls.Add(checkBoxSyncFilter); - groupBoxDefaults.Controls.Add(checkBoxFilterTail); - groupBoxDefaults.Location = new System.Drawing.Point(10, 171); - groupBoxDefaults.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxDefaults.Name = "groupBoxDefaults"; - groupBoxDefaults.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxDefaults.Size = new System.Drawing.Size(411, 226); - groupBoxDefaults.TabIndex = 6; - groupBoxDefaults.TabStop = false; - groupBoxDefaults.Text = "Defaults"; - // - // checkBoxDarkMode - // - checkBoxDarkMode.AutoSize = true; - checkBoxDarkMode.Location = new System.Drawing.Point(7, 141); - checkBoxDarkMode.Margin = new System.Windows.Forms.Padding(4); - checkBoxDarkMode.Name = "checkBoxDarkMode"; - checkBoxDarkMode.Size = new System.Drawing.Size(175, 19); - checkBoxDarkMode.TabIndex = 6; - checkBoxDarkMode.Text = "Dark Mode (restart required)"; - checkBoxDarkMode.UseVisualStyleBackColor = true; - // - // checkBoxFollowTail - // - checkBoxFollowTail.AutoSize = true; - checkBoxFollowTail.Location = new System.Drawing.Point(9, 29); - checkBoxFollowTail.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxFollowTail.Name = "checkBoxFollowTail"; - checkBoxFollowTail.Size = new System.Drawing.Size(125, 19); - checkBoxFollowTail.TabIndex = 3; - checkBoxFollowTail.Text = "Follow tail enabled"; - checkBoxFollowTail.UseVisualStyleBackColor = true; - // - // checkBoxColumnFinder - // - checkBoxColumnFinder.AutoSize = true; - checkBoxColumnFinder.Location = new System.Drawing.Point(9, 140); - checkBoxColumnFinder.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxColumnFinder.Name = "checkBoxColumnFinder"; - checkBoxColumnFinder.Size = new System.Drawing.Size(133, 19); - checkBoxColumnFinder.TabIndex = 5; - checkBoxColumnFinder.Text = "Show column finder"; - checkBoxColumnFinder.UseVisualStyleBackColor = true; - // - // checkBoxSyncFilter - // - checkBoxSyncFilter.AutoSize = true; - checkBoxSyncFilter.Location = new System.Drawing.Point(9, 103); - checkBoxSyncFilter.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxSyncFilter.Name = "checkBoxSyncFilter"; - checkBoxSyncFilter.Size = new System.Drawing.Size(141, 19); - checkBoxSyncFilter.TabIndex = 5; - checkBoxSyncFilter.Text = "Sync filter list enabled"; - checkBoxSyncFilter.UseVisualStyleBackColor = true; - // - // checkBoxFilterTail - // - checkBoxFilterTail.AutoSize = true; - checkBoxFilterTail.Location = new System.Drawing.Point(9, 66); - checkBoxFilterTail.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxFilterTail.Name = "checkBoxFilterTail"; - checkBoxFilterTail.Size = new System.Drawing.Size(116, 19); - checkBoxFilterTail.TabIndex = 4; - checkBoxFilterTail.Text = "Filter tail enabled"; - checkBoxFilterTail.UseVisualStyleBackColor = true; - // - // groupBoxFont - // - groupBoxFont.Controls.Add(buttonChangeFont); - groupBoxFont.Controls.Add(labelFont); - groupBoxFont.Location = new System.Drawing.Point(10, 9); - groupBoxFont.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxFont.Name = "groupBoxFont"; - groupBoxFont.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxFont.Size = new System.Drawing.Size(408, 128); - groupBoxFont.TabIndex = 1; - groupBoxFont.TabStop = false; - groupBoxFont.Text = "Font"; - // - // buttonChangeFont - // - buttonChangeFont.Location = new System.Drawing.Point(9, 77); - buttonChangeFont.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonChangeFont.Name = "buttonChangeFont"; - buttonChangeFont.Size = new System.Drawing.Size(112, 35); - buttonChangeFont.TabIndex = 1; - buttonChangeFont.Text = "Change..."; - buttonChangeFont.UseVisualStyleBackColor = true; - buttonChangeFont.Click += OnBtnChangeFontClick; - // - // labelFont - // - labelFont.Location = new System.Drawing.Point(9, 25); - labelFont.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelFont.Name = "labelFont"; - labelFont.Size = new System.Drawing.Size(312, 48); - labelFont.TabIndex = 0; - labelFont.Text = "Font"; - labelFont.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // tabPageTimeStampFeatures - // - tabPageTimeStampFeatures.Controls.Add(groupBoxTimeSpreadDisplay); - tabPageTimeStampFeatures.Controls.Add(groupBoxTimeStampNavigationControl); - tabPageTimeStampFeatures.Location = new System.Drawing.Point(4, 24); - tabPageTimeStampFeatures.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPageTimeStampFeatures.Name = "tabPageTimeStampFeatures"; - tabPageTimeStampFeatures.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPageTimeStampFeatures.Size = new System.Drawing.Size(942, 440); - tabPageTimeStampFeatures.TabIndex = 1; - tabPageTimeStampFeatures.Text = "Timestamp features"; - tabPageTimeStampFeatures.UseVisualStyleBackColor = true; - // - // groupBoxTimeSpreadDisplay - // - groupBoxTimeSpreadDisplay.Controls.Add(groupBoxDisplayMode); - groupBoxTimeSpreadDisplay.Controls.Add(checkBoxReverseAlpha); - groupBoxTimeSpreadDisplay.Controls.Add(buttonTimespreadColor); - groupBoxTimeSpreadDisplay.Controls.Add(checkBoxTimeSpread); - groupBoxTimeSpreadDisplay.Location = new System.Drawing.Point(490, 25); - groupBoxTimeSpreadDisplay.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxTimeSpreadDisplay.Name = "groupBoxTimeSpreadDisplay"; - groupBoxTimeSpreadDisplay.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxTimeSpreadDisplay.Size = new System.Drawing.Size(300, 246); - groupBoxTimeSpreadDisplay.TabIndex = 8; - groupBoxTimeSpreadDisplay.TabStop = false; - groupBoxTimeSpreadDisplay.Text = "Time spread display"; - // - // groupBoxDisplayMode - // - groupBoxDisplayMode.Controls.Add(radioButtonLineView); - groupBoxDisplayMode.Controls.Add(radioButtonTimeView); - groupBoxDisplayMode.Location = new System.Drawing.Point(22, 109); - groupBoxDisplayMode.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxDisplayMode.Name = "groupBoxDisplayMode"; - groupBoxDisplayMode.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxDisplayMode.Size = new System.Drawing.Size(188, 118); - groupBoxDisplayMode.TabIndex = 11; - groupBoxDisplayMode.TabStop = false; - groupBoxDisplayMode.Text = "Display mode"; - // - // radioButtonLineView - // - radioButtonLineView.AutoSize = true; - radioButtonLineView.Location = new System.Drawing.Point(9, 65); - radioButtonLineView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - radioButtonLineView.Name = "radioButtonLineView"; - radioButtonLineView.Size = new System.Drawing.Size(74, 19); - radioButtonLineView.TabIndex = 9; - radioButtonLineView.TabStop = true; - radioButtonLineView.Text = "Line view"; - radioButtonLineView.UseVisualStyleBackColor = true; - // - // radioButtonTimeView - // - radioButtonTimeView.AutoSize = true; - radioButtonTimeView.Location = new System.Drawing.Point(9, 29); - radioButtonTimeView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - radioButtonTimeView.Name = "radioButtonTimeView"; - radioButtonTimeView.Size = new System.Drawing.Size(79, 19); - radioButtonTimeView.TabIndex = 10; - radioButtonTimeView.TabStop = true; - radioButtonTimeView.Text = "Time view"; - radioButtonTimeView.UseVisualStyleBackColor = true; - // - // checkBoxReverseAlpha - // - checkBoxReverseAlpha.AutoSize = true; - checkBoxReverseAlpha.Location = new System.Drawing.Point(22, 74); - checkBoxReverseAlpha.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxReverseAlpha.Name = "checkBoxReverseAlpha"; - checkBoxReverseAlpha.Size = new System.Drawing.Size(98, 19); - checkBoxReverseAlpha.TabIndex = 8; - checkBoxReverseAlpha.Text = "Reverse alpha"; - checkBoxReverseAlpha.UseVisualStyleBackColor = true; - // - // buttonTimespreadColor - // - buttonTimespreadColor.Location = new System.Drawing.Point(207, 32); - buttonTimespreadColor.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonTimespreadColor.Name = "buttonTimespreadColor"; - buttonTimespreadColor.Size = new System.Drawing.Size(84, 32); - buttonTimespreadColor.TabIndex = 7; - buttonTimespreadColor.Text = "Color..."; - buttonTimespreadColor.UseVisualStyleBackColor = true; - buttonTimespreadColor.Click += OnBtnTimespreadColorClick; - // - // checkBoxTimeSpread - // - checkBoxTimeSpread.AutoSize = true; - checkBoxTimeSpread.Location = new System.Drawing.Point(22, 37); - checkBoxTimeSpread.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxTimeSpread.Name = "checkBoxTimeSpread"; - checkBoxTimeSpread.Size = new System.Drawing.Size(120, 19); - checkBoxTimeSpread.TabIndex = 6; - checkBoxTimeSpread.Text = "Show time spread"; - checkBoxTimeSpread.UseVisualStyleBackColor = true; - // - // groupBoxTimeStampNavigationControl - // - groupBoxTimeStampNavigationControl.Controls.Add(checkBoxTimestamp); - groupBoxTimeStampNavigationControl.Controls.Add(groupBoxMouseDragDefaults); - groupBoxTimeStampNavigationControl.Location = new System.Drawing.Point(10, 25); - groupBoxTimeStampNavigationControl.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxTimeStampNavigationControl.Name = "groupBoxTimeStampNavigationControl"; - groupBoxTimeStampNavigationControl.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxTimeStampNavigationControl.Size = new System.Drawing.Size(450, 246); - groupBoxTimeStampNavigationControl.TabIndex = 7; - groupBoxTimeStampNavigationControl.TabStop = false; - groupBoxTimeStampNavigationControl.Text = "Timestamp navigation control"; - // - // checkBoxTimestamp - // - checkBoxTimestamp.AutoSize = true; - checkBoxTimestamp.Location = new System.Drawing.Point(27, 37); - checkBoxTimestamp.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxTimestamp.Name = "checkBoxTimestamp"; - checkBoxTimestamp.Size = new System.Drawing.Size(304, 19); - checkBoxTimestamp.TabIndex = 3; - checkBoxTimestamp.Text = "Show timestamp control, if supported by columnizer"; - checkBoxTimestamp.UseVisualStyleBackColor = true; - // - // groupBoxMouseDragDefaults - // - groupBoxMouseDragDefaults.Controls.Add(radioButtonVerticalMouseDragInverted); - groupBoxMouseDragDefaults.Controls.Add(radioButtonHorizMouseDrag); - groupBoxMouseDragDefaults.Controls.Add(radioButtonVerticalMouseDrag); - groupBoxMouseDragDefaults.Location = new System.Drawing.Point(27, 80); - groupBoxMouseDragDefaults.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxMouseDragDefaults.Name = "groupBoxMouseDragDefaults"; - groupBoxMouseDragDefaults.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxMouseDragDefaults.Size = new System.Drawing.Size(186, 148); - groupBoxMouseDragDefaults.TabIndex = 5; - groupBoxMouseDragDefaults.TabStop = false; - groupBoxMouseDragDefaults.Text = "Mouse Drag Default"; - // - // radioButtonVerticalMouseDragInverted - // - radioButtonVerticalMouseDragInverted.AutoSize = true; - radioButtonVerticalMouseDragInverted.Location = new System.Drawing.Point(9, 102); - radioButtonVerticalMouseDragInverted.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - radioButtonVerticalMouseDragInverted.Name = "radioButtonVerticalMouseDragInverted"; - radioButtonVerticalMouseDragInverted.Size = new System.Drawing.Size(109, 19); - radioButtonVerticalMouseDragInverted.TabIndex = 6; - radioButtonVerticalMouseDragInverted.TabStop = true; - radioButtonVerticalMouseDragInverted.Text = "Vertical Inverted"; - radioButtonVerticalMouseDragInverted.UseVisualStyleBackColor = true; - // - // radioButtonHorizMouseDrag - // - radioButtonHorizMouseDrag.AutoSize = true; - radioButtonHorizMouseDrag.Location = new System.Drawing.Point(9, 29); - radioButtonHorizMouseDrag.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - radioButtonHorizMouseDrag.Name = "radioButtonHorizMouseDrag"; - radioButtonHorizMouseDrag.Size = new System.Drawing.Size(80, 19); - radioButtonHorizMouseDrag.TabIndex = 5; - radioButtonHorizMouseDrag.TabStop = true; - radioButtonHorizMouseDrag.Text = "Horizontal"; - radioButtonHorizMouseDrag.UseVisualStyleBackColor = true; - // - // radioButtonVerticalMouseDrag - // - radioButtonVerticalMouseDrag.AutoSize = true; - radioButtonVerticalMouseDrag.Location = new System.Drawing.Point(9, 65); - radioButtonVerticalMouseDrag.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - radioButtonVerticalMouseDrag.Name = "radioButtonVerticalMouseDrag"; - radioButtonVerticalMouseDrag.Size = new System.Drawing.Size(63, 19); - radioButtonVerticalMouseDrag.TabIndex = 4; - radioButtonVerticalMouseDrag.TabStop = true; - radioButtonVerticalMouseDrag.Text = "Vertical"; - radioButtonVerticalMouseDrag.UseVisualStyleBackColor = true; - // - // tabPageExternalTools - // - tabPageExternalTools.Controls.Add(labelToolsDescription); - tabPageExternalTools.Controls.Add(buttonToolDelete); - tabPageExternalTools.Controls.Add(buttonToolAdd); - tabPageExternalTools.Controls.Add(buttonToolDown); - tabPageExternalTools.Controls.Add(buttonToolUp); - tabPageExternalTools.Controls.Add(listBoxTools); - tabPageExternalTools.Controls.Add(groupBoxToolSettings); - tabPageExternalTools.Location = new System.Drawing.Point(4, 24); - tabPageExternalTools.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPageExternalTools.Name = "tabPageExternalTools"; - tabPageExternalTools.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPageExternalTools.Size = new System.Drawing.Size(942, 440); - tabPageExternalTools.TabIndex = 2; - tabPageExternalTools.Text = "External Tools"; - tabPageExternalTools.UseVisualStyleBackColor = true; - // - // labelToolsDescription - // - labelToolsDescription.Location = new System.Drawing.Point(546, 102); - labelToolsDescription.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelToolsDescription.Name = "labelToolsDescription"; - labelToolsDescription.Size = new System.Drawing.Size(376, 80); - labelToolsDescription.TabIndex = 6; - labelToolsDescription.Text = "You can configure as many tools as you want. \r\nChecked tools will appear in the icon bar. All other tools are available in the tools menu."; - // - // buttonToolDelete - // - buttonToolDelete.Location = new System.Drawing.Point(550, 14); - buttonToolDelete.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonToolDelete.Name = "buttonToolDelete"; - buttonToolDelete.Size = new System.Drawing.Size(112, 35); - buttonToolDelete.TabIndex = 2; - buttonToolDelete.Text = "Remove"; - buttonToolDelete.UseVisualStyleBackColor = true; - buttonToolDelete.Click += OnToolDeleteButtonClick; - // - // buttonToolAdd - // - buttonToolAdd.Location = new System.Drawing.Point(429, 14); - buttonToolAdd.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonToolAdd.Name = "buttonToolAdd"; - buttonToolAdd.Size = new System.Drawing.Size(112, 35); - buttonToolAdd.TabIndex = 1; - buttonToolAdd.Text = "Add new"; - buttonToolAdd.UseVisualStyleBackColor = true; - buttonToolAdd.Click += OnBtnToolAddClick; - // - // buttonToolDown - // - buttonToolDown.Location = new System.Drawing.Point(429, 146); - buttonToolDown.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonToolDown.Name = "buttonToolDown"; - buttonToolDown.Size = new System.Drawing.Size(64, 35); - buttonToolDown.TabIndex = 4; - buttonToolDown.Text = "Down"; - buttonToolDown.UseVisualStyleBackColor = true; - buttonToolDown.Click += OnBtnToolDownClick; - // - // buttonToolUp - // - buttonToolUp.Location = new System.Drawing.Point(429, 102); - buttonToolUp.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonToolUp.Name = "buttonToolUp"; - buttonToolUp.Size = new System.Drawing.Size(64, 35); - buttonToolUp.TabIndex = 3; - buttonToolUp.Text = "Up"; - buttonToolUp.UseVisualStyleBackColor = true; - buttonToolUp.Click += OnBtnToolUpClick; - // - // listBoxTools - // - listBoxTools.FormattingEnabled = true; - listBoxTools.Location = new System.Drawing.Point(10, 14); - listBoxTools.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - listBoxTools.Name = "listBoxTools"; - listBoxTools.Size = new System.Drawing.Size(406, 148); - listBoxTools.TabIndex = 0; - listBoxTools.SelectedIndexChanged += OnListBoxToolSelectedIndexChanged; - // - // groupBoxToolSettings - // - groupBoxToolSettings.Controls.Add(labelWorkingDir); - groupBoxToolSettings.Controls.Add(buttonWorkingDir); - groupBoxToolSettings.Controls.Add(textBoxWorkingDir); - groupBoxToolSettings.Controls.Add(buttonIcon); - groupBoxToolSettings.Controls.Add(labelToolName); - groupBoxToolSettings.Controls.Add(labelToolColumnizerForOutput); - groupBoxToolSettings.Controls.Add(comboBoxColumnizer); - groupBoxToolSettings.Controls.Add(textBoxToolName); - groupBoxToolSettings.Controls.Add(checkBoxSysout); - groupBoxToolSettings.Controls.Add(buttonArguments); - groupBoxToolSettings.Controls.Add(labelTool); - groupBoxToolSettings.Controls.Add(buttonTool); - groupBoxToolSettings.Controls.Add(textBoxTool); - groupBoxToolSettings.Controls.Add(labelArguments); - groupBoxToolSettings.Controls.Add(textBoxArguments); - groupBoxToolSettings.Location = new System.Drawing.Point(10, 191); - groupBoxToolSettings.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxToolSettings.Name = "groupBoxToolSettings"; - groupBoxToolSettings.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxToolSettings.Size = new System.Drawing.Size(912, 228); - groupBoxToolSettings.TabIndex = 0; - groupBoxToolSettings.TabStop = false; - groupBoxToolSettings.Text = "Tool settings"; - // - // labelWorkingDir - // - labelWorkingDir.AutoSize = true; - labelWorkingDir.Location = new System.Drawing.Point(474, 86); - labelWorkingDir.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelWorkingDir.Name = "labelWorkingDir"; - labelWorkingDir.Size = new System.Drawing.Size(72, 15); - labelWorkingDir.TabIndex = 11; - labelWorkingDir.Text = "Working dir:"; - // - // buttonWorkingDir - // - buttonWorkingDir.Location = new System.Drawing.Point(856, 80); - buttonWorkingDir.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonWorkingDir.Name = "buttonWorkingDir"; - buttonWorkingDir.Size = new System.Drawing.Size(45, 31); - buttonWorkingDir.TabIndex = 10; - buttonWorkingDir.Text = "..."; - buttonWorkingDir.UseVisualStyleBackColor = true; - buttonWorkingDir.Click += OnBtnWorkingDirClick; - // - // textBoxWorkingDir - // - textBoxWorkingDir.Location = new System.Drawing.Point(576, 82); - textBoxWorkingDir.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - textBoxWorkingDir.Name = "textBoxWorkingDir"; - textBoxWorkingDir.Size = new System.Drawing.Size(270, 23); - textBoxWorkingDir.TabIndex = 9; - // - // buttonIcon - // - buttonIcon.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; - buttonIcon.Location = new System.Drawing.Point(418, 26); - buttonIcon.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonIcon.Name = "buttonIcon"; - buttonIcon.Size = new System.Drawing.Size(112, 35); - buttonIcon.TabIndex = 1; - buttonIcon.Text = " Icon..."; - buttonIcon.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; - buttonIcon.UseVisualStyleBackColor = true; - buttonIcon.Click += OnBtnIconClick; - // - // labelToolName - // - labelToolName.AutoSize = true; - labelToolName.Location = new System.Drawing.Point(9, 34); - labelToolName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelToolName.Name = "labelToolName"; - labelToolName.Size = new System.Drawing.Size(42, 15); - labelToolName.TabIndex = 8; - labelToolName.Text = "Name:"; - // - // labelToolColumnizerForOutput - // - labelToolColumnizerForOutput.AutoSize = true; - labelToolColumnizerForOutput.Location = new System.Drawing.Point(404, 185); - labelToolColumnizerForOutput.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelToolColumnizerForOutput.Name = "labelToolColumnizerForOutput"; - labelToolColumnizerForOutput.Size = new System.Drawing.Size(128, 15); - labelToolColumnizerForOutput.TabIndex = 6; - labelToolColumnizerForOutput.Text = "Columnizer for output:"; - // - // comboBoxColumnizer - // - comboBoxColumnizer.FormattingEnabled = true; - comboBoxColumnizer.Location = new System.Drawing.Point(576, 180); - comboBoxColumnizer.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - comboBoxColumnizer.Name = "comboBoxColumnizer"; - comboBoxColumnizer.Size = new System.Drawing.Size(270, 23); - comboBoxColumnizer.TabIndex = 7; - // - // textBoxToolName - // - textBoxToolName.Location = new System.Drawing.Point(108, 29); - textBoxToolName.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - textBoxToolName.Name = "textBoxToolName"; - textBoxToolName.Size = new System.Drawing.Size(298, 23); - textBoxToolName.TabIndex = 0; - // - // checkBoxSysout - // - checkBoxSysout.AutoSize = true; - checkBoxSysout.Location = new System.Drawing.Point(108, 183); - checkBoxSysout.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxSysout.Name = "checkBoxSysout"; - checkBoxSysout.Size = new System.Drawing.Size(120, 19); - checkBoxSysout.TabIndex = 6; - checkBoxSysout.Text = "Pipe sysout to tab"; - checkBoxSysout.UseVisualStyleBackColor = true; - checkBoxSysout.CheckedChanged += OnChkBoxSysoutCheckedChanged; - // - // buttonArguments - // - buttonArguments.Location = new System.Drawing.Point(856, 128); - buttonArguments.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonArguments.Name = "buttonArguments"; - buttonArguments.Size = new System.Drawing.Size(46, 32); - buttonArguments.TabIndex = 5; - buttonArguments.Text = "..."; - buttonArguments.UseVisualStyleBackColor = true; - buttonArguments.Click += OnBtnArgClick; - // - // labelTool - // - labelTool.AutoSize = true; - labelTool.Location = new System.Drawing.Point(9, 86); - labelTool.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelTool.Name = "labelTool"; - labelTool.Size = new System.Drawing.Size(56, 15); - labelTool.TabIndex = 4; - labelTool.Text = "Program:"; - // - // buttonTool - // - buttonTool.Location = new System.Drawing.Point(418, 78); - buttonTool.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonTool.Name = "buttonTool"; - buttonTool.Size = new System.Drawing.Size(45, 31); - buttonTool.TabIndex = 3; - buttonTool.Text = "..."; - buttonTool.UseVisualStyleBackColor = true; - buttonTool.Click += OnBtnToolClick; - // - // textBoxTool - // - textBoxTool.Location = new System.Drawing.Point(108, 80); - textBoxTool.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - textBoxTool.Name = "textBoxTool"; - textBoxTool.Size = new System.Drawing.Size(298, 23); - textBoxTool.TabIndex = 2; - // - // labelArguments - // - labelArguments.AutoSize = true; - labelArguments.Location = new System.Drawing.Point(9, 134); - labelArguments.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelArguments.Name = "labelArguments"; - labelArguments.Size = new System.Drawing.Size(69, 15); - labelArguments.TabIndex = 1; - labelArguments.Text = "Arguments:"; - // - // textBoxArguments - // - textBoxArguments.Location = new System.Drawing.Point(108, 129); - textBoxArguments.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - textBoxArguments.Name = "textBoxArguments"; - textBoxArguments.Size = new System.Drawing.Size(738, 23); - textBoxArguments.TabIndex = 4; - // - // tabPageColumnizers - // - tabPageColumnizers.Controls.Add(checkBoxAutoPick); - tabPageColumnizers.Controls.Add(checkBoxMaskPrio); - tabPageColumnizers.Controls.Add(buttonDelete); - tabPageColumnizers.Controls.Add(dataGridViewColumnizer); - tabPageColumnizers.Location = new System.Drawing.Point(4, 24); - tabPageColumnizers.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPageColumnizers.Name = "tabPageColumnizers"; - tabPageColumnizers.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPageColumnizers.Size = new System.Drawing.Size(942, 440); - tabPageColumnizers.TabIndex = 3; - tabPageColumnizers.Text = "Columnizers"; - tabPageColumnizers.UseVisualStyleBackColor = true; - // - // checkBoxAutoPick - // - checkBoxAutoPick.AutoSize = true; - checkBoxAutoPick.Checked = true; - checkBoxAutoPick.CheckState = System.Windows.Forms.CheckState.Checked; - checkBoxAutoPick.Location = new System.Drawing.Point(530, 386); - checkBoxAutoPick.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxAutoPick.Name = "checkBoxAutoPick"; - checkBoxAutoPick.Size = new System.Drawing.Size(192, 19); - checkBoxAutoPick.TabIndex = 5; - checkBoxAutoPick.Text = "Automatically pick for new files"; - checkBoxAutoPick.UseVisualStyleBackColor = true; - // - // checkBoxMaskPrio - // - checkBoxMaskPrio.AutoSize = true; - checkBoxMaskPrio.Location = new System.Drawing.Point(213, 388); - checkBoxMaskPrio.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxMaskPrio.Name = "checkBoxMaskPrio"; - checkBoxMaskPrio.Size = new System.Drawing.Size(192, 19); - checkBoxMaskPrio.TabIndex = 4; - checkBoxMaskPrio.Text = "Mask has priority before history"; - checkBoxMaskPrio.UseVisualStyleBackColor = true; - // - // buttonDelete - // - buttonDelete.Location = new System.Drawing.Point(12, 380); - buttonDelete.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonDelete.Name = "buttonDelete"; - buttonDelete.Size = new System.Drawing.Size(112, 35); - buttonDelete.TabIndex = 3; - buttonDelete.Text = "Delete"; - buttonDelete.UseVisualStyleBackColor = true; - buttonDelete.Click += OnBtnDeleteClick; - // - // dataGridViewColumnizer - // - dataGridViewColumnizer.AllowUserToResizeRows = false; - dataGridViewColumnizer.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; - dataGridViewColumnizer.BackgroundColor = System.Drawing.SystemColors.ControlLight; - dataGridViewColumnizer.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridViewColumnizer.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { columnFileMask, columnColumnizer }); - dataGridViewColumnizer.Dock = System.Windows.Forms.DockStyle.Top; - dataGridViewColumnizer.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter; - dataGridViewColumnizer.Location = new System.Drawing.Point(4, 5); - dataGridViewColumnizer.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - dataGridViewColumnizer.Name = "dataGridViewColumnizer"; - dataGridViewColumnizer.RowHeadersWidth = 62; - dataGridViewColumnizer.Size = new System.Drawing.Size(934, 365); - dataGridViewColumnizer.TabIndex = 2; - dataGridViewColumnizer.RowsAdded += OnDataGridViewColumnizerRowsAdded; - // - // columnFileMask - // - columnFileMask.HeaderText = "File name mask (RegEx)"; - columnFileMask.MinimumWidth = 40; - columnFileMask.Name = "columnFileMask"; - // - // columnColumnizer - // - columnColumnizer.HeaderText = "Columnizer"; - columnColumnizer.MinimumWidth = 230; - columnColumnizer.Name = "columnColumnizer"; - // - // tabPageHighlightMask - // - tabPageHighlightMask.Controls.Add(dataGridViewHighlightMask); - tabPageHighlightMask.Location = new System.Drawing.Point(4, 24); - tabPageHighlightMask.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPageHighlightMask.Name = "tabPageHighlightMask"; - tabPageHighlightMask.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPageHighlightMask.Size = new System.Drawing.Size(942, 440); - tabPageHighlightMask.TabIndex = 8; - tabPageHighlightMask.Text = "Highlight"; - tabPageHighlightMask.UseVisualStyleBackColor = true; - // - // dataGridViewHighlightMask - // - dataGridViewHighlightMask.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; - dataGridViewHighlightMask.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridViewHighlightMask.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { columnFileName, columnHighlightGroup }); - dataGridViewHighlightMask.Dock = System.Windows.Forms.DockStyle.Fill; - dataGridViewHighlightMask.Location = new System.Drawing.Point(4, 5); - dataGridViewHighlightMask.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - dataGridViewHighlightMask.Name = "dataGridViewHighlightMask"; - dataGridViewHighlightMask.RowHeadersWidth = 62; - dataGridViewHighlightMask.Size = new System.Drawing.Size(934, 430); - dataGridViewHighlightMask.TabIndex = 0; - // - // columnFileName - // - columnFileName.HeaderText = "File name mask (RegEx)"; - columnFileName.MinimumWidth = 40; - columnFileName.Name = "columnFileName"; - // - // columnHighlightGroup - // - columnHighlightGroup.HeaderText = "Highlight group"; - columnHighlightGroup.MinimumWidth = 50; - columnHighlightGroup.Name = "columnHighlightGroup"; - // - // tabPageMultiFile - // - tabPageMultiFile.Controls.Add(groupBoxDefaultFileNamePattern); - tabPageMultiFile.Controls.Add(labelHintMultiFile); - tabPageMultiFile.Controls.Add(labelNoteMultiFile); - tabPageMultiFile.Controls.Add(groupBoxWhenOpeningMultiFile); - tabPageMultiFile.Location = new System.Drawing.Point(4, 24); - tabPageMultiFile.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPageMultiFile.Name = "tabPageMultiFile"; - tabPageMultiFile.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPageMultiFile.Size = new System.Drawing.Size(942, 440); - tabPageMultiFile.TabIndex = 4; - tabPageMultiFile.Text = "MultiFile"; - tabPageMultiFile.UseVisualStyleBackColor = true; - // - // groupBoxDefaultFileNamePattern - // - groupBoxDefaultFileNamePattern.Controls.Add(labelMaxDays); - groupBoxDefaultFileNamePattern.Controls.Add(labelPattern); - groupBoxDefaultFileNamePattern.Controls.Add(upDownMultifileDays); - groupBoxDefaultFileNamePattern.Controls.Add(textBoxMultifilePattern); - groupBoxDefaultFileNamePattern.Location = new System.Drawing.Point(364, 28); - groupBoxDefaultFileNamePattern.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxDefaultFileNamePattern.Name = "groupBoxDefaultFileNamePattern"; - groupBoxDefaultFileNamePattern.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxDefaultFileNamePattern.Size = new System.Drawing.Size(436, 154); - groupBoxDefaultFileNamePattern.TabIndex = 3; - groupBoxDefaultFileNamePattern.TabStop = false; - groupBoxDefaultFileNamePattern.Text = "Default filename pattern"; - // - // labelMaxDays - // - labelMaxDays.AutoSize = true; - labelMaxDays.Location = new System.Drawing.Point(10, 75); - labelMaxDays.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelMaxDays.Name = "labelMaxDays"; - labelMaxDays.Size = new System.Drawing.Size(59, 15); - labelMaxDays.TabIndex = 3; - labelMaxDays.Text = "Max days:"; - // - // labelPattern - // - labelPattern.AutoSize = true; - labelPattern.Location = new System.Drawing.Point(10, 37); - labelPattern.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelPattern.Name = "labelPattern"; - labelPattern.Size = new System.Drawing.Size(48, 15); - labelPattern.TabIndex = 2; - labelPattern.Text = "Pattern:"; - // - // upDownMultifileDays - // - upDownMultifileDays.Location = new System.Drawing.Point(102, 72); - upDownMultifileDays.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - upDownMultifileDays.Maximum = new decimal(new int[] { 40, 0, 0, 0 }); - upDownMultifileDays.Name = "upDownMultifileDays"; - helpProvider.SetShowHelp(upDownMultifileDays, false); - upDownMultifileDays.Size = new System.Drawing.Size(92, 23); - upDownMultifileDays.TabIndex = 1; - upDownMultifileDays.Value = new decimal(new int[] { 1, 0, 0, 0 }); - // - // textBoxMultifilePattern - // - textBoxMultifilePattern.Location = new System.Drawing.Point(102, 32); - textBoxMultifilePattern.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - textBoxMultifilePattern.Name = "textBoxMultifilePattern"; - textBoxMultifilePattern.Size = new System.Drawing.Size(278, 23); - textBoxMultifilePattern.TabIndex = 0; - textBoxMultifilePattern.TextChanged += OnMultiFilePatternTextChanged; - // - // labelHintMultiFile - // - labelHintMultiFile.Location = new System.Drawing.Point(6, 203); - labelHintMultiFile.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelHintMultiFile.Name = "labelHintMultiFile"; - labelHintMultiFile.Size = new System.Drawing.Size(304, 111); - labelHintMultiFile.TabIndex = 2; - labelHintMultiFile.Text = "Hint: Pressing the Shift key while dropping files onto LogExpert will switch the behaviour from single to multi and vice versa."; - // - // labelNoteMultiFile - // - labelNoteMultiFile.Location = new System.Drawing.Point(6, 314); - labelNoteMultiFile.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelNoteMultiFile.Name = "labelNoteMultiFile"; - labelNoteMultiFile.Size = new System.Drawing.Size(705, 82); - labelNoteMultiFile.TabIndex = 1; - labelNoteMultiFile.Text = resources.GetString("labelNoteMultiFile.Text"); - // - // groupBoxWhenOpeningMultiFile - // - groupBoxWhenOpeningMultiFile.Controls.Add(radioButtonAskWhatToDo); - groupBoxWhenOpeningMultiFile.Controls.Add(radioButtonTreatAllFilesAsOneMultifile); - groupBoxWhenOpeningMultiFile.Controls.Add(radioButtonLoadEveryFileIntoSeperatedTab); - groupBoxWhenOpeningMultiFile.Location = new System.Drawing.Point(10, 28); - groupBoxWhenOpeningMultiFile.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxWhenOpeningMultiFile.Name = "groupBoxWhenOpeningMultiFile"; - groupBoxWhenOpeningMultiFile.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxWhenOpeningMultiFile.Size = new System.Drawing.Size(300, 154); - groupBoxWhenOpeningMultiFile.TabIndex = 0; - groupBoxWhenOpeningMultiFile.TabStop = false; - groupBoxWhenOpeningMultiFile.Text = "When opening multiple files..."; - // - // radioButtonAskWhatToDo - // - radioButtonAskWhatToDo.AutoSize = true; - radioButtonAskWhatToDo.Location = new System.Drawing.Point(10, 105); - radioButtonAskWhatToDo.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - radioButtonAskWhatToDo.Name = "radioButtonAskWhatToDo"; - radioButtonAskWhatToDo.Size = new System.Drawing.Size(104, 19); - radioButtonAskWhatToDo.TabIndex = 2; - radioButtonAskWhatToDo.TabStop = true; - radioButtonAskWhatToDo.Text = "Ask what to do"; - radioButtonAskWhatToDo.UseVisualStyleBackColor = true; - // - // radioButtonTreatAllFilesAsOneMultifile - // - radioButtonTreatAllFilesAsOneMultifile.AutoSize = true; - radioButtonTreatAllFilesAsOneMultifile.Location = new System.Drawing.Point(10, 68); - radioButtonTreatAllFilesAsOneMultifile.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - radioButtonTreatAllFilesAsOneMultifile.Name = "radioButtonTreatAllFilesAsOneMultifile"; - radioButtonTreatAllFilesAsOneMultifile.Size = new System.Drawing.Size(182, 19); - radioButtonTreatAllFilesAsOneMultifile.TabIndex = 1; - radioButtonTreatAllFilesAsOneMultifile.TabStop = true; - radioButtonTreatAllFilesAsOneMultifile.Text = "Treat all files as one 'MultiFile'"; - radioButtonTreatAllFilesAsOneMultifile.UseVisualStyleBackColor = true; - // - // radioButtonLoadEveryFileIntoSeperatedTab - // - radioButtonLoadEveryFileIntoSeperatedTab.AutoSize = true; - radioButtonLoadEveryFileIntoSeperatedTab.Location = new System.Drawing.Point(10, 31); - radioButtonLoadEveryFileIntoSeperatedTab.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - radioButtonLoadEveryFileIntoSeperatedTab.Name = "radioButtonLoadEveryFileIntoSeperatedTab"; - radioButtonLoadEveryFileIntoSeperatedTab.Size = new System.Drawing.Size(201, 19); - radioButtonLoadEveryFileIntoSeperatedTab.TabIndex = 0; - radioButtonLoadEveryFileIntoSeperatedTab.TabStop = true; - radioButtonLoadEveryFileIntoSeperatedTab.Text = "Load every file into a separate tab"; - radioButtonLoadEveryFileIntoSeperatedTab.UseVisualStyleBackColor = true; - // - // tabPagePlugins - // - tabPagePlugins.Controls.Add(groupBoxPlugins); - tabPagePlugins.Controls.Add(groupBoxSettings); - tabPagePlugins.Location = new System.Drawing.Point(4, 24); - tabPagePlugins.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPagePlugins.Name = "tabPagePlugins"; - tabPagePlugins.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPagePlugins.Size = new System.Drawing.Size(942, 440); - tabPagePlugins.TabIndex = 5; - tabPagePlugins.Text = "Plugins"; - tabPagePlugins.UseVisualStyleBackColor = true; - // - // groupBoxPlugins - // - groupBoxPlugins.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - groupBoxPlugins.Controls.Add(listBoxPlugin); - groupBoxPlugins.Location = new System.Drawing.Point(10, 23); - groupBoxPlugins.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxPlugins.Name = "groupBoxPlugins"; - groupBoxPlugins.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxPlugins.Size = new System.Drawing.Size(342, 400); - groupBoxPlugins.TabIndex = 3; - groupBoxPlugins.TabStop = false; - groupBoxPlugins.Text = "Plugins"; - // - // listBoxPlugin - // - listBoxPlugin.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - listBoxPlugin.DisplayMember = "Text"; - listBoxPlugin.FormattingEnabled = true; - listBoxPlugin.ItemHeight = 15; - listBoxPlugin.Location = new System.Drawing.Point(9, 29); - listBoxPlugin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - listBoxPlugin.Name = "listBoxPlugin"; - listBoxPlugin.Size = new System.Drawing.Size(322, 349); - listBoxPlugin.TabIndex = 0; - listBoxPlugin.ValueMember = "Text"; - listBoxPlugin.SelectedIndexChanged += OnListBoxPluginSelectedIndexChanged; - // - // groupBoxSettings - // - groupBoxSettings.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - groupBoxSettings.Controls.Add(panelPlugin); - groupBoxSettings.Location = new System.Drawing.Point(362, 23); - groupBoxSettings.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxSettings.Name = "groupBoxSettings"; - groupBoxSettings.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxSettings.Size = new System.Drawing.Size(567, 400); - groupBoxSettings.TabIndex = 2; - groupBoxSettings.TabStop = false; - groupBoxSettings.Text = "Settings"; - // - // panelPlugin - // - panelPlugin.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - panelPlugin.AutoScroll = true; - panelPlugin.Controls.Add(buttonConfigPlugin); - panelPlugin.Location = new System.Drawing.Point(9, 29); - panelPlugin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - panelPlugin.Name = "panelPlugin"; - panelPlugin.Size = new System.Drawing.Size(549, 362); - panelPlugin.TabIndex = 1; - // - // buttonConfigPlugin - // - buttonConfigPlugin.Location = new System.Drawing.Point(164, 163); - buttonConfigPlugin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonConfigPlugin.Name = "buttonConfigPlugin"; - buttonConfigPlugin.Size = new System.Drawing.Size(170, 35); - buttonConfigPlugin.TabIndex = 0; - buttonConfigPlugin.Text = "Configure..."; - buttonConfigPlugin.UseVisualStyleBackColor = true; - buttonConfigPlugin.Click += OnBtnConfigPluginClick; - // - // tabPageSessions - // - tabPageSessions.Controls.Add(checkBoxPortableMode); - tabPageSessions.Controls.Add(checkBoxSaveFilter); - tabPageSessions.Controls.Add(groupBoxPersistantFileLocation); - tabPageSessions.Controls.Add(checkBoxSaveSessions); - tabPageSessions.Location = new System.Drawing.Point(4, 24); - tabPageSessions.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPageSessions.Name = "tabPageSessions"; - tabPageSessions.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPageSessions.Size = new System.Drawing.Size(942, 440); - tabPageSessions.TabIndex = 6; - tabPageSessions.Text = "Persistence"; - tabPageSessions.UseVisualStyleBackColor = true; - // - // checkBoxPortableMode - // - checkBoxPortableMode.AutoSize = true; - checkBoxPortableMode.Location = new System.Drawing.Point(35, 110); - checkBoxPortableMode.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxPortableMode.Name = "checkBoxPortableMode"; - checkBoxPortableMode.Size = new System.Drawing.Size(150, 19); - checkBoxPortableMode.TabIndex = 3; - checkBoxPortableMode.Text = "Activate Portable Mode"; - toolTip.SetToolTip(checkBoxPortableMode, "If this mode is activated, the save file will be loaded from the Executable Location"); - checkBoxPortableMode.UseVisualStyleBackColor = true; - checkBoxPortableMode.CheckedChanged += OnPortableModeCheckedChanged; - // - // checkBoxSaveFilter - // - checkBoxSaveFilter.AutoSize = true; - checkBoxSaveFilter.Location = new System.Drawing.Point(35, 75); - checkBoxSaveFilter.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxSaveFilter.Name = "checkBoxSaveFilter"; - checkBoxSaveFilter.Size = new System.Drawing.Size(217, 19); - checkBoxSaveFilter.TabIndex = 2; - checkBoxSaveFilter.Text = " Save and restore filter and filter tabs"; - checkBoxSaveFilter.UseVisualStyleBackColor = true; - // - // groupBoxPersistantFileLocation - // - groupBoxPersistantFileLocation.Controls.Add(labelSessionSaveOwnDir); - groupBoxPersistantFileLocation.Controls.Add(buttonSessionSaveDir); - groupBoxPersistantFileLocation.Controls.Add(radioButtonSessionSaveOwn); - groupBoxPersistantFileLocation.Controls.Add(radioButtonsessionSaveDocuments); - groupBoxPersistantFileLocation.Controls.Add(radioButtonSessionSameDir); - groupBoxPersistantFileLocation.Controls.Add(radioButtonSessionApplicationStartupDir); - groupBoxPersistantFileLocation.Location = new System.Drawing.Point(34, 145); - groupBoxPersistantFileLocation.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxPersistantFileLocation.Name = "groupBoxPersistantFileLocation"; - groupBoxPersistantFileLocation.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxPersistantFileLocation.Size = new System.Drawing.Size(411, 190); - groupBoxPersistantFileLocation.TabIndex = 1; - groupBoxPersistantFileLocation.TabStop = false; - groupBoxPersistantFileLocation.Text = "Persistence file location"; - // - // labelSessionSaveOwnDir - // - labelSessionSaveOwnDir.Location = new System.Drawing.Point(27, 160); - labelSessionSaveOwnDir.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelSessionSaveOwnDir.Name = "labelSessionSaveOwnDir"; - labelSessionSaveOwnDir.Size = new System.Drawing.Size(252, 31); - labelSessionSaveOwnDir.TabIndex = 4; - labelSessionSaveOwnDir.Text = "sessionSaveOwnDirLabel"; - // - // buttonSessionSaveDir - // - buttonSessionSaveDir.Location = new System.Drawing.Point(358, 135); - buttonSessionSaveDir.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonSessionSaveDir.Name = "buttonSessionSaveDir"; - buttonSessionSaveDir.Size = new System.Drawing.Size(45, 19); - buttonSessionSaveDir.TabIndex = 3; - buttonSessionSaveDir.Text = "..."; - buttonSessionSaveDir.UseVisualStyleBackColor = true; - buttonSessionSaveDir.Click += OnBtnSessionSaveDirClick; - // - // radioButtonSessionSaveOwn - // - radioButtonSessionSaveOwn.AutoSize = true; - radioButtonSessionSaveOwn.Location = new System.Drawing.Point(10, 135); - radioButtonSessionSaveOwn.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - radioButtonSessionSaveOwn.Name = "radioButtonSessionSaveOwn"; - radioButtonSessionSaveOwn.Size = new System.Drawing.Size(100, 19); - radioButtonSessionSaveOwn.TabIndex = 2; - radioButtonSessionSaveOwn.TabStop = true; - radioButtonSessionSaveOwn.Text = "Own directory"; - radioButtonSessionSaveOwn.UseVisualStyleBackColor = true; - // - // radioButtonsessionSaveDocuments - // - radioButtonsessionSaveDocuments.AutoSize = true; - radioButtonsessionSaveDocuments.Location = new System.Drawing.Point(10, 65); - radioButtonsessionSaveDocuments.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - radioButtonsessionSaveDocuments.Name = "radioButtonsessionSaveDocuments"; - radioButtonsessionSaveDocuments.Size = new System.Drawing.Size(160, 19); - radioButtonsessionSaveDocuments.TabIndex = 1; - radioButtonsessionSaveDocuments.TabStop = true; - radioButtonsessionSaveDocuments.Text = "MyDocuments/LogExpert"; - radioButtonsessionSaveDocuments.UseVisualStyleBackColor = true; - // - // radioButtonSessionSameDir - // - radioButtonSessionSameDir.AutoSize = true; - radioButtonSessionSameDir.Location = new System.Drawing.Point(10, 30); - radioButtonSessionSameDir.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - radioButtonSessionSameDir.Name = "radioButtonSessionSameDir"; - radioButtonSessionSameDir.Size = new System.Drawing.Size(157, 19); - radioButtonSessionSameDir.TabIndex = 0; - radioButtonSessionSameDir.TabStop = true; - radioButtonSessionSameDir.Text = "Same directory as log file"; - radioButtonSessionSameDir.UseVisualStyleBackColor = true; - // - // radioButtonSessionApplicationStartupDir - // - radioButtonSessionApplicationStartupDir.AutoSize = true; - radioButtonSessionApplicationStartupDir.Location = new System.Drawing.Point(10, 100); - radioButtonSessionApplicationStartupDir.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - radioButtonSessionApplicationStartupDir.Name = "radioButtonSessionApplicationStartupDir"; - radioButtonSessionApplicationStartupDir.Size = new System.Drawing.Size(176, 19); - radioButtonSessionApplicationStartupDir.TabIndex = 5; - radioButtonSessionApplicationStartupDir.TabStop = true; - radioButtonSessionApplicationStartupDir.Text = "Application startup directory"; - toolTip.SetToolTip(radioButtonSessionApplicationStartupDir, "This path is based on the executable and where it has been started from."); - radioButtonSessionApplicationStartupDir.UseVisualStyleBackColor = true; - // - // checkBoxSaveSessions - // - checkBoxSaveSessions.AutoSize = true; - checkBoxSaveSessions.Location = new System.Drawing.Point(35, 40); - checkBoxSaveSessions.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxSaveSessions.Name = "checkBoxSaveSessions"; - checkBoxSaveSessions.Size = new System.Drawing.Size(241, 19); - checkBoxSaveSessions.TabIndex = 0; - checkBoxSaveSessions.Text = "Automatically save persistence files (.lxp)"; - checkBoxSaveSessions.UseVisualStyleBackColor = true; - // - // tabPageMemory - // - tabPageMemory.Controls.Add(groupBoxCPUAndStuff); - tabPageMemory.Controls.Add(groupBoxLineBufferUsage); - tabPageMemory.Location = new System.Drawing.Point(4, 24); - tabPageMemory.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPageMemory.Name = "tabPageMemory"; - tabPageMemory.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - tabPageMemory.Size = new System.Drawing.Size(942, 440); - tabPageMemory.TabIndex = 7; - tabPageMemory.Text = "Memory/CPU"; - tabPageMemory.UseVisualStyleBackColor = true; - // - // groupBoxCPUAndStuff - // - groupBoxCPUAndStuff.Controls.Add(checkBoxLegacyReader); - groupBoxCPUAndStuff.Controls.Add(checkBoxMultiThread); - groupBoxCPUAndStuff.Controls.Add(labelFilePollingInterval); - groupBoxCPUAndStuff.Controls.Add(upDownPollingInterval); - groupBoxCPUAndStuff.Location = new System.Drawing.Point(408, 29); - groupBoxCPUAndStuff.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxCPUAndStuff.Name = "groupBoxCPUAndStuff"; - groupBoxCPUAndStuff.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxCPUAndStuff.Size = new System.Drawing.Size(300, 197); - groupBoxCPUAndStuff.TabIndex = 8; - groupBoxCPUAndStuff.TabStop = false; - groupBoxCPUAndStuff.Text = "CPU and stuff"; - // - // checkBoxLegacyReader - // - checkBoxLegacyReader.AutoSize = true; - checkBoxLegacyReader.Location = new System.Drawing.Point(14, 138); - checkBoxLegacyReader.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxLegacyReader.Name = "checkBoxLegacyReader"; - checkBoxLegacyReader.Size = new System.Drawing.Size(182, 19); - checkBoxLegacyReader.TabIndex = 9; - checkBoxLegacyReader.Text = "Use legacy file reader (slower)"; - toolTip.SetToolTip(checkBoxLegacyReader, "Slower but more compatible with strange linefeeds and encodings"); - checkBoxLegacyReader.UseVisualStyleBackColor = true; - // - // checkBoxMultiThread - // - checkBoxMultiThread.AutoSize = true; - checkBoxMultiThread.Location = new System.Drawing.Point(14, 103); - checkBoxMultiThread.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - checkBoxMultiThread.Name = "checkBoxMultiThread"; - checkBoxMultiThread.Size = new System.Drawing.Size(131, 19); - checkBoxMultiThread.TabIndex = 5; - checkBoxMultiThread.Text = "Multi threaded filter"; - checkBoxMultiThread.UseVisualStyleBackColor = true; - // - // labelFilePollingInterval - // - labelFilePollingInterval.AutoSize = true; - labelFilePollingInterval.Location = new System.Drawing.Point(9, 52); - labelFilePollingInterval.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelFilePollingInterval.Name = "labelFilePollingInterval"; - labelFilePollingInterval.Size = new System.Drawing.Size(137, 15); - labelFilePollingInterval.TabIndex = 7; - labelFilePollingInterval.Text = "File polling interval (ms):"; - // - // upDownPollingInterval - // - upDownPollingInterval.Location = new System.Drawing.Point(190, 49); - upDownPollingInterval.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - upDownPollingInterval.Maximum = new decimal(new int[] { 5000, 0, 0, 0 }); - upDownPollingInterval.Minimum = new decimal(new int[] { 20, 0, 0, 0 }); - upDownPollingInterval.Name = "upDownPollingInterval"; - upDownPollingInterval.Size = new System.Drawing.Size(86, 23); - upDownPollingInterval.TabIndex = 6; - upDownPollingInterval.Value = new decimal(new int[] { 20, 0, 0, 0 }); - // - // groupBoxLineBufferUsage - // - groupBoxLineBufferUsage.Controls.Add(labelInfo); - groupBoxLineBufferUsage.Controls.Add(labelNumberOfBlocks); - groupBoxLineBufferUsage.Controls.Add(upDownLinesPerBlock); - groupBoxLineBufferUsage.Controls.Add(upDownBlockCount); - groupBoxLineBufferUsage.Controls.Add(labelLinesPerBlock); - groupBoxLineBufferUsage.Location = new System.Drawing.Point(10, 29); - groupBoxLineBufferUsage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxLineBufferUsage.Name = "groupBoxLineBufferUsage"; - groupBoxLineBufferUsage.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - groupBoxLineBufferUsage.Size = new System.Drawing.Size(326, 197); - groupBoxLineBufferUsage.TabIndex = 4; - groupBoxLineBufferUsage.TabStop = false; - groupBoxLineBufferUsage.Text = "Line buffer usage"; - // - // labelInfo - // - labelInfo.AutoSize = true; - labelInfo.Location = new System.Drawing.Point(9, 145); - labelInfo.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelInfo.Name = "labelInfo"; - labelInfo.Size = new System.Drawing.Size(219, 15); - labelInfo.TabIndex = 4; - labelInfo.Text = "Changes will take effect on next file load"; - // - // labelNumberOfBlocks - // - labelNumberOfBlocks.AutoSize = true; - labelNumberOfBlocks.Location = new System.Drawing.Point(9, 52); - labelNumberOfBlocks.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelNumberOfBlocks.Name = "labelNumberOfBlocks"; - labelNumberOfBlocks.Size = new System.Drawing.Size(102, 15); - labelNumberOfBlocks.TabIndex = 1; - labelNumberOfBlocks.Text = "Number of blocks"; - // - // upDownLinesPerBlock - // - upDownLinesPerBlock.Location = new System.Drawing.Point(210, 102); - upDownLinesPerBlock.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - upDownLinesPerBlock.Maximum = new decimal(new int[] { 5000000, 0, 0, 0 }); - upDownLinesPerBlock.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); - upDownLinesPerBlock.Name = "upDownLinesPerBlock"; - upDownLinesPerBlock.Size = new System.Drawing.Size(94, 23); - upDownLinesPerBlock.TabIndex = 3; - upDownLinesPerBlock.Value = new decimal(new int[] { 50000, 0, 0, 0 }); - upDownLinesPerBlock.ValueChanged += OnNumericUpDown1ValueChanged; - // - // upDownBlockCount - // - upDownBlockCount.Location = new System.Drawing.Point(210, 49); - upDownBlockCount.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - upDownBlockCount.Maximum = new decimal(new int[] { 5000, 0, 0, 0 }); - upDownBlockCount.Minimum = new decimal(new int[] { 10, 0, 0, 0 }); - upDownBlockCount.Name = "upDownBlockCount"; - upDownBlockCount.Size = new System.Drawing.Size(94, 23); - upDownBlockCount.TabIndex = 0; - upDownBlockCount.Value = new decimal(new int[] { 100, 0, 0, 0 }); - // - // labelLinesPerBlock - // - labelLinesPerBlock.AutoSize = true; - labelLinesPerBlock.Location = new System.Drawing.Point(9, 105); - labelLinesPerBlock.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - labelLinesPerBlock.Name = "labelLinesPerBlock"; - labelLinesPerBlock.Size = new System.Drawing.Size(68, 15); - labelLinesPerBlock.TabIndex = 2; - labelLinesPerBlock.Text = "Lines/block"; - // - // buttonCancel - // - buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - buttonCancel.Location = new System.Drawing.Point(818, 509); - buttonCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new System.Drawing.Size(112, 35); - buttonCancel.TabIndex = 1; - buttonCancel.Text = "Cancel"; - buttonCancel.UseVisualStyleBackColor = true; - buttonCancel.Click += OnBtnCancelClick; - // - // buttonOk - // - buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - buttonOk.Location = new System.Drawing.Point(696, 509); - buttonOk.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonOk.Name = "buttonOk"; - buttonOk.Size = new System.Drawing.Size(112, 35); - buttonOk.TabIndex = 0; - buttonOk.Text = "OK"; - buttonOk.UseVisualStyleBackColor = true; - buttonOk.Click += OnBtnOkClick; - // - // helpProvider - // - helpProvider.HelpNamespace = "LogExpert.chm"; - // - // buttonExport - // - buttonExport.Location = new System.Drawing.Point(20, 509); - buttonExport.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonExport.Name = "buttonExport"; - buttonExport.Size = new System.Drawing.Size(112, 35); - buttonExport.TabIndex = 2; - buttonExport.Text = "Export..."; - buttonExport.UseVisualStyleBackColor = true; - buttonExport.Click += OnBtnExportClick; - // - // buttonImport - // - buttonImport.Location = new System.Drawing.Point(142, 509); - buttonImport.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - buttonImport.Name = "buttonImport"; - buttonImport.Size = new System.Drawing.Size(112, 35); - buttonImport.TabIndex = 3; - buttonImport.Text = "Import..."; - buttonImport.UseVisualStyleBackColor = true; - buttonImport.Click += OnBtnImportClick; - // - // dataGridViewTextBoxColumn1 - // - dataGridViewTextBoxColumn1.HeaderText = "File name mask (RegEx)"; - dataGridViewTextBoxColumn1.MinimumWidth = 40; - dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; - dataGridViewTextBoxColumn1.Width = 99; - // - // dataGridViewTextBoxColumn2 - // - dataGridViewTextBoxColumn2.HeaderText = "File name mask (RegEx)"; - dataGridViewTextBoxColumn2.MinimumWidth = 40; - dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2"; - dataGridViewTextBoxColumn2.Width = 259; - // - // SettingsDialog - // - AcceptButton = buttonOk; - CancelButton = buttonCancel; - ClientSize = new System.Drawing.Size(956, 563); - Controls.Add(buttonImport); - Controls.Add(buttonExport); - Controls.Add(buttonOk); - Controls.Add(buttonCancel); - Controls.Add(tabControlSettings); - FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - helpProvider.SetHelpKeyword(this, "Settings.htm"); - helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); - Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon"); - Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - MaximizeBox = false; - MinimizeBox = false; - Name = "SettingsDialog"; - helpProvider.SetShowHelp(this, true); - StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - Text = "Settings"; - Load += OnSettingsDialogLoad; - tabControlSettings.ResumeLayout(false); - tabPageViewSettings.ResumeLayout(false); - tabPageViewSettings.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)upDownMaximumLineLength).EndInit(); - ((System.ComponentModel.ISupportInitialize)upDownMaximumFilterEntriesDisplayed).EndInit(); - ((System.ComponentModel.ISupportInitialize)upDownMaximumFilterEntries).EndInit(); - groupBoxMisc.ResumeLayout(false); - groupBoxMisc.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)cpDownColumnWidth).EndInit(); - groupBoxDefaults.ResumeLayout(false); - groupBoxDefaults.PerformLayout(); - groupBoxFont.ResumeLayout(false); - tabPageTimeStampFeatures.ResumeLayout(false); - groupBoxTimeSpreadDisplay.ResumeLayout(false); - groupBoxTimeSpreadDisplay.PerformLayout(); - groupBoxDisplayMode.ResumeLayout(false); - groupBoxDisplayMode.PerformLayout(); - groupBoxTimeStampNavigationControl.ResumeLayout(false); - groupBoxTimeStampNavigationControl.PerformLayout(); - groupBoxMouseDragDefaults.ResumeLayout(false); - groupBoxMouseDragDefaults.PerformLayout(); - tabPageExternalTools.ResumeLayout(false); - groupBoxToolSettings.ResumeLayout(false); - groupBoxToolSettings.PerformLayout(); - tabPageColumnizers.ResumeLayout(false); - tabPageColumnizers.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridViewColumnizer).EndInit(); - tabPageHighlightMask.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)dataGridViewHighlightMask).EndInit(); - tabPageMultiFile.ResumeLayout(false); - groupBoxDefaultFileNamePattern.ResumeLayout(false); - groupBoxDefaultFileNamePattern.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)upDownMultifileDays).EndInit(); - groupBoxWhenOpeningMultiFile.ResumeLayout(false); - groupBoxWhenOpeningMultiFile.PerformLayout(); - tabPagePlugins.ResumeLayout(false); - groupBoxPlugins.ResumeLayout(false); - groupBoxSettings.ResumeLayout(false); - panelPlugin.ResumeLayout(false); - tabPageSessions.ResumeLayout(false); - tabPageSessions.PerformLayout(); - groupBoxPersistantFileLocation.ResumeLayout(false); - groupBoxPersistantFileLocation.PerformLayout(); - tabPageMemory.ResumeLayout(false); - groupBoxCPUAndStuff.ResumeLayout(false); - groupBoxCPUAndStuff.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)upDownPollingInterval).EndInit(); - groupBoxLineBufferUsage.ResumeLayout(false); - groupBoxLineBufferUsage.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)upDownLinesPerBlock).EndInit(); - ((System.ComponentModel.ISupportInitialize)upDownBlockCount).EndInit(); - ResumeLayout(false); - } - - #endregion - - private System.Windows.Forms.TabControl tabControlSettings; - private System.Windows.Forms.TabPage tabPageViewSettings; - private System.Windows.Forms.Label labelFont; - private System.Windows.Forms.TabPage tabPageTimeStampFeatures; - private System.Windows.Forms.GroupBox groupBoxFont; - private System.Windows.Forms.Button buttonChangeFont; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.CheckBox checkBoxFilterTail; - private System.Windows.Forms.CheckBox checkBoxFollowTail; - private System.Windows.Forms.CheckBox checkBoxSyncFilter; - private System.Windows.Forms.GroupBox groupBoxDefaults; - private System.Windows.Forms.CheckBox checkBoxTimestamp; - private System.Windows.Forms.GroupBox groupBoxMouseDragDefaults; - private System.Windows.Forms.RadioButton radioButtonHorizMouseDrag; - private System.Windows.Forms.RadioButton radioButtonVerticalMouseDrag; - private System.Windows.Forms.RadioButton radioButtonVerticalMouseDragInverted; - private System.Windows.Forms.TabPage tabPageExternalTools; - private System.Windows.Forms.GroupBox groupBoxToolSettings; - private System.Windows.Forms.TextBox textBoxArguments; - private System.Windows.Forms.Button buttonTool; - private System.Windows.Forms.TextBox textBoxTool; - private System.Windows.Forms.Label labelArguments; - private System.Windows.Forms.Label labelTool; - private System.Windows.Forms.Button buttonArguments; - private System.Windows.Forms.TabPage tabPageColumnizers; - private System.Windows.Forms.DataGridView dataGridViewColumnizer; - private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1; - private System.Windows.Forms.Button buttonDelete; - private System.Windows.Forms.DataGridViewTextBoxColumn columnFileMask; - private System.Windows.Forms.DataGridViewComboBoxColumn columnColumnizer; - private System.Windows.Forms.CheckBox checkBoxSysout; - private System.Windows.Forms.CheckBox checkBoxMaskPrio; - private System.Windows.Forms.GroupBox groupBoxMisc; - private System.Windows.Forms.CheckBox checkBoxAskCloseTabs; - private System.Windows.Forms.TabPage tabPageMultiFile; - private System.Windows.Forms.GroupBox groupBoxWhenOpeningMultiFile; - private System.Windows.Forms.RadioButton radioButtonAskWhatToDo; - private System.Windows.Forms.RadioButton radioButtonTreatAllFilesAsOneMultifile; - private System.Windows.Forms.RadioButton radioButtonLoadEveryFileIntoSeperatedTab; - private System.Windows.Forms.Label labelNoteMultiFile; - private System.Windows.Forms.Label labelHintMultiFile; - private System.Windows.Forms.HelpProvider helpProvider; - private System.Windows.Forms.CheckBox checkBoxSingleInstance; - private System.Windows.Forms.ComboBox comboBoxColumnizer; - private System.Windows.Forms.CheckBox checkBoxOpenLastFiles; - private System.Windows.Forms.CheckBox checkBoxTailState; - private System.Windows.Forms.Button buttonTailColor; - private System.Windows.Forms.NumericUpDown cpDownColumnWidth; - private System.Windows.Forms.CheckBox checkBoxColumnSize; - private System.Windows.Forms.CheckBox checkBoxTimeSpread; - private System.Windows.Forms.GroupBox groupBoxTimeSpreadDisplay; - private System.Windows.Forms.GroupBox groupBoxTimeStampNavigationControl; - private System.Windows.Forms.Button buttonTimespreadColor; - private System.Windows.Forms.CheckBox checkBoxReverseAlpha; - private System.Windows.Forms.GroupBox groupBoxDisplayMode; - private System.Windows.Forms.RadioButton radioButtonLineView; - private System.Windows.Forms.RadioButton radioButtonTimeView; - private System.Windows.Forms.TabPage tabPagePlugins; - private System.Windows.Forms.ListBox listBoxPlugin; - private System.Windows.Forms.Panel panelPlugin; - private System.Windows.Forms.GroupBox groupBoxPlugins; - private System.Windows.Forms.GroupBox groupBoxSettings; - private System.Windows.Forms.Button buttonConfigPlugin; - private System.Windows.Forms.TabPage tabPageSessions; - private System.Windows.Forms.GroupBox groupBoxPersistantFileLocation; - private System.Windows.Forms.RadioButton radioButtonsessionSaveDocuments; - private System.Windows.Forms.RadioButton radioButtonSessionSameDir; - private System.Windows.Forms.CheckBox checkBoxSaveSessions; - private System.Windows.Forms.RadioButton radioButtonSessionSaveOwn; - private System.Windows.Forms.Label labelSessionSaveOwnDir; - private System.Windows.Forms.Button buttonSessionSaveDir; - private System.Windows.Forms.CheckBox checkBoxSaveFilter; - private System.Windows.Forms.TabPage tabPageMemory; - private System.Windows.Forms.Label labelNumberOfBlocks; - private System.Windows.Forms.NumericUpDown upDownBlockCount; - private System.Windows.Forms.NumericUpDown upDownLinesPerBlock; - private System.Windows.Forms.Label labelLinesPerBlock; - private System.Windows.Forms.GroupBox groupBoxLineBufferUsage; - private System.Windows.Forms.Label labelInfo; - private System.Windows.Forms.TabPage tabPageHighlightMask; - private System.Windows.Forms.DataGridView dataGridViewHighlightMask; - private System.Windows.Forms.DataGridViewTextBoxColumn columnFileName; - private System.Windows.Forms.DataGridViewComboBoxColumn columnHighlightGroup; - private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2; - private System.Windows.Forms.CheckBox checkBoxMultiThread; - private System.Windows.Forms.Label labelFilePollingInterval; - private System.Windows.Forms.NumericUpDown upDownPollingInterval; - private System.Windows.Forms.GroupBox groupBoxCPUAndStuff; - private System.Windows.Forms.Label labelToolColumnizerForOutput; - private System.Windows.Forms.Label labelToolName; - private System.Windows.Forms.CheckedListBox listBoxTools; - private System.Windows.Forms.TextBox textBoxToolName; - private System.Windows.Forms.Button buttonToolDelete; - private System.Windows.Forms.Button buttonToolAdd; - private System.Windows.Forms.Button buttonToolDown; - private System.Windows.Forms.Button buttonToolUp; - private System.Windows.Forms.Label labelToolsDescription; - private System.Windows.Forms.Button buttonIcon; - private System.Windows.Forms.Label labelWorkingDir; - private System.Windows.Forms.Button buttonWorkingDir; - private System.Windows.Forms.TextBox textBoxWorkingDir; - private System.Windows.Forms.GroupBox groupBoxDefaultFileNamePattern; - private System.Windows.Forms.Label labelMaxDays; - private System.Windows.Forms.Label labelPattern; - private System.Windows.Forms.NumericUpDown upDownMultifileDays; - private System.Windows.Forms.TextBox textBoxMultifilePattern; - private System.Windows.Forms.Label labelDefaultEncoding; - private System.Windows.Forms.ComboBox comboBoxEncoding; - private System.Windows.Forms.ToolTip toolTip; - private System.Windows.Forms.CheckBox checkBoxColumnFinder; - private System.Windows.Forms.Button buttonExport; - private System.Windows.Forms.Button buttonImport; - private System.Windows.Forms.CheckBox checkBoxLegacyReader; - private System.Windows.Forms.Label labelMaximumFilterEntries; - private System.Windows.Forms.NumericUpDown upDownMaximumFilterEntries; - private System.Windows.Forms.NumericUpDown upDownMaximumFilterEntriesDisplayed; - private System.Windows.Forms.Label labelMaximumFilterEntriesDisplayed; - private System.Windows.Forms.CheckBox checkBoxAutoPick; - private System.Windows.Forms.CheckBox checkBoxPortableMode; - private System.Windows.Forms.RadioButton radioButtonSessionApplicationStartupDir; - private System.Windows.Forms.CheckBox checkBoxShowErrorMessageOnlyOneInstance; - private System.Windows.Forms.CheckBox checkBoxDarkMode; - private System.Windows.Forms.NumericUpDown upDownMaximumLineLength; - private System.Windows.Forms.Label labelMaximumLineLength; - private System.Windows.Forms.Label labelWarningMaximumLineLenght; - } -} diff --git a/src/LogExpert/Dialogs/SettingsDialog.cs b/src/LogExpert/Dialogs/SettingsDialog.cs deleted file mode 100644 index b8c3476b..00000000 --- a/src/LogExpert/Dialogs/SettingsDialog.cs +++ /dev/null @@ -1,1038 +0,0 @@ -using LogExpert.Config; -using LogExpert.Controls.LogTabWindow; -using LogExpert.Core.Classes; -using LogExpert.Core.Classes.Columnizer; -using LogExpert.Core.Config; -using LogExpert.Core.Entities; -using LogExpert.Core.Enums; -using LogExpert.UI.Dialogs; - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; -using System.Windows.Forms; - -namespace LogExpert.Dialogs -{ - internal partial class SettingsDialog : Form - { - #region Fields - - private readonly Image _emptyImage = new Bitmap(16, 16); - private readonly LogTabWindow _logTabWin; - - private ILogExpertPluginConfigurator _selectedPlugin; - private ToolEntry _selectedTool; - - #endregion - - #region cTor - - public SettingsDialog(Preferences prefs, LogTabWindow logTabWin) - { - Preferences = prefs; - _logTabWin = logTabWin; - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); - } - - public SettingsDialog(Preferences prefs, LogTabWindow logTabWin, int tabToOpen) : this(prefs, logTabWin) - { - tabControlSettings.SelectedIndex = tabToOpen; - } - - #endregion - - #region Properties - - public Preferences Preferences { get; private set; } - - #endregion - - #region Private Methods - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - private static extern bool DestroyIcon(IntPtr handle); - - private void FillDialog() - { - Preferences ??= new Preferences(); - - if (Preferences.fontName == null) - { - Preferences.fontName = "Courier New"; - } - - if (Math.Abs(Preferences.fontSize) < 0.1) - { - Preferences.fontSize = 9.0f; - } - - FillPortableMode(); - - checkBoxDarkMode.Checked = Preferences.darkMode; - checkBoxTimestamp.Checked = Preferences.timestampControl; - checkBoxSyncFilter.Checked = Preferences.filterSync; - checkBoxFilterTail.Checked = Preferences.filterTail; - checkBoxFollowTail.Checked = Preferences.followTail; - - radioButtonHorizMouseDrag.Checked = Preferences.timestampControlDragOrientation == DragOrientationsEnum.Horizontal; - radioButtonVerticalMouseDrag.Checked = Preferences.timestampControlDragOrientation == DragOrientationsEnum.Vertical; - radioButtonVerticalMouseDragInverted.Checked = Preferences.timestampControlDragOrientation == DragOrientationsEnum.InvertedVertical; - - checkBoxSingleInstance.Checked = Preferences.allowOnlyOneInstance; - checkBoxOpenLastFiles.Checked = Preferences.openLastFiles; - checkBoxTailState.Checked = Preferences.showTailState; - checkBoxColumnSize.Checked = Preferences.setLastColumnWidth; - cpDownColumnWidth.Enabled = Preferences.setLastColumnWidth; - - if (Preferences.lastColumnWidth != 0) - { - if (Preferences.lastColumnWidth < cpDownColumnWidth.Minimum) - { - Preferences.lastColumnWidth = (int)cpDownColumnWidth.Minimum; - } - - if (Preferences.lastColumnWidth > cpDownColumnWidth.Maximum) - { - Preferences.lastColumnWidth = (int)cpDownColumnWidth.Maximum; - } - - cpDownColumnWidth.Value = Preferences.lastColumnWidth; - } - - checkBoxTimeSpread.Checked = Preferences.showTimeSpread; - checkBoxReverseAlpha.Checked = Preferences.reverseAlpha; - - radioButtonTimeView.Checked = Preferences.timeSpreadTimeMode; - radioButtonLineView.Checked = !Preferences.timeSpreadTimeMode; - - checkBoxSaveSessions.Checked = Preferences.saveSessions; - - switch (Preferences.saveLocation) - { - case SessionSaveLocation.OwnDir: - { - radioButtonSessionSaveOwn.Checked = true; - } - break; - case SessionSaveLocation.SameDir: - { - radioButtonSessionSameDir.Checked = true; - } - break; - case SessionSaveLocation.DocumentsDir: - { - radioButtonsessionSaveDocuments.Checked = true; - break; - } - case SessionSaveLocation.ApplicationStartupDir: - { - radioButtonSessionApplicationStartupDir.Checked = true; - break; - } - } - - //overwrite preferences save location in portable mode to always be application startup directory - if (checkBoxPortableMode.Checked) - { - radioButtonSessionApplicationStartupDir.Checked = true; - } - - upDownMaximumLineLength.Value = Preferences.MaxLineLength; - - upDownMaximumFilterEntriesDisplayed.Value = Preferences.maximumFilterEntriesDisplayed; - upDownMaximumFilterEntries.Value = Preferences.maximumFilterEntries; - - labelSessionSaveOwnDir.Text = Preferences.sessionSaveDirectory ?? string.Empty; - checkBoxSaveFilter.Checked = Preferences.saveFilters; - upDownBlockCount.Value = Preferences.bufferCount; - upDownLinesPerBlock.Value = Preferences.linesPerBuffer; - upDownPollingInterval.Value = Preferences.pollingInterval; - checkBoxMultiThread.Checked = Preferences.multiThreadFilter; - - dataGridViewColumnizer.DataError += OnDataGridViewColumnizerDataError; - - FillColumnizerList(); - FillPluginList(); - DisplayFontName(); - FillHighlightMaskList(); - FillToolListbox(); - FillMultifileSettings(); - FillEncodingList(); - - var temp = Encoding.GetEncoding(Preferences.defaultEncoding); - - comboBoxEncoding.SelectedItem = Encoding.GetEncoding(Preferences.defaultEncoding); - checkBoxMaskPrio.Checked = Preferences.maskPrio; - checkBoxAutoPick.Checked = Preferences.autoPick; - checkBoxAskCloseTabs.Checked = Preferences.askForClose; - checkBoxColumnFinder.Checked = Preferences.showColumnFinder; - checkBoxLegacyReader.Checked = Preferences.useLegacyReader; - checkBoxShowErrorMessageOnlyOneInstance.Checked = Preferences.ShowErrorMessageAllowOnlyOneInstances; - } - - private void FillPortableMode() - { - checkBoxPortableMode.CheckState = Preferences.PortableMode ? CheckState.Checked : CheckState.Unchecked; - } - - private void DisplayFontName() - { - labelFont.Text = Preferences.fontName + @" " + (int)Preferences.fontSize; - labelFont.Font = new Font(new FontFamily(Preferences.fontName), Preferences.fontSize); - } - - private void SaveMultifileData() - { - if (radioButtonLoadEveryFileIntoSeperatedTab.Checked) - { - Preferences.multiFileOption = MultiFileOption.SingleFiles; - } - - if (radioButtonTreatAllFilesAsOneMultifile.Checked) - { - Preferences.multiFileOption = MultiFileOption.MultiFile; - } - - if (radioButtonAskWhatToDo.Checked) - { - Preferences.multiFileOption = MultiFileOption.Ask; - } - - Preferences.multiFileOptions.FormatPattern = textBoxMultifilePattern.Text; - Preferences.multiFileOptions.MaxDayTry = (int)upDownMultifileDays.Value; - } - - private void OnBtnToolClickInternal(TextBox textBox) - { - OpenFileDialog dlg = new(); - dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); - - if (string.IsNullOrEmpty(textBox.Text) == false) - { - FileInfo info = new(textBox.Text); - if (info.Directory != null && info.Directory.Exists) - { - dlg.InitialDirectory = info.DirectoryName; - } - } - - if (dlg.ShowDialog() == DialogResult.OK) - { - textBox.Text = dlg.FileName; - } - } - - private void OnBtnArgsClickInternal(TextBox textBox) - { - ToolArgsDialog dlg = new(_logTabWin, this) - { - Arg = textBox.Text - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - textBox.Text = dlg.Arg; - } - } - - private void OnBtnWorkingDirClick(TextBox textBox) - { - FolderBrowserDialog dlg = new() - { - RootFolder = Environment.SpecialFolder.MyComputer, - Description = @"Select a working directory" - }; - - if (!string.IsNullOrEmpty(textBox.Text)) - { - DirectoryInfo info = new(textBox.Text); - if (info.Exists) - { - dlg.SelectedPath = info.FullName; - } - } - - if (dlg.ShowDialog() == DialogResult.OK) - { - textBox.Text = dlg.SelectedPath; - } - } - - private void FillColumnizerForToolsList() - { - if (_selectedTool != null) - { - FillColumnizerForToolsList(comboBoxColumnizer, _selectedTool.columnizerName); - } - } - - private void FillColumnizerForToolsList(ComboBox comboBox, string columnizerName) - { - int selIndex = 0; - comboBox.Items.Clear(); - IList columnizers = PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers; - - foreach (ILogLineColumnizer columnizer in columnizers) - { - int index = comboBox.Items.Add(columnizer.GetName()); - if (columnizer.GetName().Equals(columnizerName)) - { - selIndex = index; - } - } - - //ILogLineColumnizer columnizer = Util.FindColumnizerByName(columnizerName, this.logTabWin.RegisteredColumnizers); - //if (columnizer == null) - // columnizer = this.logTabWin.RegisteredColumnizers[0]; - comboBox.SelectedIndex = selIndex; - } - - private void FillColumnizerList() - { - dataGridViewColumnizer.Rows.Clear(); - - DataGridViewComboBoxColumn comboColumn = (DataGridViewComboBoxColumn)dataGridViewColumnizer.Columns[1]; - comboColumn.Items.Clear(); - - DataGridViewTextBoxColumn textColumn = (DataGridViewTextBoxColumn)dataGridViewColumnizer.Columns[0]; - - IList columnizers = PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers; - - foreach (ILogLineColumnizer columnizer in columnizers) - { - comboColumn.Items.Add(columnizer.GetName()); - } - //comboColumn.DisplayMember = "Name"; - //comboColumn.ValueMember = "Columnizer"; - - foreach (ColumnizerMaskEntry maskEntry in Preferences.columnizerMaskList) - { - DataGridViewRow row = new(); - row.Cells.Add(new DataGridViewTextBoxCell()); - DataGridViewComboBoxCell cell = new(); - - foreach (ILogLineColumnizer logColumnizer in columnizers) - { - cell.Items.Add(logColumnizer.GetName()); - } - - row.Cells.Add(cell); - row.Cells[0].Value = maskEntry.mask; - ILogLineColumnizer columnizer = ColumnizerPicker.DecideColumnizerByName(maskEntry.columnizerName, - PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - - row.Cells[1].Value = columnizer.GetName(); - dataGridViewColumnizer.Rows.Add(row); - } - - int count = dataGridViewColumnizer.RowCount; - - if (count > 0 && !dataGridViewColumnizer.Rows[count - 1].IsNewRow) - { - DataGridViewComboBoxCell comboCell = (DataGridViewComboBoxCell)dataGridViewColumnizer.Rows[count - 1].Cells[1]; - comboCell.Value = comboCell.Items[0]; - } - } - - private void FillHighlightMaskList() - { - dataGridViewHighlightMask.Rows.Clear(); - - DataGridViewComboBoxColumn comboColumn = (DataGridViewComboBoxColumn)dataGridViewHighlightMask.Columns[1]; - comboColumn.Items.Clear(); - - //TODO Remove if not necessary - DataGridViewTextBoxColumn textColumn = (DataGridViewTextBoxColumn)dataGridViewHighlightMask.Columns[0]; - - foreach (HighlightGroup group in (IList)_logTabWin.HighlightGroupList) - { - comboColumn.Items.Add(group.GroupName); - } - - foreach (HighlightMaskEntry maskEntry in Preferences.highlightMaskList) - { - DataGridViewRow row = new(); - row.Cells.Add(new DataGridViewTextBoxCell()); - DataGridViewComboBoxCell cell = new(); - - foreach (HighlightGroup group in (IList)_logTabWin.HighlightGroupList) - { - cell.Items.Add(group.GroupName); - } - - row.Cells.Add(cell); - row.Cells[0].Value = maskEntry.mask; - - HighlightGroup currentGroup = _logTabWin.FindHighlightGroup(maskEntry.highlightGroupName); - currentGroup ??= ((IList)_logTabWin.HighlightGroupList)[0]; - currentGroup ??= new HighlightGroup(); - - row.Cells[1].Value = currentGroup.GroupName; - dataGridViewHighlightMask.Rows.Add(row); - } - - int count = dataGridViewHighlightMask.RowCount; - - if (count > 0 && !dataGridViewHighlightMask.Rows[count - 1].IsNewRow) - { - DataGridViewComboBoxCell comboCell = - (DataGridViewComboBoxCell)dataGridViewHighlightMask.Rows[count - 1].Cells[1]; - comboCell.Value = comboCell.Items[0]; - } - } - - private void SaveColumnizerList() - { - Preferences.columnizerMaskList.Clear(); - - foreach (DataGridViewRow row in dataGridViewColumnizer.Rows) - { - if (!row.IsNewRow) - { - ColumnizerMaskEntry entry = new(); - entry.mask = (string)row.Cells[0].Value; - entry.columnizerName = (string)row.Cells[1].Value; - Preferences.columnizerMaskList.Add(entry); - } - } - } - - private void SaveHighlightMaskList() - { - Preferences.highlightMaskList.Clear(); - - foreach (DataGridViewRow row in dataGridViewHighlightMask.Rows) - { - if (!row.IsNewRow) - { - HighlightMaskEntry entry = new(); - entry.mask = (string)row.Cells[0].Value; - entry.highlightGroupName = (string)row.Cells[1].Value; - Preferences.highlightMaskList.Add(entry); - } - } - } - - private void FillPluginList() - { - listBoxPlugin.Items.Clear(); - - foreach (IContextMenuEntry entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins) - { - listBoxPlugin.Items.Add(entry); - if (entry is ILogExpertPluginConfigurator configurator) - { - configurator.StartConfig(); - } - } - - foreach (IKeywordAction entry in PluginRegistry.PluginRegistry.Instance.RegisteredKeywordActions) - { - listBoxPlugin.Items.Add(entry); - if (entry is ILogExpertPluginConfigurator configurator) - { - configurator.StartConfig(); - } - } - - foreach (IFileSystemPlugin entry in PluginRegistry.PluginRegistry.Instance.RegisteredFileSystemPlugins) - { - listBoxPlugin.Items.Add(entry); - if (entry is ILogExpertPluginConfigurator configurator) - { - configurator.StartConfig(); - } - } - - buttonConfigPlugin.Enabled = false; - } - - private void SavePluginSettings() - { - _selectedPlugin?.HideConfigForm(); - - foreach (IContextMenuEntry entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins) - { - if (entry is ILogExpertPluginConfigurator configurator) - { - configurator.SaveConfig(checkBoxPortableMode.Checked ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir); - } - } - - foreach (IKeywordAction entry in PluginRegistry.PluginRegistry.Instance.RegisteredKeywordActions) - { - if (entry is ILogExpertPluginConfigurator configurator) - { - configurator.SaveConfig(checkBoxPortableMode.Checked ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir); - } - } - } - - private void FillToolListbox() - { - listBoxTools.Items.Clear(); - - foreach (ToolEntry tool in Preferences.toolEntries) - { - listBoxTools.Items.Add(tool.Clone(), tool.isFavourite); - } - - if (listBoxTools.Items.Count > 0) - { - listBoxTools.SelectedIndex = 0; - } - } - - private void FillMultifileSettings() - { - switch (Preferences.multiFileOption) - { - case MultiFileOption.SingleFiles: - { - radioButtonLoadEveryFileIntoSeperatedTab.Checked = true; - break; - } - case MultiFileOption.MultiFile: - { - radioButtonTreatAllFilesAsOneMultifile.Checked = true; - break; - } - case MultiFileOption.Ask: - { - radioButtonAskWhatToDo.Checked = true; - break; - } - } - - textBoxMultifilePattern.Text = Preferences.multiFileOptions.FormatPattern; - upDownMultifileDays.Value = Preferences.multiFileOptions.MaxDayTry; - } - - private void GetToolListBoxData() - { - GetCurrentToolValues(); - Preferences.toolEntries.Clear(); - - for (int i = 0; i < listBoxTools.Items.Count; ++i) - { - Preferences.toolEntries.Add(listBoxTools.Items[i] as ToolEntry); - (listBoxTools.Items[i] as ToolEntry).isFavourite = listBoxTools.GetItemChecked(i); - } - } - - private void GetCurrentToolValues() - { - if (_selectedTool != null) - { - _selectedTool.name = Util.IsNullOrSpaces(textBoxToolName.Text) ? textBoxTool.Text : textBoxToolName.Text; - _selectedTool.cmd = textBoxTool.Text; - _selectedTool.args = textBoxArguments.Text; - _selectedTool.columnizerName = comboBoxColumnizer.Text; - _selectedTool.sysout = checkBoxSysout.Checked; - _selectedTool.workingDir = textBoxWorkingDir.Text; - } - } - - private void ShowCurrentToolValues() - { - if (_selectedTool != null) - { - textBoxToolName.Text = _selectedTool.name; - textBoxTool.Text = _selectedTool.cmd; - textBoxArguments.Text = _selectedTool.args; - comboBoxColumnizer.Text = _selectedTool.columnizerName; - checkBoxSysout.Checked = _selectedTool.sysout; - comboBoxColumnizer.Enabled = _selectedTool.sysout; - textBoxWorkingDir.Text = _selectedTool.workingDir; - } - } - - private void DisplayCurrentIcon() - { - if (_selectedTool != null) - { - Icon icon = Win32.LoadIconFromExe(_selectedTool.iconFile, _selectedTool.iconIndex); - if (icon != null) - { - Image image = icon.ToBitmap(); - buttonIcon.Image = image; - DestroyIcon(icon.Handle); - icon.Dispose(); - } - else - { - buttonIcon.Image = _emptyImage; - } - } - } - - private void FillEncodingList() - { - comboBoxEncoding.Items.Clear(); - - comboBoxEncoding.Items.Add(Encoding.ASCII); - comboBoxEncoding.Items.Add(Encoding.Default); - comboBoxEncoding.Items.Add(Encoding.GetEncoding("iso-8859-1")); - comboBoxEncoding.Items.Add(Encoding.UTF8); - comboBoxEncoding.Items.Add(Encoding.Unicode); - comboBoxEncoding.Items.Add(CodePagesEncodingProvider.Instance.GetEncoding(1252)); - - comboBoxEncoding.ValueMember = "HeaderName"; - } - - #endregion - - #region Events handler - - private void OnSettingsDialogLoad(object sender, EventArgs e) - { - FillDialog(); - } - - private void OnBtnChangeFontClick(object sender, EventArgs e) - { - FontDialog dlg = new() - { - ShowEffects = false, - AllowVerticalFonts = false, - AllowScriptChange = false, - Font = new Font(new FontFamily(Preferences.fontName), Preferences.fontSize) - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - Preferences.fontSize = dlg.Font.Size; - Preferences.fontName = dlg.Font.FontFamily.Name; - } - - DisplayFontName(); - } - - private void OnBtnOkClick(object sender, EventArgs e) - { - Preferences.timestampControl = checkBoxTimestamp.Checked; - Preferences.filterSync = checkBoxSyncFilter.Checked; - Preferences.filterTail = checkBoxFilterTail.Checked; - Preferences.followTail = checkBoxFollowTail.Checked; - - if (radioButtonVerticalMouseDrag.Checked) - { - Preferences.timestampControlDragOrientation = DragOrientationsEnum.Vertical; - } - else if (radioButtonVerticalMouseDragInverted.Checked) - { - Preferences.timestampControlDragOrientation = DragOrientationsEnum.InvertedVertical; - } - else - { - Preferences.timestampControlDragOrientation = DragOrientationsEnum.Horizontal; - } - - SaveColumnizerList(); - - Preferences.maskPrio = checkBoxMaskPrio.Checked; - Preferences.autoPick = checkBoxAutoPick.Checked; - Preferences.askForClose = checkBoxAskCloseTabs.Checked; - Preferences.allowOnlyOneInstance = checkBoxSingleInstance.Checked; - Preferences.openLastFiles = checkBoxOpenLastFiles.Checked; - Preferences.showTailState = checkBoxTailState.Checked; - Preferences.setLastColumnWidth = checkBoxColumnSize.Checked; - Preferences.lastColumnWidth = (int)cpDownColumnWidth.Value; - Preferences.showTimeSpread = checkBoxTimeSpread.Checked; - Preferences.reverseAlpha = checkBoxReverseAlpha.Checked; - Preferences.timeSpreadTimeMode = radioButtonTimeView.Checked; - - Preferences.saveSessions = checkBoxSaveSessions.Checked; - Preferences.sessionSaveDirectory = labelSessionSaveOwnDir.Text; - - if (radioButtonsessionSaveDocuments.Checked) - { - Preferences.saveLocation = SessionSaveLocation.DocumentsDir; - } - else if (radioButtonSessionSaveOwn.Checked) - { - Preferences.saveLocation = SessionSaveLocation.OwnDir; - } - else if (radioButtonSessionApplicationStartupDir.Checked) - { - Preferences.saveLocation = SessionSaveLocation.ApplicationStartupDir; - } - else - { - Preferences.saveLocation = SessionSaveLocation.SameDir; - } - - Preferences.saveFilters = checkBoxSaveFilter.Checked; - Preferences.bufferCount = (int)upDownBlockCount.Value; - Preferences.linesPerBuffer = (int)upDownLinesPerBlock.Value; - Preferences.pollingInterval = (int)upDownPollingInterval.Value; - Preferences.multiThreadFilter = checkBoxMultiThread.Checked; - Preferences.defaultEncoding = comboBoxEncoding.SelectedItem != null ? (comboBoxEncoding.SelectedItem as Encoding).HeaderName : Encoding.Default.HeaderName; - Preferences.showColumnFinder = checkBoxColumnFinder.Checked; - Preferences.useLegacyReader = checkBoxLegacyReader.Checked; - - Preferences.maximumFilterEntries = (int)upDownMaximumFilterEntries.Value; - Preferences.maximumFilterEntriesDisplayed = (int)upDownMaximumFilterEntriesDisplayed.Value; - Preferences.ShowErrorMessageAllowOnlyOneInstances = checkBoxShowErrorMessageOnlyOneInstance.Checked; - Preferences.darkMode = checkBoxDarkMode.Checked; - - SavePluginSettings(); - SaveHighlightMaskList(); - GetToolListBoxData(); - SaveMultifileData(); - } - - private void OnBtnToolClick(object sender, EventArgs e) - { - OnBtnToolClickInternal(textBoxTool); - } - - private void OnBtnArgClick(object sender, EventArgs e) - { - OnBtnArgsClickInternal(textBoxArguments); - } - - //TODO Remove or refactor this function - private void OnDataGridViewColumnizerRowsAdded(object sender, DataGridViewRowsAddedEventArgs e) - { - DataGridViewComboBoxCell comboCell = (DataGridViewComboBoxCell)dataGridViewColumnizer.Rows[e.RowIndex].Cells[1]; - if (comboCell.Items.Count > 0) - { - // comboCell.Value = comboCell.Items[0]; - } - } - - private void OnBtnDeleteClick(object sender, EventArgs e) - { - if (dataGridViewColumnizer.CurrentRow != null && !dataGridViewColumnizer.CurrentRow.IsNewRow) - { - int index = dataGridViewColumnizer.CurrentRow.Index; - dataGridViewColumnizer.EndEdit(); - dataGridViewColumnizer.Rows.RemoveAt(index); - } - } - - private void OnDataGridViewColumnizerDataError(object sender, DataGridViewDataErrorEventArgs e) - { - e.Cancel = true; - } - - private void OnChkBoxSysoutCheckedChanged(object sender, EventArgs e) - { - comboBoxColumnizer.Enabled = checkBoxSysout.Checked; - } - - private void OnBtnTailColorClick(object sender, EventArgs e) - { - ColorDialog dlg = new() - { - Color = Preferences.showTailColor - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - Preferences.showTailColor = dlg.Color; - } - } - - private void OnChkBoxColumnSizeCheckedChanged(object sender, EventArgs e) - { - cpDownColumnWidth.Enabled = checkBoxColumnSize.Checked; - } - - private void OnBtnTimespreadColorClick(object sender, EventArgs e) - { - ColorDialog dlg = new() - { - Color = Preferences.timeSpreadColor - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - Preferences.timeSpreadColor = dlg.Color; - } - } - - private void OnListBoxPluginSelectedIndexChanged(object sender, EventArgs e) - { - _selectedPlugin?.HideConfigForm(); - - object o = listBoxPlugin.SelectedItem; - - if (o != null) - { - _selectedPlugin = o as ILogExpertPluginConfigurator; - - if (o is ILogExpertPluginConfigurator) - { - if (_selectedPlugin.HasEmbeddedForm()) - { - buttonConfigPlugin.Enabled = false; - buttonConfigPlugin.Visible = false; - _selectedPlugin.ShowConfigForm(panelPlugin); - } - else - { - buttonConfigPlugin.Enabled = true; - buttonConfigPlugin.Visible = true; - } - } - } - else - { - buttonConfigPlugin.Enabled = false; - buttonConfigPlugin.Visible = true; - } - } - - private void OnBtnSessionSaveDirClick(object sender, EventArgs e) - { - FolderBrowserDialog dlg = new(); - - if (Preferences.sessionSaveDirectory != null) - { - dlg.SelectedPath = Preferences.sessionSaveDirectory; - } - - dlg.ShowNewFolderButton = true; - dlg.Description = @"Choose folder for LogExpert's session files"; - - if (dlg.ShowDialog() == DialogResult.OK) - { - labelSessionSaveOwnDir.Text = dlg.SelectedPath; - } - } - - private void OnPortableModeCheckedChanged(object sender, EventArgs e) - { - try - { - switch (checkBoxPortableMode.CheckState) - { - case CheckState.Checked when !File.Exists(ConfigManager.PortableModeDir + Path.DirectorySeparatorChar + ConfigManager.PortableModeSettingsFileName): - { - if (Directory.Exists(ConfigManager.PortableModeDir) == false) - { - Directory.CreateDirectory(ConfigManager.PortableModeDir); - } - - using (File.Create(ConfigManager.PortableModeDir + Path.DirectorySeparatorChar + ConfigManager.PortableModeSettingsFileName)) - { - break; - } - } - case CheckState.Unchecked when File.Exists(ConfigManager.PortableModeDir + Path.DirectorySeparatorChar + ConfigManager.PortableModeSettingsFileName): - { - File.Delete(ConfigManager.PortableModeDir + Path.DirectorySeparatorChar + ConfigManager.PortableModeSettingsFileName); - break; - } - } - - switch (checkBoxPortableMode.CheckState) - { - case CheckState.Unchecked: - { - checkBoxPortableMode.Text = @"Activate Portable Mode"; - Preferences.PortableMode = false; - break; - } - - case CheckState.Checked: - { - Preferences.PortableMode = true; - checkBoxPortableMode.Text = @"Deactivate Portable Mode"; - break; - } - } - } - catch (Exception exception) - { - MessageBox.Show($@"Could not create / delete marker for Portable Mode: {exception}", @"Error", MessageBoxButtons.OK); - } - - } - - private void OnBtnConfigPluginClick(object sender, EventArgs e) - { - if (!_selectedPlugin.HasEmbeddedForm()) - { - _selectedPlugin.ShowConfigDialog(this); - } - } - - private void OnNumericUpDown1ValueChanged(object sender, EventArgs e) - { - //TODO implement - } - - private void OnListBoxToolSelectedIndexChanged(object sender, EventArgs e) - { - GetCurrentToolValues(); - _selectedTool = listBoxTools.SelectedItem as ToolEntry; - ShowCurrentToolValues(); - listBoxTools.Refresh(); - FillColumnizerForToolsList(); - DisplayCurrentIcon(); - } - - private void OnBtnToolUpClick(object sender, EventArgs e) - { - int i = listBoxTools.SelectedIndex; - - if (i > 0) - { - bool isChecked = listBoxTools.GetItemChecked(i); - object item = listBoxTools.Items[i]; - listBoxTools.Items.RemoveAt(i); - i--; - listBoxTools.Items.Insert(i, item); - listBoxTools.SelectedIndex = i; - listBoxTools.SetItemChecked(i, isChecked); - } - } - - private void OnBtnToolDownClick(object sender, EventArgs e) - { - int i = listBoxTools.SelectedIndex; - - if (i < listBoxTools.Items.Count - 1) - { - bool isChecked = listBoxTools.GetItemChecked(i); - object item = listBoxTools.Items[i]; - listBoxTools.Items.RemoveAt(i); - i++; - listBoxTools.Items.Insert(i, item); - listBoxTools.SelectedIndex = i; - listBoxTools.SetItemChecked(i, isChecked); - } - } - - private void OnBtnToolAddClick(object sender, EventArgs e) - { - listBoxTools.Items.Add(new ToolEntry()); - listBoxTools.SelectedIndex = listBoxTools.Items.Count - 1; - } - - private void OnToolDeleteButtonClick(object sender, EventArgs e) - { - int i = listBoxTools.SelectedIndex; - - if (i < listBoxTools.Items.Count && i >= 0) - { - listBoxTools.Items.RemoveAt(i); - if (i < listBoxTools.Items.Count) - { - listBoxTools.SelectedIndex = i; - } - else - { - if (listBoxTools.Items.Count > 0) - { - listBoxTools.SelectedIndex = listBoxTools.Items.Count - 1; - } - } - } - } - - private void OnBtnIconClick(object sender, EventArgs e) - { - if (_selectedTool != null) - { - string iconFile = _selectedTool.iconFile; - - if (Util.IsNullOrSpaces(iconFile)) - { - iconFile = textBoxTool.Text; - } - - ChooseIconDlg dlg = new(iconFile); - - if (dlg.ShowDialog() == DialogResult.OK) - { - _selectedTool.iconFile = dlg.FileName; - _selectedTool.iconIndex = dlg.IconIndex; - DisplayCurrentIcon(); - } - } - } - - private void OnBtnCancelClick(object sender, EventArgs e) - { - _selectedPlugin?.HideConfigForm(); - } - - private void OnBtnWorkingDirClick(object sender, EventArgs e) - { - OnBtnWorkingDirClick(textBoxWorkingDir); - } - - private void OnMultiFilePatternTextChanged(object sender, EventArgs e) - { - string pattern = textBoxMultifilePattern.Text; - upDownMultifileDays.Enabled = pattern.Contains("$D"); - } - - private void OnBtnExportClick(object sender, EventArgs e) - { - SaveFileDialog dlg = new() - { - Title = @"Export Settings to file", - DefaultExt = "json", - AddExtension = true, - Filter = @"Settings (*.json)|*.json|All files (*.*)|*.*" - }; - - DialogResult result = dlg.ShowDialog(); - - if (result == DialogResult.OK) - { - FileInfo fileInfo = new(dlg.FileName); - ConfigManager.Export(fileInfo); - } - } - - /// - /// - /// - /// - /// - private void OnBtnImportClick(object sender, EventArgs e) - { - ImportSettingsDialog dlg = new(ExportImportFlags.All); - - if (dlg.ShowDialog() == DialogResult.OK) - { - if (string.IsNullOrWhiteSpace(dlg.FileName)) - { - return; - } - - FileInfo fileInfo; - try - { - fileInfo = new FileInfo(dlg.FileName); - } - catch (Exception ex) - { - MessageBox.Show(this, $@"Settings could not be imported: {ex}", @"LogExpert"); - return; - } - - ConfigManager.Import(fileInfo, dlg.ImportFlags); - Preferences = ConfigManager.Settings.Preferences; - FillDialog(); - MessageBox.Show(this, @"Settings imported", @"LogExpert"); - } - } - - #endregion - } -} diff --git a/src/LogExpert/Dialogs/ToolArgsDialog.Designer.cs b/src/LogExpert/Dialogs/ToolArgsDialog.Designer.cs deleted file mode 100644 index fc9d4dcd..00000000 --- a/src/LogExpert/Dialogs/ToolArgsDialog.Designer.cs +++ /dev/null @@ -1,151 +0,0 @@ -namespace LogExpert.Dialogs -{ - partial class ToolArgsDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonOk = new System.Windows.Forms.Button(); - this.buttonRegexHelp = new System.Windows.Forms.Button(); - this.textBoxArguments = new System.Windows.Forms.TextBox(); - this.buttonTest = new System.Windows.Forms.Button(); - this.labelEnterArguments = new System.Windows.Forms.Label(); - this.labelHelp = new System.Windows.Forms.Label(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.labelTestResult = new System.Windows.Forms.TextBox(); - this.SuspendLayout(); - // - // buttonOk - // - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(348, 292); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 23); - this.buttonOk.TabIndex = 1; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.OnButtonOkClick); - // - // buttonRegexHelp - // - this.buttonRegexHelp.Location = new System.Drawing.Point(429, 59); - this.buttonRegexHelp.Name = "buttonRegexHelp"; - this.buttonRegexHelp.Size = new System.Drawing.Size(75, 21); - this.buttonRegexHelp.TabIndex = 2; - this.buttonRegexHelp.Text = "RegEx Help"; - this.buttonRegexHelp.UseVisualStyleBackColor = true; - this.buttonRegexHelp.Click += new System.EventHandler(this.OnButtonRegexHelpClick); - // - // textBoxArguments - // - this.textBoxArguments.Location = new System.Drawing.Point(12, 36); - this.textBoxArguments.Name = "textBoxArguments"; - this.textBoxArguments.Size = new System.Drawing.Size(395, 26); - this.textBoxArguments.TabIndex = 8; - // - // buttonTest - // - this.buttonTest.Location = new System.Drawing.Point(429, 30); - this.buttonTest.Name = "buttonTest"; - this.buttonTest.Size = new System.Drawing.Size(75, 23); - this.buttonTest.TabIndex = 9; - this.buttonTest.Text = "Test"; - this.buttonTest.UseVisualStyleBackColor = true; - this.buttonTest.Click += new System.EventHandler(this.OnButtonTestClick); - // - // labelEnterArguments - // - this.labelEnterArguments.AutoSize = true; - this.labelEnterArguments.Location = new System.Drawing.Point(12, 13); - this.labelEnterArguments.Name = "labelEnterArguments"; - this.labelEnterArguments.Size = new System.Drawing.Size(154, 20); - this.labelEnterArguments.TabIndex = 11; - this.labelEnterArguments.Text = "Enter command line:"; - // - // labelHelp - // - this.labelHelp.Location = new System.Drawing.Point(15, 124); - this.labelHelp.Name = "labelHelp"; - this.labelHelp.Size = new System.Drawing.Size(392, 157); - this.labelHelp.TabIndex = 12; - this.labelHelp.Text = "Help"; - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(429, 292); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 13; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // labelTestResult - // - this.labelTestResult.Location = new System.Drawing.Point(12, 68); - this.labelTestResult.Multiline = true; - this.labelTestResult.Name = "labelTestResult"; - this.labelTestResult.ReadOnly = true; - this.labelTestResult.Size = new System.Drawing.Size(395, 48); - this.labelTestResult.TabIndex = 14; - // - // ToolArgsDialog - // - this.AcceptButton = this.buttonOk; - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(516, 327); - this.Controls.Add(this.labelTestResult); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.labelHelp); - this.Controls.Add(this.labelEnterArguments); - this.Controls.Add(this.buttonTest); - this.Controls.Add(this.textBoxArguments); - this.Controls.Add(this.buttonRegexHelp); - this.Controls.Add(this.buttonOk); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ToolArgsDialog"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Tool Arguments Help"; - this.Load += new System.EventHandler(this.OnToolArgsDialogLoad); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.Button buttonRegexHelp; - private System.Windows.Forms.TextBox textBoxArguments; - private System.Windows.Forms.Button buttonTest; - private System.Windows.Forms.Label labelEnterArguments; - private System.Windows.Forms.Label labelHelp; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.TextBox labelTestResult; - } -} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/ToolArgsDialog.cs b/src/LogExpert/Dialogs/ToolArgsDialog.cs deleted file mode 100644 index 9428c9be..00000000 --- a/src/LogExpert/Dialogs/ToolArgsDialog.cs +++ /dev/null @@ -1,97 +0,0 @@ -using LogExpert.Classes; -using LogExpert.Controls.LogTabWindow; -using LogExpert.UI.Dialogs; - -using System; -using System.Drawing; -using System.Windows.Forms; - - -namespace LogExpert.Dialogs -{ - internal partial class ToolArgsDialog : Form - { - #region Fields - - private readonly LogTabWindow logTabWin; - - #endregion - - #region cTor - - public ToolArgsDialog(LogTabWindow logTabWin, Form parent) - { - this.logTabWin = logTabWin; - parent.AddOwnedForm(this); - TopMost = parent.TopMost; - InitializeComponent(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - } - - #endregion - - #region Properties - - public string Arg { get; set; } - - #endregion - - #region Events handler - - private void OnToolArgsDialogLoad(object sender, EventArgs e) - { - labelHelp.Text = "" + - "%L = Current line number\n" + - "%N = Current log file name without path\n" + - "%P = Path (directory) of current log file\n" + - "%F = Full name (incl. path) of log file\n" + - "%E = Extension of log file name (e.g. 'txt')\n" + - "%M = Name of log file without extension\n" + - "%S = User (from URI)\n" + - "%R = Path (from URI)\n" + - "%H = Host (from URI)\n" + - "%T = Port (from URI)\n" + - "?\"\" = variable parameter 'name'\n" + - "?\"\"(def1,def2,...) = variable parameter with predefined values\n" + - "\n" + - "{}{}:\n" + - "Regex search/replace on current selected line."; - - textBoxArguments.Text = Arg; - } - - private void OnButtonRegexHelpClick(object sender, EventArgs e) - { - RegexHelperDialog regexDlg = new(); - if (regexDlg.ShowDialog() == DialogResult.OK) - { - textBoxArguments.SelectedText = regexDlg.Pattern; - } - } - - - private void OnButtonTestClick(object sender, EventArgs e) - { - if (logTabWin.CurrentLogWindow != null) - { - ILogLine line = logTabWin.CurrentLogWindow.GetCurrentLine(); - ILogFileInfo info = logTabWin.CurrentLogWindow.GetCurrentFileInfo(); - if (line != null && info != null) - { - ArgParser parser = new(textBoxArguments.Text); - string args = parser.BuildArgs(line, logTabWin.CurrentLogWindow.GetRealLineNum() + 1, info, this); - labelTestResult.Text = args; - } - } - } - - private void OnButtonOkClick(object sender, EventArgs e) - { - Arg = textBoxArguments.Text; - } - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert/Entities/EventArgs/CurrentHighlightGroupChangedEventArgs.cs b/src/LogExpert/Entities/EventArgs/CurrentHighlightGroupChangedEventArgs.cs deleted file mode 100644 index f919def5..00000000 --- a/src/LogExpert/Entities/EventArgs/CurrentHighlightGroupChangedEventArgs.cs +++ /dev/null @@ -1,16 +0,0 @@ -using LogExpert.Controls.LogWindow; -using LogExpert.Core.Entities; - -namespace LogExpert.Entities.EventArgs -{ - public class CurrentHighlightGroupChangedEventArgs(LogWindow logWindow, HighlightGroup currentGroup) - { - #region Properties - - public LogWindow LogWindow { get; } = logWindow; - - public HighlightGroup CurrentGroup { get; } = currentGroup; - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert/Entities/EventArgs/FilterListChangedEventArgs.cs b/src/LogExpert/Entities/EventArgs/FilterListChangedEventArgs.cs deleted file mode 100644 index 6e664ec8..00000000 --- a/src/LogExpert/Entities/EventArgs/FilterListChangedEventArgs.cs +++ /dev/null @@ -1,13 +0,0 @@ -using LogExpert.Controls.LogWindow; - -namespace LogExpert.Entities.EventArgs -{ - public class FilterListChangedEventArgs(LogWindow logWindow) - { - #region Properties - - public LogWindow LogWindow { get; } = logWindow; - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert/LogExpert.csproj b/src/LogExpert/LogExpert.csproj index d57155ce..834aca9a 100644 --- a/src/LogExpert/LogExpert.csproj +++ b/src/LogExpert/LogExpert.csproj @@ -1,47 +1,36 @@  net8.0-windows - true + True WinExe logexpert.ico - false - true - true + False + False $(SolutionDir)..\bin\Docs\LogExpert.xml - false - true + False + False Auto - true + True ..\Solution Items\Key.snk - false + False $(SolutionDir)..\bin\$(Configuration) - true + True PerMonitorV2 - true + True CS1591; + False True + Properties\AssemblyVersion.cs - - UserControl - - - UserControl - - - Component - - - Component - Key.snk @@ -53,14 +42,9 @@ Always - - Always - - - @@ -71,6 +55,7 @@ + diff --git a/src/LogExpert/Program.cs b/src/LogExpert/Program.cs index 4dbdac5e..a808363d 100644 --- a/src/LogExpert/Program.cs +++ b/src/LogExpert/Program.cs @@ -1,17 +1,15 @@ using LogExpert.Classes; using LogExpert.Config; -using LogExpert.Controls.LogTabWindow; using LogExpert.Core.Classes; using LogExpert.Core.Classes.IPC; using LogExpert.Core.Config; +using LogExpert.Core.Interface; using LogExpert.Dialogs; +using LogExpert.UI.Controls.LogTabWindow; using LogExpert.UI.Dialogs; - using Newtonsoft.Json; using Newtonsoft.Json.Linq; - using NLog; - using System; using System.Collections.Generic; using System.Diagnostics; @@ -61,6 +59,7 @@ private static void Sub_Main(string[] orgArgs) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.ThreadException += Application_ThreadException; + ApplicationConfiguration.Initialize(); Application.EnableVisualStyles(); @@ -71,39 +70,37 @@ private static void Sub_Main(string[] orgArgs) CmdLine cmdLine = new(); CmdLineString configFile = new("config", false, "A configuration (settings) file"); cmdLine.RegisterParameter(configFile); - string[] remainingArgs = cmdLine.Parse(orgArgs); - string[] absoluteFilePaths = GenerateAbsoluteFilePaths(remainingArgs); - if (configFile.Exists) { FileInfo cfgFileInfo = new(configFile.Value); if (cfgFileInfo.Exists) { - ConfigManager.Import(cfgFileInfo, ExportImportFlags.All); + ConfigManager.Instance.Import(cfgFileInfo, ExportImportFlags.All); } else { MessageBox.Show(@"Config file not found", @"LogExpert"); } } - - PluginRegistry.PluginRegistry.Instance.Create(ConfigManager.ConfigDir, ConfigManager.Settings.Preferences.pollingInterval); + PluginRegistry.PluginRegistry.Instance.Create(ConfigManager.Instance.ConfigDir, ConfigManager.Instance.Settings.Preferences.pollingInterval); int pId = Process.GetCurrentProcess().SessionId; try { - Settings settings = ConfigManager.Settings; + Settings settings = ConfigManager.Instance.Settings; Mutex mutex = new(false, "Local\\LogExpertInstanceMutex" + pId, out var isCreated); + var remainingArgs = cmdLine.Parse(orgArgs); + var absoluteFilePaths = GenerateAbsoluteFilePaths(remainingArgs); if (isCreated) { // first application instance Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - LogTabWindow logWin = new(absoluteFilePaths.Length > 0 ? absoluteFilePaths : null, 1, false); + ILogTabWindow logWin = AbstractLogTabWindow.Create(absoluteFilePaths.Length > 0 ? absoluteFilePaths : null, 1, false, ConfigManager.Instance); // first instance WindowsIdentity wi = WindowsIdentity.GetCurrent(); @@ -149,7 +146,7 @@ private static void Sub_Main(string[] orgArgs) if (a.ShowDialog() == DialogResult.OK) { settings.Preferences.ShowErrorMessageAllowOnlyOneInstances = !a.DoNotShowThisMessageAgain; - ConfigManager.Save(SettingsFlags.All); + ConfigManager.Instance.Save(SettingsFlags.All); } } } diff --git a/src/LogExpert/Classes/ILogLineColumnizerCallback/ColumnizerCallback.cs b/src/Logexpert.Core/Callback/ColumnizerCallback.cs similarity index 83% rename from src/LogExpert/Classes/ILogLineColumnizerCallback/ColumnizerCallback.cs rename to src/Logexpert.Core/Callback/ColumnizerCallback.cs index 788a17a0..4168713e 100644 --- a/src/LogExpert/Classes/ILogLineColumnizerCallback/ColumnizerCallback.cs +++ b/src/Logexpert.Core/Callback/ColumnizerCallback.cs @@ -1,6 +1,4 @@ -using LogExpert.Controls.LogWindow; - -using System.Collections.Generic; +using LogExpert.Core.Interface; namespace LogExpert.Classes.ILogLineColumnizerCallback { @@ -8,13 +6,14 @@ public class ColumnizerCallback : LogExpert.ILogLineColumnizerCallback, IAutoLog { #region Fields - protected LogWindow _logWindow; + protected ILogWindow _logWindow; + protected IPluginRegistry _pluginRegistry; #endregion #region cTor - public ColumnizerCallback(LogWindow logWindow) + public ColumnizerCallback(ILogWindow logWindow) { _logWindow = logWindow; } @@ -57,7 +56,7 @@ public ILogLine GetLogLine(int lineNum) public IList GetRegisteredColumnizers() { - return PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers; + return _pluginRegistry.RegisteredColumnizers; } public int GetLineCount() diff --git a/src/Logexpert.Core/Classes/Bookmark/BookmarkView.cs b/src/Logexpert.Core/Classes/Bookmark/BookmarkView.cs index c194d5cf..7812f91d 100644 --- a/src/Logexpert.Core/Classes/Bookmark/BookmarkView.cs +++ b/src/Logexpert.Core/Classes/Bookmark/BookmarkView.cs @@ -4,6 +4,7 @@ namespace LogExpert.Core.Classes.Bookmark { + //TODO: Not in use! internal class BookmarkView : IBookmarkView { #region Fields diff --git a/src/Logexpert.Core/Classes/Columnizer/TimestampColumnizer.cs b/src/Logexpert.Core/Classes/Columnizer/TimestampColumnizer.cs index 3b9f3624..fd033f9a 100644 --- a/src/Logexpert.Core/Classes/Columnizer/TimestampColumnizer.cs +++ b/src/Logexpert.Core/Classes/Columnizer/TimestampColumnizer.cs @@ -1,14 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using static LogExpert.Core.Classes.Columnizer.TimeFormatDeterminer; namespace LogExpert.Core.Classes.Columnizer { - using static TimeFormatDeterminer; - public class TimestampColumnizer : ILogLineColumnizer, IColumnizerPriority { - #region ILogLineColumnizer implementation protected int timeOffset = 0; diff --git a/src/LogExpert/Classes/Filter/Filter.cs b/src/Logexpert.Core/Classes/Filter/Filter.cs similarity index 94% rename from src/LogExpert/Classes/Filter/Filter.cs rename to src/Logexpert.Core/Classes/Filter/Filter.cs index 12581e06..80ec7d4b 100644 --- a/src/LogExpert/Classes/Filter/Filter.cs +++ b/src/Logexpert.Core/Classes/Filter/Filter.cs @@ -1,181 +1,182 @@ -using LogExpert.Classes.ILogLineColumnizerCallback; -using LogExpert.Core.Classes; -using LogExpert.Core.Classes.Filter; - -using NLog; - -using System; -using System.Collections.Generic; -using System.Windows.Forms; - -namespace LogExpert.Classes.Filter -{ - internal delegate void FilterFx(FilterParams filterParams, List filterResultLines, List lastFilterResultLines, List filterHitList); - - internal class Filter - { - #region Fields - - private const int PROGRESS_BAR_MODULO = 1000; - private const int SPREAD_MAX = 50; - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - - private readonly ColumnizerCallback _callback; - - #endregion - - #region cTor - - //TODO Is the callback needed? - public Filter(ColumnizerCallback callback) - { - _callback = callback; - FilterResultLines = []; - LastFilterLinesList = []; - FilterHitList = []; - } - - #endregion - - #region Properties - - public List FilterResultLines { get; } - - public List LastFilterLinesList { get; } - - public List FilterHitList { get; } - - public bool ShouldCancel { get; set; } = false; - - #endregion - - #region Public methods - - public int DoFilter(FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) - { - return DoFilter(filterParams, startLine, maxCount, FilterResultLines, LastFilterLinesList, FilterHitList, progressCallback); - } - - #endregion - - #region Private Methods - - private int DoFilter(FilterParams filterParams, int startLine, int maxCount, List filterResultLines, - List lastFilterLinesList, List filterHitList, ProgressCallback progressCallback) - { - int lineNum = startLine; - int count = 0; - int callbackCounter = 0; - - try - { - filterParams.Reset(); - while ((count++ < maxCount || filterParams.IsInRange) && !ShouldCancel) - { - if (lineNum >= _callback.GetLineCount()) - { - return count; - } - - ILogLine line = _callback.GetLogLine(lineNum); - if (line == null) - { - return count; - } - - _callback.LineNum = lineNum; - if (Util.TestFilterCondition(filterParams, line, _callback)) - { - AddFilterLine(lineNum, false, filterParams, filterResultLines, lastFilterLinesList, - filterHitList); - } - - lineNum++; - callbackCounter++; - - if (lineNum % PROGRESS_BAR_MODULO == 0) - { - progressCallback(callbackCounter); - callbackCounter = 0; - } - } - } - catch (Exception ex) - { - _logger.Error(ex, "Exception while filtering. Please report to developer"); - MessageBox.Show(null, - "Exception while filtering. Please report to developer: \n\n" + ex + "\n\n" + ex.StackTrace, - "LogExpert"); - } - - return count; - } - - private void AddFilterLine(int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) - { - filterHitList.Add(lineNum); - IList filterResult = GetAdditionalFilterResults(filterParams, lineNum, lastFilterLinesList); - - filterResultLines.AddRange(filterResult); - - lastFilterLinesList.AddRange(filterResult); - - if (lastFilterLinesList.Count > SPREAD_MAX * 2) - { - lastFilterLinesList.RemoveRange(0, lastFilterLinesList.Count - SPREAD_MAX * 2); - } - } - - - /// - /// Returns a list with 'additional filter results'. This is the given line number - /// and (if back spread and/or fore spread is enabled) some additional lines. - /// This function doesn't check the filter condition! - /// - /// - /// - /// - /// - private IList GetAdditionalFilterResults(FilterParams filterParams, int lineNum, IList checkList) - { - IList resultList = []; - - if (filterParams.SpreadBefore == 0 && filterParams.SpreadBehind == 0) - { - resultList.Add(lineNum); - return resultList; - } - - // back spread - for (int i = filterParams.SpreadBefore; i > 0; --i) - { - if (lineNum - i > 0) - { - if (!resultList.Contains(lineNum - i) && !checkList.Contains(lineNum - i)) - { - resultList.Add(lineNum - i); - } - } - } - // direct filter hit - if (!resultList.Contains(lineNum) && !checkList.Contains(lineNum)) - { - resultList.Add(lineNum); - } - // after spread - for (int i = 1; i <= filterParams.SpreadBehind; ++i) - { - if (lineNum + i < _callback.GetLineCount()) - { - if (!resultList.Contains(lineNum + i) && !checkList.Contains(lineNum + i)) - { - resultList.Add(lineNum + i); - } - } - } - return resultList; - } - - #endregion - } +using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Filter; + +using NLog; + +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace LogExpert.Classes.Filter +{ + internal delegate void FilterFx(FilterParams filterParams, List filterResultLines, List lastFilterResultLines, List filterHitList); + + internal class Filter + { + #region Fields + + private const int PROGRESS_BAR_MODULO = 1000; + private const int SPREAD_MAX = 50; + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + + private readonly ColumnizerCallback _callback; + + #endregion + + #region cTor + + //TODO Is the callback needed? + public Filter(ColumnizerCallback callback) + { + _callback = callback; + FilterResultLines = []; + LastFilterLinesList = []; + FilterHitList = []; + } + + #endregion + + #region Properties + + public List FilterResultLines { get; } + + public List LastFilterLinesList { get; } + + public List FilterHitList { get; } + + public bool ShouldCancel { get; set; } = false; + + #endregion + + #region Public methods + + public int DoFilter(FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) + { + return DoFilter(filterParams, startLine, maxCount, FilterResultLines, LastFilterLinesList, FilterHitList, progressCallback); + } + + #endregion + + #region Private Methods + + private int DoFilter(FilterParams filterParams, int startLine, int maxCount, List filterResultLines, + List lastFilterLinesList, List filterHitList, ProgressCallback progressCallback) + { + int lineNum = startLine; + int count = 0; + int callbackCounter = 0; + + try + { + filterParams.Reset(); + while ((count++ < maxCount || filterParams.IsInRange) && !ShouldCancel) + { + if (lineNum >= _callback.GetLineCount()) + { + return count; + } + + ILogLine line = _callback.GetLogLine(lineNum); + if (line == null) + { + return count; + } + + _callback.LineNum = lineNum; + if (Util.TestFilterCondition(filterParams, line, _callback)) + { + AddFilterLine(lineNum, false, filterParams, filterResultLines, lastFilterLinesList, + filterHitList); + } + + lineNum++; + callbackCounter++; + + if (lineNum % PROGRESS_BAR_MODULO == 0) + { + progressCallback(callbackCounter); + callbackCounter = 0; + } + } + } + catch (Exception ex) + { + _logger.Error(ex, "Exception while filtering. Please report to developer"); + //TODO: This information should be handled from the LogExpert project and not from LogExpert.Core. + //MessageBox.Show(null, + // "Exception while filtering. Please report to developer: \n\n" + ex + "\n\n" + ex.StackTrace, + // "LogExpert"); + } + + return count; + } + + private void AddFilterLine(int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) + { + filterHitList.Add(lineNum); + IList filterResult = GetAdditionalFilterResults(filterParams, lineNum, lastFilterLinesList); + + filterResultLines.AddRange(filterResult); + + lastFilterLinesList.AddRange(filterResult); + + if (lastFilterLinesList.Count > SPREAD_MAX * 2) + { + lastFilterLinesList.RemoveRange(0, lastFilterLinesList.Count - SPREAD_MAX * 2); + } + } + + + /// + /// Returns a list with 'additional filter results'. This is the given line number + /// and (if back spread and/or fore spread is enabled) some additional lines. + /// This function doesn't check the filter condition! + /// + /// + /// + /// + /// + private IList GetAdditionalFilterResults(FilterParams filterParams, int lineNum, IList checkList) + { + IList resultList = []; + + if (filterParams.SpreadBefore == 0 && filterParams.SpreadBehind == 0) + { + resultList.Add(lineNum); + return resultList; + } + + // back spread + for (int i = filterParams.SpreadBefore; i > 0; --i) + { + if (lineNum - i > 0) + { + if (!resultList.Contains(lineNum - i) && !checkList.Contains(lineNum - i)) + { + resultList.Add(lineNum - i); + } + } + } + // direct filter hit + if (!resultList.Contains(lineNum) && !checkList.Contains(lineNum)) + { + resultList.Add(lineNum); + } + // after spread + for (int i = 1; i <= filterParams.SpreadBehind; ++i) + { + if (lineNum + i < _callback.GetLineCount()) + { + if (!resultList.Contains(lineNum + i) && !checkList.Contains(lineNum + i)) + { + resultList.Add(lineNum + i); + } + } + } + return resultList; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Filter/FilterCancelHandler.cs b/src/Logexpert.Core/Classes/Filter/FilterCancelHandler.cs similarity index 86% rename from src/LogExpert/Classes/Filter/FilterCancelHandler.cs rename to src/Logexpert.Core/Classes/Filter/FilterCancelHandler.cs index 9db7932d..6a4c8c6b 100644 --- a/src/LogExpert/Classes/Filter/FilterCancelHandler.cs +++ b/src/Logexpert.Core/Classes/Filter/FilterCancelHandler.cs @@ -1,35 +1,35 @@ -using LogExpert.Core.Interface; - -using NLog; - -namespace LogExpert.Classes.Filter -{ - internal class FilterCancelHandler : BackgroundProcessCancelHandler - { - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - #region Fields - - private readonly FilterStarter _filterStarter; - - #endregion - - #region cTor - - public FilterCancelHandler(FilterStarter filterStarter) - { - _filterStarter = filterStarter; - } - - #endregion - - #region Public methods - - public void EscapePressed() - { - _logger.Info("FilterCancelHandler called."); - _filterStarter.CancelFilter(); - } - - #endregion - } +using LogExpert.Core.Interface; + +using NLog; + +namespace LogExpert.Classes.Filter +{ + public class FilterCancelHandler : IBackgroundProcessCancelHandler + { + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + #region Fields + + private readonly FilterStarter _filterStarter; + + #endregion + + #region cTor + + public FilterCancelHandler(FilterStarter filterStarter) + { + _filterStarter = filterStarter; + } + + #endregion + + #region Public methods + + public void EscapePressed() + { + _logger.Info("FilterCancelHandler called."); + _filterStarter.CancelFilter(); + } + + #endregion + } } \ No newline at end of file diff --git a/src/Logexpert.Core/Classes/Filter/FilterParams.cs b/src/Logexpert.Core/Classes/Filter/FilterParams.cs index c195a46e..d59c9deb 100644 --- a/src/Logexpert.Core/Classes/Filter/FilterParams.cs +++ b/src/Logexpert.Core/Classes/Filter/FilterParams.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Drawing; +using System.Text.Json.Serialization; using System.Text.RegularExpressions; namespace LogExpert.Core.Classes.Filter @@ -70,6 +71,7 @@ public string RangeSearchText // list of columns in which to search public List ColumnList { get; set; } = []; + [JsonIgnore] [field: NonSerialized] public ILogLineColumnizer CurrentColumnizer { get; set; } diff --git a/src/LogExpert/Classes/Filter/FilterPipe.cs b/src/Logexpert.Core/Classes/Filter/FilterPipe.cs similarity index 92% rename from src/LogExpert/Classes/Filter/FilterPipe.cs rename to src/Logexpert.Core/Classes/Filter/FilterPipe.cs index d31f5cac..fecae37f 100644 --- a/src/LogExpert/Classes/Filter/FilterPipe.cs +++ b/src/Logexpert.Core/Classes/Filter/FilterPipe.cs @@ -1,200 +1,199 @@ -using LogExpert.Controls.LogWindow; -using LogExpert.Core.Classes.Filter; - -using NLog; - -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace LogExpert.Classes.Filter -{ - public class FilterPipe - { - #region Fields - - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - - private IList _lineMappingList = new List(); - private StreamWriter _writer; - - #endregion - - #region cTor - - public FilterPipe(FilterParams filterParams, LogWindow logWindow) - { - FilterParams = filterParams; - LogWindow = logWindow; - IsStopped = false; - FileName = Path.GetTempFileName(); - - _logger.Info("Created temp file: {0}", FileName); - } - - #endregion - - #region Delegates - - public delegate void ClosedEventHandler(object sender, EventArgs e); - - #endregion - - #region Events - - public event ClosedEventHandler Closed; - - #endregion - - #region Properties - - public bool IsStopped { get; set; } - - public string FileName { get; } - - public FilterParams FilterParams { get; } - - public IList LastLinesHistoryList { get; } = new List(); - - public LogWindow LogWindow { get; } - - public LogWindow OwnLogWindow { get; set; } - - #endregion - - #region Public methods - - public void OpenFile() - { - FileStream fStream = new(FileName, FileMode.Append, FileAccess.Write, FileShare.Read); - _writer = new StreamWriter(fStream, new UnicodeEncoding(false, false)); - } - - public void CloseFile() - { - if (_writer != null) - { - _writer.Close(); - _writer = null; - } - } - - public bool WriteToPipe(ILogLine textLine, int orgLineNum) - { - try - { - lock (FileName) - { - lock (_lineMappingList) - { - try - { - _writer.WriteLine(textLine.FullLine); - _lineMappingList.Add(orgLineNum); - return true; - } - catch (IOException e) - { - _logger.Error(e, "writeToPipe()"); - return false; - } - } - } - } - catch (IOException ex) - { - _logger.Error(ex, "writeToPipe(): file was closed"); - return false; - } - } - - public int GetOriginalLineNum(int lineNum) - { - lock (_lineMappingList) - { - if (_lineMappingList.Count > lineNum) - { - return _lineMappingList[lineNum]; - } - - return -1; - } - } - - public void ShiftLineNums(int offset) - { - _logger.Debug("FilterPipe.ShiftLineNums() offset={0}", offset); - List newList = []; - lock (_lineMappingList) - { - foreach (int lineNum in _lineMappingList) - { - int line = lineNum - offset; - if (line >= 0) - { - newList.Add(line); - } - else - { - newList.Add(-1); - } - } - _lineMappingList = newList; - } - } - - public void ClearLineNums() - { - _logger.Debug("FilterPipe.ClearLineNums()"); - lock (_lineMappingList) - { - for (int i = 0; i < _lineMappingList.Count; ++i) - { - _lineMappingList[i] = -1; - } - } - } - - public void ClearLineList() - { - lock (_lineMappingList) - { - _lineMappingList.Clear(); - } - } - - public void RecreateTempFile() - { - lock (_lineMappingList) - { - _lineMappingList = new List(); - } - lock (FileName) - { - CloseFile(); - // trunc file - FileStream fStream = new(FileName, FileMode.Truncate, FileAccess.Write, FileShare.Read); - fStream.SetLength(0); - fStream.Close(); - } - } - - public void CloseAndDisconnect() - { - ClearLineList(); - OnClosed(); - } - - #endregion - - #region Private Methods - - private void OnClosed() - { - Closed?.Invoke(this, EventArgs.Empty); - } - - #endregion - } +using LogExpert.Core.Classes.Filter; +using LogExpert.Core.Interface; +using NLog; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace LogExpert.Classes.Filter +{ + public class FilterPipe + { + #region Fields + + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + + private IList _lineMappingList = new List(); + private StreamWriter _writer; + + #endregion + + #region cTor + + public FilterPipe(FilterParams filterParams, ILogWindow logWindow) + { + FilterParams = filterParams; + LogWindow = logWindow; + IsStopped = false; + FileName = Path.GetTempFileName(); + + _logger.Info("Created temp file: {0}", FileName); + } + + #endregion + + #region Delegates + + public delegate void ClosedEventHandler(object sender, EventArgs e); + + #endregion + + #region Events + + public event ClosedEventHandler Closed; + + #endregion + + #region Properties + + public bool IsStopped { get; set; } + + public string FileName { get; } + + public FilterParams FilterParams { get; } + + public IList LastLinesHistoryList { get; } = new List(); + + public ILogWindow LogWindow { get; } + + public ILogWindow OwnLogWindow { get; set; } + + #endregion + + #region Public methods + + public void OpenFile() + { + FileStream fStream = new(FileName, FileMode.Append, FileAccess.Write, FileShare.Read); + _writer = new StreamWriter(fStream, new UnicodeEncoding(false, false)); + } + + public void CloseFile() + { + if (_writer != null) + { + _writer.Close(); + _writer = null; + } + } + + public bool WriteToPipe(ILogLine textLine, int orgLineNum) + { + try + { + lock (FileName) + { + lock (_lineMappingList) + { + try + { + _writer.WriteLine(textLine.FullLine); + _lineMappingList.Add(orgLineNum); + return true; + } + catch (IOException e) + { + _logger.Error(e, "writeToPipe()"); + return false; + } + } + } + } + catch (IOException ex) + { + _logger.Error(ex, "writeToPipe(): file was closed"); + return false; + } + } + + public int GetOriginalLineNum(int lineNum) + { + lock (_lineMappingList) + { + if (_lineMappingList.Count > lineNum) + { + return _lineMappingList[lineNum]; + } + + return -1; + } + } + + public void ShiftLineNums(int offset) + { + _logger.Debug("FilterPipe.ShiftLineNums() offset={0}", offset); + List newList = []; + lock (_lineMappingList) + { + foreach (int lineNum in _lineMappingList) + { + int line = lineNum - offset; + if (line >= 0) + { + newList.Add(line); + } + else + { + newList.Add(-1); + } + } + _lineMappingList = newList; + } + } + + public void ClearLineNums() + { + _logger.Debug("FilterPipe.ClearLineNums()"); + lock (_lineMappingList) + { + for (int i = 0; i < _lineMappingList.Count; ++i) + { + _lineMappingList[i] = -1; + } + } + } + + public void ClearLineList() + { + lock (_lineMappingList) + { + _lineMappingList.Clear(); + } + } + + public void RecreateTempFile() + { + lock (_lineMappingList) + { + _lineMappingList = new List(); + } + lock (FileName) + { + CloseFile(); + // trunc file + FileStream fStream = new(FileName, FileMode.Truncate, FileAccess.Write, FileShare.Read); + fStream.SetLength(0); + fStream.Close(); + } + } + + public void CloseAndDisconnect() + { + ClearLineList(); + OnClosed(); + } + + #endregion + + #region Private Methods + + private void OnClosed() + { + Closed?.Invoke(this, EventArgs.Empty); + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Filter/FilterStarter.cs b/src/Logexpert.Core/Classes/Filter/FilterStarter.cs similarity index 96% rename from src/LogExpert/Classes/Filter/FilterStarter.cs rename to src/Logexpert.Core/Classes/Filter/FilterStarter.cs index cbce334b..672f33c8 100644 --- a/src/LogExpert/Classes/Filter/FilterStarter.cs +++ b/src/Logexpert.Core/Classes/Filter/FilterStarter.cs @@ -1,225 +1,225 @@ -using LogExpert.Classes.ILogLineColumnizerCallback; -using LogExpert.Core.Classes.Filter; - -using NLog; - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace LogExpert.Classes.Filter -{ - public delegate void ProgressCallback(int lineCount); - - internal class FilterStarter - { - #region Fields - - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - - private readonly ColumnizerCallback _callback; - private readonly SortedDictionary _filterHitDict; - private readonly List _filterReadyList; - private readonly SortedDictionary _filterResultDict; - - private readonly List _filterWorkerList; - - private readonly SortedDictionary _lastFilterLinesDict; - - private ProgressCallback _progressCallback; - private int _progressLineCount; - private bool _shouldStop; - - #endregion - - #region cTor - - public FilterStarter(ColumnizerCallback callback, int minThreads) - { - _callback = callback; - FilterResultLines = []; - LastFilterLinesList = []; - FilterHitList = []; - _filterReadyList = []; - _filterWorkerList = []; - _filterHitDict = []; - _filterResultDict = []; - _lastFilterLinesDict = []; - ThreadCount = Environment.ProcessorCount * 4; - ThreadCount = minThreads; - ThreadPool.GetMinThreads(out _, out var completion); - ThreadPool.SetMinThreads(minThreads, completion); - ThreadPool.GetMaxThreads(out _, out _); - } - - #endregion - - #region Properties - - public List FilterResultLines { get; set; } - - public List LastFilterLinesList { get; set; } - - public List FilterHitList { get; set; } - - public int ThreadCount { get; set; } - - #endregion - - #region Public methods - - public async void DoFilter(FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) - { - FilterResultLines.Clear(); - LastFilterLinesList.Clear(); - FilterHitList.Clear(); - _filterHitDict.Clear(); - _filterReadyList.Clear(); - _filterResultDict.Clear(); - _lastFilterLinesDict.Clear(); - _filterWorkerList.Clear(); - _shouldStop = false; - - int interval = maxCount / ThreadCount; - - if (interval < 1) - { - interval = 1; - } - int workStartLine = startLine; - List handleList = []; - _progressLineCount = 0; - _progressCallback = progressCallback; - while (workStartLine < startLine + maxCount) - { - if (workStartLine + interval > maxCount) - { - interval = maxCount - workStartLine; - if (interval == 0) - { - break; - } - } - _logger.Info("FilterStarter starts worker for line {0}, lineCount {1}", workStartLine, interval); - - await Task.Run(() => DoWork(filterParams, workStartLine, interval, ThreadProgressCallback)).ContinueWith(FilterDoneCallback); - workStartLine += interval; - } - - WaitHandle[] handles = [.. handleList]; - // wait for worker threads completion - if (handles.Length > 0) - { - WaitHandle.WaitAll(handles); - } - - MergeResults(); - } - - /// - /// Requests the FilterStarter to stop all filter threads. Call this from another thread (e.g. GUI). The function returns - /// immediately without waiting for filter end. - /// - public void CancelFilter() - { - _shouldStop = true; - lock (_filterWorkerList) - { - _logger.Info("Filter cancel requested. Stopping all {0} threads.", _filterWorkerList.Count); - foreach (Filter filter in _filterWorkerList) - { - filter.ShouldCancel = true; - } - } - } - - #endregion - - #region Private Methods - - private void ThreadProgressCallback(int lineCount) - { - int count = Interlocked.Add(ref _progressLineCount, lineCount); - _progressCallback(count); - } - - private Filter DoWork(FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) - { - _logger.Info("Started Filter worker [{0}] for line {1}", Environment.CurrentManagedThreadId, startLine); - - // Give every thread own copies of ColumnizerCallback and FilterParams, because the state of the objects changes while filtering - FilterParams threadFilterParams = filterParams.CloneWithCurrentColumnizer(); - ColumnizerCallback threadColumnizerCallback = _callback.CreateCopy(); - - Filter filter = new(threadColumnizerCallback); - lock (_filterWorkerList) - { - _filterWorkerList.Add(filter); - } - - if (_shouldStop) - { - return filter; - } - - _ = filter.DoFilter(threadFilterParams, startLine, maxCount, progressCallback); - _logger.Info("Filter worker [{0}] for line {1} has completed.", Thread.CurrentThread.ManagedThreadId, startLine); - - lock (_filterReadyList) - { - _filterReadyList.Add(filter); - } - - return filter; - } - - private void FilterDoneCallback(Task filterTask) - { - if (filterTask.IsCompleted) - { - Filter filter = filterTask.Result; - - lock (_filterReadyList) - { - _filterReadyList.Add(filter); - } - } - } - - private void MergeResults() - { - _logger.Info("Merging filter results."); - foreach (Filter filter in _filterReadyList) - { - foreach (int lineNum in filter.FilterHitList) - { - if (!_filterHitDict.ContainsKey(lineNum)) - { - _filterHitDict.Add(lineNum, lineNum); - } - } - foreach (int lineNum in filter.FilterResultLines) - { - if (!_filterResultDict.ContainsKey(lineNum)) - { - _filterResultDict.Add(lineNum, lineNum); - } - } - foreach (int lineNum in filter.LastFilterLinesList) - { - if (!_lastFilterLinesDict.ContainsKey(lineNum)) - { - _lastFilterLinesDict.Add(lineNum, lineNum); - } - } - } - FilterHitList.AddRange(_filterHitDict.Keys); - FilterResultLines.AddRange(_filterResultDict.Keys); - LastFilterLinesList.AddRange(_lastFilterLinesDict.Keys); - _logger.Info("Merging done."); - } - - #endregion - } +using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Classes.Filter; + +using NLog; + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace LogExpert.Classes.Filter +{ + public delegate void ProgressCallback(int lineCount); + + public class FilterStarter + { + #region Fields + + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + + private readonly ColumnizerCallback _callback; + private readonly SortedDictionary _filterHitDict; + private readonly List _filterReadyList; + private readonly SortedDictionary _filterResultDict; + + private readonly List _filterWorkerList; + + private readonly SortedDictionary _lastFilterLinesDict; + + private ProgressCallback _progressCallback; + private int _progressLineCount; + private bool _shouldStop; + + #endregion + + #region cTor + + public FilterStarter(ColumnizerCallback callback, int minThreads) + { + _callback = callback; + FilterResultLines = []; + LastFilterLinesList = []; + FilterHitList = []; + _filterReadyList = []; + _filterWorkerList = []; + _filterHitDict = []; + _filterResultDict = []; + _lastFilterLinesDict = []; + ThreadCount = Environment.ProcessorCount * 4; + ThreadCount = minThreads; + ThreadPool.GetMinThreads(out _, out var completion); + ThreadPool.SetMinThreads(minThreads, completion); + ThreadPool.GetMaxThreads(out _, out _); + } + + #endregion + + #region Properties + + public List FilterResultLines { get; set; } + + public List LastFilterLinesList { get; set; } + + public List FilterHitList { get; set; } + + public int ThreadCount { get; set; } + + #endregion + + #region Public methods + + public async void DoFilter(FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) + { + FilterResultLines.Clear(); + LastFilterLinesList.Clear(); + FilterHitList.Clear(); + _filterHitDict.Clear(); + _filterReadyList.Clear(); + _filterResultDict.Clear(); + _lastFilterLinesDict.Clear(); + _filterWorkerList.Clear(); + _shouldStop = false; + + int interval = maxCount / ThreadCount; + + if (interval < 1) + { + interval = 1; + } + int workStartLine = startLine; + List handleList = []; + _progressLineCount = 0; + _progressCallback = progressCallback; + while (workStartLine < startLine + maxCount) + { + if (workStartLine + interval > maxCount) + { + interval = maxCount - workStartLine; + if (interval == 0) + { + break; + } + } + _logger.Info("FilterStarter starts worker for line {0}, lineCount {1}", workStartLine, interval); + + await Task.Run(() => DoWork(filterParams, workStartLine, interval, ThreadProgressCallback)).ContinueWith(FilterDoneCallback); + workStartLine += interval; + } + + WaitHandle[] handles = [.. handleList]; + // wait for worker threads completion + if (handles.Length > 0) + { + WaitHandle.WaitAll(handles); + } + + MergeResults(); + } + + /// + /// Requests the FilterStarter to stop all filter threads. Call this from another thread (e.g. GUI). The function returns + /// immediately without waiting for filter end. + /// + public void CancelFilter() + { + _shouldStop = true; + lock (_filterWorkerList) + { + _logger.Info("Filter cancel requested. Stopping all {0} threads.", _filterWorkerList.Count); + foreach (Filter filter in _filterWorkerList) + { + filter.ShouldCancel = true; + } + } + } + + #endregion + + #region Private Methods + + private void ThreadProgressCallback(int lineCount) + { + int count = Interlocked.Add(ref _progressLineCount, lineCount); + _progressCallback(count); + } + + private Filter DoWork(FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) + { + _logger.Info("Started Filter worker [{0}] for line {1}", Environment.CurrentManagedThreadId, startLine); + + // Give every thread own copies of ColumnizerCallback and FilterParams, because the state of the objects changes while filtering + FilterParams threadFilterParams = filterParams.CloneWithCurrentColumnizer(); + ColumnizerCallback threadColumnizerCallback = _callback.CreateCopy(); + + Filter filter = new(threadColumnizerCallback); + lock (_filterWorkerList) + { + _filterWorkerList.Add(filter); + } + + if (_shouldStop) + { + return filter; + } + + _ = filter.DoFilter(threadFilterParams, startLine, maxCount, progressCallback); + _logger.Info("Filter worker [{0}] for line {1} has completed.", Thread.CurrentThread.ManagedThreadId, startLine); + + lock (_filterReadyList) + { + _filterReadyList.Add(filter); + } + + return filter; + } + + private void FilterDoneCallback(Task filterTask) + { + if (filterTask.IsCompleted) + { + Filter filter = filterTask.Result; + + lock (_filterReadyList) + { + _filterReadyList.Add(filter); + } + } + } + + private void MergeResults() + { + _logger.Info("Merging filter results."); + foreach (Filter filter in _filterReadyList) + { + foreach (int lineNum in filter.FilterHitList) + { + if (!_filterHitDict.ContainsKey(lineNum)) + { + _filterHitDict.Add(lineNum, lineNum); + } + } + foreach (int lineNum in filter.FilterResultLines) + { + if (!_filterResultDict.ContainsKey(lineNum)) + { + _filterResultDict.Add(lineNum, lineNum); + } + } + foreach (int lineNum in filter.LastFilterLinesList) + { + if (!_lastFilterLinesDict.ContainsKey(lineNum)) + { + _lastFilterLinesDict.Add(lineNum, lineNum); + } + } + } + FilterHitList.AddRange(_filterHitDict.Keys); + FilterResultLines.AddRange(_filterResultDict.Keys); + LastFilterLinesList.AddRange(_lastFilterLinesDict.Keys); + _logger.Info("Merging done."); + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Log/LogfileReader.cs b/src/Logexpert.Core/Classes/Log/LogfileReader.cs similarity index 96% rename from src/LogExpert/Classes/Log/LogfileReader.cs rename to src/Logexpert.Core/Classes/Log/LogfileReader.cs index f55f6373..944e4624 100644 --- a/src/LogExpert/Classes/Log/LogfileReader.cs +++ b/src/Logexpert.Core/Classes/Log/LogfileReader.cs @@ -1,1846 +1,1833 @@ -using LogExpert.Core.Classes; -using LogExpert.Core.Classes.Log; -using LogExpert.Core.Classes.xml; -using LogExpert.Core.Entities; -using LogExpert.Core.EventArgs; -using LogExpert.Core.Interface; - -using NLog; - -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace LogExpert.Classes.Log -{ - public class LogfileReader : IAutoLogLineColumnizerCallback - { - #region Fields - - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - - private readonly GetLogLineFx _logLineFx; - - private readonly string _fileName; - private readonly int _MAX_BUFFERS = 10; - private readonly int _MAX_LINES_PER_BUFFER = 100; - - private readonly object _monitor = new(); - private readonly MultiFileOptions _multiFileOptions; - - private IList _bufferList; - private ReaderWriterLock _bufferListLock; - private IList _bufferLru; - private bool _contentDeleted; - private int _currLineCount; - private ReaderWriterLock _disposeLock; - private EncodingOptions _encodingOptions; - private long _fileLength; - - private Task _garbageCollectorTask; - private Task _monitorTask; - private readonly CancellationTokenSource cts = new(); - - private bool _isDeleted; - private bool _isFailModeCheckCallPending; - private bool _isFastFailOnGetLogLine; - private bool _isLineCountDirty = true; - private IList _logFileInfoList = []; - private Dictionary _lruCacheDict; - - private ReaderWriterLock _lruCacheDictLock; - - private bool _shouldStop; - private ILogFileInfo _watchedILogFileInfo; - - #endregion - - #region cTor - - public LogfileReader(string fileName, EncodingOptions encodingOptions, bool multiFile, int bufferCount, int linesPerBuffer, MultiFileOptions multiFileOptions) - { - if (fileName == null) - { - return; - } - - _fileName = fileName; - EncodingOptions = encodingOptions; - IsMultiFile = multiFile; - _MAX_BUFFERS = bufferCount; - _MAX_LINES_PER_BUFFER = linesPerBuffer; - _multiFileOptions = multiFileOptions; - _logLineFx = GetLogLineInternal; - InitLruBuffers(); - - if (multiFile) - { - ILogFileInfo info = GetLogFileInfo(fileName); - RolloverFilenameHandler rolloverHandler = new(info, _multiFileOptions); - LinkedList nameList = rolloverHandler.GetNameList(); - - ILogFileInfo fileInfo = null; - foreach (string name in nameList) - { - fileInfo = AddFile(name); - } - - _watchedILogFileInfo = fileInfo; // last added file in the list is the watched file - } - else - { - _watchedILogFileInfo = AddFile(fileName); - } - - StartGCThread(); - } - - public LogfileReader(string[] fileNames, EncodingOptions encodingOptions, int bufferCount, int linesPerBuffer, MultiFileOptions multiFileOptions) - { - if (fileNames == null || fileNames.Length < 1) - { - return; - } - - EncodingOptions = encodingOptions; - IsMultiFile = true; - _MAX_BUFFERS = bufferCount; - _MAX_LINES_PER_BUFFER = linesPerBuffer; - _multiFileOptions = multiFileOptions; - _logLineFx = GetLogLineInternal; - - InitLruBuffers(); - - ILogFileInfo fileInfo = null; - foreach (string name in fileNames) - { - fileInfo = AddFile(name); - } - - _watchedILogFileInfo = fileInfo; - _fileName = fileInfo.FullName; - - StartGCThread(); - } - - #endregion - - #region Delegates - - public delegate void BlockLoadedEventHandler(object sender, LoadFileEventArgs e); - - public delegate void FileNotFoundEventHandler(object sender, EventArgs e); - - public delegate void FileRespawnedEventHandler(object sender, EventArgs e); - - public delegate void FileSizeChangedEventHandler(object sender, LogEventArgs e); - - public delegate void FinishedLoadingEventHandler(object sender, EventArgs e); - - private delegate Task GetLogLineFx(int lineNum); - - public delegate void LoadingStartedEventHandler(object sender, LoadFileEventArgs e); - - #endregion - - #region Events - - public event FileSizeChangedEventHandler FileSizeChanged; - public event BlockLoadedEventHandler LoadFile; - public event LoadingStartedEventHandler LoadingStarted; - public event FinishedLoadingEventHandler LoadingFinished; - public event FileNotFoundEventHandler FileNotFound; - public event FileRespawnedEventHandler Respawned; - - #endregion - - #region Properties - - public int LineCount - { - get - { - if (_isLineCountDirty) - { - _currLineCount = 0; - AcquireBufferListReaderLock(); - foreach (LogBuffer buffer in _bufferList) - { - _currLineCount += buffer.LineCount; - } - - ReleaseBufferListReaderLock(); - _isLineCountDirty = false; - } - - return _currLineCount; - } - set => _currLineCount = value; - } - - public bool IsMultiFile { get; } - - public Encoding CurrentEncoding { get; private set; } - - public long FileSize { get; private set; } - - public bool IsXmlMode { get; set; } = false; - - public IXmlLogConfiguration XmlLogConfig { get; set; } - - public IPreProcessColumnizer PreProcessColumnizer { get; set; } = null; - - public EncodingOptions EncodingOptions - { - get => _encodingOptions; - set - { - { - _encodingOptions = new EncodingOptions - { - DefaultEncoding = value.DefaultEncoding, - Encoding = value.Encoding - }; - } - } - } - - public bool UseNewReader { get; set; } - - #endregion - - #region Public methods - - /// - /// Public for unit test reasons - /// - public void ReadFiles() - { - FileSize = 0; - LineCount = 0; - //this.lastReturnedLine = ""; - //this.lastReturnedLineNum = -1; - //this.lastReturnedLineNumForBuffer = -1; - _isDeleted = false; - ClearLru(); - AcquireBufferListWriterLock(); - _bufferList.Clear(); - ReleaseBufferListWriterLock(); - try - { - foreach (ILogFileInfo info in _logFileInfoList) - { - //info.OpenFile(); - ReadToBufferList(info, 0, LineCount); - } - - if (_logFileInfoList.Count > 0) - { - ILogFileInfo info = _logFileInfoList[_logFileInfoList.Count - 1]; - _fileLength = info.Length; - _watchedILogFileInfo = info; - } - } - catch (IOException e) - { - _logger.Warn(e, "IOException"); - _fileLength = 0; - _isDeleted = true; - LineCount = 0; - } - - LogEventArgs args = new() - { - PrevFileSize = 0, - PrevLineCount = 0, - LineCount = LineCount, - FileSize = FileSize - }; - - OnFileSizeChanged(args); - } - - /// - /// Public for unit tests. - /// - /// - public int ShiftBuffers() - { - _logger.Info("ShiftBuffers() begin for {0}{1}", _fileName, IsMultiFile ? " (MultiFile)" : ""); - AcquireBufferListWriterLock(); - int offset = 0; - _isLineCountDirty = true; - lock (_monitor) - { - RolloverFilenameHandler rolloverHandler = new(_watchedILogFileInfo, _multiFileOptions); - LinkedList fileNameList = rolloverHandler.GetNameList(); - - ResetBufferCache(); - IList lostILogFileInfoList = []; - IList readNewILogFileInfoList = []; - IList newFileInfoList = []; - IEnumerator enumerator = _logFileInfoList.GetEnumerator(); - while (enumerator.MoveNext()) - { - ILogFileInfo logFileInfo = enumerator.Current; - string fileName = logFileInfo.FullName; - _logger.Debug("Testing file {0}", fileName); - LinkedListNode node = fileNameList.Find(fileName); - if (node == null) - { - _logger.Warn("File {0} not found", fileName); - continue; - } - - if (node.Previous != null) - { - fileName = node.Previous.Value; - ILogFileInfo newILogFileInfo = GetLogFileInfo(fileName); - _logger.Debug("{0} exists\r\nOld size={1}, new size={2}", fileName, logFileInfo.OriginalLength, newILogFileInfo.Length); - // is the new file the same as the old buffer info? - if (newILogFileInfo.Length == logFileInfo.OriginalLength) - { - ReplaceBufferInfos(logFileInfo, newILogFileInfo); - newFileInfoList.Add(newILogFileInfo); - } - else - { - _logger.Debug("Buffer for {0} must be re-read.", fileName); - // not the same. so must read the rest of the list anew from the files - readNewILogFileInfoList.Add(newILogFileInfo); - while (enumerator.MoveNext()) - { - fileName = enumerator.Current.FullName; - node = fileNameList.Find(fileName); - if (node == null) - { - _logger.Warn("File {0} not found", fileName); - continue; - } - - if (node.Previous != null) - { - fileName = node.Previous.Value; - _logger.Debug("New name is {0}", fileName); - readNewILogFileInfoList.Add(GetLogFileInfo(fileName)); - } - else - { - _logger.Warn("No previous file for {0} found", fileName); - } - } - } - } - else - { - _logger.Info("{0} does not exist", fileName); - lostILogFileInfoList.Add(logFileInfo); -#if DEBUG // for better overview in logfile: - //ILogFileInfo newILogFileInfo = new ILogFileInfo(fileName); - //ReplaceBufferInfos(ILogFileInfo, newILogFileInfo); -#endif - } - } - - if (lostILogFileInfoList.Count > 0) - { - _logger.Info("Deleting buffers for lost files"); - foreach (ILogFileInfo ILogFileInfo in lostILogFileInfoList) - { - //this.ILogFileInfoList.Remove(ILogFileInfo); - LogBuffer lastBuffer = DeleteBuffersForInfo(ILogFileInfo, false); - if (lastBuffer != null) - { - offset += lastBuffer.StartLine + lastBuffer.LineCount; - } - } - - _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); - _logger.Info("Adjusting StartLine values in {0} buffers by offset {1}", _bufferList.Count, offset); - foreach (LogBuffer buffer in _bufferList) - { - SetNewStartLineForBuffer(buffer, buffer.StartLine - offset); - } - - _lruCacheDictLock.ReleaseWriterLock(); -#if DEBUG - if (_bufferList.Count > 0) - { - _logger.Debug("First buffer now has StartLine {0}", _bufferList[0].StartLine); - } -#endif - } - - // Read anew all buffers following a buffer info that couldn't be matched with the corresponding existing file - _logger.Info("Deleting buffers for files that must be re-read"); - foreach (ILogFileInfo ILogFileInfo in readNewILogFileInfoList) - { - DeleteBuffersForInfo(ILogFileInfo, true); - //this.ILogFileInfoList.Remove(ILogFileInfo); - } - - _logger.Info("Deleting buffers for the watched file"); - DeleteBuffersForInfo(_watchedILogFileInfo, true); - int startLine = LineCount - 1; - _logger.Info("Re-Reading files"); - foreach (ILogFileInfo ILogFileInfo in readNewILogFileInfoList) - { - //ILogFileInfo.OpenFile(); - ReadToBufferList(ILogFileInfo, 0, LineCount); - //this.ILogFileInfoList.Add(ILogFileInfo); - newFileInfoList.Add(ILogFileInfo); - } - - //this.watchedILogFileInfo = this.ILogFileInfoList[this.ILogFileInfoList.Count - 1]; - _logFileInfoList = newFileInfoList; - _watchedILogFileInfo = GetLogFileInfo(_watchedILogFileInfo.FullName); - _logFileInfoList.Add(_watchedILogFileInfo); - _logger.Info("Reading watched file"); - ReadToBufferList(_watchedILogFileInfo, 0, LineCount); - } - - _logger.Info("ShiftBuffers() end. offset={0}", offset); - ReleaseBufferListWriterLock(); - return offset; - } - - public ILogLine GetLogLine(int lineNum) - { - return GetLogLineInternal(lineNum).Result; - } - - /// - /// Get the text content of the given line number. - /// The actual work is done in an async thread. This method waits for thread completion for only 1 second. If the async - /// thread has not returned, the method will return null. This is because this method is also called from GUI thread - /// (e.g. LogWindow draw events). Under some circumstances, repeated calls to this method would lead the GUI to freeze. E.g. when - /// trying to re-load content from disk but the file was deleted. Especially on network shares. - /// - /// - /// Once the method detects a timeout it will enter a kind of 'fast fail mode'. That means all following calls will be returned with - /// null immediately (without 1 second wait). A background call to GetLogLineInternal() will check if a result is available. - /// If so, the 'fast fail mode' is switched off. In most cases a fail is caused by a deleted file. But it may also be caused by slow - /// network connections. So all this effort is needed to prevent entering an endless 'fast fail mode' just because of temporary problems. - /// - /// line to retrieve - /// - public async Task GetLogLineWithWait(int lineNum) - { - const int WAIT_TIME = 1000; - - ILogLine result = null; - - if (!_isFastFailOnGetLogLine) - { - var task = Task.Run(() => _logLineFx(lineNum)); - if (task.Wait(WAIT_TIME)) - { - result = task.Result; - _isFastFailOnGetLogLine = false; - } - else - { - _isFastFailOnGetLogLine = true; - _logger.Debug("No result after {0}ms. Returning .", WAIT_TIME); - } - } - else - { - _logger.Debug("Fast failing GetLogLine()"); - if (!_isFailModeCheckCallPending) - { - _isFailModeCheckCallPending = true; - var logLine = await _logLineFx(lineNum); - GetLineFinishedCallback(logLine); - } - } - - return result; - } - - /// - /// Returns the file name of the actual file for the given line. Needed for MultiFile. - /// - /// - /// - public string GetLogFileNameForLine(int lineNum) - { - AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); - string fileName = logBuffer?.FileInfo.FullName; - ReleaseBufferListReaderLock(); - return fileName; - } - - /// - /// Returns the ILogFileInfo for the actual file for the given line. Needed for MultiFile. - /// - /// - /// - public ILogFileInfo GetLogFileInfoForLine(int lineNum) - { - AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); - ILogFileInfo info = logBuffer?.FileInfo; - ReleaseBufferListReaderLock(); - return info; - } - - /// - /// Returns the line number (starting from the given number) where the next multi file - /// starts. - /// - /// - /// - public int GetNextMultiFileLine(int lineNum) - { - int result = -1; - AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); - if (logBuffer != null) - { - int index = _bufferList.IndexOf(logBuffer); - if (index != -1) - { - for (int i = index; i < _bufferList.Count; ++i) - { - if (_bufferList[i].FileInfo != logBuffer.FileInfo) - { - result = _bufferList[i].StartLine; - break; - } - } - } - } - - ReleaseBufferListReaderLock(); - return result; - } - - public int GetPrevMultiFileLine(int lineNum) - { - int result = -1; - AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); - if (logBuffer != null) - { - int index = _bufferList.IndexOf(logBuffer); - if (index != -1) - { - for (int i = index; i >= 0; --i) - { - if (_bufferList[i].FileInfo != logBuffer.FileInfo) - { - result = _bufferList[i].StartLine + _bufferList[i].LineCount; - break; - } - } - } - } - - ReleaseBufferListReaderLock(); - return result; - } - - /// - /// Returns the actual line number in the file for the given 'virtual line num'. - /// This is needed for multi file mode. 'Virtual' means that the given line num is a line - /// number in the collections of the files currently viewed together in multi file mode as one large virtual file. - /// This method finds the real file for the line number and maps the line number to the correct position - /// in that file. This is needed when launching external tools to provide correct line number arguments. - /// - /// - /// - public int GetRealLineNumForVirtualLineNum(int lineNum) - { - AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); - int result = -1; - if (logBuffer != null) - { - logBuffer = GetFirstBufferForFileByLogBuffer(logBuffer); - if (logBuffer != null) - { - result = lineNum - logBuffer.StartLine; - } - } - - ReleaseBufferListReaderLock(); - return result; - } - - public void StartMonitoring() - { - _logger.Info("startMonitoring()"); - _monitorTask = Task.Run(MonitorThreadProc, cts.Token); - _shouldStop = false; - } - - public void StopMonitoring() - { - _logger.Info("stopMonitoring()"); - _shouldStop = true; - - Thread.Sleep(_watchedILogFileInfo.PollInterval); // leave time for the threads to stop by themselves - - if (_monitorTask != null) - { - if (_monitorTask.Status == TaskStatus.Running) // if thread has not finished, abort it - { - cts.Cancel(); - } - } - - if (_garbageCollectorTask.IsCanceled == false) - { - if (_garbageCollectorTask.Status == TaskStatus.Running) // if thread has not finished, abort it - { - cts.Cancel(); - } - } - - //this.loadThread = null; - //_monitorThread = null; - //_garbageCollectorThread = null; // preventive call - CloseFiles(); - } - - /// - /// calls stopMonitoring() in a background thread and returns to the caller immediately. - /// This is useful for a fast responding GUI (e.g. when closing a file tab) - /// - public void StopMonitoringAsync() - { - Task task = Task.Run(StopMonitoring); - - //Thread stopperThread = new(new ThreadStart(StopMonitoring)) - //{ - // IsBackground = true - //}; - //stopperThread.Start(); - } - - /// - /// Deletes all buffer lines and disposes their content. Use only when the LogfileReader - /// is about to be closed! - /// - public void DeleteAllContent() - { - if (_contentDeleted) - { - _logger.Debug("Buffers for {0} already deleted.", Util.GetNameFromPath(_fileName)); - return; - } - - _logger.Info("Deleting all log buffers for {0}. Used mem: {1:N0}", Util.GetNameFromPath(_fileName), GC.GetTotalMemory(true)); //TODO [Z] uh GC collect calls creepy - AcquireBufferListWriterLock(); - _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); - _disposeLock.AcquireWriterLock(Timeout.Infinite); - - foreach (LogBuffer logBuffer in _bufferList) - { - if (!logBuffer.IsDisposed) - { - logBuffer.DisposeContent(); - } - } - - _lruCacheDict.Clear(); - _bufferList.Clear(); - - _disposeLock.ReleaseWriterLock(); - _lruCacheDictLock.ReleaseWriterLock(); - ReleaseBufferListWriterLock(); - GC.Collect(); - _contentDeleted = true; - _logger.Info("Deleting complete. Used mem: {0:N0}", GC.GetTotalMemory(true)); //TODO [Z] uh GC collect calls creepy - } - - /// - /// Explicit change the encoding. - /// - /// - public void ChangeEncoding(Encoding encoding) - { - CurrentEncoding = encoding; - EncodingOptions.Encoding = encoding; - ResetBufferCache(); - ClearLru(); - } - - /// - /// For unit tests only. - /// - /// - public IList GetLogFileInfoList() - { - return _logFileInfoList; - } - - /// - /// For unit tests only - /// - /// - public IList GetBufferList() - { - return _bufferList; - } - - #endregion - - #region Internals - -#if DEBUG - - public void LogBufferInfoForLine(int lineNum) - { - AcquireBufferListReaderLock(); - LogBuffer buffer = GetBufferForLine(lineNum); - if (buffer == null) - { - ReleaseBufferListReaderLock(); - _logger.Error("Cannot find buffer for line {0}, file: {1}{2}", lineNum, _fileName, IsMultiFile ? " (MultiFile)" : ""); - return; - } - - _logger.Info("-----------------------------------"); - _disposeLock.AcquireReaderLock(Timeout.Infinite); - _logger.Info("Buffer info for line {0}", lineNum); - DumpBufferInfos(buffer); - _logger.Info("File pos for current line: {0}", buffer.GetFilePosForLineOfBlock(lineNum - buffer.StartLine)); - _disposeLock.ReleaseReaderLock(); - _logger.Info("-----------------------------------"); - ReleaseBufferListReaderLock(); - } -#endif - -#if DEBUG - public void LogBufferDiagnostic() - { - _logger.Info("-------- Buffer diagnostics -------"); - _lruCacheDictLock.AcquireReaderLock(Timeout.Infinite); - int cacheCount = _lruCacheDict.Count; - _logger.Info("LRU entries: {0}", cacheCount); - _lruCacheDictLock.ReleaseReaderLock(); - - AcquireBufferListReaderLock(); - _logger.Info("File: {0}\r\nBuffer count: {1}\r\nDisposed buffers: {2}", _fileName, _bufferList.Count, _bufferList.Count - cacheCount); - int lineNum = 0; - long disposeSum = 0; - long maxDispose = 0; - long minDispose = int.MaxValue; - for (int i = 0; i < _bufferList.Count; ++i) - { - LogBuffer buffer = _bufferList[i]; - _disposeLock.AcquireReaderLock(Timeout.Infinite); - if (buffer.StartLine != lineNum) - { - _logger.Error("Start line of buffer is: {0}, expected: {1}", buffer.StartLine, lineNum); - _logger.Info("Info of buffer follows:"); - DumpBufferInfos(buffer); - } - - lineNum += buffer.LineCount; - disposeSum += buffer.DisposeCount; - maxDispose = Math.Max(maxDispose, buffer.DisposeCount); - minDispose = Math.Min(minDispose, buffer.DisposeCount); - _disposeLock.ReleaseReaderLock(); - } - - ReleaseBufferListReaderLock(); - _logger.Info("Dispose count sum is: {0}\r\nMin dispose count is: {1}\r\nMax dispose count is: {2}\r\n-----------------------------------", disposeSum, minDispose, maxDispose); - } - -#endif - - #endregion - - #region Private Methods - - private ILogFileInfo AddFile(string fileName) - { - _logger.Info("Adding file to ILogFileInfoList: " + fileName); - ILogFileInfo info = GetLogFileInfo(fileName); - _logFileInfoList.Add(info); - return info; - } - - private Task GetLogLineInternal(int lineNum) - { - if (_isDeleted) - { - _logger.Debug("Returning null for line {0} because file is deleted.", lineNum); - - // fast fail if dead file was detected. Prevents repeated lags in GUI thread caused by callbacks from control (e.g. repaint) - return null; - } - - AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); - if (logBuffer == null) - { - ReleaseBufferListReaderLock(); - _logger.Error("Cannot find buffer for line {0}, file: {1}{2}", lineNum, _fileName, IsMultiFile ? " (MultiFile)" : ""); - return null; - } - - // disposeLock prevents that the garbage collector is disposing just in the moment we use the buffer - _disposeLock.AcquireReaderLock(Timeout.Infinite); - if (logBuffer.IsDisposed) - { - LockCookie cookie = _disposeLock.UpgradeToWriterLock(Timeout.Infinite); - lock (logBuffer.FileInfo) - { - ReReadBuffer(logBuffer); - } - - _disposeLock.DowngradeFromWriterLock(ref cookie); - } - - ILogLine line = logBuffer.GetLineOfBlock(lineNum - logBuffer.StartLine); - _disposeLock.ReleaseReaderLock(); - ReleaseBufferListReaderLock(); - - return Task.FromResult(line); - } - - private void InitLruBuffers() - { - _bufferList = []; - _bufferLru = new List(_MAX_BUFFERS + 1); - //this.lruDict = new Dictionary(this.MAX_BUFFERS + 1); // key=startline, value = index in bufferLru - _lruCacheDict = new Dictionary(_MAX_BUFFERS + 1); - _lruCacheDictLock = new ReaderWriterLock(); - _bufferListLock = new ReaderWriterLock(); - _disposeLock = new ReaderWriterLock(); - } - - private void StartGCThread() - { - _garbageCollectorTask = Task.Run(GarbageCollectorThreadProc, cts.Token); - //_garbageCollectorThread = new Thread(new ThreadStart(GarbageCollectorThreadProc)); - //_garbageCollectorThread.IsBackground = true; - //_garbageCollectorThread.Start(); - } - - private void ResetBufferCache() - { - FileSize = 0; - LineCount = 0; - //this.lastReturnedLine = ""; - //this.lastReturnedLineNum = -1; - //this.lastReturnedLineNumForBuffer = -1; - } - - private void CloseFiles() - { - //foreach (ILogFileInfo info in this.ILogFileInfoList) - //{ - // info.CloseFile(); - //} - FileSize = 0; - LineCount = 0; - //this.lastReturnedLine = ""; - //this.lastReturnedLineNum = -1; - //this.lastReturnedLineNumForBuffer = -1; - } - - private ILogFileInfo GetLogFileInfo(string fileNameOrUri) - { - //TODO this must be fixed and should be given to the logfilereader not just called - IFileSystemPlugin fs = PluginRegistry.PluginRegistry.Instance.FindFileSystemForUri(fileNameOrUri) ?? throw new LogFileException("No file system plugin found for " + fileNameOrUri); - ILogFileInfo logFileInfo = fs.GetLogfileInfo(fileNameOrUri); - return logFileInfo ?? throw new LogFileException("Cannot find " + fileNameOrUri); - } - - private void ReplaceBufferInfos(ILogFileInfo oldLogFileInfo, ILogFileInfo newLogFileInfo) - { - _logger.Debug("ReplaceBufferInfos() " + oldLogFileInfo.FullName + " -> " + newLogFileInfo.FullName); - AcquireBufferListReaderLock(); - foreach (LogBuffer buffer in _bufferList) - { - if (buffer.FileInfo == oldLogFileInfo) - { - _logger.Debug("Buffer with startLine={0}, lineCount={1}, filePos={2}, size={3} gets new filename {4}", buffer.StartLine, buffer.LineCount, buffer.StartPos, buffer.Size, newLogFileInfo.FullName); - buffer.FileInfo = newLogFileInfo; - } - } - - ReleaseBufferListReaderLock(); - } - - private LogBuffer DeleteBuffersForInfo(ILogFileInfo ILogFileInfo, bool matchNamesOnly) - { - _logger.Info("Deleting buffers for file {0}", ILogFileInfo.FullName); - LogBuffer lastRemovedBuffer = null; - IList deleteList = []; - AcquireBufferListWriterLock(); - _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); - if (matchNamesOnly) - { - foreach (LogBuffer buffer in _bufferList) - { - if (buffer.FileInfo.FullName.ToLower().Equals(ILogFileInfo.FullName.ToLower())) - { - lastRemovedBuffer = buffer; - deleteList.Add(buffer); - } - } - } - else - { - foreach (LogBuffer buffer in _bufferList) - { - if (buffer.FileInfo == ILogFileInfo) - { - lastRemovedBuffer = buffer; - deleteList.Add(buffer); - } - } - } - - foreach (LogBuffer buffer in deleteList) - { - RemoveFromBufferList(buffer); - } - - _lruCacheDictLock.ReleaseWriterLock(); - ReleaseBufferListWriterLock(); - if (lastRemovedBuffer == null) - { - _logger.Info("lastRemovedBuffer is null"); - } - else - { - _logger.Info("lastRemovedBuffer: startLine={0}", lastRemovedBuffer.StartLine); - } - - return lastRemovedBuffer; - } - - /// - /// The caller must have writer locks for lruCache and buffer list! - /// - /// - private void RemoveFromBufferList(LogBuffer buffer) - { - Util.AssertTrue(_lruCacheDictLock.IsWriterLockHeld, "No writer lock for lru cache"); - Util.AssertTrue(_bufferListLock.IsWriterLockHeld, "No writer lock for buffer list"); - _lruCacheDict.Remove(buffer.StartLine); - _bufferList.Remove(buffer); - } - - private void ReadToBufferList(ILogFileInfo logFileInfo, long filePos, int startLine) - { - try - { - using Stream fileStream = logFileInfo.OpenStream(); - try - { - using ILogStreamReader reader = GetLogStreamReader(fileStream, EncodingOptions, UseNewReader); - reader.Position = filePos; - _fileLength = logFileInfo.Length; - - int lineNum = startLine; - LogBuffer logBuffer; - AcquireBufferListReaderLock(); - if (_bufferList.Count == 0) - { - logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER); - logBuffer.StartLine = startLine; - logBuffer.StartPos = filePos; - LockCookie cookie = UpgradeBufferListLockToWriter(); - AddBufferToList(logBuffer); - DowngradeBufferListLockFromWriter(ref cookie); - } - else - { - logBuffer = _bufferList[_bufferList.Count - 1]; - - if (!logBuffer.FileInfo.FullName.Equals(logFileInfo.FullName)) - { - logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER); - logBuffer.StartLine = startLine; - logBuffer.StartPos = filePos; - LockCookie cookie = UpgradeBufferListLockToWriter(); - AddBufferToList(logBuffer); - DowngradeBufferListLockFromWriter(ref cookie); - } - - _disposeLock.AcquireReaderLock(Timeout.Infinite); - if (logBuffer.IsDisposed) - { - LockCookie cookie = _disposeLock.UpgradeToWriterLock(Timeout.Infinite); - ReReadBuffer(logBuffer); - _disposeLock.DowngradeFromWriterLock(ref cookie); - } - - _disposeLock.ReleaseReaderLock(); - } - - Monitor.Enter(logBuffer); // Lock the buffer - ReleaseBufferListReaderLock(); - int lineCount = logBuffer.LineCount; - int droppedLines = logBuffer.PrevBuffersDroppedLinesSum; - filePos = reader.Position; - - while (ReadLine(reader, logBuffer.StartLine + logBuffer.LineCount, logBuffer.StartLine + logBuffer.LineCount + droppedLines, out var line)) - { - LogLine logLine = new(); - if (_shouldStop) - { - Monitor.Exit(logBuffer); - return; - } - - if (line == null) - { - logBuffer.DroppedLinesCount += 1; - droppedLines++; - continue; - } - - lineCount++; - if (lineCount > _MAX_LINES_PER_BUFFER && reader.IsBufferComplete) - { - OnLoadFile(new LoadFileEventArgs(logFileInfo.FullName, filePos, false, logFileInfo.Length, false)); - - Monitor.Exit(logBuffer); - logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER); - Monitor.Enter(logBuffer); - logBuffer.StartLine = lineNum; - logBuffer.StartPos = filePos; - logBuffer.PrevBuffersDroppedLinesSum = droppedLines; - AcquireBufferListWriterLock(); - AddBufferToList(logBuffer); - ReleaseBufferListWriterLock(); - lineCount = 1; - } - - logLine.FullLine = line; - logLine.LineNumber = logBuffer.StartLine + logBuffer.LineCount; - - logBuffer.AddLine(logLine, filePos); - filePos = reader.Position; - lineNum++; - } - - logBuffer.Size = filePos - logBuffer.StartPos; - Monitor.Exit(logBuffer); - _isLineCountDirty = true; - FileSize = reader.Position; - CurrentEncoding = reader.Encoding; // Reader may have detected another encoding - if (!_shouldStop) - { - OnLoadFile(new LoadFileEventArgs(logFileInfo.FullName, filePos, true, _fileLength, false)); - // Fire "Ready" Event - } - } - catch (IOException ioex) - { - _logger.Warn(ioex); - } - } - catch (IOException fe) - { - _logger.Warn(fe, "IOException: "); - _isDeleted = true; - LineCount = 0; - FileSize = 0; - OnFileNotFound(); // notify LogWindow - } - } - - private void AddBufferToList(LogBuffer logBuffer) - { -#if DEBUG - _logger.Debug("AddBufferToList(): {0}/{1}/{2}", logBuffer.StartLine, logBuffer.LineCount, logBuffer.FileInfo.FullName); -#endif - _bufferList.Add(logBuffer); - //UpdateLru(logBuffer); - UpdateLruCache(logBuffer); - } - - private void UpdateLruCache(LogBuffer logBuffer) - { - _lruCacheDictLock.AcquireReaderLock(Timeout.Infinite); - if (_lruCacheDict.TryGetValue(logBuffer.StartLine, out LogBufferCacheEntry cacheEntry)) - { - cacheEntry.Touch(); - } - else - { - LockCookie cookie = _lruCacheDictLock.UpgradeToWriterLock(Timeout.Infinite); - if (!_lruCacheDict.TryGetValue(logBuffer.StartLine, out cacheEntry) - ) // #536: re-test, because multiple threads may have been waiting for writer lock - { - cacheEntry = new LogBufferCacheEntry(); - cacheEntry.LogBuffer = logBuffer; - try - { - _lruCacheDict.Add(logBuffer.StartLine, cacheEntry); - } - catch (ArgumentException e) - { - _logger.Error(e, "Error in LRU cache: " + e.Message); -#if DEBUG // there seems to be a bug with double added key - - _logger.Info("Added buffer:"); - DumpBufferInfos(logBuffer); - if (_lruCacheDict.TryGetValue(logBuffer.StartLine, out LogBufferCacheEntry existingEntry)) - { - _logger.Info("Existing buffer: "); - DumpBufferInfos(existingEntry.LogBuffer); - } - else - { - _logger.Warn("Ooops? Cannot find the already existing entry in LRU."); - } -#endif - _lruCacheDictLock.ReleaseLock(); - throw; - } - } - - _lruCacheDictLock.DowngradeFromWriterLock(ref cookie); - } - - _lruCacheDictLock.ReleaseReaderLock(); - } - - /// - /// Sets a new start line in the given buffer and updates the LRU cache, if the buffer - /// is present in the cache. The caller must have write lock for 'lruCacheDictLock'; - /// - /// - /// - private void SetNewStartLineForBuffer(LogBuffer logBuffer, int newLineNum) - { - Util.AssertTrue(_lruCacheDictLock.IsWriterLockHeld, "No writer lock for lru cache"); - if (_lruCacheDict.ContainsKey(logBuffer.StartLine)) - { - _lruCacheDict.Remove(logBuffer.StartLine); - logBuffer.StartLine = newLineNum; - LogBufferCacheEntry cacheEntry = new(); - cacheEntry.LogBuffer = logBuffer; - _lruCacheDict.Add(logBuffer.StartLine, cacheEntry); - } - else - { - logBuffer.StartLine = newLineNum; - } - } - - private void GarbageCollectLruCache() - { -#if DEBUG - long startTime = Environment.TickCount; -#endif - _logger.Debug("Starting garbage collection"); - int threshold = 10; - _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); - int diff = 0; - if (_lruCacheDict.Count - (_MAX_BUFFERS + threshold) > 0) - { - diff = _lruCacheDict.Count - _MAX_BUFFERS; -#if DEBUG - if (diff > 0) - { - _logger.Info("Removing {0} entries from LRU cache for {1}", diff, Util.GetNameFromPath(_fileName)); - } -#endif - SortedList useSorterList = []; - // sort by usage counter - foreach (LogBufferCacheEntry entry in _lruCacheDict.Values) - { - if (!useSorterList.ContainsKey(entry.LastUseTimeStamp)) - { - useSorterList.Add(entry.LastUseTimeStamp, entry.LogBuffer.StartLine); - } - } - - // remove first entries (least usage) - _disposeLock.AcquireWriterLock(Timeout.Infinite); - for (int i = 0; i < diff; ++i) - { - if (i >= useSorterList.Count) - { - break; - } - - int startLine = useSorterList.Values[i]; - LogBufferCacheEntry entry = _lruCacheDict[startLine]; - _lruCacheDict.Remove(startLine); - entry.LogBuffer.DisposeContent(); - } - - _disposeLock.ReleaseWriterLock(); - } - - _lruCacheDictLock.ReleaseWriterLock(); -#if DEBUG - if (diff > 0) - { - long endTime = Environment.TickCount; - _logger.Info("Garbage collector time: " + (endTime - startTime) + " ms."); - } -#endif - } - - private void GarbageCollectorThreadProc() - { - while (!_shouldStop) - { - try - { - Thread.Sleep(10000); - } - catch (Exception) - { - } - - GarbageCollectLruCache(); - } - } - - // private void UpdateLru(LogBuffer logBuffer) - // { - // lock (this.monitor) - // { - // int index; - // if (this.lruDict.TryGetValue(logBuffer.StartLine, out index)) - // { - // RemoveBufferFromLru(logBuffer, index); - // AddBufferToLru(logBuffer); - // } - // else - // { - // if (this.bufferLru.Count > MAX_BUFFERS - 1) - // { - // LogBuffer looser = this.bufferLru[0]; - // if (looser != null) - // { - //#if DEBUG - // _logger.logDebug("Disposing buffer: " + looser.StartLine + "/" + looser.LineCount + "/" + looser.FileInfo.FileName); - //#endif - // looser.DisposeContent(); - // RemoveBufferFromLru(looser); - // } - // } - // AddBufferToLru(logBuffer); - // } - // } - // } - - ///// - ///// Removes a LogBuffer from the LRU. Note that the LogBuffer is searched in the lruDict - ///// via StartLine. So this property must have a consistent value. - ///// - ///// - //private void RemoveBufferFromLru(LogBuffer buffer) - //{ - // int index; - // lock (this.monitor) - // { - // if (this.lruDict.TryGetValue(buffer.StartLine, out index)) - // { - // RemoveBufferFromLru(buffer, index); - // } - // } - //} - - ///// - ///// Removes a LogBuffer from the LRU with known index. Note that the LogBuffer is searched in the lruDict - ///// via StartLine. So this property must have a consistent value. - ///// - ///// - ///// - //private void RemoveBufferFromLru(LogBuffer buffer, int index) - //{ - // lock (this.monitor) - // { - // this.bufferLru.RemoveAt(index); - // this.lruDict.Remove(buffer.StartLine); - // // adjust indizes, they have changed because of the remove - // for (int i = index; i < this.bufferLru.Count; ++i) - // { - // this.lruDict[this.bufferLru[i].StartLine] = this.lruDict[this.bufferLru[i].StartLine] - 1; - // } - // } - //} - - //private void AddBufferToLru(LogBuffer logBuffer) - //{ - // lock (this.monitor) - // { - // this.bufferLru.Add(logBuffer); - // int newIndex = this.bufferLru.Count - 1; - // this.lruDict[logBuffer.StartLine] = newIndex; - // } - //} - - private void ClearLru() - { - //lock (this.monitor) - //{ - // foreach (LogBuffer buffer in this.bufferLru) - // { - // buffer.DisposeContent(); - // } - // this.bufferLru.Clear(); - // this.lruDict.Clear(); - //} - _logger.Info("Clearing LRU cache."); - _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); - _disposeLock.AcquireWriterLock(Timeout.Infinite); - foreach (LogBufferCacheEntry entry in _lruCacheDict.Values) - { - entry.LogBuffer.DisposeContent(); - } - - _lruCacheDict.Clear(); - _disposeLock.ReleaseWriterLock(); - _lruCacheDictLock.ReleaseWriterLock(); - _logger.Info("Clearing done."); - } - - private void ReReadBuffer(LogBuffer logBuffer) - { -#if DEBUG - _logger.Info("re-reading buffer: {0}/{1}/{2}", logBuffer.StartLine, logBuffer.LineCount, logBuffer.FileInfo.FullName); -#endif - try - { - Monitor.Enter(logBuffer); - Stream fileStream = null; - try - { - fileStream = logBuffer.FileInfo.OpenStream(); - } - catch (IOException e) - { - _logger.Warn(e); - return; - } - - try - { - ILogStreamReader reader = GetLogStreamReader(fileStream, EncodingOptions, UseNewReader); - - long filePos = logBuffer.StartPos; - reader.Position = logBuffer.StartPos; - int maxLinesCount = logBuffer.LineCount; - int lineCount = 0; - int dropCount = logBuffer.PrevBuffersDroppedLinesSum; - logBuffer.ClearLines(); - - while (ReadLine(reader, logBuffer.StartLine + logBuffer.LineCount, logBuffer.StartLine + logBuffer.LineCount + dropCount, out string line)) - { - if (lineCount >= maxLinesCount) - { - break; - } - - if (line == null) - { - dropCount++; - continue; - } - - LogLine logLine = new() - { - FullLine = line, - LineNumber = logBuffer.StartLine + logBuffer.LineCount - }; - - logBuffer.AddLine(logLine, filePos); - filePos = reader.Position; - lineCount++; - } - - if (maxLinesCount != logBuffer.LineCount) - { - _logger.Warn("LineCount in buffer differs after re-reading. old={0}, new={1}", maxLinesCount, logBuffer.LineCount); - } - - if (dropCount - logBuffer.PrevBuffersDroppedLinesSum != logBuffer.DroppedLinesCount) - { - _logger.Warn("DroppedLinesCount in buffer differs after re-reading. old={0}, new={1}", logBuffer.DroppedLinesCount, dropCount); - logBuffer.DroppedLinesCount = dropCount - logBuffer.PrevBuffersDroppedLinesSum; - } - - GC.KeepAlive(fileStream); - } - catch (IOException e) - { - _logger.Warn(e); - } - finally - { - fileStream.Close(); - } - } - finally - { - Monitor.Exit(logBuffer); - } - } - - private LogBuffer GetBufferForLine(int lineNum) - { -#if DEBUG - long startTime = Environment.TickCount; -#endif - LogBuffer logBuffer = null; - AcquireBufferListReaderLock(); - //if (lineNum == this.lastReturnedLineNumForBuffer) - //{ - // return this.lastReturnedBuffer; - //} - - //int startIndex = lineNum / LogBuffer.MAX_LINES; // doesn't work anymore since XML buffer may contain more lines than MAX_LINES - int startIndex = 0; - int count = _bufferList.Count; - for (int i = startIndex; i < count; ++i) - { - logBuffer = _bufferList[i]; - if (lineNum >= logBuffer.StartLine && lineNum < logBuffer.StartLine + logBuffer.LineCount) - { - //UpdateLru(logBuffer); - UpdateLruCache(logBuffer); - //this.lastReturnedLineNumForBuffer = lineNum; - //this.lastReturnedBuffer = logBuffer; - break; - } - } -#if DEBUG - long endTime = Environment.TickCount; - //_logger.logDebug("getBufferForLine(" + lineNum + ") duration: " + ((endTime - startTime)) + " ms. Buffer start line: " + logBuffer.StartLine); -#endif - ReleaseBufferListReaderLock(); - return logBuffer; - } - - /// - /// Async callback used to check if the GetLogLine() call is succeeding again after a detected timeout. - /// - private void GetLineFinishedCallback(ILogLine line) - { - _isFailModeCheckCallPending = false; - if (line != null) - { - _logger.Debug("'isFastFailOnGetLogLine' flag was reset"); - _isFastFailOnGetLogLine = false; - } - - _logger.Debug("'isLogLineCallPending' flag was reset."); - } - - private LogBuffer GetFirstBufferForFileByLogBuffer(LogBuffer logBuffer) - { - ILogFileInfo info = logBuffer.FileInfo; - AcquireBufferListReaderLock(); - int index = _bufferList.IndexOf(logBuffer); - if (index == -1) - { - ReleaseBufferListReaderLock(); - return null; - } - - LogBuffer resultBuffer = logBuffer; - while (true) - { - index--; - if (index < 0 || _bufferList[index].FileInfo != info) - { - break; - } - - resultBuffer = _bufferList[index]; - } - - ReleaseBufferListReaderLock(); - return resultBuffer; - } - - private void MonitorThreadProc() - { - Thread.CurrentThread.Name = "MonitorThread"; - //IFileSystemPlugin fs = PluginRegistry.GetInstance().FindFileSystemForUri(this.watchedILogFileInfo.FullName); - _logger.Info("MonitorThreadProc() for file {0}", _watchedILogFileInfo.FullName); - - long oldSize = 0; - try - { - OnLoadingStarted(new LoadFileEventArgs(_fileName, 0, false, 0, false)); - ReadFiles(); - if (!_isDeleted) - { - oldSize = _fileLength; - OnLoadingFinished(); - } - } - catch (Exception e) - { - _logger.Error(e); - } - - while (!_shouldStop) - { - try - { - int pollInterval = _watchedILogFileInfo.PollInterval; - //#if DEBUG - // if (_logger.IsDebug) - // { - // _logger.logDebug("Poll interval for " + this.fileName + ": " + pollInterval); - // } - //#endif - Thread.Sleep(pollInterval); - } - catch (Exception e) - { - _logger.Error(e); - } - - if (_shouldStop) - { - return; - } - - try - { - if (_watchedILogFileInfo.FileHasChanged()) - { - _fileLength = _watchedILogFileInfo.Length; - if (_fileLength == -1) - { - MonitoredFileNotFound(); - } - else - { - oldSize = _fileLength; - FileChanged(); - } - } - } - catch (FileNotFoundException) - { - MonitoredFileNotFound(); - } - } - } - - private void MonitoredFileNotFound() - { - long oldSize; - if (!_isDeleted) - { - _logger.Debug("File not FileNotFoundException catched. Switching to 'deleted' mode."); - _isDeleted = true; - oldSize = _fileLength = -1; - FileSize = 0; - OnFileNotFound(); // notify LogWindow - } -#if DEBUG - else - { - _logger.Debug("File not FileNotFoundException catched. Already in deleted mode."); - } -#endif - } - - private void FileChanged() - { - if (_isDeleted) - { - OnRespawned(); - // prevent size update events. The window should reload the complete file. - FileSize = _fileLength; - } - - long newSize = _fileLength; - //if (this.currFileSize != newSize) - { - _logger.Info("file size changed. new size={0}, file: {1}", newSize, _fileName); - FireChangeEvent(); - } - } - - private void FireChangeEvent() - { - LogEventArgs args = new(); - args.PrevFileSize = FileSize; - args.PrevLineCount = LineCount; - long newSize = _fileLength; - if (newSize < FileSize || _isDeleted) - { - _logger.Info("File was created anew: new size={0}, oldSize={1}", newSize, FileSize); - // Fire "New File" event - FileSize = 0; - LineCount = 0; - try - { - if (!IsMultiFile) - { - // ReloadBufferList(); // removed because reloading is triggered by owning LogWindow - // Trigger "new file" handling (reload) - OnLoadFile(new LoadFileEventArgs(_fileName, 0, true, _fileLength, true)); - - if (_isDeleted) - { - args.FileSize = newSize; - args.LineCount = LineCount; - if (args.PrevLineCount != args.LineCount && !_shouldStop) - { - OnFileSizeChanged(args); - } - } - - _isDeleted = false; - } - else - { - int offset = ShiftBuffers(); - //this.currFileSize = newSize; // removed because ShiftBuffers() calls ReadToBuffer() which will set the actual read size - args.FileSize = newSize; - args.LineCount = LineCount; - args.IsRollover = true; - args.RolloverOffset = offset; - _isDeleted = false; - if (!_shouldStop) - { - OnFileSizeChanged(args); - } - } - } - catch (FileNotFoundException e) - { - // trying anew in next poll intervall. So let currFileSize untouched. - _logger.Warn(e); - } - } - else - { - ReadToBufferList(_watchedILogFileInfo, FileSize, LineCount); - args.FileSize = newSize; - args.LineCount = LineCount; - //if (args.PrevLineCount != args.LineCount && !this.shouldStop) - OnFileSizeChanged(args); - } - } - - private ILogStreamReader GetLogStreamReader(Stream stream, EncodingOptions encodingOptions, bool useNewReader) - { - ILogStreamReader reader = CreateLogStreamReader(stream, encodingOptions, useNewReader); - - return IsXmlMode ? new XmlBlockSplitter(new XmlLogReader(reader), XmlLogConfig) : reader; - } - - private ILogStreamReader CreateLogStreamReader(Stream stream, EncodingOptions encodingOptions, bool useSystemReader) - { - if (useSystemReader) - { - return new PositionAwareStreamReaderSystem(stream, encodingOptions); - } - - return new PositionAwareStreamReaderLegacy(stream, encodingOptions); - } - - private bool ReadLine(ILogStreamReader reader, int lineNum, int realLineNum, out string outLine) - { - string line = null; - try - { - line = reader.ReadLine(); - } - catch (IOException e) - { - _logger.Warn(e); - } - catch (NotSupportedException e) - { - // Bug#11: "Reading operations are not supported by the stream" - // Currently not reproducible. Probably happens at an unlucky time interval (after opening the file) - // when the file is being deleted (rolling) - // This will be handled as EOF. - _logger.Warn(e); - } - - if (line == null) // EOF or catched Exception - { - outLine = null; - return false; - } - - if (PreProcessColumnizer != null) - { - line = PreProcessColumnizer.PreProcessLine(line, lineNum, realLineNum); - } - - outLine = line; - return true; - } - - private void AcquireBufferListReaderLock() - { - try - { - _bufferListLock.AcquireReaderLock(10000); -#if DEBUG && TRACE_LOCKS - StackTrace st = new StackTrace(true); - StackFrame callerFrame = st.GetFrame(2); - this.bufferListLockInfo = -"Read lock from " + callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "() " + callerFrame.GetFileLineNumber(); -#endif - } - catch (ApplicationException e) - { - _logger.Warn(e, "Reader lock wait for bufferList timed out. Now trying infinite."); -#if DEBUG && TRACE_LOCKS - _logger.logInfo(this.bufferListLockInfo); -#endif - _bufferListLock.AcquireReaderLock(Timeout.Infinite); - } - } - - private void ReleaseBufferListReaderLock() - { - _bufferListLock.ReleaseReaderLock(); - } - - private void AcquireBufferListWriterLock() - { - try - { - _bufferListLock.AcquireWriterLock(10000); -#if DEBUG && TRACE_LOCKS - StackTrace st = new StackTrace(true); - StackFrame callerFrame = st.GetFrame(1); - this.bufferListLockInfo = -"Write lock from " + callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "() " + callerFrame.GetFileLineNumber(); - callerFrame.GetFileName(); -#endif - } - catch (ApplicationException e) - { - _logger.Warn(e, "Writer lock wait for bufferList timed out. Now trying infinite."); -#if DEBUG && TRACE_LOCKS - _logger.logInfo(this.bufferListLockInfo); -#endif - _bufferListLock.AcquireWriterLock(Timeout.Infinite); - } - } - - private void ReleaseBufferListWriterLock() - { - _bufferListLock.ReleaseWriterLock(); - } - - private LockCookie UpgradeBufferListLockToWriter() - { - try - { - LockCookie cookie = _bufferListLock.UpgradeToWriterLock(10000); -#if DEBUG && TRACE_LOCKS - StackTrace st = new StackTrace(true); - StackFrame callerFrame = st.GetFrame(2); - this.bufferListLockInfo += -", upgraded to writer from " + callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "() " + callerFrame.GetFileLineNumber(); -#endif - return cookie; - } - catch (ApplicationException e) - { - _logger.Warn(e, "Writer lock update wait for bufferList timed out. Now trying infinite."); -#if DEBUG && TRACE_LOCKS - _logger.logInfo(this.bufferListLockInfo); -#endif - return _bufferListLock.UpgradeToWriterLock(Timeout.Infinite); - } - } - - private void DowngradeBufferListLockFromWriter(ref LockCookie cookie) - { - _bufferListLock.DowngradeFromWriterLock(ref cookie); -#if DEBUG && TRACE_LOCKS - StackTrace st = new StackTrace(true); - StackFrame callerFrame = st.GetFrame(2); - this.bufferListLockInfo += -", downgraded to reader from " + callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "() " + callerFrame.GetFileLineNumber(); -#endif - } - -#if DEBUG - private void DumpBufferInfos(LogBuffer buffer) - { - if (_logger.IsTraceEnabled) - { - _logger.Trace("StartLine: {0}\r\nLineCount: {1}\r\nStartPos: {2}\r\nSize: {3}\r\nDisposed: {4}\r\nDisposeCount: {5}\r\nFile: {6}", - buffer.StartLine, - buffer.LineCount, - buffer.StartPos, - buffer.Size, - buffer.IsDisposed ? "yes" : "no", - buffer.DisposeCount, - buffer.FileInfo.FullName); - } - } - -#endif - - #endregion - - ~LogfileReader() - { - DeleteAllContent(); - } - - protected virtual void OnFileSizeChanged(LogEventArgs e) - { - FileSizeChanged?.Invoke(this, e); - } - - protected virtual void OnLoadFile(LoadFileEventArgs e) - { - LoadFile?.Invoke(this, e); - } - - protected virtual void OnLoadingStarted(LoadFileEventArgs e) - { - LoadingStarted?.Invoke(this, e); - } - - protected virtual void OnLoadingFinished() - { - LoadingFinished?.Invoke(this, EventArgs.Empty); - } - - protected virtual void OnFileNotFound() - { - FileNotFound?.Invoke(this, EventArgs.Empty); - } - - protected virtual void OnRespawned() - { - _logger.Info("OnRespawned()"); - Respawned?.Invoke(this, EventArgs.Empty); - } - - private class LogLine : ILogLine - { - #region Properties - - public string FullLine { get; set; } - - public int LineNumber { get; set; } - - string ITextValue.Text => FullLine; - - #endregion - } - } +using LogExpert.Core.Classes.xml; +using LogExpert.Core.Entities; +using LogExpert.Core.EventArguments; +using LogExpert.Core.EventHandlers; +using LogExpert.Core.Interface; +using NLog; +using System.Text; + +namespace LogExpert.Core.Classes.Log +{ + public class LogfileReader : IAutoLogLineColumnizerCallback + { + #region Fields + + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + + private readonly GetLogLineFx _logLineFx; + + private readonly string _fileName; + private readonly int _MAX_BUFFERS = 10; + private readonly int _MAX_LINES_PER_BUFFER = 100; + + private readonly object _monitor = new(); + private readonly MultiFileOptions _multiFileOptions; + private readonly IPluginRegistry _pluginRegistry; + private IList _bufferList; + private ReaderWriterLock _bufferListLock; + private IList _bufferLru; + private bool _contentDeleted; + private int _currLineCount; + private ReaderWriterLock _disposeLock; + private EncodingOptions _encodingOptions; + private long _fileLength; + + private Task _garbageCollectorTask; + private Task _monitorTask; + private readonly CancellationTokenSource cts = new(); + + private bool _isDeleted; + private bool _isFailModeCheckCallPending; + private bool _isFastFailOnGetLogLine; + private bool _isLineCountDirty = true; + private IList _logFileInfoList = []; + private Dictionary _lruCacheDict; + + private ReaderWriterLock _lruCacheDictLock; + + private bool _shouldStop; + private ILogFileInfo _watchedILogFileInfo; + + #endregion + + #region cTor + + public LogfileReader(string fileName, EncodingOptions encodingOptions, bool multiFile, int bufferCount, int linesPerBuffer, MultiFileOptions multiFileOptions, IPluginRegistry pluginRegistry) + { + if (fileName == null) + { + return; + } + + _fileName = fileName; + EncodingOptions = encodingOptions; + IsMultiFile = multiFile; + _MAX_BUFFERS = bufferCount; + _MAX_LINES_PER_BUFFER = linesPerBuffer; + _multiFileOptions = multiFileOptions; + _pluginRegistry = pluginRegistry; + _logLineFx = GetLogLineInternal; + InitLruBuffers(); + + if (multiFile) + { + ILogFileInfo info = GetLogFileInfo(fileName); + RolloverFilenameHandler rolloverHandler = new(info, _multiFileOptions); + LinkedList nameList = rolloverHandler.GetNameList(_pluginRegistry); + + ILogFileInfo fileInfo = null; + foreach (string name in nameList) + { + fileInfo = AddFile(name); + } + + _watchedILogFileInfo = fileInfo; // last added file in the list is the watched file + } + else + { + _watchedILogFileInfo = AddFile(fileName); + } + + StartGCThread(); + } + + public LogfileReader(string[] fileNames, EncodingOptions encodingOptions, int bufferCount, int linesPerBuffer, MultiFileOptions multiFileOptions, IPluginRegistry pluginRegistry) + { + if (fileNames == null || fileNames.Length < 1) + { + return; + } + + EncodingOptions = encodingOptions; + IsMultiFile = true; + _MAX_BUFFERS = bufferCount; + _MAX_LINES_PER_BUFFER = linesPerBuffer; + _multiFileOptions = multiFileOptions; + _pluginRegistry = pluginRegistry; + _logLineFx = GetLogLineInternal; + + InitLruBuffers(); + + ILogFileInfo fileInfo = null; + foreach (string name in fileNames) + { + fileInfo = AddFile(name); + } + + _watchedILogFileInfo = fileInfo; + _fileName = fileInfo.FullName; + + StartGCThread(); + } + + #endregion + + #region Delegates + + public delegate void BlockLoadedEventHandler(object sender, LoadFileEventArgs e); + public delegate void FileNotFoundEventHandler(object sender, EventArgs e); + public delegate void FileRespawnedEventHandler(object sender, EventArgs e); + public delegate void FinishedLoadingEventHandler(object sender, EventArgs e); + private delegate Task GetLogLineFx(int lineNum); + public delegate void LoadingStartedEventHandler(object sender, LoadFileEventArgs e); + + #endregion + + #region Events + + public event FileSizeChangedEventHandler FileSizeChanged; + public event BlockLoadedEventHandler LoadFile; + public event LoadingStartedEventHandler LoadingStarted; + public event FinishedLoadingEventHandler LoadingFinished; + public event FileNotFoundEventHandler FileNotFound; + public event FileRespawnedEventHandler Respawned; + + #endregion + + #region Properties + + public int LineCount + { + get + { + if (_isLineCountDirty) + { + _currLineCount = 0; + AcquireBufferListReaderLock(); + foreach (LogBuffer buffer in _bufferList) + { + _currLineCount += buffer.LineCount; + } + + ReleaseBufferListReaderLock(); + _isLineCountDirty = false; + } + + return _currLineCount; + } + set => _currLineCount = value; + } + + public bool IsMultiFile { get; } + + public Encoding CurrentEncoding { get; private set; } + + public long FileSize { get; private set; } + + public bool IsXmlMode { get; set; } = false; + + public IXmlLogConfiguration XmlLogConfig { get; set; } + + public IPreProcessColumnizer PreProcessColumnizer { get; set; } = null; + + public EncodingOptions EncodingOptions + { + get => _encodingOptions; + set + { + { + _encodingOptions = new EncodingOptions + { + DefaultEncoding = value.DefaultEncoding, + Encoding = value.Encoding + }; + } + } + } + + public bool UseNewReader { get; set; } + + #endregion + + #region Public methods + + /// + /// Public for unit test reasons + /// + public void ReadFiles() + { + FileSize = 0; + LineCount = 0; + //this.lastReturnedLine = ""; + //this.lastReturnedLineNum = -1; + //this.lastReturnedLineNumForBuffer = -1; + _isDeleted = false; + ClearLru(); + AcquireBufferListWriterLock(); + _bufferList.Clear(); + ReleaseBufferListWriterLock(); + try + { + foreach (ILogFileInfo info in _logFileInfoList) + { + //info.OpenFile(); + ReadToBufferList(info, 0, LineCount); + } + + if (_logFileInfoList.Count > 0) + { + ILogFileInfo info = _logFileInfoList[_logFileInfoList.Count - 1]; + _fileLength = info.Length; + _watchedILogFileInfo = info; + } + } + catch (IOException e) + { + _logger.Warn(e, "IOException"); + _fileLength = 0; + _isDeleted = true; + LineCount = 0; + } + + LogEventArgs args = new() + { + PrevFileSize = 0, + PrevLineCount = 0, + LineCount = LineCount, + FileSize = FileSize + }; + + OnFileSizeChanged(args); + } + + /// + /// Public for unit tests. + /// + /// + public int ShiftBuffers() + { + _logger.Info("ShiftBuffers() begin for {0}{1}", _fileName, IsMultiFile ? " (MultiFile)" : ""); + AcquireBufferListWriterLock(); + int offset = 0; + _isLineCountDirty = true; + lock (_monitor) + { + RolloverFilenameHandler rolloverHandler = new(_watchedILogFileInfo, _multiFileOptions); + LinkedList fileNameList = rolloverHandler.GetNameList(_pluginRegistry); + + ResetBufferCache(); + IList lostILogFileInfoList = []; + IList readNewILogFileInfoList = []; + IList newFileInfoList = []; + IEnumerator enumerator = _logFileInfoList.GetEnumerator(); + while (enumerator.MoveNext()) + { + ILogFileInfo logFileInfo = enumerator.Current; + string fileName = logFileInfo.FullName; + _logger.Debug("Testing file {0}", fileName); + LinkedListNode node = fileNameList.Find(fileName); + if (node == null) + { + _logger.Warn("File {0} not found", fileName); + continue; + } + + if (node.Previous != null) + { + fileName = node.Previous.Value; + ILogFileInfo newILogFileInfo = GetLogFileInfo(fileName); + _logger.Debug("{0} exists\r\nOld size={1}, new size={2}", fileName, logFileInfo.OriginalLength, newILogFileInfo.Length); + // is the new file the same as the old buffer info? + if (newILogFileInfo.Length == logFileInfo.OriginalLength) + { + ReplaceBufferInfos(logFileInfo, newILogFileInfo); + newFileInfoList.Add(newILogFileInfo); + } + else + { + _logger.Debug("Buffer for {0} must be re-read.", fileName); + // not the same. so must read the rest of the list anew from the files + readNewILogFileInfoList.Add(newILogFileInfo); + while (enumerator.MoveNext()) + { + fileName = enumerator.Current.FullName; + node = fileNameList.Find(fileName); + if (node == null) + { + _logger.Warn("File {0} not found", fileName); + continue; + } + + if (node.Previous != null) + { + fileName = node.Previous.Value; + _logger.Debug("New name is {0}", fileName); + readNewILogFileInfoList.Add(GetLogFileInfo(fileName)); + } + else + { + _logger.Warn("No previous file for {0} found", fileName); + } + } + } + } + else + { + _logger.Info("{0} does not exist", fileName); + lostILogFileInfoList.Add(logFileInfo); +#if DEBUG // for better overview in logfile: + //ILogFileInfo newILogFileInfo = new ILogFileInfo(fileName); + //ReplaceBufferInfos(ILogFileInfo, newILogFileInfo); +#endif + } + } + + if (lostILogFileInfoList.Count > 0) + { + _logger.Info("Deleting buffers for lost files"); + foreach (ILogFileInfo ILogFileInfo in lostILogFileInfoList) + { + //this.ILogFileInfoList.Remove(ILogFileInfo); + LogBuffer lastBuffer = DeleteBuffersForInfo(ILogFileInfo, false); + if (lastBuffer != null) + { + offset += lastBuffer.StartLine + lastBuffer.LineCount; + } + } + + _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); + _logger.Info("Adjusting StartLine values in {0} buffers by offset {1}", _bufferList.Count, offset); + foreach (LogBuffer buffer in _bufferList) + { + SetNewStartLineForBuffer(buffer, buffer.StartLine - offset); + } + + _lruCacheDictLock.ReleaseWriterLock(); +#if DEBUG + if (_bufferList.Count > 0) + { + _logger.Debug("First buffer now has StartLine {0}", _bufferList[0].StartLine); + } +#endif + } + + // Read anew all buffers following a buffer info that couldn't be matched with the corresponding existing file + _logger.Info("Deleting buffers for files that must be re-read"); + foreach (ILogFileInfo ILogFileInfo in readNewILogFileInfoList) + { + DeleteBuffersForInfo(ILogFileInfo, true); + //this.ILogFileInfoList.Remove(ILogFileInfo); + } + + _logger.Info("Deleting buffers for the watched file"); + DeleteBuffersForInfo(_watchedILogFileInfo, true); + int startLine = LineCount - 1; + _logger.Info("Re-Reading files"); + foreach (ILogFileInfo ILogFileInfo in readNewILogFileInfoList) + { + //ILogFileInfo.OpenFile(); + ReadToBufferList(ILogFileInfo, 0, LineCount); + //this.ILogFileInfoList.Add(ILogFileInfo); + newFileInfoList.Add(ILogFileInfo); + } + + //this.watchedILogFileInfo = this.ILogFileInfoList[this.ILogFileInfoList.Count - 1]; + _logFileInfoList = newFileInfoList; + _watchedILogFileInfo = GetLogFileInfo(_watchedILogFileInfo.FullName); + _logFileInfoList.Add(_watchedILogFileInfo); + _logger.Info("Reading watched file"); + ReadToBufferList(_watchedILogFileInfo, 0, LineCount); + } + + _logger.Info("ShiftBuffers() end. offset={0}", offset); + ReleaseBufferListWriterLock(); + return offset; + } + + public ILogLine GetLogLine(int lineNum) + { + return GetLogLineInternal(lineNum).Result; + } + + /// + /// Get the text content of the given line number. + /// The actual work is done in an async thread. This method waits for thread completion for only 1 second. If the async + /// thread has not returned, the method will return null. This is because this method is also called from GUI thread + /// (e.g. LogWindow draw events). Under some circumstances, repeated calls to this method would lead the GUI to freeze. E.g. when + /// trying to re-load content from disk but the file was deleted. Especially on network shares. + /// + /// + /// Once the method detects a timeout it will enter a kind of 'fast fail mode'. That means all following calls will be returned with + /// null immediately (without 1 second wait). A background call to GetLogLineInternal() will check if a result is available. + /// If so, the 'fast fail mode' is switched off. In most cases a fail is caused by a deleted file. But it may also be caused by slow + /// network connections. So all this effort is needed to prevent entering an endless 'fast fail mode' just because of temporary problems. + /// + /// line to retrieve + /// + public async Task GetLogLineWithWait(int lineNum) + { + const int WAIT_TIME = 1000; + + ILogLine result = null; + + if (!_isFastFailOnGetLogLine) + { + var task = Task.Run(() => _logLineFx(lineNum)); + if (task.Wait(WAIT_TIME)) + { + result = task.Result; + _isFastFailOnGetLogLine = false; + } + else + { + _isFastFailOnGetLogLine = true; + _logger.Debug("No result after {0}ms. Returning .", WAIT_TIME); + } + } + else + { + _logger.Debug("Fast failing GetLogLine()"); + if (!_isFailModeCheckCallPending) + { + _isFailModeCheckCallPending = true; + var logLine = await _logLineFx(lineNum); + GetLineFinishedCallback(logLine); + } + } + + return result; + } + + /// + /// Returns the file name of the actual file for the given line. Needed for MultiFile. + /// + /// + /// + public string GetLogFileNameForLine(int lineNum) + { + AcquireBufferListReaderLock(); + LogBuffer logBuffer = GetBufferForLine(lineNum); + string fileName = logBuffer?.FileInfo.FullName; + ReleaseBufferListReaderLock(); + return fileName; + } + + /// + /// Returns the ILogFileInfo for the actual file for the given line. Needed for MultiFile. + /// + /// + /// + public ILogFileInfo GetLogFileInfoForLine(int lineNum) + { + AcquireBufferListReaderLock(); + LogBuffer logBuffer = GetBufferForLine(lineNum); + ILogFileInfo info = logBuffer?.FileInfo; + ReleaseBufferListReaderLock(); + return info; + } + + /// + /// Returns the line number (starting from the given number) where the next multi file + /// starts. + /// + /// + /// + public int GetNextMultiFileLine(int lineNum) + { + int result = -1; + AcquireBufferListReaderLock(); + LogBuffer logBuffer = GetBufferForLine(lineNum); + if (logBuffer != null) + { + int index = _bufferList.IndexOf(logBuffer); + if (index != -1) + { + for (int i = index; i < _bufferList.Count; ++i) + { + if (_bufferList[i].FileInfo != logBuffer.FileInfo) + { + result = _bufferList[i].StartLine; + break; + } + } + } + } + + ReleaseBufferListReaderLock(); + return result; + } + + public int GetPrevMultiFileLine(int lineNum) + { + int result = -1; + AcquireBufferListReaderLock(); + LogBuffer logBuffer = GetBufferForLine(lineNum); + if (logBuffer != null) + { + int index = _bufferList.IndexOf(logBuffer); + if (index != -1) + { + for (int i = index; i >= 0; --i) + { + if (_bufferList[i].FileInfo != logBuffer.FileInfo) + { + result = _bufferList[i].StartLine + _bufferList[i].LineCount; + break; + } + } + } + } + + ReleaseBufferListReaderLock(); + return result; + } + + /// + /// Returns the actual line number in the file for the given 'virtual line num'. + /// This is needed for multi file mode. 'Virtual' means that the given line num is a line + /// number in the collections of the files currently viewed together in multi file mode as one large virtual file. + /// This method finds the real file for the line number and maps the line number to the correct position + /// in that file. This is needed when launching external tools to provide correct line number arguments. + /// + /// + /// + public int GetRealLineNumForVirtualLineNum(int lineNum) + { + AcquireBufferListReaderLock(); + LogBuffer logBuffer = GetBufferForLine(lineNum); + int result = -1; + if (logBuffer != null) + { + logBuffer = GetFirstBufferForFileByLogBuffer(logBuffer); + if (logBuffer != null) + { + result = lineNum - logBuffer.StartLine; + } + } + + ReleaseBufferListReaderLock(); + return result; + } + + public void StartMonitoring() + { + _logger.Info("startMonitoring()"); + _monitorTask = Task.Run(MonitorThreadProc, cts.Token); + _shouldStop = false; + } + + public void StopMonitoring() + { + _logger.Info("stopMonitoring()"); + _shouldStop = true; + + Thread.Sleep(_watchedILogFileInfo.PollInterval); // leave time for the threads to stop by themselves + + if (_monitorTask != null) + { + if (_monitorTask.Status == TaskStatus.Running) // if thread has not finished, abort it + { + cts.Cancel(); + } + } + + if (_garbageCollectorTask.IsCanceled == false) + { + if (_garbageCollectorTask.Status == TaskStatus.Running) // if thread has not finished, abort it + { + cts.Cancel(); + } + } + + //this.loadThread = null; + //_monitorThread = null; + //_garbageCollectorThread = null; // preventive call + CloseFiles(); + } + + /// + /// calls stopMonitoring() in a background thread and returns to the caller immediately. + /// This is useful for a fast responding GUI (e.g. when closing a file tab) + /// + public void StopMonitoringAsync() + { + Task task = Task.Run(StopMonitoring); + + //Thread stopperThread = new(new ThreadStart(StopMonitoring)) + //{ + // IsBackground = true + //}; + //stopperThread.Start(); + } + + /// + /// Deletes all buffer lines and disposes their content. Use only when the LogfileReader + /// is about to be closed! + /// + public void DeleteAllContent() + { + if (_contentDeleted) + { + _logger.Debug("Buffers for {0} already deleted.", Util.GetNameFromPath(_fileName)); + return; + } + + _logger.Info("Deleting all log buffers for {0}. Used mem: {1:N0}", Util.GetNameFromPath(_fileName), GC.GetTotalMemory(true)); //TODO [Z] uh GC collect calls creepy + AcquireBufferListWriterLock(); + _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); + _disposeLock.AcquireWriterLock(Timeout.Infinite); + + foreach (LogBuffer logBuffer in _bufferList) + { + if (!logBuffer.IsDisposed) + { + logBuffer.DisposeContent(); + } + } + + _lruCacheDict.Clear(); + _bufferList.Clear(); + + _disposeLock.ReleaseWriterLock(); + _lruCacheDictLock.ReleaseWriterLock(); + ReleaseBufferListWriterLock(); + GC.Collect(); + _contentDeleted = true; + _logger.Info("Deleting complete. Used mem: {0:N0}", GC.GetTotalMemory(true)); //TODO [Z] uh GC collect calls creepy + } + + /// + /// Explicit change the encoding. + /// + /// + public void ChangeEncoding(Encoding encoding) + { + CurrentEncoding = encoding; + EncodingOptions.Encoding = encoding; + ResetBufferCache(); + ClearLru(); + } + + /// + /// For unit tests only. + /// + /// + public IList GetLogFileInfoList() + { + return _logFileInfoList; + } + + /// + /// For unit tests only + /// + /// + public IList GetBufferList() + { + return _bufferList; + } + + #endregion + + #region Internals + +#if DEBUG + + public void LogBufferInfoForLine(int lineNum) + { + AcquireBufferListReaderLock(); + LogBuffer buffer = GetBufferForLine(lineNum); + if (buffer == null) + { + ReleaseBufferListReaderLock(); + _logger.Error("Cannot find buffer for line {0}, file: {1}{2}", lineNum, _fileName, IsMultiFile ? " (MultiFile)" : ""); + return; + } + + _logger.Info("-----------------------------------"); + _disposeLock.AcquireReaderLock(Timeout.Infinite); + _logger.Info("Buffer info for line {0}", lineNum); + DumpBufferInfos(buffer); + _logger.Info("File pos for current line: {0}", buffer.GetFilePosForLineOfBlock(lineNum - buffer.StartLine)); + _disposeLock.ReleaseReaderLock(); + _logger.Info("-----------------------------------"); + ReleaseBufferListReaderLock(); + } +#endif + +#if DEBUG + public void LogBufferDiagnostic() + { + _logger.Info("-------- Buffer diagnostics -------"); + _lruCacheDictLock.AcquireReaderLock(Timeout.Infinite); + int cacheCount = _lruCacheDict.Count; + _logger.Info("LRU entries: {0}", cacheCount); + _lruCacheDictLock.ReleaseReaderLock(); + + AcquireBufferListReaderLock(); + _logger.Info("File: {0}\r\nBuffer count: {1}\r\nDisposed buffers: {2}", _fileName, _bufferList.Count, _bufferList.Count - cacheCount); + int lineNum = 0; + long disposeSum = 0; + long maxDispose = 0; + long minDispose = int.MaxValue; + for (int i = 0; i < _bufferList.Count; ++i) + { + LogBuffer buffer = _bufferList[i]; + _disposeLock.AcquireReaderLock(Timeout.Infinite); + if (buffer.StartLine != lineNum) + { + _logger.Error("Start line of buffer is: {0}, expected: {1}", buffer.StartLine, lineNum); + _logger.Info("Info of buffer follows:"); + DumpBufferInfos(buffer); + } + + lineNum += buffer.LineCount; + disposeSum += buffer.DisposeCount; + maxDispose = Math.Max(maxDispose, buffer.DisposeCount); + minDispose = Math.Min(minDispose, buffer.DisposeCount); + _disposeLock.ReleaseReaderLock(); + } + + ReleaseBufferListReaderLock(); + _logger.Info("Dispose count sum is: {0}\r\nMin dispose count is: {1}\r\nMax dispose count is: {2}\r\n-----------------------------------", disposeSum, minDispose, maxDispose); + } + +#endif + + #endregion + + #region Private Methods + + private ILogFileInfo AddFile(string fileName) + { + _logger.Info("Adding file to ILogFileInfoList: " + fileName); + ILogFileInfo info = GetLogFileInfo(fileName); + _logFileInfoList.Add(info); + return info; + } + + private Task GetLogLineInternal(int lineNum) + { + if (_isDeleted) + { + _logger.Debug("Returning null for line {0} because file is deleted.", lineNum); + + // fast fail if dead file was detected. Prevents repeated lags in GUI thread caused by callbacks from control (e.g. repaint) + return null; + } + + AcquireBufferListReaderLock(); + LogBuffer logBuffer = GetBufferForLine(lineNum); + if (logBuffer == null) + { + ReleaseBufferListReaderLock(); + _logger.Error("Cannot find buffer for line {0}, file: {1}{2}", lineNum, _fileName, IsMultiFile ? " (MultiFile)" : ""); + return null; + } + + // disposeLock prevents that the garbage collector is disposing just in the moment we use the buffer + _disposeLock.AcquireReaderLock(Timeout.Infinite); + if (logBuffer.IsDisposed) + { + LockCookie cookie = _disposeLock.UpgradeToWriterLock(Timeout.Infinite); + lock (logBuffer.FileInfo) + { + ReReadBuffer(logBuffer); + } + + _disposeLock.DowngradeFromWriterLock(ref cookie); + } + + ILogLine line = logBuffer.GetLineOfBlock(lineNum - logBuffer.StartLine); + _disposeLock.ReleaseReaderLock(); + ReleaseBufferListReaderLock(); + + return Task.FromResult(line); + } + + private void InitLruBuffers() + { + _bufferList = []; + _bufferLru = new List(_MAX_BUFFERS + 1); + //this.lruDict = new Dictionary(this.MAX_BUFFERS + 1); // key=startline, value = index in bufferLru + _lruCacheDict = new Dictionary(_MAX_BUFFERS + 1); + _lruCacheDictLock = new ReaderWriterLock(); + _bufferListLock = new ReaderWriterLock(); + _disposeLock = new ReaderWriterLock(); + } + + private void StartGCThread() + { + _garbageCollectorTask = Task.Run(GarbageCollectorThreadProc, cts.Token); + //_garbageCollectorThread = new Thread(new ThreadStart(GarbageCollectorThreadProc)); + //_garbageCollectorThread.IsBackground = true; + //_garbageCollectorThread.Start(); + } + + private void ResetBufferCache() + { + FileSize = 0; + LineCount = 0; + //this.lastReturnedLine = ""; + //this.lastReturnedLineNum = -1; + //this.lastReturnedLineNumForBuffer = -1; + } + + private void CloseFiles() + { + //foreach (ILogFileInfo info in this.ILogFileInfoList) + //{ + // info.CloseFile(); + //} + FileSize = 0; + LineCount = 0; + //this.lastReturnedLine = ""; + //this.lastReturnedLineNum = -1; + //this.lastReturnedLineNumForBuffer = -1; + } + + private ILogFileInfo GetLogFileInfo(string fileNameOrUri) //TODO: I changed to static + { + //TODO this must be fixed and should be given to the logfilereader not just called + IFileSystemPlugin fs = _pluginRegistry.FindFileSystemForUri(fileNameOrUri) ?? throw new LogFileException("No file system plugin found for " + fileNameOrUri); + ILogFileInfo logFileInfo = fs.GetLogfileInfo(fileNameOrUri); + return logFileInfo ?? throw new LogFileException("Cannot find " + fileNameOrUri); + } + + private void ReplaceBufferInfos(ILogFileInfo oldLogFileInfo, ILogFileInfo newLogFileInfo) + { + _logger.Debug("ReplaceBufferInfos() " + oldLogFileInfo.FullName + " -> " + newLogFileInfo.FullName); + AcquireBufferListReaderLock(); + foreach (LogBuffer buffer in _bufferList) + { + if (buffer.FileInfo == oldLogFileInfo) + { + _logger.Debug("Buffer with startLine={0}, lineCount={1}, filePos={2}, size={3} gets new filename {4}", buffer.StartLine, buffer.LineCount, buffer.StartPos, buffer.Size, newLogFileInfo.FullName); + buffer.FileInfo = newLogFileInfo; + } + } + + ReleaseBufferListReaderLock(); + } + + private LogBuffer DeleteBuffersForInfo(ILogFileInfo ILogFileInfo, bool matchNamesOnly) + { + _logger.Info("Deleting buffers for file {0}", ILogFileInfo.FullName); + LogBuffer lastRemovedBuffer = null; + IList deleteList = []; + AcquireBufferListWriterLock(); + _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); + if (matchNamesOnly) + { + foreach (LogBuffer buffer in _bufferList) + { + if (buffer.FileInfo.FullName.ToLower().Equals(ILogFileInfo.FullName.ToLower())) + { + lastRemovedBuffer = buffer; + deleteList.Add(buffer); + } + } + } + else + { + foreach (LogBuffer buffer in _bufferList) + { + if (buffer.FileInfo == ILogFileInfo) + { + lastRemovedBuffer = buffer; + deleteList.Add(buffer); + } + } + } + + foreach (LogBuffer buffer in deleteList) + { + RemoveFromBufferList(buffer); + } + + _lruCacheDictLock.ReleaseWriterLock(); + ReleaseBufferListWriterLock(); + if (lastRemovedBuffer == null) + { + _logger.Info("lastRemovedBuffer is null"); + } + else + { + _logger.Info("lastRemovedBuffer: startLine={0}", lastRemovedBuffer.StartLine); + } + + return lastRemovedBuffer; + } + + /// + /// The caller must have writer locks for lruCache and buffer list! + /// + /// + private void RemoveFromBufferList(LogBuffer buffer) + { + Util.AssertTrue(_lruCacheDictLock.IsWriterLockHeld, "No writer lock for lru cache"); + Util.AssertTrue(_bufferListLock.IsWriterLockHeld, "No writer lock for buffer list"); + _lruCacheDict.Remove(buffer.StartLine); + _bufferList.Remove(buffer); + } + + private void ReadToBufferList(ILogFileInfo logFileInfo, long filePos, int startLine) + { + try + { + using Stream fileStream = logFileInfo.OpenStream(); + try + { + using ILogStreamReader reader = GetLogStreamReader(fileStream, EncodingOptions, UseNewReader); + reader.Position = filePos; + _fileLength = logFileInfo.Length; + + int lineNum = startLine; + LogBuffer logBuffer; + AcquireBufferListReaderLock(); + if (_bufferList.Count == 0) + { + logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER); + logBuffer.StartLine = startLine; + logBuffer.StartPos = filePos; + LockCookie cookie = UpgradeBufferListLockToWriter(); + AddBufferToList(logBuffer); + DowngradeBufferListLockFromWriter(ref cookie); + } + else + { + logBuffer = _bufferList[_bufferList.Count - 1]; + + if (!logBuffer.FileInfo.FullName.Equals(logFileInfo.FullName)) + { + logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER); + logBuffer.StartLine = startLine; + logBuffer.StartPos = filePos; + LockCookie cookie = UpgradeBufferListLockToWriter(); + AddBufferToList(logBuffer); + DowngradeBufferListLockFromWriter(ref cookie); + } + + _disposeLock.AcquireReaderLock(Timeout.Infinite); + if (logBuffer.IsDisposed) + { + LockCookie cookie = _disposeLock.UpgradeToWriterLock(Timeout.Infinite); + ReReadBuffer(logBuffer); + _disposeLock.DowngradeFromWriterLock(ref cookie); + } + + _disposeLock.ReleaseReaderLock(); + } + + Monitor.Enter(logBuffer); // Lock the buffer + ReleaseBufferListReaderLock(); + int lineCount = logBuffer.LineCount; + int droppedLines = logBuffer.PrevBuffersDroppedLinesSum; + filePos = reader.Position; + + while (ReadLine(reader, logBuffer.StartLine + logBuffer.LineCount, logBuffer.StartLine + logBuffer.LineCount + droppedLines, out var line)) + { + LogLine logLine = new(); + if (_shouldStop) + { + Monitor.Exit(logBuffer); + return; + } + + if (line == null) + { + logBuffer.DroppedLinesCount += 1; + droppedLines++; + continue; + } + + lineCount++; + if (lineCount > _MAX_LINES_PER_BUFFER && reader.IsBufferComplete) + { + OnLoadFile(new LoadFileEventArgs(logFileInfo.FullName, filePos, false, logFileInfo.Length, false)); + + Monitor.Exit(logBuffer); + logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER); + Monitor.Enter(logBuffer); + logBuffer.StartLine = lineNum; + logBuffer.StartPos = filePos; + logBuffer.PrevBuffersDroppedLinesSum = droppedLines; + AcquireBufferListWriterLock(); + AddBufferToList(logBuffer); + ReleaseBufferListWriterLock(); + lineCount = 1; + } + + logLine.FullLine = line; + logLine.LineNumber = logBuffer.StartLine + logBuffer.LineCount; + + logBuffer.AddLine(logLine, filePos); + filePos = reader.Position; + lineNum++; + } + + logBuffer.Size = filePos - logBuffer.StartPos; + Monitor.Exit(logBuffer); + _isLineCountDirty = true; + FileSize = reader.Position; + CurrentEncoding = reader.Encoding; // Reader may have detected another encoding + if (!_shouldStop) + { + OnLoadFile(new LoadFileEventArgs(logFileInfo.FullName, filePos, true, _fileLength, false)); + // Fire "Ready" Event + } + } + catch (IOException ioex) + { + _logger.Warn(ioex); + } + } + catch (IOException fe) + { + _logger.Warn(fe, "IOException: "); + _isDeleted = true; + LineCount = 0; + FileSize = 0; + OnFileNotFound(); // notify LogWindow + } + } + + private void AddBufferToList(LogBuffer logBuffer) + { +#if DEBUG + _logger.Debug("AddBufferToList(): {0}/{1}/{2}", logBuffer.StartLine, logBuffer.LineCount, logBuffer.FileInfo.FullName); +#endif + _bufferList.Add(logBuffer); + //UpdateLru(logBuffer); + UpdateLruCache(logBuffer); + } + + private void UpdateLruCache(LogBuffer logBuffer) + { + _lruCacheDictLock.AcquireReaderLock(Timeout.Infinite); + if (_lruCacheDict.TryGetValue(logBuffer.StartLine, out LogBufferCacheEntry cacheEntry)) + { + cacheEntry.Touch(); + } + else + { + LockCookie cookie = _lruCacheDictLock.UpgradeToWriterLock(Timeout.Infinite); + if (!_lruCacheDict.TryGetValue(logBuffer.StartLine, out cacheEntry) + ) // #536: re-test, because multiple threads may have been waiting for writer lock + { + cacheEntry = new LogBufferCacheEntry(); + cacheEntry.LogBuffer = logBuffer; + try + { + _lruCacheDict.Add(logBuffer.StartLine, cacheEntry); + } + catch (ArgumentException e) + { + _logger.Error(e, "Error in LRU cache: " + e.Message); +#if DEBUG // there seems to be a bug with double added key + + _logger.Info("Added buffer:"); + DumpBufferInfos(logBuffer); + if (_lruCacheDict.TryGetValue(logBuffer.StartLine, out LogBufferCacheEntry existingEntry)) + { + _logger.Info("Existing buffer: "); + DumpBufferInfos(existingEntry.LogBuffer); + } + else + { + _logger.Warn("Ooops? Cannot find the already existing entry in LRU."); + } +#endif + _lruCacheDictLock.ReleaseLock(); + throw; + } + } + + _lruCacheDictLock.DowngradeFromWriterLock(ref cookie); + } + + _lruCacheDictLock.ReleaseReaderLock(); + } + + /// + /// Sets a new start line in the given buffer and updates the LRU cache, if the buffer + /// is present in the cache. The caller must have write lock for 'lruCacheDictLock'; + /// + /// + /// + private void SetNewStartLineForBuffer(LogBuffer logBuffer, int newLineNum) + { + Util.AssertTrue(_lruCacheDictLock.IsWriterLockHeld, "No writer lock for lru cache"); + if (_lruCacheDict.ContainsKey(logBuffer.StartLine)) + { + _lruCacheDict.Remove(logBuffer.StartLine); + logBuffer.StartLine = newLineNum; + LogBufferCacheEntry cacheEntry = new(); + cacheEntry.LogBuffer = logBuffer; + _lruCacheDict.Add(logBuffer.StartLine, cacheEntry); + } + else + { + logBuffer.StartLine = newLineNum; + } + } + + private void GarbageCollectLruCache() + { +#if DEBUG + long startTime = Environment.TickCount; +#endif + _logger.Debug("Starting garbage collection"); + int threshold = 10; + _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); + int diff = 0; + if (_lruCacheDict.Count - (_MAX_BUFFERS + threshold) > 0) + { + diff = _lruCacheDict.Count - _MAX_BUFFERS; +#if DEBUG + if (diff > 0) + { + _logger.Info("Removing {0} entries from LRU cache for {1}", diff, Util.GetNameFromPath(_fileName)); + } +#endif + SortedList useSorterList = []; + // sort by usage counter + foreach (LogBufferCacheEntry entry in _lruCacheDict.Values) + { + if (!useSorterList.ContainsKey(entry.LastUseTimeStamp)) + { + useSorterList.Add(entry.LastUseTimeStamp, entry.LogBuffer.StartLine); + } + } + + // remove first entries (least usage) + _disposeLock.AcquireWriterLock(Timeout.Infinite); + for (int i = 0; i < diff; ++i) + { + if (i >= useSorterList.Count) + { + break; + } + + int startLine = useSorterList.Values[i]; + LogBufferCacheEntry entry = _lruCacheDict[startLine]; + _lruCacheDict.Remove(startLine); + entry.LogBuffer.DisposeContent(); + } + + _disposeLock.ReleaseWriterLock(); + } + + _lruCacheDictLock.ReleaseWriterLock(); +#if DEBUG + if (diff > 0) + { + long endTime = Environment.TickCount; + _logger.Info("Garbage collector time: " + (endTime - startTime) + " ms."); + } +#endif + } + + private void GarbageCollectorThreadProc() + { + while (!_shouldStop) + { + try + { + Thread.Sleep(10000); + } + catch (Exception) + { + } + + GarbageCollectLruCache(); + } + } + + // private void UpdateLru(LogBuffer logBuffer) + // { + // lock (this.monitor) + // { + // int index; + // if (this.lruDict.TryGetValue(logBuffer.StartLine, out index)) + // { + // RemoveBufferFromLru(logBuffer, index); + // AddBufferToLru(logBuffer); + // } + // else + // { + // if (this.bufferLru.Count > MAX_BUFFERS - 1) + // { + // LogBuffer looser = this.bufferLru[0]; + // if (looser != null) + // { + //#if DEBUG + // _logger.logDebug("Disposing buffer: " + looser.StartLine + "/" + looser.LineCount + "/" + looser.FileInfo.FileName); + //#endif + // looser.DisposeContent(); + // RemoveBufferFromLru(looser); + // } + // } + // AddBufferToLru(logBuffer); + // } + // } + // } + + ///// + ///// Removes a LogBuffer from the LRU. Note that the LogBuffer is searched in the lruDict + ///// via StartLine. So this property must have a consistent value. + ///// + ///// + //private void RemoveBufferFromLru(LogBuffer buffer) + //{ + // int index; + // lock (this.monitor) + // { + // if (this.lruDict.TryGetValue(buffer.StartLine, out index)) + // { + // RemoveBufferFromLru(buffer, index); + // } + // } + //} + + ///// + ///// Removes a LogBuffer from the LRU with known index. Note that the LogBuffer is searched in the lruDict + ///// via StartLine. So this property must have a consistent value. + ///// + ///// + ///// + //private void RemoveBufferFromLru(LogBuffer buffer, int index) + //{ + // lock (this.monitor) + // { + // this.bufferLru.RemoveAt(index); + // this.lruDict.Remove(buffer.StartLine); + // // adjust indizes, they have changed because of the remove + // for (int i = index; i < this.bufferLru.Count; ++i) + // { + // this.lruDict[this.bufferLru[i].StartLine] = this.lruDict[this.bufferLru[i].StartLine] - 1; + // } + // } + //} + + //private void AddBufferToLru(LogBuffer logBuffer) + //{ + // lock (this.monitor) + // { + // this.bufferLru.Add(logBuffer); + // int newIndex = this.bufferLru.Count - 1; + // this.lruDict[logBuffer.StartLine] = newIndex; + // } + //} + + private void ClearLru() + { + //lock (this.monitor) + //{ + // foreach (LogBuffer buffer in this.bufferLru) + // { + // buffer.DisposeContent(); + // } + // this.bufferLru.Clear(); + // this.lruDict.Clear(); + //} + _logger.Info("Clearing LRU cache."); + _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); + _disposeLock.AcquireWriterLock(Timeout.Infinite); + foreach (LogBufferCacheEntry entry in _lruCacheDict.Values) + { + entry.LogBuffer.DisposeContent(); + } + + _lruCacheDict.Clear(); + _disposeLock.ReleaseWriterLock(); + _lruCacheDictLock.ReleaseWriterLock(); + _logger.Info("Clearing done."); + } + + private void ReReadBuffer(LogBuffer logBuffer) + { +#if DEBUG + _logger.Info("re-reading buffer: {0}/{1}/{2}", logBuffer.StartLine, logBuffer.LineCount, logBuffer.FileInfo.FullName); +#endif + try + { + Monitor.Enter(logBuffer); + Stream fileStream = null; + try + { + fileStream = logBuffer.FileInfo.OpenStream(); + } + catch (IOException e) + { + _logger.Warn(e); + return; + } + + try + { + ILogStreamReader reader = GetLogStreamReader(fileStream, EncodingOptions, UseNewReader); + + long filePos = logBuffer.StartPos; + reader.Position = logBuffer.StartPos; + int maxLinesCount = logBuffer.LineCount; + int lineCount = 0; + int dropCount = logBuffer.PrevBuffersDroppedLinesSum; + logBuffer.ClearLines(); + + while (ReadLine(reader, logBuffer.StartLine + logBuffer.LineCount, logBuffer.StartLine + logBuffer.LineCount + dropCount, out string line)) + { + if (lineCount >= maxLinesCount) + { + break; + } + + if (line == null) + { + dropCount++; + continue; + } + + LogLine logLine = new() + { + FullLine = line, + LineNumber = logBuffer.StartLine + logBuffer.LineCount + }; + + logBuffer.AddLine(logLine, filePos); + filePos = reader.Position; + lineCount++; + } + + if (maxLinesCount != logBuffer.LineCount) + { + _logger.Warn("LineCount in buffer differs after re-reading. old={0}, new={1}", maxLinesCount, logBuffer.LineCount); + } + + if (dropCount - logBuffer.PrevBuffersDroppedLinesSum != logBuffer.DroppedLinesCount) + { + _logger.Warn("DroppedLinesCount in buffer differs after re-reading. old={0}, new={1}", logBuffer.DroppedLinesCount, dropCount); + logBuffer.DroppedLinesCount = dropCount - logBuffer.PrevBuffersDroppedLinesSum; + } + + GC.KeepAlive(fileStream); + } + catch (IOException e) + { + _logger.Warn(e); + } + finally + { + fileStream.Close(); + } + } + finally + { + Monitor.Exit(logBuffer); + } + } + + private LogBuffer GetBufferForLine(int lineNum) + { +#if DEBUG + long startTime = Environment.TickCount; +#endif + LogBuffer logBuffer = null; + AcquireBufferListReaderLock(); + //if (lineNum == this.lastReturnedLineNumForBuffer) + //{ + // return this.lastReturnedBuffer; + //} + + //int startIndex = lineNum / LogBuffer.MAX_LINES; // doesn't work anymore since XML buffer may contain more lines than MAX_LINES + int startIndex = 0; + int count = _bufferList.Count; + for (int i = startIndex; i < count; ++i) + { + logBuffer = _bufferList[i]; + if (lineNum >= logBuffer.StartLine && lineNum < logBuffer.StartLine + logBuffer.LineCount) + { + //UpdateLru(logBuffer); + UpdateLruCache(logBuffer); + //this.lastReturnedLineNumForBuffer = lineNum; + //this.lastReturnedBuffer = logBuffer; + break; + } + } +#if DEBUG + long endTime = Environment.TickCount; + //_logger.logDebug("getBufferForLine(" + lineNum + ") duration: " + ((endTime - startTime)) + " ms. Buffer start line: " + logBuffer.StartLine); +#endif + ReleaseBufferListReaderLock(); + return logBuffer; + } + + /// + /// Async callback used to check if the GetLogLine() call is succeeding again after a detected timeout. + /// + private void GetLineFinishedCallback(ILogLine line) + { + _isFailModeCheckCallPending = false; + if (line != null) + { + _logger.Debug("'isFastFailOnGetLogLine' flag was reset"); + _isFastFailOnGetLogLine = false; + } + + _logger.Debug("'isLogLineCallPending' flag was reset."); + } + + private LogBuffer GetFirstBufferForFileByLogBuffer(LogBuffer logBuffer) + { + ILogFileInfo info = logBuffer.FileInfo; + AcquireBufferListReaderLock(); + int index = _bufferList.IndexOf(logBuffer); + if (index == -1) + { + ReleaseBufferListReaderLock(); + return null; + } + + LogBuffer resultBuffer = logBuffer; + while (true) + { + index--; + if (index < 0 || _bufferList[index].FileInfo != info) + { + break; + } + + resultBuffer = _bufferList[index]; + } + + ReleaseBufferListReaderLock(); + return resultBuffer; + } + + private void MonitorThreadProc() + { + Thread.CurrentThread.Name = "MonitorThread"; + //IFileSystemPlugin fs = PluginRegistry.GetInstance().FindFileSystemForUri(this.watchedILogFileInfo.FullName); + _logger.Info("MonitorThreadProc() for file {0}", _watchedILogFileInfo.FullName); + + long oldSize = 0; + try + { + OnLoadingStarted(new LoadFileEventArgs(_fileName, 0, false, 0, false)); + ReadFiles(); + if (!_isDeleted) + { + oldSize = _fileLength; + OnLoadingFinished(); + } + } + catch (Exception e) + { + _logger.Error(e); + } + + while (!_shouldStop) + { + try + { + int pollInterval = _watchedILogFileInfo.PollInterval; + //#if DEBUG + // if (_logger.IsDebug) + // { + // _logger.logDebug("Poll interval for " + this.fileName + ": " + pollInterval); + // } + //#endif + Thread.Sleep(pollInterval); + } + catch (Exception e) + { + _logger.Error(e); + } + + if (_shouldStop) + { + return; + } + + try + { + if (_watchedILogFileInfo.FileHasChanged()) + { + _fileLength = _watchedILogFileInfo.Length; + if (_fileLength == -1) + { + MonitoredFileNotFound(); + } + else + { + oldSize = _fileLength; + FileChanged(); + } + } + } + catch (FileNotFoundException) + { + MonitoredFileNotFound(); + } + } + } + + private void MonitoredFileNotFound() + { + long oldSize; + if (!_isDeleted) + { + _logger.Debug("File not FileNotFoundException catched. Switching to 'deleted' mode."); + _isDeleted = true; + oldSize = _fileLength = -1; + FileSize = 0; + OnFileNotFound(); // notify LogWindow + } +#if DEBUG + else + { + _logger.Debug("File not FileNotFoundException catched. Already in deleted mode."); + } +#endif + } + + private void FileChanged() + { + if (_isDeleted) + { + OnRespawned(); + // prevent size update events. The window should reload the complete file. + FileSize = _fileLength; + } + + long newSize = _fileLength; + //if (this.currFileSize != newSize) + { + _logger.Info("file size changed. new size={0}, file: {1}", newSize, _fileName); + FireChangeEvent(); + } + } + + private void FireChangeEvent() + { + LogEventArgs args = new(); + args.PrevFileSize = FileSize; + args.PrevLineCount = LineCount; + long newSize = _fileLength; + if (newSize < FileSize || _isDeleted) + { + _logger.Info("File was created anew: new size={0}, oldSize={1}", newSize, FileSize); + // Fire "New File" event + FileSize = 0; + LineCount = 0; + try + { + if (!IsMultiFile) + { + // ReloadBufferList(); // removed because reloading is triggered by owning LogWindow + // Trigger "new file" handling (reload) + OnLoadFile(new LoadFileEventArgs(_fileName, 0, true, _fileLength, true)); + + if (_isDeleted) + { + args.FileSize = newSize; + args.LineCount = LineCount; + if (args.PrevLineCount != args.LineCount && !_shouldStop) + { + OnFileSizeChanged(args); + } + } + + _isDeleted = false; + } + else + { + int offset = ShiftBuffers(); + //this.currFileSize = newSize; // removed because ShiftBuffers() calls ReadToBuffer() which will set the actual read size + args.FileSize = newSize; + args.LineCount = LineCount; + args.IsRollover = true; + args.RolloverOffset = offset; + _isDeleted = false; + if (!_shouldStop) + { + OnFileSizeChanged(args); + } + } + } + catch (FileNotFoundException e) + { + // trying anew in next poll intervall. So let currFileSize untouched. + _logger.Warn(e); + } + } + else + { + ReadToBufferList(_watchedILogFileInfo, FileSize, LineCount); + args.FileSize = newSize; + args.LineCount = LineCount; + //if (args.PrevLineCount != args.LineCount && !this.shouldStop) + OnFileSizeChanged(args); + } + } + + private ILogStreamReader GetLogStreamReader(Stream stream, EncodingOptions encodingOptions, bool useNewReader) + { + ILogStreamReader reader = CreateLogStreamReader(stream, encodingOptions, useNewReader); + + return IsXmlMode ? new XmlBlockSplitter(new XmlLogReader(reader), XmlLogConfig) : reader; + } + + private ILogStreamReader CreateLogStreamReader(Stream stream, EncodingOptions encodingOptions, bool useSystemReader) + { + if (useSystemReader) + { + return new PositionAwareStreamReaderSystem(stream, encodingOptions); + } + + return new PositionAwareStreamReaderLegacy(stream, encodingOptions); + } + + private bool ReadLine(ILogStreamReader reader, int lineNum, int realLineNum, out string outLine) + { + string line = null; + try + { + line = reader.ReadLine(); + } + catch (IOException e) + { + _logger.Warn(e); + } + catch (NotSupportedException e) + { + // Bug#11: "Reading operations are not supported by the stream" + // Currently not reproducible. Probably happens at an unlucky time interval (after opening the file) + // when the file is being deleted (rolling) + // This will be handled as EOF. + _logger.Warn(e); + } + + if (line == null) // EOF or catched Exception + { + outLine = null; + return false; + } + + if (PreProcessColumnizer != null) + { + line = PreProcessColumnizer.PreProcessLine(line, lineNum, realLineNum); + } + + outLine = line; + return true; + } + + private void AcquireBufferListReaderLock() + { + try + { + _bufferListLock.AcquireReaderLock(10000); +#if DEBUG && TRACE_LOCKS + StackTrace st = new StackTrace(true); + StackFrame callerFrame = st.GetFrame(2); + this.bufferListLockInfo = +"Read lock from " + callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "() " + callerFrame.GetFileLineNumber(); +#endif + } + catch (ApplicationException e) + { + _logger.Warn(e, "Reader lock wait for bufferList timed out. Now trying infinite."); +#if DEBUG && TRACE_LOCKS + _logger.logInfo(this.bufferListLockInfo); +#endif + _bufferListLock.AcquireReaderLock(Timeout.Infinite); + } + } + + private void ReleaseBufferListReaderLock() + { + _bufferListLock.ReleaseReaderLock(); + } + + private void AcquireBufferListWriterLock() + { + try + { + _bufferListLock.AcquireWriterLock(10000); +#if DEBUG && TRACE_LOCKS + StackTrace st = new StackTrace(true); + StackFrame callerFrame = st.GetFrame(1); + this.bufferListLockInfo = +"Write lock from " + callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "() " + callerFrame.GetFileLineNumber(); + callerFrame.GetFileName(); +#endif + } + catch (ApplicationException e) + { + _logger.Warn(e, "Writer lock wait for bufferList timed out. Now trying infinite."); +#if DEBUG && TRACE_LOCKS + _logger.logInfo(this.bufferListLockInfo); +#endif + _bufferListLock.AcquireWriterLock(Timeout.Infinite); + } + } + + private void ReleaseBufferListWriterLock() + { + _bufferListLock.ReleaseWriterLock(); + } + + private LockCookie UpgradeBufferListLockToWriter() + { + try + { + LockCookie cookie = _bufferListLock.UpgradeToWriterLock(10000); +#if DEBUG && TRACE_LOCKS + StackTrace st = new StackTrace(true); + StackFrame callerFrame = st.GetFrame(2); + this.bufferListLockInfo += +", upgraded to writer from " + callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "() " + callerFrame.GetFileLineNumber(); +#endif + return cookie; + } + catch (ApplicationException e) + { + _logger.Warn(e, "Writer lock update wait for bufferList timed out. Now trying infinite."); +#if DEBUG && TRACE_LOCKS + _logger.logInfo(this.bufferListLockInfo); +#endif + return _bufferListLock.UpgradeToWriterLock(Timeout.Infinite); + } + } + + private void DowngradeBufferListLockFromWriter(ref LockCookie cookie) + { + _bufferListLock.DowngradeFromWriterLock(ref cookie); +#if DEBUG && TRACE_LOCKS + StackTrace st = new StackTrace(true); + StackFrame callerFrame = st.GetFrame(2); + this.bufferListLockInfo += +", downgraded to reader from " + callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "() " + callerFrame.GetFileLineNumber(); +#endif + } + +#if DEBUG + private void DumpBufferInfos(LogBuffer buffer) + { + if (_logger.IsTraceEnabled) + { + _logger.Trace("StartLine: {0}\r\nLineCount: {1}\r\nStartPos: {2}\r\nSize: {3}\r\nDisposed: {4}\r\nDisposeCount: {5}\r\nFile: {6}", + buffer.StartLine, + buffer.LineCount, + buffer.StartPos, + buffer.Size, + buffer.IsDisposed ? "yes" : "no", + buffer.DisposeCount, + buffer.FileInfo.FullName); + } + } + +#endif + + #endregion + + ~LogfileReader() + { + DeleteAllContent(); + } + + protected virtual void OnFileSizeChanged(LogEventArgs e) + { + FileSizeChanged?.Invoke(this, e); + } + + protected virtual void OnLoadFile(LoadFileEventArgs e) + { + LoadFile?.Invoke(this, e); + } + + protected virtual void OnLoadingStarted(LoadFileEventArgs e) + { + LoadingStarted?.Invoke(this, e); + } + + protected virtual void OnLoadingFinished() + { + LoadingFinished?.Invoke(this, EventArgs.Empty); + } + + protected virtual void OnFileNotFound() + { + FileNotFound?.Invoke(this, EventArgs.Empty); + } + + protected virtual void OnRespawned() + { + _logger.Info("OnRespawned()"); + Respawned?.Invoke(this, EventArgs.Empty); + } + + private class LogLine : ILogLine + { + #region Properties + + public string FullLine { get; set; } + + public int LineNumber { get; set; } + + string ITextValue.Text => FullLine; + + #endregion + } + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/Log/RolloverFilenameHandler.cs b/src/Logexpert.Core/Classes/Log/RolloverFilenameHandler.cs similarity index 85% rename from src/LogExpert/Classes/Log/RolloverFilenameHandler.cs rename to src/Logexpert.Core/Classes/Log/RolloverFilenameHandler.cs index 3909c737..9880af25 100644 --- a/src/LogExpert/Classes/Log/RolloverFilenameHandler.cs +++ b/src/Logexpert.Core/Classes/Log/RolloverFilenameHandler.cs @@ -1,111 +1,110 @@ -using LogExpert.Core.Classes.Log; -using LogExpert.Core.Entities; - -using System.Collections.Generic; - -namespace LogExpert.Classes.Log -{ - /// - /// Handles rollover naming. The names built by the RolloverFilenameBuilder will be used - /// to check if the file exist. Names will be built by incrmenting an index and decrementing a date. - /// A configurable number of days in the past will be checked (date gaps may occur on days without log file activity). - /// Date checking is only performed if the format pattern contains a date format. Index checking - /// is only performed of the format pattern contains an index placeholder. - /// - public class RolloverFilenameHandler - { - #region Fields - - private readonly RolloverFilenameBuilder _filenameBuilder; - private readonly ILogFileInfo _logFileInfo; - private readonly MultiFileOptions _options; - - #endregion - - #region cTor - - /// - /// Constructor. - /// - /// The complete path of the logfile - /// Multifile option (e.g. format pattern) - public RolloverFilenameHandler(ILogFileInfo logFileInfo, MultiFileOptions options) - { - _options = options; - _logFileInfo = logFileInfo; - _filenameBuilder = new RolloverFilenameBuilder(_options.FormatPattern); - _filenameBuilder.SetFileName(logFileInfo.FileName); - } - - #endregion - - #region Public methods - - /// - /// Returns a list of the built file names (complete path) which also exists on disk. - /// The list is created by using the RolloverFilenameBuilder and checking for file existence. - /// The first entry in the list contains the oldest file. The last entry contains the file given - /// in the contructor. - /// - /// - public LinkedList GetNameList() - { - LinkedList fileList = new(); - string fileName = _filenameBuilder.BuildFileName(); - string filePath = _logFileInfo.DirectoryName + _logFileInfo.DirectorySeparatorChar + fileName; - fileList.AddFirst(filePath); - bool found = true; - while (found) - { - found = false; - // increment index and check if file exists - if (_filenameBuilder.IsIndexPattern) - { - _filenameBuilder.Index += 1; - fileName = _filenameBuilder.BuildFileName(); - filePath = _logFileInfo.DirectoryName + _logFileInfo.DirectorySeparatorChar + fileName; - if (FileExists(filePath)) - { - fileList.AddFirst(filePath); - found = true; - continue; - } - } - // if file with index isn't found or no index is in format pattern, decrement the current date - if (_filenameBuilder.IsDatePattern) - { - int tryCounter = 0; - _filenameBuilder.Index = 0; - while (tryCounter < _options.MaxDayTry) - { - _filenameBuilder.DecrementDate(); - fileName = _filenameBuilder.BuildFileName(); - filePath = _logFileInfo.DirectoryName + _logFileInfo.DirectorySeparatorChar + fileName; - if (FileExists(filePath)) - { - fileList.AddFirst(filePath); - found = true; - break; - } - - tryCounter++; - } - } - } - return fileList; - } - - #endregion - - #region Private Methods - - private bool FileExists(string filePath) - { - IFileSystemPlugin fs = PluginRegistry.PluginRegistry.Instance.FindFileSystemForUri(filePath); - ILogFileInfo info = fs.GetLogfileInfo(filePath); - return info.FileExists; - } - - #endregion - } +using LogExpert.Core.Entities; +using LogExpert.Core.Interface; +using System.Collections.Generic; + +namespace LogExpert.Core.Classes.Log +{ + /// + /// Handles rollover naming. The names built by the RolloverFilenameBuilder will be used + /// to check if the file exist. Names will be built by incrmenting an index and decrementing a date. + /// A configurable number of days in the past will be checked (date gaps may occur on days without log file activity). + /// Date checking is only performed if the format pattern contains a date format. Index checking + /// is only performed of the format pattern contains an index placeholder. + /// + public class RolloverFilenameHandler + { + #region Fields + + private readonly RolloverFilenameBuilder _filenameBuilder; + private readonly ILogFileInfo _logFileInfo; + private readonly MultiFileOptions _options; + + #endregion + + #region cTor + + /// + /// Constructor. + /// + /// The complete path of the logfile + /// Multifile option (e.g. format pattern) + public RolloverFilenameHandler(ILogFileInfo logFileInfo, MultiFileOptions options) + { + _options = options; + _logFileInfo = logFileInfo; + _filenameBuilder = new RolloverFilenameBuilder(_options.FormatPattern); + _filenameBuilder.SetFileName(logFileInfo.FileName); + } + + #endregion + + #region Public methods + + /// + /// Returns a list of the built file names (complete path) which also exists on disk. + /// The list is created by using the RolloverFilenameBuilder and checking for file existence. + /// The first entry in the list contains the oldest file. The last entry contains the file given + /// in the contructor. + /// + /// + public LinkedList GetNameList(IPluginRegistry pluginRegistry) + { + LinkedList fileList = new(); + string fileName = _filenameBuilder.BuildFileName(); + string filePath = _logFileInfo.DirectoryName + _logFileInfo.DirectorySeparatorChar + fileName; + fileList.AddFirst(filePath); + bool found = true; + while (found) + { + found = false; + // increment index and check if file exists + if (_filenameBuilder.IsIndexPattern) + { + _filenameBuilder.Index += 1; + fileName = _filenameBuilder.BuildFileName(); + filePath = _logFileInfo.DirectoryName + _logFileInfo.DirectorySeparatorChar + fileName;//TODO: Change to Directory.Combine + if (FileExists(filePath, pluginRegistry)) + { + fileList.AddFirst(filePath); + found = true; + continue; + } + } + // if file with index isn't found or no index is in format pattern, decrement the current date + if (_filenameBuilder.IsDatePattern) + { + int tryCounter = 0; + _filenameBuilder.Index = 0; + while (tryCounter < _options.MaxDayTry) + { + _filenameBuilder.DecrementDate(); + fileName = _filenameBuilder.BuildFileName(); + filePath = _logFileInfo.DirectoryName + _logFileInfo.DirectorySeparatorChar + fileName;//TODO: Change to Directory.Combine + if (FileExists(filePath, pluginRegistry)) + { + fileList.AddFirst(filePath); + found = true; + break; + } + + tryCounter++; + } + } + } + return fileList; + } + + #endregion + + #region Private Methods + + private bool FileExists(string filePath, IPluginRegistry pluginRegistry) + { + IFileSystemPlugin fs = pluginRegistry.FindFileSystemForUri(filePath); + ILogFileInfo info = fs.GetLogfileInfo(filePath); + return info.FileExists; + } + + #endregion + } } \ No newline at end of file diff --git a/src/Logexpert.Core/EventArgs/BookmarkEventArgs.cs b/src/Logexpert.Core/EventArguments/BookmarkEventArgs.cs similarity index 84% rename from src/Logexpert.Core/EventArgs/BookmarkEventArgs.cs rename to src/Logexpert.Core/EventArguments/BookmarkEventArgs.cs index 40456151..2a600219 100644 --- a/src/Logexpert.Core/EventArgs/BookmarkEventArgs.cs +++ b/src/Logexpert.Core/EventArguments/BookmarkEventArgs.cs @@ -1,6 +1,6 @@ using LogExpert.Core.Entities; -namespace LogExpert.Core.EventArgs +namespace LogExpert.Core.EventArguments { public class BookmarkEventArgs(Bookmark bookmark) : System.EventArgs { diff --git a/src/Logexpert.Core/EventArgs/ColumnizerEventArgs.cs b/src/Logexpert.Core/EventArguments/ColumnizerEventArgs.cs similarity index 83% rename from src/Logexpert.Core/EventArgs/ColumnizerEventArgs.cs rename to src/Logexpert.Core/EventArguments/ColumnizerEventArgs.cs index d440d769..ad8ef92a 100644 --- a/src/Logexpert.Core/EventArgs/ColumnizerEventArgs.cs +++ b/src/Logexpert.Core/EventArguments/ColumnizerEventArgs.cs @@ -1,4 +1,4 @@ -namespace LogExpert.Core.EventArgs +namespace LogExpert.Core.EventArguments { public class ColumnizerEventArgs(ILogLineColumnizer columnizer) : System.EventArgs { diff --git a/src/Logexpert.Core/EventArgs/ConfigChangedEventArgs.cs b/src/Logexpert.Core/EventArguments/ConfigChangedEventArgs.cs similarity index 85% rename from src/Logexpert.Core/EventArgs/ConfigChangedEventArgs.cs rename to src/Logexpert.Core/EventArguments/ConfigChangedEventArgs.cs index 2247fdab..243faa0d 100644 --- a/src/Logexpert.Core/EventArgs/ConfigChangedEventArgs.cs +++ b/src/Logexpert.Core/EventArguments/ConfigChangedEventArgs.cs @@ -1,6 +1,6 @@ using LogExpert.Core.Config; -namespace LogExpert.Core.EventArgs +namespace LogExpert.Core.EventArguments { public class ConfigChangedEventArgs(SettingsFlags changeFlags) : System.EventArgs { diff --git a/src/Logexpert.Core/EventArgs/ContextMenuPluginEventArgs.cs b/src/Logexpert.Core/EventArguments/ContextMenuPluginEventArgs.cs similarity index 91% rename from src/Logexpert.Core/EventArgs/ContextMenuPluginEventArgs.cs rename to src/Logexpert.Core/EventArguments/ContextMenuPluginEventArgs.cs index 86aca2a8..28df85f7 100644 --- a/src/Logexpert.Core/EventArgs/ContextMenuPluginEventArgs.cs +++ b/src/Logexpert.Core/EventArguments/ContextMenuPluginEventArgs.cs @@ -1,4 +1,4 @@ -namespace LogExpert.Core.EventArgs +namespace LogExpert.Core.EventArguments { public class ContextMenuPluginEventArgs(IContextMenuEntry entry, IList logLines, ILogLineColumnizer columnizer, ILogExpertCallback callback) : System.EventArgs diff --git a/src/Logexpert.Core/EventArguments/CurrentHighlightGroupChangedEventArgs.cs b/src/Logexpert.Core/EventArguments/CurrentHighlightGroupChangedEventArgs.cs new file mode 100644 index 00000000..efc33f45 --- /dev/null +++ b/src/Logexpert.Core/EventArguments/CurrentHighlightGroupChangedEventArgs.cs @@ -0,0 +1,16 @@ +using LogExpert.Core.Entities; +using LogExpert.Core.Interface; + +namespace LogExpert.Core.EventArguments +{ + public class CurrentHighlightGroupChangedEventArgs(ILogWindow logWindow, HighlightGroup currentGroup) + { + #region Properties + + public ILogWindow LogWindow { get; } = logWindow; + + public HighlightGroup CurrentGroup { get; } = currentGroup; + + #endregion + } +} \ No newline at end of file diff --git a/src/Logexpert.Core/EventArguments/FilterListChangedEventArgs.cs b/src/Logexpert.Core/EventArguments/FilterListChangedEventArgs.cs new file mode 100644 index 00000000..684f993c --- /dev/null +++ b/src/Logexpert.Core/EventArguments/FilterListChangedEventArgs.cs @@ -0,0 +1,14 @@ + +using LogExpert.Core.Interface; + +namespace LogExpert.Core.EventArguments +{ + public class FilterListChangedEventArgs(ILogWindow logWindow) + { + #region Properties + + public ILogWindow LogWindow { get; } = logWindow; + + #endregion + } +} \ No newline at end of file diff --git a/src/Logexpert.Core/EventArgs/GuiStateArgs.cs b/src/Logexpert.Core/EventArguments/GuiStateArgs.cs similarity index 96% rename from src/Logexpert.Core/EventArgs/GuiStateArgs.cs rename to src/Logexpert.Core/EventArguments/GuiStateArgs.cs index 17bb96f3..25faf023 100644 --- a/src/Logexpert.Core/EventArgs/GuiStateArgs.cs +++ b/src/Logexpert.Core/EventArguments/GuiStateArgs.cs @@ -1,6 +1,6 @@ using System.Text; -namespace LogExpert.Core.EventArgs +namespace LogExpert.Core.EventArguments { public class GuiStateArgs : System.EventArgs { diff --git a/src/Logexpert.Core/EventArgs/LoadFileEventArgs.cs b/src/Logexpert.Core/EventArguments/LoadFileEventArgs.cs similarity index 72% rename from src/Logexpert.Core/EventArgs/LoadFileEventArgs.cs rename to src/Logexpert.Core/EventArguments/LoadFileEventArgs.cs index 3ae24ce6..18f786b9 100644 --- a/src/Logexpert.Core/EventArgs/LoadFileEventArgs.cs +++ b/src/Logexpert.Core/EventArguments/LoadFileEventArgs.cs @@ -1,4 +1,4 @@ -namespace LogExpert.Core.EventArgs +namespace LogExpert.Core.EventArguments { public record LoadFileEventArgs(string FileName, long ReadPos, bool Finished, long FileSize, bool NewFile); } \ No newline at end of file diff --git a/src/Logexpert.Core/EventArgs/OverlayEventArgs.cs b/src/Logexpert.Core/EventArguments/OverlayEventArgs.cs similarity index 86% rename from src/Logexpert.Core/EventArgs/OverlayEventArgs.cs rename to src/Logexpert.Core/EventArguments/OverlayEventArgs.cs index efae4ce9..ef826147 100644 --- a/src/Logexpert.Core/EventArgs/OverlayEventArgs.cs +++ b/src/Logexpert.Core/EventArguments/OverlayEventArgs.cs @@ -1,6 +1,6 @@ using LogExpert.Core.Entities; -namespace LogExpert.Core.EventArgs +namespace LogExpert.Core.EventArguments { public class OverlayEventArgs(BookmarkOverlay overlay) : System.EventArgs { diff --git a/src/Logexpert.Core/EventArgs/PatternArgs.cs b/src/Logexpert.Core/EventArguments/PatternArgs.cs similarity index 89% rename from src/Logexpert.Core/EventArgs/PatternArgs.cs rename to src/Logexpert.Core/EventArguments/PatternArgs.cs index 5d69421d..b8b63a60 100644 --- a/src/Logexpert.Core/EventArgs/PatternArgs.cs +++ b/src/Logexpert.Core/EventArguments/PatternArgs.cs @@ -1,4 +1,4 @@ -namespace LogExpert.Core.EventArgs +namespace LogExpert.Core.EventArguments { public class PatternArgs { diff --git a/src/Logexpert.Core/EventArgs/ProgressEventArgs.cs b/src/Logexpert.Core/EventArguments/ProgressEventArgs.cs similarity index 87% rename from src/Logexpert.Core/EventArgs/ProgressEventArgs.cs rename to src/Logexpert.Core/EventArguments/ProgressEventArgs.cs index 7edbb77c..f91c15fc 100644 --- a/src/Logexpert.Core/EventArgs/ProgressEventArgs.cs +++ b/src/Logexpert.Core/EventArguments/ProgressEventArgs.cs @@ -1,4 +1,4 @@ -namespace LogExpert.Core.EventArgs +namespace LogExpert.Core.EventArguments { public class ProgressEventArgs : System.EventArgs { diff --git a/src/Logexpert.Core/EventArgs/SelectLineEventArgs.cs b/src/Logexpert.Core/EventArguments/SelectLineEventArgs.cs similarity index 79% rename from src/Logexpert.Core/EventArgs/SelectLineEventArgs.cs rename to src/Logexpert.Core/EventArguments/SelectLineEventArgs.cs index 380ebe4b..b667872b 100644 --- a/src/Logexpert.Core/EventArgs/SelectLineEventArgs.cs +++ b/src/Logexpert.Core/EventArguments/SelectLineEventArgs.cs @@ -1,4 +1,4 @@ -namespace LogExpert.Core.EventArgs +namespace LogExpert.Core.EventArguments { public class SelectLineEventArgs(int line) : System.EventArgs { diff --git a/src/Logexpert.Core/EventArgs/StatusEventArgs.cs b/src/Logexpert.Core/EventArguments/StatusEventArgs.cs similarity index 94% rename from src/Logexpert.Core/EventArgs/StatusEventArgs.cs rename to src/Logexpert.Core/EventArguments/StatusEventArgs.cs index 47a1d50a..43d6f99d 100644 --- a/src/Logexpert.Core/EventArgs/StatusEventArgs.cs +++ b/src/Logexpert.Core/EventArguments/StatusEventArgs.cs @@ -1,4 +1,4 @@ -namespace LogExpert.Core.EventArgs +namespace LogExpert.Core.EventArguments { public class StatusLineEventArgs : System.EventArgs { diff --git a/src/Logexpert.Core/EventArgs/SyncModeEventArgs.cs b/src/Logexpert.Core/EventArguments/SyncModeEventArgs.cs similarity index 81% rename from src/Logexpert.Core/EventArgs/SyncModeEventArgs.cs rename to src/Logexpert.Core/EventArguments/SyncModeEventArgs.cs index 838aaae1..f595c0d4 100644 --- a/src/Logexpert.Core/EventArgs/SyncModeEventArgs.cs +++ b/src/Logexpert.Core/EventArguments/SyncModeEventArgs.cs @@ -1,4 +1,4 @@ -namespace LogExpert.Core.EventArgs +namespace LogExpert.Core.EventArguments { public class SyncModeEventArgs(bool isSynced) : System.EventArgs { diff --git a/src/Logexpert.Core/EventHandlers/EventHandlers.cs b/src/Logexpert.Core/EventHandlers/EventHandlers.cs new file mode 100644 index 00000000..2254b17a --- /dev/null +++ b/src/Logexpert.Core/EventHandlers/EventHandlers.cs @@ -0,0 +1,8 @@ +using LogExpert.Core.Entities; +using LogExpert.Core.EventArguments; + +namespace LogExpert.Core.EventHandlers +{ + public delegate void ConfigChangedEventHandler(object sender, ConfigChangedEventArgs e); + public delegate void FileSizeChangedEventHandler(object sender, LogEventArgs e); +} diff --git a/src/Logexpert.Core/Interface/BackgroundProcessCancelHandler.cs b/src/Logexpert.Core/Interface/IBackgroundProcessCancelHandler.cs similarity index 87% rename from src/Logexpert.Core/Interface/BackgroundProcessCancelHandler.cs rename to src/Logexpert.Core/Interface/IBackgroundProcessCancelHandler.cs index 18e23d32..132589e0 100644 --- a/src/Logexpert.Core/Interface/BackgroundProcessCancelHandler.cs +++ b/src/Logexpert.Core/Interface/IBackgroundProcessCancelHandler.cs @@ -4,7 +4,7 @@ /// Interface which can register at the LogWindow to be informed of pressing ESC. /// Used e.g. for cancelling a filter. /// - public interface BackgroundProcessCancelHandler + public interface IBackgroundProcessCancelHandler { #region Public methods diff --git a/src/Logexpert.Core/Interface/IBookmarkView.cs b/src/Logexpert.Core/Interface/IBookmarkView.cs index c020858c..f626c004 100644 --- a/src/Logexpert.Core/Interface/IBookmarkView.cs +++ b/src/Logexpert.Core/Interface/IBookmarkView.cs @@ -5,6 +5,7 @@ namespace LogExpert.Core.Interface /// /// To be implemented by the bookmark window. Will be informed from LogWindow about changes in bookmarks. /// + //TODO: Not in use! public interface IBookmarkView { #region Properties diff --git a/src/Logexpert.Core/Interface/IConfigManager.cs b/src/Logexpert.Core/Interface/IConfigManager.cs new file mode 100644 index 00000000..37ca8a74 --- /dev/null +++ b/src/Logexpert.Core/Interface/IConfigManager.cs @@ -0,0 +1,21 @@ +using LogExpert.Core.Config; +using LogExpert.Core.EventArguments; +using LogExpert.Core.EventHandlers; + +namespace LogExpert.Core.Interface +{ + public interface IConfigManager + { + Settings Settings { get; } + string PortableModeDir { get; } + string ConfigDir { get; } + IConfigManager Instance { get; } + string PortableModeSettingsFileName { get; } + void Export(FileInfo fileInfo, SettingsFlags highlightSettings); + void Export(FileInfo fileInfo); + void Import(FileInfo fileInfo, ExportImportFlags importFlags); + void ImportHighlightSettings(FileInfo fileInfo, ExportImportFlags importFlags); + event ConfigChangedEventHandler ConfigChanged; //TODO: All handlers that are public shoulld be in Core + void Save(SettingsFlags flags); + } +} \ No newline at end of file diff --git a/src/LogExpert/Interface/ILogExpertProxy.cs b/src/Logexpert.Core/Interface/ILogExpertProxy.cs similarity index 86% rename from src/LogExpert/Interface/ILogExpertProxy.cs rename to src/Logexpert.Core/Interface/ILogExpertProxy.cs index 313e50be..1bf43bcc 100644 --- a/src/LogExpert/Interface/ILogExpertProxy.cs +++ b/src/Logexpert.Core/Interface/ILogExpertProxy.cs @@ -1,40 +1,38 @@ -using LogExpert.Controls.LogTabWindow; - -namespace LogExpert.Interface -{ - public interface ILogExpertProxy - { - #region Public methods - - /// - /// Load the given files into the existing window. - /// - /// - void LoadFiles(string[] fileNames); - - /// - /// Open a new LogExpert window and load the given files. - /// - /// - void NewWindow(string[] fileNames); - - /// - /// load given files into the locked window or open a new window if no window is locked. - /// - /// - void NewWindowOrLockedWindow(string[] fileNames); - - - /// - /// Called from LogTabWindow when the window is about to be closed. - /// - /// - void WindowClosed(LogTabWindow logWin); - - int GetLogWindowCount(); - - #endregion - - //void BroadcastSettingsChanged(Object cookie); - } +namespace LogExpert.Core.Interface +{ + public interface ILogExpertProxy + { + #region Public methods + + /// + /// Load the given files into the existing window. + /// + /// + void LoadFiles(string[] fileNames); + + /// + /// Open a new LogExpert window and load the given files. + /// + /// + void NewWindow(string[] fileNames); + + /// + /// load given files into the locked window or open a new window if no window is locked. + /// + /// + void NewWindowOrLockedWindow(string[] fileNames); + + + /// + /// Called from LogTabWindow when the window is about to be closed. + /// + /// + void WindowClosed(ILogTabWindow logWin); + + int GetLogWindowCount(); + + #endregion + + //void BroadcastSettingsChanged(Object cookie); + } } \ No newline at end of file diff --git a/src/Logexpert.Core/Interface/ILogTabWindow.cs b/src/Logexpert.Core/Interface/ILogTabWindow.cs new file mode 100644 index 00000000..85382180 --- /dev/null +++ b/src/Logexpert.Core/Interface/ILogTabWindow.cs @@ -0,0 +1,14 @@ +namespace LogExpert.Core.Interface +{ + public interface ILogTabWindow + { + ILogExpertProxy LogExpertProxy { get; set; } + bool IsDisposed { get; } + + void Activate(); + object Invoke(Delegate method, params object?[]? objects); + void LoadFiles(string[] fileNames); + void SetForeground(); + void Show(); + } +} \ No newline at end of file diff --git a/src/Logexpert.Core/Interface/ILogWindow.cs b/src/Logexpert.Core/Interface/ILogWindow.cs new file mode 100644 index 00000000..6475f260 --- /dev/null +++ b/src/Logexpert.Core/Interface/ILogWindow.cs @@ -0,0 +1,29 @@ + +using LogExpert.Core.Classes.Log; +using LogExpert.Core.Classes.Persister; +using LogExpert.Core.Entities; +using LogExpert.Core.EventHandlers; +using static LogExpert.Core.Classes.Log.LogfileReader; + +namespace LogExpert.Core.Interface +{ + public interface ILogWindow + { + string GetCurrentFileName(int lineNum); + ILogLine GetLine(int lineNum); + DateTime GetTimestampForLineForward(ref int lineNum, bool v); + DateTime GetTimestampForLine(ref int lastLineNum, bool v); + int FindTimestampLine_Internal(int lineNum1, int lineNum2, int lastLineNum, DateTime searchTimeStamp, bool v); + void SelectLine(int lineNum, bool v1, bool v2); + PersistenceData GetPersistenceData(); + void AddTempFileTab(string fileName, string title); + void WritePipeTab(IList lineEntryList, string title); + void Activate(); + LogfileReader _logFileReader { get; } + string Text { get; } + string FileName { get; } + event FileSizeChangedEventHandler FileSizeChanged; //TODO: All handlers should be moved to Core + event EventHandler TailFollowed; + //LogExpert.UI.Controls.LogTabWindow.LogTabWindow.LogWindowData Tag { get; } + } +} \ No newline at end of file diff --git a/src/Logexpert.Core/Interface/IPluginRegistry.cs b/src/Logexpert.Core/Interface/IPluginRegistry.cs new file mode 100644 index 00000000..4ce9d7e9 --- /dev/null +++ b/src/Logexpert.Core/Interface/IPluginRegistry.cs @@ -0,0 +1,9 @@ +namespace LogExpert.Core.Interface +{ + public interface IPluginRegistry + { + IList RegisteredColumnizers { get; } + + IFileSystemPlugin FindFileSystemForUri(string fileNameOrUri); + } +} \ No newline at end of file diff --git a/src/Logexpert.Core/Logexpert.Core.csproj b/src/Logexpert.Core/Logexpert.Core.csproj index 8d46cfcc..e5f95874 100644 --- a/src/Logexpert.Core/Logexpert.Core.csproj +++ b/src/Logexpert.Core/Logexpert.Core.csproj @@ -4,15 +4,15 @@ net8.0 enable enable - false + false true True ..\Solution Items\Key.snk - - - + + + diff --git a/src/Logexpert.UI/Controls/BufferedDataGridView.Designer.cs b/src/Logexpert.UI/Controls/BufferedDataGridView.Designer.cs new file mode 100644 index 00000000..694fce0a --- /dev/null +++ b/src/Logexpert.UI/Controls/BufferedDataGridView.Designer.cs @@ -0,0 +1,35 @@ +namespace LogExpert.Dialogs; + +partial class BufferedDataGridView +{ +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; + +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} + +#region Component Designer generated code + +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + components = new System.ComponentModel.Container(); +} + +#endregion +} diff --git a/src/Logexpert.UI/Controls/BufferedDataGridView.cs b/src/Logexpert.UI/Controls/BufferedDataGridView.cs new file mode 100644 index 00000000..afb248a2 --- /dev/null +++ b/src/Logexpert.UI/Controls/BufferedDataGridView.cs @@ -0,0 +1,341 @@ +using LogExpert.Core.Entities; +using LogExpert.Core.EventArguments; +using LogExpert.UI.Controls; +using NLog; + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +namespace LogExpert.Dialogs; + +public partial class BufferedDataGridView : DataGridView +{ + #region Fields + + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private readonly Brush _brush; + + private readonly Color _bubbleColor = Color.FromArgb(160, 250, 250, 00); + private readonly Font _font = new("Arial", 10); + + private readonly SortedList _overlayList = []; + + private readonly Pen _pen; + private readonly Brush _textBrush = new SolidBrush(Color.FromArgb(200, 0, 0, 90)); + + private BookmarkOverlay _draggedOverlay; + private Point _dragStartPoint; + private bool _isDrag; + private Size _oldOverlayOffset; + + #endregion + + #region cTor + + public BufferedDataGridView() + { + _pen = new Pen(_bubbleColor, (float)3.0); + _brush = new SolidBrush(_bubbleColor); + + InitializeComponent(); + DoubleBuffered = true; + VirtualMode = true; + } + + #endregion + + #region Delegates + + public delegate void OverlayDoubleClickedEventHandler(object sender, OverlayEventArgs e); + + #endregion + + #region Events + + public event OverlayDoubleClickedEventHandler OverlayDoubleClicked; + + #endregion + + #region Properties + + /* + public Graphics Buffer + { + get { return this.myBuffer.Graphics; } + } + */ + + public ContextMenuStrip EditModeMenuStrip { get; set; } = null; + + public bool PaintWithOverlays { get; set; } = false; + + #endregion + + #region Public methods + + public void AddOverlay(BookmarkOverlay overlay) + { + lock (_overlayList) + { + _overlayList.Add(overlay.Position.Y, overlay); + } + } + + #endregion + + #region Overrides + + protected override void OnPaint(PaintEventArgs e) + { + try + { + if (PaintWithOverlays) + { + PaintOverlays(e); + } + else + { + base.OnPaint(e); + } + } + catch (Exception ex) + { + _logger.Error(ex); + } + } + + protected override void OnEditingControlShowing(DataGridViewEditingControlShowingEventArgs e) + { + base.OnEditingControlShowing(e); + e.Control.KeyDown -= OnControlKeyDown; + e.Control.KeyDown += OnControlKeyDown; + DataGridViewTextBoxEditingControl editControl = (DataGridViewTextBoxEditingControl)e.Control; + e.Control.PreviewKeyDown -= Control_PreviewKeyDown; + e.Control.PreviewKeyDown += Control_PreviewKeyDown; + + editControl.ContextMenuStrip = EditModeMenuStrip; + } + + protected override void OnMouseDown(MouseEventArgs e) + { + BookmarkOverlay overlay = GetOverlayForPosition(e.Location); + if (overlay != null) + { + if (e.Button == MouseButtons.Right) + { + if (_isDrag) + { + _isDrag = false; + overlay.Bookmark.OverlayOffset = _oldOverlayOffset; + Refresh(); + } + } + else + { + _dragStartPoint = e.Location; + _isDrag = true; + _draggedOverlay = overlay; + _oldOverlayOffset = overlay.Bookmark.OverlayOffset; + } + } + else + { + _isDrag = false; + base.OnMouseDown(e); + } + } + + protected override void OnMouseUp(MouseEventArgs e) + { + if (_isDrag) + { + _isDrag = false; + Refresh(); + } + else + { + base.OnMouseUp(e); + } + } + + protected override void OnMouseMove(MouseEventArgs e) + { + if (_isDrag) + { + Cursor = Cursors.Hand; + Size offset = new(e.X - _dragStartPoint.X, e.Y - _dragStartPoint.Y); + _draggedOverlay.Bookmark.OverlayOffset = _oldOverlayOffset + offset; + Refresh(); + } + else + { + BookmarkOverlay overlay = GetOverlayForPosition(e.Location); + Cursor = overlay != null ? Cursors.Hand : Cursors.Default; + base.OnMouseMove(e); + } + } + + protected override void OnMouseDoubleClick(MouseEventArgs e) + { + BookmarkOverlay overlay = GetOverlayForPosition(e.Location); + if (overlay != null) + { + if (e.Button == MouseButtons.Left) + { + OnOverlayDoubleClicked(new OverlayEventArgs(overlay)); + } + } + else + { + base.OnMouseDoubleClick(e); + } + } + + #endregion + + #region Private Methods + + private BookmarkOverlay GetOverlayForPosition(Point pos) + { + lock (_overlayList) + { + foreach (BookmarkOverlay overlay in _overlayList.Values) + { + if (overlay.BubbleRect.Contains(pos)) + { + return overlay; + } + } + } + + return null; + } + + private void PaintOverlays(PaintEventArgs e) + { + BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current; + + using BufferedGraphics myBuffer = currentContext.Allocate(CreateGraphics(), ClientRectangle); + lock (_overlayList) + { + _overlayList.Clear(); + } + + myBuffer.Graphics.SetClip(ClientRectangle, CombineMode.Union); + e.Graphics.SetClip(ClientRectangle, CombineMode.Union); + + PaintEventArgs args = new(myBuffer.Graphics, e.ClipRectangle); + + base.OnPaint(args); + + StringFormat format = new(); + format.LineAlignment = StringAlignment.Center; + format.Alignment = StringAlignment.Near; + + myBuffer.Graphics.SetClip(DisplayRectangle, CombineMode.Intersect); + + // Remove Columnheader from Clippingarea + Rectangle rectTableHeader = new(DisplayRectangle.X, DisplayRectangle.Y, DisplayRectangle.Width, ColumnHeadersHeight); + myBuffer.Graphics.SetClip(rectTableHeader, CombineMode.Exclude); + + //e.Graphics.SetClip(rect, CombineMode.Union); + + lock (_overlayList) + { + foreach (BookmarkOverlay overlay in _overlayList.Values) + { + SizeF textSize = myBuffer.Graphics.MeasureString(overlay.Bookmark.Text, _font, 300); + Rectangle rectBubble = new(overlay.Position, + new Size((int)textSize.Width, (int)textSize.Height)); + rectBubble.Offset(60, -(rectBubble.Height + 40)); + rectBubble.Inflate(3, 3); + rectBubble.Location += overlay.Bookmark.OverlayOffset; + overlay.BubbleRect = rectBubble; + myBuffer.Graphics.SetClip(rectBubble, CombineMode.Union); // Bubble to clip + myBuffer.Graphics.SetClip(rectTableHeader, CombineMode.Exclude); + e.Graphics.SetClip(rectBubble, CombineMode.Union); + RectangleF textRect = new(rectBubble.X, rectBubble.Y, rectBubble.Width, rectBubble.Height); + myBuffer.Graphics.FillRectangle(_brush, rectBubble); + //myBuffer.Graphics.DrawLine(_pen, overlay.Position, new Point(rect.X, rect.Y + rect.Height / 2)); + myBuffer.Graphics.DrawLine(_pen, overlay.Position, new Point(rectBubble.X, rectBubble.Y + rectBubble.Height)); + myBuffer.Graphics.DrawString(overlay.Bookmark.Text, _font, _textBrush, textRect, format); + + if (_logger.IsDebugEnabled) + { + _logger.Debug("ClipRgn: {0},{1},{2},{3}", myBuffer.Graphics.ClipBounds.Left, myBuffer.Graphics.ClipBounds.Top, myBuffer.Graphics.ClipBounds.Width, myBuffer.Graphics.ClipBounds.Height); + } + } + } + + myBuffer.Render(e.Graphics); + } + + #endregion + + #region Events handler + + private void Control_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) + { + if ((e.KeyCode == Keys.C || e.KeyCode == Keys.Insert) && e.Control) + { + if (EditingControl != null) + { + e.IsInputKey = true; + } + } + } + + private void OnControlKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down) + { + if (EditingControl != null) + { + if (EditingControl is LogCellEditingControl editControl) + { + editControl.EditingControlDataGridView.EndEdit(); + int line = editControl.EditingControlDataGridView.CurrentCellAddress.Y; + if (e.KeyCode == Keys.Up) + { + if (line > 0) + { + line--; + } + } + + if (e.KeyCode == Keys.Down) + { + if (line < editControl.EditingControlDataGridView.RowCount - 1) + { + line++; + } + } + + int col = editControl.EditingControlDataGridView.CurrentCellAddress.X; + int scrollIndex = editControl.EditingControlDataGridView.HorizontalScrollingOffset; + int selStart = editControl.SelectionStart; + editControl.EditingControlDataGridView.CurrentCell = editControl.EditingControlDataGridView.Rows[line].Cells[col]; + editControl.EditingControlDataGridView.BeginEdit(false); + editControl.SelectionStart = selStart; + editControl.ScrollToCaret(); + editControl.EditingControlDataGridView.HorizontalScrollingOffset = scrollIndex; + e.Handled = true; + } + else + { + _logger.Warn("Edit control was null, to be checked"); + } + } + } + } + + #endregion + + protected virtual void OnOverlayDoubleClicked(OverlayEventArgs e) + { + OverlayDoubleClicked?.Invoke(this, e); + } +} diff --git a/src/Logexpert.UI/Controls/ColorComboBox.cs b/src/Logexpert.UI/Controls/ColorComboBox.cs index 2d4c6e96..352eead1 100644 --- a/src/Logexpert.UI/Controls/ColorComboBox.cs +++ b/src/Logexpert.UI/Controls/ColorComboBox.cs @@ -1,100 +1,99 @@ using System.Drawing.Drawing2D; using System.Runtime.Versioning; -namespace LogExpert.UI.Controls +namespace LogExpert.UI.Controls; + +[SupportedOSPlatform("windows")] +public class ColorComboBox : ComboBox { - [SupportedOSPlatform("windows")] - public class ColorComboBox : ComboBox - { - #region Fields + #region Fields - private Color _customColor = Color.FromKnownColor(KnownColor.Black); + private Color _customColor = Color.FromKnownColor(KnownColor.Black); - #endregion + #endregion - #region cTor + #region cTor - public ColorComboBox() + public ColorComboBox() + { + DrawMode = DrawMode.OwnerDrawFixed; + DrawItem += OnColorComboBoxDrawItem; + // add color presets + if (!DesignMode) { - DrawMode = DrawMode.OwnerDrawFixed; - DrawItem += OnColorComboBoxDrawItem; - // add color presets - if (!DesignMode) - { - Items.Add(_customColor); - Items.Add(Color.Black); - Items.Add(Color.White); - Items.Add(Color.Gray); - Items.Add(Color.DarkGray); - Items.Add(Color.Blue); - Items.Add(Color.LightBlue); - Items.Add(Color.DarkBlue); - Items.Add(Color.Green); - Items.Add(Color.LightGreen); - Items.Add(Color.DarkGreen); - Items.Add(Color.Olive); - Items.Add(Color.Red); - Items.Add(Color.Pink); - Items.Add(Color.Purple); - Items.Add(Color.IndianRed); - Items.Add(Color.DarkCyan); - Items.Add(Color.Yellow); - } + Items.Add(_customColor); + Items.Add(Color.Black); + Items.Add(Color.White); + Items.Add(Color.Gray); + Items.Add(Color.DarkGray); + Items.Add(Color.Blue); + Items.Add(Color.LightBlue); + Items.Add(Color.DarkBlue); + Items.Add(Color.Green); + Items.Add(Color.LightGreen); + Items.Add(Color.DarkGreen); + Items.Add(Color.Olive); + Items.Add(Color.Red); + Items.Add(Color.Pink); + Items.Add(Color.Purple); + Items.Add(Color.IndianRed); + Items.Add(Color.DarkCyan); + Items.Add(Color.Yellow); } + } - #endregion + #endregion - #region Properties + #region Properties - public Color CustomColor + public Color CustomColor + { + get => _customColor; + set { - get => _customColor; - set - { - _customColor = value; - Items.RemoveAt(0); - Items.Insert(0, _customColor); - } + _customColor = value; + Items.RemoveAt(0); + Items.Insert(0, _customColor); } + } - public Color SelectedColor => (Color)(SelectedIndex != -1 ? Items[SelectedIndex] : null); + public Color SelectedColor => (Color)(SelectedIndex != -1 ? Items[SelectedIndex] : null); - #endregion + #endregion - #region Events handler + #region Events handler - private void OnColorComboBoxDrawItem(object sender, DrawItemEventArgs e) + private void OnColorComboBoxDrawItem(object sender, DrawItemEventArgs e) + { + e.DrawBackground(); + if (e.Index >= 0) { - e.DrawBackground(); - if (e.Index >= 0) + Rectangle rectangle = new(4, e.Bounds.Top + 2, 30, e.Bounds.Height - 4); + Color rectColor = (Color)Items[e.Index]; + e.Graphics.FillRectangle(new SolidBrush(rectColor), rectangle); + e.Graphics.DrawRectangle(Pens.Black, rectangle); + + if (e.Index == 0) { - Rectangle rectangle = new(4, e.Bounds.Top + 2, 30, e.Bounds.Height - 4); - Color rectColor = (Color)Items[e.Index]; - e.Graphics.FillRectangle(new SolidBrush(rectColor), rectangle); - e.Graphics.DrawRectangle(Pens.Black, rectangle); - - if (e.Index == 0) - { - e.Graphics.DrawString("Custom", e.Font, Brushes.Black, - new PointF(42, e.Bounds.Top + 2)); - } - else - { - e.Graphics.DrawString(((Color)Items[e.Index]).Name, e.Font, Brushes.Black, - new PointF(42, e.Bounds.Top + 2)); - } - - if (!Enabled) - { - HatchBrush brush = new(HatchStyle.Percent50, Color.LightGray, Color.FromArgb(10, Color.LightGray)); - rectangle.Inflate(1, 1); - e.Graphics.FillRectangle(brush, rectangle); - brush.Dispose(); - } - e.DrawFocusRectangle(); + e.Graphics.DrawString("Custom", e.Font, Brushes.Black, + new PointF(42, e.Bounds.Top + 2)); + } + else + { + e.Graphics.DrawString(((Color)Items[e.Index]).Name, e.Font, Brushes.Black, + new PointF(42, e.Bounds.Top + 2)); } - } - #endregion + if (!Enabled) + { + HatchBrush brush = new(HatchStyle.Percent50, Color.LightGray, Color.FromArgb(10, Color.LightGray)); + rectangle.Inflate(1, 1); + e.Graphics.FillRectangle(brush, rectangle); + brush.Dispose(); + } + e.DrawFocusRectangle(); + } } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert/Controls/DateTimeDragControl.Designer.cs b/src/Logexpert.UI/Controls/DateTimeDragControl.Designer.cs similarity index 100% rename from src/LogExpert/Controls/DateTimeDragControl.Designer.cs rename to src/Logexpert.UI/Controls/DateTimeDragControl.Designer.cs diff --git a/src/LogExpert/Controls/DateTimeDragControl.cs b/src/Logexpert.UI/Controls/DateTimeDragControl.cs similarity index 100% rename from src/LogExpert/Controls/DateTimeDragControl.cs rename to src/Logexpert.UI/Controls/DateTimeDragControl.cs diff --git a/src/LogExpert/Controls/DateTimeDragControl.resx b/src/Logexpert.UI/Controls/DateTimeDragControl.resx similarity index 100% rename from src/LogExpert/Controls/DateTimeDragControl.resx rename to src/Logexpert.UI/Controls/DateTimeDragControl.resx diff --git a/src/Logexpert.UI/Controls/KnobControl.Designer.cs b/src/Logexpert.UI/Controls/KnobControl.Designer.cs index 8b780d80..74a54cb3 100644 --- a/src/Logexpert.UI/Controls/KnobControl.Designer.cs +++ b/src/Logexpert.UI/Controls/KnobControl.Designer.cs @@ -1,4 +1,4 @@ -namespace LogExpert.Controls; +namespace LogExpert.UI.Controls; partial class KnobControl { diff --git a/src/Logexpert.UI/Controls/KnobControl.cs b/src/Logexpert.UI/Controls/KnobControl.cs index 0350ac36..fc2c1c0e 100644 --- a/src/Logexpert.UI/Controls/KnobControl.cs +++ b/src/Logexpert.UI/Controls/KnobControl.cs @@ -2,7 +2,7 @@ using System.Runtime.Versioning; -namespace LogExpert.Controls; +namespace LogExpert.UI.Controls; [SupportedOSPlatform("windows")] public partial class KnobControl : UserControl diff --git a/src/LogExpert/Dialogs/LogGridCell.cs b/src/Logexpert.UI/Controls/LogGridCell.cs similarity index 74% rename from src/LogExpert/Dialogs/LogGridCell.cs rename to src/Logexpert.UI/Controls/LogGridCell.cs index 3f0b4222..70ca04bd 100644 --- a/src/LogExpert/Dialogs/LogGridCell.cs +++ b/src/Logexpert.UI/Controls/LogGridCell.cs @@ -1,9 +1,7 @@ -using LogExpert.UI.Controls; - -using System; +using System; using System.Windows.Forms; -namespace LogExpert.Dialogs +namespace LogExpert.UI.Controls { public class LogGridCell : DataGridViewTextBoxCell { diff --git a/src/LogExpert/Dialogs/LogTextColumn.cs b/src/Logexpert.UI/Controls/LogTextColumn.cs similarity index 87% rename from src/LogExpert/Dialogs/LogTextColumn.cs rename to src/Logexpert.UI/Controls/LogTextColumn.cs index 03b5839f..a4f5e291 100644 --- a/src/LogExpert/Dialogs/LogTextColumn.cs +++ b/src/Logexpert.UI/Controls/LogTextColumn.cs @@ -1,6 +1,6 @@ using System.Windows.Forms; -namespace LogExpert.Dialogs +namespace LogExpert.UI.Controls { public class LogTextColumn : DataGridViewColumn { diff --git a/src/LogExpert/Classes/ColumnCache.cs b/src/Logexpert.UI/Controls/LogWindow/ColumnCache.cs similarity index 92% rename from src/LogExpert/Classes/ColumnCache.cs rename to src/Logexpert.UI/Controls/LogWindow/ColumnCache.cs index ba71a4e4..4d735027 100644 --- a/src/LogExpert/Classes/ColumnCache.cs +++ b/src/Logexpert.UI/Controls/LogWindow/ColumnCache.cs @@ -1,40 +1,40 @@ -using LogExpert.Classes.ILogLineColumnizerCallback; -using LogExpert.Classes.Log; - -namespace LogExpert.Classes -{ - internal class ColumnCache - { - #region Fields - - private IColumnizedLogLine _cachedColumns; - private ILogLineColumnizer _lastColumnizer; - private int _lastLineNumber = -1; - - #endregion - - #region Internals - - internal IColumnizedLogLine GetColumnsForLine(LogfileReader logFileReader, int lineNumber, ILogLineColumnizer columnizer, ColumnizerCallback columnizerCallback) - { - if (_lastColumnizer != columnizer || _lastLineNumber != lineNumber && _cachedColumns != null || columnizerCallback.LineNum != lineNumber) - { - _lastColumnizer = columnizer; - _lastLineNumber = lineNumber; - ILogLine line = logFileReader.GetLogLineWithWait(lineNumber).Result; - if (line != null) - { - columnizerCallback.LineNum = lineNumber; - _cachedColumns = columnizer.SplitLine(columnizerCallback, line); - } - else - { - _cachedColumns = null; - } - } - return _cachedColumns; - } - - #endregion - } +using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Classes.Log; + +namespace LogExpert.UI.Controls.LogWindow +{ + internal class ColumnCache + { + #region Fields + + private IColumnizedLogLine _cachedColumns; + private ILogLineColumnizer _lastColumnizer; + private int _lastLineNumber = -1; + + #endregion + + #region Internals + + internal IColumnizedLogLine GetColumnsForLine(LogfileReader logFileReader, int lineNumber, ILogLineColumnizer columnizer, ColumnizerCallback columnizerCallback) + { + if (_lastColumnizer != columnizer || _lastLineNumber != lineNumber && _cachedColumns != null || columnizerCallback.LineNum != lineNumber) + { + _lastColumnizer = columnizer; + _lastLineNumber = lineNumber; + ILogLine line = logFileReader.GetLogLineWithWait(lineNumber).Result; + if (line != null) + { + columnizerCallback.LineNum = lineNumber; + _cachedColumns = columnizer.SplitLine(columnizerCallback, line); + } + else + { + _cachedColumns = null; + } + } + return _cachedColumns; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/ILogLineColumnizerCallback/LogExpertCallback.cs b/src/Logexpert.UI/Controls/LogWindow/LogExpertCallback.cs similarity index 81% rename from src/LogExpert/Classes/ILogLineColumnizerCallback/LogExpertCallback.cs rename to src/Logexpert.UI/Controls/LogWindow/LogExpertCallback.cs index 8fd463cc..d3de849b 100644 --- a/src/LogExpert/Classes/ILogLineColumnizerCallback/LogExpertCallback.cs +++ b/src/Logexpert.UI/Controls/LogWindow/LogExpertCallback.cs @@ -1,8 +1,6 @@ -using LogExpert.Controls.LogWindow; +using LogExpert.Classes.ILogLineColumnizerCallback; -using System.Collections.Generic; - -namespace LogExpert.Classes.ILogLineColumnizerCallback +namespace LogExpert.UI.Controls.LogWindow { internal class LogExpertCallback(LogWindow logWindow) : ColumnizerCallback(logWindow), ILogExpertCallback { diff --git a/src/LogExpert/Controls/LogWindow/LogWindow.cs b/src/Logexpert.UI/Controls/LogWindow/LogWindow.cs similarity index 90% rename from src/LogExpert/Controls/LogWindow/LogWindow.cs rename to src/Logexpert.UI/Controls/LogWindow/LogWindow.cs index f150ebbc..a80a4b71 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindow.cs +++ b/src/Logexpert.UI/Controls/LogWindow/LogWindow.cs @@ -1,664 +1,702 @@ -using LogExpert.Classes; -using LogExpert.Classes.Filter; -using LogExpert.Classes.ILogLineColumnizerCallback; -using LogExpert.Classes.Log; -using LogExpert.Config; -using LogExpert.Core.Classes.Bookmark; -using LogExpert.Core.Classes.Filter; -using LogExpert.Core.Classes.Highlight; -using LogExpert.Core.Classes.Persister; -using LogExpert.Core.Config; -using LogExpert.Core.Entities; -using LogExpert.Core.EventArgs; -using LogExpert.Core.Interface; -using LogExpert.Dialogs; -using LogExpert.Entities.EventArgs; -using LogExpert.UI.Dialogs; -using LogExpert.UI.Extensions.Forms; - -using NLog; - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Forms; - -using WeifenLuo.WinFormsUI.Docking; - -namespace LogExpert.Controls.LogWindow -{ - public partial class LogWindow : DockContent, ILogPaintContext, ILogView - { - #region Fields - - private const int SPREAD_MAX = 99; - private const int PROGRESS_BAR_MODULO = 1000; - private const int FILTER_ADVANCED_SPLITTER_DISTANCE = 150; - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - - private readonly Image _advancedButtonImage; - - private readonly object _bookmarkLock = new(); - private readonly BookmarkDataProvider _bookmarkProvider = new(); - - private readonly IList _cancelHandlerList = new List(); - - private readonly object _currentColumnizerLock = new(); - - private readonly object _currentHighlightGroupLock = new(); - - private readonly EventWaitHandle _externaLoadingFinishedEvent = new ManualResetEvent(false); - - private readonly IList _filterPipeList = new List(); - private readonly Dictionary _freezeStateMap = []; - private readonly GuiStateArgs _guiStateArgs = new(); - - private readonly List _lineHashList = []; - - private readonly EventWaitHandle _loadingFinishedEvent = new ManualResetEvent(false); - - private readonly EventWaitHandle _logEventArgsEvent = new ManualResetEvent(false); - - private readonly List _logEventArgsList = []; - private readonly Task _logEventHandlerTask; - //private readonly Thread _logEventHandlerThread; - private readonly Image _panelCloseButtonImage; - - private readonly Image _panelOpenButtonImage; - private readonly LogTabWindow.LogTabWindow _parentLogTabWin; - - private readonly ProgressEventArgs _progressEventArgs = new(); - private readonly object _reloadLock = new(); - private readonly Image _searchButtonImage; - private readonly StatusLineEventArgs _statusEventArgs = new(); - - private readonly object _tempHighlightEntryListLock = new(); - - private readonly Task _timeShiftSyncTask; - private readonly CancellationTokenSource cts = new(); - - //private readonly Thread _timeShiftSyncThread; - private readonly EventWaitHandle _timeShiftSyncTimerEvent = new ManualResetEvent(false); - private readonly EventWaitHandle _timeShiftSyncWakeupEvent = new ManualResetEvent(false); - - private readonly TimeSpreadCalculator _timeSpreadCalc; - - private readonly object _timeSyncListLock = new(); - - private ColumnCache _columnCache = new(); - - private ILogLineColumnizer _currentColumnizer; - - //List currentHilightEntryList = new List(); - private HighlightGroup _currentHighlightGroup = new(); - - private SearchParams _currentSearchParams; - - private string[] _fileNames; - private List _filterHitList = []; - private FilterParams _filterParams = new(); - private int _filterPipeNameCounter = 0; - private List _filterResultList = []; - - private EventWaitHandle _filterUpdateEvent = new ManualResetEvent(false); - - private ILogLineColumnizer _forcedColumnizer; - private ILogLineColumnizer _forcedColumnizerForLoading; - private bool _isDeadFile; - private bool _isErrorShowing; - private bool _isLoadError; - private bool _isLoading; - private bool _isMultiFile; - private bool _isSearching; - private bool _isTimestampDisplaySyncing; - private List _lastFilterLinesList = []; - - private int _lineHeight = 0; - - internal LogfileReader _logFileReader; - private MultiFileOptions _multiFileOptions = new(); - private bool _noSelectionUpdates; - private PatternArgs _patternArgs = new(); - private PatternWindow _patternWindow; - - private ReloadMemento _reloadMemento; - private int _reloadOverloadCounter = 0; - private SortedList _rowHeightList = []; - private int _selectedCol = 0; // set by context menu event for column headers only - private bool _shouldCallTimeSync; - private bool _shouldCancel; - private bool _shouldTimestampDisplaySyncingCancel; - private bool _showAdvanced; - private List _tempHighlightEntryList = []; - private int _timeShiftSyncLine = 0; - - private bool _waitingForClose; - - #endregion - - #region cTor - - public LogWindow(LogTabWindow.LogTabWindow parent, string fileName, bool isTempFile, bool forcePersistenceLoading) - { - SuspendLayout(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - InitializeComponent(); - - CreateDefaultViewStyle(); - - columnNamesLabel.Text = ""; // no filtering on columns by default - - _parentLogTabWin = parent; - IsTempFile = isTempFile; - //Thread.CurrentThread.Name = "LogWindowThread"; - ColumnizerCallbackObject = new ColumnizerCallback(this); - - FileName = fileName; - ForcePersistenceLoading = forcePersistenceLoading; - - dataGridView.CellValueNeeded += OnDataGridViewCellValueNeeded; - dataGridView.CellPainting += OnDataGridView_CellPainting; - - filterGridView.CellValueNeeded += OnFilterGridViewCellValueNeeded; - filterGridView.CellPainting += OnFilterGridViewCellPainting; - filterListBox.DrawMode = DrawMode.OwnerDrawVariable; - filterListBox.MeasureItem += MeasureItem; - - Closing += OnLogWindowClosing; - Disposed += OnLogWindowDisposed; - Load += OnLogWindowLoad; - - _timeSpreadCalc = new TimeSpreadCalculator(this); - timeSpreadingControl.TimeSpreadCalc = _timeSpreadCalc; - timeSpreadingControl.LineSelected += OnTimeSpreadingControlLineSelected; - tableLayoutPanel1.ColumnStyles[1].SizeType = SizeType.Absolute; - tableLayoutPanel1.ColumnStyles[1].Width = 20; - tableLayoutPanel1.ColumnStyles[0].SizeType = SizeType.Percent; - tableLayoutPanel1.ColumnStyles[0].Width = 100; - - _parentLogTabWin.HighlightSettingsChanged += OnParentHighlightSettingsChanged; - SetColumnizer(PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers[0]); - - _patternArgs.MaxMisses = 5; - _patternArgs.MinWeight = 1; - _patternArgs.MaxDiffInBlock = 5; - _patternArgs.Fuzzy = 5; - - //InitPatternWindow(); - - //this.toolwinTabControl.TabPages.Add(this.patternWindow); - //this.toolwinTabControl.TabPages.Add(this.bookmarkWindow); - - _filterParams = new FilterParams(); - foreach (string item in ConfigManager.Settings.filterHistoryList) - { - filterComboBox.Items.Add(item); - } - - filterComboBox.DropDownHeight = filterComboBox.ItemHeight * ConfigManager.Settings.Preferences.maximumFilterEntriesDisplayed; - AutoResizeFilterBox(); - - filterRegexCheckBox.Checked = _filterParams.IsRegex; - filterCaseSensitiveCheckBox.Checked = _filterParams.IsCaseSensitive; - filterTailCheckBox.Checked = _filterParams.IsFilterTail; - - splitContainerLogWindow.Panel2Collapsed = true; - advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; - - _timeShiftSyncTask = new Task(SyncTimestampDisplayWorker, cts.Token); - _timeShiftSyncTask.Start(); - //_timeShiftSyncThread = new Thread(SyncTimestampDisplayWorker); - //_timeShiftSyncThread.IsBackground = true; - //_timeShiftSyncThread.Start(); - - _logEventHandlerTask = new Task(LogEventWorker, cts.Token); - _logEventHandlerTask.Start(); - //_logEventHandlerThread = new Thread(LogEventWorker); - //_logEventHandlerThread.IsBackground = true; - //_logEventHandlerThread.Start(); - - //this.filterUpdateThread = new Thread(new ThreadStart(this.FilterUpdateWorker)); - //this.filterUpdateThread.Start(); - - _advancedButtonImage = advancedButton.Image; - _searchButtonImage = filterSearchButton.Image; - filterSearchButton.Image = null; - - dataGridView.EditModeMenuStrip = editModeContextMenuStrip; - markEditModeToolStripMenuItem.Enabled = true; - - _panelOpenButtonImage = Resources.Resources.Arrow_menu_open; - _panelCloseButtonImage = Resources.Resources.Arrow_menu_close; - - Settings settings = ConfigManager.Settings; - - if (settings.appBounds.Right > 0) - { - Bounds = settings.appBounds; - } - - _waitingForClose = false; - dataGridView.Enabled = false; - dataGridView.ColumnDividerDoubleClick += OnDataGridViewColumnDividerDoubleClick; - ShowAdvancedFilterPanel(false); - filterKnobBackSpread.MinValue = 0; - filterKnobBackSpread.MaxValue = SPREAD_MAX; - filterKnobBackSpread.ValueChanged += OnFilterKnobControlValueChanged; - filterKnobForeSpread.MinValue = 0; - filterKnobForeSpread.MaxValue = SPREAD_MAX; - filterKnobForeSpread.ValueChanged += OnFilterKnobControlValueChanged; - fuzzyKnobControl.MinValue = 0; - fuzzyKnobControl.MaxValue = 10; - //PreferencesChanged(settings.preferences, true); - AdjustHighlightSplitterWidth(); - ToggleHighlightPanel(false); // hidden - - _bookmarkProvider.BookmarkAdded += OnBookmarkProviderBookmarkAdded; - _bookmarkProvider.BookmarkRemoved += OnBookmarkProviderBookmarkRemoved; - _bookmarkProvider.AllBookmarksRemoved += OnBookmarkProviderAllBookmarksRemoved; - - ResumeLayout(); - - ChangeTheme(Controls); - } - - #endregion - - #region ColorTheme - public void ChangeTheme(Control.ControlCollection container) - { - #region ApplyColorToAllControls - foreach (Control component in container) - { - if (component.Controls != null && component.Controls.Count > 0) - { - ChangeTheme(component.Controls); - component.BackColor = ColorMode.BackgroundColor; - component.ForeColor = ColorMode.ForeColor; - } - else - { - component.BackColor = ColorMode.BackgroundColor; - component.ForeColor = ColorMode.ForeColor; - } - - } - #endregion - - #region DataGridView - - // Main DataGridView - dataGridView.BackgroundColor = ColorMode.DockBackgroundColor; - dataGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor; - dataGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor; - dataGridView.EnableHeadersVisualStyles = false; - - // Filter dataGridView - filterGridView.BackgroundColor = ColorMode.DockBackgroundColor; - filterGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor; - filterGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor; - filterGridView.EnableHeadersVisualStyles = false; - - // Colors for menu - dataGridContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - bookmarkContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - columnContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - editModeContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - filterContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - filterListContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - - foreach (ToolStripItem item in dataGridContextMenuStrip.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - foreach (ToolStripItem item in bookmarkContextMenuStrip.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - foreach (ToolStripItem item in columnContextMenuStrip.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - foreach (ToolStripItem item in editModeContextMenuStrip.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - foreach (ToolStripItem item in filterContextMenuStrip.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - foreach (ToolStripItem item in filterListContextMenuStrip.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - // Colors for menu - filterContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - - for (var y = 0; y < filterContextMenuStrip.Items.Count; y++) - { - var item = filterContextMenuStrip.Items[y]; - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - #endregion DataGridView - - filterComboBox.BackColor = ColorMode.DockBackgroundColor; - } - - #endregion - - #region Delegates - - public delegate void BookmarkAddedEventHandler(object sender, EventArgs e); - - public delegate void BookmarkRemovedEventHandler(object sender, EventArgs e); - - public delegate void BookmarkTextChangedEventHandler(object sender, BookmarkEventArgs e); - - public delegate void ColumnizerChangedEventHandler(object sender, ColumnizerEventArgs e); - - public delegate void CurrentHighlightGroupChangedEventHandler(object sender, CurrentHighlightGroupChangedEventArgs e); - - public delegate void FileNotFoundEventHandler(object sender, EventArgs e); - - public delegate void FileRespawnedEventHandler(object sender, EventArgs e); - - public delegate void FileSizeChangedEventHandler(object sender, LogEventArgs e); - - public delegate void FilterListChangedEventHandler(object sender, FilterListChangedEventArgs e); - - // used for filterTab restore - public delegate void FilterRestoreFx(LogWindow newWin, PersistenceData persistenceData); - - public delegate void GuiStateEventHandler(object sender, GuiStateArgs e); - - public delegate void ProgressBarEventHandler(object sender, ProgressEventArgs e); - - public delegate void RestoreFiltersFx(PersistenceData persistenceData); - - public delegate bool ScrollToTimestampFx(DateTime timestamp, bool roundToSeconds, bool triggerSyncCall); - - public delegate void StatusLineEventHandler(object sender, StatusLineEventArgs e); - - public delegate void SyncModeChangedEventHandler(object sender, SyncModeEventArgs e); - - public delegate void TailFollowedEventHandler(object sender, EventArgs e); - - #endregion - - #region Events - - public event FileSizeChangedEventHandler FileSizeChanged; - - public event ProgressBarEventHandler ProgressBarUpdate; - - public event StatusLineEventHandler StatusLineEvent; - - public event GuiStateEventHandler GuiStateUpdate; - - public event TailFollowedEventHandler TailFollowed; - - public event FileNotFoundEventHandler FileNotFound; - - public event FileRespawnedEventHandler FileRespawned; - - public event FilterListChangedEventHandler FilterListChanged; - - public event CurrentHighlightGroupChangedEventHandler CurrentHighlightGroupChanged; - - public event BookmarkAddedEventHandler BookmarkAdded; - - public event BookmarkRemovedEventHandler BookmarkRemoved; - - public event BookmarkTextChangedEventHandler BookmarkTextChanged; - - public event ColumnizerChangedEventHandler ColumnizerChanged; - - public event SyncModeChangedEventHandler SyncModeChanged; - - #endregion - - #region Properties - - public Color BookmarkColor { get; set; } = Color.FromArgb(165, 200, 225); - - public ILogLineColumnizer CurrentColumnizer - { - get => _currentColumnizer; - private set - { - lock (_currentColumnizerLock) - { - _currentColumnizer = value; - _logger.Debug($"Setting columnizer {_currentColumnizer.GetName()} "); - } - } - } - - public bool ShowBookmarkBubbles - { - get => _guiStateArgs.ShowBookmarkBubbles; - set - { - _guiStateArgs.ShowBookmarkBubbles = dataGridView.PaintWithOverlays = value; - dataGridView.Refresh(); - } - } - - public string FileName { get; private set; } - - public string SessionFileName { get; set; } = null; - - public bool IsMultiFile - { - get => _isMultiFile; - private set => _guiStateArgs.IsMultiFileActive = _isMultiFile = value; - } - - public bool IsTempFile { get; } - - public string TempTitleName { get; set; } = ""; - - internal FilterPipe FilterPipe { get; set; } = null; - - public string Title - { - get - { - if (IsTempFile) - { - return TempTitleName; - } - - return FileName; - } - } - - public ColumnizerCallback ColumnizerCallbackObject { get; } - - public bool ForcePersistenceLoading { get; set; } - - public string ForcedPersistenceFileName { get; set; } = null; - - public Preferences Preferences => ConfigManager.Settings.Preferences; - - public string GivenFileName { get; set; } = null; - - public TimeSyncList TimeSyncList { get; private set; } - - public bool IsTimeSynced => TimeSyncList != null; - - protected EncodingOptions EncodingOptions { get; set; } - - public IBookmarkData BookmarkData => _bookmarkProvider; - - public Font MonospacedFont { get; private set; } - - public Font NormalFont { get; private set; } - - public Font BoldFont { get; private set; } - - #endregion - - #region Public methods - - public ILogLine GetLogLine(int lineNum) - { - return _logFileReader.GetLogLine(lineNum); - } - - public Bookmark GetBookmarkForLine(int lineNum) - { - return _bookmarkProvider.GetBookmarkForLine(lineNum); - } - - #endregion - - #region Internals - - internal IColumnizedLogLine GetColumnsForLine(int lineNumber) - { - return _columnCache.GetColumnsForLine(_logFileReader, lineNumber, CurrentColumnizer, ColumnizerCallbackObject); - - //string line = this.logFileReader.GetLogLine(lineNumber); - //if (line != null) - //{ - // string[] cols; - // this.columnizerCallback.LineNum = lineNumber; - // cols = this.CurrentColumnizer.SplitLine(this.columnizerCallback, line); - // return cols; - //} - //else - //{ - // return null; - //} - } - - internal void RefreshAllGrids() - { - dataGridView.Refresh(); - filterGridView.Refresh(); - } - - internal void ChangeMultifileMask() - { - MultiFileMaskDialog dlg = new(this, FileName) - { - Owner = this, - MaxDays = _multiFileOptions.MaxDayTry, - FileNamePattern = _multiFileOptions.FormatPattern - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - _multiFileOptions.FormatPattern = dlg.FileNamePattern; - _multiFileOptions.MaxDayTry = dlg.MaxDays; - if (IsMultiFile) - { - Reload(); - } - } - } - - internal void ToggleColumnFinder(bool show, bool setFocus) - { - _guiStateArgs.ColumnFinderVisible = show; - if (show) - { - columnComboBox.AutoCompleteMode = AutoCompleteMode.Suggest; - columnComboBox.AutoCompleteSource = AutoCompleteSource.CustomSource; - columnComboBox.AutoCompleteCustomSource = [.. CurrentColumnizer.GetColumnNames()]; - if (setFocus) - { - columnComboBox.Focus(); - } - } - else - { - dataGridView.Focus(); - } - - tableLayoutPanel1.RowStyles[0].Height = show ? 28 : 0; - } - - #endregion - - #region Overrides - - protected override string GetPersistString() - { - return "LogWindow#" + FileName; - } - - #endregion - - private void OnButtonSizeChanged(object sender, EventArgs e) - { - if (sender is Button button && button.Image != null) - { - button.ImageAlign = ContentAlignment.MiddleCenter; - button.Image = new Bitmap(button.Image, new Size(button.Size.Height, button.Size.Height)); - } - } - - // used for external wait fx WaitForLoadFinished() - - private delegate void SelectLineFx(int line, bool triggerSyncCall); - - private Action, List, List> FilterFxAction; - //private delegate void FilterFx(FilterParams filterParams, List filterResultLines, List lastFilterResultLines, List filterHitList); - - private delegate void UpdateProgressBarFx(int lineNum); - - private delegate void SetColumnizerFx(ILogLineColumnizer columnizer); - - private delegate void WriteFilterToTabFinishedFx(FilterPipe pipe, string namePrefix, PersistenceData persistenceData); - - private delegate void SetBookmarkFx(int lineNum, string comment); - - private delegate void FunctionWith1BoolParam(bool arg); - - private delegate void PatternStatisticFx(PatternArgs patternArgs); - - private delegate void ActionPluginExecuteFx(string keyword, string param, ILogExpertCallback callback, ILogLineColumnizer columnizer); - - private delegate void PositionAfterReloadFx(ReloadMemento reloadMemento); - - private delegate void AutoResizeColumnsFx(BufferedDataGridView gridView); - - private delegate bool BoolReturnDelegate(); - - // =================== ILogLineColumnizerCallback ============================ - -#if DEBUG - internal void DumpBufferInfo() - { - int currentLineNum = dataGridView.CurrentCellAddress.Y; - _logFileReader.LogBufferInfoForLine(currentLineNum); - } - - internal void DumpBufferDiagnostic() - { - _logFileReader.LogBufferDiagnostic(); - } -#endif - } +using LogExpert.Classes.Filter; +using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Classes.Bookmark; +using LogExpert.Core.Classes.Filter; +using LogExpert.Core.Classes.Highlight; +using LogExpert.Core.Classes.Log; +using LogExpert.Core.Classes.Persister; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.EventArguments; +using LogExpert.Core.EventHandlers; +using LogExpert.Core.Interface; +using LogExpert.Dialogs; +using LogExpert.UI.Controls.LogTabWindow; +using LogExpert.UI.Dialogs; +using LogExpert.UI.Extensions.Forms; +using NLog; +using WeifenLuo.WinFormsUI.Docking; +//using static LogExpert.PluginRegistry.PluginRegistry; //TODO: Adjust the instance name so using static can be used. + +namespace LogExpert.UI.Controls.LogWindow +{ + //TODO: Implemented 4 interfaces explicitly. Find them by searcginh: ILogWindow. + internal partial class LogWindow : DockContent, ILogPaintContext, ILogView, ILogWindow + { + #region Fields + + private const int SPREAD_MAX = 99; + private const int PROGRESS_BAR_MODULO = 1000; + private const int FILTER_ADVANCED_SPLITTER_DISTANCE = 150; + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + + private readonly Image _advancedButtonImage; + + private readonly object _bookmarkLock = new(); + private readonly BookmarkDataProvider _bookmarkProvider = new(); + + private readonly IList _cancelHandlerList = new List(); + + private readonly object _currentColumnizerLock = new(); + + private readonly object _currentHighlightGroupLock = new(); + + private readonly EventWaitHandle _externaLoadingFinishedEvent = new ManualResetEvent(false); + + private readonly IList _filterPipeList = new List(); + private readonly Dictionary _freezeStateMap = []; + private readonly GuiStateArgs _guiStateArgs = new(); + + private readonly List _lineHashList = []; + + private readonly EventWaitHandle _loadingFinishedEvent = new ManualResetEvent(false); + + private readonly EventWaitHandle _logEventArgsEvent = new ManualResetEvent(false); + + private readonly List _logEventArgsList = []; + private readonly Task _logEventHandlerTask; + //private readonly Thread _logEventHandlerThread; + private readonly Image _panelCloseButtonImage; + + private readonly Image _panelOpenButtonImage; + private readonly LogTabWindow.LogTabWindow _parentLogTabWin; + + private readonly ProgressEventArgs _progressEventArgs = new(); + private readonly object _reloadLock = new(); + private readonly Image _searchButtonImage; + private readonly StatusLineEventArgs _statusEventArgs = new(); + + private readonly object _tempHighlightEntryListLock = new(); + + private readonly Task _timeShiftSyncTask; + private readonly CancellationTokenSource cts = new(); + + //private readonly Thread _timeShiftSyncThread; + private readonly EventWaitHandle _timeShiftSyncTimerEvent = new ManualResetEvent(false); + private readonly EventWaitHandle _timeShiftSyncWakeupEvent = new ManualResetEvent(false); + + private readonly TimeSpreadCalculator _timeSpreadCalc; + + private readonly object _timeSyncListLock = new(); + + private ColumnCache _columnCache = new(); + + private ILogLineColumnizer _currentColumnizer; + + //List currentHilightEntryList = new List(); + private HighlightGroup _currentHighlightGroup = new(); + + private SearchParams _currentSearchParams; + + private string[] _fileNames; + private List _filterHitList = []; + private FilterParams _filterParams = new(); + private int _filterPipeNameCounter = 0; + private List _filterResultList = []; + + private EventWaitHandle _filterUpdateEvent = new ManualResetEvent(false); + + private ILogLineColumnizer _forcedColumnizer; + private ILogLineColumnizer _forcedColumnizerForLoading; + private bool _isDeadFile; + private bool _isErrorShowing; + private bool _isLoadError; + private bool _isLoading; + private bool _isMultiFile; + private bool _isSearching; + private bool _isTimestampDisplaySyncing; + private List _lastFilterLinesList = []; + + private int _lineHeight = 0; + + internal LogfileReader _logFileReader; + private MultiFileOptions _multiFileOptions = new(); + private bool _noSelectionUpdates; + private PatternArgs _patternArgs = new(); + private PatternWindow _patternWindow; + + private ReloadMemento _reloadMemento; + private int _reloadOverloadCounter = 0; + private SortedList _rowHeightList = []; + private int _selectedCol = 0; // set by context menu event for column headers only + private bool _shouldCallTimeSync; + private bool _shouldCancel; + private bool _shouldTimestampDisplaySyncingCancel; + private bool _showAdvanced; + private List _tempHighlightEntryList = []; + private int _timeShiftSyncLine = 0; + + private bool _waitingForClose; + + #endregion + + #region cTor + + public LogWindow(LogTabWindow.LogTabWindow parent, string fileName, bool isTempFile, bool forcePersistenceLoading, IConfigManager configManager) + { + SuspendLayout(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + InitializeComponent(); //TODO: Move this to be the first line of the constructor? + + CreateDefaultViewStyle(); + + columnNamesLabel.Text = ""; // no filtering on columns by default + + _parentLogTabWin = parent; + IsTempFile = isTempFile; + ConfigManager = configManager; //TODO: This should be changed to DI + //Thread.CurrentThread.Name = "LogWindowThread"; + ColumnizerCallbackObject = new ColumnizerCallback(this); + + FileName = fileName; + ForcePersistenceLoading = forcePersistenceLoading; + + dataGridView.CellValueNeeded += OnDataGridViewCellValueNeeded; + dataGridView.CellPainting += OnDataGridView_CellPainting; + + filterGridView.CellValueNeeded += OnFilterGridViewCellValueNeeded; + filterGridView.CellPainting += OnFilterGridViewCellPainting; + filterListBox.DrawMode = DrawMode.OwnerDrawVariable; + filterListBox.MeasureItem += MeasureItem; + + Closing += OnLogWindowClosing; + Disposed += OnLogWindowDisposed; + Load += OnLogWindowLoad; + + _timeSpreadCalc = new TimeSpreadCalculator(this); + timeSpreadingControl.TimeSpreadCalc = _timeSpreadCalc; + timeSpreadingControl.LineSelected += OnTimeSpreadingControlLineSelected; + tableLayoutPanel1.ColumnStyles[1].SizeType = SizeType.Absolute; + tableLayoutPanel1.ColumnStyles[1].Width = 20; + tableLayoutPanel1.ColumnStyles[0].SizeType = SizeType.Percent; + tableLayoutPanel1.ColumnStyles[0].Width = 100; + + _parentLogTabWin.HighlightSettingsChanged += OnParentHighlightSettingsChanged; + SetColumnizer(PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers[0]); + + _patternArgs.MaxMisses = 5; + _patternArgs.MinWeight = 1; + _patternArgs.MaxDiffInBlock = 5; + _patternArgs.Fuzzy = 5; + + //InitPatternWindow(); + + //this.toolwinTabControl.TabPages.Add(this.patternWindow); + //this.toolwinTabControl.TabPages.Add(this.bookmarkWindow); + + _filterParams = new FilterParams(); + foreach (string item in configManager.Settings.filterHistoryList) + { + filterComboBox.Items.Add(item); + } + + filterComboBox.DropDownHeight = filterComboBox.ItemHeight * configManager.Settings.Preferences.maximumFilterEntriesDisplayed; + AutoResizeFilterBox(); + + filterRegexCheckBox.Checked = _filterParams.IsRegex; + filterCaseSensitiveCheckBox.Checked = _filterParams.IsCaseSensitive; + filterTailCheckBox.Checked = _filterParams.IsFilterTail; + + splitContainerLogWindow.Panel2Collapsed = true; + advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; + + _timeShiftSyncTask = new Task(SyncTimestampDisplayWorker, cts.Token); + _timeShiftSyncTask.Start(); + //_timeShiftSyncThread = new Thread(SyncTimestampDisplayWorker); + //_timeShiftSyncThread.IsBackground = true; + //_timeShiftSyncThread.Start(); + + _logEventHandlerTask = new Task(LogEventWorker, cts.Token); + _logEventHandlerTask.Start(); + //_logEventHandlerThread = new Thread(LogEventWorker); + //_logEventHandlerThread.IsBackground = true; + //_logEventHandlerThread.Start(); + + //this.filterUpdateThread = new Thread(new ThreadStart(this.FilterUpdateWorker)); + //this.filterUpdateThread.Start(); + + _advancedButtonImage = advancedButton.Image; + _searchButtonImage = filterSearchButton.Image; + filterSearchButton.Image = null; + + dataGridView.EditModeMenuStrip = editModeContextMenuStrip; + markEditModeToolStripMenuItem.Enabled = true; + + _panelOpenButtonImage = Resources.Resources.Arrow_menu_open; + _panelCloseButtonImage = Resources.Resources.Arrow_menu_close; + + Settings settings = configManager.Settings; + + if (settings.appBounds.Right > 0) + { + Bounds = settings.appBounds; + } + + _waitingForClose = false; + dataGridView.Enabled = false; + dataGridView.ColumnDividerDoubleClick += OnDataGridViewColumnDividerDoubleClick; + ShowAdvancedFilterPanel(false); + filterKnobBackSpread.MinValue = 0; + filterKnobBackSpread.MaxValue = SPREAD_MAX; + filterKnobBackSpread.ValueChanged += OnFilterKnobControlValueChanged; + filterKnobForeSpread.MinValue = 0; + filterKnobForeSpread.MaxValue = SPREAD_MAX; + filterKnobForeSpread.ValueChanged += OnFilterKnobControlValueChanged; + fuzzyKnobControl.MinValue = 0; + fuzzyKnobControl.MaxValue = 10; + //PreferencesChanged(settings.preferences, true); + AdjustHighlightSplitterWidth(); + ToggleHighlightPanel(false); // hidden + + _bookmarkProvider.BookmarkAdded += OnBookmarkProviderBookmarkAdded; + _bookmarkProvider.BookmarkRemoved += OnBookmarkProviderBookmarkRemoved; + _bookmarkProvider.AllBookmarksRemoved += OnBookmarkProviderAllBookmarksRemoved; + + ResumeLayout(); + + ChangeTheme(Controls); + } + + + + #endregion + + #region ColorTheme + public void ChangeTheme(Control.ControlCollection container) + { + #region ApplyColorToAllControls + foreach (Control component in container) + { + if (component.Controls != null && component.Controls.Count > 0) + { + ChangeTheme(component.Controls); + component.BackColor = ColorMode.BackgroundColor; + component.ForeColor = ColorMode.ForeColor; + } + else + { + component.BackColor = ColorMode.BackgroundColor; + component.ForeColor = ColorMode.ForeColor; + } + + } + #endregion + + #region DataGridView + + // Main DataGridView + dataGridView.BackgroundColor = ColorMode.DockBackgroundColor; + dataGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor; + dataGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor; + dataGridView.EnableHeadersVisualStyles = false; + + // Filter dataGridView + filterGridView.BackgroundColor = ColorMode.DockBackgroundColor; + filterGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor; + filterGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor; + filterGridView.EnableHeadersVisualStyles = false; + + // Colors for menu + dataGridContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); + bookmarkContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); + columnContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); + editModeContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); + filterContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); + filterListContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); + + foreach (ToolStripItem item in dataGridContextMenuStrip.Items) + { + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.MenuBackgroundColor; + } + + foreach (ToolStripItem item in bookmarkContextMenuStrip.Items) + { + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.MenuBackgroundColor; + } + + foreach (ToolStripItem item in columnContextMenuStrip.Items) + { + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.MenuBackgroundColor; + } + + foreach (ToolStripItem item in editModeContextMenuStrip.Items) + { + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.MenuBackgroundColor; + } + + foreach (ToolStripItem item in filterContextMenuStrip.Items) + { + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.MenuBackgroundColor; + } + + foreach (ToolStripItem item in filterListContextMenuStrip.Items) + { + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.MenuBackgroundColor; + } + + // Colors for menu + filterContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); + + for (var y = 0; y < filterContextMenuStrip.Items.Count; y++) + { + var item = filterContextMenuStrip.Items[y]; + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.MenuBackgroundColor; + } + + #endregion DataGridView + + filterComboBox.BackColor = ColorMode.DockBackgroundColor; + } + + #endregion + + #region Delegates + + public delegate void BookmarkAddedEventHandler(object sender, EventArgs e); + + public delegate void BookmarkRemovedEventHandler(object sender, EventArgs e); + + public delegate void BookmarkTextChangedEventHandler(object sender, BookmarkEventArgs e); + + public delegate void ColumnizerChangedEventHandler(object sender, ColumnizerEventArgs e); + + public delegate void CurrentHighlightGroupChangedEventHandler(object sender, CurrentHighlightGroupChangedEventArgs e); + + public delegate void FileNotFoundEventHandler(object sender, EventArgs e); + + public delegate void FileRespawnedEventHandler(object sender, EventArgs e); + + public delegate void FilterListChangedEventHandler(object sender, FilterListChangedEventArgs e); + + // used for filterTab restore + public delegate void FilterRestoreFx(LogWindow newWin, PersistenceData persistenceData); + + public delegate void GuiStateEventHandler(object sender, GuiStateArgs e); + + public delegate void ProgressBarEventHandler(object sender, ProgressEventArgs e); + + public delegate void RestoreFiltersFx(PersistenceData persistenceData); + + public delegate bool ScrollToTimestampFx(DateTime timestamp, bool roundToSeconds, bool triggerSyncCall); + + public delegate void StatusLineEventHandler(object sender, StatusLineEventArgs e); + + public delegate void SyncModeChangedEventHandler(object sender, SyncModeEventArgs e); + + public delegate void TailFollowedEventHandler(object sender, EventArgs e); + + #endregion + + #region Events + + public event FileSizeChangedEventHandler FileSizeChanged; + + public event ProgressBarEventHandler ProgressBarUpdate; + + public event StatusLineEventHandler StatusLineEvent; + + public event GuiStateEventHandler GuiStateUpdate; + + public event TailFollowedEventHandler TailFollowed; + + public event FileNotFoundEventHandler FileNotFound; + + public event FileRespawnedEventHandler FileRespawned; + + public event FilterListChangedEventHandler FilterListChanged; + + public event CurrentHighlightGroupChangedEventHandler CurrentHighlightGroupChanged; + + public event BookmarkAddedEventHandler BookmarkAdded; + + public event BookmarkRemovedEventHandler BookmarkRemoved; + + public event BookmarkTextChangedEventHandler BookmarkTextChanged; + + public event ColumnizerChangedEventHandler ColumnizerChanged; + + public event SyncModeChangedEventHandler SyncModeChanged; + + #endregion + + #region Properties + + public Color BookmarkColor { get; set; } = Color.FromArgb(165, 200, 225); + + public ILogLineColumnizer CurrentColumnizer + { + get => _currentColumnizer; + private set + { + lock (_currentColumnizerLock) + { + _currentColumnizer = value; + _logger.Debug($"Setting columnizer {_currentColumnizer.GetName()} "); + } + } + } + + public bool ShowBookmarkBubbles + { + get => _guiStateArgs.ShowBookmarkBubbles; + set + { + _guiStateArgs.ShowBookmarkBubbles = dataGridView.PaintWithOverlays = value; + dataGridView.Refresh(); + } + } + + public string FileName { get; private set; } + + public string SessionFileName { get; set; } = null; + + public bool IsMultiFile + { + get => _isMultiFile; + private set => _guiStateArgs.IsMultiFileActive = _isMultiFile = value; + } + + public bool IsTempFile { get; } + + private readonly IConfigManager ConfigManager; + + public string TempTitleName { get; set; } = ""; + + internal FilterPipe FilterPipe { get; set; } = null; + + public string Title + { + get + { + if (IsTempFile) + { + return TempTitleName; + } + + return FileName; + } + } + + public ColumnizerCallback ColumnizerCallbackObject { get; } + + public bool ForcePersistenceLoading { get; set; } + + public string ForcedPersistenceFileName { get; set; } = null; + + public Preferences Preferences => ConfigManager.Settings.Preferences; + + public string GivenFileName { get; set; } = null; + + public TimeSyncList TimeSyncList { get; private set; } + + public bool IsTimeSynced => TimeSyncList != null; + + protected EncodingOptions EncodingOptions { get; set; } + + public IBookmarkData BookmarkData => _bookmarkProvider; + + public Font MonospacedFont { get; private set; } + + public Font NormalFont { get; private set; } + + public Font BoldFont { get; private set; } + + LogfileReader ILogWindow._logFileReader => _logFileReader; + + event FileSizeChangedEventHandler ILogWindow.FileSizeChanged + { + add + { + this.FileSizeChanged += new FileSizeChangedEventHandler(value); + } + + remove + { + this.FileSizeChanged -= new FileSizeChangedEventHandler(value); + } + } + + event EventHandler ILogWindow.TailFollowed + { + add + { + this.TailFollowed += new TailFollowedEventHandler(value); + } + + remove + { + this.TailFollowed -= new TailFollowedEventHandler(value); + } + } + + #endregion + + #region Public methods + + public ILogLine GetLogLine(int lineNum) + { + return _logFileReader.GetLogLine(lineNum); + } + + public Bookmark GetBookmarkForLine(int lineNum) + { + return _bookmarkProvider.GetBookmarkForLine(lineNum); + } + + #endregion + + #region Internals + + internal IColumnizedLogLine GetColumnsForLine(int lineNumber) + { + return _columnCache.GetColumnsForLine(_logFileReader, lineNumber, CurrentColumnizer, ColumnizerCallbackObject); + + //string line = this.logFileReader.GetLogLine(lineNumber); + //if (line != null) + //{ + // string[] cols; + // this.columnizerCallback.LineNum = lineNumber; + // cols = this.CurrentColumnizer.SplitLine(this.columnizerCallback, line); + // return cols; + //} + //else + //{ + // return null; + //} + } + + internal void RefreshAllGrids() + { + dataGridView.Refresh(); + filterGridView.Refresh(); + } + + internal void ChangeMultifileMask() + { + MultiFileMaskDialog dlg = new(this, FileName) + { + Owner = this, + MaxDays = _multiFileOptions.MaxDayTry, + FileNamePattern = _multiFileOptions.FormatPattern + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + _multiFileOptions.FormatPattern = dlg.FileNamePattern; + _multiFileOptions.MaxDayTry = dlg.MaxDays; + if (IsMultiFile) + { + Reload(); + } + } + } + + internal void ToggleColumnFinder(bool show, bool setFocus) + { + _guiStateArgs.ColumnFinderVisible = show; + if (show) + { + columnComboBox.AutoCompleteMode = AutoCompleteMode.Suggest; + columnComboBox.AutoCompleteSource = AutoCompleteSource.CustomSource; + columnComboBox.AutoCompleteCustomSource = [.. CurrentColumnizer.GetColumnNames()]; + if (setFocus) + { + columnComboBox.Focus(); + } + } + else + { + dataGridView.Focus(); + } + + tableLayoutPanel1.RowStyles[0].Height = show ? 28 : 0; + } + + #endregion + + #region Overrides + + protected override string GetPersistString() + { + return "LogWindow#" + FileName; + } + + #endregion + + private void OnButtonSizeChanged(object sender, EventArgs e) + { + if (sender is Button button && button.Image != null) + { + button.ImageAlign = ContentAlignment.MiddleCenter; + button.Image = new Bitmap(button.Image, new Size(button.Size.Height, button.Size.Height)); + } + } + + // used for external wait fx WaitForLoadFinished() + + private delegate void SelectLineFx(int line, bool triggerSyncCall); + + private Action, List, List> FilterFxAction; + //private delegate void FilterFx(FilterParams filterParams, List filterResultLines, List lastFilterResultLines, List filterHitList); + + private delegate void UpdateProgressBarFx(int lineNum); + + private delegate void SetColumnizerFx(ILogLineColumnizer columnizer); + + private delegate void WriteFilterToTabFinishedFx(FilterPipe pipe, string namePrefix, PersistenceData persistenceData); + + private delegate void SetBookmarkFx(int lineNum, string comment); + + private delegate void FunctionWith1BoolParam(bool arg); + + private delegate void PatternStatisticFx(PatternArgs patternArgs); + + private delegate void ActionPluginExecuteFx(string keyword, string param, ILogExpertCallback callback, ILogLineColumnizer columnizer); + + private delegate void PositionAfterReloadFx(ReloadMemento reloadMemento); + + private delegate void AutoResizeColumnsFx(BufferedDataGridView gridView); + + private delegate bool BoolReturnDelegate(); + + // =================== ILogLineColumnizerCallback ============================ + +#if DEBUG + internal void DumpBufferInfo() + { + int currentLineNum = dataGridView.CurrentCellAddress.Y; + _logFileReader.LogBufferInfoForLine(currentLineNum); + } + + internal void DumpBufferDiagnostic() + { + _logFileReader.LogBufferDiagnostic(); + } + + void ILogWindow.SelectLine(int lineNum, bool v1, bool v2) + { + SelectLine(lineNum, v1, v2); + } + + void ILogWindow.AddTempFileTab(string fileName, string title) + { + AddTempFileTab(fileName, title); + } + + void ILogWindow.WritePipeTab(IList lineEntryList, string title) + { + WritePipeTab(lineEntryList, title); + } +#endif + } } \ No newline at end of file diff --git a/src/LogExpert/Controls/LogWindow/LogWindow.designer.cs b/src/Logexpert.UI/Controls/LogWindow/LogWindow.designer.cs similarity index 98% rename from src/LogExpert/Controls/LogWindow/LogWindow.designer.cs rename to src/Logexpert.UI/Controls/LogWindow/LogWindow.designer.cs index 64ca94ef..82822995 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindow.designer.cs +++ b/src/Logexpert.UI/Controls/LogWindow/LogWindow.designer.cs @@ -1,1306 +1,1305 @@ -using LogExpert.Dialogs; -using LogExpert.UI.Extensions.Forms; - -using System; -using System.Drawing; -using System.IO; -using System.Windows.Forms; - -namespace LogExpert.Controls.LogWindow -{ - partial class LogWindow - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LogWindow)); - splitContainerLogWindow = new SplitContainer(); - tableLayoutPanel1 = new TableLayoutPanel(); - columnFinderPanel = new Panel(); - columnComboBox = new ComboBox(); - lblColumnName = new Label(); - dataGridView = new BufferedDataGridView(); - dataGridContextMenuStrip = new ContextMenuStrip(components); - copyToolStripMenuItem = new ToolStripMenuItem(); - copyToTabToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparator1 = new MenuToolStripSeparatorExtension(); - scrollAllTabsToTimestampToolStripMenuItem = new ToolStripMenuItem(); - syncTimestampsToToolStripMenuItem = new ToolStripMenuItem(); - freeThisWindowFromTimeSyncToolStripMenuItem = new ToolStripMenuItem(); - locateLineInOriginalFileToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparator2 = new MenuToolStripSeparatorExtension(); - toggleBoomarkToolStripMenuItem = new ToolStripMenuItem(); - bookmarkCommentToolStripMenuItem = new ToolStripMenuItem(); - markEditModeToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparator3 = new MenuToolStripSeparatorExtension(); - tempHighlightsToolStripMenuItem = new ToolStripMenuItem(); - removeAllToolStripMenuItem = new ToolStripMenuItem(); - makePermanentToolStripMenuItem = new ToolStripMenuItem(); - markCurrentFilterRangeToolStripMenuItem = new ToolStripMenuItem(); - pluginSeparator = new MenuToolStripSeparatorExtension(); - timeSpreadingControl = new TimeSpreadingControl(); - advancedBackPanel = new Panel(); - advancedFilterSplitContainer = new SplitContainer(); - pnlProFilter = new Panel(); - columnButton = new Button(); - columnRestrictCheckBox = new CheckBox(); - rangeCheckBox = new CheckBox(); - filterRangeComboBox = new ComboBox(); - columnNamesLabel = new Label(); - fuzzyLabel = new Label(); - fuzzyKnobControl = new KnobControl(); - invertFilterCheckBox = new CheckBox(); - pnlProFilterLabel = new Panel(); - lblBackSpread = new Label(); - filterKnobBackSpread = new KnobControl(); - lblForeSpread = new Label(); - filterKnobForeSpread = new KnobControl(); - btnFilterToTab = new Button(); - panelBackgroundAdvancedFilterSplitContainer = new Panel(); - btnToggleHighlightPanel = new Button(); - highlightSplitContainer = new SplitContainer(); - filterGridView = new BufferedDataGridView(); - filterContextMenuStrip = new ContextMenuStrip(components); - setBookmarksOnSelectedLinesToolStripMenuItem = new ToolStripMenuItem(); - filterToTabToolStripMenuItem = new ToolStripMenuItem(); - markFilterHitsInLogViewToolStripMenuItem = new ToolStripMenuItem(); - highlightSplitContainerBackPanel = new Panel(); - hideFilterListOnLoadCheckBox = new CheckBox(); - filterDownButton = new Button(); - filterUpButton = new Button(); - filterOnLoadCheckBox = new CheckBox(); - saveFilterButton = new Button(); - deleteFilterButton = new Button(); - filterListBox = new ListBox(); - filterListContextMenuStrip = new ContextMenuStrip(components); - colorToolStripMenuItem = new ToolStripMenuItem(); - pnlFilterInput = new Panel(); - filterSplitContainer = new SplitContainer(); - filterComboBox = new ComboBox(); - lblTextFilter = new Label(); - advancedButton = new Button(); - syncFilterCheckBox = new CheckBox(); - lblFilterCount = new Label(); - filterTailCheckBox = new CheckBox(); - filterRegexCheckBox = new CheckBox(); - filterCaseSensitiveCheckBox = new CheckBox(); - filterSearchButton = new Button(); - bookmarkContextMenuStrip = new ContextMenuStrip(components); - deleteBookmarksToolStripMenuItem = new ToolStripMenuItem(); - columnContextMenuStrip = new ContextMenuStrip(components); - freezeLeftColumnsUntilHereToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparator4 = new MenuToolStripSeparatorExtension(); - moveToLastColumnToolStripMenuItem = new ToolStripMenuItem(); - moveLeftToolStripMenuItem = new ToolStripMenuItem(); - moveRightToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparator5 = new MenuToolStripSeparatorExtension(); - hideColumnToolStripMenuItem = new ToolStripMenuItem(); - restoreColumnsToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparator6 = new MenuToolStripSeparatorExtension(); - allColumnsToolStripMenuItem = new ToolStripMenuItem(); - editModeContextMenuStrip = new ContextMenuStrip(components); - editModecopyToolStripMenuItem = new ToolStripMenuItem(); - highlightSelectionInLogFileToolStripMenuItem = new ToolStripMenuItem(); - highlightSelectionInLogFilewordModeToolStripMenuItem = new ToolStripMenuItem(); - filterForSelectionToolStripMenuItem = new ToolStripMenuItem(); - setSelectedTextAsBookmarkCommentToolStripMenuItem = new ToolStripMenuItem(); - helpToolTip = new ToolTip(components); - ((System.ComponentModel.ISupportInitialize)splitContainerLogWindow).BeginInit(); - splitContainerLogWindow.Panel1.SuspendLayout(); - splitContainerLogWindow.Panel2.SuspendLayout(); - splitContainerLogWindow.SuspendLayout(); - tableLayoutPanel1.SuspendLayout(); - columnFinderPanel.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - dataGridContextMenuStrip.SuspendLayout(); - advancedBackPanel.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)advancedFilterSplitContainer).BeginInit(); - advancedFilterSplitContainer.Panel1.SuspendLayout(); - advancedFilterSplitContainer.Panel2.SuspendLayout(); - advancedFilterSplitContainer.SuspendLayout(); - pnlProFilter.SuspendLayout(); - panelBackgroundAdvancedFilterSplitContainer.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)highlightSplitContainer).BeginInit(); - highlightSplitContainer.Panel1.SuspendLayout(); - highlightSplitContainer.Panel2.SuspendLayout(); - highlightSplitContainer.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)filterGridView).BeginInit(); - filterContextMenuStrip.SuspendLayout(); - highlightSplitContainerBackPanel.SuspendLayout(); - filterListContextMenuStrip.SuspendLayout(); - pnlFilterInput.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)filterSplitContainer).BeginInit(); - filterSplitContainer.Panel1.SuspendLayout(); - filterSplitContainer.Panel2.SuspendLayout(); - filterSplitContainer.SuspendLayout(); - bookmarkContextMenuStrip.SuspendLayout(); - columnContextMenuStrip.SuspendLayout(); - editModeContextMenuStrip.SuspendLayout(); - SuspendLayout(); - // - // splitContainerLogWindow - // - splitContainerLogWindow.BorderStyle = BorderStyle.FixedSingle; - splitContainerLogWindow.Dock = DockStyle.Fill; - splitContainerLogWindow.Location = new Point(0, 0); - splitContainerLogWindow.Margin = new Padding(0); - splitContainerLogWindow.Name = "splitContainerLogWindow"; - splitContainerLogWindow.Orientation = Orientation.Horizontal; - // - // splitContainerLogWindow.Panel1 - // - splitContainerLogWindow.Panel1.Controls.Add(tableLayoutPanel1); - splitContainerLogWindow.Panel1MinSize = 50; - // - // splitContainerLogWindow.Panel2 - // - splitContainerLogWindow.Panel2.Controls.Add(advancedBackPanel); - splitContainerLogWindow.Panel2.Controls.Add(pnlFilterInput); - splitContainerLogWindow.Panel2MinSize = 50; - splitContainerLogWindow.Size = new Size(1862, 1104); - splitContainerLogWindow.SplitterDistance = 486; - splitContainerLogWindow.TabIndex = 9; - splitContainerLogWindow.SplitterMoved += OnSplitContainerSplitterMoved; - // - // tableLayoutPanel1 - // - tableLayoutPanel1.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single; - tableLayoutPanel1.ColumnCount = 2; - tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle()); - tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 181F)); - tableLayoutPanel1.Controls.Add(columnFinderPanel, 0, 0); - tableLayoutPanel1.Controls.Add(dataGridView, 0, 1); - tableLayoutPanel1.Controls.Add(timeSpreadingControl, 1, 1); - tableLayoutPanel1.Dock = DockStyle.Fill; - tableLayoutPanel1.ForeColor = SystemColors.ControlText; - tableLayoutPanel1.Location = new Point(0, 0); - tableLayoutPanel1.Margin = new Padding(0); - tableLayoutPanel1.Name = "tableLayoutPanel1"; - tableLayoutPanel1.RowCount = 2; - tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 28F)); - tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); - tableLayoutPanel1.Size = new Size(1860, 484); - tableLayoutPanel1.TabIndex = 2; - // - // columnFinderPanel - // - columnFinderPanel.Controls.Add(columnComboBox); - columnFinderPanel.Controls.Add(lblColumnName); - columnFinderPanel.Dock = DockStyle.Fill; - columnFinderPanel.Location = new Point(4, 4); - columnFinderPanel.Name = "columnFinderPanel"; - columnFinderPanel.Size = new Size(841, 22); - columnFinderPanel.TabIndex = 2; - // - // columnComboBox - // - columnComboBox.FormattingEnabled = true; - columnComboBox.Location = new Point(125, 1); - columnComboBox.MaxDropDownItems = 15; - columnComboBox.Name = "columnComboBox"; - columnComboBox.Size = new Size(181, 21); - columnComboBox.TabIndex = 1; - helpToolTip.SetToolTip(columnComboBox, "Select column to scroll to"); - columnComboBox.SelectionChangeCommitted += OnColumnComboBoxSelectionChangeCommitted; - columnComboBox.KeyDown += OnColumnComboBoxKeyDown; - columnComboBox.PreviewKeyDown += OnColumnComboBoxPreviewKeyDown; - // - // lblColumnName - // - lblColumnName.AutoSize = true; - lblColumnName.Location = new Point(8, 4); - lblColumnName.Name = "lblColumnName"; - lblColumnName.Size = new Size(74, 13); - lblColumnName.TabIndex = 0; - lblColumnName.Text = "Column name:"; - // - // dataGridView - // - dataGridView.AllowUserToAddRows = false; - dataGridView.AllowUserToDeleteRows = false; - dataGridView.AllowUserToOrderColumns = true; - dataGridView.AllowUserToResizeRows = false; - dataGridView.BackgroundColor = SystemColors.Window; - dataGridView.BorderStyle = BorderStyle.None; - dataGridView.CellBorderStyle = DataGridViewCellBorderStyle.None; - dataGridView.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.ContextMenuStrip = dataGridContextMenuStrip; - dataGridView.Dock = DockStyle.Fill; - dataGridView.EditMode = DataGridViewEditMode.EditProgrammatically; - dataGridView.EditModeMenuStrip = null; - dataGridView.ImeMode = ImeMode.Disable; - dataGridView.Location = new Point(1, 30); - dataGridView.Margin = new Padding(0); - dataGridView.Name = "dataGridView"; - dataGridView.PaintWithOverlays = false; - dataGridView.RowHeadersVisible = false; - dataGridView.RowHeadersWidth = 62; - dataGridView.RowTemplate.DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomLeft; - dataGridView.RowTemplate.DefaultCellStyle.Padding = new Padding(2, 0, 0, 0); - dataGridView.RowTemplate.Height = 15; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.ShowCellErrors = false; - dataGridView.ShowCellToolTips = false; - dataGridView.ShowEditingIcon = false; - dataGridView.ShowRowErrors = false; - dataGridView.Size = new Size(847, 453); - dataGridView.TabIndex = 0; - dataGridView.VirtualMode = true; - dataGridView.OverlayDoubleClicked += OnDataGridViewOverlayDoubleClicked; - dataGridView.CellClick += OnDataGridViewCellClick; - dataGridView.CellContentDoubleClick += OnDataGridViewCellContentDoubleClick; - dataGridView.CellContextMenuStripNeeded += OnDataGridViewCellContextMenuStripNeeded; - dataGridView.CellDoubleClick += OnDataGridViewCellDoubleClick; - dataGridView.CellValuePushed += OnDataGridViewCellValuePushed; - dataGridView.RowHeightInfoNeeded += OnDataGridViewRowHeightInfoNeeded; - dataGridView.RowUnshared += OnDataGridViewRowUnshared; - dataGridView.Scroll += OnDataGridViewScroll; - dataGridView.SelectionChanged += OnDataGridViewSelectionChanged; - dataGridView.Paint += OnDataGridViewPaint; - dataGridView.Enter += OnDataGridViewEnter; - dataGridView.KeyDown += OnDataGridViewKeyDown; - dataGridView.Leave += OnDataGridViewLeave; - dataGridView.PreviewKeyDown += OnDataGridViewPreviewKeyDown; - dataGridView.Resize += OnDataGridViewResize; - // - // dataGridContextMenuStrip - // - dataGridContextMenuStrip.ImageScalingSize = new Size(24, 24); - dataGridContextMenuStrip.Items.AddRange(new ToolStripItem[] { copyToolStripMenuItem, copyToTabToolStripMenuItem, menuToolStripSeparator1, scrollAllTabsToTimestampToolStripMenuItem, syncTimestampsToToolStripMenuItem, freeThisWindowFromTimeSyncToolStripMenuItem, locateLineInOriginalFileToolStripMenuItem, menuToolStripSeparator2, toggleBoomarkToolStripMenuItem, bookmarkCommentToolStripMenuItem, markEditModeToolStripMenuItem, menuToolStripSeparator3, tempHighlightsToolStripMenuItem, markCurrentFilterRangeToolStripMenuItem, pluginSeparator }); - dataGridContextMenuStrip.Name = "dataGridContextMenuStrip"; - dataGridContextMenuStrip.Size = new Size(287, 270); - dataGridContextMenuStrip.Opening += OnDataGridContextMenuStripOpening; - // - // copyToolStripMenuItem - // - copyToolStripMenuItem.Name = "copyToolStripMenuItem"; - copyToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C; - copyToolStripMenuItem.Size = new Size(286, 22); - copyToolStripMenuItem.Text = "Copy to clipboard"; - copyToolStripMenuItem.Click += OnCopyToolStripMenuItemClick; - // - // copyToTabToolStripMenuItem - // - copyToTabToolStripMenuItem.Name = "copyToTabToolStripMenuItem"; - copyToTabToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T; - copyToTabToolStripMenuItem.Size = new Size(286, 22); - copyToTabToolStripMenuItem.Text = "Copy to new tab"; - copyToTabToolStripMenuItem.ToolTipText = "Copy marked lines into a new tab window"; - copyToTabToolStripMenuItem.Click += OnCopyToTabToolStripMenuItemClick; - // - // menuToolStripSeparator1 - // - menuToolStripSeparator1.Name = "menuToolStripSeparator1"; - menuToolStripSeparator1.Size = new Size(283, 6); - // - // scrollAllTabsToTimestampToolStripMenuItem - // - scrollAllTabsToTimestampToolStripMenuItem.Name = "scrollAllTabsToTimestampToolStripMenuItem"; - scrollAllTabsToTimestampToolStripMenuItem.Size = new Size(286, 22); - scrollAllTabsToTimestampToolStripMenuItem.Text = "Scroll all tabs to current timestamp"; - scrollAllTabsToTimestampToolStripMenuItem.ToolTipText = "Scolls all open tabs to the selected timestamp, if possible"; - scrollAllTabsToTimestampToolStripMenuItem.Click += OnScrollAllTabsToTimestampToolStripMenuItemClick; - // - // syncTimestampsToToolStripMenuItem - // - syncTimestampsToToolStripMenuItem.Name = "syncTimestampsToToolStripMenuItem"; - syncTimestampsToToolStripMenuItem.Size = new Size(286, 22); - syncTimestampsToToolStripMenuItem.Text = "Time synced files"; - // - // freeThisWindowFromTimeSyncToolStripMenuItem - // - freeThisWindowFromTimeSyncToolStripMenuItem.Name = "freeThisWindowFromTimeSyncToolStripMenuItem"; - freeThisWindowFromTimeSyncToolStripMenuItem.Size = new Size(286, 22); - freeThisWindowFromTimeSyncToolStripMenuItem.Text = "Free this window from time sync"; - freeThisWindowFromTimeSyncToolStripMenuItem.Click += OnFreeThisWindowFromTimeSyncToolStripMenuItemClick; - // - // locateLineInOriginalFileToolStripMenuItem - // - locateLineInOriginalFileToolStripMenuItem.Name = "locateLineInOriginalFileToolStripMenuItem"; - locateLineInOriginalFileToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L; - locateLineInOriginalFileToolStripMenuItem.Size = new Size(286, 22); - locateLineInOriginalFileToolStripMenuItem.Text = "Locate filtered line in original file"; - locateLineInOriginalFileToolStripMenuItem.Click += OnLocateLineInOriginalFileToolStripMenuItemClick; - // - // menuToolStripSeparator2 - // - menuToolStripSeparator2.Name = "menuToolStripSeparator2"; - menuToolStripSeparator2.Size = new Size(283, 6); - // - // toggleBoomarkToolStripMenuItem - // - toggleBoomarkToolStripMenuItem.Name = "toggleBoomarkToolStripMenuItem"; - toggleBoomarkToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.F2; - toggleBoomarkToolStripMenuItem.Size = new Size(286, 22); - toggleBoomarkToolStripMenuItem.Text = "Toggle Boomark"; - toggleBoomarkToolStripMenuItem.Click += OnToggleBoomarkToolStripMenuItemClick; - // - // bookmarkCommentToolStripMenuItem - // - bookmarkCommentToolStripMenuItem.Name = "bookmarkCommentToolStripMenuItem"; - bookmarkCommentToolStripMenuItem.ShortcutKeys = Keys.Alt | Keys.F2; - bookmarkCommentToolStripMenuItem.Size = new Size(286, 22); - bookmarkCommentToolStripMenuItem.Text = "Bookmark comment..."; - bookmarkCommentToolStripMenuItem.ToolTipText = "Edit the comment for a bookmark"; - bookmarkCommentToolStripMenuItem.Click += OnBookmarkCommentToolStripMenuItemClick; - // - // markEditModeToolStripMenuItem - // - markEditModeToolStripMenuItem.Name = "markEditModeToolStripMenuItem"; - markEditModeToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E; - markEditModeToolStripMenuItem.Size = new Size(286, 22); - markEditModeToolStripMenuItem.Text = "Mark/Edit-Mode"; - markEditModeToolStripMenuItem.Click += OnMarkEditModeToolStripMenuItemClick; - // - // menuToolStripSeparator3 - // - menuToolStripSeparator3.Name = "menuToolStripSeparator3"; - menuToolStripSeparator3.Size = new Size(283, 6); - // - // tempHighlightsToolStripMenuItem - // - tempHighlightsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { removeAllToolStripMenuItem, makePermanentToolStripMenuItem }); - tempHighlightsToolStripMenuItem.Name = "tempHighlightsToolStripMenuItem"; - tempHighlightsToolStripMenuItem.Size = new Size(286, 22); - tempHighlightsToolStripMenuItem.Text = "Temp Highlights"; - // - // removeAllToolStripMenuItem - // - removeAllToolStripMenuItem.Name = "removeAllToolStripMenuItem"; - removeAllToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.Shift | Keys.H; - removeAllToolStripMenuItem.Size = new Size(207, 22); - removeAllToolStripMenuItem.Text = "Remove all"; - removeAllToolStripMenuItem.Click += OnRemoveAllToolStripMenuItemClick; - // - // makePermanentToolStripMenuItem - // - makePermanentToolStripMenuItem.Name = "makePermanentToolStripMenuItem"; - makePermanentToolStripMenuItem.Size = new Size(207, 22); - makePermanentToolStripMenuItem.Text = "Make all permanent"; - makePermanentToolStripMenuItem.Click += OnMakePermanentToolStripMenuItemClick; - // - // markCurrentFilterRangeToolStripMenuItem - // - markCurrentFilterRangeToolStripMenuItem.Name = "markCurrentFilterRangeToolStripMenuItem"; - markCurrentFilterRangeToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.R; - markCurrentFilterRangeToolStripMenuItem.Size = new Size(286, 22); - markCurrentFilterRangeToolStripMenuItem.Text = "Mark current filter range"; - markCurrentFilterRangeToolStripMenuItem.Click += OnMarkCurrentFilterRangeToolStripMenuItemClick; - // - // pluginSeparator - // - pluginSeparator.Name = "pluginSeparator"; - pluginSeparator.Size = new Size(283, 6); - // - // timeSpreadingControl - // - timeSpreadingControl.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right; - timeSpreadingControl.Font = new Font("Verdana", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - timeSpreadingControl.ForeColor = Color.Teal; - timeSpreadingControl.Location = new Point(1842, 30); - timeSpreadingControl.Margin = new Padding(2, 0, 1, 0); - timeSpreadingControl.Name = "timeSpreadingControl"; - timeSpreadingControl.ReverseAlpha = false; - timeSpreadingControl.Size = new Size(16, 453); - timeSpreadingControl.TabIndex = 1; - // - // advancedBackPanel - // - advancedBackPanel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; - advancedBackPanel.Controls.Add(advancedFilterSplitContainer); - advancedBackPanel.Location = new Point(3, 48); - advancedBackPanel.Name = "advancedBackPanel"; - advancedBackPanel.Size = new Size(1855, 561); - advancedBackPanel.TabIndex = 3; - // - // advancedFilterSplitContainer - // - advancedFilterSplitContainer.Dock = DockStyle.Fill; - advancedFilterSplitContainer.IsSplitterFixed = true; - advancedFilterSplitContainer.Location = new Point(0, 0); - advancedFilterSplitContainer.Margin = new Padding(0); - advancedFilterSplitContainer.Name = "advancedFilterSplitContainer"; - advancedFilterSplitContainer.Orientation = Orientation.Horizontal; - // - // advancedFilterSplitContainer.Panel1 - // - advancedFilterSplitContainer.Panel1.Controls.Add(pnlProFilter); - advancedFilterSplitContainer.Panel1MinSize = 100; - // - // advancedFilterSplitContainer.Panel2 - // - advancedFilterSplitContainer.Panel2.Controls.Add(panelBackgroundAdvancedFilterSplitContainer); - advancedFilterSplitContainer.Panel2MinSize = 200; - advancedFilterSplitContainer.Size = new Size(1855, 561); - advancedFilterSplitContainer.SplitterDistance = 124; - advancedFilterSplitContainer.SplitterWidth = 2; - advancedFilterSplitContainer.TabIndex = 2; - // - // pnlProFilter - // - pnlProFilter.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - pnlProFilter.Controls.Add(columnButton); - pnlProFilter.Controls.Add(columnRestrictCheckBox); - pnlProFilter.Controls.Add(rangeCheckBox); - pnlProFilter.Controls.Add(filterRangeComboBox); - pnlProFilter.Controls.Add(columnNamesLabel); - pnlProFilter.Controls.Add(fuzzyLabel); - pnlProFilter.Controls.Add(fuzzyKnobControl); - pnlProFilter.Controls.Add(invertFilterCheckBox); - pnlProFilter.Controls.Add(pnlProFilterLabel); - pnlProFilter.Controls.Add(lblBackSpread); - pnlProFilter.Controls.Add(filterKnobBackSpread); - pnlProFilter.Controls.Add(lblForeSpread); - pnlProFilter.Controls.Add(filterKnobForeSpread); - pnlProFilter.Controls.Add(btnFilterToTab); - pnlProFilter.Location = new Point(0, 3); - pnlProFilter.Name = "pnlProFilter"; - pnlProFilter.Size = new Size(1852, 117); - pnlProFilter.TabIndex = 0; - // - // columnButton - // - columnButton.Enabled = false; - columnButton.Location = new Point(750, 41); - columnButton.Name = "columnButton"; - columnButton.Size = new Size(85, 35); - columnButton.TabIndex = 15; - columnButton.Text = "Columns..."; - helpToolTip.SetToolTip(columnButton, "Choose columns for 'Column restrict'"); - columnButton.UseVisualStyleBackColor = true; - columnButton.Click += OnColumnButtonClick; - // - // columnRestrictCheckBox - // - columnRestrictCheckBox.AutoSize = true; - columnRestrictCheckBox.Location = new Point(594, 38); - columnRestrictCheckBox.Name = "columnRestrictCheckBox"; - columnRestrictCheckBox.Size = new Size(95, 17); - columnRestrictCheckBox.TabIndex = 14; - columnRestrictCheckBox.Text = "Column restrict"; - helpToolTip.SetToolTip(columnRestrictCheckBox, "Restrict search to columns"); - columnRestrictCheckBox.UseVisualStyleBackColor = true; - columnRestrictCheckBox.CheckedChanged += OnColumnRestrictCheckBoxCheckedChanged; - // - // rangeCheckBox - // - rangeCheckBox.AutoSize = true; - rangeCheckBox.Location = new Point(73, 38); - rangeCheckBox.Name = "rangeCheckBox"; - rangeCheckBox.Size = new Size(93, 17); - rangeCheckBox.TabIndex = 13; - rangeCheckBox.Text = "Range search"; - helpToolTip.SetToolTip(rangeCheckBox, "Enable a special search mode which filters all content between the 2 given search terms."); - rangeCheckBox.UseVisualStyleBackColor = true; - rangeCheckBox.CheckedChanged += OnRangeCheckBoxCheckedChanged; - // - // filterRangeComboBox - // - filterRangeComboBox.Enabled = false; - filterRangeComboBox.FormattingEnabled = true; - filterRangeComboBox.Location = new Point(73, 11); - filterRangeComboBox.Name = "filterRangeComboBox"; - filterRangeComboBox.Size = new Size(207, 21); - filterRangeComboBox.TabIndex = 12; - helpToolTip.SetToolTip(filterRangeComboBox, "2nd search string ('end string') when using the range search"); - filterRangeComboBox.TextChanged += OnFilterRangeComboBoxTextChanged; - // - // columnNamesLabel - // - columnNamesLabel.AutoSize = true; - columnNamesLabel.Location = new Point(841, 41); - columnNamesLabel.Name = "columnNamesLabel"; - columnNamesLabel.Size = new Size(75, 13); - columnNamesLabel.TabIndex = 11; - columnNamesLabel.Text = "column names"; - // - // fuzzyLabel - // - fuzzyLabel.AutoSize = true; - fuzzyLabel.Location = new Point(502, 38); - fuzzyLabel.Name = "fuzzyLabel"; - fuzzyLabel.Size = new Size(56, 13); - fuzzyLabel.TabIndex = 11; - fuzzyLabel.Text = "Fuzzyness"; - // - // fuzzyKnobControl - // - fuzzyKnobControl.DragSensitivity = 6; - fuzzyKnobControl.Font = new Font("Verdana", 6F, FontStyle.Regular, GraphicsUnit.Point, 0); - fuzzyKnobControl.Location = new Point(521, 7); - fuzzyKnobControl.Margin = new Padding(2); - fuzzyKnobControl.MaxValue = 0; - fuzzyKnobControl.MinValue = 0; - fuzzyKnobControl.Name = "fuzzyKnobControl"; - fuzzyKnobControl.Size = new Size(17, 29); - fuzzyKnobControl.TabIndex = 10; - helpToolTip.SetToolTip(fuzzyKnobControl, "Fuzzy search level (0 = fuzzy off)"); - fuzzyKnobControl.Value = 0; - fuzzyKnobControl.ValueChanged += OnFuzzyKnobControlValueChanged; - // - // invertFilterCheckBox - // - invertFilterCheckBox.AutoSize = true; - invertFilterCheckBox.Location = new Point(594, 7); - invertFilterCheckBox.Name = "invertFilterCheckBox"; - invertFilterCheckBox.Size = new Size(86, 17); - invertFilterCheckBox.TabIndex = 8; - invertFilterCheckBox.Text = "Invert Match"; - helpToolTip.SetToolTip(invertFilterCheckBox, "Invert the search result"); - invertFilterCheckBox.UseVisualStyleBackColor = true; - invertFilterCheckBox.CheckedChanged += OnInvertFilterCheckBoxCheckedChanged; - // - // pnlProFilterLabel - // - pnlProFilterLabel.BackgroundImage = LogExpert.Resources.Resources.Pro_Filter; - pnlProFilterLabel.BackgroundImageLayout = ImageLayout.Center; - pnlProFilterLabel.Location = new Point(5, 7); - pnlProFilterLabel.Name = "pnlProFilterLabel"; - pnlProFilterLabel.Size = new Size(60, 44); - pnlProFilterLabel.TabIndex = 7; - // - // lblBackSpread - // - lblBackSpread.AutoSize = true; - lblBackSpread.Location = new Point(287, 38); - lblBackSpread.Name = "lblBackSpread"; - lblBackSpread.Size = new Size(72, 13); - lblBackSpread.TabIndex = 6; - lblBackSpread.Text = "Back Spread "; - // - // filterKnobBackSpread - // - filterKnobBackSpread.DragSensitivity = 3; - filterKnobBackSpread.Font = new Font("Verdana", 6F, FontStyle.Regular, GraphicsUnit.Point, 0); - filterKnobBackSpread.Location = new Point(313, 7); - filterKnobBackSpread.Margin = new Padding(2); - filterKnobBackSpread.MaxValue = 0; - filterKnobBackSpread.MinValue = 0; - filterKnobBackSpread.Name = "filterKnobBackSpread"; - filterKnobBackSpread.Size = new Size(17, 29); - filterKnobBackSpread.TabIndex = 5; - helpToolTip.SetToolTip(filterKnobBackSpread, "Add preceding lines to search result (Drag up/down, press Shift for finer pitch)"); - filterKnobBackSpread.Value = 0; - // - // lblForeSpread - // - lblForeSpread.AutoSize = true; - lblForeSpread.Location = new Point(397, 38); - lblForeSpread.Name = "lblForeSpread"; - lblForeSpread.Size = new Size(65, 13); - lblForeSpread.TabIndex = 2; - lblForeSpread.Text = "Fore Spread"; - // - // filterKnobForeSpread - // - filterKnobForeSpread.DragSensitivity = 3; - filterKnobForeSpread.Font = new Font("Verdana", 6F, FontStyle.Regular, GraphicsUnit.Point, 0); - filterKnobForeSpread.Location = new Point(420, 7); - filterKnobForeSpread.Margin = new Padding(2); - filterKnobForeSpread.MaxValue = 0; - filterKnobForeSpread.MinValue = 0; - filterKnobForeSpread.Name = "filterKnobForeSpread"; - filterKnobForeSpread.Size = new Size(17, 29); - filterKnobForeSpread.TabIndex = 1; - helpToolTip.SetToolTip(filterKnobForeSpread, "Add following lines to search result (Drag up/down, press Shift for finer pitch)"); - filterKnobForeSpread.Value = 0; - // - // btnFilterToTab - // - btnFilterToTab.Location = new Point(750, 3); - btnFilterToTab.Name = "btnFilterToTab"; - btnFilterToTab.Size = new Size(85, 35); - btnFilterToTab.TabIndex = 0; - btnFilterToTab.Text = "Filter to Tab"; - helpToolTip.SetToolTip(btnFilterToTab, "Launch a new tab with filtered content"); - btnFilterToTab.UseVisualStyleBackColor = true; - btnFilterToTab.Click += OnFilterToTabButtonClick; - // - // panelBackgroundAdvancedFilterSplitContainer - // - panelBackgroundAdvancedFilterSplitContainer.Controls.Add(btnToggleHighlightPanel); - panelBackgroundAdvancedFilterSplitContainer.Controls.Add(highlightSplitContainer); - panelBackgroundAdvancedFilterSplitContainer.Dock = DockStyle.Fill; - panelBackgroundAdvancedFilterSplitContainer.Location = new Point(0, 0); - panelBackgroundAdvancedFilterSplitContainer.Name = "panelBackgroundAdvancedFilterSplitContainer"; - panelBackgroundAdvancedFilterSplitContainer.Size = new Size(1855, 435); - panelBackgroundAdvancedFilterSplitContainer.TabIndex = 7; - // - // btnToggleHighlightPanel - // - btnToggleHighlightPanel.Anchor = AnchorStyles.Top | AnchorStyles.Right; - btnToggleHighlightPanel.Image = LogExpert.Resources.Resources.Arrow_menu_open; - btnToggleHighlightPanel.Location = new Point(1832, 1); - btnToggleHighlightPanel.Name = "btnToggleHighlightPanel"; - btnToggleHighlightPanel.Size = new Size(20, 21); - btnToggleHighlightPanel.TabIndex = 6; - helpToolTip.SetToolTip(btnToggleHighlightPanel, "Open or close a list with saved filters"); - btnToggleHighlightPanel.UseVisualStyleBackColor = true; - btnToggleHighlightPanel.SizeChanged += OnButtonSizeChanged; - btnToggleHighlightPanel.Click += OnToggleHighlightPanelButtonClick; - // - // highlightSplitContainer - // - highlightSplitContainer.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; - highlightSplitContainer.BorderStyle = BorderStyle.FixedSingle; - highlightSplitContainer.FixedPanel = FixedPanel.Panel2; - highlightSplitContainer.Location = new Point(0, 3); - highlightSplitContainer.Name = "highlightSplitContainer"; - // - // highlightSplitContainer.Panel1 - // - highlightSplitContainer.Panel1.Controls.Add(filterGridView); - highlightSplitContainer.Panel1MinSize = 100; - // - // highlightSplitContainer.Panel2 - // - highlightSplitContainer.Panel2.Controls.Add(highlightSplitContainerBackPanel); - highlightSplitContainer.Panel2MinSize = 350; - highlightSplitContainer.Size = new Size(1829, 432); - highlightSplitContainer.SplitterDistance = 1475; - highlightSplitContainer.TabIndex = 2; - // - // filterGridView - // - filterGridView.AllowUserToAddRows = false; - filterGridView.AllowUserToDeleteRows = false; - filterGridView.AllowUserToOrderColumns = true; - filterGridView.AllowUserToResizeRows = false; - filterGridView.BackgroundColor = SystemColors.Window; - filterGridView.BorderStyle = BorderStyle.None; - filterGridView.CellBorderStyle = DataGridViewCellBorderStyle.None; - filterGridView.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText; - filterGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - filterGridView.ContextMenuStrip = filterContextMenuStrip; - filterGridView.Dock = DockStyle.Fill; - filterGridView.EditMode = DataGridViewEditMode.EditProgrammatically; - filterGridView.EditModeMenuStrip = null; - filterGridView.ImeMode = ImeMode.Disable; - filterGridView.Location = new Point(0, 0); - filterGridView.Margin = new Padding(0); - filterGridView.Name = "filterGridView"; - filterGridView.PaintWithOverlays = false; - filterGridView.ReadOnly = true; - filterGridView.RowHeadersVisible = false; - filterGridView.RowHeadersWidth = 62; - filterGridView.RowTemplate.Height = 15; - filterGridView.RowTemplate.ReadOnly = true; - filterGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - filterGridView.ShowCellErrors = false; - filterGridView.ShowCellToolTips = false; - filterGridView.ShowEditingIcon = false; - filterGridView.ShowRowErrors = false; - filterGridView.Size = new Size(1473, 430); - filterGridView.TabIndex = 1; - filterGridView.VirtualMode = true; - filterGridView.CellContextMenuStripNeeded += OnFilterGridViewCellContextMenuStripNeeded; - filterGridView.CellDoubleClick += OnFilterGridViewCellDoubleClick; - filterGridView.ColumnDividerDoubleClick += OnFilterGridViewColumnDividerDoubleClick; - filterGridView.RowHeightInfoNeeded += OnFilterGridViewRowHeightInfoNeeded; - filterGridView.Enter += OnFilterGridViewEnter; - filterGridView.KeyDown += OnFilterGridViewKeyDown; - filterGridView.Leave += OnFilterGridViewLeave; - // - // filterContextMenuStrip - // - filterContextMenuStrip.ImageScalingSize = new Size(24, 24); - filterContextMenuStrip.Items.AddRange(new ToolStripItem[] { setBookmarksOnSelectedLinesToolStripMenuItem, filterToTabToolStripMenuItem, markFilterHitsInLogViewToolStripMenuItem }); - filterContextMenuStrip.Name = "filterContextMenuStrip"; - filterContextMenuStrip.Size = new Size(243, 70); - // - // setBookmarksOnSelectedLinesToolStripMenuItem - // - setBookmarksOnSelectedLinesToolStripMenuItem.Name = "setBookmarksOnSelectedLinesToolStripMenuItem"; - setBookmarksOnSelectedLinesToolStripMenuItem.Size = new Size(242, 22); - setBookmarksOnSelectedLinesToolStripMenuItem.Text = "Set bookmarks on selected lines"; - setBookmarksOnSelectedLinesToolStripMenuItem.Click += OnSetBookmarksOnSelectedLinesToolStripMenuItemClick; - // - // filterToTabToolStripMenuItem - // - filterToTabToolStripMenuItem.Name = "filterToTabToolStripMenuItem"; - filterToTabToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.Shift | Keys.T; - filterToTabToolStripMenuItem.Size = new Size(242, 22); - filterToTabToolStripMenuItem.Text = "Filter to new tab"; - filterToTabToolStripMenuItem.Click += OnFilterToTabToolStripMenuItemClick; - // - // markFilterHitsInLogViewToolStripMenuItem - // - markFilterHitsInLogViewToolStripMenuItem.Name = "markFilterHitsInLogViewToolStripMenuItem"; - markFilterHitsInLogViewToolStripMenuItem.Size = new Size(242, 22); - markFilterHitsInLogViewToolStripMenuItem.Text = "Mark filter hits in log view"; - markFilterHitsInLogViewToolStripMenuItem.Click += OnMarkFilterHitsInLogViewToolStripMenuItemClick; - // - // highlightSplitContainerBackPanel - // - highlightSplitContainerBackPanel.Controls.Add(hideFilterListOnLoadCheckBox); - highlightSplitContainerBackPanel.Controls.Add(filterDownButton); - highlightSplitContainerBackPanel.Controls.Add(filterUpButton); - highlightSplitContainerBackPanel.Controls.Add(filterOnLoadCheckBox); - highlightSplitContainerBackPanel.Controls.Add(saveFilterButton); - highlightSplitContainerBackPanel.Controls.Add(deleteFilterButton); - highlightSplitContainerBackPanel.Controls.Add(filterListBox); - highlightSplitContainerBackPanel.Dock = DockStyle.Fill; - highlightSplitContainerBackPanel.Location = new Point(0, 0); - highlightSplitContainerBackPanel.Name = "highlightSplitContainerBackPanel"; - highlightSplitContainerBackPanel.Size = new Size(348, 430); - highlightSplitContainerBackPanel.TabIndex = 1; - // - // hideFilterListOnLoadCheckBox - // - hideFilterListOnLoadCheckBox.AutoSize = true; - hideFilterListOnLoadCheckBox.Location = new Point(258, 147); - hideFilterListOnLoadCheckBox.Name = "hideFilterListOnLoadCheckBox"; - hideFilterListOnLoadCheckBox.Size = new Size(71, 17); - hideFilterListOnLoadCheckBox.TabIndex = 20; - hideFilterListOnLoadCheckBox.Text = "Auto hide"; - helpToolTip.SetToolTip(hideFilterListOnLoadCheckBox, "Hides the filter list after loading a filter"); - hideFilterListOnLoadCheckBox.UseVisualStyleBackColor = true; - hideFilterListOnLoadCheckBox.MouseClick += OnHideFilterListOnLoadCheckBoxMouseClick; - // - // filterDownButton - // - filterDownButton.BackgroundImage = LogExpert.Resources.Resources.ArrowDown; - filterDownButton.BackgroundImageLayout = ImageLayout.Stretch; - filterDownButton.Location = new Point(296, 85); - filterDownButton.Name = "filterDownButton"; - filterDownButton.Size = new Size(35, 35); - filterDownButton.TabIndex = 19; - helpToolTip.SetToolTip(filterDownButton, "Move the selected entry down in the list"); - filterDownButton.UseVisualStyleBackColor = true; - filterDownButton.SizeChanged += OnButtonSizeChanged; - filterDownButton.Click += OnFilterDownButtonClick; - // - // filterUpButton - // - filterUpButton.BackgroundImage = LogExpert.Resources.Resources.ArrowUp; - filterUpButton.BackgroundImageLayout = ImageLayout.Stretch; - filterUpButton.Location = new Point(258, 85); - filterUpButton.Name = "filterUpButton"; - filterUpButton.Size = new Size(35, 35); - filterUpButton.TabIndex = 18; - helpToolTip.SetToolTip(filterUpButton, "Move the selected entry up in the list"); - filterUpButton.UseVisualStyleBackColor = true; - filterUpButton.SizeChanged += OnButtonSizeChanged; - filterUpButton.Click += OnFilterUpButtonClick; - // - // filterOnLoadCheckBox - // - filterOnLoadCheckBox.AutoSize = true; - filterOnLoadCheckBox.Location = new Point(258, 123); - filterOnLoadCheckBox.Name = "filterOnLoadCheckBox"; - filterOnLoadCheckBox.Size = new Size(71, 17); - filterOnLoadCheckBox.TabIndex = 17; - filterOnLoadCheckBox.Text = "Auto start"; - helpToolTip.SetToolTip(filterOnLoadCheckBox, "Start immediate filtering after loading a saved filter"); - filterOnLoadCheckBox.UseVisualStyleBackColor = true; - filterOnLoadCheckBox.KeyPress += OnFilterOnLoadCheckBoxKeyPress; - filterOnLoadCheckBox.MouseClick += OnFilterOnLoadCheckBoxMouseClick; - // - // saveFilterButton - // - saveFilterButton.Location = new Point(258, 11); - saveFilterButton.Name = "saveFilterButton"; - saveFilterButton.Size = new Size(75, 35); - saveFilterButton.TabIndex = 16; - saveFilterButton.Text = "Save filter"; - saveFilterButton.UseVisualStyleBackColor = true; - saveFilterButton.Click += OnSaveFilterButtonClick; - // - // deleteFilterButton - // - deleteFilterButton.Location = new Point(258, 47); - deleteFilterButton.Name = "deleteFilterButton"; - deleteFilterButton.Size = new Size(75, 35); - deleteFilterButton.TabIndex = 3; - deleteFilterButton.Text = "Delete"; - deleteFilterButton.UseVisualStyleBackColor = true; - deleteFilterButton.Click += OnDeleteFilterButtonClick; - // - // filterListBox - // - filterListBox.ContextMenuStrip = filterListContextMenuStrip; - filterListBox.Dock = DockStyle.Left; - filterListBox.DrawMode = DrawMode.OwnerDrawFixed; - filterListBox.Font = new Font("Courier New", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); - filterListBox.FormattingEnabled = true; - filterListBox.IntegralHeight = false; - filterListBox.ItemHeight = 25; - filterListBox.Location = new Point(0, 0); - filterListBox.Name = "filterListBox"; - filterListBox.Size = new Size(252, 430); - filterListBox.TabIndex = 0; - helpToolTip.SetToolTip(filterListBox, "Doubleclick to load a saved filter"); - filterListBox.DrawItem += OnFilterListBoxDrawItem; - filterListBox.MouseDoubleClick += OnFilterListBoxMouseDoubleClick; - // - // filterListContextMenuStrip - // - filterListContextMenuStrip.ImageScalingSize = new Size(24, 24); - filterListContextMenuStrip.Items.AddRange(new ToolStripItem[] { colorToolStripMenuItem }); - filterListContextMenuStrip.Name = "filterListContextMenuStrip"; - filterListContextMenuStrip.Size = new Size(113, 26); - // - // colorToolStripMenuItem - // - colorToolStripMenuItem.Name = "colorToolStripMenuItem"; - colorToolStripMenuItem.Size = new Size(112, 22); - colorToolStripMenuItem.Text = "Color..."; - colorToolStripMenuItem.Click += OnColorToolStripMenuItemClick; - // - // pnlFilterInput - // - pnlFilterInput.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - pnlFilterInput.Controls.Add(filterSplitContainer); - pnlFilterInput.Location = new Point(3, 2); - pnlFilterInput.Name = "pnlFilterInput"; - pnlFilterInput.Size = new Size(1855, 46); - pnlFilterInput.TabIndex = 0; - // - // filterSplitContainer - // - filterSplitContainer.Dock = DockStyle.Fill; - filterSplitContainer.Location = new Point(0, 0); - filterSplitContainer.Name = "filterSplitContainer"; - // - // filterSplitContainer.Panel1 - // - filterSplitContainer.Panel1.Controls.Add(filterComboBox); - filterSplitContainer.Panel1.Controls.Add(lblTextFilter); - filterSplitContainer.Panel1MinSize = 200; - // - // filterSplitContainer.Panel2 - // - filterSplitContainer.Panel2.Controls.Add(advancedButton); - filterSplitContainer.Panel2.Controls.Add(syncFilterCheckBox); - filterSplitContainer.Panel2.Controls.Add(lblFilterCount); - filterSplitContainer.Panel2.Controls.Add(filterTailCheckBox); - filterSplitContainer.Panel2.Controls.Add(filterRegexCheckBox); - filterSplitContainer.Panel2.Controls.Add(filterCaseSensitiveCheckBox); - filterSplitContainer.Panel2.Controls.Add(filterSearchButton); - filterSplitContainer.Panel2MinSize = 550; - filterSplitContainer.Size = new Size(1855, 46); - filterSplitContainer.SplitterDistance = 518; - filterSplitContainer.TabIndex = 11; - filterSplitContainer.MouseDoubleClick += OnFilterSplitContainerMouseDoubleClick; - filterSplitContainer.MouseDown += OnFilterSplitContainerMouseDown; - filterSplitContainer.MouseMove += OnFilterSplitContainerMouseMove; - filterSplitContainer.MouseUp += OnFilterSplitContainerMouseUp; - // - // filterComboBox - // - filterComboBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - filterComboBox.Font = new Font("Courier New", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); - filterComboBox.FormattingEnabled = true; - filterComboBox.Location = new Point(89, 5); - filterComboBox.Name = "filterComboBox"; - filterComboBox.Size = new Size(426, 26); - filterComboBox.TabIndex = 4; - helpToolTip.SetToolTip(filterComboBox, "Search string for the filter"); - filterComboBox.TextChanged += OnFilterComboBoxTextChanged; - filterComboBox.KeyDown += OnFilterComboBoxKeyDown; - // - // lblTextFilter - // - lblTextFilter.AutoSize = true; - lblTextFilter.Location = new Point(5, 5); - lblTextFilter.Name = "lblTextFilter"; - lblTextFilter.Size = new Size(53, 13); - lblTextFilter.TabIndex = 3; - lblTextFilter.Text = "Text &filter:"; - // - // advancedButton - // - advancedButton.DialogResult = DialogResult.Cancel; - advancedButton.Image = (Image)resources.GetObject("advancedButton.Image"); - advancedButton.ImageAlign = ContentAlignment.MiddleRight; - advancedButton.Location = new Point(539, 5); - advancedButton.Name = "advancedButton"; - advancedButton.Size = new Size(110, 35); - advancedButton.TabIndex = 17; - advancedButton.Text = "Show advanced..."; - helpToolTip.SetToolTip(advancedButton, "Toggel the advanced filter options panel"); - advancedButton.UseVisualStyleBackColor = true; - advancedButton.Click += OnAdvancedButtonClick; - // - // syncFilterCheckBox - // - syncFilterCheckBox.AutoSize = true; - syncFilterCheckBox.Location = new Point(467, 5); - syncFilterCheckBox.Name = "syncFilterCheckBox"; - syncFilterCheckBox.Size = new Size(50, 17); - syncFilterCheckBox.TabIndex = 16; - syncFilterCheckBox.Text = "Sync"; - helpToolTip.SetToolTip(syncFilterCheckBox, "Sync the current selected line in the filter view to the selection in the log file view"); - syncFilterCheckBox.UseVisualStyleBackColor = true; - syncFilterCheckBox.CheckedChanged += OnSyncFilterCheckBoxCheckedChanged; - // - // lblFilterCount - // - lblFilterCount.Anchor = AnchorStyles.Right; - lblFilterCount.BorderStyle = BorderStyle.Fixed3D; - lblFilterCount.Location = new Point(1259, 8); - lblFilterCount.Name = "lblFilterCount"; - lblFilterCount.Size = new Size(71, 21); - lblFilterCount.TabIndex = 15; - lblFilterCount.Text = "0"; - lblFilterCount.TextAlign = ContentAlignment.MiddleRight; - // - // filterTailCheckBox - // - filterTailCheckBox.AutoSize = true; - filterTailCheckBox.Location = new Point(367, 5); - filterTailCheckBox.Name = "filterTailCheckBox"; - filterTailCheckBox.Size = new Size(64, 17); - filterTailCheckBox.TabIndex = 14; - filterTailCheckBox.Text = "Filter tail"; - helpToolTip.SetToolTip(filterTailCheckBox, "Filter tailed file content (keeps filter view up to date on file changes)"); - filterTailCheckBox.UseVisualStyleBackColor = true; - // - // filterRegexCheckBox - // - filterRegexCheckBox.AutoSize = true; - filterRegexCheckBox.Location = new Point(283, 5); - filterRegexCheckBox.Name = "filterRegexCheckBox"; - filterRegexCheckBox.Size = new Size(57, 17); - filterRegexCheckBox.TabIndex = 13; - filterRegexCheckBox.Text = "Regex"; - helpToolTip.SetToolTip(filterRegexCheckBox, "Use regular expressions. (right-click for RegEx helper window)"); - filterRegexCheckBox.UseVisualStyleBackColor = true; - filterRegexCheckBox.CheckedChanged += OnFilterRegexCheckBoxCheckedChanged; - filterRegexCheckBox.MouseUp += OnFilterRegexCheckBoxMouseUp; - // - // filterCaseSensitiveCheckBox - // - filterCaseSensitiveCheckBox.AutoSize = true; - filterCaseSensitiveCheckBox.Location = new Point(137, 5); - filterCaseSensitiveCheckBox.Name = "filterCaseSensitiveCheckBox"; - filterCaseSensitiveCheckBox.Size = new Size(94, 17); - filterCaseSensitiveCheckBox.TabIndex = 12; - filterCaseSensitiveCheckBox.Text = "Case sensitive"; - helpToolTip.SetToolTip(filterCaseSensitiveCheckBox, "Makes the filter case sensitive"); - filterCaseSensitiveCheckBox.UseVisualStyleBackColor = true; - filterCaseSensitiveCheckBox.CheckedChanged += OnFilterCaseSensitiveCheckBoxCheckedChanged; - // - // filterSearchButton - // - filterSearchButton.Image = (Image)resources.GetObject("filterSearchButton.Image"); - filterSearchButton.ImageAlign = ContentAlignment.MiddleRight; - filterSearchButton.Location = new Point(3, 5); - filterSearchButton.Name = "filterSearchButton"; - filterSearchButton.Size = new Size(128, 35); - filterSearchButton.TabIndex = 11; - filterSearchButton.Text = "Search"; - helpToolTip.SetToolTip(filterSearchButton, "Start the filter search"); - filterSearchButton.UseVisualStyleBackColor = true; - filterSearchButton.Click += OnFilterSearchButtonClick; - // - // bookmarkContextMenuStrip - // - bookmarkContextMenuStrip.ImageScalingSize = new Size(24, 24); - bookmarkContextMenuStrip.Items.AddRange(new ToolStripItem[] { deleteBookmarksToolStripMenuItem }); - bookmarkContextMenuStrip.Name = "bookmarkContextMenuStrip"; - bookmarkContextMenuStrip.Size = new Size(68, 26); - // - // deleteBookmarksToolStripMenuItem - // - deleteBookmarksToolStripMenuItem.Name = "deleteBookmarksToolStripMenuItem"; - deleteBookmarksToolStripMenuItem.Size = new Size(67, 22); - // - // columnContextMenuStrip - // - columnContextMenuStrip.ImageScalingSize = new Size(24, 24); - columnContextMenuStrip.Items.AddRange(new ToolStripItem[] { freezeLeftColumnsUntilHereToolStripMenuItem, menuToolStripSeparator4, moveToLastColumnToolStripMenuItem, moveLeftToolStripMenuItem, moveRightToolStripMenuItem, menuToolStripSeparator5, hideColumnToolStripMenuItem, restoreColumnsToolStripMenuItem, menuToolStripSeparator6, allColumnsToolStripMenuItem }); - columnContextMenuStrip.Name = "columnContextMenuStrip"; - columnContextMenuStrip.Size = new Size(230, 198); - columnContextMenuStrip.Opening += OnColumnContextMenuStripOpening; - // - // freezeLeftColumnsUntilHereToolStripMenuItem - // - freezeLeftColumnsUntilHereToolStripMenuItem.Name = "freezeLeftColumnsUntilHereToolStripMenuItem"; - freezeLeftColumnsUntilHereToolStripMenuItem.Size = new Size(229, 22); - freezeLeftColumnsUntilHereToolStripMenuItem.Text = "Freeze left columns until here"; - freezeLeftColumnsUntilHereToolStripMenuItem.Click += OnFreezeLeftColumnsUntilHereToolStripMenuItemClick; - // - // menuToolStripSeparator4 - // - menuToolStripSeparator4.Name = "menuToolStripSeparator4"; - menuToolStripSeparator4.Size = new Size(226, 6); - // - // moveToLastColumnToolStripMenuItem - // - moveToLastColumnToolStripMenuItem.Name = "moveToLastColumnToolStripMenuItem"; - moveToLastColumnToolStripMenuItem.Size = new Size(229, 22); - moveToLastColumnToolStripMenuItem.Text = "Move to last column"; - moveToLastColumnToolStripMenuItem.ToolTipText = "Move this column to the last position"; - moveToLastColumnToolStripMenuItem.Click += OnMoveToLastColumnToolStripMenuItemClick; - // - // moveLeftToolStripMenuItem - // - moveLeftToolStripMenuItem.Name = "moveLeftToolStripMenuItem"; - moveLeftToolStripMenuItem.Size = new Size(229, 22); - moveLeftToolStripMenuItem.Text = "Move left"; - moveLeftToolStripMenuItem.Click += OnMoveLeftToolStripMenuItemClick; - // - // moveRightToolStripMenuItem - // - moveRightToolStripMenuItem.Name = "moveRightToolStripMenuItem"; - moveRightToolStripMenuItem.Size = new Size(229, 22); - moveRightToolStripMenuItem.Text = "Move right"; - moveRightToolStripMenuItem.Click += OnMoveRightToolStripMenuItemClick; - // - // menuToolStripSeparator5 - // - menuToolStripSeparator5.Name = "menuToolStripSeparator5"; - menuToolStripSeparator5.Size = new Size(226, 6); - // - // hideColumnToolStripMenuItem - // - hideColumnToolStripMenuItem.Name = "hideColumnToolStripMenuItem"; - hideColumnToolStripMenuItem.Size = new Size(229, 22); - hideColumnToolStripMenuItem.Text = "Hide column"; - hideColumnToolStripMenuItem.ToolTipText = "Hide this column"; - hideColumnToolStripMenuItem.Click += OnHideColumnToolStripMenuItemClick; - // - // restoreColumnsToolStripMenuItem - // - restoreColumnsToolStripMenuItem.Name = "restoreColumnsToolStripMenuItem"; - restoreColumnsToolStripMenuItem.Size = new Size(229, 22); - restoreColumnsToolStripMenuItem.Text = "Restore columns"; - restoreColumnsToolStripMenuItem.Click += OnRestoreColumnsToolStripMenuItemClick; - // - // menuToolStripSeparator6 - // - menuToolStripSeparator6.Name = "menuToolStripSeparator6"; - menuToolStripSeparator6.Size = new Size(226, 6); - // - // allColumnsToolStripMenuItem - // - allColumnsToolStripMenuItem.Name = "allColumnsToolStripMenuItem"; - allColumnsToolStripMenuItem.Size = new Size(229, 22); - allColumnsToolStripMenuItem.Text = "Scroll to column..."; - // - // editModeContextMenuStrip - // - editModeContextMenuStrip.ImageScalingSize = new Size(24, 24); - editModeContextMenuStrip.Items.AddRange(new ToolStripItem[] { editModecopyToolStripMenuItem, highlightSelectionInLogFileToolStripMenuItem, highlightSelectionInLogFilewordModeToolStripMenuItem, filterForSelectionToolStripMenuItem, setSelectedTextAsBookmarkCommentToolStripMenuItem }); - editModeContextMenuStrip.Name = "editModeContextMenuStrip"; - editModeContextMenuStrip.Size = new Size(344, 114); - // - // editModecopyToolStripMenuItem - // - editModecopyToolStripMenuItem.Name = "editModecopyToolStripMenuItem"; - editModecopyToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C; - editModecopyToolStripMenuItem.Size = new Size(343, 22); - editModecopyToolStripMenuItem.Text = "Copy"; - editModecopyToolStripMenuItem.Click += OnEditModeCopyToolStripMenuItemClick; - // - // highlightSelectionInLogFileToolStripMenuItem - // - highlightSelectionInLogFileToolStripMenuItem.Name = "highlightSelectionInLogFileToolStripMenuItem"; - highlightSelectionInLogFileToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.H; - highlightSelectionInLogFileToolStripMenuItem.Size = new Size(343, 22); - highlightSelectionInLogFileToolStripMenuItem.Text = "Highlight selection in log file (full line)"; - highlightSelectionInLogFileToolStripMenuItem.Click += OnHighlightSelectionInLogFileToolStripMenuItemClick; - // - // highlightSelectionInLogFilewordModeToolStripMenuItem - // - highlightSelectionInLogFilewordModeToolStripMenuItem.Name = "highlightSelectionInLogFilewordModeToolStripMenuItem"; - highlightSelectionInLogFilewordModeToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W; - highlightSelectionInLogFilewordModeToolStripMenuItem.Size = new Size(343, 22); - highlightSelectionInLogFilewordModeToolStripMenuItem.Text = "Highlight selection in log file (word mode)"; - highlightSelectionInLogFilewordModeToolStripMenuItem.Click += OnHighlightSelectionInLogFilewordModeToolStripMenuItemClick; - // - // filterForSelectionToolStripMenuItem - // - filterForSelectionToolStripMenuItem.Name = "filterForSelectionToolStripMenuItem"; - filterForSelectionToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.F; - filterForSelectionToolStripMenuItem.Size = new Size(343, 22); - filterForSelectionToolStripMenuItem.Text = "Filter for selection"; - filterForSelectionToolStripMenuItem.Click += OnFilterForSelectionToolStripMenuItemClick; - // - // setSelectedTextAsBookmarkCommentToolStripMenuItem - // - setSelectedTextAsBookmarkCommentToolStripMenuItem.Name = "setSelectedTextAsBookmarkCommentToolStripMenuItem"; - setSelectedTextAsBookmarkCommentToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.B; - setSelectedTextAsBookmarkCommentToolStripMenuItem.Size = new Size(343, 22); - setSelectedTextAsBookmarkCommentToolStripMenuItem.Text = "Set selected text as bookmark comment"; - setSelectedTextAsBookmarkCommentToolStripMenuItem.Click += OnSetSelectedTextAsBookmarkCommentToolStripMenuItemClick; - // - // LogWindow - // - ClientSize = new Size(1862, 1104); - ControlBox = false; - Controls.Add(splitContainerLogWindow); - Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - FormBorderStyle = FormBorderStyle.None; - Icon = (Icon)resources.GetObject("$this.Icon"); - Margin = new Padding(0); - MaximizeBox = false; - MinimizeBox = false; - Name = "LogWindow"; - ShowIcon = false; - ShowInTaskbar = false; - SizeGripStyle = SizeGripStyle.Hide; - SizeChanged += OnLogWindowSizeChanged; - Enter += OnLogWindowEnter; - KeyDown += OnLogWindowKeyDown; - Leave += OnLogWindowLeave; - splitContainerLogWindow.Panel1.ResumeLayout(false); - splitContainerLogWindow.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)splitContainerLogWindow).EndInit(); - splitContainerLogWindow.ResumeLayout(false); - tableLayoutPanel1.ResumeLayout(false); - columnFinderPanel.ResumeLayout(false); - columnFinderPanel.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - dataGridContextMenuStrip.ResumeLayout(false); - advancedBackPanel.ResumeLayout(false); - advancedFilterSplitContainer.Panel1.ResumeLayout(false); - advancedFilterSplitContainer.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)advancedFilterSplitContainer).EndInit(); - advancedFilterSplitContainer.ResumeLayout(false); - pnlProFilter.ResumeLayout(false); - pnlProFilter.PerformLayout(); - panelBackgroundAdvancedFilterSplitContainer.ResumeLayout(false); - highlightSplitContainer.Panel1.ResumeLayout(false); - highlightSplitContainer.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)highlightSplitContainer).EndInit(); - highlightSplitContainer.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)filterGridView).EndInit(); - filterContextMenuStrip.ResumeLayout(false); - highlightSplitContainerBackPanel.ResumeLayout(false); - highlightSplitContainerBackPanel.PerformLayout(); - filterListContextMenuStrip.ResumeLayout(false); - pnlFilterInput.ResumeLayout(false); - filterSplitContainer.Panel1.ResumeLayout(false); - filterSplitContainer.Panel1.PerformLayout(); - filterSplitContainer.Panel2.ResumeLayout(false); - filterSplitContainer.Panel2.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)filterSplitContainer).EndInit(); - filterSplitContainer.ResumeLayout(false); - bookmarkContextMenuStrip.ResumeLayout(false); - columnContextMenuStrip.ResumeLayout(false); - editModeContextMenuStrip.ResumeLayout(false); - ResumeLayout(false); - } - - #endregion - - private System.Windows.Forms.SplitContainer splitContainerLogWindow; - private System.Windows.Forms.Panel pnlFilterInput; - private BufferedDataGridView dataGridView; - private BufferedDataGridView filterGridView; - private System.Windows.Forms.SplitContainer advancedFilterSplitContainer; - private System.Windows.Forms.Panel pnlProFilter; - private System.Windows.Forms.Button btnFilterToTab; - private KnobControl filterKnobForeSpread; - private System.Windows.Forms.Label lblForeSpread; - private KnobControl filterKnobBackSpread; - private System.Windows.Forms.Label lblBackSpread; - private System.Windows.Forms.Panel pnlProFilterLabel; - private System.Windows.Forms.CheckBox invertFilterCheckBox; - private System.Windows.Forms.Label fuzzyLabel; - private KnobControl fuzzyKnobControl; - private System.Windows.Forms.CheckBox rangeCheckBox; - private System.Windows.Forms.ComboBox filterRangeComboBox; - private System.Windows.Forms.ContextMenuStrip dataGridContextMenuStrip; - private System.Windows.Forms.ToolStripMenuItem copyToTabToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem scrollAllTabsToTimestampToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem locateLineInOriginalFileToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toggleBoomarkToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem markEditModeToolStripMenuItem; - private System.Windows.Forms.ContextMenuStrip bookmarkContextMenuStrip; - private System.Windows.Forms.ToolStripMenuItem deleteBookmarksToolStripMenuItem; - private System.Windows.Forms.CheckBox columnRestrictCheckBox; - private System.Windows.Forms.Button columnButton; - private System.Windows.Forms.ContextMenuStrip columnContextMenuStrip; - private System.Windows.Forms.ToolStripMenuItem freezeLeftColumnsUntilHereToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem moveToLastColumnToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem moveLeftToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem moveRightToolStripMenuItem; - private TimeSpreadingControl timeSpreadingControl; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private System.Windows.Forms.ToolStripMenuItem bookmarkCommentToolStripMenuItem; - private System.Windows.Forms.ContextMenuStrip editModeContextMenuStrip; - private System.Windows.Forms.ToolStripMenuItem highlightSelectionInLogFileToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem editModecopyToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem tempHighlightsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem removeAllToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem makePermanentToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem filterForSelectionToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem setSelectedTextAsBookmarkCommentToolStripMenuItem; - private System.Windows.Forms.ToolTip helpToolTip; - private System.Windows.Forms.SplitContainer highlightSplitContainer; - private System.Windows.Forms.Button btnToggleHighlightPanel; - private System.Windows.Forms.Panel highlightSplitContainerBackPanel; - private System.Windows.Forms.Button saveFilterButton; - private System.Windows.Forms.Button deleteFilterButton; - private System.Windows.Forms.ListBox filterListBox; - private System.Windows.Forms.ContextMenuStrip filterContextMenuStrip; - private System.Windows.Forms.ToolStripMenuItem setBookmarksOnSelectedLinesToolStripMenuItem; - private System.Windows.Forms.CheckBox filterOnLoadCheckBox; - private System.Windows.Forms.ToolStripMenuItem markCurrentFilterRangeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem syncTimestampsToToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem freeThisWindowFromTimeSyncToolStripMenuItem; - private System.Windows.Forms.Button filterDownButton; - private System.Windows.Forms.Button filterUpButton; - private System.Windows.Forms.ContextMenuStrip filterListContextMenuStrip; - private System.Windows.Forms.ToolStripMenuItem colorToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem filterToTabToolStripMenuItem; - private System.Windows.Forms.CheckBox hideFilterListOnLoadCheckBox; - private System.Windows.Forms.Panel advancedBackPanel; - private System.Windows.Forms.ToolStripMenuItem markFilterHitsInLogViewToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem highlightSelectionInLogFilewordModeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem hideColumnToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem restoreColumnsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem allColumnsToolStripMenuItem; - private System.Windows.Forms.Label columnNamesLabel; - private System.Windows.Forms.Panel columnFinderPanel; - private System.Windows.Forms.ComboBox columnComboBox; - private System.Windows.Forms.Label lblColumnName; - private System.Windows.Forms.SplitContainer filterSplitContainer; - private System.Windows.Forms.Label lblTextFilter; - private System.Windows.Forms.ComboBox filterComboBox; - private System.Windows.Forms.Button advancedButton; - private System.Windows.Forms.CheckBox syncFilterCheckBox; - private System.Windows.Forms.Label lblFilterCount; - private System.Windows.Forms.CheckBox filterTailCheckBox; - private System.Windows.Forms.CheckBox filterRegexCheckBox; - private System.Windows.Forms.CheckBox filterCaseSensitiveCheckBox; - private System.Windows.Forms.Button filterSearchButton; - private System.Windows.Forms.Panel panelBackgroundAdvancedFilterSplitContainer; - private MenuToolStripSeparatorExtension pluginSeparator; - private MenuToolStripSeparatorExtension menuToolStripSeparator1; - private MenuToolStripSeparatorExtension menuToolStripSeparator2; - private MenuToolStripSeparatorExtension menuToolStripSeparator3; - private MenuToolStripSeparatorExtension menuToolStripSeparator4; - private MenuToolStripSeparatorExtension menuToolStripSeparator5; - private MenuToolStripSeparatorExtension menuToolStripSeparator6; - } -} +using LogExpert.Dialogs; +using LogExpert.UI.Extensions.Forms; +using System; +using System.Drawing; +using System.IO; +using System.Windows.Forms; + +namespace LogExpert.UI.Controls.LogWindow +{ + partial class LogWindow + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LogWindow)); + splitContainerLogWindow = new SplitContainer(); + tableLayoutPanel1 = new TableLayoutPanel(); + columnFinderPanel = new Panel(); + columnComboBox = new ComboBox(); + lblColumnName = new Label(); + dataGridView = new BufferedDataGridView(); + dataGridContextMenuStrip = new ContextMenuStrip(components); + copyToolStripMenuItem = new ToolStripMenuItem(); + copyToTabToolStripMenuItem = new ToolStripMenuItem(); + menuToolStripSeparator1 = new MenuToolStripSeparatorExtension(); + scrollAllTabsToTimestampToolStripMenuItem = new ToolStripMenuItem(); + syncTimestampsToToolStripMenuItem = new ToolStripMenuItem(); + freeThisWindowFromTimeSyncToolStripMenuItem = new ToolStripMenuItem(); + locateLineInOriginalFileToolStripMenuItem = new ToolStripMenuItem(); + menuToolStripSeparator2 = new MenuToolStripSeparatorExtension(); + toggleBoomarkToolStripMenuItem = new ToolStripMenuItem(); + bookmarkCommentToolStripMenuItem = new ToolStripMenuItem(); + markEditModeToolStripMenuItem = new ToolStripMenuItem(); + menuToolStripSeparator3 = new MenuToolStripSeparatorExtension(); + tempHighlightsToolStripMenuItem = new ToolStripMenuItem(); + removeAllToolStripMenuItem = new ToolStripMenuItem(); + makePermanentToolStripMenuItem = new ToolStripMenuItem(); + markCurrentFilterRangeToolStripMenuItem = new ToolStripMenuItem(); + pluginSeparator = new MenuToolStripSeparatorExtension(); + timeSpreadingControl = new TimeSpreadingControl(); + advancedBackPanel = new Panel(); + advancedFilterSplitContainer = new SplitContainer(); + pnlProFilter = new Panel(); + columnButton = new Button(); + columnRestrictCheckBox = new CheckBox(); + rangeCheckBox = new CheckBox(); + filterRangeComboBox = new ComboBox(); + columnNamesLabel = new Label(); + fuzzyLabel = new Label(); + fuzzyKnobControl = new KnobControl(); + invertFilterCheckBox = new CheckBox(); + pnlProFilterLabel = new Panel(); + lblBackSpread = new Label(); + filterKnobBackSpread = new KnobControl(); + lblForeSpread = new Label(); + filterKnobForeSpread = new KnobControl(); + btnFilterToTab = new Button(); + panelBackgroundAdvancedFilterSplitContainer = new Panel(); + btnToggleHighlightPanel = new Button(); + highlightSplitContainer = new SplitContainer(); + filterGridView = new BufferedDataGridView(); + filterContextMenuStrip = new ContextMenuStrip(components); + setBookmarksOnSelectedLinesToolStripMenuItem = new ToolStripMenuItem(); + filterToTabToolStripMenuItem = new ToolStripMenuItem(); + markFilterHitsInLogViewToolStripMenuItem = new ToolStripMenuItem(); + highlightSplitContainerBackPanel = new Panel(); + hideFilterListOnLoadCheckBox = new CheckBox(); + filterDownButton = new Button(); + filterUpButton = new Button(); + filterOnLoadCheckBox = new CheckBox(); + saveFilterButton = new Button(); + deleteFilterButton = new Button(); + filterListBox = new ListBox(); + filterListContextMenuStrip = new ContextMenuStrip(components); + colorToolStripMenuItem = new ToolStripMenuItem(); + pnlFilterInput = new Panel(); + filterSplitContainer = new SplitContainer(); + filterComboBox = new ComboBox(); + lblTextFilter = new Label(); + advancedButton = new Button(); + syncFilterCheckBox = new CheckBox(); + lblFilterCount = new Label(); + filterTailCheckBox = new CheckBox(); + filterRegexCheckBox = new CheckBox(); + filterCaseSensitiveCheckBox = new CheckBox(); + filterSearchButton = new Button(); + bookmarkContextMenuStrip = new ContextMenuStrip(components); + deleteBookmarksToolStripMenuItem = new ToolStripMenuItem(); + columnContextMenuStrip = new ContextMenuStrip(components); + freezeLeftColumnsUntilHereToolStripMenuItem = new ToolStripMenuItem(); + menuToolStripSeparator4 = new MenuToolStripSeparatorExtension(); + moveToLastColumnToolStripMenuItem = new ToolStripMenuItem(); + moveLeftToolStripMenuItem = new ToolStripMenuItem(); + moveRightToolStripMenuItem = new ToolStripMenuItem(); + menuToolStripSeparator5 = new MenuToolStripSeparatorExtension(); + hideColumnToolStripMenuItem = new ToolStripMenuItem(); + restoreColumnsToolStripMenuItem = new ToolStripMenuItem(); + menuToolStripSeparator6 = new MenuToolStripSeparatorExtension(); + allColumnsToolStripMenuItem = new ToolStripMenuItem(); + editModeContextMenuStrip = new ContextMenuStrip(components); + editModecopyToolStripMenuItem = new ToolStripMenuItem(); + highlightSelectionInLogFileToolStripMenuItem = new ToolStripMenuItem(); + highlightSelectionInLogFilewordModeToolStripMenuItem = new ToolStripMenuItem(); + filterForSelectionToolStripMenuItem = new ToolStripMenuItem(); + setSelectedTextAsBookmarkCommentToolStripMenuItem = new ToolStripMenuItem(); + helpToolTip = new ToolTip(components); + ((System.ComponentModel.ISupportInitialize)splitContainerLogWindow).BeginInit(); + splitContainerLogWindow.Panel1.SuspendLayout(); + splitContainerLogWindow.Panel2.SuspendLayout(); + splitContainerLogWindow.SuspendLayout(); + tableLayoutPanel1.SuspendLayout(); + columnFinderPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + dataGridContextMenuStrip.SuspendLayout(); + advancedBackPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)advancedFilterSplitContainer).BeginInit(); + advancedFilterSplitContainer.Panel1.SuspendLayout(); + advancedFilterSplitContainer.Panel2.SuspendLayout(); + advancedFilterSplitContainer.SuspendLayout(); + pnlProFilter.SuspendLayout(); + panelBackgroundAdvancedFilterSplitContainer.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)highlightSplitContainer).BeginInit(); + highlightSplitContainer.Panel1.SuspendLayout(); + highlightSplitContainer.Panel2.SuspendLayout(); + highlightSplitContainer.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)filterGridView).BeginInit(); + filterContextMenuStrip.SuspendLayout(); + highlightSplitContainerBackPanel.SuspendLayout(); + filterListContextMenuStrip.SuspendLayout(); + pnlFilterInput.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)filterSplitContainer).BeginInit(); + filterSplitContainer.Panel1.SuspendLayout(); + filterSplitContainer.Panel2.SuspendLayout(); + filterSplitContainer.SuspendLayout(); + bookmarkContextMenuStrip.SuspendLayout(); + columnContextMenuStrip.SuspendLayout(); + editModeContextMenuStrip.SuspendLayout(); + SuspendLayout(); + // + // splitContainerLogWindow + // + splitContainerLogWindow.BorderStyle = BorderStyle.FixedSingle; + splitContainerLogWindow.Dock = DockStyle.Fill; + splitContainerLogWindow.Location = new Point(0, 0); + splitContainerLogWindow.Margin = new Padding(0); + splitContainerLogWindow.Name = "splitContainerLogWindow"; + splitContainerLogWindow.Orientation = Orientation.Horizontal; + // + // splitContainerLogWindow.Panel1 + // + splitContainerLogWindow.Panel1.Controls.Add(tableLayoutPanel1); + splitContainerLogWindow.Panel1MinSize = 50; + // + // splitContainerLogWindow.Panel2 + // + splitContainerLogWindow.Panel2.Controls.Add(advancedBackPanel); + splitContainerLogWindow.Panel2.Controls.Add(pnlFilterInput); + splitContainerLogWindow.Panel2MinSize = 50; + splitContainerLogWindow.Size = new Size(1862, 1104); + splitContainerLogWindow.SplitterDistance = 486; + splitContainerLogWindow.TabIndex = 9; + splitContainerLogWindow.SplitterMoved += OnSplitContainerSplitterMoved; + // + // tableLayoutPanel1 + // + tableLayoutPanel1.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single; + tableLayoutPanel1.ColumnCount = 2; + tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle()); + tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 181F)); + tableLayoutPanel1.Controls.Add(columnFinderPanel, 0, 0); + tableLayoutPanel1.Controls.Add(dataGridView, 0, 1); + tableLayoutPanel1.Controls.Add(timeSpreadingControl, 1, 1); + tableLayoutPanel1.Dock = DockStyle.Fill; + tableLayoutPanel1.ForeColor = SystemColors.ControlText; + tableLayoutPanel1.Location = new Point(0, 0); + tableLayoutPanel1.Margin = new Padding(0); + tableLayoutPanel1.Name = "tableLayoutPanel1"; + tableLayoutPanel1.RowCount = 2; + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 28F)); + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + tableLayoutPanel1.Size = new Size(1860, 484); + tableLayoutPanel1.TabIndex = 2; + // + // columnFinderPanel + // + columnFinderPanel.Controls.Add(columnComboBox); + columnFinderPanel.Controls.Add(lblColumnName); + columnFinderPanel.Dock = DockStyle.Fill; + columnFinderPanel.Location = new Point(4, 4); + columnFinderPanel.Name = "columnFinderPanel"; + columnFinderPanel.Size = new Size(841, 22); + columnFinderPanel.TabIndex = 2; + // + // columnComboBox + // + columnComboBox.FormattingEnabled = true; + columnComboBox.Location = new Point(125, 1); + columnComboBox.MaxDropDownItems = 15; + columnComboBox.Name = "columnComboBox"; + columnComboBox.Size = new Size(181, 21); + columnComboBox.TabIndex = 1; + helpToolTip.SetToolTip(columnComboBox, "Select column to scroll to"); + columnComboBox.SelectionChangeCommitted += OnColumnComboBoxSelectionChangeCommitted; + columnComboBox.KeyDown += OnColumnComboBoxKeyDown; + columnComboBox.PreviewKeyDown += OnColumnComboBoxPreviewKeyDown; + // + // lblColumnName + // + lblColumnName.AutoSize = true; + lblColumnName.Location = new Point(8, 4); + lblColumnName.Name = "lblColumnName"; + lblColumnName.Size = new Size(74, 13); + lblColumnName.TabIndex = 0; + lblColumnName.Text = "Column name:"; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToOrderColumns = true; + dataGridView.AllowUserToResizeRows = false; + dataGridView.BackgroundColor = SystemColors.Window; + dataGridView.BorderStyle = BorderStyle.None; + dataGridView.CellBorderStyle = DataGridViewCellBorderStyle.None; + dataGridView.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.ContextMenuStrip = dataGridContextMenuStrip; + dataGridView.Dock = DockStyle.Fill; + dataGridView.EditMode = DataGridViewEditMode.EditProgrammatically; + dataGridView.EditModeMenuStrip = null; + dataGridView.ImeMode = ImeMode.Disable; + dataGridView.Location = new Point(1, 30); + dataGridView.Margin = new Padding(0); + dataGridView.Name = "dataGridView"; + dataGridView.PaintWithOverlays = false; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 62; + dataGridView.RowTemplate.DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomLeft; + dataGridView.RowTemplate.DefaultCellStyle.Padding = new Padding(2, 0, 0, 0); + dataGridView.RowTemplate.Height = 15; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.ShowCellErrors = false; + dataGridView.ShowCellToolTips = false; + dataGridView.ShowEditingIcon = false; + dataGridView.ShowRowErrors = false; + dataGridView.Size = new Size(847, 453); + dataGridView.TabIndex = 0; + dataGridView.VirtualMode = true; + dataGridView.OverlayDoubleClicked += OnDataGridViewOverlayDoubleClicked; + dataGridView.CellClick += OnDataGridViewCellClick; + dataGridView.CellContentDoubleClick += OnDataGridViewCellContentDoubleClick; + dataGridView.CellContextMenuStripNeeded += OnDataGridViewCellContextMenuStripNeeded; + dataGridView.CellDoubleClick += OnDataGridViewCellDoubleClick; + dataGridView.CellValuePushed += OnDataGridViewCellValuePushed; + dataGridView.RowHeightInfoNeeded += OnDataGridViewRowHeightInfoNeeded; + dataGridView.RowUnshared += OnDataGridViewRowUnshared; + dataGridView.Scroll += OnDataGridViewScroll; + dataGridView.SelectionChanged += OnDataGridViewSelectionChanged; + dataGridView.Paint += OnDataGridViewPaint; + dataGridView.Enter += OnDataGridViewEnter; + dataGridView.KeyDown += OnDataGridViewKeyDown; + dataGridView.Leave += OnDataGridViewLeave; + dataGridView.PreviewKeyDown += OnDataGridViewPreviewKeyDown; + dataGridView.Resize += OnDataGridViewResize; + // + // dataGridContextMenuStrip + // + dataGridContextMenuStrip.ImageScalingSize = new Size(24, 24); + dataGridContextMenuStrip.Items.AddRange(new ToolStripItem[] { copyToolStripMenuItem, copyToTabToolStripMenuItem, menuToolStripSeparator1, scrollAllTabsToTimestampToolStripMenuItem, syncTimestampsToToolStripMenuItem, freeThisWindowFromTimeSyncToolStripMenuItem, locateLineInOriginalFileToolStripMenuItem, menuToolStripSeparator2, toggleBoomarkToolStripMenuItem, bookmarkCommentToolStripMenuItem, markEditModeToolStripMenuItem, menuToolStripSeparator3, tempHighlightsToolStripMenuItem, markCurrentFilterRangeToolStripMenuItem, pluginSeparator }); + dataGridContextMenuStrip.Name = "dataGridContextMenuStrip"; + dataGridContextMenuStrip.Size = new Size(287, 270); + dataGridContextMenuStrip.Opening += OnDataGridContextMenuStripOpening; + // + // copyToolStripMenuItem + // + copyToolStripMenuItem.Name = "copyToolStripMenuItem"; + copyToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C; + copyToolStripMenuItem.Size = new Size(286, 22); + copyToolStripMenuItem.Text = "Copy to clipboard"; + copyToolStripMenuItem.Click += OnCopyToolStripMenuItemClick; + // + // copyToTabToolStripMenuItem + // + copyToTabToolStripMenuItem.Name = "copyToTabToolStripMenuItem"; + copyToTabToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T; + copyToTabToolStripMenuItem.Size = new Size(286, 22); + copyToTabToolStripMenuItem.Text = "Copy to new tab"; + copyToTabToolStripMenuItem.ToolTipText = "Copy marked lines into a new tab window"; + copyToTabToolStripMenuItem.Click += OnCopyToTabToolStripMenuItemClick; + // + // menuToolStripSeparator1 + // + menuToolStripSeparator1.Name = "menuToolStripSeparator1"; + menuToolStripSeparator1.Size = new Size(283, 6); + // + // scrollAllTabsToTimestampToolStripMenuItem + // + scrollAllTabsToTimestampToolStripMenuItem.Name = "scrollAllTabsToTimestampToolStripMenuItem"; + scrollAllTabsToTimestampToolStripMenuItem.Size = new Size(286, 22); + scrollAllTabsToTimestampToolStripMenuItem.Text = "Scroll all tabs to current timestamp"; + scrollAllTabsToTimestampToolStripMenuItem.ToolTipText = "Scolls all open tabs to the selected timestamp, if possible"; + scrollAllTabsToTimestampToolStripMenuItem.Click += OnScrollAllTabsToTimestampToolStripMenuItemClick; + // + // syncTimestampsToToolStripMenuItem + // + syncTimestampsToToolStripMenuItem.Name = "syncTimestampsToToolStripMenuItem"; + syncTimestampsToToolStripMenuItem.Size = new Size(286, 22); + syncTimestampsToToolStripMenuItem.Text = "Time synced files"; + // + // freeThisWindowFromTimeSyncToolStripMenuItem + // + freeThisWindowFromTimeSyncToolStripMenuItem.Name = "freeThisWindowFromTimeSyncToolStripMenuItem"; + freeThisWindowFromTimeSyncToolStripMenuItem.Size = new Size(286, 22); + freeThisWindowFromTimeSyncToolStripMenuItem.Text = "Free this window from time sync"; + freeThisWindowFromTimeSyncToolStripMenuItem.Click += OnFreeThisWindowFromTimeSyncToolStripMenuItemClick; + // + // locateLineInOriginalFileToolStripMenuItem + // + locateLineInOriginalFileToolStripMenuItem.Name = "locateLineInOriginalFileToolStripMenuItem"; + locateLineInOriginalFileToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L; + locateLineInOriginalFileToolStripMenuItem.Size = new Size(286, 22); + locateLineInOriginalFileToolStripMenuItem.Text = "Locate filtered line in original file"; + locateLineInOriginalFileToolStripMenuItem.Click += OnLocateLineInOriginalFileToolStripMenuItemClick; + // + // menuToolStripSeparator2 + // + menuToolStripSeparator2.Name = "menuToolStripSeparator2"; + menuToolStripSeparator2.Size = new Size(283, 6); + // + // toggleBoomarkToolStripMenuItem + // + toggleBoomarkToolStripMenuItem.Name = "toggleBoomarkToolStripMenuItem"; + toggleBoomarkToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.F2; + toggleBoomarkToolStripMenuItem.Size = new Size(286, 22); + toggleBoomarkToolStripMenuItem.Text = "Toggle Boomark"; + toggleBoomarkToolStripMenuItem.Click += OnToggleBoomarkToolStripMenuItemClick; + // + // bookmarkCommentToolStripMenuItem + // + bookmarkCommentToolStripMenuItem.Name = "bookmarkCommentToolStripMenuItem"; + bookmarkCommentToolStripMenuItem.ShortcutKeys = Keys.Alt | Keys.F2; + bookmarkCommentToolStripMenuItem.Size = new Size(286, 22); + bookmarkCommentToolStripMenuItem.Text = "Bookmark comment..."; + bookmarkCommentToolStripMenuItem.ToolTipText = "Edit the comment for a bookmark"; + bookmarkCommentToolStripMenuItem.Click += OnBookmarkCommentToolStripMenuItemClick; + // + // markEditModeToolStripMenuItem + // + markEditModeToolStripMenuItem.Name = "markEditModeToolStripMenuItem"; + markEditModeToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E; + markEditModeToolStripMenuItem.Size = new Size(286, 22); + markEditModeToolStripMenuItem.Text = "Mark/Edit-Mode"; + markEditModeToolStripMenuItem.Click += OnMarkEditModeToolStripMenuItemClick; + // + // menuToolStripSeparator3 + // + menuToolStripSeparator3.Name = "menuToolStripSeparator3"; + menuToolStripSeparator3.Size = new Size(283, 6); + // + // tempHighlightsToolStripMenuItem + // + tempHighlightsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { removeAllToolStripMenuItem, makePermanentToolStripMenuItem }); + tempHighlightsToolStripMenuItem.Name = "tempHighlightsToolStripMenuItem"; + tempHighlightsToolStripMenuItem.Size = new Size(286, 22); + tempHighlightsToolStripMenuItem.Text = "Temp Highlights"; + // + // removeAllToolStripMenuItem + // + removeAllToolStripMenuItem.Name = "removeAllToolStripMenuItem"; + removeAllToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.Shift | Keys.H; + removeAllToolStripMenuItem.Size = new Size(207, 22); + removeAllToolStripMenuItem.Text = "Remove all"; + removeAllToolStripMenuItem.Click += OnRemoveAllToolStripMenuItemClick; + // + // makePermanentToolStripMenuItem + // + makePermanentToolStripMenuItem.Name = "makePermanentToolStripMenuItem"; + makePermanentToolStripMenuItem.Size = new Size(207, 22); + makePermanentToolStripMenuItem.Text = "Make all permanent"; + makePermanentToolStripMenuItem.Click += OnMakePermanentToolStripMenuItemClick; + // + // markCurrentFilterRangeToolStripMenuItem + // + markCurrentFilterRangeToolStripMenuItem.Name = "markCurrentFilterRangeToolStripMenuItem"; + markCurrentFilterRangeToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.R; + markCurrentFilterRangeToolStripMenuItem.Size = new Size(286, 22); + markCurrentFilterRangeToolStripMenuItem.Text = "Mark current filter range"; + markCurrentFilterRangeToolStripMenuItem.Click += OnMarkCurrentFilterRangeToolStripMenuItemClick; + // + // pluginSeparator + // + pluginSeparator.Name = "pluginSeparator"; + pluginSeparator.Size = new Size(283, 6); + // + // timeSpreadingControl + // + timeSpreadingControl.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right; + timeSpreadingControl.Font = new Font("Verdana", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); + timeSpreadingControl.ForeColor = Color.Teal; + timeSpreadingControl.Location = new Point(1842, 30); + timeSpreadingControl.Margin = new Padding(2, 0, 1, 0); + timeSpreadingControl.Name = "timeSpreadingControl"; + timeSpreadingControl.ReverseAlpha = false; + timeSpreadingControl.Size = new Size(16, 453); + timeSpreadingControl.TabIndex = 1; + // + // advancedBackPanel + // + advancedBackPanel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + advancedBackPanel.Controls.Add(advancedFilterSplitContainer); + advancedBackPanel.Location = new Point(3, 48); + advancedBackPanel.Name = "advancedBackPanel"; + advancedBackPanel.Size = new Size(1855, 561); + advancedBackPanel.TabIndex = 3; + // + // advancedFilterSplitContainer + // + advancedFilterSplitContainer.Dock = DockStyle.Fill; + advancedFilterSplitContainer.IsSplitterFixed = true; + advancedFilterSplitContainer.Location = new Point(0, 0); + advancedFilterSplitContainer.Margin = new Padding(0); + advancedFilterSplitContainer.Name = "advancedFilterSplitContainer"; + advancedFilterSplitContainer.Orientation = Orientation.Horizontal; + // + // advancedFilterSplitContainer.Panel1 + // + advancedFilterSplitContainer.Panel1.Controls.Add(pnlProFilter); + advancedFilterSplitContainer.Panel1MinSize = 100; + // + // advancedFilterSplitContainer.Panel2 + // + advancedFilterSplitContainer.Panel2.Controls.Add(panelBackgroundAdvancedFilterSplitContainer); + advancedFilterSplitContainer.Panel2MinSize = 200; + advancedFilterSplitContainer.Size = new Size(1855, 561); + advancedFilterSplitContainer.SplitterDistance = 124; + advancedFilterSplitContainer.SplitterWidth = 2; + advancedFilterSplitContainer.TabIndex = 2; + // + // pnlProFilter + // + pnlProFilter.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + pnlProFilter.Controls.Add(columnButton); + pnlProFilter.Controls.Add(columnRestrictCheckBox); + pnlProFilter.Controls.Add(rangeCheckBox); + pnlProFilter.Controls.Add(filterRangeComboBox); + pnlProFilter.Controls.Add(columnNamesLabel); + pnlProFilter.Controls.Add(fuzzyLabel); + pnlProFilter.Controls.Add(fuzzyKnobControl); + pnlProFilter.Controls.Add(invertFilterCheckBox); + pnlProFilter.Controls.Add(pnlProFilterLabel); + pnlProFilter.Controls.Add(lblBackSpread); + pnlProFilter.Controls.Add(filterKnobBackSpread); + pnlProFilter.Controls.Add(lblForeSpread); + pnlProFilter.Controls.Add(filterKnobForeSpread); + pnlProFilter.Controls.Add(btnFilterToTab); + pnlProFilter.Location = new Point(0, 3); + pnlProFilter.Name = "pnlProFilter"; + pnlProFilter.Size = new Size(1852, 117); + pnlProFilter.TabIndex = 0; + // + // columnButton + // + columnButton.Enabled = false; + columnButton.Location = new Point(750, 41); + columnButton.Name = "columnButton"; + columnButton.Size = new Size(85, 35); + columnButton.TabIndex = 15; + columnButton.Text = "Columns..."; + helpToolTip.SetToolTip(columnButton, "Choose columns for 'Column restrict'"); + columnButton.UseVisualStyleBackColor = true; + columnButton.Click += OnColumnButtonClick; + // + // columnRestrictCheckBox + // + columnRestrictCheckBox.AutoSize = true; + columnRestrictCheckBox.Location = new Point(594, 38); + columnRestrictCheckBox.Name = "columnRestrictCheckBox"; + columnRestrictCheckBox.Size = new Size(95, 17); + columnRestrictCheckBox.TabIndex = 14; + columnRestrictCheckBox.Text = "Column restrict"; + helpToolTip.SetToolTip(columnRestrictCheckBox, "Restrict search to columns"); + columnRestrictCheckBox.UseVisualStyleBackColor = true; + columnRestrictCheckBox.CheckedChanged += OnColumnRestrictCheckBoxCheckedChanged; + // + // rangeCheckBox + // + rangeCheckBox.AutoSize = true; + rangeCheckBox.Location = new Point(73, 38); + rangeCheckBox.Name = "rangeCheckBox"; + rangeCheckBox.Size = new Size(93, 17); + rangeCheckBox.TabIndex = 13; + rangeCheckBox.Text = "Range search"; + helpToolTip.SetToolTip(rangeCheckBox, "Enable a special search mode which filters all content between the 2 given search terms."); + rangeCheckBox.UseVisualStyleBackColor = true; + rangeCheckBox.CheckedChanged += OnRangeCheckBoxCheckedChanged; + // + // filterRangeComboBox + // + filterRangeComboBox.Enabled = false; + filterRangeComboBox.FormattingEnabled = true; + filterRangeComboBox.Location = new Point(73, 11); + filterRangeComboBox.Name = "filterRangeComboBox"; + filterRangeComboBox.Size = new Size(207, 21); + filterRangeComboBox.TabIndex = 12; + helpToolTip.SetToolTip(filterRangeComboBox, "2nd search string ('end string') when using the range search"); + filterRangeComboBox.TextChanged += OnFilterRangeComboBoxTextChanged; + // + // columnNamesLabel + // + columnNamesLabel.AutoSize = true; + columnNamesLabel.Location = new Point(841, 41); + columnNamesLabel.Name = "columnNamesLabel"; + columnNamesLabel.Size = new Size(75, 13); + columnNamesLabel.TabIndex = 11; + columnNamesLabel.Text = "column names"; + // + // fuzzyLabel + // + fuzzyLabel.AutoSize = true; + fuzzyLabel.Location = new Point(502, 38); + fuzzyLabel.Name = "fuzzyLabel"; + fuzzyLabel.Size = new Size(56, 13); + fuzzyLabel.TabIndex = 11; + fuzzyLabel.Text = "Fuzzyness"; + // + // fuzzyKnobControl + // + fuzzyKnobControl.DragSensitivity = 6; + fuzzyKnobControl.Font = new Font("Verdana", 6F, FontStyle.Regular, GraphicsUnit.Point, 0); + fuzzyKnobControl.Location = new Point(521, 7); + fuzzyKnobControl.Margin = new Padding(2); + fuzzyKnobControl.MaxValue = 0; + fuzzyKnobControl.MinValue = 0; + fuzzyKnobControl.Name = "fuzzyKnobControl"; + fuzzyKnobControl.Size = new Size(17, 29); + fuzzyKnobControl.TabIndex = 10; + helpToolTip.SetToolTip(fuzzyKnobControl, "Fuzzy search level (0 = fuzzy off)"); + fuzzyKnobControl.Value = 0; + fuzzyKnobControl.ValueChanged += OnFuzzyKnobControlValueChanged; + // + // invertFilterCheckBox + // + invertFilterCheckBox.AutoSize = true; + invertFilterCheckBox.Location = new Point(594, 7); + invertFilterCheckBox.Name = "invertFilterCheckBox"; + invertFilterCheckBox.Size = new Size(86, 17); + invertFilterCheckBox.TabIndex = 8; + invertFilterCheckBox.Text = "Invert Match"; + helpToolTip.SetToolTip(invertFilterCheckBox, "Invert the search result"); + invertFilterCheckBox.UseVisualStyleBackColor = true; + invertFilterCheckBox.CheckedChanged += OnInvertFilterCheckBoxCheckedChanged; + // + // pnlProFilterLabel + // + pnlProFilterLabel.BackgroundImage = LogExpert.Resources.Resources.Pro_Filter; + pnlProFilterLabel.BackgroundImageLayout = ImageLayout.Center; + pnlProFilterLabel.Location = new Point(5, 7); + pnlProFilterLabel.Name = "pnlProFilterLabel"; + pnlProFilterLabel.Size = new Size(60, 44); + pnlProFilterLabel.TabIndex = 7; + // + // lblBackSpread + // + lblBackSpread.AutoSize = true; + lblBackSpread.Location = new Point(287, 38); + lblBackSpread.Name = "lblBackSpread"; + lblBackSpread.Size = new Size(72, 13); + lblBackSpread.TabIndex = 6; + lblBackSpread.Text = "Back Spread "; + // + // filterKnobBackSpread + // + filterKnobBackSpread.DragSensitivity = 3; + filterKnobBackSpread.Font = new Font("Verdana", 6F, FontStyle.Regular, GraphicsUnit.Point, 0); + filterKnobBackSpread.Location = new Point(313, 7); + filterKnobBackSpread.Margin = new Padding(2); + filterKnobBackSpread.MaxValue = 0; + filterKnobBackSpread.MinValue = 0; + filterKnobBackSpread.Name = "filterKnobBackSpread"; + filterKnobBackSpread.Size = new Size(17, 29); + filterKnobBackSpread.TabIndex = 5; + helpToolTip.SetToolTip(filterKnobBackSpread, "Add preceding lines to search result (Drag up/down, press Shift for finer pitch)"); + filterKnobBackSpread.Value = 0; + // + // lblForeSpread + // + lblForeSpread.AutoSize = true; + lblForeSpread.Location = new Point(397, 38); + lblForeSpread.Name = "lblForeSpread"; + lblForeSpread.Size = new Size(65, 13); + lblForeSpread.TabIndex = 2; + lblForeSpread.Text = "Fore Spread"; + // + // filterKnobForeSpread + // + filterKnobForeSpread.DragSensitivity = 3; + filterKnobForeSpread.Font = new Font("Verdana", 6F, FontStyle.Regular, GraphicsUnit.Point, 0); + filterKnobForeSpread.Location = new Point(420, 7); + filterKnobForeSpread.Margin = new Padding(2); + filterKnobForeSpread.MaxValue = 0; + filterKnobForeSpread.MinValue = 0; + filterKnobForeSpread.Name = "filterKnobForeSpread"; + filterKnobForeSpread.Size = new Size(17, 29); + filterKnobForeSpread.TabIndex = 1; + helpToolTip.SetToolTip(filterKnobForeSpread, "Add following lines to search result (Drag up/down, press Shift for finer pitch)"); + filterKnobForeSpread.Value = 0; + // + // btnFilterToTab + // + btnFilterToTab.Location = new Point(750, 3); + btnFilterToTab.Name = "btnFilterToTab"; + btnFilterToTab.Size = new Size(85, 35); + btnFilterToTab.TabIndex = 0; + btnFilterToTab.Text = "Filter to Tab"; + helpToolTip.SetToolTip(btnFilterToTab, "Launch a new tab with filtered content"); + btnFilterToTab.UseVisualStyleBackColor = true; + btnFilterToTab.Click += OnFilterToTabButtonClick; + // + // panelBackgroundAdvancedFilterSplitContainer + // + panelBackgroundAdvancedFilterSplitContainer.Controls.Add(btnToggleHighlightPanel); + panelBackgroundAdvancedFilterSplitContainer.Controls.Add(highlightSplitContainer); + panelBackgroundAdvancedFilterSplitContainer.Dock = DockStyle.Fill; + panelBackgroundAdvancedFilterSplitContainer.Location = new Point(0, 0); + panelBackgroundAdvancedFilterSplitContainer.Name = "panelBackgroundAdvancedFilterSplitContainer"; + panelBackgroundAdvancedFilterSplitContainer.Size = new Size(1855, 435); + panelBackgroundAdvancedFilterSplitContainer.TabIndex = 7; + // + // btnToggleHighlightPanel + // + btnToggleHighlightPanel.Anchor = AnchorStyles.Top | AnchorStyles.Right; + btnToggleHighlightPanel.Image = LogExpert.Resources.Resources.Arrow_menu_open; + btnToggleHighlightPanel.Location = new Point(1832, 1); + btnToggleHighlightPanel.Name = "btnToggleHighlightPanel"; + btnToggleHighlightPanel.Size = new Size(20, 21); + btnToggleHighlightPanel.TabIndex = 6; + helpToolTip.SetToolTip(btnToggleHighlightPanel, "Open or close a list with saved filters"); + btnToggleHighlightPanel.UseVisualStyleBackColor = true; + btnToggleHighlightPanel.SizeChanged += OnButtonSizeChanged; + btnToggleHighlightPanel.Click += OnToggleHighlightPanelButtonClick; + // + // highlightSplitContainer + // + highlightSplitContainer.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + highlightSplitContainer.BorderStyle = BorderStyle.FixedSingle; + highlightSplitContainer.FixedPanel = FixedPanel.Panel2; + highlightSplitContainer.Location = new Point(0, 3); + highlightSplitContainer.Name = "highlightSplitContainer"; + // + // highlightSplitContainer.Panel1 + // + highlightSplitContainer.Panel1.Controls.Add(filterGridView); + highlightSplitContainer.Panel1MinSize = 100; + // + // highlightSplitContainer.Panel2 + // + highlightSplitContainer.Panel2.Controls.Add(highlightSplitContainerBackPanel); + highlightSplitContainer.Panel2MinSize = 350; + highlightSplitContainer.Size = new Size(1829, 432); + highlightSplitContainer.SplitterDistance = 1475; + highlightSplitContainer.TabIndex = 2; + // + // filterGridView + // + filterGridView.AllowUserToAddRows = false; + filterGridView.AllowUserToDeleteRows = false; + filterGridView.AllowUserToOrderColumns = true; + filterGridView.AllowUserToResizeRows = false; + filterGridView.BackgroundColor = SystemColors.Window; + filterGridView.BorderStyle = BorderStyle.None; + filterGridView.CellBorderStyle = DataGridViewCellBorderStyle.None; + filterGridView.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText; + filterGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + filterGridView.ContextMenuStrip = filterContextMenuStrip; + filterGridView.Dock = DockStyle.Fill; + filterGridView.EditMode = DataGridViewEditMode.EditProgrammatically; + filterGridView.EditModeMenuStrip = null; + filterGridView.ImeMode = ImeMode.Disable; + filterGridView.Location = new Point(0, 0); + filterGridView.Margin = new Padding(0); + filterGridView.Name = "filterGridView"; + filterGridView.PaintWithOverlays = false; + filterGridView.ReadOnly = true; + filterGridView.RowHeadersVisible = false; + filterGridView.RowHeadersWidth = 62; + filterGridView.RowTemplate.Height = 15; + filterGridView.RowTemplate.ReadOnly = true; + filterGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + filterGridView.ShowCellErrors = false; + filterGridView.ShowCellToolTips = false; + filterGridView.ShowEditingIcon = false; + filterGridView.ShowRowErrors = false; + filterGridView.Size = new Size(1473, 430); + filterGridView.TabIndex = 1; + filterGridView.VirtualMode = true; + filterGridView.CellContextMenuStripNeeded += OnFilterGridViewCellContextMenuStripNeeded; + filterGridView.CellDoubleClick += OnFilterGridViewCellDoubleClick; + filterGridView.ColumnDividerDoubleClick += OnFilterGridViewColumnDividerDoubleClick; + filterGridView.RowHeightInfoNeeded += OnFilterGridViewRowHeightInfoNeeded; + filterGridView.Enter += OnFilterGridViewEnter; + filterGridView.KeyDown += OnFilterGridViewKeyDown; + filterGridView.Leave += OnFilterGridViewLeave; + // + // filterContextMenuStrip + // + filterContextMenuStrip.ImageScalingSize = new Size(24, 24); + filterContextMenuStrip.Items.AddRange(new ToolStripItem[] { setBookmarksOnSelectedLinesToolStripMenuItem, filterToTabToolStripMenuItem, markFilterHitsInLogViewToolStripMenuItem }); + filterContextMenuStrip.Name = "filterContextMenuStrip"; + filterContextMenuStrip.Size = new Size(243, 70); + // + // setBookmarksOnSelectedLinesToolStripMenuItem + // + setBookmarksOnSelectedLinesToolStripMenuItem.Name = "setBookmarksOnSelectedLinesToolStripMenuItem"; + setBookmarksOnSelectedLinesToolStripMenuItem.Size = new Size(242, 22); + setBookmarksOnSelectedLinesToolStripMenuItem.Text = "Set bookmarks on selected lines"; + setBookmarksOnSelectedLinesToolStripMenuItem.Click += OnSetBookmarksOnSelectedLinesToolStripMenuItemClick; + // + // filterToTabToolStripMenuItem + // + filterToTabToolStripMenuItem.Name = "filterToTabToolStripMenuItem"; + filterToTabToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.Shift | Keys.T; + filterToTabToolStripMenuItem.Size = new Size(242, 22); + filterToTabToolStripMenuItem.Text = "Filter to new tab"; + filterToTabToolStripMenuItem.Click += OnFilterToTabToolStripMenuItemClick; + // + // markFilterHitsInLogViewToolStripMenuItem + // + markFilterHitsInLogViewToolStripMenuItem.Name = "markFilterHitsInLogViewToolStripMenuItem"; + markFilterHitsInLogViewToolStripMenuItem.Size = new Size(242, 22); + markFilterHitsInLogViewToolStripMenuItem.Text = "Mark filter hits in log view"; + markFilterHitsInLogViewToolStripMenuItem.Click += OnMarkFilterHitsInLogViewToolStripMenuItemClick; + // + // highlightSplitContainerBackPanel + // + highlightSplitContainerBackPanel.Controls.Add(hideFilterListOnLoadCheckBox); + highlightSplitContainerBackPanel.Controls.Add(filterDownButton); + highlightSplitContainerBackPanel.Controls.Add(filterUpButton); + highlightSplitContainerBackPanel.Controls.Add(filterOnLoadCheckBox); + highlightSplitContainerBackPanel.Controls.Add(saveFilterButton); + highlightSplitContainerBackPanel.Controls.Add(deleteFilterButton); + highlightSplitContainerBackPanel.Controls.Add(filterListBox); + highlightSplitContainerBackPanel.Dock = DockStyle.Fill; + highlightSplitContainerBackPanel.Location = new Point(0, 0); + highlightSplitContainerBackPanel.Name = "highlightSplitContainerBackPanel"; + highlightSplitContainerBackPanel.Size = new Size(348, 430); + highlightSplitContainerBackPanel.TabIndex = 1; + // + // hideFilterListOnLoadCheckBox + // + hideFilterListOnLoadCheckBox.AutoSize = true; + hideFilterListOnLoadCheckBox.Location = new Point(258, 147); + hideFilterListOnLoadCheckBox.Name = "hideFilterListOnLoadCheckBox"; + hideFilterListOnLoadCheckBox.Size = new Size(71, 17); + hideFilterListOnLoadCheckBox.TabIndex = 20; + hideFilterListOnLoadCheckBox.Text = "Auto hide"; + helpToolTip.SetToolTip(hideFilterListOnLoadCheckBox, "Hides the filter list after loading a filter"); + hideFilterListOnLoadCheckBox.UseVisualStyleBackColor = true; + hideFilterListOnLoadCheckBox.MouseClick += OnHideFilterListOnLoadCheckBoxMouseClick; + // + // filterDownButton + // + filterDownButton.BackgroundImage = LogExpert.Resources.Resources.ArrowDown; + filterDownButton.BackgroundImageLayout = ImageLayout.Stretch; + filterDownButton.Location = new Point(296, 85); + filterDownButton.Name = "filterDownButton"; + filterDownButton.Size = new Size(35, 35); + filterDownButton.TabIndex = 19; + helpToolTip.SetToolTip(filterDownButton, "Move the selected entry down in the list"); + filterDownButton.UseVisualStyleBackColor = true; + filterDownButton.SizeChanged += OnButtonSizeChanged; + filterDownButton.Click += OnFilterDownButtonClick; + // + // filterUpButton + // + filterUpButton.BackgroundImage = LogExpert.Resources.Resources.ArrowUp; + filterUpButton.BackgroundImageLayout = ImageLayout.Stretch; + filterUpButton.Location = new Point(258, 85); + filterUpButton.Name = "filterUpButton"; + filterUpButton.Size = new Size(35, 35); + filterUpButton.TabIndex = 18; + helpToolTip.SetToolTip(filterUpButton, "Move the selected entry up in the list"); + filterUpButton.UseVisualStyleBackColor = true; + filterUpButton.SizeChanged += OnButtonSizeChanged; + filterUpButton.Click += OnFilterUpButtonClick; + // + // filterOnLoadCheckBox + // + filterOnLoadCheckBox.AutoSize = true; + filterOnLoadCheckBox.Location = new Point(258, 123); + filterOnLoadCheckBox.Name = "filterOnLoadCheckBox"; + filterOnLoadCheckBox.Size = new Size(71, 17); + filterOnLoadCheckBox.TabIndex = 17; + filterOnLoadCheckBox.Text = "Auto start"; + helpToolTip.SetToolTip(filterOnLoadCheckBox, "Start immediate filtering after loading a saved filter"); + filterOnLoadCheckBox.UseVisualStyleBackColor = true; + filterOnLoadCheckBox.KeyPress += OnFilterOnLoadCheckBoxKeyPress; + filterOnLoadCheckBox.MouseClick += OnFilterOnLoadCheckBoxMouseClick; + // + // saveFilterButton + // + saveFilterButton.Location = new Point(258, 11); + saveFilterButton.Name = "saveFilterButton"; + saveFilterButton.Size = new Size(75, 35); + saveFilterButton.TabIndex = 16; + saveFilterButton.Text = "Save filter"; + saveFilterButton.UseVisualStyleBackColor = true; + saveFilterButton.Click += OnSaveFilterButtonClick; + // + // deleteFilterButton + // + deleteFilterButton.Location = new Point(258, 47); + deleteFilterButton.Name = "deleteFilterButton"; + deleteFilterButton.Size = new Size(75, 35); + deleteFilterButton.TabIndex = 3; + deleteFilterButton.Text = "Delete"; + deleteFilterButton.UseVisualStyleBackColor = true; + deleteFilterButton.Click += OnDeleteFilterButtonClick; + // + // filterListBox + // + filterListBox.ContextMenuStrip = filterListContextMenuStrip; + filterListBox.Dock = DockStyle.Left; + filterListBox.DrawMode = DrawMode.OwnerDrawFixed; + filterListBox.Font = new Font("Courier New", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); + filterListBox.FormattingEnabled = true; + filterListBox.IntegralHeight = false; + filterListBox.ItemHeight = 25; + filterListBox.Location = new Point(0, 0); + filterListBox.Name = "filterListBox"; + filterListBox.Size = new Size(252, 430); + filterListBox.TabIndex = 0; + helpToolTip.SetToolTip(filterListBox, "Doubleclick to load a saved filter"); + filterListBox.DrawItem += OnFilterListBoxDrawItem; + filterListBox.MouseDoubleClick += OnFilterListBoxMouseDoubleClick; + // + // filterListContextMenuStrip + // + filterListContextMenuStrip.ImageScalingSize = new Size(24, 24); + filterListContextMenuStrip.Items.AddRange(new ToolStripItem[] { colorToolStripMenuItem }); + filterListContextMenuStrip.Name = "filterListContextMenuStrip"; + filterListContextMenuStrip.Size = new Size(113, 26); + // + // colorToolStripMenuItem + // + colorToolStripMenuItem.Name = "colorToolStripMenuItem"; + colorToolStripMenuItem.Size = new Size(112, 22); + colorToolStripMenuItem.Text = "Color..."; + colorToolStripMenuItem.Click += OnColorToolStripMenuItemClick; + // + // pnlFilterInput + // + pnlFilterInput.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + pnlFilterInput.Controls.Add(filterSplitContainer); + pnlFilterInput.Location = new Point(3, 2); + pnlFilterInput.Name = "pnlFilterInput"; + pnlFilterInput.Size = new Size(1855, 46); + pnlFilterInput.TabIndex = 0; + // + // filterSplitContainer + // + filterSplitContainer.Dock = DockStyle.Fill; + filterSplitContainer.Location = new Point(0, 0); + filterSplitContainer.Name = "filterSplitContainer"; + // + // filterSplitContainer.Panel1 + // + filterSplitContainer.Panel1.Controls.Add(filterComboBox); + filterSplitContainer.Panel1.Controls.Add(lblTextFilter); + filterSplitContainer.Panel1MinSize = 200; + // + // filterSplitContainer.Panel2 + // + filterSplitContainer.Panel2.Controls.Add(advancedButton); + filterSplitContainer.Panel2.Controls.Add(syncFilterCheckBox); + filterSplitContainer.Panel2.Controls.Add(lblFilterCount); + filterSplitContainer.Panel2.Controls.Add(filterTailCheckBox); + filterSplitContainer.Panel2.Controls.Add(filterRegexCheckBox); + filterSplitContainer.Panel2.Controls.Add(filterCaseSensitiveCheckBox); + filterSplitContainer.Panel2.Controls.Add(filterSearchButton); + filterSplitContainer.Panel2MinSize = 550; + filterSplitContainer.Size = new Size(1855, 46); + filterSplitContainer.SplitterDistance = 518; + filterSplitContainer.TabIndex = 11; + filterSplitContainer.MouseDoubleClick += OnFilterSplitContainerMouseDoubleClick; + filterSplitContainer.MouseDown += OnFilterSplitContainerMouseDown; + filterSplitContainer.MouseMove += OnFilterSplitContainerMouseMove; + filterSplitContainer.MouseUp += OnFilterSplitContainerMouseUp; + // + // filterComboBox + // + filterComboBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + filterComboBox.Font = new Font("Courier New", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); + filterComboBox.FormattingEnabled = true; + filterComboBox.Location = new Point(89, 5); + filterComboBox.Name = "filterComboBox"; + filterComboBox.Size = new Size(426, 26); + filterComboBox.TabIndex = 4; + helpToolTip.SetToolTip(filterComboBox, "Search string for the filter"); + filterComboBox.TextChanged += OnFilterComboBoxTextChanged; + filterComboBox.KeyDown += OnFilterComboBoxKeyDown; + // + // lblTextFilter + // + lblTextFilter.AutoSize = true; + lblTextFilter.Location = new Point(5, 5); + lblTextFilter.Name = "lblTextFilter"; + lblTextFilter.Size = new Size(53, 13); + lblTextFilter.TabIndex = 3; + lblTextFilter.Text = "Text &filter:"; + // + // advancedButton + // + advancedButton.DialogResult = DialogResult.Cancel; + advancedButton.Image = (Image)resources.GetObject("advancedButton.Image"); + advancedButton.ImageAlign = ContentAlignment.MiddleRight; + advancedButton.Location = new Point(539, 5); + advancedButton.Name = "advancedButton"; + advancedButton.Size = new Size(110, 35); + advancedButton.TabIndex = 17; + advancedButton.Text = "Show advanced..."; + helpToolTip.SetToolTip(advancedButton, "Toggel the advanced filter options panel"); + advancedButton.UseVisualStyleBackColor = true; + advancedButton.Click += OnAdvancedButtonClick; + // + // syncFilterCheckBox + // + syncFilterCheckBox.AutoSize = true; + syncFilterCheckBox.Location = new Point(467, 5); + syncFilterCheckBox.Name = "syncFilterCheckBox"; + syncFilterCheckBox.Size = new Size(50, 17); + syncFilterCheckBox.TabIndex = 16; + syncFilterCheckBox.Text = "Sync"; + helpToolTip.SetToolTip(syncFilterCheckBox, "Sync the current selected line in the filter view to the selection in the log file view"); + syncFilterCheckBox.UseVisualStyleBackColor = true; + syncFilterCheckBox.CheckedChanged += OnSyncFilterCheckBoxCheckedChanged; + // + // lblFilterCount + // + lblFilterCount.Anchor = AnchorStyles.Right; + lblFilterCount.BorderStyle = BorderStyle.Fixed3D; + lblFilterCount.Location = new Point(1259, 8); + lblFilterCount.Name = "lblFilterCount"; + lblFilterCount.Size = new Size(71, 21); + lblFilterCount.TabIndex = 15; + lblFilterCount.Text = "0"; + lblFilterCount.TextAlign = ContentAlignment.MiddleRight; + // + // filterTailCheckBox + // + filterTailCheckBox.AutoSize = true; + filterTailCheckBox.Location = new Point(367, 5); + filterTailCheckBox.Name = "filterTailCheckBox"; + filterTailCheckBox.Size = new Size(64, 17); + filterTailCheckBox.TabIndex = 14; + filterTailCheckBox.Text = "Filter tail"; + helpToolTip.SetToolTip(filterTailCheckBox, "Filter tailed file content (keeps filter view up to date on file changes)"); + filterTailCheckBox.UseVisualStyleBackColor = true; + // + // filterRegexCheckBox + // + filterRegexCheckBox.AutoSize = true; + filterRegexCheckBox.Location = new Point(283, 5); + filterRegexCheckBox.Name = "filterRegexCheckBox"; + filterRegexCheckBox.Size = new Size(57, 17); + filterRegexCheckBox.TabIndex = 13; + filterRegexCheckBox.Text = "Regex"; + helpToolTip.SetToolTip(filterRegexCheckBox, "Use regular expressions. (right-click for RegEx helper window)"); + filterRegexCheckBox.UseVisualStyleBackColor = true; + filterRegexCheckBox.CheckedChanged += OnFilterRegexCheckBoxCheckedChanged; + filterRegexCheckBox.MouseUp += OnFilterRegexCheckBoxMouseUp; + // + // filterCaseSensitiveCheckBox + // + filterCaseSensitiveCheckBox.AutoSize = true; + filterCaseSensitiveCheckBox.Location = new Point(137, 5); + filterCaseSensitiveCheckBox.Name = "filterCaseSensitiveCheckBox"; + filterCaseSensitiveCheckBox.Size = new Size(94, 17); + filterCaseSensitiveCheckBox.TabIndex = 12; + filterCaseSensitiveCheckBox.Text = "Case sensitive"; + helpToolTip.SetToolTip(filterCaseSensitiveCheckBox, "Makes the filter case sensitive"); + filterCaseSensitiveCheckBox.UseVisualStyleBackColor = true; + filterCaseSensitiveCheckBox.CheckedChanged += OnFilterCaseSensitiveCheckBoxCheckedChanged; + // + // filterSearchButton + // + filterSearchButton.Image = (Image)resources.GetObject("filterSearchButton.Image"); + filterSearchButton.ImageAlign = ContentAlignment.MiddleRight; + filterSearchButton.Location = new Point(3, 5); + filterSearchButton.Name = "filterSearchButton"; + filterSearchButton.Size = new Size(128, 35); + filterSearchButton.TabIndex = 11; + filterSearchButton.Text = "Search"; + helpToolTip.SetToolTip(filterSearchButton, "Start the filter search"); + filterSearchButton.UseVisualStyleBackColor = true; + filterSearchButton.Click += OnFilterSearchButtonClick; + // + // bookmarkContextMenuStrip + // + bookmarkContextMenuStrip.ImageScalingSize = new Size(24, 24); + bookmarkContextMenuStrip.Items.AddRange(new ToolStripItem[] { deleteBookmarksToolStripMenuItem }); + bookmarkContextMenuStrip.Name = "bookmarkContextMenuStrip"; + bookmarkContextMenuStrip.Size = new Size(68, 26); + // + // deleteBookmarksToolStripMenuItem + // + deleteBookmarksToolStripMenuItem.Name = "deleteBookmarksToolStripMenuItem"; + deleteBookmarksToolStripMenuItem.Size = new Size(67, 22); + // + // columnContextMenuStrip + // + columnContextMenuStrip.ImageScalingSize = new Size(24, 24); + columnContextMenuStrip.Items.AddRange(new ToolStripItem[] { freezeLeftColumnsUntilHereToolStripMenuItem, menuToolStripSeparator4, moveToLastColumnToolStripMenuItem, moveLeftToolStripMenuItem, moveRightToolStripMenuItem, menuToolStripSeparator5, hideColumnToolStripMenuItem, restoreColumnsToolStripMenuItem, menuToolStripSeparator6, allColumnsToolStripMenuItem }); + columnContextMenuStrip.Name = "columnContextMenuStrip"; + columnContextMenuStrip.Size = new Size(230, 198); + columnContextMenuStrip.Opening += OnColumnContextMenuStripOpening; + // + // freezeLeftColumnsUntilHereToolStripMenuItem + // + freezeLeftColumnsUntilHereToolStripMenuItem.Name = "freezeLeftColumnsUntilHereToolStripMenuItem"; + freezeLeftColumnsUntilHereToolStripMenuItem.Size = new Size(229, 22); + freezeLeftColumnsUntilHereToolStripMenuItem.Text = "Freeze left columns until here"; + freezeLeftColumnsUntilHereToolStripMenuItem.Click += OnFreezeLeftColumnsUntilHereToolStripMenuItemClick; + // + // menuToolStripSeparator4 + // + menuToolStripSeparator4.Name = "menuToolStripSeparator4"; + menuToolStripSeparator4.Size = new Size(226, 6); + // + // moveToLastColumnToolStripMenuItem + // + moveToLastColumnToolStripMenuItem.Name = "moveToLastColumnToolStripMenuItem"; + moveToLastColumnToolStripMenuItem.Size = new Size(229, 22); + moveToLastColumnToolStripMenuItem.Text = "Move to last column"; + moveToLastColumnToolStripMenuItem.ToolTipText = "Move this column to the last position"; + moveToLastColumnToolStripMenuItem.Click += OnMoveToLastColumnToolStripMenuItemClick; + // + // moveLeftToolStripMenuItem + // + moveLeftToolStripMenuItem.Name = "moveLeftToolStripMenuItem"; + moveLeftToolStripMenuItem.Size = new Size(229, 22); + moveLeftToolStripMenuItem.Text = "Move left"; + moveLeftToolStripMenuItem.Click += OnMoveLeftToolStripMenuItemClick; + // + // moveRightToolStripMenuItem + // + moveRightToolStripMenuItem.Name = "moveRightToolStripMenuItem"; + moveRightToolStripMenuItem.Size = new Size(229, 22); + moveRightToolStripMenuItem.Text = "Move right"; + moveRightToolStripMenuItem.Click += OnMoveRightToolStripMenuItemClick; + // + // menuToolStripSeparator5 + // + menuToolStripSeparator5.Name = "menuToolStripSeparator5"; + menuToolStripSeparator5.Size = new Size(226, 6); + // + // hideColumnToolStripMenuItem + // + hideColumnToolStripMenuItem.Name = "hideColumnToolStripMenuItem"; + hideColumnToolStripMenuItem.Size = new Size(229, 22); + hideColumnToolStripMenuItem.Text = "Hide column"; + hideColumnToolStripMenuItem.ToolTipText = "Hide this column"; + hideColumnToolStripMenuItem.Click += OnHideColumnToolStripMenuItemClick; + // + // restoreColumnsToolStripMenuItem + // + restoreColumnsToolStripMenuItem.Name = "restoreColumnsToolStripMenuItem"; + restoreColumnsToolStripMenuItem.Size = new Size(229, 22); + restoreColumnsToolStripMenuItem.Text = "Restore columns"; + restoreColumnsToolStripMenuItem.Click += OnRestoreColumnsToolStripMenuItemClick; + // + // menuToolStripSeparator6 + // + menuToolStripSeparator6.Name = "menuToolStripSeparator6"; + menuToolStripSeparator6.Size = new Size(226, 6); + // + // allColumnsToolStripMenuItem + // + allColumnsToolStripMenuItem.Name = "allColumnsToolStripMenuItem"; + allColumnsToolStripMenuItem.Size = new Size(229, 22); + allColumnsToolStripMenuItem.Text = "Scroll to column..."; + // + // editModeContextMenuStrip + // + editModeContextMenuStrip.ImageScalingSize = new Size(24, 24); + editModeContextMenuStrip.Items.AddRange(new ToolStripItem[] { editModecopyToolStripMenuItem, highlightSelectionInLogFileToolStripMenuItem, highlightSelectionInLogFilewordModeToolStripMenuItem, filterForSelectionToolStripMenuItem, setSelectedTextAsBookmarkCommentToolStripMenuItem }); + editModeContextMenuStrip.Name = "editModeContextMenuStrip"; + editModeContextMenuStrip.Size = new Size(344, 114); + // + // editModecopyToolStripMenuItem + // + editModecopyToolStripMenuItem.Name = "editModecopyToolStripMenuItem"; + editModecopyToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C; + editModecopyToolStripMenuItem.Size = new Size(343, 22); + editModecopyToolStripMenuItem.Text = "Copy"; + editModecopyToolStripMenuItem.Click += OnEditModeCopyToolStripMenuItemClick; + // + // highlightSelectionInLogFileToolStripMenuItem + // + highlightSelectionInLogFileToolStripMenuItem.Name = "highlightSelectionInLogFileToolStripMenuItem"; + highlightSelectionInLogFileToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.H; + highlightSelectionInLogFileToolStripMenuItem.Size = new Size(343, 22); + highlightSelectionInLogFileToolStripMenuItem.Text = "Highlight selection in log file (full line)"; + highlightSelectionInLogFileToolStripMenuItem.Click += OnHighlightSelectionInLogFileToolStripMenuItemClick; + // + // highlightSelectionInLogFilewordModeToolStripMenuItem + // + highlightSelectionInLogFilewordModeToolStripMenuItem.Name = "highlightSelectionInLogFilewordModeToolStripMenuItem"; + highlightSelectionInLogFilewordModeToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W; + highlightSelectionInLogFilewordModeToolStripMenuItem.Size = new Size(343, 22); + highlightSelectionInLogFilewordModeToolStripMenuItem.Text = "Highlight selection in log file (word mode)"; + highlightSelectionInLogFilewordModeToolStripMenuItem.Click += OnHighlightSelectionInLogFilewordModeToolStripMenuItemClick; + // + // filterForSelectionToolStripMenuItem + // + filterForSelectionToolStripMenuItem.Name = "filterForSelectionToolStripMenuItem"; + filterForSelectionToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.F; + filterForSelectionToolStripMenuItem.Size = new Size(343, 22); + filterForSelectionToolStripMenuItem.Text = "Filter for selection"; + filterForSelectionToolStripMenuItem.Click += OnFilterForSelectionToolStripMenuItemClick; + // + // setSelectedTextAsBookmarkCommentToolStripMenuItem + // + setSelectedTextAsBookmarkCommentToolStripMenuItem.Name = "setSelectedTextAsBookmarkCommentToolStripMenuItem"; + setSelectedTextAsBookmarkCommentToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.B; + setSelectedTextAsBookmarkCommentToolStripMenuItem.Size = new Size(343, 22); + setSelectedTextAsBookmarkCommentToolStripMenuItem.Text = "Set selected text as bookmark comment"; + setSelectedTextAsBookmarkCommentToolStripMenuItem.Click += OnSetSelectedTextAsBookmarkCommentToolStripMenuItemClick; + // + // LogWindow + // + ClientSize = new Size(1862, 1104); + ControlBox = false; + Controls.Add(splitContainerLogWindow); + Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); + FormBorderStyle = FormBorderStyle.None; + Icon = (Icon)resources.GetObject("$this.Icon"); + Margin = new Padding(0); + MaximizeBox = false; + MinimizeBox = false; + Name = "LogWindow"; + ShowIcon = false; + ShowInTaskbar = false; + SizeGripStyle = SizeGripStyle.Hide; + SizeChanged += OnLogWindowSizeChanged; + Enter += OnLogWindowEnter; + KeyDown += OnLogWindowKeyDown; + Leave += OnLogWindowLeave; + splitContainerLogWindow.Panel1.ResumeLayout(false); + splitContainerLogWindow.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)splitContainerLogWindow).EndInit(); + splitContainerLogWindow.ResumeLayout(false); + tableLayoutPanel1.ResumeLayout(false); + columnFinderPanel.ResumeLayout(false); + columnFinderPanel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + dataGridContextMenuStrip.ResumeLayout(false); + advancedBackPanel.ResumeLayout(false); + advancedFilterSplitContainer.Panel1.ResumeLayout(false); + advancedFilterSplitContainer.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)advancedFilterSplitContainer).EndInit(); + advancedFilterSplitContainer.ResumeLayout(false); + pnlProFilter.ResumeLayout(false); + pnlProFilter.PerformLayout(); + panelBackgroundAdvancedFilterSplitContainer.ResumeLayout(false); + highlightSplitContainer.Panel1.ResumeLayout(false); + highlightSplitContainer.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)highlightSplitContainer).EndInit(); + highlightSplitContainer.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)filterGridView).EndInit(); + filterContextMenuStrip.ResumeLayout(false); + highlightSplitContainerBackPanel.ResumeLayout(false); + highlightSplitContainerBackPanel.PerformLayout(); + filterListContextMenuStrip.ResumeLayout(false); + pnlFilterInput.ResumeLayout(false); + filterSplitContainer.Panel1.ResumeLayout(false); + filterSplitContainer.Panel1.PerformLayout(); + filterSplitContainer.Panel2.ResumeLayout(false); + filterSplitContainer.Panel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)filterSplitContainer).EndInit(); + filterSplitContainer.ResumeLayout(false); + bookmarkContextMenuStrip.ResumeLayout(false); + columnContextMenuStrip.ResumeLayout(false); + editModeContextMenuStrip.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.SplitContainer splitContainerLogWindow; + private System.Windows.Forms.Panel pnlFilterInput; + private BufferedDataGridView dataGridView; + private BufferedDataGridView filterGridView; + private System.Windows.Forms.SplitContainer advancedFilterSplitContainer; + private System.Windows.Forms.Panel pnlProFilter; + private System.Windows.Forms.Button btnFilterToTab; + private KnobControl filterKnobForeSpread; + private System.Windows.Forms.Label lblForeSpread; + private KnobControl filterKnobBackSpread; + private System.Windows.Forms.Label lblBackSpread; + private System.Windows.Forms.Panel pnlProFilterLabel; + private System.Windows.Forms.CheckBox invertFilterCheckBox; + private System.Windows.Forms.Label fuzzyLabel; + private KnobControl fuzzyKnobControl; + private System.Windows.Forms.CheckBox rangeCheckBox; + private System.Windows.Forms.ComboBox filterRangeComboBox; + private System.Windows.Forms.ContextMenuStrip dataGridContextMenuStrip; + private System.Windows.Forms.ToolStripMenuItem copyToTabToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem scrollAllTabsToTimestampToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem locateLineInOriginalFileToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toggleBoomarkToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem markEditModeToolStripMenuItem; + private System.Windows.Forms.ContextMenuStrip bookmarkContextMenuStrip; + private System.Windows.Forms.ToolStripMenuItem deleteBookmarksToolStripMenuItem; + private System.Windows.Forms.CheckBox columnRestrictCheckBox; + private System.Windows.Forms.Button columnButton; + private System.Windows.Forms.ContextMenuStrip columnContextMenuStrip; + private System.Windows.Forms.ToolStripMenuItem freezeLeftColumnsUntilHereToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem moveToLastColumnToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem moveLeftToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem moveRightToolStripMenuItem; + private TimeSpreadingControl timeSpreadingControl; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.ToolStripMenuItem bookmarkCommentToolStripMenuItem; + private System.Windows.Forms.ContextMenuStrip editModeContextMenuStrip; + private System.Windows.Forms.ToolStripMenuItem highlightSelectionInLogFileToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem editModecopyToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem tempHighlightsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem removeAllToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem makePermanentToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem filterForSelectionToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem setSelectedTextAsBookmarkCommentToolStripMenuItem; + private System.Windows.Forms.ToolTip helpToolTip; + private System.Windows.Forms.SplitContainer highlightSplitContainer; + private System.Windows.Forms.Button btnToggleHighlightPanel; + private System.Windows.Forms.Panel highlightSplitContainerBackPanel; + private System.Windows.Forms.Button saveFilterButton; + private System.Windows.Forms.Button deleteFilterButton; + private System.Windows.Forms.ListBox filterListBox; + private System.Windows.Forms.ContextMenuStrip filterContextMenuStrip; + private System.Windows.Forms.ToolStripMenuItem setBookmarksOnSelectedLinesToolStripMenuItem; + private System.Windows.Forms.CheckBox filterOnLoadCheckBox; + private System.Windows.Forms.ToolStripMenuItem markCurrentFilterRangeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem syncTimestampsToToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem freeThisWindowFromTimeSyncToolStripMenuItem; + private System.Windows.Forms.Button filterDownButton; + private System.Windows.Forms.Button filterUpButton; + private System.Windows.Forms.ContextMenuStrip filterListContextMenuStrip; + private System.Windows.Forms.ToolStripMenuItem colorToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem filterToTabToolStripMenuItem; + private System.Windows.Forms.CheckBox hideFilterListOnLoadCheckBox; + private System.Windows.Forms.Panel advancedBackPanel; + private System.Windows.Forms.ToolStripMenuItem markFilterHitsInLogViewToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem highlightSelectionInLogFilewordModeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem hideColumnToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem restoreColumnsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem allColumnsToolStripMenuItem; + private System.Windows.Forms.Label columnNamesLabel; + private System.Windows.Forms.Panel columnFinderPanel; + private System.Windows.Forms.ComboBox columnComboBox; + private System.Windows.Forms.Label lblColumnName; + private System.Windows.Forms.SplitContainer filterSplitContainer; + private System.Windows.Forms.Label lblTextFilter; + private System.Windows.Forms.ComboBox filterComboBox; + private System.Windows.Forms.Button advancedButton; + private System.Windows.Forms.CheckBox syncFilterCheckBox; + private System.Windows.Forms.Label lblFilterCount; + private System.Windows.Forms.CheckBox filterTailCheckBox; + private System.Windows.Forms.CheckBox filterRegexCheckBox; + private System.Windows.Forms.CheckBox filterCaseSensitiveCheckBox; + private System.Windows.Forms.Button filterSearchButton; + private System.Windows.Forms.Panel panelBackgroundAdvancedFilterSplitContainer; + private MenuToolStripSeparatorExtension pluginSeparator; + private MenuToolStripSeparatorExtension menuToolStripSeparator1; + private MenuToolStripSeparatorExtension menuToolStripSeparator2; + private MenuToolStripSeparatorExtension menuToolStripSeparator3; + private MenuToolStripSeparatorExtension menuToolStripSeparator4; + private MenuToolStripSeparatorExtension menuToolStripSeparator5; + private MenuToolStripSeparatorExtension menuToolStripSeparator6; + } +} diff --git a/src/LogExpert/Controls/LogWindow/LogWindow.resx b/src/Logexpert.UI/Controls/LogWindow/LogWindow.resx similarity index 98% rename from src/LogExpert/Controls/LogWindow/LogWindow.resx rename to src/Logexpert.UI/Controls/LogWindow/LogWindow.resx index df7aeccf..dd8f0ebb 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindow.resx +++ b/src/Logexpert.UI/Controls/LogWindow/LogWindow.resx @@ -1,173 +1,173 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 27 - - - 11, 68 - - - 17, 27 - - - 862, 21 - - - - - iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO - vAAADrwBlbxySQAAAM1JREFUOE/dlDsKQkEMRYO1jZU7EAS3YG1h51ZsdSdWIoLrcBla2dhZ2PvhPiYQ - rplMsLDwwBS5n8C8gSfyT0xF5EVnwqEsF1q0FZE9aRsuRWgpopfMdaSDhWb+3ApUQGfBovLNQjCudfWV - syB7o/mD5rcxeFnMV9I6cceig7ewqkM40MwhT1NczxOt5vkWeEcWR5WSLvM8S9WH0WcxKhSWUWYdmQHo - DFi0ZK5qQfbBoocunrFhWJXMk42IOT2Sd4ZcyoJf3N0sOnHgJ7wBih1ZgqnoK8MAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO - vAAADrwBlbxySQAAAM1JREFUOE/dlDsKQkEMRYO1jZU7EAS3YG1h51ZsdSdWIoLrcBla2dhZ2PvhPiYQ - rplMsLDwwBS5n8C8gSfyT0xF5EVnwqEsF1q0FZE9aRsuRWgpopfMdaSDhWb+3ApUQGfBovLNQjCudfWV - syB7o/mD5rcxeFnMV9I6cceig7ewqkM40MwhT1NczxOt5vkWeEcWR5WSLvM8S9WH0WcxKhSWUWYdmQHo - DFi0ZK5qQfbBoocunrFhWJXMk42IOT2Sd4ZcyoJf3N0sOnHgJ7wBih1ZgqnoK8MAAAAASUVORK5CYII= - - - - 261, 21 - - - 467, 21 - - - 658, 21 - - - 70 - - - - AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA - AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// - AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// - //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA - AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAIABAAD//wAA - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 27 + + + 11, 68 + + + 17, 27 + + + 862, 21 + + + + + iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + vAAADrwBlbxySQAAAM1JREFUOE/dlDsKQkEMRYO1jZU7EAS3YG1h51ZsdSdWIoLrcBla2dhZ2PvhPiYQ + rplMsLDwwBS5n8C8gSfyT0xF5EVnwqEsF1q0FZE9aRsuRWgpopfMdaSDhWb+3ApUQGfBovLNQjCudfWV + syB7o/mD5rcxeFnMV9I6cceig7ewqkM40MwhT1NczxOt5vkWeEcWR5WSLvM8S9WH0WcxKhSWUWYdmQHo + DFi0ZK5qQfbBoocunrFhWJXMk42IOT2Sd4ZcyoJf3N0sOnHgJ7wBih1ZgqnoK8MAAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + vAAADrwBlbxySQAAAM1JREFUOE/dlDsKQkEMRYO1jZU7EAS3YG1h51ZsdSdWIoLrcBla2dhZ2PvhPiYQ + rplMsLDwwBS5n8C8gSfyT0xF5EVnwqEsF1q0FZE9aRsuRWgpopfMdaSDhWb+3ApUQGfBovLNQjCudfWV + syB7o/mD5rcxeFnMV9I6cceig7ewqkM40MwhT1NczxOt5vkWeEcWR5WSLvM8S9WH0WcxKhSWUWYdmQHo + DFi0ZK5qQfbBoocunrFhWJXMk42IOT2Sd4ZcyoJf3N0sOnHgJ7wBih1ZgqnoK8MAAAAASUVORK5CYII= + + + + 261, 21 + + + 467, 21 + + + 658, 21 + + + 70 + + + + AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// + //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA + AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAIABAAD//wAA + + \ No newline at end of file diff --git a/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs b/src/Logexpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs similarity index 96% rename from src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs rename to src/Logexpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs index 78d8da1b..5a4f2034 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/Logexpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs @@ -1,1647 +1,1634 @@ -#region - -using LogExpert.Classes; -using LogExpert.Classes.Filter; -using LogExpert.Classes.ILogLineColumnizerCallback; -using LogExpert.Config; -using LogExpert.Core.Classes; -using LogExpert.Core.Classes.Filter; -using LogExpert.Core.Classes.Highlight; -using LogExpert.Core.Config; -using LogExpert.Core.Entities; -using LogExpert.Core.EventArgs; -using LogExpert.Core.Interface; -using LogExpert.Dialogs; -using LogExpert.Entities; -using LogExpert.Entities.EventArgs; -using LogExpert.UI.Dialogs; -using LogExpert.UI.Extensions; - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Windows.Forms; - -#endregion - -namespace LogExpert.Controls.LogWindow -{ - public partial class LogWindow - { - private void AutoResizeFilterBox() - { - filterSplitContainer.SplitterDistance = filterComboBox.Left + filterComboBox.GetMaxTextWidth(); - } - - #region Events handler - - protected void OnProgressBarUpdate(ProgressEventArgs e) - { - ProgressBarUpdate?.Invoke(this, e); - } - - protected void OnStatusLine(StatusLineEventArgs e) - { - StatusLineEvent?.Invoke(this, e); - } - - protected void OnGuiState(GuiStateArgs e) - { - GuiStateUpdate?.Invoke(this, e); - } - - protected void OnTailFollowed(EventArgs e) - { - TailFollowed?.Invoke(this, e); - } - - protected void OnFileNotFound(EventArgs e) - { - FileNotFound?.Invoke(this, e); - } - - protected void OnFileRespawned(EventArgs e) - { - FileRespawned?.Invoke(this, e); - } - - protected void OnFilterListChanged(LogWindow source) - { - FilterListChanged?.Invoke(this, new FilterListChangedEventArgs(source)); - } - - protected void OnCurrentHighlightListChanged() - { - CurrentHighlightGroupChanged?.Invoke(this, new CurrentHighlightGroupChangedEventArgs(this, _currentHighlightGroup)); - } - - protected void OnBookmarkAdded() - { - BookmarkAdded?.Invoke(this, EventArgs.Empty); - } - - protected void OnBookmarkRemoved() - { - BookmarkRemoved?.Invoke(this, EventArgs.Empty); - } - - protected void OnBookmarkTextChanged(Bookmark bookmark) - { - BookmarkTextChanged?.Invoke(this, new BookmarkEventArgs(bookmark)); - } - - protected void OnColumnizerChanged(ILogLineColumnizer columnizer) - { - ColumnizerChanged?.Invoke(this, new ColumnizerEventArgs(columnizer)); - } - - protected void OnRegisterCancelHandler(BackgroundProcessCancelHandler handler) - { - lock (_cancelHandlerList) - { - _cancelHandlerList.Add(handler); - } - } - - protected void OnDeRegisterCancelHandler(BackgroundProcessCancelHandler handler) - { - lock (_cancelHandlerList) - { - _cancelHandlerList.Remove(handler); - } - } - - private void OnLogWindowLoad(object sender, EventArgs e) - { - PreferencesChanged(_parentLogTabWin.Preferences, true, SettingsFlags.GuiOrColors); - } - - private void OnLogWindowDisposed(object sender, EventArgs e) - { - _waitingForClose = true; - _parentLogTabWin.HighlightSettingsChanged -= OnParentHighlightSettingsChanged; - _logFileReader?.DeleteAllContent(); - - FreeFromTimeSync(); - } - - private void OnLogFileReaderLoadingStarted(object sender, LoadFileEventArgs e) - { - Invoke(LoadingStarted, e); - } - - private void OnLogFileReaderFinishedLoading(object sender, EventArgs e) - { - //Thread.CurrentThread.Name = "FinishedLoading event thread"; - _logger.Info("Finished loading."); - _isLoading = false; - _isDeadFile = false; - if (!_waitingForClose) - { - Invoke(new MethodInvoker(LoadingFinished)); - Invoke(new MethodInvoker(LoadPersistenceData)); - Invoke(new MethodInvoker(SetGuiAfterLoading)); - _loadingFinishedEvent.Set(); - _externaLoadingFinishedEvent.Set(); - _timeSpreadCalc.SetLineCount(_logFileReader.LineCount); - - if (_reloadMemento != null) - { - Invoke(new PositionAfterReloadFx(PositionAfterReload), _reloadMemento); - } - - if (filterTailCheckBox.Checked) - { - _logger.Info("Refreshing filter view because of reload."); - Invoke(new MethodInvoker(FilterSearch)); // call on proper thread - } - - HandleChangedFilterList(); - } - - _reloadMemento = null; - } - - private void OnLogFileReaderFileNotFound(object sender, EventArgs e) - { - if (!IsDisposed && !Disposing) - { - _logger.Info("Handling file not found event."); - _isDeadFile = true; - BeginInvoke(new MethodInvoker(LogfileDead)); - } - } - - private void OnLogFileReaderRespawned(object sender, EventArgs e) - { - BeginInvoke(new MethodInvoker(LogfileRespawned)); - } - - private void OnLogWindowClosing(object sender, CancelEventArgs e) - { - if (Preferences.askForClose) - { - if (MessageBox.Show("Sure to close?", "LogExpert", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) - { - e.Cancel = true; - return; - } - } - - SavePersistenceData(false); - CloseLogWindow(); - } - - private void OnDataGridViewColumnDividerDoubleClick(object sender, DataGridViewColumnDividerDoubleClickEventArgs e) - { - e.Handled = true; - AutoResizeColumns(dataGridView); - } - - /** - * Event handler for the Load event from LogfileReader - */ - private void OnLogFileReaderLoadFile(object sender, LoadFileEventArgs e) - { - if (e.NewFile) - { - _logger.Info("File created anew."); - - // File was new created (e.g. rollover) - _isDeadFile = false; - UnRegisterLogFileReaderEvents(); - dataGridView.CurrentCellChanged -= OnDataGridViewCurrentCellChanged; - MethodInvoker invoker = ReloadNewFile; - BeginInvoke(invoker); - //Thread loadThread = new Thread(new ThreadStart(ReloadNewFile)); - //loadThread.Start(); - _logger.Debug("Reloading invoked."); - } - else if (_isLoading) - { - BeginInvoke(UpdateProgress, e); - } - } - - private void OnFileSizeChanged(object sender, LogEventArgs e) - { - //OnFileSizeChanged(e); // now done in UpdateGrid() - _logger.Info("Got FileSizeChanged event. prevLines:{0}, curr lines: {1}", e.PrevLineCount, e.LineCount); - - // - now done in the thread that works on the event args list - //if (e.IsRollover) - //{ - // ShiftBookmarks(e.RolloverOffset); - // ShiftFilterPipes(e.RolloverOffset); - //} - - //UpdateGridCallback callback = new UpdateGridCallback(UpdateGrid); - //this.BeginInvoke(callback, new object[] { e }); - lock (_logEventArgsList) - { - _logEventArgsList.Add(e); - _logEventArgsEvent.Set(); - } - } - - private void OnDataGridViewCellValueNeeded(object sender, DataGridViewCellValueEventArgs e) - { - int startCount = CurrentColumnizer?.GetColumnCount() ?? 0; - - e.Value = GetCellValue(e.RowIndex, e.ColumnIndex); - - // The new column could be find dynamically. - // Only support add new columns for now. - // TODO: Support reload all columns? - if (CurrentColumnizer != null && CurrentColumnizer.GetColumnCount() > startCount) - { - for (int i = startCount; i < CurrentColumnizer.GetColumnCount(); i++) - { - var colName = CurrentColumnizer.GetColumnNames()[i]; - dataGridView.Columns.Add(PaintHelper.CreateTitleColumn(colName)); - } - } - } - - private void OnDataGridViewCellValuePushed(object sender, DataGridViewCellValueEventArgs e) - { - if (!CurrentColumnizer.IsTimeshiftImplemented()) - { - return; - } - - ILogLine line = _logFileReader.GetLogLine(e.RowIndex); - int offset = CurrentColumnizer.GetTimeOffset(); - CurrentColumnizer.SetTimeOffset(0); - ColumnizerCallbackObject.LineNum = e.RowIndex; - IColumnizedLogLine cols = CurrentColumnizer.SplitLine(ColumnizerCallbackObject, line); - CurrentColumnizer.SetTimeOffset(offset); - if (cols.ColumnValues.Length <= e.ColumnIndex - 2) - { - return; - } - - string oldValue = cols.ColumnValues[e.ColumnIndex - 2].FullValue; - string newValue = (string)e.Value; - //string oldValue = (string) this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; - CurrentColumnizer.PushValue(ColumnizerCallbackObject, e.ColumnIndex - 2, newValue, oldValue); - dataGridView.Refresh(); - TimeSpan timeSpan = new(CurrentColumnizer.GetTimeOffset() * TimeSpan.TicksPerMillisecond); - string span = timeSpan.ToString(); - int index = span.LastIndexOf('.'); - if (index > 0) - { - span = span.Substring(0, index + 4); - } - - SetTimeshiftValue(span); - SendGuiStateUpdate(); - } - - private void OnDataGridViewRowHeightInfoNeeded(object sender, DataGridViewRowHeightInfoNeededEventArgs e) - { - e.Height = GetRowHeight(e.RowIndex); - } - - private void OnDataGridViewCurrentCellChanged(object sender, EventArgs e) - { - if (dataGridView.CurrentRow != null) - { - _statusEventArgs.CurrentLineNum = dataGridView.CurrentRow.Index + 1; - SendStatusLineUpdate(); - if (syncFilterCheckBox.Checked) - { - SyncFilterGridPos(); - } - - if (CurrentColumnizer.IsTimeshiftImplemented() && Preferences.timestampControl) - { - SyncTimestampDisplay(); - } - - //MethodInvoker invoker = new MethodInvoker(DisplayCurrentFileOnStatusline); - //invoker.BeginInvoke(null, null); - } - } - - private void OnDataGridViewCellEndEdit(object sender, DataGridViewCellEventArgs e) - { - StatusLineText(string.Empty); - } - - private void OnEditControlKeyUp(object sender, KeyEventArgs e) - { - UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); - } - - private void OnEditControlKeyPress(object sender, KeyPressEventArgs e) - { - UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); - } - - private void OnEditControlClick(object sender, EventArgs e) - { - UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); - } - - private void OnEditControlKeyDown(object sender, KeyEventArgs e) - { - UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); - } - - private void OnDataGridViewPaint(object sender, PaintEventArgs e) - { - if (ShowBookmarkBubbles) - { - AddBookmarkOverlays(); - } - } - - // ====================================================================================== - // Filter Grid stuff - // ====================================================================================== - - private void OnFilterSearchButtonClick(object sender, EventArgs e) - { - FilterSearch(); - } - - private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintingEventArgs e) - { - BufferedDataGridView gridView = (BufferedDataGridView)sender; - - if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) - { - e.Handled = false; - return; - } - - int lineNum = _filterResultList[e.RowIndex]; - ILogLine line = _logFileReader.GetLogLineWithWait(lineNum).Result; - - if (line != null) - { - HighlightEntry entry = FindFirstNoWordMatchHilightEntry(line); - e.Graphics.SetClip(e.CellBounds); - if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) - { - Brush brush; - if (gridView.Focused) - { - brush = new SolidBrush(e.CellStyle.SelectionBackColor); - } - else - { - Color color = Color.FromArgb(255, 170, 170, 170); - brush = new SolidBrush(color); - } - - e.Graphics.FillRectangle(brush, e.CellBounds); - brush.Dispose(); - } - else - { - Color bgColor = Color.White; - // paint direct filter hits with different bg color - //if (this.filterParams.SpreadEnabled && this.filterHitList.Contains(lineNum)) - //{ - // bgColor = Color.FromArgb(255, 220, 220, 220); - //} - if (!DebugOptions.DisableWordHighlight) - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - else - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - - e.CellStyle.BackColor = bgColor; - e.PaintBackground(e.ClipBounds, false); - } - - if (DebugOptions.DisableWordHighlight) - { - e.PaintContent(e.CellBounds); - } - else - { - PaintCell(e, filterGridView, false, entry); - } - - if (e.ColumnIndex == 0) - { - if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - Rectangle r = new(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); - r = e.CellBounds; - r.Inflate(-2, -2); - Brush brush = new SolidBrush(BookmarkColor); - e.Graphics.FillRectangle(brush, r); - brush.Dispose(); - - Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); - - if (bookmark.Text.Length > 0) - { - StringFormat format = new() - { - LineAlignment = StringAlignment.Center, - Alignment = StringAlignment.Center - }; - - Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); - Font font = new("Verdana", Preferences.fontSize, FontStyle.Bold); - e.Graphics.DrawString("!", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); - font.Dispose(); - brush2.Dispose(); - } - } - } - - e.Paint(e.CellBounds, DataGridViewPaintParts.Border); - e.Handled = true; - } - } - - private void OnFilterGridViewCellValueNeeded(object sender, DataGridViewCellValueEventArgs e) - { - if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) - { - e.Value = ""; - return; - } - - int lineNum = _filterResultList[e.RowIndex]; - e.Value = GetCellValue(lineNum, e.ColumnIndex); - } - - private void OnFilterGridViewRowHeightInfoNeeded(object sender, DataGridViewRowHeightInfoNeededEventArgs e) - { - e.Height = _lineHeight; - } - - private void OnFilterComboBoxKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - FilterSearch(); - } - } - - private void OnFilterGridViewColumnDividerDoubleClick(object sender, - DataGridViewColumnDividerDoubleClickEventArgs e) - { - e.Handled = true; - AutoResizeColumnsFx fx = AutoResizeColumns; - BeginInvoke(fx, filterGridView); - } - - private void OnFilterGridViewCellDoubleClick(object sender, DataGridViewCellEventArgs e) - { - if (e.ColumnIndex == 0) - { - ToggleBookmark(); - return; - } - - if (filterGridView.CurrentRow != null && e.RowIndex >= 0) - { - int lineNum = _filterResultList[filterGridView.CurrentRow.Index]; - SelectAndEnsureVisible(lineNum, true); - } - } - - private void OnRangeCheckBoxCheckedChanged(object sender, EventArgs e) - { - filterRangeComboBox.Enabled = rangeCheckBox.Checked; - CheckForFilterDirty(); - } - - private void OnDataGridViewScroll(object sender, ScrollEventArgs e) - { - if (e.ScrollOrientation == ScrollOrientation.VerticalScroll) - { - if (dataGridView.DisplayedRowCount(false) + dataGridView.FirstDisplayedScrollingRowIndex >= dataGridView.RowCount) - { - //this.guiStateArgs.FollowTail = true; - if (!_guiStateArgs.FollowTail) - { - FollowTailChanged(true, false); - } - - OnTailFollowed(EventArgs.Empty); - } - else - { - //this.guiStateArgs.FollowTail = false; - if (_guiStateArgs.FollowTail) - { - FollowTailChanged(false, false); - } - } - - SendGuiStateUpdate(); - } - } - - private void OnFilterGridViewKeyDown(object sender, KeyEventArgs e) - { - switch (e.KeyCode) - { - case Keys.Enter: - { - if (filterGridView.CurrentCellAddress.Y >= 0 && filterGridView.CurrentCellAddress.Y < _filterResultList.Count) - { - int lineNum = _filterResultList[filterGridView.CurrentCellAddress.Y]; - SelectLine(lineNum, false, true); - e.Handled = true; - } - - break; - } - case Keys.Tab when e.Modifiers == Keys.None: - dataGridView.Focus(); - e.Handled = true; - break; - } - } - - private void OnDataGridViewKeyDown(object sender, KeyEventArgs e) - { - switch (e.KeyCode) - { - case Keys.Tab when e.Modifiers == Keys.None: - { - filterGridView.Focus(); - e.Handled = true; - break; - } - } - - //switch (e.KeyCode) - //{ - // case Keys.Tab when e.Modifiers == Keys.Control: - // //this.parentLogTabWin.SwitchTab(e.Shift); - // break; - //} - - _shouldCallTimeSync = true; - } - - private void OnDataGridViewPreviewKeyDown(object sender, PreviewKeyDownEventArgs e) - { - if (e.KeyCode == Keys.Tab && e.Control) - { - e.IsInputKey = true; - } - } - - private void OnDataGridViewCellContentDoubleClick(object sender, DataGridViewCellEventArgs e) - { - if (dataGridView.CurrentCell != null) - { - dataGridView.BeginEdit(false); - } - } - - private void OnSyncFilterCheckBoxCheckedChanged(object sender, EventArgs e) - { - if (syncFilterCheckBox.Checked) - { - SyncFilterGridPos(); - } - } - - private void OnDataGridViewLeave(object sender, EventArgs e) - { - InvalidateCurrentRow(dataGridView); - } - - private void OnDataGridViewEnter(object sender, EventArgs e) - { - InvalidateCurrentRow(dataGridView); - } - - private void OnFilterGridViewEnter(object sender, EventArgs e) - { - InvalidateCurrentRow(filterGridView); - } - - private void OnFilterGridViewLeave(object sender, EventArgs e) - { - InvalidateCurrentRow(filterGridView); - } - - private void OnDataGridViewResize(object sender, EventArgs e) - { - if (_logFileReader != null && dataGridView.RowCount > 0 && _guiStateArgs.FollowTail) - { - dataGridView.FirstDisplayedScrollingRowIndex = dataGridView.RowCount - 1; - } - } - - private void OnDataGridViewSelectionChanged(object sender, EventArgs e) - { - UpdateSelectionDisplay(); - } - - private void OnSelectionChangedTriggerSignal(object sender, EventArgs e) - { - int selCount = 0; - try - { - _logger.Debug("Selection changed trigger"); - selCount = dataGridView.SelectedRows.Count; - if (selCount > 1) - { - StatusLineText(selCount + " selected lines"); - } - else - { - if (IsMultiFile) - { - MethodInvoker invoker = DisplayCurrentFileOnStatusline; - invoker.BeginInvoke(null, null); - } - else - { - StatusLineText(""); - } - } - } - catch (Exception ex) - { - _logger.Error(ex, "Error in selectionChangedTrigger_Signal selcount {0}", selCount); - } - } - - private void OnFilterKnobControlValueChanged(object sender, EventArgs e) - { - CheckForFilterDirty(); - } - - private void OnFilterToTabButtonClick(object sender, EventArgs e) - { - FilterToTab(); - } - - private void OnPipeDisconnected(object sender, EventArgs e) - { - if (sender.GetType() == typeof(FilterPipe)) - { - lock (_filterPipeList) - { - _filterPipeList.Remove((FilterPipe)sender); - if (_filterPipeList.Count == 0) - // reset naming counter to 0 if no more open filter tabs for this source window - { - _filterPipeNameCounter = 0; - } - } - } - } - - private void OnAdvancedButtonClick(object sender, EventArgs e) - { - _showAdvanced = !_showAdvanced; - ShowAdvancedFilterPanel(_showAdvanced); - } - - private void OnFilterSplitContainerMouseDown(object sender, MouseEventArgs e) - { - ((SplitContainer)sender).IsSplitterFixed = true; - } - - private void OnFilterSplitContainerMouseUp(object sender, MouseEventArgs e) - { - ((SplitContainer)sender).IsSplitterFixed = false; - } - - private void OnFilterSplitContainerMouseMove(object sender, MouseEventArgs e) - { - SplitContainer splitContainer = (SplitContainer)sender; - if (splitContainer.IsSplitterFixed) - { - if (e.Button.Equals(MouseButtons.Left)) - { - if (splitContainer.Orientation.Equals(Orientation.Vertical)) - { - if (e.X > 0 && e.X < splitContainer.Width) - { - splitContainer.SplitterDistance = e.X; - splitContainer.Refresh(); - } - } - else - { - if (e.Y > 0 && e.Y < splitContainer.Height) - { - splitContainer.SplitterDistance = e.Y; - splitContainer.Refresh(); - } - } - } - else - { - splitContainer.IsSplitterFixed = false; - } - } - } - - private void OnFilterSplitContainerMouseDoubleClick(object sender, MouseEventArgs e) - { - AutoResizeFilterBox(); - } - - #region Context Menu - - private void OnDataGridContextMenuStripOpening(object sender, CancelEventArgs e) - { - int lineNum = -1; - if (dataGridView.CurrentRow != null) - { - lineNum = dataGridView.CurrentRow.Index; - } - - if (lineNum == -1) - { - return; - } - - int refLineNum = lineNum; - - copyToTabToolStripMenuItem.Enabled = dataGridView.SelectedCells.Count > 0; - scrollAllTabsToTimestampToolStripMenuItem.Enabled = CurrentColumnizer.IsTimeshiftImplemented() - && - GetTimestampForLine(ref refLineNum, false) != - DateTime.MinValue; - - locateLineInOriginalFileToolStripMenuItem.Enabled = IsTempFile && - FilterPipe != null && - FilterPipe.GetOriginalLineNum(lineNum) != -1; - - markEditModeToolStripMenuItem.Enabled = !dataGridView.CurrentCell.ReadOnly; - - // Remove all "old" plugin entries - int index = dataGridContextMenuStrip.Items.IndexOf(pluginSeparator); - - if (index > 0) - { - for (int i = index + 1; i < dataGridContextMenuStrip.Items.Count;) - { - dataGridContextMenuStrip.Items.RemoveAt(i); - } - } - - // Add plugin entries - bool isAdded = false; - if (PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins.Count > 0) - { - IList lines = GetSelectedContent(); - foreach (IContextMenuEntry entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins) - { - LogExpertCallback callback = new(this); - string menuText = entry.GetMenuText(lines.Count, CurrentColumnizer, callback.GetLogLine(lines[0])); - - if (menuText != null) - { - bool disabled = menuText.StartsWith('_'); - if (disabled) - { - menuText = menuText[1..]; - } - - ToolStripItem item = dataGridContextMenuStrip.Items.Add(menuText, null, OnHandlePluginContextMenu); - item.Tag = new ContextMenuPluginEventArgs(entry, lines, CurrentColumnizer, callback); - item.Enabled = !disabled; - isAdded = true; - } - } - } - - pluginSeparator.Visible = isAdded; - - // enable/disable Temp Highlight item - tempHighlightsToolStripMenuItem.Enabled = _tempHighlightEntryList.Count > 0; - - markCurrentFilterRangeToolStripMenuItem.Enabled = string.IsNullOrEmpty(filterRangeComboBox.Text) == false; - - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - IList list = _parentLogTabWin.GetListOfOpenFiles(); - syncTimestampsToToolStripMenuItem.Enabled = true; - syncTimestampsToToolStripMenuItem.DropDownItems.Clear(); - EventHandler ev = OnHandleSyncContextMenu; - Font italicFont = new(syncTimestampsToToolStripMenuItem.Font.FontFamily, syncTimestampsToToolStripMenuItem.Font.Size, FontStyle.Italic); - - foreach (WindowFileEntry fileEntry in list) - { - if (fileEntry.LogWindow != this) - { - ToolStripMenuItem item = syncTimestampsToToolStripMenuItem.DropDownItems.Add(fileEntry.Title, null, ev) as ToolStripMenuItem; - item.Tag = fileEntry; - item.Checked = TimeSyncList != null && TimeSyncList.Contains(fileEntry.LogWindow); - if (fileEntry.LogWindow.TimeSyncList != null && !fileEntry.LogWindow.TimeSyncList.Contains(this)) - { - item.Font = italicFont; - item.ForeColor = Color.Blue; - } - - item.Enabled = fileEntry.LogWindow.CurrentColumnizer.IsTimeshiftImplemented(); - } - } - } - else - { - syncTimestampsToToolStripMenuItem.Enabled = false; - } - - freeThisWindowFromTimeSyncToolStripMenuItem.Enabled = TimeSyncList != null && - TimeSyncList.Count > 1; - } - - private void OnHandlePluginContextMenu(object sender, EventArgs args) - { - if (sender is ToolStripItem item) - { - ContextMenuPluginEventArgs menuArgs = item.Tag as ContextMenuPluginEventArgs; - var logLines = menuArgs.LogLines; - menuArgs.Entry.MenuSelected(logLines.Count, menuArgs.Columnizer, menuArgs.Callback.GetLogLine(logLines[0])); - } - } - - private void OnHandleSyncContextMenu(object sender, EventArgs args) - { - if (sender is ToolStripItem item) - { - WindowFileEntry entry = item.Tag as WindowFileEntry; - - if (TimeSyncList != null && TimeSyncList.Contains(entry.LogWindow)) - { - FreeSlaveFromTimesync(entry.LogWindow); - } - else - //AddSlaveToTimesync(entry.LogWindow); - { - AddOtherWindowToTimesync(entry.LogWindow); - } - } - } - - private void OnCopyToolStripMenuItemClick(object sender, EventArgs e) - { - CopyMarkedLinesToClipboard(); - } - - private void OnCopyToTabToolStripMenuItemClick(object sender, EventArgs e) - { - CopyMarkedLinesToTab(); - } - - private void OnScrollAllTabsToTimestampToolStripMenuItemClick(object sender, EventArgs e) - { - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - int currentLine = dataGridView.CurrentCellAddress.Y; - if (currentLine > 0 && currentLine < dataGridView.RowCount) - { - int lineNum = currentLine; - DateTime timeStamp = GetTimestampForLine(ref lineNum, false); - if (timeStamp.Equals(DateTime.MinValue)) // means: invalid - { - return; - } - - _parentLogTabWin.ScrollAllTabsToTimestamp(timeStamp, this); - } - } - } - - private void OnLocateLineInOriginalFileToolStripMenuItemClick(object sender, EventArgs e) - { - if (dataGridView.CurrentRow != null && FilterPipe != null) - { - int lineNum = FilterPipe.GetOriginalLineNum(dataGridView.CurrentRow.Index); - if (lineNum != -1) - { - FilterPipe.LogWindow.SelectLine(lineNum, false, true); - _parentLogTabWin.SelectTab(FilterPipe.LogWindow); - } - } - } - - private void OnToggleBoomarkToolStripMenuItemClick(object sender, EventArgs e) - { - ToggleBookmark(); - } - - private void OnMarkEditModeToolStripMenuItemClick(object sender, EventArgs e) - { - StartEditMode(); - } - - private void OnLogWindowSizeChanged(object sender, EventArgs e) - { - //AdjustMinimumGridWith(); - AdjustHighlightSplitterWidth(); - } - - #region BookMarkList - - private void OnColumnRestrictCheckBoxCheckedChanged(object sender, EventArgs e) - { - columnButton.Enabled = columnRestrictCheckBox.Checked; - if (columnRestrictCheckBox.Checked) // disable when nothing to filter - { - columnNamesLabel.Visible = true; - _filterParams.ColumnRestrict = true; - columnNamesLabel.Text = CalculateColumnNames(_filterParams); - } - else - { - columnNamesLabel.Visible = false; - } - - CheckForFilterDirty(); - } - - private void OnColumnButtonClick(object sender, EventArgs e) - { - _filterParams.CurrentColumnizer = _currentColumnizer; - FilterColumnChooser chooser = new(_filterParams); - if (chooser.ShowDialog() == DialogResult.OK) - { - columnNamesLabel.Text = CalculateColumnNames(_filterParams); - - //CheckForFilterDirty(); //!!!GBro: Indicate to redo the search if search columns were changed - filterSearchButton.Image = _searchButtonImage; - saveFilterButton.Enabled = false; - } - } - - #endregion - - #region Column Header Context Menu - - private void OnDataGridViewCellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) - { - if (e.RowIndex >= 0 && e.RowIndex < dataGridView.RowCount && !dataGridView.Rows[e.RowIndex].Selected) - { - SelectLine(e.RowIndex, false, true); - } - else if (e.RowIndex < 0) - { - e.ContextMenuStrip = columnContextMenuStrip; - } - - if (e.ContextMenuStrip == columnContextMenuStrip) - { - _selectedCol = e.ColumnIndex; - } - } - - //private void boomarkDataGridView_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) - //{ - // if (e.RowIndex > 0 && e.RowIndex < this.boomarkDataGridView.RowCount - // && !this.boomarkDataGridView.Rows[e.RowIndex].Selected) - // { - // this.boomarkDataGridView.Rows[e.RowIndex].Selected = true; - // this.boomarkDataGridView.CurrentCell = this.boomarkDataGridView.Rows[e.RowIndex].Cells[0]; - // } - // if (e.ContextMenuStrip == this.columnContextMenuStrip) - // { - // this.selectedCol = e.ColumnIndex; - // } - //} - - private void OnFilterGridViewCellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) - { - if (e.ContextMenuStrip == columnContextMenuStrip) - { - _selectedCol = e.ColumnIndex; - } - } - - private void OnColumnContextMenuStripOpening(object sender, CancelEventArgs e) - { - Control ctl = columnContextMenuStrip.SourceControl; - BufferedDataGridView gridView = ctl as BufferedDataGridView; - bool frozen = false; - if (_freezeStateMap.TryGetValue(ctl, out bool value)) - { - frozen = value; - } - - freezeLeftColumnsUntilHereToolStripMenuItem.Checked = frozen; - - if (frozen) - { - freezeLeftColumnsUntilHereToolStripMenuItem.Text = "Frozen"; - } - else - { - if (ctl is BufferedDataGridView) - { - freezeLeftColumnsUntilHereToolStripMenuItem.Text = $"Freeze left columns until here ({gridView.Columns[_selectedCol].HeaderText})"; - } - } - - - DataGridViewColumn col = gridView.Columns[_selectedCol]; - moveLeftToolStripMenuItem.Enabled = col != null && col.DisplayIndex > 0; - moveRightToolStripMenuItem.Enabled = col != null && col.DisplayIndex < gridView.Columns.Count - 1; - - if (gridView.Columns.Count - 1 > _selectedCol) - { - // DataGridViewColumn colRight = gridView.Columns[this.selectedCol + 1]; - DataGridViewColumn colRight = gridView.Columns.GetNextColumn(col, DataGridViewElementStates.None, DataGridViewElementStates.None); - moveRightToolStripMenuItem.Enabled = colRight != null && colRight.Frozen == col.Frozen; - } - - if (_selectedCol > 0) - { - //DataGridViewColumn colLeft = gridView.Columns[this.selectedCol - 1]; - DataGridViewColumn colLeft = gridView.Columns.GetPreviousColumn(col, DataGridViewElementStates.None, DataGridViewElementStates.None); - - moveLeftToolStripMenuItem.Enabled = colLeft != null && colLeft.Frozen == col.Frozen; - } - - DataGridViewColumn colLast = gridView.Columns[gridView.Columns.Count - 1]; - moveToLastColumnToolStripMenuItem.Enabled = colLast != null && colLast.Frozen == col.Frozen; - - // Fill context menu with column names - // - EventHandler ev = OnHandleColumnItemContextMenu; - allColumnsToolStripMenuItem.DropDownItems.Clear(); - foreach (DataGridViewColumn column in gridView.Columns) - { - if (column.HeaderText.Length > 0) - { - ToolStripMenuItem item = allColumnsToolStripMenuItem.DropDownItems.Add(column.HeaderText, null, ev) as ToolStripMenuItem; - item.Tag = column; - item.Enabled = !column.Frozen; - } - } - } - - private void OnHandleColumnItemContextMenu(object sender, EventArgs args) - { - if (sender is ToolStripItem item) - { - DataGridViewColumn column = item.Tag as DataGridViewColumn; - column.Visible = true; - column.DataGridView.FirstDisplayedScrollingColumnIndex = column.Index; - } - } - - private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick(object sender, EventArgs e) - { - Control ctl = columnContextMenuStrip.SourceControl; - bool frozen = false; - - if (_freezeStateMap.TryGetValue(ctl, out bool value)) - { - frozen = value; - } - - frozen = !frozen; - _freezeStateMap[ctl] = frozen; - - if (ctl is BufferedDataGridView gridView) - { - ApplyFrozenState(gridView); - } - } - - private void OnMoveToLastColumnToolStripMenuItemClick(object sender, EventArgs e) - { - BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - DataGridViewColumn col = gridView.Columns[_selectedCol]; - if (col != null) - { - col.DisplayIndex = gridView.Columns.Count - 1; - } - } - - private void OnMoveLeftToolStripMenuItemClick(object sender, EventArgs e) - { - BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - DataGridViewColumn col = gridView.Columns[_selectedCol]; - if (col != null && col.DisplayIndex > 0) - { - col.DisplayIndex -= 1; - } - } - - private void OnMoveRightToolStripMenuItemClick(object sender, EventArgs e) - { - BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - DataGridViewColumn col = gridView.Columns[_selectedCol]; - if (col != null && col.DisplayIndex < gridView.Columns.Count - 1) - { - col.DisplayIndex = col.DisplayIndex + 1; - } - } - - private void OnHideColumnToolStripMenuItemClick(object sender, EventArgs e) - { - BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - DataGridViewColumn col = gridView.Columns[_selectedCol]; - col.Visible = false; - } - - private void OnRestoreColumnsToolStripMenuItemClick(object sender, EventArgs e) - { - BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - foreach (DataGridViewColumn col in gridView.Columns) - { - col.Visible = true; - } - } - - private void OnTimeSpreadingControlLineSelected(object sender, SelectLineEventArgs e) - { - SelectLine(e.Line, false, true); - } - - private void OnBookmarkCommentToolStripMenuItemClick(object sender, EventArgs e) - { - AddBookmarkAndEditComment(); - } - - private void OnHighlightSelectionInLogFileToolStripMenuItemClick(object sender, EventArgs e) - { - if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) - { - var he = new HighlightEntry() - { - SearchText = ctl.SelectedText, - ForegroundColor = Color.Red, - BackgroundColor = Color.Yellow, - IsRegEx = false, - IsCaseSensitive = true, - IsLedSwitch = false, - IsSetBookmark = false, - IsActionEntry = false, - ActionEntry = null, - IsWordMatch = false - }; - - lock (_tempHighlightEntryListLock) - { - _tempHighlightEntryList.Add(he); - } - - dataGridView.CancelEdit(); - dataGridView.EndEdit(); - RefreshAllGrids(); - } - } - - private void OnHighlightSelectionInLogFilewordModeToolStripMenuItemClick(object sender, EventArgs e) - { - if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) - { - HighlightEntry he = new() - { - SearchText = ctl.SelectedText, - ForegroundColor = Color.Red, - BackgroundColor = Color.Yellow, - IsRegEx = false, - IsCaseSensitive = true, - IsLedSwitch = false, - IsStopTail = false, - IsSetBookmark = false, - IsActionEntry = false, - ActionEntry = null, - IsWordMatch = true - }; - - lock (_tempHighlightEntryListLock) - { - _tempHighlightEntryList.Add(he); - } - - dataGridView.CancelEdit(); - dataGridView.EndEdit(); - RefreshAllGrids(); - } - } - - private void OnEditModeCopyToolStripMenuItemClick(object sender, EventArgs e) - { - if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) - { - if (Util.IsNull(ctl.SelectedText) == false) - { - Clipboard.SetText(ctl.SelectedText); - } - } - } - - private void OnRemoveAllToolStripMenuItemClick(object sender, EventArgs e) - { - RemoveTempHighlights(); - } - - private void OnMakePermanentToolStripMenuItemClick(object sender, EventArgs e) - { - lock (_tempHighlightEntryListLock) - { - lock (_currentHighlightGroupLock) - { - _currentHighlightGroup.HighlightEntryList.AddRange(_tempHighlightEntryList); - RemoveTempHighlights(); - OnCurrentHighlightListChanged(); - } - } - } - - private void OnMarkCurrentFilterRangeToolStripMenuItemClick(object sender, EventArgs e) - { - MarkCurrentFilterRange(); - } - - private void OnFilterForSelectionToolStripMenuItemClick(object sender, EventArgs e) - { - if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) - { - splitContainerLogWindow.Panel2Collapsed = false; - ResetFilterControls(); - FilterSearch(ctl.SelectedText); - } - } - - private void OnSetSelectedTextAsBookmarkCommentToolStripMenuItemClick(object sender, EventArgs e) - { - if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) - { - AddBookmarkComment(ctl.SelectedText); - } - } - - private void OnDataGridViewCellClick(object sender, DataGridViewCellEventArgs e) - { - _shouldCallTimeSync = true; - } - - private void OnDataGridViewCellDoubleClick(object sender, DataGridViewCellEventArgs e) - { - if (e.ColumnIndex == 0) - { - ToggleBookmark(); - } - } - - private void OnDataGridViewOverlayDoubleClicked(object sender, OverlayEventArgs e) - { - BookmarkComment(e.BookmarkOverlay.Bookmark); - } - - private void OnFilterRegexCheckBoxMouseUp(object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Right) - { - RegexHelperDialog dlg = new() - { - ExpressionHistoryList = ConfigManager.Settings.RegexHistory.ExpressionHistoryList, - TesttextHistoryList = ConfigManager.Settings.RegexHistory.TesttextHistoryList, - Owner = this, - CaseSensitive = filterCaseSensitiveCheckBox.Checked, - Pattern = filterComboBox.Text - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - ConfigManager.Settings.RegexHistory.ExpressionHistoryList = dlg.ExpressionHistoryList; - ConfigManager.Settings.RegexHistory.TesttextHistoryList = dlg.TesttextHistoryList; - - filterCaseSensitiveCheckBox.Checked = dlg.CaseSensitive; - filterComboBox.Text = dlg.Pattern; - - ConfigManager.Save(SettingsFlags.RegexHistory); - } - } - } - - #endregion - - #region Filter-Highlight - - private void OnToggleHighlightPanelButtonClick(object sender, EventArgs e) - { - ToggleHighlightPanel(highlightSplitContainer.Panel2Collapsed); - } - - private void OnSaveFilterButtonClick(object sender, EventArgs e) - { - FilterParams newParams = _filterParams.Clone(); - newParams.Color = Color.FromKnownColor(KnownColor.Black); - ConfigManager.Settings.filterList.Add(newParams); - OnFilterListChanged(this); - } - - private void OnDeleteFilterButtonClick(object sender, EventArgs e) - { - int index = filterListBox.SelectedIndex; - if (index >= 0) - { - FilterParams filterParams = (FilterParams)filterListBox.Items[index]; - ConfigManager.Settings.filterList.Remove(filterParams); - OnFilterListChanged(this); - if (filterListBox.Items.Count > 0) - { - filterListBox.SelectedIndex = filterListBox.Items.Count - 1; - } - } - } - - private void OnFilterUpButtonClick(object sender, EventArgs e) - { - int i = filterListBox.SelectedIndex; - if (i > 0) - { - FilterParams filterParams = (FilterParams)filterListBox.Items[i]; - ConfigManager.Settings.filterList.RemoveAt(i); - i--; - ConfigManager.Settings.filterList.Insert(i, filterParams); - OnFilterListChanged(this); - filterListBox.SelectedIndex = i; - } - } - - private void OnFilterDownButtonClick(object sender, EventArgs e) - { - int i = filterListBox.SelectedIndex; - if (i < 0) - { - return; - } - - if (i < filterListBox.Items.Count - 1) - { - FilterParams filterParams = (FilterParams)filterListBox.Items[i]; - ConfigManager.Settings.filterList.RemoveAt(i); - i++; - ConfigManager.Settings.filterList.Insert(i, filterParams); - OnFilterListChanged(this); - filterListBox.SelectedIndex = i; - } - } - - private void OnFilterListBoxMouseDoubleClick(object sender, MouseEventArgs e) - { - if (filterListBox.SelectedIndex >= 0) - { - FilterParams filterParams = (FilterParams)filterListBox.Items[filterListBox.SelectedIndex]; - FilterParams newParams = filterParams.Clone(); - //newParams.historyList = ConfigManager.Settings.filterHistoryList; - this._filterParams = newParams; - ReInitFilterParams(this._filterParams); - ApplyFilterParams(); - CheckForAdvancedButtonDirty(); - CheckForFilterDirty(); - filterSearchButton.Image = _searchButtonImage; - saveFilterButton.Enabled = false; - if (hideFilterListOnLoadCheckBox.Checked) - { - ToggleHighlightPanel(false); - } - - if (filterOnLoadCheckBox.Checked) - { - FilterSearch(); - } - } - } - - private void OnFilterListBoxDrawItem(object sender, DrawItemEventArgs e) - { - e.DrawBackground(); - if (e.Index >= 0) - { - FilterParams filterParams = (FilterParams)filterListBox.Items[e.Index]; - Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); - - Brush brush; - - if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) - { - brush = new SolidBrush(filterListBox.BackColor); - } - else - { - brush = new SolidBrush(filterParams.Color); - } - - e.Graphics.DrawString(filterParams.SearchText, e.Font, brush, - new PointF(rectangle.Left, rectangle.Top)); - e.DrawFocusRectangle(); - brush.Dispose(); - } - } - - // Color for filter list entry - private void OnColorToolStripMenuItemClick(object sender, EventArgs e) - { - int i = filterListBox.SelectedIndex; - if (i < filterListBox.Items.Count && i >= 0) - { - FilterParams filterParams = (FilterParams)filterListBox.Items[i]; - ColorDialog dlg = new(); - dlg.CustomColors = new[] { filterParams.Color.ToArgb() }; - dlg.Color = filterParams.Color; - if (dlg.ShowDialog() == DialogResult.OK) - { - filterParams.Color = dlg.Color; - filterListBox.Refresh(); - } - } - } - - private void OnFilterCaseSensitiveCheckBoxCheckedChanged(object sender, EventArgs e) - { - CheckForFilterDirty(); - } - - private void OnFilterRegexCheckBoxCheckedChanged(object sender, EventArgs e) - { - fuzzyKnobControl.Enabled = !filterRegexCheckBox.Checked; - fuzzyLabel.Enabled = !filterRegexCheckBox.Checked; - CheckForFilterDirty(); - } - - private void OnInvertFilterCheckBoxCheckedChanged(object sender, EventArgs e) - { - CheckForFilterDirty(); - } - - private void OnFilterRangeComboBoxTextChanged(object sender, EventArgs e) - { - CheckForFilterDirty(); - } - - private void OnFuzzyKnobControlValueChanged(object sender, EventArgs e) - { - CheckForFilterDirty(); - } - - private void OnFilterComboBoxTextChanged(object sender, EventArgs e) - { - CheckForFilterDirty(); - } - - private void OnSetBookmarksOnSelectedLinesToolStripMenuItemClick(object sender, EventArgs e) - { - SetBookmarksForSelectedFilterLines(); - } - - private void OnParentHighlightSettingsChanged(object sender, EventArgs e) - { - string groupName = _guiStateArgs.HighlightGroupName; - SetCurrentHighlightGroup(groupName); - } - - private void OnFilterOnLoadCheckBoxMouseClick(object sender, MouseEventArgs e) - { - HandleChangedFilterOnLoadSetting(); - } - - private void OnFilterOnLoadCheckBoxKeyPress(object sender, KeyPressEventArgs e) - { - HandleChangedFilterOnLoadSetting(); - } - - private void OnHideFilterListOnLoadCheckBoxMouseClick(object sender, MouseEventArgs e) - { - HandleChangedFilterOnLoadSetting(); - } - - private void OnFilterToTabToolStripMenuItemClick(object sender, EventArgs e) - { - FilterToTab(); - } - - private void OnTimeSyncListWindowRemoved(object sender, EventArgs e) - { - TimeSyncList syncList = sender as TimeSyncList; - lock (_timeSyncListLock) - { - if (syncList.Count == 0 || syncList.Count == 1 && syncList.Contains(this)) - { - if (syncList == TimeSyncList) - { - TimeSyncList = null; - OnSyncModeChanged(); - } - } - } - } - - private void OnFreeThisWindowFromTimeSyncToolStripMenuItemClick(object sender, EventArgs e) - { - FreeFromTimeSync(); - } - - private void OnSplitContainerSplitterMoved(object sender, SplitterEventArgs e) - { - advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; - } - - private void OnMarkFilterHitsInLogViewToolStripMenuItemClick(object sender, EventArgs e) - { - SearchParams p = new(); - p.SearchText = _filterParams.SearchText; - p.IsRegex = _filterParams.IsRegex; - p.IsCaseSensitive = _filterParams.IsCaseSensitive; - AddSearchHitHighlightEntry(p); - } - - private void OnColumnComboBoxSelectionChangeCommitted(object sender, EventArgs e) - { - SelectColumn(); - } - - private void OnColumnComboBoxKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - SelectColumn(); - dataGridView.Focus(); - } - } - - private void OnColumnComboBoxPreviewKeyDown(object sender, PreviewKeyDownEventArgs e) - { - if (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt) - { - columnComboBox.DroppedDown = true; - } - - if (e.KeyCode == Keys.Enter) - { - e.IsInputKey = true; - } - } - - private void OnBookmarkProviderBookmarkRemoved(object sender, EventArgs e) - { - if (!_isLoading) - { - dataGridView.Refresh(); - filterGridView.Refresh(); - } - } - - private void OnBookmarkProviderBookmarkAdded(object sender, EventArgs e) - { - if (!_isLoading) - { - dataGridView.Refresh(); - filterGridView.Refresh(); - } - } - - private void OnBookmarkProviderAllBookmarksRemoved(object sender, EventArgs e) - { - // nothing - } - - private void OnLogWindowLeave(object sender, EventArgs e) - { - InvalidateCurrentRow(); - } - - private void OnLogWindowEnter(object sender, EventArgs e) - { - InvalidateCurrentRow(); - } - - private void OnDataGridViewRowUnshared(object sender, DataGridViewRowEventArgs e) - { - if (_logger.IsTraceEnabled) - { - _logger.Trace($"Row unshared line {e.Row.Cells[1].Value}"); - } - } - - #endregion - - #endregion - - #endregion - - private void MeasureItem(object sender, MeasureItemEventArgs e) - { - e.ItemHeight = filterListBox.Font.Height; - } - } -} +using LogExpert.Classes.Filter; +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Filter; +using LogExpert.Core.Classes.Highlight; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.EventArguments; +using LogExpert.Core.Interface; +using LogExpert.Dialogs; +using LogExpert.UI.Dialogs; +using LogExpert.UI.Entities; +using LogExpert.UI.Extensions; +using System.ComponentModel; + +namespace LogExpert.UI.Controls.LogWindow +{ + partial class LogWindow + { + private void AutoResizeFilterBox() + { + filterSplitContainer.SplitterDistance = filterComboBox.Left + filterComboBox.GetMaxTextWidth(); + } + + #region Events handler + + protected void OnProgressBarUpdate(ProgressEventArgs e) + { + ProgressBarUpdate?.Invoke(this, e); + } + + protected void OnStatusLine(StatusLineEventArgs e) + { + StatusLineEvent?.Invoke(this, e); + } + + protected void OnGuiState(GuiStateArgs e) + { + GuiStateUpdate?.Invoke(this, e); + } + + protected void OnTailFollowed(EventArgs e) + { + TailFollowed?.Invoke(this, e); + } + + protected void OnFileNotFound(EventArgs e) + { + FileNotFound?.Invoke(this, e); + } + + protected void OnFileRespawned(EventArgs e) + { + FileRespawned?.Invoke(this, e); + } + + protected void OnFilterListChanged(LogWindow source) + { + FilterListChanged?.Invoke(this, new FilterListChangedEventArgs(source)); + } + + protected void OnCurrentHighlightListChanged() + { + CurrentHighlightGroupChanged?.Invoke(this, new CurrentHighlightGroupChangedEventArgs(this, _currentHighlightGroup)); + } + + protected void OnBookmarkAdded() + { + BookmarkAdded?.Invoke(this, EventArgs.Empty); + } + + protected void OnBookmarkRemoved() + { + BookmarkRemoved?.Invoke(this, EventArgs.Empty); + } + + protected void OnBookmarkTextChanged(Bookmark bookmark) + { + BookmarkTextChanged?.Invoke(this, new BookmarkEventArgs(bookmark)); + } + + protected void OnColumnizerChanged(ILogLineColumnizer columnizer) + { + ColumnizerChanged?.Invoke(this, new ColumnizerEventArgs(columnizer)); + } + + protected void OnRegisterCancelHandler(IBackgroundProcessCancelHandler handler) + { + lock (_cancelHandlerList) + { + _cancelHandlerList.Add(handler); + } + } + + protected void OnDeRegisterCancelHandler(IBackgroundProcessCancelHandler handler) + { + lock (_cancelHandlerList) + { + _cancelHandlerList.Remove(handler); + } + } + + private void OnLogWindowLoad(object sender, EventArgs e) + { + PreferencesChanged(_parentLogTabWin.Preferences, true, SettingsFlags.GuiOrColors); + } + + private void OnLogWindowDisposed(object sender, EventArgs e) + { + _waitingForClose = true; + _parentLogTabWin.HighlightSettingsChanged -= OnParentHighlightSettingsChanged; + _logFileReader?.DeleteAllContent(); + + FreeFromTimeSync(); + } + + private void OnLogFileReaderLoadingStarted(object sender, LoadFileEventArgs e) + { + Invoke(LoadingStarted, e); + } + + private void OnLogFileReaderFinishedLoading(object sender, EventArgs e) + { + //Thread.CurrentThread.Name = "FinishedLoading event thread"; + _logger.Info("Finished loading."); + _isLoading = false; + _isDeadFile = false; + if (!_waitingForClose) + { + Invoke(new MethodInvoker(LoadingFinished)); + Invoke(new MethodInvoker(LoadPersistenceData)); + Invoke(new MethodInvoker(SetGuiAfterLoading)); + _loadingFinishedEvent.Set(); + _externaLoadingFinishedEvent.Set(); + _timeSpreadCalc.SetLineCount(_logFileReader.LineCount); + + if (_reloadMemento != null) + { + Invoke(new PositionAfterReloadFx(PositionAfterReload), _reloadMemento); + } + + if (filterTailCheckBox.Checked) + { + _logger.Info("Refreshing filter view because of reload."); + Invoke(new MethodInvoker(FilterSearch)); // call on proper thread + } + + HandleChangedFilterList(); + } + + _reloadMemento = null; + } + + private void OnLogFileReaderFileNotFound(object sender, EventArgs e) + { + if (!IsDisposed && !Disposing) + { + _logger.Info("Handling file not found event."); + _isDeadFile = true; + BeginInvoke(new MethodInvoker(LogfileDead)); + } + } + + private void OnLogFileReaderRespawned(object sender, EventArgs e) + { + BeginInvoke(new MethodInvoker(LogfileRespawned)); + } + + private void OnLogWindowClosing(object sender, CancelEventArgs e) + { + if (Preferences.askForClose) + { + if (MessageBox.Show("Sure to close?", "LogExpert", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + return; + } + } + + SavePersistenceData(false); + CloseLogWindow(); + } + + private void OnDataGridViewColumnDividerDoubleClick(object sender, DataGridViewColumnDividerDoubleClickEventArgs e) + { + e.Handled = true; + AutoResizeColumns(dataGridView); + } + + /** + * Event handler for the Load event from LogfileReader + */ + private void OnLogFileReaderLoadFile(object sender, LoadFileEventArgs e) + { + if (e.NewFile) + { + _logger.Info("File created anew."); + + // File was new created (e.g. rollover) + _isDeadFile = false; + UnRegisterLogFileReaderEvents(); + dataGridView.CurrentCellChanged -= OnDataGridViewCurrentCellChanged; + MethodInvoker invoker = ReloadNewFile; + BeginInvoke(invoker); + //Thread loadThread = new Thread(new ThreadStart(ReloadNewFile)); + //loadThread.Start(); + _logger.Debug("Reloading invoked."); + } + else if (_isLoading) + { + BeginInvoke(UpdateProgress, e); + } + } + + private void OnFileSizeChanged(object sender, LogEventArgs e) + { + //OnFileSizeChanged(e); // now done in UpdateGrid() + _logger.Info("Got FileSizeChanged event. prevLines:{0}, curr lines: {1}", e.PrevLineCount, e.LineCount); + + // - now done in the thread that works on the event args list + //if (e.IsRollover) + //{ + // ShiftBookmarks(e.RolloverOffset); + // ShiftFilterPipes(e.RolloverOffset); + //} + + //UpdateGridCallback callback = new UpdateGridCallback(UpdateGrid); + //this.BeginInvoke(callback, new object[] { e }); + lock (_logEventArgsList) + { + _logEventArgsList.Add(e); + _logEventArgsEvent.Set(); + } + } + + private void OnDataGridViewCellValueNeeded(object sender, DataGridViewCellValueEventArgs e) + { + int startCount = CurrentColumnizer?.GetColumnCount() ?? 0; + + e.Value = GetCellValue(e.RowIndex, e.ColumnIndex); + + // The new column could be find dynamically. + // Only support add new columns for now. + // TODO: Support reload all columns? + if (CurrentColumnizer != null && CurrentColumnizer.GetColumnCount() > startCount) + { + for (int i = startCount; i < CurrentColumnizer.GetColumnCount(); i++) + { + var colName = CurrentColumnizer.GetColumnNames()[i]; + dataGridView.Columns.Add(PaintHelper.CreateTitleColumn(colName)); + } + } + } + + private void OnDataGridViewCellValuePushed(object sender, DataGridViewCellValueEventArgs e) + { + if (!CurrentColumnizer.IsTimeshiftImplemented()) + { + return; + } + + ILogLine line = _logFileReader.GetLogLine(e.RowIndex); + int offset = CurrentColumnizer.GetTimeOffset(); + CurrentColumnizer.SetTimeOffset(0); + ColumnizerCallbackObject.LineNum = e.RowIndex; + IColumnizedLogLine cols = CurrentColumnizer.SplitLine(ColumnizerCallbackObject, line); + CurrentColumnizer.SetTimeOffset(offset); + if (cols.ColumnValues.Length <= e.ColumnIndex - 2) + { + return; + } + + string oldValue = cols.ColumnValues[e.ColumnIndex - 2].FullValue; + string newValue = (string)e.Value; + //string oldValue = (string) this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; + CurrentColumnizer.PushValue(ColumnizerCallbackObject, e.ColumnIndex - 2, newValue, oldValue); + dataGridView.Refresh(); + TimeSpan timeSpan = new(CurrentColumnizer.GetTimeOffset() * TimeSpan.TicksPerMillisecond); + string span = timeSpan.ToString(); + int index = span.LastIndexOf('.'); + if (index > 0) + { + span = span.Substring(0, index + 4); + } + + SetTimeshiftValue(span); + SendGuiStateUpdate(); + } + + private void OnDataGridViewRowHeightInfoNeeded(object sender, DataGridViewRowHeightInfoNeededEventArgs e) + { + e.Height = GetRowHeight(e.RowIndex); + } + + private void OnDataGridViewCurrentCellChanged(object sender, EventArgs e) + { + if (dataGridView.CurrentRow != null) + { + _statusEventArgs.CurrentLineNum = dataGridView.CurrentRow.Index + 1; + SendStatusLineUpdate(); + if (syncFilterCheckBox.Checked) + { + SyncFilterGridPos(); + } + + if (CurrentColumnizer.IsTimeshiftImplemented() && Preferences.timestampControl) + { + SyncTimestampDisplay(); + } + + //MethodInvoker invoker = new MethodInvoker(DisplayCurrentFileOnStatusline); + //invoker.BeginInvoke(null, null); + } + } + + private void OnDataGridViewCellEndEdit(object sender, DataGridViewCellEventArgs e) + { + StatusLineText(string.Empty); + } + + private void OnEditControlKeyUp(object sender, KeyEventArgs e) + { + UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); + } + + private void OnEditControlKeyPress(object sender, KeyPressEventArgs e) + { + UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); + } + + private void OnEditControlClick(object sender, EventArgs e) + { + UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); + } + + private void OnEditControlKeyDown(object sender, KeyEventArgs e) + { + UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); + } + + private void OnDataGridViewPaint(object sender, PaintEventArgs e) + { + if (ShowBookmarkBubbles) + { + AddBookmarkOverlays(); + } + } + + // ====================================================================================== + // Filter Grid stuff + // ====================================================================================== + + private void OnFilterSearchButtonClick(object sender, EventArgs e) + { + FilterSearch(); + } + + private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintingEventArgs e) + { + BufferedDataGridView gridView = (BufferedDataGridView)sender; + + if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) + { + e.Handled = false; + return; + } + + int lineNum = _filterResultList[e.RowIndex]; + ILogLine line = _logFileReader.GetLogLineWithWait(lineNum).Result; + + if (line != null) + { + HighlightEntry entry = FindFirstNoWordMatchHilightEntry(line); + e.Graphics.SetClip(e.CellBounds); + if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) + { + Brush brush; + if (gridView.Focused) + { + brush = new SolidBrush(e.CellStyle.SelectionBackColor); + } + else + { + Color color = Color.FromArgb(255, 170, 170, 170); + brush = new SolidBrush(color); + } + + e.Graphics.FillRectangle(brush, e.CellBounds); + brush.Dispose(); + } + else + { + Color bgColor = Color.White; + // paint direct filter hits with different bg color + //if (this.filterParams.SpreadEnabled && this.filterHitList.Contains(lineNum)) + //{ + // bgColor = Color.FromArgb(255, 220, 220, 220); + //} + if (!DebugOptions.DisableWordHighlight) + { + if (entry != null) + { + bgColor = entry.BackgroundColor; + } + } + else + { + if (entry != null) + { + bgColor = entry.BackgroundColor; + } + } + + e.CellStyle.BackColor = bgColor; + e.PaintBackground(e.ClipBounds, false); + } + + if (DebugOptions.DisableWordHighlight) + { + e.PaintContent(e.CellBounds); + } + else + { + PaintCell(e, filterGridView, false, entry); + } + + if (e.ColumnIndex == 0) + { + if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) + { + Rectangle r = new(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); + r = e.CellBounds; + r.Inflate(-2, -2); + Brush brush = new SolidBrush(BookmarkColor); + e.Graphics.FillRectangle(brush, r); + brush.Dispose(); + + Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); + + if (bookmark.Text.Length > 0) + { + StringFormat format = new() + { + LineAlignment = StringAlignment.Center, + Alignment = StringAlignment.Center + }; + + Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); + Font font = new("Verdana", Preferences.fontSize, FontStyle.Bold); + e.Graphics.DrawString("!", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); + font.Dispose(); + brush2.Dispose(); + } + } + } + + e.Paint(e.CellBounds, DataGridViewPaintParts.Border); + e.Handled = true; + } + } + + private void OnFilterGridViewCellValueNeeded(object sender, DataGridViewCellValueEventArgs e) + { + if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) + { + e.Value = ""; + return; + } + + int lineNum = _filterResultList[e.RowIndex]; + e.Value = GetCellValue(lineNum, e.ColumnIndex); + } + + private void OnFilterGridViewRowHeightInfoNeeded(object sender, DataGridViewRowHeightInfoNeededEventArgs e) + { + e.Height = _lineHeight; + } + + private void OnFilterComboBoxKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + FilterSearch(); + } + } + + private void OnFilterGridViewColumnDividerDoubleClick(object sender, + DataGridViewColumnDividerDoubleClickEventArgs e) + { + e.Handled = true; + AutoResizeColumnsFx fx = AutoResizeColumns; + BeginInvoke(fx, filterGridView); + } + + private void OnFilterGridViewCellDoubleClick(object sender, DataGridViewCellEventArgs e) + { + if (e.ColumnIndex == 0) + { + ToggleBookmark(); + return; + } + + if (filterGridView.CurrentRow != null && e.RowIndex >= 0) + { + int lineNum = _filterResultList[filterGridView.CurrentRow.Index]; + SelectAndEnsureVisible(lineNum, true); + } + } + + private void OnRangeCheckBoxCheckedChanged(object sender, EventArgs e) + { + filterRangeComboBox.Enabled = rangeCheckBox.Checked; + CheckForFilterDirty(); + } + + private void OnDataGridViewScroll(object sender, ScrollEventArgs e) + { + if (e.ScrollOrientation == ScrollOrientation.VerticalScroll) + { + if (dataGridView.DisplayedRowCount(false) + dataGridView.FirstDisplayedScrollingRowIndex >= dataGridView.RowCount) + { + //this.guiStateArgs.FollowTail = true; + if (!_guiStateArgs.FollowTail) + { + FollowTailChanged(true, false); + } + + OnTailFollowed(EventArgs.Empty); + } + else + { + //this.guiStateArgs.FollowTail = false; + if (_guiStateArgs.FollowTail) + { + FollowTailChanged(false, false); + } + } + + SendGuiStateUpdate(); + } + } + + private void OnFilterGridViewKeyDown(object sender, KeyEventArgs e) + { + switch (e.KeyCode) + { + case Keys.Enter: + { + if (filterGridView.CurrentCellAddress.Y >= 0 && filterGridView.CurrentCellAddress.Y < _filterResultList.Count) + { + int lineNum = _filterResultList[filterGridView.CurrentCellAddress.Y]; + SelectLine(lineNum, false, true); + e.Handled = true; + } + + break; + } + case Keys.Tab when e.Modifiers == Keys.None: + dataGridView.Focus(); + e.Handled = true; + break; + } + } + + private void OnDataGridViewKeyDown(object sender, KeyEventArgs e) + { + switch (e.KeyCode) + { + case Keys.Tab when e.Modifiers == Keys.None: + { + filterGridView.Focus(); + e.Handled = true; + break; + } + } + + //switch (e.KeyCode) + //{ + // case Keys.Tab when e.Modifiers == Keys.Control: + // //this.parentLogTabWin.SwitchTab(e.Shift); + // break; + //} + + _shouldCallTimeSync = true; + } + + private void OnDataGridViewPreviewKeyDown(object sender, PreviewKeyDownEventArgs e) + { + if (e.KeyCode == Keys.Tab && e.Control) + { + e.IsInputKey = true; + } + } + + private void OnDataGridViewCellContentDoubleClick(object sender, DataGridViewCellEventArgs e) + { + if (dataGridView.CurrentCell != null) + { + dataGridView.BeginEdit(false); + } + } + + private void OnSyncFilterCheckBoxCheckedChanged(object sender, EventArgs e) + { + if (syncFilterCheckBox.Checked) + { + SyncFilterGridPos(); + } + } + + private void OnDataGridViewLeave(object sender, EventArgs e) + { + InvalidateCurrentRow(dataGridView); + } + + private void OnDataGridViewEnter(object sender, EventArgs e) + { + InvalidateCurrentRow(dataGridView); + } + + private void OnFilterGridViewEnter(object sender, EventArgs e) + { + InvalidateCurrentRow(filterGridView); + } + + private void OnFilterGridViewLeave(object sender, EventArgs e) + { + InvalidateCurrentRow(filterGridView); + } + + private void OnDataGridViewResize(object sender, EventArgs e) + { + if (_logFileReader != null && dataGridView.RowCount > 0 && _guiStateArgs.FollowTail) + { + dataGridView.FirstDisplayedScrollingRowIndex = dataGridView.RowCount - 1; + } + } + + private void OnDataGridViewSelectionChanged(object sender, EventArgs e) + { + UpdateSelectionDisplay(); + } + + private void OnSelectionChangedTriggerSignal(object sender, EventArgs e) + { + int selCount = 0; + try + { + _logger.Debug("Selection changed trigger"); + selCount = dataGridView.SelectedRows.Count; + if (selCount > 1) + { + StatusLineText(selCount + " selected lines"); + } + else + { + if (IsMultiFile) + { + MethodInvoker invoker = DisplayCurrentFileOnStatusline; + invoker.BeginInvoke(null, null); + } + else + { + StatusLineText(""); + } + } + } + catch (Exception ex) + { + _logger.Error(ex, "Error in selectionChangedTrigger_Signal selcount {0}", selCount); + } + } + + private void OnFilterKnobControlValueChanged(object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + private void OnFilterToTabButtonClick(object sender, EventArgs e) + { + FilterToTab(); + } + + private void OnPipeDisconnected(object sender, EventArgs e) + { + if (sender.GetType() == typeof(FilterPipe)) + { + lock (_filterPipeList) + { + _filterPipeList.Remove((FilterPipe)sender); + if (_filterPipeList.Count == 0) + // reset naming counter to 0 if no more open filter tabs for this source window + { + _filterPipeNameCounter = 0; + } + } + } + } + + private void OnAdvancedButtonClick(object sender, EventArgs e) + { + _showAdvanced = !_showAdvanced; + ShowAdvancedFilterPanel(_showAdvanced); + } + + private void OnFilterSplitContainerMouseDown(object sender, MouseEventArgs e) + { + ((SplitContainer)sender).IsSplitterFixed = true; + } + + private void OnFilterSplitContainerMouseUp(object sender, MouseEventArgs e) + { + ((SplitContainer)sender).IsSplitterFixed = false; + } + + private void OnFilterSplitContainerMouseMove(object sender, MouseEventArgs e) + { + SplitContainer splitContainer = (SplitContainer)sender; + if (splitContainer.IsSplitterFixed) + { + if (e.Button.Equals(MouseButtons.Left)) + { + if (splitContainer.Orientation.Equals(Orientation.Vertical)) + { + if (e.X > 0 && e.X < splitContainer.Width) + { + splitContainer.SplitterDistance = e.X; + splitContainer.Refresh(); + } + } + else + { + if (e.Y > 0 && e.Y < splitContainer.Height) + { + splitContainer.SplitterDistance = e.Y; + splitContainer.Refresh(); + } + } + } + else + { + splitContainer.IsSplitterFixed = false; + } + } + } + + private void OnFilterSplitContainerMouseDoubleClick(object sender, MouseEventArgs e) + { + AutoResizeFilterBox(); + } + + #region Context Menu + + private void OnDataGridContextMenuStripOpening(object sender, CancelEventArgs e) + { + int lineNum = -1; + if (dataGridView.CurrentRow != null) + { + lineNum = dataGridView.CurrentRow.Index; + } + + if (lineNum == -1) + { + return; + } + + int refLineNum = lineNum; + + copyToTabToolStripMenuItem.Enabled = dataGridView.SelectedCells.Count > 0; + scrollAllTabsToTimestampToolStripMenuItem.Enabled = CurrentColumnizer.IsTimeshiftImplemented() + && + GetTimestampForLine(ref refLineNum, false) != + DateTime.MinValue; + + locateLineInOriginalFileToolStripMenuItem.Enabled = IsTempFile && + FilterPipe != null && + FilterPipe.GetOriginalLineNum(lineNum) != -1; + + markEditModeToolStripMenuItem.Enabled = !dataGridView.CurrentCell.ReadOnly; + + // Remove all "old" plugin entries + int index = dataGridContextMenuStrip.Items.IndexOf(pluginSeparator); + + if (index > 0) + { + for (int i = index + 1; i < dataGridContextMenuStrip.Items.Count;) + { + dataGridContextMenuStrip.Items.RemoveAt(i); + } + } + + // Add plugin entries + bool isAdded = false; + if (PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins.Count > 0) + { + IList lines = GetSelectedContent(); + foreach (IContextMenuEntry entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins) + { + LogExpertCallback callback = new(this); + string menuText = entry.GetMenuText(lines.Count, CurrentColumnizer, callback.GetLogLine(lines[0])); + + if (menuText != null) + { + bool disabled = menuText.StartsWith('_'); + if (disabled) + { + menuText = menuText[1..]; + } + + ToolStripItem item = dataGridContextMenuStrip.Items.Add(menuText, null, OnHandlePluginContextMenu); + item.Tag = new ContextMenuPluginEventArgs(entry, lines, CurrentColumnizer, callback); + item.Enabled = !disabled; + isAdded = true; + } + } + } + + pluginSeparator.Visible = isAdded; + + // enable/disable Temp Highlight item + tempHighlightsToolStripMenuItem.Enabled = _tempHighlightEntryList.Count > 0; + + markCurrentFilterRangeToolStripMenuItem.Enabled = string.IsNullOrEmpty(filterRangeComboBox.Text) == false; + + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + IList list = _parentLogTabWin.GetListOfOpenFiles(); + syncTimestampsToToolStripMenuItem.Enabled = true; + syncTimestampsToToolStripMenuItem.DropDownItems.Clear(); + EventHandler ev = OnHandleSyncContextMenu; + Font italicFont = new(syncTimestampsToToolStripMenuItem.Font.FontFamily, syncTimestampsToToolStripMenuItem.Font.Size, FontStyle.Italic); + + foreach (WindowFileEntry fileEntry in list) + { + if (fileEntry.LogWindow != this) + { + ToolStripMenuItem item = syncTimestampsToToolStripMenuItem.DropDownItems.Add(fileEntry.Title, null, ev) as ToolStripMenuItem; + item.Tag = fileEntry; + item.Checked = TimeSyncList != null && TimeSyncList.Contains(fileEntry.LogWindow); + if (fileEntry.LogWindow.TimeSyncList != null && !fileEntry.LogWindow.TimeSyncList.Contains(this)) + { + item.Font = italicFont; + item.ForeColor = Color.Blue; + } + + item.Enabled = fileEntry.LogWindow.CurrentColumnizer.IsTimeshiftImplemented(); + } + } + } + else + { + syncTimestampsToToolStripMenuItem.Enabled = false; + } + + freeThisWindowFromTimeSyncToolStripMenuItem.Enabled = TimeSyncList != null && + TimeSyncList.Count > 1; + } + + private void OnHandlePluginContextMenu(object sender, EventArgs args) + { + if (sender is ToolStripItem item) + { + ContextMenuPluginEventArgs menuArgs = item.Tag as ContextMenuPluginEventArgs; + var logLines = menuArgs.LogLines; + menuArgs.Entry.MenuSelected(logLines.Count, menuArgs.Columnizer, menuArgs.Callback.GetLogLine(logLines[0])); + } + } + + private void OnHandleSyncContextMenu(object sender, EventArgs args) + { + if (sender is ToolStripItem item) + { + WindowFileEntry entry = item.Tag as WindowFileEntry; + + if (TimeSyncList != null && TimeSyncList.Contains(entry.LogWindow)) + { + FreeSlaveFromTimesync(entry.LogWindow); + } + else + //AddSlaveToTimesync(entry.LogWindow); + { + AddOtherWindowToTimesync(entry.LogWindow); + } + } + } + + private void OnCopyToolStripMenuItemClick(object sender, EventArgs e) + { + CopyMarkedLinesToClipboard(); + } + + private void OnCopyToTabToolStripMenuItemClick(object sender, EventArgs e) + { + CopyMarkedLinesToTab(); + } + + private void OnScrollAllTabsToTimestampToolStripMenuItemClick(object sender, EventArgs e) + { + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + int currentLine = dataGridView.CurrentCellAddress.Y; + if (currentLine > 0 && currentLine < dataGridView.RowCount) + { + int lineNum = currentLine; + DateTime timeStamp = GetTimestampForLine(ref lineNum, false); + if (timeStamp.Equals(DateTime.MinValue)) // means: invalid + { + return; + } + + _parentLogTabWin.ScrollAllTabsToTimestamp(timeStamp, this); + } + } + } + + private void OnLocateLineInOriginalFileToolStripMenuItemClick(object sender, EventArgs e) + { + if (dataGridView.CurrentRow != null && FilterPipe != null) + { + int lineNum = FilterPipe.GetOriginalLineNum(dataGridView.CurrentRow.Index); + if (lineNum != -1) + { + FilterPipe.LogWindow.SelectLine(lineNum, false, true); + _parentLogTabWin.SelectTab(FilterPipe.LogWindow); + } + } + } + + private void OnToggleBoomarkToolStripMenuItemClick(object sender, EventArgs e) + { + ToggleBookmark(); + } + + private void OnMarkEditModeToolStripMenuItemClick(object sender, EventArgs e) + { + StartEditMode(); + } + + private void OnLogWindowSizeChanged(object sender, EventArgs e) + { + //AdjustMinimumGridWith(); + AdjustHighlightSplitterWidth(); + } + + #region BookMarkList + + private void OnColumnRestrictCheckBoxCheckedChanged(object sender, EventArgs e) + { + columnButton.Enabled = columnRestrictCheckBox.Checked; + if (columnRestrictCheckBox.Checked) // disable when nothing to filter + { + columnNamesLabel.Visible = true; + _filterParams.ColumnRestrict = true; + columnNamesLabel.Text = CalculateColumnNames(_filterParams); + } + else + { + columnNamesLabel.Visible = false; + } + + CheckForFilterDirty(); + } + + private void OnColumnButtonClick(object sender, EventArgs e) + { + _filterParams.CurrentColumnizer = _currentColumnizer; + FilterColumnChooser chooser = new(_filterParams); + if (chooser.ShowDialog() == DialogResult.OK) + { + columnNamesLabel.Text = CalculateColumnNames(_filterParams); + + //CheckForFilterDirty(); //!!!GBro: Indicate to redo the search if search columns were changed + filterSearchButton.Image = _searchButtonImage; + saveFilterButton.Enabled = false; + } + } + + #endregion + + #region Column Header Context Menu + + private void OnDataGridViewCellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) + { + if (e.RowIndex >= 0 && e.RowIndex < dataGridView.RowCount && !dataGridView.Rows[e.RowIndex].Selected) + { + SelectLine(e.RowIndex, false, true); + } + else if (e.RowIndex < 0) + { + e.ContextMenuStrip = columnContextMenuStrip; + } + + if (e.ContextMenuStrip == columnContextMenuStrip) + { + _selectedCol = e.ColumnIndex; + } + } + + //private void boomarkDataGridView_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) + //{ + // if (e.RowIndex > 0 && e.RowIndex < this.boomarkDataGridView.RowCount + // && !this.boomarkDataGridView.Rows[e.RowIndex].Selected) + // { + // this.boomarkDataGridView.Rows[e.RowIndex].Selected = true; + // this.boomarkDataGridView.CurrentCell = this.boomarkDataGridView.Rows[e.RowIndex].Cells[0]; + // } + // if (e.ContextMenuStrip == this.columnContextMenuStrip) + // { + // this.selectedCol = e.ColumnIndex; + // } + //} + + private void OnFilterGridViewCellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) + { + if (e.ContextMenuStrip == columnContextMenuStrip) + { + _selectedCol = e.ColumnIndex; + } + } + + private void OnColumnContextMenuStripOpening(object sender, CancelEventArgs e) + { + Control ctl = columnContextMenuStrip.SourceControl; + BufferedDataGridView gridView = ctl as BufferedDataGridView; + bool frozen = false; + if (_freezeStateMap.TryGetValue(ctl, out bool value)) + { + frozen = value; + } + + freezeLeftColumnsUntilHereToolStripMenuItem.Checked = frozen; + + if (frozen) + { + freezeLeftColumnsUntilHereToolStripMenuItem.Text = "Frozen"; + } + else + { + if (ctl is BufferedDataGridView) + { + freezeLeftColumnsUntilHereToolStripMenuItem.Text = $"Freeze left columns until here ({gridView.Columns[_selectedCol].HeaderText})"; + } + } + + + DataGridViewColumn col = gridView.Columns[_selectedCol]; + moveLeftToolStripMenuItem.Enabled = col != null && col.DisplayIndex > 0; + moveRightToolStripMenuItem.Enabled = col != null && col.DisplayIndex < gridView.Columns.Count - 1; + + if (gridView.Columns.Count - 1 > _selectedCol) + { + // DataGridViewColumn colRight = gridView.Columns[this.selectedCol + 1]; + DataGridViewColumn colRight = gridView.Columns.GetNextColumn(col, DataGridViewElementStates.None, DataGridViewElementStates.None); + moveRightToolStripMenuItem.Enabled = colRight != null && colRight.Frozen == col.Frozen; + } + + if (_selectedCol > 0) + { + //DataGridViewColumn colLeft = gridView.Columns[this.selectedCol - 1]; + DataGridViewColumn colLeft = gridView.Columns.GetPreviousColumn(col, DataGridViewElementStates.None, DataGridViewElementStates.None); + + moveLeftToolStripMenuItem.Enabled = colLeft != null && colLeft.Frozen == col.Frozen; + } + + DataGridViewColumn colLast = gridView.Columns[gridView.Columns.Count - 1]; + moveToLastColumnToolStripMenuItem.Enabled = colLast != null && colLast.Frozen == col.Frozen; + + // Fill context menu with column names + // + EventHandler ev = OnHandleColumnItemContextMenu; + allColumnsToolStripMenuItem.DropDownItems.Clear(); + foreach (DataGridViewColumn column in gridView.Columns) + { + if (column.HeaderText.Length > 0) + { + ToolStripMenuItem item = allColumnsToolStripMenuItem.DropDownItems.Add(column.HeaderText, null, ev) as ToolStripMenuItem; + item.Tag = column; + item.Enabled = !column.Frozen; + } + } + } + + private void OnHandleColumnItemContextMenu(object sender, EventArgs args) + { + if (sender is ToolStripItem item) + { + DataGridViewColumn column = item.Tag as DataGridViewColumn; + column.Visible = true; + column.DataGridView.FirstDisplayedScrollingColumnIndex = column.Index; + } + } + + private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick(object sender, EventArgs e) + { + Control ctl = columnContextMenuStrip.SourceControl; + bool frozen = false; + + if (_freezeStateMap.TryGetValue(ctl, out bool value)) + { + frozen = value; + } + + frozen = !frozen; + _freezeStateMap[ctl] = frozen; + + if (ctl is BufferedDataGridView gridView) + { + ApplyFrozenState(gridView); + } + } + + private void OnMoveToLastColumnToolStripMenuItemClick(object sender, EventArgs e) + { + BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + DataGridViewColumn col = gridView.Columns[_selectedCol]; + if (col != null) + { + col.DisplayIndex = gridView.Columns.Count - 1; + } + } + + private void OnMoveLeftToolStripMenuItemClick(object sender, EventArgs e) + { + BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + DataGridViewColumn col = gridView.Columns[_selectedCol]; + if (col != null && col.DisplayIndex > 0) + { + col.DisplayIndex -= 1; + } + } + + private void OnMoveRightToolStripMenuItemClick(object sender, EventArgs e) + { + BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + DataGridViewColumn col = gridView.Columns[_selectedCol]; + if (col != null && col.DisplayIndex < gridView.Columns.Count - 1) + { + col.DisplayIndex = col.DisplayIndex + 1; + } + } + + private void OnHideColumnToolStripMenuItemClick(object sender, EventArgs e) + { + BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + DataGridViewColumn col = gridView.Columns[_selectedCol]; + col.Visible = false; + } + + private void OnRestoreColumnsToolStripMenuItemClick(object sender, EventArgs e) + { + BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + foreach (DataGridViewColumn col in gridView.Columns) + { + col.Visible = true; + } + } + + private void OnTimeSpreadingControlLineSelected(object sender, SelectLineEventArgs e) + { + SelectLine(e.Line, false, true); + } + + private void OnBookmarkCommentToolStripMenuItemClick(object sender, EventArgs e) + { + AddBookmarkAndEditComment(); + } + + private void OnHighlightSelectionInLogFileToolStripMenuItemClick(object sender, EventArgs e) + { + if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) + { + var he = new HighlightEntry() + { + SearchText = ctl.SelectedText, + ForegroundColor = Color.Red, + BackgroundColor = Color.Yellow, + IsRegEx = false, + IsCaseSensitive = true, + IsLedSwitch = false, + IsSetBookmark = false, + IsActionEntry = false, + ActionEntry = null, + IsWordMatch = false + }; + + lock (_tempHighlightEntryListLock) + { + _tempHighlightEntryList.Add(he); + } + + dataGridView.CancelEdit(); + dataGridView.EndEdit(); + RefreshAllGrids(); + } + } + + private void OnHighlightSelectionInLogFilewordModeToolStripMenuItemClick(object sender, EventArgs e) + { + if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) + { + HighlightEntry he = new() + { + SearchText = ctl.SelectedText, + ForegroundColor = Color.Red, + BackgroundColor = Color.Yellow, + IsRegEx = false, + IsCaseSensitive = true, + IsLedSwitch = false, + IsStopTail = false, + IsSetBookmark = false, + IsActionEntry = false, + ActionEntry = null, + IsWordMatch = true + }; + + lock (_tempHighlightEntryListLock) + { + _tempHighlightEntryList.Add(he); + } + + dataGridView.CancelEdit(); + dataGridView.EndEdit(); + RefreshAllGrids(); + } + } + + private void OnEditModeCopyToolStripMenuItemClick(object sender, EventArgs e) + { + if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) + { + if (Util.IsNull(ctl.SelectedText) == false) + { + Clipboard.SetText(ctl.SelectedText); + } + } + } + + private void OnRemoveAllToolStripMenuItemClick(object sender, EventArgs e) + { + RemoveTempHighlights(); + } + + private void OnMakePermanentToolStripMenuItemClick(object sender, EventArgs e) + { + lock (_tempHighlightEntryListLock) + { + lock (_currentHighlightGroupLock) + { + _currentHighlightGroup.HighlightEntryList.AddRange(_tempHighlightEntryList); + RemoveTempHighlights(); + OnCurrentHighlightListChanged(); + } + } + } + + private void OnMarkCurrentFilterRangeToolStripMenuItemClick(object sender, EventArgs e) + { + MarkCurrentFilterRange(); + } + + private void OnFilterForSelectionToolStripMenuItemClick(object sender, EventArgs e) + { + if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) + { + splitContainerLogWindow.Panel2Collapsed = false; + ResetFilterControls(); + FilterSearch(ctl.SelectedText); + } + } + + private void OnSetSelectedTextAsBookmarkCommentToolStripMenuItemClick(object sender, EventArgs e) + { + if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) + { + AddBookmarkComment(ctl.SelectedText); + } + } + + private void OnDataGridViewCellClick(object sender, DataGridViewCellEventArgs e) + { + _shouldCallTimeSync = true; + } + + private void OnDataGridViewCellDoubleClick(object sender, DataGridViewCellEventArgs e) + { + if (e.ColumnIndex == 0) + { + ToggleBookmark(); + } + } + + private void OnDataGridViewOverlayDoubleClicked(object sender, OverlayEventArgs e) + { + BookmarkComment(e.BookmarkOverlay.Bookmark); + } + + private void OnFilterRegexCheckBoxMouseUp(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + RegexHelperDialog dlg = new() + { + ExpressionHistoryList = ConfigManager.Settings.RegexHistory.ExpressionHistoryList, + TesttextHistoryList = ConfigManager.Settings.RegexHistory.TesttextHistoryList, + Owner = this, + CaseSensitive = filterCaseSensitiveCheckBox.Checked, + Pattern = filterComboBox.Text + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + ConfigManager.Settings.RegexHistory.ExpressionHistoryList = dlg.ExpressionHistoryList; + ConfigManager.Settings.RegexHistory.TesttextHistoryList = dlg.TesttextHistoryList; + + filterCaseSensitiveCheckBox.Checked = dlg.CaseSensitive; + filterComboBox.Text = dlg.Pattern; + + ConfigManager.Save(SettingsFlags.RegexHistory); + } + } + } + + #endregion + + #region Filter-Highlight + + private void OnToggleHighlightPanelButtonClick(object sender, EventArgs e) + { + ToggleHighlightPanel(highlightSplitContainer.Panel2Collapsed); + } + + private void OnSaveFilterButtonClick(object sender, EventArgs e) + { + FilterParams newParams = _filterParams.Clone(); + newParams.Color = Color.FromKnownColor(KnownColor.Black); + ConfigManager.Settings.filterList.Add(newParams); + OnFilterListChanged(this); + } + + private void OnDeleteFilterButtonClick(object sender, EventArgs e) + { + int index = filterListBox.SelectedIndex; + if (index >= 0) + { + FilterParams filterParams = (FilterParams)filterListBox.Items[index]; + ConfigManager.Settings.filterList.Remove(filterParams); + OnFilterListChanged(this); + if (filterListBox.Items.Count > 0) + { + filterListBox.SelectedIndex = filterListBox.Items.Count - 1; + } + } + } + + private void OnFilterUpButtonClick(object sender, EventArgs e) + { + int i = filterListBox.SelectedIndex; + if (i > 0) + { + FilterParams filterParams = (FilterParams)filterListBox.Items[i]; + ConfigManager.Settings.filterList.RemoveAt(i); + i--; + ConfigManager.Settings.filterList.Insert(i, filterParams); + OnFilterListChanged(this); + filterListBox.SelectedIndex = i; + } + } + + private void OnFilterDownButtonClick(object sender, EventArgs e) + { + int i = filterListBox.SelectedIndex; + if (i < 0) + { + return; + } + + if (i < filterListBox.Items.Count - 1) + { + FilterParams filterParams = (FilterParams)filterListBox.Items[i]; + ConfigManager.Settings.filterList.RemoveAt(i); + i++; + ConfigManager.Settings.filterList.Insert(i, filterParams); + OnFilterListChanged(this); + filterListBox.SelectedIndex = i; + } + } + + private void OnFilterListBoxMouseDoubleClick(object sender, MouseEventArgs e) + { + if (filterListBox.SelectedIndex >= 0) + { + FilterParams filterParams = (FilterParams)filterListBox.Items[filterListBox.SelectedIndex]; + FilterParams newParams = filterParams.Clone(); + //newParams.historyList = ConfigManager.Settings.filterHistoryList; + this._filterParams = newParams; + ReInitFilterParams(this._filterParams); + ApplyFilterParams(); + CheckForAdvancedButtonDirty(); + CheckForFilterDirty(); + filterSearchButton.Image = _searchButtonImage; + saveFilterButton.Enabled = false; + if (hideFilterListOnLoadCheckBox.Checked) + { + ToggleHighlightPanel(false); + } + + if (filterOnLoadCheckBox.Checked) + { + FilterSearch(); + } + } + } + + private void OnFilterListBoxDrawItem(object sender, DrawItemEventArgs e) + { + e.DrawBackground(); + if (e.Index >= 0) + { + FilterParams filterParams = (FilterParams)filterListBox.Items[e.Index]; + Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); + + Brush brush; + + if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) + { + brush = new SolidBrush(filterListBox.BackColor); + } + else + { + brush = new SolidBrush(filterParams.Color); + } + + e.Graphics.DrawString(filterParams.SearchText, e.Font, brush, + new PointF(rectangle.Left, rectangle.Top)); + e.DrawFocusRectangle(); + brush.Dispose(); + } + } + + // Color for filter list entry + private void OnColorToolStripMenuItemClick(object sender, EventArgs e) + { + int i = filterListBox.SelectedIndex; + if (i < filterListBox.Items.Count && i >= 0) + { + FilterParams filterParams = (FilterParams)filterListBox.Items[i]; + ColorDialog dlg = new(); + dlg.CustomColors = new[] { filterParams.Color.ToArgb() }; + dlg.Color = filterParams.Color; + if (dlg.ShowDialog() == DialogResult.OK) + { + filterParams.Color = dlg.Color; + filterListBox.Refresh(); + } + } + } + + private void OnFilterCaseSensitiveCheckBoxCheckedChanged(object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + private void OnFilterRegexCheckBoxCheckedChanged(object sender, EventArgs e) + { + fuzzyKnobControl.Enabled = !filterRegexCheckBox.Checked; + fuzzyLabel.Enabled = !filterRegexCheckBox.Checked; + CheckForFilterDirty(); + } + + private void OnInvertFilterCheckBoxCheckedChanged(object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + private void OnFilterRangeComboBoxTextChanged(object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + private void OnFuzzyKnobControlValueChanged(object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + private void OnFilterComboBoxTextChanged(object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + private void OnSetBookmarksOnSelectedLinesToolStripMenuItemClick(object sender, EventArgs e) + { + SetBookmarksForSelectedFilterLines(); + } + + private void OnParentHighlightSettingsChanged(object sender, EventArgs e) + { + string groupName = _guiStateArgs.HighlightGroupName; + SetCurrentHighlightGroup(groupName); + } + + private void OnFilterOnLoadCheckBoxMouseClick(object sender, MouseEventArgs e) + { + HandleChangedFilterOnLoadSetting(); + } + + private void OnFilterOnLoadCheckBoxKeyPress(object sender, KeyPressEventArgs e) + { + HandleChangedFilterOnLoadSetting(); + } + + private void OnHideFilterListOnLoadCheckBoxMouseClick(object sender, MouseEventArgs e) + { + HandleChangedFilterOnLoadSetting(); + } + + private void OnFilterToTabToolStripMenuItemClick(object sender, EventArgs e) + { + FilterToTab(); + } + + private void OnTimeSyncListWindowRemoved(object sender, EventArgs e) + { + TimeSyncList syncList = sender as TimeSyncList; + lock (_timeSyncListLock) + { + if (syncList.Count == 0 || syncList.Count == 1 && syncList.Contains(this)) + { + if (syncList == TimeSyncList) + { + TimeSyncList = null; + OnSyncModeChanged(); + } + } + } + } + + private void OnFreeThisWindowFromTimeSyncToolStripMenuItemClick(object sender, EventArgs e) + { + FreeFromTimeSync(); + } + + private void OnSplitContainerSplitterMoved(object sender, SplitterEventArgs e) + { + advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; + } + + private void OnMarkFilterHitsInLogViewToolStripMenuItemClick(object sender, EventArgs e) + { + SearchParams p = new(); + p.SearchText = _filterParams.SearchText; + p.IsRegex = _filterParams.IsRegex; + p.IsCaseSensitive = _filterParams.IsCaseSensitive; + AddSearchHitHighlightEntry(p); + } + + private void OnColumnComboBoxSelectionChangeCommitted(object sender, EventArgs e) + { + SelectColumn(); + } + + private void OnColumnComboBoxKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + SelectColumn(); + dataGridView.Focus(); + } + } + + private void OnColumnComboBoxPreviewKeyDown(object sender, PreviewKeyDownEventArgs e) + { + if (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt) + { + columnComboBox.DroppedDown = true; + } + + if (e.KeyCode == Keys.Enter) + { + e.IsInputKey = true; + } + } + + private void OnBookmarkProviderBookmarkRemoved(object sender, EventArgs e) + { + if (!_isLoading) + { + dataGridView.Refresh(); + filterGridView.Refresh(); + } + } + + private void OnBookmarkProviderBookmarkAdded(object sender, EventArgs e) + { + if (!_isLoading) + { + dataGridView.Refresh(); + filterGridView.Refresh(); + } + } + + private void OnBookmarkProviderAllBookmarksRemoved(object sender, EventArgs e) + { + // nothing + } + + private void OnLogWindowLeave(object sender, EventArgs e) + { + InvalidateCurrentRow(); + } + + private void OnLogWindowEnter(object sender, EventArgs e) + { + InvalidateCurrentRow(); + } + + private void OnDataGridViewRowUnshared(object sender, DataGridViewRowEventArgs e) + { + if (_logger.IsTraceEnabled) + { + _logger.Trace($"Row unshared line {e.Row.Cells[1].Value}"); + } + } + + #endregion + + #endregion + + #endregion + + private void MeasureItem(object sender, MeasureItemEventArgs e) + { + e.ItemHeight = filterListBox.Font.Height; + } + } +} diff --git a/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs b/src/Logexpert.UI/Controls/LogWindow/LogWindowPrivate.cs similarity index 96% rename from src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs rename to src/Logexpert.UI/Controls/LogWindow/LogWindowPrivate.cs index 41e2d047..5b5622ed 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/Logexpert.UI/Controls/LogWindow/LogWindowPrivate.cs @@ -1,3758 +1,3745 @@ -using LogExpert.Classes; -using LogExpert.Classes.Filter; -using LogExpert.Classes.ILogLineColumnizerCallback; -using LogExpert.Config; -using LogExpert.Core.Classes; -using LogExpert.Core.Classes.Columnizer; -using LogExpert.Core.Classes.Filter; -using LogExpert.Core.Classes.Highlight; -using LogExpert.Core.Classes.Persister; -using LogExpert.Core.Config; -using LogExpert.Core.Entities; -using LogExpert.Core.EventArgs; -using LogExpert.Core.Interface; -using LogExpert.Dialogs; -using LogExpert.Extensions; -using LogExpert.UI.Controls; - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Linq; -//using System.Runtime.Remoting.Messaging; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace LogExpert.Controls.LogWindow -{ - public partial class LogWindow - { - #region Private Methods - - private void RegisterLogFileReaderEvents() - { - _logFileReader.LoadFile += OnLogFileReaderLoadFile; - _logFileReader.LoadingFinished += OnLogFileReaderFinishedLoading; - _logFileReader.LoadingStarted += OnLogFileReaderLoadingStarted; - _logFileReader.FileNotFound += OnLogFileReaderFileNotFound; - _logFileReader.Respawned += OnLogFileReaderRespawned; - // FileSizeChanged is not registered here because it's registered after loading has finished - } - - private void UnRegisterLogFileReaderEvents() - { - if (_logFileReader != null) - { - _logFileReader.LoadFile -= OnLogFileReaderLoadFile; - _logFileReader.LoadingFinished -= OnLogFileReaderFinishedLoading; - _logFileReader.LoadingStarted -= OnLogFileReaderLoadingStarted; - _logFileReader.FileNotFound -= OnLogFileReaderFileNotFound; - _logFileReader.Respawned -= OnLogFileReaderRespawned; - _logFileReader.FileSizeChanged -= OnFileSizeChanged; - } - } - - private void CreateDefaultViewStyle() - { - DataGridViewCellStyle dataGridViewCellStyleMainGrid = new(); - DataGridViewCellStyle dataGridViewCellStyleFilterGrid = new(); - - dataGridViewCellStyleMainGrid.Alignment = DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyleMainGrid.BackColor = SystemColors.Window; - dataGridViewCellStyleMainGrid.Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - dataGridViewCellStyleMainGrid.ForeColor = SystemColors.ControlText; - dataGridViewCellStyleMainGrid.SelectionBackColor = SystemColors.Highlight; - dataGridViewCellStyleMainGrid.SelectionForeColor = SystemColors.HighlightText; - dataGridViewCellStyleMainGrid.WrapMode = DataGridViewTriState.False; - dataGridView.DefaultCellStyle = dataGridViewCellStyleMainGrid; - - dataGridViewCellStyleFilterGrid.Alignment = DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyleFilterGrid.BackColor = SystemColors.Window; - dataGridViewCellStyleFilterGrid.Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - dataGridViewCellStyleFilterGrid.ForeColor = SystemColors.ControlText; - dataGridViewCellStyleFilterGrid.SelectionBackColor = SystemColors.Highlight; - dataGridViewCellStyleFilterGrid.SelectionForeColor = SystemColors.HighlightText; - dataGridViewCellStyleFilterGrid.WrapMode = DataGridViewTriState.False; - filterGridView.DefaultCellStyle = dataGridViewCellStyleFilterGrid; - } - - private bool LoadPersistenceOptions() - { - if (InvokeRequired) - { - return (bool)Invoke(new BoolReturnDelegate(LoadPersistenceOptions)); - } - - if (!Preferences.saveSessions && ForcedPersistenceFileName == null) - { - return false; - } - - try - { - PersistenceData persistenceData; - if (ForcedPersistenceFileName == null) - { - persistenceData = Persister.LoadPersistenceDataOptionsOnly(FileName, Preferences); - } - else - { - persistenceData = - Persister.LoadPersistenceDataOptionsOnlyFromFixedFile(ForcedPersistenceFileName); - } - - if (persistenceData == null) - { - _logger.Info($"No persistence data for {FileName} found."); - return false; - } - - IsMultiFile = persistenceData.multiFile; - _multiFileOptions = new MultiFileOptions(); - _multiFileOptions.FormatPattern = persistenceData.multiFilePattern; - _multiFileOptions.MaxDayTry = persistenceData.multiFileMaxDays; - - if (string.IsNullOrEmpty(_multiFileOptions.FormatPattern)) - { - _multiFileOptions = ObjectClone.Clone(Preferences.multiFileOptions); - } - - splitContainerLogWindow.SplitterDistance = persistenceData.filterPosition; - splitContainerLogWindow.Panel2Collapsed = !persistenceData.filterVisible; - ToggleHighlightPanel(persistenceData.filterSaveListVisible); - ShowAdvancedFilterPanel(persistenceData.filterAdvanced); - - if (_reloadMemento == null) - { - PreselectColumnizer(persistenceData.columnizerName); - } - - FollowTailChanged(persistenceData.followTail, false); - if (persistenceData.tabName != null) - { - Text = persistenceData.tabName; - } - - AdjustHighlightSplitterWidth(); - SetCurrentHighlightGroup(persistenceData.highlightGroupName); - - if (persistenceData.multiFileNames.Count > 0) - { - _logger.Info("Detected MultiFile name list in persistence options"); - _fileNames = new string[persistenceData.multiFileNames.Count]; - persistenceData.multiFileNames.CopyTo(_fileNames); - } - else - { - _fileNames = null; - } - - //this.bookmarkWindow.ShowBookmarkCommentColumn = persistenceData.showBookmarkCommentColumn; - SetExplicitEncoding(persistenceData.encoding); - return true; - } - catch (Exception ex) - { - _logger.Error(ex, "Error loading persistence data: "); - return false; - } - } - - private void SetDefaultsFromPrefs() - { - filterTailCheckBox.Checked = Preferences.filterTail; - syncFilterCheckBox.Checked = Preferences.filterSync; - FollowTailChanged(Preferences.followTail, false); - _multiFileOptions = ObjectClone.Clone(Preferences.multiFileOptions); - } - - private void LoadPersistenceData() - { - if (InvokeRequired) - { - Invoke(new MethodInvoker(LoadPersistenceData)); - return; - } - - if (!Preferences.saveSessions && !ForcePersistenceLoading && ForcedPersistenceFileName == null) - { - SetDefaultsFromPrefs(); - return; - } - - if (IsTempFile) - { - SetDefaultsFromPrefs(); - return; - } - - ForcePersistenceLoading = false; // force only 1 time (while session load) - - try - { - PersistenceData persistenceData; - - if (ForcedPersistenceFileName == null) - { - persistenceData = Persister.LoadPersistenceData(FileName, Preferences); - } - else - { - persistenceData = Persister.LoadPersistenceDataFromFixedFile(ForcedPersistenceFileName); - } - - if (persistenceData.lineCount > _logFileReader.LineCount) - { - // outdated persistence data (logfile rollover) - // MessageBox.Show(this, "Persistence data for " + this.FileName + " is outdated. It was discarded.", "Log Expert"); - _logger.Info("Persistence data for {0} is outdated. It was discarded.", FileName); - LoadPersistenceOptions(); - return; - } - - _bookmarkProvider.BookmarkList = persistenceData.bookmarkList; - _rowHeightList = persistenceData.rowHeightList; - try - { - if (persistenceData.currentLine >= 0 && persistenceData.currentLine < dataGridView.RowCount) - { - SelectLine(persistenceData.currentLine, false, true); - } - else - { - if (_logFileReader.LineCount > 0) - { - dataGridView.FirstDisplayedScrollingRowIndex = _logFileReader.LineCount - 1; - SelectLine(_logFileReader.LineCount - 1, false, true); - } - } - - if (persistenceData.firstDisplayedLine >= 0 && - persistenceData.firstDisplayedLine < dataGridView.RowCount) - { - dataGridView.FirstDisplayedScrollingRowIndex = persistenceData.firstDisplayedLine; - } - - if (persistenceData.followTail) - { - FollowTailChanged(persistenceData.followTail, false); - } - } - catch (ArgumentOutOfRangeException) - { - // FirstDisplayedScrollingRowIndex calculates sometimes the wrong scrolling ranges??? - } - - if (Preferences.saveFilters) - { - RestoreFilters(persistenceData); - } - } - catch (IOException ex) - { - SetDefaultsFromPrefs(); - _logger.Error(ex, "Error loading bookmarks: "); - } - } - - private void RestoreFilters(PersistenceData persistenceData) - { - if (persistenceData.filterParamsList.Count > 0) - { - _filterParams = persistenceData.filterParamsList[0]; - ReInitFilterParams(_filterParams); - } - - ApplyFilterParams(); // re-loaded filter settingss - BeginInvoke(new MethodInvoker(FilterSearch)); - try - { - splitContainerLogWindow.SplitterDistance = persistenceData.filterPosition; - splitContainerLogWindow.Panel2Collapsed = !persistenceData.filterVisible; - } - catch (InvalidOperationException e) - { - _logger.Error(e, "Error setting splitter distance: "); - } - - ShowAdvancedFilterPanel(persistenceData.filterAdvanced); - if (_filterPipeList.Count == 0) // don't restore if it's only a reload - { - RestoreFilterTabs(persistenceData); - } - } - - private void RestoreFilterTabs(PersistenceData persistenceData) - { - foreach (FilterTabData data in persistenceData.filterTabDataList) - { - FilterParams persistFilterParams = data.FilterParams; - ReInitFilterParams(persistFilterParams); - List filterResultList = []; - //List lastFilterResultList = new List(); - List filterHitList = []; - Filter(persistFilterParams, filterResultList, _lastFilterLinesList, filterHitList); - FilterPipe pipe = new(persistFilterParams.Clone(), this); - WritePipeToTab(pipe, filterResultList, data.PersistenceData.tabName, data.PersistenceData); - } - } - - private void ReInitFilterParams(FilterParams filterParams) - { - filterParams.SearchText = filterParams.SearchText; // init "lowerSearchText" - filterParams.RangeSearchText = filterParams.RangeSearchText; // init "lowerRangesearchText" - filterParams.CurrentColumnizer = CurrentColumnizer; - if (filterParams.IsRegex) - { - try - { - filterParams.CreateRegex(); - } - catch (ArgumentException) - { - StatusLineError("Invalid regular expression"); - } - } - } - - private void EnterLoadFileStatus() - { - _logger.Debug("EnterLoadFileStatus begin"); - - if (InvokeRequired) - { - Invoke(new MethodInvoker(EnterLoadFileStatus)); - return; - } - - _statusEventArgs.StatusText = "Loading file..."; - _statusEventArgs.LineCount = 0; - _statusEventArgs.FileSize = 0; - SendStatusLineUpdate(); - - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = 0; - _progressEventArgs.Value = 0; - _progressEventArgs.Visible = true; - SendProgressBarUpdate(); - - _isLoading = true; - _shouldCancel = true; - ClearFilterList(); - ClearBookmarkList(); - dataGridView.ClearSelection(); - dataGridView.RowCount = 0; - _logger.Debug("EnterLoadFileStatus end"); - } - - private void PositionAfterReload(ReloadMemento reloadMemento) - { - if (_reloadMemento.CurrentLine < dataGridView.RowCount && _reloadMemento.CurrentLine >= 0) - { - dataGridView.CurrentCell = dataGridView.Rows[_reloadMemento.CurrentLine].Cells[0]; - } - - if (_reloadMemento.FirstDisplayedLine < dataGridView.RowCount && _reloadMemento.FirstDisplayedLine >= 0) - { - dataGridView.FirstDisplayedScrollingRowIndex = _reloadMemento.FirstDisplayedLine; - } - } - - private void LogfileDead() - { - _logger.Info("File not found."); - _isDeadFile = true; - - //this.logFileReader.FileSizeChanged -= this.FileSizeChangedHandler; - //if (this.logFileReader != null) - // this.logFileReader.stopMonitoring(); - - dataGridView.Enabled = false; - dataGridView.RowCount = 0; - _progressEventArgs.Visible = false; - _progressEventArgs.Value = _progressEventArgs.MaxValue; - SendProgressBarUpdate(); - _statusEventArgs.FileSize = 0; - _statusEventArgs.LineCount = 0; - _statusEventArgs.CurrentLineNum = 0; - SendStatusLineUpdate(); - _shouldCancel = true; - ClearFilterList(); - ClearBookmarkList(); - - StatusLineText("File not found"); - OnFileNotFound(EventArgs.Empty); - } - - private void LogfileRespawned() - { - _logger.Info("LogfileDead(): Reloading file because it has been respawned."); - _isDeadFile = false; - dataGridView.Enabled = true; - StatusLineText(""); - OnFileRespawned(EventArgs.Empty); - Reload(); - } - - private void SetGuiAfterLoading() - { - if (Text.Length == 0) - { - if (IsTempFile) - { - Text = TempTitleName; - } - else - { - Text = Util.GetNameFromPath(FileName); - } - } - - ShowBookmarkBubbles = Preferences.showBubbles; - //if (this.forcedColumnizer == null) - { - ILogLineColumnizer columnizer; - if (_forcedColumnizerForLoading != null) - { - columnizer = _forcedColumnizerForLoading; - _forcedColumnizerForLoading = null; - } - else - { - columnizer = FindColumnizer(); - if (columnizer != null) - { - if (_reloadMemento == null) - { - //TODO this needs to be refactored - var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - - columnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); - } - } - else - { - //TODO this needs to be refactored - var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - - // Default Columnizers - columnizer = ColumnizerPicker.CloneColumnizer(ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers), directory); - } - } - - Invoke(new SetColumnizerFx(SetColumnizer), columnizer); - } - dataGridView.Enabled = true; - DisplayCurrentFileOnStatusline(); - //this.guiStateArgs.FollowTail = this.Preferences.followTail; - _guiStateArgs.MultiFileEnabled = !IsTempFile; - _guiStateArgs.MenuEnabled = true; - _guiStateArgs.CurrentEncoding = _logFileReader.CurrentEncoding; - SendGuiStateUpdate(); - //if (this.dataGridView.RowCount > 0) - // SelectLine(this.dataGridView.RowCount - 1); - //if (this.dataGridView.Columns.Count > 1) - //{ - // this.dataGridView.Columns[this.dataGridView.Columns.Count-1].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; - // this.dataGridView.Columns[this.dataGridView.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - // AdjustMinimumGridWith(); - //} - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - if (Preferences.timestampControl) - { - SetTimestampLimits(); - SyncTimestampDisplay(); - } - - Settings settings = ConfigManager.Settings; - ShowLineColumn(!settings.hideLineColumn); - } - - ShowTimeSpread(Preferences.showTimeSpread && CurrentColumnizer.IsTimeshiftImplemented()); - locateLineInOriginalFileToolStripMenuItem.Enabled = FilterPipe != null; - } - - private ILogLineColumnizer FindColumnizer() - { - ILogLineColumnizer columnizer; - if (Preferences.maskPrio) - { - columnizer = _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)) ?? _parentLogTabWin.GetColumnizerHistoryEntry(FileName); - } - else - { - columnizer = _parentLogTabWin.GetColumnizerHistoryEntry(FileName) ?? _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)); - } - - return columnizer; - } - - private void ReloadNewFile() - { - // prevent "overloads". May occur on very fast rollovers (next rollover before the file is reloaded) - lock (_reloadLock) - { - _reloadOverloadCounter++; - _logger.Info("ReloadNewFile(): counter = {0}", _reloadOverloadCounter); - if (_reloadOverloadCounter <= 1) - { - SavePersistenceData(false); - _loadingFinishedEvent.Reset(); - _externaLoadingFinishedEvent.Reset(); - Thread reloadFinishedThread = new(ReloadFinishedThreadFx); - reloadFinishedThread.IsBackground = true; - reloadFinishedThread.Start(); - LoadFile(FileName, EncodingOptions); - - ClearBookmarkList(); - SavePersistenceData(false); - - //if (this.filterTailCheckBox.Checked) - //{ - // _logger.logDebug("Waiting for loading to be complete."); - // loadingFinishedEvent.WaitOne(); - // _logger.logDebug("Refreshing filter view because of reload."); - // FilterSearch(); - //} - //LoadFilterPipes(); - } - else - { - _logger.Debug("Preventing reload because of recursive calls."); - } - - _reloadOverloadCounter--; - } - } - - private void ReloadFinishedThreadFx() - { - _logger.Info("Waiting for loading to be complete."); - _loadingFinishedEvent.WaitOne(); - _logger.Info("Refreshing filter view because of reload."); - Invoke(new MethodInvoker(FilterSearch)); - LoadFilterPipes(); - } - - private void UpdateProgress(LoadFileEventArgs e) - { - try - { - if (e.ReadPos >= e.FileSize) - { - //_logger.Warn("UpdateProgress(): ReadPos (" + e.ReadPos + ") is greater than file size (" + e.FileSize + "). Aborting Update"); - return; - } - - _statusEventArgs.FileSize = e.ReadPos; - //this.progressEventArgs.Visible = true; - _progressEventArgs.MaxValue = (int)e.FileSize; - _progressEventArgs.Value = (int)e.ReadPos; - SendProgressBarUpdate(); - SendStatusLineUpdate(); - } - catch (Exception ex) - { - _logger.Error(ex, "UpdateProgress(): "); - } - } - - private void LoadingStarted(LoadFileEventArgs e) - { - try - { - _statusEventArgs.FileSize = e.ReadPos; - _statusEventArgs.StatusText = "Loading " + Util.GetNameFromPath(e.FileName); - _progressEventArgs.Visible = true; - _progressEventArgs.MaxValue = (int)e.FileSize; - _progressEventArgs.Value = (int)e.ReadPos; - SendProgressBarUpdate(); - SendStatusLineUpdate(); - } - catch (Exception ex) - { - _logger.Error(ex, "LoadingStarted(): "); - } - } - - private void LoadingFinished() - { - _logger.Info("File loading complete."); - - StatusLineText(""); - _logFileReader.FileSizeChanged += OnFileSizeChanged; - _isLoading = false; - _shouldCancel = false; - dataGridView.SuspendLayout(); - dataGridView.RowCount = _logFileReader.LineCount; - dataGridView.CurrentCellChanged += OnDataGridViewCurrentCellChanged; - dataGridView.Enabled = true; - dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - dataGridView.ResumeLayout(); - _progressEventArgs.Visible = false; - _progressEventArgs.Value = _progressEventArgs.MaxValue; - SendProgressBarUpdate(); - //if (this.logFileReader.LineCount > 0) - //{ - // this.dataGridView.FirstDisplayedScrollingRowIndex = this.logFileReader.LineCount - 1; - // SelectLine(this.logFileReader.LineCount - 1); - //} - _guiStateArgs.FollowTail = true; - SendGuiStateUpdate(); - _statusEventArgs.LineCount = _logFileReader.LineCount; - _statusEventArgs.FileSize = _logFileReader.FileSize; - SendStatusLineUpdate(); - - PreferencesChanged(_parentLogTabWin.Preferences, true, SettingsFlags.All); - //LoadPersistenceData(); - } - - private void LogEventWorker() - { - Thread.CurrentThread.Name = "LogEventWorker"; - while (true) - { - _logger.Debug("Waiting for signal"); - _logEventArgsEvent.WaitOne(); - _logger.Debug("Wakeup signal received."); - while (true) - { - LogEventArgs e; - int lastLineCount = 0; - lock (_logEventArgsList) - { - _logger.Info("{0} events in queue", _logEventArgsList.Count); - if (_logEventArgsList.Count == 0) - { - _logEventArgsEvent.Reset(); - break; - } - - e = _logEventArgsList[0]; - _logEventArgsList.RemoveAt(0); - } - - if (e.IsRollover) - { - ShiftBookmarks(e.RolloverOffset); - ShiftRowHeightList(e.RolloverOffset); - ShiftFilterPipes(e.RolloverOffset); - lastLineCount = 0; - } - else - { - if (e.LineCount < lastLineCount) - { - _logger.Error("Line count of event is: {0}, should be greater than last line count: {1}", e.LineCount, lastLineCount); - } - } - - Invoke(UpdateGrid, [e]); - CheckFilterAndHighlight(e); - _timeSpreadCalc.SetLineCount(e.LineCount); - } - } - } - - private void StopLogEventWorkerThread() - { - _logEventArgsEvent.Set(); - cts.Cancel(); - //_logEventHandlerThread.Abort(); - //_logEventHandlerThread.Join(); - } - - private void OnFileSizeChanged(LogEventArgs e) - { - FileSizeChanged?.Invoke(this, e); - } - - private void UpdateGrid(LogEventArgs e) - { - int oldRowCount = dataGridView.RowCount; - int firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex; - - if (dataGridView.CurrentCellAddress.Y >= e.LineCount) - { - //this.dataGridView.Rows[this.dataGridView.CurrentCellAddress.Y].Selected = false; - //this.dataGridView.CurrentCell = this.dataGridView.Rows[0].Cells[0]; - } - - try - { - if (dataGridView.RowCount > e.LineCount) - { - int currentLineNum = dataGridView.CurrentCellAddress.Y; - dataGridView.RowCount = 0; - dataGridView.RowCount = e.LineCount; - if (_guiStateArgs.FollowTail == false) - { - if (currentLineNum >= dataGridView.RowCount) - { - currentLineNum = dataGridView.RowCount - 1; - } - - dataGridView.CurrentCell = dataGridView.Rows[currentLineNum].Cells[0]; - } - } - else - { - dataGridView.RowCount = e.LineCount; - } - - _logger.Debug("UpdateGrid(): new RowCount={0}", dataGridView.RowCount); - - if (e.IsRollover) - { - // Multifile rollover - // keep selection and view range, if no follow tail mode - if (!_guiStateArgs.FollowTail) - { - int currentLineNum = dataGridView.CurrentCellAddress.Y; - currentLineNum -= e.RolloverOffset; - if (currentLineNum < 0) - { - currentLineNum = 0; - } - - _logger.Debug("UpdateGrid(): Rollover=true, Rollover offset={0}, currLineNum was {1}, new currLineNum={2}", e.RolloverOffset, dataGridView.CurrentCellAddress.Y, currentLineNum); - firstDisplayedLine -= e.RolloverOffset; - if (firstDisplayedLine < 0) - { - firstDisplayedLine = 0; - } - - dataGridView.FirstDisplayedScrollingRowIndex = firstDisplayedLine; - dataGridView.CurrentCell = dataGridView.Rows[currentLineNum].Cells[0]; - dataGridView.Rows[currentLineNum].Selected = true; - } - } - - _statusEventArgs.LineCount = e.LineCount; - StatusLineFileSize(e.FileSize); - - if (!_isLoading) - { - if (oldRowCount == 0) - { - AdjustMinimumGridWith(); - } - - //CheckFilterAndHighlight(e); - } - - if (_guiStateArgs.FollowTail && dataGridView.RowCount > 0) - { - dataGridView.FirstDisplayedScrollingRowIndex = dataGridView.RowCount - 1; - OnTailFollowed(EventArgs.Empty); - } - - if (Preferences.timestampControl && !_isLoading) - { - SetTimestampLimits(); - } - } - catch (Exception ex) - { - _logger.Error(ex, "Fehler bei UpdateGrid(): "); - } - - //this.dataGridView.Refresh(); - //this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - } - - private void CheckFilterAndHighlight(LogEventArgs e) - { - bool noLed = true; - bool suppressLed; - bool setBookmark; - bool stopTail; - string bookmarkComment; - - if (filterTailCheckBox.Checked || _filterPipeList.Count > 0) - { - int filterStart = e.PrevLineCount; - if (e.IsRollover) - { - ShiftFilterLines(e.RolloverOffset); - filterStart -= e.RolloverOffset; - } - - bool firstStopTail = true; - ColumnizerCallback callback = new(this); - bool filterLineAdded = false; - for (int i = filterStart; i < e.LineCount; ++i) - { - ILogLine line = _logFileReader.GetLogLine(i); - if (line == null) - { - return; - } - - if (filterTailCheckBox.Checked) - { - callback.LineNum = i; - if (Util.TestFilterCondition(_filterParams, line, callback)) - { - //AddFilterLineFx addFx = new AddFilterLineFx(AddFilterLine); - //this.Invoke(addFx, new object[] { i, true }); - filterLineAdded = true; - AddFilterLine(i, false, _filterParams, _filterResultList, _lastFilterLinesList, - _filterHitList); - } - } - - //ProcessFilterPipeFx pipeFx = new ProcessFilterPipeFx(ProcessFilterPipes); - //pipeFx.BeginInvoke(i, null, null); - ProcessFilterPipes(i); - - IList matchingList = FindMatchingHilightEntries(line); - LaunchHighlightPlugins(matchingList, i); - GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, out bookmarkComment); - if (setBookmark) - { - SetBookmarkFx fx = SetBookmarkFromTrigger; - fx.BeginInvoke(i, bookmarkComment, null, null); - } - - if (stopTail && _guiStateArgs.FollowTail) - { - bool wasFollow = _guiStateArgs.FollowTail; - FollowTailChanged(false, true); - if (firstStopTail && wasFollow) - { - Invoke(new SelectLineFx(SelectAndEnsureVisible), [i, false]); - firstStopTail = false; - } - } - - if (!suppressLed) - { - noLed = false; - } - } - - if (filterLineAdded) - { - //AddFilterLineGuiUpdateFx addFx = new AddFilterLineGuiUpdateFx(AddFilterLineGuiUpdate); - //this.Invoke(addFx); - TriggerFilterLineGuiUpdate(); - } - } - else - { - bool firstStopTail = true; - int startLine = e.PrevLineCount; - if (e.IsRollover) - { - ShiftFilterLines(e.RolloverOffset); - startLine -= e.RolloverOffset; - } - - for (int i = startLine; i < e.LineCount; ++i) - { - ILogLine line = _logFileReader.GetLogLine(i); - if (line != null) - { - IList matchingList = FindMatchingHilightEntries(line); - LaunchHighlightPlugins(matchingList, i); - GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, - out bookmarkComment); - if (setBookmark) - { - SetBookmarkFx fx = SetBookmarkFromTrigger; - fx.BeginInvoke(i, bookmarkComment, null, null); - } - - if (stopTail && _guiStateArgs.FollowTail) - { - bool wasFollow = _guiStateArgs.FollowTail; - FollowTailChanged(false, true); - if (firstStopTail && wasFollow) - { - Invoke(new SelectLineFx(SelectAndEnsureVisible), [i, false]); - firstStopTail = false; - } - } - - if (!suppressLed) - { - noLed = false; - } - } - } - } - - if (!noLed) - { - OnFileSizeChanged(e); - } - } - - private void LaunchHighlightPlugins(IList matchingList, int lineNum) - { - LogExpertCallback callback = new(this) - { - LineNum = lineNum - }; - - foreach (HighlightEntry entry in matchingList) - { - if (entry.IsActionEntry && entry.ActionEntry.PluginName != null) - { - IKeywordAction plugin = PluginRegistry.PluginRegistry.Instance.FindKeywordActionPluginByName(entry.ActionEntry.PluginName); - if (plugin != null) - { - ActionPluginExecuteFx fx = plugin.Execute; - fx.BeginInvoke(entry.SearchText, entry.ActionEntry.ActionParam, callback, - CurrentColumnizer, null, null); - } - } - } - } - - private void PreSelectColumnizer(ILogLineColumnizer columnizer) - { - if (columnizer != null) - { - CurrentColumnizer = _forcedColumnizerForLoading = columnizer; - } - else - { - CurrentColumnizer = _forcedColumnizerForLoading = - ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - } - } - - private void SetColumnizer(ILogLineColumnizer columnizer) - { - columnizer = ColumnizerPicker.FindReplacementForAutoColumnizer(FileName, _logFileReader, columnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - - int timeDiff = 0; - if (CurrentColumnizer != null && CurrentColumnizer.IsTimeshiftImplemented()) - { - timeDiff = CurrentColumnizer.GetTimeOffset(); - } - - SetColumnizerInternal(columnizer); - - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - CurrentColumnizer.SetTimeOffset(timeDiff); - } - } - - private void SetColumnizerInternal(ILogLineColumnizer columnizer) - { - _logger.Info("SetColumnizerInternal(): {0}", columnizer.GetName()); - - ILogLineColumnizer oldColumnizer = CurrentColumnizer; - bool oldColumnizerIsXmlType = CurrentColumnizer is ILogLineXmlColumnizer; - bool oldColumnizerIsPreProcess = CurrentColumnizer is IPreProcessColumnizer; - bool mustReload = false; - - // Check if the filtered columns disappeared, if so must refresh the UI - if (_filterParams.ColumnRestrict) - { - string[] newColumns = columnizer != null ? columnizer.GetColumnNames() : Array.Empty(); - bool colChanged = false; - - if (dataGridView.ColumnCount - 2 == newColumns.Length) // two first columns are 'marker' and 'line number' - { - for (int i = 0; i < newColumns.Length; i++) - { - if (dataGridView.Columns[i].HeaderText != newColumns[i]) - { - colChanged = true; - break; // one change is sufficient - } - } - } - else - { - colChanged = true; - } - - if (colChanged) - { - // Update UI - columnNamesLabel.Text = CalculateColumnNames(_filterParams); - } - } - - Type oldColType = _filterParams.CurrentColumnizer?.GetType(); - Type newColType = columnizer?.GetType(); - - if (oldColType != newColType && _filterParams.ColumnRestrict && _filterParams.IsFilterTail) - { - _filterParams.ColumnList.Clear(); - } - - if (CurrentColumnizer == null || CurrentColumnizer.GetType() != columnizer.GetType()) - { - CurrentColumnizer = columnizer; - _freezeStateMap.Clear(); - if (_logFileReader != null) - { - if (CurrentColumnizer is IPreProcessColumnizer) - { - _logFileReader.PreProcessColumnizer = (IPreProcessColumnizer)CurrentColumnizer; - } - else - { - _logFileReader.PreProcessColumnizer = null; - } - } - - // always reload when choosing XML columnizers - if (_logFileReader != null && CurrentColumnizer is ILogLineXmlColumnizer) - { - //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() - mustReload = true; - } - - // Reload when choosing no XML columnizer but previous columnizer was XML - if (_logFileReader != null && !(CurrentColumnizer is ILogLineXmlColumnizer) && oldColumnizerIsXmlType) - { - _logFileReader.IsXmlMode = false; - //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() - mustReload = true; - } - - // Reload when previous columnizer was PreProcess and current is not, and vice versa. - // When the current columnizer is a preProcess columnizer, reload in every case. - if (CurrentColumnizer is IPreProcessColumnizer != oldColumnizerIsPreProcess || - CurrentColumnizer is IPreProcessColumnizer) - { - //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() - mustReload = true; - } - } - else - { - CurrentColumnizer = columnizer; - } - - (oldColumnizer as IInitColumnizer)?.DeSelected(new ColumnizerCallback(this)); - - (columnizer as IInitColumnizer)?.Selected(new ColumnizerCallback(this)); - - SetColumnizer(columnizer, dataGridView); - SetColumnizer(columnizer, filterGridView); - _patternWindow?.SetColumnizer(columnizer); - - _guiStateArgs.TimeshiftPossible = columnizer.IsTimeshiftImplemented(); - SendGuiStateUpdate(); - - if (_logFileReader != null) - { - dataGridView.RowCount = _logFileReader.LineCount; - } - - if (_filterResultList != null) - { - filterGridView.RowCount = _filterResultList.Count; - } - - if (mustReload) - { - Reload(); - } - else - { - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - SetTimestampLimits(); - SyncTimestampDisplay(); - } - - Settings settings = ConfigManager.Settings; - ShowLineColumn(!settings.hideLineColumn); - ShowTimeSpread(Preferences.showTimeSpread && columnizer.IsTimeshiftImplemented()); - } - - if (!columnizer.IsTimeshiftImplemented() && IsTimeSynced) - { - FreeFromTimeSync(); - } - - columnComboBox.Items.Clear(); - - foreach (string columnName in columnizer.GetColumnNames()) - { - columnComboBox.Items.Add(columnName); - } - - columnComboBox.SelectedIndex = 0; - - OnColumnizerChanged(CurrentColumnizer); - } - - private void AutoResizeColumns(BufferedDataGridView gridView) - { - try - { - gridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - if (gridView.Columns.Count > 1 && Preferences.setLastColumnWidth && - gridView.Columns[gridView.Columns.Count - 1].Width < Preferences.lastColumnWidth - ) - { - // It seems that using 'MinimumWidth' instead of 'Width' prevents the DataGridView's NullReferenceExceptions - //gridView.Columns[gridView.Columns.Count - 1].Width = this.Preferences.lastColumnWidth; - gridView.Columns[gridView.Columns.Count - 1].MinimumWidth = Preferences.lastColumnWidth; - } - } - catch (NullReferenceException e) - { - // See https://connect.microsoft.com/VisualStudio/feedback/details/366943/autoresizecolumns-in-datagridview-throws-nullreferenceexception - // possible solution => https://stackoverflow.com/questions/36287553/nullreferenceexception-when-trying-to-set-datagridview-column-width-brings-th - // There are some rare situations with null ref exceptions when resizing columns and on filter finished - // So catch them here. Better than crashing. - _logger.Error(e, "Error while resizing columns: "); - } - } - - private void PaintCell(DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, - HighlightEntry groundEntry) - { - PaintHighlightedCell(e, gridView, noBackgroundFill, groundEntry); - } - - private void PaintHighlightedCell(DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, - bool noBackgroundFill, - HighlightEntry groundEntry) - { - var column = e.Value as IColumn; - - column ??= Column.EmptyColumn; - - IList matchList = FindHighlightMatches(column); - // too many entries per line seem to cause problems with the GDI - while (matchList.Count > 50) - { - matchList.RemoveAt(50); - } - - var he = new HighlightEntry - { - SearchText = column.DisplayValue, - ForegroundColor = groundEntry?.ForegroundColor ?? Color.FromKnownColor(KnownColor.Black), - BackgroundColor = groundEntry?.BackgroundColor ?? Color.Empty, - IsWordMatch = true - }; - - HilightMatchEntry hme = new() - { - StartPos = 0, - Length = column.DisplayValue.Length, - HilightEntry = he - }; - - if (groundEntry != null) - { - hme.HilightEntry.IsBold = groundEntry.IsBold; - } - - matchList = MergeHighlightMatchEntries(matchList, hme); - - int leftPad = e.CellStyle.Padding.Left; - RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, - e.CellBounds.Height); - Rectangle borderWidths = PaintHelper.BorderWidths(e.AdvancedBorderStyle); - Rectangle valBounds = e.CellBounds; - valBounds.Offset(borderWidths.X, borderWidths.Y); - valBounds.Width -= borderWidths.Right; - valBounds.Height -= borderWidths.Bottom; - if (e.CellStyle.Padding != Padding.Empty) - { - valBounds.Offset(e.CellStyle.Padding.Left, e.CellStyle.Padding.Top); - valBounds.Width -= e.CellStyle.Padding.Horizontal; - valBounds.Height -= e.CellStyle.Padding.Vertical; - } - - TextFormatFlags flags = - TextFormatFlags.Left - | TextFormatFlags.SingleLine - | TextFormatFlags.NoPrefix - | TextFormatFlags.PreserveGraphicsClipping - | TextFormatFlags.NoPadding - | TextFormatFlags.VerticalCenter - | TextFormatFlags.TextBoxControl - ; - - // | TextFormatFlags.VerticalCenter - // | TextFormatFlags.TextBoxControl - // TextFormatFlags.SingleLine - - //TextRenderer.DrawText(e.Graphics, e.Value as String, e.CellStyle.Font, valBounds, Color.FromKnownColor(KnownColor.Black), flags); - - Point wordPos = valBounds.Location; - Size proposedSize = new(valBounds.Width, valBounds.Height); - - Rectangle r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); - e.Graphics.SetClip(e.CellBounds); - - foreach (HilightMatchEntry matchEntry in matchList) - { - Font font = matchEntry != null && matchEntry.HilightEntry.IsBold ? BoldFont : NormalFont; - Brush bgBrush = matchEntry.HilightEntry.BackgroundColor != Color.Empty - ? new SolidBrush(matchEntry.HilightEntry.BackgroundColor) - : null; - string matchWord = column.DisplayValue.Substring(matchEntry.StartPos, matchEntry.Length); - Size wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags); - wordSize.Height = e.CellBounds.Height; - Rectangle wordRect = new(wordPos, wordSize); - - Color foreColor = matchEntry.HilightEntry.ForegroundColor; - if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected) - { - if (!noBackgroundFill && bgBrush != null && !matchEntry.HilightEntry.NoBackground) - { - e.Graphics.FillRectangle(bgBrush, wordRect); - } - } - - if (foreColor == Color.Black) - { - foreColor = ColorMode.ForeColor; - } - - TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, - foreColor, flags); - - wordPos.Offset(wordSize.Width, 0); - bgBrush?.Dispose(); - } - } - - /// - /// Builds a list of HilightMatchEntry objects. A HilightMatchEntry spans over a region that is painted with the same foreground and - /// background colors. - /// All regions which don't match a word-mode entry will be painted with the colors of a default entry (groundEntry). This is either the - /// first matching non-word-mode highlight entry or a black-on-white default (if no matching entry was found). - /// - /// List of all highlight matches for the current cell - /// The entry that is used as the default. - /// List of HilightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring. - private IList MergeHighlightMatchEntries(IList matchList, - HilightMatchEntry groundEntry) - { - // Fill an area with lenth of whole text with a default hilight entry - HighlightEntry[] entryArray = new HighlightEntry[groundEntry.Length]; - for (int i = 0; i < entryArray.Length; ++i) - { - entryArray[i] = groundEntry.HilightEntry; - } - - // "overpaint" with all matching word match enries - // Non-word-mode matches will not overpaint because they use the groundEntry - foreach (HilightMatchEntry me in matchList) - { - int endPos = me.StartPos + me.Length; - for (int i = me.StartPos; i < endPos; ++i) - { - if (me.HilightEntry.IsWordMatch) - { - entryArray[i] = me.HilightEntry; - } - else - { - //entryArray[i].ForegroundColor = me.HilightEntry.ForegroundColor; - } - } - } - - // collect areas with same hilight entry and build new highlight match entries for it - IList mergedList = []; - - if (entryArray.Length > 0) - { - HighlightEntry currentEntry = entryArray[0]; - int lastStartPos = 0; - int pos = 0; - - for (; pos < entryArray.Length; ++pos) - { - if (entryArray[pos] != currentEntry) - { - HilightMatchEntry me = new() - { - StartPos = lastStartPos, - Length = pos - lastStartPos, - HilightEntry = currentEntry - }; - - mergedList.Add(me); - currentEntry = entryArray[pos]; - lastStartPos = pos; - } - } - - HilightMatchEntry me2 = new() - { - StartPos = lastStartPos, - Length = pos - lastStartPos, - HilightEntry = currentEntry - }; - - mergedList.Add(me2); - } - - return mergedList; - } - - /// - /// Returns the first HilightEntry that matches the given line - /// - private HighlightEntry FindHilightEntry(ITextValue line) - { - return FindHighlightEntry(line, false); - } - - private HighlightEntry FindFirstNoWordMatchHilightEntry(ITextValue line) - { - return FindHighlightEntry(line, true); - } - - private bool CheckHighlightEntryMatch(HighlightEntry entry, ITextValue column) - { - if (entry.IsRegEx) - { - //Regex rex = new Regex(entry.SearchText, entry.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); - if (entry.Regex.IsMatch(column.Text)) - { - return true; - } - } - else - { - if (entry.IsCaseSensitive) - { - if (column.Text.Contains(entry.SearchText)) - { - return true; - } - } - else - { - if (column.Text.ToLower().Contains(entry.SearchText.ToLower())) - { - return true; - } - } - } - - return false; - } - - /// - /// Returns all HilightEntry entries which matches the given line - /// - private IList FindMatchingHilightEntries(ITextValue line) - { - IList resultList = []; - if (line != null) - { - lock (_currentHighlightGroupLock) - { - foreach (HighlightEntry entry in _currentHighlightGroup.HighlightEntryList) - { - if (CheckHighlightEntryMatch(entry, line)) - { - resultList.Add(entry); - } - } - } - } - - return resultList; - } - - private void GetHighlightEntryMatches(ITextValue line, IList hilightEntryList, IList resultList) - { - foreach (HighlightEntry entry in hilightEntryList) - { - if (entry.IsWordMatch) - { - MatchCollection matches = entry.Regex.Matches(line.Text); - foreach (Match match in matches) - { - HilightMatchEntry me = new(); - me.HilightEntry = entry; - me.StartPos = match.Index; - me.Length = match.Length; - resultList.Add(me); - } - } - else - { - if (CheckHighlightEntryMatch(entry, line)) - { - HilightMatchEntry me = new(); - me.HilightEntry = entry; - me.StartPos = 0; - me.Length = line.Text.Length; - resultList.Add(me); - } - } - } - } - - private void GetHilightActions(IList matchingList, out bool noLed, out bool stopTail, - out bool setBookmark, out string bookmarkComment) - { - noLed = stopTail = setBookmark = false; - bookmarkComment = string.Empty; - - foreach (HighlightEntry entry in matchingList) - { - if (entry.IsLedSwitch) - { - noLed = true; - } - - if (entry.IsSetBookmark) - { - setBookmark = true; - if (!string.IsNullOrEmpty(entry.BookmarkComment)) - { - bookmarkComment += entry.BookmarkComment + "\r\n"; - } - } - - if (entry.IsStopTail) - { - stopTail = true; - } - } - - bookmarkComment = bookmarkComment.TrimEnd(['\r', '\n']); - } - - private void StopTimespreadThread() - { - _timeSpreadCalc.Stop(); - } - - private void StopTimestampSyncThread() - { - _shouldTimestampDisplaySyncingCancel = true; - //_timeShiftSyncWakeupEvent.Set(); - //_timeShiftSyncThread.Abort(); - //_timeShiftSyncThread.Join(); - cts.Cancel(); - } - - private void SyncTimestampDisplay() - { - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - if (dataGridView.CurrentRow != null) - { - SyncTimestampDisplay(dataGridView.CurrentRow.Index); - } - } - } - - private void SyncTimestampDisplay(int lineNum) - { - _timeShiftSyncLine = lineNum; - _timeShiftSyncTimerEvent.Set(); - _timeShiftSyncWakeupEvent.Set(); - } - - private void SyncTimestampDisplayWorker() - { - const int WAIT_TIME = 500; - Thread.CurrentThread.Name = "SyncTimestampDisplayWorker"; - _shouldTimestampDisplaySyncingCancel = false; - _isTimestampDisplaySyncing = true; - - while (!_shouldTimestampDisplaySyncingCancel) - { - _timeShiftSyncWakeupEvent.WaitOne(); - if (_shouldTimestampDisplaySyncingCancel) - { - return; - } - - _timeShiftSyncWakeupEvent.Reset(); - - while (!_shouldTimestampDisplaySyncingCancel) - { - bool signaled = _timeShiftSyncTimerEvent.WaitOne(WAIT_TIME, true); - _timeShiftSyncTimerEvent.Reset(); - if (!signaled) - { - break; - } - } - - // timeout with no new Trigger -> update display - int lineNum = _timeShiftSyncLine; - if (lineNum >= 0 && lineNum < dataGridView.RowCount) - { - int refLine = lineNum; - DateTime timeStamp = GetTimestampForLine(ref refLine, true); - if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel) - { - _guiStateArgs.Timestamp = timeStamp; - SendGuiStateUpdate(); - if (_shouldCallTimeSync) - { - refLine = lineNum; - DateTime exactTimeStamp = GetTimestampForLine(ref refLine, false); - SyncOtherWindows(exactTimeStamp); - _shouldCallTimeSync = false; - } - } - } - - // show time difference between 2 selected lines - if (dataGridView.SelectedRows.Count == 2) - { - int row1 = dataGridView.SelectedRows[0].Index; - int row2 = dataGridView.SelectedRows[1].Index; - if (row1 > row2) - { - (row2, row1) = (row1, row2); - } - - int refLine = row1; - DateTime timeStamp1 = GetTimestampForLine(ref refLine, false); - refLine = row2; - DateTime timeStamp2 = GetTimestampForLine(ref refLine, false); - //TimeSpan span = TimeSpan.FromTicks(timeStamp2.Ticks - timeStamp1.Ticks); - DateTime diff; - if (timeStamp1.Ticks > timeStamp2.Ticks) - { - diff = new DateTime(timeStamp1.Ticks - timeStamp2.Ticks); - } - else - { - diff = new DateTime(timeStamp2.Ticks - timeStamp1.Ticks); - } - - StatusLineText("Time diff is " + diff.ToString("HH:mm:ss.fff")); - } - else - { - if (!IsMultiFile && dataGridView.SelectedRows.Count == 1) - { - StatusLineText(string.Empty); - } - } - } - } - - private void SyncFilterGridPos() - { - try - { - if (_filterResultList.Count > 0) - { - int index = _filterResultList.BinarySearch(dataGridView.CurrentRow.Index); - if (index < 0) - { - index = ~index; - if (index > 0) - { - --index; - } - } - - if (filterGridView.Rows.GetRowCount(DataGridViewElementStates.None) > 0) // exception no rows - { - filterGridView.CurrentCell = filterGridView.Rows[index].Cells[0]; - } - else - { - filterGridView.CurrentCell = null; - } - } - } - catch (Exception e) - { - _logger.Error(e, "SyncFilterGridPos(): "); - } - } - - private void StatusLineFileSize(long size) - { - _statusEventArgs.FileSize = size; - SendStatusLineUpdate(); - } - - private int Search(SearchParams searchParams) - { - if (searchParams.SearchText == null) - { - return -1; - } - - int lineNum = searchParams.IsFromTop && !searchParams.IsFindNext - ? 0 - : searchParams.CurrentLine; - - string lowerSearchText = searchParams.SearchText.ToLower(); - int count = 0; - bool hasWrapped = false; - - while (true) - { - if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) - { - if (lineNum >= _logFileReader.LineCount) - { - if (hasWrapped) - { - StatusLineError("Not found: " + searchParams.SearchText); - return -1; - } - - lineNum = 0; - count = 0; - hasWrapped = true; - StatusLineError("Started from beginning of file"); - } - } - else - { - if (lineNum < 0) - { - if (hasWrapped) - { - StatusLineError("Not found: " + searchParams.SearchText); - return -1; - } - - count = 0; - lineNum = _logFileReader.LineCount - 1; - hasWrapped = true; - StatusLineError("Started from end of file"); - } - } - - ILogLine line = _logFileReader.GetLogLine(lineNum); - if (line == null) - { - return -1; - } - - if (searchParams.IsRegex) - { - Regex rex = new(searchParams.SearchText, searchParams.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); - if (rex.IsMatch(line.FullLine)) - { - return lineNum; - } - } - else - { - if (!searchParams.IsCaseSensitive) - { - if (line.FullLine.Contains(lowerSearchText, StringComparison.CurrentCultureIgnoreCase)) - { - return lineNum; - } - } - else - { - if (line.FullLine.Contains(searchParams.SearchText)) - { - return lineNum; - } - } - } - - if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) - { - lineNum++; - } - else - { - lineNum--; - } - - if (_shouldCancel) - { - return -1; - } - - if (++count % PROGRESS_BAR_MODULO == 0) - { - try - { - if (!Disposing) - { - Invoke(UpdateProgressBar, [count]); - } - } - catch (ObjectDisposedException ex) // can occur when closing the app while searching - { - _logger.Warn(ex); - } - } - } - } - - private void ResetProgressBar() - { - _progressEventArgs.Value = _progressEventArgs.MaxValue; - _progressEventArgs.Visible = false; - SendProgressBarUpdate(); - } - - private void SelectLine(int line, bool triggerSyncCall, bool shouldScroll) - { - try - { - _shouldCallTimeSync = triggerSyncCall; - bool wasCancelled = _shouldCancel; - _shouldCancel = false; - _isSearching = false; - StatusLineText(""); - _guiStateArgs.MenuEnabled = true; - - if (wasCancelled) - { - return; - } - - if (line == -1) - { - // Hmm... is that experimental code from early days? - MessageBox.Show(this, "Not found:", "Search result"); - return; - } - - // Prevent ArgumentOutOfRangeException - if (line >= dataGridView.Rows.GetRowCount(DataGridViewElementStates.None)) - { - line = dataGridView.Rows.GetRowCount(DataGridViewElementStates.None) - 1; - } - - dataGridView.Rows[line].Selected = true; - - if (shouldScroll) - { - dataGridView.CurrentCell = dataGridView.Rows[line].Cells[0]; - dataGridView.Focus(); - } - } - catch (ArgumentOutOfRangeException e) - { - _logger.Error(e, "Error while selecting line: "); - } - catch (IndexOutOfRangeException e) - { - // Occures sometimes (but cannot reproduce) - _logger.Error(e, "Error while selecting line: "); - } - } - - private void StartEditMode() - { - if (!dataGridView.CurrentCell.ReadOnly) - { - dataGridView.BeginEdit(false); - if (dataGridView.EditingControl != null) - { - if (dataGridView.EditingControl is LogCellEditingControl editControl) - { - editControl.KeyDown += OnEditControlKeyDown; - editControl.KeyPress += OnEditControlKeyPress; - editControl.KeyUp += OnEditControlKeyUp; - editControl.Click += OnEditControlClick; - dataGridView.CellEndEdit += OnDataGridViewCellEndEdit; - editControl.SelectionStart = 0; - } - else - { - _logger.Warn("Edit control in logWindow was null"); - } - } - } - } - - private void UpdateEditColumnDisplay(DataGridViewTextBoxEditingControl editControl) - { - // prevents key events after edit mode has ended - if (dataGridView.EditingControl != null) - { - int pos = editControl.SelectionStart + editControl.SelectionLength; - StatusLineText(" " + pos); - _logger.Debug("SelStart: {0}, SelLen: {1}", editControl.SelectionStart, editControl.SelectionLength); - } - } - - private void SelectPrevHighlightLine() - { - int lineNum = dataGridView.CurrentCellAddress.Y; - while (lineNum > 0) - { - lineNum--; - ILogLine line = _logFileReader.GetLogLine(lineNum); - if (line != null) - { - HighlightEntry entry = FindHilightEntry(line); - if (entry != null) - { - SelectLine(lineNum, false, true); - break; - } - } - } - } - - private void SelectNextHighlightLine() - { - int lineNum = dataGridView.CurrentCellAddress.Y; - while (lineNum < _logFileReader.LineCount) - { - lineNum++; - ILogLine line = _logFileReader.GetLogLine(lineNum); - if (line != null) - { - HighlightEntry entry = FindHilightEntry(line); - if (entry != null) - { - SelectLine(lineNum, false, true); - break; - } - } - } - } - - private int FindNextBookmarkIndex(int lineNum) - { - if (lineNum >= dataGridView.RowCount) - { - lineNum = 0; - } - else - { - lineNum++; - } - - return _bookmarkProvider.FindNextBookmarkIndex(lineNum); - } - - private int FindPrevBookmarkIndex(int lineNum) - { - if (lineNum <= 0) - { - lineNum = dataGridView.RowCount - 1; - } - else - { - lineNum--; - } - - return _bookmarkProvider.FindPrevBookmarkIndex(lineNum); - } - - /** - * Shift bookmarks after a logfile rollover - */ - - private void ShiftBookmarks(int offset) - { - _bookmarkProvider.ShiftBookmarks(offset); - OnBookmarkRemoved(); - } - - private void ShiftRowHeightList(int offset) - { - SortedList newList = []; - foreach (RowHeightEntry entry in _rowHeightList.Values) - { - int line = entry.LineNum - offset; - if (line >= 0) - { - entry.LineNum = line; - newList.Add(line, entry); - } - } - - _rowHeightList = newList; - } - - private void ShiftFilterPipes(int offset) - { - lock (_filterPipeList) - { - foreach (FilterPipe pipe in _filterPipeList) - { - pipe.ShiftLineNums(offset); - } - } - } - - private void LoadFilterPipes() - { - lock (_filterPipeList) - { - foreach (FilterPipe pipe in _filterPipeList) - { - pipe.RecreateTempFile(); - } - } - - if (_filterPipeList.Count > 0) - { - for (int i = 0; i < dataGridView.RowCount; ++i) - { - ProcessFilterPipes(i); - } - } - } - - private void DisconnectFilterPipes() - { - lock (_filterPipeList) - { - foreach (FilterPipe pipe in _filterPipeList) - { - pipe.ClearLineList(); - } - } - } - - private void ApplyFilterParams() - { - filterComboBox.Text = _filterParams.SearchText; - filterCaseSensitiveCheckBox.Checked = _filterParams.IsCaseSensitive; - filterRegexCheckBox.Checked = _filterParams.IsRegex; - filterTailCheckBox.Checked = _filterParams.IsFilterTail; - invertFilterCheckBox.Checked = _filterParams.IsInvert; - filterKnobBackSpread.Value = _filterParams.SpreadBefore; - filterKnobForeSpread.Value = _filterParams.SpreadBehind; - rangeCheckBox.Checked = _filterParams.IsRangeSearch; - columnRestrictCheckBox.Checked = _filterParams.ColumnRestrict; - fuzzyKnobControl.Value = _filterParams.FuzzyValue; - filterRangeComboBox.Text = _filterParams.RangeSearchText; - } - - private void ResetFilterControls() - { - filterComboBox.Text = ""; - filterCaseSensitiveCheckBox.Checked = false; - filterRegexCheckBox.Checked = false; - //this.filterTailCheckBox.Checked = this.Preferences.filterTail; - invertFilterCheckBox.Checked = false; - filterKnobBackSpread.Value = 0; - filterKnobForeSpread.Value = 0; - rangeCheckBox.Checked = false; - columnRestrictCheckBox.Checked = false; - fuzzyKnobControl.Value = 0; - filterRangeComboBox.Text = ""; - } - - private void FilterSearch() - { - if (filterComboBox.Text.Length == 0) - { - _filterParams.SearchText = ""; - _filterParams.LowerSearchText = ""; - _filterParams.IsRangeSearch = false; - ClearFilterList(); - filterSearchButton.Image = null; - ResetFilterControls(); - saveFilterButton.Enabled = false; - return; - } - - FilterSearch(filterComboBox.Text); - } - - private async void FilterSearch(string text) - { - FireCancelHandlers(); // make sure that there's no other filter running (maybe from filter restore) - - _filterParams.SearchText = text; - _filterParams.LowerSearchText = text.ToLower(); - ConfigManager.Settings.filterHistoryList.Remove(text); - ConfigManager.Settings.filterHistoryList.Insert(0, text); - int maxHistory = ConfigManager.Settings.Preferences.maximumFilterEntries; - - if (ConfigManager.Settings.filterHistoryList.Count > maxHistory) - { - ConfigManager.Settings.filterHistoryList.RemoveAt(filterComboBox.Items.Count - 1); - } - - filterComboBox.Items.Clear(); - foreach (string item in ConfigManager.Settings.filterHistoryList) - { - filterComboBox.Items.Add(item); - } - - filterComboBox.Text = text; - - _filterParams.IsRangeSearch = rangeCheckBox.Checked; - _filterParams.RangeSearchText = filterRangeComboBox.Text; - if (_filterParams.IsRangeSearch) - { - ConfigManager.Settings.filterRangeHistoryList.Remove(filterRangeComboBox.Text); - ConfigManager.Settings.filterRangeHistoryList.Insert(0, filterRangeComboBox.Text); - if (ConfigManager.Settings.filterRangeHistoryList.Count > maxHistory) - { - ConfigManager.Settings.filterRangeHistoryList.RemoveAt(filterRangeComboBox.Items.Count - 1); - } - - filterRangeComboBox.Items.Clear(); - foreach (string item in ConfigManager.Settings.filterRangeHistoryList) - { - filterRangeComboBox.Items.Add(item); - } - } - - ConfigManager.Save(SettingsFlags.FilterHistory); - - _filterParams.IsCaseSensitive = filterCaseSensitiveCheckBox.Checked; - _filterParams.IsRegex = filterRegexCheckBox.Checked; - _filterParams.IsFilterTail = filterTailCheckBox.Checked; - _filterParams.IsInvert = invertFilterCheckBox.Checked; - if (_filterParams.IsRegex) - { - try - { - _filterParams.CreateRegex(); - } - catch (ArgumentException) - { - StatusLineError("Invalid regular expression"); - return; - } - } - - _filterParams.FuzzyValue = fuzzyKnobControl.Value; - _filterParams.SpreadBefore = filterKnobBackSpread.Value; - _filterParams.SpreadBehind = filterKnobForeSpread.Value; - _filterParams.ColumnRestrict = columnRestrictCheckBox.Checked; - - //ConfigManager.SaveFilterParams(this.filterParams); - ConfigManager.Settings.filterParams = _filterParams; // wozu eigentlich? sinnlos seit MDI? - - _shouldCancel = false; - _isSearching = true; - StatusLineText("Filtering... Press ESC to cancel"); - filterSearchButton.Enabled = false; - ClearFilterList(); - - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = dataGridView.RowCount; - _progressEventArgs.Value = 0; - _progressEventArgs.Visible = true; - SendProgressBarUpdate(); - - Settings settings = ConfigManager.Settings; - - //FilterFx fx = settings.preferences.multiThreadFilter ? MultiThreadedFilter : new FilterFx(Filter); - FilterFxAction = settings.Preferences.multiThreadFilter ? MultiThreadedFilter : Filter; - - //Task.Run(() => fx.Invoke(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList)); - Task filterFxActionTask = Task.Run(() => Filter(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList)); - - await filterFxActionTask; - FilterComplete(); - - //fx.BeginInvoke(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList, FilterComplete, null); - CheckForFilterDirty(); - } - - private void MultiThreadedFilter(FilterParams filterParams, List filterResultLines, - List lastFilterLinesList, List filterHitList) - { - ColumnizerCallback callback = new(this); - FilterStarter fs = new(callback, Environment.ProcessorCount + 2); - fs.FilterHitList = _filterHitList; - fs.FilterResultLines = _filterResultList; - fs.LastFilterLinesList = _lastFilterLinesList; - BackgroundProcessCancelHandler cancelHandler = new FilterCancelHandler(fs); - OnRegisterCancelHandler(cancelHandler); - long startTime = Environment.TickCount; - - fs.DoFilter(filterParams, 0, _logFileReader.LineCount, FilterProgressCallback); - - long endTime = Environment.TickCount; - - _logger.Debug("Multi threaded filter duration: {0} ms.", endTime - startTime); - - OnDeRegisterCancelHandler(cancelHandler); - StatusLineText("Filter duration: " + (endTime - startTime) + " ms."); - } - - private void FilterProgressCallback(int lineCount) - { - UpdateProgressBar(lineCount); - } - - private void Filter(FilterParams filterParams, List filterResultLines, List lastFilterLinesList, - List filterHitList) - { - long startTime = Environment.TickCount; - try - { - filterParams.Reset(); - int lineNum = 0; - //AddFilterLineFx addFx = new AddFilterLineFx(AddFilterLine); - ColumnizerCallback callback = new(this); - while (true) - { - ILogLine line = _logFileReader.GetLogLine(lineNum); - if (line == null) - { - break; - } - - callback.LineNum = lineNum; - if (Util.TestFilterCondition(filterParams, line, callback)) - { - AddFilterLine(lineNum, false, filterParams, filterResultLines, lastFilterLinesList, - filterHitList); - } - - lineNum++; - if (lineNum % PROGRESS_BAR_MODULO == 0) - { - UpdateProgressBar(lineNum); - } - - if (_shouldCancel) - { - break; - } - } - } - catch (Exception ex) - { - _logger.Error(ex, "Exception while filtering. Please report to developer: "); - MessageBox.Show(null, - "Exception while filtering. Please report to developer: \n\n" + ex + "\n\n" + ex.StackTrace, - "LogExpert"); - } - - long endTime = Environment.TickCount; - - _logger.Info("Single threaded filter duration: {0} ms.", endTime - startTime); - - StatusLineText("Filter duration: " + (endTime - startTime) + " ms."); - } - - /// - /// Returns a list with 'additional filter results'. This is the given line number - /// and (if back spread and/or fore spread is enabled) some additional lines. - /// This function doesn't check the filter condition! - /// - /// - /// - /// - /// - private IList GetAdditionalFilterResults(FilterParams filterParams, int lineNum, IList checkList) - { - IList resultList = []; - //string textLine = this.logFileReader.GetLogLine(lineNum); - //ColumnizerCallback callback = new ColumnizerCallback(this); - //callback.LineNum = lineNum; - - if (filterParams.SpreadBefore == 0 && filterParams.SpreadBehind == 0) - { - resultList.Add(lineNum); - return resultList; - } - - // back spread - for (int i = filterParams.SpreadBefore; i > 0; --i) - { - if (lineNum - i > 0) - { - if (!resultList.Contains(lineNum - i) && !checkList.Contains(lineNum - i)) - { - resultList.Add(lineNum - i); - } - } - } - - // direct filter hit - if (!resultList.Contains(lineNum) && !checkList.Contains(lineNum)) - { - resultList.Add(lineNum); - } - - // after spread - for (int i = 1; i <= filterParams.SpreadBehind; ++i) - { - if (lineNum + i < _logFileReader.LineCount) - { - if (!resultList.Contains(lineNum + i) && !checkList.Contains(lineNum + i)) - { - resultList.Add(lineNum + i); - } - } - } - - return resultList; - } - - private void AddFilterLine(int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, - List lastFilterLinesList, List filterHitList) - { - int count; - lock (_filterResultList) - { - filterHitList.Add(lineNum); - IList filterResult = GetAdditionalFilterResults(filterParams, lineNum, lastFilterLinesList); - filterResultLines.AddRange(filterResult); - count = filterResultLines.Count; - lastFilterLinesList.AddRange(filterResult); - if (lastFilterLinesList.Count > SPREAD_MAX * 2) - { - lastFilterLinesList.RemoveRange(0, lastFilterLinesList.Count - SPREAD_MAX * 2); - } - } - - if (immediate) - { - TriggerFilterLineGuiUpdate(); - } - else if (lineNum % PROGRESS_BAR_MODULO == 0) - { - //FunctionWith1IntParam fx = new FunctionWith1IntParam(UpdateFilterCountLabel); - //this.Invoke(fx, new object[] { count}); - } - } - - private void TriggerFilterLineGuiUpdate() - { - //lock (this.filterUpdateThread) - //{ - // this.filterEventCount++; - // this.filterUpdateEvent.Set(); - //} - Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); - } - - //private void FilterUpdateWorker() - //{ - // Thread.CurrentThread.Name = "FilterUpdateWorker"; - // while (true) - // { - // this.filterUpdateEvent.WaitOne(); - // lock (this.filterUpdateThread) - // { - // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); - // this.filterUpdateEvent.Reset(); - // } - - // //_logger.logDebug("FilterUpdateWorker: Waiting for signal"); - // //bool signaled = this.filterUpdateEvent.WaitOne(1000, false); - - // //if (!signaled) - // //{ - // // lock (this.filterUpdateThread) - // // { - // // if (this.filterEventCount > 0) - // // { - // // this.filterEventCount = 0; - // // _logger.logDebug("FilterUpdateWorker: Invoking GUI update because of wait timeout"); - // // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); - // // } - // // } - // //} - // //else - // //{ - // // _logger.logDebug("FilterUpdateWorker: Wakeup signal received."); - // // lock (this.filterUpdateThread) - // // { - // // _logger.logDebug("FilterUpdateWorker: event count: " + this.filterEventCount); - // // if (this.filterEventCount > 100) - // // { - // // this.filterEventCount = 0; - // // _logger.logDebug("FilterUpdateWorker: Invoking GUI update because of event count"); - // // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); - // // } - // // this.filterUpdateEvent.Reset(); - // // } - // //} - // } - //} - - //private void StopFilterUpdateWorkerThread() - //{ - // this.filterUpdateEvent.Set(); - // this.filterUpdateThread.Abort(); - // this.filterUpdateThread.Join(); - //} - - private void AddFilterLineGuiUpdate() - { - try - { - lock (_filterResultList) - { - lblFilterCount.Text = "" + _filterResultList.Count; - if (filterGridView.RowCount > _filterResultList.Count) - { - filterGridView.RowCount = 0; // helps to prevent hang ? - } - - filterGridView.RowCount = _filterResultList.Count; - if (filterGridView.RowCount > 0) - { - filterGridView.FirstDisplayedScrollingRowIndex = filterGridView.RowCount - 1; - } - - if (filterGridView.RowCount == 1) - { - // after a file reload adjusted column sizes anew when the first line arrives - //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - AutoResizeColumns(filterGridView); - } - } - } - catch (Exception e) - { - _logger.Error(e, "AddFilterLineGuiUpdate(): "); - } - } - - private void UpdateProgressBar(int value) - { - _progressEventArgs.Value = value; - if (value > _progressEventArgs.MaxValue) - { - // can occur if new lines will be added while filtering - _progressEventArgs.MaxValue = value; - } - - SendProgressBarUpdate(); - } - - private void FilterComplete() - { - if (!IsDisposed && !_waitingForClose && !Disposing) - { - Invoke(new MethodInvoker(ResetStatusAfterFilter)); - } - } - - private void FilterComplete(IAsyncResult result) - { - if (!IsDisposed && !_waitingForClose && !Disposing) - { - Invoke(new MethodInvoker(ResetStatusAfterFilter)); - } - } - - private void ResetStatusAfterFilter() - { - try - { - //StatusLineText(""); - _isSearching = false; - _progressEventArgs.Value = _progressEventArgs.MaxValue; - _progressEventArgs.Visible = false; - SendProgressBarUpdate(); - filterGridView.RowCount = _filterResultList.Count; - //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - AutoResizeColumns(filterGridView); - lblFilterCount.Text = "" + _filterResultList.Count; - if (filterGridView.RowCount > 0) - { - filterGridView.Focus(); - } - - filterSearchButton.Enabled = true; - } - catch (NullReferenceException e) - { - // See https://connect.microsoft.com/VisualStudio/feedback/details/366943/autoresizecolumns-in-datagridview-throws-nullreferenceexception - // There are some rare situations with null ref exceptions when resizing columns and on filter finished - // So catch them here. Better than crashing. - _logger.Error(e, "Error: "); - } - } - - private void ClearFilterList() - { - try - { - //this.shouldCancel = true; - lock (_filterResultList) - { - filterGridView.SuspendLayout(); - filterGridView.RowCount = 0; - lblFilterCount.Text = "0"; - _filterResultList = []; - _lastFilterLinesList = []; - _filterHitList = []; - //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - filterGridView.ResumeLayout(); - } - } - catch (Exception ex) - { - _logger.Error(ex, "Wieder dieser sporadische Fehler: "); - - MessageBox.Show(null, ex.StackTrace, "Wieder dieser sporadische Fehler:"); - } - } - - private void ClearBookmarkList() - { - _bookmarkProvider.ClearAllBookmarks(); - } - - /** - * Shift filter list line entries after a logfile rollover - */ - - private void ShiftFilterLines(int offset) - { - List newFilterList = []; - lock (_filterResultList) - { - foreach (int lineNum in _filterResultList) - { - int line = lineNum - offset; - if (line >= 0) - { - newFilterList.Add(line); - } - } - - _filterResultList = newFilterList; - } - - newFilterList = []; - foreach (int lineNum in _filterHitList) - { - int line = lineNum - offset; - if (line >= 0) - { - newFilterList.Add(line); - } - } - - _filterHitList = newFilterList; - - int count = SPREAD_MAX; - if (_filterResultList.Count < SPREAD_MAX) - { - count = _filterResultList.Count; - } - - _lastFilterLinesList = _filterResultList.GetRange(_filterResultList.Count - count, count); - - //this.filterGridView.RowCount = this.filterResultList.Count; - //this.filterCountLabel.Text = "" + this.filterResultList.Count; - //this.BeginInvoke(new MethodInvoker(this.filterGridView.Refresh)); - //this.BeginInvoke(new MethodInvoker(AddFilterLineGuiUpdate)); - TriggerFilterLineGuiUpdate(); - } - - private void CheckForFilterDirty() - { - if (IsFilterSearchDirty(_filterParams)) - { - filterSearchButton.Image = _searchButtonImage; - saveFilterButton.Enabled = false; - } - else - { - filterSearchButton.Image = null; - saveFilterButton.Enabled = true; - } - } - - private bool IsFilterSearchDirty(FilterParams filterParams) - { - if (!filterParams.SearchText.Equals(filterComboBox.Text)) - { - return true; - } - - if (filterParams.IsRangeSearch != rangeCheckBox.Checked) - { - return true; - } - - if (filterParams.IsRangeSearch && !filterParams.RangeSearchText.Equals(filterRangeComboBox.Text)) - { - return true; - } - - if (filterParams.IsRegex != filterRegexCheckBox.Checked) - { - return true; - } - - if (filterParams.IsInvert != invertFilterCheckBox.Checked) - { - return true; - } - - if (filterParams.SpreadBefore != filterKnobBackSpread.Value) - { - return true; - } - - if (filterParams.SpreadBehind != filterKnobForeSpread.Value) - { - return true; - } - - if (filterParams.FuzzyValue != fuzzyKnobControl.Value) - { - return true; - } - - if (filterParams.ColumnRestrict != columnRestrictCheckBox.Checked) - { - return true; - } - - if (filterParams.IsCaseSensitive != filterCaseSensitiveCheckBox.Checked) - { - return true; - } - - return false; - } - - private void AdjustMinimumGridWith() - { - if (dataGridView.Columns.Count > 1) - { - //this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - AutoResizeColumns(dataGridView); - - int width = dataGridView.Columns.GetColumnsWidth(DataGridViewElementStates.Visible); - int diff = dataGridView.Width - width; - if (diff > 0) - { - diff -= dataGridView.RowHeadersWidth / 2; - dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].Width += diff; - filterGridView.Columns[filterGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].Width += diff; - } - } - } - - private void InvalidateCurrentRow(BufferedDataGridView gridView) - { - if (gridView.CurrentCellAddress.Y > -1) - { - gridView.InvalidateRow(gridView.CurrentCellAddress.Y); - } - } - - private void InvalidateCurrentRow() - { - InvalidateCurrentRow(dataGridView); - InvalidateCurrentRow(filterGridView); - } - - private void DisplayCurrentFileOnStatusline() - { - if (_logFileReader.IsMultiFile) - { - try - { - if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index > -1) - { - string fileName = _logFileReader.GetLogFileNameForLine(dataGridView.CurrentRow.Index); - if (fileName != null) - { - StatusLineText(Util.GetNameFromPath(fileName)); - } - } - } - catch (Exception) - { - // TODO: handle this concurrent situation better: - // this.dataGridView.CurrentRow may be null even if checked before. - // This can happen when MultiFile shift deselects the current row because there - // are less lines after rollover than before. - // access to dataGridView-Rows should be locked - } - } - } - - private void UpdateSelectionDisplay() - { - if (_noSelectionUpdates) - { - return; - } - } - - private void UpdateFilterHistoryFromSettings() - { - ConfigManager.Settings.filterHistoryList = ConfigManager.Settings.filterHistoryList; - filterComboBox.Items.Clear(); - foreach (string item in ConfigManager.Settings.filterHistoryList) - { - filterComboBox.Items.Add(item); - } - - filterRangeComboBox.Items.Clear(); - foreach (string item in ConfigManager.Settings.filterRangeHistoryList) - { - filterRangeComboBox.Items.Add(item); - } - } - - private void StatusLineText(string text) - { - _statusEventArgs.StatusText = text; - SendStatusLineUpdate(); - } - - private void StatusLineError(string text) - { - StatusLineText(text); - _isErrorShowing = true; - } - - private void RemoveStatusLineError() - { - StatusLineText(""); - _isErrorShowing = false; - } - - private void SendGuiStateUpdate() - { - OnGuiState(_guiStateArgs); - } - - private void SendProgressBarUpdate() - { - OnProgressBarUpdate(_progressEventArgs); - } - - private void SendStatusLineUpdate() - { - OnStatusLine(_statusEventArgs); - } - - private void ShowAdvancedFilterPanel(bool show) - { - if (show) - { - advancedButton.Text = "Hide advanced..."; - advancedButton.Image = null; - } - else - { - advancedButton.Text = "Show advanced..."; - CheckForAdvancedButtonDirty(); - } - - advancedFilterSplitContainer.Panel1Collapsed = !show; - advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; - _showAdvanced = show; - } - - private void CheckForAdvancedButtonDirty() - { - if (IsAdvancedOptionActive() && !_showAdvanced) - { - advancedButton.Image = _advancedButtonImage; - } - else - { - advancedButton.Image = null; - } - } - - private void FilterToTab() - { - filterSearchButton.Enabled = false; - Task.Run(() => WriteFilterToTab()); - } - - private void WriteFilterToTab() - { - FilterPipe pipe = new(_filterParams.Clone(), this); - lock (_filterResultList) - { - string namePrefix = "->F"; - string title; - if (IsTempFile) - { - title = TempTitleName + namePrefix + ++_filterPipeNameCounter; - } - else - { - title = Util.GetNameFromPath(FileName) + namePrefix + ++_filterPipeNameCounter; - } - - WritePipeToTab(pipe, _filterResultList, title, null); - } - } - - private void WritePipeToTab(FilterPipe pipe, IList lineNumberList, string name, PersistenceData persistenceData) - { - _logger.Info("WritePipeToTab(): {0} lines.", lineNumberList.Count); - StatusLineText("Writing to temp file... Press ESC to cancel."); - _guiStateArgs.MenuEnabled = false; - SendGuiStateUpdate(); - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = lineNumberList.Count; - _progressEventArgs.Value = 0; - _progressEventArgs.Visible = true; - Invoke(new MethodInvoker(SendProgressBarUpdate)); - _isSearching = true; - _shouldCancel = false; - - lock (_filterPipeList) - { - _filterPipeList.Add(pipe); - } - - pipe.Closed += OnPipeDisconnected; - int count = 0; - pipe.OpenFile(); - LogExpertCallback callback = new(this); - foreach (int i in lineNumberList) - { - if (_shouldCancel) - { - break; - } - - ILogLine line = _logFileReader.GetLogLine(i); - if (CurrentColumnizer is ILogLineXmlColumnizer) - { - callback.LineNum = i; - line = (CurrentColumnizer as ILogLineXmlColumnizer).GetLineTextForClipboard(line, callback); - } - - pipe.WriteToPipe(line, i); - if (++count % PROGRESS_BAR_MODULO == 0) - { - _progressEventArgs.Value = count; - Invoke(new MethodInvoker(SendProgressBarUpdate)); - } - } - - pipe.CloseFile(); - _logger.Info("WritePipeToTab(): finished"); - Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), pipe, name, persistenceData); - } - - private void WriteFilterToTabFinished(FilterPipe pipe, string name, PersistenceData persistenceData) - { - _isSearching = false; - if (!_shouldCancel) - { - string title = name; - ILogLineColumnizer preProcessColumnizer = null; - if (CurrentColumnizer is not ILogLineXmlColumnizer) - { - preProcessColumnizer = CurrentColumnizer; - } - - LogWindow newWin = _parentLogTabWin.AddFilterTab(pipe, title, preProcessColumnizer); - newWin.FilterPipe = pipe; - pipe.OwnLogWindow = newWin; - if (persistenceData != null) - { - Task.Run(() => FilterRestore(newWin, persistenceData)); - } - } - - _progressEventArgs.Value = _progressEventArgs.MaxValue; - _progressEventArgs.Visible = false; - SendProgressBarUpdate(); - _guiStateArgs.MenuEnabled = true; - SendGuiStateUpdate(); - StatusLineText(""); - filterSearchButton.Enabled = true; - } - - /// - /// Used to create a new tab and pipe the given content into it. - /// - /// - /// - internal void WritePipeTab(IList lineEntryList, string title) - { - FilterPipe pipe = new(new FilterParams(), this); - pipe.IsStopped = true; - pipe.Closed += OnPipeDisconnected; - pipe.OpenFile(); - foreach (LineEntry entry in lineEntryList) - { - pipe.WriteToPipe(entry.logLine, entry.lineNum); - } - - pipe.CloseFile(); - Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), [pipe, title, null]); - } - - private void FilterRestore(LogWindow newWin, PersistenceData persistenceData) - { - newWin.WaitForLoadingFinished(); - ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(persistenceData.columnizerName, - PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - if (columnizer != null) - { - SetColumnizerFx fx = newWin.ForceColumnizer; - newWin.Invoke(fx, [columnizer]); - } - else - { - _logger.Warn("FilterRestore(): Columnizer {0} not found", persistenceData.columnizerName); - } - - newWin.BeginInvoke(new RestoreFiltersFx(newWin.RestoreFilters), [persistenceData]); - } - - private void ProcessFilterPipes(int lineNum) - { - ILogLine searchLine = _logFileReader.GetLogLine(lineNum); - if (searchLine == null) - { - return; - } - - ColumnizerCallback callback = new(this); - callback.LineNum = lineNum; - IList deleteList = []; - lock (_filterPipeList) - { - foreach (FilterPipe pipe in _filterPipeList) - { - if (pipe.IsStopped) - { - continue; - } - - long startTime = Environment.TickCount; - if (Util.TestFilterCondition(pipe.FilterParams, searchLine, callback)) - { - IList filterResult = - GetAdditionalFilterResults(pipe.FilterParams, lineNum, pipe.LastLinesHistoryList); - pipe.OpenFile(); - foreach (int line in filterResult) - { - pipe.LastLinesHistoryList.Add(line); - if (pipe.LastLinesHistoryList.Count > SPREAD_MAX * 2) - { - pipe.LastLinesHistoryList.RemoveAt(0); - } - - ILogLine textLine = _logFileReader.GetLogLine(line); - bool fileOk = pipe.WriteToPipe(textLine, line); - if (!fileOk) - { - deleteList.Add(pipe); - } - } - - pipe.CloseFile(); - } - - long endTime = Environment.TickCount; - //_logger.logDebug("ProcessFilterPipes(" + lineNum + ") duration: " + ((endTime - startTime))); - } - } - - foreach (FilterPipe pipe in deleteList) - { - _filterPipeList.Remove(pipe); - } - } - - private void CopyMarkedLinesToClipboard() - { - if (_guiStateArgs.CellSelectMode) - { - DataObject data = dataGridView.GetClipboardContent(); - Clipboard.SetDataObject(data); - } - else - { - List lineNumList = []; - foreach (DataGridViewRow row in dataGridView.SelectedRows) - { - if (row.Index != -1) - { - lineNumList.Add(row.Index); - } - } - - lineNumList.Sort(); - StringBuilder clipText = new(); - LogExpertCallback callback = new(this); - - var xmlColumnizer = _currentColumnizer as ILogLineXmlColumnizer; - - foreach (int lineNum in lineNumList) - { - ILogLine line = _logFileReader.GetLogLine(lineNum); - if (xmlColumnizer != null) - { - callback.LineNum = lineNum; - line = xmlColumnizer.GetLineTextForClipboard(line, callback); - } - - clipText.AppendLine(line.ToClipBoardText()); - } - - Clipboard.SetText(clipText.ToString()); - } - } - - /// - /// Set an Encoding which shall be used when loading a file. Used before a file is loaded. - /// - /// - private void SetExplicitEncoding(Encoding encoding) - { - EncodingOptions.Encoding = encoding; - } - - private void ApplyDataGridViewPrefs(BufferedDataGridView dataGridView, Preferences prefs) - { - if (dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) > 1) - { - if (prefs.setLastColumnWidth) - { - dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].MinimumWidth = prefs.lastColumnWidth; - } - else - { - // Workaround for a .NET bug which brings the DataGridView into an unstable state (causing lots of NullReferenceExceptions). - dataGridView.FirstDisplayedScrollingColumnIndex = 0; - - dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].MinimumWidth = 5; // default - } - } - - if (dataGridView.RowCount > 0) - { - dataGridView.UpdateRowHeightInfo(0, true); - } - - dataGridView.Invalidate(); - dataGridView.Refresh(); - AutoResizeColumns(dataGridView); - } - - private IList GetSelectedContent() - { - if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) - { - List lineNumList = []; - - foreach (DataGridViewRow row in dataGridView.SelectedRows) - { - if (row.Index != -1) - { - lineNumList.Add(row.Index); - } - } - - lineNumList.Sort(); - return lineNumList; - } - - return []; - } - - /* ======================================================================== - * Timestamp stuff - * =======================================================================*/ - - private void SetTimestampLimits() - { - if (!CurrentColumnizer.IsTimeshiftImplemented()) - { - return; - } - - int line = 0; - _guiStateArgs.MinTimestamp = GetTimestampForLineForward(ref line, true); - line = dataGridView.RowCount - 1; - _guiStateArgs.MaxTimestamp = GetTimestampForLine(ref line, true); - SendGuiStateUpdate(); - } - - private void AdjustHighlightSplitterWidth() - { - //int size = this.editHighlightsSplitContainer.Panel2Collapsed ? 600 : 660; - //int distance = this.highlightSplitContainer.Width - size; - //if (distance < 10) - // distance = 10; - //this.highlightSplitContainer.SplitterDistance = distance; - } - - private void BookmarkComment(Bookmark bookmark) - { - BookmarkCommentDlg dlg = new(); - dlg.Comment = bookmark.Text; - if (dlg.ShowDialog() == DialogResult.OK) - { - bookmark.Text = dlg.Comment; - dataGridView.Refresh(); - OnBookmarkTextChanged(bookmark); - } - } - - /// - /// Indicates which columns we are filtering on - /// - /// - /// - private string CalculateColumnNames(FilterParams filter) - { - string names = string.Empty; - - if (filter.ColumnRestrict) - { - foreach (int colIndex in filter.ColumnList) - { - if (colIndex < dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 2) - { - if (names.Length > 0) - { - names += ", "; - } - - names += dataGridView.Columns[2 + colIndex] - .HeaderText; // skip first two columns: marker + line number - } - } - } - - return names; - } - - private void ApplyFrozenState(BufferedDataGridView gridView) - { - SortedDictionary dict = []; - foreach (DataGridViewColumn col in gridView.Columns) - { - dict.Add(col.DisplayIndex, col); - } - - foreach (DataGridViewColumn col in dict.Values) - { - col.Frozen = _freezeStateMap.ContainsKey(gridView) && _freezeStateMap[gridView]; - bool sel = col.HeaderCell.Selected; - if (col.Index == _selectedCol) - { - break; - } - } - } - - private void ShowTimeSpread(bool show) - { - if (show) - { - tableLayoutPanel1.ColumnStyles[1].Width = 16; - } - else - { - tableLayoutPanel1.ColumnStyles[1].Width = 0; - } - - _timeSpreadCalc.Enabled = show; - } - - protected internal void AddTempFileTab(string fileName, string title) - { - _parentLogTabWin.AddTempFileTab(fileName, title); - } - - private void InitPatternWindow() - { - //PatternStatistic(this.patternArgs); - _patternWindow = new PatternWindow(this); - _patternWindow.SetColumnizer(CurrentColumnizer); - //this.patternWindow.SetBlockList(blockList); - _patternWindow.SetFont(Preferences.fontName, Preferences.fontSize); - _patternWindow.Fuzzy = _patternArgs.Fuzzy; - _patternWindow.MaxDiff = _patternArgs.MaxDiffInBlock; - _patternWindow.MaxMisses = _patternArgs.MaxMisses; - _patternWindow.Weight = _patternArgs.MinWeight; - //this.patternWindow.Show(); - } - - private void TestStatistic(PatternArgs patternArgs) - { - int beginLine = patternArgs.StartLine; - _logger.Info("TestStatistics() called with start line {0}", beginLine); - - _patternArgs = patternArgs; - - int num = beginLine + 1; //this.dataGridView.RowCount; - - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = dataGridView.RowCount; - _progressEventArgs.Value = beginLine; - _progressEventArgs.Visible = true; - SendProgressBarUpdate(); - - PrepareDict(); - ResetCache(num); - - Dictionary processedLinesDict = []; - List blockList = []; - int blockId = 0; - _isSearching = true; - _shouldCancel = false; - int searchLine = -1; - for (int i = beginLine; i < num && !_shouldCancel; ++i) - { - if (processedLinesDict.ContainsKey(i)) - { - continue; - } - - PatternBlock block; - int maxBlockLen = patternArgs.EndLine - patternArgs.StartLine; - //int searchLine = i + 1; - _logger.Debug("TestStatistic(): i={0} searchLine={1}", i, searchLine); - //bool firstBlock = true; - searchLine++; - UpdateProgressBar(searchLine); - while (!_shouldCancel && - (block = - DetectBlock(i, searchLine, maxBlockLen, _patternArgs.MaxDiffInBlock, - _patternArgs.MaxMisses, - processedLinesDict)) != null) - { - _logger.Debug("Found block: {0}", block); - if (block.weigth >= _patternArgs.MinWeight) - { - //PatternBlock existingBlock = FindExistingBlock(block, blockList); - //if (existingBlock != null) - //{ - // if (block.weigth > existingBlock.weigth) - // { - // blockList.Remove(existingBlock); - // blockList.Add(block); - // } - //} - //else - { - blockList.Add(block); - addBlockTargetLinesToDict(processedLinesDict, block); - } - block.blockId = blockId; - //if (firstBlock) - //{ - // addBlockSrcLinesToDict(processedLinesDict, block); - //} - searchLine = block.targetEnd + 1; - } - else - { - searchLine = block.targetStart + 1; - } - - UpdateProgressBar(searchLine); - } - - blockId++; - } - - _isSearching = false; - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = 0; - _progressEventArgs.Value = 0; - _progressEventArgs.Visible = false; - SendProgressBarUpdate(); - //if (this.patternWindow.IsDisposed) - //{ - // this.Invoke(new MethodInvoker(CreatePatternWindow)); - //} - _patternWindow.SetBlockList(blockList, _patternArgs); - _logger.Info("TestStatistics() ended"); - } - - private void addBlockTargetLinesToDict(Dictionary dict, PatternBlock block) - { - foreach (int lineNum in block.targetLines.Keys) - { - if (!dict.ContainsKey(lineNum)) - { - dict.Add(lineNum, lineNum); - } - } - } - - //Well keep this for the moment because there is some other commented code which calls this one - private PatternBlock FindExistingBlock(PatternBlock block, List blockList) - { - foreach (PatternBlock searchBlock in blockList) - { - if ((block.startLine > searchBlock.startLine && - block.startLine < searchBlock.endLine - || - block.endLine > searchBlock.startLine && - block.endLine < searchBlock.endLine) && block.startLine != searchBlock.startLine && - block.endLine != searchBlock.endLine - ) - { - return searchBlock; - } - } - - return null; - } - - private PatternBlock DetectBlock(int startNum, int startLineToSearch, int maxBlockLen, int maxDiffInBlock, - int maxMisses, Dictionary processedLinesDict) - { - int targetLine = FindSimilarLine(startNum, startLineToSearch, processedLinesDict); - if (targetLine == -1) - { - return null; - } - - PatternBlock block = new(); - block.startLine = startNum; - int srcLine = block.startLine; - block.targetStart = targetLine; - int srcMisses = 0; - block.srcLines.Add(srcLine, srcLine); - //block.targetLines.Add(targetLine, targetLine); - int len = 0; - QualityInfo qi = new(); - qi.quality = block.weigth; - block.qualityInfoList[targetLine] = qi; - - while (!_shouldCancel) - { - srcLine++; - len++; - //if (srcLine >= block.targetStart) - // break; // prevent to search in the own block - if (maxBlockLen > 0 && len > maxBlockLen) - { - break; - } - - int nextTargetLine = FindSimilarLine(srcLine, targetLine + 1, processedLinesDict); - if (nextTargetLine > -1 && nextTargetLine - targetLine - 1 <= maxDiffInBlock) - { - block.weigth += maxDiffInBlock - (nextTargetLine - targetLine - 1) + 1; - block.endLine = srcLine; - //block.targetLines.Add(nextTargetLine, nextTargetLine); - block.srcLines.Add(srcLine, srcLine); - if (nextTargetLine - targetLine > 1) - { - int tempWeight = block.weigth; - for (int tl = targetLine + 1; tl < nextTargetLine; ++tl) - { - qi = new QualityInfo(); - qi.quality = --tempWeight; - block.qualityInfoList[tl] = qi; - } - } - - targetLine = nextTargetLine; - qi = new QualityInfo(); - qi.quality = block.weigth; - block.qualityInfoList[targetLine] = qi; - } - else - { - srcMisses++; - block.weigth--; - targetLine++; - qi = new QualityInfo(); - qi.quality = block.weigth; - block.qualityInfoList[targetLine] = qi; - if (srcMisses > maxMisses) - { - break; - } - } - } - - block.targetEnd = targetLine; - qi = new QualityInfo(); - qi.quality = block.weigth; - block.qualityInfoList[targetLine] = qi; - for (int k = block.targetStart; k <= block.targetEnd; ++k) - { - block.targetLines.Add(k, k); - } - - return block; - } - - private void PrepareDict() - { - _lineHashList.Clear(); - Regex regex = new("\\d"); - Regex regex2 = new("\\S"); - - int num = _logFileReader.LineCount; - for (int i = 0; i < num; ++i) - { - string msg = GetMsgForLine(i); - if (msg != null) - { - msg = msg.ToLower(); - msg = regex.Replace(msg, "0"); - msg = regex2.Replace(msg, " "); - char[] chars = msg.ToCharArray(); - int value = 0; - int numOfE = 0; - int numOfA = 0; - int numOfI = 0; - foreach (var t in chars) - { - value += t; - switch (t) - { - case 'e': - numOfE++; - break; - case 'a': - numOfA++; - break; - case 'i': - numOfI++; - break; - } - } - - value += numOfE * 30; - value += numOfA * 20; - value += numOfI * 10; - _lineHashList.Add(value); - } - } - } - - private int _FindSimilarLine(int srcLine, int startLine) - { - int value = _lineHashList[srcLine]; - - int num = _lineHashList.Count; - for (int i = startLine; i < num; ++i) - { - if (Math.Abs(_lineHashList[i] - value) < 3) - { - return i; - } - } - - return -1; - } - - // int[,] similarCache; - - private void ResetCache(int num) - { - //this.similarCache = new int[num, num]; - //for (int i = 0; i < num; ++i) - //{ - // for (int j = 0; j < num; j++) - // { - // this.similarCache[i, j] = -1; - // } - //} - } - - private int FindSimilarLine(int srcLine, int startLine, Dictionary processedLinesDict) - { - int threshold = _patternArgs.Fuzzy; - - bool prepared = false; - Regex regex = null; - Regex regex2 = null; - string msgToFind = null; - CultureInfo culture = CultureInfo.CurrentCulture; - - int num = _logFileReader.LineCount; - for (int i = startLine; i < num; ++i) - { - if (processedLinesDict.ContainsKey(i)) - { - continue; - } - - //if (this.similarCache[srcLine, i] != -1) - //{ - // if (this.similarCache[srcLine, i] < threshold) - // { - // return i; - // } - //} - //else - { - if (!prepared) - { - msgToFind = GetMsgForLine(srcLine); - regex = new Regex("\\d"); - regex2 = new Regex("\\W"); - msgToFind = msgToFind.ToLower(culture); - msgToFind = regex.Replace(msgToFind, "0"); - msgToFind = regex2.Replace(msgToFind, " "); - prepared = true; - } - - string msg = GetMsgForLine(i); - if (msg != null) - { - msg = regex.Replace(msg, "0"); - msg = regex2.Replace(msg, " "); - int lenDiff = Math.Abs(msg.Length - msgToFind.Length); - if (lenDiff > threshold) - { - //this.similarCache[srcLine, i] = lenDiff; - continue; - } - - msg = msg.ToLower(culture); - int distance = Util.YetiLevenshtein(msgToFind, msg); - //this.similarCache[srcLine, i] = distance; - if (distance < threshold) - { - return i; - } - } - } - } - - return -1; - } - - private string GetMsgForLine(int i) - { - ILogLine line = _logFileReader.GetLogLine(i); - ILogLineColumnizer columnizer = CurrentColumnizer; - ColumnizerCallback callback = new(this); - IColumnizedLogLine cols = columnizer.SplitLine(callback, line); - return cols.ColumnValues.Last().FullValue; - } - - private void ChangeRowHeight(bool decrease) - { - int rowNum = dataGridView.CurrentCellAddress.Y; - if (rowNum < 0 || rowNum >= dataGridView.RowCount) - { - return; - } - - if (decrease) - { - if (!_rowHeightList.ContainsKey(rowNum)) - { - return; - } - else - { - RowHeightEntry entry = _rowHeightList[rowNum]; - entry.Height -= _lineHeight; - if (entry.Height <= _lineHeight) - { - _rowHeightList.Remove(rowNum); - } - } - } - else - { - RowHeightEntry entry; - if (!_rowHeightList.ContainsKey(rowNum)) - { - entry = new RowHeightEntry(); - entry.LineNum = rowNum; - entry.Height = _lineHeight; - _rowHeightList[rowNum] = entry; - } - else - { - entry = _rowHeightList[rowNum]; - } - - entry.Height += _lineHeight; - } - - dataGridView.UpdateRowHeightInfo(rowNum, false); - if (rowNum == dataGridView.RowCount - 1 && _guiStateArgs.FollowTail) - { - dataGridView.FirstDisplayedScrollingRowIndex = rowNum; - } - - dataGridView.Refresh(); - } - - private int GetRowHeight(int rowNum) - { - if (_rowHeightList.ContainsKey(rowNum)) - { - return _rowHeightList[rowNum].Height; - } - else - { - return _lineHeight; - } - } - - private void AddBookmarkAtLineSilently(int lineNum) - { - if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - _bookmarkProvider.AddBookmark(new Bookmark(lineNum)); - } - } - - private void AddBookmarkAndEditComment() - { - int lineNum = dataGridView.CurrentCellAddress.Y; - if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - ToggleBookmark(); - } - - BookmarkComment(_bookmarkProvider.GetBookmarkForLine(lineNum)); - } - - private void AddBookmarkComment(string text) - { - int lineNum = dataGridView.CurrentCellAddress.Y; - Bookmark bookmark; - if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - _bookmarkProvider.AddBookmark(bookmark = new Bookmark(lineNum)); - } - else - { - bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); - } - - bookmark.Text += text; - dataGridView.Refresh(); - filterGridView.Refresh(); - OnBookmarkTextChanged(bookmark); - } - - private void MarkCurrentFilterRange() - { - _filterParams.RangeSearchText = filterRangeComboBox.Text; - ColumnizerCallback callback = new(this); - RangeFinder rangeFinder = new(_filterParams, callback); - Core.Entities.Range range = rangeFinder.FindRange(dataGridView.CurrentCellAddress.Y); - if (range != null) - { - SetCellSelectionMode(false); - _noSelectionUpdates = true; - for (int i = range.StartLine; i <= range.EndLine; ++i) - { - dataGridView.Rows[i].Selected = true; - } - - _noSelectionUpdates = false; - UpdateSelectionDisplay(); - } - } - - private void RemoveTempHighlights() - { - lock (_tempHighlightEntryListLock) - { - _tempHighlightEntryList.Clear(); - } - - RefreshAllGrids(); - } - - private void ToggleHighlightPanel(bool open) - { - highlightSplitContainer.Panel2Collapsed = !open; - btnToggleHighlightPanel.Image = open - ? new Bitmap(_panelCloseButtonImage, new Size(btnToggleHighlightPanel.Size.Height, btnToggleHighlightPanel.Size.Height)) - : new Bitmap(_panelOpenButtonImage, new Size(btnToggleHighlightPanel.Size.Height, btnToggleHighlightPanel.Size.Height)); - } - - private void SetBookmarksForSelectedFilterLines() - { - lock (_filterResultList) - { - foreach (DataGridViewRow row in filterGridView.SelectedRows) - { - int lineNum = _filterResultList[row.Index]; - AddBookmarkAtLineSilently(lineNum); - } - } - - dataGridView.Refresh(); - filterGridView.Refresh(); - OnBookmarkAdded(); - } - - private void SetDefaultHighlightGroup() - { - HighlightGroup group = _parentLogTabWin.FindHighlightGroupByFileMask(FileName); - if (group != null) - { - SetCurrentHighlightGroup(group.GroupName); - } - else - { - SetCurrentHighlightGroup("[Default]"); - } - } - - private void HandleChangedFilterOnLoadSetting() - { - _parentLogTabWin.Preferences.isFilterOnLoad = filterOnLoadCheckBox.Checked; - _parentLogTabWin.Preferences.isAutoHideFilterList = hideFilterListOnLoadCheckBox.Checked; - OnFilterListChanged(this); - } - - private void FireCancelHandlers() - { - lock (_cancelHandlerList) - { - foreach (BackgroundProcessCancelHandler handler in _cancelHandlerList) - { - handler.EscapePressed(); - } - } - } - - private void SyncOtherWindows(DateTime timestamp) - { - lock (_timeSyncListLock) - { - TimeSyncList?.NavigateToTimestamp(timestamp, this); - } - } - - private void AddSlaveToTimesync(LogWindow slave) - { - lock (_timeSyncListLock) - { - if (TimeSyncList == null) - { - if (slave.TimeSyncList == null) - { - TimeSyncList = new TimeSyncList(); - TimeSyncList.AddWindow(this); - } - else - { - TimeSyncList = slave.TimeSyncList; - } - - int currentLineNum = dataGridView.CurrentCellAddress.Y; - int refLine = currentLineNum; - DateTime timeStamp = GetTimestampForLine(ref refLine, true); - if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel) - { - TimeSyncList.CurrentTimestamp = timeStamp; - } - - TimeSyncList.WindowRemoved += OnTimeSyncListWindowRemoved; - } - } - - slave.AddToTimeSync(this); - OnSyncModeChanged(); - } - - private void FreeSlaveFromTimesync(LogWindow slave) - { - slave.FreeFromTimeSync(); - } - - private void OnSyncModeChanged() - { - SyncModeChanged?.Invoke(this, new SyncModeEventArgs(IsTimeSynced)); - } - - private void AddSearchHitHighlightEntry(SearchParams para) - { - HighlightEntry he = new() - { - SearchText = para.SearchText, - ForegroundColor = Color.Red, - BackgroundColor = Color.Yellow, - IsRegEx = para.IsRegex, - IsCaseSensitive = para.IsCaseSensitive, - IsLedSwitch = false, - IsStopTail = false, - IsSetBookmark = false, - IsActionEntry = false, - ActionEntry = null, - IsWordMatch = true, - IsSearchHit = true - }; - - lock (_tempHighlightEntryListLock) - { - _tempHighlightEntryList.Add(he); - } - - RefreshAllGrids(); - } - - private void RemoveAllSearchHighlightEntries() - { - lock (_tempHighlightEntryListLock) - { - List newList = []; - foreach (HighlightEntry he in _tempHighlightEntryList) - { - if (!he.IsSearchHit) - { - newList.Add(he); - } - } - - _tempHighlightEntryList = newList; - } - - RefreshAllGrids(); - } - - private DataGridViewColumn GetColumnByName(BufferedDataGridView dataGridView, string name) - { - foreach (DataGridViewColumn col in dataGridView.Columns) - { - if (col.HeaderText.Equals(name)) - { - return col; - } - } - - return null; - } - - private void SelectColumn() - { - string colName = columnComboBox.SelectedItem as string; - DataGridViewColumn col = GetColumnByName(dataGridView, colName); - if (col != null && !col.Frozen) - { - dataGridView.FirstDisplayedScrollingColumnIndex = col.Index; - int currentLine = dataGridView.CurrentCellAddress.Y; - if (currentLine >= 0) - { - dataGridView.CurrentCell = dataGridView.Rows[dataGridView.CurrentCellAddress.Y].Cells[col.Index]; - } - } - } - - #endregion - - } +using LogExpert.Classes.Filter; +using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Classes.Filter; +using LogExpert.Core.Classes.Highlight; +using LogExpert.Core.Classes.Persister; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.EventArguments; +using LogExpert.Dialogs; +using LogExpert.Extensions; +using LogExpert.UI.Entities; +using System.Globalization; +using System.Text; +using System.Text.RegularExpressions; + +namespace LogExpert.UI.Controls.LogWindow +{ + partial class LogWindow + { + #region Private Methods + + private void RegisterLogFileReaderEvents() + { + _logFileReader.LoadFile += OnLogFileReaderLoadFile; + _logFileReader.LoadingFinished += OnLogFileReaderFinishedLoading; + _logFileReader.LoadingStarted += OnLogFileReaderLoadingStarted; + _logFileReader.FileNotFound += OnLogFileReaderFileNotFound; + _logFileReader.Respawned += OnLogFileReaderRespawned; + // FileSizeChanged is not registered here because it's registered after loading has finished + } + + private void UnRegisterLogFileReaderEvents() + { + if (_logFileReader != null) + { + _logFileReader.LoadFile -= OnLogFileReaderLoadFile; + _logFileReader.LoadingFinished -= OnLogFileReaderFinishedLoading; + _logFileReader.LoadingStarted -= OnLogFileReaderLoadingStarted; + _logFileReader.FileNotFound -= OnLogFileReaderFileNotFound; + _logFileReader.Respawned -= OnLogFileReaderRespawned; + _logFileReader.FileSizeChanged -= OnFileSizeChanged; + } + } + + private void CreateDefaultViewStyle() + { + DataGridViewCellStyle dataGridViewCellStyleMainGrid = new(); + DataGridViewCellStyle dataGridViewCellStyleFilterGrid = new(); + + dataGridViewCellStyleMainGrid.Alignment = DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyleMainGrid.BackColor = SystemColors.Window; + dataGridViewCellStyleMainGrid.Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); + dataGridViewCellStyleMainGrid.ForeColor = SystemColors.ControlText; + dataGridViewCellStyleMainGrid.SelectionBackColor = SystemColors.Highlight; + dataGridViewCellStyleMainGrid.SelectionForeColor = SystemColors.HighlightText; + dataGridViewCellStyleMainGrid.WrapMode = DataGridViewTriState.False; + dataGridView.DefaultCellStyle = dataGridViewCellStyleMainGrid; + + dataGridViewCellStyleFilterGrid.Alignment = DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyleFilterGrid.BackColor = SystemColors.Window; + dataGridViewCellStyleFilterGrid.Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); + dataGridViewCellStyleFilterGrid.ForeColor = SystemColors.ControlText; + dataGridViewCellStyleFilterGrid.SelectionBackColor = SystemColors.Highlight; + dataGridViewCellStyleFilterGrid.SelectionForeColor = SystemColors.HighlightText; + dataGridViewCellStyleFilterGrid.WrapMode = DataGridViewTriState.False; + filterGridView.DefaultCellStyle = dataGridViewCellStyleFilterGrid; + } + + private bool LoadPersistenceOptions() + { + if (InvokeRequired) + { + return (bool)Invoke(new BoolReturnDelegate(LoadPersistenceOptions)); + } + + if (!Preferences.saveSessions && ForcedPersistenceFileName == null) + { + return false; + } + + try + { + PersistenceData persistenceData; + if (ForcedPersistenceFileName == null) + { + persistenceData = Persister.LoadPersistenceDataOptionsOnly(FileName, Preferences); + } + else + { + persistenceData = + Persister.LoadPersistenceDataOptionsOnlyFromFixedFile(ForcedPersistenceFileName); + } + + if (persistenceData == null) + { + _logger.Info($"No persistence data for {FileName} found."); + return false; + } + + IsMultiFile = persistenceData.multiFile; + _multiFileOptions = new MultiFileOptions(); + _multiFileOptions.FormatPattern = persistenceData.multiFilePattern; + _multiFileOptions.MaxDayTry = persistenceData.multiFileMaxDays; + + if (string.IsNullOrEmpty(_multiFileOptions.FormatPattern)) + { + _multiFileOptions = ObjectClone.Clone(Preferences.multiFileOptions); + } + + splitContainerLogWindow.SplitterDistance = persistenceData.filterPosition; + splitContainerLogWindow.Panel2Collapsed = !persistenceData.filterVisible; + ToggleHighlightPanel(persistenceData.filterSaveListVisible); + ShowAdvancedFilterPanel(persistenceData.filterAdvanced); + + if (_reloadMemento == null) + { + PreselectColumnizer(persistenceData.columnizerName); + } + + FollowTailChanged(persistenceData.followTail, false); + if (persistenceData.tabName != null) + { + Text = persistenceData.tabName; + } + + AdjustHighlightSplitterWidth(); + SetCurrentHighlightGroup(persistenceData.highlightGroupName); + + if (persistenceData.multiFileNames.Count > 0) + { + _logger.Info("Detected MultiFile name list in persistence options"); + _fileNames = new string[persistenceData.multiFileNames.Count]; + persistenceData.multiFileNames.CopyTo(_fileNames); + } + else + { + _fileNames = null; + } + + //this.bookmarkWindow.ShowBookmarkCommentColumn = persistenceData.showBookmarkCommentColumn; + SetExplicitEncoding(persistenceData.encoding); + return true; + } + catch (Exception ex) + { + _logger.Error(ex, "Error loading persistence data: "); + return false; + } + } + + private void SetDefaultsFromPrefs() + { + filterTailCheckBox.Checked = Preferences.filterTail; + syncFilterCheckBox.Checked = Preferences.filterSync; + FollowTailChanged(Preferences.followTail, false); + _multiFileOptions = ObjectClone.Clone(Preferences.multiFileOptions); + } + + private void LoadPersistenceData() + { + if (InvokeRequired) + { + Invoke(new MethodInvoker(LoadPersistenceData)); + return; + } + + if (!Preferences.saveSessions && !ForcePersistenceLoading && ForcedPersistenceFileName == null) + { + SetDefaultsFromPrefs(); + return; + } + + if (IsTempFile) + { + SetDefaultsFromPrefs(); + return; + } + + ForcePersistenceLoading = false; // force only 1 time (while session load) + + try + { + PersistenceData persistenceData; + + if (ForcedPersistenceFileName == null) + { + persistenceData = Persister.LoadPersistenceData(FileName, Preferences); + } + else + { + persistenceData = Persister.LoadPersistenceDataFromFixedFile(ForcedPersistenceFileName); + } + + if (persistenceData.lineCount > _logFileReader.LineCount) + { + // outdated persistence data (logfile rollover) + // MessageBox.Show(this, "Persistence data for " + this.FileName + " is outdated. It was discarded.", "Log Expert"); + _logger.Info("Persistence data for {0} is outdated. It was discarded.", FileName); + LoadPersistenceOptions(); + return; + } + + _bookmarkProvider.BookmarkList = persistenceData.bookmarkList; + _rowHeightList = persistenceData.rowHeightList; + try + { + if (persistenceData.currentLine >= 0 && persistenceData.currentLine < dataGridView.RowCount) + { + SelectLine(persistenceData.currentLine, false, true); + } + else + { + if (_logFileReader.LineCount > 0) + { + dataGridView.FirstDisplayedScrollingRowIndex = _logFileReader.LineCount - 1; + SelectLine(_logFileReader.LineCount - 1, false, true); + } + } + + if (persistenceData.firstDisplayedLine >= 0 && + persistenceData.firstDisplayedLine < dataGridView.RowCount) + { + dataGridView.FirstDisplayedScrollingRowIndex = persistenceData.firstDisplayedLine; + } + + if (persistenceData.followTail) + { + FollowTailChanged(persistenceData.followTail, false); + } + } + catch (ArgumentOutOfRangeException) + { + // FirstDisplayedScrollingRowIndex calculates sometimes the wrong scrolling ranges??? + } + + if (Preferences.saveFilters) + { + RestoreFilters(persistenceData); + } + } + catch (IOException ex) + { + SetDefaultsFromPrefs(); + _logger.Error(ex, "Error loading bookmarks: "); + } + } + + private void RestoreFilters(PersistenceData persistenceData) + { + if (persistenceData.filterParamsList.Count > 0) + { + _filterParams = persistenceData.filterParamsList[0]; + ReInitFilterParams(_filterParams); + } + + ApplyFilterParams(); // re-loaded filter settingss + BeginInvoke(new MethodInvoker(FilterSearch)); + try + { + splitContainerLogWindow.SplitterDistance = persistenceData.filterPosition; + splitContainerLogWindow.Panel2Collapsed = !persistenceData.filterVisible; + } + catch (InvalidOperationException e) + { + _logger.Error(e, "Error setting splitter distance: "); + } + + ShowAdvancedFilterPanel(persistenceData.filterAdvanced); + if (_filterPipeList.Count == 0) // don't restore if it's only a reload + { + RestoreFilterTabs(persistenceData); + } + } + + private void RestoreFilterTabs(PersistenceData persistenceData) + { + foreach (FilterTabData data in persistenceData.filterTabDataList) + { + FilterParams persistFilterParams = data.FilterParams; + ReInitFilterParams(persistFilterParams); + List filterResultList = []; + //List lastFilterResultList = new List(); + List filterHitList = []; + Filter(persistFilterParams, filterResultList, _lastFilterLinesList, filterHitList); + FilterPipe pipe = new(persistFilterParams.Clone(), this); + WritePipeToTab(pipe, filterResultList, data.PersistenceData.tabName, data.PersistenceData); + } + } + + private void ReInitFilterParams(FilterParams filterParams) + { + filterParams.SearchText = filterParams.SearchText; // init "lowerSearchText" + filterParams.RangeSearchText = filterParams.RangeSearchText; // init "lowerRangesearchText" + filterParams.CurrentColumnizer = CurrentColumnizer; + if (filterParams.IsRegex) + { + try + { + filterParams.CreateRegex(); + } + catch (ArgumentException) + { + StatusLineError("Invalid regular expression"); + } + } + } + + private void EnterLoadFileStatus() + { + _logger.Debug("EnterLoadFileStatus begin"); + + if (InvokeRequired) + { + Invoke(new MethodInvoker(EnterLoadFileStatus)); + return; + } + + _statusEventArgs.StatusText = "Loading file..."; + _statusEventArgs.LineCount = 0; + _statusEventArgs.FileSize = 0; + SendStatusLineUpdate(); + + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = 0; + _progressEventArgs.Value = 0; + _progressEventArgs.Visible = true; + SendProgressBarUpdate(); + + _isLoading = true; + _shouldCancel = true; + ClearFilterList(); + ClearBookmarkList(); + dataGridView.ClearSelection(); + dataGridView.RowCount = 0; + _logger.Debug("EnterLoadFileStatus end"); + } + + private void PositionAfterReload(ReloadMemento reloadMemento) + { + if (_reloadMemento.CurrentLine < dataGridView.RowCount && _reloadMemento.CurrentLine >= 0) + { + dataGridView.CurrentCell = dataGridView.Rows[_reloadMemento.CurrentLine].Cells[0]; + } + + if (_reloadMemento.FirstDisplayedLine < dataGridView.RowCount && _reloadMemento.FirstDisplayedLine >= 0) + { + dataGridView.FirstDisplayedScrollingRowIndex = _reloadMemento.FirstDisplayedLine; + } + } + + private void LogfileDead() + { + _logger.Info("File not found."); + _isDeadFile = true; + + //this.logFileReader.FileSizeChanged -= this.FileSizeChangedHandler; + //if (this.logFileReader != null) + // this.logFileReader.stopMonitoring(); + + dataGridView.Enabled = false; + dataGridView.RowCount = 0; + _progressEventArgs.Visible = false; + _progressEventArgs.Value = _progressEventArgs.MaxValue; + SendProgressBarUpdate(); + _statusEventArgs.FileSize = 0; + _statusEventArgs.LineCount = 0; + _statusEventArgs.CurrentLineNum = 0; + SendStatusLineUpdate(); + _shouldCancel = true; + ClearFilterList(); + ClearBookmarkList(); + + StatusLineText("File not found"); + OnFileNotFound(EventArgs.Empty); + } + + private void LogfileRespawned() + { + _logger.Info("LogfileDead(): Reloading file because it has been respawned."); + _isDeadFile = false; + dataGridView.Enabled = true; + StatusLineText(""); + OnFileRespawned(EventArgs.Empty); + Reload(); + } + + private void SetGuiAfterLoading() + { + if (Text.Length == 0) + { + if (IsTempFile) + { + Text = TempTitleName; + } + else + { + Text = Util.GetNameFromPath(FileName); + } + } + + ShowBookmarkBubbles = Preferences.showBubbles; + //if (this.forcedColumnizer == null) + { + ILogLineColumnizer columnizer; + if (_forcedColumnizerForLoading != null) + { + columnizer = _forcedColumnizerForLoading; + _forcedColumnizerForLoading = null; + } + else + { + columnizer = FindColumnizer(); + if (columnizer != null) + { + if (_reloadMemento == null) + { + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + + columnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); + } + } + else + { + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + + // Default Columnizers + columnizer = ColumnizerPicker.CloneColumnizer(ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers), directory); + } + } + + Invoke(new SetColumnizerFx(SetColumnizer), columnizer); + } + dataGridView.Enabled = true; + DisplayCurrentFileOnStatusline(); + //this.guiStateArgs.FollowTail = this.Preferences.followTail; + _guiStateArgs.MultiFileEnabled = !IsTempFile; + _guiStateArgs.MenuEnabled = true; + _guiStateArgs.CurrentEncoding = _logFileReader.CurrentEncoding; + SendGuiStateUpdate(); + //if (this.dataGridView.RowCount > 0) + // SelectLine(this.dataGridView.RowCount - 1); + //if (this.dataGridView.Columns.Count > 1) + //{ + // this.dataGridView.Columns[this.dataGridView.Columns.Count-1].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; + // this.dataGridView.Columns[this.dataGridView.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; + // AdjustMinimumGridWith(); + //} + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + if (Preferences.timestampControl) + { + SetTimestampLimits(); + SyncTimestampDisplay(); + } + + Settings settings = ConfigManager.Settings; + ShowLineColumn(!settings.hideLineColumn); + } + + ShowTimeSpread(Preferences.showTimeSpread && CurrentColumnizer.IsTimeshiftImplemented()); + locateLineInOriginalFileToolStripMenuItem.Enabled = FilterPipe != null; + } + + private ILogLineColumnizer FindColumnizer() + { + ILogLineColumnizer columnizer; + if (Preferences.maskPrio) + { + columnizer = _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)) ?? _parentLogTabWin.GetColumnizerHistoryEntry(FileName); + } + else + { + columnizer = _parentLogTabWin.GetColumnizerHistoryEntry(FileName) ?? _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)); + } + + return columnizer; + } + + private void ReloadNewFile() + { + // prevent "overloads". May occur on very fast rollovers (next rollover before the file is reloaded) + lock (_reloadLock) + { + _reloadOverloadCounter++; + _logger.Info("ReloadNewFile(): counter = {0}", _reloadOverloadCounter); + if (_reloadOverloadCounter <= 1) + { + SavePersistenceData(false); + _loadingFinishedEvent.Reset(); + _externaLoadingFinishedEvent.Reset(); + Thread reloadFinishedThread = new(ReloadFinishedThreadFx); + reloadFinishedThread.IsBackground = true; + reloadFinishedThread.Start(); + LoadFile(FileName, EncodingOptions); + + ClearBookmarkList(); + SavePersistenceData(false); + + //if (this.filterTailCheckBox.Checked) + //{ + // _logger.logDebug("Waiting for loading to be complete."); + // loadingFinishedEvent.WaitOne(); + // _logger.logDebug("Refreshing filter view because of reload."); + // FilterSearch(); + //} + //LoadFilterPipes(); + } + else + { + _logger.Debug("Preventing reload because of recursive calls."); + } + + _reloadOverloadCounter--; + } + } + + private void ReloadFinishedThreadFx() + { + _logger.Info("Waiting for loading to be complete."); + _loadingFinishedEvent.WaitOne(); + _logger.Info("Refreshing filter view because of reload."); + Invoke(new MethodInvoker(FilterSearch)); + LoadFilterPipes(); + } + + private void UpdateProgress(LoadFileEventArgs e) + { + try + { + if (e.ReadPos >= e.FileSize) + { + //_logger.Warn("UpdateProgress(): ReadPos (" + e.ReadPos + ") is greater than file size (" + e.FileSize + "). Aborting Update"); + return; + } + + _statusEventArgs.FileSize = e.ReadPos; + //this.progressEventArgs.Visible = true; + _progressEventArgs.MaxValue = (int)e.FileSize; + _progressEventArgs.Value = (int)e.ReadPos; + SendProgressBarUpdate(); + SendStatusLineUpdate(); + } + catch (Exception ex) + { + _logger.Error(ex, "UpdateProgress(): "); + } + } + + private void LoadingStarted(LoadFileEventArgs e) + { + try + { + _statusEventArgs.FileSize = e.ReadPos; + _statusEventArgs.StatusText = "Loading " + Util.GetNameFromPath(e.FileName); + _progressEventArgs.Visible = true; + _progressEventArgs.MaxValue = (int)e.FileSize; + _progressEventArgs.Value = (int)e.ReadPos; + SendProgressBarUpdate(); + SendStatusLineUpdate(); + } + catch (Exception ex) + { + _logger.Error(ex, "LoadingStarted(): "); + } + } + + private void LoadingFinished() + { + _logger.Info("File loading complete."); + + StatusLineText(""); + _logFileReader.FileSizeChanged += OnFileSizeChanged; + _isLoading = false; + _shouldCancel = false; + dataGridView.SuspendLayout(); + dataGridView.RowCount = _logFileReader.LineCount; + dataGridView.CurrentCellChanged += OnDataGridViewCurrentCellChanged; + dataGridView.Enabled = true; + dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + dataGridView.ResumeLayout(); + _progressEventArgs.Visible = false; + _progressEventArgs.Value = _progressEventArgs.MaxValue; + SendProgressBarUpdate(); + //if (this.logFileReader.LineCount > 0) + //{ + // this.dataGridView.FirstDisplayedScrollingRowIndex = this.logFileReader.LineCount - 1; + // SelectLine(this.logFileReader.LineCount - 1); + //} + _guiStateArgs.FollowTail = true; + SendGuiStateUpdate(); + _statusEventArgs.LineCount = _logFileReader.LineCount; + _statusEventArgs.FileSize = _logFileReader.FileSize; + SendStatusLineUpdate(); + + PreferencesChanged(_parentLogTabWin.Preferences, true, SettingsFlags.All); + //LoadPersistenceData(); + } + + private void LogEventWorker() + { + Thread.CurrentThread.Name = "LogEventWorker"; + while (true) + { + _logger.Debug("Waiting for signal"); + _logEventArgsEvent.WaitOne(); + _logger.Debug("Wakeup signal received."); + while (true) + { + LogEventArgs e; + int lastLineCount = 0; + lock (_logEventArgsList) + { + _logger.Info("{0} events in queue", _logEventArgsList.Count); + if (_logEventArgsList.Count == 0) + { + _logEventArgsEvent.Reset(); + break; + } + + e = _logEventArgsList[0]; + _logEventArgsList.RemoveAt(0); + } + + if (e.IsRollover) + { + ShiftBookmarks(e.RolloverOffset); + ShiftRowHeightList(e.RolloverOffset); + ShiftFilterPipes(e.RolloverOffset); + lastLineCount = 0; + } + else + { + if (e.LineCount < lastLineCount) + { + _logger.Error("Line count of event is: {0}, should be greater than last line count: {1}", e.LineCount, lastLineCount); + } + } + + Invoke(UpdateGrid, [e]); + CheckFilterAndHighlight(e); + _timeSpreadCalc.SetLineCount(e.LineCount); + } + } + } + + private void StopLogEventWorkerThread() + { + _logEventArgsEvent.Set(); + cts.Cancel(); + //_logEventHandlerThread.Abort(); + //_logEventHandlerThread.Join(); + } + + private void OnFileSizeChanged(LogEventArgs e) + { + FileSizeChanged?.Invoke(this, e); + } + + private void UpdateGrid(LogEventArgs e) + { + int oldRowCount = dataGridView.RowCount; + int firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex; + + if (dataGridView.CurrentCellAddress.Y >= e.LineCount) + { + //this.dataGridView.Rows[this.dataGridView.CurrentCellAddress.Y].Selected = false; + //this.dataGridView.CurrentCell = this.dataGridView.Rows[0].Cells[0]; + } + + try + { + if (dataGridView.RowCount > e.LineCount) + { + int currentLineNum = dataGridView.CurrentCellAddress.Y; + dataGridView.RowCount = 0; + dataGridView.RowCount = e.LineCount; + if (_guiStateArgs.FollowTail == false) + { + if (currentLineNum >= dataGridView.RowCount) + { + currentLineNum = dataGridView.RowCount - 1; + } + + dataGridView.CurrentCell = dataGridView.Rows[currentLineNum].Cells[0]; + } + } + else + { + dataGridView.RowCount = e.LineCount; + } + + _logger.Debug("UpdateGrid(): new RowCount={0}", dataGridView.RowCount); + + if (e.IsRollover) + { + // Multifile rollover + // keep selection and view range, if no follow tail mode + if (!_guiStateArgs.FollowTail) + { + int currentLineNum = dataGridView.CurrentCellAddress.Y; + currentLineNum -= e.RolloverOffset; + if (currentLineNum < 0) + { + currentLineNum = 0; + } + + _logger.Debug("UpdateGrid(): Rollover=true, Rollover offset={0}, currLineNum was {1}, new currLineNum={2}", e.RolloverOffset, dataGridView.CurrentCellAddress.Y, currentLineNum); + firstDisplayedLine -= e.RolloverOffset; + if (firstDisplayedLine < 0) + { + firstDisplayedLine = 0; + } + + dataGridView.FirstDisplayedScrollingRowIndex = firstDisplayedLine; + dataGridView.CurrentCell = dataGridView.Rows[currentLineNum].Cells[0]; + dataGridView.Rows[currentLineNum].Selected = true; + } + } + + _statusEventArgs.LineCount = e.LineCount; + StatusLineFileSize(e.FileSize); + + if (!_isLoading) + { + if (oldRowCount == 0) + { + AdjustMinimumGridWith(); + } + + //CheckFilterAndHighlight(e); + } + + if (_guiStateArgs.FollowTail && dataGridView.RowCount > 0) + { + dataGridView.FirstDisplayedScrollingRowIndex = dataGridView.RowCount - 1; + OnTailFollowed(EventArgs.Empty); + } + + if (Preferences.timestampControl && !_isLoading) + { + SetTimestampLimits(); + } + } + catch (Exception ex) + { + _logger.Error(ex, "Fehler bei UpdateGrid(): "); + } + + //this.dataGridView.Refresh(); + //this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + } + + private void CheckFilterAndHighlight(LogEventArgs e) + { + bool noLed = true; + bool suppressLed; + bool setBookmark; + bool stopTail; + string bookmarkComment; + + if (filterTailCheckBox.Checked || _filterPipeList.Count > 0) + { + int filterStart = e.PrevLineCount; + if (e.IsRollover) + { + ShiftFilterLines(e.RolloverOffset); + filterStart -= e.RolloverOffset; + } + + bool firstStopTail = true; + ColumnizerCallback callback = new(this); + bool filterLineAdded = false; + for (int i = filterStart; i < e.LineCount; ++i) + { + ILogLine line = _logFileReader.GetLogLine(i); + if (line == null) + { + return; + } + + if (filterTailCheckBox.Checked) + { + callback.LineNum = i; + if (Util.TestFilterCondition(_filterParams, line, callback)) + { + //AddFilterLineFx addFx = new AddFilterLineFx(AddFilterLine); + //this.Invoke(addFx, new object[] { i, true }); + filterLineAdded = true; + AddFilterLine(i, false, _filterParams, _filterResultList, _lastFilterLinesList, + _filterHitList); + } + } + + //ProcessFilterPipeFx pipeFx = new ProcessFilterPipeFx(ProcessFilterPipes); + //pipeFx.BeginInvoke(i, null, null); + ProcessFilterPipes(i); + + IList matchingList = FindMatchingHilightEntries(line); + LaunchHighlightPlugins(matchingList, i); + GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, out bookmarkComment); + if (setBookmark) + { + SetBookmarkFx fx = SetBookmarkFromTrigger; + fx.BeginInvoke(i, bookmarkComment, null, null); + } + + if (stopTail && _guiStateArgs.FollowTail) + { + bool wasFollow = _guiStateArgs.FollowTail; + FollowTailChanged(false, true); + if (firstStopTail && wasFollow) + { + Invoke(new SelectLineFx(SelectAndEnsureVisible), [i, false]); + firstStopTail = false; + } + } + + if (!suppressLed) + { + noLed = false; + } + } + + if (filterLineAdded) + { + //AddFilterLineGuiUpdateFx addFx = new AddFilterLineGuiUpdateFx(AddFilterLineGuiUpdate); + //this.Invoke(addFx); + TriggerFilterLineGuiUpdate(); + } + } + else + { + bool firstStopTail = true; + int startLine = e.PrevLineCount; + if (e.IsRollover) + { + ShiftFilterLines(e.RolloverOffset); + startLine -= e.RolloverOffset; + } + + for (int i = startLine; i < e.LineCount; ++i) + { + ILogLine line = _logFileReader.GetLogLine(i); + if (line != null) + { + IList matchingList = FindMatchingHilightEntries(line); + LaunchHighlightPlugins(matchingList, i); + GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, + out bookmarkComment); + if (setBookmark) + { + SetBookmarkFx fx = SetBookmarkFromTrigger; + fx.BeginInvoke(i, bookmarkComment, null, null); + } + + if (stopTail && _guiStateArgs.FollowTail) + { + bool wasFollow = _guiStateArgs.FollowTail; + FollowTailChanged(false, true); + if (firstStopTail && wasFollow) + { + Invoke(new SelectLineFx(SelectAndEnsureVisible), [i, false]); + firstStopTail = false; + } + } + + if (!suppressLed) + { + noLed = false; + } + } + } + } + + if (!noLed) + { + OnFileSizeChanged(e); + } + } + + private void LaunchHighlightPlugins(IList matchingList, int lineNum) + { + LogExpertCallback callback = new(this) + { + LineNum = lineNum + }; + + foreach (HighlightEntry entry in matchingList) + { + if (entry.IsActionEntry && entry.ActionEntry.PluginName != null) + { + IKeywordAction plugin = PluginRegistry.PluginRegistry.Instance.FindKeywordActionPluginByName(entry.ActionEntry.PluginName); + if (plugin != null) + { + ActionPluginExecuteFx fx = plugin.Execute; + fx.BeginInvoke(entry.SearchText, entry.ActionEntry.ActionParam, callback, + CurrentColumnizer, null, null); + } + } + } + } + + private void PreSelectColumnizer(ILogLineColumnizer columnizer) + { + if (columnizer != null) + { + CurrentColumnizer = _forcedColumnizerForLoading = columnizer; + } + else + { + CurrentColumnizer = _forcedColumnizerForLoading = + ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + } + } + + private void SetColumnizer(ILogLineColumnizer columnizer) + { + columnizer = ColumnizerPicker.FindReplacementForAutoColumnizer(FileName, _logFileReader, columnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + + int timeDiff = 0; + if (CurrentColumnizer != null && CurrentColumnizer.IsTimeshiftImplemented()) + { + timeDiff = CurrentColumnizer.GetTimeOffset(); + } + + SetColumnizerInternal(columnizer); + + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + CurrentColumnizer.SetTimeOffset(timeDiff); + } + } + + private void SetColumnizerInternal(ILogLineColumnizer columnizer) + { + _logger.Info("SetColumnizerInternal(): {0}", columnizer.GetName()); + + ILogLineColumnizer oldColumnizer = CurrentColumnizer; + bool oldColumnizerIsXmlType = CurrentColumnizer is ILogLineXmlColumnizer; + bool oldColumnizerIsPreProcess = CurrentColumnizer is IPreProcessColumnizer; + bool mustReload = false; + + // Check if the filtered columns disappeared, if so must refresh the UI + if (_filterParams.ColumnRestrict) + { + string[] newColumns = columnizer != null ? columnizer.GetColumnNames() : Array.Empty(); + bool colChanged = false; + + if (dataGridView.ColumnCount - 2 == newColumns.Length) // two first columns are 'marker' and 'line number' + { + for (int i = 0; i < newColumns.Length; i++) + { + if (dataGridView.Columns[i].HeaderText != newColumns[i]) + { + colChanged = true; + break; // one change is sufficient + } + } + } + else + { + colChanged = true; + } + + if (colChanged) + { + // Update UI + columnNamesLabel.Text = CalculateColumnNames(_filterParams); + } + } + + Type oldColType = _filterParams.CurrentColumnizer?.GetType(); + Type newColType = columnizer?.GetType(); + + if (oldColType != newColType && _filterParams.ColumnRestrict && _filterParams.IsFilterTail) + { + _filterParams.ColumnList.Clear(); + } + + if (CurrentColumnizer == null || CurrentColumnizer.GetType() != columnizer.GetType()) + { + CurrentColumnizer = columnizer; + _freezeStateMap.Clear(); + if (_logFileReader != null) + { + if (CurrentColumnizer is IPreProcessColumnizer) + { + _logFileReader.PreProcessColumnizer = (IPreProcessColumnizer)CurrentColumnizer; + } + else + { + _logFileReader.PreProcessColumnizer = null; + } + } + + // always reload when choosing XML columnizers + if (_logFileReader != null && CurrentColumnizer is ILogLineXmlColumnizer) + { + //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() + mustReload = true; + } + + // Reload when choosing no XML columnizer but previous columnizer was XML + if (_logFileReader != null && !(CurrentColumnizer is ILogLineXmlColumnizer) && oldColumnizerIsXmlType) + { + _logFileReader.IsXmlMode = false; + //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() + mustReload = true; + } + + // Reload when previous columnizer was PreProcess and current is not, and vice versa. + // When the current columnizer is a preProcess columnizer, reload in every case. + if (CurrentColumnizer is IPreProcessColumnizer != oldColumnizerIsPreProcess || + CurrentColumnizer is IPreProcessColumnizer) + { + //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() + mustReload = true; + } + } + else + { + CurrentColumnizer = columnizer; + } + + (oldColumnizer as IInitColumnizer)?.DeSelected(new ColumnizerCallback(this)); + + (columnizer as IInitColumnizer)?.Selected(new ColumnizerCallback(this)); + + SetColumnizer(columnizer, dataGridView); + SetColumnizer(columnizer, filterGridView); + _patternWindow?.SetColumnizer(columnizer); + + _guiStateArgs.TimeshiftPossible = columnizer.IsTimeshiftImplemented(); + SendGuiStateUpdate(); + + if (_logFileReader != null) + { + dataGridView.RowCount = _logFileReader.LineCount; + } + + if (_filterResultList != null) + { + filterGridView.RowCount = _filterResultList.Count; + } + + if (mustReload) + { + Reload(); + } + else + { + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + SetTimestampLimits(); + SyncTimestampDisplay(); + } + + Settings settings = ConfigManager.Settings; + ShowLineColumn(!settings.hideLineColumn); + ShowTimeSpread(Preferences.showTimeSpread && columnizer.IsTimeshiftImplemented()); + } + + if (!columnizer.IsTimeshiftImplemented() && IsTimeSynced) + { + FreeFromTimeSync(); + } + + columnComboBox.Items.Clear(); + + foreach (string columnName in columnizer.GetColumnNames()) + { + columnComboBox.Items.Add(columnName); + } + + columnComboBox.SelectedIndex = 0; + + OnColumnizerChanged(CurrentColumnizer); + } + + private void AutoResizeColumns(BufferedDataGridView gridView) + { + try + { + gridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + if (gridView.Columns.Count > 1 && Preferences.setLastColumnWidth && + gridView.Columns[gridView.Columns.Count - 1].Width < Preferences.lastColumnWidth + ) + { + // It seems that using 'MinimumWidth' instead of 'Width' prevents the DataGridView's NullReferenceExceptions + //gridView.Columns[gridView.Columns.Count - 1].Width = this.Preferences.lastColumnWidth; + gridView.Columns[gridView.Columns.Count - 1].MinimumWidth = Preferences.lastColumnWidth; + } + } + catch (NullReferenceException e) + { + // See https://connect.microsoft.com/VisualStudio/feedback/details/366943/autoresizecolumns-in-datagridview-throws-nullreferenceexception + // possible solution => https://stackoverflow.com/questions/36287553/nullreferenceexception-when-trying-to-set-datagridview-column-width-brings-th + // There are some rare situations with null ref exceptions when resizing columns and on filter finished + // So catch them here. Better than crashing. + _logger.Error(e, "Error while resizing columns: "); + } + } + + private void PaintCell(DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, + HighlightEntry groundEntry) + { + PaintHighlightedCell(e, gridView, noBackgroundFill, groundEntry); + } + + private void PaintHighlightedCell(DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, + bool noBackgroundFill, + HighlightEntry groundEntry) + { + var column = e.Value as IColumn; + + column ??= Column.EmptyColumn; + + IList matchList = FindHighlightMatches(column); + // too many entries per line seem to cause problems with the GDI + while (matchList.Count > 50) + { + matchList.RemoveAt(50); + } + + var he = new HighlightEntry + { + SearchText = column.DisplayValue, + ForegroundColor = groundEntry?.ForegroundColor ?? Color.FromKnownColor(KnownColor.Black), + BackgroundColor = groundEntry?.BackgroundColor ?? Color.Empty, + IsWordMatch = true + }; + + HilightMatchEntry hme = new() + { + StartPos = 0, + Length = column.DisplayValue.Length, + HilightEntry = he + }; + + if (groundEntry != null) + { + hme.HilightEntry.IsBold = groundEntry.IsBold; + } + + matchList = MergeHighlightMatchEntries(matchList, hme); + + int leftPad = e.CellStyle.Padding.Left; + RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, + e.CellBounds.Height); + Rectangle borderWidths = PaintHelper.BorderWidths(e.AdvancedBorderStyle); + Rectangle valBounds = e.CellBounds; + valBounds.Offset(borderWidths.X, borderWidths.Y); + valBounds.Width -= borderWidths.Right; + valBounds.Height -= borderWidths.Bottom; + if (e.CellStyle.Padding != Padding.Empty) + { + valBounds.Offset(e.CellStyle.Padding.Left, e.CellStyle.Padding.Top); + valBounds.Width -= e.CellStyle.Padding.Horizontal; + valBounds.Height -= e.CellStyle.Padding.Vertical; + } + + TextFormatFlags flags = + TextFormatFlags.Left + | TextFormatFlags.SingleLine + | TextFormatFlags.NoPrefix + | TextFormatFlags.PreserveGraphicsClipping + | TextFormatFlags.NoPadding + | TextFormatFlags.VerticalCenter + | TextFormatFlags.TextBoxControl + ; + + // | TextFormatFlags.VerticalCenter + // | TextFormatFlags.TextBoxControl + // TextFormatFlags.SingleLine + + //TextRenderer.DrawText(e.Graphics, e.Value as String, e.CellStyle.Font, valBounds, Color.FromKnownColor(KnownColor.Black), flags); + + Point wordPos = valBounds.Location; + Size proposedSize = new(valBounds.Width, valBounds.Height); + + Rectangle r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); + e.Graphics.SetClip(e.CellBounds); + + foreach (HilightMatchEntry matchEntry in matchList) + { + Font font = matchEntry != null && matchEntry.HilightEntry.IsBold ? BoldFont : NormalFont; + Brush bgBrush = matchEntry.HilightEntry.BackgroundColor != Color.Empty + ? new SolidBrush(matchEntry.HilightEntry.BackgroundColor) + : null; + string matchWord = column.DisplayValue.Substring(matchEntry.StartPos, matchEntry.Length); + Size wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags); + wordSize.Height = e.CellBounds.Height; + Rectangle wordRect = new(wordPos, wordSize); + + Color foreColor = matchEntry.HilightEntry.ForegroundColor; + if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected) + { + if (!noBackgroundFill && bgBrush != null && !matchEntry.HilightEntry.NoBackground) + { + e.Graphics.FillRectangle(bgBrush, wordRect); + } + } + + if (foreColor == Color.Black) + { + foreColor = ColorMode.ForeColor; + } + + TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, + foreColor, flags); + + wordPos.Offset(wordSize.Width, 0); + bgBrush?.Dispose(); + } + } + + /// + /// Builds a list of HilightMatchEntry objects. A HilightMatchEntry spans over a region that is painted with the same foreground and + /// background colors. + /// All regions which don't match a word-mode entry will be painted with the colors of a default entry (groundEntry). This is either the + /// first matching non-word-mode highlight entry or a black-on-white default (if no matching entry was found). + /// + /// List of all highlight matches for the current cell + /// The entry that is used as the default. + /// List of HilightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring. + private IList MergeHighlightMatchEntries(IList matchList, + HilightMatchEntry groundEntry) + { + // Fill an area with lenth of whole text with a default hilight entry + HighlightEntry[] entryArray = new HighlightEntry[groundEntry.Length]; + for (int i = 0; i < entryArray.Length; ++i) + { + entryArray[i] = groundEntry.HilightEntry; + } + + // "overpaint" with all matching word match enries + // Non-word-mode matches will not overpaint because they use the groundEntry + foreach (HilightMatchEntry me in matchList) + { + int endPos = me.StartPos + me.Length; + for (int i = me.StartPos; i < endPos; ++i) + { + if (me.HilightEntry.IsWordMatch) + { + entryArray[i] = me.HilightEntry; + } + else + { + //entryArray[i].ForegroundColor = me.HilightEntry.ForegroundColor; + } + } + } + + // collect areas with same hilight entry and build new highlight match entries for it + IList mergedList = []; + + if (entryArray.Length > 0) + { + HighlightEntry currentEntry = entryArray[0]; + int lastStartPos = 0; + int pos = 0; + + for (; pos < entryArray.Length; ++pos) + { + if (entryArray[pos] != currentEntry) + { + HilightMatchEntry me = new() + { + StartPos = lastStartPos, + Length = pos - lastStartPos, + HilightEntry = currentEntry + }; + + mergedList.Add(me); + currentEntry = entryArray[pos]; + lastStartPos = pos; + } + } + + HilightMatchEntry me2 = new() + { + StartPos = lastStartPos, + Length = pos - lastStartPos, + HilightEntry = currentEntry + }; + + mergedList.Add(me2); + } + + return mergedList; + } + + /// + /// Returns the first HilightEntry that matches the given line + /// + private HighlightEntry FindHilightEntry(ITextValue line) + { + return FindHighlightEntry(line, false); + } + + private HighlightEntry FindFirstNoWordMatchHilightEntry(ITextValue line) + { + return FindHighlightEntry(line, true); + } + + private bool CheckHighlightEntryMatch(HighlightEntry entry, ITextValue column) + { + if (entry.IsRegEx) + { + //Regex rex = new Regex(entry.SearchText, entry.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); + if (entry.Regex.IsMatch(column.Text)) + { + return true; + } + } + else + { + if (entry.IsCaseSensitive) + { + if (column.Text.Contains(entry.SearchText)) + { + return true; + } + } + else + { + if (column.Text.ToLower().Contains(entry.SearchText.ToLower())) + { + return true; + } + } + } + + return false; + } + + /// + /// Returns all HilightEntry entries which matches the given line + /// + private IList FindMatchingHilightEntries(ITextValue line) + { + IList resultList = []; + if (line != null) + { + lock (_currentHighlightGroupLock) + { + foreach (HighlightEntry entry in _currentHighlightGroup.HighlightEntryList) + { + if (CheckHighlightEntryMatch(entry, line)) + { + resultList.Add(entry); + } + } + } + } + + return resultList; + } + + private void GetHighlightEntryMatches(ITextValue line, IList hilightEntryList, IList resultList) + { + foreach (HighlightEntry entry in hilightEntryList) + { + if (entry.IsWordMatch) + { + MatchCollection matches = entry.Regex.Matches(line.Text); + foreach (Match match in matches) + { + HilightMatchEntry me = new(); + me.HilightEntry = entry; + me.StartPos = match.Index; + me.Length = match.Length; + resultList.Add(me); + } + } + else + { + if (CheckHighlightEntryMatch(entry, line)) + { + HilightMatchEntry me = new(); + me.HilightEntry = entry; + me.StartPos = 0; + me.Length = line.Text.Length; + resultList.Add(me); + } + } + } + } + + private void GetHilightActions(IList matchingList, out bool noLed, out bool stopTail, + out bool setBookmark, out string bookmarkComment) + { + noLed = stopTail = setBookmark = false; + bookmarkComment = string.Empty; + + foreach (HighlightEntry entry in matchingList) + { + if (entry.IsLedSwitch) + { + noLed = true; + } + + if (entry.IsSetBookmark) + { + setBookmark = true; + if (!string.IsNullOrEmpty(entry.BookmarkComment)) + { + bookmarkComment += entry.BookmarkComment + "\r\n"; + } + } + + if (entry.IsStopTail) + { + stopTail = true; + } + } + + bookmarkComment = bookmarkComment.TrimEnd(['\r', '\n']); + } + + private void StopTimespreadThread() + { + _timeSpreadCalc.Stop(); + } + + private void StopTimestampSyncThread() + { + _shouldTimestampDisplaySyncingCancel = true; + //_timeShiftSyncWakeupEvent.Set(); + //_timeShiftSyncThread.Abort(); + //_timeShiftSyncThread.Join(); + cts.Cancel(); + } + + private void SyncTimestampDisplay() + { + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + if (dataGridView.CurrentRow != null) + { + SyncTimestampDisplay(dataGridView.CurrentRow.Index); + } + } + } + + private void SyncTimestampDisplay(int lineNum) + { + _timeShiftSyncLine = lineNum; + _timeShiftSyncTimerEvent.Set(); + _timeShiftSyncWakeupEvent.Set(); + } + + private void SyncTimestampDisplayWorker() + { + const int WAIT_TIME = 500; + Thread.CurrentThread.Name = "SyncTimestampDisplayWorker"; + _shouldTimestampDisplaySyncingCancel = false; + _isTimestampDisplaySyncing = true; + + while (!_shouldTimestampDisplaySyncingCancel) + { + _timeShiftSyncWakeupEvent.WaitOne(); + if (_shouldTimestampDisplaySyncingCancel) + { + return; + } + + _timeShiftSyncWakeupEvent.Reset(); + + while (!_shouldTimestampDisplaySyncingCancel) + { + bool signaled = _timeShiftSyncTimerEvent.WaitOne(WAIT_TIME, true); + _timeShiftSyncTimerEvent.Reset(); + if (!signaled) + { + break; + } + } + + // timeout with no new Trigger -> update display + int lineNum = _timeShiftSyncLine; + if (lineNum >= 0 && lineNum < dataGridView.RowCount) + { + int refLine = lineNum; + DateTime timeStamp = GetTimestampForLine(ref refLine, true); + if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel) + { + _guiStateArgs.Timestamp = timeStamp; + SendGuiStateUpdate(); + if (_shouldCallTimeSync) + { + refLine = lineNum; + DateTime exactTimeStamp = GetTimestampForLine(ref refLine, false); + SyncOtherWindows(exactTimeStamp); + _shouldCallTimeSync = false; + } + } + } + + // show time difference between 2 selected lines + if (dataGridView.SelectedRows.Count == 2) + { + int row1 = dataGridView.SelectedRows[0].Index; + int row2 = dataGridView.SelectedRows[1].Index; + if (row1 > row2) + { + (row2, row1) = (row1, row2); + } + + int refLine = row1; + DateTime timeStamp1 = GetTimestampForLine(ref refLine, false); + refLine = row2; + DateTime timeStamp2 = GetTimestampForLine(ref refLine, false); + //TimeSpan span = TimeSpan.FromTicks(timeStamp2.Ticks - timeStamp1.Ticks); + DateTime diff; + if (timeStamp1.Ticks > timeStamp2.Ticks) + { + diff = new DateTime(timeStamp1.Ticks - timeStamp2.Ticks); + } + else + { + diff = new DateTime(timeStamp2.Ticks - timeStamp1.Ticks); + } + + StatusLineText("Time diff is " + diff.ToString("HH:mm:ss.fff")); + } + else + { + if (!IsMultiFile && dataGridView.SelectedRows.Count == 1) + { + StatusLineText(string.Empty); + } + } + } + } + + private void SyncFilterGridPos() + { + try + { + if (_filterResultList.Count > 0) + { + int index = _filterResultList.BinarySearch(dataGridView.CurrentRow.Index); + if (index < 0) + { + index = ~index; + if (index > 0) + { + --index; + } + } + + if (filterGridView.Rows.GetRowCount(DataGridViewElementStates.None) > 0) // exception no rows + { + filterGridView.CurrentCell = filterGridView.Rows[index].Cells[0]; + } + else + { + filterGridView.CurrentCell = null; + } + } + } + catch (Exception e) + { + _logger.Error(e, "SyncFilterGridPos(): "); + } + } + + private void StatusLineFileSize(long size) + { + _statusEventArgs.FileSize = size; + SendStatusLineUpdate(); + } + + private int Search(SearchParams searchParams) + { + if (searchParams.SearchText == null) + { + return -1; + } + + int lineNum = searchParams.IsFromTop && !searchParams.IsFindNext + ? 0 + : searchParams.CurrentLine; + + string lowerSearchText = searchParams.SearchText.ToLower(); + int count = 0; + bool hasWrapped = false; + + while (true) + { + if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) + { + if (lineNum >= _logFileReader.LineCount) + { + if (hasWrapped) + { + StatusLineError("Not found: " + searchParams.SearchText); + return -1; + } + + lineNum = 0; + count = 0; + hasWrapped = true; + StatusLineError("Started from beginning of file"); + } + } + else + { + if (lineNum < 0) + { + if (hasWrapped) + { + StatusLineError("Not found: " + searchParams.SearchText); + return -1; + } + + count = 0; + lineNum = _logFileReader.LineCount - 1; + hasWrapped = true; + StatusLineError("Started from end of file"); + } + } + + ILogLine line = _logFileReader.GetLogLine(lineNum); + if (line == null) + { + return -1; + } + + if (searchParams.IsRegex) + { + Regex rex = new(searchParams.SearchText, searchParams.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); + if (rex.IsMatch(line.FullLine)) + { + return lineNum; + } + } + else + { + if (!searchParams.IsCaseSensitive) + { + if (line.FullLine.Contains(lowerSearchText, StringComparison.CurrentCultureIgnoreCase)) + { + return lineNum; + } + } + else + { + if (line.FullLine.Contains(searchParams.SearchText)) + { + return lineNum; + } + } + } + + if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) + { + lineNum++; + } + else + { + lineNum--; + } + + if (_shouldCancel) + { + return -1; + } + + if (++count % PROGRESS_BAR_MODULO == 0) + { + try + { + if (!Disposing) + { + Invoke(UpdateProgressBar, [count]); + } + } + catch (ObjectDisposedException ex) // can occur when closing the app while searching + { + _logger.Warn(ex); + } + } + } + } + + private void ResetProgressBar() + { + _progressEventArgs.Value = _progressEventArgs.MaxValue; + _progressEventArgs.Visible = false; + SendProgressBarUpdate(); + } + + private void SelectLine(int line, bool triggerSyncCall, bool shouldScroll) + { + try + { + _shouldCallTimeSync = triggerSyncCall; + bool wasCancelled = _shouldCancel; + _shouldCancel = false; + _isSearching = false; + StatusLineText(""); + _guiStateArgs.MenuEnabled = true; + + if (wasCancelled) + { + return; + } + + if (line == -1) + { + // Hmm... is that experimental code from early days? + MessageBox.Show(this, "Not found:", "Search result"); + return; + } + + // Prevent ArgumentOutOfRangeException + if (line >= dataGridView.Rows.GetRowCount(DataGridViewElementStates.None)) + { + line = dataGridView.Rows.GetRowCount(DataGridViewElementStates.None) - 1; + } + + dataGridView.Rows[line].Selected = true; + + if (shouldScroll) + { + dataGridView.CurrentCell = dataGridView.Rows[line].Cells[0]; + dataGridView.Focus(); + } + } + catch (ArgumentOutOfRangeException e) + { + _logger.Error(e, "Error while selecting line: "); + } + catch (IndexOutOfRangeException e) + { + // Occures sometimes (but cannot reproduce) + _logger.Error(e, "Error while selecting line: "); + } + } + + private void StartEditMode() + { + if (!dataGridView.CurrentCell.ReadOnly) + { + dataGridView.BeginEdit(false); + if (dataGridView.EditingControl != null) + { + if (dataGridView.EditingControl is LogCellEditingControl editControl) + { + editControl.KeyDown += OnEditControlKeyDown; + editControl.KeyPress += OnEditControlKeyPress; + editControl.KeyUp += OnEditControlKeyUp; + editControl.Click += OnEditControlClick; + dataGridView.CellEndEdit += OnDataGridViewCellEndEdit; + editControl.SelectionStart = 0; + } + else + { + _logger.Warn("Edit control in logWindow was null"); + } + } + } + } + + private void UpdateEditColumnDisplay(DataGridViewTextBoxEditingControl editControl) + { + // prevents key events after edit mode has ended + if (dataGridView.EditingControl != null) + { + int pos = editControl.SelectionStart + editControl.SelectionLength; + StatusLineText(" " + pos); + _logger.Debug("SelStart: {0}, SelLen: {1}", editControl.SelectionStart, editControl.SelectionLength); + } + } + + private void SelectPrevHighlightLine() + { + int lineNum = dataGridView.CurrentCellAddress.Y; + while (lineNum > 0) + { + lineNum--; + ILogLine line = _logFileReader.GetLogLine(lineNum); + if (line != null) + { + HighlightEntry entry = FindHilightEntry(line); + if (entry != null) + { + SelectLine(lineNum, false, true); + break; + } + } + } + } + + private void SelectNextHighlightLine() + { + int lineNum = dataGridView.CurrentCellAddress.Y; + while (lineNum < _logFileReader.LineCount) + { + lineNum++; + ILogLine line = _logFileReader.GetLogLine(lineNum); + if (line != null) + { + HighlightEntry entry = FindHilightEntry(line); + if (entry != null) + { + SelectLine(lineNum, false, true); + break; + } + } + } + } + + private int FindNextBookmarkIndex(int lineNum) + { + if (lineNum >= dataGridView.RowCount) + { + lineNum = 0; + } + else + { + lineNum++; + } + + return _bookmarkProvider.FindNextBookmarkIndex(lineNum); + } + + private int FindPrevBookmarkIndex(int lineNum) + { + if (lineNum <= 0) + { + lineNum = dataGridView.RowCount - 1; + } + else + { + lineNum--; + } + + return _bookmarkProvider.FindPrevBookmarkIndex(lineNum); + } + + /** + * Shift bookmarks after a logfile rollover + */ + + private void ShiftBookmarks(int offset) + { + _bookmarkProvider.ShiftBookmarks(offset); + OnBookmarkRemoved(); + } + + private void ShiftRowHeightList(int offset) + { + SortedList newList = []; + foreach (RowHeightEntry entry in _rowHeightList.Values) + { + int line = entry.LineNum - offset; + if (line >= 0) + { + entry.LineNum = line; + newList.Add(line, entry); + } + } + + _rowHeightList = newList; + } + + private void ShiftFilterPipes(int offset) + { + lock (_filterPipeList) + { + foreach (FilterPipe pipe in _filterPipeList) + { + pipe.ShiftLineNums(offset); + } + } + } + + private void LoadFilterPipes() + { + lock (_filterPipeList) + { + foreach (FilterPipe pipe in _filterPipeList) + { + pipe.RecreateTempFile(); + } + } + + if (_filterPipeList.Count > 0) + { + for (int i = 0; i < dataGridView.RowCount; ++i) + { + ProcessFilterPipes(i); + } + } + } + + private void DisconnectFilterPipes() + { + lock (_filterPipeList) + { + foreach (FilterPipe pipe in _filterPipeList) + { + pipe.ClearLineList(); + } + } + } + + private void ApplyFilterParams() + { + filterComboBox.Text = _filterParams.SearchText; + filterCaseSensitiveCheckBox.Checked = _filterParams.IsCaseSensitive; + filterRegexCheckBox.Checked = _filterParams.IsRegex; + filterTailCheckBox.Checked = _filterParams.IsFilterTail; + invertFilterCheckBox.Checked = _filterParams.IsInvert; + filterKnobBackSpread.Value = _filterParams.SpreadBefore; + filterKnobForeSpread.Value = _filterParams.SpreadBehind; + rangeCheckBox.Checked = _filterParams.IsRangeSearch; + columnRestrictCheckBox.Checked = _filterParams.ColumnRestrict; + fuzzyKnobControl.Value = _filterParams.FuzzyValue; + filterRangeComboBox.Text = _filterParams.RangeSearchText; + } + + private void ResetFilterControls() + { + filterComboBox.Text = ""; + filterCaseSensitiveCheckBox.Checked = false; + filterRegexCheckBox.Checked = false; + //this.filterTailCheckBox.Checked = this.Preferences.filterTail; + invertFilterCheckBox.Checked = false; + filterKnobBackSpread.Value = 0; + filterKnobForeSpread.Value = 0; + rangeCheckBox.Checked = false; + columnRestrictCheckBox.Checked = false; + fuzzyKnobControl.Value = 0; + filterRangeComboBox.Text = ""; + } + + private void FilterSearch() + { + if (filterComboBox.Text.Length == 0) + { + _filterParams.SearchText = ""; + _filterParams.LowerSearchText = ""; + _filterParams.IsRangeSearch = false; + ClearFilterList(); + filterSearchButton.Image = null; + ResetFilterControls(); + saveFilterButton.Enabled = false; + return; + } + + FilterSearch(filterComboBox.Text); + } + + private async void FilterSearch(string text) + { + FireCancelHandlers(); // make sure that there's no other filter running (maybe from filter restore) + + _filterParams.SearchText = text; + _filterParams.LowerSearchText = text.ToLower(); + ConfigManager.Settings.filterHistoryList.Remove(text); + ConfigManager.Settings.filterHistoryList.Insert(0, text); + int maxHistory = ConfigManager.Settings.Preferences.maximumFilterEntries; + + if (ConfigManager.Settings.filterHistoryList.Count > maxHistory) + { + ConfigManager.Settings.filterHistoryList.RemoveAt(filterComboBox.Items.Count - 1); + } + + filterComboBox.Items.Clear(); + foreach (string item in ConfigManager.Settings.filterHistoryList) + { + filterComboBox.Items.Add(item); + } + + filterComboBox.Text = text; + + _filterParams.IsRangeSearch = rangeCheckBox.Checked; + _filterParams.RangeSearchText = filterRangeComboBox.Text; + if (_filterParams.IsRangeSearch) + { + ConfigManager.Settings.filterRangeHistoryList.Remove(filterRangeComboBox.Text); + ConfigManager.Settings.filterRangeHistoryList.Insert(0, filterRangeComboBox.Text); + if (ConfigManager.Settings.filterRangeHistoryList.Count > maxHistory) + { + ConfigManager.Settings.filterRangeHistoryList.RemoveAt(filterRangeComboBox.Items.Count - 1); + } + + filterRangeComboBox.Items.Clear(); + foreach (string item in ConfigManager.Settings.filterRangeHistoryList) + { + filterRangeComboBox.Items.Add(item); + } + } + + ConfigManager.Save(SettingsFlags.FilterHistory); + + _filterParams.IsCaseSensitive = filterCaseSensitiveCheckBox.Checked; + _filterParams.IsRegex = filterRegexCheckBox.Checked; + _filterParams.IsFilterTail = filterTailCheckBox.Checked; + _filterParams.IsInvert = invertFilterCheckBox.Checked; + if (_filterParams.IsRegex) + { + try + { + _filterParams.CreateRegex(); + } + catch (ArgumentException) + { + StatusLineError("Invalid regular expression"); + return; + } + } + + _filterParams.FuzzyValue = fuzzyKnobControl.Value; + _filterParams.SpreadBefore = filterKnobBackSpread.Value; + _filterParams.SpreadBehind = filterKnobForeSpread.Value; + _filterParams.ColumnRestrict = columnRestrictCheckBox.Checked; + + //ConfigManager.SaveFilterParams(this.filterParams); + ConfigManager.Settings.filterParams = _filterParams; // wozu eigentlich? sinnlos seit MDI? + + _shouldCancel = false; + _isSearching = true; + StatusLineText("Filtering... Press ESC to cancel"); + filterSearchButton.Enabled = false; + ClearFilterList(); + + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = dataGridView.RowCount; + _progressEventArgs.Value = 0; + _progressEventArgs.Visible = true; + SendProgressBarUpdate(); + + Settings settings = ConfigManager.Settings; + + //FilterFx fx = settings.preferences.multiThreadFilter ? MultiThreadedFilter : new FilterFx(Filter); + FilterFxAction = settings.Preferences.multiThreadFilter ? MultiThreadedFilter : Filter; + + //Task.Run(() => fx.Invoke(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList)); + Task filterFxActionTask = Task.Run(() => Filter(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList)); + + await filterFxActionTask; + FilterComplete(); + + //fx.BeginInvoke(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList, FilterComplete, null); + CheckForFilterDirty(); + } + + private void MultiThreadedFilter(FilterParams filterParams, List filterResultLines, + List lastFilterLinesList, List filterHitList) + { + ColumnizerCallback callback = new(this); + FilterStarter fs = new(callback, Environment.ProcessorCount + 2); + fs.FilterHitList = _filterHitList; + fs.FilterResultLines = _filterResultList; + fs.LastFilterLinesList = _lastFilterLinesList; + var cancelHandler = new FilterCancelHandler(fs); + OnRegisterCancelHandler(cancelHandler); + long startTime = Environment.TickCount; + + fs.DoFilter(filterParams, 0, _logFileReader.LineCount, FilterProgressCallback); + + long endTime = Environment.TickCount; + + _logger.Debug("Multi threaded filter duration: {0} ms.", endTime - startTime); + + OnDeRegisterCancelHandler(cancelHandler); + StatusLineText("Filter duration: " + (endTime - startTime) + " ms."); + } + + private void FilterProgressCallback(int lineCount) + { + UpdateProgressBar(lineCount); + } + + private void Filter(FilterParams filterParams, List filterResultLines, List lastFilterLinesList, + List filterHitList) + { + long startTime = Environment.TickCount; + try + { + filterParams.Reset(); + int lineNum = 0; + //AddFilterLineFx addFx = new AddFilterLineFx(AddFilterLine); + ColumnizerCallback callback = new(this); + while (true) + { + ILogLine line = _logFileReader.GetLogLine(lineNum); + if (line == null) + { + break; + } + + callback.LineNum = lineNum; + if (Util.TestFilterCondition(filterParams, line, callback)) + { + AddFilterLine(lineNum, false, filterParams, filterResultLines, lastFilterLinesList, + filterHitList); + } + + lineNum++; + if (lineNum % PROGRESS_BAR_MODULO == 0) + { + UpdateProgressBar(lineNum); + } + + if (_shouldCancel) + { + break; + } + } + } + catch (Exception ex) + { + _logger.Error(ex, "Exception while filtering. Please report to developer: "); + MessageBox.Show(null, + "Exception while filtering. Please report to developer: \n\n" + ex + "\n\n" + ex.StackTrace, + "LogExpert"); + } + + long endTime = Environment.TickCount; + + _logger.Info("Single threaded filter duration: {0} ms.", endTime - startTime); + + StatusLineText("Filter duration: " + (endTime - startTime) + " ms."); + } + + /// + /// Returns a list with 'additional filter results'. This is the given line number + /// and (if back spread and/or fore spread is enabled) some additional lines. + /// This function doesn't check the filter condition! + /// + /// + /// + /// + /// + private IList GetAdditionalFilterResults(FilterParams filterParams, int lineNum, IList checkList) + { + IList resultList = []; + //string textLine = this.logFileReader.GetLogLine(lineNum); + //ColumnizerCallback callback = new ColumnizerCallback(this); + //callback.LineNum = lineNum; + + if (filterParams.SpreadBefore == 0 && filterParams.SpreadBehind == 0) + { + resultList.Add(lineNum); + return resultList; + } + + // back spread + for (int i = filterParams.SpreadBefore; i > 0; --i) + { + if (lineNum - i > 0) + { + if (!resultList.Contains(lineNum - i) && !checkList.Contains(lineNum - i)) + { + resultList.Add(lineNum - i); + } + } + } + + // direct filter hit + if (!resultList.Contains(lineNum) && !checkList.Contains(lineNum)) + { + resultList.Add(lineNum); + } + + // after spread + for (int i = 1; i <= filterParams.SpreadBehind; ++i) + { + if (lineNum + i < _logFileReader.LineCount) + { + if (!resultList.Contains(lineNum + i) && !checkList.Contains(lineNum + i)) + { + resultList.Add(lineNum + i); + } + } + } + + return resultList; + } + + private void AddFilterLine(int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, + List lastFilterLinesList, List filterHitList) + { + int count; + lock (_filterResultList) + { + filterHitList.Add(lineNum); + IList filterResult = GetAdditionalFilterResults(filterParams, lineNum, lastFilterLinesList); + filterResultLines.AddRange(filterResult); + count = filterResultLines.Count; + lastFilterLinesList.AddRange(filterResult); + if (lastFilterLinesList.Count > SPREAD_MAX * 2) + { + lastFilterLinesList.RemoveRange(0, lastFilterLinesList.Count - SPREAD_MAX * 2); + } + } + + if (immediate) + { + TriggerFilterLineGuiUpdate(); + } + else if (lineNum % PROGRESS_BAR_MODULO == 0) + { + //FunctionWith1IntParam fx = new FunctionWith1IntParam(UpdateFilterCountLabel); + //this.Invoke(fx, new object[] { count}); + } + } + + private void TriggerFilterLineGuiUpdate() + { + //lock (this.filterUpdateThread) + //{ + // this.filterEventCount++; + // this.filterUpdateEvent.Set(); + //} + Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); + } + + //private void FilterUpdateWorker() + //{ + // Thread.CurrentThread.Name = "FilterUpdateWorker"; + // while (true) + // { + // this.filterUpdateEvent.WaitOne(); + // lock (this.filterUpdateThread) + // { + // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); + // this.filterUpdateEvent.Reset(); + // } + + // //_logger.logDebug("FilterUpdateWorker: Waiting for signal"); + // //bool signaled = this.filterUpdateEvent.WaitOne(1000, false); + + // //if (!signaled) + // //{ + // // lock (this.filterUpdateThread) + // // { + // // if (this.filterEventCount > 0) + // // { + // // this.filterEventCount = 0; + // // _logger.logDebug("FilterUpdateWorker: Invoking GUI update because of wait timeout"); + // // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); + // // } + // // } + // //} + // //else + // //{ + // // _logger.logDebug("FilterUpdateWorker: Wakeup signal received."); + // // lock (this.filterUpdateThread) + // // { + // // _logger.logDebug("FilterUpdateWorker: event count: " + this.filterEventCount); + // // if (this.filterEventCount > 100) + // // { + // // this.filterEventCount = 0; + // // _logger.logDebug("FilterUpdateWorker: Invoking GUI update because of event count"); + // // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); + // // } + // // this.filterUpdateEvent.Reset(); + // // } + // //} + // } + //} + + //private void StopFilterUpdateWorkerThread() + //{ + // this.filterUpdateEvent.Set(); + // this.filterUpdateThread.Abort(); + // this.filterUpdateThread.Join(); + //} + + private void AddFilterLineGuiUpdate() + { + try + { + lock (_filterResultList) + { + lblFilterCount.Text = "" + _filterResultList.Count; + if (filterGridView.RowCount > _filterResultList.Count) + { + filterGridView.RowCount = 0; // helps to prevent hang ? + } + + filterGridView.RowCount = _filterResultList.Count; + if (filterGridView.RowCount > 0) + { + filterGridView.FirstDisplayedScrollingRowIndex = filterGridView.RowCount - 1; + } + + if (filterGridView.RowCount == 1) + { + // after a file reload adjusted column sizes anew when the first line arrives + //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + AutoResizeColumns(filterGridView); + } + } + } + catch (Exception e) + { + _logger.Error(e, "AddFilterLineGuiUpdate(): "); + } + } + + private void UpdateProgressBar(int value) + { + _progressEventArgs.Value = value; + if (value > _progressEventArgs.MaxValue) + { + // can occur if new lines will be added while filtering + _progressEventArgs.MaxValue = value; + } + + SendProgressBarUpdate(); + } + + private void FilterComplete() + { + if (!IsDisposed && !_waitingForClose && !Disposing) + { + Invoke(new MethodInvoker(ResetStatusAfterFilter)); + } + } + + private void FilterComplete(IAsyncResult result) + { + if (!IsDisposed && !_waitingForClose && !Disposing) + { + Invoke(new MethodInvoker(ResetStatusAfterFilter)); + } + } + + private void ResetStatusAfterFilter() + { + try + { + //StatusLineText(""); + _isSearching = false; + _progressEventArgs.Value = _progressEventArgs.MaxValue; + _progressEventArgs.Visible = false; + SendProgressBarUpdate(); + filterGridView.RowCount = _filterResultList.Count; + //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + AutoResizeColumns(filterGridView); + lblFilterCount.Text = "" + _filterResultList.Count; + if (filterGridView.RowCount > 0) + { + filterGridView.Focus(); + } + + filterSearchButton.Enabled = true; + } + catch (NullReferenceException e) + { + // See https://connect.microsoft.com/VisualStudio/feedback/details/366943/autoresizecolumns-in-datagridview-throws-nullreferenceexception + // There are some rare situations with null ref exceptions when resizing columns and on filter finished + // So catch them here. Better than crashing. + _logger.Error(e, "Error: "); + } + } + + private void ClearFilterList() + { + try + { + //this.shouldCancel = true; + lock (_filterResultList) + { + filterGridView.SuspendLayout(); + filterGridView.RowCount = 0; + lblFilterCount.Text = "0"; + _filterResultList = []; + _lastFilterLinesList = []; + _filterHitList = []; + //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + filterGridView.ResumeLayout(); + } + } + catch (Exception ex) + { + _logger.Error(ex, "Wieder dieser sporadische Fehler: "); + + MessageBox.Show(null, ex.StackTrace, "Wieder dieser sporadische Fehler:"); + } + } + + private void ClearBookmarkList() + { + _bookmarkProvider.ClearAllBookmarks(); + } + + /** + * Shift filter list line entries after a logfile rollover + */ + + private void ShiftFilterLines(int offset) + { + List newFilterList = []; + lock (_filterResultList) + { + foreach (int lineNum in _filterResultList) + { + int line = lineNum - offset; + if (line >= 0) + { + newFilterList.Add(line); + } + } + + _filterResultList = newFilterList; + } + + newFilterList = []; + foreach (int lineNum in _filterHitList) + { + int line = lineNum - offset; + if (line >= 0) + { + newFilterList.Add(line); + } + } + + _filterHitList = newFilterList; + + int count = SPREAD_MAX; + if (_filterResultList.Count < SPREAD_MAX) + { + count = _filterResultList.Count; + } + + _lastFilterLinesList = _filterResultList.GetRange(_filterResultList.Count - count, count); + + //this.filterGridView.RowCount = this.filterResultList.Count; + //this.filterCountLabel.Text = "" + this.filterResultList.Count; + //this.BeginInvoke(new MethodInvoker(this.filterGridView.Refresh)); + //this.BeginInvoke(new MethodInvoker(AddFilterLineGuiUpdate)); + TriggerFilterLineGuiUpdate(); + } + + private void CheckForFilterDirty() + { + if (IsFilterSearchDirty(_filterParams)) + { + filterSearchButton.Image = _searchButtonImage; + saveFilterButton.Enabled = false; + } + else + { + filterSearchButton.Image = null; + saveFilterButton.Enabled = true; + } + } + + private bool IsFilterSearchDirty(FilterParams filterParams) + { + if (!filterParams.SearchText.Equals(filterComboBox.Text)) + { + return true; + } + + if (filterParams.IsRangeSearch != rangeCheckBox.Checked) + { + return true; + } + + if (filterParams.IsRangeSearch && !filterParams.RangeSearchText.Equals(filterRangeComboBox.Text)) + { + return true; + } + + if (filterParams.IsRegex != filterRegexCheckBox.Checked) + { + return true; + } + + if (filterParams.IsInvert != invertFilterCheckBox.Checked) + { + return true; + } + + if (filterParams.SpreadBefore != filterKnobBackSpread.Value) + { + return true; + } + + if (filterParams.SpreadBehind != filterKnobForeSpread.Value) + { + return true; + } + + if (filterParams.FuzzyValue != fuzzyKnobControl.Value) + { + return true; + } + + if (filterParams.ColumnRestrict != columnRestrictCheckBox.Checked) + { + return true; + } + + if (filterParams.IsCaseSensitive != filterCaseSensitiveCheckBox.Checked) + { + return true; + } + + return false; + } + + private void AdjustMinimumGridWith() + { + if (dataGridView.Columns.Count > 1) + { + //this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + AutoResizeColumns(dataGridView); + + int width = dataGridView.Columns.GetColumnsWidth(DataGridViewElementStates.Visible); + int diff = dataGridView.Width - width; + if (diff > 0) + { + diff -= dataGridView.RowHeadersWidth / 2; + dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].Width += diff; + filterGridView.Columns[filterGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].Width += diff; + } + } + } + + private void InvalidateCurrentRow(BufferedDataGridView gridView) + { + if (gridView.CurrentCellAddress.Y > -1) + { + gridView.InvalidateRow(gridView.CurrentCellAddress.Y); + } + } + + private void InvalidateCurrentRow() + { + InvalidateCurrentRow(dataGridView); + InvalidateCurrentRow(filterGridView); + } + + private void DisplayCurrentFileOnStatusline() + { + if (_logFileReader.IsMultiFile) + { + try + { + if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index > -1) + { + string fileName = _logFileReader.GetLogFileNameForLine(dataGridView.CurrentRow.Index); + if (fileName != null) + { + StatusLineText(Util.GetNameFromPath(fileName)); + } + } + } + catch (Exception) + { + // TODO: handle this concurrent situation better: + // this.dataGridView.CurrentRow may be null even if checked before. + // This can happen when MultiFile shift deselects the current row because there + // are less lines after rollover than before. + // access to dataGridView-Rows should be locked + } + } + } + + private void UpdateSelectionDisplay() + { + if (_noSelectionUpdates) + { + return; + } + } + + private void UpdateFilterHistoryFromSettings() + { + ConfigManager.Settings.filterHistoryList = ConfigManager.Settings.filterHistoryList; + filterComboBox.Items.Clear(); + foreach (string item in ConfigManager.Settings.filterHistoryList) + { + filterComboBox.Items.Add(item); + } + + filterRangeComboBox.Items.Clear(); + foreach (string item in ConfigManager.Settings.filterRangeHistoryList) + { + filterRangeComboBox.Items.Add(item); + } + } + + private void StatusLineText(string text) + { + _statusEventArgs.StatusText = text; + SendStatusLineUpdate(); + } + + private void StatusLineError(string text) + { + StatusLineText(text); + _isErrorShowing = true; + } + + private void RemoveStatusLineError() + { + StatusLineText(""); + _isErrorShowing = false; + } + + private void SendGuiStateUpdate() + { + OnGuiState(_guiStateArgs); + } + + private void SendProgressBarUpdate() + { + OnProgressBarUpdate(_progressEventArgs); + } + + private void SendStatusLineUpdate() + { + OnStatusLine(_statusEventArgs); + } + + private void ShowAdvancedFilterPanel(bool show) + { + if (show) + { + advancedButton.Text = "Hide advanced..."; + advancedButton.Image = null; + } + else + { + advancedButton.Text = "Show advanced..."; + CheckForAdvancedButtonDirty(); + } + + advancedFilterSplitContainer.Panel1Collapsed = !show; + advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; + _showAdvanced = show; + } + + private void CheckForAdvancedButtonDirty() + { + if (IsAdvancedOptionActive() && !_showAdvanced) + { + advancedButton.Image = _advancedButtonImage; + } + else + { + advancedButton.Image = null; + } + } + + private void FilterToTab() + { + filterSearchButton.Enabled = false; + Task.Run(() => WriteFilterToTab()); + } + + private void WriteFilterToTab() + { + FilterPipe pipe = new(_filterParams.Clone(), this); + lock (_filterResultList) + { + string namePrefix = "->F"; + string title; + if (IsTempFile) + { + title = TempTitleName + namePrefix + ++_filterPipeNameCounter; + } + else + { + title = Util.GetNameFromPath(FileName) + namePrefix + ++_filterPipeNameCounter; + } + + WritePipeToTab(pipe, _filterResultList, title, null); + } + } + + private void WritePipeToTab(FilterPipe pipe, IList lineNumberList, string name, PersistenceData persistenceData) + { + _logger.Info("WritePipeToTab(): {0} lines.", lineNumberList.Count); + StatusLineText("Writing to temp file... Press ESC to cancel."); + _guiStateArgs.MenuEnabled = false; + SendGuiStateUpdate(); + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = lineNumberList.Count; + _progressEventArgs.Value = 0; + _progressEventArgs.Visible = true; + Invoke(new MethodInvoker(SendProgressBarUpdate)); + _isSearching = true; + _shouldCancel = false; + + lock (_filterPipeList) + { + _filterPipeList.Add(pipe); + } + + pipe.Closed += OnPipeDisconnected; + int count = 0; + pipe.OpenFile(); + LogExpertCallback callback = new(this); + foreach (int i in lineNumberList) + { + if (_shouldCancel) + { + break; + } + + ILogLine line = _logFileReader.GetLogLine(i); + if (CurrentColumnizer is ILogLineXmlColumnizer) + { + callback.LineNum = i; + line = (CurrentColumnizer as ILogLineXmlColumnizer).GetLineTextForClipboard(line, callback); + } + + pipe.WriteToPipe(line, i); + if (++count % PROGRESS_BAR_MODULO == 0) + { + _progressEventArgs.Value = count; + Invoke(new MethodInvoker(SendProgressBarUpdate)); + } + } + + pipe.CloseFile(); + _logger.Info("WritePipeToTab(): finished"); + Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), pipe, name, persistenceData); + } + + private void WriteFilterToTabFinished(FilterPipe pipe, string name, PersistenceData persistenceData) + { + _isSearching = false; + if (!_shouldCancel) + { + string title = name; + ILogLineColumnizer preProcessColumnizer = null; + if (CurrentColumnizer is not ILogLineXmlColumnizer) + { + preProcessColumnizer = CurrentColumnizer; + } + + LogWindow newWin = _parentLogTabWin.AddFilterTab(pipe, title, preProcessColumnizer); + newWin.FilterPipe = pipe; + pipe.OwnLogWindow = newWin; + if (persistenceData != null) + { + Task.Run(() => FilterRestore(newWin, persistenceData)); + } + } + + _progressEventArgs.Value = _progressEventArgs.MaxValue; + _progressEventArgs.Visible = false; + SendProgressBarUpdate(); + _guiStateArgs.MenuEnabled = true; + SendGuiStateUpdate(); + StatusLineText(""); + filterSearchButton.Enabled = true; + } + + /// + /// Used to create a new tab and pipe the given content into it. + /// + /// + /// + internal void WritePipeTab(IList lineEntryList, string title) + { + FilterPipe pipe = new(new FilterParams(), this); + pipe.IsStopped = true; + pipe.Closed += OnPipeDisconnected; + pipe.OpenFile(); + foreach (LineEntry entry in lineEntryList) + { + pipe.WriteToPipe(entry.logLine, entry.lineNum); + } + + pipe.CloseFile(); + Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), [pipe, title, null]); + } + + private void FilterRestore(LogWindow newWin, PersistenceData persistenceData) + { + newWin.WaitForLoadingFinished(); + ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(persistenceData.columnizerName, + PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + if (columnizer != null) + { + SetColumnizerFx fx = newWin.ForceColumnizer; + newWin.Invoke(fx, [columnizer]); + } + else + { + _logger.Warn("FilterRestore(): Columnizer {0} not found", persistenceData.columnizerName); + } + + newWin.BeginInvoke(new RestoreFiltersFx(newWin.RestoreFilters), [persistenceData]); + } + + private void ProcessFilterPipes(int lineNum) + { + ILogLine searchLine = _logFileReader.GetLogLine(lineNum); + if (searchLine == null) + { + return; + } + + ColumnizerCallback callback = new(this); + callback.LineNum = lineNum; + IList deleteList = []; + lock (_filterPipeList) + { + foreach (FilterPipe pipe in _filterPipeList) + { + if (pipe.IsStopped) + { + continue; + } + + long startTime = Environment.TickCount; + if (Util.TestFilterCondition(pipe.FilterParams, searchLine, callback)) + { + IList filterResult = + GetAdditionalFilterResults(pipe.FilterParams, lineNum, pipe.LastLinesHistoryList); + pipe.OpenFile(); + foreach (int line in filterResult) + { + pipe.LastLinesHistoryList.Add(line); + if (pipe.LastLinesHistoryList.Count > SPREAD_MAX * 2) + { + pipe.LastLinesHistoryList.RemoveAt(0); + } + + ILogLine textLine = _logFileReader.GetLogLine(line); + bool fileOk = pipe.WriteToPipe(textLine, line); + if (!fileOk) + { + deleteList.Add(pipe); + } + } + + pipe.CloseFile(); + } + + long endTime = Environment.TickCount; + //_logger.logDebug("ProcessFilterPipes(" + lineNum + ") duration: " + ((endTime - startTime))); + } + } + + foreach (FilterPipe pipe in deleteList) + { + _filterPipeList.Remove(pipe); + } + } + + private void CopyMarkedLinesToClipboard() + { + if (_guiStateArgs.CellSelectMode) + { + DataObject data = dataGridView.GetClipboardContent(); + Clipboard.SetDataObject(data); + } + else + { + List lineNumList = []; + foreach (DataGridViewRow row in dataGridView.SelectedRows) + { + if (row.Index != -1) + { + lineNumList.Add(row.Index); + } + } + + lineNumList.Sort(); + StringBuilder clipText = new(); + LogExpertCallback callback = new(this); + + var xmlColumnizer = _currentColumnizer as ILogLineXmlColumnizer; + + foreach (int lineNum in lineNumList) + { + ILogLine line = _logFileReader.GetLogLine(lineNum); + if (xmlColumnizer != null) + { + callback.LineNum = lineNum; + line = xmlColumnizer.GetLineTextForClipboard(line, callback); + } + + clipText.AppendLine(line.ToClipBoardText()); + } + + Clipboard.SetText(clipText.ToString()); + } + } + + /// + /// Set an Encoding which shall be used when loading a file. Used before a file is loaded. + /// + /// + private void SetExplicitEncoding(Encoding encoding) + { + EncodingOptions.Encoding = encoding; + } + + private void ApplyDataGridViewPrefs(BufferedDataGridView dataGridView, Preferences prefs) + { + if (dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) > 1) + { + if (prefs.setLastColumnWidth) + { + dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].MinimumWidth = prefs.lastColumnWidth; + } + else + { + // Workaround for a .NET bug which brings the DataGridView into an unstable state (causing lots of NullReferenceExceptions). + dataGridView.FirstDisplayedScrollingColumnIndex = 0; + + dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].MinimumWidth = 5; // default + } + } + + if (dataGridView.RowCount > 0) + { + dataGridView.UpdateRowHeightInfo(0, true); + } + + dataGridView.Invalidate(); + dataGridView.Refresh(); + AutoResizeColumns(dataGridView); + } + + private IList GetSelectedContent() + { + if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) + { + List lineNumList = []; + + foreach (DataGridViewRow row in dataGridView.SelectedRows) + { + if (row.Index != -1) + { + lineNumList.Add(row.Index); + } + } + + lineNumList.Sort(); + return lineNumList; + } + + return []; + } + + /* ======================================================================== + * Timestamp stuff + * =======================================================================*/ + + private void SetTimestampLimits() + { + if (!CurrentColumnizer.IsTimeshiftImplemented()) + { + return; + } + + int line = 0; + _guiStateArgs.MinTimestamp = GetTimestampForLineForward(ref line, true); + line = dataGridView.RowCount - 1; + _guiStateArgs.MaxTimestamp = GetTimestampForLine(ref line, true); + SendGuiStateUpdate(); + } + + private void AdjustHighlightSplitterWidth() + { + //int size = this.editHighlightsSplitContainer.Panel2Collapsed ? 600 : 660; + //int distance = this.highlightSplitContainer.Width - size; + //if (distance < 10) + // distance = 10; + //this.highlightSplitContainer.SplitterDistance = distance; + } + + private void BookmarkComment(Bookmark bookmark) + { + BookmarkCommentDlg dlg = new(); + dlg.Comment = bookmark.Text; + if (dlg.ShowDialog() == DialogResult.OK) + { + bookmark.Text = dlg.Comment; + dataGridView.Refresh(); + OnBookmarkTextChanged(bookmark); + } + } + + /// + /// Indicates which columns we are filtering on + /// + /// + /// + private string CalculateColumnNames(FilterParams filter) + { + string names = string.Empty; + + if (filter.ColumnRestrict) + { + foreach (int colIndex in filter.ColumnList) + { + if (colIndex < dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 2) + { + if (names.Length > 0) + { + names += ", "; + } + + names += dataGridView.Columns[2 + colIndex] + .HeaderText; // skip first two columns: marker + line number + } + } + } + + return names; + } + + private void ApplyFrozenState(BufferedDataGridView gridView) + { + SortedDictionary dict = []; + foreach (DataGridViewColumn col in gridView.Columns) + { + dict.Add(col.DisplayIndex, col); + } + + foreach (DataGridViewColumn col in dict.Values) + { + col.Frozen = _freezeStateMap.ContainsKey(gridView) && _freezeStateMap[gridView]; + bool sel = col.HeaderCell.Selected; + if (col.Index == _selectedCol) + { + break; + } + } + } + + private void ShowTimeSpread(bool show) + { + if (show) + { + tableLayoutPanel1.ColumnStyles[1].Width = 16; + } + else + { + tableLayoutPanel1.ColumnStyles[1].Width = 0; + } + + _timeSpreadCalc.Enabled = show; + } + + protected internal void AddTempFileTab(string fileName, string title) + { + _parentLogTabWin.AddTempFileTab(fileName, title); + } + + private void InitPatternWindow() + { + //PatternStatistic(this.patternArgs); + _patternWindow = new PatternWindow(this); + _patternWindow.SetColumnizer(CurrentColumnizer); + //this.patternWindow.SetBlockList(blockList); + _patternWindow.SetFont(Preferences.fontName, Preferences.fontSize); + _patternWindow.Fuzzy = _patternArgs.Fuzzy; + _patternWindow.MaxDiff = _patternArgs.MaxDiffInBlock; + _patternWindow.MaxMisses = _patternArgs.MaxMisses; + _patternWindow.Weight = _patternArgs.MinWeight; + //this.patternWindow.Show(); + } + + private void TestStatistic(PatternArgs patternArgs) + { + int beginLine = patternArgs.StartLine; + _logger.Info("TestStatistics() called with start line {0}", beginLine); + + _patternArgs = patternArgs; + + int num = beginLine + 1; //this.dataGridView.RowCount; + + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = dataGridView.RowCount; + _progressEventArgs.Value = beginLine; + _progressEventArgs.Visible = true; + SendProgressBarUpdate(); + + PrepareDict(); + ResetCache(num); + + Dictionary processedLinesDict = []; + List blockList = []; + int blockId = 0; + _isSearching = true; + _shouldCancel = false; + int searchLine = -1; + for (int i = beginLine; i < num && !_shouldCancel; ++i) + { + if (processedLinesDict.ContainsKey(i)) + { + continue; + } + + PatternBlock block; + int maxBlockLen = patternArgs.EndLine - patternArgs.StartLine; + //int searchLine = i + 1; + _logger.Debug("TestStatistic(): i={0} searchLine={1}", i, searchLine); + //bool firstBlock = true; + searchLine++; + UpdateProgressBar(searchLine); + while (!_shouldCancel && + (block = + DetectBlock(i, searchLine, maxBlockLen, _patternArgs.MaxDiffInBlock, + _patternArgs.MaxMisses, + processedLinesDict)) != null) + { + _logger.Debug("Found block: {0}", block); + if (block.weigth >= _patternArgs.MinWeight) + { + //PatternBlock existingBlock = FindExistingBlock(block, blockList); + //if (existingBlock != null) + //{ + // if (block.weigth > existingBlock.weigth) + // { + // blockList.Remove(existingBlock); + // blockList.Add(block); + // } + //} + //else + { + blockList.Add(block); + addBlockTargetLinesToDict(processedLinesDict, block); + } + block.blockId = blockId; + //if (firstBlock) + //{ + // addBlockSrcLinesToDict(processedLinesDict, block); + //} + searchLine = block.targetEnd + 1; + } + else + { + searchLine = block.targetStart + 1; + } + + UpdateProgressBar(searchLine); + } + + blockId++; + } + + _isSearching = false; + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = 0; + _progressEventArgs.Value = 0; + _progressEventArgs.Visible = false; + SendProgressBarUpdate(); + //if (this.patternWindow.IsDisposed) + //{ + // this.Invoke(new MethodInvoker(CreatePatternWindow)); + //} + _patternWindow.SetBlockList(blockList, _patternArgs); + _logger.Info("TestStatistics() ended"); + } + + private void addBlockTargetLinesToDict(Dictionary dict, PatternBlock block) + { + foreach (int lineNum in block.targetLines.Keys) + { + if (!dict.ContainsKey(lineNum)) + { + dict.Add(lineNum, lineNum); + } + } + } + + //Well keep this for the moment because there is some other commented code which calls this one + private PatternBlock FindExistingBlock(PatternBlock block, List blockList) + { + foreach (PatternBlock searchBlock in blockList) + { + if ((block.startLine > searchBlock.startLine && + block.startLine < searchBlock.endLine + || + block.endLine > searchBlock.startLine && + block.endLine < searchBlock.endLine) && block.startLine != searchBlock.startLine && + block.endLine != searchBlock.endLine + ) + { + return searchBlock; + } + } + + return null; + } + + private PatternBlock DetectBlock(int startNum, int startLineToSearch, int maxBlockLen, int maxDiffInBlock, + int maxMisses, Dictionary processedLinesDict) + { + int targetLine = FindSimilarLine(startNum, startLineToSearch, processedLinesDict); + if (targetLine == -1) + { + return null; + } + + PatternBlock block = new(); + block.startLine = startNum; + int srcLine = block.startLine; + block.targetStart = targetLine; + int srcMisses = 0; + block.srcLines.Add(srcLine, srcLine); + //block.targetLines.Add(targetLine, targetLine); + int len = 0; + QualityInfo qi = new(); + qi.quality = block.weigth; + block.qualityInfoList[targetLine] = qi; + + while (!_shouldCancel) + { + srcLine++; + len++; + //if (srcLine >= block.targetStart) + // break; // prevent to search in the own block + if (maxBlockLen > 0 && len > maxBlockLen) + { + break; + } + + int nextTargetLine = FindSimilarLine(srcLine, targetLine + 1, processedLinesDict); + if (nextTargetLine > -1 && nextTargetLine - targetLine - 1 <= maxDiffInBlock) + { + block.weigth += maxDiffInBlock - (nextTargetLine - targetLine - 1) + 1; + block.endLine = srcLine; + //block.targetLines.Add(nextTargetLine, nextTargetLine); + block.srcLines.Add(srcLine, srcLine); + if (nextTargetLine - targetLine > 1) + { + int tempWeight = block.weigth; + for (int tl = targetLine + 1; tl < nextTargetLine; ++tl) + { + qi = new QualityInfo(); + qi.quality = --tempWeight; + block.qualityInfoList[tl] = qi; + } + } + + targetLine = nextTargetLine; + qi = new QualityInfo(); + qi.quality = block.weigth; + block.qualityInfoList[targetLine] = qi; + } + else + { + srcMisses++; + block.weigth--; + targetLine++; + qi = new QualityInfo(); + qi.quality = block.weigth; + block.qualityInfoList[targetLine] = qi; + if (srcMisses > maxMisses) + { + break; + } + } + } + + block.targetEnd = targetLine; + qi = new QualityInfo(); + qi.quality = block.weigth; + block.qualityInfoList[targetLine] = qi; + for (int k = block.targetStart; k <= block.targetEnd; ++k) + { + block.targetLines.Add(k, k); + } + + return block; + } + + private void PrepareDict() + { + _lineHashList.Clear(); + Regex regex = new("\\d"); + Regex regex2 = new("\\S"); + + int num = _logFileReader.LineCount; + for (int i = 0; i < num; ++i) + { + string msg = GetMsgForLine(i); + if (msg != null) + { + msg = msg.ToLower(); + msg = regex.Replace(msg, "0"); + msg = regex2.Replace(msg, " "); + char[] chars = msg.ToCharArray(); + int value = 0; + int numOfE = 0; + int numOfA = 0; + int numOfI = 0; + foreach (var t in chars) + { + value += t; + switch (t) + { + case 'e': + numOfE++; + break; + case 'a': + numOfA++; + break; + case 'i': + numOfI++; + break; + } + } + + value += numOfE * 30; + value += numOfA * 20; + value += numOfI * 10; + _lineHashList.Add(value); + } + } + } + + private int _FindSimilarLine(int srcLine, int startLine) + { + int value = _lineHashList[srcLine]; + + int num = _lineHashList.Count; + for (int i = startLine; i < num; ++i) + { + if (Math.Abs(_lineHashList[i] - value) < 3) + { + return i; + } + } + + return -1; + } + + // int[,] similarCache; + + private void ResetCache(int num) + { + //this.similarCache = new int[num, num]; + //for (int i = 0; i < num; ++i) + //{ + // for (int j = 0; j < num; j++) + // { + // this.similarCache[i, j] = -1; + // } + //} + } + + private int FindSimilarLine(int srcLine, int startLine, Dictionary processedLinesDict) + { + int threshold = _patternArgs.Fuzzy; + + bool prepared = false; + Regex regex = null; + Regex regex2 = null; + string msgToFind = null; + CultureInfo culture = CultureInfo.CurrentCulture; + + int num = _logFileReader.LineCount; + for (int i = startLine; i < num; ++i) + { + if (processedLinesDict.ContainsKey(i)) + { + continue; + } + + //if (this.similarCache[srcLine, i] != -1) + //{ + // if (this.similarCache[srcLine, i] < threshold) + // { + // return i; + // } + //} + //else + { + if (!prepared) + { + msgToFind = GetMsgForLine(srcLine); + regex = new Regex("\\d"); + regex2 = new Regex("\\W"); + msgToFind = msgToFind.ToLower(culture); + msgToFind = regex.Replace(msgToFind, "0"); + msgToFind = regex2.Replace(msgToFind, " "); + prepared = true; + } + + string msg = GetMsgForLine(i); + if (msg != null) + { + msg = regex.Replace(msg, "0"); + msg = regex2.Replace(msg, " "); + int lenDiff = Math.Abs(msg.Length - msgToFind.Length); + if (lenDiff > threshold) + { + //this.similarCache[srcLine, i] = lenDiff; + continue; + } + + msg = msg.ToLower(culture); + int distance = Util.YetiLevenshtein(msgToFind, msg); + //this.similarCache[srcLine, i] = distance; + if (distance < threshold) + { + return i; + } + } + } + } + + return -1; + } + + private string GetMsgForLine(int i) + { + ILogLine line = _logFileReader.GetLogLine(i); + ILogLineColumnizer columnizer = CurrentColumnizer; + ColumnizerCallback callback = new(this); + IColumnizedLogLine cols = columnizer.SplitLine(callback, line); + return cols.ColumnValues.Last().FullValue; + } + + private void ChangeRowHeight(bool decrease) + { + int rowNum = dataGridView.CurrentCellAddress.Y; + if (rowNum < 0 || rowNum >= dataGridView.RowCount) + { + return; + } + + if (decrease) + { + if (!_rowHeightList.ContainsKey(rowNum)) + { + return; + } + else + { + RowHeightEntry entry = _rowHeightList[rowNum]; + entry.Height -= _lineHeight; + if (entry.Height <= _lineHeight) + { + _rowHeightList.Remove(rowNum); + } + } + } + else + { + RowHeightEntry entry; + if (!_rowHeightList.ContainsKey(rowNum)) + { + entry = new RowHeightEntry(); + entry.LineNum = rowNum; + entry.Height = _lineHeight; + _rowHeightList[rowNum] = entry; + } + else + { + entry = _rowHeightList[rowNum]; + } + + entry.Height += _lineHeight; + } + + dataGridView.UpdateRowHeightInfo(rowNum, false); + if (rowNum == dataGridView.RowCount - 1 && _guiStateArgs.FollowTail) + { + dataGridView.FirstDisplayedScrollingRowIndex = rowNum; + } + + dataGridView.Refresh(); + } + + private int GetRowHeight(int rowNum) + { + if (_rowHeightList.ContainsKey(rowNum)) + { + return _rowHeightList[rowNum].Height; + } + else + { + return _lineHeight; + } + } + + private void AddBookmarkAtLineSilently(int lineNum) + { + if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) + { + _bookmarkProvider.AddBookmark(new Bookmark(lineNum)); + } + } + + private void AddBookmarkAndEditComment() + { + int lineNum = dataGridView.CurrentCellAddress.Y; + if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) + { + ToggleBookmark(); + } + + BookmarkComment(_bookmarkProvider.GetBookmarkForLine(lineNum)); + } + + private void AddBookmarkComment(string text) + { + int lineNum = dataGridView.CurrentCellAddress.Y; + Bookmark bookmark; + if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) + { + _bookmarkProvider.AddBookmark(bookmark = new Bookmark(lineNum)); + } + else + { + bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); + } + + bookmark.Text += text; + dataGridView.Refresh(); + filterGridView.Refresh(); + OnBookmarkTextChanged(bookmark); + } + + private void MarkCurrentFilterRange() + { + _filterParams.RangeSearchText = filterRangeComboBox.Text; + ColumnizerCallback callback = new(this); + RangeFinder rangeFinder = new(_filterParams, callback); + Core.Entities.Range range = rangeFinder.FindRange(dataGridView.CurrentCellAddress.Y); + if (range != null) + { + SetCellSelectionMode(false); + _noSelectionUpdates = true; + for (int i = range.StartLine; i <= range.EndLine; ++i) + { + dataGridView.Rows[i].Selected = true; + } + + _noSelectionUpdates = false; + UpdateSelectionDisplay(); + } + } + + private void RemoveTempHighlights() + { + lock (_tempHighlightEntryListLock) + { + _tempHighlightEntryList.Clear(); + } + + RefreshAllGrids(); + } + + private void ToggleHighlightPanel(bool open) + { + highlightSplitContainer.Panel2Collapsed = !open; + btnToggleHighlightPanel.Image = open + ? new Bitmap(_panelCloseButtonImage, new Size(btnToggleHighlightPanel.Size.Height, btnToggleHighlightPanel.Size.Height)) + : new Bitmap(_panelOpenButtonImage, new Size(btnToggleHighlightPanel.Size.Height, btnToggleHighlightPanel.Size.Height)); + } + + private void SetBookmarksForSelectedFilterLines() + { + lock (_filterResultList) + { + foreach (DataGridViewRow row in filterGridView.SelectedRows) + { + int lineNum = _filterResultList[row.Index]; + AddBookmarkAtLineSilently(lineNum); + } + } + + dataGridView.Refresh(); + filterGridView.Refresh(); + OnBookmarkAdded(); + } + + private void SetDefaultHighlightGroup() + { + HighlightGroup group = _parentLogTabWin.FindHighlightGroupByFileMask(FileName); + if (group != null) + { + SetCurrentHighlightGroup(group.GroupName); + } + else + { + SetCurrentHighlightGroup("[Default]"); + } + } + + private void HandleChangedFilterOnLoadSetting() + { + _parentLogTabWin.Preferences.isFilterOnLoad = filterOnLoadCheckBox.Checked; + _parentLogTabWin.Preferences.isAutoHideFilterList = hideFilterListOnLoadCheckBox.Checked; + OnFilterListChanged(this); + } + + private void FireCancelHandlers() + { + lock (_cancelHandlerList) + { + foreach (var handler in _cancelHandlerList) + { + handler.EscapePressed(); + } + } + } + + private void SyncOtherWindows(DateTime timestamp) + { + lock (_timeSyncListLock) + { + TimeSyncList?.NavigateToTimestamp(timestamp, this); + } + } + + private void AddSlaveToTimesync(LogWindow slave) + { + lock (_timeSyncListLock) + { + if (TimeSyncList == null) + { + if (slave.TimeSyncList == null) + { + TimeSyncList = new TimeSyncList(); + TimeSyncList.AddWindow(this); + } + else + { + TimeSyncList = slave.TimeSyncList; + } + + int currentLineNum = dataGridView.CurrentCellAddress.Y; + int refLine = currentLineNum; + DateTime timeStamp = GetTimestampForLine(ref refLine, true); + if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel) + { + TimeSyncList.CurrentTimestamp = timeStamp; + } + + TimeSyncList.WindowRemoved += OnTimeSyncListWindowRemoved; + } + } + + slave.AddToTimeSync(this); + OnSyncModeChanged(); + } + + private void FreeSlaveFromTimesync(LogWindow slave) + { + slave.FreeFromTimeSync(); + } + + private void OnSyncModeChanged() + { + SyncModeChanged?.Invoke(this, new SyncModeEventArgs(IsTimeSynced)); + } + + private void AddSearchHitHighlightEntry(SearchParams para) + { + HighlightEntry he = new() + { + SearchText = para.SearchText, + ForegroundColor = Color.Red, + BackgroundColor = Color.Yellow, + IsRegEx = para.IsRegex, + IsCaseSensitive = para.IsCaseSensitive, + IsLedSwitch = false, + IsStopTail = false, + IsSetBookmark = false, + IsActionEntry = false, + ActionEntry = null, + IsWordMatch = true, + IsSearchHit = true + }; + + lock (_tempHighlightEntryListLock) + { + _tempHighlightEntryList.Add(he); + } + + RefreshAllGrids(); + } + + private void RemoveAllSearchHighlightEntries() + { + lock (_tempHighlightEntryListLock) + { + List newList = []; + foreach (HighlightEntry he in _tempHighlightEntryList) + { + if (!he.IsSearchHit) + { + newList.Add(he); + } + } + + _tempHighlightEntryList = newList; + } + + RefreshAllGrids(); + } + + private DataGridViewColumn GetColumnByName(BufferedDataGridView dataGridView, string name) + { + foreach (DataGridViewColumn col in dataGridView.Columns) + { + if (col.HeaderText.Equals(name)) + { + return col; + } + } + + return null; + } + + private void SelectColumn() + { + string colName = columnComboBox.SelectedItem as string; + DataGridViewColumn col = GetColumnByName(dataGridView, colName); + if (col != null && !col.Frozen) + { + dataGridView.FirstDisplayedScrollingColumnIndex = col.Index; + int currentLine = dataGridView.CurrentCellAddress.Y; + if (currentLine >= 0) + { + dataGridView.CurrentCell = dataGridView.Rows[dataGridView.CurrentCellAddress.Y].Cells[col.Index]; + } + } + } + + #endregion + + } } \ No newline at end of file diff --git a/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs b/src/Logexpert.UI/Controls/LogWindow/LogWindowPublic.cs similarity index 96% rename from src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs rename to src/Logexpert.UI/Controls/LogWindow/LogWindowPublic.cs index 18dd68e6..afb29b12 100644 --- a/src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs +++ b/src/Logexpert.UI/Controls/LogWindow/LogWindowPublic.cs @@ -1,1850 +1,1842 @@ -using LogExpert.Classes; -using LogExpert.Classes.Filter; -using LogExpert.Config; -using LogExpert.Core.Classes; -using LogExpert.Core.Classes.Bookmark; -using LogExpert.Core.Classes.Columnizer; -using LogExpert.Core.Classes.Filter; -using LogExpert.Core.Classes.Highlight; -using LogExpert.Core.Classes.Persister; -using LogExpert.Core.Config; -using LogExpert.Core.Entities; -using LogExpert.Core.EventArgs; -using LogExpert.Dialogs; - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace LogExpert.Controls.LogWindow -{ - public partial class LogWindow - { - #region Public methods - - public void LoadFile(string fileName, EncodingOptions encodingOptions) - { - EnterLoadFileStatus(); - - if (fileName != null) - { - FileName = fileName; - EncodingOptions = encodingOptions; - - if (_logFileReader != null) - { - _logFileReader.StopMonitoringAsync(); - UnRegisterLogFileReaderEvents(); - } - - // - // isUsingDefaultColumnizer is to enable automatically find the best columnizer. - // When a new log file is opened, and no Columnizer can be chose by file mask, - // this flag will enable find a columnizer automatically. - // Current solution is not elegant. - // Since the refactory will involving a lot of work, we can plan it in the future. - // One possible solution is, using raw file stream to read the sample lines to help - // the ColumnizerPicker to determine the priority. - // - bool isUsingDefaultColumnizer = false; - if (!LoadPersistenceOptions()) - { - if (!IsTempFile) - { - ILogLineColumnizer columnizer = FindColumnizer(); - if (columnizer != null) - { - if (_reloadMemento == null) - { - //TODO this needs to be refactored - var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - - columnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); - } - } - else - { - isUsingDefaultColumnizer = true; - } - PreSelectColumnizer(columnizer); - } - SetDefaultHighlightGroup(); - } - - // this may be set after loading persistence data - if (_fileNames != null && IsMultiFile) - { - LoadFilesAsMulti(_fileNames, EncodingOptions); - return; - } - - _columnCache = new ColumnCache(); - - try - { - _logFileReader = new(fileName, EncodingOptions, IsMultiFile, Preferences.bufferCount, Preferences.linesPerBuffer, _multiFileOptions) - { - UseNewReader = !Preferences.useLegacyReader - }; - } - catch (LogFileException lfe) - { - _logger.Error(lfe); - MessageBox.Show("Cannot load file\n" + lfe.Message, "LogExpert"); - _ = BeginInvoke(new FunctionWith1BoolParam(Close), true); - _isLoadError = true; - return; - } - - if (CurrentColumnizer is ILogLineXmlColumnizer xmlColumnizer) - { - _logFileReader.IsXmlMode = true; - _logFileReader.XmlLogConfig = xmlColumnizer.GetXmlLogConfiguration(); - } - - if (_forcedColumnizerForLoading != null) - { - CurrentColumnizer = _forcedColumnizerForLoading; - } - - if (CurrentColumnizer is IPreProcessColumnizer processColumnizer) - { - _logFileReader.PreProcessColumnizer = processColumnizer; - } - else - { - _logFileReader.PreProcessColumnizer = null; - } - - RegisterLogFileReaderEvents(); - _logger.Info($"Loading logfile: {fileName}"); - _logFileReader.StartMonitoring(); - - if (isUsingDefaultColumnizer) - { - if (Preferences.autoPick) - { - ILogLineColumnizer newColumnizer = ColumnizerPicker.FindBetterColumnizer(FileName, _logFileReader, CurrentColumnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - - if (newColumnizer != null) - { - _logger.Debug($"Picked new columnizer '{newColumnizer}'"); - - PreSelectColumnizer(newColumnizer); - } - } - } - } - } - - public void LoadFilesAsMulti(string[] fileNames, EncodingOptions encodingOptions) - { - _logger.Info("Loading given files as MultiFile:"); - - EnterLoadFileStatus(); - - foreach (string name in fileNames) - { - _logger.Info("File: {0}", name); - } - - if (_logFileReader != null) - { - _logFileReader.StopMonitoring(); - UnRegisterLogFileReaderEvents(); - } - - EncodingOptions = encodingOptions; - _columnCache = new ColumnCache(); - - _logFileReader = new(fileNames, EncodingOptions, Preferences.bufferCount, Preferences.linesPerBuffer, _multiFileOptions) - { - UseNewReader = !Preferences.useLegacyReader - }; - - RegisterLogFileReaderEvents(); - _logFileReader.StartMonitoring(); - FileName = fileNames[^1]; - _fileNames = fileNames; - IsMultiFile = true; - //if (this.isTempFile) - // this.Text = this.tempTitleName; - //else - // this.Text = Util.GetNameFromPath(this.FileName); - } - - public string SavePersistenceData(bool force) - { - if (!force) - { - if (!Preferences.saveSessions) - { - return null; - } - } - - if (IsTempFile || _isLoadError) - { - return null; - } - - try - { - PersistenceData persistenceData = GetPersistenceData(); - - if (ForcedPersistenceFileName == null) - { - return Persister.SavePersistenceData(FileName, persistenceData, Preferences); - } - - return Persister.SavePersistenceDataWithFixedName(ForcedPersistenceFileName, persistenceData); - } - catch (IOException ex) - { - _logger.Error(ex, "Error saving persistence: "); - } - catch (Exception e) - { - MessageBox.Show($"Unexpected error while saving persistence: {e.Message}"); - } - - return null; - } - - public PersistenceData GetPersistenceData() - { - PersistenceData persistenceData = new() - { - bookmarkList = _bookmarkProvider.BookmarkList, - rowHeightList = _rowHeightList, - multiFile = IsMultiFile, - multiFilePattern = _multiFileOptions.FormatPattern, - multiFileMaxDays = _multiFileOptions.MaxDayTry, - currentLine = dataGridView.CurrentCellAddress.Y, - firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex, - filterVisible = !splitContainerLogWindow.Panel2Collapsed, - filterAdvanced = !advancedFilterSplitContainer.Panel1Collapsed, - filterPosition = splitContainerLogWindow.SplitterDistance, - followTail = _guiStateArgs.FollowTail, - fileName = FileName, - tabName = Text, - sessionFileName = SessionFileName, - columnizerName = CurrentColumnizer.GetName(), - lineCount = _logFileReader.LineCount - }; - - _filterParams.IsFilterTail = filterTailCheckBox.Checked; // this option doesnt need a press on 'search' - - if (Preferences.saveFilters) - { - List filterList = [_filterParams]; - persistenceData.filterParamsList = filterList; - - foreach (FilterPipe filterPipe in _filterPipeList) - { - FilterTabData data = new() - { - PersistenceData = filterPipe.OwnLogWindow.GetPersistenceData(), - FilterParams = filterPipe.FilterParams - }; - persistenceData.filterTabDataList.Add(data); - } - } - - if (_currentHighlightGroup != null) - { - persistenceData.highlightGroupName = _currentHighlightGroup.GroupName; - } - - if (_fileNames != null && IsMultiFile) - { - persistenceData.multiFileNames.AddRange(_fileNames); - } - - //persistenceData.showBookmarkCommentColumn = this.bookmarkWindow.ShowBookmarkCommentColumn; - persistenceData.filterSaveListVisible = !highlightSplitContainer.Panel2Collapsed; - persistenceData.encoding = _logFileReader.CurrentEncoding; - - return persistenceData; - } - - public void Close(bool dontAsk) - { - Preferences.askForClose = !dontAsk; - Close(); - } - - public void CloseLogWindow() - { - StopTimespreadThread(); - StopTimestampSyncThread(); - StopLogEventWorkerThread(); - _shouldCancel = true; - - if (_logFileReader != null) - { - UnRegisterLogFileReaderEvents(); - _logFileReader.StopMonitoringAsync(); - //this.logFileReader.DeleteAllContent(); - } - - if (_isLoading) - { - _waitingForClose = true; - } - - if (IsTempFile) - { - _logger.Info("Deleting temp file {0}", FileName); - - try - { - File.Delete(FileName); - } - catch (IOException e) - { - _logger.Error(e, "Error while deleting temp file {0}: {1}", FileName, e); - } - } - - FilterPipe?.CloseAndDisconnect(); - DisconnectFilterPipes(); - } - - public void WaitForLoadingFinished() - { - _externaLoadingFinishedEvent.WaitOne(); - } - - public void ForceColumnizer(ILogLineColumnizer columnizer) - { - //TODO this needs to be refactored - var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - - _forcedColumnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); - SetColumnizer(_forcedColumnizer); - } - - public void ForceColumnizerForLoading(ILogLineColumnizer columnizer) - { - //TODO this needs to be refactored - var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - - _forcedColumnizerForLoading = ColumnizerPicker.CloneColumnizer(columnizer, directory); - } - - public void PreselectColumnizer(string columnizerName) - { - //TODO this needs to be refactored - var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - - ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - PreSelectColumnizer(ColumnizerPicker.CloneColumnizer(columnizer, directory)); - } - - public void ColumnizerConfigChanged() - { - SetColumnizerInternal(CurrentColumnizer); - } - - public void SetColumnizer(ILogLineColumnizer columnizer, BufferedDataGridView gridView) - { - PaintHelper.SetColumnizer(columnizer, gridView); - - gridView.Refresh(); - AutoResizeColumns(gridView); - ApplyFrozenState(gridView); - } - - public IColumn GetCellValue(int rowIndex, int columnIndex) - { - if (columnIndex == 1) - { - return new Column - { - FullValue = (rowIndex + 1).ToString() // line number - }; - } - - if (columnIndex == 0) // marker column - { - return Column.EmptyColumn; - } - - try - { - IColumnizedLogLine cols = GetColumnsForLine(rowIndex); - if (cols != null && cols.ColumnValues != null) - { - if (columnIndex <= cols.ColumnValues.Length + 1) - { - IColumn value = cols.ColumnValues[columnIndex - 2]; - - if (value != null && value.DisplayValue != null) - { - return value; - } - return value; - } - - if (columnIndex == 2) - { - return cols.ColumnValues[^1]; - } - - return Column.EmptyColumn; - } - } - catch - { - return Column.EmptyColumn; - } - - return Column.EmptyColumn; - } - - public void CellPainting(BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) - { - if (rowIndex < 0 || e.ColumnIndex < 0) - { - e.Handled = false; - return; - } - - ILogLine line = _logFileReader.GetLogLineWithWait(rowIndex).Result; - - if (line != null) - { - HighlightEntry entry = FindFirstNoWordMatchHilightEntry(line); - e.Graphics.SetClip(e.CellBounds); - - if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) - { - Color backColor = ColorMode.BackgroundColor; - - Brush brush; - - if (gridView.Focused) - { - brush = new SolidBrush(e.CellStyle.SelectionBackColor); - } - else - { - Color color = backColor; - brush = new SolidBrush(color); - } - - e.Graphics.FillRectangle(brush, e.CellBounds); - brush.Dispose(); - } - else - { - Color bgColor = ColorMode.DockBackgroundColor; - - if (!DebugOptions.DisableWordHighlight) - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - else - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - - e.CellStyle.BackColor = bgColor; - - e.PaintBackground(e.ClipBounds, false); - } - - if (DebugOptions.DisableWordHighlight) - { - e.PaintContent(e.CellBounds); - } - else - { - PaintCell(e, gridView, false, entry); - } - - if (e.ColumnIndex == 0) - { - if (_bookmarkProvider.IsBookmarkAtLine(rowIndex)) - { - Rectangle r; // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); - r = e.CellBounds; - r.Inflate(-2, -2); - Brush brush = new SolidBrush(BookmarkColor); - e.Graphics.FillRectangle(brush, r); - brush.Dispose(); - Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(rowIndex); - - if (bookmark.Text.Length > 0) - { - StringFormat format = new() - { - LineAlignment = StringAlignment.Center, - Alignment = StringAlignment.Center - }; - Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); - Font font = new("Courier New", Preferences.fontSize, FontStyle.Bold); - e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), - format); - font.Dispose(); - brush2.Dispose(); - } - } - } - - e.Paint(e.CellBounds, DataGridViewPaintParts.Border); - e.Handled = true; - } - } - - public void OnDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) - { - BufferedDataGridView gridView = (BufferedDataGridView)sender; - CellPainting(gridView, e.RowIndex, e); - } - - /// - /// Returns the first HilightEntry that matches the given line - /// - /// - /// - /// - public HighlightEntry FindHighlightEntry(ITextValue line, bool noWordMatches) - { - // first check the temp entries - lock (_tempHighlightEntryListLock) - { - foreach (HighlightEntry entry in _tempHighlightEntryList) - { - if (noWordMatches && entry.IsWordMatch) - { - continue; - } - if (CheckHighlightEntryMatch(entry, line)) - { - return entry; - } - } - } - - lock (_currentHighlightGroupLock) - { - foreach (HighlightEntry entry in _currentHighlightGroup.HighlightEntryList) - { - if (noWordMatches && entry.IsWordMatch) - { - continue; - } - if (CheckHighlightEntryMatch(entry, line)) - { - return entry; - } - } - return null; - } - } - - public IList FindHighlightMatches(ITextValue column) - { - IList resultList = new List(); - if (column != null) - { - lock (_currentHighlightGroupLock) - { - GetHighlightEntryMatches(column, _currentHighlightGroup.HighlightEntryList, resultList); - } - lock (_tempHighlightEntryList) - { - GetHighlightEntryMatches(column, _tempHighlightEntryList, resultList); - } - } - return resultList; - } - - public void FollowTailChanged(bool isChecked, bool byTrigger) - { - _guiStateArgs.FollowTail = isChecked; - - if (_guiStateArgs.FollowTail && _logFileReader != null) - { - if (dataGridView.RowCount >= _logFileReader.LineCount && _logFileReader.LineCount > 0) - { - dataGridView.FirstDisplayedScrollingRowIndex = _logFileReader.LineCount - 1; - } - } - BeginInvoke(new MethodInvoker(dataGridView.Refresh)); - //this.dataGridView.Refresh(); - _parentLogTabWin.FollowTailChanged(this, isChecked, byTrigger); - SendGuiStateUpdate(); - } - - public void GotoLine(int line) - { - if (line >= 0) - { - if (line < dataGridView.RowCount) - { - SelectLine(line, false, true); - } - else - { - SelectLine(dataGridView.RowCount - 1, false, true); - } - dataGridView.Focus(); - } - } - - public void StartSearch() - { - _guiStateArgs.MenuEnabled = false; - GuiStateUpdate(this, _guiStateArgs); - SearchParams searchParams = _parentLogTabWin.SearchParams; - - if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) - { - searchParams.CurrentLine = dataGridView.CurrentCellAddress.Y + 1; - } - else - { - searchParams.CurrentLine = dataGridView.CurrentCellAddress.Y - 1; - } - - _currentSearchParams = searchParams; // remember for async "not found" messages - - _isSearching = true; - _shouldCancel = false; - StatusLineText("Searching... Press ESC to cancel."); - - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = dataGridView.RowCount; - _progressEventArgs.Value = 0; - _progressEventArgs.Visible = true; - SendProgressBarUpdate(); - - Task.Run(() => Search(searchParams)).ContinueWith(SearchComplete); - - RemoveAllSearchHighlightEntries(); - AddSearchHitHighlightEntry(searchParams); - } - - private void SearchComplete(Task task) - { - if (Disposing) - { - return; - } - - try - { - Invoke(new MethodInvoker(ResetProgressBar)); - int line = task.Result; - _guiStateArgs.MenuEnabled = true; - GuiStateUpdate(this, _guiStateArgs); - if (line == -1) - { - return; - } - - dataGridView.Invoke(new SelectLineFx((line1, triggerSyncCall) => SelectLine(line1, triggerSyncCall, true)), line, true); - } - catch (Exception ex) // in the case the windows is already destroyed - { - _logger.Warn(ex); - } - } - - public void SelectLogLine(int line) - { - Invoke(new SelectLineFx((line1, triggerSyncCall) => SelectLine(line1, triggerSyncCall, true)), line, true); - } - - public void SelectAndEnsureVisible(int line, bool triggerSyncCall) - { - try - { - SelectLine(line, triggerSyncCall, false); - - //if (!this.dataGridView.CurrentRow.Displayed) - if (line < dataGridView.FirstDisplayedScrollingRowIndex || line > dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false)) - { - dataGridView.FirstDisplayedScrollingRowIndex = line; - for (int i = 0; i < 8 && dataGridView.FirstDisplayedScrollingRowIndex > 0 && line < dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false); ++i) - { - dataGridView.FirstDisplayedScrollingRowIndex -= 1; - } - - if (line >= dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false)) - { - dataGridView.FirstDisplayedScrollingRowIndex += 1; - } - } - dataGridView.CurrentCell = dataGridView.Rows[line].Cells[0]; - } - catch (Exception e) - { - // In rare situations there seems to be an invalid argument exceptions (or something like this). Concrete location isn't visible in stack - // trace because use of Invoke(). So catch it, and log (better than crashing the app). - _logger.Error(e); - } - } - - public void OnLogWindowKeyDown(object sender, KeyEventArgs e) - { - if (_isErrorShowing) - { - RemoveStatusLineError(); - } - - switch (e.KeyCode) - { - case Keys.F3 when _parentLogTabWin.SearchParams?.SearchText == null || _parentLogTabWin.SearchParams.SearchText.Length == 0: - { - return; - } - case Keys.F3: - { - _parentLogTabWin.SearchParams.IsFindNext = true; - _parentLogTabWin.SearchParams.IsShiftF3Pressed = (e.Modifiers & Keys.Shift) == Keys.Shift; - StartSearch(); - break; - } - case Keys.Escape: - { - if (_isSearching) - { - _shouldCancel = true; - } - - FireCancelHandlers(); - RemoveAllSearchHighlightEntries(); - break; - } - case Keys.E when (e.Modifiers & Keys.Control) == Keys.Control: - { - StartEditMode(); - - break; - } - case Keys.Down when e.Modifiers == Keys.Alt: - { - int newLine = _logFileReader.GetNextMultiFileLine(dataGridView.CurrentCellAddress.Y); - - if (newLine != -1) - { - SelectLine(newLine, false, true); - } - - e.Handled = true; - - break; - } - case Keys.Up when e.Modifiers == Keys.Alt: - { - int newLine = _logFileReader.GetPrevMultiFileLine(dataGridView.CurrentCellAddress.Y); - - if (newLine != -1) - { - SelectLine(newLine - 1, false, true); - } - - e.Handled = true; - - break; - } - case Keys.Enter when dataGridView.Focused: - { - ChangeRowHeight(e.Shift); - e.Handled = true; - - break; - } - case Keys.Back when dataGridView.Focused: - { - ChangeRowHeight(true); - e.Handled = true; - - break; - } - case Keys.PageUp when e.Modifiers == Keys.Alt: - { - SelectPrevHighlightLine(); - e.Handled = true; - - break; - } - case Keys.PageDown when e.Modifiers == Keys.Alt: - { - SelectNextHighlightLine(); - e.Handled = true; - - break; - } - case Keys.T when (e.Modifiers & Keys.Control) == Keys.Control && (e.Modifiers & Keys.Shift) == Keys.Shift: - { - FilterToTab(); - break; - } - } - } - - public void AddBookmarkOverlays() - { - const int OVERSCAN = 20; - - int firstLine = dataGridView.FirstDisplayedScrollingRowIndex; - if (firstLine < 0) - { - return; - } - - firstLine -= OVERSCAN; - if (firstLine < 0) - { - firstLine = 0; - } - - int oversizeCount = OVERSCAN; - - for (int i = firstLine; i < dataGridView.RowCount; ++i) - { - if (!dataGridView.Rows[i].Displayed && i > dataGridView.FirstDisplayedScrollingRowIndex) - { - if (oversizeCount-- < 0) - { - break; - } - } - if (_bookmarkProvider.IsBookmarkAtLine(i)) - { - Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(i); - if (bookmark.Text.Length > 0) - { - //BookmarkOverlay overlay = new BookmarkOverlay(); - BookmarkOverlay overlay = bookmark.Overlay; - overlay.Bookmark = bookmark; - - Rectangle r; - if (dataGridView.Rows[i].Displayed) - { - r = dataGridView.GetCellDisplayRectangle(0, i, false); - } - else - { - r = dataGridView.GetCellDisplayRectangle(0, dataGridView.FirstDisplayedScrollingRowIndex, false); - //int count = i - this.dataGridView.FirstDisplayedScrollingRowIndex; - int heightSum = 0; - if (dataGridView.FirstDisplayedScrollingRowIndex < i) - { - for (int rn = dataGridView.FirstDisplayedScrollingRowIndex + 1; rn < i; ++rn) - { - //Rectangle rr = this.dataGridView.GetCellDisplayRectangle(0, rn, false); - //heightSum += rr.Height; - heightSum += GetRowHeight(rn); - } - r.Offset(0, r.Height + heightSum); - } - else - { - for (int rn = dataGridView.FirstDisplayedScrollingRowIndex + 1; rn > i; --rn) - { - //Rectangle rr = this.dataGridView.GetCellDisplayRectangle(0, rn, false); - //heightSum += rr.Height; - heightSum += GetRowHeight(rn); - } - r.Offset(0, -(r.Height + heightSum)); - } - //r.Offset(0, this.dataGridView.DisplayRectangle.Height); - } - if (_logger.IsDebugEnabled) - { - _logger.Debug("AddBookmarkOverlay() r.Location={0}, width={1}, scroll_offset={2}", r.Location.X, r.Width, dataGridView.HorizontalScrollingOffset); - } - overlay.Position = r.Location - new Size(dataGridView.HorizontalScrollingOffset, 0); - overlay.Position += new Size(10, r.Height / 2); - dataGridView.AddOverlay(overlay); - } - } - } - } - - public void ToggleBookmark() - { - BufferedDataGridView gridView; - int lineNum; - - if (filterGridView.Focused) - { - gridView = filterGridView; - if (gridView.CurrentCellAddress.Y == -1) - { - return; - } - - lineNum = _filterResultList[gridView.CurrentCellAddress.Y]; - } - else - { - gridView = dataGridView; - if (gridView.CurrentCellAddress.Y == -1) - { - return; - } - lineNum = dataGridView.CurrentCellAddress.Y; - } - - ToggleBookmark(lineNum); - } - - public void ToggleBookmark(int lineNum) - { - if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); - - if (string.IsNullOrEmpty(bookmark.Text) == false) - { - if (DialogResult.No == MessageBox.Show("There's a comment attached to the bookmark. Really remove the bookmark?", "LogExpert", MessageBoxButtons.YesNo)) - { - return; - } - } - _bookmarkProvider.RemoveBookmarkForLine(lineNum); - } - else - { - _bookmarkProvider.AddBookmark(new Bookmark(lineNum)); - } - dataGridView.Refresh(); - filterGridView.Refresh(); - OnBookmarkAdded(); - } - - public void SetBookmarkFromTrigger(int lineNum, string comment) - { - lock (_bookmarkLock) - { - ILogLine line = _logFileReader.GetLogLine(lineNum); - if (line == null) - { - return; - } - ParamParser paramParser = new ParamParser(comment); - try - { - comment = paramParser.ReplaceParams(line, lineNum, FileName); - } - catch (ArgumentException) - { - // occurs on invalid regex - } - if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - _bookmarkProvider.RemoveBookmarkForLine(lineNum); - } - _bookmarkProvider.AddBookmark(new Bookmark(lineNum, comment)); - OnBookmarkAdded(); - } - } - - public void JumpNextBookmark() - { - if (_bookmarkProvider.Bookmarks.Count > 0) - { - if (filterGridView.Focused) - { - int index = FindNextBookmarkIndex(_filterResultList[filterGridView.CurrentCellAddress.Y]); - int startIndex = index; - bool wrapped = false; - while (true) - { - int lineNum = _bookmarkProvider.Bookmarks[index].LineNum; - if (_filterResultList.Contains(lineNum)) - { - int filterLine = _filterResultList.IndexOf(lineNum); - filterGridView.Rows[filterLine].Selected = true; - filterGridView.CurrentCell = filterGridView.Rows[filterLine].Cells[0]; - break; - } - index++; - if (index > _bookmarkProvider.Bookmarks.Count - 1) - { - index = 0; - wrapped = true; - } - if (index >= startIndex && wrapped) - { - break; - } - } - } - else - { - int index = FindNextBookmarkIndex(dataGridView.CurrentCellAddress.Y); - if (index > _bookmarkProvider.Bookmarks.Count - 1) - { - index = 0; - } - - int lineNum = _bookmarkProvider.Bookmarks[index].LineNum; - SelectLine(lineNum, true, true); - } - } - } - - public void JumpPrevBookmark() - { - if (_bookmarkProvider.Bookmarks.Count > 0) - { - if (filterGridView.Focused) - { - //int index = this.bookmarkList.BinarySearch(this.filterResultList[this.filterGridView.CurrentCellAddress.Y]); - //if (index < 0) - // index = ~index; - //index--; - int index = FindPrevBookmarkIndex(_filterResultList[filterGridView.CurrentCellAddress.Y]); - if (index < 0) - { - index = _bookmarkProvider.Bookmarks.Count - 1; - } - int startIndex = index; - bool wrapped = false; - while (true) - { - int lineNum = _bookmarkProvider.Bookmarks[index].LineNum; - if (_filterResultList.Contains(lineNum)) - { - int filterLine = _filterResultList.IndexOf(lineNum); - filterGridView.Rows[filterLine].Selected = true; - filterGridView.CurrentCell = filterGridView.Rows[filterLine].Cells[0]; - break; - } - index--; - if (index < 0) - { - index = _bookmarkProvider.Bookmarks.Count - 1; - wrapped = true; - } - if (index <= startIndex && wrapped) - { - break; - } - } - } - else - { - int index = FindPrevBookmarkIndex(dataGridView.CurrentCellAddress.Y); - if (index < 0) - { - index = _bookmarkProvider.Bookmarks.Count - 1; - } - - int lineNum = _bookmarkProvider.Bookmarks[index].LineNum; - SelectLine(lineNum, false, true); - } - } - } - - public void DeleteBookmarks(List lineNumList) - { - bool bookmarksPresent = false; - foreach (int lineNum in lineNumList) - { - if (lineNum != -1) - { - if (_bookmarkProvider.IsBookmarkAtLine(lineNum) && - _bookmarkProvider.GetBookmarkForLine(lineNum).Text.Length > 0) - { - bookmarksPresent = true; - } - } - } - if (bookmarksPresent) - { - if ( - MessageBox.Show("There are some comments in the bookmarks. Really remove bookmarks?", "LogExpert", - MessageBoxButtons.YesNo) == DialogResult.No) - { - return; - } - } - _bookmarkProvider.RemoveBookmarksForLines(lineNumList); - OnBookmarkRemoved(); - } - - public void SetTimeshiftValue(string value) - { - _guiStateArgs.TimeshiftText = value; - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - try - { - if (_guiStateArgs.TimeshiftEnabled) - { - try - { - string text = _guiStateArgs.TimeshiftText; - if (text.StartsWith("+")) - { - text = text.Substring(1); - } - TimeSpan timeSpan = TimeSpan.Parse(text); - int diff = (int)(timeSpan.Ticks / TimeSpan.TicksPerMillisecond); - CurrentColumnizer.SetTimeOffset(diff); - } - catch (Exception) - { - CurrentColumnizer.SetTimeOffset(0); - } - } - else - { - CurrentColumnizer.SetTimeOffset(0); - } - dataGridView.Refresh(); - filterGridView.Refresh(); - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - SetTimestampLimits(); - SyncTimestampDisplay(); - } - } - catch (FormatException ex) - { - _logger.Error(ex); - } - } - } - - public void ToggleFilterPanel() - { - splitContainerLogWindow.Panel2Collapsed = !splitContainerLogWindow.Panel2Collapsed; - if (!splitContainerLogWindow.Panel2Collapsed) - { - filterComboBox.Focus(); - } - else - { - dataGridView.Focus(); - } - } - - public void LogWindowActivated() - { - if (_guiStateArgs.FollowTail && !_isDeadFile) - { - OnTailFollowed(EventArgs.Empty); - } - if (Preferences.timestampControl) - { - SetTimestampLimits(); - SyncTimestampDisplay(); - } - dataGridView.Focus(); - - SendGuiStateUpdate(); - SendStatusLineUpdate(); - SendProgressBarUpdate(); - } - - public void SetCellSelectionMode(bool isCellMode) - { - if (isCellMode) - { - //possible performance issue, see => https://docs.microsoft.com/en-us/dotnet/desktop/winforms/controls/best-practices-for-scaling-the-windows-forms-datagridview-control?view=netframeworkdesktop-4.8#using-the-selected-cells-rows-and-columns-collections-efficiently - dataGridView.SelectionMode = DataGridViewSelectionMode.CellSelect; - } - else - { - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - } - - _guiStateArgs.CellSelectMode = isCellMode; - } - - public void TimeshiftEnabled(bool isEnabled, string shiftValue) - { - _guiStateArgs.TimeshiftEnabled = isEnabled; - SetTimestampLimits(); - SetTimeshiftValue(shiftValue); - } - - public void CopyMarkedLinesToTab() - { - if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) - { - List lineNumList = new List(); - foreach (DataGridViewRow row in dataGridView.SelectedRows) - { - if (row.Index != -1) - { - lineNumList.Add(row.Index); - } - } - lineNumList.Sort(); - // create dummy FilterPipe for connecting line numbers to original window - // setting IsStopped to true prevents further filter processing - FilterPipe pipe = new FilterPipe(new FilterParams(), this) - { - IsStopped = true - }; - WritePipeToTab(pipe, lineNumList, Text + "->C", null); - } - else - { - string fileName = Path.GetTempFileName(); - FileStream fStream = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.Read); - StreamWriter writer = new StreamWriter(fStream, Encoding.Unicode); - - DataObject data = dataGridView.GetClipboardContent(); - string text = data.GetText(TextDataFormat.Text); - writer.Write(text); - - writer.Close(); - string title = Util.GetNameFromPath(FileName) + "->Clip"; - _parentLogTabWin.AddTempFileTab(fileName, title); - } - } - - /// - /// Change the file encoding. May force a reload if byte count ot preamble lenght differs from previous used encoding. - /// - /// - public void ChangeEncoding(Encoding encoding) - { - _logFileReader.ChangeEncoding(encoding); - EncodingOptions.Encoding = encoding; - if (_guiStateArgs.CurrentEncoding.IsSingleByte != encoding.IsSingleByte || - _guiStateArgs.CurrentEncoding.GetPreamble().Length != encoding.GetPreamble().Length) - { - Reload(); - } - else - { - dataGridView.Refresh(); - SendGuiStateUpdate(); - } - _guiStateArgs.CurrentEncoding = _logFileReader.CurrentEncoding; - } - - public void Reload() - { - SavePersistenceData(false); - - _reloadMemento = new ReloadMemento - { - CurrentLine = dataGridView.CurrentCellAddress.Y, - FirstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex - }; - _forcedColumnizerForLoading = CurrentColumnizer; - - if (_fileNames == null || !IsMultiFile) - { - LoadFile(FileName, EncodingOptions); - } - else - { - LoadFilesAsMulti(_fileNames, EncodingOptions); - } - //if (currentLine < this.dataGridView.RowCount && currentLine >= 0) - // this.dataGridView.CurrentCell = this.dataGridView.Rows[currentLine].Cells[0]; - //if (firstDisplayedLine < this.dataGridView.RowCount && firstDisplayedLine >= 0) - // this.dataGridView.FirstDisplayedScrollingRowIndex = firstDisplayedLine; - - //if (this.filterTailCheckBox.Checked) - //{ - // _logger.logInfo("Refreshing filter view because of reload."); - // FilterSearch(); - //} - } - - public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags) - { - if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors) - { - NormalFont = new Font(new FontFamily(newPreferences.fontName), newPreferences.fontSize); - BoldFont = new Font(NormalFont, FontStyle.Bold); - MonospacedFont = new Font("Courier New", Preferences.fontSize, FontStyle.Bold); - - int lineSpacing = NormalFont.FontFamily.GetLineSpacing(FontStyle.Regular); - float lineSpacingPixel = NormalFont.Size * lineSpacing / NormalFont.FontFamily.GetEmHeight(FontStyle.Regular); - - dataGridView.DefaultCellStyle.Font = NormalFont; - filterGridView.DefaultCellStyle.Font = NormalFont; - _lineHeight = NormalFont.Height + 4; - dataGridView.RowTemplate.Height = NormalFont.Height + 4; - - ShowBookmarkBubbles = Preferences.showBubbles; - - ApplyDataGridViewPrefs(dataGridView, newPreferences); - ApplyDataGridViewPrefs(filterGridView, newPreferences); - - if (Preferences.timestampControl) - { - SetTimestampLimits(); - SyncTimestampDisplay(); - } - if (isLoadTime) - { - filterTailCheckBox.Checked = Preferences.filterTail; - syncFilterCheckBox.Checked = Preferences.filterSync; - //this.FollowTailChanged(this.Preferences.followTail, false); - } - - _timeSpreadCalc.TimeMode = Preferences.timeSpreadTimeMode; - timeSpreadingControl.ForeColor = Preferences.timeSpreadColor; - timeSpreadingControl.ReverseAlpha = Preferences.reverseAlpha; - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - timeSpreadingControl.Invoke(new MethodInvoker(timeSpreadingControl.Refresh)); - ShowTimeSpread(Preferences.showTimeSpread); - } - ToggleColumnFinder(Preferences.showColumnFinder, false); - } - - if ((flags & SettingsFlags.FilterList) == SettingsFlags.FilterList) - { - HandleChangedFilterList(); - } - - if ((flags & SettingsFlags.FilterHistory) == SettingsFlags.FilterHistory) - { - UpdateFilterHistoryFromSettings(); - - if (isLoadTime) - { - AutoResizeFilterBox(); - } - } - } - - public bool ScrollToTimestamp(DateTime timestamp, bool roundToSeconds, bool triggerSyncCall) - { - if (InvokeRequired) - { - BeginInvoke(new ScrollToTimestampFx(ScrollToTimestampWorker), timestamp, roundToSeconds, triggerSyncCall); - return true; - } - - return ScrollToTimestampWorker(timestamp, roundToSeconds, triggerSyncCall); - } - - public bool ScrollToTimestampWorker(DateTime timestamp, bool roundToSeconds, bool triggerSyncCall) - { - bool hasScrolled = false; - if (!CurrentColumnizer.IsTimeshiftImplemented() || dataGridView.RowCount == 0) - { - return false; - } - - //this.Cursor = Cursors.WaitCursor; - int currentLine = dataGridView.CurrentCellAddress.Y; - if (currentLine < 0 || currentLine >= dataGridView.RowCount) - { - currentLine = 0; - } - int foundLine = FindTimestampLine(currentLine, timestamp, roundToSeconds); - if (foundLine >= 0) - { - SelectAndEnsureVisible(foundLine, triggerSyncCall); - hasScrolled = true; - } - //this.Cursor = Cursors.Default; - return hasScrolled; - } - - public int FindTimestampLine(int lineNum, DateTime timestamp, bool roundToSeconds) - { - int foundLine = - FindTimestampLine_Internal(lineNum, 0, dataGridView.RowCount - 1, timestamp, roundToSeconds); - if (foundLine >= 0) - { - // go backwards to the first occurence of the hit - DateTime foundTimestamp = GetTimestampForLine(ref foundLine, roundToSeconds); - while (foundTimestamp.CompareTo(timestamp) == 0 && foundLine >= 0) - { - foundLine--; - foundTimestamp = GetTimestampForLine(ref foundLine, roundToSeconds); - } - if (foundLine < 0) - { - return 0; - } - - foundLine++; - GetTimestampForLineForward(ref foundLine, roundToSeconds); // fwd to next valid timestamp - return foundLine; - } - return -foundLine; - } - - public int FindTimestampLine_Internal(int lineNum, int rangeStart, int rangeEnd, DateTime timestamp, - bool roundToSeconds) - { - _logger.Debug("FindTimestampLine_Internal(): timestamp={0}, lineNum={1}, rangeStart={2}, rangeEnd={3}", timestamp, lineNum, rangeStart, rangeEnd); - int refLine = lineNum; - DateTime currentTimestamp = GetTimestampForLine(ref refLine, roundToSeconds); - if (currentTimestamp.CompareTo(timestamp) == 0) - { - return lineNum; - } - if (timestamp < currentTimestamp) - { - //rangeStart = rangeStart; - rangeEnd = lineNum; - } - else - { - rangeStart = lineNum; - //rangeEnd = rangeEnd; - } - - if (rangeEnd - rangeStart <= 0) - { - return -lineNum; - } - - lineNum = (rangeEnd - rangeStart) / 2 + rangeStart; - // prevent endless loop - if (rangeEnd - rangeStart < 2) - { - currentTimestamp = GetTimestampForLine(ref rangeStart, roundToSeconds); - if (currentTimestamp.CompareTo(timestamp) == 0) - { - return rangeStart; - } - currentTimestamp = GetTimestampForLine(ref rangeEnd, roundToSeconds); - if (currentTimestamp.CompareTo(timestamp) == 0) - { - return rangeEnd; - } - return -lineNum; - } - - return FindTimestampLine_Internal(lineNum, rangeStart, rangeEnd, timestamp, roundToSeconds); - } - - /** - * Get the timestamp for the given line number. If the line - * has no timestamp, the previous line will be checked until a - * timestamp is found. - */ - - public DateTime GetTimestampForLine(ref int lineNum, bool roundToSeconds) - { - lock (_currentColumnizerLock) - { - if (!CurrentColumnizer.IsTimeshiftImplemented()) - { - return DateTime.MinValue; - } - _logger.Debug("GetTimestampForLine({0}) enter", lineNum); - DateTime timeStamp = DateTime.MinValue; - bool lookBack = false; - if (lineNum >= 0 && lineNum < dataGridView.RowCount) - { - while (timeStamp.CompareTo(DateTime.MinValue) == 0 && lineNum >= 0) - { - if (_isTimestampDisplaySyncing && _shouldTimestampDisplaySyncingCancel) - { - return DateTime.MinValue; - } - lookBack = true; - ILogLine logLine = _logFileReader.GetLogLine(lineNum); - if (logLine == null) - { - return DateTime.MinValue; - } - ColumnizerCallbackObject.LineNum = lineNum; - timeStamp = CurrentColumnizer.GetTimestamp(ColumnizerCallbackObject, logLine); - if (roundToSeconds) - { - timeStamp = timeStamp.Subtract(TimeSpan.FromMilliseconds(timeStamp.Millisecond)); - } - lineNum--; - } - } - if (lookBack) - { - lineNum++; - } - _logger.Debug("GetTimestampForLine() leave with lineNum={0}", lineNum); - return timeStamp; - } - } - - /** - * Get the timestamp for the given line number. If the line - * has no timestamp, the next line will be checked until a - * timestamp is found. - */ - - public DateTime GetTimestampForLineForward(ref int lineNum, bool roundToSeconds) - { - lock (_currentColumnizerLock) - { - if (!CurrentColumnizer.IsTimeshiftImplemented()) - { - return DateTime.MinValue; - } - - DateTime timeStamp = DateTime.MinValue; - bool lookFwd = false; - if (lineNum >= 0 && lineNum < dataGridView.RowCount) - { - while (timeStamp.CompareTo(DateTime.MinValue) == 0 && lineNum < dataGridView.RowCount) - { - lookFwd = true; - ILogLine logLine = _logFileReader.GetLogLine(lineNum); - if (logLine == null) - { - timeStamp = DateTime.MinValue; - break; - } - timeStamp = CurrentColumnizer.GetTimestamp(ColumnizerCallbackObject, logLine); - if (roundToSeconds) - { - timeStamp = timeStamp.Subtract(TimeSpan.FromMilliseconds(timeStamp.Millisecond)); - } - lineNum++; - } - } - if (lookFwd) - { - lineNum--; - } - return timeStamp; - } - } - - public void AppFocusLost() - { - InvalidateCurrentRow(dataGridView); - } - - public void AppFocusGained() - { - InvalidateCurrentRow(dataGridView); - } - - public ILogLine GetCurrentLine() - { - if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index != -1) - { - return _logFileReader.GetLogLine(dataGridView.CurrentRow.Index); - } - return null; - } - - public ILogLine GetLine(int lineNum) - { - if (lineNum < 0 || _logFileReader == null || lineNum >= _logFileReader.LineCount) - { - return null; - } - return _logFileReader.GetLogLine(lineNum); - } - - public int GetCurrentLineNum() - { - if (dataGridView.CurrentRow == null) - { - return -1; - } - return dataGridView.CurrentRow.Index; - } - - public int GetRealLineNum() - { - int lineNum = GetCurrentLineNum(); - if (lineNum == -1) - { - return -1; - } - return _logFileReader.GetRealLineNumForVirtualLineNum(lineNum); - } - - public ILogFileInfo GetCurrentFileInfo() - { - if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index != -1) - { - return _logFileReader.GetLogFileInfoForLine(dataGridView.CurrentRow.Index); - } - return null; - } - - /// - /// zero-based - /// - /// - /// - public string GetCurrentFileName(int lineNum) - { - return _logFileReader.GetLogFileNameForLine(lineNum); - } - - // =============== end of bookmark stuff =================================== - - public void ShowLineColumn(bool show) - { - dataGridView.Columns[1].Visible = show; - filterGridView.Columns[1].Visible = show; - } - - // ================================================================= - // Pattern statistics - // ================================================================= - - public void PatternStatistic() - { - InitPatternWindow(); - } - - public void PatternStatisticSelectRange(PatternArgs patternArgs) - { - if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) - { - List lineNumList = []; - foreach (DataGridViewRow row in dataGridView.SelectedRows) - { - if (row.Index != -1) - { - lineNumList.Add(row.Index); - } - } - lineNumList.Sort(); - patternArgs.StartLine = lineNumList[0]; - patternArgs.EndLine = lineNumList[^1]; - } - else - { - if (dataGridView.CurrentCellAddress.Y != -1) - { - patternArgs.StartLine = dataGridView.CurrentCellAddress.Y; - } - else - { - patternArgs.StartLine = 0; - } - patternArgs.EndLine = dataGridView.RowCount - 1; - } - } - - public void PatternStatistic(PatternArgs patternArgs) - { - PatternStatisticFx fx = new PatternStatisticFx(TestStatistic); - fx.BeginInvoke(patternArgs, null, null); - } - - public void ExportBookmarkList() - { - SaveFileDialog dlg = new() - { - Title = "Choose a file to save bookmarks into", - AddExtension = true, - DefaultExt = "csv", - Filter = "CSV file (*.csv)|*.csv|Bookmark file (*.bmk)|*.bmk", - FilterIndex = 1, - FileName = Path.GetFileNameWithoutExtension(FileName) - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - try - { - BookmarkExporter.ExportBookmarkList(_bookmarkProvider.BookmarkList, FileName, - dlg.FileName); - } - catch (IOException e) - { - _logger.Error(e); - MessageBox.Show("Error while exporting bookmark list: " + e.Message, "LogExpert"); - } - } - } - - public void ImportBookmarkList() - { - OpenFileDialog dlg = new() - { - Title = "Choose a file to load bookmarks from", - AddExtension = true, - DefaultExt = "csv", - Filter = "CSV file (*.csv)|*.csv|Bookmark file (*.bmk)|*.bmk", - FilterIndex = 1, - FileName = Path.GetFileNameWithoutExtension(FileName) - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - try - { - // add to the existing bookmarks - SortedList newBookmarks = []; - BookmarkExporter.ImportBookmarkList(FileName, dlg.FileName, newBookmarks); - - // Add (or replace) to existing bookmark list - bool bookmarkAdded = false; - foreach (Bookmark b in newBookmarks.Values) - { - if (!_bookmarkProvider.BookmarkList.ContainsKey(b.LineNum)) - { - _bookmarkProvider.BookmarkList.Add(b.LineNum, b); - bookmarkAdded = true; // refresh the list only once at the end - } - else - { - Bookmark existingBookmark = _bookmarkProvider.BookmarkList[b.LineNum]; - existingBookmark.Text = - b.Text; // replace existing bookmark for that line, preserving the overlay - OnBookmarkTextChanged(b); - } - } - - // Refresh the lists - if (bookmarkAdded) - { - OnBookmarkAdded(); - } - dataGridView.Refresh(); - filterGridView.Refresh(); - } - catch (IOException e) - { - _logger.Error(e); - MessageBox.Show($"Error while importing bookmark list: {e.Message}", "LogExpert"); - } - } - } - - public bool IsAdvancedOptionActive() - { - return rangeCheckBox.Checked || - fuzzyKnobControl.Value > 0 || - filterKnobBackSpread.Value > 0 || - filterKnobForeSpread.Value > 0 || - invertFilterCheckBox.Checked || - columnRestrictCheckBox.Checked; - } - - public void HandleChangedFilterList() - { - Invoke(new MethodInvoker(HandleChangedFilterListWorker)); - } - - public void HandleChangedFilterListWorker() - { - int index = filterListBox.SelectedIndex; - filterListBox.Items.Clear(); - foreach (FilterParams filterParam in ConfigManager.Settings.filterList) - { - filterListBox.Items.Add(filterParam); - } - filterListBox.Refresh(); - if (index >= 0 && index < filterListBox.Items.Count) - { - filterListBox.SelectedIndex = index; - } - filterOnLoadCheckBox.Checked = Preferences.isFilterOnLoad; - hideFilterListOnLoadCheckBox.Checked = Preferences.isAutoHideFilterList; - } - - public void SetCurrentHighlightGroup(string groupName) - { - _guiStateArgs.HighlightGroupName = groupName; - lock (_currentHighlightGroupLock) - { - _currentHighlightGroup = _parentLogTabWin.FindHighlightGroup(groupName); - if (_currentHighlightGroup == null) - { - if (_parentLogTabWin.HighlightGroupList.Count > 0) - { - _currentHighlightGroup = _parentLogTabWin.HighlightGroupList[0]; - } - else - { - _currentHighlightGroup = new HighlightGroup(); - } - } - _guiStateArgs.HighlightGroupName = _currentHighlightGroup.GroupName; - } - SendGuiStateUpdate(); - BeginInvoke(new MethodInvoker(RefreshAllGrids)); - } - - public void SwitchMultiFile(bool enabled) - { - IsMultiFile = enabled; - Reload(); - } - - public void AddOtherWindowToTimesync(LogWindow other) - { - if (other.IsTimeSynced) - { - if (IsTimeSynced) - { - other.FreeFromTimeSync(); - AddSlaveToTimesync(other); - } - else - { - AddToTimeSync(other); - } - } - else - { - AddSlaveToTimesync(other); - } - } - - public void AddToTimeSync(LogWindow master) - { - _logger.Info("Syncing window for {0} to {1}", Util.GetNameFromPath(FileName), Util.GetNameFromPath(master.FileName)); - lock (_timeSyncListLock) - { - if (IsTimeSynced && master.TimeSyncList != TimeSyncList) - // already synced but master has different sync list - { - FreeFromTimeSync(); - } - TimeSyncList = master.TimeSyncList; - TimeSyncList.AddWindow(this); - ScrollToTimestamp(TimeSyncList.CurrentTimestamp, false, false); - } - OnSyncModeChanged(); - } - - public void FreeFromTimeSync() - { - lock (_timeSyncListLock) - { - if (TimeSyncList != null) - { - _logger.Info("De-Syncing window for {0}", Util.GetNameFromPath(FileName)); - TimeSyncList.WindowRemoved -= OnTimeSyncListWindowRemoved; - TimeSyncList.RemoveWindow(this); - TimeSyncList = null; - } - } - OnSyncModeChanged(); - } - - public void RefreshLogView() - { - RefreshAllGrids(); - } - - #endregion - } -} +using LogExpert.Classes.Filter; +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Bookmark; +using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Classes.Filter; +using LogExpert.Core.Classes.Highlight; +using LogExpert.Core.Classes.Persister; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.EventArguments; +using LogExpert.Dialogs; +using LogExpert.UI.Entities; +using System.Text; + +namespace LogExpert.UI.Controls.LogWindow +{ + partial class LogWindow + { + #region Public methods + + public void LoadFile(string fileName, EncodingOptions encodingOptions) + { + EnterLoadFileStatus(); + + if (fileName != null) + { + FileName = fileName; + EncodingOptions = encodingOptions; + + if (_logFileReader != null) + { + _logFileReader.StopMonitoringAsync(); + UnRegisterLogFileReaderEvents(); + } + + // + // isUsingDefaultColumnizer is to enable automatically find the best columnizer. + // When a new log file is opened, and no Columnizer can be chose by file mask, + // this flag will enable find a columnizer automatically. + // Current solution is not elegant. + // Since the refactory will involving a lot of work, we can plan it in the future. + // One possible solution is, using raw file stream to read the sample lines to help + // the ColumnizerPicker to determine the priority. + // + bool isUsingDefaultColumnizer = false; + if (!LoadPersistenceOptions()) + { + if (!IsTempFile) + { + ILogLineColumnizer columnizer = FindColumnizer(); + if (columnizer != null) + { + if (_reloadMemento == null) + { + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + + columnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); + } + } + else + { + isUsingDefaultColumnizer = true; + } + PreSelectColumnizer(columnizer); + } + SetDefaultHighlightGroup(); + } + + // this may be set after loading persistence data + if (_fileNames != null && IsMultiFile) + { + LoadFilesAsMulti(_fileNames, EncodingOptions); + return; + } + + _columnCache = new ColumnCache(); + + try + { + _logFileReader = new(fileName, EncodingOptions, IsMultiFile, Preferences.bufferCount, Preferences.linesPerBuffer, _multiFileOptions, PluginRegistry.PluginRegistry.Instance) + { + UseNewReader = !Preferences.useLegacyReader + }; + } + catch (LogFileException lfe) + { + _logger.Error(lfe); + MessageBox.Show("Cannot load file\n" + lfe.Message, "LogExpert"); + _ = BeginInvoke(new FunctionWith1BoolParam(Close), true); + _isLoadError = true; + return; + } + + if (CurrentColumnizer is ILogLineXmlColumnizer xmlColumnizer) + { + _logFileReader.IsXmlMode = true; + _logFileReader.XmlLogConfig = xmlColumnizer.GetXmlLogConfiguration(); + } + + if (_forcedColumnizerForLoading != null) + { + CurrentColumnizer = _forcedColumnizerForLoading; + } + + if (CurrentColumnizer is IPreProcessColumnizer processColumnizer) + { + _logFileReader.PreProcessColumnizer = processColumnizer; + } + else + { + _logFileReader.PreProcessColumnizer = null; + } + + RegisterLogFileReaderEvents(); + _logger.Info($"Loading logfile: {fileName}"); + _logFileReader.StartMonitoring(); + + if (isUsingDefaultColumnizer) + { + if (Preferences.autoPick) + { + ILogLineColumnizer newColumnizer = ColumnizerPicker.FindBetterColumnizer(FileName, _logFileReader, CurrentColumnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + + if (newColumnizer != null) + { + _logger.Debug($"Picked new columnizer '{newColumnizer}'"); + + PreSelectColumnizer(newColumnizer); + } + } + } + } + } + + public void LoadFilesAsMulti(string[] fileNames, EncodingOptions encodingOptions) + { + _logger.Info("Loading given files as MultiFile:"); + + EnterLoadFileStatus(); + + foreach (string name in fileNames) + { + _logger.Info("File: {0}", name); + } + + if (_logFileReader != null) + { + _logFileReader.StopMonitoring(); + UnRegisterLogFileReaderEvents(); + } + + EncodingOptions = encodingOptions; + _columnCache = new ColumnCache(); + + _logFileReader = new(fileNames, EncodingOptions, Preferences.bufferCount, Preferences.linesPerBuffer, _multiFileOptions, PluginRegistry.PluginRegistry.Instance) + { + UseNewReader = !Preferences.useLegacyReader + }; + + RegisterLogFileReaderEvents(); + _logFileReader.StartMonitoring(); + FileName = fileNames[^1]; + _fileNames = fileNames; + IsMultiFile = true; + //if (this.isTempFile) + // this.Text = this.tempTitleName; + //else + // this.Text = Util.GetNameFromPath(this.FileName); + } + + public string SavePersistenceData(bool force) + { + if (!force) + { + if (!Preferences.saveSessions) + { + return null; + } + } + + if (IsTempFile || _isLoadError) + { + return null; + } + + try + { + PersistenceData persistenceData = GetPersistenceData(); + + if (ForcedPersistenceFileName == null) + { + return Persister.SavePersistenceData(FileName, persistenceData, Preferences); + } + + return Persister.SavePersistenceDataWithFixedName(ForcedPersistenceFileName, persistenceData); + } + catch (IOException ex) + { + _logger.Error(ex, "Error saving persistence: "); + } + catch (Exception e) + { + MessageBox.Show($"Unexpected error while saving persistence: {e.Message}"); + } + + return null; + } + + public PersistenceData GetPersistenceData() + { + PersistenceData persistenceData = new() + { + bookmarkList = _bookmarkProvider.BookmarkList, + rowHeightList = _rowHeightList, + multiFile = IsMultiFile, + multiFilePattern = _multiFileOptions.FormatPattern, + multiFileMaxDays = _multiFileOptions.MaxDayTry, + currentLine = dataGridView.CurrentCellAddress.Y, + firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex, + filterVisible = !splitContainerLogWindow.Panel2Collapsed, + filterAdvanced = !advancedFilterSplitContainer.Panel1Collapsed, + filterPosition = splitContainerLogWindow.SplitterDistance, + followTail = _guiStateArgs.FollowTail, + fileName = FileName, + tabName = Text, + sessionFileName = SessionFileName, + columnizerName = CurrentColumnizer.GetName(), + lineCount = _logFileReader.LineCount + }; + + _filterParams.IsFilterTail = filterTailCheckBox.Checked; // this option doesnt need a press on 'search' + + if (Preferences.saveFilters) + { + List filterList = [_filterParams]; + persistenceData.filterParamsList = filterList; + + foreach (FilterPipe filterPipe in _filterPipeList) + { + FilterTabData data = new() + { + PersistenceData = filterPipe.OwnLogWindow.GetPersistenceData(), + FilterParams = filterPipe.FilterParams + }; + persistenceData.filterTabDataList.Add(data); + } + } + + if (_currentHighlightGroup != null) + { + persistenceData.highlightGroupName = _currentHighlightGroup.GroupName; + } + + if (_fileNames != null && IsMultiFile) + { + persistenceData.multiFileNames.AddRange(_fileNames); + } + + //persistenceData.showBookmarkCommentColumn = this.bookmarkWindow.ShowBookmarkCommentColumn; + persistenceData.filterSaveListVisible = !highlightSplitContainer.Panel2Collapsed; + persistenceData.encoding = _logFileReader.CurrentEncoding; + + return persistenceData; + } + + public void Close(bool dontAsk) + { + Preferences.askForClose = !dontAsk; + Close(); + } + + public void CloseLogWindow() + { + StopTimespreadThread(); + StopTimestampSyncThread(); + StopLogEventWorkerThread(); + _shouldCancel = true; + + if (_logFileReader != null) + { + UnRegisterLogFileReaderEvents(); + _logFileReader.StopMonitoringAsync(); + //this.logFileReader.DeleteAllContent(); + } + + if (_isLoading) + { + _waitingForClose = true; + } + + if (IsTempFile) + { + _logger.Info("Deleting temp file {0}", FileName); + + try + { + File.Delete(FileName); + } + catch (IOException e) + { + _logger.Error(e, "Error while deleting temp file {0}: {1}", FileName, e); + } + } + + FilterPipe?.CloseAndDisconnect(); + DisconnectFilterPipes(); + } + + public void WaitForLoadingFinished() + { + _externaLoadingFinishedEvent.WaitOne(); + } + + public void ForceColumnizer(ILogLineColumnizer columnizer) + { + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + + _forcedColumnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); + SetColumnizer(_forcedColumnizer); + } + + public void ForceColumnizerForLoading(ILogLineColumnizer columnizer) + { + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + + _forcedColumnizerForLoading = ColumnizerPicker.CloneColumnizer(columnizer, directory); + } + + public void PreselectColumnizer(string columnizerName) + { + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + + ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + PreSelectColumnizer(ColumnizerPicker.CloneColumnizer(columnizer, directory)); + } + + public void ColumnizerConfigChanged() + { + SetColumnizerInternal(CurrentColumnizer); + } + + public void SetColumnizer(ILogLineColumnizer columnizer, BufferedDataGridView gridView) + { + PaintHelper.SetColumnizer(columnizer, gridView); + + gridView.Refresh(); + AutoResizeColumns(gridView); + ApplyFrozenState(gridView); + } + + public IColumn GetCellValue(int rowIndex, int columnIndex) + { + if (columnIndex == 1) + { + return new Column + { + FullValue = (rowIndex + 1).ToString() // line number + }; + } + + if (columnIndex == 0) // marker column + { + return Column.EmptyColumn; + } + + try + { + IColumnizedLogLine cols = GetColumnsForLine(rowIndex); + if (cols != null && cols.ColumnValues != null) + { + if (columnIndex <= cols.ColumnValues.Length + 1) + { + IColumn value = cols.ColumnValues[columnIndex - 2]; + + if (value != null && value.DisplayValue != null) + { + return value; + } + return value; + } + + if (columnIndex == 2) + { + return cols.ColumnValues[^1]; + } + + return Column.EmptyColumn; + } + } + catch + { + return Column.EmptyColumn; + } + + return Column.EmptyColumn; + } + + public void CellPainting(BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) + { + if (rowIndex < 0 || e.ColumnIndex < 0) + { + e.Handled = false; + return; + } + + ILogLine line = _logFileReader.GetLogLineWithWait(rowIndex).Result; + + if (line != null) + { + HighlightEntry entry = FindFirstNoWordMatchHilightEntry(line); + e.Graphics.SetClip(e.CellBounds); + + if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) + { + Color backColor = ColorMode.BackgroundColor; + + Brush brush; + + if (gridView.Focused) + { + brush = new SolidBrush(e.CellStyle.SelectionBackColor); + } + else + { + Color color = backColor; + brush = new SolidBrush(color); + } + + e.Graphics.FillRectangle(brush, e.CellBounds); + brush.Dispose(); + } + else + { + Color bgColor = ColorMode.DockBackgroundColor; + + if (!DebugOptions.DisableWordHighlight) + { + if (entry != null) + { + bgColor = entry.BackgroundColor; + } + } + else + { + if (entry != null) + { + bgColor = entry.BackgroundColor; + } + } + + e.CellStyle.BackColor = bgColor; + + e.PaintBackground(e.ClipBounds, false); + } + + if (DebugOptions.DisableWordHighlight) + { + e.PaintContent(e.CellBounds); + } + else + { + PaintCell(e, gridView, false, entry); + } + + if (e.ColumnIndex == 0) + { + if (_bookmarkProvider.IsBookmarkAtLine(rowIndex)) + { + Rectangle r; // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); + r = e.CellBounds; + r.Inflate(-2, -2); + Brush brush = new SolidBrush(BookmarkColor); + e.Graphics.FillRectangle(brush, r); + brush.Dispose(); + Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(rowIndex); + + if (bookmark.Text.Length > 0) + { + StringFormat format = new() + { + LineAlignment = StringAlignment.Center, + Alignment = StringAlignment.Center + }; + Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); + Font font = new("Courier New", Preferences.fontSize, FontStyle.Bold); + e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), + format); + font.Dispose(); + brush2.Dispose(); + } + } + } + + e.Paint(e.CellBounds, DataGridViewPaintParts.Border); + e.Handled = true; + } + } + + public void OnDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) + { + BufferedDataGridView gridView = (BufferedDataGridView)sender; + CellPainting(gridView, e.RowIndex, e); + } + + /// + /// Returns the first HilightEntry that matches the given line + /// + /// + /// + /// + public HighlightEntry FindHighlightEntry(ITextValue line, bool noWordMatches) + { + // first check the temp entries + lock (_tempHighlightEntryListLock) + { + foreach (HighlightEntry entry in _tempHighlightEntryList) + { + if (noWordMatches && entry.IsWordMatch) + { + continue; + } + if (CheckHighlightEntryMatch(entry, line)) + { + return entry; + } + } + } + + lock (_currentHighlightGroupLock) + { + foreach (HighlightEntry entry in _currentHighlightGroup.HighlightEntryList) + { + if (noWordMatches && entry.IsWordMatch) + { + continue; + } + if (CheckHighlightEntryMatch(entry, line)) + { + return entry; + } + } + return null; + } + } + + public IList FindHighlightMatches(ITextValue column) + { + IList resultList = new List(); + if (column != null) + { + lock (_currentHighlightGroupLock) + { + GetHighlightEntryMatches(column, _currentHighlightGroup.HighlightEntryList, resultList); + } + lock (_tempHighlightEntryList) + { + GetHighlightEntryMatches(column, _tempHighlightEntryList, resultList); + } + } + return resultList; + } + + public void FollowTailChanged(bool isChecked, bool byTrigger) + { + _guiStateArgs.FollowTail = isChecked; + + if (_guiStateArgs.FollowTail && _logFileReader != null) + { + if (dataGridView.RowCount >= _logFileReader.LineCount && _logFileReader.LineCount > 0) + { + dataGridView.FirstDisplayedScrollingRowIndex = _logFileReader.LineCount - 1; + } + } + BeginInvoke(new MethodInvoker(dataGridView.Refresh)); + //this.dataGridView.Refresh(); + _parentLogTabWin.FollowTailChanged(this, isChecked, byTrigger); + SendGuiStateUpdate(); + } + + public void GotoLine(int line) + { + if (line >= 0) + { + if (line < dataGridView.RowCount) + { + SelectLine(line, false, true); + } + else + { + SelectLine(dataGridView.RowCount - 1, false, true); + } + dataGridView.Focus(); + } + } + + public void StartSearch() + { + _guiStateArgs.MenuEnabled = false; + GuiStateUpdate(this, _guiStateArgs); + SearchParams searchParams = _parentLogTabWin.SearchParams; + + if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) + { + searchParams.CurrentLine = dataGridView.CurrentCellAddress.Y + 1; + } + else + { + searchParams.CurrentLine = dataGridView.CurrentCellAddress.Y - 1; + } + + _currentSearchParams = searchParams; // remember for async "not found" messages + + _isSearching = true; + _shouldCancel = false; + StatusLineText("Searching... Press ESC to cancel."); + + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = dataGridView.RowCount; + _progressEventArgs.Value = 0; + _progressEventArgs.Visible = true; + SendProgressBarUpdate(); + + Task.Run(() => Search(searchParams)).ContinueWith(SearchComplete); + + RemoveAllSearchHighlightEntries(); + AddSearchHitHighlightEntry(searchParams); + } + + private void SearchComplete(Task task) + { + if (Disposing) + { + return; + } + + try + { + Invoke(new MethodInvoker(ResetProgressBar)); + int line = task.Result; + _guiStateArgs.MenuEnabled = true; + GuiStateUpdate(this, _guiStateArgs); + if (line == -1) + { + return; + } + + dataGridView.Invoke(new SelectLineFx((line1, triggerSyncCall) => SelectLine(line1, triggerSyncCall, true)), line, true); + } + catch (Exception ex) // in the case the windows is already destroyed + { + _logger.Warn(ex); + } + } + + public void SelectLogLine(int line) + { + Invoke(new SelectLineFx((line1, triggerSyncCall) => SelectLine(line1, triggerSyncCall, true)), line, true); + } + + public void SelectAndEnsureVisible(int line, bool triggerSyncCall) + { + try + { + SelectLine(line, triggerSyncCall, false); + + //if (!this.dataGridView.CurrentRow.Displayed) + if (line < dataGridView.FirstDisplayedScrollingRowIndex || line > dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false)) + { + dataGridView.FirstDisplayedScrollingRowIndex = line; + for (int i = 0; i < 8 && dataGridView.FirstDisplayedScrollingRowIndex > 0 && line < dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false); ++i) + { + dataGridView.FirstDisplayedScrollingRowIndex -= 1; + } + + if (line >= dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false)) + { + dataGridView.FirstDisplayedScrollingRowIndex += 1; + } + } + dataGridView.CurrentCell = dataGridView.Rows[line].Cells[0]; + } + catch (Exception e) + { + // In rare situations there seems to be an invalid argument exceptions (or something like this). Concrete location isn't visible in stack + // trace because use of Invoke(). So catch it, and log (better than crashing the app). + _logger.Error(e); + } + } + + public void OnLogWindowKeyDown(object sender, KeyEventArgs e) + { + if (_isErrorShowing) + { + RemoveStatusLineError(); + } + + switch (e.KeyCode) + { + case Keys.F3 when _parentLogTabWin.SearchParams?.SearchText == null || _parentLogTabWin.SearchParams.SearchText.Length == 0: + { + return; + } + case Keys.F3: + { + _parentLogTabWin.SearchParams.IsFindNext = true; + _parentLogTabWin.SearchParams.IsShiftF3Pressed = (e.Modifiers & Keys.Shift) == Keys.Shift; + StartSearch(); + break; + } + case Keys.Escape: + { + if (_isSearching) + { + _shouldCancel = true; + } + + FireCancelHandlers(); + RemoveAllSearchHighlightEntries(); + break; + } + case Keys.E when (e.Modifiers & Keys.Control) == Keys.Control: + { + StartEditMode(); + + break; + } + case Keys.Down when e.Modifiers == Keys.Alt: + { + int newLine = _logFileReader.GetNextMultiFileLine(dataGridView.CurrentCellAddress.Y); + + if (newLine != -1) + { + SelectLine(newLine, false, true); + } + + e.Handled = true; + + break; + } + case Keys.Up when e.Modifiers == Keys.Alt: + { + int newLine = _logFileReader.GetPrevMultiFileLine(dataGridView.CurrentCellAddress.Y); + + if (newLine != -1) + { + SelectLine(newLine - 1, false, true); + } + + e.Handled = true; + + break; + } + case Keys.Enter when dataGridView.Focused: + { + ChangeRowHeight(e.Shift); + e.Handled = true; + + break; + } + case Keys.Back when dataGridView.Focused: + { + ChangeRowHeight(true); + e.Handled = true; + + break; + } + case Keys.PageUp when e.Modifiers == Keys.Alt: + { + SelectPrevHighlightLine(); + e.Handled = true; + + break; + } + case Keys.PageDown when e.Modifiers == Keys.Alt: + { + SelectNextHighlightLine(); + e.Handled = true; + + break; + } + case Keys.T when (e.Modifiers & Keys.Control) == Keys.Control && (e.Modifiers & Keys.Shift) == Keys.Shift: + { + FilterToTab(); + break; + } + } + } + + public void AddBookmarkOverlays() + { + const int OVERSCAN = 20; + + int firstLine = dataGridView.FirstDisplayedScrollingRowIndex; + if (firstLine < 0) + { + return; + } + + firstLine -= OVERSCAN; + if (firstLine < 0) + { + firstLine = 0; + } + + int oversizeCount = OVERSCAN; + + for (int i = firstLine; i < dataGridView.RowCount; ++i) + { + if (!dataGridView.Rows[i].Displayed && i > dataGridView.FirstDisplayedScrollingRowIndex) + { + if (oversizeCount-- < 0) + { + break; + } + } + if (_bookmarkProvider.IsBookmarkAtLine(i)) + { + Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(i); + if (bookmark.Text.Length > 0) + { + //BookmarkOverlay overlay = new BookmarkOverlay(); + BookmarkOverlay overlay = bookmark.Overlay; + overlay.Bookmark = bookmark; + + Rectangle r; + if (dataGridView.Rows[i].Displayed) + { + r = dataGridView.GetCellDisplayRectangle(0, i, false); + } + else + { + r = dataGridView.GetCellDisplayRectangle(0, dataGridView.FirstDisplayedScrollingRowIndex, false); + //int count = i - this.dataGridView.FirstDisplayedScrollingRowIndex; + int heightSum = 0; + if (dataGridView.FirstDisplayedScrollingRowIndex < i) + { + for (int rn = dataGridView.FirstDisplayedScrollingRowIndex + 1; rn < i; ++rn) + { + //Rectangle rr = this.dataGridView.GetCellDisplayRectangle(0, rn, false); + //heightSum += rr.Height; + heightSum += GetRowHeight(rn); + } + r.Offset(0, r.Height + heightSum); + } + else + { + for (int rn = dataGridView.FirstDisplayedScrollingRowIndex + 1; rn > i; --rn) + { + //Rectangle rr = this.dataGridView.GetCellDisplayRectangle(0, rn, false); + //heightSum += rr.Height; + heightSum += GetRowHeight(rn); + } + r.Offset(0, -(r.Height + heightSum)); + } + //r.Offset(0, this.dataGridView.DisplayRectangle.Height); + } + if (_logger.IsDebugEnabled) + { + _logger.Debug("AddBookmarkOverlay() r.Location={0}, width={1}, scroll_offset={2}", r.Location.X, r.Width, dataGridView.HorizontalScrollingOffset); + } + overlay.Position = r.Location - new Size(dataGridView.HorizontalScrollingOffset, 0); + overlay.Position += new Size(10, r.Height / 2); + dataGridView.AddOverlay(overlay); + } + } + } + } + + public void ToggleBookmark() + { + BufferedDataGridView gridView; + int lineNum; + + if (filterGridView.Focused) + { + gridView = filterGridView; + if (gridView.CurrentCellAddress.Y == -1) + { + return; + } + + lineNum = _filterResultList[gridView.CurrentCellAddress.Y]; + } + else + { + gridView = dataGridView; + if (gridView.CurrentCellAddress.Y == -1) + { + return; + } + lineNum = dataGridView.CurrentCellAddress.Y; + } + + ToggleBookmark(lineNum); + } + + public void ToggleBookmark(int lineNum) + { + if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) + { + Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); + + if (string.IsNullOrEmpty(bookmark.Text) == false) + { + if (DialogResult.No == MessageBox.Show("There's a comment attached to the bookmark. Really remove the bookmark?", "LogExpert", MessageBoxButtons.YesNo)) + { + return; + } + } + _bookmarkProvider.RemoveBookmarkForLine(lineNum); + } + else + { + _bookmarkProvider.AddBookmark(new Bookmark(lineNum)); + } + dataGridView.Refresh(); + filterGridView.Refresh(); + OnBookmarkAdded(); + } + + public void SetBookmarkFromTrigger(int lineNum, string comment) + { + lock (_bookmarkLock) + { + ILogLine line = _logFileReader.GetLogLine(lineNum); + if (line == null) + { + return; + } + ParamParser paramParser = new ParamParser(comment); + try + { + comment = paramParser.ReplaceParams(line, lineNum, FileName); + } + catch (ArgumentException) + { + // occurs on invalid regex + } + if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) + { + _bookmarkProvider.RemoveBookmarkForLine(lineNum); + } + _bookmarkProvider.AddBookmark(new Bookmark(lineNum, comment)); + OnBookmarkAdded(); + } + } + + public void JumpNextBookmark() + { + if (_bookmarkProvider.Bookmarks.Count > 0) + { + if (filterGridView.Focused) + { + int index = FindNextBookmarkIndex(_filterResultList[filterGridView.CurrentCellAddress.Y]); + int startIndex = index; + bool wrapped = false; + while (true) + { + int lineNum = _bookmarkProvider.Bookmarks[index].LineNum; + if (_filterResultList.Contains(lineNum)) + { + int filterLine = _filterResultList.IndexOf(lineNum); + filterGridView.Rows[filterLine].Selected = true; + filterGridView.CurrentCell = filterGridView.Rows[filterLine].Cells[0]; + break; + } + index++; + if (index > _bookmarkProvider.Bookmarks.Count - 1) + { + index = 0; + wrapped = true; + } + if (index >= startIndex && wrapped) + { + break; + } + } + } + else + { + int index = FindNextBookmarkIndex(dataGridView.CurrentCellAddress.Y); + if (index > _bookmarkProvider.Bookmarks.Count - 1) + { + index = 0; + } + + int lineNum = _bookmarkProvider.Bookmarks[index].LineNum; + SelectLine(lineNum, true, true); + } + } + } + + public void JumpPrevBookmark() + { + if (_bookmarkProvider.Bookmarks.Count > 0) + { + if (filterGridView.Focused) + { + //int index = this.bookmarkList.BinarySearch(this.filterResultList[this.filterGridView.CurrentCellAddress.Y]); + //if (index < 0) + // index = ~index; + //index--; + int index = FindPrevBookmarkIndex(_filterResultList[filterGridView.CurrentCellAddress.Y]); + if (index < 0) + { + index = _bookmarkProvider.Bookmarks.Count - 1; + } + int startIndex = index; + bool wrapped = false; + while (true) + { + int lineNum = _bookmarkProvider.Bookmarks[index].LineNum; + if (_filterResultList.Contains(lineNum)) + { + int filterLine = _filterResultList.IndexOf(lineNum); + filterGridView.Rows[filterLine].Selected = true; + filterGridView.CurrentCell = filterGridView.Rows[filterLine].Cells[0]; + break; + } + index--; + if (index < 0) + { + index = _bookmarkProvider.Bookmarks.Count - 1; + wrapped = true; + } + if (index <= startIndex && wrapped) + { + break; + } + } + } + else + { + int index = FindPrevBookmarkIndex(dataGridView.CurrentCellAddress.Y); + if (index < 0) + { + index = _bookmarkProvider.Bookmarks.Count - 1; + } + + int lineNum = _bookmarkProvider.Bookmarks[index].LineNum; + SelectLine(lineNum, false, true); + } + } + } + + public void DeleteBookmarks(List lineNumList) + { + bool bookmarksPresent = false; + foreach (int lineNum in lineNumList) + { + if (lineNum != -1) + { + if (_bookmarkProvider.IsBookmarkAtLine(lineNum) && + _bookmarkProvider.GetBookmarkForLine(lineNum).Text.Length > 0) + { + bookmarksPresent = true; + } + } + } + if (bookmarksPresent) + { + if ( + MessageBox.Show("There are some comments in the bookmarks. Really remove bookmarks?", "LogExpert", + MessageBoxButtons.YesNo) == DialogResult.No) + { + return; + } + } + _bookmarkProvider.RemoveBookmarksForLines(lineNumList); + OnBookmarkRemoved(); + } + + public void SetTimeshiftValue(string value) + { + _guiStateArgs.TimeshiftText = value; + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + try + { + if (_guiStateArgs.TimeshiftEnabled) + { + try + { + string text = _guiStateArgs.TimeshiftText; + if (text.StartsWith("+")) + { + text = text.Substring(1); + } + TimeSpan timeSpan = TimeSpan.Parse(text); + int diff = (int)(timeSpan.Ticks / TimeSpan.TicksPerMillisecond); + CurrentColumnizer.SetTimeOffset(diff); + } + catch (Exception) + { + CurrentColumnizer.SetTimeOffset(0); + } + } + else + { + CurrentColumnizer.SetTimeOffset(0); + } + dataGridView.Refresh(); + filterGridView.Refresh(); + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + SetTimestampLimits(); + SyncTimestampDisplay(); + } + } + catch (FormatException ex) + { + _logger.Error(ex); + } + } + } + + public void ToggleFilterPanel() + { + splitContainerLogWindow.Panel2Collapsed = !splitContainerLogWindow.Panel2Collapsed; + if (!splitContainerLogWindow.Panel2Collapsed) + { + filterComboBox.Focus(); + } + else + { + dataGridView.Focus(); + } + } + + public void LogWindowActivated() + { + if (_guiStateArgs.FollowTail && !_isDeadFile) + { + OnTailFollowed(EventArgs.Empty); + } + if (Preferences.timestampControl) + { + SetTimestampLimits(); + SyncTimestampDisplay(); + } + dataGridView.Focus(); + + SendGuiStateUpdate(); + SendStatusLineUpdate(); + SendProgressBarUpdate(); + } + + public void SetCellSelectionMode(bool isCellMode) + { + if (isCellMode) + { + //possible performance issue, see => https://docs.microsoft.com/en-us/dotnet/desktop/winforms/controls/best-practices-for-scaling-the-windows-forms-datagridview-control?view=netframeworkdesktop-4.8#using-the-selected-cells-rows-and-columns-collections-efficiently + dataGridView.SelectionMode = DataGridViewSelectionMode.CellSelect; + } + else + { + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + } + + _guiStateArgs.CellSelectMode = isCellMode; + } + + public void TimeshiftEnabled(bool isEnabled, string shiftValue) + { + _guiStateArgs.TimeshiftEnabled = isEnabled; + SetTimestampLimits(); + SetTimeshiftValue(shiftValue); + } + + public void CopyMarkedLinesToTab() + { + if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) + { + List lineNumList = new List(); + foreach (DataGridViewRow row in dataGridView.SelectedRows) + { + if (row.Index != -1) + { + lineNumList.Add(row.Index); + } + } + lineNumList.Sort(); + // create dummy FilterPipe for connecting line numbers to original window + // setting IsStopped to true prevents further filter processing + FilterPipe pipe = new FilterPipe(new FilterParams(), this) + { + IsStopped = true + }; + WritePipeToTab(pipe, lineNumList, Text + "->C", null); + } + else + { + string fileName = Path.GetTempFileName(); + FileStream fStream = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.Read); + StreamWriter writer = new StreamWriter(fStream, Encoding.Unicode); + + DataObject data = dataGridView.GetClipboardContent(); + string text = data.GetText(TextDataFormat.Text); + writer.Write(text); + + writer.Close(); + string title = Util.GetNameFromPath(FileName) + "->Clip"; + _parentLogTabWin.AddTempFileTab(fileName, title); + } + } + + /// + /// Change the file encoding. May force a reload if byte count ot preamble lenght differs from previous used encoding. + /// + /// + public void ChangeEncoding(Encoding encoding) + { + _logFileReader.ChangeEncoding(encoding); + EncodingOptions.Encoding = encoding; + if (_guiStateArgs.CurrentEncoding.IsSingleByte != encoding.IsSingleByte || + _guiStateArgs.CurrentEncoding.GetPreamble().Length != encoding.GetPreamble().Length) + { + Reload(); + } + else + { + dataGridView.Refresh(); + SendGuiStateUpdate(); + } + _guiStateArgs.CurrentEncoding = _logFileReader.CurrentEncoding; + } + + public void Reload() + { + SavePersistenceData(false); + + _reloadMemento = new ReloadMemento + { + CurrentLine = dataGridView.CurrentCellAddress.Y, + FirstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex + }; + _forcedColumnizerForLoading = CurrentColumnizer; + + if (_fileNames == null || !IsMultiFile) + { + LoadFile(FileName, EncodingOptions); + } + else + { + LoadFilesAsMulti(_fileNames, EncodingOptions); + } + //if (currentLine < this.dataGridView.RowCount && currentLine >= 0) + // this.dataGridView.CurrentCell = this.dataGridView.Rows[currentLine].Cells[0]; + //if (firstDisplayedLine < this.dataGridView.RowCount && firstDisplayedLine >= 0) + // this.dataGridView.FirstDisplayedScrollingRowIndex = firstDisplayedLine; + + //if (this.filterTailCheckBox.Checked) + //{ + // _logger.logInfo("Refreshing filter view because of reload."); + // FilterSearch(); + //} + } + + public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags) + { + if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors) + { + NormalFont = new Font(new FontFamily(newPreferences.fontName), newPreferences.fontSize); + BoldFont = new Font(NormalFont, FontStyle.Bold); + MonospacedFont = new Font("Courier New", Preferences.fontSize, FontStyle.Bold); + + int lineSpacing = NormalFont.FontFamily.GetLineSpacing(FontStyle.Regular); + float lineSpacingPixel = NormalFont.Size * lineSpacing / NormalFont.FontFamily.GetEmHeight(FontStyle.Regular); + + dataGridView.DefaultCellStyle.Font = NormalFont; + filterGridView.DefaultCellStyle.Font = NormalFont; + _lineHeight = NormalFont.Height + 4; + dataGridView.RowTemplate.Height = NormalFont.Height + 4; + + ShowBookmarkBubbles = Preferences.showBubbles; + + ApplyDataGridViewPrefs(dataGridView, newPreferences); + ApplyDataGridViewPrefs(filterGridView, newPreferences); + + if (Preferences.timestampControl) + { + SetTimestampLimits(); + SyncTimestampDisplay(); + } + if (isLoadTime) + { + filterTailCheckBox.Checked = Preferences.filterTail; + syncFilterCheckBox.Checked = Preferences.filterSync; + //this.FollowTailChanged(this.Preferences.followTail, false); + } + + _timeSpreadCalc.TimeMode = Preferences.timeSpreadTimeMode; + timeSpreadingControl.ForeColor = Preferences.timeSpreadColor; + timeSpreadingControl.ReverseAlpha = Preferences.reverseAlpha; + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + timeSpreadingControl.Invoke(new MethodInvoker(timeSpreadingControl.Refresh)); + ShowTimeSpread(Preferences.showTimeSpread); + } + ToggleColumnFinder(Preferences.showColumnFinder, false); + } + + if ((flags & SettingsFlags.FilterList) == SettingsFlags.FilterList) + { + HandleChangedFilterList(); + } + + if ((flags & SettingsFlags.FilterHistory) == SettingsFlags.FilterHistory) + { + UpdateFilterHistoryFromSettings(); + + if (isLoadTime) + { + AutoResizeFilterBox(); + } + } + } + + public bool ScrollToTimestamp(DateTime timestamp, bool roundToSeconds, bool triggerSyncCall) + { + if (InvokeRequired) + { + BeginInvoke(new ScrollToTimestampFx(ScrollToTimestampWorker), timestamp, roundToSeconds, triggerSyncCall); + return true; + } + + return ScrollToTimestampWorker(timestamp, roundToSeconds, triggerSyncCall); + } + + public bool ScrollToTimestampWorker(DateTime timestamp, bool roundToSeconds, bool triggerSyncCall) + { + bool hasScrolled = false; + if (!CurrentColumnizer.IsTimeshiftImplemented() || dataGridView.RowCount == 0) + { + return false; + } + + //this.Cursor = Cursors.WaitCursor; + int currentLine = dataGridView.CurrentCellAddress.Y; + if (currentLine < 0 || currentLine >= dataGridView.RowCount) + { + currentLine = 0; + } + int foundLine = FindTimestampLine(currentLine, timestamp, roundToSeconds); + if (foundLine >= 0) + { + SelectAndEnsureVisible(foundLine, triggerSyncCall); + hasScrolled = true; + } + //this.Cursor = Cursors.Default; + return hasScrolled; + } + + public int FindTimestampLine(int lineNum, DateTime timestamp, bool roundToSeconds) + { + int foundLine = + FindTimestampLine_Internal(lineNum, 0, dataGridView.RowCount - 1, timestamp, roundToSeconds); + if (foundLine >= 0) + { + // go backwards to the first occurence of the hit + DateTime foundTimestamp = GetTimestampForLine(ref foundLine, roundToSeconds); + while (foundTimestamp.CompareTo(timestamp) == 0 && foundLine >= 0) + { + foundLine--; + foundTimestamp = GetTimestampForLine(ref foundLine, roundToSeconds); + } + if (foundLine < 0) + { + return 0; + } + + foundLine++; + GetTimestampForLineForward(ref foundLine, roundToSeconds); // fwd to next valid timestamp + return foundLine; + } + return -foundLine; + } + + public int FindTimestampLine_Internal(int lineNum, int rangeStart, int rangeEnd, DateTime timestamp, + bool roundToSeconds) + { + _logger.Debug("FindTimestampLine_Internal(): timestamp={0}, lineNum={1}, rangeStart={2}, rangeEnd={3}", timestamp, lineNum, rangeStart, rangeEnd); + int refLine = lineNum; + DateTime currentTimestamp = GetTimestampForLine(ref refLine, roundToSeconds); + if (currentTimestamp.CompareTo(timestamp) == 0) + { + return lineNum; + } + if (timestamp < currentTimestamp) + { + //rangeStart = rangeStart; + rangeEnd = lineNum; + } + else + { + rangeStart = lineNum; + //rangeEnd = rangeEnd; + } + + if (rangeEnd - rangeStart <= 0) + { + return -lineNum; + } + + lineNum = (rangeEnd - rangeStart) / 2 + rangeStart; + // prevent endless loop + if (rangeEnd - rangeStart < 2) + { + currentTimestamp = GetTimestampForLine(ref rangeStart, roundToSeconds); + if (currentTimestamp.CompareTo(timestamp) == 0) + { + return rangeStart; + } + currentTimestamp = GetTimestampForLine(ref rangeEnd, roundToSeconds); + if (currentTimestamp.CompareTo(timestamp) == 0) + { + return rangeEnd; + } + return -lineNum; + } + + return FindTimestampLine_Internal(lineNum, rangeStart, rangeEnd, timestamp, roundToSeconds); + } + + /** + * Get the timestamp for the given line number. If the line + * has no timestamp, the previous line will be checked until a + * timestamp is found. + */ + + public DateTime GetTimestampForLine(ref int lineNum, bool roundToSeconds) + { + lock (_currentColumnizerLock) + { + if (!CurrentColumnizer.IsTimeshiftImplemented()) + { + return DateTime.MinValue; + } + _logger.Debug("GetTimestampForLine({0}) enter", lineNum); + DateTime timeStamp = DateTime.MinValue; + bool lookBack = false; + if (lineNum >= 0 && lineNum < dataGridView.RowCount) + { + while (timeStamp.CompareTo(DateTime.MinValue) == 0 && lineNum >= 0) + { + if (_isTimestampDisplaySyncing && _shouldTimestampDisplaySyncingCancel) + { + return DateTime.MinValue; + } + lookBack = true; + ILogLine logLine = _logFileReader.GetLogLine(lineNum); + if (logLine == null) + { + return DateTime.MinValue; + } + ColumnizerCallbackObject.LineNum = lineNum; + timeStamp = CurrentColumnizer.GetTimestamp(ColumnizerCallbackObject, logLine); + if (roundToSeconds) + { + timeStamp = timeStamp.Subtract(TimeSpan.FromMilliseconds(timeStamp.Millisecond)); + } + lineNum--; + } + } + if (lookBack) + { + lineNum++; + } + _logger.Debug("GetTimestampForLine() leave with lineNum={0}", lineNum); + return timeStamp; + } + } + + /** + * Get the timestamp for the given line number. If the line + * has no timestamp, the next line will be checked until a + * timestamp is found. + */ + + public DateTime GetTimestampForLineForward(ref int lineNum, bool roundToSeconds) + { + lock (_currentColumnizerLock) + { + if (!CurrentColumnizer.IsTimeshiftImplemented()) + { + return DateTime.MinValue; + } + + DateTime timeStamp = DateTime.MinValue; + bool lookFwd = false; + if (lineNum >= 0 && lineNum < dataGridView.RowCount) + { + while (timeStamp.CompareTo(DateTime.MinValue) == 0 && lineNum < dataGridView.RowCount) + { + lookFwd = true; + ILogLine logLine = _logFileReader.GetLogLine(lineNum); + if (logLine == null) + { + timeStamp = DateTime.MinValue; + break; + } + timeStamp = CurrentColumnizer.GetTimestamp(ColumnizerCallbackObject, logLine); + if (roundToSeconds) + { + timeStamp = timeStamp.Subtract(TimeSpan.FromMilliseconds(timeStamp.Millisecond)); + } + lineNum++; + } + } + if (lookFwd) + { + lineNum--; + } + return timeStamp; + } + } + + public void AppFocusLost() + { + InvalidateCurrentRow(dataGridView); + } + + public void AppFocusGained() + { + InvalidateCurrentRow(dataGridView); + } + + public ILogLine GetCurrentLine() + { + if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index != -1) + { + return _logFileReader.GetLogLine(dataGridView.CurrentRow.Index); + } + return null; + } + + public ILogLine GetLine(int lineNum) + { + if (lineNum < 0 || _logFileReader == null || lineNum >= _logFileReader.LineCount) + { + return null; + } + return _logFileReader.GetLogLine(lineNum); + } + + public int GetCurrentLineNum() + { + if (dataGridView.CurrentRow == null) + { + return -1; + } + return dataGridView.CurrentRow.Index; + } + + public int GetRealLineNum() + { + int lineNum = GetCurrentLineNum(); + if (lineNum == -1) + { + return -1; + } + return _logFileReader.GetRealLineNumForVirtualLineNum(lineNum); + } + + public ILogFileInfo GetCurrentFileInfo() + { + if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index != -1) + { + return _logFileReader.GetLogFileInfoForLine(dataGridView.CurrentRow.Index); + } + return null; + } + + /// + /// zero-based + /// + /// + /// + public string GetCurrentFileName(int lineNum) + { + return _logFileReader.GetLogFileNameForLine(lineNum); + } + + // =============== end of bookmark stuff =================================== + + public void ShowLineColumn(bool show) + { + dataGridView.Columns[1].Visible = show; + filterGridView.Columns[1].Visible = show; + } + + // ================================================================= + // Pattern statistics + // ================================================================= + + public void PatternStatistic() + { + InitPatternWindow(); + } + + public void PatternStatisticSelectRange(PatternArgs patternArgs) + { + if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) + { + List lineNumList = []; + foreach (DataGridViewRow row in dataGridView.SelectedRows) + { + if (row.Index != -1) + { + lineNumList.Add(row.Index); + } + } + lineNumList.Sort(); + patternArgs.StartLine = lineNumList[0]; + patternArgs.EndLine = lineNumList[^1]; + } + else + { + if (dataGridView.CurrentCellAddress.Y != -1) + { + patternArgs.StartLine = dataGridView.CurrentCellAddress.Y; + } + else + { + patternArgs.StartLine = 0; + } + patternArgs.EndLine = dataGridView.RowCount - 1; + } + } + + public void PatternStatistic(PatternArgs patternArgs) + { + PatternStatisticFx fx = new PatternStatisticFx(TestStatistic); + fx.BeginInvoke(patternArgs, null, null); + } + + public void ExportBookmarkList() + { + SaveFileDialog dlg = new() + { + Title = "Choose a file to save bookmarks into", + AddExtension = true, + DefaultExt = "csv", + Filter = "CSV file (*.csv)|*.csv|Bookmark file (*.bmk)|*.bmk", + FilterIndex = 1, + FileName = Path.GetFileNameWithoutExtension(FileName) + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + try + { + BookmarkExporter.ExportBookmarkList(_bookmarkProvider.BookmarkList, FileName, + dlg.FileName); + } + catch (IOException e) + { + _logger.Error(e); + MessageBox.Show("Error while exporting bookmark list: " + e.Message, "LogExpert"); + } + } + } + + public void ImportBookmarkList() + { + OpenFileDialog dlg = new() + { + Title = "Choose a file to load bookmarks from", + AddExtension = true, + DefaultExt = "csv", + Filter = "CSV file (*.csv)|*.csv|Bookmark file (*.bmk)|*.bmk", + FilterIndex = 1, + FileName = Path.GetFileNameWithoutExtension(FileName) + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + try + { + // add to the existing bookmarks + SortedList newBookmarks = []; + BookmarkExporter.ImportBookmarkList(FileName, dlg.FileName, newBookmarks); + + // Add (or replace) to existing bookmark list + bool bookmarkAdded = false; + foreach (Bookmark b in newBookmarks.Values) + { + if (!_bookmarkProvider.BookmarkList.ContainsKey(b.LineNum)) + { + _bookmarkProvider.BookmarkList.Add(b.LineNum, b); + bookmarkAdded = true; // refresh the list only once at the end + } + else + { + Bookmark existingBookmark = _bookmarkProvider.BookmarkList[b.LineNum]; + existingBookmark.Text = + b.Text; // replace existing bookmark for that line, preserving the overlay + OnBookmarkTextChanged(b); + } + } + + // Refresh the lists + if (bookmarkAdded) + { + OnBookmarkAdded(); + } + dataGridView.Refresh(); + filterGridView.Refresh(); + } + catch (IOException e) + { + _logger.Error(e); + MessageBox.Show($"Error while importing bookmark list: {e.Message}", "LogExpert"); + } + } + } + + public bool IsAdvancedOptionActive() + { + return rangeCheckBox.Checked || + fuzzyKnobControl.Value > 0 || + filterKnobBackSpread.Value > 0 || + filterKnobForeSpread.Value > 0 || + invertFilterCheckBox.Checked || + columnRestrictCheckBox.Checked; + } + + public void HandleChangedFilterList() + { + Invoke(new MethodInvoker(HandleChangedFilterListWorker)); + } + + public void HandleChangedFilterListWorker() + { + int index = filterListBox.SelectedIndex; + filterListBox.Items.Clear(); + foreach (FilterParams filterParam in ConfigManager.Settings.filterList) + { + filterListBox.Items.Add(filterParam); + } + filterListBox.Refresh(); + if (index >= 0 && index < filterListBox.Items.Count) + { + filterListBox.SelectedIndex = index; + } + filterOnLoadCheckBox.Checked = Preferences.isFilterOnLoad; + hideFilterListOnLoadCheckBox.Checked = Preferences.isAutoHideFilterList; + } + + public void SetCurrentHighlightGroup(string groupName) + { + _guiStateArgs.HighlightGroupName = groupName; + lock (_currentHighlightGroupLock) + { + _currentHighlightGroup = _parentLogTabWin.FindHighlightGroup(groupName); + if (_currentHighlightGroup == null) + { + if (_parentLogTabWin.HighlightGroupList.Count > 0) + { + _currentHighlightGroup = _parentLogTabWin.HighlightGroupList[0]; + } + else + { + _currentHighlightGroup = new HighlightGroup(); + } + } + _guiStateArgs.HighlightGroupName = _currentHighlightGroup.GroupName; + } + SendGuiStateUpdate(); + BeginInvoke(new MethodInvoker(RefreshAllGrids)); + } + + public void SwitchMultiFile(bool enabled) + { + IsMultiFile = enabled; + Reload(); + } + + public void AddOtherWindowToTimesync(LogWindow other) + { + if (other.IsTimeSynced) + { + if (IsTimeSynced) + { + other.FreeFromTimeSync(); + AddSlaveToTimesync(other); + } + else + { + AddToTimeSync(other); + } + } + else + { + AddSlaveToTimesync(other); + } + } + + public void AddToTimeSync(LogWindow master) + { + _logger.Info("Syncing window for {0} to {1}", Util.GetNameFromPath(FileName), Util.GetNameFromPath(master.FileName)); + lock (_timeSyncListLock) + { + if (IsTimeSynced && master.TimeSyncList != TimeSyncList) + // already synced but master has different sync list + { + FreeFromTimeSync(); + } + TimeSyncList = master.TimeSyncList; + TimeSyncList.AddWindow(this); + ScrollToTimestamp(TimeSyncList.CurrentTimestamp, false, false); + } + OnSyncModeChanged(); + } + + public void FreeFromTimeSync() + { + lock (_timeSyncListLock) + { + if (TimeSyncList != null) + { + _logger.Info("De-Syncing window for {0}", Util.GetNameFromPath(FileName)); + TimeSyncList.WindowRemoved -= OnTimeSyncListWindowRemoved; + TimeSyncList.RemoveWindow(this); + TimeSyncList = null; + } + } + OnSyncModeChanged(); + } + + public void RefreshLogView() + { + RefreshAllGrids(); + } + + #endregion + } +} diff --git a/src/LogExpert/Controls/PatternWindow.Designer.cs b/src/Logexpert.UI/Controls/LogWindow/PatternWindow.Designer.cs similarity index 97% rename from src/LogExpert/Controls/PatternWindow.Designer.cs rename to src/Logexpert.UI/Controls/LogWindow/PatternWindow.Designer.cs index 7b211e99..bd148048 100644 --- a/src/LogExpert/Controls/PatternWindow.Designer.cs +++ b/src/Logexpert.UI/Controls/LogWindow/PatternWindow.Designer.cs @@ -1,430 +1,430 @@ -namespace LogExpert.Controls -{ - partial class PatternWindow - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PatternWindow)); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.panel3 = new System.Windows.Forms.Panel(); - this.splitContainer2 = new System.Windows.Forms.SplitContainer(); - this.panel2 = new System.Windows.Forms.Panel(); - this.blockCountLabel = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.panel1 = new System.Windows.Forms.Panel(); - this.label2 = new System.Windows.Forms.Label(); - this.blockLinesLabel = new System.Windows.Forms.Label(); - this.panel4 = new System.Windows.Forms.Panel(); - this.setRangeButton = new System.Windows.Forms.Button(); - this.label7 = new System.Windows.Forms.Label(); - this.recalcButton = new System.Windows.Forms.Button(); - this.label6 = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.rangeLabel = new System.Windows.Forms.Label(); - this.weigthKnobControl = new KnobControl(); - this.maxMissesKnobControl = new KnobControl(); - this.maxDiffKnobControl = new KnobControl(); - this.fuzzyKnobControl = new KnobControl(); - this.patternHitsDataGridView = new LogExpert.Dialogs.BufferedDataGridView(); - this.contentDataGridView = new LogExpert.Dialogs.BufferedDataGridView(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); - this.splitContainer2.Panel1.SuspendLayout(); - this.splitContainer2.Panel2.SuspendLayout(); - this.splitContainer2.SuspendLayout(); - this.panel2.SuspendLayout(); - this.panel1.SuspendLayout(); - this.panel4.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.patternHitsDataGridView)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.contentDataGridView)).BeginInit(); - this.SuspendLayout(); - // - // splitContainer1 - // - this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.splitContainer1.BackColor = System.Drawing.SystemColors.Control; - this.splitContainer1.IsSplitterFixed = true; - this.splitContainer1.Location = new System.Drawing.Point(2, 1); - this.splitContainer1.Name = "splitContainer1"; - this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.panel3); - this.splitContainer1.Panel1Collapsed = true; - this.splitContainer1.Panel1MinSize = 0; - // - // splitContainer1.Panel2 - // - this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); - this.splitContainer1.Panel2MinSize = 0; - this.splitContainer1.Size = new System.Drawing.Size(795, 106); - this.splitContainer1.SplitterDistance = 106; - this.splitContainer1.TabIndex = 3; - // - // panel3 - // - this.panel3.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel3.Location = new System.Drawing.Point(0, 0); - this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(150, 106); - this.panel3.TabIndex = 1; - // - // splitContainer2 - // - this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer2.Location = new System.Drawing.Point(0, 0); - this.splitContainer2.Name = "splitContainer2"; - // - // splitContainer2.Panel1 - // - this.splitContainer2.Panel1.Controls.Add(this.panel2); - // - // splitContainer2.Panel2 - // - this.splitContainer2.Panel2.Controls.Add(this.panel1); - this.splitContainer2.Size = new System.Drawing.Size(795, 106); - this.splitContainer2.SplitterDistance = 294; - this.splitContainer2.TabIndex = 2; - // - // panel2 - // - this.panel2.Controls.Add(this.blockCountLabel); - this.panel2.Controls.Add(this.label1); - this.panel2.Controls.Add(this.patternHitsDataGridView); - this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel2.Location = new System.Drawing.Point(0, 0); - this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(294, 106); - this.panel2.TabIndex = 2; - // - // blockCountLabel - // - this.blockCountLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.blockCountLabel.AutoSize = true; - this.blockCountLabel.Location = new System.Drawing.Point(184, 89); - this.blockCountLabel.Name = "blockCountLabel"; - this.blockCountLabel.Size = new System.Drawing.Size(13, 13); - this.blockCountLabel.TabIndex = 3; - this.blockCountLabel.Text = "0"; - // - // label1 - // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(0, 89); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(175, 13); - this.label1.TabIndex = 2; - this.label1.Text = "Number of blocks (pattern variants):"; - // - // panel1 - // - this.panel1.Controls.Add(this.label2); - this.panel1.Controls.Add(this.blockLinesLabel); - this.panel1.Controls.Add(this.contentDataGridView); - this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(497, 106); - this.panel1.TabIndex = 1; - // - // label2 - // - this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(3, 89); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(61, 13); - this.label2.TabIndex = 2; - this.label2.Text = "Block lines:"; - // - // blockLinesLabel - // - this.blockLinesLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.blockLinesLabel.Location = new System.Drawing.Point(70, 89); - this.blockLinesLabel.Name = "blockLinesLabel"; - this.blockLinesLabel.Size = new System.Drawing.Size(69, 13); - this.blockLinesLabel.TabIndex = 1; - this.blockLinesLabel.Text = "0"; - // - // panel4 - // - this.panel4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.panel4.Controls.Add(this.setRangeButton); - this.panel4.Controls.Add(this.label7); - this.panel4.Controls.Add(this.recalcButton); - this.panel4.Controls.Add(this.weigthKnobControl); - this.panel4.Controls.Add(this.label6); - this.panel4.Controls.Add(this.maxMissesKnobControl); - this.panel4.Controls.Add(this.label5); - this.panel4.Controls.Add(this.maxDiffKnobControl); - this.panel4.Controls.Add(this.label4); - this.panel4.Controls.Add(this.fuzzyKnobControl); - this.panel4.Location = new System.Drawing.Point(3, 106); - this.panel4.Name = "panel4"; - this.panel4.Size = new System.Drawing.Size(345, 57); - this.panel4.TabIndex = 5; - // - // setRangeButton - // - this.setRangeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.setRangeButton.Location = new System.Drawing.Point(267, 5); - this.setRangeButton.Name = "setRangeButton"; - this.setRangeButton.Size = new System.Drawing.Size(75, 23); - this.setRangeButton.TabIndex = 12; - this.setRangeButton.Text = "Set range"; - this.setRangeButton.UseVisualStyleBackColor = true; - this.setRangeButton.Click += new System.EventHandler(this.setRangeButton_Click); - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(192, 41); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(41, 13); - this.label7.TabIndex = 11; - this.label7.Text = "Weigth"; - // - // recalcButton - // - this.recalcButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.recalcButton.Location = new System.Drawing.Point(267, 30); - this.recalcButton.Name = "recalcButton"; - this.recalcButton.Size = new System.Drawing.Size(75, 23); - this.recalcButton.TabIndex = 6; - this.recalcButton.Text = "Recalc"; - this.recalcButton.UseVisualStyleBackColor = true; - this.recalcButton.Click += new System.EventHandler(this.recalcButton_Click); - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(113, 41); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(61, 13); - this.label6.TabIndex = 9; - this.label6.Text = "Max misses"; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(57, 41); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(44, 13); - this.label5.TabIndex = 7; - this.label5.Text = "Max diff"; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(6, 41); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(34, 13); - this.label4.TabIndex = 5; - this.label4.Text = "Fuzzy"; - // - // label3 - // - this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.label3.Location = new System.Drawing.Point(483, 110); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(303, 49); - this.label3.TabIndex = 12; - this.label3.Text = "This feature is pre-beta and does not work :)\r\nUsage: Select a range in the log w" + - "indow and press \"Recalc\". \r\nThis will search for text ranges similar to the sele" + - "cted one."; - // - // rangeLabel - // - this.rangeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.rangeLabel.Location = new System.Drawing.Point(352, 114); - this.rangeLabel.Name = "rangeLabel"; - this.rangeLabel.Size = new System.Drawing.Size(125, 42); - this.rangeLabel.TabIndex = 13; - this.rangeLabel.Text = "(no range set)"; - // - // weigthKnobControl - // - this.weigthKnobControl.Location = new System.Drawing.Point(202, 5); - this.weigthKnobControl.MaxValue = 30; - this.weigthKnobControl.MinValue = 1; - this.weigthKnobControl.Name = "weigthKnobControl"; - this.weigthKnobControl.Size = new System.Drawing.Size(21, 35); - this.weigthKnobControl.TabIndex = 10; - this.weigthKnobControl.Value = 0; - // - // maxMissesKnobControl - // - this.maxMissesKnobControl.Location = new System.Drawing.Point(134, 5); - this.maxMissesKnobControl.MaxValue = 30; - this.maxMissesKnobControl.MinValue = 0; - this.maxMissesKnobControl.Name = "maxMissesKnobControl"; - this.maxMissesKnobControl.Size = new System.Drawing.Size(22, 35); - this.maxMissesKnobControl.TabIndex = 8; - this.maxMissesKnobControl.Value = 0; - // - // maxDiffKnobControl - // - this.maxDiffKnobControl.Location = new System.Drawing.Point(69, 5); - this.maxDiffKnobControl.MaxValue = 30; - this.maxDiffKnobControl.MinValue = 0; - this.maxDiffKnobControl.Name = "maxDiffKnobControl"; - this.maxDiffKnobControl.Size = new System.Drawing.Size(21, 35); - this.maxDiffKnobControl.TabIndex = 6; - this.maxDiffKnobControl.Value = 0; - // - // fuzzyKnobControl - // - this.fuzzyKnobControl.Location = new System.Drawing.Point(9, 5); - this.fuzzyKnobControl.MaxValue = 20; - this.fuzzyKnobControl.MinValue = 0; - this.fuzzyKnobControl.Name = "fuzzyKnobControl"; - this.fuzzyKnobControl.Size = new System.Drawing.Size(22, 35); - this.fuzzyKnobControl.TabIndex = 4; - this.fuzzyKnobControl.Value = 0; - // - // patternHitsDataGridView - // - this.patternHitsDataGridView.AllowUserToAddRows = false; - this.patternHitsDataGridView.AllowUserToDeleteRows = false; - this.patternHitsDataGridView.AllowUserToResizeRows = false; - this.patternHitsDataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.patternHitsDataGridView.BackgroundColor = System.Drawing.SystemColors.Window; - this.patternHitsDataGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; - this.patternHitsDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.patternHitsDataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; - this.patternHitsDataGridView.EditModeMenuStrip = null; - this.patternHitsDataGridView.Location = new System.Drawing.Point(3, 3); - this.patternHitsDataGridView.MultiSelect = false; - this.patternHitsDataGridView.Name = "patternHitsDataGridView"; - this.patternHitsDataGridView.ReadOnly = true; - this.patternHitsDataGridView.RowHeadersVisible = false; - this.patternHitsDataGridView.RowTemplate.DefaultCellStyle.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.patternHitsDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.patternHitsDataGridView.ShowCellToolTips = false; - this.patternHitsDataGridView.Size = new System.Drawing.Size(289, 83); - this.patternHitsDataGridView.TabIndex = 1; - this.patternHitsDataGridView.VirtualMode = true; - this.patternHitsDataGridView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.patternHitsDataGridView_MouseDoubleClick); - this.patternHitsDataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.patternHitsDataGridView_CellValueNeeded); - this.patternHitsDataGridView.ColumnDividerDoubleClick += new System.Windows.Forms.DataGridViewColumnDividerDoubleClickEventHandler(this.patternHitsDataGridView_ColumnDividerDoubleClick); - this.patternHitsDataGridView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.patternHitsDataGridView_CellPainting); - this.patternHitsDataGridView.CurrentCellChanged += new System.EventHandler(this.patternHitsDataGridView_CurrentCellChanged); - // - // contentDataGridView - // - this.contentDataGridView.AllowUserToAddRows = false; - this.contentDataGridView.AllowUserToDeleteRows = false; - this.contentDataGridView.AllowUserToResizeRows = false; - this.contentDataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.contentDataGridView.BackgroundColor = System.Drawing.SystemColors.Window; - this.contentDataGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; - this.contentDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.contentDataGridView.EditModeMenuStrip = null; - this.contentDataGridView.Location = new System.Drawing.Point(3, 3); - this.contentDataGridView.Name = "contentDataGridView"; - this.contentDataGridView.ReadOnly = true; - this.contentDataGridView.RowHeadersVisible = false; - this.contentDataGridView.RowTemplate.DefaultCellStyle.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.contentDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.contentDataGridView.ShowCellToolTips = false; - this.contentDataGridView.Size = new System.Drawing.Size(491, 83); - this.contentDataGridView.TabIndex = 0; - this.contentDataGridView.VirtualMode = true; - this.contentDataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.contentDataGridView_CellValueNeeded); - this.contentDataGridView.ColumnDividerDoubleClick += new System.Windows.Forms.DataGridViewColumnDividerDoubleClickEventHandler(this.contentDataGridView_ColumnDividerDoubleClick); - this.contentDataGridView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.contentDataGridView_CellPainting); - this.contentDataGridView.CellMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.contentDataGridView_CellMouseDoubleClick); - // - // PatternWindow - // - this.ClientSize = new System.Drawing.Size(798, 165); - this.Controls.Add(this.rangeLabel); - this.Controls.Add(this.label3); - this.Controls.Add(this.panel4); - this.Controls.Add(this.splitContainer1); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.Name = "PatternWindow"; - this.Text = "Patterns"; - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel2.ResumeLayout(false); - this.splitContainer1.ResumeLayout(false); - this.splitContainer2.Panel1.ResumeLayout(false); - this.splitContainer2.Panel2.ResumeLayout(false); - this.splitContainer2.ResumeLayout(false); - this.panel2.ResumeLayout(false); - this.panel2.PerformLayout(); - this.panel1.ResumeLayout(false); - this.panel1.PerformLayout(); - this.panel4.ResumeLayout(false); - this.panel4.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.patternHitsDataGridView)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.contentDataGridView)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private LogExpert.Dialogs.BufferedDataGridView patternHitsDataGridView; - private System.Windows.Forms.SplitContainer splitContainer1; - private System.Windows.Forms.SplitContainer splitContainer2; - private LogExpert.Dialogs.BufferedDataGridView contentDataGridView; - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label blockLinesLabel; - private System.Windows.Forms.Panel panel2; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label blockCountLabel; - private System.Windows.Forms.Panel panel3; - private KnobControl fuzzyKnobControl; - private System.Windows.Forms.Panel panel4; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label label5; - private KnobControl maxDiffKnobControl; - private System.Windows.Forms.Label label6; - private KnobControl maxMissesKnobControl; - private System.Windows.Forms.Label label7; - private KnobControl weigthKnobControl; - private System.Windows.Forms.Button recalcButton; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Button setRangeButton; - private System.Windows.Forms.Label rangeLabel; - } +namespace LogExpert.UI.Controls.LogWindow +{ + partial class PatternWindow + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PatternWindow)); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.panel3 = new System.Windows.Forms.Panel(); + this.splitContainer2 = new System.Windows.Forms.SplitContainer(); + this.panel2 = new System.Windows.Forms.Panel(); + this.blockCountLabel = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); + this.label2 = new System.Windows.Forms.Label(); + this.blockLinesLabel = new System.Windows.Forms.Label(); + this.panel4 = new System.Windows.Forms.Panel(); + this.setRangeButton = new System.Windows.Forms.Button(); + this.label7 = new System.Windows.Forms.Label(); + this.recalcButton = new System.Windows.Forms.Button(); + this.label6 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.rangeLabel = new System.Windows.Forms.Label(); + this.weigthKnobControl = new KnobControl(); + this.maxMissesKnobControl = new KnobControl(); + this.maxDiffKnobControl = new KnobControl(); + this.fuzzyKnobControl = new KnobControl(); + this.patternHitsDataGridView = new LogExpert.Dialogs.BufferedDataGridView(); + this.contentDataGridView = new LogExpert.Dialogs.BufferedDataGridView(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.splitContainer2.Panel1.SuspendLayout(); + this.splitContainer2.Panel2.SuspendLayout(); + this.splitContainer2.SuspendLayout(); + this.panel2.SuspendLayout(); + this.panel1.SuspendLayout(); + this.panel4.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.patternHitsDataGridView)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.contentDataGridView)).BeginInit(); + this.SuspendLayout(); + // + // splitContainer1 + // + this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.splitContainer1.BackColor = System.Drawing.SystemColors.Control; + this.splitContainer1.IsSplitterFixed = true; + this.splitContainer1.Location = new System.Drawing.Point(2, 1); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.panel3); + this.splitContainer1.Panel1Collapsed = true; + this.splitContainer1.Panel1MinSize = 0; + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); + this.splitContainer1.Panel2MinSize = 0; + this.splitContainer1.Size = new System.Drawing.Size(795, 106); + this.splitContainer1.SplitterDistance = 106; + this.splitContainer1.TabIndex = 3; + // + // panel3 + // + this.panel3.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel3.Location = new System.Drawing.Point(0, 0); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(150, 106); + this.panel3.TabIndex = 1; + // + // splitContainer2 + // + this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer2.Location = new System.Drawing.Point(0, 0); + this.splitContainer2.Name = "splitContainer2"; + // + // splitContainer2.Panel1 + // + this.splitContainer2.Panel1.Controls.Add(this.panel2); + // + // splitContainer2.Panel2 + // + this.splitContainer2.Panel2.Controls.Add(this.panel1); + this.splitContainer2.Size = new System.Drawing.Size(795, 106); + this.splitContainer2.SplitterDistance = 294; + this.splitContainer2.TabIndex = 2; + // + // panel2 + // + this.panel2.Controls.Add(this.blockCountLabel); + this.panel2.Controls.Add(this.label1); + this.panel2.Controls.Add(this.patternHitsDataGridView); + this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel2.Location = new System.Drawing.Point(0, 0); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(294, 106); + this.panel2.TabIndex = 2; + // + // blockCountLabel + // + this.blockCountLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.blockCountLabel.AutoSize = true; + this.blockCountLabel.Location = new System.Drawing.Point(184, 89); + this.blockCountLabel.Name = "blockCountLabel"; + this.blockCountLabel.Size = new System.Drawing.Size(13, 13); + this.blockCountLabel.TabIndex = 3; + this.blockCountLabel.Text = "0"; + // + // label1 + // + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(0, 89); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(175, 13); + this.label1.TabIndex = 2; + this.label1.Text = "Number of blocks (pattern variants):"; + // + // panel1 + // + this.panel1.Controls.Add(this.label2); + this.panel1.Controls.Add(this.blockLinesLabel); + this.panel1.Controls.Add(this.contentDataGridView); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(497, 106); + this.panel1.TabIndex = 1; + // + // label2 + // + this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(3, 89); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(61, 13); + this.label2.TabIndex = 2; + this.label2.Text = "Block lines:"; + // + // blockLinesLabel + // + this.blockLinesLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.blockLinesLabel.Location = new System.Drawing.Point(70, 89); + this.blockLinesLabel.Name = "blockLinesLabel"; + this.blockLinesLabel.Size = new System.Drawing.Size(69, 13); + this.blockLinesLabel.TabIndex = 1; + this.blockLinesLabel.Text = "0"; + // + // panel4 + // + this.panel4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.panel4.Controls.Add(this.setRangeButton); + this.panel4.Controls.Add(this.label7); + this.panel4.Controls.Add(this.recalcButton); + this.panel4.Controls.Add(this.weigthKnobControl); + this.panel4.Controls.Add(this.label6); + this.panel4.Controls.Add(this.maxMissesKnobControl); + this.panel4.Controls.Add(this.label5); + this.panel4.Controls.Add(this.maxDiffKnobControl); + this.panel4.Controls.Add(this.label4); + this.panel4.Controls.Add(this.fuzzyKnobControl); + this.panel4.Location = new System.Drawing.Point(3, 106); + this.panel4.Name = "panel4"; + this.panel4.Size = new System.Drawing.Size(345, 57); + this.panel4.TabIndex = 5; + // + // setRangeButton + // + this.setRangeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.setRangeButton.Location = new System.Drawing.Point(267, 5); + this.setRangeButton.Name = "setRangeButton"; + this.setRangeButton.Size = new System.Drawing.Size(75, 23); + this.setRangeButton.TabIndex = 12; + this.setRangeButton.Text = "Set range"; + this.setRangeButton.UseVisualStyleBackColor = true; + this.setRangeButton.Click += new System.EventHandler(this.setRangeButton_Click); + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(192, 41); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(41, 13); + this.label7.TabIndex = 11; + this.label7.Text = "Weigth"; + // + // recalcButton + // + this.recalcButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.recalcButton.Location = new System.Drawing.Point(267, 30); + this.recalcButton.Name = "recalcButton"; + this.recalcButton.Size = new System.Drawing.Size(75, 23); + this.recalcButton.TabIndex = 6; + this.recalcButton.Text = "Recalc"; + this.recalcButton.UseVisualStyleBackColor = true; + this.recalcButton.Click += new System.EventHandler(this.recalcButton_Click); + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(113, 41); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(61, 13); + this.label6.TabIndex = 9; + this.label6.Text = "Max misses"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(57, 41); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(44, 13); + this.label5.TabIndex = 7; + this.label5.Text = "Max diff"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(6, 41); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(34, 13); + this.label4.TabIndex = 5; + this.label4.Text = "Fuzzy"; + // + // label3 + // + this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.label3.Location = new System.Drawing.Point(483, 110); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(303, 49); + this.label3.TabIndex = 12; + this.label3.Text = "This feature is pre-beta and does not work :)\r\nUsage: Select a range in the log w" + + "indow and press \"Recalc\". \r\nThis will search for text ranges similar to the sele" + + "cted one."; + // + // rangeLabel + // + this.rangeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.rangeLabel.Location = new System.Drawing.Point(352, 114); + this.rangeLabel.Name = "rangeLabel"; + this.rangeLabel.Size = new System.Drawing.Size(125, 42); + this.rangeLabel.TabIndex = 13; + this.rangeLabel.Text = "(no range set)"; + // + // weigthKnobControl + // + this.weigthKnobControl.Location = new System.Drawing.Point(202, 5); + this.weigthKnobControl.MaxValue = 30; + this.weigthKnobControl.MinValue = 1; + this.weigthKnobControl.Name = "weigthKnobControl"; + this.weigthKnobControl.Size = new System.Drawing.Size(21, 35); + this.weigthKnobControl.TabIndex = 10; + this.weigthKnobControl.Value = 0; + // + // maxMissesKnobControl + // + this.maxMissesKnobControl.Location = new System.Drawing.Point(134, 5); + this.maxMissesKnobControl.MaxValue = 30; + this.maxMissesKnobControl.MinValue = 0; + this.maxMissesKnobControl.Name = "maxMissesKnobControl"; + this.maxMissesKnobControl.Size = new System.Drawing.Size(22, 35); + this.maxMissesKnobControl.TabIndex = 8; + this.maxMissesKnobControl.Value = 0; + // + // maxDiffKnobControl + // + this.maxDiffKnobControl.Location = new System.Drawing.Point(69, 5); + this.maxDiffKnobControl.MaxValue = 30; + this.maxDiffKnobControl.MinValue = 0; + this.maxDiffKnobControl.Name = "maxDiffKnobControl"; + this.maxDiffKnobControl.Size = new System.Drawing.Size(21, 35); + this.maxDiffKnobControl.TabIndex = 6; + this.maxDiffKnobControl.Value = 0; + // + // fuzzyKnobControl + // + this.fuzzyKnobControl.Location = new System.Drawing.Point(9, 5); + this.fuzzyKnobControl.MaxValue = 20; + this.fuzzyKnobControl.MinValue = 0; + this.fuzzyKnobControl.Name = "fuzzyKnobControl"; + this.fuzzyKnobControl.Size = new System.Drawing.Size(22, 35); + this.fuzzyKnobControl.TabIndex = 4; + this.fuzzyKnobControl.Value = 0; + // + // patternHitsDataGridView + // + this.patternHitsDataGridView.AllowUserToAddRows = false; + this.patternHitsDataGridView.AllowUserToDeleteRows = false; + this.patternHitsDataGridView.AllowUserToResizeRows = false; + this.patternHitsDataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.patternHitsDataGridView.BackgroundColor = System.Drawing.SystemColors.Window; + this.patternHitsDataGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; + this.patternHitsDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.patternHitsDataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; + this.patternHitsDataGridView.EditModeMenuStrip = null; + this.patternHitsDataGridView.Location = new System.Drawing.Point(3, 3); + this.patternHitsDataGridView.MultiSelect = false; + this.patternHitsDataGridView.Name = "patternHitsDataGridView"; + this.patternHitsDataGridView.ReadOnly = true; + this.patternHitsDataGridView.RowHeadersVisible = false; + this.patternHitsDataGridView.RowTemplate.DefaultCellStyle.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.patternHitsDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.patternHitsDataGridView.ShowCellToolTips = false; + this.patternHitsDataGridView.Size = new System.Drawing.Size(289, 83); + this.patternHitsDataGridView.TabIndex = 1; + this.patternHitsDataGridView.VirtualMode = true; + this.patternHitsDataGridView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.patternHitsDataGridView_MouseDoubleClick); + this.patternHitsDataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.patternHitsDataGridView_CellValueNeeded); + this.patternHitsDataGridView.ColumnDividerDoubleClick += new System.Windows.Forms.DataGridViewColumnDividerDoubleClickEventHandler(this.patternHitsDataGridView_ColumnDividerDoubleClick); + this.patternHitsDataGridView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.patternHitsDataGridView_CellPainting); + this.patternHitsDataGridView.CurrentCellChanged += new System.EventHandler(this.patternHitsDataGridView_CurrentCellChanged); + // + // contentDataGridView + // + this.contentDataGridView.AllowUserToAddRows = false; + this.contentDataGridView.AllowUserToDeleteRows = false; + this.contentDataGridView.AllowUserToResizeRows = false; + this.contentDataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.contentDataGridView.BackgroundColor = System.Drawing.SystemColors.Window; + this.contentDataGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; + this.contentDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.contentDataGridView.EditModeMenuStrip = null; + this.contentDataGridView.Location = new System.Drawing.Point(3, 3); + this.contentDataGridView.Name = "contentDataGridView"; + this.contentDataGridView.ReadOnly = true; + this.contentDataGridView.RowHeadersVisible = false; + this.contentDataGridView.RowTemplate.DefaultCellStyle.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.contentDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.contentDataGridView.ShowCellToolTips = false; + this.contentDataGridView.Size = new System.Drawing.Size(491, 83); + this.contentDataGridView.TabIndex = 0; + this.contentDataGridView.VirtualMode = true; + this.contentDataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.contentDataGridView_CellValueNeeded); + this.contentDataGridView.ColumnDividerDoubleClick += new System.Windows.Forms.DataGridViewColumnDividerDoubleClickEventHandler(this.contentDataGridView_ColumnDividerDoubleClick); + this.contentDataGridView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.contentDataGridView_CellPainting); + this.contentDataGridView.CellMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.contentDataGridView_CellMouseDoubleClick); + // + // PatternWindow + // + this.ClientSize = new System.Drawing.Size(798, 165); + this.Controls.Add(this.rangeLabel); + this.Controls.Add(this.label3); + this.Controls.Add(this.panel4); + this.Controls.Add(this.splitContainer1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.Name = "PatternWindow"; + this.Text = "Patterns"; + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + this.splitContainer1.ResumeLayout(false); + this.splitContainer2.Panel1.ResumeLayout(false); + this.splitContainer2.Panel2.ResumeLayout(false); + this.splitContainer2.ResumeLayout(false); + this.panel2.ResumeLayout(false); + this.panel2.PerformLayout(); + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + this.panel4.ResumeLayout(false); + this.panel4.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.patternHitsDataGridView)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.contentDataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private LogExpert.Dialogs.BufferedDataGridView patternHitsDataGridView; + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.SplitContainer splitContainer2; + private LogExpert.Dialogs.BufferedDataGridView contentDataGridView; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label blockLinesLabel; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label blockCountLabel; + private System.Windows.Forms.Panel panel3; + private KnobControl fuzzyKnobControl; + private System.Windows.Forms.Panel panel4; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private KnobControl maxDiffKnobControl; + private System.Windows.Forms.Label label6; + private KnobControl maxMissesKnobControl; + private System.Windows.Forms.Label label7; + private KnobControl weigthKnobControl; + private System.Windows.Forms.Button recalcButton; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Button setRangeButton; + private System.Windows.Forms.Label rangeLabel; + } } \ No newline at end of file diff --git a/src/LogExpert/Controls/PatternWindow.cs b/src/Logexpert.UI/Controls/LogWindow/PatternWindow.cs similarity index 93% rename from src/LogExpert/Controls/PatternWindow.cs rename to src/Logexpert.UI/Controls/LogWindow/PatternWindow.cs index b656331b..b003c8bb 100644 --- a/src/LogExpert/Controls/PatternWindow.cs +++ b/src/Logexpert.UI/Controls/LogWindow/PatternWindow.cs @@ -1,361 +1,360 @@ -using LogExpert.Core.Classes; -using LogExpert.Core.EventArgs; -using LogExpert.Dialogs; - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert.Controls -{ - internal partial class PatternWindow : Form - { - #region Fields - - private readonly List> blockList = []; - private PatternBlock currentBlock; - private List currentList; - - private readonly LogWindow.LogWindow logWindow; - private PatternArgs patternArgs = new(); - - #endregion - - #region cTor - - public PatternWindow() - { - InitializeComponent(); - } - - public PatternWindow(LogWindow.LogWindow logWindow) - { - this.logWindow = logWindow; - InitializeComponent(); - recalcButton.Enabled = false; - } - - #endregion - - #region Properties - - public int Fuzzy - { - set { fuzzyKnobControl.Value = value; } - get { return fuzzyKnobControl.Value; } - } - - public int MaxDiff - { - set { maxDiffKnobControl.Value = value; } - get { return maxDiffKnobControl.Value; } - } - - public int MaxMisses - { - set { maxMissesKnobControl.Value = value; } - get { return maxMissesKnobControl.Value; } - } - - public int Weight - { - set { weigthKnobControl.Value = value; } - get { return weigthKnobControl.Value; } - } - - #endregion - - #region Public methods - - public void SetBlockList(List flatBlockList, PatternArgs patternArgs) - { - this.patternArgs = patternArgs; - blockList.Clear(); - List singeList = []; - //int blockId = -1; - for (int i = 0; i < flatBlockList.Count; ++i) - { - PatternBlock block = flatBlockList[i]; - singeList.Add(block); - //if (block.blockId != blockId) - //{ - // singeList = new List(); - // PatternBlock selfRefBlock = new PatternBlock(); - // selfRefBlock.targetStart = block.startLine; - // selfRefBlock.targetEnd = block.endLine; - // selfRefBlock.blockId = block.blockId; - // singeList.Add(selfRefBlock); - // singeList.Add(block); - // this.blockList.Add(singeList); - // blockId = block.blockId; - //} - //else - //{ - // singeList.Add(block); - //} - } - blockList.Add(singeList); - Invoke(new MethodInvoker(SetBlockListGuiStuff)); - } - - - public void SetColumnizer(ILogLineColumnizer columnizer) - { - logWindow.SetColumnizer(columnizer, patternHitsDataGridView); - logWindow.SetColumnizer(columnizer, contentDataGridView); - patternHitsDataGridView.Columns[0].Width = 20; - contentDataGridView.Columns[0].Width = 20; - - DataGridViewTextBoxColumn blockInfoColumn = new(); - blockInfoColumn.HeaderText = "Weight"; - blockInfoColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - blockInfoColumn.Resizable = DataGridViewTriState.False; - blockInfoColumn.DividerWidth = 1; - blockInfoColumn.ReadOnly = true; - blockInfoColumn.Width = 50; - - DataGridViewTextBoxColumn contentInfoColumn = new(); - contentInfoColumn.HeaderText = "Diff"; - contentInfoColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - contentInfoColumn.Resizable = DataGridViewTriState.False; - contentInfoColumn.DividerWidth = 1; - contentInfoColumn.ReadOnly = true; - contentInfoColumn.Width = 50; - - patternHitsDataGridView.Columns.Insert(1, blockInfoColumn); - contentDataGridView.Columns.Insert(1, contentInfoColumn); - } - - public void SetFont(string fontName, float fontSize) - { - Font font = new(new FontFamily(fontName), fontSize); - int lineSpacing = font.FontFamily.GetLineSpacing(FontStyle.Regular); - float lineSpacingPixel = font.Size * lineSpacing / font.FontFamily.GetEmHeight(FontStyle.Regular); - - patternHitsDataGridView.DefaultCellStyle.Font = font; - contentDataGridView.DefaultCellStyle.Font = font; - //this.lineHeight = font.Height + 4; - patternHitsDataGridView.RowTemplate.Height = font.Height + 4; - contentDataGridView.RowTemplate.Height = font.Height + 4; - } - - #endregion - - #region Private Methods - - private void SetBlockListGuiStuff() - { - patternHitsDataGridView.RowCount = 0; - blockCountLabel.Text = "0"; - contentDataGridView.RowCount = 0; - blockLinesLabel.Text = "0"; - recalcButton.Enabled = true; - setRangeButton.Enabled = true; - if (blockList.Count > 0) - { - SetCurrentList(blockList[0]); - } - } - - private void SetCurrentList(List patternList) - { - patternHitsDataGridView.RowCount = 0; - currentList = patternList; - patternHitsDataGridView.RowCount = currentList.Count; - patternHitsDataGridView.Refresh(); - blockCountLabel.Text = "" + currentList.Count; - } - - private int GetLineForHitGrid(int rowIndex) - { - int line; - line = currentList[rowIndex].targetStart; - return line; - } - - private int GetLineForContentGrid(int rowIndex) - { - int line; - line = currentBlock.targetStart + rowIndex; - return line; - } - - #endregion - - #region Events handler - - private void patternHitsDataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) - { - if (currentList == null || e.RowIndex < 0) - { - return; - } - int rowIndex = GetLineForHitGrid(e.RowIndex); - int colIndex = e.ColumnIndex; - if (colIndex == 1) - { - e.Value = currentList[e.RowIndex].weigth; - } - else - { - if (colIndex > 1) - { - colIndex--; // correct the additional inserted col - } - e.Value = logWindow.GetCellValue(rowIndex, colIndex); - } - } - - private void patternHitsDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) - { - if (currentList == null || e.RowIndex < 0) - { - return; - } - if (e.ColumnIndex == 1) - { - e.PaintBackground(e.CellBounds, false); - int selCount = patternArgs.EndLine - patternArgs.StartLine; - int maxWeight = patternArgs.MaxDiffInBlock * selCount + selCount; - if (maxWeight > 0) - { - int width = (int)((double)(int)e.Value / (double)maxWeight * (double)e.CellBounds.Width); - Rectangle rect = new(e.CellBounds.X, e.CellBounds.Y, width, e.CellBounds.Height); - int alpha = 90 + (int)((double)(int)e.Value / (double)maxWeight * (double)165); - Color color = Color.FromArgb(alpha, 170, 180, 150); - Brush brush = new SolidBrush(color); - rect.Inflate(-2, -1); - e.Graphics.FillRectangle(brush, rect); - brush.Dispose(); - } - e.PaintContent(e.CellBounds); - e.Handled = true; - } - else - { - BufferedDataGridView gridView = (BufferedDataGridView)sender; - int rowIndex = GetLineForHitGrid(e.RowIndex); - logWindow.CellPainting(gridView, rowIndex, e); - } - } - - private void patternHitsDataGridView_MouseDoubleClick(object sender, MouseEventArgs e) - { - //if (this.currentList == null || patternHitsDataGridView.CurrentRow == null) - // return; - //int rowIndex = GetLineForHitGrid(patternHitsDataGridView.CurrentRow.Index); - - //this.logWindow.SelectLogLine(rowIndex); - } - - private void patternHitsDataGridView_CurrentCellChanged(object sender, EventArgs e) - { - if (currentList == null || patternHitsDataGridView.CurrentRow == null) - { - return; - } - if (patternHitsDataGridView.CurrentRow.Index > currentList.Count - 1) - { - return; - } - contentDataGridView.RowCount = 0; - currentBlock = currentList[patternHitsDataGridView.CurrentRow.Index]; - contentDataGridView.RowCount = currentBlock.targetEnd - currentBlock.targetStart + 1; - contentDataGridView.Refresh(); - contentDataGridView.CurrentCell = contentDataGridView.Rows[0].Cells[0]; - blockLinesLabel.Text = "" + contentDataGridView.RowCount; - } - - private void contentDataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) - { - if (currentBlock == null || e.RowIndex < 0) - { - return; - } - int rowIndex = GetLineForContentGrid(e.RowIndex); - int colIndex = e.ColumnIndex; - if (colIndex == 1) - { - QualityInfo qi; - if (currentBlock.qualityInfoList.TryGetValue(rowIndex, out qi)) - { - e.Value = qi.quality; - } - else - { - e.Value = ""; - } - } - else - { - if (colIndex != 0) - { - colIndex--; // adjust the inserted column - } - e.Value = logWindow.GetCellValue(rowIndex, colIndex); - } - } - - private void contentDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) - { - if (currentBlock == null || e.RowIndex < 0) - { - return; - } - BufferedDataGridView gridView = (BufferedDataGridView)sender; - int rowIndex = GetLineForContentGrid(e.RowIndex); - logWindow.CellPainting(gridView, rowIndex, e); - } - - private void contentDataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) - { - if (currentBlock == null || contentDataGridView.CurrentRow == null) - { - return; - } - int rowIndex = GetLineForContentGrid(contentDataGridView.CurrentRow.Index); - - logWindow.SelectLogLine(rowIndex); - } - - private void recalcButton_Click(object sender, EventArgs e) - { - patternArgs.Fuzzy = fuzzyKnobControl.Value; - patternArgs.MaxDiffInBlock = maxDiffKnobControl.Value; - patternArgs.MaxMisses = maxMissesKnobControl.Value; - patternArgs.MinWeight = weigthKnobControl.Value; - logWindow.PatternStatistic(patternArgs); - recalcButton.Enabled = false; - setRangeButton.Enabled = false; - } - - private void closeButton_Click(object sender, EventArgs e) - { - Close(); - } - - private void contentDataGridView_ColumnDividerDoubleClick(object sender, - DataGridViewColumnDividerDoubleClickEventArgs e) - { - e.Handled = true; - contentDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - } - - private void patternHitsDataGridView_ColumnDividerDoubleClick(object sender, - DataGridViewColumnDividerDoubleClickEventArgs e) - { - e.Handled = true; - patternHitsDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - } - - private void setRangeButton_Click(object sender, EventArgs e) - { - logWindow.PatternStatisticSelectRange(patternArgs); - recalcButton.Enabled = true; - rangeLabel.Text = "Start: " + patternArgs.StartLine + "\r\nEnd: " + patternArgs.EndLine; - } - - #endregion - } +using LogExpert.Core.Classes; +using LogExpert.Core.EventArguments; +using LogExpert.Dialogs; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; + +namespace LogExpert.UI.Controls.LogWindow +{ + internal partial class PatternWindow : Form //TODO: Can this be changed to UserControl? + { + #region Fields + + private readonly List> blockList = []; + private PatternBlock currentBlock; + private List currentList; + + private readonly LogWindow logWindow; + private PatternArgs patternArgs = new(); + + #endregion + + #region cTor + + public PatternWindow() + { + InitializeComponent(); + } + + public PatternWindow(LogWindow logWindow) + { + this.logWindow = logWindow; + InitializeComponent(); + recalcButton.Enabled = false; + } + + #endregion + + #region Properties + + public int Fuzzy + { + set { fuzzyKnobControl.Value = value; } + get { return fuzzyKnobControl.Value; } + } + + public int MaxDiff + { + set { maxDiffKnobControl.Value = value; } + get { return maxDiffKnobControl.Value; } + } + + public int MaxMisses + { + set { maxMissesKnobControl.Value = value; } + get { return maxMissesKnobControl.Value; } + } + + public int Weight + { + set { weigthKnobControl.Value = value; } + get { return weigthKnobControl.Value; } + } + + #endregion + + #region Public methods + + public void SetBlockList(List flatBlockList, PatternArgs patternArgs) + { + this.patternArgs = patternArgs; + blockList.Clear(); + List singeList = []; + //int blockId = -1; + for (int i = 0; i < flatBlockList.Count; ++i) + { + PatternBlock block = flatBlockList[i]; + singeList.Add(block); + //if (block.blockId != blockId) + //{ + // singeList = new List(); + // PatternBlock selfRefBlock = new PatternBlock(); + // selfRefBlock.targetStart = block.startLine; + // selfRefBlock.targetEnd = block.endLine; + // selfRefBlock.blockId = block.blockId; + // singeList.Add(selfRefBlock); + // singeList.Add(block); + // this.blockList.Add(singeList); + // blockId = block.blockId; + //} + //else + //{ + // singeList.Add(block); + //} + } + blockList.Add(singeList); + Invoke(new MethodInvoker(SetBlockListGuiStuff)); + } + + + public void SetColumnizer(ILogLineColumnizer columnizer) + { + logWindow.SetColumnizer(columnizer, patternHitsDataGridView); + logWindow.SetColumnizer(columnizer, contentDataGridView); + patternHitsDataGridView.Columns[0].Width = 20; + contentDataGridView.Columns[0].Width = 20; + + DataGridViewTextBoxColumn blockInfoColumn = new(); + blockInfoColumn.HeaderText = "Weight"; + blockInfoColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; + blockInfoColumn.Resizable = DataGridViewTriState.False; + blockInfoColumn.DividerWidth = 1; + blockInfoColumn.ReadOnly = true; + blockInfoColumn.Width = 50; + + DataGridViewTextBoxColumn contentInfoColumn = new(); + contentInfoColumn.HeaderText = "Diff"; + contentInfoColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; + contentInfoColumn.Resizable = DataGridViewTriState.False; + contentInfoColumn.DividerWidth = 1; + contentInfoColumn.ReadOnly = true; + contentInfoColumn.Width = 50; + + patternHitsDataGridView.Columns.Insert(1, blockInfoColumn); + contentDataGridView.Columns.Insert(1, contentInfoColumn); + } + + public void SetFont(string fontName, float fontSize) + { + Font font = new(new FontFamily(fontName), fontSize); + int lineSpacing = font.FontFamily.GetLineSpacing(FontStyle.Regular); + float lineSpacingPixel = font.Size * lineSpacing / font.FontFamily.GetEmHeight(FontStyle.Regular); + + patternHitsDataGridView.DefaultCellStyle.Font = font; + contentDataGridView.DefaultCellStyle.Font = font; + //this.lineHeight = font.Height + 4; + patternHitsDataGridView.RowTemplate.Height = font.Height + 4; + contentDataGridView.RowTemplate.Height = font.Height + 4; + } + + #endregion + + #region Private Methods + + private void SetBlockListGuiStuff() + { + patternHitsDataGridView.RowCount = 0; + blockCountLabel.Text = "0"; + contentDataGridView.RowCount = 0; + blockLinesLabel.Text = "0"; + recalcButton.Enabled = true; + setRangeButton.Enabled = true; + if (blockList.Count > 0) + { + SetCurrentList(blockList[0]); + } + } + + private void SetCurrentList(List patternList) + { + patternHitsDataGridView.RowCount = 0; + currentList = patternList; + patternHitsDataGridView.RowCount = currentList.Count; + patternHitsDataGridView.Refresh(); + blockCountLabel.Text = "" + currentList.Count; + } + + private int GetLineForHitGrid(int rowIndex) + { + int line; + line = currentList[rowIndex].targetStart; + return line; + } + + private int GetLineForContentGrid(int rowIndex) + { + int line; + line = currentBlock.targetStart + rowIndex; + return line; + } + + #endregion + + #region Events handler + + private void patternHitsDataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) + { + if (currentList == null || e.RowIndex < 0) + { + return; + } + int rowIndex = GetLineForHitGrid(e.RowIndex); + int colIndex = e.ColumnIndex; + if (colIndex == 1) + { + e.Value = currentList[e.RowIndex].weigth; + } + else + { + if (colIndex > 1) + { + colIndex--; // correct the additional inserted col + } + e.Value = logWindow.GetCellValue(rowIndex, colIndex); + } + } + + private void patternHitsDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) + { + if (currentList == null || e.RowIndex < 0) + { + return; + } + if (e.ColumnIndex == 1) + { + e.PaintBackground(e.CellBounds, false); + int selCount = patternArgs.EndLine - patternArgs.StartLine; + int maxWeight = patternArgs.MaxDiffInBlock * selCount + selCount; + if (maxWeight > 0) + { + int width = (int)((int)e.Value / (double)maxWeight * e.CellBounds.Width); + Rectangle rect = new(e.CellBounds.X, e.CellBounds.Y, width, e.CellBounds.Height); + int alpha = 90 + (int)((int)e.Value / (double)maxWeight * 165); + Color color = Color.FromArgb(alpha, 170, 180, 150); + Brush brush = new SolidBrush(color); + rect.Inflate(-2, -1); + e.Graphics.FillRectangle(brush, rect); + brush.Dispose(); + } + e.PaintContent(e.CellBounds); + e.Handled = true; + } + else + { + BufferedDataGridView gridView = (BufferedDataGridView)sender; + int rowIndex = GetLineForHitGrid(e.RowIndex); + logWindow.CellPainting(gridView, rowIndex, e); + } + } + + private void patternHitsDataGridView_MouseDoubleClick(object sender, MouseEventArgs e) + { + //if (this.currentList == null || patternHitsDataGridView.CurrentRow == null) + // return; + //int rowIndex = GetLineForHitGrid(patternHitsDataGridView.CurrentRow.Index); + + //this.logWindow.SelectLogLine(rowIndex); + } + + private void patternHitsDataGridView_CurrentCellChanged(object sender, EventArgs e) + { + if (currentList == null || patternHitsDataGridView.CurrentRow == null) + { + return; + } + if (patternHitsDataGridView.CurrentRow.Index > currentList.Count - 1) + { + return; + } + contentDataGridView.RowCount = 0; + currentBlock = currentList[patternHitsDataGridView.CurrentRow.Index]; + contentDataGridView.RowCount = currentBlock.targetEnd - currentBlock.targetStart + 1; + contentDataGridView.Refresh(); + contentDataGridView.CurrentCell = contentDataGridView.Rows[0].Cells[0]; + blockLinesLabel.Text = "" + contentDataGridView.RowCount; + } + + private void contentDataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) + { + if (currentBlock == null || e.RowIndex < 0) + { + return; + } + int rowIndex = GetLineForContentGrid(e.RowIndex); + int colIndex = e.ColumnIndex; + if (colIndex == 1) + { + QualityInfo qi; + if (currentBlock.qualityInfoList.TryGetValue(rowIndex, out qi)) + { + e.Value = qi.quality; + } + else + { + e.Value = ""; + } + } + else + { + if (colIndex != 0) + { + colIndex--; // adjust the inserted column + } + e.Value = logWindow.GetCellValue(rowIndex, colIndex); + } + } + + private void contentDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) + { + if (currentBlock == null || e.RowIndex < 0) + { + return; + } + BufferedDataGridView gridView = (BufferedDataGridView)sender; + int rowIndex = GetLineForContentGrid(e.RowIndex); + logWindow.CellPainting(gridView, rowIndex, e); + } + + private void contentDataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) + { + if (currentBlock == null || contentDataGridView.CurrentRow == null) + { + return; + } + int rowIndex = GetLineForContentGrid(contentDataGridView.CurrentRow.Index); + + logWindow.SelectLogLine(rowIndex); + } + + private void recalcButton_Click(object sender, EventArgs e) + { + patternArgs.Fuzzy = fuzzyKnobControl.Value; + patternArgs.MaxDiffInBlock = maxDiffKnobControl.Value; + patternArgs.MaxMisses = maxMissesKnobControl.Value; + patternArgs.MinWeight = weigthKnobControl.Value; + logWindow.PatternStatistic(patternArgs); + recalcButton.Enabled = false; + setRangeButton.Enabled = false; + } + + private void closeButton_Click(object sender, EventArgs e) + { + Close(); + } + + private void contentDataGridView_ColumnDividerDoubleClick(object sender, + DataGridViewColumnDividerDoubleClickEventArgs e) + { + e.Handled = true; + contentDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + } + + private void patternHitsDataGridView_ColumnDividerDoubleClick(object sender, + DataGridViewColumnDividerDoubleClickEventArgs e) + { + e.Handled = true; + patternHitsDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + } + + private void setRangeButton_Click(object sender, EventArgs e) + { + logWindow.PatternStatisticSelectRange(patternArgs); + recalcButton.Enabled = true; + rangeLabel.Text = "Start: " + patternArgs.StartLine + "\r\nEnd: " + patternArgs.EndLine; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Controls/PatternWindow.resx b/src/Logexpert.UI/Controls/LogWindow/PatternWindow.resx similarity index 98% rename from src/LogExpert/Controls/PatternWindow.resx rename to src/Logexpert.UI/Controls/LogWindow/PatternWindow.resx index 20cf2a6f..e97451d5 100644 --- a/src/LogExpert/Controls/PatternWindow.resx +++ b/src/Logexpert.UI/Controls/LogWindow/PatternWindow.resx @@ -1,131 +1,131 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA - AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// - AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// - //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA - AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAIABAAD//wAA - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// + //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA + AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAIABAAD//wAA + + \ No newline at end of file diff --git a/src/LogExpert/Classes/RangeFinder.cs b/src/Logexpert.UI/Controls/LogWindow/RangeFinder.cs similarity index 96% rename from src/LogExpert/Classes/RangeFinder.cs rename to src/Logexpert.UI/Controls/LogWindow/RangeFinder.cs index 63538a2c..4852acea 100644 --- a/src/LogExpert/Classes/RangeFinder.cs +++ b/src/Logexpert.UI/Controls/LogWindow/RangeFinder.cs @@ -1,104 +1,105 @@ -using LogExpert.Classes.ILogLineColumnizerCallback; -using LogExpert.Core.Classes; -using LogExpert.Core.Classes.Filter; -using LogExpert.Core.Entities; - -using NLog; - -namespace LogExpert.Classes -{ - /// - /// Delivers the range (from..to) that matches the current range filter settings starting from a given line. - /// - public class RangeFinder(FilterParams filterParams, ColumnizerCallback callback) - { - #region Fields - - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - private readonly FilterParams _filterParams = filterParams.CloneWithCurrentColumnizer(); - - #endregion - - #region Public methods - - public Range FindRange(int startLine) - { - _logger.Info($"Starting range search for {_filterParams.SearchText} ... {_filterParams.RangeSearchText}"); - - if (_filterParams.RangeSearchText == null || _filterParams.RangeSearchText.Trim().Length == 0) - { - _logger.Info("Range search text not set. Cancelling range search."); - return null; - } - if (_filterParams.SearchText == null || _filterParams.SearchText.Trim().Length == 0) - { - _logger.Info("Search text not set. Cancelling range search."); - return null; - } - - _filterParams.IsRangeSearch = false; - _filterParams.IsInRange = false; - - int lineCount = callback.GetLineCount(); - int lineNum = startLine; - bool foundStartLine = false; - - Range range = new(); - FilterParams tmpParam = _filterParams.CloneWithCurrentColumnizer(); - - tmpParam.SearchText = _filterParams.RangeSearchText; - - // search backward for starting keyword - var line = callback.GetLogLine(lineNum); - - while (lineNum >= 0) - { - callback.LineNum = lineNum; - - if (Util.TestFilterCondition(_filterParams, line, callback)) - { - foundStartLine = true; - break; - } - lineNum--; - line = callback.GetLogLine(lineNum); - - if (lineNum < 0 || Util.TestFilterCondition(tmpParam, line, callback)) // do not crash on Ctrl+R when there is not start line found - { - // lower range bound found --> we are not in between a valid range - break; - } - } - - if (!foundStartLine) - { - _logger.Info("Range start not found"); - return null; - } - - range.StartLine = lineNum; - _filterParams.IsRangeSearch = true; - _filterParams.IsInRange = true; - lineNum++; - - while (lineNum < lineCount) - { - line = callback.GetLogLine(lineNum); - callback.LineNum = lineNum; - if (!Util.TestFilterCondition(_filterParams, line, callback)) - { - break; - } - lineNum++; - } - lineNum--; - range.EndLine = lineNum; - - _logger.Info($"Range search finished. Found {range.EndLine - range.StartLine} lines"); - - return range; - } - - #endregion - } +using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Filter; +using LogExpert.Core.Entities; +using NLog; + +using Range = LogExpert.Core.Entities.Range; + +namespace LogExpert.UI.Controls.LogWindow +{ + /// + /// Delivers the range (from..to) that matches the current range filter settings starting from a given line. + /// + public class RangeFinder(FilterParams filterParams, ColumnizerCallback callback) + { + #region Fields + + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private readonly FilterParams _filterParams = filterParams.CloneWithCurrentColumnizer(); + + #endregion + + #region Public methods + + public Range FindRange(int startLine) + { + _logger.Info($"Starting range search for {_filterParams.SearchText} ... {_filterParams.RangeSearchText}"); + + if (_filterParams.RangeSearchText == null || _filterParams.RangeSearchText.Trim().Length == 0) + { + _logger.Info("Range search text not set. Cancelling range search."); + return null; + } + if (_filterParams.SearchText == null || _filterParams.SearchText.Trim().Length == 0) + { + _logger.Info("Search text not set. Cancelling range search."); + return null; + } + + _filterParams.IsRangeSearch = false; + _filterParams.IsInRange = false; + + int lineCount = callback.GetLineCount(); + int lineNum = startLine; + bool foundStartLine = false; + + Range range = new(); + FilterParams tmpParam = _filterParams.CloneWithCurrentColumnizer(); + + tmpParam.SearchText = _filterParams.RangeSearchText; + + // search backward for starting keyword + var line = callback.GetLogLine(lineNum); + + while (lineNum >= 0) + { + callback.LineNum = lineNum; + + if (Util.TestFilterCondition(_filterParams, line, callback)) + { + foundStartLine = true; + break; + } + lineNum--; + line = callback.GetLogLine(lineNum); + + if (lineNum < 0 || Util.TestFilterCondition(tmpParam, line, callback)) // do not crash on Ctrl+R when there is not start line found + { + // lower range bound found --> we are not in between a valid range + break; + } + } + + if (!foundStartLine) + { + _logger.Info("Range start not found"); + return null; + } + + range.StartLine = lineNum; + _filterParams.IsRangeSearch = true; + _filterParams.IsInRange = true; + lineNum++; + + while (lineNum < lineCount) + { + line = callback.GetLogLine(lineNum); + callback.LineNum = lineNum; + if (!Util.TestFilterCondition(_filterParams, line, callback)) + { + break; + } + lineNum++; + } + lineNum--; + range.EndLine = lineNum; + + _logger.Info($"Range search finished. Found {range.EndLine - range.StartLine} lines"); + + return range; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/TimeSpreadCalculator.cs b/src/Logexpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs similarity index 95% rename from src/LogExpert/Classes/TimeSpreadCalculator.cs rename to src/Logexpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs index 4e609ee7..f787bf21 100644 --- a/src/LogExpert/Classes/TimeSpreadCalculator.cs +++ b/src/Logexpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs @@ -1,454 +1,453 @@ -using LogExpert.Classes.ILogLineColumnizerCallback; -using LogExpert.Controls.LogWindow; -using LogExpert.Core.Classes; - -using NLog; - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace LogExpert.Classes -{ - internal partial class TimeSpreadCalculator - { - #region Fields - - private const int INACTIVITY_TIME = 2000; - - private const int MAX_CONTRAST = 1300; - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - - private readonly EventWaitHandle _calcEvent = new ManualResetEvent(false); - private readonly ColumnizerCallback _callback; - - private readonly object _diffListLock = new(); - private readonly EventWaitHandle _lineCountEvent = new ManualResetEvent(false); - - //TODO Refactor that it does not need LogWindow - private readonly LogWindow _logWindow; - - // for DoCalc_via_Time - private double _average; - - private int _contrast = 400; - private int _displayHeight = 0; - private bool _enabled; - private DateTime _endTimestamp; - private int _lineCount = 0; - private int _maxDiff; - private TimeSpan _maxSpan; - private bool _shouldStop; - private CancellationTokenSource cts = new(); - - private DateTime _startTimestamp; - - private bool _timeMode = true; - - // for DoCalc - private int _timePerLine; - - #endregion - - #region cTor - - public TimeSpreadCalculator(LogWindow logWindow) - { - _logWindow = logWindow; - _callback = new ColumnizerCallback(_logWindow); - - Task.Run(WorkerFx, cts.Token); - } - - #endregion - - #region Delegates - - public delegate void CalcDoneEventHandler(object sender, EventArgs e); - - public delegate void StartCalcEventHandler(object sender, EventArgs e); - - #endregion - - #region Events - - public event CalcDoneEventHandler CalcDone; - public event StartCalcEventHandler StartCalc; - - #endregion - - #region Properties - - public bool Enabled - { - get => _enabled; - set - { - _enabled = value; - if (_enabled) - { - _calcEvent.Set(); - _lineCountEvent.Set(); - } - } - } - - public bool TimeMode - { - get => _timeMode; - set - { - _timeMode = value; - if (_enabled) - { - _calcEvent.Set(); - _lineCountEvent.Set(); - } - } - } - - public int Contrast - { - set - { - _contrast = value; - if (_contrast < 0) - { - _contrast = 0; - } - else if (_contrast > MAX_CONTRAST) - { - _contrast = MAX_CONTRAST; - } - - if (TimeMode) - { - CalcValuesViaTime(_maxDiff, _average); - } - else - { - CalcValuesViaLines(_timePerLine, _maxSpan); - } - OnCalcDone(EventArgs.Empty); - } - - get => _contrast; - } - - public List DiffList { get; set; } = []; - - #endregion - - #region Public methods - - public void Stop() - { - _shouldStop = true; - _lineCountEvent.Set(); - cts.Cancel(); - } - - public void SetLineCount(int count) - { - _lineCount = count; - if (Enabled) - { - _calcEvent.Set(); - _lineCountEvent.Set(); - } - } - - public void SetDisplayHeight(int height) - { - _displayHeight = height; - if (Enabled) - { - _calcEvent.Set(); - _lineCountEvent.Set(); - } - } - - #endregion - - #region Private Methods - - private void WorkerFx() - { - //Thread.CurrentThread.Name = "TimeSpreadCalculator Worker"; - //Thread.CurrentThread.Priority = ThreadPriority.BelowNormal; - - while (!_shouldStop) - { - // wait for wakeup - _lineCountEvent.WaitOne(); - - while (!_shouldStop) - { - // wait for unbusy moments - _logger.Debug("TimeSpreadCalculator: wait for unbusy moments"); - bool signaled = _calcEvent.WaitOne(INACTIVITY_TIME, false); - if (signaled == false) - { - _logger.Debug("TimeSpreadCalculator: unbusy. starting calc."); - if (TimeMode) - { - DoCalc_via_Time(); - } - else - { - DoCalc(); - } - break; - } - - _logger.Debug("TimeSpreadCalculator: signalled. no calc."); - _calcEvent.Reset(); - } - _lineCountEvent.Reset(); - } - } - - private void DoCalc() - { - OnStartCalc(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc() begin"); - - if (_callback.GetLineCount() < 1) - { - OnCalcDone(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc() end because of line count < 1"); - return; - } - - int lineNum = 0; - int lastLineNum = _callback.GetLineCount() - 1; - _startTimestamp = _logWindow.GetTimestampForLineForward(ref lineNum, false); - _endTimestamp = _logWindow.GetTimestampForLine(ref lastLineNum, false); - - int timePerLineSum = 0; - - if (_startTimestamp != DateTime.MinValue && _endTimestamp != DateTime.MinValue) - { - TimeSpan overallSpan = _endTimestamp - _startTimestamp; - int overallSpanMillis = (int)(overallSpan.Ticks / TimeSpan.TicksPerMillisecond); - _timePerLine = (int)Math.Round(overallSpanMillis / (double)_lineCount); - DateTime oldTime = _logWindow.GetTimestampForLineForward(ref lineNum, false); - int step; - - if (_lineCount > _displayHeight) - { - step = (int)Math.Round(_lineCount / (double)_displayHeight); - } - else - { - step = 1; - } - - _logger.Debug("TimeSpreadCalculator.DoCalc() collecting data for {0} lines with step size {1}", lastLineNum, step); - - List newDiffList = []; - List maxList = []; - lineNum++; - - for (int i = lineNum; i < lastLineNum; i += step) - { - int currLineNum = i; - DateTime time = _logWindow.GetTimestampForLineForward(ref currLineNum, false); - if (time != DateTime.MinValue) - { - TimeSpan span = time - oldTime; - maxList.Add(span); - timePerLineSum += (int)(span.Ticks / TimeSpan.TicksPerMillisecond); - newDiffList.Add(new SpreadEntry(i, 0, time)); - oldTime = time; - _logger.Debug("TimeSpreadCalculator.DoCalc() time diff {0}", span); - } - } - - if (maxList.Count > 3) - { - maxList.Sort(); - _maxSpan = maxList[^3]; - } - - lock (_diffListLock) - { - DiffList = newDiffList; - _timePerLine = (int)Math.Round(timePerLineSum / ((double)(lastLineNum + 1) / step)); - CalcValuesViaLines(_timePerLine, _maxSpan); - OnCalcDone(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc() end"); - } - } - } - - //TODO Refactor this method - private void DoCalc_via_Time() - { - OnStartCalc(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() begin"); - - if (_callback.GetLineCount() < 1) - { - OnCalcDone(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc() end because of line count < 1"); - return; - } - - int lineNum = 0; - int lastLineNum = _callback.GetLineCount() - 1; - _startTimestamp = _logWindow.GetTimestampForLineForward(ref lineNum, false); - _endTimestamp = _logWindow.GetTimestampForLine(ref lastLineNum, false); - - if (_startTimestamp != DateTime.MinValue && _endTimestamp != DateTime.MinValue) - { - TimeSpan overallSpan = _endTimestamp - _startTimestamp; - long overallSpanMillis = overallSpan.Ticks / TimeSpan.TicksPerMillisecond; - //int timePerLine = (int)Math.Round((double)overallSpanMillis / (double)this.lineCount); - - long step; - - if (overallSpanMillis > _displayHeight) - { - step = (long)Math.Round(overallSpanMillis / (double)_displayHeight); - } - else - { - step = 1; - } - - _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() time range is {0} ms", overallSpanMillis); - - lineNum = 0; - DateTime searchTimeStamp = _startTimestamp; - int oldLineNum = lineNum; - int loopCount = 0; - int lineDiffSum = 0; - int minDiff = int.MaxValue; - _maxDiff = 0; - List maxList = []; - List newDiffList = []; - - while (searchTimeStamp.CompareTo(_endTimestamp) <= 0) - { - lineNum = _logWindow.FindTimestampLine_Internal(lineNum, lineNum, lastLineNum, searchTimeStamp, false); - if (lineNum < 0) - { - lineNum = -lineNum; - } - int lineDiff = lineNum - oldLineNum; - - _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() test time {0:HH:mm:ss.fff} line diff={1}", searchTimeStamp, lineDiff); - - if (lineDiff >= 0) - { - lineDiffSum += lineDiff; - newDiffList.Add(new SpreadEntry(lineNum, lineDiff, searchTimeStamp)); - - if (lineDiff < minDiff) - { - minDiff = lineDiff; - } - - if (lineDiff > _maxDiff) - { - _maxDiff = lineDiff; - } - maxList.Add(lineDiff); - loopCount++; - } - - searchTimeStamp = searchTimeStamp.AddMilliseconds(step); - oldLineNum = lineNum; - //lineNum++; - } - - if (maxList.Count > 3) - { - maxList.Sort(); - _maxDiff = maxList[^3]; - } - - _average = lineDiffSum / (double)loopCount; - //double average = maxList[maxList.Count / 2]; - _logger.Debug("Average diff={0} minDiff={1} maxDiff={2}", _average, minDiff, _maxDiff); - - lock (_diffListLock) - { - if (newDiffList.Count > 0) - { - newDiffList.RemoveAt(0); - } - - if (newDiffList.Count > 0) - { - newDiffList.RemoveAt(0); - } - - DiffList = newDiffList; - CalcValuesViaTime(_maxDiff, _average); - OnCalcDone(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() end"); - } - } - } - - private DateTime CalcValuesViaLines(int timePerLine, TimeSpan maxSpan) - { - DateTime oldTime = DateTime.MinValue; - - if (DiffList.Count > 0) - { - oldTime = DiffList[0].Timestamp; - - foreach (SpreadEntry entry in DiffList) - { - TimeSpan span = entry.Timestamp - oldTime; - double diffFromAverage = (int)(span.Ticks / TimeSpan.TicksPerMillisecond) - timePerLine; - - if (diffFromAverage < 0) - { - diffFromAverage = 0; - } - - int value = (int)(diffFromAverage / (timePerLine / TimeSpan.TicksPerMillisecond) * _contrast); - entry.Value = 255 - value; - oldTime = entry.Timestamp; - } - } - - return oldTime; - } - - private void CalcValuesViaTime(int maxDiff, double average) - { - foreach (SpreadEntry entry in DiffList) - { - int lineDiff = entry.Diff; - double diffFromAverage = entry.Diff - average; - - if (diffFromAverage < 0) - { - diffFromAverage = 0; - } - int value = (int)(diffFromAverage / maxDiff * _contrast); - entry.Value = 255 - value; - - _logger.Debug("TimeSpreadCalculator.DoCalc() test time {0:HH:mm:ss.fff} line diff={1} value={2}", entry.Timestamp, lineDiff, value); - } - } - - private void OnCalcDone(EventArgs e) - { - CalcDone?.Invoke(this, e); - } - - private void OnStartCalc(EventArgs e) - { - StartCalc?.Invoke(this, e); - } - - #endregion - } +using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Classes; +using LogExpert.Core.Interface; +using NLog; + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace LogExpert.UI.Controls.LogWindow +{ + internal class TimeSpreadCalculator + { + #region Fields + + private const int INACTIVITY_TIME = 2000; + + private const int MAX_CONTRAST = 1300; + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + + private readonly EventWaitHandle _calcEvent = new ManualResetEvent(false); + private readonly ColumnizerCallback _callback; + + private readonly object _diffListLock = new(); + private readonly EventWaitHandle _lineCountEvent = new ManualResetEvent(false); + + //TODO Refactor that it does not need LogWindow + private readonly ILogWindow _logWindow; + + // for DoCalc_via_Time + private double _average; + + private int _contrast = 400; + private int _displayHeight = 0; + private bool _enabled; + private DateTime _endTimestamp; + private int _lineCount = 0; + private int _maxDiff; + private TimeSpan _maxSpan; + private bool _shouldStop; + private CancellationTokenSource cts = new(); + + private DateTime _startTimestamp; + + private bool _timeMode = true; + + // for DoCalc + private int _timePerLine; + + #endregion + + #region cTor + + public TimeSpreadCalculator(ILogWindow logWindow) + { + _logWindow = logWindow; + _callback = new ColumnizerCallback(_logWindow); + + Task.Run(WorkerFx, cts.Token); + } + + #endregion + + #region Delegates + + public delegate void CalcDoneEventHandler(object sender, EventArgs e); + + public delegate void StartCalcEventHandler(object sender, EventArgs e); + + #endregion + + #region Events + + public event CalcDoneEventHandler CalcDone; + public event StartCalcEventHandler StartCalc; + + #endregion + + #region Properties + + public bool Enabled + { + get => _enabled; + set + { + _enabled = value; + if (_enabled) + { + _calcEvent.Set(); + _lineCountEvent.Set(); + } + } + } + + public bool TimeMode + { + get => _timeMode; + set + { + _timeMode = value; + if (_enabled) + { + _calcEvent.Set(); + _lineCountEvent.Set(); + } + } + } + + public int Contrast + { + set + { + _contrast = value; + if (_contrast < 0) + { + _contrast = 0; + } + else if (_contrast > MAX_CONTRAST) + { + _contrast = MAX_CONTRAST; + } + + if (TimeMode) + { + CalcValuesViaTime(_maxDiff, _average); + } + else + { + CalcValuesViaLines(_timePerLine, _maxSpan); + } + OnCalcDone(EventArgs.Empty); + } + + get => _contrast; + } + + public List DiffList { get; set; } = []; + + #endregion + + #region Public methods + + public void Stop() + { + _shouldStop = true; + _lineCountEvent.Set(); + cts.Cancel(); + } + + public void SetLineCount(int count) + { + _lineCount = count; + if (Enabled) + { + _calcEvent.Set(); + _lineCountEvent.Set(); + } + } + + public void SetDisplayHeight(int height) + { + _displayHeight = height; + if (Enabled) + { + _calcEvent.Set(); + _lineCountEvent.Set(); + } + } + + #endregion + + #region Private Methods + + private void WorkerFx() + { + //Thread.CurrentThread.Name = "TimeSpreadCalculator Worker"; + //Thread.CurrentThread.Priority = ThreadPriority.BelowNormal; + + while (!_shouldStop) + { + // wait for wakeup + _lineCountEvent.WaitOne(); + + while (!_shouldStop) + { + // wait for unbusy moments + _logger.Debug("TimeSpreadCalculator: wait for unbusy moments"); + bool signaled = _calcEvent.WaitOne(INACTIVITY_TIME, false); + if (signaled == false) + { + _logger.Debug("TimeSpreadCalculator: unbusy. starting calc."); + if (TimeMode) + { + DoCalc_via_Time(); + } + else + { + DoCalc(); + } + break; + } + + _logger.Debug("TimeSpreadCalculator: signalled. no calc."); + _calcEvent.Reset(); + } + _lineCountEvent.Reset(); + } + } + + private void DoCalc() + { + OnStartCalc(EventArgs.Empty); + _logger.Debug("TimeSpreadCalculator.DoCalc() begin"); + + if (_callback.GetLineCount() < 1) + { + OnCalcDone(EventArgs.Empty); + _logger.Debug("TimeSpreadCalculator.DoCalc() end because of line count < 1"); + return; + } + + int lineNum = 0; + int lastLineNum = _callback.GetLineCount() - 1; + _startTimestamp = _logWindow.GetTimestampForLineForward(ref lineNum, false); + _endTimestamp = _logWindow.GetTimestampForLine(ref lastLineNum, false); + + int timePerLineSum = 0; + + if (_startTimestamp != DateTime.MinValue && _endTimestamp != DateTime.MinValue) + { + TimeSpan overallSpan = _endTimestamp - _startTimestamp; + int overallSpanMillis = (int)(overallSpan.Ticks / TimeSpan.TicksPerMillisecond); + _timePerLine = (int)Math.Round(overallSpanMillis / (double)_lineCount); + DateTime oldTime = _logWindow.GetTimestampForLineForward(ref lineNum, false); + int step; + + if (_lineCount > _displayHeight) + { + step = (int)Math.Round(_lineCount / (double)_displayHeight); + } + else + { + step = 1; + } + + _logger.Debug("TimeSpreadCalculator.DoCalc() collecting data for {0} lines with step size {1}", lastLineNum, step); + + List newDiffList = []; + List maxList = []; + lineNum++; + + for (int i = lineNum; i < lastLineNum; i += step) + { + int currLineNum = i; + DateTime time = _logWindow.GetTimestampForLineForward(ref currLineNum, false); + if (time != DateTime.MinValue) + { + TimeSpan span = time - oldTime; + maxList.Add(span); + timePerLineSum += (int)(span.Ticks / TimeSpan.TicksPerMillisecond); + newDiffList.Add(new SpreadEntry(i, 0, time)); + oldTime = time; + _logger.Debug("TimeSpreadCalculator.DoCalc() time diff {0}", span); + } + } + + if (maxList.Count > 3) + { + maxList.Sort(); + _maxSpan = maxList[^3]; + } + + lock (_diffListLock) + { + DiffList = newDiffList; + _timePerLine = (int)Math.Round(timePerLineSum / ((double)(lastLineNum + 1) / step)); + CalcValuesViaLines(_timePerLine, _maxSpan); + OnCalcDone(EventArgs.Empty); + _logger.Debug("TimeSpreadCalculator.DoCalc() end"); + } + } + } + + //TODO Refactor this method + private void DoCalc_via_Time() + { + OnStartCalc(EventArgs.Empty); + _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() begin"); + + if (_callback.GetLineCount() < 1) + { + OnCalcDone(EventArgs.Empty); + _logger.Debug("TimeSpreadCalculator.DoCalc() end because of line count < 1"); + return; + } + + int lineNum = 0; + int lastLineNum = _callback.GetLineCount() - 1; + _startTimestamp = _logWindow.GetTimestampForLineForward(ref lineNum, false); + _endTimestamp = _logWindow.GetTimestampForLine(ref lastLineNum, false); + + if (_startTimestamp != DateTime.MinValue && _endTimestamp != DateTime.MinValue) + { + TimeSpan overallSpan = _endTimestamp - _startTimestamp; + long overallSpanMillis = overallSpan.Ticks / TimeSpan.TicksPerMillisecond; + //int timePerLine = (int)Math.Round((double)overallSpanMillis / (double)this.lineCount); + + long step; + + if (overallSpanMillis > _displayHeight) + { + step = (long)Math.Round(overallSpanMillis / (double)_displayHeight); + } + else + { + step = 1; + } + + _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() time range is {0} ms", overallSpanMillis); + + lineNum = 0; + DateTime searchTimeStamp = _startTimestamp; + int oldLineNum = lineNum; + int loopCount = 0; + int lineDiffSum = 0; + int minDiff = int.MaxValue; + _maxDiff = 0; + List maxList = []; + List newDiffList = []; + + while (searchTimeStamp.CompareTo(_endTimestamp) <= 0) + { + lineNum = _logWindow.FindTimestampLine_Internal(lineNum, lineNum, lastLineNum, searchTimeStamp, false); + if (lineNum < 0) + { + lineNum = -lineNum; + } + int lineDiff = lineNum - oldLineNum; + + _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() test time {0:HH:mm:ss.fff} line diff={1}", searchTimeStamp, lineDiff); + + if (lineDiff >= 0) + { + lineDiffSum += lineDiff; + newDiffList.Add(new SpreadEntry(lineNum, lineDiff, searchTimeStamp)); + + if (lineDiff < minDiff) + { + minDiff = lineDiff; + } + + if (lineDiff > _maxDiff) + { + _maxDiff = lineDiff; + } + maxList.Add(lineDiff); + loopCount++; + } + + searchTimeStamp = searchTimeStamp.AddMilliseconds(step); + oldLineNum = lineNum; + //lineNum++; + } + + if (maxList.Count > 3) + { + maxList.Sort(); + _maxDiff = maxList[^3]; + } + + _average = lineDiffSum / (double)loopCount; + //double average = maxList[maxList.Count / 2]; + _logger.Debug("Average diff={0} minDiff={1} maxDiff={2}", _average, minDiff, _maxDiff); + + lock (_diffListLock) + { + if (newDiffList.Count > 0) + { + newDiffList.RemoveAt(0); + } + + if (newDiffList.Count > 0) + { + newDiffList.RemoveAt(0); + } + + DiffList = newDiffList; + CalcValuesViaTime(_maxDiff, _average); + OnCalcDone(EventArgs.Empty); + _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() end"); + } + } + } + + private DateTime CalcValuesViaLines(int timePerLine, TimeSpan maxSpan) + { + DateTime oldTime = DateTime.MinValue; + + if (DiffList.Count > 0) + { + oldTime = DiffList[0].Timestamp; + + foreach (SpreadEntry entry in DiffList) + { + TimeSpan span = entry.Timestamp - oldTime; + double diffFromAverage = (int)(span.Ticks / TimeSpan.TicksPerMillisecond) - timePerLine; + + if (diffFromAverage < 0) + { + diffFromAverage = 0; + } + + int value = (int)(diffFromAverage / (timePerLine / TimeSpan.TicksPerMillisecond) * _contrast); + entry.Value = 255 - value; + oldTime = entry.Timestamp; + } + } + + return oldTime; + } + + private void CalcValuesViaTime(int maxDiff, double average) + { + foreach (SpreadEntry entry in DiffList) + { + int lineDiff = entry.Diff; + double diffFromAverage = entry.Diff - average; + + if (diffFromAverage < 0) + { + diffFromAverage = 0; + } + int value = (int)(diffFromAverage / maxDiff * _contrast); + entry.Value = 255 - value; + + _logger.Debug("TimeSpreadCalculator.DoCalc() test time {0:HH:mm:ss.fff} line diff={1} value={2}", entry.Timestamp, lineDiff, value); + } + } + + private void OnCalcDone(EventArgs e) + { + CalcDone?.Invoke(this, e); + } + + private void OnStartCalc(EventArgs e) + { + StartCalc?.Invoke(this, e); + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Controls/TimeSpreadigControl.Designer.cs b/src/Logexpert.UI/Controls/LogWindow/TimeSpreadigControl.Designer.cs similarity index 97% rename from src/LogExpert/Controls/TimeSpreadigControl.Designer.cs rename to src/Logexpert.UI/Controls/LogWindow/TimeSpreadigControl.Designer.cs index 5ae40aa5..ba25f3c3 100644 --- a/src/LogExpert/Controls/TimeSpreadigControl.Designer.cs +++ b/src/Logexpert.UI/Controls/LogWindow/TimeSpreadigControl.Designer.cs @@ -1,4 +1,4 @@ -namespace LogExpert.Dialogs +namespace LogExpert.UI.Controls.LogWindow { partial class TimeSpreadingControl { diff --git a/src/LogExpert/Controls/TimeSpreadigControl.cs b/src/Logexpert.UI/Controls/LogWindow/TimeSpreadigControl.cs similarity index 98% rename from src/LogExpert/Controls/TimeSpreadigControl.cs rename to src/Logexpert.UI/Controls/LogWindow/TimeSpreadigControl.cs index f277b8c9..f5035e25 100644 --- a/src/LogExpert/Controls/TimeSpreadigControl.cs +++ b/src/Logexpert.UI/Controls/LogWindow/TimeSpreadigControl.cs @@ -1,7 +1,7 @@ using LogExpert.Classes; using LogExpert.Core.Classes; -using LogExpert.Core.EventArgs; - +using LogExpert.Core.EventArguments; +using LogExpert.UI.Controls.LogWindow; using NLog; using System; @@ -9,9 +9,9 @@ using System.Drawing; using System.Windows.Forms; -namespace LogExpert.Dialogs +namespace LogExpert.UI.Controls.LogWindow { - public partial class TimeSpreadingControl : UserControl + internal partial class TimeSpreadingControl : UserControl { private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); diff --git a/src/LogExpert/Controls/TimeSpreadigControl.resx b/src/Logexpert.UI/Controls/LogWindow/TimeSpreadigControl.resx similarity index 100% rename from src/LogExpert/Controls/TimeSpreadigControl.resx rename to src/Logexpert.UI/Controls/LogWindow/TimeSpreadigControl.resx diff --git a/src/LogExpert/Classes/TimeSyncList.cs b/src/Logexpert.UI/Controls/LogWindow/TimeSyncList.cs similarity index 89% rename from src/LogExpert/Classes/TimeSyncList.cs rename to src/Logexpert.UI/Controls/LogWindow/TimeSyncList.cs index a5d40d34..67d5c392 100644 --- a/src/LogExpert/Classes/TimeSyncList.cs +++ b/src/Logexpert.UI/Controls/LogWindow/TimeSyncList.cs @@ -1,106 +1,101 @@ -using LogExpert.Controls.LogWindow; - -using System; -using System.Collections.Generic; - -namespace LogExpert.Classes -{ - /// - /// Holds all windows which are in sync via timestamp - /// - public class TimeSyncList - { - #region Fields - - private readonly IList logWindowList = new List(); - - #endregion - - #region Delegates - - public delegate void WindowRemovedEventHandler(object sender, EventArgs e); - - #endregion - - #region Events - - public event WindowRemovedEventHandler WindowRemoved; - - #endregion - - #region Properties - - public DateTime CurrentTimestamp { get; set; } - - public int Count - { - get { return logWindowList.Count; } - } - - #endregion - - #region Public methods - - public void AddWindow(LogWindow logWindow) - { - lock (logWindowList) - { - if (!logWindowList.Contains(logWindow)) - { - logWindowList.Add(logWindow); - } - } - } - - - public void RemoveWindow(LogWindow logWindow) - { - lock (logWindowList) - { - logWindowList.Remove(logWindow); - } - OnWindowRemoved(); - } - - - /// - /// Scrolls all LogWindows to the given timestamp - /// - /// - /// - public void NavigateToTimestamp(DateTime timestamp, LogWindow sender) - { - CurrentTimestamp = timestamp; - lock (logWindowList) - { - foreach (LogWindow logWindow in logWindowList) - { - if (sender != logWindow) - { - logWindow.ScrollToTimestamp(timestamp, false, false); - } - } - } - } - - - public bool Contains(LogWindow logWindow) - { - return logWindowList.Contains(logWindow); - } - - #endregion - - #region Private Methods - - private void OnWindowRemoved() - { - if (WindowRemoved != null) - { - WindowRemoved(this, new EventArgs()); - } - } - - #endregion - } +namespace LogExpert.UI.Controls.LogWindow +{ + /// + /// Holds all windows which are in sync via timestamp + /// + internal class TimeSyncList + { + #region Fields + + private readonly IList logWindowList = new List(); + + #endregion + + #region Delegates + + public delegate void WindowRemovedEventHandler(object sender, EventArgs e); + + #endregion + + #region Events + + public event WindowRemovedEventHandler WindowRemoved; + + #endregion + + #region Properties + + public DateTime CurrentTimestamp { get; set; } + + public int Count + { + get { return logWindowList.Count; } + } + + #endregion + + #region Public methods + + public void AddWindow(LogWindow logWindow) + { + lock (logWindowList) + { + if (!logWindowList.Contains(logWindow)) + { + logWindowList.Add(logWindow); + } + } + } + + + public void RemoveWindow(LogWindow logWindow) + { + lock (logWindowList) + { + logWindowList.Remove(logWindow); + } + OnWindowRemoved(); + } + + + /// + /// Scrolls all LogWindows to the given timestamp + /// + /// + /// + public void NavigateToTimestamp(DateTime timestamp, LogWindow sender) + { + CurrentTimestamp = timestamp; + lock (logWindowList) + { + foreach (LogWindow logWindow in logWindowList) + { + if (sender != logWindow) + { + logWindow.ScrollToTimestamp(timestamp, false, false); + } + } + } + } + + + public bool Contains(LogWindow logWindow) + { + return logWindowList.Contains(logWindow); + } + + #endregion + + #region Private Methods + + private void OnWindowRemoved() + { + if (WindowRemoved != null) + { + WindowRemoved(this, new EventArgs()); + } + } + + #endregion + } } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.Designer.cs b/src/Logexpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.Designer.cs new file mode 100644 index 00000000..6a07b9df --- /dev/null +++ b/src/Logexpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.Designer.cs @@ -0,0 +1,98 @@ +namespace LogExpert.Dialogs; + +partial class AllowOnlyOneInstanceErrorDialog +{ + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.checkBoxIgnoreMessage = new System.Windows.Forms.CheckBox(); + this.buttonOk = new System.Windows.Forms.Button(); + this.labelErrorText = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // checkBoxIgnoreMessage + // + this.checkBoxIgnoreMessage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.checkBoxIgnoreMessage.AutoSize = true; + this.checkBoxIgnoreMessage.Location = new System.Drawing.Point(9, 56); + this.checkBoxIgnoreMessage.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.checkBoxIgnoreMessage.Name = "checkBoxIgnoreMessage"; + this.checkBoxIgnoreMessage.Size = new System.Drawing.Size(177, 17); + this.checkBoxIgnoreMessage.TabIndex = 0; + this.checkBoxIgnoreMessage.Text = "Show this message only once\\?"; + this.checkBoxIgnoreMessage.UseVisualStyleBackColor = true; + // + // buttonOk + // + this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(209, 53); + this.buttonOk.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(74, 23); + this.buttonOk.TabIndex = 1; + this.buttonOk.Text = "Ok"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.OnButtonOkClick); + // + // labelErrorText + // + this.labelErrorText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.labelErrorText.AutoEllipsis = true; + this.labelErrorText.Location = new System.Drawing.Point(9, 8); + this.labelErrorText.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.labelErrorText.Name = "labelErrorText"; + this.labelErrorText.Size = new System.Drawing.Size(273, 43); + this.labelErrorText.TabIndex = 2; + this.labelErrorText.Text = "Only one instance allowed, uncheck \\\"View Settings => Allow only 1 Instances\\\" to" + +" start multiple instances!"; + // + // AllowOnlyOneInstanceErrorDialog + // + this.ClientSize = new System.Drawing.Size(293, 84); + this.Controls.Add(this.labelErrorText); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.checkBoxIgnoreMessage); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.MaximizeBox = false; + this.Name = "AllowOnlyOneInstanceErrorDialog"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.Text = "AllowOnlyOneInstanceErrorDialog"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.CheckBox checkBoxIgnoreMessage; + private System.Windows.Forms.Button buttonOk; + private System.Windows.Forms.Label labelErrorText; +} \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.cs b/src/Logexpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.cs new file mode 100644 index 00000000..717d3e00 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.cs @@ -0,0 +1,24 @@ +using System.Windows.Forms; + +namespace LogExpert.Dialogs; + +public partial class AllowOnlyOneInstanceErrorDialog : Form +{ + public bool DoNotShowThisMessageAgain { get; private set; } + + public AllowOnlyOneInstanceErrorDialog() + { + InitializeComponent(); + SetText(); + } + + private void SetText() + { + labelErrorText.Text = @"Only one instance allowed, uncheck ""View Settings => Allow only 1 Instances"" to start multiple instances!"; + } + + private void OnButtonOkClick(object sender, System.EventArgs e) + { + DoNotShowThisMessageAgain = checkBoxIgnoreMessage.Checked; + } +} diff --git a/src/LogExpert/Dialogs/AllowOnlyOneInstanceErrorDialog.resx b/src/Logexpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.resx similarity index 100% rename from src/LogExpert/Dialogs/AllowOnlyOneInstanceErrorDialog.resx rename to src/Logexpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.resx diff --git a/src/Logexpert.UI/Dialogs/BookmarkWindow.Designer.cs b/src/Logexpert.UI/Dialogs/BookmarkWindow.Designer.cs new file mode 100644 index 00000000..c7310c5f --- /dev/null +++ b/src/Logexpert.UI/Dialogs/BookmarkWindow.Designer.cs @@ -0,0 +1,195 @@ +namespace LogExpert.Dialogs; +partial class BookmarkWindow { +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; + +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); +} + +#region Windows Form Designer generated code + +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BookmarkWindow)); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.deleteBookmarkssToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeCommentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.bookmarkTextBox = new System.Windows.Forms.TextBox(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.bookmarkDataGridView = new LogExpert.Dialogs.BufferedDataGridView(); + this.commentColumnCheckBox = new System.Windows.Forms.CheckBox(); + this.label1 = new System.Windows.Forms.Label(); + this.contextMenuStrip1.SuspendLayout(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.bookmarkDataGridView)).BeginInit(); + this.SuspendLayout(); + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.deleteBookmarkssToolStripMenuItem, + this.removeCommentsToolStripMenuItem}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(186, 48); + // + // deleteBookmarkssToolStripMenuItem + // + this.deleteBookmarkssToolStripMenuItem.Name = "deleteBookmarkssToolStripMenuItem"; + this.deleteBookmarkssToolStripMenuItem.Size = new System.Drawing.Size(185, 22); + this.deleteBookmarkssToolStripMenuItem.Text = "Delete bookmarks(s)"; + this.deleteBookmarkssToolStripMenuItem.Click += new System.EventHandler(this.deleteBookmarksToolStripMenuItem_Click); + // + // removeCommentsToolStripMenuItem + // + this.removeCommentsToolStripMenuItem.Name = "removeCommentsToolStripMenuItem"; + this.removeCommentsToolStripMenuItem.Size = new System.Drawing.Size(185, 22); + this.removeCommentsToolStripMenuItem.Text = "Remove comment(s)"; + this.removeCommentsToolStripMenuItem.Click += new System.EventHandler(this.removeCommentsToolStripMenuItem_Click); + // + // bookmarkTextBox + // + this.bookmarkTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.bookmarkTextBox.Location = new System.Drawing.Point(0, 20); + this.bookmarkTextBox.Multiline = true; + this.bookmarkTextBox.Name = "bookmarkTextBox"; + this.bookmarkTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.bookmarkTextBox.Size = new System.Drawing.Size(194, 114); + this.bookmarkTextBox.TabIndex = 0; + this.bookmarkTextBox.TextChanged += new System.EventHandler(this.bookmarkTextBox_TextChanged); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.bookmarkDataGridView); + this.splitContainer1.Panel1MinSize = 40; + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.commentColumnCheckBox); + this.splitContainer1.Panel2.Controls.Add(this.label1); + this.splitContainer1.Panel2.Controls.Add(this.bookmarkTextBox); + this.splitContainer1.Size = new System.Drawing.Size(717, 158); + this.splitContainer1.SplitterDistance = 517; + this.splitContainer1.TabIndex = 7; + // + // bookmarkDataGridView + // + this.bookmarkDataGridView.AllowUserToAddRows = false; + this.bookmarkDataGridView.AllowUserToDeleteRows = false; + this.bookmarkDataGridView.AllowUserToOrderColumns = true; + this.bookmarkDataGridView.AllowUserToResizeRows = false; + this.bookmarkDataGridView.BackgroundColor = System.Drawing.SystemColors.Window; + this.bookmarkDataGridView.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.bookmarkDataGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; + this.bookmarkDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.bookmarkDataGridView.ContextMenuStrip = this.contextMenuStrip1; + this.bookmarkDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; + this.bookmarkDataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; + this.bookmarkDataGridView.EditModeMenuStrip = null; + this.bookmarkDataGridView.Location = new System.Drawing.Point(0, 0); + this.bookmarkDataGridView.Margin = new System.Windows.Forms.Padding(0); + this.bookmarkDataGridView.Name = "bookmarkDataGridView"; + this.bookmarkDataGridView.PaintWithOverlays = false; + this.bookmarkDataGridView.ReadOnly = true; + this.bookmarkDataGridView.RowHeadersVisible = false; + this.bookmarkDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.bookmarkDataGridView.Size = new System.Drawing.Size(517, 158); + this.bookmarkDataGridView.TabIndex = 0; + this.bookmarkDataGridView.VirtualMode = true; + this.bookmarkDataGridView.Enter += new System.EventHandler(this.bookmarkGridView_Enter); + this.bookmarkDataGridView.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.bookmarkDataGridView_CellDoubleClick); + this.bookmarkDataGridView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.boomarkDataGridView_MouseDoubleClick); + this.bookmarkDataGridView.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.bookmarkDataGridView_PreviewKeyDown); + this.bookmarkDataGridView.Leave += new System.EventHandler(this.bookmarkGridView_Leave); + this.bookmarkDataGridView.ColumnDividerDoubleClick += new System.Windows.Forms.DataGridViewColumnDividerDoubleClickEventHandler(this.boomarkDataGridView_ColumnDividerDoubleClick); + this.bookmarkDataGridView.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(this.bookmarkDataGridView_RowsAdded); + this.bookmarkDataGridView.SelectionChanged += new System.EventHandler(bookmarkDataGridView_SelectionChanged); + this.bookmarkDataGridView.CellToolTipTextNeeded += new System.Windows.Forms.DataGridViewCellToolTipTextNeededEventHandler(this.bookmarkDataGridView_CellToolTipTextNeeded); + this.bookmarkDataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.bookmarkGridView_KeyDown); + this.bookmarkDataGridView.RowsRemoved += new System.Windows.Forms.DataGridViewRowsRemovedEventHandler(this.bookmarkDataGridView_RowsRemoved); + // + // commentColumnCheckBox + // + this.commentColumnCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.commentColumnCheckBox.AutoSize = true; + this.commentColumnCheckBox.Location = new System.Drawing.Point(7, 138); + this.commentColumnCheckBox.Name = "commentColumnCheckBox"; + this.commentColumnCheckBox.Size = new System.Drawing.Size(136, 17); + this.commentColumnCheckBox.TabIndex = 8; + this.commentColumnCheckBox.Text = "Show comment column"; + this.commentColumnCheckBox.UseVisualStyleBackColor = true; + this.commentColumnCheckBox.CheckedChanged += new System.EventHandler(this.commentColumnCheckBox_CheckedChanged); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(4, 4); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(104, 13); + this.label1.TabIndex = 7; + this.label1.Text = "Bookmark comment:"; + // + // BookmarkWindow + // + this.ClientSize = new System.Drawing.Size(717, 158); + this.ControlBox = false; + this.Controls.Add(this.splitContainer1); + this.DockAreas = ((WeifenLuo.WinFormsUI.Docking.DockAreas)(((((WeifenLuo.WinFormsUI.Docking.DockAreas.Float | WeifenLuo.WinFormsUI.Docking.DockAreas.DockLeft) + | WeifenLuo.WinFormsUI.Docking.DockAreas.DockRight) + | WeifenLuo.WinFormsUI.Docking.DockAreas.DockTop) + | WeifenLuo.WinFormsUI.Docking.DockAreas.DockBottom))); + this.DoubleBuffered = true; + this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "BookmarkWindow"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.Text = "Bookmarks"; + this.ClientSizeChanged += new System.EventHandler(this.BookmarkWindow_ClientSizeChanged); + this.SizeChanged += new System.EventHandler(this.BookmarkWindow_SizeChanged); + this.contextMenuStrip1.ResumeLayout(false); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + this.splitContainer1.Panel2.PerformLayout(); + this.splitContainer1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.bookmarkDataGridView)).EndInit(); + this.ResumeLayout(false); +} + +#endregion + +private BufferedDataGridView bookmarkDataGridView; +private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; +private System.Windows.Forms.ToolStripMenuItem deleteBookmarkssToolStripMenuItem; +private System.Windows.Forms.TextBox bookmarkTextBox; +private System.Windows.Forms.SplitContainer splitContainer1; +private System.Windows.Forms.Label label1; +private System.Windows.Forms.ToolStripMenuItem removeCommentsToolStripMenuItem; +private System.Windows.Forms.CheckBox commentColumnCheckBox; +} \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/BookmarkWindow.cs b/src/Logexpert.UI/Dialogs/BookmarkWindow.cs new file mode 100644 index 00000000..328a7366 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/BookmarkWindow.cs @@ -0,0 +1,682 @@ +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.Enums; +using LogExpert.Core.Interface; +using LogExpert.UI.Entities; +using LogExpert.UI.Extensions.Forms; + +using NLog; + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; + +using WeifenLuo.WinFormsUI.Docking; + +namespace LogExpert.Dialogs; + +//TODO can be moved to Logexpert.UI if the PaintHelper has been refactored +public partial class BookmarkWindow : DockContent, ISharedToolWindow, IBookmarkView +{ + #region Fields + + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private readonly object paintLock = new(); + + private IBookmarkData bookmarkData; + private ILogPaintContext logPaintContext; + private ILogView logView; + + #endregion + + #region cTor + + public BookmarkWindow() + { + InitializeComponent(); + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + bookmarkDataGridView.CellValueNeeded += OnBoomarkDataGridViewCellValueNeeded; + bookmarkDataGridView.CellPainting += boomarkDataGridView_CellPainting; + + ChangeTheme(Controls); + } + + #endregion + + #region ColorTheme + + public void ChangeTheme(Control.ControlCollection container) + { + #region ApplyColorToAllControls + foreach (Control component in container) + { + if (component.Controls != null && component.Controls.Count > 0) + { + ChangeTheme(component.Controls); + component.BackColor = ColorMode.BackgroundColor; + component.ForeColor = ColorMode.ForeColor; + } + else + { + component.BackColor = ColorMode.BackgroundColor; + component.ForeColor = ColorMode.ForeColor; + } + + } + #endregion + + #region DataGridView + + BackColor = ColorMode.DockBackgroundColor; + + // Main DataGridView + bookmarkDataGridView.BackgroundColor = ColorMode.DockBackgroundColor; + bookmarkDataGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor; + bookmarkDataGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor; + bookmarkDataGridView.EnableHeadersVisualStyles = false; + + // Colors for menu + contextMenuStrip1.Renderer = new ExtendedMenuStripRenderer(); + + for (var y = 0; y < contextMenuStrip1.Items.Count; y++) + { + var item = contextMenuStrip1.Items[y]; + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.MenuBackgroundColor; + } + + #endregion DataGridView + } + + #endregion + + #region Properties + + public bool LineColumnVisible + { + set => bookmarkDataGridView.Columns[2].Visible = value; + } + + public bool ShowBookmarkCommentColumn + { + get => commentColumnCheckBox.Checked; + set + { + commentColumnCheckBox.Checked = value; + ShowCommentColumn(value); + } + } + + #endregion + + #region Public methods + + public void SetColumnizer(ILogLineColumnizer columnizer) + { + PaintHelper.SetColumnizer(columnizer, bookmarkDataGridView); + + if (bookmarkDataGridView.ColumnCount > 0) + { + bookmarkDataGridView.Columns[0].Width = 20; + } + + DataGridViewTextBoxColumn commentColumn = new(); + commentColumn.HeaderText = "Bookmark Comment"; + commentColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; + commentColumn.Resizable = DataGridViewTriState.NotSet; + commentColumn.DividerWidth = 1; + commentColumn.ReadOnly = true; + commentColumn.Width = 250; + commentColumn.MinimumWidth = 130; + bookmarkDataGridView.Columns.Insert(1, commentColumn); + ShowCommentColumn(commentColumnCheckBox.Checked); + ResizeColumns(); + } + + /// + /// Called from LogWindow after reloading and when double clicking a header divider. + /// + public void ResizeColumns() + { + // this.bookmarkDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + for (int i = 2; i < bookmarkDataGridView.ColumnCount; ++i) + { + bookmarkDataGridView.AutoResizeColumn(i, DataGridViewAutoSizeColumnMode.DisplayedCells); + } + } + + public void UpdateView() + { + bookmarkDataGridView.RowCount = bookmarkData?.Bookmarks.Count ?? 0; + ResizeColumns(); + bookmarkDataGridView.Refresh(); + } + + /// + /// Called from LogWindow if the bookmark text was changed via popup window + /// + /// + public void BookmarkTextChanged(Bookmark bookmark) + { + int rowIndex = bookmarkDataGridView.CurrentCellAddress.Y; + if (rowIndex == -1) + { + return; + } + + if (bookmarkData.Bookmarks[rowIndex] == bookmark) + { + bookmarkTextBox.Text = bookmark.Text; + } + + bookmarkDataGridView.Refresh(); + } + + public void SelectBookmark(int lineNum) + { + if (bookmarkData.IsBookmarkAtLine(lineNum)) + { + if (bookmarkDataGridView.Rows.GetRowCount(DataGridViewElementStates.None) < bookmarkData.Bookmarks.Count) + { + // just for the case... There was an exception but I cannot find the cause + UpdateView(); + } + + int row = bookmarkData.GetBookmarkIndexForLine(lineNum); + bookmarkDataGridView.CurrentCell = bookmarkDataGridView.Rows[row].Cells[0]; + } + } + + public void SetBookmarkData(IBookmarkData bookmarkData) + { + this.bookmarkData = bookmarkData; + bookmarkDataGridView.RowCount = bookmarkData?.Bookmarks.Count ?? 0; + HideIfNeeded(); + } + + //TODO: BAD DESIGN! FIX!!! + public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags, IConfigManager configManager) { + if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors) + { + SetFont(newPreferences.fontName, newPreferences.fontSize); + if (bookmarkDataGridView.Columns.Count > 1 && newPreferences.setLastColumnWidth) + { + bookmarkDataGridView.Columns[bookmarkDataGridView.Columns.Count - 1].MinimumWidth = + newPreferences.lastColumnWidth; + } + + PaintHelper.ApplyDataGridViewPrefs(bookmarkDataGridView, newPreferences, configManager); + } + } + + //TODO: BAD DESIGN! FIX!!! + public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags) + { + PreferencesChanged(newPreferences, isLoadTime, flags, null); + } + + public void SetCurrentFile(FileViewContext ctx) + { + if (ctx != null) + { + _logger.Debug("Current file changed to {0}", ctx.LogView.FileName); + lock (paintLock) + { + logView = ctx.LogView; + logPaintContext = ctx.LogPaintContext; + } + + SetColumnizer(ctx.LogView.CurrentColumnizer); + } + else + { + logView = null; + logPaintContext = null; + } + + UpdateView(); + } + + public void FileChanged() + { + // nothing to do + } + + #endregion + + #region Overrides + + protected override string GetPersistString() + { + return WindowTypes.BookmarkWindow.ToString(); + } + + protected override void OnPaint(PaintEventArgs e) + { + if (!splitContainer1.Visible) + { + Rectangle r = ClientRectangle; + e.Graphics.FillRectangle(SystemBrushes.FromSystemColor(ColorMode.BookmarksDefaultBackgroundColor), r); + RectangleF rect = r; + StringFormat sf = new(); + sf.Alignment = StringAlignment.Center; + sf.LineAlignment = StringAlignment.Center; + e.Graphics.DrawString("No bookmarks in current file", SystemFonts.DialogFont, SystemBrushes.WindowText, r, sf); + } + else + { + base.OnPaint(e); + } + } + + #endregion + + #region Private Methods + + private void SetFont(string fontName, float fontSize) + { + Font font = new(new FontFamily(fontName), fontSize); + bookmarkDataGridView.DefaultCellStyle.Font = font; + bookmarkDataGridView.RowTemplate.Height = font.Height + 4; + bookmarkDataGridView.Refresh(); + } + + private void CommentPainting(BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) + { + Color backColor = ColorMode.DockBackgroundColor; + + if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) + { + Brush brush; + if (gridView.Focused) + { + // _logger.logDebug("CellPaint Focus"); + brush = new SolidBrush(backColor); + } + else + { + // _logger.logDebug("CellPaint No Focus"); + Color color = Color.FromArgb(255, 170, 170, 170); + brush = new SolidBrush(color); + } + + e.Graphics.FillRectangle(brush, e.CellBounds); + brush.Dispose(); + } + else + { + e.CellStyle.BackColor = backColor; + e.PaintBackground(e.CellBounds, false); + } + + e.PaintContent(e.CellBounds); + } + + private void DeleteSelectedBookmarks() + { + List lineNumList = []; + foreach (DataGridViewRow row in bookmarkDataGridView.SelectedRows) + { + if (row.Index != -1) + { + lineNumList.Add(bookmarkData.Bookmarks[row.Index].LineNum); + } + } + + logView?.DeleteBookmarks(lineNumList); + } + + private static void InvalidateCurrentRow(BufferedDataGridView gridView) + { + if (gridView.CurrentCellAddress.Y > -1) + { + gridView.InvalidateRow(gridView.CurrentCellAddress.Y); + } + } + + private void CurrentRowChanged(int rowIndex) + { + if (rowIndex == -1) + { + // multiple selection or no selection at all + bookmarkTextBox.Enabled = false; + + // disable the control first so that changes made to it won't propagate to the bookmark item + bookmarkTextBox.Text = string.Empty; + } + else + { + Bookmark bookmark = bookmarkData.Bookmarks[rowIndex]; + bookmarkTextBox.Text = bookmark.Text; + bookmarkTextBox.Enabled = true; + } + } + + private void ShowCommentColumn(bool show) + { + bookmarkDataGridView.Columns[1].Visible = show; + } + + private void HideIfNeeded() + { + splitContainer1.Visible = bookmarkDataGridView.RowCount > 0; + } + + #endregion + + #region Events handler + + private void boomarkDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) + { + if (bookmarkData == null) + { + return; + } + + lock (paintLock) + { + try + { + if (e.RowIndex < 0 || e.ColumnIndex < 0 || bookmarkData.Bookmarks.Count <= e.RowIndex) + { + e.Handled = false; + return; + } + + int lineNum = bookmarkData.Bookmarks[e.RowIndex].LineNum; + + // if (e.ColumnIndex == 1) + // { + // CommentPainting(this.bookmarkDataGridView, lineNum, e); + // } + { + // else + PaintHelper.CellPainting(logPaintContext, bookmarkDataGridView, lineNum, e); + } + } + catch (Exception ex) + { + _logger.Error(ex); + } + } + } + + private void OnBoomarkDataGridViewCellValueNeeded(object sender, DataGridViewCellValueEventArgs e) + { + if (bookmarkData == null) + { + return; + } + + if (e.RowIndex < 0 || e.ColumnIndex < 0 || bookmarkData.Bookmarks.Count <= e.RowIndex) + { + e.Value = string.Empty; + return; + } + + Bookmark bookmarkForLine = bookmarkData.Bookmarks[e.RowIndex]; + int lineNum = bookmarkForLine.LineNum; + if (e.ColumnIndex == 1) + { + e.Value = bookmarkForLine.Text?.Replace('\n', ' ').Replace('\r', ' '); + } + else + { + int columnIndex = e.ColumnIndex > 1 ? e.ColumnIndex - 1 : e.ColumnIndex; + e.Value = logPaintContext.GetCellValue(lineNum, columnIndex); + } + } + + + private void boomarkDataGridView_MouseDoubleClick(object sender, MouseEventArgs e) + { + // if (this.bookmarkDataGridView.CurrentRow != null) + // { + // int lineNum = this.BookmarkList.Values[this.bookmarkDataGridView.CurrentRow.Index].LineNum; + // this.logWindow.SelectLogLine(lineNum); + // } + } + + private void boomarkDataGridView_ColumnDividerDoubleClick(object sender, + DataGridViewColumnDividerDoubleClickEventArgs e) + { + e.Handled = true; + ResizeColumns(); + } + + private void bookmarkGridView_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + if (bookmarkDataGridView.CurrentCellAddress.Y >= 0 && + bookmarkDataGridView.CurrentCellAddress.Y < bookmarkData.Bookmarks.Count) + { + int lineNum = bookmarkData.Bookmarks[bookmarkDataGridView.CurrentCellAddress.Y].LineNum; + logView.SelectLogLine(lineNum); + } + + e.Handled = true; + } + + if (e.KeyCode == Keys.Delete && e.Modifiers == Keys.None) + { + DeleteSelectedBookmarks(); + } + + if (e.KeyCode == Keys.Tab) + { + if (bookmarkDataGridView.Focused) + { + bookmarkTextBox.Focus(); + e.Handled = true; + } + } + } + + private void bookmarkGridView_Enter(object sender, EventArgs e) + { + InvalidateCurrentRow(bookmarkDataGridView); + } + + private void bookmarkGridView_Leave(object sender, EventArgs e) + { + InvalidateCurrentRow(bookmarkDataGridView); + } + + private void deleteBookmarksToolStripMenuItem_Click(object sender, EventArgs e) + { + DeleteSelectedBookmarks(); + } + + private void bookmarkTextBox_TextChanged(object sender, EventArgs e) + { + if (!bookmarkTextBox.Enabled) + { + return; // ignore all changes done while the control is disabled + } + + int rowIndex = bookmarkDataGridView.CurrentCellAddress.Y; + if (rowIndex == -1) + { + return; + } + + if (bookmarkData.Bookmarks.Count <= rowIndex) + { + return; + } + + Bookmark bookmark = bookmarkData.Bookmarks[rowIndex]; + bookmark.Text = bookmarkTextBox.Text; + logView?.RefreshLogView(); + } + + private void bookmarkDataGridView_SelectionChanged(object sender, EventArgs e) + { + if (bookmarkDataGridView.SelectedRows.Count != 1 + || bookmarkDataGridView.SelectedRows[0].Index >= bookmarkData.Bookmarks.Count) + { + CurrentRowChanged(-1); + } + else + { + CurrentRowChanged(bookmarkDataGridView.SelectedRows[0].Index); + } + } + + private void bookmarkDataGridView_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) + { + if (e.KeyCode == Keys.Tab) + { + e.IsInputKey = true; + } + } + + private void bookmarkDataGridView_CellToolTipTextNeeded(object sender, + DataGridViewCellToolTipTextNeededEventArgs e) + { + if (e.ColumnIndex != 0 || e.RowIndex <= -1 || e.RowIndex >= bookmarkData.Bookmarks.Count) + { + return; + } + + Bookmark bookmark = bookmarkData.Bookmarks[e.RowIndex]; + if (!string.IsNullOrEmpty(bookmark.Text)) + { + e.ToolTipText = bookmark.Text; + return; + } + } + + private void bookmarkDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) + { + // Toggle bookmark when double-clicking on the first column + if (e.ColumnIndex == 0 && e.RowIndex >= 0 && bookmarkDataGridView.CurrentRow != null) + { + int index = bookmarkDataGridView.CurrentRow.Index; + int lineNum = bookmarkData.Bookmarks[bookmarkDataGridView.CurrentRow.Index].LineNum; + bookmarkData.ToggleBookmark(lineNum); + + // we don't ask for confirmation if the bookmark has an associated comment... + int boomarkCount = bookmarkData.Bookmarks.Count; + bookmarkDataGridView.RowCount = boomarkCount; + + if (index < boomarkCount) + { + bookmarkDataGridView.CurrentCell = bookmarkDataGridView.Rows[index].Cells[0]; + } + else + { + if (boomarkCount > 0) + { + bookmarkDataGridView.CurrentCell = + bookmarkDataGridView.Rows[boomarkCount - 1].Cells[0]; + } + } + + if (boomarkCount > index) + { + CurrentRowChanged(index); + } + else + { + if (boomarkCount > 0) + { + CurrentRowChanged(bookmarkDataGridView.RowCount - 1); + } + else + { + CurrentRowChanged(-1); + } + } + + return; + } + + if (bookmarkDataGridView.CurrentRow != null && e.RowIndex >= 0) + { + int lineNum = bookmarkData.Bookmarks[bookmarkDataGridView.CurrentRow.Index].LineNum; + logView.SelectAndEnsureVisible(lineNum, true); + } + } + + private void removeCommentsToolStripMenuItem_Click(object sender, EventArgs e) + { + if ( + MessageBox.Show("Really remove bookmark comments for selected lines?", "LogExpert", + MessageBoxButtons.YesNo) == + DialogResult.Yes) + { + List lineNumList = []; + foreach (DataGridViewRow row in bookmarkDataGridView.SelectedRows) + { + if (row.Index != -1) + { + bookmarkData.Bookmarks[row.Index].Text = string.Empty; + } + } + + bookmarkTextBox.Text = string.Empty; + bookmarkDataGridView.Refresh(); + logView.RefreshLogView(); + } + } + + private void commentColumnCheckBox_CheckedChanged(object sender, EventArgs e) + { + ShowCommentColumn(commentColumnCheckBox.Checked); + } + + private void BookmarkWindow_ClientSizeChanged(object sender, EventArgs e) + { + if (Width > 0 && Height > 0) + { + if (Width > Height) + { + splitContainer1.Orientation = Orientation.Vertical; + int distance = Width - 200; + splitContainer1.SplitterDistance = distance > splitContainer1.Panel1MinSize + ? distance + : splitContainer1.Panel1MinSize; + } + else + { + splitContainer1.Orientation = Orientation.Horizontal; + int distance = Height - 200; + splitContainer1.SplitterDistance = distance > splitContainer1.Panel1MinSize + ? distance + : splitContainer1.Panel1MinSize; + } + } + + if (!splitContainer1.Visible) + { + // redraw the "no bookmarks" display + Invalidate(); + } + } + + private void bookmarkDataGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) + { + HideIfNeeded(); + } + + private void bookmarkDataGridView_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e) + { + HideIfNeeded(); + } + + private void BookmarkWindow_SizeChanged(object sender, EventArgs e) + { + // if (!this.splitContainer1.Visible) + // { + // // redraw the "no bookmarks" display + // Invalidate(); + // } + } + + #endregion +} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/BookmarkWindow.resx b/src/Logexpert.UI/Dialogs/BookmarkWindow.resx similarity index 98% rename from src/LogExpert/Dialogs/BookmarkWindow.resx rename to src/Logexpert.UI/Dialogs/BookmarkWindow.resx index 5815d62c..4963f92b 100644 --- a/src/LogExpert/Dialogs/BookmarkWindow.resx +++ b/src/Logexpert.UI/Dialogs/BookmarkWindow.resx @@ -1,151 +1,151 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - - - AAABAAEADg4AAAEACABABQAAFgAAACgAAAAOAAAAHAAAAAEACAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAA - AADrw3EA7MNxAP7+/gD01ZQA4q9LANmdKAD64asA1JERAPTUkwDi4+IA2Z4oAP39/QDw8O8A5ebmAPf4 - +ADz8/IA8fLyAOOvSwDr6ukA6enoAPDx8QD7+/wA9PTzAP79/QD+//4A9fb2AOKvSgDn5+YA4rBLAN/g - 3wD29vYA7e3tAPn5+QD7+vsA+/v7APf39wDr6+sA3t7dAO/v7gDa2tkA7OzsAOTk4wD8/PwAwcHBAC8v - LwB8fHwA////AP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAALy8vLy8vLywsLy8vLy8AAC0tLS0tLSwGBiwrLy8vAAAtLisrKywIAwMILC8vLwAALS4uLiwB - AAEBAAAsLy8AAC0uGC4sBBEsLBoEHCwvAAAtLhUCLiwsLi4sBQUKLAAALS4jIQsuLi4uKywHBywAAC0u - EBkgKgIuListLCwvAAAtLigMFg4iFy4rLS8vLwAALS4NEiYPHisrKy0vLy8AAC0uHSkTHxQtLS0tLy8v - AAAtLiclCRskLS4uLS8vLwAALS4uLi4uLi0uLS8vLy8AAC0tLS0tLS0tLS8vLy8vAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + + AAABAAEADg4AAAEACABABQAAFgAAACgAAAAOAAAAHAAAAAEACAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAA + AADrw3EA7MNxAP7+/gD01ZQA4q9LANmdKAD64asA1JERAPTUkwDi4+IA2Z4oAP39/QDw8O8A5ebmAPf4 + +ADz8/IA8fLyAOOvSwDr6ukA6enoAPDx8QD7+/wA9PTzAP79/QD+//4A9fb2AOKvSgDn5+YA4rBLAN/g + 3wD29vYA7e3tAPn5+QD7+vsA+/v7APf39wDr6+sA3t7dAO/v7gDa2tkA7OzsAOTk4wD8/PwAwcHBAC8v + LwB8fHwA////AP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAALy8vLy8vLywsLy8vLy8AAC0tLS0tLSwGBiwrLy8vAAAtLisrKywIAwMILC8vLwAALS4uLiwB + AAEBAAAsLy8AAC0uGC4sBBEsLBoEHCwvAAAtLhUCLiwsLi4sBQUKLAAALS4jIQsuLi4uKywHBywAAC0u + EBkgKgIuListLCwvAAAtLigMFg4iFy4rLS8vLwAALS4NEiYPHisrKy0vLy8AAC0uHSkTHxQtLS0tLy8v + AAAtLiclCRskLS4uLS8vLwAALS4uLi4uLi0uLS8vLy8AAC0tLS0tLS0tLS8vLy8vAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/ExceptionWindow.Designer.cs b/src/Logexpert.UI/Dialogs/ExceptionWindow.Designer.cs index f3aa0fc6..7c7b4c72 100644 --- a/src/Logexpert.UI/Dialogs/ExceptionWindow.Designer.cs +++ b/src/Logexpert.UI/Dialogs/ExceptionWindow.Designer.cs @@ -1,108 +1,107 @@ -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +partial class ExceptionWindow { - partial class ExceptionWindow - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} - #region Windows Form Designer generated code +#region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ExceptionWindow)); - this.stackTraceTextBox = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); - this.okButton = new System.Windows.Forms.Button(); - this.copyButton = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // stackTraceTextBox - // - this.stackTraceTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.stackTraceTextBox.Location = new System.Drawing.Point(12, 42); - this.stackTraceTextBox.Multiline = true; - this.stackTraceTextBox.Name = "stackTraceTextBox"; - this.stackTraceTextBox.ReadOnly = true; - this.stackTraceTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.stackTraceTextBox.Size = new System.Drawing.Size(439, 205); - this.stackTraceTextBox.TabIndex = 0; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(13, 13); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(310, 13); - this.label1.TabIndex = 1; - this.label1.Text = "An unhandled error has occured. Please report to the developer."; - // - // okButton - // - this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.okButton.Location = new System.Drawing.Point(376, 265); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(75, 23); - this.okButton.TabIndex = 2; - this.okButton.Text = "Close"; - this.okButton.UseVisualStyleBackColor = true; - // - // copyButton - // - this.copyButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.copyButton.Location = new System.Drawing.Point(12, 265); - this.copyButton.Name = "copyButton"; - this.copyButton.Size = new System.Drawing.Size(117, 23); - this.copyButton.TabIndex = 4; - this.copyButton.Text = "Copy to clipboard"; - this.copyButton.UseVisualStyleBackColor = true; - this.copyButton.Click += new System.EventHandler(this.copyButton_Click); - // - // ExceptionWindow - // - this.CancelButton = this.okButton; - this.ClientSize = new System.Drawing.Size(464, 300); - this.Controls.Add(this.copyButton); - this.Controls.Add(this.okButton); - this.Controls.Add(this.label1); - this.Controls.Add(this.stackTraceTextBox); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ExceptionWindow"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "LogExpert Error"; - this.ResumeLayout(false); - this.PerformLayout(); +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ExceptionWindow)); + this.stackTraceTextBox = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.okButton = new System.Windows.Forms.Button(); + this.copyButton = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // stackTraceTextBox + // + this.stackTraceTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.stackTraceTextBox.Location = new System.Drawing.Point(12, 42); + this.stackTraceTextBox.Multiline = true; + this.stackTraceTextBox.Name = "stackTraceTextBox"; + this.stackTraceTextBox.ReadOnly = true; + this.stackTraceTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.stackTraceTextBox.Size = new System.Drawing.Size(439, 205); + this.stackTraceTextBox.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(13, 13); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(310, 13); + this.label1.TabIndex = 1; + this.label1.Text = "An unhandled error has occured. Please report to the developer."; + // + // okButton + // + this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.Location = new System.Drawing.Point(376, 265); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(75, 23); + this.okButton.TabIndex = 2; + this.okButton.Text = "Close"; + this.okButton.UseVisualStyleBackColor = true; + // + // copyButton + // + this.copyButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.copyButton.Location = new System.Drawing.Point(12, 265); + this.copyButton.Name = "copyButton"; + this.copyButton.Size = new System.Drawing.Size(117, 23); + this.copyButton.TabIndex = 4; + this.copyButton.Text = "Copy to clipboard"; + this.copyButton.UseVisualStyleBackColor = true; + this.copyButton.Click += new System.EventHandler(this.copyButton_Click); + // + // ExceptionWindow + // + this.CancelButton = this.okButton; + this.ClientSize = new System.Drawing.Size(464, 300); + this.Controls.Add(this.copyButton); + this.Controls.Add(this.okButton); + this.Controls.Add(this.label1); + this.Controls.Add(this.stackTraceTextBox); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ExceptionWindow"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "LogExpert Error"; + this.ResumeLayout(false); + this.PerformLayout(); - } +} - #endregion +#endregion - private System.Windows.Forms.TextBox stackTraceTextBox; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Button okButton; - private System.Windows.Forms.Button copyButton; - } +private System.Windows.Forms.TextBox stackTraceTextBox; +private System.Windows.Forms.Label label1; +private System.Windows.Forms.Button okButton; + private System.Windows.Forms.Button copyButton; } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/ExceptionWindow.cs b/src/Logexpert.UI/Dialogs/ExceptionWindow.cs index 4ada46c7..1f38dc61 100644 --- a/src/Logexpert.UI/Dialogs/ExceptionWindow.cs +++ b/src/Logexpert.UI/Dialogs/ExceptionWindow.cs @@ -1,49 +1,48 @@ -namespace LogExpert.UI.Dialogs -{ - public partial class ExceptionWindow : Form - { - #region Fields +namespace LogExpert.UI.Dialogs; - private readonly string _errorText; +public partial class ExceptionWindow : Form +{ + #region Fields - private readonly string _stackTrace; + private readonly string _errorText; - #endregion + private readonly string _stackTrace; - #region cTor + #endregion - public ExceptionWindow(string errorText, string stackTrace) - { - InitializeComponent(); + #region cTor - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; + public ExceptionWindow(string errorText, string stackTrace) + { + InitializeComponent(); - _errorText = errorText; - _stackTrace = stackTrace; + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; - stackTraceTextBox.Text = _errorText + @"\n\n" + _stackTrace; - stackTraceTextBox.Select(0, 0); - } + _errorText = errorText; + _stackTrace = stackTrace; - #endregion + stackTraceTextBox.Text = _errorText + @"\n\n" + _stackTrace; + stackTraceTextBox.Select(0, 0); + } - #region Private Methods + #endregion - private void CopyToClipboard() - { - Clipboard.SetText(_errorText + @"\n\n" + _stackTrace); - } + #region Private Methods - #endregion + private void CopyToClipboard() + { + Clipboard.SetText(_errorText + @"\n\n" + _stackTrace); + } - #region Events handler + #endregion - private void copyButton_Click(object sender, EventArgs e) - { - CopyToClipboard(); - } + #region Events handler - #endregion + private void copyButton_Click(object sender, EventArgs e) + { + CopyToClipboard(); } + + #endregion } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/FilterColumnChooser.Designer.cs b/src/Logexpert.UI/Dialogs/FilterColumnChooser.Designer.cs index 1fe5b69e..484f8987 100644 --- a/src/Logexpert.UI/Dialogs/FilterColumnChooser.Designer.cs +++ b/src/Logexpert.UI/Dialogs/FilterColumnChooser.Designer.cs @@ -1,218 +1,217 @@ -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +partial class FilterColumnChooser { - partial class FilterColumnChooser - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} - #region Windows Form Designer generated code +#region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FilterColumnChooser)); - this.columnListBox = new System.Windows.Forms.CheckedListBox(); - this.buttonOk = new System.Windows.Forms.Button(); - this.toolTipEmptyColumnNoHit = new System.Windows.Forms.ToolTip(this.components); - this.emptyColumnNoHitRadioButton = new System.Windows.Forms.RadioButton(); - this.toolTipListBox = new System.Windows.Forms.ToolTip(this.components); - this.checkBoxExactMatch = new System.Windows.Forms.CheckBox(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.emptyColumnUsePrevRadioButton = new System.Windows.Forms.RadioButton(); - this.emptyColumnHitRadioButton = new System.Windows.Forms.RadioButton(); - this.groupBoxExectMatch = new System.Windows.Forms.GroupBox(); - this.toolTipSearchHit = new System.Windows.Forms.ToolTip(this.components); - this.toolTipPrevContent = new System.Windows.Forms.ToolTip(this.components); - this.toolTipExactMatch = new System.Windows.Forms.ToolTip(this.components); - this.buttonCancel = new System.Windows.Forms.Button(); - this.groupBox1.SuspendLayout(); - this.groupBoxExectMatch.SuspendLayout(); - this.SuspendLayout(); - // - // columnListBox - // - this.columnListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.columnListBox.CheckOnClick = true; - this.columnListBox.Font = new System.Drawing.Font("Courier New", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.columnListBox.FormattingEnabled = true; - this.columnListBox.Location = new System.Drawing.Point(3, 3); - this.columnListBox.Name = "columnListBox"; - this.columnListBox.Size = new System.Drawing.Size(177, 119); - this.columnListBox.TabIndex = 0; - this.toolTipListBox.SetToolTip(this.columnListBox, "Choose one ore more columns to restrict the search operations to the selected col" + - "umns."); - // - // buttonOk - // - this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(3, 309); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 23); - this.buttonOk.TabIndex = 2; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.OnOkButtonClick); - // - // toolTipEmptyColumnNoHit - // - this.toolTipEmptyColumnNoHit.ToolTipTitle = "Empty column"; - // - // emptyColumnNoHitRadioButton - // - this.emptyColumnNoHitRadioButton.AutoSize = true; - this.emptyColumnNoHitRadioButton.Location = new System.Drawing.Point(6, 21); - this.emptyColumnNoHitRadioButton.Name = "emptyColumnNoHitRadioButton"; - this.emptyColumnNoHitRadioButton.Size = new System.Drawing.Size(75, 24); - this.emptyColumnNoHitRadioButton.TabIndex = 0; - this.emptyColumnNoHitRadioButton.TabStop = true; - this.emptyColumnNoHitRadioButton.Text = "No hit"; - this.toolTipEmptyColumnNoHit.SetToolTip(this.emptyColumnNoHitRadioButton, "No search hit on empty columns"); - this.emptyColumnNoHitRadioButton.UseVisualStyleBackColor = true; - // - // toolTipListBox - // - this.toolTipListBox.ToolTipTitle = "Columns"; - // - // checkBoxExactMatch - // - this.checkBoxExactMatch.AutoSize = true; - this.checkBoxExactMatch.Location = new System.Drawing.Point(9, 11); - this.checkBoxExactMatch.Name = "checkBoxExactMatch"; - this.checkBoxExactMatch.Size = new System.Drawing.Size(123, 24); - this.checkBoxExactMatch.TabIndex = 4; - this.checkBoxExactMatch.Text = "Exact match"; - this.toolTipExactMatch.SetToolTip(this.checkBoxExactMatch, "If selected, the search string must match exactly (no substring search)"); - this.checkBoxExactMatch.UseVisualStyleBackColor = true; - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.emptyColumnUsePrevRadioButton); - this.groupBox1.Controls.Add(this.emptyColumnHitRadioButton); - this.groupBox1.Controls.Add(this.emptyColumnNoHitRadioButton); - this.groupBox1.Location = new System.Drawing.Point(3, 177); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(177, 108); - this.groupBox1.TabIndex = 5; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "On empty columns"; - // - // emptyColumnUsePrevRadioButton - // - this.emptyColumnUsePrevRadioButton.AutoSize = true; - this.emptyColumnUsePrevRadioButton.Location = new System.Drawing.Point(6, 76); - this.emptyColumnUsePrevRadioButton.Name = "emptyColumnUsePrevRadioButton"; - this.emptyColumnUsePrevRadioButton.Size = new System.Drawing.Size(155, 24); - this.emptyColumnUsePrevRadioButton.TabIndex = 2; - this.emptyColumnUsePrevRadioButton.TabStop = true; - this.emptyColumnUsePrevRadioButton.Text = "Use prev content"; - this.toolTipPrevContent.SetToolTip(this.emptyColumnUsePrevRadioButton, "An empty column will be a search hit if the previous non-empty column was a searc" + - "h hit"); - this.emptyColumnUsePrevRadioButton.UseVisualStyleBackColor = true; - // - // emptyColumnHitRadioButton - // - this.emptyColumnHitRadioButton.AutoSize = true; - this.emptyColumnHitRadioButton.Location = new System.Drawing.Point(6, 49); - this.emptyColumnHitRadioButton.Name = "emptyColumnHitRadioButton"; - this.emptyColumnHitRadioButton.Size = new System.Drawing.Size(106, 24); - this.emptyColumnHitRadioButton.TabIndex = 1; - this.emptyColumnHitRadioButton.TabStop = true; - this.emptyColumnHitRadioButton.Text = "Search hit"; - this.toolTipSearchHit.SetToolTip(this.emptyColumnHitRadioButton, "An empty column will always be a search hit"); - this.emptyColumnHitRadioButton.UseVisualStyleBackColor = true; - // - // groupBoxExectMatch - // - this.groupBoxExectMatch.Controls.Add(this.checkBoxExactMatch); - this.groupBoxExectMatch.Location = new System.Drawing.Point(3, 130); - this.groupBoxExectMatch.Name = "groupBoxExectMatch"; - this.groupBoxExectMatch.Size = new System.Drawing.Size(177, 41); - this.groupBoxExectMatch.TabIndex = 6; - this.groupBoxExectMatch.TabStop = false; - // - // toolTipSearchHit - // - this.toolTipSearchHit.ToolTipTitle = "Empty column"; - // - // toolTipPrevContent - // - this.toolTipPrevContent.ToolTipTitle = "Empty column"; - // - // toolTipExactMatch - // - this.toolTipExactMatch.ToolTipTitle = "Exact match"; - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(104, 309); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 7; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // FilterColumnChooser - // - this.AcceptButton = this.buttonOk; - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(184, 335); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.groupBoxExectMatch); - this.Controls.Add(this.groupBox1); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.columnListBox); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Name = "FilterColumnChooser"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Columns"; - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - this.groupBoxExectMatch.ResumeLayout(false); - this.groupBoxExectMatch.PerformLayout(); - this.ResumeLayout(false); +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FilterColumnChooser)); + this.columnListBox = new System.Windows.Forms.CheckedListBox(); + this.buttonOk = new System.Windows.Forms.Button(); + this.toolTipEmptyColumnNoHit = new System.Windows.Forms.ToolTip(this.components); + this.emptyColumnNoHitRadioButton = new System.Windows.Forms.RadioButton(); + this.toolTipListBox = new System.Windows.Forms.ToolTip(this.components); + this.checkBoxExactMatch = new System.Windows.Forms.CheckBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.emptyColumnUsePrevRadioButton = new System.Windows.Forms.RadioButton(); + this.emptyColumnHitRadioButton = new System.Windows.Forms.RadioButton(); + this.groupBoxExectMatch = new System.Windows.Forms.GroupBox(); + this.toolTipSearchHit = new System.Windows.Forms.ToolTip(this.components); + this.toolTipPrevContent = new System.Windows.Forms.ToolTip(this.components); + this.toolTipExactMatch = new System.Windows.Forms.ToolTip(this.components); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBox1.SuspendLayout(); + this.groupBoxExectMatch.SuspendLayout(); + this.SuspendLayout(); + // + // columnListBox + // + this.columnListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.columnListBox.CheckOnClick = true; + this.columnListBox.Font = new System.Drawing.Font("Courier New", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.columnListBox.FormattingEnabled = true; + this.columnListBox.Location = new System.Drawing.Point(3, 3); + this.columnListBox.Name = "columnListBox"; + this.columnListBox.Size = new System.Drawing.Size(177, 119); + this.columnListBox.TabIndex = 0; + this.toolTipListBox.SetToolTip(this.columnListBox, "Choose one ore more columns to restrict the search operations to the selected col" + + "umns."); + // + // buttonOk + // + this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(3, 309); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 2; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.OnOkButtonClick); + // + // toolTipEmptyColumnNoHit + // + this.toolTipEmptyColumnNoHit.ToolTipTitle = "Empty column"; + // + // emptyColumnNoHitRadioButton + // + this.emptyColumnNoHitRadioButton.AutoSize = true; + this.emptyColumnNoHitRadioButton.Location = new System.Drawing.Point(6, 21); + this.emptyColumnNoHitRadioButton.Name = "emptyColumnNoHitRadioButton"; + this.emptyColumnNoHitRadioButton.Size = new System.Drawing.Size(75, 24); + this.emptyColumnNoHitRadioButton.TabIndex = 0; + this.emptyColumnNoHitRadioButton.TabStop = true; + this.emptyColumnNoHitRadioButton.Text = "No hit"; + this.toolTipEmptyColumnNoHit.SetToolTip(this.emptyColumnNoHitRadioButton, "No search hit on empty columns"); + this.emptyColumnNoHitRadioButton.UseVisualStyleBackColor = true; + // + // toolTipListBox + // + this.toolTipListBox.ToolTipTitle = "Columns"; + // + // checkBoxExactMatch + // + this.checkBoxExactMatch.AutoSize = true; + this.checkBoxExactMatch.Location = new System.Drawing.Point(9, 11); + this.checkBoxExactMatch.Name = "checkBoxExactMatch"; + this.checkBoxExactMatch.Size = new System.Drawing.Size(123, 24); + this.checkBoxExactMatch.TabIndex = 4; + this.checkBoxExactMatch.Text = "Exact match"; + this.toolTipExactMatch.SetToolTip(this.checkBoxExactMatch, "If selected, the search string must match exactly (no substring search)"); + this.checkBoxExactMatch.UseVisualStyleBackColor = true; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.emptyColumnUsePrevRadioButton); + this.groupBox1.Controls.Add(this.emptyColumnHitRadioButton); + this.groupBox1.Controls.Add(this.emptyColumnNoHitRadioButton); + this.groupBox1.Location = new System.Drawing.Point(3, 177); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(177, 108); + this.groupBox1.TabIndex = 5; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "On empty columns"; + // + // emptyColumnUsePrevRadioButton + // + this.emptyColumnUsePrevRadioButton.AutoSize = true; + this.emptyColumnUsePrevRadioButton.Location = new System.Drawing.Point(6, 76); + this.emptyColumnUsePrevRadioButton.Name = "emptyColumnUsePrevRadioButton"; + this.emptyColumnUsePrevRadioButton.Size = new System.Drawing.Size(155, 24); + this.emptyColumnUsePrevRadioButton.TabIndex = 2; + this.emptyColumnUsePrevRadioButton.TabStop = true; + this.emptyColumnUsePrevRadioButton.Text = "Use prev content"; + this.toolTipPrevContent.SetToolTip(this.emptyColumnUsePrevRadioButton, "An empty column will be a search hit if the previous non-empty column was a searc" + + "h hit"); + this.emptyColumnUsePrevRadioButton.UseVisualStyleBackColor = true; + // + // emptyColumnHitRadioButton + // + this.emptyColumnHitRadioButton.AutoSize = true; + this.emptyColumnHitRadioButton.Location = new System.Drawing.Point(6, 49); + this.emptyColumnHitRadioButton.Name = "emptyColumnHitRadioButton"; + this.emptyColumnHitRadioButton.Size = new System.Drawing.Size(106, 24); + this.emptyColumnHitRadioButton.TabIndex = 1; + this.emptyColumnHitRadioButton.TabStop = true; + this.emptyColumnHitRadioButton.Text = "Search hit"; + this.toolTipSearchHit.SetToolTip(this.emptyColumnHitRadioButton, "An empty column will always be a search hit"); + this.emptyColumnHitRadioButton.UseVisualStyleBackColor = true; + // + // groupBoxExectMatch + // + this.groupBoxExectMatch.Controls.Add(this.checkBoxExactMatch); + this.groupBoxExectMatch.Location = new System.Drawing.Point(3, 130); + this.groupBoxExectMatch.Name = "groupBoxExectMatch"; + this.groupBoxExectMatch.Size = new System.Drawing.Size(177, 41); + this.groupBoxExectMatch.TabIndex = 6; + this.groupBoxExectMatch.TabStop = false; + // + // toolTipSearchHit + // + this.toolTipSearchHit.ToolTipTitle = "Empty column"; + // + // toolTipPrevContent + // + this.toolTipPrevContent.ToolTipTitle = "Empty column"; + // + // toolTipExactMatch + // + this.toolTipExactMatch.ToolTipTitle = "Exact match"; + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(104, 309); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 7; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // FilterColumnChooser + // + this.AcceptButton = this.buttonOk; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(184, 335); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.groupBoxExectMatch); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.columnListBox); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Name = "FilterColumnChooser"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Columns"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBoxExectMatch.ResumeLayout(false); + this.groupBoxExectMatch.PerformLayout(); + this.ResumeLayout(false); - } +} - #endregion +#endregion - private System.Windows.Forms.CheckedListBox columnListBox; - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.ToolTip toolTipEmptyColumnNoHit; - private System.Windows.Forms.ToolTip toolTipListBox; - private System.Windows.Forms.CheckBox checkBoxExactMatch; - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.RadioButton emptyColumnUsePrevRadioButton; - private System.Windows.Forms.RadioButton emptyColumnHitRadioButton; - private System.Windows.Forms.RadioButton emptyColumnNoHitRadioButton; - private System.Windows.Forms.GroupBox groupBoxExectMatch; - private System.Windows.Forms.ToolTip toolTipExactMatch; - private System.Windows.Forms.ToolTip toolTipSearchHit; - private System.Windows.Forms.ToolTip toolTipPrevContent; - private System.Windows.Forms.Button buttonCancel; - } +private System.Windows.Forms.CheckedListBox columnListBox; +private System.Windows.Forms.Button buttonOk; +private System.Windows.Forms.ToolTip toolTipEmptyColumnNoHit; +private System.Windows.Forms.ToolTip toolTipListBox; +private System.Windows.Forms.CheckBox checkBoxExactMatch; +private System.Windows.Forms.GroupBox groupBox1; +private System.Windows.Forms.RadioButton emptyColumnUsePrevRadioButton; +private System.Windows.Forms.RadioButton emptyColumnHitRadioButton; +private System.Windows.Forms.RadioButton emptyColumnNoHitRadioButton; +private System.Windows.Forms.GroupBox groupBoxExectMatch; +private System.Windows.Forms.ToolTip toolTipExactMatch; +private System.Windows.Forms.ToolTip toolTipSearchHit; +private System.Windows.Forms.ToolTip toolTipPrevContent; +private System.Windows.Forms.Button buttonCancel; } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/FilterColumnChooser.cs b/src/Logexpert.UI/Dialogs/FilterColumnChooser.cs index d5c1330d..812dc786 100644 --- a/src/Logexpert.UI/Dialogs/FilterColumnChooser.cs +++ b/src/Logexpert.UI/Dialogs/FilterColumnChooser.cs @@ -2,73 +2,72 @@ using System.Runtime.Versioning; -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +[SupportedOSPlatform("windows")] +public partial class FilterColumnChooser : Form { - [SupportedOSPlatform("windows")] - public partial class FilterColumnChooser : Form - { - #region Fields + #region Fields - private readonly ILogLineColumnizer _columnizer; - private readonly FilterParams _filterParams; + private readonly ILogLineColumnizer _columnizer; + private readonly FilterParams _filterParams; - #endregion + #endregion - #region cTor + #region cTor - public FilterColumnChooser(FilterParams filterParams) - { - InitializeComponent(); + public FilterColumnChooser(FilterParams filterParams) + { + InitializeComponent(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; - columnListBox.ItemHeight = columnListBox.Font.Height; + columnListBox.ItemHeight = columnListBox.Font.Height; - _columnizer = filterParams.CurrentColumnizer; - _filterParams = filterParams; + _columnizer = filterParams.CurrentColumnizer; + _filterParams = filterParams; - Init(); - } + Init(); + } - #endregion + #endregion - #region Private Methods + #region Private Methods - private void Init() + private void Init() + { + int count = _columnizer.GetColumnCount(); + string[] names = _columnizer.GetColumnNames(); + + for (int i = 0; i < count; ++i) { - int count = _columnizer.GetColumnCount(); - string[] names = _columnizer.GetColumnNames(); - - for (int i = 0; i < count; ++i) - { - columnListBox.Items.Add(names[i], _filterParams.ColumnList.Contains(i)); - } - - emptyColumnUsePrevRadioButton.Checked = _filterParams.EmptyColumnUsePrev; - emptyColumnHitRadioButton.Checked = _filterParams.EmptyColumnHit; - emptyColumnNoHitRadioButton.Checked = _filterParams.EmptyColumnHit == false && _filterParams.EmptyColumnUsePrev == false; - checkBoxExactMatch.Checked = _filterParams.ExactColumnMatch; + columnListBox.Items.Add(names[i], _filterParams.ColumnList.Contains(i)); } - #endregion + emptyColumnUsePrevRadioButton.Checked = _filterParams.EmptyColumnUsePrev; + emptyColumnHitRadioButton.Checked = _filterParams.EmptyColumnHit; + emptyColumnNoHitRadioButton.Checked = _filterParams.EmptyColumnHit == false && _filterParams.EmptyColumnUsePrev == false; + checkBoxExactMatch.Checked = _filterParams.ExactColumnMatch; + } - #region Events handler + #endregion - private void OnOkButtonClick(object sender, EventArgs e) - { - _filterParams.ColumnList.Clear(); + #region Events handler - foreach (int colNum in columnListBox.CheckedIndices) - { - _filterParams.ColumnList.Add(colNum); - } + private void OnOkButtonClick(object sender, EventArgs e) + { + _filterParams.ColumnList.Clear(); - _filterParams.EmptyColumnUsePrev = emptyColumnUsePrevRadioButton.Checked; - _filterParams.EmptyColumnHit = emptyColumnHitRadioButton.Checked; - _filterParams.ExactColumnMatch = checkBoxExactMatch.Checked; + foreach (int colNum in columnListBox.CheckedIndices) + { + _filterParams.ColumnList.Add(colNum); } - #endregion + _filterParams.EmptyColumnUsePrev = emptyColumnUsePrevRadioButton.Checked; + _filterParams.EmptyColumnHit = emptyColumnHitRadioButton.Checked; + _filterParams.ExactColumnMatch = checkBoxExactMatch.Checked; } + + #endregion } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/GotoLineDialog.Designer.cs b/src/Logexpert.UI/Dialogs/GotoLineDialog.Designer.cs index dd708615..799a964e 100644 --- a/src/Logexpert.UI/Dialogs/GotoLineDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/GotoLineDialog.Designer.cs @@ -1,108 +1,107 @@ -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +partial class GotoLineDialog { - partial class GotoLineDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} - #region Windows Form Designer generated code +#region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.labelLineNumber = new System.Windows.Forms.Label(); - this.buttonOk = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.lineNumberTextBox = new System.Windows.Forms.TextBox(); - this.SuspendLayout(); - // - // labelLineNumber - // - this.labelLineNumber.AutoSize = true; - this.labelLineNumber.Location = new System.Drawing.Point(12, 30); - this.labelLineNumber.Name = "labelLineNumber"; - this.labelLineNumber.Size = new System.Drawing.Size(101, 20); - this.labelLineNumber.TabIndex = 0; - this.labelLineNumber.Text = "Line number:"; - // - // buttonOk - // - this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonOk.AutoSize = true; - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(15, 90); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 30); - this.buttonOk.TabIndex = 2; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.okButton_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.AutoSize = true; - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(149, 90); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 30); - this.buttonCancel.TabIndex = 3; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // lineNumberTextBox - // - this.lineNumberTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.lineNumberTextBox.Location = new System.Drawing.Point(124, 27); - this.lineNumberTextBox.Name = "lineNumberTextBox"; - this.lineNumberTextBox.Size = new System.Drawing.Size(100, 26); - this.lineNumberTextBox.TabIndex = 0; - // - // GotoLineDialog - // - this.AcceptButton = this.buttonOk; - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(243, 130); - this.Controls.Add(this.lineNumberTextBox); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.labelLineNumber); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "GotoLineDialog"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Go to line"; - this.Load += new System.EventHandler(this.GotoLineDialog_Load); - this.ResumeLayout(false); - this.PerformLayout(); +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + this.labelLineNumber = new System.Windows.Forms.Label(); + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.lineNumberTextBox = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // labelLineNumber + // + this.labelLineNumber.AutoSize = true; + this.labelLineNumber.Location = new System.Drawing.Point(12, 30); + this.labelLineNumber.Name = "labelLineNumber"; + this.labelLineNumber.Size = new System.Drawing.Size(101, 20); + this.labelLineNumber.TabIndex = 0; + this.labelLineNumber.Text = "Line number:"; + // + // buttonOk + // + this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonOk.AutoSize = true; + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(15, 90); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 30); + this.buttonOk.TabIndex = 2; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.okButton_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.AutoSize = true; + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(149, 90); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 30); + this.buttonCancel.TabIndex = 3; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // lineNumberTextBox + // + this.lineNumberTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.lineNumberTextBox.Location = new System.Drawing.Point(124, 27); + this.lineNumberTextBox.Name = "lineNumberTextBox"; + this.lineNumberTextBox.Size = new System.Drawing.Size(100, 26); + this.lineNumberTextBox.TabIndex = 0; + // + // GotoLineDialog + // + this.AcceptButton = this.buttonOk; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(243, 130); + this.Controls.Add(this.lineNumberTextBox); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.labelLineNumber); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "GotoLineDialog"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Go to line"; + this.Load += new System.EventHandler(this.GotoLineDialog_Load); + this.ResumeLayout(false); + this.PerformLayout(); - } +} - #endregion +#endregion - private System.Windows.Forms.Label labelLineNumber; - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.TextBox lineNumberTextBox; - } +private System.Windows.Forms.Label labelLineNumber; +private System.Windows.Forms.Button buttonOk; +private System.Windows.Forms.Button buttonCancel; +private System.Windows.Forms.TextBox lineNumberTextBox; } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/GotoLineDialog.cs b/src/Logexpert.UI/Dialogs/GotoLineDialog.cs index 7ebe8bef..123b1ca1 100644 --- a/src/Logexpert.UI/Dialogs/GotoLineDialog.cs +++ b/src/Logexpert.UI/Dialogs/GotoLineDialog.cs @@ -1,52 +1,51 @@ using System.Runtime.Versioning; -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +[SupportedOSPlatform("windows")] +public partial class GotoLineDialog : Form { - [SupportedOSPlatform("windows")] - public partial class GotoLineDialog : Form - { - #region Fields + #region Fields - #endregion + #endregion - #region cTor + #region cTor - public GotoLineDialog(Form parent) - { - InitializeComponent(); + public GotoLineDialog(Form parent) + { + InitializeComponent(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; - Owner = parent; - } + Owner = parent; + } - #endregion + #endregion - #region Properties + #region Properties - public int Line { get; private set; } + public int Line { get; private set; } - #endregion + #endregion - #region Events handler + #region Events handler - private void GotoLineDialog_Load(object sender, EventArgs e) + private void GotoLineDialog_Load(object sender, EventArgs e) + { + } + + private void okButton_Click(object sender, EventArgs e) + { + try { + Line = int.Parse(lineNumberTextBox.Text); } - - private void okButton_Click(object sender, EventArgs e) + catch (Exception) { - try - { - Line = int.Parse(lineNumberTextBox.Text); - } - catch (Exception) - { - Line = -1; - } + Line = -1; } - - #endregion } + + #endregion } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/ImportSettingsDialog.Designer.cs b/src/Logexpert.UI/Dialogs/ImportSettingsDialog.Designer.cs index 2c420493..907f734a 100644 --- a/src/Logexpert.UI/Dialogs/ImportSettingsDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/ImportSettingsDialog.Designer.cs @@ -1,226 +1,225 @@ -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +partial class ImportSettingsDialog { - partial class ImportSettingsDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} - #region Windows Form Designer generated code +#region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImportSettingsDialog)); - this.buttonFile = new System.Windows.Forms.Button(); - this.textBoxFileName = new System.Windows.Forms.TextBox(); - this.labelSettingsFileToImport = new System.Windows.Forms.Label(); - this.groupBoxImportOptions = new System.Windows.Forms.GroupBox(); - this.checkBoxKeepExistingSettings = new System.Windows.Forms.CheckBox(); - this.checkBoxOther = new System.Windows.Forms.CheckBox(); - this.checkBoxExternalTools = new System.Windows.Forms.CheckBox(); - this.checkBoxColumnizerFileMasks = new System.Windows.Forms.CheckBox(); - this.checkBoxHighlightFileMasks = new System.Windows.Forms.CheckBox(); - this.checkBoxHighlightSettings = new System.Windows.Forms.CheckBox(); - this.buttonOk = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.groupBoxImportOptions.SuspendLayout(); - this.SuspendLayout(); - // - // buttonFile - // - this.buttonFile.Location = new System.Drawing.Point(306, 25); - this.buttonFile.Name = "buttonFile"; - this.buttonFile.Size = new System.Drawing.Size(94, 23); - this.buttonFile.TabIndex = 0; - this.buttonFile.Text = "Choose file..."; - this.buttonFile.UseVisualStyleBackColor = true; - this.buttonFile.Click += new System.EventHandler(this.OnFileButtonClick); - // - // textBoxFileName - // - this.textBoxFileName.Location = new System.Drawing.Point(13, 27); - this.textBoxFileName.Name = "textBoxFileName"; - this.textBoxFileName.Size = new System.Drawing.Size(287, 20); - this.textBoxFileName.TabIndex = 1; - // - // labelSettingsFileToImport - // - this.labelSettingsFileToImport.AutoSize = true; - this.labelSettingsFileToImport.Location = new System.Drawing.Point(13, 8); - this.labelSettingsFileToImport.Name = "labelSettingsFileToImport"; - this.labelSettingsFileToImport.Size = new System.Drawing.Size(107, 13); - this.labelSettingsFileToImport.TabIndex = 2; - this.labelSettingsFileToImport.Text = "Settings file to import:"; - // - // groupBoxImportOptions - // - this.groupBoxImportOptions.Controls.Add(this.checkBoxKeepExistingSettings); - this.groupBoxImportOptions.Controls.Add(this.checkBoxOther); - this.groupBoxImportOptions.Controls.Add(this.checkBoxExternalTools); - this.groupBoxImportOptions.Controls.Add(this.checkBoxColumnizerFileMasks); - this.groupBoxImportOptions.Controls.Add(this.checkBoxHighlightFileMasks); - this.groupBoxImportOptions.Controls.Add(this.checkBoxHighlightSettings); - this.groupBoxImportOptions.Location = new System.Drawing.Point(16, 67); - this.groupBoxImportOptions.Name = "groupBoxImportOptions"; - this.groupBoxImportOptions.Size = new System.Drawing.Size(284, 143); - this.groupBoxImportOptions.TabIndex = 3; - this.groupBoxImportOptions.TabStop = false; - this.groupBoxImportOptions.Text = "Import options"; - // - // checkBoxKeepExistingSettings - // - this.checkBoxKeepExistingSettings.AutoSize = true; - this.checkBoxKeepExistingSettings.Location = new System.Drawing.Point(141, 20); - this.checkBoxKeepExistingSettings.Name = "checkBoxKeepExistingSettings"; - this.checkBoxKeepExistingSettings.Size = new System.Drawing.Size(128, 17); - this.checkBoxKeepExistingSettings.TabIndex = 1; - this.checkBoxKeepExistingSettings.Tag = "32"; - this.checkBoxKeepExistingSettings.Text = "Keep existing settings"; - this.checkBoxKeepExistingSettings.UseVisualStyleBackColor = true; - // - // checkBoxOther - // - this.checkBoxOther.AutoSize = true; - this.checkBoxOther.Checked = true; - this.checkBoxOther.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxOther.Location = new System.Drawing.Point(7, 112); - this.checkBoxOther.Name = "checkBoxOther"; - this.checkBoxOther.Size = new System.Drawing.Size(52, 17); - this.checkBoxOther.TabIndex = 0; - this.checkBoxOther.Tag = "16"; - this.checkBoxOther.Text = "Other"; - this.checkBoxOther.UseVisualStyleBackColor = true; - // - // checkBoxExternalTools - // - this.checkBoxExternalTools.AutoSize = true; - this.checkBoxExternalTools.Checked = true; - this.checkBoxExternalTools.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxExternalTools.Location = new System.Drawing.Point(7, 89); - this.checkBoxExternalTools.Name = "checkBoxExternalTools"; - this.checkBoxExternalTools.Size = new System.Drawing.Size(89, 17); - this.checkBoxExternalTools.TabIndex = 0; - this.checkBoxExternalTools.Tag = "8"; - this.checkBoxExternalTools.Text = "External tools"; - this.checkBoxExternalTools.UseVisualStyleBackColor = true; - // - // checkBoxColumnizerFileMasks - // - this.checkBoxColumnizerFileMasks.AutoSize = true; - this.checkBoxColumnizerFileMasks.Checked = true; - this.checkBoxColumnizerFileMasks.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxColumnizerFileMasks.Location = new System.Drawing.Point(7, 66); - this.checkBoxColumnizerFileMasks.Name = "checkBoxColumnizerFileMasks"; - this.checkBoxColumnizerFileMasks.Size = new System.Drawing.Size(126, 17); - this.checkBoxColumnizerFileMasks.TabIndex = 0; - this.checkBoxColumnizerFileMasks.Tag = "2"; - this.checkBoxColumnizerFileMasks.Text = "Columnizer file masks"; - this.checkBoxColumnizerFileMasks.UseVisualStyleBackColor = true; - // - // checkBoxHighlightFileMasks - // - this.checkBoxHighlightFileMasks.AutoSize = true; - this.checkBoxHighlightFileMasks.Checked = true; - this.checkBoxHighlightFileMasks.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxHighlightFileMasks.Location = new System.Drawing.Point(7, 43); - this.checkBoxHighlightFileMasks.Name = "checkBoxHighlightFileMasks"; - this.checkBoxHighlightFileMasks.Size = new System.Drawing.Size(116, 17); - this.checkBoxHighlightFileMasks.TabIndex = 0; - this.checkBoxHighlightFileMasks.Tag = "4"; - this.checkBoxHighlightFileMasks.Text = "Highlight file masks"; - this.checkBoxHighlightFileMasks.UseVisualStyleBackColor = true; - // - // checkBoxHighlightSettings - // - this.checkBoxHighlightSettings.AutoSize = true; - this.checkBoxHighlightSettings.Checked = true; - this.checkBoxHighlightSettings.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxHighlightSettings.Location = new System.Drawing.Point(7, 20); - this.checkBoxHighlightSettings.Name = "checkBoxHighlightSettings"; - this.checkBoxHighlightSettings.Size = new System.Drawing.Size(106, 17); - this.checkBoxHighlightSettings.TabIndex = 0; - this.checkBoxHighlightSettings.Tag = "1"; - this.checkBoxHighlightSettings.Text = "Highlight settings"; - this.checkBoxHighlightSettings.UseVisualStyleBackColor = true; - // - // buttonOk - // - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(325, 187); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 23); - this.buttonOk.TabIndex = 4; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.OnOkButtonClick); - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(325, 154); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // ImportSettingsDialog - // - this.AcceptButton = this.buttonOk; - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(412, 224); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.groupBoxImportOptions); - this.Controls.Add(this.labelSettingsFileToImport); - this.Controls.Add(this.textBoxFileName); - this.Controls.Add(this.buttonFile); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ImportSettingsDialog"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Import Settings"; - this.Load += new System.EventHandler(this.OnImportSettingsDialogLoad); - this.groupBoxImportOptions.ResumeLayout(false); - this.groupBoxImportOptions.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImportSettingsDialog)); + this.buttonFile = new System.Windows.Forms.Button(); + this.textBoxFileName = new System.Windows.Forms.TextBox(); + this.labelSettingsFileToImport = new System.Windows.Forms.Label(); + this.groupBoxImportOptions = new System.Windows.Forms.GroupBox(); + this.checkBoxKeepExistingSettings = new System.Windows.Forms.CheckBox(); + this.checkBoxOther = new System.Windows.Forms.CheckBox(); + this.checkBoxExternalTools = new System.Windows.Forms.CheckBox(); + this.checkBoxColumnizerFileMasks = new System.Windows.Forms.CheckBox(); + this.checkBoxHighlightFileMasks = new System.Windows.Forms.CheckBox(); + this.checkBoxHighlightSettings = new System.Windows.Forms.CheckBox(); + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBoxImportOptions.SuspendLayout(); + this.SuspendLayout(); + // + // buttonFile + // + this.buttonFile.Location = new System.Drawing.Point(306, 25); + this.buttonFile.Name = "buttonFile"; + this.buttonFile.Size = new System.Drawing.Size(94, 23); + this.buttonFile.TabIndex = 0; + this.buttonFile.Text = "Choose file..."; + this.buttonFile.UseVisualStyleBackColor = true; + this.buttonFile.Click += new System.EventHandler(this.OnFileButtonClick); + // + // textBoxFileName + // + this.textBoxFileName.Location = new System.Drawing.Point(13, 27); + this.textBoxFileName.Name = "textBoxFileName"; + this.textBoxFileName.Size = new System.Drawing.Size(287, 20); + this.textBoxFileName.TabIndex = 1; + // + // labelSettingsFileToImport + // + this.labelSettingsFileToImport.AutoSize = true; + this.labelSettingsFileToImport.Location = new System.Drawing.Point(13, 8); + this.labelSettingsFileToImport.Name = "labelSettingsFileToImport"; + this.labelSettingsFileToImport.Size = new System.Drawing.Size(107, 13); + this.labelSettingsFileToImport.TabIndex = 2; + this.labelSettingsFileToImport.Text = "Settings file to import:"; + // + // groupBoxImportOptions + // + this.groupBoxImportOptions.Controls.Add(this.checkBoxKeepExistingSettings); + this.groupBoxImportOptions.Controls.Add(this.checkBoxOther); + this.groupBoxImportOptions.Controls.Add(this.checkBoxExternalTools); + this.groupBoxImportOptions.Controls.Add(this.checkBoxColumnizerFileMasks); + this.groupBoxImportOptions.Controls.Add(this.checkBoxHighlightFileMasks); + this.groupBoxImportOptions.Controls.Add(this.checkBoxHighlightSettings); + this.groupBoxImportOptions.Location = new System.Drawing.Point(16, 67); + this.groupBoxImportOptions.Name = "groupBoxImportOptions"; + this.groupBoxImportOptions.Size = new System.Drawing.Size(284, 143); + this.groupBoxImportOptions.TabIndex = 3; + this.groupBoxImportOptions.TabStop = false; + this.groupBoxImportOptions.Text = "Import options"; + // + // checkBoxKeepExistingSettings + // + this.checkBoxKeepExistingSettings.AutoSize = true; + this.checkBoxKeepExistingSettings.Location = new System.Drawing.Point(141, 20); + this.checkBoxKeepExistingSettings.Name = "checkBoxKeepExistingSettings"; + this.checkBoxKeepExistingSettings.Size = new System.Drawing.Size(128, 17); + this.checkBoxKeepExistingSettings.TabIndex = 1; + this.checkBoxKeepExistingSettings.Tag = "32"; + this.checkBoxKeepExistingSettings.Text = "Keep existing settings"; + this.checkBoxKeepExistingSettings.UseVisualStyleBackColor = true; + // + // checkBoxOther + // + this.checkBoxOther.AutoSize = true; + this.checkBoxOther.Checked = true; + this.checkBoxOther.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxOther.Location = new System.Drawing.Point(7, 112); + this.checkBoxOther.Name = "checkBoxOther"; + this.checkBoxOther.Size = new System.Drawing.Size(52, 17); + this.checkBoxOther.TabIndex = 0; + this.checkBoxOther.Tag = "16"; + this.checkBoxOther.Text = "Other"; + this.checkBoxOther.UseVisualStyleBackColor = true; + // + // checkBoxExternalTools + // + this.checkBoxExternalTools.AutoSize = true; + this.checkBoxExternalTools.Checked = true; + this.checkBoxExternalTools.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxExternalTools.Location = new System.Drawing.Point(7, 89); + this.checkBoxExternalTools.Name = "checkBoxExternalTools"; + this.checkBoxExternalTools.Size = new System.Drawing.Size(89, 17); + this.checkBoxExternalTools.TabIndex = 0; + this.checkBoxExternalTools.Tag = "8"; + this.checkBoxExternalTools.Text = "External tools"; + this.checkBoxExternalTools.UseVisualStyleBackColor = true; + // + // checkBoxColumnizerFileMasks + // + this.checkBoxColumnizerFileMasks.AutoSize = true; + this.checkBoxColumnizerFileMasks.Checked = true; + this.checkBoxColumnizerFileMasks.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxColumnizerFileMasks.Location = new System.Drawing.Point(7, 66); + this.checkBoxColumnizerFileMasks.Name = "checkBoxColumnizerFileMasks"; + this.checkBoxColumnizerFileMasks.Size = new System.Drawing.Size(126, 17); + this.checkBoxColumnizerFileMasks.TabIndex = 0; + this.checkBoxColumnizerFileMasks.Tag = "2"; + this.checkBoxColumnizerFileMasks.Text = "Columnizer file masks"; + this.checkBoxColumnizerFileMasks.UseVisualStyleBackColor = true; + // + // checkBoxHighlightFileMasks + // + this.checkBoxHighlightFileMasks.AutoSize = true; + this.checkBoxHighlightFileMasks.Checked = true; + this.checkBoxHighlightFileMasks.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxHighlightFileMasks.Location = new System.Drawing.Point(7, 43); + this.checkBoxHighlightFileMasks.Name = "checkBoxHighlightFileMasks"; + this.checkBoxHighlightFileMasks.Size = new System.Drawing.Size(116, 17); + this.checkBoxHighlightFileMasks.TabIndex = 0; + this.checkBoxHighlightFileMasks.Tag = "4"; + this.checkBoxHighlightFileMasks.Text = "Highlight file masks"; + this.checkBoxHighlightFileMasks.UseVisualStyleBackColor = true; + // + // checkBoxHighlightSettings + // + this.checkBoxHighlightSettings.AutoSize = true; + this.checkBoxHighlightSettings.Checked = true; + this.checkBoxHighlightSettings.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxHighlightSettings.Location = new System.Drawing.Point(7, 20); + this.checkBoxHighlightSettings.Name = "checkBoxHighlightSettings"; + this.checkBoxHighlightSettings.Size = new System.Drawing.Size(106, 17); + this.checkBoxHighlightSettings.TabIndex = 0; + this.checkBoxHighlightSettings.Tag = "1"; + this.checkBoxHighlightSettings.Text = "Highlight settings"; + this.checkBoxHighlightSettings.UseVisualStyleBackColor = true; + // + // buttonOk + // + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(325, 187); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 4; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.OnOkButtonClick); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(325, 154); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // ImportSettingsDialog + // + this.AcceptButton = this.buttonOk; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(412, 224); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.groupBoxImportOptions); + this.Controls.Add(this.labelSettingsFileToImport); + this.Controls.Add(this.textBoxFileName); + this.Controls.Add(this.buttonFile); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ImportSettingsDialog"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Import Settings"; + this.Load += new System.EventHandler(this.OnImportSettingsDialogLoad); + this.groupBoxImportOptions.ResumeLayout(false); + this.groupBoxImportOptions.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); - } +} - #endregion +#endregion - private System.Windows.Forms.Button buttonFile; - private System.Windows.Forms.TextBox textBoxFileName; - private System.Windows.Forms.Label labelSettingsFileToImport; - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.Button buttonCancel; - public System.Windows.Forms.CheckBox checkBoxExternalTools; - public System.Windows.Forms.CheckBox checkBoxColumnizerFileMasks; - public System.Windows.Forms.CheckBox checkBoxHighlightFileMasks; - public System.Windows.Forms.CheckBox checkBoxHighlightSettings; - public System.Windows.Forms.CheckBox checkBoxOther; - public System.Windows.Forms.CheckBox checkBoxKeepExistingSettings; - public System.Windows.Forms.GroupBox groupBoxImportOptions; - } +private System.Windows.Forms.Button buttonFile; +private System.Windows.Forms.TextBox textBoxFileName; +private System.Windows.Forms.Label labelSettingsFileToImport; +private System.Windows.Forms.Button buttonOk; +private System.Windows.Forms.Button buttonCancel; + public System.Windows.Forms.CheckBox checkBoxExternalTools; + public System.Windows.Forms.CheckBox checkBoxColumnizerFileMasks; + public System.Windows.Forms.CheckBox checkBoxHighlightFileMasks; + public System.Windows.Forms.CheckBox checkBoxHighlightSettings; + public System.Windows.Forms.CheckBox checkBoxOther; + public System.Windows.Forms.CheckBox checkBoxKeepExistingSettings; + public System.Windows.Forms.GroupBox groupBoxImportOptions; } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/ImportSettingsDialog.cs b/src/Logexpert.UI/Dialogs/ImportSettingsDialog.cs index cfd97e0f..5d66a75b 100644 --- a/src/Logexpert.UI/Dialogs/ImportSettingsDialog.cs +++ b/src/Logexpert.UI/Dialogs/ImportSettingsDialog.cs @@ -2,98 +2,97 @@ using System.Runtime.Versioning; -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +[SupportedOSPlatform("windows")] +public partial class ImportSettingsDialog : Form { - [SupportedOSPlatform("windows")] - public partial class ImportSettingsDialog : Form + #region cTor + + public ImportSettingsDialog(ExportImportFlags importFlags) { - #region cTor + InitializeComponent(); + SuspendLayout(); + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; - public ImportSettingsDialog(ExportImportFlags importFlags) - { - InitializeComponent(); - SuspendLayout(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; + ImportFlags = importFlags; + FileName = string.Empty; - ImportFlags = importFlags; - FileName = string.Empty; + if (ImportFlags == ExportImportFlags.HighlightSettings) + { + checkBoxHighlightSettings.Checked = true; + checkBoxHighlightSettings.Enabled = false; + checkBoxHighlightFileMasks.Checked = false; + checkBoxHighlightFileMasks.Enabled = false; + checkBoxColumnizerFileMasks.Checked = false; + checkBoxColumnizerFileMasks.Enabled = false; + checkBoxExternalTools.Checked = false; + checkBoxExternalTools.Enabled = false; + checkBoxOther.Checked = false; + checkBoxOther.Enabled = false; + } - if (ImportFlags == ExportImportFlags.HighlightSettings) - { - checkBoxHighlightSettings.Checked = true; - checkBoxHighlightSettings.Enabled = false; - checkBoxHighlightFileMasks.Checked = false; - checkBoxHighlightFileMasks.Enabled = false; - checkBoxColumnizerFileMasks.Checked = false; - checkBoxColumnizerFileMasks.Enabled = false; - checkBoxExternalTools.Checked = false; - checkBoxExternalTools.Enabled = false; - checkBoxOther.Checked = false; - checkBoxOther.Enabled = false; - } + ResumeLayout(); + } - ResumeLayout(); - } + #endregion - #endregion + #region Properties - #region Properties + public string FileName { get; private set; } - public string FileName { get; private set; } + public ExportImportFlags ImportFlags { get; private set; } - public ExportImportFlags ImportFlags { get; private set; } + #endregion - #endregion + #region Events handler - #region Events handler + private void OnImportSettingsDialogLoad(object sender, EventArgs e) + { + } - private void OnImportSettingsDialogLoad(object sender, EventArgs e) + private void OnFileButtonClick(object sender, EventArgs e) + { + OpenFileDialog dlg = new() { - } + Title = "Load Settings from file", + DefaultExt = "json", + AddExtension = false, + Filter = "Settings (*.json)|*.json|All files (*.*)|*.*" + }; - private void OnFileButtonClick(object sender, EventArgs e) + if (dlg.ShowDialog() == DialogResult.OK) { - OpenFileDialog dlg = new() - { - Title = "Load Settings from file", - DefaultExt = "json", - AddExtension = false, - Filter = "Settings (*.json)|*.json|All files (*.*)|*.*" - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - textBoxFileName.Text = dlg.FileName; - } + textBoxFileName.Text = dlg.FileName; } + } - private void OnOkButtonClick(object sender, EventArgs e) - { - FileName = textBoxFileName.Text; + private void OnOkButtonClick(object sender, EventArgs e) + { + FileName = textBoxFileName.Text; - if (ImportFlags != ExportImportFlags.HighlightSettings) + if (ImportFlags != ExportImportFlags.HighlightSettings) + { + foreach (Control ctl in groupBoxImportOptions.Controls) { - foreach (Control ctl in groupBoxImportOptions.Controls) + if (ctl.Tag != null) { - if (ctl.Tag != null) + if (((CheckBox)ctl).Checked) { - if (((CheckBox)ctl).Checked) - { - ImportFlags |= (ExportImportFlags)long.Parse(ctl.Tag as string ?? string.Empty); - } + ImportFlags |= (ExportImportFlags)long.Parse(ctl.Tag as string ?? string.Empty); } } } - else + } + else + { + if (checkBoxKeepExistingSettings.Checked) { - if (checkBoxKeepExistingSettings.Checked) - { - ImportFlags |= ExportImportFlags.KeepExisting; - } + ImportFlags |= ExportImportFlags.KeepExisting; } } - - #endregion } + + #endregion } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/KeywordActionDlg.Designer.cs b/src/Logexpert.UI/Dialogs/KeywordActionDlg.Designer.cs index 3a776b37..d7c8b0d6 100644 --- a/src/Logexpert.UI/Dialogs/KeywordActionDlg.Designer.cs +++ b/src/Logexpert.UI/Dialogs/KeywordActionDlg.Designer.cs @@ -1,139 +1,138 @@ -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +partial class KeywordActionDlg { - partial class KeywordActionDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} - #region Windows Form Designer generated code +#region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(KeywordActionDlg)); - this.actionComboBox = new System.Windows.Forms.ComboBox(); - this.label1 = new System.Windows.Forms.Label(); - this.parameterTextBox = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.buttonOk = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.commentTextBox = new System.Windows.Forms.TextBox(); - this.SuspendLayout(); - // - // actionComboBox - // - this.actionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.actionComboBox.FormattingEnabled = true; - this.actionComboBox.Location = new System.Drawing.Point(12, 36); - this.actionComboBox.Name = "actionComboBox"; - this.actionComboBox.Size = new System.Drawing.Size(329, 28); - this.actionComboBox.TabIndex = 0; - this.actionComboBox.SelectedIndexChanged += new System.EventHandler(this.OnActionComboBoxSelectedIndexChanged); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 20); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(166, 20); - this.label1.TabIndex = 1; - this.label1.Text = "Keyword action plugin:"; - // - // parameterTextBox - // - this.parameterTextBox.Location = new System.Drawing.Point(12, 188); - this.parameterTextBox.Name = "parameterTextBox"; - this.parameterTextBox.Size = new System.Drawing.Size(331, 26); - this.parameterTextBox.TabIndex = 2; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(12, 172); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(83, 20); - this.label2.TabIndex = 3; - this.label2.Text = "Parameter"; - // - // buttonOk - // - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(166, 223); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 23); - this.buttonOk.TabIndex = 4; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.OnOkButtonClick); - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(264, 223); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // commentTextBox - // - this.commentTextBox.Location = new System.Drawing.Point(15, 64); - this.commentTextBox.Multiline = true; - this.commentTextBox.Name = "commentTextBox"; - this.commentTextBox.ReadOnly = true; - this.commentTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.commentTextBox.Size = new System.Drawing.Size(326, 95); - this.commentTextBox.TabIndex = 6; - // - // KeywordActionDlg - // - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(353, 258); - this.Controls.Add(this.commentTextBox); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.label2); - this.Controls.Add(this.parameterTextBox); - this.Controls.Add(this.label1); - this.Controls.Add(this.actionComboBox); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "KeywordActionDlg"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Keyword Action"; - this.ResumeLayout(false); - this.PerformLayout(); +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(KeywordActionDlg)); + this.actionComboBox = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.parameterTextBox = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.commentTextBox = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // actionComboBox + // + this.actionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.actionComboBox.FormattingEnabled = true; + this.actionComboBox.Location = new System.Drawing.Point(12, 36); + this.actionComboBox.Name = "actionComboBox"; + this.actionComboBox.Size = new System.Drawing.Size(329, 28); + this.actionComboBox.TabIndex = 0; + this.actionComboBox.SelectedIndexChanged += new System.EventHandler(this.OnActionComboBoxSelectedIndexChanged); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 20); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(166, 20); + this.label1.TabIndex = 1; + this.label1.Text = "Keyword action plugin:"; + // + // parameterTextBox + // + this.parameterTextBox.Location = new System.Drawing.Point(12, 188); + this.parameterTextBox.Name = "parameterTextBox"; + this.parameterTextBox.Size = new System.Drawing.Size(331, 26); + this.parameterTextBox.TabIndex = 2; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 172); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(83, 20); + this.label2.TabIndex = 3; + this.label2.Text = "Parameter"; + // + // buttonOk + // + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(166, 223); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 4; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.OnOkButtonClick); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(264, 223); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // commentTextBox + // + this.commentTextBox.Location = new System.Drawing.Point(15, 64); + this.commentTextBox.Multiline = true; + this.commentTextBox.Name = "commentTextBox"; + this.commentTextBox.ReadOnly = true; + this.commentTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.commentTextBox.Size = new System.Drawing.Size(326, 95); + this.commentTextBox.TabIndex = 6; + // + // KeywordActionDlg + // + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(353, 258); + this.Controls.Add(this.commentTextBox); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.label2); + this.Controls.Add(this.parameterTextBox); + this.Controls.Add(this.label1); + this.Controls.Add(this.actionComboBox); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "KeywordActionDlg"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Keyword Action"; + this.ResumeLayout(false); + this.PerformLayout(); - } +} - #endregion +#endregion - private System.Windows.Forms.ComboBox actionComboBox; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox parameterTextBox; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Button buttonOk; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.TextBox commentTextBox; - } +private System.Windows.Forms.ComboBox actionComboBox; +private System.Windows.Forms.Label label1; +private System.Windows.Forms.TextBox parameterTextBox; +private System.Windows.Forms.Label label2; +private System.Windows.Forms.Button buttonOk; +private System.Windows.Forms.Button buttonCancel; +private System.Windows.Forms.TextBox commentTextBox; } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/KeywordActionDlg.cs b/src/Logexpert.UI/Dialogs/KeywordActionDlg.cs index c933850b..b34dca5b 100644 --- a/src/Logexpert.UI/Dialogs/KeywordActionDlg.cs +++ b/src/Logexpert.UI/Dialogs/KeywordActionDlg.cs @@ -2,82 +2,81 @@ using System.Runtime.Versioning; -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +[SupportedOSPlatform("windows")] +public partial class KeywordActionDlg : Form { - [SupportedOSPlatform("windows")] - public partial class KeywordActionDlg : Form - { - #region Fields + #region Fields - private readonly IDictionary _actionDict = new Dictionary(); + private readonly IDictionary _actionDict = new Dictionary(); - private IList _keywordActionList; + private IList _keywordActionList; - #endregion + #endregion - #region cTor + #region cTor - public KeywordActionDlg(ActionEntry entry, IList actionList) - { - _keywordActionList = actionList; - ActionEntry = entry; + public KeywordActionDlg(ActionEntry entry, IList actionList) + { + _keywordActionList = actionList; + ActionEntry = entry; - InitializeComponent(); + InitializeComponent(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; - actionComboBox.Items.Clear(); + actionComboBox.Items.Clear(); - foreach (IKeywordAction action in actionList) + foreach (IKeywordAction action in actionList) + { + actionComboBox.Items.Add(action.GetName()); + _actionDict[action.GetName()] = action; + } + + if (actionComboBox.Items.Count > 0) + { + if (ActionEntry.PluginName != null && _actionDict.ContainsKey(ActionEntry.PluginName)) { - actionComboBox.Items.Add(action.GetName()); - _actionDict[action.GetName()] = action; + actionComboBox.SelectedItem = ActionEntry.PluginName; } - - if (actionComboBox.Items.Count > 0) + else { - if (ActionEntry.PluginName != null && _actionDict.ContainsKey(ActionEntry.PluginName)) - { - actionComboBox.SelectedItem = ActionEntry.PluginName; - } - else - { - actionComboBox.SelectedIndex = 0; - } + actionComboBox.SelectedIndex = 0; } - - parameterTextBox.Text = ActionEntry.ActionParam; } - #endregion + parameterTextBox.Text = ActionEntry.ActionParam; + } - #region Properties + #endregion - public ActionEntry ActionEntry { get; private set; } + #region Properties - #endregion + public ActionEntry ActionEntry { get; private set; } - #region Events handler + #endregion - private void OnOkButtonClick(object sender, EventArgs e) - { - ActionEntry = new ActionEntry - { - ActionParam = parameterTextBox.Text - }; + #region Events handler - if (_actionDict.ContainsKey((string)actionComboBox.SelectedItem)) - { - ActionEntry.PluginName = (string)actionComboBox.SelectedItem; - } - } + private void OnOkButtonClick(object sender, EventArgs e) + { + ActionEntry = new ActionEntry + { + ActionParam = parameterTextBox.Text + }; - private void OnActionComboBoxSelectedIndexChanged(object sender, EventArgs e) + if (_actionDict.ContainsKey((string)actionComboBox.SelectedItem)) { - commentTextBox.Text = _actionDict[(string)actionComboBox.SelectedItem].GetDescription(); + ActionEntry.PluginName = (string)actionComboBox.SelectedItem; } + } - #endregion + private void OnActionComboBoxSelectedIndexChanged(object sender, EventArgs e) + { + commentTextBox.Text = _actionDict[(string)actionComboBox.SelectedItem].GetDescription(); } + + #endregion } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.Designer.cs b/src/Logexpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.Designer.cs new file mode 100644 index 00000000..812f5924 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.Designer.cs @@ -0,0 +1,155 @@ +namespace LogExpert.Dialogs; + +partial class FilterSelectorForm +{ +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; + +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} + +#region Windows Form Designer generated code + +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FilterSelectorForm)); + this.filterComboBox = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.okButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); + this.commentTextBox = new System.Windows.Forms.TextBox(); + this.applyToAllCheckBox = new System.Windows.Forms.CheckBox(); + this.helpProvider1 = new System.Windows.Forms.HelpProvider(); + this.configButton = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // filterComboBox + // + this.filterComboBox.DisplayMember = "Text"; + this.filterComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.filterComboBox.FormattingEnabled = true; + this.filterComboBox.Location = new System.Drawing.Point(12, 25); + this.filterComboBox.Name = "filterComboBox"; + this.filterComboBox.Size = new System.Drawing.Size(298, 21); + this.filterComboBox.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(13, 6); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(108, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Choose a columnizer:"; + // + // okButton + // + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.Location = new System.Drawing.Point(154, 194); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(75, 23); + this.okButton.TabIndex = 2; + this.okButton.Text = "OK"; + this.okButton.UseVisualStyleBackColor = true; + // + // cancelButton + // + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(235, 194); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(75, 23); + this.cancelButton.TabIndex = 3; + this.cancelButton.Text = "Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + // + // commentTextBox + // + this.commentTextBox.Location = new System.Drawing.Point(12, 81); + this.commentTextBox.Multiline = true; + this.commentTextBox.Name = "commentTextBox"; + this.commentTextBox.ReadOnly = true; + this.commentTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.commentTextBox.Size = new System.Drawing.Size(298, 89); + this.commentTextBox.TabIndex = 4; + // + // applyToAllCheckBox + // + this.applyToAllCheckBox.AutoSize = true; + this.applyToAllCheckBox.Location = new System.Drawing.Point(12, 176); + this.applyToAllCheckBox.Name = "applyToAllCheckBox"; + this.applyToAllCheckBox.Size = new System.Drawing.Size(125, 17); + this.applyToAllCheckBox.TabIndex = 6; + this.applyToAllCheckBox.Text = "Apply to all open files"; + this.applyToAllCheckBox.UseVisualStyleBackColor = true; + // + // helpProvider1 + // + this.helpProvider1.HelpNamespace = "LogExpert.chm"; + // + // configButton + // + this.configButton.Location = new System.Drawing.Point(235, 52); + this.configButton.Name = "configButton"; + this.configButton.Size = new System.Drawing.Size(75, 23); + this.configButton.TabIndex = 7; + this.configButton.Text = "Config..."; + this.configButton.UseVisualStyleBackColor = true; + this.configButton.Click += new System.EventHandler(this.OnConfigButtonClick); + // + // FilterSelectorForm + // + this.AcceptButton = this.okButton; + this.CancelButton = this.cancelButton; + this.ClientSize = new System.Drawing.Size(322, 232); + this.Controls.Add(this.configButton); + this.Controls.Add(this.applyToAllCheckBox); + this.Controls.Add(this.commentTextBox); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.okButton); + this.Controls.Add(this.label1); + this.Controls.Add(this.filterComboBox); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.helpProvider1.SetHelpKeyword(this, "Columnizers.htm"); + this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FilterSelectorForm"; + this.helpProvider1.SetShowHelp(this, true); + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Columnizer"; + this.ResumeLayout(false); + this.PerformLayout(); + +} + +#endregion + +private System.Windows.Forms.ComboBox filterComboBox; +private System.Windows.Forms.Label label1; +private System.Windows.Forms.Button okButton; +private System.Windows.Forms.Button cancelButton; +private System.Windows.Forms.TextBox commentTextBox; +private System.Windows.Forms.CheckBox applyToAllCheckBox; +private System.Windows.Forms.HelpProvider helpProvider1; +private System.Windows.Forms.Button configButton; +} \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.cs b/src/Logexpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.cs new file mode 100644 index 00000000..f0261e74 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.cs @@ -0,0 +1,102 @@ +using LogExpert.Core.Interface; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; + +namespace LogExpert.Dialogs; + +internal partial class FilterSelectorForm : Form //TODO: Can this be changed to UserControl? +{ + #region Fields + + private readonly ILogLineColumnizerCallback _callback; + private readonly IList _columnizerList; + + #endregion + + #region cTor + + public FilterSelectorForm(IList existingColumnizerList, ILogLineColumnizer currentColumnizer, ILogLineColumnizerCallback callback, IConfigManager configManager) + { + SelectedColumnizer = currentColumnizer; + _callback = callback; + InitializeComponent(); + + ConfigManager = configManager; + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + filterComboBox.SelectedIndexChanged += OnFilterComboBoxSelectedIndexChanged; + + // for the currently selected columnizer use the current instance and not the template instance from + // columnizer registry. This ensures that changes made in columnizer config dialogs + // will apply to the current instance + _columnizerList = new List(); + + foreach (ILogLineColumnizer col in existingColumnizerList) + { + _columnizerList.Add(col.GetType() == SelectedColumnizer.GetType() ? SelectedColumnizer : col); + } + + foreach (ILogLineColumnizer col in _columnizerList) + { + filterComboBox.Items.Add(col); + } + + foreach (ILogLineColumnizer columnizer in _columnizerList) + { + if (columnizer.GetType() == SelectedColumnizer.GetType()) + { + filterComboBox.SelectedItem = columnizer; + break; + } + } + } + + #endregion + + #region Properties + + public ILogLineColumnizer SelectedColumnizer { get; private set; } + + public bool ApplyToAll => applyToAllCheckBox.Checked; + + public bool IsConfigPressed { get; private set; } + public IConfigManager ConfigManager { get; } + + #endregion + + #region Events handler + + private void OnFilterComboBoxSelectedIndexChanged(object sender, EventArgs e) + { + ILogLineColumnizer col = _columnizerList[filterComboBox.SelectedIndex]; + SelectedColumnizer = col; + string description = col.GetDescription(); + description += "\r\nSupports timeshift: " + (SelectedColumnizer.IsTimeshiftImplemented() ? "Yes" : "No"); + commentTextBox.Text = description; + configButton.Enabled = SelectedColumnizer is IColumnizerConfigurator; + } + + + //TODO: Check if this logic can be remoed from this class and remove all the config manager instances from here. + private void OnConfigButtonClick(object sender, EventArgs e) + { + if (SelectedColumnizer is IColumnizerConfigurator configurator) + { + string configDir = ConfigManager.ConfigDir; + + if (ConfigManager.Settings.Preferences.PortableMode) + { + configDir = ConfigManager.PortableModeDir; + } + + configurator.Configure(_callback, configDir); + IsConfigPressed = true; + } + } + + #endregion +} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/FilterSelectorForm.resx b/src/Logexpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.resx similarity index 98% rename from src/LogExpert/Dialogs/FilterSelectorForm.resx rename to src/Logexpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.resx index 03269ae2..59a0e090 100644 --- a/src/LogExpert/Dialogs/FilterSelectorForm.resx +++ b/src/Logexpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.resx @@ -1,134 +1,134 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - - - AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA - AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// - AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// - //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA - AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAIABAAD//wAA - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + + AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// + //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA + AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAIABAAD//wAA + + \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/HighlightDialog.Designer.cs b/src/Logexpert.UI/Dialogs/LogTabWindow/HighlightDialog.Designer.cs new file mode 100644 index 00000000..fab3e223 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/LogTabWindow/HighlightDialog.Designer.cs @@ -0,0 +1,725 @@ +using LogExpert.UI.Controls; + +using System.Drawing; + +namespace LogExpert.Dialogs; + +partial class HighlightDialog +{ + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HighlightDialog)); + listBoxHighlight = new System.Windows.Forms.ListBox(); + btnAdd = new System.Windows.Forms.Button(); + btnDelete = new System.Windows.Forms.Button(); + btnMoveUp = new System.Windows.Forms.Button(); + btnMoveDown = new System.Windows.Forms.Button(); + labelForgroundColor = new System.Windows.Forms.Label(); + labelBackgroundColor = new System.Windows.Forms.Label(); + btnOk = new System.Windows.Forms.Button(); + btnCancel = new System.Windows.Forms.Button(); + textBoxSearchString = new System.Windows.Forms.TextBox(); + labelSearchString = new System.Windows.Forms.Label(); + btnApply = new System.Windows.Forms.Button(); + btnCustomForeColor = new System.Windows.Forms.Button(); + btnCustomBackColor = new System.Windows.Forms.Button(); + checkBoxRegex = new System.Windows.Forms.CheckBox(); + checkBoxCaseSensitive = new System.Windows.Forms.CheckBox(); + checkBoxDontDirtyLed = new System.Windows.Forms.CheckBox(); + groupBoxLineMatchCriteria = new System.Windows.Forms.GroupBox(); + groupBoxColoring = new System.Windows.Forms.GroupBox(); + checkBoxNoBackground = new System.Windows.Forms.CheckBox(); + checkBoxBold = new System.Windows.Forms.CheckBox(); + checkBoxWordMatch = new System.Windows.Forms.CheckBox(); + colorBoxForeground = new ColorComboBox(); + colorBoxBackground = new ColorComboBox(); + groupBoxActions = new System.Windows.Forms.GroupBox(); + btnBookmarkComment = new System.Windows.Forms.Button(); + btnSelectPlugin = new System.Windows.Forms.Button(); + checkBoxPlugin = new System.Windows.Forms.CheckBox(); + checkBoxStopTail = new System.Windows.Forms.CheckBox(); + checkBoxBookmark = new System.Windows.Forms.CheckBox(); + helpProvider = new System.Windows.Forms.HelpProvider(); + groupBox4 = new System.Windows.Forms.GroupBox(); + btnImportGroup = new System.Windows.Forms.Button(); + btnExportGroup = new System.Windows.Forms.Button(); + btnMoveGroupDown = new System.Windows.Forms.Button(); + btnMoveGroupUp = new System.Windows.Forms.Button(); + labelAssignNamesToGroups = new System.Windows.Forms.Label(); + btnCopyGroup = new System.Windows.Forms.Button(); + btnDeleteGroup = new System.Windows.Forms.Button(); + btnNewGroup = new System.Windows.Forms.Button(); + comboBoxGroups = new System.Windows.Forms.ComboBox(); + toolTip = new System.Windows.Forms.ToolTip(components); + pnlBackground = new System.Windows.Forms.Panel(); + groupBoxLineMatchCriteria.SuspendLayout(); + groupBoxColoring.SuspendLayout(); + groupBoxActions.SuspendLayout(); + groupBox4.SuspendLayout(); + pnlBackground.SuspendLayout(); + SuspendLayout(); + // + // listBoxHighlight + // + listBoxHighlight.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + listBoxHighlight.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; + listBoxHighlight.FormattingEnabled = true; + listBoxHighlight.Location = new Point(32, 160); + listBoxHighlight.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + listBoxHighlight.Name = "listBoxHighlight"; + listBoxHighlight.Size = new Size(487, 228); + listBoxHighlight.TabIndex = 0; + listBoxHighlight.SelectedIndexChanged += OnListBoxHighlightSelectedIndexChanged; + // + // btnAdd + // + btnAdd.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + btnAdd.Location = new Point(529, 218); + btnAdd.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnAdd.Name = "btnAdd"; + btnAdd.Size = new Size(158, 35); + btnAdd.TabIndex = 1; + btnAdd.Text = "&Add"; + toolTip.SetToolTip(btnAdd, "Create a new hilight item from information below"); + btnAdd.UseVisualStyleBackColor = true; + btnAdd.Click += OnAddButtonClick; + // + // btnDelete + // + btnDelete.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + btnDelete.Location = new Point(529, 263); + btnDelete.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnDelete.Name = "btnDelete"; + btnDelete.Size = new Size(158, 35); + btnDelete.TabIndex = 2; + btnDelete.Text = "D&elete"; + toolTip.SetToolTip(btnDelete, "Delete the current hilight"); + btnDelete.UseVisualStyleBackColor = true; + btnDelete.Click += OnDeleteButtonClick; + // + // btnMoveUp + // + btnMoveUp.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + btnMoveUp.Location = new Point(529, 160); + btnMoveUp.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnMoveUp.Name = "btnMoveUp"; + btnMoveUp.Size = new Size(75, 35); + btnMoveUp.TabIndex = 3; + btnMoveUp.Text = "&Up"; + toolTip.SetToolTip(btnMoveUp, "Move the current hilight one position up"); + btnMoveUp.UseVisualStyleBackColor = true; + btnMoveUp.Click += OnBtnMoveUpClick; + // + // btnMoveDown + // + btnMoveDown.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + btnMoveDown.Location = new Point(612, 160); + btnMoveDown.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnMoveDown.Name = "btnMoveDown"; + btnMoveDown.Size = new Size(75, 35); + btnMoveDown.TabIndex = 4; + btnMoveDown.Text = "&Down"; + toolTip.SetToolTip(btnMoveDown, "Move the current hilight one position down"); + btnMoveDown.UseVisualStyleBackColor = true; + btnMoveDown.Click += OnBtnMoveDownClick; + // + // labelForgroundColor + // + labelForgroundColor.AutoSize = true; + labelForgroundColor.Location = new Point(9, 38); + labelForgroundColor.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelForgroundColor.Name = "labelForgroundColor"; + labelForgroundColor.Size = new Size(99, 15); + labelForgroundColor.TabIndex = 6; + labelForgroundColor.Text = "Foreground color"; + // + // labelBackgroundColor + // + labelBackgroundColor.AutoSize = true; + labelBackgroundColor.Location = new Point(9, 115); + labelBackgroundColor.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelBackgroundColor.Name = "labelBackgroundColor"; + labelBackgroundColor.Size = new Size(101, 15); + labelBackgroundColor.TabIndex = 8; + labelBackgroundColor.Text = "Background color"; + // + // btnOk + // + btnOk.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; + btnOk.DialogResult = System.Windows.Forms.DialogResult.OK; + btnOk.Location = new Point(449, 832); + btnOk.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnOk.Name = "btnOk"; + btnOk.Size = new Size(112, 35); + btnOk.TabIndex = 9; + btnOk.Text = "OK"; + btnOk.UseVisualStyleBackColor = true; + btnOk.Click += OnBtnOkClick; + // + // btnCancel + // + btnCancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; + btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + btnCancel.Location = new Point(576, 832); + btnCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnCancel.Name = "btnCancel"; + btnCancel.Size = new Size(112, 35); + btnCancel.TabIndex = 10; + btnCancel.Text = "Cancel"; + btnCancel.UseVisualStyleBackColor = true; + // + // textBoxSearchString + // + textBoxSearchString.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + textBoxSearchString.Location = new Point(9, 55); + textBoxSearchString.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + textBoxSearchString.Name = "textBoxSearchString"; + textBoxSearchString.Size = new Size(639, 23); + textBoxSearchString.TabIndex = 11; + textBoxSearchString.TextChanged += ChangeToDirty; + // + // labelSearchString + // + labelSearchString.AutoSize = true; + labelSearchString.Location = new Point(9, 31); + labelSearchString.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelSearchString.Name = "labelSearchString"; + labelSearchString.Size = new Size(78, 15); + labelSearchString.TabIndex = 12; + labelSearchString.Text = "Search string:"; + // + // btnApply + // + btnApply.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + btnApply.Enabled = false; + btnApply.Image = (Image)resources.GetObject("btnApply.Image"); + btnApply.ImageAlign = ContentAlignment.MiddleRight; + btnApply.Location = new Point(529, 308); + btnApply.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnApply.Name = "btnApply"; + btnApply.Size = new Size(158, 35); + btnApply.TabIndex = 13; + btnApply.Text = "A&pply"; + toolTip.SetToolTip(btnApply, "Apply changes below to current hiligth"); + btnApply.UseVisualStyleBackColor = true; + btnApply.Click += OnBtnApplyClick; + // + // btnCustomForeColor + // + btnCustomForeColor.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + btnCustomForeColor.Location = new Point(247, 60); + btnCustomForeColor.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnCustomForeColor.Name = "btnCustomForeColor"; + btnCustomForeColor.Size = new Size(78, 35); + btnCustomForeColor.TabIndex = 14; + btnCustomForeColor.Text = "Custom"; + toolTip.SetToolTip(btnCustomForeColor, "Pick a custom foreground color"); + btnCustomForeColor.UseVisualStyleBackColor = true; + btnCustomForeColor.Click += OnBtnCustomForeColorClick; + // + // btnCustomBackColor + // + btnCustomBackColor.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + btnCustomBackColor.Location = new Point(247, 137); + btnCustomBackColor.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnCustomBackColor.Name = "btnCustomBackColor"; + btnCustomBackColor.Size = new Size(78, 35); + btnCustomBackColor.TabIndex = 15; + btnCustomBackColor.Text = "Custom"; + toolTip.SetToolTip(btnCustomBackColor, "Pick a custom background color"); + btnCustomBackColor.UseVisualStyleBackColor = true; + btnCustomBackColor.Click += OnBtnCustomBackColorClick; + // + // checkBoxRegex + // + checkBoxRegex.AutoSize = true; + checkBoxRegex.Location = new Point(180, 95); + checkBoxRegex.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxRegex.Name = "checkBoxRegex"; + checkBoxRegex.Size = new Size(57, 19); + checkBoxRegex.TabIndex = 16; + checkBoxRegex.Text = "RegEx"; + toolTip.SetToolTip(checkBoxRegex, "Whether the string is a regular expresion"); + checkBoxRegex.UseVisualStyleBackColor = true; + checkBoxRegex.CheckedChanged += ChangeToDirty; + checkBoxRegex.MouseUp += OnChkBoxRegexMouseUp; + // + // checkBoxCaseSensitive + // + checkBoxCaseSensitive.AutoSize = true; + checkBoxCaseSensitive.Location = new Point(14, 95); + checkBoxCaseSensitive.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxCaseSensitive.Name = "checkBoxCaseSensitive"; + checkBoxCaseSensitive.Size = new Size(99, 19); + checkBoxCaseSensitive.TabIndex = 17; + checkBoxCaseSensitive.Text = "Case sensitive"; + toolTip.SetToolTip(checkBoxCaseSensitive, "Whether the string will match uppercases and lowercases"); + checkBoxCaseSensitive.UseVisualStyleBackColor = true; + checkBoxCaseSensitive.CheckedChanged += ChangeToDirty; + // + // checkBoxDontDirtyLed + // + checkBoxDontDirtyLed.AutoSize = true; + checkBoxDontDirtyLed.Location = new Point(15, 38); + checkBoxDontDirtyLed.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxDontDirtyLed.Name = "checkBoxDontDirtyLed"; + checkBoxDontDirtyLed.Size = new Size(118, 19); + checkBoxDontDirtyLed.TabIndex = 18; + checkBoxDontDirtyLed.Text = "Don't lit dirty LED"; + toolTip.SetToolTip(checkBoxDontDirtyLed, "When matching a line, don't mark the page as \"dirty\""); + checkBoxDontDirtyLed.UseVisualStyleBackColor = true; + checkBoxDontDirtyLed.CheckedChanged += ChangeToDirty; + // + // groupBoxLineMatchCriteria + // + groupBoxLineMatchCriteria.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + groupBoxLineMatchCriteria.Controls.Add(textBoxSearchString); + groupBoxLineMatchCriteria.Controls.Add(labelSearchString); + groupBoxLineMatchCriteria.Controls.Add(checkBoxRegex); + groupBoxLineMatchCriteria.Controls.Add(checkBoxCaseSensitive); + groupBoxLineMatchCriteria.Location = new Point(18, 437); + groupBoxLineMatchCriteria.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxLineMatchCriteria.Name = "groupBoxLineMatchCriteria"; + groupBoxLineMatchCriteria.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxLineMatchCriteria.Size = new Size(671, 135); + groupBoxLineMatchCriteria.TabIndex = 19; + groupBoxLineMatchCriteria.TabStop = false; + groupBoxLineMatchCriteria.Text = "Line match criteria"; + // + // groupBoxColoring + // + groupBoxColoring.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + groupBoxColoring.Controls.Add(checkBoxNoBackground); + groupBoxColoring.Controls.Add(checkBoxBold); + groupBoxColoring.Controls.Add(checkBoxWordMatch); + groupBoxColoring.Controls.Add(labelForgroundColor); + groupBoxColoring.Controls.Add(colorBoxForeground); + groupBoxColoring.Controls.Add(btnCustomForeColor); + groupBoxColoring.Controls.Add(btnCustomBackColor); + groupBoxColoring.Controls.Add(labelBackgroundColor); + groupBoxColoring.Controls.Add(colorBoxBackground); + groupBoxColoring.Location = new Point(18, 581); + groupBoxColoring.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxColoring.Name = "groupBoxColoring"; + groupBoxColoring.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxColoring.Size = new Size(349, 286); + groupBoxColoring.TabIndex = 20; + groupBoxColoring.TabStop = false; + groupBoxColoring.Text = "Coloring"; + // + // checkBoxNoBackground + // + checkBoxNoBackground.AutoSize = true; + checkBoxNoBackground.Enabled = false; + checkBoxNoBackground.Location = new Point(141, 240); + checkBoxNoBackground.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxNoBackground.Name = "checkBoxNoBackground"; + checkBoxNoBackground.Size = new Size(109, 19); + checkBoxNoBackground.TabIndex = 18; + checkBoxNoBackground.Text = "No Background"; + toolTip.SetToolTip(checkBoxNoBackground, "Don't set the background color"); + checkBoxNoBackground.UseVisualStyleBackColor = true; + checkBoxNoBackground.CheckedChanged += OnChkBoxNoBackgroundCheckedChanged; + // + // checkBoxBold + // + checkBoxBold.AutoSize = true; + checkBoxBold.Location = new Point(9, 205); + checkBoxBold.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxBold.Name = "checkBoxBold"; + checkBoxBold.Size = new Size(50, 19); + checkBoxBold.TabIndex = 17; + checkBoxBold.Text = "Bold"; + toolTip.SetToolTip(checkBoxBold, "Display the line in bold characters"); + checkBoxBold.UseVisualStyleBackColor = true; + checkBoxBold.CheckedChanged += OnChkBoxBoldCheckedChanged; + // + // checkBoxWordMatch + // + checkBoxWordMatch.AutoSize = true; + checkBoxWordMatch.Location = new Point(9, 240); + checkBoxWordMatch.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxWordMatch.Name = "checkBoxWordMatch"; + checkBoxWordMatch.Size = new Size(89, 19); + checkBoxWordMatch.TabIndex = 16; + checkBoxWordMatch.Text = "Word mode"; + toolTip.SetToolTip(checkBoxWordMatch, "Don't highlight the whole line but only the matching keywords"); + checkBoxWordMatch.UseVisualStyleBackColor = true; + checkBoxWordMatch.CheckedChanged += OnChkBoxWordMatchCheckedChanged; + // + // colorBoxForeground + // + colorBoxForeground.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + colorBoxForeground.CustomColor = Color.Black; + colorBoxForeground.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; + colorBoxForeground.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + colorBoxForeground.FormattingEnabled = true; + colorBoxForeground.Location = new Point(8, 63); + colorBoxForeground.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + colorBoxForeground.Name = "colorBoxForeground"; + colorBoxForeground.Size = new Size(229, 24); + colorBoxForeground.TabIndex = 5; + colorBoxForeground.SelectedIndexChanged += ChangeToDirty; + // + // colorBoxBackground + // + colorBoxBackground.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + colorBoxBackground.CustomColor = Color.Black; + colorBoxBackground.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; + colorBoxBackground.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + colorBoxBackground.FormattingEnabled = true; + colorBoxBackground.Location = new Point(9, 140); + colorBoxBackground.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + colorBoxBackground.Name = "colorBoxBackground"; + colorBoxBackground.Size = new Size(229, 24); + colorBoxBackground.TabIndex = 7; + colorBoxBackground.SelectedIndexChanged += ChangeToDirty; + // + // groupBoxActions + // + groupBoxActions.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; + groupBoxActions.Controls.Add(btnBookmarkComment); + groupBoxActions.Controls.Add(btnSelectPlugin); + groupBoxActions.Controls.Add(checkBoxPlugin); + groupBoxActions.Controls.Add(checkBoxStopTail); + groupBoxActions.Controls.Add(checkBoxBookmark); + groupBoxActions.Controls.Add(checkBoxDontDirtyLed); + groupBoxActions.Location = new Point(377, 581); + groupBoxActions.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxActions.Name = "groupBoxActions"; + groupBoxActions.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxActions.Size = new Size(312, 195); + groupBoxActions.TabIndex = 21; + groupBoxActions.TabStop = false; + groupBoxActions.Text = "Actions"; + // + // btnBookmarkComment + // + btnBookmarkComment.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + btnBookmarkComment.Location = new Point(210, 69); + btnBookmarkComment.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnBookmarkComment.Name = "btnBookmarkComment"; + btnBookmarkComment.Size = new Size(81, 31); + btnBookmarkComment.TabIndex = 23; + btnBookmarkComment.Text = "Text..."; + btnBookmarkComment.UseVisualStyleBackColor = true; + btnBookmarkComment.Click += OnBtnBookmarkCommentClick; + // + // btnSelectPlugin + // + btnSelectPlugin.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + btnSelectPlugin.Location = new Point(210, 143); + btnSelectPlugin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnSelectPlugin.Name = "btnSelectPlugin"; + btnSelectPlugin.Size = new Size(81, 31); + btnSelectPlugin.TabIndex = 22; + btnSelectPlugin.Text = "Select..."; + btnSelectPlugin.UseVisualStyleBackColor = true; + btnSelectPlugin.Click += OnPluginButtonClick; + // + // checkBoxPlugin + // + checkBoxPlugin.AutoSize = true; + checkBoxPlugin.Location = new Point(15, 148); + checkBoxPlugin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxPlugin.Name = "checkBoxPlugin"; + checkBoxPlugin.Size = new Size(60, 19); + checkBoxPlugin.TabIndex = 21; + checkBoxPlugin.Text = "Plugin"; + toolTip.SetToolTip(checkBoxPlugin, "When matching a line, call a keyword action plugin"); + checkBoxPlugin.UseVisualStyleBackColor = true; + checkBoxPlugin.CheckedChanged += OnChkBoxPluginCheckedChanged; + // + // checkBoxStopTail + // + checkBoxStopTail.AutoSize = true; + checkBoxStopTail.Location = new Point(15, 111); + checkBoxStopTail.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxStopTail.Name = "checkBoxStopTail"; + checkBoxStopTail.Size = new Size(109, 19); + checkBoxStopTail.TabIndex = 20; + checkBoxStopTail.Text = "Stop Follow Tail"; + toolTip.SetToolTip(checkBoxStopTail, "When matching a line, stop automatic scrolling"); + checkBoxStopTail.UseVisualStyleBackColor = true; + checkBoxStopTail.CheckedChanged += ChangeToDirty; + // + // checkBoxBookmark + // + checkBoxBookmark.AutoSize = true; + checkBoxBookmark.Location = new Point(15, 74); + checkBoxBookmark.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxBookmark.Name = "checkBoxBookmark"; + checkBoxBookmark.Size = new Size(99, 19); + checkBoxBookmark.TabIndex = 19; + checkBoxBookmark.Text = "Set bookmark"; + toolTip.SetToolTip(checkBoxBookmark, "When matching a line, create a new bookmark for it"); + checkBoxBookmark.UseVisualStyleBackColor = true; + checkBoxBookmark.CheckedChanged += ChangeToDirty; + // + // helpProvider + // + helpProvider.HelpNamespace = "LogExpert.chm"; + helpProvider.Tag = ""; + // + // groupBox4 + // + groupBox4.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + groupBox4.Controls.Add(btnImportGroup); + groupBox4.Controls.Add(btnExportGroup); + groupBox4.Controls.Add(btnMoveGroupDown); + groupBox4.Controls.Add(btnMoveGroupUp); + groupBox4.Controls.Add(labelAssignNamesToGroups); + groupBox4.Controls.Add(btnCopyGroup); + groupBox4.Controls.Add(btnDeleteGroup); + groupBox4.Controls.Add(btnNewGroup); + groupBox4.Controls.Add(comboBoxGroups); + groupBox4.Location = new Point(18, 5); + groupBox4.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBox4.Name = "groupBox4"; + groupBox4.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBox4.Size = new Size(671, 129); + groupBox4.TabIndex = 22; + groupBox4.TabStop = false; + groupBox4.Text = "Groups"; + // + // btnImportGroup + // + btnImportGroup.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; + btnImportGroup.Location = new Point(333, 26); + btnImportGroup.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnImportGroup.Name = "btnImportGroup"; + btnImportGroup.Size = new Size(75, 35); + btnImportGroup.TabIndex = 7; + btnImportGroup.Text = "Import"; + toolTip.SetToolTip(btnImportGroup, "Import highlight groups"); + btnImportGroup.UseVisualStyleBackColor = true; + btnImportGroup.Click += OnBtnImportGroupClick; + // + // btnExportGroup + // + btnExportGroup.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; + btnExportGroup.Location = new Point(333, 75); + btnExportGroup.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnExportGroup.Name = "btnExportGroup"; + btnExportGroup.Size = new Size(75, 35); + btnExportGroup.TabIndex = 8; + btnExportGroup.Text = "Export"; + toolTip.SetToolTip(btnExportGroup, "Export highlight groups"); + btnExportGroup.UseVisualStyleBackColor = true; + btnExportGroup.Click += OnBtnExportGroupClick; + // + // btnMoveGroupDown + // + btnMoveGroupDown.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + btnMoveGroupDown.Location = new Point(582, 75); + btnMoveGroupDown.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnMoveGroupDown.Name = "btnMoveGroupDown"; + btnMoveGroupDown.Size = new Size(75, 35); + btnMoveGroupDown.TabIndex = 6; + btnMoveGroupDown.Text = "Down"; + toolTip.SetToolTip(btnMoveGroupDown, "Move the current hilight group one position down"); + btnMoveGroupDown.UseVisualStyleBackColor = true; + btnMoveGroupDown.Click += OnBtnGroupDownClick; + // + // btnMoveGroupUp + // + btnMoveGroupUp.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + btnMoveGroupUp.Location = new Point(499, 75); + btnMoveGroupUp.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnMoveGroupUp.Name = "btnMoveGroupUp"; + btnMoveGroupUp.Size = new Size(75, 35); + btnMoveGroupUp.TabIndex = 5; + btnMoveGroupUp.Text = "Up"; + toolTip.SetToolTip(btnMoveGroupUp, "Move the current hilight group one position up"); + btnMoveGroupUp.UseVisualStyleBackColor = true; + btnMoveGroupUp.Click += OnBtnGroupUpClick; + // + // labelAssignNamesToGroups + // + labelAssignNamesToGroups.AutoSize = true; + labelAssignNamesToGroups.Location = new Point(9, 88); + labelAssignNamesToGroups.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelAssignNamesToGroups.Name = "labelAssignNamesToGroups"; + labelAssignNamesToGroups.Size = new Size(276, 15); + labelAssignNamesToGroups.TabIndex = 4; + labelAssignNamesToGroups.Text = "You can assign groups to file names in the settings."; + // + // btnCopyGroup + // + btnCopyGroup.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; + btnCopyGroup.Location = new Point(582, 26); + btnCopyGroup.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnCopyGroup.Name = "btnCopyGroup"; + btnCopyGroup.Size = new Size(75, 35); + btnCopyGroup.TabIndex = 3; + btnCopyGroup.Text = "Copy"; + toolTip.SetToolTip(btnCopyGroup, "Copy the current hilight group into a new one"); + btnCopyGroup.UseVisualStyleBackColor = true; + btnCopyGroup.Click += OnBtnCopyGroupClick; + // + // btnDeleteGroup + // + btnDeleteGroup.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; + btnDeleteGroup.Location = new Point(499, 26); + btnDeleteGroup.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnDeleteGroup.Name = "btnDeleteGroup"; + btnDeleteGroup.Size = new Size(75, 35); + btnDeleteGroup.TabIndex = 2; + btnDeleteGroup.Text = "Del"; + toolTip.SetToolTip(btnDeleteGroup, "Delete the current hilight group"); + btnDeleteGroup.UseVisualStyleBackColor = true; + btnDeleteGroup.Click += OnBtnDelGroupClick; + // + // btnNewGroup + // + btnNewGroup.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; + btnNewGroup.Location = new Point(416, 26); + btnNewGroup.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + btnNewGroup.Name = "btnNewGroup"; + btnNewGroup.Size = new Size(75, 35); + btnNewGroup.TabIndex = 1; + btnNewGroup.Text = "New group"; + btnNewGroup.TextAlign = ContentAlignment.MiddleLeft; + toolTip.SetToolTip(btnNewGroup, "Create a new empty hilight group"); + btnNewGroup.UseVisualStyleBackColor = true; + btnNewGroup.Click += OnBtnNewGroupClick; + // + // comboBoxGroups + // + comboBoxGroups.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + comboBoxGroups.DisplayMember = "GroupName"; + comboBoxGroups.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; + comboBoxGroups.Location = new Point(14, 32); + comboBoxGroups.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + comboBoxGroups.Name = "comboBoxGroups"; + comboBoxGroups.Size = new Size(311, 24); + comboBoxGroups.TabIndex = 0; + toolTip.SetToolTip(comboBoxGroups, "Choose a group to create different highlight settings. Type in a name to change in the name of a group."); + comboBoxGroups.DrawItem += OnCmbBoxGroupDrawItem; + comboBoxGroups.SelectionChangeCommitted += OnCmbBoxGroupSelectionChangeCommitted; + comboBoxGroups.TextUpdate += OnCmbBoxGroupTextUpdate; + // + // pnlBackground + // + pnlBackground.AutoScroll = true; + pnlBackground.Controls.Add(listBoxHighlight); + pnlBackground.Controls.Add(btnAdd); + pnlBackground.Controls.Add(btnDelete); + pnlBackground.Controls.Add(btnMoveUp); + pnlBackground.Controls.Add(btnMoveDown); + pnlBackground.Controls.Add(btnOk); + pnlBackground.Controls.Add(btnCancel); + pnlBackground.Controls.Add(btnApply); + pnlBackground.Controls.Add(groupBoxLineMatchCriteria); + pnlBackground.Controls.Add(groupBoxColoring); + pnlBackground.Controls.Add(groupBoxActions); + pnlBackground.Controls.Add(groupBox4); + pnlBackground.Dock = System.Windows.Forms.DockStyle.Fill; + pnlBackground.Location = new Point(0, 0); + pnlBackground.Name = "pnlBackground"; + pnlBackground.Size = new Size(708, 895); + pnlBackground.TabIndex = 23; + // + // HighlightDialog + // + AcceptButton = btnOk; + CancelButton = btnCancel; + ClientSize = new Size(708, 895); + Controls.Add(pnlBackground); + DoubleBuffered = true; + helpProvider.SetHelpKeyword(this, "Highlighting.htm"); + helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); + helpProvider.SetHelpString(this, ""); + Icon = (Icon)resources.GetObject("$this.Icon"); + Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + MaximizeBox = false; + MinimizeBox = false; + MinimumSize = new Size(660, 934); + Name = "HighlightDialog"; + helpProvider.SetShowHelp(this, true); + StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + Text = "Highlighting and action triggers"; + Shown += OnHighlightDialogShown; + groupBoxLineMatchCriteria.ResumeLayout(false); + groupBoxLineMatchCriteria.PerformLayout(); + groupBoxColoring.ResumeLayout(false); + groupBoxColoring.PerformLayout(); + groupBoxActions.ResumeLayout(false); + groupBoxActions.PerformLayout(); + groupBox4.ResumeLayout(false); + groupBox4.PerformLayout(); + pnlBackground.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.ListBox listBoxHighlight; + private System.Windows.Forms.Button btnAdd; + private System.Windows.Forms.Button btnDelete; + private System.Windows.Forms.Button btnMoveUp; + private System.Windows.Forms.Button btnMoveDown; + private ColorComboBox colorBoxForeground; + private System.Windows.Forms.Label labelForgroundColor; + private ColorComboBox colorBoxBackground; + private System.Windows.Forms.Label labelBackgroundColor; + private System.Windows.Forms.Button btnOk; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.TextBox textBoxSearchString; + private System.Windows.Forms.Label labelSearchString; + private System.Windows.Forms.Button btnApply; + private System.Windows.Forms.Button btnCustomForeColor; + private System.Windows.Forms.Button btnCustomBackColor; + private System.Windows.Forms.CheckBox checkBoxRegex; + private System.Windows.Forms.CheckBox checkBoxCaseSensitive; + private System.Windows.Forms.CheckBox checkBoxDontDirtyLed; + private System.Windows.Forms.GroupBox groupBoxLineMatchCriteria; + private System.Windows.Forms.GroupBox groupBoxColoring; + private System.Windows.Forms.GroupBox groupBoxActions; + private System.Windows.Forms.CheckBox checkBoxBookmark; + private System.Windows.Forms.CheckBox checkBoxStopTail; + private System.Windows.Forms.HelpProvider helpProvider; + private System.Windows.Forms.CheckBox checkBoxPlugin; + private System.Windows.Forms.Button btnSelectPlugin; + private System.Windows.Forms.Button btnBookmarkComment; + private System.Windows.Forms.GroupBox groupBox4; + private System.Windows.Forms.ComboBox comboBoxGroups; + private System.Windows.Forms.Button btnDeleteGroup; + private System.Windows.Forms.Button btnNewGroup; + private System.Windows.Forms.Button btnCopyGroup; + private System.Windows.Forms.ToolTip toolTip; + private System.Windows.Forms.Label labelAssignNamesToGroups; + private System.Windows.Forms.Button btnMoveGroupUp; + private System.Windows.Forms.Button btnMoveGroupDown; + private System.Windows.Forms.CheckBox checkBoxWordMatch; + private System.Windows.Forms.CheckBox checkBoxBold; + private System.Windows.Forms.CheckBox checkBoxNoBackground; + private System.Windows.Forms.Button btnImportGroup; + private System.Windows.Forms.Button btnExportGroup; + private System.Windows.Forms.Panel pnlBackground; +} \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs b/src/Logexpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs new file mode 100644 index 00000000..6ccfcb29 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs @@ -0,0 +1,731 @@ +using LogExpert.Core.Classes.Highlight; +using LogExpert.Core.Entities; +using LogExpert.Core.Interface; +using LogExpert.UI.Controls; +using LogExpert.UI.Dialogs; + +using NLog; + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using System.Windows.Forms; + +namespace LogExpert.Dialogs; + +public partial class HighlightDialog : Form +{ + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + + #region Private Fields + + private readonly Image _applyButtonImage; + private string _bookmarkComment; + private ActionEntry _currentActionEntry = new(); + private HighlightGroup _currentGroup; + private List _highlightGroupList; + + #endregion + + #region Ctor + + public HighlightDialog(IConfigManager configManager) + { + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + ConfigManager = configManager; + Load += OnHighlightDialogLoad; + listBoxHighlight.DrawItem += OnHighlightListBoxDrawItem; + _applyButtonImage = btnApply.Image; + btnApply.Image = null; + } + + #endregion + + #region Properties / Indexers + + public List HighlightGroupList + { + get => _highlightGroupList; + set + { + _highlightGroupList ??= []; + + foreach (var group in value) + { + _highlightGroupList.Add((HighlightGroup)group.Clone()); + } + } + } + + public IList KeywordActionList { get; set; } + + public string PreSelectedGroupName { get; set; } + + private bool IsDirty => btnApply.Image == _applyButtonImage; + + private IConfigManager ConfigManager { get; } + + #endregion + + #region Event handling Methods + + private void OnAddButtonClick(object sender, EventArgs e) + { + AddNewEntry(); + Dirty(); + } + + private void OnBtnApplyClick(object sender, EventArgs e) + { + SaveEntry(); + } + + private void OnBtnBookmarkCommentClick(object sender, EventArgs e) + { + BookmarkCommentDlg dlg = new(); + dlg.Comment = _bookmarkComment; + if (dlg.ShowDialog() == DialogResult.OK) + { + _bookmarkComment = dlg.Comment; + Dirty(); + } + } + + private void OnBtnCopyGroupClick(object sender, EventArgs e) + { + if (comboBoxGroups.SelectedIndex >= 0 && comboBoxGroups.SelectedIndex < HighlightGroupList.Count) + { + HighlightGroup newGroup = (HighlightGroup)HighlightGroupList[comboBoxGroups.SelectedIndex].Clone(); + newGroup.GroupName = "Copy of " + newGroup.GroupName; + + HighlightGroupList.Add(newGroup); + FillGroupComboBox(); + SelectGroup(HighlightGroupList.Count - 1); + } + } + + private void OnBtnCustomBackColorClick(object sender, EventArgs e) + { + ChooseColor(colorBoxBackground); + Dirty(); + } + + private void OnBtnCustomForeColorClick(object sender, EventArgs e) + { + ChooseColor(colorBoxForeground); + Dirty(); + } + + private void OnBtnDelGroupClick(object sender, EventArgs e) + { + // the last group cannot be deleted + if (HighlightGroupList.Count == 1) + { + return; + } + + if (comboBoxGroups.SelectedIndex >= 0 && comboBoxGroups.SelectedIndex < HighlightGroupList.Count) + { + int index = comboBoxGroups.SelectedIndex; + HighlightGroupList.RemoveAt(comboBoxGroups.SelectedIndex); + FillGroupComboBox(); + if (index < HighlightGroupList.Count) + { + SelectGroup(index); + } + else + { + SelectGroup(HighlightGroupList.Count - 1); + } + } + } + + //TODO: This class should not knoow ConfigManager? + private void OnBtnExportGroupClick(object sender, EventArgs e) + { + SaveFileDialog dlg = new() + { + Title = @"Export Settings to file", + DefaultExt = "json", + AddExtension = true, + Filter = @"Settings (*.json)|*.json|All files (*.*)|*.*" + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + FileInfo fileInfo = new(dlg.FileName); + ConfigManager.Export(fileInfo, Core.Config.SettingsFlags.HighlightSettings); + } + } + + private void OnBtnGroupDownClick(object sender, EventArgs e) + { + int index = comboBoxGroups.SelectedIndex; + if (index > -1 && index < _highlightGroupList.Count - 1) + { + _highlightGroupList.Reverse(index, 2); + comboBoxGroups.Refresh(); + FillGroupComboBox(); + SelectGroup(index + 1); + } + } + + private void OnBtnGroupUpClick(object sender, EventArgs e) + { + int index = comboBoxGroups.SelectedIndex; + if (index > 0) + { + _highlightGroupList.Reverse(index - 1, 2); + comboBoxGroups.Refresh(); + FillGroupComboBox(); + SelectGroup(index - 1); + } + } + + private void OnBtnImportGroupClick(object sender, EventArgs e) + { + ImportSettingsDialog dlg = new(Core.Config.ExportImportFlags.HighlightSettings); + + foreach (Control ctl in dlg.groupBoxImportOptions.Controls) + { + if (ctl.Tag != null) + { + ((CheckBox)ctl).Checked = false; + } + } + + dlg.checkBoxHighlightSettings.Checked = true; + dlg.checkBoxKeepExistingSettings.Checked = true; + + if (dlg.ShowDialog() != DialogResult.OK) + { + return; + } + + if (string.IsNullOrWhiteSpace(dlg.FileName)) + { + return; + } + + Cursor.Current = Cursors.WaitCursor; + + FileInfo fileInfo; + + try + { + fileInfo = new FileInfo(dlg.FileName); + } + catch (Exception ex) + { + MessageBox.Show(this, $@"Settings could not be imported: {ex}", @"LogExpert"); + _logger.Error($"Error while trying to access file: {dlg.FileName}: {ex}"); + return; + } + + ConfigManager.ImportHighlightSettings(fileInfo, dlg.ImportFlags); + Cursor.Current = Cursors.Default; + + _highlightGroupList = ConfigManager.Settings.Preferences.HighlightGroupList; + + FillGroupComboBox(); + + MessageBox.Show(this, @"Settings imported", @"LogExpert"); + } + + private void OnBtnMoveDownClick(object sender, EventArgs e) + { + int index = listBoxHighlight.SelectedIndex; + + if (index > -1 && index < listBoxHighlight.Items.Count - 1) + { + object item = listBoxHighlight.SelectedItem; + listBoxHighlight.Items.RemoveAt(index); + listBoxHighlight.Items.Insert(index + 1, item); + listBoxHighlight.SelectedIndex = index + 1; + _currentGroup.HighlightEntryList.Reverse(index, 2); + } + } + + private void OnBtnMoveUpClick(object sender, EventArgs e) + { + int index = listBoxHighlight.SelectedIndex; + if (index > 0) + { + object item = listBoxHighlight.SelectedItem; + listBoxHighlight.Items.RemoveAt(index); // will also clear the selection + listBoxHighlight.Items.Insert(index - 1, item); + listBoxHighlight.SelectedIndex = index - 1; // restore the selection + _currentGroup.HighlightEntryList.Reverse(index - 1, 2); + } + } + + private void OnBtnNewGroupClick(object sender, EventArgs e) + { + // Propose a unique name + const string baseName = "New group"; + string name = baseName; + bool uniqueName = false; + int i = 1; + while (!uniqueName) + { + uniqueName = HighlightGroupList.FindIndex(delegate (HighlightGroup g) { return g.GroupName == name; }) < 0; + + if (!uniqueName) + { + name = $"{baseName} #{i++}"; + } + } + + HighlightGroup newGroup = new() { GroupName = name }; + HighlightGroupList.Add(newGroup); + FillGroupComboBox(); + SelectGroup(HighlightGroupList.Count - 1); + } + + private void OnBtnOkClick(object sender, EventArgs e) + { + // Apply pending changes if closing the form. + if (IsDirty) + { + // cannot call 'this.applyButton.PerformClick();' because it prohibits the OK button to terminate the dialog + OnBtnApplyClick(btnApply, EventArgs.Empty); + } + } + + private void OnChkBoxBoldCheckedChanged(object sender, EventArgs e) + { + Dirty(); + } + + private void OnChkBoxNoBackgroundCheckedChanged(object sender, EventArgs e) + { + colorBoxBackground.Enabled = !checkBoxNoBackground.Checked; + btnCustomBackColor.Enabled = !checkBoxNoBackground.Checked; + Dirty(); + } + + private void OnChkBoxPluginCheckedChanged(object sender, EventArgs e) + { + Dirty(); + btnSelectPlugin.Enabled = checkBoxPlugin.Checked; + } + + private void OnChkBoxRegexMouseUp(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + RegexHelperDialog dlg = new() + { + Owner = this, + CaseSensitive = checkBoxCaseSensitive.Checked, + Pattern = textBoxSearchString.Text + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + checkBoxCaseSensitive.Checked = dlg.CaseSensitive; + textBoxSearchString.Text = dlg.Pattern; + } + } + } + + private void OnChkBoxWordMatchCheckedChanged(object sender, EventArgs e) + { + Dirty(); + checkBoxNoBackground.Enabled = checkBoxWordMatch.Checked; + } + + private void OnCmbBoxGroupDrawItem(object sender, DrawItemEventArgs e) + { + e.DrawBackground(); + if (e.Index >= 0) + { + HighlightGroup group = HighlightGroupList[e.Index]; + Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); + + Brush brush = new SolidBrush(SystemColors.ControlText); + e.Graphics.DrawString(group.GroupName, e.Font, brush, new PointF(rectangle.Left, rectangle.Top)); + e.DrawFocusRectangle(); + brush.Dispose(); + } + } + + private void OnCmbBoxGroupSelectionChangeCommitted(object sender, EventArgs e) + { + SelectGroup(comboBoxGroups.SelectedIndex); + } + + private void OnCmbBoxGroupTextUpdate(object sender, EventArgs e) + { + _currentGroup.GroupName = comboBoxGroups.Text; + } + + private void OnDeleteButtonClick(object sender, EventArgs e) + { + if (listBoxHighlight.SelectedIndex >= 0) + { + int removeIndex = listBoxHighlight.SelectedIndex; + _currentGroup.HighlightEntryList.RemoveAt(removeIndex); + listBoxHighlight.Items.RemoveAt(removeIndex); + + // Select previous (or first if none before) + int nextSelectIndex = removeIndex; + if (nextSelectIndex >= listBoxHighlight.Items.Count) + { + nextSelectIndex--; // if last item was removed, go one up + } + + if (nextSelectIndex >= 0) + { + listBoxHighlight.SelectedIndex = nextSelectIndex; // if still some item, select it + } + + ReEvaluateHighlightButtonStates(); + } + } + + private void OnHighlightDialogLoad(object sender, EventArgs e) + { + colorBoxForeground.SelectedIndex = 1; + colorBoxBackground.SelectedIndex = 2; + btnApply.Enabled = false; + btnApply.Image = null; + btnBookmarkComment.Enabled = false; + btnSelectPlugin.Enabled = false; + + ReEvaluateHighlightButtonStates(); + } + + private void OnHighlightDialogShown(object sender, EventArgs e) + { + InitData(); + } + + private void OnHighlightListBoxDrawItem(object sender, DrawItemEventArgs e) + { + e.DrawBackground(); + if (e.Index >= 0) + { + HighlightEntry entry = (HighlightEntry)listBoxHighlight.Items[e.Index]; + Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); + + if ((e.State & DrawItemState.Selected) != DrawItemState.Selected) + { + e.Graphics.FillRectangle(new SolidBrush(entry.BackgroundColor), rectangle); + } + + e.Graphics.DrawString(entry.SearchText, e.Font, new SolidBrush(entry.ForegroundColor), + new PointF(rectangle.Left, rectangle.Top)); + + e.DrawFocusRectangle(); + } + } + + private void OnListBoxHighlightSelectedIndexChanged(object sender, EventArgs e) + { + StartEditEntry(); + } + + private void OnPluginButtonClick(object sender, EventArgs e) + { + KeywordActionDlg dlg = new(_currentActionEntry, KeywordActionList); + + if (dlg.ShowDialog() == DialogResult.OK) + { + _currentActionEntry = dlg.ActionEntry; + Dirty(); + } + } + + #endregion + + #region Private Methods + + private void AddNewEntry() + { + { + try + { + CheckRegex(); + + HighlightEntry entry = new() + { + SearchText = textBoxSearchString.Text, + ForegroundColor = colorBoxForeground.SelectedColor, + BackgroundColor = colorBoxBackground.SelectedColor, + IsRegEx = checkBoxRegex.Checked, + IsCaseSensitive = checkBoxCaseSensitive.Checked, + IsLedSwitch = checkBoxDontDirtyLed.Checked, + IsStopTail = checkBoxStopTail.Checked, + IsSetBookmark = checkBoxBookmark.Checked, + IsActionEntry = checkBoxPlugin.Checked, + ActionEntry = _currentActionEntry, + IsWordMatch = checkBoxWordMatch.Checked, + IsBold = checkBoxBold.Checked, + NoBackground = checkBoxNoBackground.Checked + }; + + listBoxHighlight.Items.Add(entry); + + // Select the newly created item + _currentGroup.HighlightEntryList.Add(entry); + listBoxHighlight.SelectedItem = entry; + } + catch (Exception ex) + { + _logger.Error(ex, "Error during add of highlight entry"); + MessageBox.Show($"Error during add of entry.\r\n{ex.Message}"); + } + } + } + + private void ChangeToDirty(object sender, EventArgs e) + { + Dirty(); + } + + private void CheckRegex() + { + if (checkBoxRegex.Checked) + { + if (string.IsNullOrWhiteSpace(textBoxSearchString.Text)) + { + throw new ArgumentException("Regex value is null or whitespace"); + } + + // ReSharper disable once ReturnValueOfPureMethodIsNotUsed + Regex.IsMatch("", textBoxSearchString.Text); + } + } + + private void ChooseColor(ColorComboBox comboBox) + { + ColorDialog colorDialog = new(); + colorDialog.AllowFullOpen = true; + colorDialog.ShowHelp = false; + colorDialog.Color = comboBox.CustomColor; + if (colorDialog.ShowDialog() == DialogResult.OK) + { + comboBox.CustomColor = colorDialog.Color; + comboBox.SelectedIndex = 0; + } + } + + private void Dirty() + { + int index = listBoxHighlight.SelectedIndex; + if (index > -1) + { + btnApply.Enabled = true; + btnApply.Image = _applyButtonImage; + } + + btnAdd.Enabled = textBoxSearchString.Text.Length > 0; + } + + private void FillGroupComboBox() + { + SelectGroup(-1); + + comboBoxGroups.Items.Clear(); + + foreach (HighlightGroup group in HighlightGroupList) + { + comboBoxGroups.Items.Add(group); + } + + ReEvaluateGroupButtonStates(); + } + + private void FillHighlightListBox() + { + listBoxHighlight.Items.Clear(); + if (_currentGroup != null) + { + foreach (HighlightEntry entry in _currentGroup.HighlightEntryList) + { + listBoxHighlight.Items.Add(entry); + } + } + } + + private void InitData() + { + const string def = "[Default]"; + HighlightGroupList ??= []; + + if (HighlightGroupList.Count == 0) + { + HighlightGroup highlightGroup = new() + { + GroupName = def, + HighlightEntryList = [] + }; + + HighlightGroupList.Add(highlightGroup); + } + + FillGroupComboBox(); + + _currentGroup = null; + string groupToSelect = PreSelectedGroupName; + if (string.IsNullOrEmpty(groupToSelect)) + { + groupToSelect = def; + } + + foreach (HighlightGroup group in HighlightGroupList) + { + if (group.GroupName.Equals(groupToSelect)) + { + _currentGroup = group; + comboBoxGroups.SelectedValue = group; + comboBoxGroups.SelectedIndex = HighlightGroupList.IndexOf(group); + break; + } + } + + ReEvaluateGroupButtonStates(); + + FillHighlightListBox(); + } + + private void ReEvaluateGroupButtonStates() + { + // Refresh button states based on the selection in the combobox + bool atLeastOneSelected = comboBoxGroups.SelectedItem != null; + bool moreThanOne = comboBoxGroups.Items.Count > 1; + bool firstSelected = atLeastOneSelected && comboBoxGroups.SelectedIndex == 0; + bool lastSelected = atLeastOneSelected && comboBoxGroups.SelectedIndex == comboBoxGroups.Items.Count - 1; + + btnDeleteGroup.Enabled = atLeastOneSelected; + btnCopyGroup.Enabled = atLeastOneSelected; + btnMoveGroupUp.Enabled = atLeastOneSelected && moreThanOne && !firstSelected; + btnMoveGroupDown.Enabled = atLeastOneSelected && moreThanOne && !lastSelected; + } + + private void ReEvaluateHighlightButtonStates() + { + // Refresh button states based on the selection in the combobox + bool atLeastOneSelected = listBoxHighlight.SelectedItem != null; + bool moreThanOne = listBoxHighlight.Items.Count > 1; + bool firstSelected = atLeastOneSelected && listBoxHighlight.SelectedIndex == 0; + bool lastSelected = atLeastOneSelected && listBoxHighlight.SelectedIndex == listBoxHighlight.Items.Count - 1; + + btnDelete.Enabled = atLeastOneSelected; + btnMoveUp.Enabled = atLeastOneSelected && moreThanOne && !firstSelected; + btnMoveDown.Enabled = atLeastOneSelected && moreThanOne && !lastSelected; + } + + private void SaveEntry() + { + try + { + CheckRegex(); + + HighlightEntry entry = (HighlightEntry)listBoxHighlight.SelectedItem; + + entry.ForegroundColor = (Color)colorBoxForeground.SelectedItem; + entry.BackgroundColor = (Color)colorBoxBackground.SelectedItem; + entry.SearchText = textBoxSearchString.Text; + entry.IsRegEx = checkBoxRegex.Checked; + entry.IsCaseSensitive = checkBoxCaseSensitive.Checked; + btnApply.Enabled = false; + btnApply.Image = null; + entry.IsLedSwitch = checkBoxDontDirtyLed.Checked; + entry.IsSetBookmark = checkBoxBookmark.Checked; + entry.IsStopTail = checkBoxStopTail.Checked; + entry.IsActionEntry = checkBoxPlugin.Checked; + entry.ActionEntry = (ActionEntry)_currentActionEntry.Clone(); + entry.BookmarkComment = _bookmarkComment; + entry.IsWordMatch = checkBoxWordMatch.Checked; + entry.IsBold = checkBoxBold.Checked; + entry.NoBackground = checkBoxNoBackground.Checked; + listBoxHighlight.Refresh(); + } + catch (Exception ex) + { + _logger.Error(ex, "Error during save of save highlight entry"); + MessageBox.Show($"Error during save of entry.\r\n{ex.Message}"); + } + } + + private void SelectGroup(int index) + { + if (index >= 0 && index < HighlightGroupList.Count) + { + _currentGroup = HighlightGroupList[index]; + comboBoxGroups.Items[index] = _currentGroup; + comboBoxGroups.SelectedIndex = index; + comboBoxGroups.SelectedItem = _currentGroup; + FillHighlightListBox(); + } + else + { + comboBoxGroups.SelectedItem = null; + _currentGroup = null; + listBoxHighlight.Items.Clear(); + } + + ReEvaluateHighlightButtonStates(); + ReEvaluateGroupButtonStates(); + } + + private void StartEditEntry() + { + HighlightEntry entry = (HighlightEntry)listBoxHighlight.SelectedItem; + + if (entry != null) + { + textBoxSearchString.Text = entry.SearchText; + + colorBoxForeground.CustomColor = entry.ForegroundColor; + colorBoxBackground.CustomColor = entry.BackgroundColor; + + if (colorBoxForeground.Items.Contains(entry.ForegroundColor)) + { + colorBoxForeground.SelectedIndex = colorBoxForeground.Items.Cast().ToList().LastIndexOf(entry.ForegroundColor); + } + else + { + colorBoxForeground.SelectedItem = entry.ForegroundColor; + } + + if (colorBoxForeground.Items.Contains(entry.ForegroundColor)) + { + colorBoxBackground.SelectedIndex = colorBoxBackground.Items.Cast().ToList().LastIndexOf(entry.BackgroundColor); + } + else + { + colorBoxBackground.SelectedItem = entry.BackgroundColor; + } + + checkBoxRegex.Checked = entry.IsRegEx; + checkBoxCaseSensitive.Checked = entry.IsCaseSensitive; + checkBoxDontDirtyLed.Checked = entry.IsLedSwitch; + checkBoxBookmark.Checked = entry.IsSetBookmark; + checkBoxStopTail.Checked = entry.IsStopTail; + checkBoxPlugin.Checked = entry.IsActionEntry; + btnSelectPlugin.Enabled = checkBoxPlugin.Checked; + btnBookmarkComment.Enabled = checkBoxBookmark.Checked; + _currentActionEntry = entry.ActionEntry != null ? (ActionEntry)entry.ActionEntry.Clone() : new ActionEntry(); + _bookmarkComment = entry.BookmarkComment; + checkBoxWordMatch.Checked = entry.IsWordMatch; + checkBoxBold.Checked = entry.IsBold; + checkBoxNoBackground.Checked = entry.NoBackground; + } + + btnApply.Enabled = false; + btnApply.Image = null; + + ReEvaluateHighlightButtonStates(); + } + + #endregion +} diff --git a/src/LogExpert/Dialogs/HighlightDialog.resx b/src/Logexpert.UI/Dialogs/LogTabWindow/HighlightDialog.resx similarity index 100% rename from src/LogExpert/Dialogs/HighlightDialog.resx rename to src/Logexpert.UI/Dialogs/LogTabWindow/HighlightDialog.resx diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs new file mode 100644 index 00000000..4c4533b9 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs @@ -0,0 +1,361 @@ +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.Interface; +using LogExpert.Dialogs; +using LogExpert.UI.Extensions.Forms; +using NLog; +using System.Reflection; +using System.Text; +using static LogExpert.UI.Controls.LogTabWindow.LogTabWindow; + +namespace LogExpert.UI.Controls.LogTabWindow; + +// Data shared over all LogTabWindow instances +//TODO: Can we get rid of this class? +internal partial class LogTabWindow : Form, ILogTabWindow +{ + #region Fields + + private const int MAX_COLUMNIZER_HISTORY = 40; + private const int MAX_COLOR_HISTORY = 40; + private const int DIFF_MAX = 100; + private const int MAX_FILE_HISTORY = 10; + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private readonly Icon _deadIcon; + + private readonly Color _defaultTabColor = Color.FromArgb(255, 192, 192, 192); + private readonly Brush _dirtyLedBrush; + + private readonly int _instanceNumber; + private readonly Brush[] _ledBrushes = new Brush[5]; + private readonly Icon[,,,] _ledIcons = new Icon[6, 2, 4, 2]; + + private readonly Rectangle[] _leds = new Rectangle[5]; + + private readonly IList _logWindowList = new List(); + private readonly Brush _offLedBrush; + private readonly bool _showInstanceNumbers; + + private readonly string[] _startupFileNames; + + private readonly EventWaitHandle _statusLineEventHandle = new AutoResetEvent(false); + private readonly EventWaitHandle _statusLineEventWakeupHandle = new ManualResetEvent(false); + private readonly Brush _syncLedBrush; + private readonly StringFormat _tabStringFormat = new(); + private readonly Brush[] _tailLedBrush = new Brush[3]; + + private BookmarkWindow _bookmarkWindow; + + private LogWindow.LogWindow _currentLogWindow; + private bool _firstBookmarkWindowShow = true; + + private Thread _ledThread; + + //Settings settings; + + private bool _shouldStop; + + private bool _skipEvents; + + private bool _wasMaximized; + + #endregion + + #region cTor + public LogTabWindow(string[] fileNames, int instanceNumber, bool showInstanceNumbers, IConfigManager configManager) + { + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + InitializeComponent(); + + ConfigManager = configManager; + + //Fix MainMenu and externalToolsToolStrip.Location, if the location has unintentionally been changed in the designer + mainMenuStrip.Location = new Point(0, 0); + externalToolsToolStrip.Location = new Point(0, 54); + + ChangeTheme(Controls); + + _startupFileNames = fileNames; + _instanceNumber = instanceNumber; + _showInstanceNumbers = showInstanceNumbers; + + Load += OnLogTabWindowLoad; + + configManager.Instance.ConfigChanged += OnConfigChanged; + HighlightGroupList = configManager.Settings.Preferences.HighlightGroupList; + + Rectangle led = new(0, 0, 8, 2); + + for (int i = 0; i < _leds.Length; ++i) + { + _leds[i] = led; + led.Offset(0, led.Height + 0); + } + + int grayAlpha = 50; + + _ledBrushes[0] = new SolidBrush(Color.FromArgb(255, 220, 0, 0)); + _ledBrushes[1] = new SolidBrush(Color.FromArgb(255, 220, 220, 0)); + _ledBrushes[2] = new SolidBrush(Color.FromArgb(255, 0, 220, 0)); + _ledBrushes[3] = new SolidBrush(Color.FromArgb(255, 0, 220, 0)); + _ledBrushes[4] = new SolidBrush(Color.FromArgb(255, 0, 220, 0)); + + _offLedBrush = new SolidBrush(Color.FromArgb(grayAlpha, 160, 160, 160)); + + _dirtyLedBrush = new SolidBrush(Color.FromArgb(255, 220, 0, 00)); + + _tailLedBrush[0] = new SolidBrush(Color.FromArgb(255, 50, 100, 250)); // Follow tail: blue-ish + _tailLedBrush[1] = new SolidBrush(Color.FromArgb(grayAlpha, 160, 160, 160)); // Don't follow tail: gray + _tailLedBrush[2] = new SolidBrush(Color.FromArgb(255, 220, 220, 0)); // Stop follow tail (trigger): yellow-ish + + _syncLedBrush = new SolidBrush(Color.FromArgb(255, 250, 145, 30)); + + CreateIcons(); + + _tabStringFormat.LineAlignment = StringAlignment.Center; + _tabStringFormat.Alignment = StringAlignment.Near; + + ToolStripControlHost host = new(checkBoxFollowTail); + + host.Padding = new Padding(20, 0, 0, 0); + host.BackColor = Color.FromKnownColor(KnownColor.Transparent); + + int index = buttonToolStrip.Items.IndexOfKey("toolStripButtonTail"); + + toolStripEncodingASCIIItem.Text = Encoding.ASCII.HeaderName; + toolStripEncodingANSIItem.Text = Encoding.Default.HeaderName; + toolStripEncodingISO88591Item.Text = Encoding.GetEncoding("iso-8859-1").HeaderName; + toolStripEncodingUTF8Item.Text = Encoding.UTF8.HeaderName; + toolStripEncodingUTF16Item.Text = Encoding.Unicode.HeaderName; + + if (index != -1) + { + buttonToolStrip.Items.RemoveAt(index); + buttonToolStrip.Items.Insert(index, host); + } + + dragControlDateTime.Visible = false; + loadProgessBar.Visible = false; + + // get a reference to the current assembly + Assembly a = Assembly.GetExecutingAssembly(); + + // get a list of resource names from the manifest + string[] resNames = a.GetManifestResourceNames(); + + Bitmap bmp = Resources.Resources.Deceased; + _deadIcon = Icon.FromHandle(bmp.GetHicon()); + bmp.Dispose(); + Closing += OnLogTabWindowClosing; + + InitToolWindows(); + } + + #endregion + + #region ColorTheme + public void ChangeTheme(Control.ControlCollection container) + { + ColorMode.LoadColorMode(ConfigManager.Settings.Preferences.darkMode); + ColorMode.UseImmersiveDarkMode(Handle, ColorMode.DarkModeEnabled); + + #region ApplyColorToAllControls + foreach (Control component in container) + { + if (component.Controls != null && component.Controls.Count > 0) + { + ChangeTheme(component.Controls); + component.BackColor = ColorMode.BackgroundColor; + component.ForeColor = ColorMode.ForeColor; + } + else + { + component.BackColor = ColorMode.BackgroundColor; + component.ForeColor = ColorMode.ForeColor; + } + + if (component is MenuStrip menu) + { + foreach (ToolStripMenuItem item in menu.Items) + { + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.BackgroundColor; + + try + { + for (var x = 0; x < item.DropDownItems.Count; x++) + { + var children = item.DropDownItems[x]; + children.ForeColor = ColorMode.ForeColor; + children.BackColor = ColorMode.MenuBackgroundColor; + + if (children is ToolStripDropDownItem toolstripDropDownItem) + { + for (var y = 0; y < toolstripDropDownItem.DropDownItems.Count; y++) + { + var subChildren = toolstripDropDownItem.DropDownItems[y]; + subChildren.ForeColor = ColorMode.ForeColor; + subChildren.BackColor = ColorMode.MenuBackgroundColor; + } + } + } + } + catch (Exception ex) + { + _logger.Error(ex, "An error occured while applying style dynamically to all Controls under LogTabWindow:"); + } + } + } + } + #endregion + + // Colors for selected menus + mainMenuStrip.Renderer = new ExtendedMenuStripRenderer(); + + // Dock special color + dockPanel.DockBackColor = ColorMode.DockBackgroundColor; + + // Remove toolstrip bottom border + buttonToolStrip.Renderer = new ToolStripRendererExtension(); + + #region Tabs + tabContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); + + // Tabs menu + for (var y = 0; y < tabContextMenuStrip.Items.Count; y++) + { + var item = tabContextMenuStrip.Items[y]; + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.MenuBackgroundColor; + } + + // Tabs line + dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient.StartColor = ColorMode.TabsBackgroundStripColor; + dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient.EndColor = ColorMode.TabsBackgroundStripColor; + + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.DockStripGradient.StartColor = ColorMode.TabsBackgroundStripColor; + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.DockStripGradient.EndColor = ColorMode.TabsBackgroundStripColor; + + // Tabs + dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.StartColor = ColorMode.ActiveTabColor; + dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.EndColor = ColorMode.ActiveTabColor; + dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.TextColor = ColorMode.ForeColor; + + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.StartColor = ColorMode.ActiveTabColor; + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.EndColor = ColorMode.ActiveTabColor; + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.TextColor = ColorMode.ForeColor; + + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.StartColor = ColorMode.InactiveTabColor; + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.EndColor = ColorMode.InactiveTabColor; + dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.TextColor = ColorMode.ForeColor; + #endregion Tabs + } + #endregion + + #region Delegates + + private delegate void AddFileTabsDelegate(string[] fileNames); + + private delegate void ExceptionFx(); + + private delegate void FileNotFoundDelegate(LogWindow.LogWindow logWin); + + private delegate void FileRespawnedDelegate(LogWindow.LogWindow logWin); + + public delegate void HighlightSettingsChangedEventHandler(object sender, EventArgs e); + + private delegate void LoadMultiFilesDelegate(string[] fileName, EncodingOptions encodingOptions); + + private delegate void SetColumnizerFx(ILogLineColumnizer columnizer); + + private delegate void SetTabIconDelegate(LogWindow.LogWindow logWindow, Icon icon); + + #endregion + + #region Events + + public event HighlightSettingsChangedEventHandler HighlightSettingsChanged; + + #endregion + + #region Properties + + public LogWindow.LogWindow CurrentLogWindow + { + get => _currentLogWindow; + set => ChangeCurrentLogWindow(value); + } + + public SearchParams SearchParams { get; private set; } = new SearchParams(); + + public Preferences Preferences => ConfigManager.Settings.Preferences; + + public List HighlightGroupList { get; private set; } = []; + + //public Settings Settings + //{ + // get { return ConfigManager.Settings; } + //} + + public ILogExpertProxy LogExpertProxy { get; set; } + public IConfigManager ConfigManager { get; } + + #endregion + + #region Internals + + internal HighlightGroup FindHighlightGroup(string groupName) + { + lock (HighlightGroupList) + { + foreach (HighlightGroup group in HighlightGroupList) + { + if (group.GroupName.Equals(groupName)) + { + return group; + } + } + return null; + } + } + + #endregion + + private class LogWindowData + { + #region Fields + + // public MdiTabControl.TabPage tabPage; + public Color color = Color.FromKnownColor(KnownColor.Gray); + + public int diffSum; + public bool dirty; + public int syncMode; // 0 = off, 1 = timeSynced + public int tailState; // tailState: 0,1,2 = on/off/off by Trigger + public ToolTip toolTip; + + #endregion + } +} + +public class StaticLogTabWindowData +{ + #region Properties + + public ILogTabWindow CurrentLockedMainWindow { get; set; } + + #endregion +} + +public abstract class AbstractLogTabWindow() +{ + public static StaticLogTabWindowData StaticData { get; set; } = new StaticLogTabWindowData(); + + public static ILogTabWindow Create(string[] fileNames, int instanceNumber, bool showInstanceNumbers, IConfigManager configManager) + { + return new LogTabWindow(fileNames, instanceNumber, showInstanceNumbers, configManager); + } + +} diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs b/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs similarity index 98% rename from src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs rename to src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs index e90da425..4030f93d 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.designer.cs +++ b/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs @@ -1,1286 +1,1284 @@ -using System.Windows.Forms; - -using LogExpert.Core.Enums; -using LogExpert.Dialogs; -using LogExpert.UI.Extensions.Forms; - -using WeifenLuo.WinFormsUI.Docking; - -namespace LogExpert.Controls.LogTabWindow -{ - partial class LogTabWindow - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - components = new System.ComponentModel.Container(); - AutoHideStripSkin autoHideStripSkin1 = new AutoHideStripSkin(); - DockPanelGradient dockPanelGradient1 = new DockPanelGradient(); - TabGradient tabGradient1 = new TabGradient(); - DockPaneStripSkin dockPaneStripSkin1 = new DockPaneStripSkin(); - DockPaneStripGradient dockPaneStripGradient1 = new DockPaneStripGradient(); - TabGradient tabGradient2 = new TabGradient(); - DockPanelGradient dockPanelGradient2 = new DockPanelGradient(); - TabGradient tabGradient3 = new TabGradient(); - DockPaneStripToolWindowGradient dockPaneStripToolWindowGradient1 = new DockPaneStripToolWindowGradient(); - TabGradient tabGradient4 = new TabGradient(); - TabGradient tabGradient5 = new TabGradient(); - DockPanelGradient dockPanelGradient3 = new DockPanelGradient(); - TabGradient tabGradient6 = new TabGradient(); - TabGradient tabGradient7 = new TabGradient(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LogTabWindow)); - statusStrip = new StatusStrip(); - labelLines = new ToolStripStatusLabel(); - labelSize = new ToolStripStatusLabel(); - labelCurrentLine = new ToolStripStatusLabel(); - loadProgessBar = new ToolStripProgressBar(); - labelStatus = new ToolStripStatusLabel(); - mainMenuStrip = new MenuStrip(); - fileToolStripMenuItem = new ToolStripMenuItem(); - openToolStripMenuItem = new ToolStripMenuItem(); - openURIToolStripMenuItem = new ToolStripMenuItem(); - closeFileToolStripMenuItem = new ToolStripMenuItem(); - reloadToolStripMenuItem = new ToolStripMenuItem(); - newFromClipboardToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparatorExtension1 = new MenuToolStripSeparatorExtension(); - multiFileToolStripMenuItem = new ToolStripMenuItem(); - multiFileEnabledStripMenuItem = new ToolStripMenuItem(); - multifileMaskToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparatorExtension2 = new MenuToolStripSeparatorExtension(); - loadProjectToolStripMenuItem = new ToolStripMenuItem(); - saveProjectToolStripMenuItem = new ToolStripMenuItem(); - exportBookmarksToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparatorExtension3 = new MenuToolStripSeparatorExtension(); - lastUsedToolStripMenuItem = new ToolStripMenuItem(); - exitToolStripMenuItem = new ToolStripMenuItem(); - viewNavigateToolStripMenuItem = new ToolStripMenuItem(); - goToLineToolStripMenuItem = new ToolStripMenuItem(); - searchToolStripMenuItem = new ToolStripMenuItem(); - filterToolStripMenuItem = new ToolStripMenuItem(); - bookmarksToolStripMenuItem = new ToolStripMenuItem(); - toggleBookmarkToolStripMenuItem = new ToolStripMenuItem(); - jumpToNextToolStripMenuItem = new ToolStripMenuItem(); - jumpToPrevToolStripMenuItem = new ToolStripMenuItem(); - showBookmarkListToolStripMenuItem = new ToolStripMenuItem(); - columnFinderToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparatorExtension5 = new MenuToolStripSeparatorExtension(); - toolStripEncodingMenuItem = new ToolStripMenuItem(); - toolStripEncodingASCIIItem = new ToolStripMenuItem(); - toolStripEncodingANSIItem = new ToolStripMenuItem(); - toolStripEncodingISO88591Item = new ToolStripMenuItem(); - toolStripEncodingUTF8Item = new ToolStripMenuItem(); - toolStripEncodingUTF16Item = new ToolStripMenuItem(); - menuToolStripSeparatorExtension6 = new MenuToolStripSeparatorExtension(); - timeshiftToolStripMenuItem = new ToolStripMenuItem(); - timeshiftMenuTextBox = new ToolStripTextBox(); - menuToolStripSeparatorExtension4 = new MenuToolStripSeparatorExtension(); - copyMarkedLinesIntoNewTabToolStripMenuItem = new ToolStripMenuItem(); - optionToolStripMenuItem = new ToolStripMenuItem(); - columnizerToolStripMenuItem = new ToolStripMenuItem(); - hilightingToolStripMenuItem1 = new ToolStripMenuItem(); - menuToolStripSeparatorExtension7 = new MenuToolStripSeparatorExtension(); - settingsToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparatorExtension9 = new MenuToolStripSeparatorExtension(); - cellSelectModeToolStripMenuItem = new ToolStripMenuItem(); - alwaysOnTopToolStripMenuItem = new ToolStripMenuItem(); - hideLineColumnToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparatorExtension8 = new MenuToolStripSeparatorExtension(); - lockInstanceToolStripMenuItem = new ToolStripMenuItem(); - toolsToolStripMenuItem = new ToolStripMenuItem(); - configureToolStripMenuItem = new ToolStripMenuItem(); - configureToolStripSeparator = new MenuToolStripSeparatorExtension(); - helpToolStripMenuItem = new ToolStripMenuItem(); - showHelpToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparatorExtension11 = new MenuToolStripSeparatorExtension(); - aboutToolStripMenuItem = new ToolStripMenuItem(); - debugToolStripMenuItem = new ToolStripMenuItem(); - dumpLogBufferInfoToolStripMenuItem = new ToolStripMenuItem(); - dumpBufferDiagnosticToolStripMenuItem = new ToolStripMenuItem(); - runGCToolStripMenuItem = new ToolStripMenuItem(); - gCInfoToolStripMenuItem = new ToolStripMenuItem(); - throwExceptionGUIThreadToolStripMenuItem = new ToolStripMenuItem(); - throwExceptionbackgroundThToolStripMenuItem = new ToolStripMenuItem(); - throwExceptionBackgroundThreadToolStripMenuItem = new ToolStripMenuItem(); - loglevelToolStripMenuItem = new ToolStripMenuItem(); - warnToolStripMenuItem = new ToolStripMenuItem(); - infoToolStripMenuItem = new ToolStripMenuItem(); - debugToolStripMenuItem1 = new ToolStripMenuItem(); - disableWordHighlightModeToolStripMenuItem = new ToolStripMenuItem(); - host = new CheckBox(); - toolStripContainer = new ToolStripContainer(); - dockPanel = new DockPanel(); - externalToolsToolStrip = new ToolStrip(); - buttonToolStrip = new ToolStrip(); - toolStripButtonOpen = new ToolStripButton(); - lineToolStripSeparatorExtension1 = new LineToolStripSeparatorExtension(); - toolStripButtonSearch = new ToolStripButton(); - toolStripButtonFilter = new ToolStripButton(); - lineToolStripSeparatorExtension2 = new LineToolStripSeparatorExtension(); - toolStripButtonBookmark = new ToolStripButton(); - toolStripButtonUp = new ToolStripButton(); - toolStripButtonDown = new ToolStripButton(); - lineToolStripSeparatorExtension3 = new LineToolStripSeparatorExtension(); - toolStripButtonBubbles = new ToolStripButton(); - lineToolStripSeparatorExtension4 = new LineToolStripSeparatorExtension(); - toolStripButtonTail = new ToolStripButton(); - lineToolStripSeparatorExtension5 = new LineToolStripSeparatorExtension(); - groupsComboBoxHighlightGroups = new ToolStripComboBox(); - checkBoxFollowTail = new CheckBox(); - tabContextMenuStrip = new ContextMenuStrip(components); - closeThisTabToolStripMenuItem = new ToolStripMenuItem(); - closeOtherTabsToolStripMenuItem = new ToolStripMenuItem(); - closeAllTabsToolStripMenuItem = new ToolStripMenuItem(); - tabColorToolStripMenuItem = new ToolStripMenuItem(); - tabRenameToolStripMenuItem = new ToolStripMenuItem(); - copyPathToClipboardToolStripMenuItem = new ToolStripMenuItem(); - findInExplorerToolStripMenuItem = new ToolStripMenuItem(); - dragControlDateTime = new DateTimeDragControl(); - statusStrip.SuspendLayout(); - mainMenuStrip.SuspendLayout(); - toolStripContainer.ContentPanel.SuspendLayout(); - toolStripContainer.TopToolStripPanel.SuspendLayout(); - toolStripContainer.SuspendLayout(); - buttonToolStrip.SuspendLayout(); - tabContextMenuStrip.SuspendLayout(); - SuspendLayout(); - // - // statusStrip - // - statusStrip.AutoSize = false; - statusStrip.ImageScalingSize = new System.Drawing.Size(24, 24); - statusStrip.Items.AddRange(new ToolStripItem[] { labelLines, labelSize, labelCurrentLine, loadProgessBar, labelStatus }); - statusStrip.Location = new System.Drawing.Point(0, 954); - statusStrip.Name = "statusStrip"; - statusStrip.Padding = new Padding(3, 0, 23, 0); - statusStrip.Size = new System.Drawing.Size(1603, 63); - statusStrip.SizingGrip = false; - statusStrip.TabIndex = 5; - statusStrip.Text = "statusStrip1"; - // - // labelLines - // - labelLines.AutoSize = false; - labelLines.BorderSides = ToolStripStatusLabelBorderSides.Left | ToolStripStatusLabelBorderSides.Top | ToolStripStatusLabelBorderSides.Right | ToolStripStatusLabelBorderSides.Bottom; - labelLines.BorderStyle = Border3DStyle.SunkenOuter; - labelLines.Name = "labelLines"; - labelLines.Size = new System.Drawing.Size(26, 58); - labelLines.Text = "0"; - // - // labelSize - // - labelSize.AutoSize = false; - labelSize.BorderSides = ToolStripStatusLabelBorderSides.Left | ToolStripStatusLabelBorderSides.Top | ToolStripStatusLabelBorderSides.Right | ToolStripStatusLabelBorderSides.Bottom; - labelSize.BorderStyle = Border3DStyle.SunkenOuter; - labelSize.Name = "labelSize"; - labelSize.Size = new System.Drawing.Size(26, 58); - labelSize.Text = "0"; - // - // labelCurrentLine - // - labelCurrentLine.AutoSize = false; - labelCurrentLine.BorderSides = ToolStripStatusLabelBorderSides.Left | ToolStripStatusLabelBorderSides.Top | ToolStripStatusLabelBorderSides.Right | ToolStripStatusLabelBorderSides.Bottom; - labelCurrentLine.BorderStyle = Border3DStyle.SunkenOuter; - labelCurrentLine.Name = "labelCurrentLine"; - labelCurrentLine.Size = new System.Drawing.Size(28, 58); - labelCurrentLine.Text = "L:"; - // - // loadProgessBar - // - loadProgessBar.Name = "loadProgessBar"; - loadProgessBar.Size = new System.Drawing.Size(83, 57); - // - // labelStatus - // - labelStatus.Name = "labelStatus"; - labelStatus.Size = new System.Drawing.Size(39, 58); - labelStatus.Text = "Ready"; - // - // mainMenuStrip - // - mainMenuStrip.AllowMerge = false; - mainMenuStrip.Dock = DockStyle.None; - mainMenuStrip.ImageScalingSize = new System.Drawing.Size(24, 24); - mainMenuStrip.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem, viewNavigateToolStripMenuItem, optionToolStripMenuItem, toolsToolStripMenuItem, helpToolStripMenuItem, debugToolStripMenuItem }); - mainMenuStrip.LayoutStyle = ToolStripLayoutStyle.Flow; - mainMenuStrip.Location = new System.Drawing.Point(0, 19); - mainMenuStrip.Name = "mainMenuStrip"; - mainMenuStrip.Size = new System.Drawing.Size(1603, 23); - mainMenuStrip.TabIndex = 6; - mainMenuStrip.Text = "menuStrip1"; - // - // fileToolStripMenuItem - // - fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { openToolStripMenuItem, openURIToolStripMenuItem, closeFileToolStripMenuItem, reloadToolStripMenuItem, newFromClipboardToolStripMenuItem, menuToolStripSeparatorExtension1, multiFileToolStripMenuItem, menuToolStripSeparatorExtension2, loadProjectToolStripMenuItem, saveProjectToolStripMenuItem, exportBookmarksToolStripMenuItem, menuToolStripSeparatorExtension3, lastUsedToolStripMenuItem, exitToolStripMenuItem }); - fileToolStripMenuItem.Name = "fileToolStripMenuItem"; - fileToolStripMenuItem.Size = new System.Drawing.Size(37, 19); - fileToolStripMenuItem.Text = "File"; - fileToolStripMenuItem.DropDownOpening += OnFileToolStripMenuItemDropDownOpening; - // - // openToolStripMenuItem - // - openToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; - openToolStripMenuItem.Image = LogExpert.Resources.Resources.File_open; - openToolStripMenuItem.Name = "openToolStripMenuItem"; - openToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.O; - openToolStripMenuItem.Size = new System.Drawing.Size(253, 30); - openToolStripMenuItem.Text = "Open..."; - openToolStripMenuItem.Click += OnOpenToolStripMenuItemClick; - // - // openURIToolStripMenuItem - // - openURIToolStripMenuItem.Name = "openURIToolStripMenuItem"; - openURIToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U; - openURIToolStripMenuItem.Size = new System.Drawing.Size(253, 30); - openURIToolStripMenuItem.Text = "Open URL..."; - openURIToolStripMenuItem.ToolTipText = "Opens a file by entering a URL which is supported by a file system plugin"; - openURIToolStripMenuItem.Click += OnOpenURIToolStripMenuItemClick; - // - // closeFileToolStripMenuItem - // - closeFileToolStripMenuItem.Image = LogExpert.Resources.Resources.Close; - closeFileToolStripMenuItem.Name = "closeFileToolStripMenuItem"; - closeFileToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.F4; - closeFileToolStripMenuItem.Size = new System.Drawing.Size(253, 30); - closeFileToolStripMenuItem.Text = "Close File"; - closeFileToolStripMenuItem.Click += OnCloseFileToolStripMenuItemClick; - // - // reloadToolStripMenuItem - // - reloadToolStripMenuItem.Image = LogExpert.Resources.Resources.Restart_alt; - reloadToolStripMenuItem.Name = "reloadToolStripMenuItem"; - reloadToolStripMenuItem.ShortcutKeys = Keys.F5; - reloadToolStripMenuItem.Size = new System.Drawing.Size(253, 30); - reloadToolStripMenuItem.Text = "Reload"; - reloadToolStripMenuItem.Click += OnReloadToolStripMenuItemClick; - // - // newFromClipboardToolStripMenuItem - // - newFromClipboardToolStripMenuItem.Name = "newFromClipboardToolStripMenuItem"; - newFromClipboardToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.N; - newFromClipboardToolStripMenuItem.Size = new System.Drawing.Size(253, 30); - newFromClipboardToolStripMenuItem.Text = "New tab from clipboard"; - newFromClipboardToolStripMenuItem.ToolTipText = "Creates a new tab with content from clipboard"; - newFromClipboardToolStripMenuItem.Click += OnNewFromClipboardToolStripMenuItemClick; - // - // menuToolStripSeparatorExtension1 - // - menuToolStripSeparatorExtension1.Name = "menuToolStripSeparatorExtension1"; - menuToolStripSeparatorExtension1.Size = new System.Drawing.Size(250, 6); - // - // multiFileToolStripMenuItem - // - multiFileToolStripMenuItem.CheckOnClick = true; - multiFileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { multiFileEnabledStripMenuItem, multifileMaskToolStripMenuItem }); - multiFileToolStripMenuItem.Name = "multiFileToolStripMenuItem"; - multiFileToolStripMenuItem.Size = new System.Drawing.Size(253, 30); - multiFileToolStripMenuItem.Text = "MultiFile"; - multiFileToolStripMenuItem.ToolTipText = "Treat multiple files as one large file (e.g. data.log, data.log.1, data.log.2,...)"; - multiFileToolStripMenuItem.Click += OnMultiFileToolStripMenuItemClick; - // - // multiFileEnabledStripMenuItem - // - multiFileEnabledStripMenuItem.BackColor = System.Drawing.SystemColors.Control; - multiFileEnabledStripMenuItem.CheckOnClick = true; - multiFileEnabledStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - multiFileEnabledStripMenuItem.Name = "multiFileEnabledStripMenuItem"; - multiFileEnabledStripMenuItem.Size = new System.Drawing.Size(165, 22); - multiFileEnabledStripMenuItem.Text = "Enable MultiFile"; - multiFileEnabledStripMenuItem.Click += OnMultiFileEnabledStripMenuItemClick; - // - // multifileMaskToolStripMenuItem - // - multifileMaskToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; - multifileMaskToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - multifileMaskToolStripMenuItem.Name = "multifileMaskToolStripMenuItem"; - multifileMaskToolStripMenuItem.Size = new System.Drawing.Size(165, 22); - multifileMaskToolStripMenuItem.Text = "File name mask..."; - multifileMaskToolStripMenuItem.Click += OnMultiFileMaskToolStripMenuItemClick; - // - // menuToolStripSeparatorExtension2 - // - menuToolStripSeparatorExtension2.Name = "menuToolStripSeparatorExtension2"; - menuToolStripSeparatorExtension2.Size = new System.Drawing.Size(250, 6); - // - // loadProjectToolStripMenuItem - // - loadProjectToolStripMenuItem.Name = "loadProjectToolStripMenuItem"; - loadProjectToolStripMenuItem.Size = new System.Drawing.Size(253, 30); - loadProjectToolStripMenuItem.Text = "Load session..."; - loadProjectToolStripMenuItem.ToolTipText = "Load a saved session (list of log files)"; - loadProjectToolStripMenuItem.Click += OnLoadProjectToolStripMenuItemClick; - // - // saveProjectToolStripMenuItem - // - saveProjectToolStripMenuItem.Name = "saveProjectToolStripMenuItem"; - saveProjectToolStripMenuItem.Size = new System.Drawing.Size(253, 30); - saveProjectToolStripMenuItem.Text = "Save session..."; - saveProjectToolStripMenuItem.ToolTipText = "Save a session (all open tabs)"; - saveProjectToolStripMenuItem.Click += OnSaveProjectToolStripMenuItemClick; - // - // exportBookmarksToolStripMenuItem - // - exportBookmarksToolStripMenuItem.Name = "exportBookmarksToolStripMenuItem"; - exportBookmarksToolStripMenuItem.Size = new System.Drawing.Size(253, 30); - exportBookmarksToolStripMenuItem.Text = "Export bookmarks..."; - exportBookmarksToolStripMenuItem.ToolTipText = "Write a list of bookmarks and their comments to a CSV file"; - exportBookmarksToolStripMenuItem.Click += OnExportBookmarksToolStripMenuItemClick; - // - // menuToolStripSeparatorExtension3 - // - menuToolStripSeparatorExtension3.Name = "menuToolStripSeparatorExtension3"; - menuToolStripSeparatorExtension3.Size = new System.Drawing.Size(250, 6); - // - // lastUsedToolStripMenuItem - // - lastUsedToolStripMenuItem.Name = "lastUsedToolStripMenuItem"; - lastUsedToolStripMenuItem.Size = new System.Drawing.Size(253, 30); - lastUsedToolStripMenuItem.Text = "Last used"; - // - // exitToolStripMenuItem - // - exitToolStripMenuItem.Image = LogExpert.Resources.Resources.Exit; - exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - exitToolStripMenuItem.ShortcutKeys = Keys.Alt | Keys.F4; - exitToolStripMenuItem.Size = new System.Drawing.Size(253, 30); - exitToolStripMenuItem.Text = "Exit"; - exitToolStripMenuItem.Click += OnExitToolStripMenuItemClick; - // - // viewNavigateToolStripMenuItem - // - viewNavigateToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { goToLineToolStripMenuItem, searchToolStripMenuItem, filterToolStripMenuItem, bookmarksToolStripMenuItem, columnFinderToolStripMenuItem, menuToolStripSeparatorExtension5, toolStripEncodingMenuItem, menuToolStripSeparatorExtension6, timeshiftToolStripMenuItem, timeshiftMenuTextBox, menuToolStripSeparatorExtension4, copyMarkedLinesIntoNewTabToolStripMenuItem }); - viewNavigateToolStripMenuItem.Name = "viewNavigateToolStripMenuItem"; - viewNavigateToolStripMenuItem.Size = new System.Drawing.Size(96, 19); - viewNavigateToolStripMenuItem.Text = "View/Navigate"; - // - // goToLineToolStripMenuItem - // - goToLineToolStripMenuItem.Name = "goToLineToolStripMenuItem"; - goToLineToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.G; - goToLineToolStripMenuItem.Size = new System.Drawing.Size(189, 30); - goToLineToolStripMenuItem.Text = "Go to line..."; - goToLineToolStripMenuItem.Click += OnGoToLineToolStripMenuItemClick; - // - // searchToolStripMenuItem - // - searchToolStripMenuItem.Name = "searchToolStripMenuItem"; - searchToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.F; - searchToolStripMenuItem.Size = new System.Drawing.Size(189, 30); - searchToolStripMenuItem.Text = "Search..."; - searchToolStripMenuItem.Click += OnSearchToolStripMenuItemClick; - // - // filterToolStripMenuItem - // - filterToolStripMenuItem.Image = LogExpert.Resources.Resources.Filter; - filterToolStripMenuItem.Name = "filterToolStripMenuItem"; - filterToolStripMenuItem.ShortcutKeys = Keys.F4; - filterToolStripMenuItem.Size = new System.Drawing.Size(189, 30); - filterToolStripMenuItem.Text = "Filter"; - filterToolStripMenuItem.Click += OnFilterToolStripMenuItemClick; - // - // bookmarksToolStripMenuItem - // - bookmarksToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { toggleBookmarkToolStripMenuItem, jumpToNextToolStripMenuItem, jumpToPrevToolStripMenuItem, showBookmarkListToolStripMenuItem }); - bookmarksToolStripMenuItem.Name = "bookmarksToolStripMenuItem"; - bookmarksToolStripMenuItem.Size = new System.Drawing.Size(189, 30); - bookmarksToolStripMenuItem.Text = "Bookmarks"; - // - // toggleBookmarkToolStripMenuItem - // - toggleBookmarkToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; - toggleBookmarkToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - toggleBookmarkToolStripMenuItem.Image = LogExpert.Resources.Resources.Bookmark_add; - toggleBookmarkToolStripMenuItem.Name = "toggleBookmarkToolStripMenuItem"; - toggleBookmarkToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.F2; - toggleBookmarkToolStripMenuItem.Size = new System.Drawing.Size(253, 30); - toggleBookmarkToolStripMenuItem.Text = "Toggle Bookmark"; - toggleBookmarkToolStripMenuItem.Click += OnToggleBookmarkToolStripMenuItemClick; - // - // jumpToNextToolStripMenuItem - // - jumpToNextToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; - jumpToNextToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - jumpToNextToolStripMenuItem.Image = LogExpert.Resources.Resources.ArrowDown; - jumpToNextToolStripMenuItem.Name = "jumpToNextToolStripMenuItem"; - jumpToNextToolStripMenuItem.ShortcutKeys = Keys.F2; - jumpToNextToolStripMenuItem.Size = new System.Drawing.Size(253, 30); - jumpToNextToolStripMenuItem.Text = "Jump to next"; - jumpToNextToolStripMenuItem.Click += OnJumpToNextToolStripMenuItemClick; - // - // jumpToPrevToolStripMenuItem - // - jumpToPrevToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; - jumpToPrevToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - jumpToPrevToolStripMenuItem.Image = LogExpert.Resources.Resources.ArrowUp; - jumpToPrevToolStripMenuItem.Name = "jumpToPrevToolStripMenuItem"; - jumpToPrevToolStripMenuItem.ShortcutKeys = Keys.Shift | Keys.F2; - jumpToPrevToolStripMenuItem.Size = new System.Drawing.Size(253, 30); - jumpToPrevToolStripMenuItem.Text = "Jump to prev"; - jumpToPrevToolStripMenuItem.Click += OnJumpToPrevToolStripMenuItemClick; - // - // showBookmarkListToolStripMenuItem - // - showBookmarkListToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; - showBookmarkListToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - showBookmarkListToolStripMenuItem.Name = "showBookmarkListToolStripMenuItem"; - showBookmarkListToolStripMenuItem.ShortcutKeys = Keys.F6; - showBookmarkListToolStripMenuItem.Size = new System.Drawing.Size(253, 30); - showBookmarkListToolStripMenuItem.Text = "Bookmark list"; - showBookmarkListToolStripMenuItem.Click += OnShowBookmarkListToolStripMenuItemClick; - // - // columnFinderToolStripMenuItem - // - columnFinderToolStripMenuItem.CheckOnClick = true; - columnFinderToolStripMenuItem.Name = "columnFinderToolStripMenuItem"; - columnFinderToolStripMenuItem.ShortcutKeys = Keys.F8; - columnFinderToolStripMenuItem.Size = new System.Drawing.Size(189, 30); - columnFinderToolStripMenuItem.Text = "Column finder"; - columnFinderToolStripMenuItem.Click += OnColumnFinderToolStripMenuItemClick; - // - // menuToolStripSeparatorExtension5 - // - menuToolStripSeparatorExtension5.Name = "menuToolStripSeparatorExtension5"; - menuToolStripSeparatorExtension5.Size = new System.Drawing.Size(186, 6); - // - // toolStripEncodingMenuItem - // - toolStripEncodingMenuItem.DropDownItems.AddRange(new ToolStripItem[] { toolStripEncodingASCIIItem, toolStripEncodingANSIItem, toolStripEncodingISO88591Item, toolStripEncodingUTF8Item, toolStripEncodingUTF16Item }); - toolStripEncodingMenuItem.Name = "toolStripEncodingMenuItem"; - toolStripEncodingMenuItem.Size = new System.Drawing.Size(189, 30); - toolStripEncodingMenuItem.Text = "Encoding"; - // - // toolStripEncodingASCIIItem - // - toolStripEncodingASCIIItem.BackColor = System.Drawing.SystemColors.Control; - toolStripEncodingASCIIItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - toolStripEncodingASCIIItem.Name = "toolStripEncodingASCIIItem"; - toolStripEncodingASCIIItem.Size = new System.Drawing.Size(132, 22); - toolStripEncodingASCIIItem.Tag = ""; - toolStripEncodingASCIIItem.Text = "ASCII"; - toolStripEncodingASCIIItem.Click += OnASCIIToolStripMenuItemClick; - // - // toolStripEncodingANSIItem - // - toolStripEncodingANSIItem.BackColor = System.Drawing.SystemColors.Control; - toolStripEncodingANSIItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - toolStripEncodingANSIItem.Name = "toolStripEncodingANSIItem"; - toolStripEncodingANSIItem.Size = new System.Drawing.Size(132, 22); - toolStripEncodingANSIItem.Tag = ""; - toolStripEncodingANSIItem.Text = "ANSI"; - toolStripEncodingANSIItem.Click += OnANSIToolStripMenuItemClick; - // - // toolStripEncodingISO88591Item - // - toolStripEncodingISO88591Item.BackColor = System.Drawing.SystemColors.Control; - toolStripEncodingISO88591Item.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - toolStripEncodingISO88591Item.Name = "toolStripEncodingISO88591Item"; - toolStripEncodingISO88591Item.Size = new System.Drawing.Size(132, 22); - toolStripEncodingISO88591Item.Text = "ISO-8859-1"; - toolStripEncodingISO88591Item.Click += OnISO88591ToolStripMenuItemClick; - // - // toolStripEncodingUTF8Item - // - toolStripEncodingUTF8Item.BackColor = System.Drawing.SystemColors.Control; - toolStripEncodingUTF8Item.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - toolStripEncodingUTF8Item.Name = "toolStripEncodingUTF8Item"; - toolStripEncodingUTF8Item.Size = new System.Drawing.Size(132, 22); - toolStripEncodingUTF8Item.Text = "UTF8"; - toolStripEncodingUTF8Item.Click += OnUTF8ToolStripMenuItemClick; - // - // toolStripEncodingUTF16Item - // - toolStripEncodingUTF16Item.BackColor = System.Drawing.SystemColors.Control; - toolStripEncodingUTF16Item.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - toolStripEncodingUTF16Item.Name = "toolStripEncodingUTF16Item"; - toolStripEncodingUTF16Item.Size = new System.Drawing.Size(132, 22); - toolStripEncodingUTF16Item.Text = "Unicode"; - toolStripEncodingUTF16Item.Click += OnUTF16ToolStripMenuItemClick; - // - // menuToolStripSeparatorExtension6 - // - menuToolStripSeparatorExtension6.Name = "menuToolStripSeparatorExtension6"; - menuToolStripSeparatorExtension6.Size = new System.Drawing.Size(186, 6); - // - // timeshiftToolStripMenuItem - // - timeshiftToolStripMenuItem.CheckOnClick = true; - timeshiftToolStripMenuItem.Name = "timeshiftToolStripMenuItem"; - timeshiftToolStripMenuItem.Size = new System.Drawing.Size(189, 30); - timeshiftToolStripMenuItem.Text = "Timeshift"; - timeshiftToolStripMenuItem.ToolTipText = "If supported by the columnizer, you can set an offset to the displayed log time"; - timeshiftToolStripMenuItem.CheckStateChanged += OnTimeShiftToolStripMenuItemCheckStateChanged; - // - // timeshiftMenuTextBox - // - timeshiftMenuTextBox.BorderStyle = BorderStyle.FixedSingle; - timeshiftMenuTextBox.Enabled = false; - timeshiftMenuTextBox.Font = new System.Drawing.Font("Segoe UI", 9F); - timeshiftMenuTextBox.Name = "timeshiftMenuTextBox"; - timeshiftMenuTextBox.Size = new System.Drawing.Size(100, 23); - timeshiftMenuTextBox.Text = "+00:00:00.000"; - timeshiftMenuTextBox.ToolTipText = "Time offset (hh:mm:ss.fff)"; - timeshiftMenuTextBox.KeyDown += OnTimeShiftMenuTextBoxKeyDown; - // - // menuToolStripSeparatorExtension4 - // - menuToolStripSeparatorExtension4.Name = "menuToolStripSeparatorExtension4"; - menuToolStripSeparatorExtension4.Size = new System.Drawing.Size(186, 6); - // - // copyMarkedLinesIntoNewTabToolStripMenuItem - // - copyMarkedLinesIntoNewTabToolStripMenuItem.Name = "copyMarkedLinesIntoNewTabToolStripMenuItem"; - copyMarkedLinesIntoNewTabToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T; - copyMarkedLinesIntoNewTabToolStripMenuItem.Size = new System.Drawing.Size(189, 30); - copyMarkedLinesIntoNewTabToolStripMenuItem.Text = "Copy to Tab"; - copyMarkedLinesIntoNewTabToolStripMenuItem.ToolTipText = "Copies all selected lines into a new tab page"; - copyMarkedLinesIntoNewTabToolStripMenuItem.Click += OnCopyMarkedLinesIntoNewTabToolStripMenuItemClick; - // - // optionToolStripMenuItem - // - optionToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { columnizerToolStripMenuItem, hilightingToolStripMenuItem1, menuToolStripSeparatorExtension7, settingsToolStripMenuItem, menuToolStripSeparatorExtension9, cellSelectModeToolStripMenuItem, alwaysOnTopToolStripMenuItem, hideLineColumnToolStripMenuItem, menuToolStripSeparatorExtension8, lockInstanceToolStripMenuItem }); - optionToolStripMenuItem.Name = "optionToolStripMenuItem"; - optionToolStripMenuItem.Size = new System.Drawing.Size(61, 19); - optionToolStripMenuItem.Text = "Options"; - optionToolStripMenuItem.DropDownOpening += OnOptionToolStripMenuItemDropDownOpening; - // - // columnizerToolStripMenuItem - // - columnizerToolStripMenuItem.Name = "columnizerToolStripMenuItem"; - columnizerToolStripMenuItem.Size = new System.Drawing.Size(224, 30); - columnizerToolStripMenuItem.Text = "Columnizer..."; - columnizerToolStripMenuItem.ToolTipText = "Splits various kinds of logfiles into fixed columns"; - columnizerToolStripMenuItem.Click += OnSelectFilterToolStripMenuItemClick; - // - // hilightingToolStripMenuItem1 - // - hilightingToolStripMenuItem1.Name = "hilightingToolStripMenuItem1"; - hilightingToolStripMenuItem1.Size = new System.Drawing.Size(224, 30); - hilightingToolStripMenuItem1.Text = "Highlighting and triggers..."; - hilightingToolStripMenuItem1.Click += OnHighlightingToolStripMenuItemClick; - // - // menuToolStripSeparatorExtension7 - // - menuToolStripSeparatorExtension7.Name = "menuToolStripSeparatorExtension7"; - menuToolStripSeparatorExtension7.Size = new System.Drawing.Size(221, 6); - // - // settingsToolStripMenuItem - // - settingsToolStripMenuItem.Image = LogExpert.Resources.Resources.Settings; - settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; - settingsToolStripMenuItem.Size = new System.Drawing.Size(224, 30); - settingsToolStripMenuItem.Text = "Settings..."; - settingsToolStripMenuItem.Click += OnSettingsToolStripMenuItemClick; - // - // menuToolStripSeparatorExtension9 - // - menuToolStripSeparatorExtension9.Name = "menuToolStripSeparatorExtension9"; - menuToolStripSeparatorExtension9.Size = new System.Drawing.Size(221, 6); - // - // cellSelectModeToolStripMenuItem - // - cellSelectModeToolStripMenuItem.CheckOnClick = true; - cellSelectModeToolStripMenuItem.Name = "cellSelectModeToolStripMenuItem"; - cellSelectModeToolStripMenuItem.Size = new System.Drawing.Size(224, 30); - cellSelectModeToolStripMenuItem.Text = "Cell select mode"; - cellSelectModeToolStripMenuItem.ToolTipText = "Switches between foll row selection and single cell selection mode"; - cellSelectModeToolStripMenuItem.Click += OnCellSelectModeToolStripMenuItemClick; - // - // alwaysOnTopToolStripMenuItem - // - alwaysOnTopToolStripMenuItem.CheckOnClick = true; - alwaysOnTopToolStripMenuItem.Name = "alwaysOnTopToolStripMenuItem"; - alwaysOnTopToolStripMenuItem.Size = new System.Drawing.Size(224, 30); - alwaysOnTopToolStripMenuItem.Text = "Always on top"; - alwaysOnTopToolStripMenuItem.Click += OnAlwaysOnTopToolStripMenuItemClick; - // - // hideLineColumnToolStripMenuItem - // - hideLineColumnToolStripMenuItem.CheckOnClick = true; - hideLineColumnToolStripMenuItem.Name = "hideLineColumnToolStripMenuItem"; - hideLineColumnToolStripMenuItem.Size = new System.Drawing.Size(224, 30); - hideLineColumnToolStripMenuItem.Text = "Hide line column"; - hideLineColumnToolStripMenuItem.Click += OnHideLineColumnToolStripMenuItemClick; - // - // menuToolStripSeparatorExtension8 - // - menuToolStripSeparatorExtension8.Name = "menuToolStripSeparatorExtension8"; - menuToolStripSeparatorExtension8.Size = new System.Drawing.Size(221, 6); - // - // lockInstanceToolStripMenuItem - // - lockInstanceToolStripMenuItem.Name = "lockInstanceToolStripMenuItem"; - lockInstanceToolStripMenuItem.Size = new System.Drawing.Size(224, 30); - lockInstanceToolStripMenuItem.Text = "Lock instance"; - lockInstanceToolStripMenuItem.ToolTipText = "When enabled all new launched LogExpert instances will redirect to this window"; - lockInstanceToolStripMenuItem.Click += OnLockInstanceToolStripMenuItemClick; - // - // toolsToolStripMenuItem - // - toolsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { configureToolStripMenuItem, configureToolStripSeparator }); - toolsToolStripMenuItem.Name = "toolsToolStripMenuItem"; - toolsToolStripMenuItem.Size = new System.Drawing.Size(47, 19); - toolsToolStripMenuItem.Text = "Tools"; - toolsToolStripMenuItem.ToolTipText = "Launch external tools (configure in the settings)"; - toolsToolStripMenuItem.DropDownItemClicked += OnToolsToolStripMenuItemDropDownItemClicked; - // - // configureToolStripMenuItem - // - configureToolStripMenuItem.Name = "configureToolStripMenuItem"; - configureToolStripMenuItem.Size = new System.Drawing.Size(136, 22); - configureToolStripMenuItem.Text = "Configure..."; - configureToolStripMenuItem.Click += OnConfigureToolStripMenuItemClick; - // - // configureToolStripSeparator - // - configureToolStripSeparator.Name = "configureToolStripSeparator"; - configureToolStripSeparator.Size = new System.Drawing.Size(133, 6); - // - // helpToolStripMenuItem - // - helpToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { showHelpToolStripMenuItem, menuToolStripSeparatorExtension11, aboutToolStripMenuItem }); - helpToolStripMenuItem.Name = "helpToolStripMenuItem"; - helpToolStripMenuItem.Size = new System.Drawing.Size(44, 19); - helpToolStripMenuItem.Text = "Help"; - // - // showHelpToolStripMenuItem - // - showHelpToolStripMenuItem.Name = "showHelpToolStripMenuItem"; - showHelpToolStripMenuItem.ShortcutKeys = Keys.F1; - showHelpToolStripMenuItem.Size = new System.Drawing.Size(148, 22); - showHelpToolStripMenuItem.Text = "Show help"; - showHelpToolStripMenuItem.Click += OnShowHelpToolStripMenuItemClick; - // - // menuToolStripSeparatorExtension11 - // - menuToolStripSeparatorExtension11.Name = "menuToolStripSeparatorExtension11"; - menuToolStripSeparatorExtension11.Size = new System.Drawing.Size(145, 6); - // - // aboutToolStripMenuItem - // - aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; - aboutToolStripMenuItem.Size = new System.Drawing.Size(148, 22); - aboutToolStripMenuItem.Text = "About"; - aboutToolStripMenuItem.Click += OnAboutToolStripMenuItemClick; - // - // debugToolStripMenuItem - // - debugToolStripMenuItem.Alignment = ToolStripItemAlignment.Right; - debugToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { dumpLogBufferInfoToolStripMenuItem, dumpBufferDiagnosticToolStripMenuItem, runGCToolStripMenuItem, gCInfoToolStripMenuItem, throwExceptionGUIThreadToolStripMenuItem, throwExceptionbackgroundThToolStripMenuItem, throwExceptionBackgroundThreadToolStripMenuItem, loglevelToolStripMenuItem, disableWordHighlightModeToolStripMenuItem }); - debugToolStripMenuItem.Name = "debugToolStripMenuItem"; - debugToolStripMenuItem.Size = new System.Drawing.Size(54, 19); - debugToolStripMenuItem.Text = "Debug"; - // - // dumpLogBufferInfoToolStripMenuItem - // - dumpLogBufferInfoToolStripMenuItem.Name = "dumpLogBufferInfoToolStripMenuItem"; - dumpLogBufferInfoToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - dumpLogBufferInfoToolStripMenuItem.Text = "Dump LogBuffer info"; - dumpLogBufferInfoToolStripMenuItem.Click += OnDumpLogBufferInfoToolStripMenuItemClick; - // - // dumpBufferDiagnosticToolStripMenuItem - // - dumpBufferDiagnosticToolStripMenuItem.Name = "dumpBufferDiagnosticToolStripMenuItem"; - dumpBufferDiagnosticToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - dumpBufferDiagnosticToolStripMenuItem.Text = "Dump buffer diagnostic"; - dumpBufferDiagnosticToolStripMenuItem.Click += OnDumpBufferDiagnosticToolStripMenuItemClick; - // - // runGCToolStripMenuItem - // - runGCToolStripMenuItem.Name = "runGCToolStripMenuItem"; - runGCToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - runGCToolStripMenuItem.Text = "Run GC"; - runGCToolStripMenuItem.Click += OnRunGCToolStripMenuItemClick; - // - // gCInfoToolStripMenuItem - // - gCInfoToolStripMenuItem.Name = "gCInfoToolStripMenuItem"; - gCInfoToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - gCInfoToolStripMenuItem.Text = "Dump GC info"; - gCInfoToolStripMenuItem.Click += OnGCInfoToolStripMenuItemClick; - // - // throwExceptionGUIThreadToolStripMenuItem - // - throwExceptionGUIThreadToolStripMenuItem.Name = "throwExceptionGUIThreadToolStripMenuItem"; - throwExceptionGUIThreadToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - throwExceptionGUIThreadToolStripMenuItem.Text = "Throw exception (GUI Thread)"; - throwExceptionGUIThreadToolStripMenuItem.Click += OnThrowExceptionGUIThreadToolStripMenuItemClick; - // - // throwExceptionbackgroundThToolStripMenuItem - // - throwExceptionbackgroundThToolStripMenuItem.Name = "throwExceptionbackgroundThToolStripMenuItem"; - throwExceptionbackgroundThToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - throwExceptionbackgroundThToolStripMenuItem.Text = "Throw exception (Async delegate)"; - throwExceptionbackgroundThToolStripMenuItem.Click += OnThrowExceptionBackgroundThToolStripMenuItemClick; - // - // throwExceptionBackgroundThreadToolStripMenuItem - // - throwExceptionBackgroundThreadToolStripMenuItem.Name = "throwExceptionBackgroundThreadToolStripMenuItem"; - throwExceptionBackgroundThreadToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - throwExceptionBackgroundThreadToolStripMenuItem.Text = "Throw exception (background thread)"; - throwExceptionBackgroundThreadToolStripMenuItem.Click += OnThrowExceptionBackgroundThreadToolStripMenuItemClick; - // - // loglevelToolStripMenuItem - // - loglevelToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { warnToolStripMenuItem, infoToolStripMenuItem, debugToolStripMenuItem1 }); - loglevelToolStripMenuItem.Name = "loglevelToolStripMenuItem"; - loglevelToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - loglevelToolStripMenuItem.Text = "Loglevel"; - loglevelToolStripMenuItem.DropDownOpening += OnLogLevelToolStripMenuItemDropDownOpening; - loglevelToolStripMenuItem.Click += OnLogLevelToolStripMenuItemClick; - // - // warnToolStripMenuItem - // - warnToolStripMenuItem.Name = "warnToolStripMenuItem"; - warnToolStripMenuItem.Size = new System.Drawing.Size(109, 22); - warnToolStripMenuItem.Text = "Warn"; - warnToolStripMenuItem.Click += OnWarnToolStripMenuItemClick; - // - // infoToolStripMenuItem - // - infoToolStripMenuItem.Name = "infoToolStripMenuItem"; - infoToolStripMenuItem.Size = new System.Drawing.Size(109, 22); - infoToolStripMenuItem.Text = "Info"; - infoToolStripMenuItem.Click += OnInfoToolStripMenuItemClick; - // - // debugToolStripMenuItem1 - // - debugToolStripMenuItem1.Name = "debugToolStripMenuItem1"; - debugToolStripMenuItem1.Size = new System.Drawing.Size(109, 22); - debugToolStripMenuItem1.Text = "Debug"; - debugToolStripMenuItem1.Click += OnDebugToolStripMenuItemClick; - // - // disableWordHighlightModeToolStripMenuItem - // - disableWordHighlightModeToolStripMenuItem.CheckOnClick = true; - disableWordHighlightModeToolStripMenuItem.Name = "disableWordHighlightModeToolStripMenuItem"; - disableWordHighlightModeToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - disableWordHighlightModeToolStripMenuItem.Text = "Disable word highlight mode"; - disableWordHighlightModeToolStripMenuItem.Click += OnDisableWordHighlightModeToolStripMenuItemClick; - // - // host - // - host.AccessibleName = "host"; - host.AutoSize = true; - host.BackColor = System.Drawing.Color.Transparent; - host.Location = new System.Drawing.Point(9, 1); - host.Name = "host"; - host.Size = new System.Drawing.Size(80, 22); - host.TabIndex = 7; - host.Text = "Follow tail"; - host.UseVisualStyleBackColor = false; - // - // toolStripContainer - // - // - // toolStripContainer.BottomToolStripPanel - // - toolStripContainer.BottomToolStripPanel.RenderMode = ToolStripRenderMode.System; - toolStripContainer.BottomToolStripPanelVisible = false; - // - // toolStripContainer.ContentPanel - // - toolStripContainer.ContentPanel.Controls.Add(dockPanel); - toolStripContainer.ContentPanel.Margin = new Padding(0); - toolStripContainer.ContentPanel.Size = new System.Drawing.Size(1603, 881); - toolStripContainer.Dock = DockStyle.Fill; - // - // toolStripContainer.LeftToolStripPanel - // - toolStripContainer.LeftToolStripPanel.Enabled = false; - toolStripContainer.LeftToolStripPanelVisible = false; - toolStripContainer.Location = new System.Drawing.Point(0, 0); - toolStripContainer.Margin = new Padding(0); - toolStripContainer.Name = "toolStripContainer"; - // - // toolStripContainer.RightToolStripPanel - // - toolStripContainer.RightToolStripPanel.Enabled = false; - toolStripContainer.RightToolStripPanelVisible = false; - toolStripContainer.Size = new System.Drawing.Size(1603, 954); - toolStripContainer.TabIndex = 13; - toolStripContainer.Text = "toolStripContainer1"; - // - // toolStripContainer.TopToolStripPanel - // - toolStripContainer.TopToolStripPanel.Controls.Add(externalToolsToolStrip); - toolStripContainer.TopToolStripPanel.Controls.Add(mainMenuStrip); - toolStripContainer.TopToolStripPanel.Controls.Add(buttonToolStrip); - // - // dockPanel - // - dockPanel.ActiveAutoHideContent = null; - dockPanel.DefaultFloatWindowSize = new System.Drawing.Size(600, 400); - dockPanel.Dock = DockStyle.Fill; - dockPanel.DockBackColor = System.Drawing.SystemColors.Control; - dockPanel.DocumentStyle = DocumentStyle.DockingWindow; - dockPanel.ForeColor = System.Drawing.SystemColors.Control; - dockPanel.Location = new System.Drawing.Point(0, 0); - dockPanel.Margin = new Padding(0); - dockPanel.Name = "dockPanel"; - dockPanel.ShowDocumentIcon = true; - dockPanel.Size = new System.Drawing.Size(1603, 881); - dockPanelGradient1.EndColor = System.Drawing.SystemColors.Control; - dockPanelGradient1.StartColor = System.Drawing.SystemColors.Control; - autoHideStripSkin1.DockStripGradient = dockPanelGradient1; - tabGradient1.EndColor = System.Drawing.SystemColors.Control; - tabGradient1.StartColor = System.Drawing.SystemColors.Control; - tabGradient1.TextColor = System.Drawing.SystemColors.ControlText; - autoHideStripSkin1.TabGradient = tabGradient1; - autoHideStripSkin1.TextFont = new System.Drawing.Font("Segoe UI", 9F); - tabGradient2.EndColor = System.Drawing.SystemColors.Control; - tabGradient2.StartColor = System.Drawing.SystemColors.Control; - tabGradient2.TextColor = System.Drawing.SystemColors.ControlText; - dockPaneStripGradient1.ActiveTabGradient = tabGradient2; - dockPanelGradient2.EndColor = System.Drawing.SystemColors.Control; - dockPanelGradient2.StartColor = System.Drawing.SystemColors.Control; - dockPaneStripGradient1.DockStripGradient = dockPanelGradient2; - tabGradient3.EndColor = System.Drawing.SystemColors.ControlLight; - tabGradient3.StartColor = System.Drawing.SystemColors.ControlLight; - tabGradient3.TextColor = System.Drawing.SystemColors.ControlText; - dockPaneStripGradient1.InactiveTabGradient = tabGradient3; - dockPaneStripSkin1.DocumentGradient = dockPaneStripGradient1; - dockPaneStripSkin1.TextFont = new System.Drawing.Font("Segoe UI", 9F); - tabGradient4.EndColor = System.Drawing.SystemColors.ActiveCaption; - tabGradient4.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical; - tabGradient4.StartColor = System.Drawing.SystemColors.GradientActiveCaption; - tabGradient4.TextColor = System.Drawing.SystemColors.ActiveCaptionText; - dockPaneStripToolWindowGradient1.ActiveCaptionGradient = tabGradient4; - tabGradient5.EndColor = System.Drawing.SystemColors.Control; - tabGradient5.StartColor = System.Drawing.SystemColors.Control; - tabGradient5.TextColor = System.Drawing.SystemColors.ControlText; - dockPaneStripToolWindowGradient1.ActiveTabGradient = tabGradient5; - dockPanelGradient3.EndColor = System.Drawing.SystemColors.ControlLight; - dockPanelGradient3.StartColor = System.Drawing.SystemColors.ControlLight; - dockPaneStripToolWindowGradient1.DockStripGradient = dockPanelGradient3; - tabGradient6.EndColor = System.Drawing.SystemColors.InactiveCaption; - tabGradient6.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical; - tabGradient6.StartColor = System.Drawing.SystemColors.GradientInactiveCaption; - tabGradient6.TextColor = System.Drawing.SystemColors.InactiveCaptionText; - dockPaneStripToolWindowGradient1.InactiveCaptionGradient = tabGradient6; - tabGradient7.EndColor = System.Drawing.Color.Transparent; - tabGradient7.StartColor = System.Drawing.Color.Transparent; - tabGradient7.TextColor = System.Drawing.SystemColors.Control; - dockPaneStripToolWindowGradient1.InactiveTabGradient = tabGradient7; - dockPaneStripSkin1.ToolWindowGradient = dockPaneStripToolWindowGradient1; - dockPanel.Theme = new VS2015LightTheme(); - dockPanel.Theme.Skin.DockPaneStripSkin = dockPaneStripSkin1; - dockPanel.Theme.Skin.AutoHideStripSkin = autoHideStripSkin1; - dockPanel.TabIndex = 14; - dockPanel.ActiveContentChanged += OnDockPanelActiveContentChanged; - // - // externalToolsToolStrip - // - externalToolsToolStrip.AllowMerge = false; - externalToolsToolStrip.Dock = DockStyle.None; - externalToolsToolStrip.ImageScalingSize = new System.Drawing.Size(24, 24); - externalToolsToolStrip.LayoutStyle = ToolStripLayoutStyle.Flow; - externalToolsToolStrip.Location = new System.Drawing.Point(8, 0); - externalToolsToolStrip.Name = "externalToolsToolStrip"; - externalToolsToolStrip.Size = new System.Drawing.Size(32, 19); - externalToolsToolStrip.TabIndex = 8; - externalToolsToolStrip.ItemClicked += OnExternalToolsToolStripItemClicked; - // - // buttonToolStrip - // - buttonToolStrip.AllowMerge = false; - buttonToolStrip.Dock = DockStyle.None; - buttonToolStrip.ImageScalingSize = new System.Drawing.Size(24, 24); - buttonToolStrip.Items.AddRange(new ToolStripItem[] { toolStripButtonOpen, lineToolStripSeparatorExtension1, toolStripButtonSearch, toolStripButtonFilter, lineToolStripSeparatorExtension2, toolStripButtonBookmark, toolStripButtonUp, toolStripButtonDown, lineToolStripSeparatorExtension3, toolStripButtonBubbles, lineToolStripSeparatorExtension4, toolStripButtonTail, lineToolStripSeparatorExtension5, groupsComboBoxHighlightGroups }); - buttonToolStrip.LayoutStyle = ToolStripLayoutStyle.Flow; - buttonToolStrip.Location = new System.Drawing.Point(3, 42); - buttonToolStrip.Name = "buttonToolStrip"; - buttonToolStrip.Size = new System.Drawing.Size(406, 31); - buttonToolStrip.TabIndex = 7; - // - // toolStripButtonOpen - // - toolStripButtonOpen.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonOpen.Image = LogExpert.Resources.Resources.File_open; - toolStripButtonOpen.ImageTransparentColor = System.Drawing.Color.Magenta; - toolStripButtonOpen.Name = "toolStripButtonOpen"; - toolStripButtonOpen.Size = new System.Drawing.Size(28, 28); - toolStripButtonOpen.Text = "Open File"; - toolStripButtonOpen.ToolTipText = "Open file"; - toolStripButtonOpen.Click += OnToolStripButtonOpenClick; - // - // lineToolStripSeparatorExtension1 - // - lineToolStripSeparatorExtension1.Name = "lineToolStripSeparatorExtension1"; - lineToolStripSeparatorExtension1.Size = new System.Drawing.Size(6, 23); - // - // toolStripButtonSearch - // - toolStripButtonSearch.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonSearch.Image = LogExpert.Resources.Resources.Search; - toolStripButtonSearch.ImageTransparentColor = System.Drawing.Color.Magenta; - toolStripButtonSearch.Name = "toolStripButtonSearch"; - toolStripButtonSearch.Size = new System.Drawing.Size(28, 28); - toolStripButtonSearch.Text = "Search"; - toolStripButtonSearch.ToolTipText = "Search"; - toolStripButtonSearch.Click += OnToolStripButtonSearchClick; - // - // toolStripButtonFilter - // - toolStripButtonFilter.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonFilter.Image = LogExpert.Resources.Resources.Filter; - toolStripButtonFilter.ImageTransparentColor = System.Drawing.Color.Magenta; - toolStripButtonFilter.Name = "toolStripButtonFilter"; - toolStripButtonFilter.Size = new System.Drawing.Size(28, 28); - toolStripButtonFilter.Text = "Filter"; - toolStripButtonFilter.ToolTipText = "Filter window"; - toolStripButtonFilter.Click += OnToolStripButtonFilterClick; - // - // lineToolStripSeparatorExtension2 - // - lineToolStripSeparatorExtension2.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - lineToolStripSeparatorExtension2.Name = "lineToolStripSeparatorExtension2"; - lineToolStripSeparatorExtension2.Size = new System.Drawing.Size(6, 23); - // - // toolStripButtonBookmark - // - toolStripButtonBookmark.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonBookmark.Image = LogExpert.Resources.Resources.Bookmark_add; - toolStripButtonBookmark.ImageTransparentColor = System.Drawing.Color.Magenta; - toolStripButtonBookmark.Name = "toolStripButtonBookmark"; - toolStripButtonBookmark.Size = new System.Drawing.Size(28, 28); - toolStripButtonBookmark.Text = "Toggle Bookmark"; - toolStripButtonBookmark.ToolTipText = "Toggle bookmark"; - toolStripButtonBookmark.Click += OnToolStripButtonBookmarkClick; - // - // toolStripButtonUp - // - toolStripButtonUp.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonUp.Image = LogExpert.Resources.Resources.ArrowUp; - toolStripButtonUp.ImageTransparentColor = System.Drawing.Color.Magenta; - toolStripButtonUp.Name = "toolStripButtonUp"; - toolStripButtonUp.Size = new System.Drawing.Size(28, 28); - toolStripButtonUp.Text = "Previous Bookmark"; - toolStripButtonUp.ToolTipText = "Go to previous bookmark"; - toolStripButtonUp.Click += OnToolStripButtonUpClick; - // - // toolStripButtonDown - // - toolStripButtonDown.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonDown.Image = LogExpert.Resources.Resources.ArrowDown; - toolStripButtonDown.ImageTransparentColor = System.Drawing.Color.Magenta; - toolStripButtonDown.Name = "toolStripButtonDown"; - toolStripButtonDown.Size = new System.Drawing.Size(28, 28); - toolStripButtonDown.Text = "Next Bookmark"; - toolStripButtonDown.ToolTipText = "Go to next bookmark"; - toolStripButtonDown.Click += OnToolStripButtonDownClick; - // - // lineToolStripSeparatorExtension3 - // - lineToolStripSeparatorExtension3.Name = "lineToolStripSeparatorExtension3"; - lineToolStripSeparatorExtension3.Size = new System.Drawing.Size(6, 23); - // - // toolStripButtonBubbles - // - toolStripButtonBubbles.CheckOnClick = true; - toolStripButtonBubbles.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonBubbles.Image = LogExpert.Resources.Resources.bookmark_bubbles; - toolStripButtonBubbles.ImageAlign = System.Drawing.ContentAlignment.BottomCenter; - toolStripButtonBubbles.ImageTransparentColor = System.Drawing.Color.Magenta; - toolStripButtonBubbles.Name = "toolStripButtonBubbles"; - toolStripButtonBubbles.Size = new System.Drawing.Size(28, 28); - toolStripButtonBubbles.Text = "Show bookmark bubbles"; - toolStripButtonBubbles.Click += OnToolStripButtonBubblesClick; - // - // lineToolStripSeparatorExtension4 - // - lineToolStripSeparatorExtension4.Name = "lineToolStripSeparatorExtension4"; - lineToolStripSeparatorExtension4.Size = new System.Drawing.Size(6, 23); - // - // toolStripButtonTail - // - toolStripButtonTail.DisplayStyle = ToolStripItemDisplayStyle.Text; - toolStripButtonTail.Image = (System.Drawing.Image)resources.GetObject("toolStripButtonTail.Image"); - toolStripButtonTail.ImageTransparentColor = System.Drawing.Color.Magenta; - toolStripButtonTail.Name = "toolStripButtonTail"; - toolStripButtonTail.Size = new System.Drawing.Size(27, 19); - toolStripButtonTail.Text = "tail"; - // - // lineToolStripSeparatorExtension5 - // - lineToolStripSeparatorExtension5.Name = "lineToolStripSeparatorExtension5"; - lineToolStripSeparatorExtension5.Size = new System.Drawing.Size(6, 23); - // - // groupsComboBoxHighlightGroups - // - groupsComboBoxHighlightGroups.DropDownStyle = ComboBoxStyle.DropDownList; - groupsComboBoxHighlightGroups.DropDownWidth = 250; - groupsComboBoxHighlightGroups.FlatStyle = FlatStyle.Standard; - groupsComboBoxHighlightGroups.Name = "groupsComboBoxHighlightGroups"; - groupsComboBoxHighlightGroups.Size = new System.Drawing.Size(150, 23); - groupsComboBoxHighlightGroups.ToolTipText = "Select the current highlight settings for the log file (right-click to open highlight settings)"; - groupsComboBoxHighlightGroups.DropDownClosed += OnHighlightGroupsComboBoxDropDownClosed; - groupsComboBoxHighlightGroups.SelectedIndexChanged += OnHighlightGroupsComboBoxSelectedIndexChanged; - groupsComboBoxHighlightGroups.MouseUp += OnHighlightGroupsComboBoxMouseUp; - // - // checkBoxFollowTail - // - checkBoxFollowTail.AutoSize = true; - checkBoxFollowTail.Location = new System.Drawing.Point(663, 985); - checkBoxFollowTail.Margin = new Padding(4, 7, 4, 7); - checkBoxFollowTail.Name = "checkBoxFollowTail"; - checkBoxFollowTail.Size = new System.Drawing.Size(80, 19); - checkBoxFollowTail.TabIndex = 14; - checkBoxFollowTail.Text = "Follow tail"; - checkBoxFollowTail.UseVisualStyleBackColor = true; - checkBoxFollowTail.Click += OnFollowTailCheckBoxClick; - // - // tabContextMenuStrip - // - tabContextMenuStrip.ForeColor = System.Drawing.SystemColors.ControlText; - tabContextMenuStrip.ImageScalingSize = new System.Drawing.Size(24, 24); - tabContextMenuStrip.Items.AddRange(new ToolStripItem[] { closeThisTabToolStripMenuItem, closeOtherTabsToolStripMenuItem, closeAllTabsToolStripMenuItem, tabColorToolStripMenuItem, tabRenameToolStripMenuItem, copyPathToClipboardToolStripMenuItem, findInExplorerToolStripMenuItem }); - tabContextMenuStrip.Name = "tabContextMenuStrip"; - tabContextMenuStrip.Size = new System.Drawing.Size(197, 158); - // - // closeThisTabToolStripMenuItem - // - closeThisTabToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; - closeThisTabToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlText; - closeThisTabToolStripMenuItem.Name = "closeThisTabToolStripMenuItem"; - closeThisTabToolStripMenuItem.Size = new System.Drawing.Size(196, 22); - closeThisTabToolStripMenuItem.Text = "Close this tab"; - closeThisTabToolStripMenuItem.Click += OnCloseThisTabToolStripMenuItemClick; - // - // closeOtherTabsToolStripMenuItem - // - closeOtherTabsToolStripMenuItem.Name = "closeOtherTabsToolStripMenuItem"; - closeOtherTabsToolStripMenuItem.Size = new System.Drawing.Size(196, 22); - closeOtherTabsToolStripMenuItem.Text = "Close other tabs"; - closeOtherTabsToolStripMenuItem.ToolTipText = "Close all tabs except of this one"; - closeOtherTabsToolStripMenuItem.Click += OnCloseOtherTabsToolStripMenuItemClick; - // - // closeAllTabsToolStripMenuItem - // - closeAllTabsToolStripMenuItem.Name = "closeAllTabsToolStripMenuItem"; - closeAllTabsToolStripMenuItem.Size = new System.Drawing.Size(196, 22); - closeAllTabsToolStripMenuItem.Text = "Close all tabs"; - closeAllTabsToolStripMenuItem.ToolTipText = "Close all tabs"; - closeAllTabsToolStripMenuItem.Click += OnCloseAllTabsToolStripMenuItemClick; - // - // tabColorToolStripMenuItem - // - tabColorToolStripMenuItem.Name = "tabColorToolStripMenuItem"; - tabColorToolStripMenuItem.Size = new System.Drawing.Size(196, 22); - tabColorToolStripMenuItem.Text = "Tab color..."; - tabColorToolStripMenuItem.ToolTipText = "Sets the tab color"; - tabColorToolStripMenuItem.Click += OnTabColorToolStripMenuItemClick; - // - // tabRenameToolStripMenuItem - // - tabRenameToolStripMenuItem.Name = "tabRenameToolStripMenuItem"; - tabRenameToolStripMenuItem.Size = new System.Drawing.Size(196, 22); - tabRenameToolStripMenuItem.Text = "Tab rename..."; - tabRenameToolStripMenuItem.ToolTipText = "Set the text which is shown on the tab"; - tabRenameToolStripMenuItem.Click += OnTabRenameToolStripMenuItemClick; - // - // copyPathToClipboardToolStripMenuItem - // - copyPathToClipboardToolStripMenuItem.Name = "copyPathToClipboardToolStripMenuItem"; - copyPathToClipboardToolStripMenuItem.Size = new System.Drawing.Size(196, 22); - copyPathToClipboardToolStripMenuItem.Text = "Copy path to clipboard"; - copyPathToClipboardToolStripMenuItem.ToolTipText = "The complete file name (incl. path) is copied to clipboard"; - copyPathToClipboardToolStripMenuItem.Click += OnCopyPathToClipboardToolStripMenuItemClick; - // - // findInExplorerToolStripMenuItem - // - findInExplorerToolStripMenuItem.Name = "findInExplorerToolStripMenuItem"; - findInExplorerToolStripMenuItem.Size = new System.Drawing.Size(196, 22); - findInExplorerToolStripMenuItem.Text = "Find in Explorer"; - findInExplorerToolStripMenuItem.ToolTipText = "Opens an Explorer window and selects the log file"; - findInExplorerToolStripMenuItem.Click += OnFindInExplorerToolStripMenuItemClick; - // - // dragControlDateTime - // - dragControlDateTime.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - dragControlDateTime.BackColor = System.Drawing.SystemColors.Control; - dragControlDateTime.DateTime = new System.DateTime(0L); - dragControlDateTime.DragOrientation = DragOrientationsEnum.Vertical; - dragControlDateTime.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0); - dragControlDateTime.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - dragControlDateTime.HoverColor = System.Drawing.Color.LightGray; - dragControlDateTime.Location = new System.Drawing.Point(1017, 977); - dragControlDateTime.Margin = new Padding(0); - dragControlDateTime.MaxDateTime = new System.DateTime(9999, 12, 31, 23, 59, 59, 999); - dragControlDateTime.MinDateTime = new System.DateTime(0L); - dragControlDateTime.Name = "dragControlDateTime"; - dragControlDateTime.Size = new System.Drawing.Size(313, 38); - dragControlDateTime.TabIndex = 14; - dragControlDateTime.ValueChanged += OnDateTimeDragControlValueChanged; - dragControlDateTime.ValueDragged += OnDateTimeDragControlValueDragged; - // - // LogTabWindow - // - AllowDrop = true; - ClientSize = new System.Drawing.Size(1603, 1017); - Controls.Add(checkBoxFollowTail); - Controls.Add(dragControlDateTime); - Controls.Add(toolStripContainer); - Controls.Add(statusStrip); - DoubleBuffered = true; - Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon"); - KeyPreview = true; - MainMenuStrip = mainMenuStrip; - Margin = new Padding(4, 7, 4, 7); - Name = "LogTabWindow"; - Text = "LogExpert"; - Activated += OnLogTabWindowActivated; - Deactivate += OnLogTabWindowDeactivate; - SizeChanged += OnLogTabWindowSizeChanged; - DragDrop += OnLogWindowDragDrop; - DragEnter += OnLogTabWindowDragEnter; - DragOver += OnLogWindowDragOver; - KeyDown += OnLogTabWindowKeyDown; - statusStrip.ResumeLayout(false); - statusStrip.PerformLayout(); - mainMenuStrip.ResumeLayout(false); - mainMenuStrip.PerformLayout(); - toolStripContainer.ContentPanel.ResumeLayout(false); - toolStripContainer.TopToolStripPanel.ResumeLayout(false); - toolStripContainer.TopToolStripPanel.PerformLayout(); - toolStripContainer.ResumeLayout(false); - toolStripContainer.PerformLayout(); - buttonToolStrip.ResumeLayout(false); - buttonToolStrip.PerformLayout(); - tabContextMenuStrip.ResumeLayout(false); - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private System.Windows.Forms.StatusStrip statusStrip; - private System.Windows.Forms.ToolStripStatusLabel labelLines; - private System.Windows.Forms.ToolStripStatusLabel labelSize; - private System.Windows.Forms.MenuStrip mainMenuStrip; - private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem viewNavigateToolStripMenuItem; - private System.Windows.Forms.ToolStripStatusLabel labelCurrentLine; - private System.Windows.Forms.ToolStripProgressBar loadProgessBar; - private System.Windows.Forms.ToolStripStatusLabel labelStatus; - private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; - private System.Windows.Forms.ToolStripContainer toolStripContainer; - private System.Windows.Forms.ToolStripMenuItem closeFileToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem multiFileToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem goToLineToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem searchToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem timeshiftToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem filterToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem copyMarkedLinesIntoNewTabToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem optionToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem hilightingToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem cellSelectModeToolStripMenuItem; - private System.Windows.Forms.ToolStripTextBox timeshiftMenuTextBox; - private System.Windows.Forms.ToolStripMenuItem alwaysOnTopToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem bookmarksToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toggleBookmarkToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem jumpToNextToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem jumpToPrevToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripEncodingMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripEncodingASCIIItem; - private System.Windows.Forms.ToolStripMenuItem toolStripEncodingANSIItem; - private System.Windows.Forms.ToolStripMenuItem toolStripEncodingUTF8Item; - private System.Windows.Forms.ToolStripMenuItem toolStripEncodingUTF16Item; - private System.Windows.Forms.ToolStripMenuItem reloadToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem columnizerToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem; - private DateTimeDragControl dragControlDateTime; - private System.Windows.Forms.ToolStripMenuItem showBookmarkListToolStripMenuItem; - private System.Windows.Forms.ToolStrip buttonToolStrip; - private System.Windows.Forms.ToolStripButton toolStripButtonOpen; - private System.Windows.Forms.ToolStripButton toolStripButtonSearch; - private System.Windows.Forms.ToolStripButton toolStripButtonFilter; - private System.Windows.Forms.ToolStripButton toolStripButtonBookmark; - private System.Windows.Forms.ToolStripButton toolStripButtonUp; - private System.Windows.Forms.ToolStripButton toolStripButtonDown; - private CheckBox host; - private CheckBox checkBoxFollowTail; - private ToolStripButton toolStripButtonTail; - private ToolStripMenuItem showHelpToolStripMenuItem; - private ToolStripMenuItem hideLineColumnToolStripMenuItem; - private ToolStripMenuItem lastUsedToolStripMenuItem; - private ContextMenuStrip tabContextMenuStrip; - private ToolStripMenuItem closeThisTabToolStripMenuItem; - private ToolStripMenuItem closeOtherTabsToolStripMenuItem; - private ToolStripMenuItem closeAllTabsToolStripMenuItem; - private ToolStripMenuItem tabColorToolStripMenuItem; - private ToolStripMenuItem loadProjectToolStripMenuItem; - private ToolStripMenuItem saveProjectToolStripMenuItem; - private ToolStripButton toolStripButtonBubbles; - private ToolStripMenuItem copyPathToClipboardToolStripMenuItem; - private ToolStripMenuItem findInExplorerToolStripMenuItem; - private ToolStripMenuItem exportBookmarksToolStripMenuItem; - private ToolStripComboBox groupsComboBoxHighlightGroups; - private ToolStripMenuItem debugToolStripMenuItem; - private ToolStripMenuItem dumpLogBufferInfoToolStripMenuItem; - private ToolStripMenuItem dumpBufferDiagnosticToolStripMenuItem; - private ToolStripMenuItem runGCToolStripMenuItem; - private ToolStripMenuItem gCInfoToolStripMenuItem; - private ToolStrip externalToolsToolStrip; - private ToolStripMenuItem toolsToolStripMenuItem; - private ToolStripMenuItem configureToolStripMenuItem; - private ToolStripMenuItem throwExceptionGUIThreadToolStripMenuItem; - private ToolStripMenuItem throwExceptionbackgroundThToolStripMenuItem; - private ToolStripMenuItem throwExceptionBackgroundThreadToolStripMenuItem; - private ToolStripMenuItem loglevelToolStripMenuItem; - private ToolStripMenuItem warnToolStripMenuItem; - private ToolStripMenuItem infoToolStripMenuItem; - private ToolStripMenuItem debugToolStripMenuItem1; - private ToolStripMenuItem disableWordHighlightModeToolStripMenuItem; - private ToolStripMenuItem multifileMaskToolStripMenuItem; - private ToolStripMenuItem multiFileEnabledStripMenuItem; - private ToolStripMenuItem toolStripEncodingISO88591Item; - private ToolStripMenuItem lockInstanceToolStripMenuItem; - private ToolStripMenuItem newFromClipboardToolStripMenuItem; - private ToolStripMenuItem openURIToolStripMenuItem; - private ToolStripMenuItem columnFinderToolStripMenuItem; - private DockPanel dockPanel; - private ToolStripMenuItem tabRenameToolStripMenuItem; - private LineToolStripSeparatorExtension lineToolStripSeparatorExtension1; - private LineToolStripSeparatorExtension lineToolStripSeparatorExtension2; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension1; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension2; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension3; - private LineToolStripSeparatorExtension lineToolStripSeparatorExtension3; - private LineToolStripSeparatorExtension lineToolStripSeparatorExtension4; - private LineToolStripSeparatorExtension lineToolStripSeparatorExtension5; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension5; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension6; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension4; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension7; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension9; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension8; - private MenuToolStripSeparatorExtension configureToolStripSeparator; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension11; - } -} - +using System.Windows.Forms; +using LogExpert.Core.Enums; +using LogExpert.Dialogs; +using LogExpert.UI.Extensions.Forms; +using WeifenLuo.WinFormsUI.Docking; + +namespace LogExpert.UI.Controls.LogTabWindow +{ + partial class LogTabWindow + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + AutoHideStripSkin autoHideStripSkin1 = new AutoHideStripSkin(); + DockPanelGradient dockPanelGradient1 = new DockPanelGradient(); + TabGradient tabGradient1 = new TabGradient(); + DockPaneStripSkin dockPaneStripSkin1 = new DockPaneStripSkin(); + DockPaneStripGradient dockPaneStripGradient1 = new DockPaneStripGradient(); + TabGradient tabGradient2 = new TabGradient(); + DockPanelGradient dockPanelGradient2 = new DockPanelGradient(); + TabGradient tabGradient3 = new TabGradient(); + DockPaneStripToolWindowGradient dockPaneStripToolWindowGradient1 = new DockPaneStripToolWindowGradient(); + TabGradient tabGradient4 = new TabGradient(); + TabGradient tabGradient5 = new TabGradient(); + DockPanelGradient dockPanelGradient3 = new DockPanelGradient(); + TabGradient tabGradient6 = new TabGradient(); + TabGradient tabGradient7 = new TabGradient(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LogTabWindow)); + statusStrip = new StatusStrip(); + labelLines = new ToolStripStatusLabel(); + labelSize = new ToolStripStatusLabel(); + labelCurrentLine = new ToolStripStatusLabel(); + loadProgessBar = new ToolStripProgressBar(); + labelStatus = new ToolStripStatusLabel(); + mainMenuStrip = new MenuStrip(); + fileToolStripMenuItem = new ToolStripMenuItem(); + openToolStripMenuItem = new ToolStripMenuItem(); + openURIToolStripMenuItem = new ToolStripMenuItem(); + closeFileToolStripMenuItem = new ToolStripMenuItem(); + reloadToolStripMenuItem = new ToolStripMenuItem(); + newFromClipboardToolStripMenuItem = new ToolStripMenuItem(); + menuToolStripSeparatorExtension1 = new MenuToolStripSeparatorExtension(); + multiFileToolStripMenuItem = new ToolStripMenuItem(); + multiFileEnabledStripMenuItem = new ToolStripMenuItem(); + multifileMaskToolStripMenuItem = new ToolStripMenuItem(); + menuToolStripSeparatorExtension2 = new MenuToolStripSeparatorExtension(); + loadProjectToolStripMenuItem = new ToolStripMenuItem(); + saveProjectToolStripMenuItem = new ToolStripMenuItem(); + exportBookmarksToolStripMenuItem = new ToolStripMenuItem(); + menuToolStripSeparatorExtension3 = new MenuToolStripSeparatorExtension(); + lastUsedToolStripMenuItem = new ToolStripMenuItem(); + exitToolStripMenuItem = new ToolStripMenuItem(); + viewNavigateToolStripMenuItem = new ToolStripMenuItem(); + goToLineToolStripMenuItem = new ToolStripMenuItem(); + searchToolStripMenuItem = new ToolStripMenuItem(); + filterToolStripMenuItem = new ToolStripMenuItem(); + bookmarksToolStripMenuItem = new ToolStripMenuItem(); + toggleBookmarkToolStripMenuItem = new ToolStripMenuItem(); + jumpToNextToolStripMenuItem = new ToolStripMenuItem(); + jumpToPrevToolStripMenuItem = new ToolStripMenuItem(); + showBookmarkListToolStripMenuItem = new ToolStripMenuItem(); + columnFinderToolStripMenuItem = new ToolStripMenuItem(); + menuToolStripSeparatorExtension5 = new MenuToolStripSeparatorExtension(); + toolStripEncodingMenuItem = new ToolStripMenuItem(); + toolStripEncodingASCIIItem = new ToolStripMenuItem(); + toolStripEncodingANSIItem = new ToolStripMenuItem(); + toolStripEncodingISO88591Item = new ToolStripMenuItem(); + toolStripEncodingUTF8Item = new ToolStripMenuItem(); + toolStripEncodingUTF16Item = new ToolStripMenuItem(); + menuToolStripSeparatorExtension6 = new MenuToolStripSeparatorExtension(); + timeshiftToolStripMenuItem = new ToolStripMenuItem(); + timeshiftMenuTextBox = new ToolStripTextBox(); + menuToolStripSeparatorExtension4 = new MenuToolStripSeparatorExtension(); + copyMarkedLinesIntoNewTabToolStripMenuItem = new ToolStripMenuItem(); + optionToolStripMenuItem = new ToolStripMenuItem(); + columnizerToolStripMenuItem = new ToolStripMenuItem(); + hilightingToolStripMenuItem1 = new ToolStripMenuItem(); + menuToolStripSeparatorExtension7 = new MenuToolStripSeparatorExtension(); + settingsToolStripMenuItem = new ToolStripMenuItem(); + menuToolStripSeparatorExtension9 = new MenuToolStripSeparatorExtension(); + cellSelectModeToolStripMenuItem = new ToolStripMenuItem(); + alwaysOnTopToolStripMenuItem = new ToolStripMenuItem(); + hideLineColumnToolStripMenuItem = new ToolStripMenuItem(); + menuToolStripSeparatorExtension8 = new MenuToolStripSeparatorExtension(); + lockInstanceToolStripMenuItem = new ToolStripMenuItem(); + toolsToolStripMenuItem = new ToolStripMenuItem(); + configureToolStripMenuItem = new ToolStripMenuItem(); + configureToolStripSeparator = new MenuToolStripSeparatorExtension(); + helpToolStripMenuItem = new ToolStripMenuItem(); + showHelpToolStripMenuItem = new ToolStripMenuItem(); + menuToolStripSeparatorExtension11 = new MenuToolStripSeparatorExtension(); + aboutToolStripMenuItem = new ToolStripMenuItem(); + debugToolStripMenuItem = new ToolStripMenuItem(); + dumpLogBufferInfoToolStripMenuItem = new ToolStripMenuItem(); + dumpBufferDiagnosticToolStripMenuItem = new ToolStripMenuItem(); + runGCToolStripMenuItem = new ToolStripMenuItem(); + gCInfoToolStripMenuItem = new ToolStripMenuItem(); + throwExceptionGUIThreadToolStripMenuItem = new ToolStripMenuItem(); + throwExceptionbackgroundThToolStripMenuItem = new ToolStripMenuItem(); + throwExceptionBackgroundThreadToolStripMenuItem = new ToolStripMenuItem(); + loglevelToolStripMenuItem = new ToolStripMenuItem(); + warnToolStripMenuItem = new ToolStripMenuItem(); + infoToolStripMenuItem = new ToolStripMenuItem(); + debugToolStripMenuItem1 = new ToolStripMenuItem(); + disableWordHighlightModeToolStripMenuItem = new ToolStripMenuItem(); + host = new CheckBox(); + toolStripContainer = new ToolStripContainer(); + dockPanel = new DockPanel(); + externalToolsToolStrip = new ToolStrip(); + buttonToolStrip = new ToolStrip(); + toolStripButtonOpen = new ToolStripButton(); + lineToolStripSeparatorExtension1 = new LineToolStripSeparatorExtension(); + toolStripButtonSearch = new ToolStripButton(); + toolStripButtonFilter = new ToolStripButton(); + lineToolStripSeparatorExtension2 = new LineToolStripSeparatorExtension(); + toolStripButtonBookmark = new ToolStripButton(); + toolStripButtonUp = new ToolStripButton(); + toolStripButtonDown = new ToolStripButton(); + lineToolStripSeparatorExtension3 = new LineToolStripSeparatorExtension(); + toolStripButtonBubbles = new ToolStripButton(); + lineToolStripSeparatorExtension4 = new LineToolStripSeparatorExtension(); + toolStripButtonTail = new ToolStripButton(); + lineToolStripSeparatorExtension5 = new LineToolStripSeparatorExtension(); + groupsComboBoxHighlightGroups = new ToolStripComboBox(); + checkBoxFollowTail = new CheckBox(); + tabContextMenuStrip = new ContextMenuStrip(components); + closeThisTabToolStripMenuItem = new ToolStripMenuItem(); + closeOtherTabsToolStripMenuItem = new ToolStripMenuItem(); + closeAllTabsToolStripMenuItem = new ToolStripMenuItem(); + tabColorToolStripMenuItem = new ToolStripMenuItem(); + tabRenameToolStripMenuItem = new ToolStripMenuItem(); + copyPathToClipboardToolStripMenuItem = new ToolStripMenuItem(); + findInExplorerToolStripMenuItem = new ToolStripMenuItem(); + dragControlDateTime = new DateTimeDragControl(); + statusStrip.SuspendLayout(); + mainMenuStrip.SuspendLayout(); + toolStripContainer.ContentPanel.SuspendLayout(); + toolStripContainer.TopToolStripPanel.SuspendLayout(); + toolStripContainer.SuspendLayout(); + buttonToolStrip.SuspendLayout(); + tabContextMenuStrip.SuspendLayout(); + SuspendLayout(); + // + // statusStrip + // + statusStrip.AutoSize = false; + statusStrip.ImageScalingSize = new System.Drawing.Size(24, 24); + statusStrip.Items.AddRange(new ToolStripItem[] { labelLines, labelSize, labelCurrentLine, loadProgessBar, labelStatus }); + statusStrip.Location = new System.Drawing.Point(0, 954); + statusStrip.Name = "statusStrip"; + statusStrip.Padding = new Padding(3, 0, 23, 0); + statusStrip.Size = new System.Drawing.Size(1603, 63); + statusStrip.SizingGrip = false; + statusStrip.TabIndex = 5; + statusStrip.Text = "statusStrip1"; + // + // labelLines + // + labelLines.AutoSize = false; + labelLines.BorderSides = ToolStripStatusLabelBorderSides.Left | ToolStripStatusLabelBorderSides.Top | ToolStripStatusLabelBorderSides.Right | ToolStripStatusLabelBorderSides.Bottom; + labelLines.BorderStyle = Border3DStyle.SunkenOuter; + labelLines.Name = "labelLines"; + labelLines.Size = new System.Drawing.Size(26, 58); + labelLines.Text = "0"; + // + // labelSize + // + labelSize.AutoSize = false; + labelSize.BorderSides = ToolStripStatusLabelBorderSides.Left | ToolStripStatusLabelBorderSides.Top | ToolStripStatusLabelBorderSides.Right | ToolStripStatusLabelBorderSides.Bottom; + labelSize.BorderStyle = Border3DStyle.SunkenOuter; + labelSize.Name = "labelSize"; + labelSize.Size = new System.Drawing.Size(26, 58); + labelSize.Text = "0"; + // + // labelCurrentLine + // + labelCurrentLine.AutoSize = false; + labelCurrentLine.BorderSides = ToolStripStatusLabelBorderSides.Left | ToolStripStatusLabelBorderSides.Top | ToolStripStatusLabelBorderSides.Right | ToolStripStatusLabelBorderSides.Bottom; + labelCurrentLine.BorderStyle = Border3DStyle.SunkenOuter; + labelCurrentLine.Name = "labelCurrentLine"; + labelCurrentLine.Size = new System.Drawing.Size(28, 58); + labelCurrentLine.Text = "L:"; + // + // loadProgessBar + // + loadProgessBar.Name = "loadProgessBar"; + loadProgessBar.Size = new System.Drawing.Size(83, 57); + // + // labelStatus + // + labelStatus.Name = "labelStatus"; + labelStatus.Size = new System.Drawing.Size(39, 58); + labelStatus.Text = "Ready"; + // + // mainMenuStrip + // + mainMenuStrip.AllowMerge = false; + mainMenuStrip.Dock = DockStyle.None; + mainMenuStrip.ImageScalingSize = new System.Drawing.Size(24, 24); + mainMenuStrip.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem, viewNavigateToolStripMenuItem, optionToolStripMenuItem, toolsToolStripMenuItem, helpToolStripMenuItem, debugToolStripMenuItem }); + mainMenuStrip.LayoutStyle = ToolStripLayoutStyle.Flow; + mainMenuStrip.Location = new System.Drawing.Point(0, 19); + mainMenuStrip.Name = "mainMenuStrip"; + mainMenuStrip.Size = new System.Drawing.Size(1603, 23); + mainMenuStrip.TabIndex = 6; + mainMenuStrip.Text = "menuStrip1"; + // + // fileToolStripMenuItem + // + fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { openToolStripMenuItem, openURIToolStripMenuItem, closeFileToolStripMenuItem, reloadToolStripMenuItem, newFromClipboardToolStripMenuItem, menuToolStripSeparatorExtension1, multiFileToolStripMenuItem, menuToolStripSeparatorExtension2, loadProjectToolStripMenuItem, saveProjectToolStripMenuItem, exportBookmarksToolStripMenuItem, menuToolStripSeparatorExtension3, lastUsedToolStripMenuItem, exitToolStripMenuItem }); + fileToolStripMenuItem.Name = "fileToolStripMenuItem"; + fileToolStripMenuItem.Size = new System.Drawing.Size(37, 19); + fileToolStripMenuItem.Text = "File"; + fileToolStripMenuItem.DropDownOpening += OnFileToolStripMenuItemDropDownOpening; + // + // openToolStripMenuItem + // + openToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; + openToolStripMenuItem.Image = LogExpert.Resources.Resources.File_open; + openToolStripMenuItem.Name = "openToolStripMenuItem"; + openToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.O; + openToolStripMenuItem.Size = new System.Drawing.Size(253, 30); + openToolStripMenuItem.Text = "Open..."; + openToolStripMenuItem.Click += OnOpenToolStripMenuItemClick; + // + // openURIToolStripMenuItem + // + openURIToolStripMenuItem.Name = "openURIToolStripMenuItem"; + openURIToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U; + openURIToolStripMenuItem.Size = new System.Drawing.Size(253, 30); + openURIToolStripMenuItem.Text = "Open URL..."; + openURIToolStripMenuItem.ToolTipText = "Opens a file by entering a URL which is supported by a file system plugin"; + openURIToolStripMenuItem.Click += OnOpenURIToolStripMenuItemClick; + // + // closeFileToolStripMenuItem + // + closeFileToolStripMenuItem.Image = LogExpert.Resources.Resources.Close; + closeFileToolStripMenuItem.Name = "closeFileToolStripMenuItem"; + closeFileToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.F4; + closeFileToolStripMenuItem.Size = new System.Drawing.Size(253, 30); + closeFileToolStripMenuItem.Text = "Close File"; + closeFileToolStripMenuItem.Click += OnCloseFileToolStripMenuItemClick; + // + // reloadToolStripMenuItem + // + reloadToolStripMenuItem.Image = LogExpert.Resources.Resources.Restart_alt; + reloadToolStripMenuItem.Name = "reloadToolStripMenuItem"; + reloadToolStripMenuItem.ShortcutKeys = Keys.F5; + reloadToolStripMenuItem.Size = new System.Drawing.Size(253, 30); + reloadToolStripMenuItem.Text = "Reload"; + reloadToolStripMenuItem.Click += OnReloadToolStripMenuItemClick; + // + // newFromClipboardToolStripMenuItem + // + newFromClipboardToolStripMenuItem.Name = "newFromClipboardToolStripMenuItem"; + newFromClipboardToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.N; + newFromClipboardToolStripMenuItem.Size = new System.Drawing.Size(253, 30); + newFromClipboardToolStripMenuItem.Text = "New tab from clipboard"; + newFromClipboardToolStripMenuItem.ToolTipText = "Creates a new tab with content from clipboard"; + newFromClipboardToolStripMenuItem.Click += OnNewFromClipboardToolStripMenuItemClick; + // + // menuToolStripSeparatorExtension1 + // + menuToolStripSeparatorExtension1.Name = "menuToolStripSeparatorExtension1"; + menuToolStripSeparatorExtension1.Size = new System.Drawing.Size(250, 6); + // + // multiFileToolStripMenuItem + // + multiFileToolStripMenuItem.CheckOnClick = true; + multiFileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { multiFileEnabledStripMenuItem, multifileMaskToolStripMenuItem }); + multiFileToolStripMenuItem.Name = "multiFileToolStripMenuItem"; + multiFileToolStripMenuItem.Size = new System.Drawing.Size(253, 30); + multiFileToolStripMenuItem.Text = "MultiFile"; + multiFileToolStripMenuItem.ToolTipText = "Treat multiple files as one large file (e.g. data.log, data.log.1, data.log.2,...)"; + multiFileToolStripMenuItem.Click += OnMultiFileToolStripMenuItemClick; + // + // multiFileEnabledStripMenuItem + // + multiFileEnabledStripMenuItem.BackColor = System.Drawing.SystemColors.Control; + multiFileEnabledStripMenuItem.CheckOnClick = true; + multiFileEnabledStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; + multiFileEnabledStripMenuItem.Name = "multiFileEnabledStripMenuItem"; + multiFileEnabledStripMenuItem.Size = new System.Drawing.Size(165, 22); + multiFileEnabledStripMenuItem.Text = "Enable MultiFile"; + multiFileEnabledStripMenuItem.Click += OnMultiFileEnabledStripMenuItemClick; + // + // multifileMaskToolStripMenuItem + // + multifileMaskToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; + multifileMaskToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; + multifileMaskToolStripMenuItem.Name = "multifileMaskToolStripMenuItem"; + multifileMaskToolStripMenuItem.Size = new System.Drawing.Size(165, 22); + multifileMaskToolStripMenuItem.Text = "File name mask..."; + multifileMaskToolStripMenuItem.Click += OnMultiFileMaskToolStripMenuItemClick; + // + // menuToolStripSeparatorExtension2 + // + menuToolStripSeparatorExtension2.Name = "menuToolStripSeparatorExtension2"; + menuToolStripSeparatorExtension2.Size = new System.Drawing.Size(250, 6); + // + // loadProjectToolStripMenuItem + // + loadProjectToolStripMenuItem.Name = "loadProjectToolStripMenuItem"; + loadProjectToolStripMenuItem.Size = new System.Drawing.Size(253, 30); + loadProjectToolStripMenuItem.Text = "Load session..."; + loadProjectToolStripMenuItem.ToolTipText = "Load a saved session (list of log files)"; + loadProjectToolStripMenuItem.Click += OnLoadProjectToolStripMenuItemClick; + // + // saveProjectToolStripMenuItem + // + saveProjectToolStripMenuItem.Name = "saveProjectToolStripMenuItem"; + saveProjectToolStripMenuItem.Size = new System.Drawing.Size(253, 30); + saveProjectToolStripMenuItem.Text = "Save session..."; + saveProjectToolStripMenuItem.ToolTipText = "Save a session (all open tabs)"; + saveProjectToolStripMenuItem.Click += OnSaveProjectToolStripMenuItemClick; + // + // exportBookmarksToolStripMenuItem + // + exportBookmarksToolStripMenuItem.Name = "exportBookmarksToolStripMenuItem"; + exportBookmarksToolStripMenuItem.Size = new System.Drawing.Size(253, 30); + exportBookmarksToolStripMenuItem.Text = "Export bookmarks..."; + exportBookmarksToolStripMenuItem.ToolTipText = "Write a list of bookmarks and their comments to a CSV file"; + exportBookmarksToolStripMenuItem.Click += OnExportBookmarksToolStripMenuItemClick; + // + // menuToolStripSeparatorExtension3 + // + menuToolStripSeparatorExtension3.Name = "menuToolStripSeparatorExtension3"; + menuToolStripSeparatorExtension3.Size = new System.Drawing.Size(250, 6); + // + // lastUsedToolStripMenuItem + // + lastUsedToolStripMenuItem.Name = "lastUsedToolStripMenuItem"; + lastUsedToolStripMenuItem.Size = new System.Drawing.Size(253, 30); + lastUsedToolStripMenuItem.Text = "Last used"; + // + // exitToolStripMenuItem + // + exitToolStripMenuItem.Image = LogExpert.Resources.Resources.Exit; + exitToolStripMenuItem.Name = "exitToolStripMenuItem"; + exitToolStripMenuItem.ShortcutKeys = Keys.Alt | Keys.F4; + exitToolStripMenuItem.Size = new System.Drawing.Size(253, 30); + exitToolStripMenuItem.Text = "Exit"; + exitToolStripMenuItem.Click += OnExitToolStripMenuItemClick; + // + // viewNavigateToolStripMenuItem + // + viewNavigateToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { goToLineToolStripMenuItem, searchToolStripMenuItem, filterToolStripMenuItem, bookmarksToolStripMenuItem, columnFinderToolStripMenuItem, menuToolStripSeparatorExtension5, toolStripEncodingMenuItem, menuToolStripSeparatorExtension6, timeshiftToolStripMenuItem, timeshiftMenuTextBox, menuToolStripSeparatorExtension4, copyMarkedLinesIntoNewTabToolStripMenuItem }); + viewNavigateToolStripMenuItem.Name = "viewNavigateToolStripMenuItem"; + viewNavigateToolStripMenuItem.Size = new System.Drawing.Size(96, 19); + viewNavigateToolStripMenuItem.Text = "View/Navigate"; + // + // goToLineToolStripMenuItem + // + goToLineToolStripMenuItem.Name = "goToLineToolStripMenuItem"; + goToLineToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.G; + goToLineToolStripMenuItem.Size = new System.Drawing.Size(189, 30); + goToLineToolStripMenuItem.Text = "Go to line..."; + goToLineToolStripMenuItem.Click += OnGoToLineToolStripMenuItemClick; + // + // searchToolStripMenuItem + // + searchToolStripMenuItem.Name = "searchToolStripMenuItem"; + searchToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.F; + searchToolStripMenuItem.Size = new System.Drawing.Size(189, 30); + searchToolStripMenuItem.Text = "Search..."; + searchToolStripMenuItem.Click += OnSearchToolStripMenuItemClick; + // + // filterToolStripMenuItem + // + filterToolStripMenuItem.Image = LogExpert.Resources.Resources.Filter; + filterToolStripMenuItem.Name = "filterToolStripMenuItem"; + filterToolStripMenuItem.ShortcutKeys = Keys.F4; + filterToolStripMenuItem.Size = new System.Drawing.Size(189, 30); + filterToolStripMenuItem.Text = "Filter"; + filterToolStripMenuItem.Click += OnFilterToolStripMenuItemClick; + // + // bookmarksToolStripMenuItem + // + bookmarksToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { toggleBookmarkToolStripMenuItem, jumpToNextToolStripMenuItem, jumpToPrevToolStripMenuItem, showBookmarkListToolStripMenuItem }); + bookmarksToolStripMenuItem.Name = "bookmarksToolStripMenuItem"; + bookmarksToolStripMenuItem.Size = new System.Drawing.Size(189, 30); + bookmarksToolStripMenuItem.Text = "Bookmarks"; + // + // toggleBookmarkToolStripMenuItem + // + toggleBookmarkToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; + toggleBookmarkToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; + toggleBookmarkToolStripMenuItem.Image = LogExpert.Resources.Resources.Bookmark_add; + toggleBookmarkToolStripMenuItem.Name = "toggleBookmarkToolStripMenuItem"; + toggleBookmarkToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.F2; + toggleBookmarkToolStripMenuItem.Size = new System.Drawing.Size(253, 30); + toggleBookmarkToolStripMenuItem.Text = "Toggle Bookmark"; + toggleBookmarkToolStripMenuItem.Click += OnToggleBookmarkToolStripMenuItemClick; + // + // jumpToNextToolStripMenuItem + // + jumpToNextToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; + jumpToNextToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; + jumpToNextToolStripMenuItem.Image = LogExpert.Resources.Resources.ArrowDown; + jumpToNextToolStripMenuItem.Name = "jumpToNextToolStripMenuItem"; + jumpToNextToolStripMenuItem.ShortcutKeys = Keys.F2; + jumpToNextToolStripMenuItem.Size = new System.Drawing.Size(253, 30); + jumpToNextToolStripMenuItem.Text = "Jump to next"; + jumpToNextToolStripMenuItem.Click += OnJumpToNextToolStripMenuItemClick; + // + // jumpToPrevToolStripMenuItem + // + jumpToPrevToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; + jumpToPrevToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; + jumpToPrevToolStripMenuItem.Image = LogExpert.Resources.Resources.ArrowUp; + jumpToPrevToolStripMenuItem.Name = "jumpToPrevToolStripMenuItem"; + jumpToPrevToolStripMenuItem.ShortcutKeys = Keys.Shift | Keys.F2; + jumpToPrevToolStripMenuItem.Size = new System.Drawing.Size(253, 30); + jumpToPrevToolStripMenuItem.Text = "Jump to prev"; + jumpToPrevToolStripMenuItem.Click += OnJumpToPrevToolStripMenuItemClick; + // + // showBookmarkListToolStripMenuItem + // + showBookmarkListToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; + showBookmarkListToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; + showBookmarkListToolStripMenuItem.Name = "showBookmarkListToolStripMenuItem"; + showBookmarkListToolStripMenuItem.ShortcutKeys = Keys.F6; + showBookmarkListToolStripMenuItem.Size = new System.Drawing.Size(253, 30); + showBookmarkListToolStripMenuItem.Text = "Bookmark list"; + showBookmarkListToolStripMenuItem.Click += OnShowBookmarkListToolStripMenuItemClick; + // + // columnFinderToolStripMenuItem + // + columnFinderToolStripMenuItem.CheckOnClick = true; + columnFinderToolStripMenuItem.Name = "columnFinderToolStripMenuItem"; + columnFinderToolStripMenuItem.ShortcutKeys = Keys.F8; + columnFinderToolStripMenuItem.Size = new System.Drawing.Size(189, 30); + columnFinderToolStripMenuItem.Text = "Column finder"; + columnFinderToolStripMenuItem.Click += OnColumnFinderToolStripMenuItemClick; + // + // menuToolStripSeparatorExtension5 + // + menuToolStripSeparatorExtension5.Name = "menuToolStripSeparatorExtension5"; + menuToolStripSeparatorExtension5.Size = new System.Drawing.Size(186, 6); + // + // toolStripEncodingMenuItem + // + toolStripEncodingMenuItem.DropDownItems.AddRange(new ToolStripItem[] { toolStripEncodingASCIIItem, toolStripEncodingANSIItem, toolStripEncodingISO88591Item, toolStripEncodingUTF8Item, toolStripEncodingUTF16Item }); + toolStripEncodingMenuItem.Name = "toolStripEncodingMenuItem"; + toolStripEncodingMenuItem.Size = new System.Drawing.Size(189, 30); + toolStripEncodingMenuItem.Text = "Encoding"; + // + // toolStripEncodingASCIIItem + // + toolStripEncodingASCIIItem.BackColor = System.Drawing.SystemColors.Control; + toolStripEncodingASCIIItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; + toolStripEncodingASCIIItem.Name = "toolStripEncodingASCIIItem"; + toolStripEncodingASCIIItem.Size = new System.Drawing.Size(132, 22); + toolStripEncodingASCIIItem.Tag = ""; + toolStripEncodingASCIIItem.Text = "ASCII"; + toolStripEncodingASCIIItem.Click += OnASCIIToolStripMenuItemClick; + // + // toolStripEncodingANSIItem + // + toolStripEncodingANSIItem.BackColor = System.Drawing.SystemColors.Control; + toolStripEncodingANSIItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; + toolStripEncodingANSIItem.Name = "toolStripEncodingANSIItem"; + toolStripEncodingANSIItem.Size = new System.Drawing.Size(132, 22); + toolStripEncodingANSIItem.Tag = ""; + toolStripEncodingANSIItem.Text = "ANSI"; + toolStripEncodingANSIItem.Click += OnANSIToolStripMenuItemClick; + // + // toolStripEncodingISO88591Item + // + toolStripEncodingISO88591Item.BackColor = System.Drawing.SystemColors.Control; + toolStripEncodingISO88591Item.ForeColor = System.Drawing.SystemColors.ControlDarkDark; + toolStripEncodingISO88591Item.Name = "toolStripEncodingISO88591Item"; + toolStripEncodingISO88591Item.Size = new System.Drawing.Size(132, 22); + toolStripEncodingISO88591Item.Text = "ISO-8859-1"; + toolStripEncodingISO88591Item.Click += OnISO88591ToolStripMenuItemClick; + // + // toolStripEncodingUTF8Item + // + toolStripEncodingUTF8Item.BackColor = System.Drawing.SystemColors.Control; + toolStripEncodingUTF8Item.ForeColor = System.Drawing.SystemColors.ControlDarkDark; + toolStripEncodingUTF8Item.Name = "toolStripEncodingUTF8Item"; + toolStripEncodingUTF8Item.Size = new System.Drawing.Size(132, 22); + toolStripEncodingUTF8Item.Text = "UTF8"; + toolStripEncodingUTF8Item.Click += OnUTF8ToolStripMenuItemClick; + // + // toolStripEncodingUTF16Item + // + toolStripEncodingUTF16Item.BackColor = System.Drawing.SystemColors.Control; + toolStripEncodingUTF16Item.ForeColor = System.Drawing.SystemColors.ControlDarkDark; + toolStripEncodingUTF16Item.Name = "toolStripEncodingUTF16Item"; + toolStripEncodingUTF16Item.Size = new System.Drawing.Size(132, 22); + toolStripEncodingUTF16Item.Text = "Unicode"; + toolStripEncodingUTF16Item.Click += OnUTF16ToolStripMenuItemClick; + // + // menuToolStripSeparatorExtension6 + // + menuToolStripSeparatorExtension6.Name = "menuToolStripSeparatorExtension6"; + menuToolStripSeparatorExtension6.Size = new System.Drawing.Size(186, 6); + // + // timeshiftToolStripMenuItem + // + timeshiftToolStripMenuItem.CheckOnClick = true; + timeshiftToolStripMenuItem.Name = "timeshiftToolStripMenuItem"; + timeshiftToolStripMenuItem.Size = new System.Drawing.Size(189, 30); + timeshiftToolStripMenuItem.Text = "Timeshift"; + timeshiftToolStripMenuItem.ToolTipText = "If supported by the columnizer, you can set an offset to the displayed log time"; + timeshiftToolStripMenuItem.CheckStateChanged += OnTimeShiftToolStripMenuItemCheckStateChanged; + // + // timeshiftMenuTextBox + // + timeshiftMenuTextBox.BorderStyle = BorderStyle.FixedSingle; + timeshiftMenuTextBox.Enabled = false; + timeshiftMenuTextBox.Font = new System.Drawing.Font("Segoe UI", 9F); + timeshiftMenuTextBox.Name = "timeshiftMenuTextBox"; + timeshiftMenuTextBox.Size = new System.Drawing.Size(100, 23); + timeshiftMenuTextBox.Text = "+00:00:00.000"; + timeshiftMenuTextBox.ToolTipText = "Time offset (hh:mm:ss.fff)"; + timeshiftMenuTextBox.KeyDown += OnTimeShiftMenuTextBoxKeyDown; + // + // menuToolStripSeparatorExtension4 + // + menuToolStripSeparatorExtension4.Name = "menuToolStripSeparatorExtension4"; + menuToolStripSeparatorExtension4.Size = new System.Drawing.Size(186, 6); + // + // copyMarkedLinesIntoNewTabToolStripMenuItem + // + copyMarkedLinesIntoNewTabToolStripMenuItem.Name = "copyMarkedLinesIntoNewTabToolStripMenuItem"; + copyMarkedLinesIntoNewTabToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T; + copyMarkedLinesIntoNewTabToolStripMenuItem.Size = new System.Drawing.Size(189, 30); + copyMarkedLinesIntoNewTabToolStripMenuItem.Text = "Copy to Tab"; + copyMarkedLinesIntoNewTabToolStripMenuItem.ToolTipText = "Copies all selected lines into a new tab page"; + copyMarkedLinesIntoNewTabToolStripMenuItem.Click += OnCopyMarkedLinesIntoNewTabToolStripMenuItemClick; + // + // optionToolStripMenuItem + // + optionToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { columnizerToolStripMenuItem, hilightingToolStripMenuItem1, menuToolStripSeparatorExtension7, settingsToolStripMenuItem, menuToolStripSeparatorExtension9, cellSelectModeToolStripMenuItem, alwaysOnTopToolStripMenuItem, hideLineColumnToolStripMenuItem, menuToolStripSeparatorExtension8, lockInstanceToolStripMenuItem }); + optionToolStripMenuItem.Name = "optionToolStripMenuItem"; + optionToolStripMenuItem.Size = new System.Drawing.Size(61, 19); + optionToolStripMenuItem.Text = "Options"; + optionToolStripMenuItem.DropDownOpening += OnOptionToolStripMenuItemDropDownOpening; + // + // columnizerToolStripMenuItem + // + columnizerToolStripMenuItem.Name = "columnizerToolStripMenuItem"; + columnizerToolStripMenuItem.Size = new System.Drawing.Size(224, 30); + columnizerToolStripMenuItem.Text = "Columnizer..."; + columnizerToolStripMenuItem.ToolTipText = "Splits various kinds of logfiles into fixed columns"; + columnizerToolStripMenuItem.Click += OnSelectFilterToolStripMenuItemClick; + // + // hilightingToolStripMenuItem1 + // + hilightingToolStripMenuItem1.Name = "hilightingToolStripMenuItem1"; + hilightingToolStripMenuItem1.Size = new System.Drawing.Size(224, 30); + hilightingToolStripMenuItem1.Text = "Highlighting and triggers..."; + hilightingToolStripMenuItem1.Click += OnHighlightingToolStripMenuItemClick; + // + // menuToolStripSeparatorExtension7 + // + menuToolStripSeparatorExtension7.Name = "menuToolStripSeparatorExtension7"; + menuToolStripSeparatorExtension7.Size = new System.Drawing.Size(221, 6); + // + // settingsToolStripMenuItem + // + settingsToolStripMenuItem.Image = LogExpert.Resources.Resources.Settings; + settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; + settingsToolStripMenuItem.Size = new System.Drawing.Size(224, 30); + settingsToolStripMenuItem.Text = "Settings..."; + settingsToolStripMenuItem.Click += OnSettingsToolStripMenuItemClick; + // + // menuToolStripSeparatorExtension9 + // + menuToolStripSeparatorExtension9.Name = "menuToolStripSeparatorExtension9"; + menuToolStripSeparatorExtension9.Size = new System.Drawing.Size(221, 6); + // + // cellSelectModeToolStripMenuItem + // + cellSelectModeToolStripMenuItem.CheckOnClick = true; + cellSelectModeToolStripMenuItem.Name = "cellSelectModeToolStripMenuItem"; + cellSelectModeToolStripMenuItem.Size = new System.Drawing.Size(224, 30); + cellSelectModeToolStripMenuItem.Text = "Cell select mode"; + cellSelectModeToolStripMenuItem.ToolTipText = "Switches between foll row selection and single cell selection mode"; + cellSelectModeToolStripMenuItem.Click += OnCellSelectModeToolStripMenuItemClick; + // + // alwaysOnTopToolStripMenuItem + // + alwaysOnTopToolStripMenuItem.CheckOnClick = true; + alwaysOnTopToolStripMenuItem.Name = "alwaysOnTopToolStripMenuItem"; + alwaysOnTopToolStripMenuItem.Size = new System.Drawing.Size(224, 30); + alwaysOnTopToolStripMenuItem.Text = "Always on top"; + alwaysOnTopToolStripMenuItem.Click += OnAlwaysOnTopToolStripMenuItemClick; + // + // hideLineColumnToolStripMenuItem + // + hideLineColumnToolStripMenuItem.CheckOnClick = true; + hideLineColumnToolStripMenuItem.Name = "hideLineColumnToolStripMenuItem"; + hideLineColumnToolStripMenuItem.Size = new System.Drawing.Size(224, 30); + hideLineColumnToolStripMenuItem.Text = "Hide line column"; + hideLineColumnToolStripMenuItem.Click += OnHideLineColumnToolStripMenuItemClick; + // + // menuToolStripSeparatorExtension8 + // + menuToolStripSeparatorExtension8.Name = "menuToolStripSeparatorExtension8"; + menuToolStripSeparatorExtension8.Size = new System.Drawing.Size(221, 6); + // + // lockInstanceToolStripMenuItem + // + lockInstanceToolStripMenuItem.Name = "lockInstanceToolStripMenuItem"; + lockInstanceToolStripMenuItem.Size = new System.Drawing.Size(224, 30); + lockInstanceToolStripMenuItem.Text = "Lock instance"; + lockInstanceToolStripMenuItem.ToolTipText = "When enabled all new launched LogExpert instances will redirect to this window"; + lockInstanceToolStripMenuItem.Click += OnLockInstanceToolStripMenuItemClick; + // + // toolsToolStripMenuItem + // + toolsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { configureToolStripMenuItem, configureToolStripSeparator }); + toolsToolStripMenuItem.Name = "toolsToolStripMenuItem"; + toolsToolStripMenuItem.Size = new System.Drawing.Size(47, 19); + toolsToolStripMenuItem.Text = "Tools"; + toolsToolStripMenuItem.ToolTipText = "Launch external tools (configure in the settings)"; + toolsToolStripMenuItem.DropDownItemClicked += OnToolsToolStripMenuItemDropDownItemClicked; + // + // configureToolStripMenuItem + // + configureToolStripMenuItem.Name = "configureToolStripMenuItem"; + configureToolStripMenuItem.Size = new System.Drawing.Size(136, 22); + configureToolStripMenuItem.Text = "Configure..."; + configureToolStripMenuItem.Click += OnConfigureToolStripMenuItemClick; + // + // configureToolStripSeparator + // + configureToolStripSeparator.Name = "configureToolStripSeparator"; + configureToolStripSeparator.Size = new System.Drawing.Size(133, 6); + // + // helpToolStripMenuItem + // + helpToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { showHelpToolStripMenuItem, menuToolStripSeparatorExtension11, aboutToolStripMenuItem }); + helpToolStripMenuItem.Name = "helpToolStripMenuItem"; + helpToolStripMenuItem.Size = new System.Drawing.Size(44, 19); + helpToolStripMenuItem.Text = "Help"; + // + // showHelpToolStripMenuItem + // + showHelpToolStripMenuItem.Name = "showHelpToolStripMenuItem"; + showHelpToolStripMenuItem.ShortcutKeys = Keys.F1; + showHelpToolStripMenuItem.Size = new System.Drawing.Size(148, 22); + showHelpToolStripMenuItem.Text = "Show help"; + showHelpToolStripMenuItem.Click += OnShowHelpToolStripMenuItemClick; + // + // menuToolStripSeparatorExtension11 + // + menuToolStripSeparatorExtension11.Name = "menuToolStripSeparatorExtension11"; + menuToolStripSeparatorExtension11.Size = new System.Drawing.Size(145, 6); + // + // aboutToolStripMenuItem + // + aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; + aboutToolStripMenuItem.Size = new System.Drawing.Size(148, 22); + aboutToolStripMenuItem.Text = "About"; + aboutToolStripMenuItem.Click += OnAboutToolStripMenuItemClick; + // + // debugToolStripMenuItem + // + debugToolStripMenuItem.Alignment = ToolStripItemAlignment.Right; + debugToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { dumpLogBufferInfoToolStripMenuItem, dumpBufferDiagnosticToolStripMenuItem, runGCToolStripMenuItem, gCInfoToolStripMenuItem, throwExceptionGUIThreadToolStripMenuItem, throwExceptionbackgroundThToolStripMenuItem, throwExceptionBackgroundThreadToolStripMenuItem, loglevelToolStripMenuItem, disableWordHighlightModeToolStripMenuItem }); + debugToolStripMenuItem.Name = "debugToolStripMenuItem"; + debugToolStripMenuItem.Size = new System.Drawing.Size(54, 19); + debugToolStripMenuItem.Text = "Debug"; + // + // dumpLogBufferInfoToolStripMenuItem + // + dumpLogBufferInfoToolStripMenuItem.Name = "dumpLogBufferInfoToolStripMenuItem"; + dumpLogBufferInfoToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + dumpLogBufferInfoToolStripMenuItem.Text = "Dump LogBuffer info"; + dumpLogBufferInfoToolStripMenuItem.Click += OnDumpLogBufferInfoToolStripMenuItemClick; + // + // dumpBufferDiagnosticToolStripMenuItem + // + dumpBufferDiagnosticToolStripMenuItem.Name = "dumpBufferDiagnosticToolStripMenuItem"; + dumpBufferDiagnosticToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + dumpBufferDiagnosticToolStripMenuItem.Text = "Dump buffer diagnostic"; + dumpBufferDiagnosticToolStripMenuItem.Click += OnDumpBufferDiagnosticToolStripMenuItemClick; + // + // runGCToolStripMenuItem + // + runGCToolStripMenuItem.Name = "runGCToolStripMenuItem"; + runGCToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + runGCToolStripMenuItem.Text = "Run GC"; + runGCToolStripMenuItem.Click += OnRunGCToolStripMenuItemClick; + // + // gCInfoToolStripMenuItem + // + gCInfoToolStripMenuItem.Name = "gCInfoToolStripMenuItem"; + gCInfoToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + gCInfoToolStripMenuItem.Text = "Dump GC info"; + gCInfoToolStripMenuItem.Click += OnGCInfoToolStripMenuItemClick; + // + // throwExceptionGUIThreadToolStripMenuItem + // + throwExceptionGUIThreadToolStripMenuItem.Name = "throwExceptionGUIThreadToolStripMenuItem"; + throwExceptionGUIThreadToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + throwExceptionGUIThreadToolStripMenuItem.Text = "Throw exception (GUI Thread)"; + throwExceptionGUIThreadToolStripMenuItem.Click += OnThrowExceptionGUIThreadToolStripMenuItemClick; + // + // throwExceptionbackgroundThToolStripMenuItem + // + throwExceptionbackgroundThToolStripMenuItem.Name = "throwExceptionbackgroundThToolStripMenuItem"; + throwExceptionbackgroundThToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + throwExceptionbackgroundThToolStripMenuItem.Text = "Throw exception (Async delegate)"; + throwExceptionbackgroundThToolStripMenuItem.Click += OnThrowExceptionBackgroundThToolStripMenuItemClick; + // + // throwExceptionBackgroundThreadToolStripMenuItem + // + throwExceptionBackgroundThreadToolStripMenuItem.Name = "throwExceptionBackgroundThreadToolStripMenuItem"; + throwExceptionBackgroundThreadToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + throwExceptionBackgroundThreadToolStripMenuItem.Text = "Throw exception (background thread)"; + throwExceptionBackgroundThreadToolStripMenuItem.Click += OnThrowExceptionBackgroundThreadToolStripMenuItemClick; + // + // loglevelToolStripMenuItem + // + loglevelToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { warnToolStripMenuItem, infoToolStripMenuItem, debugToolStripMenuItem1 }); + loglevelToolStripMenuItem.Name = "loglevelToolStripMenuItem"; + loglevelToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + loglevelToolStripMenuItem.Text = "Loglevel"; + loglevelToolStripMenuItem.DropDownOpening += OnLogLevelToolStripMenuItemDropDownOpening; + loglevelToolStripMenuItem.Click += OnLogLevelToolStripMenuItemClick; + // + // warnToolStripMenuItem + // + warnToolStripMenuItem.Name = "warnToolStripMenuItem"; + warnToolStripMenuItem.Size = new System.Drawing.Size(109, 22); + warnToolStripMenuItem.Text = "Warn"; + warnToolStripMenuItem.Click += OnWarnToolStripMenuItemClick; + // + // infoToolStripMenuItem + // + infoToolStripMenuItem.Name = "infoToolStripMenuItem"; + infoToolStripMenuItem.Size = new System.Drawing.Size(109, 22); + infoToolStripMenuItem.Text = "Info"; + infoToolStripMenuItem.Click += OnInfoToolStripMenuItemClick; + // + // debugToolStripMenuItem1 + // + debugToolStripMenuItem1.Name = "debugToolStripMenuItem1"; + debugToolStripMenuItem1.Size = new System.Drawing.Size(109, 22); + debugToolStripMenuItem1.Text = "Debug"; + debugToolStripMenuItem1.Click += OnDebugToolStripMenuItemClick; + // + // disableWordHighlightModeToolStripMenuItem + // + disableWordHighlightModeToolStripMenuItem.CheckOnClick = true; + disableWordHighlightModeToolStripMenuItem.Name = "disableWordHighlightModeToolStripMenuItem"; + disableWordHighlightModeToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + disableWordHighlightModeToolStripMenuItem.Text = "Disable word highlight mode"; + disableWordHighlightModeToolStripMenuItem.Click += OnDisableWordHighlightModeToolStripMenuItemClick; + // + // host + // + host.AccessibleName = "host"; + host.AutoSize = true; + host.BackColor = System.Drawing.Color.Transparent; + host.Location = new System.Drawing.Point(9, 1); + host.Name = "host"; + host.Size = new System.Drawing.Size(80, 22); + host.TabIndex = 7; + host.Text = "Follow tail"; + host.UseVisualStyleBackColor = false; + // + // toolStripContainer + // + // + // toolStripContainer.BottomToolStripPanel + // + toolStripContainer.BottomToolStripPanel.RenderMode = ToolStripRenderMode.System; + toolStripContainer.BottomToolStripPanelVisible = false; + // + // toolStripContainer.ContentPanel + // + toolStripContainer.ContentPanel.Controls.Add(dockPanel); + toolStripContainer.ContentPanel.Margin = new Padding(0); + toolStripContainer.ContentPanel.Size = new System.Drawing.Size(1603, 881); + toolStripContainer.Dock = DockStyle.Fill; + // + // toolStripContainer.LeftToolStripPanel + // + toolStripContainer.LeftToolStripPanel.Enabled = false; + toolStripContainer.LeftToolStripPanelVisible = false; + toolStripContainer.Location = new System.Drawing.Point(0, 0); + toolStripContainer.Margin = new Padding(0); + toolStripContainer.Name = "toolStripContainer"; + // + // toolStripContainer.RightToolStripPanel + // + toolStripContainer.RightToolStripPanel.Enabled = false; + toolStripContainer.RightToolStripPanelVisible = false; + toolStripContainer.Size = new System.Drawing.Size(1603, 954); + toolStripContainer.TabIndex = 13; + toolStripContainer.Text = "toolStripContainer1"; + // + // toolStripContainer.TopToolStripPanel + // + toolStripContainer.TopToolStripPanel.Controls.Add(externalToolsToolStrip); + toolStripContainer.TopToolStripPanel.Controls.Add(mainMenuStrip); + toolStripContainer.TopToolStripPanel.Controls.Add(buttonToolStrip); + // + // dockPanel + // + dockPanel.ActiveAutoHideContent = null; + dockPanel.DefaultFloatWindowSize = new System.Drawing.Size(600, 400); + dockPanel.Dock = DockStyle.Fill; + dockPanel.DockBackColor = System.Drawing.SystemColors.Control; + dockPanel.DocumentStyle = DocumentStyle.DockingWindow; + dockPanel.ForeColor = System.Drawing.SystemColors.Control; + dockPanel.Location = new System.Drawing.Point(0, 0); + dockPanel.Margin = new Padding(0); + dockPanel.Name = "dockPanel"; + dockPanel.ShowDocumentIcon = true; + dockPanel.Size = new System.Drawing.Size(1603, 881); + dockPanelGradient1.EndColor = System.Drawing.SystemColors.Control; + dockPanelGradient1.StartColor = System.Drawing.SystemColors.Control; + autoHideStripSkin1.DockStripGradient = dockPanelGradient1; + tabGradient1.EndColor = System.Drawing.SystemColors.Control; + tabGradient1.StartColor = System.Drawing.SystemColors.Control; + tabGradient1.TextColor = System.Drawing.SystemColors.ControlText; + autoHideStripSkin1.TabGradient = tabGradient1; + autoHideStripSkin1.TextFont = new System.Drawing.Font("Segoe UI", 9F); + tabGradient2.EndColor = System.Drawing.SystemColors.Control; + tabGradient2.StartColor = System.Drawing.SystemColors.Control; + tabGradient2.TextColor = System.Drawing.SystemColors.ControlText; + dockPaneStripGradient1.ActiveTabGradient = tabGradient2; + dockPanelGradient2.EndColor = System.Drawing.SystemColors.Control; + dockPanelGradient2.StartColor = System.Drawing.SystemColors.Control; + dockPaneStripGradient1.DockStripGradient = dockPanelGradient2; + tabGradient3.EndColor = System.Drawing.SystemColors.ControlLight; + tabGradient3.StartColor = System.Drawing.SystemColors.ControlLight; + tabGradient3.TextColor = System.Drawing.SystemColors.ControlText; + dockPaneStripGradient1.InactiveTabGradient = tabGradient3; + dockPaneStripSkin1.DocumentGradient = dockPaneStripGradient1; + dockPaneStripSkin1.TextFont = new System.Drawing.Font("Segoe UI", 9F); + tabGradient4.EndColor = System.Drawing.SystemColors.ActiveCaption; + tabGradient4.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical; + tabGradient4.StartColor = System.Drawing.SystemColors.GradientActiveCaption; + tabGradient4.TextColor = System.Drawing.SystemColors.ActiveCaptionText; + dockPaneStripToolWindowGradient1.ActiveCaptionGradient = tabGradient4; + tabGradient5.EndColor = System.Drawing.SystemColors.Control; + tabGradient5.StartColor = System.Drawing.SystemColors.Control; + tabGradient5.TextColor = System.Drawing.SystemColors.ControlText; + dockPaneStripToolWindowGradient1.ActiveTabGradient = tabGradient5; + dockPanelGradient3.EndColor = System.Drawing.SystemColors.ControlLight; + dockPanelGradient3.StartColor = System.Drawing.SystemColors.ControlLight; + dockPaneStripToolWindowGradient1.DockStripGradient = dockPanelGradient3; + tabGradient6.EndColor = System.Drawing.SystemColors.InactiveCaption; + tabGradient6.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical; + tabGradient6.StartColor = System.Drawing.SystemColors.GradientInactiveCaption; + tabGradient6.TextColor = System.Drawing.SystemColors.InactiveCaptionText; + dockPaneStripToolWindowGradient1.InactiveCaptionGradient = tabGradient6; + tabGradient7.EndColor = System.Drawing.Color.Transparent; + tabGradient7.StartColor = System.Drawing.Color.Transparent; + tabGradient7.TextColor = System.Drawing.SystemColors.Control; + dockPaneStripToolWindowGradient1.InactiveTabGradient = tabGradient7; + dockPaneStripSkin1.ToolWindowGradient = dockPaneStripToolWindowGradient1; + dockPanel.Theme = new VS2015LightTheme(); + dockPanel.Theme.Skin.DockPaneStripSkin = dockPaneStripSkin1; + dockPanel.Theme.Skin.AutoHideStripSkin = autoHideStripSkin1; + dockPanel.TabIndex = 14; + dockPanel.ActiveContentChanged += OnDockPanelActiveContentChanged; + // + // externalToolsToolStrip + // + externalToolsToolStrip.AllowMerge = false; + externalToolsToolStrip.Dock = DockStyle.None; + externalToolsToolStrip.ImageScalingSize = new System.Drawing.Size(24, 24); + externalToolsToolStrip.LayoutStyle = ToolStripLayoutStyle.Flow; + externalToolsToolStrip.Location = new System.Drawing.Point(8, 0); + externalToolsToolStrip.Name = "externalToolsToolStrip"; + externalToolsToolStrip.Size = new System.Drawing.Size(32, 19); + externalToolsToolStrip.TabIndex = 8; + externalToolsToolStrip.ItemClicked += OnExternalToolsToolStripItemClicked; + // + // buttonToolStrip + // + buttonToolStrip.AllowMerge = false; + buttonToolStrip.Dock = DockStyle.None; + buttonToolStrip.ImageScalingSize = new System.Drawing.Size(24, 24); + buttonToolStrip.Items.AddRange(new ToolStripItem[] { toolStripButtonOpen, lineToolStripSeparatorExtension1, toolStripButtonSearch, toolStripButtonFilter, lineToolStripSeparatorExtension2, toolStripButtonBookmark, toolStripButtonUp, toolStripButtonDown, lineToolStripSeparatorExtension3, toolStripButtonBubbles, lineToolStripSeparatorExtension4, toolStripButtonTail, lineToolStripSeparatorExtension5, groupsComboBoxHighlightGroups }); + buttonToolStrip.LayoutStyle = ToolStripLayoutStyle.Flow; + buttonToolStrip.Location = new System.Drawing.Point(3, 42); + buttonToolStrip.Name = "buttonToolStrip"; + buttonToolStrip.Size = new System.Drawing.Size(406, 31); + buttonToolStrip.TabIndex = 7; + // + // toolStripButtonOpen + // + toolStripButtonOpen.DisplayStyle = ToolStripItemDisplayStyle.Image; + toolStripButtonOpen.Image = LogExpert.Resources.Resources.File_open; + toolStripButtonOpen.ImageTransparentColor = System.Drawing.Color.Magenta; + toolStripButtonOpen.Name = "toolStripButtonOpen"; + toolStripButtonOpen.Size = new System.Drawing.Size(28, 28); + toolStripButtonOpen.Text = "Open File"; + toolStripButtonOpen.ToolTipText = "Open file"; + toolStripButtonOpen.Click += OnToolStripButtonOpenClick; + // + // lineToolStripSeparatorExtension1 + // + lineToolStripSeparatorExtension1.Name = "lineToolStripSeparatorExtension1"; + lineToolStripSeparatorExtension1.Size = new System.Drawing.Size(6, 23); + // + // toolStripButtonSearch + // + toolStripButtonSearch.DisplayStyle = ToolStripItemDisplayStyle.Image; + toolStripButtonSearch.Image = LogExpert.Resources.Resources.Search; + toolStripButtonSearch.ImageTransparentColor = System.Drawing.Color.Magenta; + toolStripButtonSearch.Name = "toolStripButtonSearch"; + toolStripButtonSearch.Size = new System.Drawing.Size(28, 28); + toolStripButtonSearch.Text = "Search"; + toolStripButtonSearch.ToolTipText = "Search"; + toolStripButtonSearch.Click += OnToolStripButtonSearchClick; + // + // toolStripButtonFilter + // + toolStripButtonFilter.DisplayStyle = ToolStripItemDisplayStyle.Image; + toolStripButtonFilter.Image = LogExpert.Resources.Resources.Filter; + toolStripButtonFilter.ImageTransparentColor = System.Drawing.Color.Magenta; + toolStripButtonFilter.Name = "toolStripButtonFilter"; + toolStripButtonFilter.Size = new System.Drawing.Size(28, 28); + toolStripButtonFilter.Text = "Filter"; + toolStripButtonFilter.ToolTipText = "Filter window"; + toolStripButtonFilter.Click += OnToolStripButtonFilterClick; + // + // lineToolStripSeparatorExtension2 + // + lineToolStripSeparatorExtension2.ForeColor = System.Drawing.SystemColors.ControlDarkDark; + lineToolStripSeparatorExtension2.Name = "lineToolStripSeparatorExtension2"; + lineToolStripSeparatorExtension2.Size = new System.Drawing.Size(6, 23); + // + // toolStripButtonBookmark + // + toolStripButtonBookmark.DisplayStyle = ToolStripItemDisplayStyle.Image; + toolStripButtonBookmark.Image = LogExpert.Resources.Resources.Bookmark_add; + toolStripButtonBookmark.ImageTransparentColor = System.Drawing.Color.Magenta; + toolStripButtonBookmark.Name = "toolStripButtonBookmark"; + toolStripButtonBookmark.Size = new System.Drawing.Size(28, 28); + toolStripButtonBookmark.Text = "Toggle Bookmark"; + toolStripButtonBookmark.ToolTipText = "Toggle bookmark"; + toolStripButtonBookmark.Click += OnToolStripButtonBookmarkClick; + // + // toolStripButtonUp + // + toolStripButtonUp.DisplayStyle = ToolStripItemDisplayStyle.Image; + toolStripButtonUp.Image = LogExpert.Resources.Resources.ArrowUp; + toolStripButtonUp.ImageTransparentColor = System.Drawing.Color.Magenta; + toolStripButtonUp.Name = "toolStripButtonUp"; + toolStripButtonUp.Size = new System.Drawing.Size(28, 28); + toolStripButtonUp.Text = "Previous Bookmark"; + toolStripButtonUp.ToolTipText = "Go to previous bookmark"; + toolStripButtonUp.Click += OnToolStripButtonUpClick; + // + // toolStripButtonDown + // + toolStripButtonDown.DisplayStyle = ToolStripItemDisplayStyle.Image; + toolStripButtonDown.Image = LogExpert.Resources.Resources.ArrowDown; + toolStripButtonDown.ImageTransparentColor = System.Drawing.Color.Magenta; + toolStripButtonDown.Name = "toolStripButtonDown"; + toolStripButtonDown.Size = new System.Drawing.Size(28, 28); + toolStripButtonDown.Text = "Next Bookmark"; + toolStripButtonDown.ToolTipText = "Go to next bookmark"; + toolStripButtonDown.Click += OnToolStripButtonDownClick; + // + // lineToolStripSeparatorExtension3 + // + lineToolStripSeparatorExtension3.Name = "lineToolStripSeparatorExtension3"; + lineToolStripSeparatorExtension3.Size = new System.Drawing.Size(6, 23); + // + // toolStripButtonBubbles + // + toolStripButtonBubbles.CheckOnClick = true; + toolStripButtonBubbles.DisplayStyle = ToolStripItemDisplayStyle.Image; + toolStripButtonBubbles.Image = LogExpert.Resources.Resources.bookmark_bubbles; + toolStripButtonBubbles.ImageAlign = System.Drawing.ContentAlignment.BottomCenter; + toolStripButtonBubbles.ImageTransparentColor = System.Drawing.Color.Magenta; + toolStripButtonBubbles.Name = "toolStripButtonBubbles"; + toolStripButtonBubbles.Size = new System.Drawing.Size(28, 28); + toolStripButtonBubbles.Text = "Show bookmark bubbles"; + toolStripButtonBubbles.Click += OnToolStripButtonBubblesClick; + // + // lineToolStripSeparatorExtension4 + // + lineToolStripSeparatorExtension4.Name = "lineToolStripSeparatorExtension4"; + lineToolStripSeparatorExtension4.Size = new System.Drawing.Size(6, 23); + // + // toolStripButtonTail + // + toolStripButtonTail.DisplayStyle = ToolStripItemDisplayStyle.Text; + toolStripButtonTail.Image = (System.Drawing.Image)resources.GetObject("toolStripButtonTail.Image"); + toolStripButtonTail.ImageTransparentColor = System.Drawing.Color.Magenta; + toolStripButtonTail.Name = "toolStripButtonTail"; + toolStripButtonTail.Size = new System.Drawing.Size(27, 19); + toolStripButtonTail.Text = "tail"; + // + // lineToolStripSeparatorExtension5 + // + lineToolStripSeparatorExtension5.Name = "lineToolStripSeparatorExtension5"; + lineToolStripSeparatorExtension5.Size = new System.Drawing.Size(6, 23); + // + // groupsComboBoxHighlightGroups + // + groupsComboBoxHighlightGroups.DropDownStyle = ComboBoxStyle.DropDownList; + groupsComboBoxHighlightGroups.DropDownWidth = 250; + groupsComboBoxHighlightGroups.FlatStyle = FlatStyle.Standard; + groupsComboBoxHighlightGroups.Name = "groupsComboBoxHighlightGroups"; + groupsComboBoxHighlightGroups.Size = new System.Drawing.Size(150, 23); + groupsComboBoxHighlightGroups.ToolTipText = "Select the current highlight settings for the log file (right-click to open highlight settings)"; + groupsComboBoxHighlightGroups.DropDownClosed += OnHighlightGroupsComboBoxDropDownClosed; + groupsComboBoxHighlightGroups.SelectedIndexChanged += OnHighlightGroupsComboBoxSelectedIndexChanged; + groupsComboBoxHighlightGroups.MouseUp += OnHighlightGroupsComboBoxMouseUp; + // + // checkBoxFollowTail + // + checkBoxFollowTail.AutoSize = true; + checkBoxFollowTail.Location = new System.Drawing.Point(663, 985); + checkBoxFollowTail.Margin = new Padding(4, 7, 4, 7); + checkBoxFollowTail.Name = "checkBoxFollowTail"; + checkBoxFollowTail.Size = new System.Drawing.Size(80, 19); + checkBoxFollowTail.TabIndex = 14; + checkBoxFollowTail.Text = "Follow tail"; + checkBoxFollowTail.UseVisualStyleBackColor = true; + checkBoxFollowTail.Click += OnFollowTailCheckBoxClick; + // + // tabContextMenuStrip + // + tabContextMenuStrip.ForeColor = System.Drawing.SystemColors.ControlText; + tabContextMenuStrip.ImageScalingSize = new System.Drawing.Size(24, 24); + tabContextMenuStrip.Items.AddRange(new ToolStripItem[] { closeThisTabToolStripMenuItem, closeOtherTabsToolStripMenuItem, closeAllTabsToolStripMenuItem, tabColorToolStripMenuItem, tabRenameToolStripMenuItem, copyPathToClipboardToolStripMenuItem, findInExplorerToolStripMenuItem }); + tabContextMenuStrip.Name = "tabContextMenuStrip"; + tabContextMenuStrip.Size = new System.Drawing.Size(197, 158); + // + // closeThisTabToolStripMenuItem + // + closeThisTabToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; + closeThisTabToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlText; + closeThisTabToolStripMenuItem.Name = "closeThisTabToolStripMenuItem"; + closeThisTabToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + closeThisTabToolStripMenuItem.Text = "Close this tab"; + closeThisTabToolStripMenuItem.Click += OnCloseThisTabToolStripMenuItemClick; + // + // closeOtherTabsToolStripMenuItem + // + closeOtherTabsToolStripMenuItem.Name = "closeOtherTabsToolStripMenuItem"; + closeOtherTabsToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + closeOtherTabsToolStripMenuItem.Text = "Close other tabs"; + closeOtherTabsToolStripMenuItem.ToolTipText = "Close all tabs except of this one"; + closeOtherTabsToolStripMenuItem.Click += OnCloseOtherTabsToolStripMenuItemClick; + // + // closeAllTabsToolStripMenuItem + // + closeAllTabsToolStripMenuItem.Name = "closeAllTabsToolStripMenuItem"; + closeAllTabsToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + closeAllTabsToolStripMenuItem.Text = "Close all tabs"; + closeAllTabsToolStripMenuItem.ToolTipText = "Close all tabs"; + closeAllTabsToolStripMenuItem.Click += OnCloseAllTabsToolStripMenuItemClick; + // + // tabColorToolStripMenuItem + // + tabColorToolStripMenuItem.Name = "tabColorToolStripMenuItem"; + tabColorToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + tabColorToolStripMenuItem.Text = "Tab color..."; + tabColorToolStripMenuItem.ToolTipText = "Sets the tab color"; + tabColorToolStripMenuItem.Click += OnTabColorToolStripMenuItemClick; + // + // tabRenameToolStripMenuItem + // + tabRenameToolStripMenuItem.Name = "tabRenameToolStripMenuItem"; + tabRenameToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + tabRenameToolStripMenuItem.Text = "Tab rename..."; + tabRenameToolStripMenuItem.ToolTipText = "Set the text which is shown on the tab"; + tabRenameToolStripMenuItem.Click += OnTabRenameToolStripMenuItemClick; + // + // copyPathToClipboardToolStripMenuItem + // + copyPathToClipboardToolStripMenuItem.Name = "copyPathToClipboardToolStripMenuItem"; + copyPathToClipboardToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + copyPathToClipboardToolStripMenuItem.Text = "Copy path to clipboard"; + copyPathToClipboardToolStripMenuItem.ToolTipText = "The complete file name (incl. path) is copied to clipboard"; + copyPathToClipboardToolStripMenuItem.Click += OnCopyPathToClipboardToolStripMenuItemClick; + // + // findInExplorerToolStripMenuItem + // + findInExplorerToolStripMenuItem.Name = "findInExplorerToolStripMenuItem"; + findInExplorerToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + findInExplorerToolStripMenuItem.Text = "Find in Explorer"; + findInExplorerToolStripMenuItem.ToolTipText = "Opens an Explorer window and selects the log file"; + findInExplorerToolStripMenuItem.Click += OnFindInExplorerToolStripMenuItemClick; + // + // dragControlDateTime + // + dragControlDateTime.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + dragControlDateTime.BackColor = System.Drawing.SystemColors.Control; + dragControlDateTime.DateTime = new System.DateTime(0L); + dragControlDateTime.DragOrientation = DragOrientationsEnum.Vertical; + dragControlDateTime.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0); + dragControlDateTime.ForeColor = System.Drawing.SystemColors.ControlDarkDark; + dragControlDateTime.HoverColor = System.Drawing.Color.LightGray; + dragControlDateTime.Location = new System.Drawing.Point(1017, 977); + dragControlDateTime.Margin = new Padding(0); + dragControlDateTime.MaxDateTime = new System.DateTime(9999, 12, 31, 23, 59, 59, 999); + dragControlDateTime.MinDateTime = new System.DateTime(0L); + dragControlDateTime.Name = "dragControlDateTime"; + dragControlDateTime.Size = new System.Drawing.Size(313, 38); + dragControlDateTime.TabIndex = 14; + dragControlDateTime.ValueChanged += OnDateTimeDragControlValueChanged; + dragControlDateTime.ValueDragged += OnDateTimeDragControlValueDragged; + // + // LogTabWindow + // + AllowDrop = true; + ClientSize = new System.Drawing.Size(1603, 1017); + Controls.Add(checkBoxFollowTail); + Controls.Add(dragControlDateTime); + Controls.Add(toolStripContainer); + Controls.Add(statusStrip); + DoubleBuffered = true; + Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon"); + KeyPreview = true; + MainMenuStrip = mainMenuStrip; + Margin = new Padding(4, 7, 4, 7); + Name = "LogTabWindow"; + Text = "LogExpert"; + Activated += OnLogTabWindowActivated; + Deactivate += OnLogTabWindowDeactivate; + SizeChanged += OnLogTabWindowSizeChanged; + DragDrop += OnLogWindowDragDrop; + DragEnter += OnLogTabWindowDragEnter; + DragOver += OnLogWindowDragOver; + KeyDown += OnLogTabWindowKeyDown; + statusStrip.ResumeLayout(false); + statusStrip.PerformLayout(); + mainMenuStrip.ResumeLayout(false); + mainMenuStrip.PerformLayout(); + toolStripContainer.ContentPanel.ResumeLayout(false); + toolStripContainer.TopToolStripPanel.ResumeLayout(false); + toolStripContainer.TopToolStripPanel.PerformLayout(); + toolStripContainer.ResumeLayout(false); + toolStripContainer.PerformLayout(); + buttonToolStrip.ResumeLayout(false); + buttonToolStrip.PerformLayout(); + tabContextMenuStrip.ResumeLayout(false); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private System.Windows.Forms.StatusStrip statusStrip; + private System.Windows.Forms.ToolStripStatusLabel labelLines; + private System.Windows.Forms.ToolStripStatusLabel labelSize; + private System.Windows.Forms.MenuStrip mainMenuStrip; + private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem viewNavigateToolStripMenuItem; + private System.Windows.Forms.ToolStripStatusLabel labelCurrentLine; + private System.Windows.Forms.ToolStripProgressBar loadProgessBar; + private System.Windows.Forms.ToolStripStatusLabel labelStatus; + private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; + private System.Windows.Forms.ToolStripContainer toolStripContainer; + private System.Windows.Forms.ToolStripMenuItem closeFileToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem multiFileToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem goToLineToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem searchToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem timeshiftToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem filterToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem copyMarkedLinesIntoNewTabToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem optionToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem hilightingToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem cellSelectModeToolStripMenuItem; + private System.Windows.Forms.ToolStripTextBox timeshiftMenuTextBox; + private System.Windows.Forms.ToolStripMenuItem alwaysOnTopToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem bookmarksToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toggleBookmarkToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem jumpToNextToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem jumpToPrevToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripEncodingMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripEncodingASCIIItem; + private System.Windows.Forms.ToolStripMenuItem toolStripEncodingANSIItem; + private System.Windows.Forms.ToolStripMenuItem toolStripEncodingUTF8Item; + private System.Windows.Forms.ToolStripMenuItem toolStripEncodingUTF16Item; + private System.Windows.Forms.ToolStripMenuItem reloadToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem columnizerToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem; + private DateTimeDragControl dragControlDateTime; + private System.Windows.Forms.ToolStripMenuItem showBookmarkListToolStripMenuItem; + private System.Windows.Forms.ToolStrip buttonToolStrip; + private System.Windows.Forms.ToolStripButton toolStripButtonOpen; + private System.Windows.Forms.ToolStripButton toolStripButtonSearch; + private System.Windows.Forms.ToolStripButton toolStripButtonFilter; + private System.Windows.Forms.ToolStripButton toolStripButtonBookmark; + private System.Windows.Forms.ToolStripButton toolStripButtonUp; + private System.Windows.Forms.ToolStripButton toolStripButtonDown; + private CheckBox host; + private CheckBox checkBoxFollowTail; + private ToolStripButton toolStripButtonTail; + private ToolStripMenuItem showHelpToolStripMenuItem; + private ToolStripMenuItem hideLineColumnToolStripMenuItem; + private ToolStripMenuItem lastUsedToolStripMenuItem; + private ContextMenuStrip tabContextMenuStrip; + private ToolStripMenuItem closeThisTabToolStripMenuItem; + private ToolStripMenuItem closeOtherTabsToolStripMenuItem; + private ToolStripMenuItem closeAllTabsToolStripMenuItem; + private ToolStripMenuItem tabColorToolStripMenuItem; + private ToolStripMenuItem loadProjectToolStripMenuItem; + private ToolStripMenuItem saveProjectToolStripMenuItem; + private ToolStripButton toolStripButtonBubbles; + private ToolStripMenuItem copyPathToClipboardToolStripMenuItem; + private ToolStripMenuItem findInExplorerToolStripMenuItem; + private ToolStripMenuItem exportBookmarksToolStripMenuItem; + private ToolStripComboBox groupsComboBoxHighlightGroups; + private ToolStripMenuItem debugToolStripMenuItem; + private ToolStripMenuItem dumpLogBufferInfoToolStripMenuItem; + private ToolStripMenuItem dumpBufferDiagnosticToolStripMenuItem; + private ToolStripMenuItem runGCToolStripMenuItem; + private ToolStripMenuItem gCInfoToolStripMenuItem; + private ToolStrip externalToolsToolStrip; + private ToolStripMenuItem toolsToolStripMenuItem; + private ToolStripMenuItem configureToolStripMenuItem; + private ToolStripMenuItem throwExceptionGUIThreadToolStripMenuItem; + private ToolStripMenuItem throwExceptionbackgroundThToolStripMenuItem; + private ToolStripMenuItem throwExceptionBackgroundThreadToolStripMenuItem; + private ToolStripMenuItem loglevelToolStripMenuItem; + private ToolStripMenuItem warnToolStripMenuItem; + private ToolStripMenuItem infoToolStripMenuItem; + private ToolStripMenuItem debugToolStripMenuItem1; + private ToolStripMenuItem disableWordHighlightModeToolStripMenuItem; + private ToolStripMenuItem multifileMaskToolStripMenuItem; + private ToolStripMenuItem multiFileEnabledStripMenuItem; + private ToolStripMenuItem toolStripEncodingISO88591Item; + private ToolStripMenuItem lockInstanceToolStripMenuItem; + private ToolStripMenuItem newFromClipboardToolStripMenuItem; + private ToolStripMenuItem openURIToolStripMenuItem; + private ToolStripMenuItem columnFinderToolStripMenuItem; + private DockPanel dockPanel; + private ToolStripMenuItem tabRenameToolStripMenuItem; + private LineToolStripSeparatorExtension lineToolStripSeparatorExtension1; + private LineToolStripSeparatorExtension lineToolStripSeparatorExtension2; + private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension1; + private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension2; + private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension3; + private LineToolStripSeparatorExtension lineToolStripSeparatorExtension3; + private LineToolStripSeparatorExtension lineToolStripSeparatorExtension4; + private LineToolStripSeparatorExtension lineToolStripSeparatorExtension5; + private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension5; + private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension6; + private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension4; + private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension7; + private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension9; + private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension8; + private MenuToolStripSeparatorExtension configureToolStripSeparator; + private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension11; + } +} + diff --git a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.resx b/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindow.resx similarity index 98% rename from src/LogExpert/Controls/LogTabWindow/LogTabWindow.resx rename to src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindow.resx index ff6cd4c1..1b6f6b7d 100644 --- a/src/LogExpert/Controls/LogTabWindow/LogTabWindow.resx +++ b/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindow.resx @@ -1,164 +1,164 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 133, 17 - - - 522, 17 - - - 417, 17 - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIFSURBVDhPpZLtS1NhGMbPPxJmmlYSgqHiKzGU1EDxg4iK - YKyG2WBogqMYJQOtCEVRFBGdTBCJfRnkS4VaaWNT5sqx1BUxRXxDHYxAJLvkusEeBaPAB+5z4Jzn+t3X - /aLhnEfjo8m+dCoa+7/C3O2Hqe0zDC+8KG+cRZHZhdzaaWTVTCLDMIY0vfM04Nfh77/G/sEhwpEDbO3t - I7TxE8urEVy99fT/AL5gWDLrTB/hnF4XsW0khCu5ln8DmJliT2AXrcNBsU1gj/MH4nMeKwBrPktM28xM - cX79DFKrHHD5d9D26hvicx4pABt2lpg10zYzU0zr7+e3xXGcrkEB2O2TNec9nJFwB3alZn5jZorfeDZh - 6Q3g8s06BeCoKF4MRURoH1+BY2oNCbeb0TIclIYxOhzf8frTOuo7FxCbbVIAzpni0iceEc8vhzEwGkJD - lx83ymxifejdKjRNk/8PWnyIyTQqAJek0jqHwfEVscu31baIu8+90sTE4nY025dQ2/5FIPpnXlzKuK8A - HBUzHot52djqQ6HZhfR7IwK4mKpHtvEDMqvfCiQ6zaAAXM8x94aIWTNrLLG4kVUzgaTSPlzLtyJOZxbb - 1wtfyg4Q+AfA3aZlButjSfxGcUJBk4g5tuP3haQKRKXcUQDOmbvNTpPOJeFFjordZmbWTNvMTHFUcpUC - nOccAdABIDXXE1nzAAAAAElFTkSuQmCC - - - - 248, 17 - - - 49 - - - - AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA - AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// - AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// - //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA - AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAIABAAD//wAA - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 133, 17 + + + 522, 17 + + + 417, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIFSURBVDhPpZLtS1NhGMbPPxJmmlYSgqHiKzGU1EDxg4iK + YKyG2WBogqMYJQOtCEVRFBGdTBCJfRnkS4VaaWNT5sqx1BUxRXxDHYxAJLvkusEeBaPAB+5z4Jzn+t3X + /aLhnEfjo8m+dCoa+7/C3O2Hqe0zDC+8KG+cRZHZhdzaaWTVTCLDMIY0vfM04Nfh77/G/sEhwpEDbO3t + I7TxE8urEVy99fT/AL5gWDLrTB/hnF4XsW0khCu5ln8DmJliT2AXrcNBsU1gj/MH4nMeKwBrPktM28xM + cX79DFKrHHD5d9D26hvicx4pABt2lpg10zYzU0zr7+e3xXGcrkEB2O2TNec9nJFwB3alZn5jZorfeDZh + 6Q3g8s06BeCoKF4MRURoH1+BY2oNCbeb0TIclIYxOhzf8frTOuo7FxCbbVIAzpni0iceEc8vhzEwGkJD + lx83ymxifejdKjRNk/8PWnyIyTQqAJek0jqHwfEVscu31baIu8+90sTE4nY025dQ2/5FIPpnXlzKuK8A + HBUzHot52djqQ6HZhfR7IwK4mKpHtvEDMqvfCiQ6zaAAXM8x94aIWTNrLLG4kVUzgaTSPlzLtyJOZxbb + 1wtfyg4Q+AfA3aZlButjSfxGcUJBk4g5tuP3haQKRKXcUQDOmbvNTpPOJeFFjordZmbWTNvMTHFUcpUC + nOccAdABIDXXE1nzAAAAAElFTkSuQmCC + + + + 248, 17 + + + 49 + + + + AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// + //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA + AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAIABAAD//wAA + + \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs new file mode 100644 index 00000000..5da464b5 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs @@ -0,0 +1,1015 @@ +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Persister; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.EventArguments; +using LogExpert.Dialogs; +using LogExpert.UI.Dialogs; +using System.ComponentModel; +using System.Diagnostics; +using System.Text; +using WeifenLuo.WinFormsUI.Docking; + +namespace LogExpert.UI.Controls.LogTabWindow; +partial class LogTabWindow +{ + #region Events handler + + private void OnBookmarkWindowVisibleChanged(object sender, EventArgs e) + { + _firstBookmarkWindowShow = false; + } + + private void OnLogTabWindowLoad(object sender, EventArgs e) + { + ApplySettings(ConfigManager.Settings, SettingsFlags.All); + if (ConfigManager.Settings.isMaximized) + { + Bounds = ConfigManager.Settings.appBoundsFullscreen; + WindowState = FormWindowState.Maximized; + Bounds = ConfigManager.Settings.appBounds; + } + else + { + if (ConfigManager.Settings.appBounds.Right > 0) + { + Bounds = ConfigManager.Settings.appBounds; + } + } + + if (ConfigManager.Settings.Preferences.openLastFiles && _startupFileNames == null) + { + List tmpList = ObjectClone.Clone(ConfigManager.Settings.lastOpenFilesList); + + foreach (string name in tmpList) + { + if (string.IsNullOrEmpty(name) == false) + { + AddFileTab(name, false, null, false, null); + } + } + } + if (_startupFileNames != null) + { + LoadFiles(_startupFileNames, false); + } + _ledThread = new Thread(LedThreadProc); + _ledThread.IsBackground = true; + _ledThread.Start(); + + FillHighlightComboBox(); + FillToolLauncherBar(); +#if !DEBUG + debugToolStripMenuItem.Visible = false; +#endif + } + + private void OnLogTabWindowClosing(object sender, CancelEventArgs e) + { + try + { + _shouldStop = true; + _statusLineEventHandle.Set(); + _statusLineEventWakeupHandle.Set(); + _ledThread.Join(); + + IList deleteLogWindowList = new List(); + ConfigManager.Settings.alwaysOnTop = TopMost && ConfigManager.Settings.Preferences.allowOnlyOneInstance; + SaveLastOpenFilesList(); + + foreach (LogWindow.LogWindow logWindow in _logWindowList) + { + deleteLogWindowList.Add(logWindow); + } + + foreach (LogWindow.LogWindow logWindow in deleteLogWindowList) + { + RemoveAndDisposeLogWindow(logWindow, true); + } + + DestroyBookmarkWindow(); + + ConfigManager.Instance.ConfigChanged -= OnConfigChanged; + + SaveWindowPosition(); + ConfigManager.Save(SettingsFlags.WindowPosition | SettingsFlags.FileHistory); + } + catch (Exception) + { + // ignore error (can occur then multipe instances are closed simultaneously or if the + // window was not constructed completely because of errors) + } + finally + { + LogExpertProxy?.WindowClosed(this); + } + } + + private void OnStripMouseUp(object sender, MouseEventArgs e) + { + if (sender is ToolStripDropDown dropDown) + { + AddFileTab(dropDown.Text, false, null, false, null); + } + } + + private void OnHistoryItemClicked(object sender, ToolStripItemClickedEventArgs e) + { + if (string.IsNullOrEmpty(e.ClickedItem.Text) == false) + { + AddFileTab(e.ClickedItem.Text, false, null, false, null); + } + } + + private void OnLogWindowDisposed(object sender, EventArgs e) + { + LogWindow.LogWindow logWindow = sender as LogWindow.LogWindow; + + if (sender == CurrentLogWindow) + { + ChangeCurrentLogWindow(null); + } + + RemoveLogWindow(logWindow); + + logWindow.Tag = null; + } + + private void OnExitToolStripMenuItemClick(object sender, EventArgs e) + { + Close(); + } + + private void OnSelectFilterToolStripMenuItemClick(object sender, EventArgs e) + { + if (CurrentLogWindow == null) + { + return; + } + + CurrentLogWindow.ColumnizerCallbackObject.LineNum = CurrentLogWindow.GetCurrentLineNum(); + FilterSelectorForm form = new(PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers, CurrentLogWindow.CurrentColumnizer, CurrentLogWindow.ColumnizerCallbackObject, ConfigManager); + form.Owner = this; + form.TopMost = TopMost; + DialogResult res = form.ShowDialog(); + + if (res == DialogResult.OK) + { + if (form.ApplyToAll) + { + lock (_logWindowList) + { + foreach (LogWindow.LogWindow logWindow in _logWindowList) + { + if (logWindow.CurrentColumnizer.GetType() != form.SelectedColumnizer.GetType()) + { + //logWindow.SetColumnizer(form.SelectedColumnizer); + SetColumnizerFx fx = logWindow.ForceColumnizer; + logWindow.Invoke(fx, form.SelectedColumnizer); + SetColumnizerHistoryEntry(logWindow.FileName, form.SelectedColumnizer); + } + else + { + if (form.IsConfigPressed) + { + logWindow.ColumnizerConfigChanged(); + } + } + } + } + } + else + { + if (CurrentLogWindow.CurrentColumnizer.GetType() != form.SelectedColumnizer.GetType()) + { + SetColumnizerFx fx = CurrentLogWindow.ForceColumnizer; + CurrentLogWindow.Invoke(fx, form.SelectedColumnizer); + SetColumnizerHistoryEntry(CurrentLogWindow.FileName, form.SelectedColumnizer); + } + + if (form.IsConfigPressed) + { + lock (_logWindowList) + { + foreach (LogWindow.LogWindow logWindow in _logWindowList) + { + if (logWindow.CurrentColumnizer.GetType() == form.SelectedColumnizer.GetType()) + { + logWindow.ColumnizerConfigChanged(); + } + } + } + } + } + } + } + + private void OnGoToLineToolStripMenuItemClick(object sender, EventArgs e) + { + if (CurrentLogWindow == null) + { + return; + } + + GotoLineDialog dlg = new(this); + DialogResult res = dlg.ShowDialog(); + if (res == DialogResult.OK) + { + int line = dlg.Line - 1; + if (line >= 0) + { + CurrentLogWindow.GotoLine(line); + } + } + } + + private void OnHighlightingToolStripMenuItemClick(object sender, EventArgs e) + { + ShowHighlightSettingsDialog(); + } + + private void OnSearchToolStripMenuItemClick(object sender, EventArgs e) + { + OpenSearchDialog(); + } + + private void OnOpenToolStripMenuItemClick(object sender, EventArgs e) + { + OpenFileDialog(); + } + + private void OnLogTabWindowDragEnter(object sender, DragEventArgs e) + { +#if DEBUG + string[] formats = e.Data.GetFormats(); + string s = "Dragging something over LogExpert. Formats: "; + foreach (string format in formats) + { + s += format; + s += " , "; + } + s = s.Substring(0, s.Length - 3); + _logger.Info(s); +#endif + } + + private void OnLogWindowDragOver(object sender, DragEventArgs e) + { + if (!e.Data.GetDataPresent(DataFormats.FileDrop)) + { + e.Effect = DragDropEffects.None; + } + else + { + e.Effect = DragDropEffects.Copy; + } + } + + private void OnLogWindowDragDrop(object sender, DragEventArgs e) + { +#if DEBUG + string[] formats = e.Data.GetFormats(); + string s = "Dropped formats: "; + foreach (string format in formats) + { + s += format; + s += " , "; + } + s = s[..^3]; + _logger.Debug(s); +#endif + + if (e.Data.GetDataPresent(DataFormats.FileDrop)) + { + object o = e.Data.GetData(DataFormats.FileDrop); + if (o is string[] names) + { + LoadFiles(names, (e.KeyState & 4) == 4); // (shift pressed?) + e.Effect = DragDropEffects.Copy; + } + } + } + + private void OnTimeShiftToolStripMenuItemCheckStateChanged(object sender, EventArgs e) + { + if (!_skipEvents && CurrentLogWindow != null) + { + CurrentLogWindow.SetTimeshiftValue(timeshiftMenuTextBox.Text); + timeshiftMenuTextBox.Enabled = timeshiftToolStripMenuItem.Checked; + CurrentLogWindow.TimeshiftEnabled(timeshiftToolStripMenuItem.Checked, + timeshiftMenuTextBox.Text); + } + } + + private void OnAboutToolStripMenuItemClick(object sender, EventArgs e) + { + AboutBox aboutBox = new(); + aboutBox.TopMost = TopMost; + aboutBox.ShowDialog(); + } + + private void OnFilterToolStripMenuItemClick(object sender, EventArgs e) + { + CurrentLogWindow?.ToggleFilterPanel(); + } + + private void OnMultiFileToolStripMenuItemClick(object sender, EventArgs e) + { + ToggleMultiFile(); + fileToolStripMenuItem.HideDropDown(); + } + + private void OnGuiStateUpdate(object sender, GuiStateArgs e) + { + BeginInvoke(GuiStateUpdateWorker, e); + } + + private void OnColumnizerChanged(object sender, ColumnizerEventArgs e) + { + _bookmarkWindow?.SetColumnizer(e.Columnizer); + } + + private void OnBookmarkAdded(object sender, EventArgs e) + { + _bookmarkWindow.UpdateView(); + } + + private void OnBookmarkTextChanged(object sender, BookmarkEventArgs e) + { + _bookmarkWindow.BookmarkTextChanged(e.Bookmark); + } + + private void OnBookmarkRemoved(object sender, EventArgs e) + { + _bookmarkWindow.UpdateView(); + } + + private void OnProgressBarUpdate(object sender, ProgressEventArgs e) + { + Invoke(ProgressBarUpdateWorker, e); + } + + private void OnStatusLineEvent(object sender, StatusLineEventArgs e) + { + StatusLineEventWorker(e); + } + + private void OnFollowTailCheckBoxClick(object sender, EventArgs e) + { + CurrentLogWindow?.FollowTailChanged(checkBoxFollowTail.Checked, false); + } + + private void OnLogTabWindowKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.W && e.Control) + { + CurrentLogWindow?.Close(); + } + else if (e.KeyCode == Keys.Tab && e.Control) + { + SwitchTab(e.Shift); + } + else + { + CurrentLogWindow?.OnLogWindowKeyDown(sender, e); + } + } + + private void OnCloseFileToolStripMenuItemClick(object sender, EventArgs e) + { + CurrentLogWindow?.Close(); + } + + private void OnCellSelectModeToolStripMenuItemClick(object sender, EventArgs e) + { + CurrentLogWindow?.SetCellSelectionMode(cellSelectModeToolStripMenuItem.Checked); + } + + private void OnCopyMarkedLinesIntoNewTabToolStripMenuItemClick(object sender, EventArgs e) + { + CurrentLogWindow?.CopyMarkedLinesToTab(); + } + + private void OnTimeShiftMenuTextBoxKeyDown(object sender, KeyEventArgs e) + { + if (CurrentLogWindow == null) + { + return; + } + + if (e.KeyCode == Keys.Enter) + { + e.Handled = true; + CurrentLogWindow.SetTimeshiftValue(timeshiftMenuTextBox.Text); + } + } + + private void OnAlwaysOnTopToolStripMenuItemClick(object sender, EventArgs e) + { + TopMost = alwaysOnTopToolStripMenuItem.Checked; + } + + private void OnFileSizeChanged(object sender, LogEventArgs e) + { + if (sender.GetType().IsAssignableFrom(typeof(LogWindow.LogWindow))) + { + int diff = e.LineCount - e.PrevLineCount; + if (diff < 0) + { + return; + } + + if (((LogWindow.LogWindow)sender).Tag is LogWindowData data) + { + lock (data) + { + data.diffSum += diff; + if (data.diffSum > DIFF_MAX) + { + data.diffSum = DIFF_MAX; + } + } + + //if (this.dockPanel.ActiveContent != null && + // this.dockPanel.ActiveContent != sender || data.tailState != 0) + if (CurrentLogWindow != null && + CurrentLogWindow != sender || data.tailState != 0) + { + data.dirty = true; + } + Icon icon = GetIcon(diff, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); + } + } + } + + private void OnLogWindowFileNotFound(object sender, EventArgs e) + { + Invoke(new FileNotFoundDelegate(FileNotFound), sender); + } + + private void OnLogWindowFileRespawned(object sender, EventArgs e) + { + Invoke(new FileRespawnedDelegate(FileRespawned), sender); + } + + private void OnLogWindowFilterListChanged(object sender, FilterListChangedEventArgs e) + { + lock (_logWindowList) + { + foreach (LogWindow.LogWindow logWindow in _logWindowList) + { + if (logWindow != e.LogWindow) + { + logWindow.HandleChangedFilterList(); + } + } + } + ConfigManager.Save(SettingsFlags.FilterList); + } + + private void OnLogWindowCurrentHighlightGroupChanged(object sender, CurrentHighlightGroupChangedEventArgs e) + { + OnHighlightSettingsChanged(); + ConfigManager.Settings.Preferences.HighlightGroupList = HighlightGroupList; + ConfigManager.Save(SettingsFlags.HighlightSettings); + } + + private void OnTailFollowed(object sender, EventArgs e) + { + if (dockPanel.ActiveContent == null) + { + return; + } + if (sender.GetType().IsAssignableFrom(typeof(LogWindow.LogWindow))) + { + if (dockPanel.ActiveContent == sender) + { + LogWindowData data = ((LogWindow.LogWindow)sender).Tag as LogWindowData; + data.dirty = false; + Icon icon = GetIcon(data.diffSum, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); + } + } + } + + private void OnLogWindowSyncModeChanged(object sender, SyncModeEventArgs e) + { + if (!Disposing) + { + LogWindowData data = ((LogWindow.LogWindow)sender).Tag as LogWindowData; + data.syncMode = e.IsTimeSynced ? 1 : 0; + Icon icon = GetIcon(data.diffSum, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); + } + else + { + _logger.Warn("Received SyncModeChanged event while disposing. Event ignored."); + } + } + + private void OnToggleBookmarkToolStripMenuItemClick(object sender, EventArgs e) + { + CurrentLogWindow?.ToggleBookmark(); + } + + private void OnJumpToNextToolStripMenuItemClick(object sender, EventArgs e) + { + CurrentLogWindow?.JumpNextBookmark(); + } + + private void OnJumpToPrevToolStripMenuItemClick(object sender, EventArgs e) + { + CurrentLogWindow?.JumpPrevBookmark(); + } + + private void OnASCIIToolStripMenuItemClick(object sender, EventArgs e) + { + CurrentLogWindow?.ChangeEncoding(Encoding.ASCII); + } + + private void OnANSIToolStripMenuItemClick(object sender, EventArgs e) + { + CurrentLogWindow?.ChangeEncoding(Encoding.Default); + } + + private void OnUTF8ToolStripMenuItemClick(object sender, EventArgs e) + { + CurrentLogWindow?.ChangeEncoding(new UTF8Encoding(false)); + } + + private void OnUTF16ToolStripMenuItemClick(object sender, EventArgs e) + { + CurrentLogWindow?.ChangeEncoding(Encoding.Unicode); + } + + private void OnISO88591ToolStripMenuItemClick(object sender, EventArgs e) + { + CurrentLogWindow?.ChangeEncoding(Encoding.GetEncoding("iso-8859-1")); + } + + private void OnReloadToolStripMenuItemClick(object sender, EventArgs e) + { + if (CurrentLogWindow != null) + { + LogWindowData data = CurrentLogWindow.Tag as LogWindowData; + Icon icon = GetIcon(0, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), CurrentLogWindow, icon); + CurrentLogWindow.Reload(); + } + } + + private void OnSettingsToolStripMenuItemClick(object sender, EventArgs e) + { + OpenSettings(0); + } + + private void OnDateTimeDragControlValueDragged(object sender, EventArgs e) + { + if (CurrentLogWindow != null) + { + //this.CurrentLogWindow.ScrollToTimestamp(this.dateTimeDragControl.DateTime); + } + } + + private void OnDateTimeDragControlValueChanged(object sender, EventArgs e) + { + CurrentLogWindow?.ScrollToTimestamp(dragControlDateTime.DateTime, true, true); + } + + private void OnLogTabWindowDeactivate(object sender, EventArgs e) + { + CurrentLogWindow?.AppFocusLost(); + } + + private void OnLogTabWindowActivated(object sender, EventArgs e) + { + CurrentLogWindow?.AppFocusGained(); + } + + private void OnShowBookmarkListToolStripMenuItemClick(object sender, EventArgs e) + { + if (_bookmarkWindow.Visible) + { + _bookmarkWindow.Hide(); + } + else + { + // strange: on very first Show() now bookmarks are displayed. after a hide it will work. + if (_firstBookmarkWindowShow) + { + _bookmarkWindow.Show(dockPanel); + _bookmarkWindow.Hide(); + } + + _bookmarkWindow.Show(dockPanel); + } + } + + private void OnToolStripButtonOpenClick(object sender, EventArgs e) + { + OpenFileDialog(); + } + + private void OnToolStripButtonSearchClick(object sender, EventArgs e) + { + OpenSearchDialog(); + } + + private void OnToolStripButtonFilterClick(object sender, EventArgs e) + { + CurrentLogWindow?.ToggleFilterPanel(); + } + + private void OnToolStripButtonBookmarkClick(object sender, EventArgs e) + { + CurrentLogWindow?.ToggleBookmark(); + } + + private void OnToolStripButtonUpClick(object sender, EventArgs e) + { + CurrentLogWindow?.JumpPrevBookmark(); + } + + private void OnToolStripButtonDownClick(object sender, EventArgs e) + { + CurrentLogWindow?.JumpNextBookmark(); + } + + private void OnShowHelpToolStripMenuItemClick(object sender, EventArgs e) + { + Help.ShowHelp(this, "LogExpert.chm"); + } + + private void OnHideLineColumnToolStripMenuItemClick(object sender, EventArgs e) + { + ConfigManager.Settings.hideLineColumn = hideLineColumnToolStripMenuItem.Checked; + lock (_logWindowList) + { + foreach (LogWindow.LogWindow logWin in _logWindowList) + { + logWin.ShowLineColumn(!ConfigManager.Settings.hideLineColumn); + } + } + _bookmarkWindow.LineColumnVisible = ConfigManager.Settings.hideLineColumn; + } + + // ================================================================== + // Tab context menu stuff + // ================================================================== + + private void OnCloseThisTabToolStripMenuItemClick(object sender, EventArgs e) + { + (dockPanel.ActiveContent as LogWindow.LogWindow).Close(); + } + + private void OnCloseOtherTabsToolStripMenuItemClick(object sender, EventArgs e) + { + IList closeList = new List(); + lock (_logWindowList) + { + foreach (DockContent content in dockPanel.Contents) + { + if (content != dockPanel.ActiveContent && content is LogWindow.LogWindow) + { + closeList.Add(content as Form); + } + } + } + foreach (Form form in closeList) + { + form.Close(); + } + } + + private void OnCloseAllTabsToolStripMenuItemClick(object sender, EventArgs e) + { + CloseAllTabs(); + } + + private void OnTabColorToolStripMenuItemClick(object sender, EventArgs e) + { + LogWindow.LogWindow logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; + + LogWindowData data = logWindow.Tag as LogWindowData; + + if (data == null) + { + return; + } + + ColorDialog dlg = new(); + dlg.Color = data.color; + if (dlg.ShowDialog() == DialogResult.OK) + { + data.color = dlg.Color; + SetTabColor(logWindow, data.color); + } + List delList = []; + + foreach (ColorEntry entry in ConfigManager.Settings.fileColors) + { + if (entry.FileName.ToLower().Equals(logWindow.FileName.ToLower())) + { + delList.Add(entry); + } + } + + foreach (ColorEntry entry in delList) + { + ConfigManager.Settings.fileColors.Remove(entry); + } + ConfigManager.Settings.fileColors.Add(new ColorEntry(logWindow.FileName, dlg.Color)); + + while (ConfigManager.Settings.fileColors.Count > MAX_COLOR_HISTORY) + { + ConfigManager.Settings.fileColors.RemoveAt(0); + } + } + + private void OnLogTabWindowSizeChanged(object sender, EventArgs e) + { + if (WindowState != FormWindowState.Minimized) + { + _wasMaximized = WindowState == FormWindowState.Maximized; + } + } + + private void OnSaveProjectToolStripMenuItemClick(object sender, EventArgs e) + { + SaveFileDialog dlg = new(); + dlg.DefaultExt = "lxj"; + dlg.Filter = @"LogExpert session (*.lxj)|*.lxj"; + + if (dlg.ShowDialog() == DialogResult.OK) + { + string fileName = dlg.FileName; + List fileNames = []; + + lock (_logWindowList) + { + foreach (DockContent content in dockPanel.Contents) + { + LogWindow.LogWindow logWindow = content as LogWindow.LogWindow; + string persistenceFileName = logWindow?.SavePersistenceData(true); + if (persistenceFileName != null) + { + fileNames.Add(persistenceFileName); + } + } + } + + ProjectData projectData = new(); + projectData.memberList = fileNames; + projectData.tabLayoutXml = SaveLayout(); + ProjectPersister.SaveProjectData(fileName, projectData); + } + } + + private void OnLoadProjectToolStripMenuItemClick(object sender, EventArgs e) + { + OpenFileDialog dlg = new(); + dlg.DefaultExt = "lxj"; + dlg.Filter = @"LogExpert sessions (*.lxj)|*.lxj"; + + if (dlg.ShowDialog() == DialogResult.OK) + { + string projectFileName = dlg.FileName; + LoadProject(projectFileName, true); + } + } + + private void OnToolStripButtonBubblesClick(object sender, EventArgs e) + { + if (CurrentLogWindow != null) + { + CurrentLogWindow.ShowBookmarkBubbles = toolStripButtonBubbles.Checked; + } + } + + private void OnCopyPathToClipboardToolStripMenuItemClick(object sender, EventArgs e) + { + LogWindow.LogWindow logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; + Clipboard.SetText(logWindow.Title); + } + + private void OnFindInExplorerToolStripMenuItemClick(object sender, EventArgs e) + { + LogWindow.LogWindow logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; + + Process explorer = new(); + explorer.StartInfo.FileName = "explorer.exe"; + explorer.StartInfo.Arguments = "/e,/select," + logWindow.Title; + explorer.StartInfo.UseShellExecute = false; + explorer.Start(); + } + + private void OnExportBookmarksToolStripMenuItemClick(object sender, EventArgs e) + { + CurrentLogWindow?.ExportBookmarkList(); + } + + private void OnHighlightGroupsComboBoxDropDownClosed(object sender, EventArgs e) + { + ApplySelectedHighlightGroup(); + } + + private void OnHighlightGroupsComboBoxSelectedIndexChanged(object sender, EventArgs e) + { + ApplySelectedHighlightGroup(); + } + + private void OnHighlightGroupsComboBoxMouseUp(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + ShowHighlightSettingsDialog(); + } + } + + + private void OnConfigChanged(object sender, ConfigChangedEventArgs e) + { + if (LogExpertProxy != null) + { + NotifySettingsChanged(null, e.Flags); + } + } + + private void OnDumpLogBufferInfoToolStripMenuItemClick(object sender, EventArgs e) + { +#if DEBUG + CurrentLogWindow?.DumpBufferInfo(); +#endif + } + + private void OnDumpBufferDiagnosticToolStripMenuItemClick(object sender, EventArgs e) + { +#if DEBUG + CurrentLogWindow?.DumpBufferDiagnostic(); +#endif + } + + private void OnRunGCToolStripMenuItemClick(object sender, EventArgs e) + { + RunGC(); + } + + private void OnGCInfoToolStripMenuItemClick(object sender, EventArgs e) + { + DumpGCInfo(); + } + + private void OnToolsToolStripMenuItemDropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) + { + if (e.ClickedItem.Tag is ToolEntry tag) + { + ToolButtonClick(tag); + } + } + + private void OnExternalToolsToolStripItemClicked(object sender, ToolStripItemClickedEventArgs e) + { + ToolButtonClick(e.ClickedItem.Tag as ToolEntry); + } + + private void OnConfigureToolStripMenuItemClick(object sender, EventArgs e) + { + OpenSettings(2); + } + + private void OnThrowExceptionGUIThreadToolStripMenuItemClick(object sender, EventArgs e) + { + throw new Exception("This is a test exception thrown by the GUI thread"); + } + + private void OnThrowExceptionBackgroundThToolStripMenuItemClick(object sender, EventArgs e) + { + ExceptionFx fx = ThrowExceptionFx; + fx.BeginInvoke(null, null); + } + + private void OnThrowExceptionBackgroundThreadToolStripMenuItemClick(object sender, EventArgs e) + { + Thread thread = new(ThrowExceptionThreadFx); + thread.IsBackground = true; + thread.Start(); + } + + private void OnWarnToolStripMenuItemClick(object sender, EventArgs e) + { + //_logger.GetLogger().LogLevel = _logger.Level.WARN; + } + + private void OnInfoToolStripMenuItemClick(object sender, EventArgs e) + { + //_logger.Get_logger().LogLevel = _logger.Level.INFO; + } + + private void OnDebugToolStripMenuItemClick(object sender, EventArgs e) + { + //_logger.Get_logger().LogLevel = _logger.Level.DEBUG; + } + + private void OnLogLevelToolStripMenuItemClick(object sender, EventArgs e) + { + } + + private void OnLogLevelToolStripMenuItemDropDownOpening(object sender, EventArgs e) + { + //warnToolStripMenuItem.Checked = _logger.Get_logger().LogLevel == _logger.Level.WARN; + //infoToolStripMenuItem.Checked = _logger.Get_logger().LogLevel == _logger.Level.INFO; + //debugToolStripMenuItem1.Checked = _logger.Get_logger().LogLevel == _logger.Level.DEBUG; + } + + private void OnDisableWordHighlightModeToolStripMenuItemClick(object sender, EventArgs e) + { + DebugOptions.DisableWordHighlight = disableWordHighlightModeToolStripMenuItem.Checked; + CurrentLogWindow?.RefreshAllGrids(); + } + + private void OnMultiFileMaskToolStripMenuItemClick(object sender, EventArgs e) + { + CurrentLogWindow?.ChangeMultifileMask(); + } + + private void OnMultiFileEnabledStripMenuItemClick(object sender, EventArgs e) + { + ToggleMultiFile(); + } + + private void OnLockInstanceToolStripMenuItemClick(object sender, EventArgs e) + { + AbstractLogTabWindow.StaticData.CurrentLockedMainWindow = lockInstanceToolStripMenuItem.Checked ? null : this; + } + + private void OnOptionToolStripMenuItemDropDownOpening(object sender, EventArgs e) + { + lockInstanceToolStripMenuItem.Enabled = !ConfigManager.Settings.Preferences.allowOnlyOneInstance; + lockInstanceToolStripMenuItem.Checked = AbstractLogTabWindow.StaticData.CurrentLockedMainWindow == this; + } + + private void OnFileToolStripMenuItemDropDownOpening(object sender, EventArgs e) + { + newFromClipboardToolStripMenuItem.Enabled = Clipboard.ContainsText(); + } + + private void OnNewFromClipboardToolStripMenuItemClick(object sender, EventArgs e) + { + PasteFromClipboard(); + } + + private void OnOpenURIToolStripMenuItemClick(object sender, EventArgs e) + { + OpenUriDialog dlg = new() + { + UriHistory = ConfigManager.Settings.uriHistoryList + }; + + if (DialogResult.OK == dlg.ShowDialog()) + { + if (dlg.Uri.Trim().Length > 0) + { + ConfigManager.Settings.uriHistoryList = dlg.UriHistory; + ConfigManager.Save(SettingsFlags.FileHistory); + LoadFiles([dlg.Uri], false); + } + } + } + + private void OnColumnFinderToolStripMenuItemClick(object sender, EventArgs e) + { + if (CurrentLogWindow != null && !_skipEvents) + { + CurrentLogWindow.ToggleColumnFinder(columnFinderToolStripMenuItem.Checked, true); + } + } + + private void OnDockPanelActiveContentChanged(object sender, EventArgs e) + { + if (dockPanel.ActiveContent is LogWindow.LogWindow window) + { + CurrentLogWindow = window; + CurrentLogWindow.LogWindowActivated(); + ConnectToolWindows(CurrentLogWindow); + } + } + + private void OnTabRenameToolStripMenuItemClick(object sender, EventArgs e) + { + if (CurrentLogWindow != null) + { + TabRenameDialog dlg = new() + { + TabName = CurrentLogWindow.Text + }; + if (DialogResult.OK == dlg.ShowDialog()) + { + CurrentLogWindow.Text = dlg.TabName; + } + dlg.Dispose(); + } + } + + #endregion +} \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs b/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs new file mode 100644 index 00000000..e27b60db --- /dev/null +++ b/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs @@ -0,0 +1,1327 @@ +using LogExpert.Classes; +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Classes.Persister; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.Enums; +using LogExpert.Core.EventArguments; +using LogExpert.Dialogs; +using LogExpert.PluginRegistry.FileSystem; +using LogExpert.UI.Dialogs; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Security; +using System.Text; +using WeifenLuo.WinFormsUI.Docking; + +namespace LogExpert.UI.Controls.LogTabWindow; +partial class LogTabWindow +{ + #region Private Methods + + /// + /// Creates a temp file with the text content of the clipboard and opens the temp file in a new tab. + /// + private void PasteFromClipboard() + { + if (Clipboard.ContainsText()) + { + string text = Clipboard.GetText(); + string fileName = Path.GetTempFileName(); + + using (FileStream fStream = new(fileName, FileMode.Append, FileAccess.Write, FileShare.Read)) + using (StreamWriter writer = new(fStream, Encoding.Unicode)) + { + writer.Write(text); + writer.Close(); + } + + string title = "Clipboard"; + LogWindow.LogWindow logWindow = AddTempFileTab(fileName, title); + LogWindowData data = logWindow.Tag as LogWindowData; + if (data != null) + { + SetTooltipText(logWindow, "Pasted on " + DateTime.Now); + } + } + } + + private void InitToolWindows() + { + InitBookmarkWindow(); + } + + private void DestroyToolWindows() + { + DestroyBookmarkWindow(); + } + + private void InitBookmarkWindow() + { + _bookmarkWindow = new BookmarkWindow + { + HideOnClose = true, + ShowHint = DockState.DockBottom + }; + + _bookmarkWindow.PreferencesChanged(ConfigManager.Settings.Preferences, false, SettingsFlags.All, ConfigManager.Instance); + _bookmarkWindow.VisibleChanged += OnBookmarkWindowVisibleChanged; + _firstBookmarkWindowShow = true; + } + + private void DestroyBookmarkWindow() + { + _bookmarkWindow.HideOnClose = false; + _bookmarkWindow.Close(); + } + + private void SaveLastOpenFilesList() + { + ConfigManager.Settings.lastOpenFilesList.Clear(); + foreach (DockContent content in dockPanel.Contents) + { + if (content is LogWindow.LogWindow logWin) + { + if (!logWin.IsTempFile) + { + ConfigManager.Settings.lastOpenFilesList.Add(logWin.GivenFileName); + } + } + } + } + + private void SaveWindowPosition() + { + SuspendLayout(); + if (WindowState == FormWindowState.Normal) + { + ConfigManager.Settings.appBounds = Bounds; + ConfigManager.Settings.isMaximized = false; + } + else + { + ConfigManager.Settings.appBoundsFullscreen = Bounds; + ConfigManager.Settings.isMaximized = true; + WindowState = FormWindowState.Normal; + ConfigManager.Settings.appBounds = Bounds; + } + + ResumeLayout(); + } + + private void SetTooltipText(LogWindow.LogWindow logWindow, string logFileName) + { + logWindow.ToolTipText = logFileName; + } + + private void FillDefaultEncodingFromSettings(EncodingOptions encodingOptions) + { + if (ConfigManager.Settings.Preferences.defaultEncoding != null) + { + try + { + encodingOptions.DefaultEncoding = Encoding.GetEncoding(ConfigManager.Settings.Preferences.defaultEncoding); + } + catch (ArgumentException) + { + _logger.Warn("Encoding " + ConfigManager.Settings.Preferences.defaultEncoding + " is not a valid encoding"); + encodingOptions.DefaultEncoding = null; + } + } + } + + private void AddFileTabs(string[] fileNames) + { + foreach (string fileName in fileNames) + { + if (!string.IsNullOrEmpty(fileName)) + { + if (fileName.EndsWith(".lxj")) + { + LoadProject(fileName, false); + } + else + { + AddFileTab(fileName, false, null, false, null); + } + } + } + + Activate(); + } + + private void AddLogWindow(LogWindow.LogWindow logWindow, string title, bool doNotAddToPanel) + { + logWindow.CloseButton = true; + logWindow.TabPageContextMenuStrip = tabContextMenuStrip; + SetTooltipText(logWindow, title); + logWindow.DockAreas = DockAreas.Document | DockAreas.Float; + + if (!doNotAddToPanel) + { + logWindow.Show(dockPanel); + } + + LogWindowData data = new(); + data.diffSum = 0; + logWindow.Tag = data; + lock (_logWindowList) + { + _logWindowList.Add(logWindow); + } + + logWindow.FileSizeChanged += OnFileSizeChanged; + logWindow.TailFollowed += OnTailFollowed; + logWindow.Disposed += OnLogWindowDisposed; + logWindow.FileNotFound += OnLogWindowFileNotFound; + logWindow.FileRespawned += OnLogWindowFileRespawned; + logWindow.FilterListChanged += OnLogWindowFilterListChanged; + logWindow.CurrentHighlightGroupChanged += OnLogWindowCurrentHighlightGroupChanged; + logWindow.SyncModeChanged += OnLogWindowSyncModeChanged; + + logWindow.Visible = true; + } + + private void DisconnectEventHandlers(LogWindow.LogWindow logWindow) + { + logWindow.FileSizeChanged -= OnFileSizeChanged; + logWindow.TailFollowed -= OnTailFollowed; + logWindow.Disposed -= OnLogWindowDisposed; + logWindow.FileNotFound -= OnLogWindowFileNotFound; + logWindow.FileRespawned -= OnLogWindowFileRespawned; + logWindow.FilterListChanged -= OnLogWindowFilterListChanged; + logWindow.CurrentHighlightGroupChanged -= OnLogWindowCurrentHighlightGroupChanged; + logWindow.SyncModeChanged -= OnLogWindowSyncModeChanged; + + LogWindowData data = logWindow.Tag as LogWindowData; + //data.tabPage.MouseClick -= tabPage_MouseClick; + //data.tabPage.TabDoubleClick -= tabPage_TabDoubleClick; + //data.tabPage.ContextMenuStrip = null; + //data.tabPage = null; + } + + private void AddToFileHistory(string fileName) + { + bool FindName(string s) + { + return s.ToLower().Equals(fileName.ToLower()); + } + + int index = ConfigManager.Settings.fileHistoryList.FindIndex(FindName); + + if (index != -1) + { + ConfigManager.Settings.fileHistoryList.RemoveAt(index); + } + + ConfigManager.Settings.fileHistoryList.Insert(0, fileName); + + while (ConfigManager.Settings.fileHistoryList.Count > MAX_FILE_HISTORY) + { + ConfigManager.Settings.fileHistoryList.RemoveAt(ConfigManager.Settings.fileHistoryList.Count - 1); + } + + ConfigManager.Save(SettingsFlags.FileHistory); + + FillHistoryMenu(); + } + + private LogWindow.LogWindow FindWindowForFile(string fileName) + { + lock (_logWindowList) + { + foreach (LogWindow.LogWindow logWindow in _logWindowList) + { + if (logWindow.FileName.ToLower().Equals(fileName.ToLower())) + { + return logWindow; + } + } + } + + return null; + } + + /// + /// Checks if the file name is a settings file. If so, the contained logfile name + /// is returned. If not, the given file name is returned unchanged. + /// + /// + /// + private string FindFilenameForSettings(string fileName) + { + if (fileName.EndsWith(".lxp")) + { + PersistenceData persistenceData = Persister.LoadOptionsOnly(fileName); + if (persistenceData == null) + { + return fileName; + } + + if (!string.IsNullOrEmpty(persistenceData.fileName)) + { + IFileSystemPlugin fs = PluginRegistry.PluginRegistry.Instance.FindFileSystemForUri(persistenceData.fileName); + if (fs != null && !fs.GetType().Equals(typeof(LocalFileSystem))) + { + return persistenceData.fileName; + } + + // On relative paths the URI check (and therefore the file system plugin check) will fail. + // So fs == null and fs == LocalFileSystem are handled here like normal files. + if (Path.IsPathRooted(persistenceData.fileName)) + { + return persistenceData.fileName; + } + + // handle relative paths in .lxp files + string dir = Path.GetDirectoryName(fileName); + return Path.Combine(dir, persistenceData.fileName); + } + } + + return fileName; + } + + private void FillHistoryMenu() + { + ToolStripDropDown strip = new ToolStripDropDownMenu(); + + foreach (string file in ConfigManager.Settings.fileHistoryList) + { + ToolStripItem item = new ToolStripMenuItem(file); + strip.Items.Add(item); + } + + strip.ItemClicked += OnHistoryItemClicked; + strip.MouseUp += OnStripMouseUp; + lastUsedToolStripMenuItem.DropDown = strip; + } + + private void RemoveLogWindow(LogWindow.LogWindow logWindow) + { + lock (_logWindowList) + { + _logWindowList.Remove(logWindow); + } + + DisconnectEventHandlers(logWindow); + } + + private void RemoveAndDisposeLogWindow(LogWindow.LogWindow logWindow, bool dontAsk) + { + if (CurrentLogWindow == logWindow) + { + ChangeCurrentLogWindow(null); + } + + lock (_logWindowList) + { + _logWindowList.Remove(logWindow); + } + + logWindow.Close(dontAsk); + } + + private void ShowHighlightSettingsDialog() + { + HighlightDialog dlg = new(ConfigManager) + { + KeywordActionList = PluginRegistry.PluginRegistry.Instance.RegisteredKeywordActions, + Owner = this, + TopMost = TopMost, + HighlightGroupList = HighlightGroupList, + PreSelectedGroupName = groupsComboBoxHighlightGroups.Text + }; + + DialogResult res = dlg.ShowDialog(); + + if (res == DialogResult.OK) + { + HighlightGroupList = dlg.HighlightGroupList; + FillHighlightComboBox(); + ConfigManager.Settings.Preferences.HighlightGroupList = HighlightGroupList; + ConfigManager.Save(SettingsFlags.HighlightSettings); + OnHighlightSettingsChanged(); + } + } + + private void FillHighlightComboBox() + { + string currentGroupName = groupsComboBoxHighlightGroups.Text; + groupsComboBoxHighlightGroups.Items.Clear(); + foreach (HighlightGroup group in HighlightGroupList) + { + groupsComboBoxHighlightGroups.Items.Add(group.GroupName); + if (group.GroupName.Equals(currentGroupName)) + { + groupsComboBoxHighlightGroups.Text = group.GroupName; + } + } + } + + private void OpenFileDialog() + { + OpenFileDialog openFileDialog = new(); + + if (CurrentLogWindow != null) + { + FileInfo info = new(CurrentLogWindow.FileName); + openFileDialog.InitialDirectory = info.DirectoryName; + } + else + { + if (!string.IsNullOrEmpty(ConfigManager.Settings.lastDirectory)) + { + openFileDialog.InitialDirectory = ConfigManager.Settings.lastDirectory; + } + else + { + try + { + openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + } + catch (SecurityException e) + { + _logger.Warn(e, "Insufficient rights for GetFolderPath(): "); + // no initial directory if insufficient rights + } + } + } + + openFileDialog.Multiselect = true; + + if (DialogResult.OK == openFileDialog.ShowDialog(this)) + { + FileInfo info = new(openFileDialog.FileName); + if (info.Directory.Exists) + { + ConfigManager.Settings.lastDirectory = info.DirectoryName; + ConfigManager.Save(SettingsFlags.FileHistory); + } + + if (info.Exists) + { + LoadFiles(openFileDialog.FileNames, false); + } + } + } + + private void LoadFiles(string[] names, bool invertLogic) + { + Array.Sort(names); + + if (names.Length == 1) + { + if (names[0].EndsWith(".lxj")) + { + LoadProject(names[0], true); + return; + } + + AddFileTab(names[0], false, null, false, null); + return; + } + + MultiFileOption option = ConfigManager.Settings.Preferences.multiFileOption; + if (option == MultiFileOption.Ask) + { + MultiLoadRequestDialog dlg = new(); + DialogResult res = dlg.ShowDialog(); + + if (res == DialogResult.Yes) + { + option = MultiFileOption.SingleFiles; + } + else if (res == DialogResult.No) + { + option = MultiFileOption.MultiFile; + } + else + { + return; + } + } + else + { + if (invertLogic) + { + if (option == MultiFileOption.SingleFiles) + { + option = MultiFileOption.MultiFile; + } + else + { + option = MultiFileOption.SingleFiles; + } + } + } + + if (option == MultiFileOption.SingleFiles) + { + AddFileTabs(names); + } + else + { + AddMultiFileTab(names); + } + } + + private void SetColumnizerHistoryEntry(string fileName, ILogLineColumnizer columnizer) + { + ColumnizerHistoryEntry entry = FindColumnizerHistoryEntry(fileName); + if (entry != null) + { + ConfigManager.Settings.columnizerHistoryList.Remove(entry); + } + + ConfigManager.Settings.columnizerHistoryList.Add(new ColumnizerHistoryEntry(fileName, columnizer.GetName())); + + if (ConfigManager.Settings.columnizerHistoryList.Count > MAX_COLUMNIZER_HISTORY) + { + ConfigManager.Settings.columnizerHistoryList.RemoveAt(0); + } + } + + private ColumnizerHistoryEntry FindColumnizerHistoryEntry(string fileName) + { + foreach (ColumnizerHistoryEntry entry in ConfigManager.Settings.columnizerHistoryList) + { + if (entry.FileName.Equals(fileName)) + { + return entry; + } + } + + return null; + } + + private void ToggleMultiFile() + { + if (CurrentLogWindow != null) + { + CurrentLogWindow.SwitchMultiFile(!CurrentLogWindow.IsMultiFile); + multiFileToolStripMenuItem.Checked = CurrentLogWindow.IsMultiFile; + multiFileEnabledStripMenuItem.Checked = CurrentLogWindow.IsMultiFile; + } + } + + private void ChangeCurrentLogWindow(LogWindow.LogWindow newLogWindow) + { + if (newLogWindow == _currentLogWindow) + { + return; // do nothing if wishing to set the same window + } + + LogWindow.LogWindow oldLogWindow = _currentLogWindow; + _currentLogWindow = newLogWindow; + string titleName = _showInstanceNumbers ? "LogExpert #" + _instanceNumber : "LogExpert"; + + if (oldLogWindow != null) + { + oldLogWindow.StatusLineEvent -= OnStatusLineEvent; + oldLogWindow.ProgressBarUpdate -= OnProgressBarUpdate; + oldLogWindow.GuiStateUpdate -= OnGuiStateUpdate; + oldLogWindow.ColumnizerChanged -= OnColumnizerChanged; + oldLogWindow.BookmarkAdded -= OnBookmarkAdded; + oldLogWindow.BookmarkRemoved -= OnBookmarkRemoved; + oldLogWindow.BookmarkTextChanged -= OnBookmarkTextChanged; + DisconnectToolWindows(oldLogWindow); + } + + if (newLogWindow != null) + { + newLogWindow.StatusLineEvent += OnStatusLineEvent; + newLogWindow.ProgressBarUpdate += OnProgressBarUpdate; + newLogWindow.GuiStateUpdate += OnGuiStateUpdate; + newLogWindow.ColumnizerChanged += OnColumnizerChanged; + newLogWindow.BookmarkAdded += OnBookmarkAdded; + newLogWindow.BookmarkRemoved += OnBookmarkRemoved; + newLogWindow.BookmarkTextChanged += OnBookmarkTextChanged; + + if (newLogWindow.IsTempFile) + { + Text = titleName + @" - " + newLogWindow.TempTitleName; + } + else + { + Text = titleName + @" - " + newLogWindow.FileName; + } + + multiFileToolStripMenuItem.Checked = CurrentLogWindow.IsMultiFile; + multiFileToolStripMenuItem.Enabled = true; + multiFileEnabledStripMenuItem.Checked = CurrentLogWindow.IsMultiFile; + cellSelectModeToolStripMenuItem.Checked = true; + cellSelectModeToolStripMenuItem.Enabled = true; + closeFileToolStripMenuItem.Enabled = true; + searchToolStripMenuItem.Enabled = true; + filterToolStripMenuItem.Enabled = true; + goToLineToolStripMenuItem.Enabled = true; + //ConnectToolWindows(newLogWindow); + } + else + { + Text = titleName; + multiFileToolStripMenuItem.Checked = false; + multiFileEnabledStripMenuItem.Checked = false; + checkBoxFollowTail.Checked = false; + mainMenuStrip.Enabled = true; + timeshiftToolStripMenuItem.Enabled = false; + timeshiftToolStripMenuItem.Checked = false; + timeshiftMenuTextBox.Text = ""; + timeshiftMenuTextBox.Enabled = false; + multiFileToolStripMenuItem.Enabled = false; + cellSelectModeToolStripMenuItem.Checked = false; + cellSelectModeToolStripMenuItem.Enabled = false; + closeFileToolStripMenuItem.Enabled = false; + searchToolStripMenuItem.Enabled = false; + filterToolStripMenuItem.Enabled = false; + goToLineToolStripMenuItem.Enabled = false; + dragControlDateTime.Visible = false; + } + } + + private void ConnectToolWindows(LogWindow.LogWindow logWindow) + { + ConnectBookmarkWindow(logWindow); + } + + private void ConnectBookmarkWindow(LogWindow.LogWindow logWindow) + { + FileViewContext ctx = new(logWindow, logWindow); + _bookmarkWindow.SetBookmarkData(logWindow.BookmarkData); + _bookmarkWindow.SetCurrentFile(ctx); + } + + private void DisconnectToolWindows(LogWindow.LogWindow logWindow) + { + DisconnectBookmarkWindow(logWindow); + } + + private void DisconnectBookmarkWindow(LogWindow.LogWindow logWindow) + { + _bookmarkWindow.SetBookmarkData(null); + _bookmarkWindow.SetCurrentFile(null); + } + + private void GuiStateUpdateWorker(GuiStateArgs e) + { + _skipEvents = true; + checkBoxFollowTail.Checked = e.FollowTail; + mainMenuStrip.Enabled = e.MenuEnabled; + timeshiftToolStripMenuItem.Enabled = e.TimeshiftPossible; + timeshiftToolStripMenuItem.Checked = e.TimeshiftEnabled; + timeshiftMenuTextBox.Text = e.TimeshiftText; + timeshiftMenuTextBox.Enabled = e.TimeshiftEnabled; + multiFileToolStripMenuItem.Enabled = e.MultiFileEnabled; // disabled for temp files + multiFileToolStripMenuItem.Checked = e.IsMultiFileActive; + multiFileEnabledStripMenuItem.Checked = e.IsMultiFileActive; + cellSelectModeToolStripMenuItem.Checked = e.CellSelectMode; + RefreshEncodingMenuBar(e.CurrentEncoding); + + if (e.TimeshiftPossible && ConfigManager.Settings.Preferences.timestampControl) + { + dragControlDateTime.MinDateTime = e.MinTimestamp; + dragControlDateTime.MaxDateTime = e.MaxTimestamp; + dragControlDateTime.DateTime = e.Timestamp; + dragControlDateTime.Visible = true; + dragControlDateTime.Enabled = true; + dragControlDateTime.Refresh(); + } + else + { + dragControlDateTime.Visible = false; + dragControlDateTime.Enabled = false; + } + + toolStripButtonBubbles.Checked = e.ShowBookmarkBubbles; + groupsComboBoxHighlightGroups.Text = e.HighlightGroupName; + columnFinderToolStripMenuItem.Checked = e.ColumnFinderVisible; + + _skipEvents = false; + } + + private void ProgressBarUpdateWorker(ProgressEventArgs e) + { + if (e.Value <= e.MaxValue && e.Value >= e.MinValue) + { + try + { + loadProgessBar.Minimum = e.MinValue; + loadProgessBar.Maximum = e.MaxValue; + loadProgessBar.Value = e.Value; + loadProgessBar.Visible = e.Visible; + } + catch (Exception ex) + { + _logger.Error(ex, "Error during ProgressBarUpdateWorker value {0}, min {1}, max {2}, visible {3}", e.Value, e.MinValue, e.MaxValue, e.Visible); + } + + Invoke(new MethodInvoker(statusStrip.Refresh)); + } + } + + private void StatusLineEventWorker(StatusLineEventArgs e) + { + if (e != null) + { + //_logger.logDebug("StatusLineEvent: text = " + e.StatusText); + labelStatus.Text = e.StatusText; + labelStatus.Size = TextRenderer.MeasureText(labelStatus.Text, labelStatus.Font); + labelLines.Text = $" {e.LineCount} lines"; + labelLines.Size = TextRenderer.MeasureText(labelLines.Text, labelLines.Font); + labelSize.Text = Util.GetFileSizeAsText(e.FileSize); + labelSize.Size = TextRenderer.MeasureText(labelSize.Text, labelSize.Font); + labelCurrentLine.Text = $"Line: {e.CurrentLineNum}"; + labelCurrentLine.Size = TextRenderer.MeasureText(labelCurrentLine.Text, labelCurrentLine.Font); + if (statusStrip.InvokeRequired) + { + statusStrip.BeginInvoke(new MethodInvoker(delegate { statusStrip.Refresh(); })); + } + else + { + statusStrip.Refresh(); + } + } + } + + // tailState: 0,1,2 = on/off/off by Trigger + // syncMode: 0 = normal (no), 1 = time synced + private Icon CreateLedIcon(int level, bool dirty, int tailState, int syncMode) + { + Rectangle iconRect = _leds[0]; + iconRect.Height = 16; // (DockPanel's damn hardcoded height) // this.leds[this.leds.Length - 1].Bottom; + iconRect.Width = iconRect.Right + 6; + Bitmap bmp = new(iconRect.Width, iconRect.Height); + Graphics gfx = Graphics.FromImage(bmp); + + int offsetFromTop = 4; + + for (int i = 0; i < _leds.Length; ++i) + { + Rectangle ledRect = _leds[i]; + ledRect.Offset(0, offsetFromTop); + + if (level >= _leds.Length - i) + { + gfx.FillRectangle(_ledBrushes[i], ledRect); + } + else + { + gfx.FillRectangle(_offLedBrush, ledRect); + } + } + + int ledSize = 3; + int ledGap = 1; + Rectangle lastLed = _leds[^1]; + Rectangle dirtyLed = new(lastLed.Right + 2, lastLed.Bottom - ledSize, ledSize, ledSize); + Rectangle tailLed = new(dirtyLed.Location, dirtyLed.Size); + tailLed.Offset(0, -(ledSize + ledGap)); + Rectangle syncLed = new(tailLed.Location, dirtyLed.Size); + syncLed.Offset(0, -(ledSize + ledGap)); + + syncLed.Offset(0, offsetFromTop); + tailLed.Offset(0, offsetFromTop); + dirtyLed.Offset(0, offsetFromTop); + + if (dirty) + { + gfx.FillRectangle(_dirtyLedBrush, dirtyLed); + } + else + { + gfx.FillRectangle(_offLedBrush, dirtyLed); + } + + // tailMode 4 means: don't show + if (tailState < 3) + { + gfx.FillRectangle(_tailLedBrush[tailState], tailLed); + } + + if (syncMode == 1) + { + gfx.FillRectangle(_syncLedBrush, syncLed); + } + //else + //{ + // gfx.FillRectangle(this.offLedBrush, syncLed); + //} + + // see http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=345656 + // GetHicon() creates an unmanaged handle which must be destroyed. The Clone() workaround creates + // a managed copy of icon. then the unmanaged win32 handle is destroyed + IntPtr iconHandle = bmp.GetHicon(); + Icon icon = Icon.FromHandle(iconHandle).Clone() as Icon; + Win32.DestroyIcon(iconHandle); + + gfx.Dispose(); + bmp.Dispose(); + return icon; + } + + private void CreateIcons() + { + for (int syncMode = 0; syncMode <= 1; syncMode++) // LED indicating time synced tabs + { + for (int tailMode = 0; tailMode < 4; tailMode++) + { + for (int i = 0; i < 6; ++i) + { + _ledIcons[i, 0, tailMode, syncMode] = CreateLedIcon(i, false, tailMode, syncMode); + } + + for (int i = 0; i < 6; ++i) + { + _ledIcons[i, 1, tailMode, syncMode] = CreateLedIcon(i, true, tailMode, syncMode); + } + } + } + } + + private void FileNotFound(LogWindow.LogWindow logWin) + { + LogWindowData data = logWin.Tag as LogWindowData; + BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, _deadIcon); + dragControlDateTime.Visible = false; + } + + private void FileRespawned(LogWindow.LogWindow logWin) + { + LogWindowData data = logWin.Tag as LogWindowData; + Icon icon = GetIcon(0, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, icon); + } + + private void ShowLedPeak(LogWindow.LogWindow logWin) + { + LogWindowData data = logWin.Tag as LogWindowData; + lock (data) + { + data.diffSum = DIFF_MAX; + } + + Icon icon = GetIcon(data.diffSum, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, icon); + } + + private int GetLevelFromDiff(int diff) + { + if (diff > 60) + { + diff = 60; + } + + int level = diff / 10; + if (diff > 0 && level == 0) + { + level = 2; + } + else if (level == 0) + { + level = 1; + } + + return level - 1; + } + + private void LedThreadProc() + { + Thread.CurrentThread.Name = "LED Thread"; + while (!_shouldStop) + { + try + { + Thread.Sleep(200); + } + catch + { + return; + } + + lock (_logWindowList) + { + foreach (LogWindow.LogWindow logWindow in _logWindowList) + { + LogWindowData data = logWindow.Tag as LogWindowData; + if (data.diffSum > 0) + { + data.diffSum -= 10; + if (data.diffSum < 0) + { + data.diffSum = 0; + } + + Icon icon = GetIcon(data.diffSum, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); + } + } + } + } + } + + private void SetTabIcon(LogWindow.LogWindow logWindow, Icon icon) + { + if (logWindow != null) + { + logWindow.Icon = icon; + logWindow.DockHandler.Pane?.TabStripControl.Invalidate(false); + } + } + + private Icon GetIcon(int diff, LogWindowData data) + { + Icon icon = + _ledIcons[ + GetLevelFromDiff(diff), data.dirty ? 1 : 0, Preferences.showTailState ? data.tailState : 3, + data.syncMode + ]; + return icon; + } + + private void RefreshEncodingMenuBar(Encoding encoding) + { + toolStripEncodingASCIIItem.Checked = false; + toolStripEncodingANSIItem.Checked = false; + toolStripEncodingUTF8Item.Checked = false; + toolStripEncodingUTF16Item.Checked = false; + toolStripEncodingISO88591Item.Checked = false; + + if (encoding == null) + { + return; + } + + if (encoding is ASCIIEncoding) + { + toolStripEncodingASCIIItem.Checked = true; + } + else if (encoding.Equals(Encoding.Default)) + { + toolStripEncodingANSIItem.Checked = true; + } + else if (encoding is UTF8Encoding) + { + toolStripEncodingUTF8Item.Checked = true; + } + else if (encoding is UnicodeEncoding) + { + toolStripEncodingUTF16Item.Checked = true; + } + else if (encoding.Equals(Encoding.GetEncoding("iso-8859-1"))) + { + toolStripEncodingISO88591Item.Checked = true; + } + + toolStripEncodingANSIItem.Text = Encoding.Default.HeaderName; + } + + private void OpenSettings(int tabToOpen) + { + SettingsDialog dlg = new(ConfigManager.Settings.Preferences, this, tabToOpen, ConfigManager) + { + TopMost = TopMost + }; + + if (DialogResult.OK == dlg.ShowDialog()) + { + ConfigManager.Settings.Preferences = dlg.Preferences; + ConfigManager.Save(SettingsFlags.Settings); + NotifyWindowsForChangedPrefs(SettingsFlags.Settings); + } + } + + private void NotifyWindowsForChangedPrefs(SettingsFlags flags) + { + _logger.Info("The preferences have changed"); + ApplySettings(ConfigManager.Settings, flags); + + lock (_logWindowList) + { + foreach (LogWindow.LogWindow logWindow in _logWindowList) + { + logWindow.PreferencesChanged(ConfigManager.Settings.Preferences, false, flags); + } + } + + _bookmarkWindow.PreferencesChanged(ConfigManager.Settings.Preferences, false, flags); + + HighlightGroupList = ConfigManager.Settings.Preferences.HighlightGroupList; + if ((flags & SettingsFlags.HighlightSettings) == SettingsFlags.HighlightSettings) + { + OnHighlightSettingsChanged(); + } + } + + private void ApplySettings(Settings settings, SettingsFlags flags) + { + if ((flags & SettingsFlags.WindowPosition) == SettingsFlags.WindowPosition) + { + TopMost = alwaysOnTopToolStripMenuItem.Checked = settings.alwaysOnTop; + dragControlDateTime.DragOrientation = settings.Preferences.timestampControlDragOrientation; + hideLineColumnToolStripMenuItem.Checked = settings.hideLineColumn; + } + + if ((flags & SettingsFlags.FileHistory) == SettingsFlags.FileHistory) + { + FillHistoryMenu(); + } + + if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors) + { + SetTabIcons(settings.Preferences); + } + + if ((flags & SettingsFlags.ToolSettings) == SettingsFlags.ToolSettings) + { + FillToolLauncherBar(); + } + + if ((flags & SettingsFlags.HighlightSettings) == SettingsFlags.HighlightSettings) + { + FillHighlightComboBox(); + } + } + + private void SetTabIcons(Preferences preferences) + { + _tailLedBrush[0] = new SolidBrush(preferences.showTailColor); + CreateIcons(); + lock (_logWindowList) + { + foreach (LogWindow.LogWindow logWindow in _logWindowList) + { + LogWindowData data = logWindow.Tag as LogWindowData; + Icon icon = GetIcon(data.diffSum, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); + } + } + } + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + private static extern bool DestroyIcon(IntPtr handle); + + private void SetToolIcon(ToolEntry entry, ToolStripItem item) + { + Icon icon = Win32.LoadIconFromExe(entry.iconFile, entry.iconIndex); + if (icon != null) + { + item.Image = icon.ToBitmap(); + if (item is ToolStripMenuItem) + { + item.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; + } + else + { + item.DisplayStyle = ToolStripItemDisplayStyle.Image; + } + + DestroyIcon(icon.Handle); + icon.Dispose(); + } + + if (!string.IsNullOrEmpty(entry.cmd)) + { + item.ToolTipText = entry.name; + } + } + + private void ToolButtonClick(ToolEntry toolEntry) + { + if (string.IsNullOrEmpty(toolEntry.cmd)) + { + //TODO TabIndex => To Enum + OpenSettings(2); + return; + } + + if (CurrentLogWindow != null) + { + ILogLine line = CurrentLogWindow.GetCurrentLine(); + ILogFileInfo info = CurrentLogWindow.GetCurrentFileInfo(); + if (line != null && info != null) + { + ArgParser parser = new(toolEntry.args); + string argLine = parser.BuildArgs(line, CurrentLogWindow.GetRealLineNum() + 1, info, this); + if (argLine != null) + { + StartTool(toolEntry.cmd, argLine, toolEntry.sysout, toolEntry.columnizerName, + toolEntry.workingDir); + } + } + } + } + + private void StartTool(string cmd, string args, bool sysoutPipe, string columnizerName, string workingDir) + { + if (string.IsNullOrEmpty(cmd)) + { + return; + } + + Process process = new(); + ProcessStartInfo startInfo = new(cmd, args); + if (!Util.IsNull(workingDir)) + { + startInfo.WorkingDirectory = workingDir; + } + + process.StartInfo = startInfo; + process.EnableRaisingEvents = true; + + if (sysoutPipe) + { + ILogLineColumnizer columnizer = ColumnizerPicker.DecideColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + + _logger.Info("Starting external tool with sysout redirection: {0} {1}", cmd, args); + startInfo.UseShellExecute = false; + startInfo.RedirectStandardOutput = true; + //process.OutputDataReceived += pipe.DataReceivedEventHandler; + try + { + process.Start(); + } + catch (Win32Exception e) + { + _logger.Error(e); + MessageBox.Show(e.Message); + return; + } + + SysoutPipe pipe = new(process.StandardOutput); + + LogWindow.LogWindow logWin = AddTempFileTab(pipe.FileName, + CurrentLogWindow.IsTempFile + ? CurrentLogWindow.TempTitleName + : Util.GetNameFromPath(CurrentLogWindow.FileName) + "->E"); + logWin.ForceColumnizer(columnizer); + + process.Exited += pipe.ProcessExitedEventHandler; + //process.BeginOutputReadLine(); + } + else + { + _logger.Info("Starting external tool: {0} {1}", cmd, args); + + try + { + startInfo.UseShellExecute = false; + process.Start(); + } + catch (Exception e) + { + _logger.Error(e); + MessageBox.Show(e.Message); + } + } + } + + private void CloseAllTabs() + { + IList closeList = []; + lock (_logWindowList) + { + foreach (DockContent content in dockPanel.Contents) + { + if (content is LogWindow.LogWindow window) + { + closeList.Add(window); + } + } + } + + foreach (Form form in closeList) + { + form.Close(); + } + } + + private void SetTabColor(LogWindow.LogWindow logWindow, Color color) + { + //tabPage.BackLowColor = color; + //tabPage.BackLowColorDisabled = Color.FromArgb(255, + // Math.Max(0, color.R - 50), + // Math.Max(0, color.G - 50), + // Math.Max(0, color.B - 50) + // ); + } + + private void LoadProject(string projectFileName, bool restoreLayout) + { + ProjectData projectData = ProjectPersister.LoadProjectData(projectFileName); + bool hasLayoutData = projectData.tabLayoutXml != null; + + if (hasLayoutData && restoreLayout && _logWindowList.Count > 0) + { + ProjectLoadDlg dlg = new(); + if (DialogResult.Cancel != dlg.ShowDialog()) + { + switch (dlg.ProjectLoadResult) + { + case ProjectLoadDlgResult.IgnoreLayout: + hasLayoutData = false; + break; + case ProjectLoadDlgResult.CloseTabs: + CloseAllTabs(); + break; + case ProjectLoadDlgResult.NewWindow: + LogExpertProxy.NewWindow([projectFileName]); + return; + } + } + } + + if (projectData != null) + { + foreach (string fileName in projectData.memberList) + { + if (hasLayoutData) + { + AddFileTabDeferred(fileName, false, null, true, null); + } + else + { + AddFileTab(fileName, false, null, true, null); + } + } + + if (hasLayoutData && restoreLayout) + { + // Re-creating tool (non-document) windows is needed because the DockPanel control would throw strange errors + DestroyToolWindows(); + InitToolWindows(); + RestoreLayout(projectData.tabLayoutXml); + } + } + } + + private void ApplySelectedHighlightGroup() + { + string groupName = groupsComboBoxHighlightGroups.Text; + CurrentLogWindow?.SetCurrentHighlightGroup(groupName); + } + + private void FillToolLauncherBar() + { + char[] labels = + { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', + 'U', 'V', 'W', 'X', 'Y', 'Z' + }; + toolsToolStripMenuItem.DropDownItems.Clear(); + toolsToolStripMenuItem.DropDownItems.Add(configureToolStripMenuItem); + toolsToolStripMenuItem.DropDownItems.Add(configureToolStripSeparator); + externalToolsToolStrip.Items.Clear(); + int num = 0; + externalToolsToolStrip.SuspendLayout(); + foreach (ToolEntry tool in Preferences.toolEntries) + { + if (tool.isFavourite) + { + ToolStripButton button = new("" + labels[num % 26]) + { + Alignment = ToolStripItemAlignment.Left, + Tag = tool + }; + + SetToolIcon(tool, button); + externalToolsToolStrip.Items.Add(button); + } + + num++; + ToolStripMenuItem menuItem = new(tool.name); + menuItem.Tag = tool; + SetToolIcon(tool, menuItem); + toolsToolStripMenuItem.DropDownItems.Add(menuItem); + } + + externalToolsToolStrip.ResumeLayout(); + + externalToolsToolStrip.Visible = num > 0; // do not show bar if no tool uses it + } + + private void RunGC() + { + _logger.Info("Running GC. Used mem before: {0:N0}", GC.GetTotalMemory(false)); + GC.Collect(); + _logger.Info("GC done. Used mem after: {0:N0}", GC.GetTotalMemory(true)); + } + + private void DumpGCInfo() + { + _logger.Info("-------- GC info -----------\r\nUsed mem: {0:N0}", GC.GetTotalMemory(false)); + for (int i = 0; i < GC.MaxGeneration; ++i) + { + _logger.Info("Generation {0} collect count: {1}", i, GC.CollectionCount(i)); + } + + _logger.Info("----------------------------"); + } + + private void ThrowExceptionFx() + { + throw new Exception("This is a test exception thrown by an async delegate"); + } + + private void ThrowExceptionThreadFx() + { + throw new Exception("This is a test exception thrown by a background thread"); + } + + private string SaveLayout() + { + using MemoryStream memStream = new(2000); + using StreamReader r = new(memStream); + dockPanel.SaveAsXml(memStream, Encoding.UTF8, true); + + memStream.Seek(0, SeekOrigin.Begin); + string resultXml = r.ReadToEnd(); + + r.Close(); + + return resultXml; + } + + private void RestoreLayout(string layoutXml) + { + using MemoryStream memStream = new(2000); + using StreamWriter w = new(memStream); + w.Write(layoutXml); + w.Flush(); + + memStream.Seek(0, SeekOrigin.Begin); + + dockPanel.LoadFromXml(memStream, DeserializeDockContent, true); + } + + private IDockContent DeserializeDockContent(string persistString) + { + if (persistString.Equals(WindowTypes.BookmarkWindow.ToString())) + { + return _bookmarkWindow; + } + + if (persistString.StartsWith(WindowTypes.LogWindow.ToString())) + { + string fileName = persistString.Substring(WindowTypes.LogWindow.ToString().Length + 1); + LogWindow.LogWindow win = FindWindowForFile(fileName); + if (win != null) + { + return win; + } + + _logger.Warn("Layout data contains non-existing LogWindow for {0}", fileName); + } + + return null; + } + + private void OnHighlightSettingsChanged() + { + HighlightSettingsChanged?.Invoke(this, EventArgs.Empty); + } + + #endregion +} \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs b/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs new file mode 100644 index 00000000..147d8275 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs @@ -0,0 +1,351 @@ +using LogExpert.Classes.Filter; +using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.Interface; +using LogExpert.Dialogs; +using LogExpert.UI.Entities; +using System.Runtime.InteropServices; +using System.Text; +using System.Text.RegularExpressions; +using WeifenLuo.WinFormsUI.Docking; + +namespace LogExpert.UI.Controls.LogTabWindow; +partial class LogTabWindow +{ + #region Public methods + + public LogWindow.LogWindow AddTempFileTab(string fileName, string title) + { + return AddFileTab(fileName, true, title, false, null); + } + + public LogWindow.LogWindow AddFilterTab(FilterPipe pipe, string title, ILogLineColumnizer preProcessColumnizer) + { + LogWindow.LogWindow logWin = AddFileTab(pipe.FileName, true, title, false, preProcessColumnizer); + if (pipe.FilterParams.SearchText.Length > 0) + { + ToolTip tip = new(components); + tip.SetToolTip(logWin, + "Filter: \"" + pipe.FilterParams.SearchText + "\"" + + (pipe.FilterParams.IsInvert ? " (Invert match)" : "") + + (pipe.FilterParams.ColumnRestrict ? "\nColumn restrict" : "") + ); + tip.AutomaticDelay = 10; + tip.AutoPopDelay = 5000; + LogWindowData data = logWin.Tag as LogWindowData; + data.toolTip = tip; + } + + return logWin; + } + + public LogWindow.LogWindow AddFileTabDeferred(string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer) + { + return AddFileTab(givenFileName, isTempFile, title, forcePersistenceLoading, preProcessColumnizer, true); + } + + public LogWindow.LogWindow AddFileTab(string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer, bool doNotAddToDockPanel = false) + { + string logFileName = FindFilenameForSettings(givenFileName); + LogWindow.LogWindow win = FindWindowForFile(logFileName); + if (win != null) + { + if (!isTempFile) + { + AddToFileHistory(givenFileName); + } + + SelectTab(win); + return win; + } + + EncodingOptions encodingOptions = new(); + FillDefaultEncodingFromSettings(encodingOptions); + LogWindow.LogWindow logWindow = new(this, logFileName, isTempFile, forcePersistenceLoading, ConfigManager); + + logWindow.GivenFileName = givenFileName; + + if (preProcessColumnizer != null) + { + logWindow.ForceColumnizerForLoading(preProcessColumnizer); + } + + if (isTempFile) + { + logWindow.TempTitleName = title; + encodingOptions.Encoding = new UnicodeEncoding(false, false); + } + + AddLogWindow(logWindow, title, doNotAddToDockPanel); + if (!isTempFile) + { + AddToFileHistory(givenFileName); + } + + LogWindowData data = logWindow.Tag as LogWindowData; + data.color = _defaultTabColor; + SetTabColor(logWindow, _defaultTabColor); + //data.tabPage.BorderColor = this.defaultTabBorderColor; + if (!isTempFile) + { + foreach (ColorEntry colorEntry in ConfigManager.Settings.fileColors) + { + if (colorEntry.FileName.ToLower().Equals(logFileName.ToLower())) + { + data.color = colorEntry.Color; + SetTabColor(logWindow, colorEntry.Color); + break; + } + } + } + + if (!isTempFile) + { + SetTooltipText(logWindow, logFileName); + } + + if (givenFileName.EndsWith(".lxp")) + { + logWindow.ForcedPersistenceFileName = givenFileName; + } + + // this.BeginInvoke(new LoadFileDelegate(logWindow.LoadFile), new object[] { logFileName, encoding }); + Task.Run(() => logWindow.LoadFile(logFileName, encodingOptions)); + return logWindow; + } + + public LogWindow.LogWindow AddMultiFileTab(string[] fileNames) + { + if (fileNames.Length < 1) + { + return null; + } + + LogWindow.LogWindow logWindow = new(this, fileNames[fileNames.Length - 1], false, false, ConfigManager); + AddLogWindow(logWindow, fileNames[fileNames.Length - 1], false); + multiFileToolStripMenuItem.Checked = true; + multiFileEnabledStripMenuItem.Checked = true; + EncodingOptions encodingOptions = new(); + FillDefaultEncodingFromSettings(encodingOptions); + BeginInvoke(new LoadMultiFilesDelegate(logWindow.LoadFilesAsMulti), fileNames, encodingOptions); + AddToFileHistory(fileNames[0]); + return logWindow; + } + + public void LoadFiles(string[] fileNames) + { + Invoke(new AddFileTabsDelegate(AddFileTabs), [fileNames]); + } + + public void OpenSearchDialog() + { + if (CurrentLogWindow == null) + { + return; + } + + SearchDialog dlg = new(); + AddOwnedForm(dlg); + dlg.TopMost = TopMost; + SearchParams.HistoryList = ConfigManager.Settings.searchHistoryList; + dlg.SearchParams = SearchParams; + DialogResult res = dlg.ShowDialog(); + if (res == DialogResult.OK && dlg.SearchParams != null && !string.IsNullOrWhiteSpace(dlg.SearchParams.SearchText)) + { + SearchParams = dlg.SearchParams; + SearchParams.IsFindNext = false; + CurrentLogWindow.StartSearch(); + } + } + + public ILogLineColumnizer GetColumnizerHistoryEntry(string fileName) + { + ColumnizerHistoryEntry entry = FindColumnizerHistoryEntry(fileName); + if (entry != null) + { + foreach (ILogLineColumnizer columnizer in PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers) + { + if (columnizer.GetName().Equals(entry.ColumnizerName)) + { + return columnizer; + } + } + + ConfigManager.Settings.columnizerHistoryList.Remove(entry); // no valid name -> remove entry + } + + return null; + } + + public void SwitchTab(bool shiftPressed) + { + int index = dockPanel.Contents.IndexOf(dockPanel.ActiveContent); + if (shiftPressed) + { + index--; + if (index < 0) + { + index = dockPanel.Contents.Count - 1; + } + + if (index < 0) + { + return; + } + } + else + { + index++; + if (index >= dockPanel.Contents.Count) + { + index = 0; + } + } + + if (index < dockPanel.Contents.Count) + { + (dockPanel.Contents[index] as DockContent).Activate(); + } + } + + public void ScrollAllTabsToTimestamp(DateTime timestamp, LogWindow.LogWindow senderWindow) + { + lock (_logWindowList) + { + foreach (LogWindow.LogWindow logWindow in _logWindowList) + { + if (logWindow != senderWindow) + { + if (logWindow.ScrollToTimestamp(timestamp, false, false)) + { + ShowLedPeak(logWindow); + } + } + } + } + } + + public ILogLineColumnizer FindColumnizerByFileMask(string fileName) + { + foreach (ColumnizerMaskEntry entry in ConfigManager.Settings.Preferences.columnizerMaskList) + { + if (entry.mask != null) + { + try + { + if (Regex.IsMatch(fileName, entry.mask)) + { + ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(entry.columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + return columnizer; + } + } + catch (ArgumentException e) + { + _logger.Error(e, "RegEx-error while finding columnizer: "); + // occurs on invalid regex patterns + } + } + } + + return null; + } + + public HighlightGroup FindHighlightGroupByFileMask(string fileName) + { + foreach (HighlightMaskEntry entry in ConfigManager.Settings.Preferences.highlightMaskList) + { + if (entry.mask != null) + { + try + { + if (Regex.IsMatch(fileName, entry.mask)) + { + HighlightGroup group = FindHighlightGroup(entry.highlightGroupName); + return group; + } + } + catch (ArgumentException e) + { + _logger.Error(e, "RegEx-error while finding columnizer: "); + // occurs on invalid regex patterns + } + } + } + + return null; + } + + public void SelectTab(ILogWindow logWindow) + { + logWindow.Activate(); + } + + public void SetForeground() + { + SetForegroundWindow(Handle); + if (WindowState == FormWindowState.Minimized) + { + if (_wasMaximized) + { + WindowState = FormWindowState.Maximized; + } + else + { + WindowState = FormWindowState.Normal; + } + } + } + + [DllImport("User32.dll")] + public static extern int SetForegroundWindow(IntPtr hWnd); + + // called from LogWindow when follow tail was changed + public void FollowTailChanged(LogWindow.LogWindow logWindow, bool isEnabled, bool offByTrigger) + { + LogWindowData data = logWindow.Tag as LogWindowData; + if (data == null) + { + return; + } + + if (isEnabled) + { + data.tailState = 0; + } + else + { + data.tailState = offByTrigger ? 2 : 1; + } + + if (Preferences.showTailState) + { + Icon icon = GetIcon(data.diffSum, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); + } + } + + public void NotifySettingsChanged(object sender, SettingsFlags flags) + { + if (sender != this) + { + NotifyWindowsForChangedPrefs(flags); + } + } + + public IList GetListOfOpenFiles() + { + IList list = new List(); + lock (_logWindowList) + { + foreach (LogWindow.LogWindow logWindow in _logWindowList) + { + list.Add(new WindowFileEntry(logWindow)); + } + } + + return list; + } + + #endregion +} \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/SettingsDialog.Designer.cs b/src/Logexpert.UI/Dialogs/LogTabWindow/SettingsDialog.Designer.cs new file mode 100644 index 00000000..b4d5bad8 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/LogTabWindow/SettingsDialog.Designer.cs @@ -0,0 +1,1845 @@ +namespace LogExpert.Dialogs; + +partial class SettingsDialog +{ + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SettingsDialog)); + tabControlSettings = new System.Windows.Forms.TabControl(); + tabPageViewSettings = new System.Windows.Forms.TabPage(); + labelWarningMaximumLineLenght = new System.Windows.Forms.Label(); + upDownMaximumLineLength = new System.Windows.Forms.NumericUpDown(); + labelMaximumLineLength = new System.Windows.Forms.Label(); + upDownMaximumFilterEntriesDisplayed = new System.Windows.Forms.NumericUpDown(); + labelMaximumFilterEntriesDisplayed = new System.Windows.Forms.Label(); + upDownMaximumFilterEntries = new System.Windows.Forms.NumericUpDown(); + labelMaximumFilterEntries = new System.Windows.Forms.Label(); + labelDefaultEncoding = new System.Windows.Forms.Label(); + comboBoxEncoding = new System.Windows.Forms.ComboBox(); + groupBoxMisc = new System.Windows.Forms.GroupBox(); + checkBoxShowErrorMessageOnlyOneInstance = new System.Windows.Forms.CheckBox(); + cpDownColumnWidth = new System.Windows.Forms.NumericUpDown(); + checkBoxColumnSize = new System.Windows.Forms.CheckBox(); + buttonTailColor = new System.Windows.Forms.Button(); + checkBoxTailState = new System.Windows.Forms.CheckBox(); + checkBoxOpenLastFiles = new System.Windows.Forms.CheckBox(); + checkBoxSingleInstance = new System.Windows.Forms.CheckBox(); + checkBoxAskCloseTabs = new System.Windows.Forms.CheckBox(); + groupBoxDefaults = new System.Windows.Forms.GroupBox(); + checkBoxDarkMode = new System.Windows.Forms.CheckBox(); + checkBoxFollowTail = new System.Windows.Forms.CheckBox(); + checkBoxColumnFinder = new System.Windows.Forms.CheckBox(); + checkBoxSyncFilter = new System.Windows.Forms.CheckBox(); + checkBoxFilterTail = new System.Windows.Forms.CheckBox(); + groupBoxFont = new System.Windows.Forms.GroupBox(); + buttonChangeFont = new System.Windows.Forms.Button(); + labelFont = new System.Windows.Forms.Label(); + tabPageTimeStampFeatures = new System.Windows.Forms.TabPage(); + groupBoxTimeSpreadDisplay = new System.Windows.Forms.GroupBox(); + groupBoxDisplayMode = new System.Windows.Forms.GroupBox(); + radioButtonLineView = new System.Windows.Forms.RadioButton(); + radioButtonTimeView = new System.Windows.Forms.RadioButton(); + checkBoxReverseAlpha = new System.Windows.Forms.CheckBox(); + buttonTimespreadColor = new System.Windows.Forms.Button(); + checkBoxTimeSpread = new System.Windows.Forms.CheckBox(); + groupBoxTimeStampNavigationControl = new System.Windows.Forms.GroupBox(); + checkBoxTimestamp = new System.Windows.Forms.CheckBox(); + groupBoxMouseDragDefaults = new System.Windows.Forms.GroupBox(); + radioButtonVerticalMouseDragInverted = new System.Windows.Forms.RadioButton(); + radioButtonHorizMouseDrag = new System.Windows.Forms.RadioButton(); + radioButtonVerticalMouseDrag = new System.Windows.Forms.RadioButton(); + tabPageExternalTools = new System.Windows.Forms.TabPage(); + labelToolsDescription = new System.Windows.Forms.Label(); + buttonToolDelete = new System.Windows.Forms.Button(); + buttonToolAdd = new System.Windows.Forms.Button(); + buttonToolDown = new System.Windows.Forms.Button(); + buttonToolUp = new System.Windows.Forms.Button(); + listBoxTools = new System.Windows.Forms.CheckedListBox(); + groupBoxToolSettings = new System.Windows.Forms.GroupBox(); + labelWorkingDir = new System.Windows.Forms.Label(); + buttonWorkingDir = new System.Windows.Forms.Button(); + textBoxWorkingDir = new System.Windows.Forms.TextBox(); + buttonIcon = new System.Windows.Forms.Button(); + labelToolName = new System.Windows.Forms.Label(); + labelToolColumnizerForOutput = new System.Windows.Forms.Label(); + comboBoxColumnizer = new System.Windows.Forms.ComboBox(); + textBoxToolName = new System.Windows.Forms.TextBox(); + checkBoxSysout = new System.Windows.Forms.CheckBox(); + buttonArguments = new System.Windows.Forms.Button(); + labelTool = new System.Windows.Forms.Label(); + buttonTool = new System.Windows.Forms.Button(); + textBoxTool = new System.Windows.Forms.TextBox(); + labelArguments = new System.Windows.Forms.Label(); + textBoxArguments = new System.Windows.Forms.TextBox(); + tabPageColumnizers = new System.Windows.Forms.TabPage(); + checkBoxAutoPick = new System.Windows.Forms.CheckBox(); + checkBoxMaskPrio = new System.Windows.Forms.CheckBox(); + buttonDelete = new System.Windows.Forms.Button(); + dataGridViewColumnizer = new System.Windows.Forms.DataGridView(); + columnFileMask = new System.Windows.Forms.DataGridViewTextBoxColumn(); + columnColumnizer = new System.Windows.Forms.DataGridViewComboBoxColumn(); + tabPageHighlightMask = new System.Windows.Forms.TabPage(); + dataGridViewHighlightMask = new System.Windows.Forms.DataGridView(); + columnFileName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + columnHighlightGroup = new System.Windows.Forms.DataGridViewComboBoxColumn(); + tabPageMultiFile = new System.Windows.Forms.TabPage(); + groupBoxDefaultFileNamePattern = new System.Windows.Forms.GroupBox(); + labelMaxDays = new System.Windows.Forms.Label(); + labelPattern = new System.Windows.Forms.Label(); + upDownMultifileDays = new System.Windows.Forms.NumericUpDown(); + textBoxMultifilePattern = new System.Windows.Forms.TextBox(); + labelHintMultiFile = new System.Windows.Forms.Label(); + labelNoteMultiFile = new System.Windows.Forms.Label(); + groupBoxWhenOpeningMultiFile = new System.Windows.Forms.GroupBox(); + radioButtonAskWhatToDo = new System.Windows.Forms.RadioButton(); + radioButtonTreatAllFilesAsOneMultifile = new System.Windows.Forms.RadioButton(); + radioButtonLoadEveryFileIntoSeperatedTab = new System.Windows.Forms.RadioButton(); + tabPagePlugins = new System.Windows.Forms.TabPage(); + groupBoxPlugins = new System.Windows.Forms.GroupBox(); + listBoxPlugin = new System.Windows.Forms.ListBox(); + groupBoxSettings = new System.Windows.Forms.GroupBox(); + panelPlugin = new System.Windows.Forms.Panel(); + buttonConfigPlugin = new System.Windows.Forms.Button(); + tabPageSessions = new System.Windows.Forms.TabPage(); + checkBoxPortableMode = new System.Windows.Forms.CheckBox(); + checkBoxSaveFilter = new System.Windows.Forms.CheckBox(); + groupBoxPersistantFileLocation = new System.Windows.Forms.GroupBox(); + labelSessionSaveOwnDir = new System.Windows.Forms.Label(); + buttonSessionSaveDir = new System.Windows.Forms.Button(); + radioButtonSessionSaveOwn = new System.Windows.Forms.RadioButton(); + radioButtonsessionSaveDocuments = new System.Windows.Forms.RadioButton(); + radioButtonSessionSameDir = new System.Windows.Forms.RadioButton(); + radioButtonSessionApplicationStartupDir = new System.Windows.Forms.RadioButton(); + checkBoxSaveSessions = new System.Windows.Forms.CheckBox(); + tabPageMemory = new System.Windows.Forms.TabPage(); + groupBoxCPUAndStuff = new System.Windows.Forms.GroupBox(); + checkBoxLegacyReader = new System.Windows.Forms.CheckBox(); + checkBoxMultiThread = new System.Windows.Forms.CheckBox(); + labelFilePollingInterval = new System.Windows.Forms.Label(); + upDownPollingInterval = new System.Windows.Forms.NumericUpDown(); + groupBoxLineBufferUsage = new System.Windows.Forms.GroupBox(); + labelInfo = new System.Windows.Forms.Label(); + labelNumberOfBlocks = new System.Windows.Forms.Label(); + upDownLinesPerBlock = new System.Windows.Forms.NumericUpDown(); + upDownBlockCount = new System.Windows.Forms.NumericUpDown(); + labelLinesPerBlock = new System.Windows.Forms.Label(); + buttonCancel = new System.Windows.Forms.Button(); + buttonOk = new System.Windows.Forms.Button(); + helpProvider = new System.Windows.Forms.HelpProvider(); + toolTip = new System.Windows.Forms.ToolTip(components); + buttonExport = new System.Windows.Forms.Button(); + buttonImport = new System.Windows.Forms.Button(); + dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + tabControlSettings.SuspendLayout(); + tabPageViewSettings.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)upDownMaximumLineLength).BeginInit(); + ((System.ComponentModel.ISupportInitialize)upDownMaximumFilterEntriesDisplayed).BeginInit(); + ((System.ComponentModel.ISupportInitialize)upDownMaximumFilterEntries).BeginInit(); + groupBoxMisc.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)cpDownColumnWidth).BeginInit(); + groupBoxDefaults.SuspendLayout(); + groupBoxFont.SuspendLayout(); + tabPageTimeStampFeatures.SuspendLayout(); + groupBoxTimeSpreadDisplay.SuspendLayout(); + groupBoxDisplayMode.SuspendLayout(); + groupBoxTimeStampNavigationControl.SuspendLayout(); + groupBoxMouseDragDefaults.SuspendLayout(); + tabPageExternalTools.SuspendLayout(); + groupBoxToolSettings.SuspendLayout(); + tabPageColumnizers.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewColumnizer).BeginInit(); + tabPageHighlightMask.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewHighlightMask).BeginInit(); + tabPageMultiFile.SuspendLayout(); + groupBoxDefaultFileNamePattern.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)upDownMultifileDays).BeginInit(); + groupBoxWhenOpeningMultiFile.SuspendLayout(); + tabPagePlugins.SuspendLayout(); + groupBoxPlugins.SuspendLayout(); + groupBoxSettings.SuspendLayout(); + panelPlugin.SuspendLayout(); + tabPageSessions.SuspendLayout(); + groupBoxPersistantFileLocation.SuspendLayout(); + tabPageMemory.SuspendLayout(); + groupBoxCPUAndStuff.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)upDownPollingInterval).BeginInit(); + groupBoxLineBufferUsage.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)upDownLinesPerBlock).BeginInit(); + ((System.ComponentModel.ISupportInitialize)upDownBlockCount).BeginInit(); + SuspendLayout(); + // + // tabControlSettings + // + tabControlSettings.Controls.Add(tabPageViewSettings); + tabControlSettings.Controls.Add(tabPageTimeStampFeatures); + tabControlSettings.Controls.Add(tabPageExternalTools); + tabControlSettings.Controls.Add(tabPageColumnizers); + tabControlSettings.Controls.Add(tabPageHighlightMask); + tabControlSettings.Controls.Add(tabPageMultiFile); + tabControlSettings.Controls.Add(tabPagePlugins); + tabControlSettings.Controls.Add(tabPageSessions); + tabControlSettings.Controls.Add(tabPageMemory); + tabControlSettings.Location = new System.Drawing.Point(2, 3); + tabControlSettings.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabControlSettings.Name = "tabControlSettings"; + tabControlSettings.SelectedIndex = 0; + tabControlSettings.Size = new System.Drawing.Size(950, 468); + tabControlSettings.TabIndex = 0; + // + // tabPageViewSettings + // + tabPageViewSettings.Controls.Add(labelWarningMaximumLineLenght); + tabPageViewSettings.Controls.Add(upDownMaximumLineLength); + tabPageViewSettings.Controls.Add(labelMaximumLineLength); + tabPageViewSettings.Controls.Add(upDownMaximumFilterEntriesDisplayed); + tabPageViewSettings.Controls.Add(labelMaximumFilterEntriesDisplayed); + tabPageViewSettings.Controls.Add(upDownMaximumFilterEntries); + tabPageViewSettings.Controls.Add(labelMaximumFilterEntries); + tabPageViewSettings.Controls.Add(labelDefaultEncoding); + tabPageViewSettings.Controls.Add(comboBoxEncoding); + tabPageViewSettings.Controls.Add(groupBoxMisc); + tabPageViewSettings.Controls.Add(groupBoxDefaults); + tabPageViewSettings.Controls.Add(groupBoxFont); + tabPageViewSettings.Location = new System.Drawing.Point(4, 24); + tabPageViewSettings.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPageViewSettings.Name = "tabPageViewSettings"; + tabPageViewSettings.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPageViewSettings.Size = new System.Drawing.Size(942, 440); + tabPageViewSettings.TabIndex = 0; + tabPageViewSettings.Text = "View settings"; + tabPageViewSettings.UseVisualStyleBackColor = true; + // + // labelWarningMaximumLineLenght + // + labelWarningMaximumLineLenght.AutoSize = true; + labelWarningMaximumLineLenght.Location = new System.Drawing.Point(446, 118); + labelWarningMaximumLineLenght.Name = "labelWarningMaximumLineLenght"; + labelWarningMaximumLineLenght.Size = new System.Drawing.Size(482, 15); + labelWarningMaximumLineLenght.TabIndex = 16; + labelWarningMaximumLineLenght.Text = "! Changing the Maximum Line Length can impact performance and is not recommended !"; + // + // upDownMaximumLineLength + // + upDownMaximumLineLength.Location = new System.Drawing.Point(762, 138); + upDownMaximumLineLength.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + upDownMaximumLineLength.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 }); + upDownMaximumLineLength.Minimum = new decimal(new int[] { 20000, 0, 0, 0 }); + upDownMaximumLineLength.Name = "upDownMaximumLineLength"; + upDownMaximumLineLength.Size = new System.Drawing.Size(106, 23); + upDownMaximumLineLength.TabIndex = 15; + upDownMaximumLineLength.Value = new decimal(new int[] { 20000, 0, 0, 0 }); + // + // labelMaximumLineLength + // + labelMaximumLineLength.AutoSize = true; + labelMaximumLineLength.Location = new System.Drawing.Point(467, 140); + labelMaximumLineLength.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelMaximumLineLength.Name = "labelMaximumLineLength"; + labelMaximumLineLength.Size = new System.Drawing.Size(217, 15); + labelMaximumLineLength.TabIndex = 14; + labelMaximumLineLength.Text = "Maximum Line Length (restart required)"; + // + // upDownMaximumFilterEntriesDisplayed + // + upDownMaximumFilterEntriesDisplayed.Location = new System.Drawing.Point(762, 86); + upDownMaximumFilterEntriesDisplayed.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + upDownMaximumFilterEntriesDisplayed.Maximum = new decimal(new int[] { 30, 0, 0, 0 }); + upDownMaximumFilterEntriesDisplayed.Minimum = new decimal(new int[] { 10, 0, 0, 0 }); + upDownMaximumFilterEntriesDisplayed.Name = "upDownMaximumFilterEntriesDisplayed"; + upDownMaximumFilterEntriesDisplayed.Size = new System.Drawing.Size(106, 23); + upDownMaximumFilterEntriesDisplayed.TabIndex = 13; + upDownMaximumFilterEntriesDisplayed.Value = new decimal(new int[] { 20, 0, 0, 0 }); + // + // labelMaximumFilterEntriesDisplayed + // + labelMaximumFilterEntriesDisplayed.AutoSize = true; + labelMaximumFilterEntriesDisplayed.Location = new System.Drawing.Point(467, 88); + labelMaximumFilterEntriesDisplayed.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelMaximumFilterEntriesDisplayed.Name = "labelMaximumFilterEntriesDisplayed"; + labelMaximumFilterEntriesDisplayed.Size = new System.Drawing.Size(179, 15); + labelMaximumFilterEntriesDisplayed.TabIndex = 12; + labelMaximumFilterEntriesDisplayed.Text = "Maximum filter entries displayed"; + // + // upDownMaximumFilterEntries + // + upDownMaximumFilterEntries.Location = new System.Drawing.Point(762, 59); + upDownMaximumFilterEntries.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + upDownMaximumFilterEntries.Minimum = new decimal(new int[] { 10, 0, 0, 0 }); + upDownMaximumFilterEntries.Name = "upDownMaximumFilterEntries"; + upDownMaximumFilterEntries.Size = new System.Drawing.Size(106, 23); + upDownMaximumFilterEntries.TabIndex = 11; + upDownMaximumFilterEntries.Value = new decimal(new int[] { 30, 0, 0, 0 }); + // + // labelMaximumFilterEntries + // + labelMaximumFilterEntries.AutoSize = true; + labelMaximumFilterEntries.Location = new System.Drawing.Point(467, 61); + labelMaximumFilterEntries.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelMaximumFilterEntries.Name = "labelMaximumFilterEntries"; + labelMaximumFilterEntries.Size = new System.Drawing.Size(126, 15); + labelMaximumFilterEntries.TabIndex = 10; + labelMaximumFilterEntries.Text = "Maximum filter entries"; + // + // labelDefaultEncoding + // + labelDefaultEncoding.AutoSize = true; + labelDefaultEncoding.Location = new System.Drawing.Point(467, 34); + labelDefaultEncoding.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelDefaultEncoding.Name = "labelDefaultEncoding"; + labelDefaultEncoding.Size = new System.Drawing.Size(98, 15); + labelDefaultEncoding.TabIndex = 9; + labelDefaultEncoding.Text = "Default encoding"; + // + // comboBoxEncoding + // + comboBoxEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + comboBoxEncoding.FormattingEnabled = true; + comboBoxEncoding.Location = new System.Drawing.Point(691, 26); + comboBoxEncoding.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + comboBoxEncoding.Name = "comboBoxEncoding"; + comboBoxEncoding.Size = new System.Drawing.Size(177, 23); + comboBoxEncoding.TabIndex = 8; + toolTip.SetToolTip(comboBoxEncoding, "Encoding to be used when no BOM header and no persistence data is available."); + // + // groupBoxMisc + // + groupBoxMisc.Controls.Add(checkBoxShowErrorMessageOnlyOneInstance); + groupBoxMisc.Controls.Add(cpDownColumnWidth); + groupBoxMisc.Controls.Add(checkBoxColumnSize); + groupBoxMisc.Controls.Add(buttonTailColor); + groupBoxMisc.Controls.Add(checkBoxTailState); + groupBoxMisc.Controls.Add(checkBoxOpenLastFiles); + groupBoxMisc.Controls.Add(checkBoxSingleInstance); + groupBoxMisc.Controls.Add(checkBoxAskCloseTabs); + groupBoxMisc.Location = new System.Drawing.Point(458, 171); + groupBoxMisc.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxMisc.Name = "groupBoxMisc"; + groupBoxMisc.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxMisc.Size = new System.Drawing.Size(410, 226); + groupBoxMisc.TabIndex = 7; + groupBoxMisc.TabStop = false; + groupBoxMisc.Text = "Misc"; + // + // checkBoxShowErrorMessageOnlyOneInstance + // + checkBoxShowErrorMessageOnlyOneInstance.AutoSize = true; + checkBoxShowErrorMessageOnlyOneInstance.Location = new System.Drawing.Point(210, 66); + checkBoxShowErrorMessageOnlyOneInstance.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxShowErrorMessageOnlyOneInstance.Name = "checkBoxShowErrorMessageOnlyOneInstance"; + checkBoxShowErrorMessageOnlyOneInstance.Size = new System.Drawing.Size(137, 19); + checkBoxShowErrorMessageOnlyOneInstance.TabIndex = 7; + checkBoxShowErrorMessageOnlyOneInstance.Text = "Show Error Message?"; + checkBoxShowErrorMessageOnlyOneInstance.UseVisualStyleBackColor = true; + // + // cpDownColumnWidth + // + cpDownColumnWidth.Location = new System.Drawing.Point(304, 175); + cpDownColumnWidth.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + cpDownColumnWidth.Maximum = new decimal(new int[] { 9000, 0, 0, 0 }); + cpDownColumnWidth.Minimum = new decimal(new int[] { 300, 0, 0, 0 }); + cpDownColumnWidth.Name = "cpDownColumnWidth"; + cpDownColumnWidth.Size = new System.Drawing.Size(84, 23); + cpDownColumnWidth.TabIndex = 6; + cpDownColumnWidth.Value = new decimal(new int[] { 2000, 0, 0, 0 }); + // + // checkBoxColumnSize + // + checkBoxColumnSize.AutoSize = true; + checkBoxColumnSize.Location = new System.Drawing.Point(9, 177); + checkBoxColumnSize.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxColumnSize.Name = "checkBoxColumnSize"; + checkBoxColumnSize.Size = new System.Drawing.Size(140, 19); + checkBoxColumnSize.TabIndex = 5; + checkBoxColumnSize.Text = "Set last column width"; + checkBoxColumnSize.UseVisualStyleBackColor = true; + checkBoxColumnSize.CheckedChanged += OnChkBoxColumnSizeCheckedChanged; + // + // buttonTailColor + // + buttonTailColor.Location = new System.Drawing.Point(304, 135); + buttonTailColor.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonTailColor.Name = "buttonTailColor"; + buttonTailColor.Size = new System.Drawing.Size(84, 32); + buttonTailColor.TabIndex = 4; + buttonTailColor.Text = "Color..."; + buttonTailColor.UseVisualStyleBackColor = true; + buttonTailColor.Click += OnBtnTailColorClick; + // + // checkBoxTailState + // + checkBoxTailState.AutoSize = true; + checkBoxTailState.Location = new System.Drawing.Point(9, 140); + checkBoxTailState.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxTailState.Name = "checkBoxTailState"; + checkBoxTailState.Size = new System.Drawing.Size(144, 19); + checkBoxTailState.TabIndex = 3; + checkBoxTailState.Text = "Show tail state on tabs"; + checkBoxTailState.UseVisualStyleBackColor = true; + // + // checkBoxOpenLastFiles + // + checkBoxOpenLastFiles.AutoSize = true; + checkBoxOpenLastFiles.Location = new System.Drawing.Point(9, 103); + checkBoxOpenLastFiles.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxOpenLastFiles.Name = "checkBoxOpenLastFiles"; + checkBoxOpenLastFiles.Size = new System.Drawing.Size(144, 19); + checkBoxOpenLastFiles.TabIndex = 2; + checkBoxOpenLastFiles.Text = "Re-open last used files"; + checkBoxOpenLastFiles.UseVisualStyleBackColor = true; + // + // checkBoxSingleInstance + // + checkBoxSingleInstance.AutoSize = true; + checkBoxSingleInstance.Location = new System.Drawing.Point(9, 66); + checkBoxSingleInstance.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxSingleInstance.Name = "checkBoxSingleInstance"; + checkBoxSingleInstance.Size = new System.Drawing.Size(138, 19); + checkBoxSingleInstance.TabIndex = 1; + checkBoxSingleInstance.Text = "Allow only 1 Instance"; + checkBoxSingleInstance.UseVisualStyleBackColor = true; + // + // checkBoxAskCloseTabs + // + checkBoxAskCloseTabs.AutoSize = true; + checkBoxAskCloseTabs.Location = new System.Drawing.Point(9, 29); + checkBoxAskCloseTabs.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxAskCloseTabs.Name = "checkBoxAskCloseTabs"; + checkBoxAskCloseTabs.Size = new System.Drawing.Size(148, 19); + checkBoxAskCloseTabs.TabIndex = 0; + checkBoxAskCloseTabs.Text = "Ask before closing tabs"; + checkBoxAskCloseTabs.UseVisualStyleBackColor = true; + // + // groupBoxDefaults + // + groupBoxDefaults.Controls.Add(checkBoxDarkMode); + groupBoxDefaults.Controls.Add(checkBoxFollowTail); + groupBoxDefaults.Controls.Add(checkBoxColumnFinder); + groupBoxDefaults.Controls.Add(checkBoxSyncFilter); + groupBoxDefaults.Controls.Add(checkBoxFilterTail); + groupBoxDefaults.Location = new System.Drawing.Point(10, 171); + groupBoxDefaults.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxDefaults.Name = "groupBoxDefaults"; + groupBoxDefaults.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxDefaults.Size = new System.Drawing.Size(411, 226); + groupBoxDefaults.TabIndex = 6; + groupBoxDefaults.TabStop = false; + groupBoxDefaults.Text = "Defaults"; + // + // checkBoxDarkMode + // + checkBoxDarkMode.AutoSize = true; + checkBoxDarkMode.Location = new System.Drawing.Point(7, 141); + checkBoxDarkMode.Margin = new System.Windows.Forms.Padding(4); + checkBoxDarkMode.Name = "checkBoxDarkMode"; + checkBoxDarkMode.Size = new System.Drawing.Size(175, 19); + checkBoxDarkMode.TabIndex = 6; + checkBoxDarkMode.Text = "Dark Mode (restart required)"; + checkBoxDarkMode.UseVisualStyleBackColor = true; + // + // checkBoxFollowTail + // + checkBoxFollowTail.AutoSize = true; + checkBoxFollowTail.Location = new System.Drawing.Point(9, 29); + checkBoxFollowTail.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxFollowTail.Name = "checkBoxFollowTail"; + checkBoxFollowTail.Size = new System.Drawing.Size(125, 19); + checkBoxFollowTail.TabIndex = 3; + checkBoxFollowTail.Text = "Follow tail enabled"; + checkBoxFollowTail.UseVisualStyleBackColor = true; + // + // checkBoxColumnFinder + // + checkBoxColumnFinder.AutoSize = true; + checkBoxColumnFinder.Location = new System.Drawing.Point(9, 140); + checkBoxColumnFinder.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxColumnFinder.Name = "checkBoxColumnFinder"; + checkBoxColumnFinder.Size = new System.Drawing.Size(133, 19); + checkBoxColumnFinder.TabIndex = 5; + checkBoxColumnFinder.Text = "Show column finder"; + checkBoxColumnFinder.UseVisualStyleBackColor = true; + // + // checkBoxSyncFilter + // + checkBoxSyncFilter.AutoSize = true; + checkBoxSyncFilter.Location = new System.Drawing.Point(9, 103); + checkBoxSyncFilter.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxSyncFilter.Name = "checkBoxSyncFilter"; + checkBoxSyncFilter.Size = new System.Drawing.Size(141, 19); + checkBoxSyncFilter.TabIndex = 5; + checkBoxSyncFilter.Text = "Sync filter list enabled"; + checkBoxSyncFilter.UseVisualStyleBackColor = true; + // + // checkBoxFilterTail + // + checkBoxFilterTail.AutoSize = true; + checkBoxFilterTail.Location = new System.Drawing.Point(9, 66); + checkBoxFilterTail.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxFilterTail.Name = "checkBoxFilterTail"; + checkBoxFilterTail.Size = new System.Drawing.Size(116, 19); + checkBoxFilterTail.TabIndex = 4; + checkBoxFilterTail.Text = "Filter tail enabled"; + checkBoxFilterTail.UseVisualStyleBackColor = true; + // + // groupBoxFont + // + groupBoxFont.Controls.Add(buttonChangeFont); + groupBoxFont.Controls.Add(labelFont); + groupBoxFont.Location = new System.Drawing.Point(10, 9); + groupBoxFont.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxFont.Name = "groupBoxFont"; + groupBoxFont.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxFont.Size = new System.Drawing.Size(408, 128); + groupBoxFont.TabIndex = 1; + groupBoxFont.TabStop = false; + groupBoxFont.Text = "Font"; + // + // buttonChangeFont + // + buttonChangeFont.Location = new System.Drawing.Point(9, 77); + buttonChangeFont.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonChangeFont.Name = "buttonChangeFont"; + buttonChangeFont.Size = new System.Drawing.Size(112, 35); + buttonChangeFont.TabIndex = 1; + buttonChangeFont.Text = "Change..."; + buttonChangeFont.UseVisualStyleBackColor = true; + buttonChangeFont.Click += OnBtnChangeFontClick; + // + // labelFont + // + labelFont.Location = new System.Drawing.Point(9, 25); + labelFont.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelFont.Name = "labelFont"; + labelFont.Size = new System.Drawing.Size(312, 48); + labelFont.TabIndex = 0; + labelFont.Text = "Font"; + labelFont.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // tabPageTimeStampFeatures + // + tabPageTimeStampFeatures.Controls.Add(groupBoxTimeSpreadDisplay); + tabPageTimeStampFeatures.Controls.Add(groupBoxTimeStampNavigationControl); + tabPageTimeStampFeatures.Location = new System.Drawing.Point(4, 24); + tabPageTimeStampFeatures.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPageTimeStampFeatures.Name = "tabPageTimeStampFeatures"; + tabPageTimeStampFeatures.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPageTimeStampFeatures.Size = new System.Drawing.Size(942, 440); + tabPageTimeStampFeatures.TabIndex = 1; + tabPageTimeStampFeatures.Text = "Timestamp features"; + tabPageTimeStampFeatures.UseVisualStyleBackColor = true; + // + // groupBoxTimeSpreadDisplay + // + groupBoxTimeSpreadDisplay.Controls.Add(groupBoxDisplayMode); + groupBoxTimeSpreadDisplay.Controls.Add(checkBoxReverseAlpha); + groupBoxTimeSpreadDisplay.Controls.Add(buttonTimespreadColor); + groupBoxTimeSpreadDisplay.Controls.Add(checkBoxTimeSpread); + groupBoxTimeSpreadDisplay.Location = new System.Drawing.Point(490, 25); + groupBoxTimeSpreadDisplay.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxTimeSpreadDisplay.Name = "groupBoxTimeSpreadDisplay"; + groupBoxTimeSpreadDisplay.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxTimeSpreadDisplay.Size = new System.Drawing.Size(300, 246); + groupBoxTimeSpreadDisplay.TabIndex = 8; + groupBoxTimeSpreadDisplay.TabStop = false; + groupBoxTimeSpreadDisplay.Text = "Time spread display"; + // + // groupBoxDisplayMode + // + groupBoxDisplayMode.Controls.Add(radioButtonLineView); + groupBoxDisplayMode.Controls.Add(radioButtonTimeView); + groupBoxDisplayMode.Location = new System.Drawing.Point(22, 109); + groupBoxDisplayMode.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxDisplayMode.Name = "groupBoxDisplayMode"; + groupBoxDisplayMode.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxDisplayMode.Size = new System.Drawing.Size(188, 118); + groupBoxDisplayMode.TabIndex = 11; + groupBoxDisplayMode.TabStop = false; + groupBoxDisplayMode.Text = "Display mode"; + // + // radioButtonLineView + // + radioButtonLineView.AutoSize = true; + radioButtonLineView.Location = new System.Drawing.Point(9, 65); + radioButtonLineView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + radioButtonLineView.Name = "radioButtonLineView"; + radioButtonLineView.Size = new System.Drawing.Size(74, 19); + radioButtonLineView.TabIndex = 9; + radioButtonLineView.TabStop = true; + radioButtonLineView.Text = "Line view"; + radioButtonLineView.UseVisualStyleBackColor = true; + // + // radioButtonTimeView + // + radioButtonTimeView.AutoSize = true; + radioButtonTimeView.Location = new System.Drawing.Point(9, 29); + radioButtonTimeView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + radioButtonTimeView.Name = "radioButtonTimeView"; + radioButtonTimeView.Size = new System.Drawing.Size(79, 19); + radioButtonTimeView.TabIndex = 10; + radioButtonTimeView.TabStop = true; + radioButtonTimeView.Text = "Time view"; + radioButtonTimeView.UseVisualStyleBackColor = true; + // + // checkBoxReverseAlpha + // + checkBoxReverseAlpha.AutoSize = true; + checkBoxReverseAlpha.Location = new System.Drawing.Point(22, 74); + checkBoxReverseAlpha.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxReverseAlpha.Name = "checkBoxReverseAlpha"; + checkBoxReverseAlpha.Size = new System.Drawing.Size(98, 19); + checkBoxReverseAlpha.TabIndex = 8; + checkBoxReverseAlpha.Text = "Reverse alpha"; + checkBoxReverseAlpha.UseVisualStyleBackColor = true; + // + // buttonTimespreadColor + // + buttonTimespreadColor.Location = new System.Drawing.Point(207, 32); + buttonTimespreadColor.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonTimespreadColor.Name = "buttonTimespreadColor"; + buttonTimespreadColor.Size = new System.Drawing.Size(84, 32); + buttonTimespreadColor.TabIndex = 7; + buttonTimespreadColor.Text = "Color..."; + buttonTimespreadColor.UseVisualStyleBackColor = true; + buttonTimespreadColor.Click += OnBtnTimespreadColorClick; + // + // checkBoxTimeSpread + // + checkBoxTimeSpread.AutoSize = true; + checkBoxTimeSpread.Location = new System.Drawing.Point(22, 37); + checkBoxTimeSpread.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxTimeSpread.Name = "checkBoxTimeSpread"; + checkBoxTimeSpread.Size = new System.Drawing.Size(120, 19); + checkBoxTimeSpread.TabIndex = 6; + checkBoxTimeSpread.Text = "Show time spread"; + checkBoxTimeSpread.UseVisualStyleBackColor = true; + // + // groupBoxTimeStampNavigationControl + // + groupBoxTimeStampNavigationControl.Controls.Add(checkBoxTimestamp); + groupBoxTimeStampNavigationControl.Controls.Add(groupBoxMouseDragDefaults); + groupBoxTimeStampNavigationControl.Location = new System.Drawing.Point(10, 25); + groupBoxTimeStampNavigationControl.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxTimeStampNavigationControl.Name = "groupBoxTimeStampNavigationControl"; + groupBoxTimeStampNavigationControl.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxTimeStampNavigationControl.Size = new System.Drawing.Size(450, 246); + groupBoxTimeStampNavigationControl.TabIndex = 7; + groupBoxTimeStampNavigationControl.TabStop = false; + groupBoxTimeStampNavigationControl.Text = "Timestamp navigation control"; + // + // checkBoxTimestamp + // + checkBoxTimestamp.AutoSize = true; + checkBoxTimestamp.Location = new System.Drawing.Point(27, 37); + checkBoxTimestamp.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxTimestamp.Name = "checkBoxTimestamp"; + checkBoxTimestamp.Size = new System.Drawing.Size(304, 19); + checkBoxTimestamp.TabIndex = 3; + checkBoxTimestamp.Text = "Show timestamp control, if supported by columnizer"; + checkBoxTimestamp.UseVisualStyleBackColor = true; + // + // groupBoxMouseDragDefaults + // + groupBoxMouseDragDefaults.Controls.Add(radioButtonVerticalMouseDragInverted); + groupBoxMouseDragDefaults.Controls.Add(radioButtonHorizMouseDrag); + groupBoxMouseDragDefaults.Controls.Add(radioButtonVerticalMouseDrag); + groupBoxMouseDragDefaults.Location = new System.Drawing.Point(27, 80); + groupBoxMouseDragDefaults.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxMouseDragDefaults.Name = "groupBoxMouseDragDefaults"; + groupBoxMouseDragDefaults.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxMouseDragDefaults.Size = new System.Drawing.Size(186, 148); + groupBoxMouseDragDefaults.TabIndex = 5; + groupBoxMouseDragDefaults.TabStop = false; + groupBoxMouseDragDefaults.Text = "Mouse Drag Default"; + // + // radioButtonVerticalMouseDragInverted + // + radioButtonVerticalMouseDragInverted.AutoSize = true; + radioButtonVerticalMouseDragInverted.Location = new System.Drawing.Point(9, 102); + radioButtonVerticalMouseDragInverted.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + radioButtonVerticalMouseDragInverted.Name = "radioButtonVerticalMouseDragInverted"; + radioButtonVerticalMouseDragInverted.Size = new System.Drawing.Size(109, 19); + radioButtonVerticalMouseDragInverted.TabIndex = 6; + radioButtonVerticalMouseDragInverted.TabStop = true; + radioButtonVerticalMouseDragInverted.Text = "Vertical Inverted"; + radioButtonVerticalMouseDragInverted.UseVisualStyleBackColor = true; + // + // radioButtonHorizMouseDrag + // + radioButtonHorizMouseDrag.AutoSize = true; + radioButtonHorizMouseDrag.Location = new System.Drawing.Point(9, 29); + radioButtonHorizMouseDrag.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + radioButtonHorizMouseDrag.Name = "radioButtonHorizMouseDrag"; + radioButtonHorizMouseDrag.Size = new System.Drawing.Size(80, 19); + radioButtonHorizMouseDrag.TabIndex = 5; + radioButtonHorizMouseDrag.TabStop = true; + radioButtonHorizMouseDrag.Text = "Horizontal"; + radioButtonHorizMouseDrag.UseVisualStyleBackColor = true; + // + // radioButtonVerticalMouseDrag + // + radioButtonVerticalMouseDrag.AutoSize = true; + radioButtonVerticalMouseDrag.Location = new System.Drawing.Point(9, 65); + radioButtonVerticalMouseDrag.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + radioButtonVerticalMouseDrag.Name = "radioButtonVerticalMouseDrag"; + radioButtonVerticalMouseDrag.Size = new System.Drawing.Size(63, 19); + radioButtonVerticalMouseDrag.TabIndex = 4; + radioButtonVerticalMouseDrag.TabStop = true; + radioButtonVerticalMouseDrag.Text = "Vertical"; + radioButtonVerticalMouseDrag.UseVisualStyleBackColor = true; + // + // tabPageExternalTools + // + tabPageExternalTools.Controls.Add(labelToolsDescription); + tabPageExternalTools.Controls.Add(buttonToolDelete); + tabPageExternalTools.Controls.Add(buttonToolAdd); + tabPageExternalTools.Controls.Add(buttonToolDown); + tabPageExternalTools.Controls.Add(buttonToolUp); + tabPageExternalTools.Controls.Add(listBoxTools); + tabPageExternalTools.Controls.Add(groupBoxToolSettings); + tabPageExternalTools.Location = new System.Drawing.Point(4, 24); + tabPageExternalTools.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPageExternalTools.Name = "tabPageExternalTools"; + tabPageExternalTools.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPageExternalTools.Size = new System.Drawing.Size(942, 440); + tabPageExternalTools.TabIndex = 2; + tabPageExternalTools.Text = "External Tools"; + tabPageExternalTools.UseVisualStyleBackColor = true; + // + // labelToolsDescription + // + labelToolsDescription.Location = new System.Drawing.Point(546, 102); + labelToolsDescription.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelToolsDescription.Name = "labelToolsDescription"; + labelToolsDescription.Size = new System.Drawing.Size(376, 80); + labelToolsDescription.TabIndex = 6; + labelToolsDescription.Text = "You can configure as many tools as you want. \r\nChecked tools will appear in the icon bar. All other tools are available in the tools menu."; + // + // buttonToolDelete + // + buttonToolDelete.Location = new System.Drawing.Point(550, 14); + buttonToolDelete.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonToolDelete.Name = "buttonToolDelete"; + buttonToolDelete.Size = new System.Drawing.Size(112, 35); + buttonToolDelete.TabIndex = 2; + buttonToolDelete.Text = "Remove"; + buttonToolDelete.UseVisualStyleBackColor = true; + buttonToolDelete.Click += OnToolDeleteButtonClick; + // + // buttonToolAdd + // + buttonToolAdd.Location = new System.Drawing.Point(429, 14); + buttonToolAdd.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonToolAdd.Name = "buttonToolAdd"; + buttonToolAdd.Size = new System.Drawing.Size(112, 35); + buttonToolAdd.TabIndex = 1; + buttonToolAdd.Text = "Add new"; + buttonToolAdd.UseVisualStyleBackColor = true; + buttonToolAdd.Click += OnBtnToolAddClick; + // + // buttonToolDown + // + buttonToolDown.Location = new System.Drawing.Point(429, 146); + buttonToolDown.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonToolDown.Name = "buttonToolDown"; + buttonToolDown.Size = new System.Drawing.Size(64, 35); + buttonToolDown.TabIndex = 4; + buttonToolDown.Text = "Down"; + buttonToolDown.UseVisualStyleBackColor = true; + buttonToolDown.Click += OnBtnToolDownClick; + // + // buttonToolUp + // + buttonToolUp.Location = new System.Drawing.Point(429, 102); + buttonToolUp.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonToolUp.Name = "buttonToolUp"; + buttonToolUp.Size = new System.Drawing.Size(64, 35); + buttonToolUp.TabIndex = 3; + buttonToolUp.Text = "Up"; + buttonToolUp.UseVisualStyleBackColor = true; + buttonToolUp.Click += OnBtnToolUpClick; + // + // listBoxTools + // + listBoxTools.FormattingEnabled = true; + listBoxTools.Location = new System.Drawing.Point(10, 14); + listBoxTools.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + listBoxTools.Name = "listBoxTools"; + listBoxTools.Size = new System.Drawing.Size(406, 148); + listBoxTools.TabIndex = 0; + listBoxTools.SelectedIndexChanged += OnListBoxToolSelectedIndexChanged; + // + // groupBoxToolSettings + // + groupBoxToolSettings.Controls.Add(labelWorkingDir); + groupBoxToolSettings.Controls.Add(buttonWorkingDir); + groupBoxToolSettings.Controls.Add(textBoxWorkingDir); + groupBoxToolSettings.Controls.Add(buttonIcon); + groupBoxToolSettings.Controls.Add(labelToolName); + groupBoxToolSettings.Controls.Add(labelToolColumnizerForOutput); + groupBoxToolSettings.Controls.Add(comboBoxColumnizer); + groupBoxToolSettings.Controls.Add(textBoxToolName); + groupBoxToolSettings.Controls.Add(checkBoxSysout); + groupBoxToolSettings.Controls.Add(buttonArguments); + groupBoxToolSettings.Controls.Add(labelTool); + groupBoxToolSettings.Controls.Add(buttonTool); + groupBoxToolSettings.Controls.Add(textBoxTool); + groupBoxToolSettings.Controls.Add(labelArguments); + groupBoxToolSettings.Controls.Add(textBoxArguments); + groupBoxToolSettings.Location = new System.Drawing.Point(10, 191); + groupBoxToolSettings.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxToolSettings.Name = "groupBoxToolSettings"; + groupBoxToolSettings.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxToolSettings.Size = new System.Drawing.Size(912, 228); + groupBoxToolSettings.TabIndex = 0; + groupBoxToolSettings.TabStop = false; + groupBoxToolSettings.Text = "Tool settings"; + // + // labelWorkingDir + // + labelWorkingDir.AutoSize = true; + labelWorkingDir.Location = new System.Drawing.Point(474, 86); + labelWorkingDir.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelWorkingDir.Name = "labelWorkingDir"; + labelWorkingDir.Size = new System.Drawing.Size(72, 15); + labelWorkingDir.TabIndex = 11; + labelWorkingDir.Text = "Working dir:"; + // + // buttonWorkingDir + // + buttonWorkingDir.Location = new System.Drawing.Point(856, 80); + buttonWorkingDir.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonWorkingDir.Name = "buttonWorkingDir"; + buttonWorkingDir.Size = new System.Drawing.Size(45, 31); + buttonWorkingDir.TabIndex = 10; + buttonWorkingDir.Text = "..."; + buttonWorkingDir.UseVisualStyleBackColor = true; + buttonWorkingDir.Click += OnBtnWorkingDirClick; + // + // textBoxWorkingDir + // + textBoxWorkingDir.Location = new System.Drawing.Point(576, 82); + textBoxWorkingDir.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + textBoxWorkingDir.Name = "textBoxWorkingDir"; + textBoxWorkingDir.Size = new System.Drawing.Size(270, 23); + textBoxWorkingDir.TabIndex = 9; + // + // buttonIcon + // + buttonIcon.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; + buttonIcon.Location = new System.Drawing.Point(418, 26); + buttonIcon.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonIcon.Name = "buttonIcon"; + buttonIcon.Size = new System.Drawing.Size(112, 35); + buttonIcon.TabIndex = 1; + buttonIcon.Text = " Icon..."; + buttonIcon.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + buttonIcon.UseVisualStyleBackColor = true; + buttonIcon.Click += OnBtnIconClick; + // + // labelToolName + // + labelToolName.AutoSize = true; + labelToolName.Location = new System.Drawing.Point(9, 34); + labelToolName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelToolName.Name = "labelToolName"; + labelToolName.Size = new System.Drawing.Size(42, 15); + labelToolName.TabIndex = 8; + labelToolName.Text = "Name:"; + // + // labelToolColumnizerForOutput + // + labelToolColumnizerForOutput.AutoSize = true; + labelToolColumnizerForOutput.Location = new System.Drawing.Point(404, 185); + labelToolColumnizerForOutput.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelToolColumnizerForOutput.Name = "labelToolColumnizerForOutput"; + labelToolColumnizerForOutput.Size = new System.Drawing.Size(128, 15); + labelToolColumnizerForOutput.TabIndex = 6; + labelToolColumnizerForOutput.Text = "Columnizer for output:"; + // + // comboBoxColumnizer + // + comboBoxColumnizer.FormattingEnabled = true; + comboBoxColumnizer.Location = new System.Drawing.Point(576, 180); + comboBoxColumnizer.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + comboBoxColumnizer.Name = "comboBoxColumnizer"; + comboBoxColumnizer.Size = new System.Drawing.Size(270, 23); + comboBoxColumnizer.TabIndex = 7; + // + // textBoxToolName + // + textBoxToolName.Location = new System.Drawing.Point(108, 29); + textBoxToolName.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + textBoxToolName.Name = "textBoxToolName"; + textBoxToolName.Size = new System.Drawing.Size(298, 23); + textBoxToolName.TabIndex = 0; + // + // checkBoxSysout + // + checkBoxSysout.AutoSize = true; + checkBoxSysout.Location = new System.Drawing.Point(108, 183); + checkBoxSysout.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxSysout.Name = "checkBoxSysout"; + checkBoxSysout.Size = new System.Drawing.Size(120, 19); + checkBoxSysout.TabIndex = 6; + checkBoxSysout.Text = "Pipe sysout to tab"; + checkBoxSysout.UseVisualStyleBackColor = true; + checkBoxSysout.CheckedChanged += OnChkBoxSysoutCheckedChanged; + // + // buttonArguments + // + buttonArguments.Location = new System.Drawing.Point(856, 128); + buttonArguments.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonArguments.Name = "buttonArguments"; + buttonArguments.Size = new System.Drawing.Size(46, 32); + buttonArguments.TabIndex = 5; + buttonArguments.Text = "..."; + buttonArguments.UseVisualStyleBackColor = true; + buttonArguments.Click += OnBtnArgClick; + // + // labelTool + // + labelTool.AutoSize = true; + labelTool.Location = new System.Drawing.Point(9, 86); + labelTool.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelTool.Name = "labelTool"; + labelTool.Size = new System.Drawing.Size(56, 15); + labelTool.TabIndex = 4; + labelTool.Text = "Program:"; + // + // buttonTool + // + buttonTool.Location = new System.Drawing.Point(418, 78); + buttonTool.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonTool.Name = "buttonTool"; + buttonTool.Size = new System.Drawing.Size(45, 31); + buttonTool.TabIndex = 3; + buttonTool.Text = "..."; + buttonTool.UseVisualStyleBackColor = true; + buttonTool.Click += OnBtnToolClick; + // + // textBoxTool + // + textBoxTool.Location = new System.Drawing.Point(108, 80); + textBoxTool.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + textBoxTool.Name = "textBoxTool"; + textBoxTool.Size = new System.Drawing.Size(298, 23); + textBoxTool.TabIndex = 2; + // + // labelArguments + // + labelArguments.AutoSize = true; + labelArguments.Location = new System.Drawing.Point(9, 134); + labelArguments.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelArguments.Name = "labelArguments"; + labelArguments.Size = new System.Drawing.Size(69, 15); + labelArguments.TabIndex = 1; + labelArguments.Text = "Arguments:"; + // + // textBoxArguments + // + textBoxArguments.Location = new System.Drawing.Point(108, 129); + textBoxArguments.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + textBoxArguments.Name = "textBoxArguments"; + textBoxArguments.Size = new System.Drawing.Size(738, 23); + textBoxArguments.TabIndex = 4; + // + // tabPageColumnizers + // + tabPageColumnizers.Controls.Add(checkBoxAutoPick); + tabPageColumnizers.Controls.Add(checkBoxMaskPrio); + tabPageColumnizers.Controls.Add(buttonDelete); + tabPageColumnizers.Controls.Add(dataGridViewColumnizer); + tabPageColumnizers.Location = new System.Drawing.Point(4, 24); + tabPageColumnizers.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPageColumnizers.Name = "tabPageColumnizers"; + tabPageColumnizers.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPageColumnizers.Size = new System.Drawing.Size(942, 440); + tabPageColumnizers.TabIndex = 3; + tabPageColumnizers.Text = "Columnizers"; + tabPageColumnizers.UseVisualStyleBackColor = true; + // + // checkBoxAutoPick + // + checkBoxAutoPick.AutoSize = true; + checkBoxAutoPick.Checked = true; + checkBoxAutoPick.CheckState = System.Windows.Forms.CheckState.Checked; + checkBoxAutoPick.Location = new System.Drawing.Point(530, 386); + checkBoxAutoPick.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxAutoPick.Name = "checkBoxAutoPick"; + checkBoxAutoPick.Size = new System.Drawing.Size(192, 19); + checkBoxAutoPick.TabIndex = 5; + checkBoxAutoPick.Text = "Automatically pick for new files"; + checkBoxAutoPick.UseVisualStyleBackColor = true; + // + // checkBoxMaskPrio + // + checkBoxMaskPrio.AutoSize = true; + checkBoxMaskPrio.Location = new System.Drawing.Point(213, 388); + checkBoxMaskPrio.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxMaskPrio.Name = "checkBoxMaskPrio"; + checkBoxMaskPrio.Size = new System.Drawing.Size(192, 19); + checkBoxMaskPrio.TabIndex = 4; + checkBoxMaskPrio.Text = "Mask has priority before history"; + checkBoxMaskPrio.UseVisualStyleBackColor = true; + // + // buttonDelete + // + buttonDelete.Location = new System.Drawing.Point(12, 380); + buttonDelete.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new System.Drawing.Size(112, 35); + buttonDelete.TabIndex = 3; + buttonDelete.Text = "Delete"; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += OnBtnDeleteClick; + // + // dataGridViewColumnizer + // + dataGridViewColumnizer.AllowUserToResizeRows = false; + dataGridViewColumnizer.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewColumnizer.BackgroundColor = System.Drawing.SystemColors.ControlLight; + dataGridViewColumnizer.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewColumnizer.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { columnFileMask, columnColumnizer }); + dataGridViewColumnizer.Dock = System.Windows.Forms.DockStyle.Top; + dataGridViewColumnizer.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter; + dataGridViewColumnizer.Location = new System.Drawing.Point(4, 5); + dataGridViewColumnizer.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + dataGridViewColumnizer.Name = "dataGridViewColumnizer"; + dataGridViewColumnizer.RowHeadersWidth = 62; + dataGridViewColumnizer.Size = new System.Drawing.Size(934, 365); + dataGridViewColumnizer.TabIndex = 2; + dataGridViewColumnizer.RowsAdded += OnDataGridViewColumnizerRowsAdded; + // + // columnFileMask + // + columnFileMask.HeaderText = "File name mask (RegEx)"; + columnFileMask.MinimumWidth = 40; + columnFileMask.Name = "columnFileMask"; + // + // columnColumnizer + // + columnColumnizer.HeaderText = "Columnizer"; + columnColumnizer.MinimumWidth = 230; + columnColumnizer.Name = "columnColumnizer"; + // + // tabPageHighlightMask + // + tabPageHighlightMask.Controls.Add(dataGridViewHighlightMask); + tabPageHighlightMask.Location = new System.Drawing.Point(4, 24); + tabPageHighlightMask.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPageHighlightMask.Name = "tabPageHighlightMask"; + tabPageHighlightMask.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPageHighlightMask.Size = new System.Drawing.Size(942, 440); + tabPageHighlightMask.TabIndex = 8; + tabPageHighlightMask.Text = "Highlight"; + tabPageHighlightMask.UseVisualStyleBackColor = true; + // + // dataGridViewHighlightMask + // + dataGridViewHighlightMask.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewHighlightMask.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewHighlightMask.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { columnFileName, columnHighlightGroup }); + dataGridViewHighlightMask.Dock = System.Windows.Forms.DockStyle.Fill; + dataGridViewHighlightMask.Location = new System.Drawing.Point(4, 5); + dataGridViewHighlightMask.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + dataGridViewHighlightMask.Name = "dataGridViewHighlightMask"; + dataGridViewHighlightMask.RowHeadersWidth = 62; + dataGridViewHighlightMask.Size = new System.Drawing.Size(934, 430); + dataGridViewHighlightMask.TabIndex = 0; + // + // columnFileName + // + columnFileName.HeaderText = "File name mask (RegEx)"; + columnFileName.MinimumWidth = 40; + columnFileName.Name = "columnFileName"; + // + // columnHighlightGroup + // + columnHighlightGroup.HeaderText = "Highlight group"; + columnHighlightGroup.MinimumWidth = 50; + columnHighlightGroup.Name = "columnHighlightGroup"; + // + // tabPageMultiFile + // + tabPageMultiFile.Controls.Add(groupBoxDefaultFileNamePattern); + tabPageMultiFile.Controls.Add(labelHintMultiFile); + tabPageMultiFile.Controls.Add(labelNoteMultiFile); + tabPageMultiFile.Controls.Add(groupBoxWhenOpeningMultiFile); + tabPageMultiFile.Location = new System.Drawing.Point(4, 24); + tabPageMultiFile.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPageMultiFile.Name = "tabPageMultiFile"; + tabPageMultiFile.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPageMultiFile.Size = new System.Drawing.Size(942, 440); + tabPageMultiFile.TabIndex = 4; + tabPageMultiFile.Text = "MultiFile"; + tabPageMultiFile.UseVisualStyleBackColor = true; + // + // groupBoxDefaultFileNamePattern + // + groupBoxDefaultFileNamePattern.Controls.Add(labelMaxDays); + groupBoxDefaultFileNamePattern.Controls.Add(labelPattern); + groupBoxDefaultFileNamePattern.Controls.Add(upDownMultifileDays); + groupBoxDefaultFileNamePattern.Controls.Add(textBoxMultifilePattern); + groupBoxDefaultFileNamePattern.Location = new System.Drawing.Point(364, 28); + groupBoxDefaultFileNamePattern.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxDefaultFileNamePattern.Name = "groupBoxDefaultFileNamePattern"; + groupBoxDefaultFileNamePattern.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxDefaultFileNamePattern.Size = new System.Drawing.Size(436, 154); + groupBoxDefaultFileNamePattern.TabIndex = 3; + groupBoxDefaultFileNamePattern.TabStop = false; + groupBoxDefaultFileNamePattern.Text = "Default filename pattern"; + // + // labelMaxDays + // + labelMaxDays.AutoSize = true; + labelMaxDays.Location = new System.Drawing.Point(10, 75); + labelMaxDays.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelMaxDays.Name = "labelMaxDays"; + labelMaxDays.Size = new System.Drawing.Size(59, 15); + labelMaxDays.TabIndex = 3; + labelMaxDays.Text = "Max days:"; + // + // labelPattern + // + labelPattern.AutoSize = true; + labelPattern.Location = new System.Drawing.Point(10, 37); + labelPattern.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelPattern.Name = "labelPattern"; + labelPattern.Size = new System.Drawing.Size(48, 15); + labelPattern.TabIndex = 2; + labelPattern.Text = "Pattern:"; + // + // upDownMultifileDays + // + upDownMultifileDays.Location = new System.Drawing.Point(102, 72); + upDownMultifileDays.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + upDownMultifileDays.Maximum = new decimal(new int[] { 40, 0, 0, 0 }); + upDownMultifileDays.Name = "upDownMultifileDays"; + helpProvider.SetShowHelp(upDownMultifileDays, false); + upDownMultifileDays.Size = new System.Drawing.Size(92, 23); + upDownMultifileDays.TabIndex = 1; + upDownMultifileDays.Value = new decimal(new int[] { 1, 0, 0, 0 }); + // + // textBoxMultifilePattern + // + textBoxMultifilePattern.Location = new System.Drawing.Point(102, 32); + textBoxMultifilePattern.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + textBoxMultifilePattern.Name = "textBoxMultifilePattern"; + textBoxMultifilePattern.Size = new System.Drawing.Size(278, 23); + textBoxMultifilePattern.TabIndex = 0; + textBoxMultifilePattern.TextChanged += OnMultiFilePatternTextChanged; + // + // labelHintMultiFile + // + labelHintMultiFile.Location = new System.Drawing.Point(6, 203); + labelHintMultiFile.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelHintMultiFile.Name = "labelHintMultiFile"; + labelHintMultiFile.Size = new System.Drawing.Size(304, 111); + labelHintMultiFile.TabIndex = 2; + labelHintMultiFile.Text = "Hint: Pressing the Shift key while dropping files onto LogExpert will switch the behaviour from single to multi and vice versa."; + // + // labelNoteMultiFile + // + labelNoteMultiFile.Location = new System.Drawing.Point(6, 314); + labelNoteMultiFile.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelNoteMultiFile.Name = "labelNoteMultiFile"; + labelNoteMultiFile.Size = new System.Drawing.Size(705, 82); + labelNoteMultiFile.TabIndex = 1; + labelNoteMultiFile.Text = resources.GetString("labelNoteMultiFile.Text"); + // + // groupBoxWhenOpeningMultiFile + // + groupBoxWhenOpeningMultiFile.Controls.Add(radioButtonAskWhatToDo); + groupBoxWhenOpeningMultiFile.Controls.Add(radioButtonTreatAllFilesAsOneMultifile); + groupBoxWhenOpeningMultiFile.Controls.Add(radioButtonLoadEveryFileIntoSeperatedTab); + groupBoxWhenOpeningMultiFile.Location = new System.Drawing.Point(10, 28); + groupBoxWhenOpeningMultiFile.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxWhenOpeningMultiFile.Name = "groupBoxWhenOpeningMultiFile"; + groupBoxWhenOpeningMultiFile.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxWhenOpeningMultiFile.Size = new System.Drawing.Size(300, 154); + groupBoxWhenOpeningMultiFile.TabIndex = 0; + groupBoxWhenOpeningMultiFile.TabStop = false; + groupBoxWhenOpeningMultiFile.Text = "When opening multiple files..."; + // + // radioButtonAskWhatToDo + // + radioButtonAskWhatToDo.AutoSize = true; + radioButtonAskWhatToDo.Location = new System.Drawing.Point(10, 105); + radioButtonAskWhatToDo.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + radioButtonAskWhatToDo.Name = "radioButtonAskWhatToDo"; + radioButtonAskWhatToDo.Size = new System.Drawing.Size(104, 19); + radioButtonAskWhatToDo.TabIndex = 2; + radioButtonAskWhatToDo.TabStop = true; + radioButtonAskWhatToDo.Text = "Ask what to do"; + radioButtonAskWhatToDo.UseVisualStyleBackColor = true; + // + // radioButtonTreatAllFilesAsOneMultifile + // + radioButtonTreatAllFilesAsOneMultifile.AutoSize = true; + radioButtonTreatAllFilesAsOneMultifile.Location = new System.Drawing.Point(10, 68); + radioButtonTreatAllFilesAsOneMultifile.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + radioButtonTreatAllFilesAsOneMultifile.Name = "radioButtonTreatAllFilesAsOneMultifile"; + radioButtonTreatAllFilesAsOneMultifile.Size = new System.Drawing.Size(182, 19); + radioButtonTreatAllFilesAsOneMultifile.TabIndex = 1; + radioButtonTreatAllFilesAsOneMultifile.TabStop = true; + radioButtonTreatAllFilesAsOneMultifile.Text = "Treat all files as one 'MultiFile'"; + radioButtonTreatAllFilesAsOneMultifile.UseVisualStyleBackColor = true; + // + // radioButtonLoadEveryFileIntoSeperatedTab + // + radioButtonLoadEveryFileIntoSeperatedTab.AutoSize = true; + radioButtonLoadEveryFileIntoSeperatedTab.Location = new System.Drawing.Point(10, 31); + radioButtonLoadEveryFileIntoSeperatedTab.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + radioButtonLoadEveryFileIntoSeperatedTab.Name = "radioButtonLoadEveryFileIntoSeperatedTab"; + radioButtonLoadEveryFileIntoSeperatedTab.Size = new System.Drawing.Size(201, 19); + radioButtonLoadEveryFileIntoSeperatedTab.TabIndex = 0; + radioButtonLoadEveryFileIntoSeperatedTab.TabStop = true; + radioButtonLoadEveryFileIntoSeperatedTab.Text = "Load every file into a separate tab"; + radioButtonLoadEveryFileIntoSeperatedTab.UseVisualStyleBackColor = true; + // + // tabPagePlugins + // + tabPagePlugins.Controls.Add(groupBoxPlugins); + tabPagePlugins.Controls.Add(groupBoxSettings); + tabPagePlugins.Location = new System.Drawing.Point(4, 24); + tabPagePlugins.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPagePlugins.Name = "tabPagePlugins"; + tabPagePlugins.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPagePlugins.Size = new System.Drawing.Size(942, 440); + tabPagePlugins.TabIndex = 5; + tabPagePlugins.Text = "Plugins"; + tabPagePlugins.UseVisualStyleBackColor = true; + // + // groupBoxPlugins + // + groupBoxPlugins.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + groupBoxPlugins.Controls.Add(listBoxPlugin); + groupBoxPlugins.Location = new System.Drawing.Point(10, 23); + groupBoxPlugins.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxPlugins.Name = "groupBoxPlugins"; + groupBoxPlugins.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxPlugins.Size = new System.Drawing.Size(342, 400); + groupBoxPlugins.TabIndex = 3; + groupBoxPlugins.TabStop = false; + groupBoxPlugins.Text = "Plugins"; + // + // listBoxPlugin + // + listBoxPlugin.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + listBoxPlugin.DisplayMember = "Text"; + listBoxPlugin.FormattingEnabled = true; + listBoxPlugin.ItemHeight = 15; + listBoxPlugin.Location = new System.Drawing.Point(9, 29); + listBoxPlugin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + listBoxPlugin.Name = "listBoxPlugin"; + listBoxPlugin.Size = new System.Drawing.Size(322, 349); + listBoxPlugin.TabIndex = 0; + listBoxPlugin.ValueMember = "Text"; + listBoxPlugin.SelectedIndexChanged += OnListBoxPluginSelectedIndexChanged; + // + // groupBoxSettings + // + groupBoxSettings.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + groupBoxSettings.Controls.Add(panelPlugin); + groupBoxSettings.Location = new System.Drawing.Point(362, 23); + groupBoxSettings.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxSettings.Name = "groupBoxSettings"; + groupBoxSettings.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxSettings.Size = new System.Drawing.Size(567, 400); + groupBoxSettings.TabIndex = 2; + groupBoxSettings.TabStop = false; + groupBoxSettings.Text = "Settings"; + // + // panelPlugin + // + panelPlugin.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + panelPlugin.AutoScroll = true; + panelPlugin.Controls.Add(buttonConfigPlugin); + panelPlugin.Location = new System.Drawing.Point(9, 29); + panelPlugin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + panelPlugin.Name = "panelPlugin"; + panelPlugin.Size = new System.Drawing.Size(549, 362); + panelPlugin.TabIndex = 1; + // + // buttonConfigPlugin + // + buttonConfigPlugin.Location = new System.Drawing.Point(164, 163); + buttonConfigPlugin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonConfigPlugin.Name = "buttonConfigPlugin"; + buttonConfigPlugin.Size = new System.Drawing.Size(170, 35); + buttonConfigPlugin.TabIndex = 0; + buttonConfigPlugin.Text = "Configure..."; + buttonConfigPlugin.UseVisualStyleBackColor = true; + buttonConfigPlugin.Click += OnBtnConfigPluginClick; + // + // tabPageSessions + // + tabPageSessions.Controls.Add(checkBoxPortableMode); + tabPageSessions.Controls.Add(checkBoxSaveFilter); + tabPageSessions.Controls.Add(groupBoxPersistantFileLocation); + tabPageSessions.Controls.Add(checkBoxSaveSessions); + tabPageSessions.Location = new System.Drawing.Point(4, 24); + tabPageSessions.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPageSessions.Name = "tabPageSessions"; + tabPageSessions.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPageSessions.Size = new System.Drawing.Size(942, 440); + tabPageSessions.TabIndex = 6; + tabPageSessions.Text = "Persistence"; + tabPageSessions.UseVisualStyleBackColor = true; + // + // checkBoxPortableMode + // + checkBoxPortableMode.AutoSize = true; + checkBoxPortableMode.Location = new System.Drawing.Point(35, 110); + checkBoxPortableMode.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxPortableMode.Name = "checkBoxPortableMode"; + checkBoxPortableMode.Size = new System.Drawing.Size(150, 19); + checkBoxPortableMode.TabIndex = 3; + checkBoxPortableMode.Text = "Activate Portable Mode"; + toolTip.SetToolTip(checkBoxPortableMode, "If this mode is activated, the save file will be loaded from the Executable Location"); + checkBoxPortableMode.UseVisualStyleBackColor = true; + checkBoxPortableMode.CheckedChanged += OnPortableModeCheckedChanged; + // + // checkBoxSaveFilter + // + checkBoxSaveFilter.AutoSize = true; + checkBoxSaveFilter.Location = new System.Drawing.Point(35, 75); + checkBoxSaveFilter.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxSaveFilter.Name = "checkBoxSaveFilter"; + checkBoxSaveFilter.Size = new System.Drawing.Size(217, 19); + checkBoxSaveFilter.TabIndex = 2; + checkBoxSaveFilter.Text = " Save and restore filter and filter tabs"; + checkBoxSaveFilter.UseVisualStyleBackColor = true; + // + // groupBoxPersistantFileLocation + // + groupBoxPersistantFileLocation.Controls.Add(labelSessionSaveOwnDir); + groupBoxPersistantFileLocation.Controls.Add(buttonSessionSaveDir); + groupBoxPersistantFileLocation.Controls.Add(radioButtonSessionSaveOwn); + groupBoxPersistantFileLocation.Controls.Add(radioButtonsessionSaveDocuments); + groupBoxPersistantFileLocation.Controls.Add(radioButtonSessionSameDir); + groupBoxPersistantFileLocation.Controls.Add(radioButtonSessionApplicationStartupDir); + groupBoxPersistantFileLocation.Location = new System.Drawing.Point(34, 145); + groupBoxPersistantFileLocation.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxPersistantFileLocation.Name = "groupBoxPersistantFileLocation"; + groupBoxPersistantFileLocation.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxPersistantFileLocation.Size = new System.Drawing.Size(411, 190); + groupBoxPersistantFileLocation.TabIndex = 1; + groupBoxPersistantFileLocation.TabStop = false; + groupBoxPersistantFileLocation.Text = "Persistence file location"; + // + // labelSessionSaveOwnDir + // + labelSessionSaveOwnDir.Location = new System.Drawing.Point(27, 160); + labelSessionSaveOwnDir.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelSessionSaveOwnDir.Name = "labelSessionSaveOwnDir"; + labelSessionSaveOwnDir.Size = new System.Drawing.Size(252, 31); + labelSessionSaveOwnDir.TabIndex = 4; + labelSessionSaveOwnDir.Text = "sessionSaveOwnDirLabel"; + // + // buttonSessionSaveDir + // + buttonSessionSaveDir.Location = new System.Drawing.Point(358, 135); + buttonSessionSaveDir.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonSessionSaveDir.Name = "buttonSessionSaveDir"; + buttonSessionSaveDir.Size = new System.Drawing.Size(45, 19); + buttonSessionSaveDir.TabIndex = 3; + buttonSessionSaveDir.Text = "..."; + buttonSessionSaveDir.UseVisualStyleBackColor = true; + buttonSessionSaveDir.Click += OnBtnSessionSaveDirClick; + // + // radioButtonSessionSaveOwn + // + radioButtonSessionSaveOwn.AutoSize = true; + radioButtonSessionSaveOwn.Location = new System.Drawing.Point(10, 135); + radioButtonSessionSaveOwn.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + radioButtonSessionSaveOwn.Name = "radioButtonSessionSaveOwn"; + radioButtonSessionSaveOwn.Size = new System.Drawing.Size(100, 19); + radioButtonSessionSaveOwn.TabIndex = 2; + radioButtonSessionSaveOwn.TabStop = true; + radioButtonSessionSaveOwn.Text = "Own directory"; + radioButtonSessionSaveOwn.UseVisualStyleBackColor = true; + // + // radioButtonsessionSaveDocuments + // + radioButtonsessionSaveDocuments.AutoSize = true; + radioButtonsessionSaveDocuments.Location = new System.Drawing.Point(10, 65); + radioButtonsessionSaveDocuments.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + radioButtonsessionSaveDocuments.Name = "radioButtonsessionSaveDocuments"; + radioButtonsessionSaveDocuments.Size = new System.Drawing.Size(160, 19); + radioButtonsessionSaveDocuments.TabIndex = 1; + radioButtonsessionSaveDocuments.TabStop = true; + radioButtonsessionSaveDocuments.Text = "MyDocuments/LogExpert"; + radioButtonsessionSaveDocuments.UseVisualStyleBackColor = true; + // + // radioButtonSessionSameDir + // + radioButtonSessionSameDir.AutoSize = true; + radioButtonSessionSameDir.Location = new System.Drawing.Point(10, 30); + radioButtonSessionSameDir.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + radioButtonSessionSameDir.Name = "radioButtonSessionSameDir"; + radioButtonSessionSameDir.Size = new System.Drawing.Size(157, 19); + radioButtonSessionSameDir.TabIndex = 0; + radioButtonSessionSameDir.TabStop = true; + radioButtonSessionSameDir.Text = "Same directory as log file"; + radioButtonSessionSameDir.UseVisualStyleBackColor = true; + // + // radioButtonSessionApplicationStartupDir + // + radioButtonSessionApplicationStartupDir.AutoSize = true; + radioButtonSessionApplicationStartupDir.Location = new System.Drawing.Point(10, 100); + radioButtonSessionApplicationStartupDir.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + radioButtonSessionApplicationStartupDir.Name = "radioButtonSessionApplicationStartupDir"; + radioButtonSessionApplicationStartupDir.Size = new System.Drawing.Size(176, 19); + radioButtonSessionApplicationStartupDir.TabIndex = 5; + radioButtonSessionApplicationStartupDir.TabStop = true; + radioButtonSessionApplicationStartupDir.Text = "Application startup directory"; + toolTip.SetToolTip(radioButtonSessionApplicationStartupDir, "This path is based on the executable and where it has been started from."); + radioButtonSessionApplicationStartupDir.UseVisualStyleBackColor = true; + // + // checkBoxSaveSessions + // + checkBoxSaveSessions.AutoSize = true; + checkBoxSaveSessions.Location = new System.Drawing.Point(35, 40); + checkBoxSaveSessions.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxSaveSessions.Name = "checkBoxSaveSessions"; + checkBoxSaveSessions.Size = new System.Drawing.Size(241, 19); + checkBoxSaveSessions.TabIndex = 0; + checkBoxSaveSessions.Text = "Automatically save persistence files (.lxp)"; + checkBoxSaveSessions.UseVisualStyleBackColor = true; + // + // tabPageMemory + // + tabPageMemory.Controls.Add(groupBoxCPUAndStuff); + tabPageMemory.Controls.Add(groupBoxLineBufferUsage); + tabPageMemory.Location = new System.Drawing.Point(4, 24); + tabPageMemory.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPageMemory.Name = "tabPageMemory"; + tabPageMemory.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + tabPageMemory.Size = new System.Drawing.Size(942, 440); + tabPageMemory.TabIndex = 7; + tabPageMemory.Text = "Memory/CPU"; + tabPageMemory.UseVisualStyleBackColor = true; + // + // groupBoxCPUAndStuff + // + groupBoxCPUAndStuff.Controls.Add(checkBoxLegacyReader); + groupBoxCPUAndStuff.Controls.Add(checkBoxMultiThread); + groupBoxCPUAndStuff.Controls.Add(labelFilePollingInterval); + groupBoxCPUAndStuff.Controls.Add(upDownPollingInterval); + groupBoxCPUAndStuff.Location = new System.Drawing.Point(408, 29); + groupBoxCPUAndStuff.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxCPUAndStuff.Name = "groupBoxCPUAndStuff"; + groupBoxCPUAndStuff.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxCPUAndStuff.Size = new System.Drawing.Size(300, 197); + groupBoxCPUAndStuff.TabIndex = 8; + groupBoxCPUAndStuff.TabStop = false; + groupBoxCPUAndStuff.Text = "CPU and stuff"; + // + // checkBoxLegacyReader + // + checkBoxLegacyReader.AutoSize = true; + checkBoxLegacyReader.Location = new System.Drawing.Point(14, 138); + checkBoxLegacyReader.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxLegacyReader.Name = "checkBoxLegacyReader"; + checkBoxLegacyReader.Size = new System.Drawing.Size(182, 19); + checkBoxLegacyReader.TabIndex = 9; + checkBoxLegacyReader.Text = "Use legacy file reader (slower)"; + toolTip.SetToolTip(checkBoxLegacyReader, "Slower but more compatible with strange linefeeds and encodings"); + checkBoxLegacyReader.UseVisualStyleBackColor = true; + // + // checkBoxMultiThread + // + checkBoxMultiThread.AutoSize = true; + checkBoxMultiThread.Location = new System.Drawing.Point(14, 103); + checkBoxMultiThread.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + checkBoxMultiThread.Name = "checkBoxMultiThread"; + checkBoxMultiThread.Size = new System.Drawing.Size(131, 19); + checkBoxMultiThread.TabIndex = 5; + checkBoxMultiThread.Text = "Multi threaded filter"; + checkBoxMultiThread.UseVisualStyleBackColor = true; + // + // labelFilePollingInterval + // + labelFilePollingInterval.AutoSize = true; + labelFilePollingInterval.Location = new System.Drawing.Point(9, 52); + labelFilePollingInterval.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelFilePollingInterval.Name = "labelFilePollingInterval"; + labelFilePollingInterval.Size = new System.Drawing.Size(137, 15); + labelFilePollingInterval.TabIndex = 7; + labelFilePollingInterval.Text = "File polling interval (ms):"; + // + // upDownPollingInterval + // + upDownPollingInterval.Location = new System.Drawing.Point(190, 49); + upDownPollingInterval.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + upDownPollingInterval.Maximum = new decimal(new int[] { 5000, 0, 0, 0 }); + upDownPollingInterval.Minimum = new decimal(new int[] { 20, 0, 0, 0 }); + upDownPollingInterval.Name = "upDownPollingInterval"; + upDownPollingInterval.Size = new System.Drawing.Size(86, 23); + upDownPollingInterval.TabIndex = 6; + upDownPollingInterval.Value = new decimal(new int[] { 20, 0, 0, 0 }); + // + // groupBoxLineBufferUsage + // + groupBoxLineBufferUsage.Controls.Add(labelInfo); + groupBoxLineBufferUsage.Controls.Add(labelNumberOfBlocks); + groupBoxLineBufferUsage.Controls.Add(upDownLinesPerBlock); + groupBoxLineBufferUsage.Controls.Add(upDownBlockCount); + groupBoxLineBufferUsage.Controls.Add(labelLinesPerBlock); + groupBoxLineBufferUsage.Location = new System.Drawing.Point(10, 29); + groupBoxLineBufferUsage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxLineBufferUsage.Name = "groupBoxLineBufferUsage"; + groupBoxLineBufferUsage.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + groupBoxLineBufferUsage.Size = new System.Drawing.Size(326, 197); + groupBoxLineBufferUsage.TabIndex = 4; + groupBoxLineBufferUsage.TabStop = false; + groupBoxLineBufferUsage.Text = "Line buffer usage"; + // + // labelInfo + // + labelInfo.AutoSize = true; + labelInfo.Location = new System.Drawing.Point(9, 145); + labelInfo.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelInfo.Name = "labelInfo"; + labelInfo.Size = new System.Drawing.Size(219, 15); + labelInfo.TabIndex = 4; + labelInfo.Text = "Changes will take effect on next file load"; + // + // labelNumberOfBlocks + // + labelNumberOfBlocks.AutoSize = true; + labelNumberOfBlocks.Location = new System.Drawing.Point(9, 52); + labelNumberOfBlocks.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelNumberOfBlocks.Name = "labelNumberOfBlocks"; + labelNumberOfBlocks.Size = new System.Drawing.Size(102, 15); + labelNumberOfBlocks.TabIndex = 1; + labelNumberOfBlocks.Text = "Number of blocks"; + // + // upDownLinesPerBlock + // + upDownLinesPerBlock.Location = new System.Drawing.Point(210, 102); + upDownLinesPerBlock.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + upDownLinesPerBlock.Maximum = new decimal(new int[] { 5000000, 0, 0, 0 }); + upDownLinesPerBlock.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + upDownLinesPerBlock.Name = "upDownLinesPerBlock"; + upDownLinesPerBlock.Size = new System.Drawing.Size(94, 23); + upDownLinesPerBlock.TabIndex = 3; + upDownLinesPerBlock.Value = new decimal(new int[] { 50000, 0, 0, 0 }); + upDownLinesPerBlock.ValueChanged += OnNumericUpDown1ValueChanged; + // + // upDownBlockCount + // + upDownBlockCount.Location = new System.Drawing.Point(210, 49); + upDownBlockCount.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + upDownBlockCount.Maximum = new decimal(new int[] { 5000, 0, 0, 0 }); + upDownBlockCount.Minimum = new decimal(new int[] { 10, 0, 0, 0 }); + upDownBlockCount.Name = "upDownBlockCount"; + upDownBlockCount.Size = new System.Drawing.Size(94, 23); + upDownBlockCount.TabIndex = 0; + upDownBlockCount.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // labelLinesPerBlock + // + labelLinesPerBlock.AutoSize = true; + labelLinesPerBlock.Location = new System.Drawing.Point(9, 105); + labelLinesPerBlock.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + labelLinesPerBlock.Name = "labelLinesPerBlock"; + labelLinesPerBlock.Size = new System.Drawing.Size(68, 15); + labelLinesPerBlock.TabIndex = 2; + labelLinesPerBlock.Text = "Lines/block"; + // + // buttonCancel + // + buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + buttonCancel.Location = new System.Drawing.Point(818, 509); + buttonCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new System.Drawing.Size(112, 35); + buttonCancel.TabIndex = 1; + buttonCancel.Text = "Cancel"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += OnBtnCancelClick; + // + // buttonOk + // + buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + buttonOk.Location = new System.Drawing.Point(696, 509); + buttonOk.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonOk.Name = "buttonOk"; + buttonOk.Size = new System.Drawing.Size(112, 35); + buttonOk.TabIndex = 0; + buttonOk.Text = "OK"; + buttonOk.UseVisualStyleBackColor = true; + buttonOk.Click += OnBtnOkClick; + // + // helpProvider + // + helpProvider.HelpNamespace = "LogExpert.chm"; + // + // buttonExport + // + buttonExport.Location = new System.Drawing.Point(20, 509); + buttonExport.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonExport.Name = "buttonExport"; + buttonExport.Size = new System.Drawing.Size(112, 35); + buttonExport.TabIndex = 2; + buttonExport.Text = "Export..."; + buttonExport.UseVisualStyleBackColor = true; + buttonExport.Click += OnBtnExportClick; + // + // buttonImport + // + buttonImport.Location = new System.Drawing.Point(142, 509); + buttonImport.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + buttonImport.Name = "buttonImport"; + buttonImport.Size = new System.Drawing.Size(112, 35); + buttonImport.TabIndex = 3; + buttonImport.Text = "Import..."; + buttonImport.UseVisualStyleBackColor = true; + buttonImport.Click += OnBtnImportClick; + // + // dataGridViewTextBoxColumn1 + // + dataGridViewTextBoxColumn1.HeaderText = "File name mask (RegEx)"; + dataGridViewTextBoxColumn1.MinimumWidth = 40; + dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; + dataGridViewTextBoxColumn1.Width = 99; + // + // dataGridViewTextBoxColumn2 + // + dataGridViewTextBoxColumn2.HeaderText = "File name mask (RegEx)"; + dataGridViewTextBoxColumn2.MinimumWidth = 40; + dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2"; + dataGridViewTextBoxColumn2.Width = 259; + // + // SettingsDialog + // + AcceptButton = buttonOk; + CancelButton = buttonCancel; + ClientSize = new System.Drawing.Size(956, 563); + Controls.Add(buttonImport); + Controls.Add(buttonExport); + Controls.Add(buttonOk); + Controls.Add(buttonCancel); + Controls.Add(tabControlSettings); + FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + helpProvider.SetHelpKeyword(this, "Settings.htm"); + helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); + Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon"); + Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + MaximizeBox = false; + MinimizeBox = false; + Name = "SettingsDialog"; + helpProvider.SetShowHelp(this, true); + StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + Text = "Settings"; + Load += OnSettingsDialogLoad; + tabControlSettings.ResumeLayout(false); + tabPageViewSettings.ResumeLayout(false); + tabPageViewSettings.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)upDownMaximumLineLength).EndInit(); + ((System.ComponentModel.ISupportInitialize)upDownMaximumFilterEntriesDisplayed).EndInit(); + ((System.ComponentModel.ISupportInitialize)upDownMaximumFilterEntries).EndInit(); + groupBoxMisc.ResumeLayout(false); + groupBoxMisc.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)cpDownColumnWidth).EndInit(); + groupBoxDefaults.ResumeLayout(false); + groupBoxDefaults.PerformLayout(); + groupBoxFont.ResumeLayout(false); + tabPageTimeStampFeatures.ResumeLayout(false); + groupBoxTimeSpreadDisplay.ResumeLayout(false); + groupBoxTimeSpreadDisplay.PerformLayout(); + groupBoxDisplayMode.ResumeLayout(false); + groupBoxDisplayMode.PerformLayout(); + groupBoxTimeStampNavigationControl.ResumeLayout(false); + groupBoxTimeStampNavigationControl.PerformLayout(); + groupBoxMouseDragDefaults.ResumeLayout(false); + groupBoxMouseDragDefaults.PerformLayout(); + tabPageExternalTools.ResumeLayout(false); + groupBoxToolSettings.ResumeLayout(false); + groupBoxToolSettings.PerformLayout(); + tabPageColumnizers.ResumeLayout(false); + tabPageColumnizers.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewColumnizer).EndInit(); + tabPageHighlightMask.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewHighlightMask).EndInit(); + tabPageMultiFile.ResumeLayout(false); + groupBoxDefaultFileNamePattern.ResumeLayout(false); + groupBoxDefaultFileNamePattern.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)upDownMultifileDays).EndInit(); + groupBoxWhenOpeningMultiFile.ResumeLayout(false); + groupBoxWhenOpeningMultiFile.PerformLayout(); + tabPagePlugins.ResumeLayout(false); + groupBoxPlugins.ResumeLayout(false); + groupBoxSettings.ResumeLayout(false); + panelPlugin.ResumeLayout(false); + tabPageSessions.ResumeLayout(false); + tabPageSessions.PerformLayout(); + groupBoxPersistantFileLocation.ResumeLayout(false); + groupBoxPersistantFileLocation.PerformLayout(); + tabPageMemory.ResumeLayout(false); + groupBoxCPUAndStuff.ResumeLayout(false); + groupBoxCPUAndStuff.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)upDownPollingInterval).EndInit(); + groupBoxLineBufferUsage.ResumeLayout(false); + groupBoxLineBufferUsage.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)upDownLinesPerBlock).EndInit(); + ((System.ComponentModel.ISupportInitialize)upDownBlockCount).EndInit(); + ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.TabControl tabControlSettings; + private System.Windows.Forms.TabPage tabPageViewSettings; + private System.Windows.Forms.Label labelFont; + private System.Windows.Forms.TabPage tabPageTimeStampFeatures; + private System.Windows.Forms.GroupBox groupBoxFont; + private System.Windows.Forms.Button buttonChangeFont; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOk; + private System.Windows.Forms.CheckBox checkBoxFilterTail; + private System.Windows.Forms.CheckBox checkBoxFollowTail; + private System.Windows.Forms.CheckBox checkBoxSyncFilter; + private System.Windows.Forms.GroupBox groupBoxDefaults; + private System.Windows.Forms.CheckBox checkBoxTimestamp; + private System.Windows.Forms.GroupBox groupBoxMouseDragDefaults; + private System.Windows.Forms.RadioButton radioButtonHorizMouseDrag; + private System.Windows.Forms.RadioButton radioButtonVerticalMouseDrag; + private System.Windows.Forms.RadioButton radioButtonVerticalMouseDragInverted; + private System.Windows.Forms.TabPage tabPageExternalTools; + private System.Windows.Forms.GroupBox groupBoxToolSettings; + private System.Windows.Forms.TextBox textBoxArguments; + private System.Windows.Forms.Button buttonTool; + private System.Windows.Forms.TextBox textBoxTool; + private System.Windows.Forms.Label labelArguments; + private System.Windows.Forms.Label labelTool; + private System.Windows.Forms.Button buttonArguments; + private System.Windows.Forms.TabPage tabPageColumnizers; + private System.Windows.Forms.DataGridView dataGridViewColumnizer; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1; + private System.Windows.Forms.Button buttonDelete; + private System.Windows.Forms.DataGridViewTextBoxColumn columnFileMask; + private System.Windows.Forms.DataGridViewComboBoxColumn columnColumnizer; + private System.Windows.Forms.CheckBox checkBoxSysout; + private System.Windows.Forms.CheckBox checkBoxMaskPrio; + private System.Windows.Forms.GroupBox groupBoxMisc; + private System.Windows.Forms.CheckBox checkBoxAskCloseTabs; + private System.Windows.Forms.TabPage tabPageMultiFile; + private System.Windows.Forms.GroupBox groupBoxWhenOpeningMultiFile; + private System.Windows.Forms.RadioButton radioButtonAskWhatToDo; + private System.Windows.Forms.RadioButton radioButtonTreatAllFilesAsOneMultifile; + private System.Windows.Forms.RadioButton radioButtonLoadEveryFileIntoSeperatedTab; + private System.Windows.Forms.Label labelNoteMultiFile; + private System.Windows.Forms.Label labelHintMultiFile; + private System.Windows.Forms.HelpProvider helpProvider; + private System.Windows.Forms.CheckBox checkBoxSingleInstance; + private System.Windows.Forms.ComboBox comboBoxColumnizer; + private System.Windows.Forms.CheckBox checkBoxOpenLastFiles; + private System.Windows.Forms.CheckBox checkBoxTailState; + private System.Windows.Forms.Button buttonTailColor; + private System.Windows.Forms.NumericUpDown cpDownColumnWidth; + private System.Windows.Forms.CheckBox checkBoxColumnSize; + private System.Windows.Forms.CheckBox checkBoxTimeSpread; + private System.Windows.Forms.GroupBox groupBoxTimeSpreadDisplay; + private System.Windows.Forms.GroupBox groupBoxTimeStampNavigationControl; + private System.Windows.Forms.Button buttonTimespreadColor; + private System.Windows.Forms.CheckBox checkBoxReverseAlpha; + private System.Windows.Forms.GroupBox groupBoxDisplayMode; + private System.Windows.Forms.RadioButton radioButtonLineView; + private System.Windows.Forms.RadioButton radioButtonTimeView; + private System.Windows.Forms.TabPage tabPagePlugins; + private System.Windows.Forms.ListBox listBoxPlugin; + private System.Windows.Forms.Panel panelPlugin; + private System.Windows.Forms.GroupBox groupBoxPlugins; + private System.Windows.Forms.GroupBox groupBoxSettings; + private System.Windows.Forms.Button buttonConfigPlugin; + private System.Windows.Forms.TabPage tabPageSessions; + private System.Windows.Forms.GroupBox groupBoxPersistantFileLocation; + private System.Windows.Forms.RadioButton radioButtonsessionSaveDocuments; + private System.Windows.Forms.RadioButton radioButtonSessionSameDir; + private System.Windows.Forms.CheckBox checkBoxSaveSessions; + private System.Windows.Forms.RadioButton radioButtonSessionSaveOwn; + private System.Windows.Forms.Label labelSessionSaveOwnDir; + private System.Windows.Forms.Button buttonSessionSaveDir; + private System.Windows.Forms.CheckBox checkBoxSaveFilter; + private System.Windows.Forms.TabPage tabPageMemory; + private System.Windows.Forms.Label labelNumberOfBlocks; + private System.Windows.Forms.NumericUpDown upDownBlockCount; + private System.Windows.Forms.NumericUpDown upDownLinesPerBlock; + private System.Windows.Forms.Label labelLinesPerBlock; + private System.Windows.Forms.GroupBox groupBoxLineBufferUsage; + private System.Windows.Forms.Label labelInfo; + private System.Windows.Forms.TabPage tabPageHighlightMask; + private System.Windows.Forms.DataGridView dataGridViewHighlightMask; + private System.Windows.Forms.DataGridViewTextBoxColumn columnFileName; + private System.Windows.Forms.DataGridViewComboBoxColumn columnHighlightGroup; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2; + private System.Windows.Forms.CheckBox checkBoxMultiThread; + private System.Windows.Forms.Label labelFilePollingInterval; + private System.Windows.Forms.NumericUpDown upDownPollingInterval; + private System.Windows.Forms.GroupBox groupBoxCPUAndStuff; + private System.Windows.Forms.Label labelToolColumnizerForOutput; + private System.Windows.Forms.Label labelToolName; + private System.Windows.Forms.CheckedListBox listBoxTools; + private System.Windows.Forms.TextBox textBoxToolName; + private System.Windows.Forms.Button buttonToolDelete; + private System.Windows.Forms.Button buttonToolAdd; + private System.Windows.Forms.Button buttonToolDown; + private System.Windows.Forms.Button buttonToolUp; + private System.Windows.Forms.Label labelToolsDescription; + private System.Windows.Forms.Button buttonIcon; + private System.Windows.Forms.Label labelWorkingDir; + private System.Windows.Forms.Button buttonWorkingDir; + private System.Windows.Forms.TextBox textBoxWorkingDir; + private System.Windows.Forms.GroupBox groupBoxDefaultFileNamePattern; + private System.Windows.Forms.Label labelMaxDays; + private System.Windows.Forms.Label labelPattern; + private System.Windows.Forms.NumericUpDown upDownMultifileDays; + private System.Windows.Forms.TextBox textBoxMultifilePattern; + private System.Windows.Forms.Label labelDefaultEncoding; + private System.Windows.Forms.ComboBox comboBoxEncoding; + private System.Windows.Forms.ToolTip toolTip; + private System.Windows.Forms.CheckBox checkBoxColumnFinder; + private System.Windows.Forms.Button buttonExport; + private System.Windows.Forms.Button buttonImport; + private System.Windows.Forms.CheckBox checkBoxLegacyReader; + private System.Windows.Forms.Label labelMaximumFilterEntries; + private System.Windows.Forms.NumericUpDown upDownMaximumFilterEntries; + private System.Windows.Forms.NumericUpDown upDownMaximumFilterEntriesDisplayed; + private System.Windows.Forms.Label labelMaximumFilterEntriesDisplayed; + private System.Windows.Forms.CheckBox checkBoxAutoPick; + private System.Windows.Forms.CheckBox checkBoxPortableMode; + private System.Windows.Forms.RadioButton radioButtonSessionApplicationStartupDir; + private System.Windows.Forms.CheckBox checkBoxShowErrorMessageOnlyOneInstance; + private System.Windows.Forms.CheckBox checkBoxDarkMode; + private System.Windows.Forms.NumericUpDown upDownMaximumLineLength; + private System.Windows.Forms.Label labelMaximumLineLength; + private System.Windows.Forms.Label labelWarningMaximumLineLenght; +} diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs b/src/Logexpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs new file mode 100644 index 00000000..a6bce039 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs @@ -0,0 +1,1043 @@ +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.Enums; +using LogExpert.Core.Interface; +using LogExpert.UI.Controls.LogTabWindow; +using LogExpert.UI.Dialogs; + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using System.Windows.Forms; + +namespace LogExpert.Dialogs; + +//TODO: This class should not knoow ConfigManager? +internal partial class SettingsDialog : Form +{ + #region Fields + + private readonly Image _emptyImage = new Bitmap(16, 16); + private readonly LogTabWindow _logTabWin; + + private ILogExpertPluginConfigurator _selectedPlugin; + private ToolEntry _selectedTool; + + #endregion + + #region cTor + + private SettingsDialog(Preferences prefs, LogTabWindow logTabWin) + { + Preferences = prefs; + _logTabWin = logTabWin; //TODO: uses only HighlightGroupList. Can we pass IList instead? + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + } + + public SettingsDialog(Preferences prefs, LogTabWindow logTabWin, int tabToOpen, IConfigManager configManager) : this(prefs, logTabWin) + { + tabControlSettings.SelectedIndex = tabToOpen; + ConfigManager = configManager; + + } + + #endregion + + #region Properties + + public Preferences Preferences { get; private set; } + private IConfigManager ConfigManager { get; } + + #endregion + + #region Private Methods + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + private static extern bool DestroyIcon(IntPtr handle); + + private void FillDialog() + { + Preferences ??= new Preferences(); + + if (Preferences.fontName == null) + { + Preferences.fontName = "Courier New"; + } + + if (Math.Abs(Preferences.fontSize) < 0.1) + { + Preferences.fontSize = 9.0f; + } + + FillPortableMode(); + + checkBoxDarkMode.Checked = Preferences.darkMode; + checkBoxTimestamp.Checked = Preferences.timestampControl; + checkBoxSyncFilter.Checked = Preferences.filterSync; + checkBoxFilterTail.Checked = Preferences.filterTail; + checkBoxFollowTail.Checked = Preferences.followTail; + + radioButtonHorizMouseDrag.Checked = Preferences.timestampControlDragOrientation == DragOrientationsEnum.Horizontal; + radioButtonVerticalMouseDrag.Checked = Preferences.timestampControlDragOrientation == DragOrientationsEnum.Vertical; + radioButtonVerticalMouseDragInverted.Checked = Preferences.timestampControlDragOrientation == DragOrientationsEnum.InvertedVertical; + + checkBoxSingleInstance.Checked = Preferences.allowOnlyOneInstance; + checkBoxOpenLastFiles.Checked = Preferences.openLastFiles; + checkBoxTailState.Checked = Preferences.showTailState; + checkBoxColumnSize.Checked = Preferences.setLastColumnWidth; + cpDownColumnWidth.Enabled = Preferences.setLastColumnWidth; + + if (Preferences.lastColumnWidth != 0) + { + if (Preferences.lastColumnWidth < cpDownColumnWidth.Minimum) + { + Preferences.lastColumnWidth = (int)cpDownColumnWidth.Minimum; + } + + if (Preferences.lastColumnWidth > cpDownColumnWidth.Maximum) + { + Preferences.lastColumnWidth = (int)cpDownColumnWidth.Maximum; + } + + cpDownColumnWidth.Value = Preferences.lastColumnWidth; + } + + checkBoxTimeSpread.Checked = Preferences.showTimeSpread; + checkBoxReverseAlpha.Checked = Preferences.reverseAlpha; + + radioButtonTimeView.Checked = Preferences.timeSpreadTimeMode; + radioButtonLineView.Checked = !Preferences.timeSpreadTimeMode; + + checkBoxSaveSessions.Checked = Preferences.saveSessions; + + switch (Preferences.saveLocation) + { + case SessionSaveLocation.OwnDir: + { + radioButtonSessionSaveOwn.Checked = true; + } + break; + case SessionSaveLocation.SameDir: + { + radioButtonSessionSameDir.Checked = true; + } + break; + case SessionSaveLocation.DocumentsDir: + { + radioButtonsessionSaveDocuments.Checked = true; + break; + } + case SessionSaveLocation.ApplicationStartupDir: + { + radioButtonSessionApplicationStartupDir.Checked = true; + break; + } + } + + //overwrite preferences save location in portable mode to always be application startup directory + if (checkBoxPortableMode.Checked) + { + radioButtonSessionApplicationStartupDir.Checked = true; + } + + upDownMaximumLineLength.Value = Preferences.MaxLineLength; + + upDownMaximumFilterEntriesDisplayed.Value = Preferences.maximumFilterEntriesDisplayed; + upDownMaximumFilterEntries.Value = Preferences.maximumFilterEntries; + + labelSessionSaveOwnDir.Text = Preferences.sessionSaveDirectory ?? string.Empty; + checkBoxSaveFilter.Checked = Preferences.saveFilters; + upDownBlockCount.Value = Preferences.bufferCount; + upDownLinesPerBlock.Value = Preferences.linesPerBuffer; + upDownPollingInterval.Value = Preferences.pollingInterval; + checkBoxMultiThread.Checked = Preferences.multiThreadFilter; + + dataGridViewColumnizer.DataError += OnDataGridViewColumnizerDataError; + + FillColumnizerList(); + FillPluginList(); + DisplayFontName(); + FillHighlightMaskList(); + FillToolListbox(); + FillMultifileSettings(); + FillEncodingList(); + + var temp = Encoding.GetEncoding(Preferences.defaultEncoding); + + comboBoxEncoding.SelectedItem = Encoding.GetEncoding(Preferences.defaultEncoding); + checkBoxMaskPrio.Checked = Preferences.maskPrio; + checkBoxAutoPick.Checked = Preferences.autoPick; + checkBoxAskCloseTabs.Checked = Preferences.askForClose; + checkBoxColumnFinder.Checked = Preferences.showColumnFinder; + checkBoxLegacyReader.Checked = Preferences.useLegacyReader; + checkBoxShowErrorMessageOnlyOneInstance.Checked = Preferences.ShowErrorMessageAllowOnlyOneInstances; + } + + private void FillPortableMode() + { + checkBoxPortableMode.CheckState = Preferences.PortableMode ? CheckState.Checked : CheckState.Unchecked; + } + + private void DisplayFontName() + { + labelFont.Text = Preferences.fontName + @" " + (int)Preferences.fontSize; + labelFont.Font = new Font(new FontFamily(Preferences.fontName), Preferences.fontSize); + } + + private void SaveMultifileData() + { + if (radioButtonLoadEveryFileIntoSeperatedTab.Checked) + { + Preferences.multiFileOption = MultiFileOption.SingleFiles; + } + + if (radioButtonTreatAllFilesAsOneMultifile.Checked) + { + Preferences.multiFileOption = MultiFileOption.MultiFile; + } + + if (radioButtonAskWhatToDo.Checked) + { + Preferences.multiFileOption = MultiFileOption.Ask; + } + + Preferences.multiFileOptions.FormatPattern = textBoxMultifilePattern.Text; + Preferences.multiFileOptions.MaxDayTry = (int)upDownMultifileDays.Value; + } + + private void OnBtnToolClickInternal(TextBox textBox) + { + OpenFileDialog dlg = new(); + dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); + + if (string.IsNullOrEmpty(textBox.Text) == false) + { + FileInfo info = new(textBox.Text); + if (info.Directory != null && info.Directory.Exists) + { + dlg.InitialDirectory = info.DirectoryName; + } + } + + if (dlg.ShowDialog() == DialogResult.OK) + { + textBox.Text = dlg.FileName; + } + } + + //TODO: what is the purpose of this method? + private void OnBtnArgsClickInternal(TextBox textBox) + { + ToolArgsDialog dlg = new(_logTabWin, this) + { + Arg = textBox.Text + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + textBox.Text = dlg.Arg; + } + } + + private void OnBtnWorkingDirClick(TextBox textBox) + { + FolderBrowserDialog dlg = new() + { + RootFolder = Environment.SpecialFolder.MyComputer, + Description = @"Select a working directory" + }; + + if (!string.IsNullOrEmpty(textBox.Text)) + { + DirectoryInfo info = new(textBox.Text); + if (info.Exists) + { + dlg.SelectedPath = info.FullName; + } + } + + if (dlg.ShowDialog() == DialogResult.OK) + { + textBox.Text = dlg.SelectedPath; + } + } + + private void FillColumnizerForToolsList() + { + if (_selectedTool != null) + { + FillColumnizerForToolsList(comboBoxColumnizer, _selectedTool.columnizerName); + } + } + + private void FillColumnizerForToolsList(ComboBox comboBox, string columnizerName) + { + int selIndex = 0; + comboBox.Items.Clear(); + IList columnizers = PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers; + + foreach (ILogLineColumnizer columnizer in columnizers) + { + int index = comboBox.Items.Add(columnizer.GetName()); + if (columnizer.GetName().Equals(columnizerName)) + { + selIndex = index; + } + } + + //ILogLineColumnizer columnizer = Util.FindColumnizerByName(columnizerName, this.logTabWin.RegisteredColumnizers); + //if (columnizer == null) + // columnizer = this.logTabWin.RegisteredColumnizers[0]; + comboBox.SelectedIndex = selIndex; + } + + private void FillColumnizerList() + { + dataGridViewColumnizer.Rows.Clear(); + + DataGridViewComboBoxColumn comboColumn = (DataGridViewComboBoxColumn)dataGridViewColumnizer.Columns[1]; + comboColumn.Items.Clear(); + + DataGridViewTextBoxColumn textColumn = (DataGridViewTextBoxColumn)dataGridViewColumnizer.Columns[0]; + + IList columnizers = PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers; + + foreach (ILogLineColumnizer columnizer in columnizers) + { + comboColumn.Items.Add(columnizer.GetName()); + } + //comboColumn.DisplayMember = "Name"; + //comboColumn.ValueMember = "Columnizer"; + + foreach (ColumnizerMaskEntry maskEntry in Preferences.columnizerMaskList) + { + DataGridViewRow row = new(); + row.Cells.Add(new DataGridViewTextBoxCell()); + DataGridViewComboBoxCell cell = new(); + + foreach (ILogLineColumnizer logColumnizer in columnizers) + { + cell.Items.Add(logColumnizer.GetName()); + } + + row.Cells.Add(cell); + row.Cells[0].Value = maskEntry.mask; + ILogLineColumnizer columnizer = ColumnizerPicker.DecideColumnizerByName(maskEntry.columnizerName, + PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + + row.Cells[1].Value = columnizer.GetName(); + dataGridViewColumnizer.Rows.Add(row); + } + + int count = dataGridViewColumnizer.RowCount; + + if (count > 0 && !dataGridViewColumnizer.Rows[count - 1].IsNewRow) + { + DataGridViewComboBoxCell comboCell = (DataGridViewComboBoxCell)dataGridViewColumnizer.Rows[count - 1].Cells[1]; + comboCell.Value = comboCell.Items[0]; + } + } + + private void FillHighlightMaskList() + { + dataGridViewHighlightMask.Rows.Clear(); + + DataGridViewComboBoxColumn comboColumn = (DataGridViewComboBoxColumn)dataGridViewHighlightMask.Columns[1]; + comboColumn.Items.Clear(); + + //TODO Remove if not necessary + DataGridViewTextBoxColumn textColumn = (DataGridViewTextBoxColumn)dataGridViewHighlightMask.Columns[0]; + + foreach (HighlightGroup group in (IList)_logTabWin.HighlightGroupList) + { + comboColumn.Items.Add(group.GroupName); + } + + foreach (HighlightMaskEntry maskEntry in Preferences.highlightMaskList) + { + DataGridViewRow row = new(); + row.Cells.Add(new DataGridViewTextBoxCell()); + DataGridViewComboBoxCell cell = new(); + + foreach (HighlightGroup group in (IList)_logTabWin.HighlightGroupList) + { + cell.Items.Add(group.GroupName); + } + + row.Cells.Add(cell); + row.Cells[0].Value = maskEntry.mask; + + HighlightGroup currentGroup = _logTabWin.FindHighlightGroup(maskEntry.highlightGroupName); + var highlightGroupList = _logTabWin.HighlightGroupList; + currentGroup ??= highlightGroupList.Count > 0 ? highlightGroupList[0] : new HighlightGroup(); + + row.Cells[1].Value = currentGroup.GroupName; + dataGridViewHighlightMask.Rows.Add(row); + } + + int count = dataGridViewHighlightMask.RowCount; + + if (count > 0 && !dataGridViewHighlightMask.Rows[count - 1].IsNewRow) + { + DataGridViewComboBoxCell comboCell = + (DataGridViewComboBoxCell)dataGridViewHighlightMask.Rows[count - 1].Cells[1]; + comboCell.Value = comboCell.Items[0]; + } + } + + private void SaveColumnizerList() + { + Preferences.columnizerMaskList.Clear(); + + foreach (DataGridViewRow row in dataGridViewColumnizer.Rows) + { + if (!row.IsNewRow) + { + ColumnizerMaskEntry entry = new(); + entry.mask = (string)row.Cells[0].Value; + entry.columnizerName = (string)row.Cells[1].Value; + Preferences.columnizerMaskList.Add(entry); + } + } + } + + private void SaveHighlightMaskList() + { + Preferences.highlightMaskList.Clear(); + + foreach (DataGridViewRow row in dataGridViewHighlightMask.Rows) + { + if (!row.IsNewRow) + { + HighlightMaskEntry entry = new(); + entry.mask = (string)row.Cells[0].Value; + entry.highlightGroupName = (string)row.Cells[1].Value; + Preferences.highlightMaskList.Add(entry); + } + } + } + + private void FillPluginList() + { + listBoxPlugin.Items.Clear(); + + foreach (IContextMenuEntry entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins) + { + listBoxPlugin.Items.Add(entry); + if (entry is ILogExpertPluginConfigurator configurator) + { + configurator.StartConfig(); + } + } + + foreach (IKeywordAction entry in PluginRegistry.PluginRegistry.Instance.RegisteredKeywordActions) + { + listBoxPlugin.Items.Add(entry); + if (entry is ILogExpertPluginConfigurator configurator) + { + configurator.StartConfig(); + } + } + + foreach (IFileSystemPlugin entry in PluginRegistry.PluginRegistry.Instance.RegisteredFileSystemPlugins) + { + listBoxPlugin.Items.Add(entry); + if (entry is ILogExpertPluginConfigurator configurator) + { + configurator.StartConfig(); + } + } + + buttonConfigPlugin.Enabled = false; + } + + private void SavePluginSettings() + { + _selectedPlugin?.HideConfigForm(); + + foreach (IContextMenuEntry entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins) + { + if (entry is ILogExpertPluginConfigurator configurator) + { + configurator.SaveConfig(checkBoxPortableMode.Checked ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir); + } + } + + foreach (IKeywordAction entry in PluginRegistry.PluginRegistry.Instance.RegisteredKeywordActions) + { + if (entry is ILogExpertPluginConfigurator configurator) + { + configurator.SaveConfig(checkBoxPortableMode.Checked ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir); + } + } + } + + private void FillToolListbox() + { + listBoxTools.Items.Clear(); + + foreach (ToolEntry tool in Preferences.toolEntries) + { + listBoxTools.Items.Add(tool.Clone(), tool.isFavourite); + } + + if (listBoxTools.Items.Count > 0) + { + listBoxTools.SelectedIndex = 0; + } + } + + private void FillMultifileSettings() + { + switch (Preferences.multiFileOption) + { + case MultiFileOption.SingleFiles: + { + radioButtonLoadEveryFileIntoSeperatedTab.Checked = true; + break; + } + case MultiFileOption.MultiFile: + { + radioButtonTreatAllFilesAsOneMultifile.Checked = true; + break; + } + case MultiFileOption.Ask: + { + radioButtonAskWhatToDo.Checked = true; + break; + } + } + + textBoxMultifilePattern.Text = Preferences.multiFileOptions.FormatPattern; //TODO: Impport settings file throws an exception. Fix or I caused it? + upDownMultifileDays.Value = Preferences.multiFileOptions.MaxDayTry; + } + + private void GetToolListBoxData() + { + GetCurrentToolValues(); + Preferences.toolEntries.Clear(); + + for (int i = 0; i < listBoxTools.Items.Count; ++i) + { + Preferences.toolEntries.Add(listBoxTools.Items[i] as ToolEntry); + (listBoxTools.Items[i] as ToolEntry).isFavourite = listBoxTools.GetItemChecked(i); + } + } + + private void GetCurrentToolValues() + { + if (_selectedTool != null) + { + _selectedTool.name = Util.IsNullOrSpaces(textBoxToolName.Text) ? textBoxTool.Text : textBoxToolName.Text; + _selectedTool.cmd = textBoxTool.Text; + _selectedTool.args = textBoxArguments.Text; + _selectedTool.columnizerName = comboBoxColumnizer.Text; + _selectedTool.sysout = checkBoxSysout.Checked; + _selectedTool.workingDir = textBoxWorkingDir.Text; + } + } + + private void ShowCurrentToolValues() + { + if (_selectedTool != null) + { + textBoxToolName.Text = _selectedTool.name; + textBoxTool.Text = _selectedTool.cmd; + textBoxArguments.Text = _selectedTool.args; + comboBoxColumnizer.Text = _selectedTool.columnizerName; + checkBoxSysout.Checked = _selectedTool.sysout; + comboBoxColumnizer.Enabled = _selectedTool.sysout; + textBoxWorkingDir.Text = _selectedTool.workingDir; + } + } + + private void DisplayCurrentIcon() + { + if (_selectedTool != null) + { + Icon icon = Win32.LoadIconFromExe(_selectedTool.iconFile, _selectedTool.iconIndex); + if (icon != null) + { + Image image = icon.ToBitmap(); + buttonIcon.Image = image; + DestroyIcon(icon.Handle); + icon.Dispose(); + } + else + { + buttonIcon.Image = _emptyImage; + } + } + } + + private void FillEncodingList() + { + comboBoxEncoding.Items.Clear(); + + comboBoxEncoding.Items.Add(Encoding.ASCII); + comboBoxEncoding.Items.Add(Encoding.Default); + comboBoxEncoding.Items.Add(Encoding.GetEncoding("iso-8859-1")); + comboBoxEncoding.Items.Add(Encoding.UTF8); + comboBoxEncoding.Items.Add(Encoding.Unicode); + comboBoxEncoding.Items.Add(CodePagesEncodingProvider.Instance.GetEncoding(1252)); + + comboBoxEncoding.ValueMember = "HeaderName"; + } + + #endregion + + #region Events handler + + private void OnSettingsDialogLoad(object sender, EventArgs e) + { + FillDialog(); + } + + private void OnBtnChangeFontClick(object sender, EventArgs e) + { + FontDialog dlg = new() + { + ShowEffects = false, + AllowVerticalFonts = false, + AllowScriptChange = false, + Font = new Font(new FontFamily(Preferences.fontName), Preferences.fontSize) + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + Preferences.fontSize = dlg.Font.Size; + Preferences.fontName = dlg.Font.FontFamily.Name; + } + + DisplayFontName(); + } + + private void OnBtnOkClick(object sender, EventArgs e) + { + Preferences.timestampControl = checkBoxTimestamp.Checked; + Preferences.filterSync = checkBoxSyncFilter.Checked; + Preferences.filterTail = checkBoxFilterTail.Checked; + Preferences.followTail = checkBoxFollowTail.Checked; + + if (radioButtonVerticalMouseDrag.Checked) + { + Preferences.timestampControlDragOrientation = DragOrientationsEnum.Vertical; + } + else if (radioButtonVerticalMouseDragInverted.Checked) + { + Preferences.timestampControlDragOrientation = DragOrientationsEnum.InvertedVertical; + } + else + { + Preferences.timestampControlDragOrientation = DragOrientationsEnum.Horizontal; + } + + SaveColumnizerList(); + + Preferences.maskPrio = checkBoxMaskPrio.Checked; + Preferences.autoPick = checkBoxAutoPick.Checked; + Preferences.askForClose = checkBoxAskCloseTabs.Checked; + Preferences.allowOnlyOneInstance = checkBoxSingleInstance.Checked; + Preferences.openLastFiles = checkBoxOpenLastFiles.Checked; + Preferences.showTailState = checkBoxTailState.Checked; + Preferences.setLastColumnWidth = checkBoxColumnSize.Checked; + Preferences.lastColumnWidth = (int)cpDownColumnWidth.Value; + Preferences.showTimeSpread = checkBoxTimeSpread.Checked; + Preferences.reverseAlpha = checkBoxReverseAlpha.Checked; + Preferences.timeSpreadTimeMode = radioButtonTimeView.Checked; + + Preferences.saveSessions = checkBoxSaveSessions.Checked; + Preferences.sessionSaveDirectory = labelSessionSaveOwnDir.Text; + + if (radioButtonsessionSaveDocuments.Checked) + { + Preferences.saveLocation = SessionSaveLocation.DocumentsDir; + } + else if (radioButtonSessionSaveOwn.Checked) + { + Preferences.saveLocation = SessionSaveLocation.OwnDir; + } + else if (radioButtonSessionApplicationStartupDir.Checked) + { + Preferences.saveLocation = SessionSaveLocation.ApplicationStartupDir; + } + else + { + Preferences.saveLocation = SessionSaveLocation.SameDir; + } + + Preferences.saveFilters = checkBoxSaveFilter.Checked; + Preferences.bufferCount = (int)upDownBlockCount.Value; + Preferences.linesPerBuffer = (int)upDownLinesPerBlock.Value; + Preferences.pollingInterval = (int)upDownPollingInterval.Value; + Preferences.multiThreadFilter = checkBoxMultiThread.Checked; + Preferences.defaultEncoding = comboBoxEncoding.SelectedItem != null ? (comboBoxEncoding.SelectedItem as Encoding).HeaderName : Encoding.Default.HeaderName; + Preferences.showColumnFinder = checkBoxColumnFinder.Checked; + Preferences.useLegacyReader = checkBoxLegacyReader.Checked; + + Preferences.maximumFilterEntries = (int)upDownMaximumFilterEntries.Value; + Preferences.maximumFilterEntriesDisplayed = (int)upDownMaximumFilterEntriesDisplayed.Value; + Preferences.ShowErrorMessageAllowOnlyOneInstances = checkBoxShowErrorMessageOnlyOneInstance.Checked; + Preferences.darkMode = checkBoxDarkMode.Checked; + + SavePluginSettings(); + SaveHighlightMaskList(); + GetToolListBoxData(); + SaveMultifileData(); + } + + private void OnBtnToolClick(object sender, EventArgs e) + { + OnBtnToolClickInternal(textBoxTool); + } + + //TODO: what is the purpose of this click? + private void OnBtnArgClick(object sender, EventArgs e) + { + OnBtnArgsClickInternal(textBoxArguments); + } + + //TODO Remove or refactor this function + private void OnDataGridViewColumnizerRowsAdded(object sender, DataGridViewRowsAddedEventArgs e) + { + DataGridViewComboBoxCell comboCell = (DataGridViewComboBoxCell)dataGridViewColumnizer.Rows[e.RowIndex].Cells[1]; + if (comboCell.Items.Count > 0) + { + // comboCell.Value = comboCell.Items[0]; + } + } + + private void OnBtnDeleteClick(object sender, EventArgs e) + { + if (dataGridViewColumnizer.CurrentRow != null && !dataGridViewColumnizer.CurrentRow.IsNewRow) + { + int index = dataGridViewColumnizer.CurrentRow.Index; + dataGridViewColumnizer.EndEdit(); + dataGridViewColumnizer.Rows.RemoveAt(index); + } + } + + private void OnDataGridViewColumnizerDataError(object sender, DataGridViewDataErrorEventArgs e) + { + e.Cancel = true; + } + + private void OnChkBoxSysoutCheckedChanged(object sender, EventArgs e) + { + comboBoxColumnizer.Enabled = checkBoxSysout.Checked; + } + + private void OnBtnTailColorClick(object sender, EventArgs e) + { + ColorDialog dlg = new() + { + Color = Preferences.showTailColor + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + Preferences.showTailColor = dlg.Color; + } + } + + private void OnChkBoxColumnSizeCheckedChanged(object sender, EventArgs e) + { + cpDownColumnWidth.Enabled = checkBoxColumnSize.Checked; + } + + private void OnBtnTimespreadColorClick(object sender, EventArgs e) + { + ColorDialog dlg = new() + { + Color = Preferences.timeSpreadColor + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + Preferences.timeSpreadColor = dlg.Color; + } + } + + private void OnListBoxPluginSelectedIndexChanged(object sender, EventArgs e) + { + _selectedPlugin?.HideConfigForm(); + + object o = listBoxPlugin.SelectedItem; + + if (o != null) + { + _selectedPlugin = o as ILogExpertPluginConfigurator; + + if (o is ILogExpertPluginConfigurator) + { + if (_selectedPlugin.HasEmbeddedForm()) + { + buttonConfigPlugin.Enabled = false; + buttonConfigPlugin.Visible = false; + _selectedPlugin.ShowConfigForm(panelPlugin); + } + else + { + buttonConfigPlugin.Enabled = true; + buttonConfigPlugin.Visible = true; + } + } + } + else + { + buttonConfigPlugin.Enabled = false; + buttonConfigPlugin.Visible = true; + } + } + + private void OnBtnSessionSaveDirClick(object sender, EventArgs e) + { + FolderBrowserDialog dlg = new(); + + if (Preferences.sessionSaveDirectory != null) + { + dlg.SelectedPath = Preferences.sessionSaveDirectory; + } + + dlg.ShowNewFolderButton = true; + dlg.Description = @"Choose folder for LogExpert's session files"; + + if (dlg.ShowDialog() == DialogResult.OK) + { + labelSessionSaveOwnDir.Text = dlg.SelectedPath; + } + } + + private void OnPortableModeCheckedChanged(object sender, EventArgs e) + { + try + { + switch (checkBoxPortableMode.CheckState) + { + case CheckState.Checked when !File.Exists(ConfigManager.PortableModeDir + Path.DirectorySeparatorChar + ConfigManager.PortableModeSettingsFileName): + { + if (Directory.Exists(ConfigManager.PortableModeDir) == false) + { + Directory.CreateDirectory(ConfigManager.PortableModeDir); + } + + using (File.Create(ConfigManager.PortableModeDir + Path.DirectorySeparatorChar + ConfigManager.PortableModeSettingsFileName)) + { + break; + } + } + case CheckState.Unchecked when File.Exists(ConfigManager.PortableModeDir + Path.DirectorySeparatorChar + ConfigManager.PortableModeSettingsFileName): + { + File.Delete(ConfigManager.PortableModeDir + Path.DirectorySeparatorChar + ConfigManager.PortableModeSettingsFileName); + break; + } + } + + switch (checkBoxPortableMode.CheckState) + { + case CheckState.Unchecked: + { + checkBoxPortableMode.Text = @"Activate Portable Mode"; + Preferences.PortableMode = false; + break; + } + + case CheckState.Checked: + { + Preferences.PortableMode = true; + checkBoxPortableMode.Text = @"Deactivate Portable Mode"; + break; + } + } + } + catch (Exception exception) + { + MessageBox.Show($@"Could not create / delete marker for Portable Mode: {exception}", @"Error", MessageBoxButtons.OK); + } + + } + + private void OnBtnConfigPluginClick(object sender, EventArgs e) + { + if (!_selectedPlugin.HasEmbeddedForm()) + { + _selectedPlugin.ShowConfigDialog(this); + } + } + + private void OnNumericUpDown1ValueChanged(object sender, EventArgs e) + { + //TODO implement + } + + private void OnListBoxToolSelectedIndexChanged(object sender, EventArgs e) + { + GetCurrentToolValues(); + _selectedTool = listBoxTools.SelectedItem as ToolEntry; + ShowCurrentToolValues(); + listBoxTools.Refresh(); + FillColumnizerForToolsList(); + DisplayCurrentIcon(); + } + + private void OnBtnToolUpClick(object sender, EventArgs e) + { + int i = listBoxTools.SelectedIndex; + + if (i > 0) + { + bool isChecked = listBoxTools.GetItemChecked(i); + object item = listBoxTools.Items[i]; + listBoxTools.Items.RemoveAt(i); + i--; + listBoxTools.Items.Insert(i, item); + listBoxTools.SelectedIndex = i; + listBoxTools.SetItemChecked(i, isChecked); + } + } + + private void OnBtnToolDownClick(object sender, EventArgs e) + { + int i = listBoxTools.SelectedIndex; + + if (i < listBoxTools.Items.Count - 1) + { + bool isChecked = listBoxTools.GetItemChecked(i); + object item = listBoxTools.Items[i]; + listBoxTools.Items.RemoveAt(i); + i++; + listBoxTools.Items.Insert(i, item); + listBoxTools.SelectedIndex = i; + listBoxTools.SetItemChecked(i, isChecked); + } + } + + private void OnBtnToolAddClick(object sender, EventArgs e) + { + listBoxTools.Items.Add(new ToolEntry()); + listBoxTools.SelectedIndex = listBoxTools.Items.Count - 1; + } + + private void OnToolDeleteButtonClick(object sender, EventArgs e) + { + int i = listBoxTools.SelectedIndex; + + if (i < listBoxTools.Items.Count && i >= 0) + { + listBoxTools.Items.RemoveAt(i); + if (i < listBoxTools.Items.Count) + { + listBoxTools.SelectedIndex = i; + } + else + { + if (listBoxTools.Items.Count > 0) + { + listBoxTools.SelectedIndex = listBoxTools.Items.Count - 1; + } + } + } + } + + private void OnBtnIconClick(object sender, EventArgs e) + { + if (_selectedTool != null) + { + string iconFile = _selectedTool.iconFile; + + if (Util.IsNullOrSpaces(iconFile)) + { + iconFile = textBoxTool.Text; + } + + ChooseIconDlg dlg = new(iconFile); + + if (dlg.ShowDialog() == DialogResult.OK) + { + _selectedTool.iconFile = dlg.FileName; + _selectedTool.iconIndex = dlg.IconIndex; + DisplayCurrentIcon(); + } + } + } + + private void OnBtnCancelClick(object sender, EventArgs e) + { + _selectedPlugin?.HideConfigForm(); + } + + private void OnBtnWorkingDirClick(object sender, EventArgs e) + { + OnBtnWorkingDirClick(textBoxWorkingDir); + } + + private void OnMultiFilePatternTextChanged(object sender, EventArgs e) + { + string pattern = textBoxMultifilePattern.Text; + upDownMultifileDays.Enabled = pattern.Contains("$D"); + } + + private void OnBtnExportClick(object sender, EventArgs e) + { + SaveFileDialog dlg = new() + { + Title = @"Export Settings to file", + DefaultExt = "json", + AddExtension = true, + Filter = @"Settings (*.json)|*.json|All files (*.*)|*.*" + }; + + DialogResult result = dlg.ShowDialog(); + + if (result == DialogResult.OK) + { + FileInfo fileInfo = new(dlg.FileName); + ConfigManager.Export(fileInfo); + } + } + + /// + /// + /// + /// + /// + private void OnBtnImportClick(object sender, EventArgs e) + { + ImportSettingsDialog dlg = new(ExportImportFlags.All); + + if (dlg.ShowDialog() == DialogResult.OK) + { + if (string.IsNullOrWhiteSpace(dlg.FileName)) + { + return; + } + + FileInfo fileInfo; + try + { + fileInfo = new FileInfo(dlg.FileName); + } + catch (Exception ex) + { + MessageBox.Show(this, $@"Settings could not be imported: {ex}", @"LogExpert"); + return; + } + + ConfigManager.Import(fileInfo, dlg.ImportFlags); + Preferences = ConfigManager.Settings.Preferences; + FillDialog(); + MessageBox.Show(this, @"Settings imported", @"LogExpert"); + } + } + + #endregion +} diff --git a/src/LogExpert/Dialogs/SettingsDialog.resx b/src/Logexpert.UI/Dialogs/LogTabWindow/SettingsDialog.resx similarity index 98% rename from src/LogExpert/Dialogs/SettingsDialog.resx rename to src/Logexpert.UI/Dialogs/LogTabWindow/SettingsDialog.resx index 1ba4e352..7f3f0ea5 100644 --- a/src/LogExpert/Dialogs/SettingsDialog.resx +++ b/src/Logexpert.UI/Dialogs/LogTabWindow/SettingsDialog.resx @@ -1,173 +1,173 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 144, 17 - - - 144, 17 - - - 144, 17 - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - 17, 17 - - - Note: You can always load your logfiles as MultiFile automatically if the files names follow the MultiFile naming rule (<filename>, <filename>.1, <filename>.2, ...). Simply choose 'MultiFile' from the File menu after loading the first file. - - - 17, 17 - - - - - AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA - AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// - AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// - //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA - AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAIABAAD//wAA - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 144, 17 + + + 144, 17 + + + 144, 17 + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + 17, 17 + + + Note: You can always load your logfiles as MultiFile automatically if the files names follow the MultiFile naming rule (<filename>, <filename>.1, <filename>.2, ...). Simply choose 'MultiFile' from the File menu after loading the first file. + + + 17, 17 + + + + + AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// + //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA + AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAIABAAD//wAA + + \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/MultiFileMaskDialog.Designer.cs b/src/Logexpert.UI/Dialogs/MultiFileMaskDialog.Designer.cs index 1caf30cc..d57d7e64 100644 --- a/src/Logexpert.UI/Dialogs/MultiFileMaskDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/MultiFileMaskDialog.Designer.cs @@ -1,5 +1,5 @@ -namespace LogExpert.UI.Dialogs -{ +namespace LogExpert.UI.Dialogs; + partial class MultiFileMaskDialog { /// @@ -28,151 +28,151 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MultiFileMaskDialog)); - this.labelMultiSettingsFor = new System.Windows.Forms.Label(); - this.labelFileName = new System.Windows.Forms.Label(); - this.labelFileNamePattern = new System.Windows.Forms.Label(); - this.upDownMaxDays = new System.Windows.Forms.NumericUpDown(); - this.fileNamePatternTextBox = new System.Windows.Forms.TextBox(); - this.labelMaxDays = new System.Windows.Forms.Label(); - this.Settings = new System.Windows.Forms.GroupBox(); - this.syntaxHelpLabel = new System.Windows.Forms.Label(); - this.buttonOk = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.upDownMaxDays)).BeginInit(); - this.Settings.SuspendLayout(); - this.SuspendLayout(); - // - // labelMultiSettingsFor - // - this.labelMultiSettingsFor.AutoSize = true; - this.labelMultiSettingsFor.Location = new System.Drawing.Point(12, 13); - this.labelMultiSettingsFor.Name = "labelMultiSettingsFor"; - this.labelMultiSettingsFor.Size = new System.Drawing.Size(154, 20); - this.labelMultiSettingsFor.TabIndex = 0; - this.labelMultiSettingsFor.Text = "MultiFile settings for:"; - // - // labelFileName - // - this.labelFileName.AutoSize = true; - this.labelFileName.Location = new System.Drawing.Point(172, 13); - this.labelFileName.Name = "labelFileName"; - this.labelFileName.Size = new System.Drawing.Size(91, 20); - this.labelFileName.TabIndex = 1; - this.labelFileName.Text = ""; - // - // labelFileNamePattern - // - this.labelFileNamePattern.AutoSize = true; - this.labelFileNamePattern.Location = new System.Drawing.Point(6, 28); - this.labelFileNamePattern.Name = "labelFileNamePattern"; - this.labelFileNamePattern.Size = new System.Drawing.Size(137, 20); - this.labelFileNamePattern.TabIndex = 2; - this.labelFileNamePattern.Text = "File name pattern:"; - // - // upDownMaxDays - // - this.upDownMaxDays.Location = new System.Drawing.Point(91, 55); - this.upDownMaxDays.Maximum = new decimal(new int[] { - 40, - 0, - 0, - 0}); - this.upDownMaxDays.Name = "upDownMaxDays"; - this.upDownMaxDays.Size = new System.Drawing.Size(49, 26); - this.upDownMaxDays.TabIndex = 3; - this.upDownMaxDays.Value = new decimal(new int[] { - 1, - 0, - 0, - 0}); - // - // fileNamePatternTextBox - // - this.fileNamePatternTextBox.Location = new System.Drawing.Point(149, 25); - this.fileNamePatternTextBox.Name = "fileNamePatternTextBox"; - this.fileNamePatternTextBox.Size = new System.Drawing.Size(247, 26); - this.fileNamePatternTextBox.TabIndex = 4; - // - // labelMaxDays - // - this.labelMaxDays.AutoSize = true; - this.labelMaxDays.Location = new System.Drawing.Point(6, 57); - this.labelMaxDays.Name = "labelMaxDays"; - this.labelMaxDays.Size = new System.Drawing.Size(79, 20); - this.labelMaxDays.TabIndex = 5; - this.labelMaxDays.Text = "Max days:"; - // - // Settings - // - this.Settings.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.Settings.Controls.Add(this.labelFileNamePattern); - this.Settings.Controls.Add(this.labelMaxDays); - this.Settings.Controls.Add(this.upDownMaxDays); - this.Settings.Controls.Add(this.fileNamePatternTextBox); - this.Settings.Location = new System.Drawing.Point(15, 39); - this.Settings.Name = "Settings"; - this.Settings.Size = new System.Drawing.Size(402, 98); - this.Settings.TabIndex = 6; - this.Settings.TabStop = false; - // - // syntaxHelpLabel - // - this.syntaxHelpLabel.Location = new System.Drawing.Point(15, 140); - this.syntaxHelpLabel.Name = "syntaxHelpLabel"; - this.syntaxHelpLabel.Size = new System.Drawing.Size(402, 194); - this.syntaxHelpLabel.TabIndex = 7; - this.syntaxHelpLabel.Text = "Syntax Help Label"; - // - // buttonOk - // - this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(261, 347); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(75, 23); - this.buttonOk.TabIndex = 8; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.OnButtonOKClick); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(342, 347); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 9; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // MultiFileMaskDialog - // - this.AcceptButton = this.buttonOk; - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(434, 386); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.syntaxHelpLabel); - this.Controls.Add(this.Settings); - this.Controls.Add(this.labelFileName); - this.Controls.Add(this.labelMultiSettingsFor); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(329, 420); - this.Name = "MultiFileMaskDialog"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "MultiFile settings"; - this.TopMost = true; - this.Load += new System.EventHandler(this.OnMultiFileMaskDialogLoad); - ((System.ComponentModel.ISupportInitialize)(this.upDownMaxDays)).EndInit(); - this.Settings.ResumeLayout(false); - this.Settings.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MultiFileMaskDialog)); + this.labelMultiSettingsFor = new System.Windows.Forms.Label(); + this.labelFileName = new System.Windows.Forms.Label(); + this.labelFileNamePattern = new System.Windows.Forms.Label(); + this.upDownMaxDays = new System.Windows.Forms.NumericUpDown(); + this.fileNamePatternTextBox = new System.Windows.Forms.TextBox(); + this.labelMaxDays = new System.Windows.Forms.Label(); + this.Settings = new System.Windows.Forms.GroupBox(); + this.syntaxHelpLabel = new System.Windows.Forms.Label(); + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.upDownMaxDays)).BeginInit(); + this.Settings.SuspendLayout(); + this.SuspendLayout(); + // + // labelMultiSettingsFor + // + this.labelMultiSettingsFor.AutoSize = true; + this.labelMultiSettingsFor.Location = new System.Drawing.Point(12, 13); + this.labelMultiSettingsFor.Name = "labelMultiSettingsFor"; + this.labelMultiSettingsFor.Size = new System.Drawing.Size(154, 20); + this.labelMultiSettingsFor.TabIndex = 0; + this.labelMultiSettingsFor.Text = "MultiFile settings for:"; + // + // labelFileName + // + this.labelFileName.AutoSize = true; + this.labelFileName.Location = new System.Drawing.Point(172, 13); + this.labelFileName.Name = "labelFileName"; + this.labelFileName.Size = new System.Drawing.Size(91, 20); + this.labelFileName.TabIndex = 1; + this.labelFileName.Text = ""; + // + // labelFileNamePattern + // + this.labelFileNamePattern.AutoSize = true; + this.labelFileNamePattern.Location = new System.Drawing.Point(6, 28); + this.labelFileNamePattern.Name = "labelFileNamePattern"; + this.labelFileNamePattern.Size = new System.Drawing.Size(137, 20); + this.labelFileNamePattern.TabIndex = 2; + this.labelFileNamePattern.Text = "File name pattern:"; + // + // upDownMaxDays + // + this.upDownMaxDays.Location = new System.Drawing.Point(91, 55); + this.upDownMaxDays.Maximum = new decimal(new int[] { + 40, + 0, + 0, + 0}); + this.upDownMaxDays.Name = "upDownMaxDays"; + this.upDownMaxDays.Size = new System.Drawing.Size(49, 26); + this.upDownMaxDays.TabIndex = 3; + this.upDownMaxDays.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + // + // fileNamePatternTextBox + // + this.fileNamePatternTextBox.Location = new System.Drawing.Point(149, 25); + this.fileNamePatternTextBox.Name = "fileNamePatternTextBox"; + this.fileNamePatternTextBox.Size = new System.Drawing.Size(247, 26); + this.fileNamePatternTextBox.TabIndex = 4; + // + // labelMaxDays + // + this.labelMaxDays.AutoSize = true; + this.labelMaxDays.Location = new System.Drawing.Point(6, 57); + this.labelMaxDays.Name = "labelMaxDays"; + this.labelMaxDays.Size = new System.Drawing.Size(79, 20); + this.labelMaxDays.TabIndex = 5; + this.labelMaxDays.Text = "Max days:"; + // + // Settings + // + this.Settings.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.Settings.Controls.Add(this.labelFileNamePattern); + this.Settings.Controls.Add(this.labelMaxDays); + this.Settings.Controls.Add(this.upDownMaxDays); + this.Settings.Controls.Add(this.fileNamePatternTextBox); + this.Settings.Location = new System.Drawing.Point(15, 39); + this.Settings.Name = "Settings"; + this.Settings.Size = new System.Drawing.Size(402, 98); + this.Settings.TabIndex = 6; + this.Settings.TabStop = false; + // + // syntaxHelpLabel + // + this.syntaxHelpLabel.Location = new System.Drawing.Point(15, 140); + this.syntaxHelpLabel.Name = "syntaxHelpLabel"; + this.syntaxHelpLabel.Size = new System.Drawing.Size(402, 194); + this.syntaxHelpLabel.TabIndex = 7; + this.syntaxHelpLabel.Text = "Syntax Help Label"; + // + // buttonOk + // + this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(261, 347); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 8; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.OnButtonOKClick); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(342, 347); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 9; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // MultiFileMaskDialog + // + this.AcceptButton = this.buttonOk; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(434, 386); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.syntaxHelpLabel); + this.Controls.Add(this.Settings); + this.Controls.Add(this.labelFileName); + this.Controls.Add(this.labelMultiSettingsFor); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(329, 420); + this.Name = "MultiFileMaskDialog"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "MultiFile settings"; + this.TopMost = true; + this.Load += new System.EventHandler(this.OnMultiFileMaskDialogLoad); + ((System.ComponentModel.ISupportInitialize)(this.upDownMaxDays)).EndInit(); + this.Settings.ResumeLayout(false); + this.Settings.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); } @@ -188,5 +188,4 @@ private void InitializeComponent() private System.Windows.Forms.Label syntaxHelpLabel; private System.Windows.Forms.Button buttonOk; private System.Windows.Forms.Button buttonCancel; - } -} \ No newline at end of file + } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/MultiFileMaskDialog.cs b/src/Logexpert.UI/Dialogs/MultiFileMaskDialog.cs index d82a5592..8b2203cf 100644 --- a/src/Logexpert.UI/Dialogs/MultiFileMaskDialog.cs +++ b/src/Logexpert.UI/Dialogs/MultiFileMaskDialog.cs @@ -1,63 +1,62 @@ using System.Runtime.Versioning; -namespace LogExpert.UI.Dialogs -{ - [SupportedOSPlatform("windows")] - public partial class MultiFileMaskDialog : Form - { - #region Fields - - #endregion +namespace LogExpert.UI.Dialogs; - #region cTor - - public MultiFileMaskDialog(Form parent, string fileName) - { - InitializeComponent(); +[SupportedOSPlatform("windows")] +public partial class MultiFileMaskDialog : Form +{ + #region Fields - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; + #endregion - syntaxHelpLabel.Text = "" + - "Pattern syntax:\n\n" + - "* = any characters (wildcard)\n" + - "$D() = Date pattern\n" + - "$I = File index number\n" + - "$J = File index number, hidden when zero\n" + - "$J() = Like $J, but adding when non-zero\n" + - "\n" + - ":\n" + - "DD = day\n" + - "MM = month\n" + - "YY[YY] = year\n" + - "all other chars will be used as given"; - labelFileName.Text = fileName; - } + #region cTor - #endregion + public MultiFileMaskDialog(Form parent, string fileName) + { + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + syntaxHelpLabel.Text = "" + + "Pattern syntax:\n\n" + + "* = any characters (wildcard)\n" + + "$D() = Date pattern\n" + + "$I = File index number\n" + + "$J = File index number, hidden when zero\n" + + "$J() = Like $J, but adding when non-zero\n" + + "\n" + + ":\n" + + "DD = day\n" + + "MM = month\n" + + "YY[YY] = year\n" + + "all other chars will be used as given"; + labelFileName.Text = fileName; + } - #region Properties + #endregion - public string FileNamePattern { get; set; } + #region Properties - public int MaxDays { get; set; } + public string FileNamePattern { get; set; } - #endregion + public int MaxDays { get; set; } - #region Events handler + #endregion - private void OnButtonOKClick(object sender, EventArgs e) - { - FileNamePattern = fileNamePatternTextBox.Text; - MaxDays = (int)upDownMaxDays.Value; - } + #region Events handler - private void OnMultiFileMaskDialogLoad(object sender, EventArgs e) - { - fileNamePatternTextBox.Text = FileNamePattern; - upDownMaxDays.Value = MaxDays; - } + private void OnButtonOKClick(object sender, EventArgs e) + { + FileNamePattern = fileNamePatternTextBox.Text; + MaxDays = (int)upDownMaxDays.Value; + } - #endregion + private void OnMultiFileMaskDialogLoad(object sender, EventArgs e) + { + fileNamePatternTextBox.Text = FileNamePattern; + upDownMaxDays.Value = MaxDays; } + + #endregion } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.Designer.cs b/src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.Designer.cs index 2bd65f3f..ecc9ddf4 100644 --- a/src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.Designer.cs @@ -1,89 +1,88 @@ -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +partial class MultiLoadRequestDialog { - partial class MultiLoadRequestDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} - #region Windows Form Designer generated code +#region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonSingleMode = new System.Windows.Forms.Button(); - this.buttonMultiMode = new System.Windows.Forms.Button(); - this.labelChooseLoadingMode = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // buttonSingleMode - // - this.buttonSingleMode.DialogResult = System.Windows.Forms.DialogResult.Yes; - this.buttonSingleMode.Location = new System.Drawing.Point(12, 59); - this.buttonSingleMode.Name = "buttonSingleMode"; - this.buttonSingleMode.Size = new System.Drawing.Size(75, 23); - this.buttonSingleMode.TabIndex = 1; - this.buttonSingleMode.Text = "Single files"; - this.buttonSingleMode.UseVisualStyleBackColor = true; - // - // buttonMultiMode - // - this.buttonMultiMode.DialogResult = System.Windows.Forms.DialogResult.No; - this.buttonMultiMode.Location = new System.Drawing.Point(114, 59); - this.buttonMultiMode.Name = "buttonMultiMode"; - this.buttonMultiMode.Size = new System.Drawing.Size(75, 23); - this.buttonMultiMode.TabIndex = 2; - this.buttonMultiMode.Text = "Multi file"; - this.buttonMultiMode.UseVisualStyleBackColor = true; - // - // labelChooseLoadingMode - // - this.labelChooseLoadingMode.AutoSize = true; - this.labelChooseLoadingMode.Location = new System.Drawing.Point(48, 18); - this.labelChooseLoadingMode.Name = "labelChooseLoadingMode"; - this.labelChooseLoadingMode.Size = new System.Drawing.Size(167, 20); - this.labelChooseLoadingMode.TabIndex = 4; - this.labelChooseLoadingMode.Text = "Choose loading mode:"; - // - // MultiLoadRequestDialog - // - this.ClientSize = new System.Drawing.Size(237, 103); - this.Controls.Add(this.labelChooseLoadingMode); - this.Controls.Add(this.buttonMultiMode); - this.Controls.Add(this.buttonSingleMode); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "MultiLoadRequestDialog"; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Loading multiple files"; - this.ResumeLayout(false); - this.PerformLayout(); +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + this.buttonSingleMode = new System.Windows.Forms.Button(); + this.buttonMultiMode = new System.Windows.Forms.Button(); + this.labelChooseLoadingMode = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonSingleMode + // + this.buttonSingleMode.DialogResult = System.Windows.Forms.DialogResult.Yes; + this.buttonSingleMode.Location = new System.Drawing.Point(12, 59); + this.buttonSingleMode.Name = "buttonSingleMode"; + this.buttonSingleMode.Size = new System.Drawing.Size(75, 23); + this.buttonSingleMode.TabIndex = 1; + this.buttonSingleMode.Text = "Single files"; + this.buttonSingleMode.UseVisualStyleBackColor = true; + // + // buttonMultiMode + // + this.buttonMultiMode.DialogResult = System.Windows.Forms.DialogResult.No; + this.buttonMultiMode.Location = new System.Drawing.Point(114, 59); + this.buttonMultiMode.Name = "buttonMultiMode"; + this.buttonMultiMode.Size = new System.Drawing.Size(75, 23); + this.buttonMultiMode.TabIndex = 2; + this.buttonMultiMode.Text = "Multi file"; + this.buttonMultiMode.UseVisualStyleBackColor = true; + // + // labelChooseLoadingMode + // + this.labelChooseLoadingMode.AutoSize = true; + this.labelChooseLoadingMode.Location = new System.Drawing.Point(48, 18); + this.labelChooseLoadingMode.Name = "labelChooseLoadingMode"; + this.labelChooseLoadingMode.Size = new System.Drawing.Size(167, 20); + this.labelChooseLoadingMode.TabIndex = 4; + this.labelChooseLoadingMode.Text = "Choose loading mode:"; + // + // MultiLoadRequestDialog + // + this.ClientSize = new System.Drawing.Size(237, 103); + this.Controls.Add(this.labelChooseLoadingMode); + this.Controls.Add(this.buttonMultiMode); + this.Controls.Add(this.buttonSingleMode); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "MultiLoadRequestDialog"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Loading multiple files"; + this.ResumeLayout(false); + this.PerformLayout(); - } +} - #endregion +#endregion - private System.Windows.Forms.Button buttonSingleMode; - private System.Windows.Forms.Button buttonMultiMode; - private System.Windows.Forms.Label labelChooseLoadingMode; - } +private System.Windows.Forms.Button buttonSingleMode; +private System.Windows.Forms.Button buttonMultiMode; +private System.Windows.Forms.Label labelChooseLoadingMode; } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.cs b/src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.cs index 31fe8d93..b53360fd 100644 --- a/src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.cs +++ b/src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.cs @@ -1,20 +1,19 @@ using System.Runtime.Versioning; -namespace LogExpert.UI.Dialogs -{ - [SupportedOSPlatform("windows")] - public partial class MultiLoadRequestDialog : Form - { - #region cTor +namespace LogExpert.UI.Dialogs; - public MultiLoadRequestDialog() - { - InitializeComponent(); +[SupportedOSPlatform("windows")] +public partial class MultiLoadRequestDialog : Form +{ + #region cTor - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - } + public MultiLoadRequestDialog() + { + InitializeComponent(); - #endregion + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; } + + #endregion } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/ParamRequesterDialog.Designer.cs b/src/Logexpert.UI/Dialogs/ParamRequesterDialog.Designer.cs new file mode 100644 index 00000000..bddf7808 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/ParamRequesterDialog.Designer.cs @@ -0,0 +1,104 @@ +namespace LogExpert.Dialogs; + +partial class ParamRequesterDialog +{ +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; + +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} + +#region Windows Form Designer generated code + +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + this.labelValueForParameter = new System.Windows.Forms.Label(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOk = new System.Windows.Forms.Button(); + this.comboBoxValue = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // labelValueForParameter + // + this.labelValueForParameter.AutoSize = true; + this.labelValueForParameter.Location = new System.Drawing.Point(13, 25); + this.labelValueForParameter.Name = "labelValueForParameter"; + this.labelValueForParameter.Size = new System.Drawing.Size(154, 20); + this.labelValueForParameter.TabIndex = 0; + this.labelValueForParameter.Text = "&Value for parameter:"; + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(238, 88); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 3; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // buttonOk + // + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(148, 88); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 2; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.okButton_Click); + // + // comboBoxValue + // + this.comboBoxValue.FormattingEnabled = true; + this.comboBoxValue.Location = new System.Drawing.Point(16, 48); + this.comboBoxValue.Name = "comboBoxValue"; + this.comboBoxValue.Size = new System.Drawing.Size(297, 28); + this.comboBoxValue.TabIndex = 1; + // + // ParamRequesterDialog + // + this.AcceptButton = this.buttonOk; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(332, 130); + this.Controls.Add(this.comboBoxValue); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.labelValueForParameter); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ParamRequesterDialog"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Tool parameter"; + this.Shown += new System.EventHandler(this.ParamRequesterDialog_Shown); + this.ResumeLayout(false); + this.PerformLayout(); + +} + +#endregion + +private System.Windows.Forms.Label labelValueForParameter; +private System.Windows.Forms.Button buttonCancel; +private System.Windows.Forms.Button buttonOk; +private System.Windows.Forms.ComboBox comboBoxValue; +} \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/ParamRequesterDialog.cs b/src/Logexpert.UI/Dialogs/ParamRequesterDialog.cs new file mode 100644 index 00000000..8953650d --- /dev/null +++ b/src/Logexpert.UI/Dialogs/ParamRequesterDialog.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace LogExpert.Dialogs; + +public partial class ParamRequesterDialog : Form +{ + #region Fields + + #endregion + + #region cTor + + public ParamRequesterDialog() + { + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + } + + #endregion + + #region Properties + + public string ParamName { get; set; } + + public string ParamValue { get; set; } + + public string[] Values { get; set; } + + #endregion + + #region Events handler + + private void ParamRequesterDialog_Shown(object sender, EventArgs e) + { + labelValueForParameter.Text = ParamName; + + if (Values != null) + { + foreach (string value in Values) + { + comboBoxValue.Items.Add(value); + } + comboBoxValue.SelectedIndex = 0; + } + } + + private void okButton_Click(object sender, EventArgs e) + { + ParamValue = comboBoxValue.Text; + } + + #endregion +} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/ParamRequesterDialog.resx b/src/Logexpert.UI/Dialogs/ParamRequesterDialog.resx similarity index 97% rename from src/LogExpert/Dialogs/ParamRequesterDialog.resx rename to src/Logexpert.UI/Dialogs/ParamRequesterDialog.resx index c7e0d4bd..d58980a3 100644 --- a/src/LogExpert/Dialogs/ParamRequesterDialog.resx +++ b/src/Logexpert.UI/Dialogs/ParamRequesterDialog.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/SearchProgressDialog.Designer.cs b/src/Logexpert.UI/Dialogs/SearchProgressDialog.Designer.cs index 87c05e64..756c707b 100644 --- a/src/Logexpert.UI/Dialogs/SearchProgressDialog.Designer.cs +++ b/src/Logexpert.UI/Dialogs/SearchProgressDialog.Designer.cs @@ -1,75 +1,74 @@ -namespace LogExpert.UI.Dialogs +namespace LogExpert.UI.Dialogs; + +partial class SearchProgressDialog { - partial class SearchProgressDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} - #region Windows Form Designer generated code +#region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.labelSearchProgress = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(159, 40); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(90, 23); - this.buttonCancel.TabIndex = 0; - this.buttonCancel.Text = "Cancel search"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.OnButtonCancelClick); - // - // labelSearchProgress - // - this.labelSearchProgress.AutoSize = true; - this.labelSearchProgress.Location = new System.Drawing.Point(13, 13); - this.labelSearchProgress.Name = "labelSearchProgress"; - this.labelSearchProgress.Size = new System.Drawing.Size(175, 20); - this.labelSearchProgress.TabIndex = 1; - this.labelSearchProgress.Text = "Searching in progress..."; - // - // SearchProgressDialog - // - this.ClientSize = new System.Drawing.Size(261, 80); - this.ControlBox = false; - this.Controls.Add(this.labelSearchProgress); - this.Controls.Add(this.buttonCancel); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Name = "SearchProgressDialog"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Searching..."; - this.ResumeLayout(false); - this.PerformLayout(); +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + this.buttonCancel = new System.Windows.Forms.Button(); + this.labelSearchProgress = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(159, 40); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(90, 23); + this.buttonCancel.TabIndex = 0; + this.buttonCancel.Text = "Cancel search"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.OnButtonCancelClick); + // + // labelSearchProgress + // + this.labelSearchProgress.AutoSize = true; + this.labelSearchProgress.Location = new System.Drawing.Point(13, 13); + this.labelSearchProgress.Name = "labelSearchProgress"; + this.labelSearchProgress.Size = new System.Drawing.Size(175, 20); + this.labelSearchProgress.TabIndex = 1; + this.labelSearchProgress.Text = "Searching in progress..."; + // + // SearchProgressDialog + // + this.ClientSize = new System.Drawing.Size(261, 80); + this.ControlBox = false; + this.Controls.Add(this.labelSearchProgress); + this.Controls.Add(this.buttonCancel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Name = "SearchProgressDialog"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Searching..."; + this.ResumeLayout(false); + this.PerformLayout(); - } +} - #endregion +#endregion - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Label labelSearchProgress; - } +private System.Windows.Forms.Button buttonCancel; +private System.Windows.Forms.Label labelSearchProgress; } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/SearchProgressDialog.cs b/src/Logexpert.UI/Dialogs/SearchProgressDialog.cs index 56223ebe..5fd7a6be 100644 --- a/src/Logexpert.UI/Dialogs/SearchProgressDialog.cs +++ b/src/Logexpert.UI/Dialogs/SearchProgressDialog.cs @@ -1,41 +1,40 @@ using System.Runtime.Versioning; -namespace LogExpert.UI.Dialogs -{ - [SupportedOSPlatform("windows")] - public partial class SearchProgressDialog : Form - { - #region Fields +namespace LogExpert.UI.Dialogs; - #endregion +[SupportedOSPlatform("windows")] +public partial class SearchProgressDialog : Form +{ + #region Fields - #region cTor + #endregion - public SearchProgressDialog() - { - InitializeComponent(); + #region cTor - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; + public SearchProgressDialog() + { + InitializeComponent(); - ShouldStop = false; - } + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; - #endregion + ShouldStop = false; + } - #region Properties + #endregion - public bool ShouldStop { get; private set; } + #region Properties - #endregion + public bool ShouldStop { get; private set; } - #region Events handler + #endregion - private void OnButtonCancelClick(object sender, EventArgs e) - { - ShouldStop = true; - } + #region Events handler - #endregion + private void OnButtonCancelClick(object sender, EventArgs e) + { + ShouldStop = true; } + + #endregion } \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/ToolArgsDialog.Designer.cs b/src/Logexpert.UI/Dialogs/ToolArgsDialog.Designer.cs new file mode 100644 index 00000000..71931e78 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/ToolArgsDialog.Designer.cs @@ -0,0 +1,150 @@ +namespace LogExpert.Dialogs; + +partial class ToolArgsDialog +{ +/// +/// Required designer variable. +/// +private System.ComponentModel.IContainer components = null; + +/// +/// Clean up any resources being used. +/// +/// true if managed resources should be disposed; otherwise, false. +protected override void Dispose(bool disposing) +{ + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); +} + +#region Windows Form Designer generated code + +/// +/// Required method for Designer support - do not modify +/// the contents of this method with the code editor. +/// +private void InitializeComponent() +{ + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonRegexHelp = new System.Windows.Forms.Button(); + this.textBoxArguments = new System.Windows.Forms.TextBox(); + this.buttonTest = new System.Windows.Forms.Button(); + this.labelEnterArguments = new System.Windows.Forms.Label(); + this.labelHelp = new System.Windows.Forms.Label(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.labelTestResult = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // buttonOk + // + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(348, 292); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 1; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.OnButtonOkClick); + // + // buttonRegexHelp + // + this.buttonRegexHelp.Location = new System.Drawing.Point(429, 59); + this.buttonRegexHelp.Name = "buttonRegexHelp"; + this.buttonRegexHelp.Size = new System.Drawing.Size(75, 21); + this.buttonRegexHelp.TabIndex = 2; + this.buttonRegexHelp.Text = "RegEx Help"; + this.buttonRegexHelp.UseVisualStyleBackColor = true; + this.buttonRegexHelp.Click += new System.EventHandler(this.OnButtonRegexHelpClick); + // + // textBoxArguments + // + this.textBoxArguments.Location = new System.Drawing.Point(12, 36); + this.textBoxArguments.Name = "textBoxArguments"; + this.textBoxArguments.Size = new System.Drawing.Size(395, 26); + this.textBoxArguments.TabIndex = 8; + // + // buttonTest + // + this.buttonTest.Location = new System.Drawing.Point(429, 30); + this.buttonTest.Name = "buttonTest"; + this.buttonTest.Size = new System.Drawing.Size(75, 23); + this.buttonTest.TabIndex = 9; + this.buttonTest.Text = "Test"; + this.buttonTest.UseVisualStyleBackColor = true; + this.buttonTest.Click += new System.EventHandler(this.OnButtonTestClick); + // + // labelEnterArguments + // + this.labelEnterArguments.AutoSize = true; + this.labelEnterArguments.Location = new System.Drawing.Point(12, 13); + this.labelEnterArguments.Name = "labelEnterArguments"; + this.labelEnterArguments.Size = new System.Drawing.Size(154, 20); + this.labelEnterArguments.TabIndex = 11; + this.labelEnterArguments.Text = "Enter command line:"; + // + // labelHelp + // + this.labelHelp.Location = new System.Drawing.Point(15, 124); + this.labelHelp.Name = "labelHelp"; + this.labelHelp.Size = new System.Drawing.Size(392, 157); + this.labelHelp.TabIndex = 12; + this.labelHelp.Text = "Help"; + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(429, 292); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 13; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // labelTestResult + // + this.labelTestResult.Location = new System.Drawing.Point(12, 68); + this.labelTestResult.Multiline = true; + this.labelTestResult.Name = "labelTestResult"; + this.labelTestResult.ReadOnly = true; + this.labelTestResult.Size = new System.Drawing.Size(395, 48); + this.labelTestResult.TabIndex = 14; + // + // ToolArgsDialog + // + this.AcceptButton = this.buttonOk; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(516, 327); + this.Controls.Add(this.labelTestResult); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.labelHelp); + this.Controls.Add(this.labelEnterArguments); + this.Controls.Add(this.buttonTest); + this.Controls.Add(this.textBoxArguments); + this.Controls.Add(this.buttonRegexHelp); + this.Controls.Add(this.buttonOk); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ToolArgsDialog"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Tool Arguments Help"; + this.Load += new System.EventHandler(this.OnToolArgsDialogLoad); + this.ResumeLayout(false); + this.PerformLayout(); + +} + +#endregion + +private System.Windows.Forms.Button buttonOk; +private System.Windows.Forms.Button buttonRegexHelp; +private System.Windows.Forms.TextBox textBoxArguments; +private System.Windows.Forms.Button buttonTest; +private System.Windows.Forms.Label labelEnterArguments; +private System.Windows.Forms.Label labelHelp; +private System.Windows.Forms.Button buttonCancel; +private System.Windows.Forms.TextBox labelTestResult; +} \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/ToolArgsDialog.cs b/src/Logexpert.UI/Dialogs/ToolArgsDialog.cs new file mode 100644 index 00000000..da95f186 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/ToolArgsDialog.cs @@ -0,0 +1,96 @@ +using LogExpert.Classes; +using LogExpert.UI.Controls.LogTabWindow; +using LogExpert.UI.Dialogs; + +using System; +using System.Drawing; +using System.Windows.Forms; + + +namespace LogExpert.Dialogs; + +internal partial class ToolArgsDialog : Form +{ + #region Fields + + private readonly LogTabWindow logTabWin; + + #endregion + + #region cTor + + public ToolArgsDialog(LogTabWindow logTabWin, Form parent) + { + this.logTabWin = logTabWin; + parent.AddOwnedForm(this); + TopMost = parent.TopMost; + InitializeComponent(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + } + + #endregion + + #region Properties + + public string Arg { get; set; } + + #endregion + + #region Events handler + + private void OnToolArgsDialogLoad(object sender, EventArgs e) + { + labelHelp.Text = "" + + "%L = Current line number\n" + + "%N = Current log file name without path\n" + + "%P = Path (directory) of current log file\n" + + "%F = Full name (incl. path) of log file\n" + + "%E = Extension of log file name (e.g. 'txt')\n" + + "%M = Name of log file without extension\n" + + "%S = User (from URI)\n" + + "%R = Path (from URI)\n" + + "%H = Host (from URI)\n" + + "%T = Port (from URI)\n" + + "?\"\" = variable parameter 'name'\n" + + "?\"\"(def1,def2,...) = variable parameter with predefined values\n" + + "\n" + + "{}{}:\n" + + "Regex search/replace on current selected line."; + + textBoxArguments.Text = Arg; + } + + private void OnButtonRegexHelpClick(object sender, EventArgs e) + { + RegexHelperDialog regexDlg = new(); + if (regexDlg.ShowDialog() == DialogResult.OK) + { + textBoxArguments.SelectedText = regexDlg.Pattern; + } + } + + //TODO: what is the purpose of this in the settings? Can we just send the line and info instead of the object? + private void OnButtonTestClick(object sender, EventArgs e) + { + if (logTabWin.CurrentLogWindow != null) + { + ILogLine line = logTabWin.CurrentLogWindow.GetCurrentLine(); + ILogFileInfo info = logTabWin.CurrentLogWindow.GetCurrentFileInfo(); + if (line != null && info != null) + { + ArgParser parser = new(textBoxArguments.Text); + string args = parser.BuildArgs(line, logTabWin.CurrentLogWindow.GetRealLineNum() + 1, info, this); + labelTestResult.Text = args; + } + } + } + + private void OnButtonOkClick(object sender, EventArgs e) + { + Arg = textBoxArguments.Text; + } + + #endregion +} \ No newline at end of file diff --git a/src/LogExpert/Dialogs/ToolArgsDialog.resx b/src/Logexpert.UI/Dialogs/ToolArgsDialog.resx similarity index 97% rename from src/LogExpert/Dialogs/ToolArgsDialog.resx rename to src/Logexpert.UI/Dialogs/ToolArgsDialog.resx index c7e0d4bd..d58980a3 100644 --- a/src/LogExpert/Dialogs/ToolArgsDialog.resx +++ b/src/Logexpert.UI/Dialogs/ToolArgsDialog.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/LogExpert/Classes/ArgParser.cs b/src/Logexpert.UI/Entities/ArgParser.cs similarity index 97% rename from src/LogExpert/Classes/ArgParser.cs rename to src/Logexpert.UI/Entities/ArgParser.cs index a5bfcabc..3b187342 100644 --- a/src/LogExpert/Classes/ArgParser.cs +++ b/src/Logexpert.UI/Entities/ArgParser.cs @@ -1,156 +1,156 @@ -using System; -using System.Text; -using System.Text.RegularExpressions; -using System.Windows.Forms; - -using LogExpert.Core.Classes; -using LogExpert.Dialogs; - -namespace LogExpert.Classes -{ - internal class ArgParser - { - #region Fields - - private readonly string argLine; - - #endregion - - #region cTor - - public ArgParser(string argTemplate) - { - argLine = argTemplate; - } - - #endregion - - #region Public methods - - public string BuildArgs(ILogLine logLine, int lineNum, ILogFileInfo logFileInfo, Form parent) - { - StringBuilder builder = new(argLine); - builder.Replace("%L", "" + lineNum); - builder.Replace("%P", logFileInfo.DirectoryName); - builder.Replace("%N", logFileInfo.FileName); - builder.Replace("%F", logFileInfo.FullName); - builder.Replace("%E", Util.GetExtension(logFileInfo.FileName)); - string stripped = Util.StripExtension(logFileInfo.FileName); - builder.Replace("%M", stripped); - - builder.Replace("%URI", logFileInfo.Uri.AbsoluteUri); - string user = logFileInfo.Uri.UserInfo; - if (user.Contains(":")) - { - user = user.Substring(0, user.IndexOf(':')); - } - builder.Replace("%S", user); - builder.Replace("%R", logFileInfo.Uri.PathAndQuery); - builder.Replace("%H", logFileInfo.Uri.Host); - builder.Replace("%T", logFileInfo.Uri.Port.ToString()); - - int sPos = 0; - string reg; - string replace; - do - { - reg = GetNextGroup(builder, ref sPos); - replace = GetNextGroup(builder, ref sPos); - if (reg != null && replace != null) - { - string result = Regex.Replace(logLine.FullLine, reg, replace); - builder.Insert(sPos, result); - } - } while (replace != null); - - int i = 0; - while (i < builder.Length) - { - // ?"Pinpad-type?"(thales,dione) - if (builder[i] == '?') - { - int end = i; - string ask = "Parameter"; - if (builder[i + 1] == '"') - { - end = builder.ToString().IndexOf('"', i + 2); - if (end == -1) - { - end = builder.Length - 1; - } - ask = builder.ToString().Substring(i + 2, end - i - 2); - } - string[] values = null; - if (builder[end + 1] == '(') - { - int end2 = builder.ToString().IndexOf(')'); - if (end2 == -1) - { - end2 = builder.Length - 1; - } - string valueStr = builder.ToString().Substring(end + 2, end2 - end - 2); - values = valueStr.Split(new char[] { ',' }, StringSplitOptions.None); - end = end2; - } - - ParamRequesterDialog dlg = new(); - dlg.ParamName = ask; - dlg.Values = values; - DialogResult res = dlg.ShowDialog(parent); - if (res == DialogResult.OK) - { - builder.Remove(i, end - i + 1); - builder.Insert(i, dlg.ParamValue); - } - else if (res == DialogResult.Cancel || res == DialogResult.Abort) - { - return null; - } - } - ++i; - } - - return builder.ToString(); - } - - #endregion - - #region Private Methods - - private string GetNextGroup(StringBuilder builder, ref int sPos) - { - int count = 0; - int ePos; - while (sPos < builder.Length) - { - if (builder[sPos] == '{') - { - ePos = sPos + 1; - count = 1; - while (ePos < builder.Length) - { - if (builder[ePos] == '{') - { - count++; - } - if (builder[ePos] == '}') - { - count--; - } - if (count == 0) - { - string reg = builder.ToString(sPos + 1, ePos - sPos - 1); - builder.Remove(sPos, ePos - sPos + 1); - return reg; - } - ePos++; - } - } - sPos++; - } - return null; - } - - #endregion - } +using System; +using System.Text; +using System.Text.RegularExpressions; +using System.Windows.Forms; + +using LogExpert.Core.Classes; +using LogExpert.Dialogs; + +namespace LogExpert.Classes +{ + internal class ArgParser + { + #region Fields + + private readonly string argLine; + + #endregion + + #region cTor + + public ArgParser(string argTemplate) + { + argLine = argTemplate; + } + + #endregion + + #region Public methods + + public string BuildArgs(ILogLine logLine, int lineNum, ILogFileInfo logFileInfo, Form parent) + { + StringBuilder builder = new(argLine); + builder.Replace("%L", "" + lineNum); + builder.Replace("%P", logFileInfo.DirectoryName); + builder.Replace("%N", logFileInfo.FileName); + builder.Replace("%F", logFileInfo.FullName); + builder.Replace("%E", Util.GetExtension(logFileInfo.FileName)); + string stripped = Util.StripExtension(logFileInfo.FileName); + builder.Replace("%M", stripped); + + builder.Replace("%URI", logFileInfo.Uri.AbsoluteUri); + string user = logFileInfo.Uri.UserInfo; + if (user.Contains(":")) + { + user = user.Substring(0, user.IndexOf(':')); + } + builder.Replace("%S", user); + builder.Replace("%R", logFileInfo.Uri.PathAndQuery); + builder.Replace("%H", logFileInfo.Uri.Host); + builder.Replace("%T", logFileInfo.Uri.Port.ToString()); + + int sPos = 0; + string reg; + string replace; + do + { + reg = GetNextGroup(builder, ref sPos); + replace = GetNextGroup(builder, ref sPos); + if (reg != null && replace != null) + { + string result = Regex.Replace(logLine.FullLine, reg, replace); + builder.Insert(sPos, result); + } + } while (replace != null); + + int i = 0; + while (i < builder.Length) + { + // ?"Pinpad-type?"(thales,dione) + if (builder[i] == '?') + { + int end = i; + string ask = "Parameter"; + if (builder[i + 1] == '"') + { + end = builder.ToString().IndexOf('"', i + 2); + if (end == -1) + { + end = builder.Length - 1; + } + ask = builder.ToString().Substring(i + 2, end - i - 2); + } + string[] values = null; + if (builder[end + 1] == '(') + { + int end2 = builder.ToString().IndexOf(')'); + if (end2 == -1) + { + end2 = builder.Length - 1; + } + string valueStr = builder.ToString().Substring(end + 2, end2 - end - 2); + values = valueStr.Split(new char[] { ',' }, StringSplitOptions.None); + end = end2; + } + + ParamRequesterDialog dlg = new(); + dlg.ParamName = ask; + dlg.Values = values; + DialogResult res = dlg.ShowDialog(parent); + if (res == DialogResult.OK) + { + builder.Remove(i, end - i + 1); + builder.Insert(i, dlg.ParamValue); + } + else if (res == DialogResult.Cancel || res == DialogResult.Abort) + { + return null; + } + } + ++i; + } + + return builder.ToString(); + } + + #endregion + + #region Private Methods + + private string GetNextGroup(StringBuilder builder, ref int sPos) + { + int count = 0; + int ePos; + while (sPos < builder.Length) + { + if (builder[sPos] == '{') + { + ePos = sPos + 1; + count = 1; + while (ePos < builder.Length) + { + if (builder[ePos] == '{') + { + count++; + } + if (builder[ePos] == '}') + { + count--; + } + if (count == 0) + { + string reg = builder.ToString(sPos + 1, ePos - sPos - 1); + builder.Remove(sPos, ePos - sPos + 1); + return reg; + } + ePos++; + } + } + sPos++; + } + return null; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Classes/PaintHelper.cs b/src/Logexpert.UI/Entities/PaintHelper.cs similarity index 95% rename from src/LogExpert/Classes/PaintHelper.cs rename to src/Logexpert.UI/Entities/PaintHelper.cs index 84297564..6b7331f4 100644 --- a/src/LogExpert/Classes/PaintHelper.cs +++ b/src/Logexpert.UI/Entities/PaintHelper.cs @@ -1,485 +1,488 @@ -using LogExpert.Config; -using LogExpert.Core.Classes.Highlight; -using LogExpert.Core.Config; -using LogExpert.Core.Entities; -using LogExpert.Core.Interface; -using LogExpert.Dialogs; - -using NLog; - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert.Classes -{ - internal class PaintHelper - { - #region Fields - - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - - //TODO Make configurable - private Color _bookmarkColor = Color.FromArgb(165, 200, 225); - - #endregion - - #region Properties - - private static Preferences Preferences => ConfigManager.Settings.Preferences; - - #endregion - - #region Public methods - - public static void CellPainting(ILogPaintContext logPaintCtx, BufferedDataGridView gridView, int rowIndex, - DataGridViewCellPaintingEventArgs e) - { - if (rowIndex < 0 || e.ColumnIndex < 0) - { - e.Handled = false; - return; - } - ILogLine line = logPaintCtx.GetLogLine(rowIndex); - if (line != null) - { - HighlightEntry entry = logPaintCtx.FindHighlightEntry(line, true); - e.Graphics.SetClip(e.CellBounds); - if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) - { - Color backColor = e.CellStyle.SelectionBackColor; - Brush brush; - if (gridView.Focused) - { - brush = new SolidBrush(e.CellStyle.SelectionBackColor); - } - else - { - Color color = Color.FromArgb(255, 170, 170, 170); - brush = new SolidBrush(color); - } - e.Graphics.FillRectangle(brush, e.CellBounds); - brush.Dispose(); - } - else - { - Color bgColor = ColorMode.DockBackgroundColor; - if (!DebugOptions.DisableWordHighlight) - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - else - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - e.CellStyle.BackColor = bgColor; - e.PaintBackground(e.ClipBounds, false); - } - - if (DebugOptions.DisableWordHighlight) - { - e.PaintContent(e.CellBounds); - } - else - { - PaintCell(logPaintCtx, e, gridView, false, entry); - } - - if (e.ColumnIndex == 0) - { - Bookmark bookmark = logPaintCtx.GetBookmarkForLine(rowIndex); - if (bookmark != null) - { - Rectangle r; // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); - r = e.CellBounds; - r.Inflate(-2, -2); - Brush brush = new SolidBrush(logPaintCtx.BookmarkColor); - e.Graphics.FillRectangle(brush, r); - brush.Dispose(); - if (bookmark.Text.Length > 0) - { - StringFormat format = new(); - format.LineAlignment = StringAlignment.Center; - format.Alignment = StringAlignment.Center; - Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); - Font font = logPaintCtx.MonospacedFont; - e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), - format); - brush2.Dispose(); - } - } - } - - e.Paint(e.CellBounds, DataGridViewPaintParts.Border); - e.Handled = true; - } - } - - public static DataGridViewTextBoxColumn CreateMarkerColumn() - { - DataGridViewTextBoxColumn markerColumn = new(); - markerColumn.HeaderText = ""; - markerColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - markerColumn.Resizable = DataGridViewTriState.False; - markerColumn.DividerWidth = 1; - markerColumn.ReadOnly = true; - markerColumn.SortMode = DataGridViewColumnSortMode.NotSortable; - - return markerColumn; - } - - public static DataGridViewTextBoxColumn CreateLineNumberColumn() - { - DataGridViewTextBoxColumn lineNumberColumn = new(); - lineNumberColumn.HeaderText = "Line"; - lineNumberColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - lineNumberColumn.Resizable = DataGridViewTriState.NotSet; - lineNumberColumn.DividerWidth = 1; - lineNumberColumn.ReadOnly = true; - lineNumberColumn.SortMode = DataGridViewColumnSortMode.NotSortable; - - return lineNumberColumn; - } - - public static DataGridViewColumn CreateTitleColumn(string colName) - { - DataGridViewColumn titleColumn = new LogTextColumn(); - titleColumn.HeaderText = colName; - titleColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - titleColumn.Resizable = DataGridViewTriState.NotSet; - titleColumn.DividerWidth = 1; - titleColumn.SortMode = DataGridViewColumnSortMode.NotSortable; - - return titleColumn; - } - - public static void SetColumnizer(ILogLineColumnizer columnizer, BufferedDataGridView gridView) - { - int rowCount = gridView.RowCount; - int currLine = gridView.CurrentCellAddress.Y; - int currFirstLine = gridView.FirstDisplayedScrollingRowIndex; - - try - { - gridView.Columns.Clear(); - } - catch (ArgumentOutOfRangeException ae) - { - // Occures sometimes on empty gridViews (no lines) if bookmark window was closed and re-opened in floating mode. - // Don't know why. - _logger.Error(ae); - } - - gridView.Columns.Add(CreateMarkerColumn()); - - gridView.Columns.Add(CreateLineNumberColumn()); - - foreach (string colName in columnizer.GetColumnNames()) - { - gridView.Columns.Add(CreateTitleColumn(colName)); - } - - gridView.RowCount = rowCount; - if (currLine != -1) - { - gridView.CurrentCell = gridView.Rows[currLine].Cells[0]; - } - if (currFirstLine != -1) - { - gridView.FirstDisplayedScrollingRowIndex = currFirstLine; - } - //gridView.Refresh(); - //AutoResizeColumns(gridView); - } - - public static void AutoResizeColumns(BufferedDataGridView gridView) - { - try - { - gridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - if (gridView.Columns.Count > 1 && Preferences.setLastColumnWidth && - gridView.Columns[gridView.Columns.Count - 1].Width < Preferences.lastColumnWidth - ) - { - // It seems that using 'MinimumWidth' instead of 'Width' prevents the DataGridView's NullReferenceExceptions - //gridView.Columns[gridView.Columns.Count - 1].Width = this.Preferences.lastColumnWidth; - gridView.Columns[gridView.Columns.Count - 1].MinimumWidth = Preferences.lastColumnWidth; - } - } - catch (NullReferenceException e) - { - // See https://connect.microsoft.com/VisualStudio/feedback/details/366943/autoresizecolumns-in-datagridview-throws-nullreferenceexception - // possible solution => https://stackoverflow.com/questions/36287553/nullreferenceexception-when-trying-to-set-datagridview-column-width-brings-th - // There are some rare situations with null ref exceptions when resizing columns and on filter finished - // So catch them here. Better than crashing. - _logger.Error(e, "Error while resizing columns: "); - } - } - - public static void ApplyDataGridViewPrefs(BufferedDataGridView dataGridView, Preferences prefs) - { - if (dataGridView.Columns.Count > 1) - { - if (prefs.setLastColumnWidth) - { - dataGridView.Columns[dataGridView.Columns.Count - 1].MinimumWidth = prefs.lastColumnWidth; - } - else - { - // Workaround for a .NET bug which brings the DataGridView into an unstable state (causing lots of NullReferenceExceptions). - dataGridView.FirstDisplayedScrollingColumnIndex = 0; - - dataGridView.Columns[dataGridView.Columns.Count - 1].MinimumWidth = 5; // default - } - } - if (dataGridView.RowCount > 0) - { - dataGridView.UpdateRowHeightInfo(0, true); - } - dataGridView.Invalidate(); - dataGridView.Refresh(); - AutoResizeColumns(dataGridView); - } - - public static Rectangle BorderWidths(DataGridViewAdvancedBorderStyle advancedBorderStyle) - { - Rectangle rect = new(); - - rect.X = advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; - if (advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.OutsetDouble || - advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.InsetDouble) - { - rect.X++; - } - - rect.Y = advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; - if (advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.OutsetDouble || - advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.InsetDouble) - { - rect.Y++; - } - - rect.Width = advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; - if (advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.OutsetDouble || - advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.InsetDouble) - { - rect.Width++; - } - - rect.Height = advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; - if (advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.OutsetDouble || - advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.InsetDouble) - { - rect.Height++; - } - - //rect.Width += this.owningColumn.DividerWidth; - //rect.Height += this.owningRow.DividerHeight; - - return rect; - } - - #endregion - - #region Private Methods - - private static void PaintCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) - { - PaintHighlightedCell(logPaintCtx, e, gridView, noBackgroundFill, groundEntry); - } - - private static void PaintHighlightedCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) - { - object value = e.Value ?? string.Empty; - - IList matchList = logPaintCtx.FindHighlightMatches(value as ILogLine); - // too many entries per line seem to cause problems with the GDI - while (matchList.Count > 50) - { - matchList.RemoveAt(50); - } - - if (value is Column column) - { - if (string.IsNullOrEmpty(column.FullValue) == false) - { - HilightMatchEntry hme = new(); - hme.StartPos = 0; - hme.Length = column.FullValue.Length; - - var he = new HighlightEntry - { - SearchText = column.FullValue, - ForegroundColor = groundEntry?.ForegroundColor ?? ColorMode.ForeColor, - BackgroundColor = groundEntry?.BackgroundColor ?? Color.Empty, - IsRegEx = false, - IsCaseSensitive = false, - IsLedSwitch = false, - IsStopTail = false, - IsSetBookmark = false, - IsActionEntry = false, - IsWordMatch = false - }; - - hme.HilightEntry = he; - - matchList = MergeHighlightMatchEntries(matchList, hme); - } - } - - int leftPad = e.CellStyle.Padding.Left; - RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, e.CellBounds.Height); - Rectangle borderWidths = BorderWidths(e.AdvancedBorderStyle); - Rectangle valBounds = e.CellBounds; - valBounds.Offset(borderWidths.X, borderWidths.Y); - valBounds.Width -= borderWidths.Right; - valBounds.Height -= borderWidths.Bottom; - if (e.CellStyle.Padding != Padding.Empty) - { - valBounds.Offset(e.CellStyle.Padding.Left, e.CellStyle.Padding.Top); - valBounds.Width -= e.CellStyle.Padding.Horizontal; - valBounds.Height -= e.CellStyle.Padding.Vertical; - } - - - TextFormatFlags flags = - TextFormatFlags.Left - | TextFormatFlags.SingleLine - | TextFormatFlags.NoPrefix - | TextFormatFlags.PreserveGraphicsClipping - | TextFormatFlags.NoPadding - | TextFormatFlags.VerticalCenter - | TextFormatFlags.TextBoxControl; - - // | TextFormatFlags.VerticalCenter - // | TextFormatFlags.TextBoxControl - // TextFormatFlags.SingleLine - //TextRenderer.DrawText(e.Graphics, e.Value as String, e.CellStyle.Font, valBounds, Color.FromKnownColor(KnownColor.Black), flags); - - Point wordPos = valBounds.Location; - Size proposedSize = new(valBounds.Width, valBounds.Height); - - Rectangle r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); - e.Graphics.SetClip(e.CellBounds); - - foreach (HilightMatchEntry matchEntry in matchList) - { - Font font = matchEntry != null && matchEntry.HilightEntry.IsBold - ? logPaintCtx.BoldFont - : logPaintCtx.NormalFont; - - Brush bgBrush = matchEntry.HilightEntry.BackgroundColor != Color.Empty - ? new SolidBrush(matchEntry.HilightEntry.BackgroundColor) - : null; - - string matchWord = string.Empty; - if (value is Column again) - { - if (string.IsNullOrEmpty(again.FullValue) == false) - { - matchWord = again.FullValue.Substring(matchEntry.StartPos, matchEntry.Length); - } - } - - Size wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags); - wordSize.Height = e.CellBounds.Height; - Rectangle wordRect = new(wordPos, wordSize); - - Color foreColor = matchEntry.HilightEntry.ForegroundColor; - if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected) - { - if (!noBackgroundFill && bgBrush != null && !matchEntry.HilightEntry.NoBackground) - { - e.Graphics.FillRectangle(bgBrush, wordRect); - } - } - else - { - if (foreColor.Equals(Color.Black)) - { - foreColor = Color.White; - } - } - TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, foreColor, flags); - - wordPos.Offset(wordSize.Width, 0); - bgBrush?.Dispose(); - } - } - - - /// - /// Builds a list of HilightMatchEntry objects. A HilightMatchEntry spans over a region that is painted with the same foreground and - /// background colors. - /// All regions which don't match a word-mode entry will be painted with the colors of a default entry (groundEntry). This is either the - /// first matching non-word-mode highlight entry or a black-on-white default (if no matching entry was found). - /// - /// List of all highlight matches for the current cell - /// The entry that is used as the default. - /// List of HilightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring. - private static IList MergeHighlightMatchEntries(IList matchList, HilightMatchEntry groundEntry) - { - // Fill an area with lenth of whole text with a default hilight entry - HighlightEntry[] entryArray = new HighlightEntry[groundEntry.Length]; - for (int i = 0; i < entryArray.Length; ++i) - { - entryArray[i] = groundEntry.HilightEntry; - } - - // "overpaint" with all matching word match enries - // Non-word-mode matches will not overpaint because they use the groundEntry - foreach (HilightMatchEntry me in matchList) - { - int endPos = me.StartPos + me.Length; - for (int i = me.StartPos; i < endPos; ++i) - { - if (me.HilightEntry.IsWordMatch) - { - entryArray[i] = me.HilightEntry; - } - //else - //{ - // //entryArray[i].ForegroundColor = me.HilightEntry.ForegroundColor; - //} - } - } - - // collect areas with same hilight entry and build new highlight match entries for it - IList mergedList = new List(); - if (entryArray.Length > 0) - { - HighlightEntry currentEntry = entryArray[0]; - int lastStartPos = 0; - int pos = 0; - for (; pos < entryArray.Length; ++pos) - { - if (entryArray[pos] != currentEntry) - { - HilightMatchEntry me = new(); - me.StartPos = lastStartPos; - me.Length = pos - lastStartPos; - me.HilightEntry = currentEntry; - mergedList.Add(me); - currentEntry = entryArray[pos]; - lastStartPos = pos; - } - } - HilightMatchEntry me2 = new(); - me2.StartPos = lastStartPos; - me2.Length = pos - lastStartPos; - me2.HilightEntry = currentEntry; - mergedList.Add(me2); - } - return mergedList; - } - - #endregion - } +using LogExpert.Core.Classes.Highlight; +using LogExpert.Core.Config; +using LogExpert.Core.Entities; +using LogExpert.Core.Interface; +using LogExpert.Dialogs; +using LogExpert.UI.Controls; +using NLog; + +namespace LogExpert.UI.Entities +{ + //TOOD: This whole class should be refactored and rethought + //TODO: This class should not knoow ConfigManager? + internal static class PaintHelper + { + #region Fields + + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + + //TODO Make configurable + private static Color _bookmarkColor = Color.FromArgb(165, 200, 225); + + #endregion + + #region Properties + public static IConfigManager ConfigManager { get; set; } + private static Preferences Preferences => ConfigManager.Settings.Preferences; + + #endregion + + #region Public methods + + public static void CellPainting(ILogPaintContext logPaintCtx, BufferedDataGridView gridView, int rowIndex, + DataGridViewCellPaintingEventArgs e) + { + if (rowIndex < 0 || e.ColumnIndex < 0) + { + e.Handled = false; + return; + } + ILogLine line = logPaintCtx.GetLogLine(rowIndex); + if (line != null) + { + HighlightEntry entry = logPaintCtx.FindHighlightEntry(line, true); + e.Graphics.SetClip(e.CellBounds); + if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) + { + Color backColor = e.CellStyle.SelectionBackColor; + Brush brush; + if (gridView.Focused) + { + brush = new SolidBrush(e.CellStyle.SelectionBackColor); + } + else + { + Color color = Color.FromArgb(255, 170, 170, 170); + brush = new SolidBrush(color); + } + e.Graphics.FillRectangle(brush, e.CellBounds); + brush.Dispose(); + } + else + { + Color bgColor = ColorMode.DockBackgroundColor; + if (!DebugOptions.DisableWordHighlight) + { + if (entry != null) + { + bgColor = entry.BackgroundColor; + } + } + else + { + if (entry != null) + { + bgColor = entry.BackgroundColor; + } + } + e.CellStyle.BackColor = bgColor; + e.PaintBackground(e.ClipBounds, false); + } + + if (DebugOptions.DisableWordHighlight) + { + e.PaintContent(e.CellBounds); + } + else + { + PaintCell(logPaintCtx, e, gridView, false, entry); + } + + if (e.ColumnIndex == 0) + { + Bookmark bookmark = logPaintCtx.GetBookmarkForLine(rowIndex); + if (bookmark != null) + { + Rectangle r; // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); + r = e.CellBounds; + r.Inflate(-2, -2); + Brush brush = new SolidBrush(logPaintCtx.BookmarkColor); + e.Graphics.FillRectangle(brush, r); + brush.Dispose(); + if (bookmark.Text.Length > 0) + { + StringFormat format = new(); + format.LineAlignment = StringAlignment.Center; + format.Alignment = StringAlignment.Center; + Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); + Font font = logPaintCtx.MonospacedFont; + e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), + format); + brush2.Dispose(); + } + } + } + + e.Paint(e.CellBounds, DataGridViewPaintParts.Border); + e.Handled = true; + } + } + + public static DataGridViewTextBoxColumn CreateMarkerColumn() + { + DataGridViewTextBoxColumn markerColumn = new(); + markerColumn.HeaderText = ""; + markerColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; + markerColumn.Resizable = DataGridViewTriState.False; + markerColumn.DividerWidth = 1; + markerColumn.ReadOnly = true; + markerColumn.SortMode = DataGridViewColumnSortMode.NotSortable; + + return markerColumn; + } + + public static DataGridViewTextBoxColumn CreateLineNumberColumn() + { + DataGridViewTextBoxColumn lineNumberColumn = new(); + lineNumberColumn.HeaderText = "Line"; + lineNumberColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; + lineNumberColumn.Resizable = DataGridViewTriState.NotSet; + lineNumberColumn.DividerWidth = 1; + lineNumberColumn.ReadOnly = true; + lineNumberColumn.SortMode = DataGridViewColumnSortMode.NotSortable; + + return lineNumberColumn; + } + + public static DataGridViewColumn CreateTitleColumn(string colName) + { + DataGridViewColumn titleColumn = new LogTextColumn(); + titleColumn.HeaderText = colName; + titleColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; + titleColumn.Resizable = DataGridViewTriState.NotSet; + titleColumn.DividerWidth = 1; + titleColumn.SortMode = DataGridViewColumnSortMode.NotSortable; + + return titleColumn; + } + + public static void SetColumnizer(ILogLineColumnizer columnizer, BufferedDataGridView gridView) + { + int rowCount = gridView.RowCount; + int currLine = gridView.CurrentCellAddress.Y; + int currFirstLine = gridView.FirstDisplayedScrollingRowIndex; + + try + { + gridView.Columns.Clear(); + } + catch (ArgumentOutOfRangeException ae) + { + // Occures sometimes on empty gridViews (no lines) if bookmark window was closed and re-opened in floating mode. + // Don't know why. + _logger.Error(ae); + } + + gridView.Columns.Add(CreateMarkerColumn()); + + gridView.Columns.Add(CreateLineNumberColumn()); + + foreach (string colName in columnizer.GetColumnNames()) + { + gridView.Columns.Add(CreateTitleColumn(colName)); + } + + gridView.RowCount = rowCount; + if (currLine != -1) + { + gridView.CurrentCell = gridView.Rows[currLine].Cells[0]; + } + if (currFirstLine != -1) + { + gridView.FirstDisplayedScrollingRowIndex = currFirstLine; + } + //gridView.Refresh(); + //AutoResizeColumns(gridView); + } + + //TODO: Original name is AutoResizeColumn. Where is this used? + //TODO: Rename ConfigManager to configManager + private static void AutoResizeColumns(BufferedDataGridView gridView, IConfigManager CnofigManager) + { + try + { + gridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + if (gridView.Columns.Count > 1 && Preferences.setLastColumnWidth && + gridView.Columns[gridView.Columns.Count - 1].Width < Preferences.lastColumnWidth + ) + { + // It seems that using 'MinimumWidth' instead of 'Width' prevents the DataGridView's NullReferenceExceptions + //gridView.Columns[gridView.Columns.Count - 1].Width = this.Preferences.lastColumnWidth; + gridView.Columns[gridView.Columns.Count - 1].MinimumWidth = Preferences.lastColumnWidth; + } + } + catch (NullReferenceException e) + { + // See https://connect.microsoft.com/VisualStudio/feedback/details/366943/autoresizecolumns-in-datagridview-throws-nullreferenceexception + // possible solution => https://stackoverflow.com/questions/36287553/nullreferenceexception-when-trying-to-set-datagridview-column-width-brings-th + // There are some rare situations with null ref exceptions when resizing columns and on filter finished + // So catch them here. Better than crashing. + _logger.Error(e, "Error while resizing columns: "); + } + } + + public static void ApplyDataGridViewPrefs(BufferedDataGridView dataGridView, Preferences prefs, IConfigManager configManager) + { + //TODO: This is a very bad solution and should be solved ASAP + if (ConfigManager == null) { + ConfigManager = configManager; + } + + if (dataGridView.Columns.Count > 1) + { + if (prefs.setLastColumnWidth) + { + dataGridView.Columns[dataGridView.Columns.Count - 1].MinimumWidth = prefs.lastColumnWidth; + } + else + { + // Workaround for a .NET bug which brings the DataGridView into an unstable state (causing lots of NullReferenceExceptions). + dataGridView.FirstDisplayedScrollingColumnIndex = 0; + + dataGridView.Columns[dataGridView.Columns.Count - 1].MinimumWidth = 5; // default + } + } + if (dataGridView.RowCount > 0) + { + dataGridView.UpdateRowHeightInfo(0, true); + } + dataGridView.Invalidate(); + dataGridView.Refresh(); + AutoResizeColumns(dataGridView, ConfigManager); + } + + public static Rectangle BorderWidths(DataGridViewAdvancedBorderStyle advancedBorderStyle) + { + Rectangle rect = new(); + + rect.X = advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; + if (advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.OutsetDouble || + advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.InsetDouble) + { + rect.X++; + } + + rect.Y = advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; + if (advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.OutsetDouble || + advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.InsetDouble) + { + rect.Y++; + } + + rect.Width = advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; + if (advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.OutsetDouble || + advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.InsetDouble) + { + rect.Width++; + } + + rect.Height = advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; + if (advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.OutsetDouble || + advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.InsetDouble) + { + rect.Height++; + } + + //rect.Width += this.owningColumn.DividerWidth; + //rect.Height += this.owningRow.DividerHeight; + + return rect; + } + + #endregion + + #region Private Methods + + private static void PaintCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) + { + PaintHighlightedCell(logPaintCtx, e, gridView, noBackgroundFill, groundEntry); + } + + private static void PaintHighlightedCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) + { + object value = e.Value ?? string.Empty; + + IList matchList = logPaintCtx.FindHighlightMatches(value as ILogLine); + // too many entries per line seem to cause problems with the GDI + while (matchList.Count > 50) + { + matchList.RemoveAt(50); + } + + if (value is Column column) + { + if (string.IsNullOrEmpty(column.FullValue) == false) + { + HilightMatchEntry hme = new(); + hme.StartPos = 0; + hme.Length = column.FullValue.Length; + + var he = new HighlightEntry + { + SearchText = column.FullValue, + ForegroundColor = groundEntry?.ForegroundColor ?? ColorMode.ForeColor, + BackgroundColor = groundEntry?.BackgroundColor ?? Color.Empty, + IsRegEx = false, + IsCaseSensitive = false, + IsLedSwitch = false, + IsStopTail = false, + IsSetBookmark = false, + IsActionEntry = false, + IsWordMatch = false + }; + + hme.HilightEntry = he; + + matchList = MergeHighlightMatchEntries(matchList, hme); + } + } + + int leftPad = e.CellStyle.Padding.Left; + RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, e.CellBounds.Height); + Rectangle borderWidths = BorderWidths(e.AdvancedBorderStyle); + Rectangle valBounds = e.CellBounds; + valBounds.Offset(borderWidths.X, borderWidths.Y); + valBounds.Width -= borderWidths.Right; + valBounds.Height -= borderWidths.Bottom; + if (e.CellStyle.Padding != Padding.Empty) + { + valBounds.Offset(e.CellStyle.Padding.Left, e.CellStyle.Padding.Top); + valBounds.Width -= e.CellStyle.Padding.Horizontal; + valBounds.Height -= e.CellStyle.Padding.Vertical; + } + + + TextFormatFlags flags = + TextFormatFlags.Left + | TextFormatFlags.SingleLine + | TextFormatFlags.NoPrefix + | TextFormatFlags.PreserveGraphicsClipping + | TextFormatFlags.NoPadding + | TextFormatFlags.VerticalCenter + | TextFormatFlags.TextBoxControl; + + // | TextFormatFlags.VerticalCenter + // | TextFormatFlags.TextBoxControl + // TextFormatFlags.SingleLine + //TextRenderer.DrawText(e.Graphics, e.Value as String, e.CellStyle.Font, valBounds, Color.FromKnownColor(KnownColor.Black), flags); + + Point wordPos = valBounds.Location; + Size proposedSize = new(valBounds.Width, valBounds.Height); + + Rectangle r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); + e.Graphics.SetClip(e.CellBounds); + + foreach (HilightMatchEntry matchEntry in matchList) + { + Font font = matchEntry != null && matchEntry.HilightEntry.IsBold + ? logPaintCtx.BoldFont + : logPaintCtx.NormalFont; + + Brush bgBrush = matchEntry.HilightEntry.BackgroundColor != Color.Empty + ? new SolidBrush(matchEntry.HilightEntry.BackgroundColor) + : null; + + string matchWord = string.Empty; + if (value is Column again) + { + if (string.IsNullOrEmpty(again.FullValue) == false) + { + matchWord = again.FullValue.Substring(matchEntry.StartPos, matchEntry.Length); + } + } + + Size wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags); + wordSize.Height = e.CellBounds.Height; + Rectangle wordRect = new(wordPos, wordSize); + + Color foreColor = matchEntry.HilightEntry.ForegroundColor; + if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected) + { + if (!noBackgroundFill && bgBrush != null && !matchEntry.HilightEntry.NoBackground) + { + e.Graphics.FillRectangle(bgBrush, wordRect); + } + } + else + { + if (foreColor.Equals(Color.Black)) + { + foreColor = Color.White; + } + } + TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, foreColor, flags); + + wordPos.Offset(wordSize.Width, 0); + bgBrush?.Dispose(); + } + } + + + /// + /// Builds a list of HilightMatchEntry objects. A HilightMatchEntry spans over a region that is painted with the same foreground and + /// background colors. + /// All regions which don't match a word-mode entry will be painted with the colors of a default entry (groundEntry). This is either the + /// first matching non-word-mode highlight entry or a black-on-white default (if no matching entry was found). + /// + /// List of all highlight matches for the current cell + /// The entry that is used as the default. + /// List of HilightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring. + private static IList MergeHighlightMatchEntries(IList matchList, HilightMatchEntry groundEntry) + { + // Fill an area with lenth of whole text with a default hilight entry + HighlightEntry[] entryArray = new HighlightEntry[groundEntry.Length]; + for (int i = 0; i < entryArray.Length; ++i) + { + entryArray[i] = groundEntry.HilightEntry; + } + + // "overpaint" with all matching word match enries + // Non-word-mode matches will not overpaint because they use the groundEntry + foreach (HilightMatchEntry me in matchList) + { + int endPos = me.StartPos + me.Length; + for (int i = me.StartPos; i < endPos; ++i) + { + if (me.HilightEntry.IsWordMatch) + { + entryArray[i] = me.HilightEntry; + } + //else + //{ + // //entryArray[i].ForegroundColor = me.HilightEntry.ForegroundColor; + //} + } + } + + // collect areas with same hilight entry and build new highlight match entries for it + IList mergedList = new List(); + if (entryArray.Length > 0) + { + HighlightEntry currentEntry = entryArray[0]; + int lastStartPos = 0; + int pos = 0; + for (; pos < entryArray.Length; ++pos) + { + if (entryArray[pos] != currentEntry) + { + HilightMatchEntry me = new(); + me.StartPos = lastStartPos; + me.Length = pos - lastStartPos; + me.HilightEntry = currentEntry; + mergedList.Add(me); + currentEntry = entryArray[pos]; + lastStartPos = pos; + } + } + HilightMatchEntry me2 = new(); + me2.StartPos = lastStartPos; + me2.Length = pos - lastStartPos; + me2.HilightEntry = currentEntry; + mergedList.Add(me2); + } + return mergedList; + } + + #endregion + } } \ No newline at end of file diff --git a/src/LogExpert/Entities/WindowFileEntry.cs b/src/Logexpert.UI/Entities/WindowFileEntry.cs similarity index 81% rename from src/LogExpert/Entities/WindowFileEntry.cs rename to src/Logexpert.UI/Entities/WindowFileEntry.cs index 31a36c81..7bd57c46 100644 --- a/src/LogExpert/Entities/WindowFileEntry.cs +++ b/src/Logexpert.UI/Entities/WindowFileEntry.cs @@ -1,44 +1,42 @@ -using LogExpert.Controls.LogWindow; - -using System; - -namespace LogExpert.Entities -{ - /// - /// Represents a log file and its window. Used as a kind of handle for menus or list of open files. - /// - public class WindowFileEntry(LogWindow logWindow) - { - #region Fields - - private const int MAX_LEN = 40; - - #endregion - #region cTor - - #endregion - - #region Properties - - public string Title - { - get - { - string title = LogWindow.Text; - - if (title.Length > MAX_LEN) - { - title = string.Concat("...", title.AsSpan(title.Length - MAX_LEN)); - } - return title; - } - } - - public string FileName => LogWindow.FileName; - - - public LogWindow LogWindow { get; } = logWindow; - - #endregion - } +using LogExpert.UI.Controls.LogWindow; + +namespace LogExpert.UI.Entities +{ + /// + /// Represents a log file and its window. Used as a kind of handle for menus or list of open files. + /// + internal class WindowFileEntry(LogWindow logWindow) + { + #region Fields + + private const int MAX_LEN = 40; + + #endregion + #region cTor + + #endregion + + #region Properties + + public string Title + { + get + { + string title = LogWindow.Text; + + if (title.Length > MAX_LEN) + { + title = string.Concat("...", title.AsSpan(title.Length - MAX_LEN)); + } + return title; + } + } + + public string FileName => LogWindow.FileName; + + + public LogWindow LogWindow { get; } = logWindow; + + #endregion + } } \ No newline at end of file diff --git a/src/Logexpert.UI/LogExpert.UI.csproj b/src/Logexpert.UI/LogExpert.UI.csproj index 67b86a95..518bb32d 100644 --- a/src/Logexpert.UI/LogExpert.UI.csproj +++ b/src/Logexpert.UI/LogExpert.UI.csproj @@ -2,103 +2,54 @@ net8.0-windows - enable + disable true enable - false - True - ..\Solution Items\Key.snk - true + false + True + ..\Solution Items\Key.snk + true - - + + + - - Component - - - UserControl - - - Component - - - Component - - - Form - - - Form - - - Form - - - Form - - - Form - - - Form - - - Form - - - Form - - - Form - - - Form - - - Form - - - Form - - - Form - - - Form - - - Form - - - Form - - - Component - - - Component - + + + + + + - + + Always + + - + + True + True + Resources.resx + - + + ResXFileCodeGenerator + Resources.Designer.cs + diff --git a/src/PluginRegistry/LogExpert.PluginRegistry.csproj b/src/PluginRegistry/LogExpert.PluginRegistry.csproj index 55e143ec..a63bd451 100644 --- a/src/PluginRegistry/LogExpert.PluginRegistry.csproj +++ b/src/PluginRegistry/LogExpert.PluginRegistry.csproj @@ -3,7 +3,7 @@ net8.0 enable - false + false enable True ..\Solution Items\Key.snk diff --git a/src/PluginRegistry/PluginRegistry.cs b/src/PluginRegistry/PluginRegistry.cs index 1ba393d9..26bf5331 100644 --- a/src/PluginRegistry/PluginRegistry.cs +++ b/src/PluginRegistry/PluginRegistry.cs @@ -1,6 +1,7 @@ using LogExpert.Core.Classes; using LogExpert.Core.Classes.Columnizer; using LogExpert.Core.Entities; +using LogExpert.Core.Interface; using LogExpert.PluginRegistry.FileSystem; using NLog; @@ -16,7 +17,7 @@ namespace LogExpert.PluginRegistry /// It all has started with Columnizers only. So the different types of plugins have no common super interface. I didn't change it /// to keep existing plugin API stable. In a future version this may change. /// - public class PluginRegistry + public class PluginRegistry : IPluginRegistry { #region Fields @@ -107,7 +108,10 @@ internal void LoadPlugins() AppDomain.CurrentDomain.AssemblyResolve += ColumnizerResolveEventHandler; - string interfaceName = typeof(ILogLineColumnizer).FullName; + var interfaceName = typeof(ILogLineColumnizer).FullName; + if (interfaceName == null) { + throw new NotImplementedException("The interface name is null. How did this happen? Let's fix this."); + } foreach (string dllName in Directory.EnumerateFiles(pluginDir, "*.dll")) { try From 683b178b3fac3e6c7f23c693609dc11827f7b11c Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Mon, 26 May 2025 01:33:31 +0300 Subject: [PATCH 030/142] Moved CmdLine back to LogExpert as it is not part of the core logic of the application. --- src/LogExpert/Classes/CommandLine/CmdLine.cs | 189 ++++++++ .../Classes/CommandLine/CmdLineException.cs | 31 ++ .../Classes/CommandLine/CmdLineInt.cs | 102 +++++ .../Classes/CommandLine/CmdLineParameter.cs | 66 +++ .../Classes/CommandLine/ConsoleCmdLine.cs | 61 +++ src/LogExpert/LogExpert.csproj | 29 +- src/LogExpert/Program.cs | 171 ++++---- src/Logexpert.Core/Classes/CmdLine.cs | 412 ------------------ 8 files changed, 544 insertions(+), 517 deletions(-) create mode 100644 src/LogExpert/Classes/CommandLine/CmdLine.cs create mode 100644 src/LogExpert/Classes/CommandLine/CmdLineException.cs create mode 100644 src/LogExpert/Classes/CommandLine/CmdLineInt.cs create mode 100644 src/LogExpert/Classes/CommandLine/CmdLineParameter.cs create mode 100644 src/LogExpert/Classes/CommandLine/ConsoleCmdLine.cs delete mode 100644 src/Logexpert.Core/Classes/CmdLine.cs diff --git a/src/LogExpert/Classes/CommandLine/CmdLine.cs b/src/LogExpert/Classes/CommandLine/CmdLine.cs new file mode 100644 index 00000000..19ad74d0 --- /dev/null +++ b/src/LogExpert/Classes/CommandLine/CmdLine.cs @@ -0,0 +1,189 @@ +/* + * Taken from https://cmdline.codeplex.com/ + * + */ + +//TODO: Replace with https://github.com/commandlineparser/commandline +//TODO: or with this https://github.com/natemcmaster/CommandLineUtils +namespace LogExpert.Classes.CommandLine +{ + /// + /// Represents an string command line parameter. + /// + public class CmdLineString(string name, bool required, string helpMessage) : CmdLineParameter(name, required, helpMessage) + { + + #region Public methods + + public static implicit operator string(CmdLineString s) + { + return s.Value; + } + + #endregion + } + + /// + /// Provides a simple strongly typed interface to work with command line parameters. + /// + public class CmdLine + { + #region Fields + + // A private dictonary containing the parameters. + private readonly Dictionary parameters = []; + + #endregion + + #region cTor + + /// + /// Creats a new empty command line object. + /// + public CmdLine() + { + } + + #endregion + + #region Properties + + /// + /// Returns a command line parameter by the name. + /// + /// The name of the parameter (the word after the initial hyphen (-). + /// A reference to the named comman line object. + public CmdLineParameter this[string name] + { + get + { + if (parameters.TryGetValue(name, out CmdLineParameter value) == false) + { + throw new CmdLineException(name, "Not a registered parameter."); + } + return value; + } + } + + #endregion + + #region Public methods + + /// + /// Registers a parameter to be used and adds it to the help screen. + /// + /// The parameter to add. + public void RegisterParameter(CmdLineParameter parameter) + { + if (parameters.ContainsKey(parameter.Name)) + { + throw new CmdLineException(parameter.Name, "Parameter is already registered."); + } + parameters.Add(parameter.Name, parameter); + } + + /// + /// Registers parameters to be used and adds hem to the help screen. + /// + /// The parameter to add. + public void RegisterParameter(CmdLineParameter[] parameters) + { + foreach (CmdLineParameter p in parameters) + { + RegisterParameter(p); + } + } + + + /// + /// Parses the command line and sets the value of each registered parmaters. + /// + /// The arguments array sent to main() + /// Any reminding strings after arguments has been processed. + public string[] Parse(string[] args) + { + int i = 0; + + List new_args = []; + + while (i < args.Length) + { + if (args[i].Length > 1 && args[i][0] == '-') + { + // The current string is a parameter name + string key = args[i][1..].ToLower(); + string argsValue = string.Empty; + i++; + if (i < args.Length) + { + if (args[i].Length > 0 && args[i][0] == '-') + { + // The next string is a new parameter, do not nothing + } + else + { + // The next string is a value, read the value and move forward + argsValue = args[i]; + i++; + } + } + if (parameters.TryGetValue(key, out CmdLineParameter cmdLineParameter) == false) + { + throw new CmdLineException(key, "Parameter is not allowed."); + } + + if (cmdLineParameter.Exists) + { + throw new CmdLineException(key, "Parameter is specified more than once."); + } + + cmdLineParameter.SetValue(argsValue); + } + else + { + new_args.Add(args[i]); + i++; + } + } + + + // Check that required parameters are present in the command line. + foreach (string key in parameters.Keys) + { + if (parameters[key].Required && parameters[key].Exists == false) + { + throw new CmdLineException(key, "Required parameter is not found."); + } + } + + return new_args.ToArray(); + } + + /// + /// Generates the help screen. + /// + public string HelpScreen() + { + int len = 0; + foreach (string key in parameters.Keys) + { + len = Math.Max(len, key.Length); + } + + string help = "\nParameters:\n\n"; + foreach (string key in parameters.Keys) + { + string s = "-" + parameters[key].Name; + while (s.Length < len + 3) + { + s += " "; + } + s += parameters[key].Help + "\n"; + help += s; + } + return help; + } + + #endregion + } +} \ No newline at end of file diff --git a/src/LogExpert/Classes/CommandLine/CmdLineException.cs b/src/LogExpert/Classes/CommandLine/CmdLineException.cs new file mode 100644 index 00000000..a89bc570 --- /dev/null +++ b/src/LogExpert/Classes/CommandLine/CmdLineException.cs @@ -0,0 +1,31 @@ +/* + * Taken from https://cmdline.codeplex.com/ + * + */ + +//TODO: Replace with https://github.com/commandlineparser/commandline +//TODO: or with this https://github.com/natemcmaster/CommandLineUtils +namespace LogExpert.Classes.CommandLine +{ + /// + /// Represents an error occuring during command line parsing. + /// + public class CmdLineException : Exception + { + #region cTor + + public CmdLineException(string parameter, string message) + : + base(string.Format("Syntax error of parameter -{0}: {1}", parameter, message)) + { + } + + public CmdLineException(string message) + : + base(message) + { + } + + #endregion + } +} \ No newline at end of file diff --git a/src/LogExpert/Classes/CommandLine/CmdLineInt.cs b/src/LogExpert/Classes/CommandLine/CmdLineInt.cs new file mode 100644 index 00000000..de6394b8 --- /dev/null +++ b/src/LogExpert/Classes/CommandLine/CmdLineInt.cs @@ -0,0 +1,102 @@ +/* + * Taken from https://cmdline.codeplex.com/ + * + */ + +//TODO: Replace with https://github.com/commandlineparser/commandline +//TODO: or with this https://github.com/natemcmaster/CommandLineUtils +namespace LogExpert.Classes.CommandLine +{ + /// + /// Represents an integer command line parameter. + /// + public class CmdLineInt : CmdLineParameter + { + #region Fields + + private readonly int _max = int.MaxValue; + private readonly int _min = int.MinValue; + + #endregion + + #region cTor + + /// + /// Creates a new instance of this class. + /// + /// Name of parameter. + /// Require that the parameter is present in the command line. + /// The explanation of the parameter to add to the help screen. + public CmdLineInt(string name, bool required, string helpMessage) + : base(name, required, helpMessage) + { + } + + /// + /// Creates a new instance of this class. + /// + /// Name of parameter. + /// Require that the parameter is present in the command line. + /// The explanation of the parameter to add to the help screen. + /// The minimum value of the parameter. + /// The maximum valie of the parameter. + public CmdLineInt(string name, bool required, string helpMessage, int min, int max) + : base(name, required, helpMessage) + { + _min = min; + _max = max; + } + + #endregion + + #region Properties + + /// + /// Returns the current value of the parameter. + /// + new public int Value { get; private set; } + + #endregion + + #region Public methods + + /// + /// Sets the value of the parameter. + /// + /// A string containing a integer expression. + public override void SetValue(string value) + { + base.SetValue(value); + int i = 0; + try + { + i = Convert.ToInt32(value); + } + catch (Exception) + { + throw new CmdLineException(Name, "Value is not an integer."); + } + if (i < _min) + { + throw new CmdLineException(Name, string.Format("Value must be greather or equal to {0}.", _min)); + } + if (i > _max) + { + throw new CmdLineException(Name, string.Format("Value must be less or equal to {0}.", _max)); + } + Value = i; + } + + /// + /// A implicit converion to a int data type. + /// + /// + /// + public static implicit operator int(CmdLineInt s) + { + return s.Value; + } + + #endregion + } +} \ No newline at end of file diff --git a/src/LogExpert/Classes/CommandLine/CmdLineParameter.cs b/src/LogExpert/Classes/CommandLine/CmdLineParameter.cs new file mode 100644 index 00000000..9f7f9db8 --- /dev/null +++ b/src/LogExpert/Classes/CommandLine/CmdLineParameter.cs @@ -0,0 +1,66 @@ +/* + * Taken from https://cmdline.codeplex.com/ + * + */ + +//TODO: Replace with https://github.com/commandlineparser/commandline +//TODO: or with this https://github.com/natemcmaster/CommandLineUtils +namespace LogExpert.Classes.CommandLine +{ + /// + /// Represents a command line parameter. + /// Parameters are words in the command line beginning with a hyphen (-). + /// The value of the parameter is the next word in + /// + /// + /// Creates a new instance of this class. + /// + /// Name of parameter. + /// Require that the parameter is present in the command line. + /// The explanation of the parameter to add to the help screen. + public class CmdLineParameter(string name, bool required, string helpMessage) + { + #region Properties + + /// + /// Returns the value of the parameter. + /// + public string Value { get; private set; } = ""; + + /// + /// Returns the help message associated with the parameter. + /// + public string Help { get; } = helpMessage; + + /// + /// Returns true if the parameter was found in the command line. + /// + public bool Exists { get; private set; } = false; + + /// + /// Returns true if the parameter is required in the command line. + /// + public bool Required { get; } = required; + + /// + /// Returns the name of the parameter. + /// + public string Name { get; } = name; + + #endregion + + #region Public methods + + /// + /// Sets the value of the parameter. + /// + /// A string containing a integer expression. + public virtual void SetValue(string value) + { + Value = value; + Exists = true; + } + + #endregion + } +} \ No newline at end of file diff --git a/src/LogExpert/Classes/CommandLine/ConsoleCmdLine.cs b/src/LogExpert/Classes/CommandLine/ConsoleCmdLine.cs new file mode 100644 index 00000000..80474c83 --- /dev/null +++ b/src/LogExpert/Classes/CommandLine/ConsoleCmdLine.cs @@ -0,0 +1,61 @@ +/* + * Taken from https://cmdline.codeplex.com/ + * + */ + +//TODO: Replace with https://github.com/commandlineparser/commandline +//TODO: or with this https://github.com/natemcmaster/CommandLineUtils +namespace LogExpert.Classes.CommandLine +{ + /// + /// Represents a CmdLine object to use with console applications. + /// The -help parameter will be registered automatically. + /// Any errors will be written to the console instead of generating exceptions. + /// + public class ConsoleCmdLine : CmdLine + { + #region cTor + + public ConsoleCmdLine() + { + RegisterParameter(new CmdLineString("help", false, "Prints the help screen.")); + } + + #endregion + + #region Public methods + + public new string[] Parse(string[] args) + { + string[] ret = []; + + string error = string.Empty; + + try + { + ret = base.Parse(args); + } + catch (CmdLineException ex) + { + error = ex.Message; + } + + if (this["help"].Exists) + { + Console.WriteLine(HelpScreen()); + Environment.Exit(0); + } + + if (error != string.Empty) + { + Console.WriteLine(error); + Console.WriteLine("Use -help for more information."); + Environment.Exit(1); + } + + return ret; + } + + #endregion + } +} \ No newline at end of file diff --git a/src/LogExpert/LogExpert.csproj b/src/LogExpert/LogExpert.csproj index 834aca9a..61859238 100644 --- a/src/LogExpert/LogExpert.csproj +++ b/src/LogExpert/LogExpert.csproj @@ -1,29 +1,30 @@  - net8.0-windows - True - WinExe - logexpert.ico - False - False - $(SolutionDir)..\bin\Docs\LogExpert.xml - False False - Auto - True - ..\Solution Items\Key.snk False - $(SolutionDir)..\bin\$(Configuration) - True PerMonitorV2 + logexpert.ico + ..\Solution Items\Key.snk + True + $(SolutionDir)..\bin\Docs\LogExpert.xml + True True + False + Auto + enable + False CS1591; + $(SolutionDir)..\bin\$(Configuration) + WinExe + True + net8.0-windows + False False - + True diff --git a/src/LogExpert/Program.cs b/src/LogExpert/Program.cs index a808363d..66caf74e 100644 --- a/src/LogExpert/Program.cs +++ b/src/LogExpert/Program.cs @@ -1,6 +1,6 @@ using LogExpert.Classes; +using LogExpert.Classes.CommandLine; using LogExpert.Config; -using LogExpert.Core.Classes; using LogExpert.Core.Classes.IPC; using LogExpert.Core.Config; using LogExpert.Core.Interface; @@ -10,17 +10,12 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using NLog; -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.IO; using System.IO.Pipes; using System.Reflection; using System.Security; using System.Security.Principal; using System.Text; -using System.Threading; -using System.Threading.Tasks; using System.Windows.Forms; namespace LogExpert @@ -32,7 +27,6 @@ internal static class Program private static readonly Logger _logger = LogManager.GetLogger("Program"); private const string PIPE_SERVER_NAME = "LogExpert_IPC"; private const int PIPE_CONNECTION_TIMEOUT_IN_MS = 5000; - private static readonly CancellationTokenSource _cts = new(); #endregion @@ -42,20 +36,7 @@ internal static class Program /// The main entry point for the application. /// [STAThread] - private static void Main(string[] orgArgs) - { - try - { - Sub_Main(orgArgs); - } - catch (SecurityException se) - { - MessageBox.Show("Insufficient system rights for LogExpert. Maybe you have started it from a network drive. Please start LogExpert from a local drive.\n(" + se.Message + ")", "LogExpert Error"); - _cts.Cancel(); - } - } - - private static void Sub_Main(string[] orgArgs) + private static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.ThreadException += Application_ThreadException; @@ -67,98 +48,106 @@ private static void Sub_Main(string[] orgArgs) _logger.Info("\r\n============================================================================\r\nLogExpert {0} started.\r\n============================================================================", Assembly.GetExecutingAssembly().GetName().Version.ToString(3)); - CmdLine cmdLine = new(); - CmdLineString configFile = new("config", false, "A configuration (settings) file"); - cmdLine.RegisterParameter(configFile); - if (configFile.Exists) + CancellationTokenSource cts = new(); + try { - FileInfo cfgFileInfo = new(configFile.Value); - - if (cfgFileInfo.Exists) - { - ConfigManager.Instance.Import(cfgFileInfo, ExportImportFlags.All); - } - else + CmdLineString configFile = new("config", false, "A configuration (settings) file"); + CmdLine cmdLine = new(); + cmdLine.RegisterParameter(configFile); + if (configFile.Exists) { - MessageBox.Show(@"Config file not found", @"LogExpert"); - } - } - PluginRegistry.PluginRegistry.Instance.Create(ConfigManager.Instance.ConfigDir, ConfigManager.Instance.Settings.Preferences.pollingInterval); - - int pId = Process.GetCurrentProcess().SessionId; + FileInfo cfgFileInfo = new(configFile.Value); - try - { - Settings settings = ConfigManager.Instance.Settings; + if (cfgFileInfo.Exists) + { + ConfigManager.Instance.Import(cfgFileInfo, ExportImportFlags.All); + } + else + { + MessageBox.Show(@"Config file not found", @"LogExpert"); + } + } + PluginRegistry.PluginRegistry.Instance.Create(ConfigManager.Instance.ConfigDir, ConfigManager.Instance.Settings.Preferences.pollingInterval); - Mutex mutex = new(false, "Local\\LogExpertInstanceMutex" + pId, out var isCreated); + var pId = Process.GetCurrentProcess().SessionId; - var remainingArgs = cmdLine.Parse(orgArgs); - var absoluteFilePaths = GenerateAbsoluteFilePaths(remainingArgs); - if (isCreated) + try { - // first application instance - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - ILogTabWindow logWin = AbstractLogTabWindow.Create(absoluteFilePaths.Length > 0 ? absoluteFilePaths : null, 1, false, ConfigManager.Instance); + Mutex mutex = new(false, "Local\\LogExpertInstanceMutex" + pId, out var isCreated); + var remainingArgs = cmdLine.Parse(args); + var absoluteFilePaths = GenerateAbsoluteFilePaths(remainingArgs); - // first instance - WindowsIdentity wi = WindowsIdentity.GetCurrent(); - LogExpertProxy proxy = new(logWin); - LogExpertApplicationContext context = new(proxy, logWin); + if (isCreated) + { + // first application instance + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + ILogTabWindow logWin = AbstractLogTabWindow.Create(absoluteFilePaths.Length > 0 ? absoluteFilePaths : null, 1, false, ConfigManager.Instance); - Task.Run(() => RunServerLoopAsync(SendMessageToProxy, proxy, _cts.Token)); + // first instance + var wi = WindowsIdentity.GetCurrent(); + LogExpertProxy proxy = new(logWin); + LogExpertApplicationContext context = new(proxy, logWin); - Application.Run(context); - } - else - { - int counter = 3; - Exception errMsg = null; + Task.Run(() => RunServerLoopAsync(SendMessageToProxy, proxy, cts.Token)); - while (counter > 0) + Application.Run(context); + } + else { - try + int counter = 3; + Exception errMsg = null; + + Settings settings = ConfigManager.Instance.Settings; + while (counter > 0) { - WindowsIdentity wi = WindowsIdentity.GetCurrent(); - var command = SerializeCommandIntoNonFormattedJSON(absoluteFilePaths, settings.Preferences.allowOnlyOneInstance); - SendCommandToServer(command); - break; + try + { + WindowsIdentity wi = WindowsIdentity.GetCurrent(); + var command = SerializeCommandIntoNonFormattedJSON(absoluteFilePaths, settings.Preferences.allowOnlyOneInstance); + SendCommandToServer(command); + break; + } + catch (Exception e) + { + _logger.Warn(e, "IpcClientChannel error: "); + errMsg = e; + counter--; + Thread.Sleep(500); + } } - catch (Exception e) + + if (counter == 0) { - _logger.Warn(e, "IpcClientChannel error: "); - errMsg = e; - counter--; - Thread.Sleep(500); + _logger.Error(errMsg, "IpcClientChannel error, giving up: "); + MessageBox.Show($"Cannot open connection to first instance ({errMsg})", "LogExpert"); } - } - if (counter == 0) - { - _logger.Error(errMsg, "IpcClientChannel error, giving up: "); - MessageBox.Show($"Cannot open connection to first instance ({errMsg})", "LogExpert"); - } - - if (settings.Preferences.allowOnlyOneInstance && settings.Preferences.ShowErrorMessageAllowOnlyOneInstances) - { - AllowOnlyOneInstanceErrorDialog a = new(); - if (a.ShowDialog() == DialogResult.OK) + if (settings.Preferences.allowOnlyOneInstance && settings.Preferences.ShowErrorMessageAllowOnlyOneInstances) { - settings.Preferences.ShowErrorMessageAllowOnlyOneInstances = !a.DoNotShowThisMessageAgain; - ConfigManager.Instance.Save(SettingsFlags.All); + AllowOnlyOneInstanceErrorDialog a = new(); + if (a.ShowDialog() == DialogResult.OK) + { + settings.Preferences.ShowErrorMessageAllowOnlyOneInstances = !a.DoNotShowThisMessageAgain; + ConfigManager.Instance.Save(SettingsFlags.All); + } } } - } - mutex.Close(); - _cts.Cancel(); + mutex.Close(); + cts.Cancel(); + } + catch (Exception ex) + { + _logger.Error(ex, "Mutex error, giving up: "); + cts.Cancel(); + MessageBox.Show($"Cannot open connection to first instance ({ex.Message})", "LogExpert"); + } } - catch (Exception ex) + catch (SecurityException se) { - _logger.Error(ex, "Mutex error, giving up: "); - _cts.Cancel(); - MessageBox.Show($"Cannot open connection to first instance ({ex.Message})", "LogExpert"); + MessageBox.Show("Insufficient system rights for LogExpert. Maybe you have started it from a network drive. Please start LogExpert from a local drive.\n(" + se.Message + ")", "LogExpert Error"); + cts.Cancel(); } } diff --git a/src/Logexpert.Core/Classes/CmdLine.cs b/src/Logexpert.Core/Classes/CmdLine.cs deleted file mode 100644 index cea24b31..00000000 --- a/src/Logexpert.Core/Classes/CmdLine.cs +++ /dev/null @@ -1,412 +0,0 @@ -/* - * Taken from https://cmdline.codeplex.com/ - * - */ - -//TODO Replace with https://github.com/commandlineparser/commandline -namespace LogExpert.Core.Classes -{ - /// - /// Represents an error occuring during command line parsing. - /// - public class CmdLineException : Exception - { - #region cTor - - public CmdLineException(string parameter, string message) - : - base(string.Format("Syntax error of parameter -{0}: {1}", parameter, message)) - { - } - - public CmdLineException(string message) - : - base(message) - { - } - - #endregion - } - - /// - /// Represents a command line parameter. - /// Parameters are words in the command line beginning with a hyphen (-). - /// The value of the parameter is the next word in - /// - /// - /// Creates a new instance of this class. - /// - /// Name of parameter. - /// Require that the parameter is present in the command line. - /// The explanation of the parameter to add to the help screen. - public class CmdLineParameter(string name, bool required, string helpMessage) - { - #region Properties - - /// - /// Returns the value of the parameter. - /// - public string Value { get; private set; } = ""; - - /// - /// Returns the help message associated with the parameter. - /// - public string Help { get; } = helpMessage; - - /// - /// Returns true if the parameter was found in the command line. - /// - public bool Exists { get; private set; } = false; - - /// - /// Returns true if the parameter is required in the command line. - /// - public bool Required { get; } = required; - - /// - /// Returns the name of the parameter. - /// - public string Name { get; } = name; - - #endregion - - #region Public methods - - /// - /// Sets the value of the parameter. - /// - /// A string containing a integer expression. - public virtual void SetValue(string value) - { - Value = value; - Exists = true; - } - - #endregion - } - - /// - /// Represents an integer command line parameter. - /// - public class CmdLineInt : CmdLineParameter - { - #region Fields - - private readonly int _max = int.MaxValue; - private readonly int _min = int.MinValue; - - #endregion - - #region cTor - - /// - /// Creates a new instance of this class. - /// - /// Name of parameter. - /// Require that the parameter is present in the command line. - /// The explanation of the parameter to add to the help screen. - public CmdLineInt(string name, bool required, string helpMessage) - : base(name, required, helpMessage) - { - } - - /// - /// Creates a new instance of this class. - /// - /// Name of parameter. - /// Require that the parameter is present in the command line. - /// The explanation of the parameter to add to the help screen. - /// The minimum value of the parameter. - /// The maximum valie of the parameter. - public CmdLineInt(string name, bool required, string helpMessage, int min, int max) - : base(name, required, helpMessage) - { - _min = min; - _max = max; - } - - #endregion - - #region Properties - - /// - /// Returns the current value of the parameter. - /// - new public int Value { get; private set; } - - #endregion - - #region Public methods - - /// - /// Sets the value of the parameter. - /// - /// A string containing a integer expression. - public override void SetValue(string value) - { - base.SetValue(value); - int i = 0; - try - { - i = Convert.ToInt32(value); - } - catch (Exception) - { - throw new CmdLineException(Name, "Value is not an integer."); - } - if (i < _min) - { - throw new CmdLineException(Name, string.Format("Value must be greather or equal to {0}.", _min)); - } - if (i > _max) - { - throw new CmdLineException(Name, string.Format("Value must be less or equal to {0}.", _max)); - } - Value = i; - } - - /// - /// A implicit converion to a int data type. - /// - /// - /// - public static implicit operator int(CmdLineInt s) - { - return s.Value; - } - - #endregion - } - - /// - /// Represents an string command line parameter. - /// - public class CmdLineString(string name, bool required, string helpMessage) : CmdLineParameter(name, required, helpMessage) - { - - #region Public methods - - public static implicit operator string(CmdLineString s) - { - return s.Value; - } - - #endregion - } - - /// - /// Provides a simple strongly typed interface to work with command line parameters. - /// - public class CmdLine - { - #region Fields - - // A private dictonary containing the parameters. - private readonly Dictionary parameters = []; - - #endregion - - #region cTor - - /// - /// Creats a new empty command line object. - /// - public CmdLine() - { - } - - #endregion - - #region Properties - - /// - /// Returns a command line parameter by the name. - /// - /// The name of the parameter (the word after the initial hyphen (-). - /// A reference to the named comman line object. - public CmdLineParameter this[string name] - { - get - { - if (parameters.TryGetValue(name, out CmdLineParameter? value) == false) - { - throw new CmdLineException(name, "Not a registered parameter."); - } - return value; - } - } - - #endregion - - #region Public methods - - /// - /// Registers a parameter to be used and adds it to the help screen. - /// - /// The parameter to add. - public void RegisterParameter(CmdLineParameter parameter) - { - if (parameters.ContainsKey(parameter.Name)) - { - throw new CmdLineException(parameter.Name, "Parameter is already registered."); - } - parameters.Add(parameter.Name, parameter); - } - - /// - /// Registers parameters to be used and adds hem to the help screen. - /// - /// The parameter to add. - public void RegisterParameter(CmdLineParameter[] parameters) - { - foreach (CmdLineParameter p in parameters) - { - RegisterParameter(p); - } - } - - - /// - /// Parses the command line and sets the value of each registered parmaters. - /// - /// The arguments array sent to main() - /// Any reminding strings after arguments has been processed. - public string[] Parse(string[] args) - { - int i = 0; - - List new_args = []; - - while (i < args.Length) - { - if (args[i].Length > 1 && args[i][0] == '-') - { - // The current string is a parameter name - string key = args[i][1..].ToLower(); - string argsValue = string.Empty; - i++; - if (i < args.Length) - { - if (args[i].Length > 0 && args[i][0] == '-') - { - // The next string is a new parameter, do not nothing - } - else - { - // The next string is a value, read the value and move forward - argsValue = args[i]; - i++; - } - } - if (parameters.TryGetValue(key, out CmdLineParameter? cmdLineParameter) == false) - { - throw new CmdLineException(key, "Parameter is not allowed."); - } - - if (cmdLineParameter.Exists) - { - throw new CmdLineException(key, "Parameter is specified more than once."); - } - - cmdLineParameter.SetValue(argsValue); - } - else - { - new_args.Add(args[i]); - i++; - } - } - - - // Check that required parameters are present in the command line. - foreach (string key in parameters.Keys) - { - if (parameters[key].Required && parameters[key].Exists == false) - { - throw new CmdLineException(key, "Required parameter is not found."); - } - } - - return new_args.ToArray(); - } - - /// - /// Generates the help screen. - /// - public string HelpScreen() - { - int len = 0; - foreach (string key in parameters.Keys) - { - len = Math.Max(len, key.Length); - } - - string help = "\nParameters:\n\n"; - foreach (string key in parameters.Keys) - { - string s = "-" + parameters[key].Name; - while (s.Length < len + 3) - { - s += " "; - } - s += parameters[key].Help + "\n"; - help += s; - } - return help; - } - - #endregion - } - - /// - /// Represents a CmdLine object to use with console applications. - /// The -help parameter will be registered automatically. - /// Any errors will be written to the console instead of generating exceptions. - /// - public class ConsoleCmdLine : CmdLine - { - #region cTor - - public ConsoleCmdLine() - { - RegisterParameter(new CmdLineString("help", false, "Prints the help screen.")); - } - - #endregion - - #region Public methods - - public new string[] Parse(string[] args) - { - string[] ret = []; - - string error = string.Empty; - - try - { - ret = base.Parse(args); - } - catch (CmdLineException ex) - { - error = ex.Message; - } - - if (this["help"].Exists) - { - Console.WriteLine(HelpScreen()); - Environment.Exit(0); - } - - if (error != string.Empty) - { - Console.WriteLine(error); - Console.WriteLine("Use -help for more information."); - Environment.Exit(1); - } - - return ret; - } - - #endregion - } -} \ No newline at end of file From 45d1c62b888f54771ae203c918c627f133b55dc8 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Tue, 27 May 2025 00:10:19 +0300 Subject: [PATCH 031/142] Fix casing of names for case sensetive FS.\nAdded a few TODOs. --- .../Callback/ColumnizerCallback.cs | 0 .../Classes/Bookmark/BookmarkDataProvider.cs | 0 .../Classes/Bookmark/BookmarkExporter.cs | 0 .../Classes/Bookmark/BookmarkView.cs | 0 .../Classes/Columnizer/ClfColumnizer.cs | 0 .../Classes/Columnizer/ColumnizerPicker.cs | 0 .../Classes/Columnizer/SquareBracketColumnizer.cs | 0 .../Classes/Columnizer/TimeFormatDeterminer.cs | 0 .../Classes/Columnizer/TimestampColumnizer.cs | 0 .../DateTimeParser/DateFormatPartAdjuster.cs | 0 .../Classes/DateTimeParser/Parser.cs | 0 .../Classes/DateTimeParser/Section.cs | 0 .../Classes/DateTimeParser/Token.cs | 0 .../Classes/DateTimeParser/Tokenizer.cs | 0 .../Classes/FileSystemCallback.cs | 0 .../Classes/Filter/Filter.cs | 0 .../Classes/Filter/FilterCancelHandler.cs | 0 .../Classes/Filter/FilterParams.cs | 0 .../Classes/Filter/FilterPipe.cs | 0 .../Classes/Filter/FilterStarter.cs | 0 .../Classes/Highlight/ActionEntry.cs | 0 .../Classes/Highlight/HighlightEntry.cs | 0 .../Classes/Highlight/HilightMatchEntry.cs | 0 .../Classes/IPC/IpcMessage.cs | 0 .../Classes/IPC/IpcMessageType.cs | 0 .../Classes/IPC/LoadPayload.cs | 0 .../Classes/Log/LogBuffer.cs | 0 .../Classes/Log/LogBufferCacheEntry.cs | 0 .../Classes/Log/LogStreamReaderBase.cs | 0 .../Classes/Log/LogfileReader.cs | 0 .../Classes/Log/PositionAwareStreamReaderBase.cs | 0 .../Classes/Log/PositionAwareStreamReaderLegacy.cs | 0 .../Classes/Log/PositionAwareStreamReaderSystem.cs | 0 .../Classes/Log/RolloverFilenameBuilder.cs | 0 .../Classes/Log/RolloverFilenameHandler.cs | 0 .../Classes/ObjectClone.cs | 0 .../Classes/ParamParser.cs | 0 .../Classes/PatternBlock.cs | 0 .../Classes/Persister/FilterTabData.cs | 0 .../Classes/Persister/Persister.cs | 0 .../Classes/Persister/ProjectData.cs | 0 .../Classes/Persister/ProjectPersister.cs | 0 .../Classes/SpreadEntry.cs | 0 .../Classes/SysoutPipe.cs | 0 .../Classes/UsedComponents.cs | 0 .../Classes/Util.cs | 0 .../Classes/Win32.cs | 0 .../Classes/xml/XmlBlockSplitter.cs | 0 .../Classes/xml/XmlLogReader.cs | 0 .../Config/ColorEntry.cs | 0 .../Config/ColorMode.cs | 0 .../Config/ColumnizerHistoryEntry.cs | 0 .../Config/ColumnizerMaskEntry.cs | 0 .../Config/ExportImportFlags.cs | 0 .../Config/HighlightMaskEntry.cs | 0 .../Config/MultiFileOption.cs | 0 .../Config/Preferences.cs | 0 .../Config/RegexHistory.cs | 0 .../Config/SessionSaveLocation.cs | 0 .../Config/Settings.cs | 0 .../Config/SettingsFlags.cs | 0 .../Config/ToolEntry.cs | 0 .../Entities/Bookmark.cs | 0 .../Entities/BookmarkCollection.cs | 0 .../Entities/BookmarkOverlay.cs | 0 .../Entities/DebugOptions.cs | 0 .../Entities/DefaultLogfileColumnizer.cs | 0 .../Entities/EncodingOptions.cs | 0 .../Entities/FileViewContext.cs | 0 .../Entities/HighlightGroup.cs | 0 .../Entities/LogEventData.cs | 0 .../Entities/LogFileException.cs | 0 .../Entities/MultifileOptions.cs | 0 .../Entities/Range.cs | 0 .../Entities/ReloadMemento.cs | 0 .../Entities/RowHeightEntry.cs | 0 .../Entities/SearchParams.cs | 0 .../Enums/DragOrientationsEnum.cs | 0 .../Enums/ProjectLoadDlgResult.cs | 0 .../Enums/WindowTypes.cs | 0 .../EventArguments/BookmarkEventArgs.cs | 0 .../EventArguments/ColumnizerEventArgs.cs | 0 .../EventArguments/ConfigChangedEventArgs.cs | 0 .../EventArguments/ContextMenuPluginEventArgs.cs | 0 .../CurrentHighlightGroupChangedEventArgs.cs | 0 .../EventArguments/FilterListChangedEventArgs.cs | 0 .../EventArguments/GuiStateArgs.cs | 0 .../EventArguments/LoadFileEventArgs.cs | 0 .../EventArguments/OverlayEventArgs.cs | 0 .../EventArguments/PatternArgs.cs | 0 .../EventArguments/ProgressEventArgs.cs | 0 .../EventArguments/SelectLineEventArgs.cs | 0 .../EventArguments/StatusEventArgs.cs | 0 .../EventArguments/SyncModeEventArgs.cs | 0 .../EventHandlers/EventHandlers.cs | 0 .../Extensions/IEnumerable.cs | 0 .../Interface/IBackgroundProcessCancelHandler.cs | 0 .../Interface/IBookmarkData.cs | 0 .../Interface/IBookmarkView.cs | 0 .../Interface/IConfigManager.cs | 1 + .../Interface/ILogExpertProxy.cs | 0 .../Interface/ILogPaintContext.cs | 0 .../Interface/ILogStreamReader.cs | 0 .../Interface/ILogTabWindow.cs | 1 + .../Interface/ILogView.cs | 0 .../Interface/ILogWindow.cs | 1 + .../Interface/IPluginRegistry.cs | 1 + .../Interface/ISharedToolWindow.cs | 0 .../LogExpert.Core.csproj} | 0 .../Structs/ActEntry.cs | 0 .../LogExpert.Resources.csproj} | 0 .../Resources.Designer.cs | 0 .../Resources.resx | 0 .../images/bmp/LogExpert.bmp | Bin .../images/bmp/Pro_Filter.bmp | Bin .../images/gif/LogExpert-Icon.gif | Bin .../images/gif/LogLover.gif | Bin .../images/icons/Icon1.ico | Bin .../images/icons/Icon2.ico | Bin .../images/icons/bubble.ico | Bin .../images/icons/logexpert.ico | Bin .../images/png/48/Add.png | Bin .../images/png/48/ArrowDown.png | Bin .../images/png/48/ArrowLeft.png | Bin .../images/png/48/ArrowRight.png | Bin .../images/png/48/ArrowUp.png | Bin .../images/png/48/Arrow_menu_close.png | Bin .../images/png/48/Arrow_menu_open.png | Bin .../images/png/48/Bookmark_add.png | Bin .../images/png/48/Bookmark_added.png | Bin .../images/png/48/Bookmark_manager.png | Bin .../images/png/48/Bookmark_remove.png | Bin .../images/png/48/Bookmarks.png | Bin .../images/png/48/Check_circle.png | Bin .../images/png/48/Close.png | Bin .../images/png/48/Deceased.png | Bin .../images/png/48/Delete.png | Bin .../images/png/48/Exit.png | Bin .../images/png/48/Favorite.png | Bin .../images/png/48/File_open.png | Bin .../images/png/48/Filter.png | Bin .../images/png/48/Folder_open.png | Bin .../images/png/48/Restart_alt.png | Bin .../images/png/48/Search.png | Bin .../images/png/48/Settings.png | Bin .../images/png/48/Star.png | Bin .../images/png/48/bookmark_bubbles.png | Bin .../Controls/BufferedDataGridView.Designer.cs | 0 .../Controls/BufferedDataGridView.cs | 0 .../Controls/ColorComboBox.cs | 0 .../Controls/DateTimeDragControl.Designer.cs | 0 .../Controls/DateTimeDragControl.cs | 0 .../Controls/DateTimeDragControl.resx | 0 .../Controls/KnobControl.Designer.cs | 0 .../Controls/KnobControl.cs | 0 .../Controls/KnobControl.resx | 0 .../Controls/LogCellEditingControl.cs | 0 .../Controls/LogGridCell.cs | 0 .../Controls/LogTabControl.cs | 0 .../Controls/LogTextColumn.cs | 0 .../Controls/LogWindow/ColumnCache.cs | 0 .../Controls/LogWindow/LogExpertCallback.cs | 0 .../Controls/LogWindow/LogWindow.cs | 0 .../Controls/LogWindow/LogWindow.designer.cs | 0 .../Controls/LogWindow/LogWindow.resx | 0 .../Controls/LogWindow/LogWindowEventHandlers.cs | 0 .../Controls/LogWindow/LogWindowEventHandlers.resx} | 0 .../Controls/LogWindow/LogWindowPrivate.cs | 0 .../Controls/LogWindow/LogWindowPublic.cs | 0 .../Controls/LogWindow/PatternWindow.Designer.cs | 0 .../Controls/LogWindow/PatternWindow.cs | 0 .../Controls/LogWindow/PatternWindow.resx | 0 .../Controls/LogWindow/RangeFinder.cs | 0 .../Controls/LogWindow/TimeSpreadCalculator.cs | 0 .../LogWindow/TimeSpreadigControl.Designer.cs | 0 .../Controls/LogWindow/TimeSpreadigControl.cs | 0 .../Controls/LogWindow/TimeSpreadigControl.resx | 0 .../Controls/LogWindow/TimeSyncList.cs | 0 .../Dialogs/AboutBox.Designer.cs | 0 .../Dialogs/AboutBox.cs | 0 .../Dialogs/AboutBox.resx | 0 .../AllowOnlyOneInstanceErrorDialog.Designer.cs | 0 .../Dialogs/AllowOnlyOneInstanceErrorDialog.cs | 0 .../Dialogs/BookmarkCommentDlg.Designer.cs | 0 .../Dialogs/BookmarkCommentDlg.cs | 0 .../Dialogs/BookmarkCommentDlg.resx | 0 .../Dialogs/BookmarkWindow.Designer.cs | 0 .../Dialogs/BookmarkWindow.cs | 0 .../Dialogs/BookmarkWindow.resx | 0 .../Dialogs/ChooseIconDlg.Designer.cs | 0 .../Dialogs/ChooseIconDlg.cs | 0 .../Dialogs/ChooseIconDlg.resx | 0 .../Dialogs/ExceptionWindow.Designer.cs | 0 .../Dialogs/ExceptionWindow.cs | 0 .../Dialogs/ExceptionWindow.resx | 0 .../Dialogs/FilterColumnChooser.Designer.cs | 0 .../Dialogs/FilterColumnChooser.cs | 0 .../Dialogs/FilterColumnChooser.resx | 0 .../Dialogs/GotoLineDialog.Designer.cs | 0 .../Dialogs/GotoLineDialog.cs | 0 .../Dialogs/GotoLineDialog.resx | 0 .../Dialogs/ImportSettingsDialog.Designer.cs | 0 .../Dialogs/ImportSettingsDialog.cs | 0 .../Dialogs/ImportSettingsDialog.resx | 0 .../Dialogs/KeywordActionDlg.Designer.cs | 0 .../Dialogs/KeywordActionDlg.cs | 0 .../Dialogs/KeywordActionDlg.resx | 0 .../LogTabWindow/FilterSelectorForm.Designer.cs | 0 .../Dialogs/LogTabWindow/FilterSelectorForm.cs | 0 .../Dialogs/LogTabWindow/FilterSelectorForm.resx | 0 .../LogTabWindow/HighlightDialog.Designer.cs | 0 .../Dialogs/LogTabWindow/HighlightDialog.cs | 0 .../Dialogs/LogTabWindow/HighlightDialog.resx | 0 .../Dialogs/LogTabWindow/LogTabWindow.cs | 0 .../Dialogs/LogTabWindow/LogTabWindow.designer.cs | 0 .../Dialogs/LogTabWindow/LogTabWindow.resx | 0 .../LogTabWindow/LogTabWindowEventHandlers.cs | 0 .../Dialogs/LogTabWindow/LogTabWindowPrivate.cs | 0 .../Dialogs/LogTabWindow/LogTabWindowPublic.cs | 0 .../Dialogs/LogTabWindow/SettingsDialog.Designer.cs | 0 .../Dialogs/LogTabWindow/SettingsDialog.cs | 0 .../Dialogs/LogTabWindow/SettingsDialog.resx | 0 .../Dialogs/MultiFileMaskDialog.Designer.cs | 0 .../Dialogs/MultiFileMaskDialog.cs | 0 .../Dialogs/MultiFileMaskDialog.resx | 0 .../Dialogs/MultiLoadRequestDialog.Designer.cs | 0 .../Dialogs/MultiLoadRequestDialog.cs | 0 .../Dialogs/MultiLoadRequestDialog.resx | 0 .../Dialogs/OpenUriDialog.Designer.cs | 0 .../Dialogs/OpenUriDialog.cs | 0 .../Dialogs/OpenUriDialog.resx | 0 .../Dialogs/ParamRequesterDialog.Designer.cs | 0 .../Dialogs/ParamRequesterDialog.cs | 0 .../Dialogs/ParamRequesterDialog.resx | 0 .../Dialogs/ProjectLoadDlg.Designer.cs | 0 .../Dialogs/ProjectLoadDlg.cs | 0 .../Dialogs/ProjectLoadDlg.resx | 0 .../Dialogs/RegexHelperDialog.Designer.cs | 0 .../Dialogs/RegexHelperDialog.cs | 0 .../Dialogs/RegexHelperDialog.resx | 0 .../Dialogs/SearchDialog.Designer.cs | 0 .../Dialogs/SearchDialog.cs | 0 .../Dialogs/SearchDialog.resx | 0 .../Dialogs/SearchProgressDialog.Designer.cs | 0 .../Dialogs/SearchProgressDialog.cs | 0 .../Dialogs/SearchProgressDialog.resx | 0 .../Dialogs/TabRenameDialog.Designer.cs | 0 .../Dialogs/TabRenameDialog.cs | 0 .../Dialogs/TabRenameDialog.resx | 0 .../Dialogs/ToolArgsDialog.Designer.cs | 0 .../Dialogs/ToolArgsDialog.cs | 0 .../Dialogs/ToolArgsDialog.resx | 0 .../Entities/ArgParser.cs | 0 .../Entities/PaintHelper.cs | 0 .../Entities/WindowFileEntry.cs | 0 .../Extensions/ComboBoxExtensions.cs | 0 .../Forms/LineToolStripSeparatorExtension.cs | 0 .../Extensions/Forms/MenuSelectedColors.cs | 0 .../Extensions/Forms/MenuStripExtension.cs | 0 .../Forms/MenuToolStripSeparatorExtension.cs | 0 .../Extensions/Forms/ToolStripRendererExtension.cs | 0 .../LogExpert.UI.csproj | 0 src/LogExpert.sln | 6 +++--- src/LogExpert/Program.cs | 2 +- 264 files changed, 8 insertions(+), 4 deletions(-) rename src/{Logexpert.Core => LogExpert.Core}/Callback/ColumnizerCallback.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Bookmark/BookmarkDataProvider.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Bookmark/BookmarkExporter.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Bookmark/BookmarkView.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Columnizer/ClfColumnizer.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Columnizer/ColumnizerPicker.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Columnizer/SquareBracketColumnizer.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Columnizer/TimeFormatDeterminer.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Columnizer/TimestampColumnizer.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/DateTimeParser/DateFormatPartAdjuster.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/DateTimeParser/Parser.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/DateTimeParser/Section.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/DateTimeParser/Token.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/DateTimeParser/Tokenizer.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/FileSystemCallback.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Filter/Filter.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Filter/FilterCancelHandler.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Filter/FilterParams.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Filter/FilterPipe.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Filter/FilterStarter.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Highlight/ActionEntry.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Highlight/HighlightEntry.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Highlight/HilightMatchEntry.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/IPC/IpcMessage.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/IPC/IpcMessageType.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/IPC/LoadPayload.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Log/LogBuffer.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Log/LogBufferCacheEntry.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Log/LogStreamReaderBase.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Log/LogfileReader.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Log/PositionAwareStreamReaderBase.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Log/PositionAwareStreamReaderLegacy.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Log/PositionAwareStreamReaderSystem.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Log/RolloverFilenameBuilder.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Log/RolloverFilenameHandler.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/ObjectClone.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/ParamParser.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/PatternBlock.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Persister/FilterTabData.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Persister/Persister.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Persister/ProjectData.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Persister/ProjectPersister.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/SpreadEntry.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/SysoutPipe.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/UsedComponents.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Util.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Win32.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/xml/XmlBlockSplitter.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Classes/xml/XmlLogReader.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Config/ColorEntry.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Config/ColorMode.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Config/ColumnizerHistoryEntry.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Config/ColumnizerMaskEntry.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Config/ExportImportFlags.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Config/HighlightMaskEntry.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Config/MultiFileOption.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Config/Preferences.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Config/RegexHistory.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Config/SessionSaveLocation.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Config/Settings.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Config/SettingsFlags.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Config/ToolEntry.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Entities/Bookmark.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Entities/BookmarkCollection.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Entities/BookmarkOverlay.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Entities/DebugOptions.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Entities/DefaultLogfileColumnizer.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Entities/EncodingOptions.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Entities/FileViewContext.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Entities/HighlightGroup.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Entities/LogEventData.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Entities/LogFileException.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Entities/MultifileOptions.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Entities/Range.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Entities/ReloadMemento.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Entities/RowHeightEntry.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Entities/SearchParams.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Enums/DragOrientationsEnum.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Enums/ProjectLoadDlgResult.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Enums/WindowTypes.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/EventArguments/BookmarkEventArgs.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/EventArguments/ColumnizerEventArgs.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/EventArguments/ConfigChangedEventArgs.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/EventArguments/ContextMenuPluginEventArgs.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/EventArguments/CurrentHighlightGroupChangedEventArgs.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/EventArguments/FilterListChangedEventArgs.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/EventArguments/GuiStateArgs.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/EventArguments/LoadFileEventArgs.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/EventArguments/OverlayEventArgs.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/EventArguments/PatternArgs.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/EventArguments/ProgressEventArgs.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/EventArguments/SelectLineEventArgs.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/EventArguments/StatusEventArgs.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/EventArguments/SyncModeEventArgs.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/EventHandlers/EventHandlers.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Extensions/IEnumerable.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Interface/IBackgroundProcessCancelHandler.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Interface/IBookmarkData.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Interface/IBookmarkView.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Interface/IConfigManager.cs (96%) rename src/{Logexpert.Core => LogExpert.Core}/Interface/ILogExpertProxy.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Interface/ILogPaintContext.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Interface/ILogStreamReader.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Interface/ILogTabWindow.cs (92%) rename src/{Logexpert.Core => LogExpert.Core}/Interface/ILogView.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Interface/ILogWindow.cs (97%) rename src/{Logexpert.Core => LogExpert.Core}/Interface/IPluginRegistry.cs (88%) rename src/{Logexpert.Core => LogExpert.Core}/Interface/ISharedToolWindow.cs (100%) rename src/{Logexpert.Core/Logexpert.Core.csproj => LogExpert.Core/LogExpert.Core.csproj} (100%) rename src/{Logexpert.Core => LogExpert.Core}/Structs/ActEntry.cs (100%) rename src/{Logexpert.Resources/Logexpert.Resources.csproj => LogExpert.Resources/LogExpert.Resources.csproj} (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/Resources.Designer.cs (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/Resources.resx (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/bmp/LogExpert.bmp (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/bmp/Pro_Filter.bmp (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/gif/LogExpert-Icon.gif (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/gif/LogLover.gif (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/icons/Icon1.ico (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/icons/Icon2.ico (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/icons/bubble.ico (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/icons/logexpert.ico (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Add.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/ArrowDown.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/ArrowLeft.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/ArrowRight.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/ArrowUp.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Arrow_menu_close.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Arrow_menu_open.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Bookmark_add.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Bookmark_added.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Bookmark_manager.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Bookmark_remove.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Bookmarks.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Check_circle.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Close.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Deceased.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Delete.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Exit.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Favorite.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/File_open.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Filter.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Folder_open.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Restart_alt.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Search.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Settings.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/Star.png (100%) rename src/{Logexpert.Resources => LogExpert.Resources}/images/png/48/bookmark_bubbles.png (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/BufferedDataGridView.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/BufferedDataGridView.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/ColorComboBox.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/DateTimeDragControl.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/DateTimeDragControl.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/DateTimeDragControl.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/KnobControl.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/KnobControl.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/KnobControl.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogCellEditingControl.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogGridCell.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogTabControl.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogTextColumn.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogWindow/ColumnCache.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogWindow/LogExpertCallback.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogWindow/LogWindow.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogWindow/LogWindow.designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogWindow/LogWindow.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogWindow/LogWindowEventHandlers.cs (100%) rename src/{Logexpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.resx => LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.resx} (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogWindow/LogWindowPrivate.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogWindow/LogWindowPublic.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogWindow/PatternWindow.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogWindow/PatternWindow.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogWindow/PatternWindow.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogWindow/RangeFinder.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogWindow/TimeSpreadCalculator.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogWindow/TimeSpreadigControl.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogWindow/TimeSpreadigControl.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogWindow/TimeSpreadigControl.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Controls/LogWindow/TimeSyncList.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/AboutBox.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/AboutBox.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/AboutBox.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/AllowOnlyOneInstanceErrorDialog.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/AllowOnlyOneInstanceErrorDialog.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/BookmarkCommentDlg.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/BookmarkCommentDlg.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/BookmarkCommentDlg.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/BookmarkWindow.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/BookmarkWindow.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/BookmarkWindow.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ChooseIconDlg.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ChooseIconDlg.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ChooseIconDlg.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ExceptionWindow.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ExceptionWindow.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ExceptionWindow.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/FilterColumnChooser.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/FilterColumnChooser.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/FilterColumnChooser.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/GotoLineDialog.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/GotoLineDialog.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/GotoLineDialog.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ImportSettingsDialog.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ImportSettingsDialog.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ImportSettingsDialog.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/KeywordActionDlg.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/KeywordActionDlg.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/KeywordActionDlg.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/LogTabWindow/FilterSelectorForm.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/LogTabWindow/FilterSelectorForm.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/LogTabWindow/FilterSelectorForm.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/LogTabWindow/HighlightDialog.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/LogTabWindow/HighlightDialog.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/LogTabWindow/HighlightDialog.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/LogTabWindow/LogTabWindow.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/LogTabWindow/LogTabWindow.designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/LogTabWindow/LogTabWindow.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/LogTabWindow/LogTabWindowPrivate.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/LogTabWindow/LogTabWindowPublic.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/LogTabWindow/SettingsDialog.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/LogTabWindow/SettingsDialog.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/LogTabWindow/SettingsDialog.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/MultiFileMaskDialog.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/MultiFileMaskDialog.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/MultiFileMaskDialog.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/MultiLoadRequestDialog.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/MultiLoadRequestDialog.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/MultiLoadRequestDialog.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/OpenUriDialog.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/OpenUriDialog.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/OpenUriDialog.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ParamRequesterDialog.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ParamRequesterDialog.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ParamRequesterDialog.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ProjectLoadDlg.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ProjectLoadDlg.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ProjectLoadDlg.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/RegexHelperDialog.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/RegexHelperDialog.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/RegexHelperDialog.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/SearchDialog.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/SearchDialog.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/SearchDialog.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/SearchProgressDialog.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/SearchProgressDialog.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/SearchProgressDialog.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/TabRenameDialog.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/TabRenameDialog.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/TabRenameDialog.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ToolArgsDialog.Designer.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ToolArgsDialog.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Dialogs/ToolArgsDialog.resx (100%) rename src/{Logexpert.UI => LogExpert.UI}/Entities/ArgParser.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Entities/PaintHelper.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Entities/WindowFileEntry.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Extensions/ComboBoxExtensions.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Extensions/Forms/LineToolStripSeparatorExtension.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Extensions/Forms/MenuSelectedColors.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Extensions/Forms/MenuStripExtension.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Extensions/Forms/MenuToolStripSeparatorExtension.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/Extensions/Forms/ToolStripRendererExtension.cs (100%) rename src/{Logexpert.UI => LogExpert.UI}/LogExpert.UI.csproj (100%) diff --git a/src/Logexpert.Core/Callback/ColumnizerCallback.cs b/src/LogExpert.Core/Callback/ColumnizerCallback.cs similarity index 100% rename from src/Logexpert.Core/Callback/ColumnizerCallback.cs rename to src/LogExpert.Core/Callback/ColumnizerCallback.cs diff --git a/src/Logexpert.Core/Classes/Bookmark/BookmarkDataProvider.cs b/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs similarity index 100% rename from src/Logexpert.Core/Classes/Bookmark/BookmarkDataProvider.cs rename to src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs diff --git a/src/Logexpert.Core/Classes/Bookmark/BookmarkExporter.cs b/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs similarity index 100% rename from src/Logexpert.Core/Classes/Bookmark/BookmarkExporter.cs rename to src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs diff --git a/src/Logexpert.Core/Classes/Bookmark/BookmarkView.cs b/src/LogExpert.Core/Classes/Bookmark/BookmarkView.cs similarity index 100% rename from src/Logexpert.Core/Classes/Bookmark/BookmarkView.cs rename to src/LogExpert.Core/Classes/Bookmark/BookmarkView.cs diff --git a/src/Logexpert.Core/Classes/Columnizer/ClfColumnizer.cs b/src/LogExpert.Core/Classes/Columnizer/ClfColumnizer.cs similarity index 100% rename from src/Logexpert.Core/Classes/Columnizer/ClfColumnizer.cs rename to src/LogExpert.Core/Classes/Columnizer/ClfColumnizer.cs diff --git a/src/Logexpert.Core/Classes/Columnizer/ColumnizerPicker.cs b/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs similarity index 100% rename from src/Logexpert.Core/Classes/Columnizer/ColumnizerPicker.cs rename to src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs diff --git a/src/Logexpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs b/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs similarity index 100% rename from src/Logexpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs rename to src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs diff --git a/src/Logexpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs b/src/LogExpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs similarity index 100% rename from src/Logexpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs rename to src/LogExpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs diff --git a/src/Logexpert.Core/Classes/Columnizer/TimestampColumnizer.cs b/src/LogExpert.Core/Classes/Columnizer/TimestampColumnizer.cs similarity index 100% rename from src/Logexpert.Core/Classes/Columnizer/TimestampColumnizer.cs rename to src/LogExpert.Core/Classes/Columnizer/TimestampColumnizer.cs diff --git a/src/Logexpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs b/src/LogExpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs similarity index 100% rename from src/Logexpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs rename to src/LogExpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs diff --git a/src/Logexpert.Core/Classes/DateTimeParser/Parser.cs b/src/LogExpert.Core/Classes/DateTimeParser/Parser.cs similarity index 100% rename from src/Logexpert.Core/Classes/DateTimeParser/Parser.cs rename to src/LogExpert.Core/Classes/DateTimeParser/Parser.cs diff --git a/src/Logexpert.Core/Classes/DateTimeParser/Section.cs b/src/LogExpert.Core/Classes/DateTimeParser/Section.cs similarity index 100% rename from src/Logexpert.Core/Classes/DateTimeParser/Section.cs rename to src/LogExpert.Core/Classes/DateTimeParser/Section.cs diff --git a/src/Logexpert.Core/Classes/DateTimeParser/Token.cs b/src/LogExpert.Core/Classes/DateTimeParser/Token.cs similarity index 100% rename from src/Logexpert.Core/Classes/DateTimeParser/Token.cs rename to src/LogExpert.Core/Classes/DateTimeParser/Token.cs diff --git a/src/Logexpert.Core/Classes/DateTimeParser/Tokenizer.cs b/src/LogExpert.Core/Classes/DateTimeParser/Tokenizer.cs similarity index 100% rename from src/Logexpert.Core/Classes/DateTimeParser/Tokenizer.cs rename to src/LogExpert.Core/Classes/DateTimeParser/Tokenizer.cs diff --git a/src/Logexpert.Core/Classes/FileSystemCallback.cs b/src/LogExpert.Core/Classes/FileSystemCallback.cs similarity index 100% rename from src/Logexpert.Core/Classes/FileSystemCallback.cs rename to src/LogExpert.Core/Classes/FileSystemCallback.cs diff --git a/src/Logexpert.Core/Classes/Filter/Filter.cs b/src/LogExpert.Core/Classes/Filter/Filter.cs similarity index 100% rename from src/Logexpert.Core/Classes/Filter/Filter.cs rename to src/LogExpert.Core/Classes/Filter/Filter.cs diff --git a/src/Logexpert.Core/Classes/Filter/FilterCancelHandler.cs b/src/LogExpert.Core/Classes/Filter/FilterCancelHandler.cs similarity index 100% rename from src/Logexpert.Core/Classes/Filter/FilterCancelHandler.cs rename to src/LogExpert.Core/Classes/Filter/FilterCancelHandler.cs diff --git a/src/Logexpert.Core/Classes/Filter/FilterParams.cs b/src/LogExpert.Core/Classes/Filter/FilterParams.cs similarity index 100% rename from src/Logexpert.Core/Classes/Filter/FilterParams.cs rename to src/LogExpert.Core/Classes/Filter/FilterParams.cs diff --git a/src/Logexpert.Core/Classes/Filter/FilterPipe.cs b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs similarity index 100% rename from src/Logexpert.Core/Classes/Filter/FilterPipe.cs rename to src/LogExpert.Core/Classes/Filter/FilterPipe.cs diff --git a/src/Logexpert.Core/Classes/Filter/FilterStarter.cs b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs similarity index 100% rename from src/Logexpert.Core/Classes/Filter/FilterStarter.cs rename to src/LogExpert.Core/Classes/Filter/FilterStarter.cs diff --git a/src/Logexpert.Core/Classes/Highlight/ActionEntry.cs b/src/LogExpert.Core/Classes/Highlight/ActionEntry.cs similarity index 100% rename from src/Logexpert.Core/Classes/Highlight/ActionEntry.cs rename to src/LogExpert.Core/Classes/Highlight/ActionEntry.cs diff --git a/src/Logexpert.Core/Classes/Highlight/HighlightEntry.cs b/src/LogExpert.Core/Classes/Highlight/HighlightEntry.cs similarity index 100% rename from src/Logexpert.Core/Classes/Highlight/HighlightEntry.cs rename to src/LogExpert.Core/Classes/Highlight/HighlightEntry.cs diff --git a/src/Logexpert.Core/Classes/Highlight/HilightMatchEntry.cs b/src/LogExpert.Core/Classes/Highlight/HilightMatchEntry.cs similarity index 100% rename from src/Logexpert.Core/Classes/Highlight/HilightMatchEntry.cs rename to src/LogExpert.Core/Classes/Highlight/HilightMatchEntry.cs diff --git a/src/Logexpert.Core/Classes/IPC/IpcMessage.cs b/src/LogExpert.Core/Classes/IPC/IpcMessage.cs similarity index 100% rename from src/Logexpert.Core/Classes/IPC/IpcMessage.cs rename to src/LogExpert.Core/Classes/IPC/IpcMessage.cs diff --git a/src/Logexpert.Core/Classes/IPC/IpcMessageType.cs b/src/LogExpert.Core/Classes/IPC/IpcMessageType.cs similarity index 100% rename from src/Logexpert.Core/Classes/IPC/IpcMessageType.cs rename to src/LogExpert.Core/Classes/IPC/IpcMessageType.cs diff --git a/src/Logexpert.Core/Classes/IPC/LoadPayload.cs b/src/LogExpert.Core/Classes/IPC/LoadPayload.cs similarity index 100% rename from src/Logexpert.Core/Classes/IPC/LoadPayload.cs rename to src/LogExpert.Core/Classes/IPC/LoadPayload.cs diff --git a/src/Logexpert.Core/Classes/Log/LogBuffer.cs b/src/LogExpert.Core/Classes/Log/LogBuffer.cs similarity index 100% rename from src/Logexpert.Core/Classes/Log/LogBuffer.cs rename to src/LogExpert.Core/Classes/Log/LogBuffer.cs diff --git a/src/Logexpert.Core/Classes/Log/LogBufferCacheEntry.cs b/src/LogExpert.Core/Classes/Log/LogBufferCacheEntry.cs similarity index 100% rename from src/Logexpert.Core/Classes/Log/LogBufferCacheEntry.cs rename to src/LogExpert.Core/Classes/Log/LogBufferCacheEntry.cs diff --git a/src/Logexpert.Core/Classes/Log/LogStreamReaderBase.cs b/src/LogExpert.Core/Classes/Log/LogStreamReaderBase.cs similarity index 100% rename from src/Logexpert.Core/Classes/Log/LogStreamReaderBase.cs rename to src/LogExpert.Core/Classes/Log/LogStreamReaderBase.cs diff --git a/src/Logexpert.Core/Classes/Log/LogfileReader.cs b/src/LogExpert.Core/Classes/Log/LogfileReader.cs similarity index 100% rename from src/Logexpert.Core/Classes/Log/LogfileReader.cs rename to src/LogExpert.Core/Classes/Log/LogfileReader.cs diff --git a/src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs similarity index 100% rename from src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs rename to src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs diff --git a/src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs similarity index 100% rename from src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs rename to src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs diff --git a/src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs similarity index 100% rename from src/Logexpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs rename to src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs diff --git a/src/Logexpert.Core/Classes/Log/RolloverFilenameBuilder.cs b/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs similarity index 100% rename from src/Logexpert.Core/Classes/Log/RolloverFilenameBuilder.cs rename to src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs diff --git a/src/Logexpert.Core/Classes/Log/RolloverFilenameHandler.cs b/src/LogExpert.Core/Classes/Log/RolloverFilenameHandler.cs similarity index 100% rename from src/Logexpert.Core/Classes/Log/RolloverFilenameHandler.cs rename to src/LogExpert.Core/Classes/Log/RolloverFilenameHandler.cs diff --git a/src/Logexpert.Core/Classes/ObjectClone.cs b/src/LogExpert.Core/Classes/ObjectClone.cs similarity index 100% rename from src/Logexpert.Core/Classes/ObjectClone.cs rename to src/LogExpert.Core/Classes/ObjectClone.cs diff --git a/src/Logexpert.Core/Classes/ParamParser.cs b/src/LogExpert.Core/Classes/ParamParser.cs similarity index 100% rename from src/Logexpert.Core/Classes/ParamParser.cs rename to src/LogExpert.Core/Classes/ParamParser.cs diff --git a/src/Logexpert.Core/Classes/PatternBlock.cs b/src/LogExpert.Core/Classes/PatternBlock.cs similarity index 100% rename from src/Logexpert.Core/Classes/PatternBlock.cs rename to src/LogExpert.Core/Classes/PatternBlock.cs diff --git a/src/Logexpert.Core/Classes/Persister/FilterTabData.cs b/src/LogExpert.Core/Classes/Persister/FilterTabData.cs similarity index 100% rename from src/Logexpert.Core/Classes/Persister/FilterTabData.cs rename to src/LogExpert.Core/Classes/Persister/FilterTabData.cs diff --git a/src/Logexpert.Core/Classes/Persister/Persister.cs b/src/LogExpert.Core/Classes/Persister/Persister.cs similarity index 100% rename from src/Logexpert.Core/Classes/Persister/Persister.cs rename to src/LogExpert.Core/Classes/Persister/Persister.cs diff --git a/src/Logexpert.Core/Classes/Persister/ProjectData.cs b/src/LogExpert.Core/Classes/Persister/ProjectData.cs similarity index 100% rename from src/Logexpert.Core/Classes/Persister/ProjectData.cs rename to src/LogExpert.Core/Classes/Persister/ProjectData.cs diff --git a/src/Logexpert.Core/Classes/Persister/ProjectPersister.cs b/src/LogExpert.Core/Classes/Persister/ProjectPersister.cs similarity index 100% rename from src/Logexpert.Core/Classes/Persister/ProjectPersister.cs rename to src/LogExpert.Core/Classes/Persister/ProjectPersister.cs diff --git a/src/Logexpert.Core/Classes/SpreadEntry.cs b/src/LogExpert.Core/Classes/SpreadEntry.cs similarity index 100% rename from src/Logexpert.Core/Classes/SpreadEntry.cs rename to src/LogExpert.Core/Classes/SpreadEntry.cs diff --git a/src/Logexpert.Core/Classes/SysoutPipe.cs b/src/LogExpert.Core/Classes/SysoutPipe.cs similarity index 100% rename from src/Logexpert.Core/Classes/SysoutPipe.cs rename to src/LogExpert.Core/Classes/SysoutPipe.cs diff --git a/src/Logexpert.Core/Classes/UsedComponents.cs b/src/LogExpert.Core/Classes/UsedComponents.cs similarity index 100% rename from src/Logexpert.Core/Classes/UsedComponents.cs rename to src/LogExpert.Core/Classes/UsedComponents.cs diff --git a/src/Logexpert.Core/Classes/Util.cs b/src/LogExpert.Core/Classes/Util.cs similarity index 100% rename from src/Logexpert.Core/Classes/Util.cs rename to src/LogExpert.Core/Classes/Util.cs diff --git a/src/Logexpert.Core/Classes/Win32.cs b/src/LogExpert.Core/Classes/Win32.cs similarity index 100% rename from src/Logexpert.Core/Classes/Win32.cs rename to src/LogExpert.Core/Classes/Win32.cs diff --git a/src/Logexpert.Core/Classes/xml/XmlBlockSplitter.cs b/src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs similarity index 100% rename from src/Logexpert.Core/Classes/xml/XmlBlockSplitter.cs rename to src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs diff --git a/src/Logexpert.Core/Classes/xml/XmlLogReader.cs b/src/LogExpert.Core/Classes/xml/XmlLogReader.cs similarity index 100% rename from src/Logexpert.Core/Classes/xml/XmlLogReader.cs rename to src/LogExpert.Core/Classes/xml/XmlLogReader.cs diff --git a/src/Logexpert.Core/Config/ColorEntry.cs b/src/LogExpert.Core/Config/ColorEntry.cs similarity index 100% rename from src/Logexpert.Core/Config/ColorEntry.cs rename to src/LogExpert.Core/Config/ColorEntry.cs diff --git a/src/Logexpert.Core/Config/ColorMode.cs b/src/LogExpert.Core/Config/ColorMode.cs similarity index 100% rename from src/Logexpert.Core/Config/ColorMode.cs rename to src/LogExpert.Core/Config/ColorMode.cs diff --git a/src/Logexpert.Core/Config/ColumnizerHistoryEntry.cs b/src/LogExpert.Core/Config/ColumnizerHistoryEntry.cs similarity index 100% rename from src/Logexpert.Core/Config/ColumnizerHistoryEntry.cs rename to src/LogExpert.Core/Config/ColumnizerHistoryEntry.cs diff --git a/src/Logexpert.Core/Config/ColumnizerMaskEntry.cs b/src/LogExpert.Core/Config/ColumnizerMaskEntry.cs similarity index 100% rename from src/Logexpert.Core/Config/ColumnizerMaskEntry.cs rename to src/LogExpert.Core/Config/ColumnizerMaskEntry.cs diff --git a/src/Logexpert.Core/Config/ExportImportFlags.cs b/src/LogExpert.Core/Config/ExportImportFlags.cs similarity index 100% rename from src/Logexpert.Core/Config/ExportImportFlags.cs rename to src/LogExpert.Core/Config/ExportImportFlags.cs diff --git a/src/Logexpert.Core/Config/HighlightMaskEntry.cs b/src/LogExpert.Core/Config/HighlightMaskEntry.cs similarity index 100% rename from src/Logexpert.Core/Config/HighlightMaskEntry.cs rename to src/LogExpert.Core/Config/HighlightMaskEntry.cs diff --git a/src/Logexpert.Core/Config/MultiFileOption.cs b/src/LogExpert.Core/Config/MultiFileOption.cs similarity index 100% rename from src/Logexpert.Core/Config/MultiFileOption.cs rename to src/LogExpert.Core/Config/MultiFileOption.cs diff --git a/src/Logexpert.Core/Config/Preferences.cs b/src/LogExpert.Core/Config/Preferences.cs similarity index 100% rename from src/Logexpert.Core/Config/Preferences.cs rename to src/LogExpert.Core/Config/Preferences.cs diff --git a/src/Logexpert.Core/Config/RegexHistory.cs b/src/LogExpert.Core/Config/RegexHistory.cs similarity index 100% rename from src/Logexpert.Core/Config/RegexHistory.cs rename to src/LogExpert.Core/Config/RegexHistory.cs diff --git a/src/Logexpert.Core/Config/SessionSaveLocation.cs b/src/LogExpert.Core/Config/SessionSaveLocation.cs similarity index 100% rename from src/Logexpert.Core/Config/SessionSaveLocation.cs rename to src/LogExpert.Core/Config/SessionSaveLocation.cs diff --git a/src/Logexpert.Core/Config/Settings.cs b/src/LogExpert.Core/Config/Settings.cs similarity index 100% rename from src/Logexpert.Core/Config/Settings.cs rename to src/LogExpert.Core/Config/Settings.cs diff --git a/src/Logexpert.Core/Config/SettingsFlags.cs b/src/LogExpert.Core/Config/SettingsFlags.cs similarity index 100% rename from src/Logexpert.Core/Config/SettingsFlags.cs rename to src/LogExpert.Core/Config/SettingsFlags.cs diff --git a/src/Logexpert.Core/Config/ToolEntry.cs b/src/LogExpert.Core/Config/ToolEntry.cs similarity index 100% rename from src/Logexpert.Core/Config/ToolEntry.cs rename to src/LogExpert.Core/Config/ToolEntry.cs diff --git a/src/Logexpert.Core/Entities/Bookmark.cs b/src/LogExpert.Core/Entities/Bookmark.cs similarity index 100% rename from src/Logexpert.Core/Entities/Bookmark.cs rename to src/LogExpert.Core/Entities/Bookmark.cs diff --git a/src/Logexpert.Core/Entities/BookmarkCollection.cs b/src/LogExpert.Core/Entities/BookmarkCollection.cs similarity index 100% rename from src/Logexpert.Core/Entities/BookmarkCollection.cs rename to src/LogExpert.Core/Entities/BookmarkCollection.cs diff --git a/src/Logexpert.Core/Entities/BookmarkOverlay.cs b/src/LogExpert.Core/Entities/BookmarkOverlay.cs similarity index 100% rename from src/Logexpert.Core/Entities/BookmarkOverlay.cs rename to src/LogExpert.Core/Entities/BookmarkOverlay.cs diff --git a/src/Logexpert.Core/Entities/DebugOptions.cs b/src/LogExpert.Core/Entities/DebugOptions.cs similarity index 100% rename from src/Logexpert.Core/Entities/DebugOptions.cs rename to src/LogExpert.Core/Entities/DebugOptions.cs diff --git a/src/Logexpert.Core/Entities/DefaultLogfileColumnizer.cs b/src/LogExpert.Core/Entities/DefaultLogfileColumnizer.cs similarity index 100% rename from src/Logexpert.Core/Entities/DefaultLogfileColumnizer.cs rename to src/LogExpert.Core/Entities/DefaultLogfileColumnizer.cs diff --git a/src/Logexpert.Core/Entities/EncodingOptions.cs b/src/LogExpert.Core/Entities/EncodingOptions.cs similarity index 100% rename from src/Logexpert.Core/Entities/EncodingOptions.cs rename to src/LogExpert.Core/Entities/EncodingOptions.cs diff --git a/src/Logexpert.Core/Entities/FileViewContext.cs b/src/LogExpert.Core/Entities/FileViewContext.cs similarity index 100% rename from src/Logexpert.Core/Entities/FileViewContext.cs rename to src/LogExpert.Core/Entities/FileViewContext.cs diff --git a/src/Logexpert.Core/Entities/HighlightGroup.cs b/src/LogExpert.Core/Entities/HighlightGroup.cs similarity index 100% rename from src/Logexpert.Core/Entities/HighlightGroup.cs rename to src/LogExpert.Core/Entities/HighlightGroup.cs diff --git a/src/Logexpert.Core/Entities/LogEventData.cs b/src/LogExpert.Core/Entities/LogEventData.cs similarity index 100% rename from src/Logexpert.Core/Entities/LogEventData.cs rename to src/LogExpert.Core/Entities/LogEventData.cs diff --git a/src/Logexpert.Core/Entities/LogFileException.cs b/src/LogExpert.Core/Entities/LogFileException.cs similarity index 100% rename from src/Logexpert.Core/Entities/LogFileException.cs rename to src/LogExpert.Core/Entities/LogFileException.cs diff --git a/src/Logexpert.Core/Entities/MultifileOptions.cs b/src/LogExpert.Core/Entities/MultifileOptions.cs similarity index 100% rename from src/Logexpert.Core/Entities/MultifileOptions.cs rename to src/LogExpert.Core/Entities/MultifileOptions.cs diff --git a/src/Logexpert.Core/Entities/Range.cs b/src/LogExpert.Core/Entities/Range.cs similarity index 100% rename from src/Logexpert.Core/Entities/Range.cs rename to src/LogExpert.Core/Entities/Range.cs diff --git a/src/Logexpert.Core/Entities/ReloadMemento.cs b/src/LogExpert.Core/Entities/ReloadMemento.cs similarity index 100% rename from src/Logexpert.Core/Entities/ReloadMemento.cs rename to src/LogExpert.Core/Entities/ReloadMemento.cs diff --git a/src/Logexpert.Core/Entities/RowHeightEntry.cs b/src/LogExpert.Core/Entities/RowHeightEntry.cs similarity index 100% rename from src/Logexpert.Core/Entities/RowHeightEntry.cs rename to src/LogExpert.Core/Entities/RowHeightEntry.cs diff --git a/src/Logexpert.Core/Entities/SearchParams.cs b/src/LogExpert.Core/Entities/SearchParams.cs similarity index 100% rename from src/Logexpert.Core/Entities/SearchParams.cs rename to src/LogExpert.Core/Entities/SearchParams.cs diff --git a/src/Logexpert.Core/Enums/DragOrientationsEnum.cs b/src/LogExpert.Core/Enums/DragOrientationsEnum.cs similarity index 100% rename from src/Logexpert.Core/Enums/DragOrientationsEnum.cs rename to src/LogExpert.Core/Enums/DragOrientationsEnum.cs diff --git a/src/Logexpert.Core/Enums/ProjectLoadDlgResult.cs b/src/LogExpert.Core/Enums/ProjectLoadDlgResult.cs similarity index 100% rename from src/Logexpert.Core/Enums/ProjectLoadDlgResult.cs rename to src/LogExpert.Core/Enums/ProjectLoadDlgResult.cs diff --git a/src/Logexpert.Core/Enums/WindowTypes.cs b/src/LogExpert.Core/Enums/WindowTypes.cs similarity index 100% rename from src/Logexpert.Core/Enums/WindowTypes.cs rename to src/LogExpert.Core/Enums/WindowTypes.cs diff --git a/src/Logexpert.Core/EventArguments/BookmarkEventArgs.cs b/src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs similarity index 100% rename from src/Logexpert.Core/EventArguments/BookmarkEventArgs.cs rename to src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs diff --git a/src/Logexpert.Core/EventArguments/ColumnizerEventArgs.cs b/src/LogExpert.Core/EventArguments/ColumnizerEventArgs.cs similarity index 100% rename from src/Logexpert.Core/EventArguments/ColumnizerEventArgs.cs rename to src/LogExpert.Core/EventArguments/ColumnizerEventArgs.cs diff --git a/src/Logexpert.Core/EventArguments/ConfigChangedEventArgs.cs b/src/LogExpert.Core/EventArguments/ConfigChangedEventArgs.cs similarity index 100% rename from src/Logexpert.Core/EventArguments/ConfigChangedEventArgs.cs rename to src/LogExpert.Core/EventArguments/ConfigChangedEventArgs.cs diff --git a/src/Logexpert.Core/EventArguments/ContextMenuPluginEventArgs.cs b/src/LogExpert.Core/EventArguments/ContextMenuPluginEventArgs.cs similarity index 100% rename from src/Logexpert.Core/EventArguments/ContextMenuPluginEventArgs.cs rename to src/LogExpert.Core/EventArguments/ContextMenuPluginEventArgs.cs diff --git a/src/Logexpert.Core/EventArguments/CurrentHighlightGroupChangedEventArgs.cs b/src/LogExpert.Core/EventArguments/CurrentHighlightGroupChangedEventArgs.cs similarity index 100% rename from src/Logexpert.Core/EventArguments/CurrentHighlightGroupChangedEventArgs.cs rename to src/LogExpert.Core/EventArguments/CurrentHighlightGroupChangedEventArgs.cs diff --git a/src/Logexpert.Core/EventArguments/FilterListChangedEventArgs.cs b/src/LogExpert.Core/EventArguments/FilterListChangedEventArgs.cs similarity index 100% rename from src/Logexpert.Core/EventArguments/FilterListChangedEventArgs.cs rename to src/LogExpert.Core/EventArguments/FilterListChangedEventArgs.cs diff --git a/src/Logexpert.Core/EventArguments/GuiStateArgs.cs b/src/LogExpert.Core/EventArguments/GuiStateArgs.cs similarity index 100% rename from src/Logexpert.Core/EventArguments/GuiStateArgs.cs rename to src/LogExpert.Core/EventArguments/GuiStateArgs.cs diff --git a/src/Logexpert.Core/EventArguments/LoadFileEventArgs.cs b/src/LogExpert.Core/EventArguments/LoadFileEventArgs.cs similarity index 100% rename from src/Logexpert.Core/EventArguments/LoadFileEventArgs.cs rename to src/LogExpert.Core/EventArguments/LoadFileEventArgs.cs diff --git a/src/Logexpert.Core/EventArguments/OverlayEventArgs.cs b/src/LogExpert.Core/EventArguments/OverlayEventArgs.cs similarity index 100% rename from src/Logexpert.Core/EventArguments/OverlayEventArgs.cs rename to src/LogExpert.Core/EventArguments/OverlayEventArgs.cs diff --git a/src/Logexpert.Core/EventArguments/PatternArgs.cs b/src/LogExpert.Core/EventArguments/PatternArgs.cs similarity index 100% rename from src/Logexpert.Core/EventArguments/PatternArgs.cs rename to src/LogExpert.Core/EventArguments/PatternArgs.cs diff --git a/src/Logexpert.Core/EventArguments/ProgressEventArgs.cs b/src/LogExpert.Core/EventArguments/ProgressEventArgs.cs similarity index 100% rename from src/Logexpert.Core/EventArguments/ProgressEventArgs.cs rename to src/LogExpert.Core/EventArguments/ProgressEventArgs.cs diff --git a/src/Logexpert.Core/EventArguments/SelectLineEventArgs.cs b/src/LogExpert.Core/EventArguments/SelectLineEventArgs.cs similarity index 100% rename from src/Logexpert.Core/EventArguments/SelectLineEventArgs.cs rename to src/LogExpert.Core/EventArguments/SelectLineEventArgs.cs diff --git a/src/Logexpert.Core/EventArguments/StatusEventArgs.cs b/src/LogExpert.Core/EventArguments/StatusEventArgs.cs similarity index 100% rename from src/Logexpert.Core/EventArguments/StatusEventArgs.cs rename to src/LogExpert.Core/EventArguments/StatusEventArgs.cs diff --git a/src/Logexpert.Core/EventArguments/SyncModeEventArgs.cs b/src/LogExpert.Core/EventArguments/SyncModeEventArgs.cs similarity index 100% rename from src/Logexpert.Core/EventArguments/SyncModeEventArgs.cs rename to src/LogExpert.Core/EventArguments/SyncModeEventArgs.cs diff --git a/src/Logexpert.Core/EventHandlers/EventHandlers.cs b/src/LogExpert.Core/EventHandlers/EventHandlers.cs similarity index 100% rename from src/Logexpert.Core/EventHandlers/EventHandlers.cs rename to src/LogExpert.Core/EventHandlers/EventHandlers.cs diff --git a/src/Logexpert.Core/Extensions/IEnumerable.cs b/src/LogExpert.Core/Extensions/IEnumerable.cs similarity index 100% rename from src/Logexpert.Core/Extensions/IEnumerable.cs rename to src/LogExpert.Core/Extensions/IEnumerable.cs diff --git a/src/Logexpert.Core/Interface/IBackgroundProcessCancelHandler.cs b/src/LogExpert.Core/Interface/IBackgroundProcessCancelHandler.cs similarity index 100% rename from src/Logexpert.Core/Interface/IBackgroundProcessCancelHandler.cs rename to src/LogExpert.Core/Interface/IBackgroundProcessCancelHandler.cs diff --git a/src/Logexpert.Core/Interface/IBookmarkData.cs b/src/LogExpert.Core/Interface/IBookmarkData.cs similarity index 100% rename from src/Logexpert.Core/Interface/IBookmarkData.cs rename to src/LogExpert.Core/Interface/IBookmarkData.cs diff --git a/src/Logexpert.Core/Interface/IBookmarkView.cs b/src/LogExpert.Core/Interface/IBookmarkView.cs similarity index 100% rename from src/Logexpert.Core/Interface/IBookmarkView.cs rename to src/LogExpert.Core/Interface/IBookmarkView.cs diff --git a/src/Logexpert.Core/Interface/IConfigManager.cs b/src/LogExpert.Core/Interface/IConfigManager.cs similarity index 96% rename from src/Logexpert.Core/Interface/IConfigManager.cs rename to src/LogExpert.Core/Interface/IConfigManager.cs index 37ca8a74..e2de05f0 100644 --- a/src/Logexpert.Core/Interface/IConfigManager.cs +++ b/src/LogExpert.Core/Interface/IConfigManager.cs @@ -4,6 +4,7 @@ namespace LogExpert.Core.Interface { + //TODO: Add documentation public interface IConfigManager { Settings Settings { get; } diff --git a/src/Logexpert.Core/Interface/ILogExpertProxy.cs b/src/LogExpert.Core/Interface/ILogExpertProxy.cs similarity index 100% rename from src/Logexpert.Core/Interface/ILogExpertProxy.cs rename to src/LogExpert.Core/Interface/ILogExpertProxy.cs diff --git a/src/Logexpert.Core/Interface/ILogPaintContext.cs b/src/LogExpert.Core/Interface/ILogPaintContext.cs similarity index 100% rename from src/Logexpert.Core/Interface/ILogPaintContext.cs rename to src/LogExpert.Core/Interface/ILogPaintContext.cs diff --git a/src/Logexpert.Core/Interface/ILogStreamReader.cs b/src/LogExpert.Core/Interface/ILogStreamReader.cs similarity index 100% rename from src/Logexpert.Core/Interface/ILogStreamReader.cs rename to src/LogExpert.Core/Interface/ILogStreamReader.cs diff --git a/src/Logexpert.Core/Interface/ILogTabWindow.cs b/src/LogExpert.Core/Interface/ILogTabWindow.cs similarity index 92% rename from src/Logexpert.Core/Interface/ILogTabWindow.cs rename to src/LogExpert.Core/Interface/ILogTabWindow.cs index 85382180..518b3c01 100644 --- a/src/Logexpert.Core/Interface/ILogTabWindow.cs +++ b/src/LogExpert.Core/Interface/ILogTabWindow.cs @@ -1,5 +1,6 @@ namespace LogExpert.Core.Interface { + //TODO: Add documentation public interface ILogTabWindow { ILogExpertProxy LogExpertProxy { get; set; } diff --git a/src/Logexpert.Core/Interface/ILogView.cs b/src/LogExpert.Core/Interface/ILogView.cs similarity index 100% rename from src/Logexpert.Core/Interface/ILogView.cs rename to src/LogExpert.Core/Interface/ILogView.cs diff --git a/src/Logexpert.Core/Interface/ILogWindow.cs b/src/LogExpert.Core/Interface/ILogWindow.cs similarity index 97% rename from src/Logexpert.Core/Interface/ILogWindow.cs rename to src/LogExpert.Core/Interface/ILogWindow.cs index 6475f260..abe821b3 100644 --- a/src/Logexpert.Core/Interface/ILogWindow.cs +++ b/src/LogExpert.Core/Interface/ILogWindow.cs @@ -7,6 +7,7 @@ namespace LogExpert.Core.Interface { + //TODO: Add documentation public interface ILogWindow { string GetCurrentFileName(int lineNum); diff --git a/src/Logexpert.Core/Interface/IPluginRegistry.cs b/src/LogExpert.Core/Interface/IPluginRegistry.cs similarity index 88% rename from src/Logexpert.Core/Interface/IPluginRegistry.cs rename to src/LogExpert.Core/Interface/IPluginRegistry.cs index 4ce9d7e9..82f42f71 100644 --- a/src/Logexpert.Core/Interface/IPluginRegistry.cs +++ b/src/LogExpert.Core/Interface/IPluginRegistry.cs @@ -1,5 +1,6 @@ namespace LogExpert.Core.Interface { + //TODO: Add documentation public interface IPluginRegistry { IList RegisteredColumnizers { get; } diff --git a/src/Logexpert.Core/Interface/ISharedToolWindow.cs b/src/LogExpert.Core/Interface/ISharedToolWindow.cs similarity index 100% rename from src/Logexpert.Core/Interface/ISharedToolWindow.cs rename to src/LogExpert.Core/Interface/ISharedToolWindow.cs diff --git a/src/Logexpert.Core/Logexpert.Core.csproj b/src/LogExpert.Core/LogExpert.Core.csproj similarity index 100% rename from src/Logexpert.Core/Logexpert.Core.csproj rename to src/LogExpert.Core/LogExpert.Core.csproj diff --git a/src/Logexpert.Core/Structs/ActEntry.cs b/src/LogExpert.Core/Structs/ActEntry.cs similarity index 100% rename from src/Logexpert.Core/Structs/ActEntry.cs rename to src/LogExpert.Core/Structs/ActEntry.cs diff --git a/src/Logexpert.Resources/Logexpert.Resources.csproj b/src/LogExpert.Resources/LogExpert.Resources.csproj similarity index 100% rename from src/Logexpert.Resources/Logexpert.Resources.csproj rename to src/LogExpert.Resources/LogExpert.Resources.csproj diff --git a/src/Logexpert.Resources/Resources.Designer.cs b/src/LogExpert.Resources/Resources.Designer.cs similarity index 100% rename from src/Logexpert.Resources/Resources.Designer.cs rename to src/LogExpert.Resources/Resources.Designer.cs diff --git a/src/Logexpert.Resources/Resources.resx b/src/LogExpert.Resources/Resources.resx similarity index 100% rename from src/Logexpert.Resources/Resources.resx rename to src/LogExpert.Resources/Resources.resx diff --git a/src/Logexpert.Resources/images/bmp/LogExpert.bmp b/src/LogExpert.Resources/images/bmp/LogExpert.bmp similarity index 100% rename from src/Logexpert.Resources/images/bmp/LogExpert.bmp rename to src/LogExpert.Resources/images/bmp/LogExpert.bmp diff --git a/src/Logexpert.Resources/images/bmp/Pro_Filter.bmp b/src/LogExpert.Resources/images/bmp/Pro_Filter.bmp similarity index 100% rename from src/Logexpert.Resources/images/bmp/Pro_Filter.bmp rename to src/LogExpert.Resources/images/bmp/Pro_Filter.bmp diff --git a/src/Logexpert.Resources/images/gif/LogExpert-Icon.gif b/src/LogExpert.Resources/images/gif/LogExpert-Icon.gif similarity index 100% rename from src/Logexpert.Resources/images/gif/LogExpert-Icon.gif rename to src/LogExpert.Resources/images/gif/LogExpert-Icon.gif diff --git a/src/Logexpert.Resources/images/gif/LogLover.gif b/src/LogExpert.Resources/images/gif/LogLover.gif similarity index 100% rename from src/Logexpert.Resources/images/gif/LogLover.gif rename to src/LogExpert.Resources/images/gif/LogLover.gif diff --git a/src/Logexpert.Resources/images/icons/Icon1.ico b/src/LogExpert.Resources/images/icons/Icon1.ico similarity index 100% rename from src/Logexpert.Resources/images/icons/Icon1.ico rename to src/LogExpert.Resources/images/icons/Icon1.ico diff --git a/src/Logexpert.Resources/images/icons/Icon2.ico b/src/LogExpert.Resources/images/icons/Icon2.ico similarity index 100% rename from src/Logexpert.Resources/images/icons/Icon2.ico rename to src/LogExpert.Resources/images/icons/Icon2.ico diff --git a/src/Logexpert.Resources/images/icons/bubble.ico b/src/LogExpert.Resources/images/icons/bubble.ico similarity index 100% rename from src/Logexpert.Resources/images/icons/bubble.ico rename to src/LogExpert.Resources/images/icons/bubble.ico diff --git a/src/Logexpert.Resources/images/icons/logexpert.ico b/src/LogExpert.Resources/images/icons/logexpert.ico similarity index 100% rename from src/Logexpert.Resources/images/icons/logexpert.ico rename to src/LogExpert.Resources/images/icons/logexpert.ico diff --git a/src/Logexpert.Resources/images/png/48/Add.png b/src/LogExpert.Resources/images/png/48/Add.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Add.png rename to src/LogExpert.Resources/images/png/48/Add.png diff --git a/src/Logexpert.Resources/images/png/48/ArrowDown.png b/src/LogExpert.Resources/images/png/48/ArrowDown.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/ArrowDown.png rename to src/LogExpert.Resources/images/png/48/ArrowDown.png diff --git a/src/Logexpert.Resources/images/png/48/ArrowLeft.png b/src/LogExpert.Resources/images/png/48/ArrowLeft.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/ArrowLeft.png rename to src/LogExpert.Resources/images/png/48/ArrowLeft.png diff --git a/src/Logexpert.Resources/images/png/48/ArrowRight.png b/src/LogExpert.Resources/images/png/48/ArrowRight.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/ArrowRight.png rename to src/LogExpert.Resources/images/png/48/ArrowRight.png diff --git a/src/Logexpert.Resources/images/png/48/ArrowUp.png b/src/LogExpert.Resources/images/png/48/ArrowUp.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/ArrowUp.png rename to src/LogExpert.Resources/images/png/48/ArrowUp.png diff --git a/src/Logexpert.Resources/images/png/48/Arrow_menu_close.png b/src/LogExpert.Resources/images/png/48/Arrow_menu_close.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Arrow_menu_close.png rename to src/LogExpert.Resources/images/png/48/Arrow_menu_close.png diff --git a/src/Logexpert.Resources/images/png/48/Arrow_menu_open.png b/src/LogExpert.Resources/images/png/48/Arrow_menu_open.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Arrow_menu_open.png rename to src/LogExpert.Resources/images/png/48/Arrow_menu_open.png diff --git a/src/Logexpert.Resources/images/png/48/Bookmark_add.png b/src/LogExpert.Resources/images/png/48/Bookmark_add.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Bookmark_add.png rename to src/LogExpert.Resources/images/png/48/Bookmark_add.png diff --git a/src/Logexpert.Resources/images/png/48/Bookmark_added.png b/src/LogExpert.Resources/images/png/48/Bookmark_added.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Bookmark_added.png rename to src/LogExpert.Resources/images/png/48/Bookmark_added.png diff --git a/src/Logexpert.Resources/images/png/48/Bookmark_manager.png b/src/LogExpert.Resources/images/png/48/Bookmark_manager.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Bookmark_manager.png rename to src/LogExpert.Resources/images/png/48/Bookmark_manager.png diff --git a/src/Logexpert.Resources/images/png/48/Bookmark_remove.png b/src/LogExpert.Resources/images/png/48/Bookmark_remove.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Bookmark_remove.png rename to src/LogExpert.Resources/images/png/48/Bookmark_remove.png diff --git a/src/Logexpert.Resources/images/png/48/Bookmarks.png b/src/LogExpert.Resources/images/png/48/Bookmarks.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Bookmarks.png rename to src/LogExpert.Resources/images/png/48/Bookmarks.png diff --git a/src/Logexpert.Resources/images/png/48/Check_circle.png b/src/LogExpert.Resources/images/png/48/Check_circle.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Check_circle.png rename to src/LogExpert.Resources/images/png/48/Check_circle.png diff --git a/src/Logexpert.Resources/images/png/48/Close.png b/src/LogExpert.Resources/images/png/48/Close.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Close.png rename to src/LogExpert.Resources/images/png/48/Close.png diff --git a/src/Logexpert.Resources/images/png/48/Deceased.png b/src/LogExpert.Resources/images/png/48/Deceased.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Deceased.png rename to src/LogExpert.Resources/images/png/48/Deceased.png diff --git a/src/Logexpert.Resources/images/png/48/Delete.png b/src/LogExpert.Resources/images/png/48/Delete.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Delete.png rename to src/LogExpert.Resources/images/png/48/Delete.png diff --git a/src/Logexpert.Resources/images/png/48/Exit.png b/src/LogExpert.Resources/images/png/48/Exit.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Exit.png rename to src/LogExpert.Resources/images/png/48/Exit.png diff --git a/src/Logexpert.Resources/images/png/48/Favorite.png b/src/LogExpert.Resources/images/png/48/Favorite.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Favorite.png rename to src/LogExpert.Resources/images/png/48/Favorite.png diff --git a/src/Logexpert.Resources/images/png/48/File_open.png b/src/LogExpert.Resources/images/png/48/File_open.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/File_open.png rename to src/LogExpert.Resources/images/png/48/File_open.png diff --git a/src/Logexpert.Resources/images/png/48/Filter.png b/src/LogExpert.Resources/images/png/48/Filter.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Filter.png rename to src/LogExpert.Resources/images/png/48/Filter.png diff --git a/src/Logexpert.Resources/images/png/48/Folder_open.png b/src/LogExpert.Resources/images/png/48/Folder_open.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Folder_open.png rename to src/LogExpert.Resources/images/png/48/Folder_open.png diff --git a/src/Logexpert.Resources/images/png/48/Restart_alt.png b/src/LogExpert.Resources/images/png/48/Restart_alt.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Restart_alt.png rename to src/LogExpert.Resources/images/png/48/Restart_alt.png diff --git a/src/Logexpert.Resources/images/png/48/Search.png b/src/LogExpert.Resources/images/png/48/Search.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Search.png rename to src/LogExpert.Resources/images/png/48/Search.png diff --git a/src/Logexpert.Resources/images/png/48/Settings.png b/src/LogExpert.Resources/images/png/48/Settings.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Settings.png rename to src/LogExpert.Resources/images/png/48/Settings.png diff --git a/src/Logexpert.Resources/images/png/48/Star.png b/src/LogExpert.Resources/images/png/48/Star.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/Star.png rename to src/LogExpert.Resources/images/png/48/Star.png diff --git a/src/Logexpert.Resources/images/png/48/bookmark_bubbles.png b/src/LogExpert.Resources/images/png/48/bookmark_bubbles.png similarity index 100% rename from src/Logexpert.Resources/images/png/48/bookmark_bubbles.png rename to src/LogExpert.Resources/images/png/48/bookmark_bubbles.png diff --git a/src/Logexpert.UI/Controls/BufferedDataGridView.Designer.cs b/src/LogExpert.UI/Controls/BufferedDataGridView.Designer.cs similarity index 100% rename from src/Logexpert.UI/Controls/BufferedDataGridView.Designer.cs rename to src/LogExpert.UI/Controls/BufferedDataGridView.Designer.cs diff --git a/src/Logexpert.UI/Controls/BufferedDataGridView.cs b/src/LogExpert.UI/Controls/BufferedDataGridView.cs similarity index 100% rename from src/Logexpert.UI/Controls/BufferedDataGridView.cs rename to src/LogExpert.UI/Controls/BufferedDataGridView.cs diff --git a/src/Logexpert.UI/Controls/ColorComboBox.cs b/src/LogExpert.UI/Controls/ColorComboBox.cs similarity index 100% rename from src/Logexpert.UI/Controls/ColorComboBox.cs rename to src/LogExpert.UI/Controls/ColorComboBox.cs diff --git a/src/Logexpert.UI/Controls/DateTimeDragControl.Designer.cs b/src/LogExpert.UI/Controls/DateTimeDragControl.Designer.cs similarity index 100% rename from src/Logexpert.UI/Controls/DateTimeDragControl.Designer.cs rename to src/LogExpert.UI/Controls/DateTimeDragControl.Designer.cs diff --git a/src/Logexpert.UI/Controls/DateTimeDragControl.cs b/src/LogExpert.UI/Controls/DateTimeDragControl.cs similarity index 100% rename from src/Logexpert.UI/Controls/DateTimeDragControl.cs rename to src/LogExpert.UI/Controls/DateTimeDragControl.cs diff --git a/src/Logexpert.UI/Controls/DateTimeDragControl.resx b/src/LogExpert.UI/Controls/DateTimeDragControl.resx similarity index 100% rename from src/Logexpert.UI/Controls/DateTimeDragControl.resx rename to src/LogExpert.UI/Controls/DateTimeDragControl.resx diff --git a/src/Logexpert.UI/Controls/KnobControl.Designer.cs b/src/LogExpert.UI/Controls/KnobControl.Designer.cs similarity index 100% rename from src/Logexpert.UI/Controls/KnobControl.Designer.cs rename to src/LogExpert.UI/Controls/KnobControl.Designer.cs diff --git a/src/Logexpert.UI/Controls/KnobControl.cs b/src/LogExpert.UI/Controls/KnobControl.cs similarity index 100% rename from src/Logexpert.UI/Controls/KnobControl.cs rename to src/LogExpert.UI/Controls/KnobControl.cs diff --git a/src/Logexpert.UI/Controls/KnobControl.resx b/src/LogExpert.UI/Controls/KnobControl.resx similarity index 100% rename from src/Logexpert.UI/Controls/KnobControl.resx rename to src/LogExpert.UI/Controls/KnobControl.resx diff --git a/src/Logexpert.UI/Controls/LogCellEditingControl.cs b/src/LogExpert.UI/Controls/LogCellEditingControl.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogCellEditingControl.cs rename to src/LogExpert.UI/Controls/LogCellEditingControl.cs diff --git a/src/Logexpert.UI/Controls/LogGridCell.cs b/src/LogExpert.UI/Controls/LogGridCell.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogGridCell.cs rename to src/LogExpert.UI/Controls/LogGridCell.cs diff --git a/src/Logexpert.UI/Controls/LogTabControl.cs b/src/LogExpert.UI/Controls/LogTabControl.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogTabControl.cs rename to src/LogExpert.UI/Controls/LogTabControl.cs diff --git a/src/Logexpert.UI/Controls/LogTextColumn.cs b/src/LogExpert.UI/Controls/LogTextColumn.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogTextColumn.cs rename to src/LogExpert.UI/Controls/LogTextColumn.cs diff --git a/src/Logexpert.UI/Controls/LogWindow/ColumnCache.cs b/src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogWindow/ColumnCache.cs rename to src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs diff --git a/src/Logexpert.UI/Controls/LogWindow/LogExpertCallback.cs b/src/LogExpert.UI/Controls/LogWindow/LogExpertCallback.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogWindow/LogExpertCallback.cs rename to src/LogExpert.UI/Controls/LogWindow/LogExpertCallback.cs diff --git a/src/Logexpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogWindow/LogWindow.cs rename to src/LogExpert.UI/Controls/LogWindow/LogWindow.cs diff --git a/src/Logexpert.UI/Controls/LogWindow/LogWindow.designer.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogWindow/LogWindow.designer.cs rename to src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs diff --git a/src/Logexpert.UI/Controls/LogWindow/LogWindow.resx b/src/LogExpert.UI/Controls/LogWindow/LogWindow.resx similarity index 100% rename from src/Logexpert.UI/Controls/LogWindow/LogWindow.resx rename to src/LogExpert.UI/Controls/LogWindow/LogWindow.resx diff --git a/src/Logexpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs rename to src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs diff --git a/src/Logexpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.resx b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.resx rename to src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.resx diff --git a/src/Logexpert.UI/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogWindow/LogWindowPrivate.cs rename to src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs diff --git a/src/Logexpert.UI/Controls/LogWindow/LogWindowPublic.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogWindow/LogWindowPublic.cs rename to src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs diff --git a/src/Logexpert.UI/Controls/LogWindow/PatternWindow.Designer.cs b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.Designer.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogWindow/PatternWindow.Designer.cs rename to src/LogExpert.UI/Controls/LogWindow/PatternWindow.Designer.cs diff --git a/src/Logexpert.UI/Controls/LogWindow/PatternWindow.cs b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogWindow/PatternWindow.cs rename to src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs diff --git a/src/Logexpert.UI/Controls/LogWindow/PatternWindow.resx b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.resx similarity index 100% rename from src/Logexpert.UI/Controls/LogWindow/PatternWindow.resx rename to src/LogExpert.UI/Controls/LogWindow/PatternWindow.resx diff --git a/src/Logexpert.UI/Controls/LogWindow/RangeFinder.cs b/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogWindow/RangeFinder.cs rename to src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs diff --git a/src/Logexpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs rename to src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs diff --git a/src/Logexpert.UI/Controls/LogWindow/TimeSpreadigControl.Designer.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.Designer.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogWindow/TimeSpreadigControl.Designer.cs rename to src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.Designer.cs diff --git a/src/Logexpert.UI/Controls/LogWindow/TimeSpreadigControl.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogWindow/TimeSpreadigControl.cs rename to src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs diff --git a/src/Logexpert.UI/Controls/LogWindow/TimeSpreadigControl.resx b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.resx similarity index 100% rename from src/Logexpert.UI/Controls/LogWindow/TimeSpreadigControl.resx rename to src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.resx diff --git a/src/Logexpert.UI/Controls/LogWindow/TimeSyncList.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs similarity index 100% rename from src/Logexpert.UI/Controls/LogWindow/TimeSyncList.cs rename to src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs diff --git a/src/Logexpert.UI/Dialogs/AboutBox.Designer.cs b/src/LogExpert.UI/Dialogs/AboutBox.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/AboutBox.Designer.cs rename to src/LogExpert.UI/Dialogs/AboutBox.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/AboutBox.cs b/src/LogExpert.UI/Dialogs/AboutBox.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/AboutBox.cs rename to src/LogExpert.UI/Dialogs/AboutBox.cs diff --git a/src/Logexpert.UI/Dialogs/AboutBox.resx b/src/LogExpert.UI/Dialogs/AboutBox.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/AboutBox.resx rename to src/LogExpert.UI/Dialogs/AboutBox.resx diff --git a/src/Logexpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.Designer.cs b/src/LogExpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.Designer.cs rename to src/LogExpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.cs b/src/LogExpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.cs rename to src/LogExpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.cs diff --git a/src/Logexpert.UI/Dialogs/BookmarkCommentDlg.Designer.cs b/src/LogExpert.UI/Dialogs/BookmarkCommentDlg.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/BookmarkCommentDlg.Designer.cs rename to src/LogExpert.UI/Dialogs/BookmarkCommentDlg.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/BookmarkCommentDlg.cs b/src/LogExpert.UI/Dialogs/BookmarkCommentDlg.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/BookmarkCommentDlg.cs rename to src/LogExpert.UI/Dialogs/BookmarkCommentDlg.cs diff --git a/src/Logexpert.UI/Dialogs/BookmarkCommentDlg.resx b/src/LogExpert.UI/Dialogs/BookmarkCommentDlg.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/BookmarkCommentDlg.resx rename to src/LogExpert.UI/Dialogs/BookmarkCommentDlg.resx diff --git a/src/Logexpert.UI/Dialogs/BookmarkWindow.Designer.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/BookmarkWindow.Designer.cs rename to src/LogExpert.UI/Dialogs/BookmarkWindow.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/BookmarkWindow.cs rename to src/LogExpert.UI/Dialogs/BookmarkWindow.cs diff --git a/src/Logexpert.UI/Dialogs/BookmarkWindow.resx b/src/LogExpert.UI/Dialogs/BookmarkWindow.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/BookmarkWindow.resx rename to src/LogExpert.UI/Dialogs/BookmarkWindow.resx diff --git a/src/Logexpert.UI/Dialogs/ChooseIconDlg.Designer.cs b/src/LogExpert.UI/Dialogs/ChooseIconDlg.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/ChooseIconDlg.Designer.cs rename to src/LogExpert.UI/Dialogs/ChooseIconDlg.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/ChooseIconDlg.cs b/src/LogExpert.UI/Dialogs/ChooseIconDlg.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/ChooseIconDlg.cs rename to src/LogExpert.UI/Dialogs/ChooseIconDlg.cs diff --git a/src/Logexpert.UI/Dialogs/ChooseIconDlg.resx b/src/LogExpert.UI/Dialogs/ChooseIconDlg.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/ChooseIconDlg.resx rename to src/LogExpert.UI/Dialogs/ChooseIconDlg.resx diff --git a/src/Logexpert.UI/Dialogs/ExceptionWindow.Designer.cs b/src/LogExpert.UI/Dialogs/ExceptionWindow.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/ExceptionWindow.Designer.cs rename to src/LogExpert.UI/Dialogs/ExceptionWindow.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/ExceptionWindow.cs b/src/LogExpert.UI/Dialogs/ExceptionWindow.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/ExceptionWindow.cs rename to src/LogExpert.UI/Dialogs/ExceptionWindow.cs diff --git a/src/Logexpert.UI/Dialogs/ExceptionWindow.resx b/src/LogExpert.UI/Dialogs/ExceptionWindow.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/ExceptionWindow.resx rename to src/LogExpert.UI/Dialogs/ExceptionWindow.resx diff --git a/src/Logexpert.UI/Dialogs/FilterColumnChooser.Designer.cs b/src/LogExpert.UI/Dialogs/FilterColumnChooser.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/FilterColumnChooser.Designer.cs rename to src/LogExpert.UI/Dialogs/FilterColumnChooser.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/FilterColumnChooser.cs b/src/LogExpert.UI/Dialogs/FilterColumnChooser.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/FilterColumnChooser.cs rename to src/LogExpert.UI/Dialogs/FilterColumnChooser.cs diff --git a/src/Logexpert.UI/Dialogs/FilterColumnChooser.resx b/src/LogExpert.UI/Dialogs/FilterColumnChooser.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/FilterColumnChooser.resx rename to src/LogExpert.UI/Dialogs/FilterColumnChooser.resx diff --git a/src/Logexpert.UI/Dialogs/GotoLineDialog.Designer.cs b/src/LogExpert.UI/Dialogs/GotoLineDialog.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/GotoLineDialog.Designer.cs rename to src/LogExpert.UI/Dialogs/GotoLineDialog.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/GotoLineDialog.cs b/src/LogExpert.UI/Dialogs/GotoLineDialog.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/GotoLineDialog.cs rename to src/LogExpert.UI/Dialogs/GotoLineDialog.cs diff --git a/src/Logexpert.UI/Dialogs/GotoLineDialog.resx b/src/LogExpert.UI/Dialogs/GotoLineDialog.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/GotoLineDialog.resx rename to src/LogExpert.UI/Dialogs/GotoLineDialog.resx diff --git a/src/Logexpert.UI/Dialogs/ImportSettingsDialog.Designer.cs b/src/LogExpert.UI/Dialogs/ImportSettingsDialog.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/ImportSettingsDialog.Designer.cs rename to src/LogExpert.UI/Dialogs/ImportSettingsDialog.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/ImportSettingsDialog.cs b/src/LogExpert.UI/Dialogs/ImportSettingsDialog.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/ImportSettingsDialog.cs rename to src/LogExpert.UI/Dialogs/ImportSettingsDialog.cs diff --git a/src/Logexpert.UI/Dialogs/ImportSettingsDialog.resx b/src/LogExpert.UI/Dialogs/ImportSettingsDialog.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/ImportSettingsDialog.resx rename to src/LogExpert.UI/Dialogs/ImportSettingsDialog.resx diff --git a/src/Logexpert.UI/Dialogs/KeywordActionDlg.Designer.cs b/src/LogExpert.UI/Dialogs/KeywordActionDlg.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/KeywordActionDlg.Designer.cs rename to src/LogExpert.UI/Dialogs/KeywordActionDlg.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/KeywordActionDlg.cs b/src/LogExpert.UI/Dialogs/KeywordActionDlg.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/KeywordActionDlg.cs rename to src/LogExpert.UI/Dialogs/KeywordActionDlg.cs diff --git a/src/Logexpert.UI/Dialogs/KeywordActionDlg.resx b/src/LogExpert.UI/Dialogs/KeywordActionDlg.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/KeywordActionDlg.resx rename to src/LogExpert.UI/Dialogs/KeywordActionDlg.resx diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.Designer.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.Designer.cs rename to src/LogExpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.cs rename to src/LogExpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.cs diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.resx b/src/LogExpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.resx rename to src/LogExpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.resx diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/HighlightDialog.Designer.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/LogTabWindow/HighlightDialog.Designer.cs rename to src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs rename to src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/HighlightDialog.resx b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/LogTabWindow/HighlightDialog.resx rename to src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.resx diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs rename to src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs rename to src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindow.resx b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindow.resx rename to src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.resx diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs rename to src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs rename to src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs rename to src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/SettingsDialog.Designer.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/LogTabWindow/SettingsDialog.Designer.cs rename to src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs rename to src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/SettingsDialog.resx b/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/LogTabWindow/SettingsDialog.resx rename to src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.resx diff --git a/src/Logexpert.UI/Dialogs/MultiFileMaskDialog.Designer.cs b/src/LogExpert.UI/Dialogs/MultiFileMaskDialog.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/MultiFileMaskDialog.Designer.cs rename to src/LogExpert.UI/Dialogs/MultiFileMaskDialog.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/MultiFileMaskDialog.cs b/src/LogExpert.UI/Dialogs/MultiFileMaskDialog.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/MultiFileMaskDialog.cs rename to src/LogExpert.UI/Dialogs/MultiFileMaskDialog.cs diff --git a/src/Logexpert.UI/Dialogs/MultiFileMaskDialog.resx b/src/LogExpert.UI/Dialogs/MultiFileMaskDialog.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/MultiFileMaskDialog.resx rename to src/LogExpert.UI/Dialogs/MultiFileMaskDialog.resx diff --git a/src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.Designer.cs b/src/LogExpert.UI/Dialogs/MultiLoadRequestDialog.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.Designer.cs rename to src/LogExpert.UI/Dialogs/MultiLoadRequestDialog.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.cs b/src/LogExpert.UI/Dialogs/MultiLoadRequestDialog.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.cs rename to src/LogExpert.UI/Dialogs/MultiLoadRequestDialog.cs diff --git a/src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.resx b/src/LogExpert.UI/Dialogs/MultiLoadRequestDialog.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/MultiLoadRequestDialog.resx rename to src/LogExpert.UI/Dialogs/MultiLoadRequestDialog.resx diff --git a/src/Logexpert.UI/Dialogs/OpenUriDialog.Designer.cs b/src/LogExpert.UI/Dialogs/OpenUriDialog.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/OpenUriDialog.Designer.cs rename to src/LogExpert.UI/Dialogs/OpenUriDialog.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/OpenUriDialog.cs b/src/LogExpert.UI/Dialogs/OpenUriDialog.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/OpenUriDialog.cs rename to src/LogExpert.UI/Dialogs/OpenUriDialog.cs diff --git a/src/Logexpert.UI/Dialogs/OpenUriDialog.resx b/src/LogExpert.UI/Dialogs/OpenUriDialog.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/OpenUriDialog.resx rename to src/LogExpert.UI/Dialogs/OpenUriDialog.resx diff --git a/src/Logexpert.UI/Dialogs/ParamRequesterDialog.Designer.cs b/src/LogExpert.UI/Dialogs/ParamRequesterDialog.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/ParamRequesterDialog.Designer.cs rename to src/LogExpert.UI/Dialogs/ParamRequesterDialog.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/ParamRequesterDialog.cs b/src/LogExpert.UI/Dialogs/ParamRequesterDialog.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/ParamRequesterDialog.cs rename to src/LogExpert.UI/Dialogs/ParamRequesterDialog.cs diff --git a/src/Logexpert.UI/Dialogs/ParamRequesterDialog.resx b/src/LogExpert.UI/Dialogs/ParamRequesterDialog.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/ParamRequesterDialog.resx rename to src/LogExpert.UI/Dialogs/ParamRequesterDialog.resx diff --git a/src/Logexpert.UI/Dialogs/ProjectLoadDlg.Designer.cs b/src/LogExpert.UI/Dialogs/ProjectLoadDlg.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/ProjectLoadDlg.Designer.cs rename to src/LogExpert.UI/Dialogs/ProjectLoadDlg.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/ProjectLoadDlg.cs b/src/LogExpert.UI/Dialogs/ProjectLoadDlg.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/ProjectLoadDlg.cs rename to src/LogExpert.UI/Dialogs/ProjectLoadDlg.cs diff --git a/src/Logexpert.UI/Dialogs/ProjectLoadDlg.resx b/src/LogExpert.UI/Dialogs/ProjectLoadDlg.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/ProjectLoadDlg.resx rename to src/LogExpert.UI/Dialogs/ProjectLoadDlg.resx diff --git a/src/Logexpert.UI/Dialogs/RegexHelperDialog.Designer.cs b/src/LogExpert.UI/Dialogs/RegexHelperDialog.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/RegexHelperDialog.Designer.cs rename to src/LogExpert.UI/Dialogs/RegexHelperDialog.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/RegexHelperDialog.cs b/src/LogExpert.UI/Dialogs/RegexHelperDialog.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/RegexHelperDialog.cs rename to src/LogExpert.UI/Dialogs/RegexHelperDialog.cs diff --git a/src/Logexpert.UI/Dialogs/RegexHelperDialog.resx b/src/LogExpert.UI/Dialogs/RegexHelperDialog.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/RegexHelperDialog.resx rename to src/LogExpert.UI/Dialogs/RegexHelperDialog.resx diff --git a/src/Logexpert.UI/Dialogs/SearchDialog.Designer.cs b/src/LogExpert.UI/Dialogs/SearchDialog.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/SearchDialog.Designer.cs rename to src/LogExpert.UI/Dialogs/SearchDialog.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/SearchDialog.cs b/src/LogExpert.UI/Dialogs/SearchDialog.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/SearchDialog.cs rename to src/LogExpert.UI/Dialogs/SearchDialog.cs diff --git a/src/Logexpert.UI/Dialogs/SearchDialog.resx b/src/LogExpert.UI/Dialogs/SearchDialog.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/SearchDialog.resx rename to src/LogExpert.UI/Dialogs/SearchDialog.resx diff --git a/src/Logexpert.UI/Dialogs/SearchProgressDialog.Designer.cs b/src/LogExpert.UI/Dialogs/SearchProgressDialog.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/SearchProgressDialog.Designer.cs rename to src/LogExpert.UI/Dialogs/SearchProgressDialog.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/SearchProgressDialog.cs b/src/LogExpert.UI/Dialogs/SearchProgressDialog.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/SearchProgressDialog.cs rename to src/LogExpert.UI/Dialogs/SearchProgressDialog.cs diff --git a/src/Logexpert.UI/Dialogs/SearchProgressDialog.resx b/src/LogExpert.UI/Dialogs/SearchProgressDialog.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/SearchProgressDialog.resx rename to src/LogExpert.UI/Dialogs/SearchProgressDialog.resx diff --git a/src/Logexpert.UI/Dialogs/TabRenameDialog.Designer.cs b/src/LogExpert.UI/Dialogs/TabRenameDialog.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/TabRenameDialog.Designer.cs rename to src/LogExpert.UI/Dialogs/TabRenameDialog.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/TabRenameDialog.cs b/src/LogExpert.UI/Dialogs/TabRenameDialog.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/TabRenameDialog.cs rename to src/LogExpert.UI/Dialogs/TabRenameDialog.cs diff --git a/src/Logexpert.UI/Dialogs/TabRenameDialog.resx b/src/LogExpert.UI/Dialogs/TabRenameDialog.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/TabRenameDialog.resx rename to src/LogExpert.UI/Dialogs/TabRenameDialog.resx diff --git a/src/Logexpert.UI/Dialogs/ToolArgsDialog.Designer.cs b/src/LogExpert.UI/Dialogs/ToolArgsDialog.Designer.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/ToolArgsDialog.Designer.cs rename to src/LogExpert.UI/Dialogs/ToolArgsDialog.Designer.cs diff --git a/src/Logexpert.UI/Dialogs/ToolArgsDialog.cs b/src/LogExpert.UI/Dialogs/ToolArgsDialog.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/ToolArgsDialog.cs rename to src/LogExpert.UI/Dialogs/ToolArgsDialog.cs diff --git a/src/Logexpert.UI/Dialogs/ToolArgsDialog.resx b/src/LogExpert.UI/Dialogs/ToolArgsDialog.resx similarity index 100% rename from src/Logexpert.UI/Dialogs/ToolArgsDialog.resx rename to src/LogExpert.UI/Dialogs/ToolArgsDialog.resx diff --git a/src/Logexpert.UI/Entities/ArgParser.cs b/src/LogExpert.UI/Entities/ArgParser.cs similarity index 100% rename from src/Logexpert.UI/Entities/ArgParser.cs rename to src/LogExpert.UI/Entities/ArgParser.cs diff --git a/src/Logexpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs similarity index 100% rename from src/Logexpert.UI/Entities/PaintHelper.cs rename to src/LogExpert.UI/Entities/PaintHelper.cs diff --git a/src/Logexpert.UI/Entities/WindowFileEntry.cs b/src/LogExpert.UI/Entities/WindowFileEntry.cs similarity index 100% rename from src/Logexpert.UI/Entities/WindowFileEntry.cs rename to src/LogExpert.UI/Entities/WindowFileEntry.cs diff --git a/src/Logexpert.UI/Extensions/ComboBoxExtensions.cs b/src/LogExpert.UI/Extensions/ComboBoxExtensions.cs similarity index 100% rename from src/Logexpert.UI/Extensions/ComboBoxExtensions.cs rename to src/LogExpert.UI/Extensions/ComboBoxExtensions.cs diff --git a/src/Logexpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs b/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs similarity index 100% rename from src/Logexpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs rename to src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs diff --git a/src/Logexpert.UI/Extensions/Forms/MenuSelectedColors.cs b/src/LogExpert.UI/Extensions/Forms/MenuSelectedColors.cs similarity index 100% rename from src/Logexpert.UI/Extensions/Forms/MenuSelectedColors.cs rename to src/LogExpert.UI/Extensions/Forms/MenuSelectedColors.cs diff --git a/src/Logexpert.UI/Extensions/Forms/MenuStripExtension.cs b/src/LogExpert.UI/Extensions/Forms/MenuStripExtension.cs similarity index 100% rename from src/Logexpert.UI/Extensions/Forms/MenuStripExtension.cs rename to src/LogExpert.UI/Extensions/Forms/MenuStripExtension.cs diff --git a/src/Logexpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs b/src/LogExpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs similarity index 100% rename from src/Logexpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs rename to src/LogExpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs diff --git a/src/Logexpert.UI/Extensions/Forms/ToolStripRendererExtension.cs b/src/LogExpert.UI/Extensions/Forms/ToolStripRendererExtension.cs similarity index 100% rename from src/Logexpert.UI/Extensions/Forms/ToolStripRendererExtension.cs rename to src/LogExpert.UI/Extensions/Forms/ToolStripRendererExtension.cs diff --git a/src/Logexpert.UI/LogExpert.UI.csproj b/src/LogExpert.UI/LogExpert.UI.csproj similarity index 100% rename from src/Logexpert.UI/LogExpert.UI.csproj rename to src/LogExpert.UI/LogExpert.UI.csproj diff --git a/src/LogExpert.sln b/src/LogExpert.sln index 81360b89..1587d67b 100644 --- a/src/LogExpert.sln +++ b/src/LogExpert.sln @@ -56,11 +56,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "setup", "setup", "{C625E7C2 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RegexColumnizer.UnitTests", "RegexColumnizer.UnitTests\RegexColumnizer.UnitTests.csproj", "{FBFB598D-B94A-4AD3-A355-0D5A618CEEE3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.Core", "Logexpert.Core\LogExpert.Core.csproj", "{F49C6738-3F62-4890-8FF2-1F53A0F0A2CD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.Core", "LogExpert.Core\LogExpert.Core.csproj", "{F49C6738-3F62-4890-8FF2-1F53A0F0A2CD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.Resources", "Logexpert.Resources\LogExpert.Resources.csproj", "{578CC5D5-1DCD-47C2-8BD3-B32C14635BEC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.Resources", "LogExpert.Resources\LogExpert.Resources.csproj", "{578CC5D5-1DCD-47C2-8BD3-B32C14635BEC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.UI", "Logexpert.UI\LogExpert.UI.csproj", "{5DB0B0F8-3C3E-4805-93A3-7E69AC45CD40}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.UI", "LogExpert.UI\LogExpert.UI.csproj", "{5DB0B0F8-3C3E-4805-93A3-7E69AC45CD40}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.PluginRegistry", "PluginRegistry\LogExpert.PluginRegistry.csproj", "{E2D8E653-B7DF-4ACE-8314-8059B1E20751}" EndProject diff --git a/src/LogExpert/Program.cs b/src/LogExpert/Program.cs index 66caf74e..1e043a20 100644 --- a/src/LogExpert/Program.cs +++ b/src/LogExpert/Program.cs @@ -57,7 +57,7 @@ private static void Main(string[] args) if (configFile.Exists) { FileInfo cfgFileInfo = new(configFile.Value); - + //TODO: The config file import and the try catch for the primary instance and secondary instance should be separated functions if (cfgFileInfo.Exists) { ConfigManager.Instance.Import(cfgFileInfo, ExportImportFlags.All); From 0e7fe4783a7cdf1bfaac02000674e43f54d0ccd1 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Tue, 27 May 2025 00:23:33 +0300 Subject: [PATCH 032/142] Added a few TODOs. --- src/LogExpert.UI/Dialogs/ExceptionWindow.cs | 1 + src/LogExpert.UI/Dialogs/FilterColumnChooser.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/LogExpert.UI/Dialogs/ExceptionWindow.cs b/src/LogExpert.UI/Dialogs/ExceptionWindow.cs index 1f38dc61..2ab0adb5 100644 --- a/src/LogExpert.UI/Dialogs/ExceptionWindow.cs +++ b/src/LogExpert.UI/Dialogs/ExceptionWindow.cs @@ -12,6 +12,7 @@ public partial class ExceptionWindow : Form #region cTor + //TODO: for HighDPI SuspendLayout() before InitializeComponent() and then ResumeLayout() as last command in the CTOR can help in complex forms to reduce flickering and miscalculations. Also, it is a good practice. public ExceptionWindow(string errorText, string stackTrace) { InitializeComponent(); diff --git a/src/LogExpert.UI/Dialogs/FilterColumnChooser.cs b/src/LogExpert.UI/Dialogs/FilterColumnChooser.cs index 812dc786..eb99587b 100644 --- a/src/LogExpert.UI/Dialogs/FilterColumnChooser.cs +++ b/src/LogExpert.UI/Dialogs/FilterColumnChooser.cs @@ -16,6 +16,7 @@ public partial class FilterColumnChooser : Form #region cTor + //TODO: add Suspend and ResumeLayout() public FilterColumnChooser(FilterParams filterParams) { InitializeComponent(); From c2e56fc62a2e775e5b3441155208f51fa88e68d0 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Tue, 27 May 2025 09:00:48 +0200 Subject: [PATCH 033/142] editor config --- src/.editorconfig | 266 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 266 insertions(+) create mode 100644 src/.editorconfig diff --git a/src/.editorconfig b/src/.editorconfig new file mode 100644 index 00000000..4e783e12 --- /dev/null +++ b/src/.editorconfig @@ -0,0 +1,266 @@ +# Remove the line below if you want to inherit .editorconfig settings from higher directories +root = true + +# C# files +[*.cs] + +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +indent_style = space +tab_width = 4 + +# New line preferences +end_of_line = crlf +insert_final_newline = false + +#### .NET Code Actions #### + +# Type members +dotnet_hide_advanced_members = false +dotnet_member_insertion_location = with_other_members_of_the_same_kind +dotnet_property_generation_behavior = prefer_auto_properties + +# Symbol search +dotnet_search_reference_assemblies = true + +#### .NET Coding Conventions #### + +# Organize usings +dotnet_separate_import_directive_groups = true +dotnet_sort_system_directives_first = false +file_header_template = unset + +# this. and Me. preferences +dotnet_style_qualification_for_event = false +dotnet_style_qualification_for_field = false +dotnet_style_qualification_for_method = false +dotnet_style_qualification_for_property = false + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning +dotnet_style_parentheses_in_other_operators = never_if_unnecessary +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members + +# Expression-level preferences +dotnet_prefer_system_hash_code = true +dotnet_style_coalesce_expression = true +dotnet_style_collection_initializer = true +dotnet_style_explicit_tuple_names = true:warning +dotnet_style_namespace_match_folder = true +dotnet_style_null_propagation = true +dotnet_style_object_initializer = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true:warning +dotnet_style_prefer_collection_expression = when_types_loosely_match +dotnet_style_prefer_compound_assignment = true +dotnet_style_prefer_conditional_expression_over_assignment = true +dotnet_style_prefer_conditional_expression_over_return = true +dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed +dotnet_style_prefer_inferred_anonymous_type_member_names = true +dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_simplified_boolean_expressions = true:warning +dotnet_style_prefer_simplified_interpolation = true + +# Field preferences +dotnet_style_readonly_field = true + +# Parameter preferences +dotnet_code_quality_unused_parameters = all + +# Suppression preferences +dotnet_remove_unnecessary_suppression_exclusions = none + +# New line preferences +dotnet_style_allow_multiple_blank_lines_experimental = false:suggestion +dotnet_style_allow_statement_immediately_after_block_experimental = false:warning + +#### C# Coding Conventions #### + +# var preferences +csharp_style_var_elsewhere = false:suggestion +csharp_style_var_for_built_in_types = false:suggestion +csharp_style_var_when_type_is_apparent = true:suggestion + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = false:warning +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true +csharp_style_pattern_matching_over_is_with_cast_check = true +csharp_style_prefer_extended_property_pattern = true +csharp_style_prefer_not_pattern = true +csharp_style_prefer_pattern_matching = true:suggestion +csharp_style_prefer_switch_expression = true + +# Null-checking preferences +csharp_style_conditional_delegate_call = true + +# Modifier preferences +csharp_prefer_static_anonymous_function = true +csharp_prefer_static_local_function = true +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async +csharp_style_prefer_readonly_struct = true +csharp_style_prefer_readonly_struct_member = true + +# Code-block preferences +csharp_prefer_braces = true:warning +csharp_prefer_simple_using_statement = true:suggestion +csharp_prefer_system_threading_lock = true:suggestion +csharp_style_namespace_declarations = block_scoped:silent +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_primary_constructors = true:suggestion +csharp_style_prefer_top_level_statements = true:silent + +# Expression-level preferences +csharp_prefer_simple_default_expression = true +csharp_style_deconstructed_variable_declaration = true +csharp_style_implicit_object_creation_when_type_is_apparent = true +csharp_style_inlined_variable_declaration = true +csharp_style_prefer_index_operator = true:warning +csharp_style_prefer_local_over_anonymous_function = true:warning +csharp_style_prefer_null_check_over_type_check = true +csharp_style_prefer_range_operator = true:warning +csharp_style_prefer_tuple_swap = true +csharp_style_prefer_utf8_string_literals = true +csharp_style_throw_expression = true +csharp_style_unused_value_assignment_preference = discard_variable +csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion + +# 'using' directive preferences +csharp_using_directive_placement = outside_namespace:silent + +# New line preferences +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false:warning +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:suggestion +csharp_style_allow_embedded_statements_on_same_line_experimental = false:suggestion + +#### C# Formatting Rules #### + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = true +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = false + +#### Naming styles #### + +# Naming rules + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Symbol specifications + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case +dotnet_diagnostic.CA1507.severity = warning + +[*.{cs,vb}] +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +indent_size = 4 +end_of_line = crlf +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_auto_properties = true:warning +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:warning +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +dotnet_diagnostic.CA1510.severity = warning +dotnet_diagnostic.CA1511.severity = warning +dotnet_diagnostic.CA1512.severity = warning +dotnet_diagnostic.CA1513.severity = warning +dotnet_diagnostic.CA1842.severity = warning +dotnet_diagnostic.CA1843.severity = warning \ No newline at end of file From b07c982e8f2b48564e086a9a2e011a4e2e5a02d5 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Tue, 27 May 2025 11:21:12 +0200 Subject: [PATCH 034/142] editor config update --- src/.editorconfig | 4732 ++++++++++++++++++++++++++++++++++++++++++++- src/LogExpert.sln | 1 + 2 files changed, 4660 insertions(+), 73 deletions(-) diff --git a/src/.editorconfig b/src/.editorconfig index 4e783e12..32adb03c 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -10,6 +10,7 @@ root = true indent_size = 4 indent_style = space tab_width = 4 +charset = utf-8 # New line preferences end_of_line = crlf @@ -29,7 +30,7 @@ dotnet_search_reference_assemblies = true # Organize usings dotnet_separate_import_directive_groups = true -dotnet_sort_system_directives_first = false +dotnet_sort_system_directives_first = true file_header_template = unset # this. and Me. preferences @@ -39,120 +40,121 @@ dotnet_style_qualification_for_method = false dotnet_style_qualification_for_property = false # Language keywords vs BCL types preferences -dotnet_style_predefined_type_for_locals_parameters_members = true -dotnet_style_predefined_type_for_member_access = true +dotnet_style_predefined_type_for_locals_parameters_members = true:warning +dotnet_style_predefined_type_for_member_access = true:warning # Parentheses preferences dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning -dotnet_style_parentheses_in_other_operators = never_if_unnecessary +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:warning dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning # Modifier preferences -dotnet_style_require_accessibility_modifiers = for_non_interface_members +dotnet_style_require_accessibility_modifiers = always:warning # Expression-level preferences dotnet_prefer_system_hash_code = true -dotnet_style_coalesce_expression = true -dotnet_style_collection_initializer = true +dotnet_style_coalesce_expression = true:warning +dotnet_style_collection_initializer = true:warning dotnet_style_explicit_tuple_names = true:warning -dotnet_style_namespace_match_folder = true -dotnet_style_null_propagation = true -dotnet_style_object_initializer = true -dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_namespace_match_folder = true:warning +dotnet_style_null_propagation = true:warning +dotnet_style_object_initializer = true:warning +dotnet_style_operator_placement_when_wrapping = beginning_of_line:warning dotnet_style_prefer_auto_properties = true:warning dotnet_style_prefer_collection_expression = when_types_loosely_match -dotnet_style_prefer_compound_assignment = true -dotnet_style_prefer_conditional_expression_over_assignment = true -dotnet_style_prefer_conditional_expression_over_return = true +dotnet_style_prefer_compound_assignment = true:warning +dotnet_style_prefer_conditional_expression_over_assignment = true:warning +dotnet_style_prefer_conditional_expression_over_return = true:warning dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed dotnet_style_prefer_inferred_anonymous_type_member_names = true dotnet_style_prefer_inferred_tuple_names = true -dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning dotnet_style_prefer_simplified_boolean_expressions = true:warning -dotnet_style_prefer_simplified_interpolation = true +dotnet_style_prefer_simplified_interpolation = true:warning # Field preferences -dotnet_style_readonly_field = true +dotnet_style_readonly_field = true:warning # Parameter preferences -dotnet_code_quality_unused_parameters = all +dotnet_code_quality_unused_parameters = all:warning # Suppression preferences dotnet_remove_unnecessary_suppression_exclusions = none # New line preferences -dotnet_style_allow_multiple_blank_lines_experimental = false:suggestion +dotnet_style_allow_multiple_blank_lines_experimental = false:warning dotnet_style_allow_statement_immediately_after_block_experimental = false:warning #### C# Coding Conventions #### # var preferences csharp_style_var_elsewhere = false:suggestion -csharp_style_var_for_built_in_types = false:suggestion -csharp_style_var_when_type_is_apparent = true:suggestion +csharp_style_var_for_built_in_types = true:warning +csharp_style_var_when_type_is_apparent = true:warning # Expression-bodied members -csharp_style_expression_bodied_accessors = true:silent -csharp_style_expression_bodied_constructors = false:silent -csharp_style_expression_bodied_indexers = true:silent -csharp_style_expression_bodied_lambdas = true:silent -csharp_style_expression_bodied_local_functions = false:warning -csharp_style_expression_bodied_methods = false:silent -csharp_style_expression_bodied_operators = false:silent -csharp_style_expression_bodied_properties = true:silent +csharp_style_expression_bodied_accessors = true:suggestion +csharp_style_expression_bodied_constructors = true:suggestion +csharp_style_expression_bodied_indexers = true:suggestion +csharp_style_expression_bodied_lambdas = true:suggestion +csharp_style_expression_bodied_local_functions = true:suggestion +csharp_style_expression_bodied_methods = true:suggestion +csharp_style_expression_bodied_operators = true:suggestion +csharp_style_expression_bodied_properties = true:suggestion # Pattern matching preferences -csharp_style_pattern_matching_over_as_with_null_check = true -csharp_style_pattern_matching_over_is_with_cast_check = true -csharp_style_prefer_extended_property_pattern = true -csharp_style_prefer_not_pattern = true -csharp_style_prefer_pattern_matching = true:suggestion -csharp_style_prefer_switch_expression = true +csharp_style_pattern_matching_over_as_with_null_check = true:warning +csharp_style_pattern_matching_over_is_with_cast_check = true:warning +csharp_style_prefer_extended_property_pattern = true:warning +csharp_style_prefer_not_pattern = true:warning +csharp_style_prefer_pattern_matching = true:warning +csharp_style_prefer_switch_expression = true:warning # Null-checking preferences -csharp_style_conditional_delegate_call = true +csharp_style_conditional_delegate_call = true:warning +csharp_style_prefer_parameter_null_checking = true:suggestion # Modifier preferences csharp_prefer_static_anonymous_function = true -csharp_prefer_static_local_function = true -csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async +csharp_prefer_static_local_function = true:warning csharp_style_prefer_readonly_struct = true csharp_style_prefer_readonly_struct_member = true +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async # Code-block preferences csharp_prefer_braces = true:warning -csharp_prefer_simple_using_statement = true:suggestion csharp_prefer_system_threading_lock = true:suggestion -csharp_style_namespace_declarations = block_scoped:silent -csharp_style_prefer_method_group_conversion = true:silent +csharp_prefer_simple_using_statement = true:warning +csharp_style_namespace_declarations = file_scoped:warning +csharp_style_prefer_method_group_conversion = true:warning csharp_style_prefer_primary_constructors = true:suggestion csharp_style_prefer_top_level_statements = true:silent # Expression-level preferences -csharp_prefer_simple_default_expression = true -csharp_style_deconstructed_variable_declaration = true -csharp_style_implicit_object_creation_when_type_is_apparent = true -csharp_style_inlined_variable_declaration = true -csharp_style_prefer_index_operator = true:warning +csharp_prefer_simple_default_expression = true:warning +csharp_style_deconstructed_variable_declaration = true:warning +csharp_style_implicit_object_creation_when_type_is_apparent = true:warning +csharp_style_inlined_variable_declaration = true:warning csharp_style_prefer_local_over_anonymous_function = true:warning -csharp_style_prefer_null_check_over_type_check = true +csharp_style_prefer_index_operator = true:warning +csharp_style_prefer_null_check_over_type_check = true:warning csharp_style_prefer_range_operator = true:warning -csharp_style_prefer_tuple_swap = true csharp_style_prefer_utf8_string_literals = true -csharp_style_throw_expression = true -csharp_style_unused_value_assignment_preference = discard_variable -csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion +csharp_style_prefer_tuple_swap = true:warning +csharp_style_throw_expression = true:warning +csharp_style_unused_value_assignment_preference = discard_variable:warning +csharp_style_unused_value_expression_statement_preference = discard_variable:warning # 'using' directive preferences -csharp_using_directive_placement = outside_namespace:silent +csharp_using_directive_placement = outside_namespace:warning # New line preferences -csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:warning csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false:warning -csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:suggestion -csharp_style_allow_embedded_statements_on_same_line_experimental = false:suggestion +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:warning +csharp_style_allow_embedded_statements_on_same_line_experimental = false:warning #### C# Formatting Rules #### @@ -205,15 +207,15 @@ csharp_preserve_single_line_statements = false # Naming rules -dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.severity = warning dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i -dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.severity = warning dotnet_naming_rule.types_should_be_pascal_case.symbols = types dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case -dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = warning dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case @@ -242,25 +244,4609 @@ dotnet_naming_style.begins_with_i.required_prefix = I dotnet_naming_style.begins_with_i.required_suffix = dotnet_naming_style.begins_with_i.word_separator = dotnet_naming_style.begins_with_i.capitalization = pascal_case + +#### Analyzers Rules #### + +## Microsoft.CodeAnalysis.CSharp.CodeStyle + +# IDE0001: Simplify name +dotnet_diagnostic.IDE0001.severity = warning + +# IDE0002: Simplify member access +dotnet_diagnostic.IDE0002.severity = warning + +# IDE0003: Remove this or Me qualification +dotnet_diagnostic.IDE0003.severity = warning + +# IDE0004: Remove unnecessary cast +dotnet_diagnostic.IDE0004.severity = warning + +# IDE0005: Remove unnecessary import +dotnet_diagnostic.IDE0005.severity = warning + +# IDE0005_gen: Remove unnecessary import (NotConfigurable) +#dotnet_diagnostic.IDE0005_gen.severity = silent + +# IDE0007: Use implicit type +dotnet_diagnostic.IDE0007.severity = warning + +# IDE0008: Use explicit type instead of 'var' +dotnet_diagnostic.IDE0008.severity = warning + +# IDE0009: Add this or Me qualification +dotnet_diagnostic.IDE0009.severity = warning + +# IDE0010: Add missing cases to switch statement +dotnet_diagnostic.IDE0010.severity = warning + +# IDE0011: Add braces +dotnet_diagnostic.IDE0011.severity = warning + +# IDE0016: Use throw expression +dotnet_diagnostic.IDE0016.severity = warning + +# IDE0017: Use object initializers +dotnet_diagnostic.IDE0017.severity = warning + +# IDE0018: Inline variable declaration +dotnet_diagnostic.IDE0018.severity = warning + +# IDE0019: Use pattern matching to avoid 'as' followed by a 'null' check +dotnet_diagnostic.IDE0019.severity = warning + +# IDE0020: Use pattern matching to avoid 'is' check followed by a cast (with variable) +dotnet_diagnostic.IDE0020.severity = warning + +# IDE0021: Use expression body for constructors +dotnet_diagnostic.IDE0021.severity = suggestion + +# IDE0022: Use expression body for methods +dotnet_diagnostic.IDE0022.severity = suggestion + +# IDE0023: Use expression body for conversion operators +dotnet_diagnostic.IDE0023.severity = suggestion + +# IDE0024: Use expression body for operators +dotnet_diagnostic.IDE0024.severity = suggestion + +# IDE0025: Use expression body for properties +dotnet_diagnostic.IDE0025.severity = suggestion + +# IDE0026: Use expression body for indexers +dotnet_diagnostic.IDE0026.severity = suggestion + +# IDE0027: Use expression body for accessors +dotnet_diagnostic.IDE0027.severity = suggestion + +# IDE0028: Use collection initializers +dotnet_diagnostic.IDE0028.severity = warning + +# IDE0029: Use coalesce expression (non-nullable types) +dotnet_diagnostic.IDE0029.severity = warning + +# IDE0030: Use coalesce expression (nullable types) +dotnet_diagnostic.IDE0030.severity = warning + +# IDE0031: Use null propagation +dotnet_diagnostic.IDE0031.severity = warning + +# IDE0032: Use auto property +dotnet_diagnostic.IDE0032.severity = warning + +# IDE0033: Use explicitly provided tuple name +dotnet_diagnostic.IDE0033.severity = warning + +# IDE0034: Simplify default expression +dotnet_diagnostic.IDE0034.severity = warning + +# IDE0035: Remove unreachable code +dotnet_diagnostic.IDE0035.severity = warning + +# IDE0036: Order modifiers +dotnet_diagnostic.IDE0036.severity = warning + +# IDE0037: Use inferred member name +dotnet_diagnostic.IDE0037.severity = warning + +# IDE0038: Use pattern matching to avoid 'is' check followed by a cast (without variable) +dotnet_diagnostic.IDE0038.severity = warning + +# IDE0039: Use local function instead of lambda +dotnet_diagnostic.IDE0039.severity = warning + +# IDE0040: Add accessibility modifiers +dotnet_diagnostic.IDE0040.severity = warning + +# IDE0041: Use 'is null' check +dotnet_diagnostic.IDE0041.severity = warning + +# IDE0042: Deconstruct variable declaration +dotnet_diagnostic.IDE0042.severity = warning + +# IDE0043: Invalid format string +dotnet_diagnostic.IDE0043.severity = warning + +# IDE0044: Add readonly modifier +dotnet_diagnostic.IDE0044.severity = warning + +# IDE0045: Use conditional expression for assignment +dotnet_diagnostic.IDE0045.severity = warning + +# IDE0046: Use conditional expression for return +dotnet_diagnostic.IDE0046.severity = warning + +# IDE0047: Remove unnecessary parentheses +dotnet_diagnostic.IDE0047.severity = warning + +# IDE0048: Add parentheses for clarity +dotnet_diagnostic.IDE0048.severity = warning + +# IDE0049: Use language keywords instead of framework type names for type references +dotnet_diagnostic.IDE0049.severity = warning + +# IDE0050: Convert anonymous type to tuple +dotnet_diagnostic.IDE0050.severity = warning + +# IDE0051: Remove unused private member +dotnet_diagnostic.IDE0051.severity = warning + +# IDE0052: Remove unused private member +dotnet_diagnostic.IDE0052.severity = warning + +# IDE0053: Use expression body for lambdas +dotnet_diagnostic.IDE0053.severity = suggestion + +# IDE0054: Use compound assignment +dotnet_diagnostic.IDE0054.severity = warning + +# IDE0055: Fix formatting +dotnet_diagnostic.IDE0055.severity = warning + +# IDE0056: Use index operator +dotnet_diagnostic.IDE0056.severity = warning + +# IDE0057: Use range operator +dotnet_diagnostic.IDE0057.severity = warning + +# IDE0058: Remove unnecessary expression value +dotnet_diagnostic.IDE0058.severity = warning + +# IDE0059: Remove unnecessary value assignment +dotnet_diagnostic.IDE0059.severity = warning + +# IDE0060: Remove unused parameter +dotnet_diagnostic.IDE0060.severity = warning + +# IDE0061: Use expression body for local functions +dotnet_diagnostic.IDE0061.severity = suggestion + +# IDE0062: Make local function static +dotnet_diagnostic.IDE0062.severity = warning + +# IDE0063: Use simple using statement +dotnet_diagnostic.IDE0063.severity = warning + +# IDE0064: Make struct fields writable +dotnet_diagnostic.IDE0064.severity = warning + +# IDE0065: using directive placement +dotnet_diagnostic.IDE0065.severity = warning + +# IDE0066: Use switch expression +dotnet_diagnostic.IDE0066.severity = warning + +# IDE0070: Use 'System.HashCode' +dotnet_diagnostic.IDE0070.severity = warning + +# IDE0071: Simplify interpolation +dotnet_diagnostic.IDE0071.severity = warning + +# IDE0072: Add missing cases to switch expression +dotnet_diagnostic.IDE0072.severity = warning + +# IDE0073: Require file header +dotnet_diagnostic.IDE0073.severity = warning + +# IDE0074: Use coalesce compound assignment +dotnet_diagnostic.IDE0074.severity = warning + +# IDE0075: Simplify conditional expression +dotnet_diagnostic.IDE0075.severity = warning + +# IDE0076: Remove invalid global 'SuppressMessageAttribute' +dotnet_diagnostic.IDE0076.severity = warning + +# IDE0077: Avoid legacy format target in global 'SuppressMessageAttribute' +dotnet_diagnostic.IDE0077.severity = warning + +# IDE0078: Use pattern matching +dotnet_diagnostic.IDE0078.severity = warning + +# IDE0079: Remove unnecessary suppression +dotnet_diagnostic.IDE0079.severity = warning + +# IDE0080: Remove unnecessary suppression operator +dotnet_diagnostic.IDE0080.severity = warning + +# IDE0081: Remove 'ByVal' +dotnet_diagnostic.IDE0081.severity = warning + +# IDE0082: Convert 'typeof' to 'nameof' +dotnet_diagnostic.IDE0082.severity = warning + +# IDE0083: Use pattern matching ('not' operator) +dotnet_diagnostic.IDE0083.severity = warning + +# IDE0084: Use pattern matching ('IsNot' operator) +dotnet_diagnostic.IDE0084.severity = warning + +# IDE0090: Simplify new expression +dotnet_diagnostic.IDE0090.severity = warning + +# IDE0100: Remove unnecessary equality operator +dotnet_diagnostic.IDE0100.severity = warning + +# IDE0110: Remove unnecessary discard +dotnet_diagnostic.IDE0110.severity = warning + +# IDE0120: Simplify LINQ expression +dotnet_diagnostic.IDE0120.severity = warning + +# IDE0130: Namespace does not match folder structure +dotnet_diagnostic.IDE0130.severity = warning + +# IDE0140: Simplify object creation +dotnet_diagnostic.IDE0140.severity = warning + +# IDE0150: Prefer 'null' check over type check +dotnet_diagnostic.IDE0150.severity = warning + +# IDE0160: Convert to block scoped namespace +dotnet_diagnostic.IDE0160.severity = none + +# IDE0161: Convert to file-scoped namespace +dotnet_diagnostic.IDE0161.severity = warning + +# IDE0170: Property pattern can be simplified +dotnet_diagnostic.IDE0170.severity = warning + +# IDE0180: Use tuple to swap values +dotnet_diagnostic.IDE0180.severity = warning + +# IDE0190: Null check can be simplified +dotnet_diagnostic.IDE0190.severity = warning + +# IDE0200: Remove unnecessary lambda expression +dotnet_diagnostic.IDE0200.severity = warning + +# IDE1005: Use conditional delegate call +dotnet_diagnostic.IDE1005.severity = warning + +# IDE1006: Naming Styles +dotnet_diagnostic.IDE1006.severity = warning + +# IDE2000: Avoid multiple blank lines +dotnet_diagnostic.IDE2000.severity = warning + +# IDE2001: Embedded statements must be on their own line +dotnet_diagnostic.IDE2001.severity = warning + +# IDE2002: Consecutive braces must not have blank line between them +dotnet_diagnostic.IDE2002.severity = warning + +# IDE2003: Blank line required between block and subsequent statement +dotnet_diagnostic.IDE2003.severity = warning + +# IDE2004: Blank line not allowed after constructor initializer colon +dotnet_diagnostic.IDE2004.severity = warning + +# RemoveUnnecessaryImportsFixable: Remove unnecessary imports fixable (NotConfigurable) +#dotnet_diagnostic.RemoveUnnecessaryImportsFixable.severity = silent + +## Microsoft.CodeAnalysis.CSharp.NetAnalyzers + +# CA1000: Do not declare static members on generic types +dotnet_diagnostic.CA1000.severity = warning +dotnet_code_quality.CA1000.api_surface = all + +# CA1001: Types that own disposable fields should be disposable +dotnet_diagnostic.CA1001.severity = warning +dotnet_code_quality.CA1001.excluded_symbol_names = +dotnet_code_quality.CA1001.excluded_type_names_with_derived_types = + +# CA1002: Do not expose generic lists +dotnet_diagnostic.CA1002.severity = warning +dotnet_code_quality.CA1002.api_surface = all + +# CA1003: Use generic event handler instances +dotnet_diagnostic.CA1003.severity = warning +dotnet_code_quality.CA1003.api_surface = all + +# CA1005: Avoid excessive parameters on generic types +dotnet_diagnostic.CA1005.severity = suggestion +dotnet_code_quality.CA1005.api_surface = all + +# CA1008: Enums should have zero value +dotnet_diagnostic.CA1008.severity = warning +dotnet_code_quality.CA1008.api_surface = all + +# CA1010: Generic interface should also be implemented +dotnet_diagnostic.CA1010.severity = warning +dotnet_code_quality.CA1010.api_surface = all +dotnet_code_quality.CA1010.additional_required_generic_interfaces = + +# CA1012: Abstract types should not have public constructors +dotnet_diagnostic.CA1012.severity = warning +dotnet_code_quality.CA1012.api_surface = all + +# CA1014: Mark assemblies with CLSCompliant +dotnet_diagnostic.CA1014.severity = warning + +# CA1016: Mark assemblies with assembly version +dotnet_diagnostic.CA1016.severity = warning + +# CA1017: Mark assemblies with ComVisible +dotnet_diagnostic.CA1017.severity = warning + +# CA1018: Mark attributes with AttributeUsageAttribute +dotnet_diagnostic.CA1018.severity = warning + +# CA1019: Define accessors for attribute arguments +dotnet_diagnostic.CA1019.severity = warning + +# CA1021: Avoid out parameters +dotnet_diagnostic.CA1021.severity = suggestion +dotnet_code_quality.CA1021.api_surface = all + +# CA1024: Use properties where appropriate +dotnet_diagnostic.CA1024.severity = suggestion +dotnet_code_quality.CA1024.api_surface = all + +# CA1027: Mark enums with FlagsAttribute +dotnet_diagnostic.CA1027.severity = suggestion +dotnet_code_quality.CA1027.api_surface = all + +# CA1028: Enum Storage should be Int32 +dotnet_diagnostic.CA1028.severity = warning +dotnet_code_quality.CA1028.api_surface = all + +# CA1030: Use events where appropriate +dotnet_diagnostic.CA1030.severity = suggestion +dotnet_code_quality.CA1030.api_surface = all + +# CA1031: Do not catch general exception types +dotnet_diagnostic.CA1031.severity = warning +dotnet_code_quality.CA1031.disallowed_symbol_names = + +# CA1032: Implement standard exception constructors +dotnet_diagnostic.CA1032.severity = warning + +# CA1033: Interface methods should be callable by child types +dotnet_diagnostic.CA1033.severity = warning + +# CA1034: Nested types should not be visible +dotnet_diagnostic.CA1034.severity = warning + +# CA1036: Override methods on comparable types +dotnet_diagnostic.CA1036.severity = warning +dotnet_code_quality.CA1036.api_surface = all + +# CA1040: Avoid empty interfaces +dotnet_diagnostic.CA1040.severity = suggestion +dotnet_code_quality.CA1040.api_surface = all + +# CA1041: Provide ObsoleteAttribute message +dotnet_diagnostic.CA1041.severity = warning +dotnet_code_quality.CA1041.api_surface = all + +# CA1043: Use Integral Or String Argument For Indexers +dotnet_diagnostic.CA1043.severity = warning +dotnet_code_quality.CA1043.api_surface = all + +# CA1044: Properties should not be write only +dotnet_diagnostic.CA1044.severity = warning +dotnet_code_quality.CA1044.api_surface = all + +# CA1045: Do not pass types by reference +dotnet_diagnostic.CA1045.severity = suggestion +dotnet_code_quality.CA1045.api_surface = all + +# CA1046: Do not overload equality operator on reference types +dotnet_diagnostic.CA1046.severity = warning +dotnet_code_quality.CA1046.api_surface = all + +# CA1047: Do not declare protected member in sealed type +dotnet_diagnostic.CA1047.severity = warning +dotnet_code_quality.CA1047.api_surface = all + +# CA1050: Declare types in namespaces +dotnet_diagnostic.CA1050.severity = warning + +# CA1051: Do not declare visible instance fields +dotnet_diagnostic.CA1051.severity = warning +dotnet_code_quality.CA1051.api_surface = all +dotnet_code_quality.CA1051.exclude_structs = false + +# CA1052: Static holder types should be Static or NotInheritable +dotnet_diagnostic.CA1052.severity = warning +dotnet_code_quality.CA1052.api_surface = all + +# CA1053: Static holder types should not have default constructors +dotnet_diagnostic.CA1053.severity = warning +dotnet_code_quality.CA1053.api_surface = all + +# CA1054: URI-like parameters should not be strings +dotnet_diagnostic.CA1054.severity = warning +dotnet_code_quality.CA1054.api_surface = all + +# CA1055: URI-like return values should not be strings +dotnet_diagnostic.CA1055.severity = warning +dotnet_code_quality.CA1055.api_surface = all + +# CA1056: URI-like properties should not be strings +dotnet_diagnostic.CA1056.severity = warning +dotnet_code_quality.CA1056.api_surface = all + +# CA1058: Types should not extend certain base types +dotnet_diagnostic.CA1058.severity = warning +dotnet_code_quality.CA1058.api_surface = all + +# CA1060: Move pinvokes to native methods class +dotnet_diagnostic.CA1060.severity = warning + +# CA1061: Do not hide base class methods +dotnet_diagnostic.CA1061.severity = warning + +# CA1062: Validate arguments of public methods +dotnet_diagnostic.CA1062.severity = warning +dotnet_code_quality.CA1062.excluded_symbol_names = +dotnet_code_quality.CA1062.excluded_type_names_with_derived_types = +dotnet_code_quality.CA1062.exclude_extension_method_this_parameter = false +dotnet_code_quality.CA1062.null_check_validation_methods = + +# CA1063: Implement IDisposable Correctly +dotnet_diagnostic.CA1063.severity = warning +dotnet_code_quality.CA1063.api_surface = all + +# CA1064: Exceptions should be public +dotnet_diagnostic.CA1064.severity = warning + +# CA1065: Do not raise exceptions in unexpected locations +dotnet_diagnostic.CA1065.severity = warning + +# CA1066: Implement IEquatable when overriding Object.Equals +dotnet_diagnostic.CA1066.severity = warning + +# CA1067: Override Object.Equals(object) when implementing IEquatable +dotnet_diagnostic.CA1067.severity = warning + +# CA1068: CancellationToken parameters must come last +dotnet_diagnostic.CA1068.severity = warning +dotnet_code_quality.CA1068.api_surface = all +dotnet_code_quality.CA1068.excluded_symbol_names = +dotnet_code_quality.CA1068.excluded_type_names_with_derived_types = + +# CA1069: Enums values should not be duplicated +dotnet_diagnostic.CA1069.severity = warning + +# CA1070: Do not declare event fields as virtual +dotnet_diagnostic.CA1070.severity = warning +dotnet_code_quality.CA1070.api_surface = all + +# CA1200: Avoid using cref tags with a prefix +dotnet_diagnostic.CA1200.severity = warning + +# CA1303: Do not pass literals as localized parameters +dotnet_diagnostic.CA1303.severity = warning +dotnet_code_quality.CA1303.excluded_symbol_names = +dotnet_code_quality.CA1303.excluded_type_names_with_derived_types = +dotnet_code_quality.CA1303.use_naming_heuristic = true + +# CA1304: Specify CultureInfo +dotnet_diagnostic.CA1304.severity = warning +dotnet_code_quality.CA1304.excluded_symbol_names = +dotnet_code_quality.CA1304.excluded_type_names_with_derived_types = + +# CA1305: Specify IFormatProvider +dotnet_diagnostic.CA1305.severity = warning + +# CA1307: Specify StringComparison for clarity +dotnet_diagnostic.CA1307.severity = warning + +# CA1308: Normalize strings to uppercase +dotnet_diagnostic.CA1308.severity = warning + +# CA1309: Use ordinal string comparison +dotnet_diagnostic.CA1309.severity = warning + +# CA1310: Specify StringComparison for correctness +dotnet_diagnostic.CA1310.severity = warning + +# CA1401: P/Invokes should not be visible +dotnet_diagnostic.CA1401.severity = warning + +# CA1416: Validate platform compatibility +dotnet_diagnostic.CA1416.severity = warning +dotnet_code_quality.CA1416.enable_platform_analyzer_on_pre_net5_target = true + +# CA1417: Do not use 'OutAttribute' on string parameters for P/Invokes +dotnet_diagnostic.CA1417.severity = warning + +# CA1418: Use valid platform string +dotnet_diagnostic.CA1418.severity = warning + +# CA1419: Provide a parameterless constructor that is as visible as the containing type for concrete types derived from 'System.Runtime.InteropServices.SafeHandle' +dotnet_diagnostic.CA1419.severity = warning + +# CA1501: Avoid excessive inheritance +dotnet_diagnostic.CA1501.severity = suggestion +dotnet_code_quality.CA1501.additional_inheritance_excluded_symbol_names = + +# CA1502: Avoid excessive complexity +dotnet_diagnostic.CA1502.severity = suggestion + +# CA1505: Avoid unmaintainable code +dotnet_diagnostic.CA1505.severity = suggestion + +# CA1506: Avoid excessive class coupling +dotnet_diagnostic.CA1506.severity = suggestion + +# CA1507: Use nameof to express symbol names dotnet_diagnostic.CA1507.severity = warning -[*.{cs,vb}] -dotnet_style_operator_placement_when_wrapping = beginning_of_line -tab_width = 4 -indent_size = 4 -end_of_line = crlf -dotnet_style_coalesce_expression = true:suggestion -dotnet_style_null_propagation = true:suggestion -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion -dotnet_style_prefer_auto_properties = true:warning -dotnet_style_object_initializer = true:suggestion -dotnet_style_collection_initializer = true:suggestion -dotnet_style_prefer_simplified_boolean_expressions = true:warning -dotnet_style_prefer_conditional_expression_over_assignment = true:silent -dotnet_style_prefer_conditional_expression_over_return = true:silent +# CA1508: Avoid dead conditional code +dotnet_diagnostic.CA1508.severity = warning +dotnet_code_quality.CA1508.excluded_symbol_names = +dotnet_code_quality.CA1508.excluded_type_names_with_derived_types = + +# CA1509: Invalid entry in code metrics rule specification file +dotnet_diagnostic.CA1509.severity = warning + +# CA1510: Use ArgumentNullException throw helper dotnet_diagnostic.CA1510.severity = warning + +# CA1511: Use ArgumentException throw helper dotnet_diagnostic.CA1511.severity = warning + +# CA1512: Use ArgumentOutOfRangeException throw helper dotnet_diagnostic.CA1512.severity = warning + +# CA1513: Use ObjectDisposedException throw helper dotnet_diagnostic.CA1513.severity = warning + +# CA1514: Avoid redundant length argument +dotnet_diagnostic.CA1514.severity = warning + +# CA1515: Consider making public types internal +dotnet_diagnostic.CA1515.severity = none + +# CA1700: Do not name enum values 'Reserved' +dotnet_diagnostic.CA1700.severity = warning +dotnet_code_quality.CA1700.api_surface = all + +# CA1707: Identifiers should not contain underscores +dotnet_diagnostic.CA1707.severity = none +# dotnet_code_quality.CA1707.api_surface = all + +# CA1708: Identifiers should differ by more than case +dotnet_diagnostic.CA1708.severity = warning +dotnet_code_quality.CA1708.api_surface = all + +# CA1710: Identifiers should have correct suffix +dotnet_diagnostic.CA1710.severity = warning +dotnet_code_quality.CA1710.api_surface = all +dotnet_code_quality.CA1710.exclude_indirect_base_types = false +dotnet_code_quality.CA1710.additional_required_suffixes = T:System.Collections.Generic.IReadOnlyList`1->List|T:System.Collections.Generic.IList`1->List|T:System.Collections.Generic.IReadOnlySet`1->Set|T:System.Collections.Generic.ISet`1->Set|T:System.Collections.Generic.IReadOnlyCollection`1->Collection + +# CA1711: Identifiers should not have incorrect suffix +dotnet_diagnostic.CA1711.severity = warning +dotnet_code_quality.CA1711.api_surface = all +dotnet_code_quality.CA1711.allowed_suffixes = + +# CA1712: Do not prefix enum values with type name +dotnet_diagnostic.CA1712.severity = warning +dotnet_code_quality.CA1712.enum_values_prefix_trigger = AnyEnumValue + +# CA1713: Events should not have 'Before' or 'After' prefix +dotnet_diagnostic.CA1713.severity = warning + +# CA1714: Flags enums should have plural names +dotnet_diagnostic.CA1714.severity = warning +dotnet_code_quality.CA1714.api_surface = all + +# CA1715: Identifiers should have correct prefix +dotnet_diagnostic.CA1715.severity = warning +dotnet_code_quality.CA1715.api_surface = all +dotnet_code_quality.CA1715.exclude_single_letter_type_parameters = false + +# CA1716: Identifiers should not match keywords +dotnet_diagnostic.CA1716.severity = warning +dotnet_code_quality.CA1716.api_surface = all +dotnet_code_quality.CA1716.analyzed_symbol_kinds = Namespace, NamedType, Method, Property, Event, Parameter + +# CA1717: Only FlagsAttribute enums should have plural names +dotnet_diagnostic.CA1717.severity = warning +dotnet_code_quality.CA1717.api_surface = all + +# CA1720: Identifier contains type name +dotnet_diagnostic.CA1720.severity = warning +dotnet_code_quality.CA1720.api_surface = all + +# CA1721: Property names should not match get methods +dotnet_diagnostic.CA1721.severity = warning +dotnet_code_quality.CA1721.api_surface = all + +# CA1724: Type names should not match namespaces +dotnet_diagnostic.CA1724.severity = warning + +# CA1725: Parameter names should match base declaration +dotnet_diagnostic.CA1725.severity = warning +dotnet_code_quality.CA1725.api_surface = all + +# CA1727: Use PascalCase for named placeholders +dotnet_diagnostic.CA1727.severity = warning + +# CA1801: Review unused parameters +dotnet_diagnostic.CA1801.severity = warning +dotnet_code_quality.CA1801.api_surface = all + +# CA1802: Use literals where appropriate +dotnet_diagnostic.CA1802.severity = warning +dotnet_code_quality.CA1802.api_surface = all +dotnet_code_quality.CA1802.required_modifiers = none + +# CA1805: Do not initialize unnecessarily +dotnet_diagnostic.CA1805.severity = warning + +# CA1806: Do not ignore method results +dotnet_diagnostic.CA1806.severity = warning +dotnet_code_quality.CA1806.additional_use_results_methods = + +# CA1810: Initialize reference type static fields inline +dotnet_diagnostic.CA1810.severity = warning + +# CA1812: Avoid uninstantiated internal classes +dotnet_diagnostic.CA1812.severity = warning + +# CA1813: Avoid unsealed attributes +dotnet_diagnostic.CA1813.severity = suggestion + +# CA1814: Prefer jagged arrays over multidimensional +dotnet_diagnostic.CA1814.severity = suggestion + +# CA1815: Override equals and operator equals on value types +dotnet_diagnostic.CA1815.severity = warning +dotnet_code_quality.CA1815.api_surface = all + +# CA1816: Dispose methods should call SuppressFinalize +dotnet_diagnostic.CA1816.severity = warning + +# CA1819: Properties should not return arrays +dotnet_diagnostic.CA1819.severity = suggestion +dotnet_code_quality.CA1819.api_surface = all + +# CA1820: Test for empty strings using string length +dotnet_diagnostic.CA1820.severity = warning + +# CA1821: Remove empty Finalizers +dotnet_diagnostic.CA1821.severity = warning + +# CA1822: Mark members as static +dotnet_diagnostic.CA1822.severity = warning +dotnet_code_quality.CA1822.api_surface = all + +# CA1823: Avoid unused private fields +dotnet_diagnostic.CA1823.severity = warning + +# CA1824: Mark assemblies with NeutralResourcesLanguageAttribute +dotnet_diagnostic.CA1824.severity = warning + +# CA1825: Avoid zero-length array allocations +dotnet_diagnostic.CA1825.severity = warning + +# CA1826: Do not use Enumerable methods on indexable collections +dotnet_diagnostic.CA1826.severity = warning +dotnet_code_quality.CA1826.exclude_ordefault_methods = false + +# CA1827: Do not use Count() or LongCount() when Any() can be used +dotnet_diagnostic.CA1827.severity = warning + +# CA1828: Do not use CountAsync() or LongCountAsync() when AnyAsync() can be used +dotnet_diagnostic.CA1828.severity = warning + +# CA1829: Use Length/Count property instead of Count() when available +dotnet_diagnostic.CA1829.severity = warning + +# CA1830: Prefer strongly-typed Append and Insert method overloads on StringBuilder +dotnet_diagnostic.CA1830.severity = warning + +# CA1831: Use AsSpan or AsMemory instead of Range-based indexers when appropriate +dotnet_diagnostic.CA1831.severity = warning + +# CA1832: Use AsSpan or AsMemory instead of Range-based indexers when appropriate +dotnet_diagnostic.CA1832.severity = warning + +# CA1833: Use AsSpan or AsMemory instead of Range-based indexers when appropriate +dotnet_diagnostic.CA1833.severity = warning + +# CA1834: Consider using 'StringBuilder.Append(char)' when applicable +dotnet_diagnostic.CA1834.severity = warning + +# CA1835: Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync' +dotnet_diagnostic.CA1835.severity = warning + +# CA1836: Prefer IsEmpty over Count +dotnet_diagnostic.CA1836.severity = warning + +# CA1837: Use 'Environment.ProcessId' +dotnet_diagnostic.CA1837.severity = warning + +# CA1838: Avoid 'StringBuilder' parameters for P/Invokes +dotnet_diagnostic.CA1838.severity = warning + +# CA1839: Use 'Environment.ProcessPath' +dotnet_diagnostic.CA1839.severity = warning + +# CA1840: Use 'Environment.CurrentManagedThreadId' +dotnet_diagnostic.CA1840.severity = warning + +# CA1841: Prefer Dictionary.Contains methods +dotnet_diagnostic.CA1841.severity = warning + +# CA1842: Do not use 'WhenAll' with a single task dotnet_diagnostic.CA1842.severity = warning -dotnet_diagnostic.CA1843.severity = warning \ No newline at end of file + +# CA1843: Do not use 'WaitAll' with a single task +dotnet_diagnostic.CA1843.severity = warning + +# CA1844: Provide memory-based overrides of async methods when subclassing 'Stream' +dotnet_diagnostic.CA1844.severity = warning + +# CA1845: Use span-based 'string.Concat' +dotnet_diagnostic.CA1845.severity = warning + +# CA1846: Prefer 'AsSpan' over 'Substring' +dotnet_diagnostic.CA1846.severity = warning + +# CA1847: Use char literal for a single character lookup +dotnet_diagnostic.CA1847.severity = warning + +# CA1848: Use the LoggerMessage delegates +dotnet_diagnostic.CA1848.severity = warning + +# CA1849: Call async methods when in an async method +dotnet_diagnostic.CA1849.severity = warning + +# CA1850: Prefer static 'HashData' method over 'ComputeHash' +dotnet_diagnostic.CA1850.severity = warning + +# CA2000: Dispose objects before losing scope +dotnet_diagnostic.CA2000.severity = warning +dotnet_code_quality.CA2000.excluded_symbol_names = +dotnet_code_quality.CA2000.excluded_type_names_with_derived_types = +dotnet_code_quality.CA2000.dispose_analysis_kind = NonExceptionPaths +dotnet_code_quality.CA2000.dispose_ownership_transfer_at_constructor = false +dotnet_code_quality.CA2000.dispose_ownership_transfer_at_method_call = false + +# CA2002: Do not lock on objects with weak identity +dotnet_diagnostic.CA2002.severity = warning + +# CA2007: Consider calling ConfigureAwait on the awaited task +dotnet_diagnostic.CA2007.severity = warning +dotnet_code_quality.CA2007.exclude_async_void_methods = false +dotnet_code_quality.CA2007.output_kind = ConsoleApplication, DynamicallyLinkedLibrary, NetModule, WindowsApplication, WindowsRuntimeApplication, WindowsRuntimeMetadata + +# CA2008: Do not create tasks without passing a TaskScheduler +dotnet_diagnostic.CA2008.severity = warning + +# CA2009: Do not call ToImmutableCollection on an ImmutableCollection value +dotnet_diagnostic.CA2009.severity = warning + +# CA2011: Avoid infinite recursion +dotnet_diagnostic.CA2011.severity = warning + +# CA2012: Use ValueTasks correctly +dotnet_diagnostic.CA2012.severity = warning + +# CA2013: Do not use ReferenceEquals with value types +dotnet_diagnostic.CA2013.severity = warning + +# CA2014: Do not use stackalloc in loops +dotnet_diagnostic.CA2014.severity = warning + +# CA2015: Do not define finalizers for types derived from MemoryManager +dotnet_diagnostic.CA2015.severity = warning + +# CA2016: Forward the 'CancellationToken' parameter to methods that take one +dotnet_diagnostic.CA2016.severity = warning + +# CA2017: Parameter count mismatch +dotnet_diagnostic.CA2017.severity = warning + +# CA2018: 'Buffer.BlockCopy' expects the number of bytes to be copied for the 'count' argument +dotnet_diagnostic.CA2018.severity = warning + +# CA2100: Review SQL queries for security vulnerabilities +dotnet_diagnostic.CA2100.severity = warning +dotnet_code_quality.CAXXXX.excluded_symbol_names = +dotnet_code_quality.CAXXXX.excluded_type_names_with_derived_types = + +# CA2101: Specify marshaling for P/Invoke string arguments +dotnet_diagnostic.CA2101.severity = warning + +# CA2109: Review visible event handlers +dotnet_diagnostic.CA2109.severity = warning + +# CA2119: Seal methods that satisfy private interfaces +dotnet_diagnostic.CA2119.severity = warning + +# CA2153: Do Not Catch Corrupted State Exceptions +dotnet_diagnostic.CA2153.severity = warning + +# CA2200: Rethrow to preserve stack details +dotnet_diagnostic.CA2200.severity = warning + +# CA2201: Do not raise reserved exception types +dotnet_diagnostic.CA2201.severity = warning + +# CA2207: Initialize value type static fields inline +dotnet_diagnostic.CA2207.severity = warning + +# CA2208: Instantiate argument exceptions correctly +dotnet_diagnostic.CA2208.severity = warning +dotnet_code_quality.CA2208.api_surface = all + +# CA2211: Non-constant fields should not be visible +dotnet_diagnostic.CA2211.severity = warning + +# CA2213: Disposable fields should be disposed +dotnet_diagnostic.CA2213.severity = warning + +# CA2214: Do not call overridable methods in constructors +dotnet_diagnostic.CA2214.severity = warning + +# CA2215: Dispose methods should call base class dispose +dotnet_diagnostic.CA2215.severity = warning + +# CA2216: Disposable types should declare finalizer +dotnet_diagnostic.CA2216.severity = warning + +# CA2217: Do not mark enums with FlagsAttribute +dotnet_diagnostic.CA2217.severity = warning +dotnet_code_quality.CA2217.api_surface = all + +# CA2218: Override GetHashCode on overriding Equals +dotnet_diagnostic.CA2218.severity = warning + +# CA2219: Do not raise exceptions in finally clauses +dotnet_diagnostic.CA2219.severity = warning + +# CA2224: Override Equals on overloading operator equals +dotnet_diagnostic.CA2224.severity = warning + +# CA2225: Operator overloads have named alternates +dotnet_diagnostic.CA2225.severity = warning +dotnet_code_quality.CA2225.api_surface = all + +# CA2226: Operators should have symmetrical overloads +dotnet_diagnostic.CA2226.severity = warning +dotnet_code_quality.CA2226.api_surface = all + +# CA2227: Collection properties should be read only +dotnet_diagnostic.CA2227.severity = suggestion + +# CA2229: Implement serialization constructors +dotnet_diagnostic.CA2229.severity = warning + +# CA2231: Overload operator equals on overriding value type Equals +dotnet_diagnostic.CA2231.severity = warning +dotnet_code_quality.CA2231.api_surface = all + +# CA2234: Pass system uri objects instead of strings +dotnet_diagnostic.CA2234.severity = warning +dotnet_code_quality.CA2234.api_surface = all + +# CA2235: Mark all non-serializable fields +dotnet_diagnostic.CA2235.severity = warning + +# CA2237: Mark ISerializable types with serializable +dotnet_diagnostic.CA2237.severity = warning + +# CA2241: Provide correct arguments to formatting methods +dotnet_diagnostic.CA2241.severity = warning +dotnet_code_quality.CA2241.additional_string_formatting_methods = +dotnet_code_quality.CA2241.try_determine_additional_string_formatting_methods_automatically = true + +# CA2242: Test for NaN correctly +dotnet_diagnostic.CA2242.severity = warning + +# CA2243: Attribute string literals should parse correctly +dotnet_diagnostic.CA2243.severity = warning + +# CA2244: Do not duplicate indexed element initializations +dotnet_diagnostic.CA2244.severity = warning + +# CA2245: Do not assign a property to itself +dotnet_diagnostic.CA2245.severity = warning + +# CA2246: Assigning symbol and its member in the same statement +dotnet_diagnostic.CA2246.severity = warning + +# CA2247: Argument passed to TaskCompletionSource constructor should be TaskCreationOptions enum instead of TaskContinuationOptions enum +dotnet_diagnostic.CA2247.severity = warning + +# CA2248: Provide correct 'enum' argument to 'Enum.HasFlag' +dotnet_diagnostic.CA2248.severity = warning + +# CA2249: Consider using 'string.Contains' instead of 'string.IndexOf' +dotnet_diagnostic.CA2249.severity = warning + +# CA2250: Use 'ThrowIfCancellationRequested' +dotnet_diagnostic.CA2250.severity = warning + +# CA2251: Use 'string.Equals' +dotnet_diagnostic.CA2251.severity = warning + +# CA2252: This API requires opting into preview features +dotnet_diagnostic.CA2252.severity = warning + +# CA2253: Named placeholders should not be numeric values +dotnet_diagnostic.CA2253.severity = warning + +# CA2254: Template should be a static expression +dotnet_diagnostic.CA2254.severity = warning + +# CA2255: The 'ModuleInitializer' attribute should not be used in libraries +dotnet_diagnostic.CA2255.severity = warning + +# CA2256: All members declared in parent interfaces must have an implementation in a DynamicInterfaceCastableImplementation-attributed interface +dotnet_diagnostic.CA2256.severity = warning + +# CA2257: Members defined on an interface with the 'DynamicInterfaceCastableImplementationAttribute' should be 'static' +dotnet_diagnostic.CA2257.severity = warning + +# CA2258: Providing a 'DynamicInterfaceCastableImplementation' interface in Visual Basic is unsupported +dotnet_diagnostic.CA2258.severity = warning + +# CA2300: Do not use insecure deserializer BinaryFormatter +dotnet_diagnostic.CA2300.severity = warning + +# CA2301: Do not call BinaryFormatter.Deserialize without first setting BinaryFormatter.Binder +dotnet_diagnostic.CA2301.severity = warning +dotnet_code_quality.CA2301.excluded_symbol_names = +dotnet_code_quality.CA2301.excluded_type_names_with_derived_types = + +# CA2302: Ensure BinaryFormatter.Binder is set before calling BinaryFormatter.Deserialize +dotnet_diagnostic.CA2302.severity = warning +dotnet_code_quality.CA2302.excluded_symbol_names = +dotnet_code_quality.CA2302.excluded_type_names_with_derived_types = + +# CA2305: Do not use insecure deserializer LosFormatter +dotnet_diagnostic.CA2305.severity = warning + +# CA2310: Do not use insecure deserializer NetDataContractSerializer +dotnet_diagnostic.CA2310.severity = warning + +# CA2311: Do not deserialize without first setting NetDataContractSerializer.Binder +dotnet_diagnostic.CA2311.severity = warning +dotnet_code_quality.CA2311.excluded_symbol_names = +dotnet_code_quality.CA2311.excluded_type_names_with_derived_types = + +# CA2312: Ensure NetDataContractSerializer.Binder is set before deserializing +dotnet_diagnostic.CA2312.severity = warning +dotnet_code_quality.CA2312.excluded_symbol_names = +dotnet_code_quality.CA2312.excluded_type_names_with_derived_types = + +# CA2315: Do not use insecure deserializer ObjectStateFormatter +dotnet_diagnostic.CA2315.severity = warning + +# CA2321: Do not deserialize with JavaScriptSerializer using a SimpleTypeResolver +dotnet_diagnostic.CA2321.severity = warning +dotnet_code_quality.CA2321.excluded_symbol_names = +dotnet_code_quality.CA2321.excluded_type_names_with_derived_types = + +# CA2322: Ensure JavaScriptSerializer is not initialized with SimpleTypeResolver before deserializing +dotnet_diagnostic.CA2322.severity = warning +dotnet_code_quality.CA2322.excluded_symbol_names = +dotnet_code_quality.CA2322.excluded_type_names_with_derived_types = + +# CA2326: Do not use TypeNameHandling values other than None +dotnet_diagnostic.CA2326.severity = warning + +# CA2327: Do not use insecure JsonSerializerSettings +dotnet_diagnostic.CA2327.severity = warning +dotnet_code_quality.CA2327.excluded_symbol_names = +dotnet_code_quality.CA2327.excluded_type_names_with_derived_types = + +# CA2328: Ensure that JsonSerializerSettings are secure +dotnet_diagnostic.CA2328.severity = warning +dotnet_code_quality.CA2328.excluded_symbol_names = +dotnet_code_quality.CA2328.excluded_type_names_with_derived_types = + +# CA2329: Do not deserialize with JsonSerializer using an insecure configuration +dotnet_diagnostic.CA2329.severity = warning +dotnet_code_quality.CA2329.excluded_symbol_names = +dotnet_code_quality.CA2329.excluded_type_names_with_derived_types = + +# CA2330: Ensure that JsonSerializer has a secure configuration when deserializing +dotnet_diagnostic.CA2330.severity = warning +dotnet_code_quality.CA2330.excluded_symbol_names = +dotnet_code_quality.CA2330.excluded_type_names_with_derived_types = + +# CA2350: Do not use DataTable.ReadXml() with untrusted data +dotnet_diagnostic.CA2350.severity = warning + +# CA2351: Do not use DataSet.ReadXml() with untrusted data +dotnet_diagnostic.CA2351.severity = warning + +# CA2352: Unsafe DataSet or DataTable in serializable type can be vulnerable to remote code execution attacks +dotnet_diagnostic.CA2352.severity = warning + +# CA2353: Unsafe DataSet or DataTable in serializable type +dotnet_diagnostic.CA2353.severity = warning + +# CA2354: Unsafe DataSet or DataTable in deserialized object graph can be vulnerable to remote code execution attacks +dotnet_diagnostic.CA2354.severity = warning + +# CA2355: Unsafe DataSet or DataTable type found in deserializable object graph +dotnet_diagnostic.CA2355.severity = warning + +# CA2356: Unsafe DataSet or DataTable type in web deserializable object graph +dotnet_diagnostic.CA2356.severity = warning + +# CA2361: Ensure auto-generated class containing DataSet.ReadXml() is not used with untrusted data +dotnet_diagnostic.CA2361.severity = warning + +# CA2362: Unsafe DataSet or DataTable in auto-generated serializable type can be vulnerable to remote code execution attacks +dotnet_diagnostic.CA2362.severity = warning + +# CA3001: Review code for SQL injection vulnerabilities +dotnet_diagnostic.CA3001.severity = warning +dotnet_code_quality.CA3001.excluded_symbol_names = +dotnet_code_quality.CA3001.excluded_type_names_with_derived_types = + +# CA3002: Review code for XSS vulnerabilities +dotnet_diagnostic.CA3002.severity = warning +dotnet_code_quality.CA3002.excluded_symbol_names = +dotnet_code_quality.CA3002.excluded_type_names_with_derived_types = + +# CA3003: Review code for file path injection vulnerabilities +dotnet_diagnostic.CA3003.severity = warning +dotnet_code_quality.CA3003.excluded_symbol_names = +dotnet_code_quality.CA3003.excluded_type_names_with_derived_types = + +# CA3004: Review code for information disclosure vulnerabilities +dotnet_diagnostic.CA3004.severity = warning +dotnet_code_quality.CA3004.excluded_symbol_names = +dotnet_code_quality.CA3004.excluded_type_names_with_derived_types = + +# CA3005: Review code for LDAP injection vulnerabilities +dotnet_diagnostic.CA3005.severity = warning +dotnet_code_quality.CA3005.excluded_symbol_names = +dotnet_code_quality.CA3005.excluded_type_names_with_derived_types = + +# CA3006: Review code for process command injection vulnerabilities +dotnet_diagnostic.CA3006.severity = warning +dotnet_code_quality.CA3006.excluded_symbol_names = +dotnet_code_quality.CA3006.excluded_type_names_with_derived_types = + +# CA3007: Review code for open redirect vulnerabilities +dotnet_diagnostic.CA3007.severity = warning +dotnet_code_quality.CA3007.excluded_symbol_names = +dotnet_code_quality.CA3007.excluded_type_names_with_derived_types = + +# CA3008: Review code for XPath injection vulnerabilities +dotnet_diagnostic.CA3008.severity = warning +dotnet_code_quality.CA3008.excluded_symbol_names = +dotnet_code_quality.CA3008.excluded_type_names_with_derived_types = + +# CA3009: Review code for XML injection vulnerabilities +dotnet_diagnostic.CA3009.severity = warning +dotnet_code_quality.CA3009.excluded_symbol_names = +dotnet_code_quality.CA3009.excluded_type_names_with_derived_types = + +# CA3010: Review code for XAML injection vulnerabilities +dotnet_diagnostic.CA3010.severity = warning +dotnet_code_quality.CA3010.excluded_symbol_names = +dotnet_code_quality.CA3010.excluded_type_names_with_derived_types = + +# CA3011: Review code for DLL injection vulnerabilities +dotnet_diagnostic.CA3011.severity = warning +dotnet_code_quality.CA3011.excluded_symbol_names = +dotnet_code_quality.CA3011.excluded_type_names_with_derived_types = + +# CA3012: Review code for regex injection vulnerabilities +dotnet_diagnostic.CA3012.severity = warning +dotnet_code_quality.CA3012.excluded_symbol_names = +dotnet_code_quality.CA3012.excluded_type_names_with_derived_types = + +# CA3061: Do Not Add Schema By URL +dotnet_diagnostic.CA3061.severity = warning + +# CA3075: Insecure DTD processing in XML +dotnet_diagnostic.CA3075.severity = warning + +# CA3076: Insecure XSLT script processing. +dotnet_diagnostic.CA3076.severity = warning + +# CA3077: Insecure Processing in API Design, XmlDocument and XmlTextReader +dotnet_diagnostic.CA3077.severity = warning + +# CA3147: Mark Verb Handlers With Validate Antiforgery Token +dotnet_diagnostic.CA3147.severity = warning + +# CA5350: Do Not Use Weak Cryptographic Algorithms +dotnet_diagnostic.CA5350.severity = warning + +# CA5351: Do Not Use Broken Cryptographic Algorithms +dotnet_diagnostic.CA5351.severity = warning + +# CA5358: Review cipher mode usage with cryptography experts +dotnet_diagnostic.CA5358.severity = warning + +# CA5359: Do Not Disable Certificate Validation +dotnet_diagnostic.CA5359.severity = warning + +# CA5360: Do Not Call Dangerous Methods In Deserialization +dotnet_diagnostic.CA5360.severity = warning + +# CA5361: Do Not Disable SChannel Use of Strong Crypto +dotnet_diagnostic.CA5361.severity = warning +dotnet_code_quality.CA5361.excluded_symbol_names = +dotnet_code_quality.CA5361.excluded_type_names_with_derived_types = + +# CA5362: Potential reference cycle in deserialized object graph +dotnet_diagnostic.CA5362.severity = warning + +# CA5363: Do Not Disable Request Validation +dotnet_diagnostic.CA5363.severity = warning + +# CA5364: Do Not Use Deprecated Security Protocols +dotnet_diagnostic.CA5364.severity = warning + +# CA5365: Do Not Disable HTTP Header Checking +dotnet_diagnostic.CA5365.severity = warning + +# CA5366: Use XmlReader for 'DataSet.ReadXml()' +dotnet_diagnostic.CA5366.severity = warning + +# CA5367: Do Not Serialize Types With Pointer Fields +dotnet_diagnostic.CA5367.severity = warning + +# CA5368: Set ViewStateUserKey For Classes Derived From Page +dotnet_diagnostic.CA5368.severity = warning + +# CA5369: Use XmlReader for 'XmlSerializer.Deserialize()' +dotnet_diagnostic.CA5369.severity = warning + +# CA5370: Use XmlReader for XmlValidatingReader constructor +dotnet_diagnostic.CA5370.severity = warning + +# CA5371: Use XmlReader for 'XmlSchema.Read()' +dotnet_diagnostic.CA5371.severity = warning + +# CA5372: Use XmlReader for XPathDocument constructor +dotnet_diagnostic.CA5372.severity = warning + +# CA5373: Do not use obsolete key derivation function +dotnet_diagnostic.CA5373.severity = warning + +# CA5374: Do Not Use XslTransform +dotnet_diagnostic.CA5374.severity = warning + +# CA5375: Do Not Use Account Shared Access Signature +dotnet_diagnostic.CA5375.severity = warning + +# CA5376: Use SharedAccessProtocol HttpsOnly +dotnet_diagnostic.CA5376.severity = warning +dotnet_code_quality.CA5376.excluded_symbol_names = +dotnet_code_quality.CA5376.excluded_type_names_with_derived_types = + +# CA5377: Use Container Level Access Policy +dotnet_diagnostic.CA5377.severity = warning +dotnet_code_quality.CA5377.excluded_symbol_names = +dotnet_code_quality.CA5377.excluded_type_names_with_derived_types = + +# CA5378: Do not disable ServicePointManagerSecurityProtocols +dotnet_diagnostic.CA5378.severity = warning +dotnet_code_quality.CA5378.excluded_symbol_names = +dotnet_code_quality.CA5378.excluded_type_names_with_derived_types = + +# CA5379: Ensure Key Derivation Function algorithm is sufficiently strong +dotnet_diagnostic.CA5379.severity = warning + +# CA5380: Do Not Add Certificates To Root Store +dotnet_diagnostic.CA5380.severity = warning +dotnet_code_quality.CA5380.excluded_symbol_names = +dotnet_code_quality.CA5380.excluded_type_names_with_derived_types = + +# CA5381: Ensure Certificates Are Not Added To Root Store +dotnet_diagnostic.CA5381.severity = warning +dotnet_code_quality.CA5381.excluded_symbol_names = +dotnet_code_quality.CA5381.excluded_type_names_with_derived_types = + +# CA5382: Use Secure Cookies In ASP.Net Core +dotnet_diagnostic.CA5382.severity = warning +dotnet_code_quality.CA5382.excluded_symbol_names = +dotnet_code_quality.CA5382.excluded_type_names_with_derived_types = + +# CA5383: Ensure Use Secure Cookies In ASP.Net Core +dotnet_diagnostic.CA5383.severity = warning +dotnet_code_quality.CA5383.excluded_symbol_names = +dotnet_code_quality.CA5383.excluded_type_names_with_derived_types = + +# CA5384: Do Not Use Digital Signature Algorithm (DSA) +dotnet_diagnostic.CA5384.severity = warning +dotnet_code_quality.CA5384.excluded_symbol_names = +dotnet_code_quality.CA5384.excluded_type_names_with_derived_types = + +# CA5385: Use Rivest–Shamir–Adleman (RSA) Algorithm With Sufficient Key Size +dotnet_diagnostic.CA5385.severity = warning + +# CA5386: Avoid hardcoding SecurityProtocolType value +dotnet_diagnostic.CA5386.severity = warning + +# CA5387: Do Not Use Weak Key Derivation Function With Insufficient Iteration Count +dotnet_diagnostic.CA5387.severity = warning +dotnet_code_quality.CA5387.excluded_symbol_names = +dotnet_code_quality.CA5387.excluded_type_names_with_derived_types = + +# CA5388: Ensure Sufficient Iteration Count When Using Weak Key Derivation Function +dotnet_diagnostic.CA5388.severity = warning +dotnet_code_quality.CA5388.excluded_symbol_names = +dotnet_code_quality.CA5388.excluded_type_names_with_derived_types = + +# CA5389: Do Not Add Archive Item's Path To The Target File System Path +dotnet_diagnostic.CA5389.severity = warning +dotnet_code_quality.CA5389.excluded_symbol_names = +dotnet_code_quality.CA5389.excluded_type_names_with_derived_types = + +# CA5390: Do not hard-code encryption key +dotnet_diagnostic.CA5390.severity = warning +dotnet_code_quality.CA5390.excluded_symbol_names = +dotnet_code_quality.CA5390.excluded_type_names_with_derived_types = + +# CA5391: Use antiforgery tokens in ASP.NET Core MVC controllers +dotnet_diagnostic.CA5391.severity = warning +dotnet_code_quality.CA5391.exclude_aspnet_core_mvc_controllerbase = false + +# CA5392: Use DefaultDllImportSearchPaths attribute for P/Invokes +dotnet_diagnostic.CA5392.severity = warning + +# CA5393: Do not use unsafe DllImportSearchPath value +dotnet_diagnostic.CA5393.severity = warning +dotnet_code_quality.CA5393.unsafe_DllImportSearchPath_bits = 770 + +# CA5394: Do not use insecure randomness +dotnet_diagnostic.CA5394.severity = warning + +# CA5395: Miss HttpVerb attribute for action methods +dotnet_diagnostic.CA5395.severity = warning + +# CA5396: Set HttpOnly to true for HttpCookie +dotnet_diagnostic.CA5396.severity = warning + +# CA5397: Do not use deprecated SslProtocols values +dotnet_diagnostic.CA5397.severity = warning + +# CA5398: Avoid hardcoded SslProtocols values +dotnet_diagnostic.CA5398.severity = warning + +# CA5399: HttpClients should enable certificate revocation list checks +dotnet_diagnostic.CA5399.severity = warning +dotnet_code_quality.CA5399.excluded_symbol_names = +dotnet_code_quality.CA5399.excluded_type_names_with_derived_types = + +# CA5400: Ensure HttpClient certificate revocation list check is not disabled +dotnet_diagnostic.CA5400.severity = warning +dotnet_code_quality.CA5400.excluded_symbol_names = +dotnet_code_quality.CA5400.excluded_type_names_with_derived_types = + +# CA5401: Do not use CreateEncryptor with non-default IV +dotnet_diagnostic.CA5401.severity = warning + +# CA5402: Use CreateEncryptor with the default IV +dotnet_diagnostic.CA5402.severity = warning + +# CA5403: Do not hard-code certificate +dotnet_diagnostic.CA5403.severity = warning + +# CA5404: Do not disable token validation checks +dotnet_diagnostic.CA5404.severity = warning + +# CA5405: Do not always skip token validation in delegates +dotnet_diagnostic.CA5405.severity = warning + +# IL3000: Avoid using accessing Assembly file path when publishing as a single-file +dotnet_diagnostic.IL3000.severity = warning + +# IL3001: Avoid using accessing Assembly file path when publishing as a single-file +dotnet_diagnostic.IL3001.severity = warning + +# IL3002: Avoid calling members annotated with 'RequiresAssemblyFilesAttribute' when publishing as a single file +dotnet_diagnostic.IL3002.severity = warning + +## Roslynator.CSharp.Analyzers + +roslynator_accessibility_modifiers = explicit +roslynator_accessor_braces_style = single_line_when_expression_is_on_single_line +roslynator_array_creation_type_style = implicit +roslynator_arrow_token_new_line = after +roslynator_binary_operator_new_line = before +roslynator_blank_line_between_closing_brace_and_switch_section = true +roslynator_blank_line_between_single_line_accessors = false +roslynator_blank_line_between_using_directives = separate_groups +roslynator_block_braces_style = multi_line +roslynator_body_style = expression +roslynator_conditional_operator_condition_parentheses_style = omit_when_condition_is_single_token +roslynator_conditional_operator_new_line = before +roslynator_configure_await = true +roslynator_doc_comment_summary_style = multi_line +roslynator_empty_string_style = field +roslynator_enum_flag_value_style = decimal_number +roslynator_enum_has_flag_style = method +roslynator_equals_token_new_line = after +roslynator_infinite_loop_style = while +roslynator_max_line_length = 256 +roslynator_new_line_at_end_of_file = true +roslynator_new_line_before_while_in_do_statement = false +roslynator_null_conditional_operator_new_line = after +roslynator_null_check_style = pattern_matching +roslynator_object_creation_parentheses_style = include +roslynator_object_creation_type_style = implicit_when_type_is_obvious +roslynator_prefix_field_identifier_with_underscore = false +roslynator_suppress_unity_script_methods = true +roslynator_use_anonymous_function_or_method_group = method_group +roslynator_use_block_body_when_declaration_spans_over_multiple_lines = true +roslynator_use_block_body_when_expression_spans_over_multiple_lines = true +roslynator_use_var_instead_of_implicit_object_creation = true + +roslynator_refactoring.add_all_properties_to_initializer.enabled = true +roslynator_refactoring.add_argument_name.enabled = true +roslynator_refactoring.add_braces.enabled = true +roslynator_refactoring.add_braces_to_if_else.enabled = true +roslynator_refactoring.add_braces_to_switch_section.enabled = true +roslynator_refactoring.add_braces_to_switch_sections.enabled = true +roslynator_refactoring.add_default_value_to_parameter.enabled = true +roslynator_refactoring.add_empty_line_between_declarations.enabled = true +roslynator_refactoring.add_exception_element_to_documentation_comment.enabled = true +roslynator_refactoring.add_generic_parameter_to_declaration.enabled = true +roslynator_refactoring.add_member_to_interface.enabled = true +roslynator_refactoring.add_missing_cases_to_switch.enabled = true +roslynator_refactoring.add_parameter_to_interface_member.enabled = true +roslynator_refactoring.add_tag_to_documentation_comment.enabled = true +roslynator_refactoring.add_using_directive.enabled = true +roslynator_refactoring.add_using_static_directive.enabled = true +roslynator_refactoring.call_extension_method_as_instance_method.enabled = true +roslynator_refactoring.call_indexof_instead_of_contains.enabled = true +roslynator_refactoring.comment_out_member_declaration.enabled = true +roslynator_refactoring.comment_out_statement.enabled = true +roslynator_refactoring.convert_auto_property_to_full_property.enabled = true +roslynator_refactoring.convert_auto_property_to_full_property_without_backing_field.enabled = true +roslynator_refactoring.convert_block_body_to_expression_body.enabled = true +roslynator_refactoring.convert_comment_to_documentation_comment.enabled = true +roslynator_refactoring.convert_conditional_expression_to_if_else.enabled = true +roslynator_refactoring.convert_do_to_while.enabled = true +roslynator_refactoring.convert_expression_body_to_block_body.enabled = true +roslynator_refactoring.convert_for_to_foreach.enabled = true +roslynator_refactoring.convert_for_to_while.enabled = true +roslynator_refactoring.convert_foreach_to_for.enabled = true +roslynator_refactoring.convert_foreach_to_for_and_reverse_loop.enabled = true +roslynator_refactoring.convert_hasflag_call_to_bitwise_operation.enabled = true +roslynator_refactoring.convert_hexadecimal_literal_to_decimal_literal.enabled = true +roslynator_refactoring.convert_if_to_conditional_expression.enabled = true +roslynator_refactoring.convert_if_to_switch.enabled = true +roslynator_refactoring.convert_interpolated_string_to_concatenation.enabled = true +roslynator_refactoring.convert_interpolated_string_to_string_format.enabled = true +roslynator_refactoring.convert_interpolated_string_to_string_literal.enabled = true +roslynator_refactoring.convert_lambda_block_body_to_expression_body.enabled = true +roslynator_refactoring.convert_lambda_expression_body_to_block_body.enabled = true +roslynator_refactoring.convert_method_group_to_lambda.enabled = true +roslynator_refactoring.convert_regular_string_literal_to_verbatim_string_literal.enabled = true +roslynator_refactoring.convert_return_statement_to_if.enabled = true +roslynator_refactoring.convert_statements_to_if_else.enabled = true +roslynator_refactoring.convert_string_format_to_interpolated_string.enabled = true +roslynator_refactoring.convert_switch_expression_to_switch_statement.enabled = true +roslynator_refactoring.convert_switch_to_if.enabled = true +roslynator_refactoring.convert_verbatim_string_literal_to_regular_string_literal.enabled = true +roslynator_refactoring.convert_verbatim_string_literal_to_regular_string_literals.enabled = true +roslynator_refactoring.convert_while_to_do.enabled = true +roslynator_refactoring.convert_while_to_for.enabled = true +roslynator_refactoring.copy_argument.enabled = true +roslynator_refactoring.copy_documentation_comment_from_base_member.enabled = true +roslynator_refactoring.copy_member_declaration.enabled = true +roslynator_refactoring.copy_parameter.enabled = true +roslynator_refactoring.copy_statement.enabled = true +roslynator_refactoring.copy_switch_section.enabled = true +roslynator_refactoring.deconstruct_foreach_variable.enabled = true +roslynator_refactoring.expand_coalesce_expression.enabled = true +roslynator_refactoring.expand_compound_assignment.enabled = true +roslynator_refactoring.expand_event_declaration.enabled = true +roslynator_refactoring.expand_initializer.enabled = true +roslynator_refactoring.expand_positional_constructor.enabled = true +roslynator_refactoring.extract_event_handler_method.enabled = true +roslynator_refactoring.extract_expression_from_condition.enabled = true +roslynator_refactoring.extract_type_declaration_to_new_file.enabled = true +roslynator_refactoring.generate_base_constructors.enabled = true +roslynator_refactoring.generate_combined_enum_member.enabled = true +roslynator_refactoring.generate_enum_member.enabled = true +roslynator_refactoring.generate_enum_values.enabled = true +roslynator_refactoring.generate_event_invoking_method.enabled = true +roslynator_refactoring.generate_property_for_debuggerdisplay_attribute.enabled = true +roslynator_refactoring.change_accessibility.enabled = true +roslynator_refactoring.change_method_return_type_to_void.enabled = true +roslynator_refactoring.change_type_according_to_expression.enabled = true +roslynator_refactoring.check_expression_for_null.enabled = true +roslynator_refactoring.check_parameter_for_null.enabled = true +roslynator_refactoring.implement_custom_enumerator.enabled = true +roslynator_refactoring.implement_iequatable.enabled = true +roslynator_refactoring.initialize_field_from_constructor.enabled = true +roslynator_refactoring.initialize_local_variable_with_default_value.enabled = true +roslynator_refactoring.inline_alias_expression.enabled = true +roslynator_refactoring.inline_constant.enabled = true +roslynator_refactoring.inline_constant_value.enabled = true +roslynator_refactoring.inline_method.enabled = true +roslynator_refactoring.inline_property.enabled = true +roslynator_refactoring.inline_using_static.enabled = true +roslynator_refactoring.insert_string_interpolation.enabled = true +roslynator_refactoring.introduce_and_initialize_field.enabled = true +roslynator_refactoring.introduce_and_initialize_property.enabled = true +roslynator_refactoring.introduce_constructor.enabled = true +roslynator_refactoring.introduce_field_to_lock_on.enabled = true +roslynator_refactoring.introduce_local_variable.enabled = true +roslynator_refactoring.invert_binary_expression.enabled = true +roslynator_refactoring.invert_boolean_literal.enabled = true +roslynator_refactoring.invert_conditional_expression.enabled = true +roslynator_refactoring.invert_if.enabled = true +roslynator_refactoring.invert_if_else.enabled = true +roslynator_refactoring.invert_is_expression.enabled = true +roslynator_refactoring.invert_linq_method_call.enabled = true +roslynator_refactoring.invert_operator.enabled = true +roslynator_refactoring.invert_prefix_or_postfix_unary_expression.enabled = true +roslynator_refactoring.join_string_expressions.enabled = true +roslynator_refactoring.make_member_abstract.enabled = true +roslynator_refactoring.make_member_virtual.enabled = true +roslynator_refactoring.merge_attributes.enabled = true +roslynator_refactoring.merge_if_statements.enabled = true +roslynator_refactoring.merge_if_with_parent_if.enabled = true +roslynator_refactoring.merge_local_declarations.enabled = true +roslynator_refactoring.merge_switch_sections.enabled = true +roslynator_refactoring.move_unsafe_context_to_containing_declaration.enabled = true +roslynator_refactoring.notify_when_property_changes.enabled = true +roslynator_refactoring.parenthesize_expression.enabled = true +roslynator_refactoring.promote_local_variable_to_parameter.enabled = true +roslynator_refactoring.remove_all_comments.enabled = true +roslynator_refactoring.remove_all_comments_except_documentation_comments.enabled = true +roslynator_refactoring.remove_all_documentation_comments.enabled = true +roslynator_refactoring.remove_all_member_declarations.enabled = true +roslynator_refactoring.remove_all_preprocessor_directives.enabled = true +roslynator_refactoring.remove_all_region_directives.enabled = true +roslynator_refactoring.remove_all_statements.enabled = true +roslynator_refactoring.remove_all_switch_sections.enabled = true +roslynator_refactoring.remove_argument_name.enabled = true +roslynator_refactoring.remove_async_await.enabled = true +roslynator_refactoring.remove_braces.enabled = true +roslynator_refactoring.remove_braces_from_if_else.enabled = true +roslynator_refactoring.remove_braces_from_switch_section.enabled = true +roslynator_refactoring.remove_braces_from_switch_sections.enabled = true +roslynator_refactoring.remove_comment.enabled = true +roslynator_refactoring.remove_condition_from_last_else.enabled = true +roslynator_refactoring.remove_containing_statement.enabled = true +roslynator_refactoring.remove_empty_lines.enabled = true +roslynator_refactoring.remove_enum_member_value.enabled = true +roslynator_refactoring.remove_instantiation_of_local_variable.enabled = true +roslynator_refactoring.remove_interpolation.enabled = true +roslynator_refactoring.remove_member_declaration.enabled = true +roslynator_refactoring.remove_member_declarations_above_or_below.enabled = true +roslynator_refactoring.remove_parentheses.enabled = true +roslynator_refactoring.remove_preprocessor_directive.enabled = true +roslynator_refactoring.remove_property_initializer.enabled = true +roslynator_refactoring.remove_region.enabled = true +roslynator_refactoring.remove_statement.enabled = true +roslynator_refactoring.remove_unnecessary_assignment.enabled = true +roslynator_refactoring.rename_identifier_according_to_type_name.enabled = true +roslynator_refactoring.rename_method_according_to_type_name.enabled = true +roslynator_refactoring.rename_parameter_according_to_type_name.enabled = true +roslynator_refactoring.rename_property_according_to_type_name.enabled = true +roslynator_refactoring.replace_as_expression_with_explicit_cast.enabled = true +roslynator_refactoring.replace_conditional_expression_with_true_or_false_branch.enabled = true +roslynator_refactoring.replace_equality_operator_with_string_equals.enabled = true +roslynator_refactoring.replace_equality_operator_with_string_isnullorempty.enabled = true +roslynator_refactoring.replace_equality_operator_with_string_isnullorwhitespace.enabled = true +roslynator_refactoring.replace_explicit_cast_with_as_expression.enabled = true +roslynator_refactoring.replace_interpolated_string_with_interpolation_expression.enabled = true +roslynator_refactoring.replace_method_with_property.enabled = true +roslynator_refactoring.replace_null_literal_with_default_expression.enabled = true +roslynator_refactoring.replace_prefix_operator_with_postfix_operator.enabled = true +roslynator_refactoring.replace_property_with_method.enabled = true +roslynator_refactoring.reverse_for_statement.enabled = true +roslynator_refactoring.simplify_if.enabled = true +roslynator_refactoring.sort_case_labels.enabled = true +roslynator_refactoring.sort_member_declarations.enabled = true +roslynator_refactoring.split_attributes.enabled = true +roslynator_refactoring.split_if.enabled = true +roslynator_refactoring.split_if_else.enabled = true +roslynator_refactoring.split_local_declaration_and_assignment.enabled = true +roslynator_refactoring.split_switch_labels.enabled = true +roslynator_refactoring.split_variable_declaration.enabled = true +roslynator_refactoring.swap_binary_operands.enabled = true +roslynator_refactoring.swap_member_declarations.enabled = true +roslynator_refactoring.sync_property_name_and_backing_field_name.enabled = true +roslynator_refactoring.uncomment_multiline_comment.enabled = true +roslynator_refactoring.uncomment_singleline_comment.enabled = true +roslynator_refactoring.use_coalesce_expression_instead_of_if.enabled = true +roslynator_refactoring.use_constant_instead_of_readonly_field.enabled = true +roslynator_refactoring.use_element_access_instead_of_linq_method.enabled = true +roslynator_refactoring.use_enumerator_explicitly.enabled = true +roslynator_refactoring.use_explicit_type.enabled = true +roslynator_refactoring.use_implicit_type.enabled = true +roslynator_refactoring.use_index_initializer.enabled = true +roslynator_refactoring.use_lambda_instead_of_anonymous_method.enabled = true +roslynator_refactoring.use_list_instead_of_yield.enabled = true +roslynator_refactoring.use_object_initializer.enabled = true +roslynator_refactoring.use_readonly_field_instead_of_constant.enabled = true +roslynator_refactoring.use_string_empty_instead_of_empty_string_literal.enabled = true +roslynator_refactoring.use_stringbuilder_instead_of_concatenation.enabled = true +roslynator_refactoring.wrap_arguments.enabled = true +roslynator_refactoring.wrap_binary_expression.enabled = true +roslynator_refactoring.wrap_call_chain.enabled = true +roslynator_refactoring.wrap_conditional_expression.enabled = true +roslynator_refactoring.wrap_constraint_clauses.enabled = true +roslynator_refactoring.wrap_initializer_expressions.enabled = true +roslynator_refactoring.wrap_lines_in_preprocessor_directive.enabled = true +roslynator_refactoring.wrap_lines_in_region.enabled = true +roslynator_refactoring.wrap_lines_in_try_catch.enabled = true +roslynator_refactoring.wrap_parameters.enabled = true +roslynator_refactoring.wrap_statements_in_condition.enabled = true +roslynator_refactoring.wrap_statements_in_using_statement.enabled = true + +roslynator_compiler_diagnostic_fix.cs0019.enabled = true +roslynator_compiler_diagnostic_fix.cs0021.enabled = true +roslynator_compiler_diagnostic_fix.cs0023.enabled = true +roslynator_compiler_diagnostic_fix.cs0029.enabled = true +roslynator_compiler_diagnostic_fix.cs0030.enabled = true +roslynator_compiler_diagnostic_fix.cs0037.enabled = true +roslynator_compiler_diagnostic_fix.cs0069.enabled = true +roslynator_compiler_diagnostic_fix.cs0077.enabled = true +roslynator_compiler_diagnostic_fix.cs0080.enabled = true +roslynator_compiler_diagnostic_fix.cs0101.enabled = true +roslynator_compiler_diagnostic_fix.cs0102.enabled = true +roslynator_compiler_diagnostic_fix.cs0103.enabled = true +roslynator_compiler_diagnostic_fix.cs0106.enabled = true +roslynator_compiler_diagnostic_fix.cs0107.enabled = true +roslynator_compiler_diagnostic_fix.cs0108.enabled = true +roslynator_compiler_diagnostic_fix.cs0109.enabled = true +roslynator_compiler_diagnostic_fix.cs0112.enabled = true +roslynator_compiler_diagnostic_fix.cs0114.enabled = true +roslynator_compiler_diagnostic_fix.cs0115.enabled = true +roslynator_compiler_diagnostic_fix.cs0119.enabled = true +roslynator_compiler_diagnostic_fix.cs0120.enabled = true +roslynator_compiler_diagnostic_fix.cs0123.enabled = true +roslynator_compiler_diagnostic_fix.cs0126.enabled = true +roslynator_compiler_diagnostic_fix.cs0127.enabled = true +roslynator_compiler_diagnostic_fix.cs0128.enabled = true +roslynator_compiler_diagnostic_fix.cs0131.enabled = true +roslynator_compiler_diagnostic_fix.cs0132.enabled = true +roslynator_compiler_diagnostic_fix.cs0133.enabled = true +roslynator_compiler_diagnostic_fix.cs0136.enabled = true +roslynator_compiler_diagnostic_fix.cs0139.enabled = true +roslynator_compiler_diagnostic_fix.cs0152.enabled = true +roslynator_compiler_diagnostic_fix.cs0161.enabled = true +roslynator_compiler_diagnostic_fix.cs0162.enabled = true +roslynator_compiler_diagnostic_fix.cs0163.enabled = true +roslynator_compiler_diagnostic_fix.cs0164.enabled = true +roslynator_compiler_diagnostic_fix.cs0165.enabled = true +roslynator_compiler_diagnostic_fix.cs0168.enabled = true +roslynator_compiler_diagnostic_fix.cs0173.enabled = true +roslynator_compiler_diagnostic_fix.cs0177.enabled = true +roslynator_compiler_diagnostic_fix.cs0191.enabled = true +roslynator_compiler_diagnostic_fix.cs0192.enabled = true +roslynator_compiler_diagnostic_fix.cs0201.enabled = true +roslynator_compiler_diagnostic_fix.cs0214.enabled = true +roslynator_compiler_diagnostic_fix.cs0216.enabled = true +roslynator_compiler_diagnostic_fix.cs0219.enabled = true +roslynator_compiler_diagnostic_fix.cs0221.enabled = true +roslynator_compiler_diagnostic_fix.cs0225.enabled = true +roslynator_compiler_diagnostic_fix.cs0238.enabled = true +roslynator_compiler_diagnostic_fix.cs0246.enabled = true +roslynator_compiler_diagnostic_fix.cs0260.enabled = true +roslynator_compiler_diagnostic_fix.cs0262.enabled = true +roslynator_compiler_diagnostic_fix.cs0266.enabled = true +roslynator_compiler_diagnostic_fix.cs0267.enabled = true +roslynator_compiler_diagnostic_fix.cs0272.enabled = true +roslynator_compiler_diagnostic_fix.cs0275.enabled = true +roslynator_compiler_diagnostic_fix.cs0305.enabled = true +roslynator_compiler_diagnostic_fix.cs0401.enabled = true +roslynator_compiler_diagnostic_fix.cs0403.enabled = true +roslynator_compiler_diagnostic_fix.cs0405.enabled = true +roslynator_compiler_diagnostic_fix.cs0407.enabled = true +roslynator_compiler_diagnostic_fix.cs0409.enabled = true +roslynator_compiler_diagnostic_fix.cs0428.enabled = true +roslynator_compiler_diagnostic_fix.cs0441.enabled = true +roslynator_compiler_diagnostic_fix.cs0442.enabled = true +roslynator_compiler_diagnostic_fix.cs0449.enabled = true +roslynator_compiler_diagnostic_fix.cs0450.enabled = true +roslynator_compiler_diagnostic_fix.cs0451.enabled = true +roslynator_compiler_diagnostic_fix.cs0472.enabled = true +roslynator_compiler_diagnostic_fix.cs0500.enabled = true +roslynator_compiler_diagnostic_fix.cs0501.enabled = true +roslynator_compiler_diagnostic_fix.cs0507.enabled = true +roslynator_compiler_diagnostic_fix.cs0508.enabled = true +roslynator_compiler_diagnostic_fix.cs0513.enabled = true +roslynator_compiler_diagnostic_fix.cs0515.enabled = true +roslynator_compiler_diagnostic_fix.cs0524.enabled = true +roslynator_compiler_diagnostic_fix.cs0525.enabled = true +roslynator_compiler_diagnostic_fix.cs0527.enabled = true +roslynator_compiler_diagnostic_fix.cs0531.enabled = true +roslynator_compiler_diagnostic_fix.cs0539.enabled = true +roslynator_compiler_diagnostic_fix.cs0541.enabled = true +roslynator_compiler_diagnostic_fix.cs0549.enabled = true +roslynator_compiler_diagnostic_fix.cs0558.enabled = true +roslynator_compiler_diagnostic_fix.cs0567.enabled = true +roslynator_compiler_diagnostic_fix.cs0568.enabled = true +roslynator_compiler_diagnostic_fix.cs0573.enabled = true +roslynator_compiler_diagnostic_fix.cs0574.enabled = true +roslynator_compiler_diagnostic_fix.cs0575.enabled = true +roslynator_compiler_diagnostic_fix.cs0579.enabled = true +roslynator_compiler_diagnostic_fix.cs0592.enabled = true +roslynator_compiler_diagnostic_fix.cs0621.enabled = true +roslynator_compiler_diagnostic_fix.cs0628.enabled = true +roslynator_compiler_diagnostic_fix.cs0659.enabled = true +roslynator_compiler_diagnostic_fix.cs0660.enabled = true +roslynator_compiler_diagnostic_fix.cs0661.enabled = true +roslynator_compiler_diagnostic_fix.cs0678.enabled = true +roslynator_compiler_diagnostic_fix.cs0693.enabled = true +roslynator_compiler_diagnostic_fix.cs0708.enabled = true +roslynator_compiler_diagnostic_fix.cs0710.enabled = true +roslynator_compiler_diagnostic_fix.cs0713.enabled = true +roslynator_compiler_diagnostic_fix.cs0714.enabled = true +roslynator_compiler_diagnostic_fix.cs0718.enabled = true +roslynator_compiler_diagnostic_fix.cs0750.enabled = true +roslynator_compiler_diagnostic_fix.cs0751.enabled = true +roslynator_compiler_diagnostic_fix.cs0753.enabled = true +roslynator_compiler_diagnostic_fix.cs0756.enabled = true +roslynator_compiler_diagnostic_fix.cs0759.enabled = true +roslynator_compiler_diagnostic_fix.cs0766.enabled = true +roslynator_compiler_diagnostic_fix.cs0815.enabled = true +roslynator_compiler_diagnostic_fix.cs0819.enabled = true +roslynator_compiler_diagnostic_fix.cs0822.enabled = true +roslynator_compiler_diagnostic_fix.cs1002.enabled = true +roslynator_compiler_diagnostic_fix.cs1003.enabled = true +roslynator_compiler_diagnostic_fix.cs1004.enabled = true +roslynator_compiler_diagnostic_fix.cs1012.enabled = true +roslynator_compiler_diagnostic_fix.cs1023.enabled = true +roslynator_compiler_diagnostic_fix.cs1031.enabled = true +roslynator_compiler_diagnostic_fix.cs1057.enabled = true +roslynator_compiler_diagnostic_fix.cs1061.enabled = true +roslynator_compiler_diagnostic_fix.cs1100.enabled = true +roslynator_compiler_diagnostic_fix.cs1105.enabled = true +roslynator_compiler_diagnostic_fix.cs1106.enabled = true +roslynator_compiler_diagnostic_fix.cs1503.enabled = true +roslynator_compiler_diagnostic_fix.cs1522.enabled = true +roslynator_compiler_diagnostic_fix.cs1526.enabled = true +roslynator_compiler_diagnostic_fix.cs1527.enabled = true +roslynator_compiler_diagnostic_fix.cs1591.enabled = true +roslynator_compiler_diagnostic_fix.cs1597.enabled = true +roslynator_compiler_diagnostic_fix.cs1609.enabled = true +roslynator_compiler_diagnostic_fix.cs1615.enabled = true +roslynator_compiler_diagnostic_fix.cs1620.enabled = true +roslynator_compiler_diagnostic_fix.cs1621.enabled = true +roslynator_compiler_diagnostic_fix.cs1622.enabled = true +roslynator_compiler_diagnostic_fix.cs1623.enabled = true +roslynator_compiler_diagnostic_fix.cs1624.enabled = true +roslynator_compiler_diagnostic_fix.cs1643.enabled = true +roslynator_compiler_diagnostic_fix.cs1674.enabled = true +roslynator_compiler_diagnostic_fix.cs1689.enabled = true +roslynator_compiler_diagnostic_fix.cs1715.enabled = true +roslynator_compiler_diagnostic_fix.cs1717.enabled = true +roslynator_compiler_diagnostic_fix.cs1722.enabled = true +roslynator_compiler_diagnostic_fix.cs1737.enabled = true +roslynator_compiler_diagnostic_fix.cs1741.enabled = true +roslynator_compiler_diagnostic_fix.cs1743.enabled = true +roslynator_compiler_diagnostic_fix.cs1750.enabled = true +roslynator_compiler_diagnostic_fix.cs1751.enabled = true +roslynator_compiler_diagnostic_fix.cs1955.enabled = true +roslynator_compiler_diagnostic_fix.cs1983.enabled = true +roslynator_compiler_diagnostic_fix.cs1988.enabled = true +roslynator_compiler_diagnostic_fix.cs1994.enabled = true +roslynator_compiler_diagnostic_fix.cs1997.enabled = true +roslynator_compiler_diagnostic_fix.cs3000.enabled = true +roslynator_compiler_diagnostic_fix.cs3001.enabled = true +roslynator_compiler_diagnostic_fix.cs3002.enabled = true +roslynator_compiler_diagnostic_fix.cs3003.enabled = true +roslynator_compiler_diagnostic_fix.cs3005.enabled = true +roslynator_compiler_diagnostic_fix.cs3006.enabled = true +roslynator_compiler_diagnostic_fix.cs3007.enabled = true +roslynator_compiler_diagnostic_fix.cs3008.enabled = true +roslynator_compiler_diagnostic_fix.cs3009.enabled = true +roslynator_compiler_diagnostic_fix.cs3016.enabled = true +roslynator_compiler_diagnostic_fix.cs3024.enabled = true +roslynator_compiler_diagnostic_fix.cs3027.enabled = true +roslynator_compiler_diagnostic_fix.cs7036.enabled = true +roslynator_compiler_diagnostic_fix.cs8050.enabled = true +roslynator_compiler_diagnostic_fix.cs8070.enabled = true +roslynator_compiler_diagnostic_fix.cs8112.enabled = true +roslynator_compiler_diagnostic_fix.cs8139.enabled = true +roslynator_compiler_diagnostic_fix.cs8340.enabled = true +roslynator_compiler_diagnostic_fix.cs8403.enabled = true +roslynator_compiler_diagnostic_fix.cs8602.enabled = true +roslynator_compiler_diagnostic_fix.cs8604.enabled = true +roslynator_compiler_diagnostic_fix.cs8618.enabled = true +roslynator_compiler_diagnostic_fix.cs8625.enabled = true +roslynator_compiler_diagnostic_fix.cs8632.enabled = true + +# RCS0001: Add empty line after embedded statement. +dotnet_diagnostic.RCS0001.severity = warning + +# RCS0002: Add empty line after #region. +dotnet_diagnostic.RCS0002.severity = warning + +# RCS0003: Add empty line after using directive list. +dotnet_diagnostic.RCS0003.severity = warning + +# RCS0004: Add empty line before closing brace of 'do' statement. +dotnet_diagnostic.RCS0004.severity = none + +# RCS0005: Add empty line before #endregion. +dotnet_diagnostic.RCS0005.severity = warning + +# RCS0006: Add empty line before using directive list. +dotnet_diagnostic.RCS0006.severity = warning + +# RCS0007: Add empty line between accessors. +dotnet_diagnostic.RCS0007.severity = warning + +# RCS0008: Add empty line between block and statement. +dotnet_diagnostic.RCS0008.severity = warning + +# RCS0009: Add empty line between declaration and documentation comment. +dotnet_diagnostic.RCS0009.severity = warning + +# RCS0010: Add empty line between declarations. +dotnet_diagnostic.RCS0010.severity = warning + +# RCS0011: Add empty line between single-line accessors (or vice versa). +dotnet_diagnostic.RCS0011.severity = warning + +# RCS0012: Add empty line between single-line declarations. +dotnet_diagnostic.RCS0012.severity = warning + +# RCS0013: Add empty line between single-line declarations of different kind. +dotnet_diagnostic.RCS0013.severity = warning + +# RCS0014: Add empty line between switch sections. +dotnet_diagnostic.RCS0014.severity = warning + +# RCS0015: Add empty line between using directives with different root namespace (or vice versa). +dotnet_diagnostic.RCS0015.severity = warning + +# RCS0016: Add newline after attribute list. +dotnet_diagnostic.RCS0016.severity = warning + +# RCS0020: Add newline after opening brace of accessor. +dotnet_diagnostic.RCS0020.severity = warning + +# RCS0021: Add newline after opening brace of block. +dotnet_diagnostic.RCS0021.severity = warning + +# RCS0022: Add newline after opening brace of empty block. +dotnet_diagnostic.RCS0022.severity = warning + +# RCS0023: Add newline after opening brace of type declaration. +dotnet_diagnostic.RCS0023.severity = warning + +# RCS0024: Add newline after switch label. +dotnet_diagnostic.RCS0024.severity = warning + +# RCS0025: Add newline before accessor of full property. +dotnet_diagnostic.RCS0025.severity = warning + +# RCS0027: Add newline before binary operator instead of after it (or vice versa). +dotnet_diagnostic.RCS0027.severity = warning + +# RCS0028: Add newline before conditional operator instead of after it (or vice versa). +dotnet_diagnostic.RCS0028.severity = warning + +# RCS0029: Add newline before constructor initializer. +dotnet_diagnostic.RCS0029.severity = none + +# RCS0030: Add newline before embedded statement. +dotnet_diagnostic.RCS0030.severity = warning + +# RCS0031: Add newline before enum member. +dotnet_diagnostic.RCS0031.severity = warning + +# RCS0032: Add newline before expression-body arrow instead of after it (or vice versa). +dotnet_diagnostic.RCS0032.severity = warning + +# RCS0033: Add newline before statement. +dotnet_diagnostic.RCS0033.severity = warning + +# RCS0034: Add newline before type parameter constraint. +dotnet_diagnostic.RCS0034.severity = warning + +# RCS0036: Remove empty line between single-line declarations of same kind. +dotnet_diagnostic.RCS0036.severity = none + +# RCS0038: Remove empty line between using directives with same root namespace. +dotnet_diagnostic.RCS0038.severity = warning + +# RCS0039: Remove newline before base list. +dotnet_diagnostic.RCS0039.severity = warning + +# RCS0041: Remove newline between 'if' keyword and 'else' keyword. +dotnet_diagnostic.RCS0041.severity = warning + +# RCS0042: Remove newlines from accessor list of auto-property. +dotnet_diagnostic.RCS0042.severity = warning + +# RCS0043: Remove newlines from accessor with single-line expression. +dotnet_diagnostic.RCS0043.severity = none + +# RCS0044: Use carriage return + linefeed as newline. +dotnet_diagnostic.RCS0044.severity = warning + +# RCS0045: Use linefeed as newline. +dotnet_diagnostic.RCS0045.severity = none + +# RCS0046: Use spaces instead of tab. +dotnet_diagnostic.RCS0046.severity = none + +# RCS0047: [deprecated] Wrap and indent each node in list +dotnet_diagnostic.RCS0047.severity = none + +# RCS0048: Remove newlines from initializer with single-line expression. +dotnet_diagnostic.RCS0048.severity = none + +# RCS0049: Add empty line after top comment. +dotnet_diagnostic.RCS0049.severity = warning + +# RCS0050: Add empty line before top declaration. +dotnet_diagnostic.RCS0050.severity = warning + +# RCS0051: Add newline between closing brace and 'while' keyword (or vice versa). +dotnet_diagnostic.RCS0051.severity = warning + +# RCS0052: Add newline before equals sign instead of after it (or vice versa). +dotnet_diagnostic.RCS0052.severity = warning + +# RCS0053: Fix formatting of a list. +dotnet_diagnostic.RCS0053.severity = warning + +# RCS0054: Fix formatting of a call chain. +dotnet_diagnostic.RCS0054.severity = warning + +# RCS0055: Fix formatting of a binary expression chain. +dotnet_diagnostic.RCS0055.severity = warning + +# RCS0056: A line is too long. +dotnet_diagnostic.RCS0056.severity = suggestion + +# RCS0057: Normalize whitespace at the beginning of a file. +dotnet_diagnostic.RCS0057.severity = warning + +# RCS0058: Normalize whitespace at the end of a file. +dotnet_diagnostic.RCS0058.severity = warning + +# RCS0059: Place new line after/before null-conditional operator. +dotnet_diagnostic.RCS0059.severity = warning + +# RCS1001: Add braces (when expression spans over multiple lines). +dotnet_diagnostic.RCS1001.severity = warning + +# RCS1002: Remove braces. +dotnet_diagnostic.RCS1002.severity = none + +# RCS1002FadeOut: Remove braces. (NotConfigurable) +#dotnet_diagnostic.RCS1002FadeOut.severity = silent + +# RCS1003: Add braces to if-else (when expression spans over multiple lines). +dotnet_diagnostic.RCS1003.severity = warning + +# RCS1004: Remove braces from if-else. +dotnet_diagnostic.RCS1004.severity = none + +# RCS1004FadeOut: Remove braces from if-else. (NotConfigurable) +#dotnet_diagnostic.RCS1004FadeOut.severity = silent + +# RCS1005: Simplify nested using statement. +dotnet_diagnostic.RCS1005.severity = warning + +# RCS1005FadeOut: Simplify nested using statement. (NotConfigurable) +#dotnet_diagnostic.RCS1005FadeOut.severity = silent + +# RCS1006: Merge 'else' with nested 'if'. +dotnet_diagnostic.RCS1006.severity = warning + +# RCS1006FadeOut: Merge 'else' with nested 'if'. (NotConfigurable) +#dotnet_diagnostic.RCS1006FadeOut.severity = silent + +# RCS1007: Add braces. +dotnet_diagnostic.RCS1007.severity = warning + +# RCS1008: Use explicit type instead of 'var' (when the type is not obvious). +dotnet_diagnostic.RCS1008.severity = none + +# RCS1009: Use explicit type instead of 'var' (foreach variable). +dotnet_diagnostic.RCS1009.severity = none + +# RCS1010: Use 'var' instead of explicit type (when the type is obvious). +dotnet_diagnostic.RCS1010.severity = warning + +# RCS1012: Use explicit type instead of 'var' (when the type is obvious). +dotnet_diagnostic.RCS1012.severity = none + +# RCS1013: Use predefined type. +dotnet_diagnostic.RCS1013.severity = warning + +# RCS1014: Use explicitly typed array (or vice versa). +dotnet_diagnostic.RCS1014.severity = warning + +# RCS1015: Use nameof operator. +dotnet_diagnostic.RCS1015.severity = warning + +# RCS1015FadeOut: Use nameof operator. (NotConfigurable) +#dotnet_diagnostic.RCS1015FadeOut.severity = silent + +# RCS1016: Use expression-bodied member. +dotnet_diagnostic.RCS1016.severity = suggestion + +# RCS1016FadeOut: Convert block body to expression-body (or vice versa). (NotConfigurable) +#dotnet_diagnostic.RCS1016FadeOut.severity = silent + +# RCS1018: Add accessibility modifiers. +dotnet_diagnostic.RCS1018.severity = warning + +# RCS1019: Order modifiers. +dotnet_diagnostic.RCS1019.severity = warning + +# RCS1020: Simplify Nullable to T?. +dotnet_diagnostic.RCS1020.severity = warning + +# RCS1021: Convert lambda expression body to expression-body. +dotnet_diagnostic.RCS1021.severity = warning + +# RCS1021FadeOut: Convert lambda expression body to expression-body. (NotConfigurable) +#dotnet_diagnostic.RCS1021FadeOut.severity = silent + +# RCS1031: Remove unnecessary braces. +dotnet_diagnostic.RCS1031.severity = none + +# RCS1031FadeOut: Remove unnecessary braces. (NotConfigurable) +#dotnet_diagnostic.RCS1031FadeOut.severity = silent + +# RCS1032: Remove redundant parentheses. +dotnet_diagnostic.RCS1032.severity = warning + +# RCS1032FadeOut: Remove redundant parentheses. (NotConfigurable) +#dotnet_diagnostic.RCS1032FadeOut.severity = silent + +# RCS1033: Remove redundant boolean literal. +dotnet_diagnostic.RCS1033.severity = warning + +# RCS1034: Remove redundant 'sealed' modifier. +dotnet_diagnostic.RCS1034.severity = warning + +# RCS1035: Remove redundant comma in initializer. +dotnet_diagnostic.RCS1035.severity = warning + +# RCS1036: Remove redundant empty line. +dotnet_diagnostic.RCS1036.severity = warning + +# RCS1037: Remove trailing white-space. +dotnet_diagnostic.RCS1037.severity = warning + +# RCS1038: Remove empty statement. +dotnet_diagnostic.RCS1038.severity = warning + +# RCS1039: Remove argument list from attribute. +dotnet_diagnostic.RCS1039.severity = warning + +# RCS1040: Remove empty 'else' clause. +dotnet_diagnostic.RCS1040.severity = warning + +# RCS1041: Remove empty initializer. +dotnet_diagnostic.RCS1041.severity = warning + +# RCS1042: Remove enum default underlying type. +dotnet_diagnostic.RCS1042.severity = warning + +# RCS1043: Remove 'partial' modifier from type with a single part. +dotnet_diagnostic.RCS1043.severity = warning + +# RCS1044: Remove original exception from throw statement. +dotnet_diagnostic.RCS1044.severity = warning + +# RCS1046: Asynchronous method name should end with 'Async'. +dotnet_diagnostic.RCS1046.severity = warning + +# RCS1047: Non-asynchronous method name should not end with 'Async'. +dotnet_diagnostic.RCS1047.severity = warning + +# RCS1047FadeOut: Non-asynchronous method name should not end with 'Async'. (NotConfigurable) +#dotnet_diagnostic.RCS1047FadeOut.severity = silent + +# RCS1048: Use lambda expression instead of anonymous method. +dotnet_diagnostic.RCS1048.severity = warning + +# RCS1048FadeOut: Use lambda expression instead of anonymous method. (NotConfigurable) +#dotnet_diagnostic.RCS1048FadeOut.severity = silent + +# RCS1049: Simplify boolean comparison. +dotnet_diagnostic.RCS1049.severity = warning + +# RCS1049FadeOut: Simplify boolean comparison. (NotConfigurable) +#dotnet_diagnostic.RCS1049FadeOut.severity = silent + +# RCS1050: Add argument list to object creation expression (or vice versa). +dotnet_diagnostic.RCS1050.severity = warning + +# RCS1051: Parenthesize condition of conditional expression. +dotnet_diagnostic.RCS1051.severity = warning + +# RCS1052: Declare each attribute separately. +dotnet_diagnostic.RCS1052.severity = warning + +# RCS1055: Avoid semicolon at the end of declaration. +dotnet_diagnostic.RCS1055.severity = warning + +# RCS1056: Avoid usage of using alias directive. +dotnet_diagnostic.RCS1056.severity = warning + +# RCS1058: Use compound assignment. +dotnet_diagnostic.RCS1058.severity = warning + +# RCS1058FadeOut: Use compound assignment. (NotConfigurable) +#dotnet_diagnostic.RCS1058FadeOut.severity = silent + +# RCS1059: Avoid locking on publicly accessible instance. +dotnet_diagnostic.RCS1059.severity = warning + +# RCS1060: Declare each type in separate file. +dotnet_diagnostic.RCS1060.severity = warning + +# RCS1061: Merge 'if' with nested 'if'. +dotnet_diagnostic.RCS1061.severity = warning + +# RCS1061FadeOut: Merge 'if' with nested 'if'. (NotConfigurable) +#dotnet_diagnostic.RCS1061FadeOut.severity = silent + +# RCS1063: Avoid usage of do statement to create an infinite loop. +dotnet_diagnostic.RCS1063.severity = warning + +# RCS1064: Avoid usage of for statement to create an infinite loop. +dotnet_diagnostic.RCS1064.severity = warning + +# RCS1065: Avoid usage of while statement to create an inifinite loop. +dotnet_diagnostic.RCS1065.severity = none + +# RCS1066: Remove empty 'finally' clause. +dotnet_diagnostic.RCS1066.severity = warning + +# RCS1066FadeOut: Remove empty 'finally' clause. (NotConfigurable) +#dotnet_diagnostic.RCS1066FadeOut.severity = silent + +# RCS1068: Simplify logical negation. +dotnet_diagnostic.RCS1068.severity = warning + +# RCS1069: Remove unnecessary case label. +dotnet_diagnostic.RCS1069.severity = warning + +# RCS1070: Remove redundant default switch section. +dotnet_diagnostic.RCS1070.severity = warning + +# RCS1071: Remove redundant base constructor call. +dotnet_diagnostic.RCS1071.severity = warning + +# RCS1072: Remove empty namespace declaration. +dotnet_diagnostic.RCS1072.severity = warning + +# RCS1073: Convert 'if' to 'return' statement. +dotnet_diagnostic.RCS1073.severity = warning + +# RCS1073FadeOut: Convert 'if' to 'return' statement. (NotConfigurable) +#dotnet_diagnostic.RCS1073FadeOut.severity = silent + +# RCS1074: Remove redundant constructor. +dotnet_diagnostic.RCS1074.severity = warning + +# RCS1075: Avoid empty catch clause that catches System.Exception. +dotnet_diagnostic.RCS1075.severity = warning + +# RCS1077: Optimize LINQ method call. +dotnet_diagnostic.RCS1077.severity = warning + +# RCS1078: Use "" instead of string.Empty. +dotnet_diagnostic.RCS1078.severity = warning + +# RCS1079: Throwing of new NotImplementedException. +dotnet_diagnostic.RCS1079.severity = warning + +# RCS1080: Use 'Count/Length' property instead of 'Any' method. +dotnet_diagnostic.RCS1080.severity = warning + +# RCS1081: Split variable declaration. +dotnet_diagnostic.RCS1081.severity = warning + +# RCS1084: Use coalesce expression instead of conditional expression. +dotnet_diagnostic.RCS1084.severity = warning + +# RCS1085: Use auto-implemented property. +dotnet_diagnostic.RCS1085.severity = warning + +# RCS1085FadeOut: Use auto-implemented property. (NotConfigurable) +#dotnet_diagnostic.RCS1085FadeOut.severity = silent + +# RCS1089: Use --/++ operator instead of assignment. +dotnet_diagnostic.RCS1089.severity = warning + +# RCS1089: Use --/++ operator instead of assignment. (NotConfigurable) +#dotnet_diagnostic.RCS1089FadeOut.severity = silent + +# RCS1090: Call 'ConfigureAwait(false)'. +dotnet_diagnostic.RCS1090.severity = warning + +# RCS1091: Remove empty region. +dotnet_diagnostic.RCS1091.severity = warning + +# RCS1091FadeOut: Remove empty region. (NotConfigurable) +#dotnet_diagnostic.RCS1091FadeOut.severity = silent + +# RCS1093: Remove file with no code. +dotnet_diagnostic.RCS1093.severity = warning + +# RCS1094: Declare using directive on top level. +dotnet_diagnostic.RCS1094.severity = warning + +# RCS1096: Convert 'HasFlag' call to bitwise operation (or vice versa). +dotnet_diagnostic.RCS1096.severity = warning + +# RCS1097: Remove redundant 'ToString' call. +dotnet_diagnostic.RCS1097.severity = warning + +# RCS1098: Constant values should be placed on right side of comparisons. +dotnet_diagnostic.RCS1098.severity = warning + +# RCS1099: Default label should be the last label in a switch section. +dotnet_diagnostic.RCS1099.severity = warning + +# RCS1100: [deprecated] Format documentation summary on a single line. +dotnet_diagnostic.RCS1100.severity = none + +# RCS1101: [deprecated] Format documentation summary on multiple lines. +dotnet_diagnostic.RCS1101.severity = none + +# RCS1102: Make class static. +dotnet_diagnostic.RCS1102.severity = warning + +# RCS1103: Convert 'if' to assignment. +dotnet_diagnostic.RCS1103.severity = warning + +# RCS1104: Simplify conditional expression. +dotnet_diagnostic.RCS1104.severity = warning + +# RCS1105: Unncessary interpolation. +dotnet_diagnostic.RCS1105.severity = warning + +# RCS1106: Remove empty destructor. +dotnet_diagnostic.RCS1106.severity = warning + +# RCS1107: Remove redundant 'ToCharArray' call. +dotnet_diagnostic.RCS1107.severity = warning + +# RCS1108: Add 'static' modifier to all partial class declarations. +dotnet_diagnostic.RCS1108.severity = warning + +# RCS1110: Declare type inside namespace. +dotnet_diagnostic.RCS1110.severity = warning + +# RCS1111: Add braces to switch section with multiple statements. +dotnet_diagnostic.RCS1111.severity = warning + +# RCS1112: Combine 'Enumerable.Where' method chain. +dotnet_diagnostic.RCS1112.severity = warning + +# RCS1112FadeOut: Combine 'Enumerable.Where' method chain. (NotConfigurable) +#dotnet_diagnostic.RCS1112FadeOut.severity = silent + +# RCS1113: Use 'string.IsNullOrEmpty' method. +dotnet_diagnostic.RCS1113.severity = warning + +# RCS1114: Remove redundant delegate creation. +dotnet_diagnostic.RCS1114.severity = warning + +# RCS1114FadeOut: Remove redundant delegate creation. (NotConfigurable) +#dotnet_diagnostic.RCS1114FadeOut.severity = silent + +# RCS1118: Mark local variable as const. +dotnet_diagnostic.RCS1118.severity = warning + +# RCS1123: Add parentheses when necessary. +dotnet_diagnostic.RCS1123.severity = warning + +# RCS1124: Inline local variable. +dotnet_diagnostic.RCS1124.severity = suggestion + +# RCS1124FadeOut: Inline local variable. (NotConfigurable) +#dotnet_diagnostic.RCS1124FadeOut.severity = silent + +# RCS1126: Add braces to if-else. +dotnet_diagnostic.RCS1126.severity = warning + +# RCS1128: Use coalesce expression. +dotnet_diagnostic.RCS1128.severity = warning + +# RCS1129: Remove redundant field initalization. +dotnet_diagnostic.RCS1129.severity = warning + +# RCS1130: Bitwise operation on enum without Flags attribute. +dotnet_diagnostic.RCS1130.severity = warning + +# RCS1132: Remove redundant overriding member. +dotnet_diagnostic.RCS1132.severity = warning + +# RCS1133: Remove redundant Dispose/Close call. +dotnet_diagnostic.RCS1133.severity = warning + +# RCS1134: Remove redundant statement. +dotnet_diagnostic.RCS1134.severity = warning + +# RCS1135: Declare enum member with zero value (when enum has FlagsAttribute). +dotnet_diagnostic.RCS1135.severity = warning + +# RCS1136: Merge switch sections with equivalent content. +dotnet_diagnostic.RCS1136.severity = warning + +# RCS1138: Add summary to documentation comment. +dotnet_diagnostic.RCS1138.severity = warning + +# RCS1139: Add summary element to documentation comment. +dotnet_diagnostic.RCS1139.severity = warning + +# RCS1140: Add exception to documentation comment. +dotnet_diagnostic.RCS1140.severity = warning + +# RCS1141: Add 'param' element to documentation comment. +dotnet_diagnostic.RCS1141.severity = warning + +# RCS1142: Add 'typeparam' element to documentation comment. +dotnet_diagnostic.RCS1142.severity = warning + +# RCS1143: Simplify coalesce expression. +dotnet_diagnostic.RCS1143.severity = warning + +# RCS1145: Remove redundant 'as' operator. +dotnet_diagnostic.RCS1145.severity = warning + +# RCS1146: Use conditional access. +dotnet_diagnostic.RCS1146.severity = warning + +# RCS1151: Remove redundant cast. +dotnet_diagnostic.RCS1151.severity = warning + +# RCS1154: Sort enum members. +dotnet_diagnostic.RCS1154.severity = warning + +# RCS1155: Use StringComparison when comparing strings. +dotnet_diagnostic.RCS1155.severity = warning + +# RCS1156: Use string.Length instead of comparison with empty string. +dotnet_diagnostic.RCS1156.severity = warning + +# RCS1157: Composite enum value contains undefined flag. +dotnet_diagnostic.RCS1157.severity = warning + +# RCS1158: Static member in generic type should use a type parameter. +dotnet_diagnostic.RCS1158.severity = warning + +# RCS1159: Use EventHandler. +dotnet_diagnostic.RCS1159.severity = warning + +# RCS1160: Abstract type should not have public constructors. +dotnet_diagnostic.RCS1160.severity = warning + +# RCS1161: Enum should declare explicit values. +dotnet_diagnostic.RCS1161.severity = warning + +# RCS1162: Avoid chain of assignments. +dotnet_diagnostic.RCS1162.severity = warning + +# RCS1163: Unused parameter. +dotnet_diagnostic.RCS1163.severity = warning + +# RCS1164: Unused type parameter. +dotnet_diagnostic.RCS1164.severity = warning + +# RCS1165: Unconstrained type parameter checked for null. +dotnet_diagnostic.RCS1165.severity = warning + +# RCS1166: Value type object is never equal to null. +dotnet_diagnostic.RCS1166.severity = warning + +# RCS1168: Parameter name differs from base name. +dotnet_diagnostic.RCS1168.severity = warning + +# RCS1169: Make field read-only. +dotnet_diagnostic.RCS1169.severity = warning + +# RCS1170: Use read-only auto-implemented property. +dotnet_diagnostic.RCS1170.severity = warning + +# RCS1171: Simplify lazy initialization. +dotnet_diagnostic.RCS1171.severity = suggestion + +# RCS1172: Use 'is' operator instead of 'as' operator. +dotnet_diagnostic.RCS1172.severity = warning + +# RCS1173: Use coalesce expression instead of 'if'. +dotnet_diagnostic.RCS1173.severity = warning + +# RCS1174: Remove redundant async/await. +dotnet_diagnostic.RCS1174.severity = warning + +# RCS1174FadeOut: Remove redundant async/await. (NotConfigurable) +#dotnet_diagnostic.RCS1174FadeOut.severity = silent + +# RCS1175: Unused this parameter. +dotnet_diagnostic.RCS1175.severity = warning + +# RCS1176: Use 'var' instead of explicit type (when the type is not obvious). +dotnet_diagnostic.RCS1176.severity = warning + +# RCS1177: Use 'var' instead of explicit type (in foreach). +dotnet_diagnostic.RCS1177.severity = warning + +# RCS1179: Unnecessary assignment. +dotnet_diagnostic.RCS1179.severity = warning + +# RCS1180: Inline lazy initialization. +dotnet_diagnostic.RCS1180.severity = suggestion + +# RCS1181: Convert comment to documentation comment. +dotnet_diagnostic.RCS1181.severity = warning + +# RCS1182: Remove redundant base interface. +dotnet_diagnostic.RCS1182.severity = warning + +# RCS1186: Use Regex instance instead of static method. +dotnet_diagnostic.RCS1186.severity = warning + +# RCS1187: Use constant instead of field. +dotnet_diagnostic.RCS1187.severity = warning + +# RCS1188: Remove redundant auto-property initialization. +dotnet_diagnostic.RCS1188.severity = warning + +# RCS1189: Add or remove region name. +dotnet_diagnostic.RCS1189.severity = warning + +# RCS1190: Join string expressions. +dotnet_diagnostic.RCS1190.severity = warning + +# RCS1191: Declare enum value as combination of names. +dotnet_diagnostic.RCS1191.severity = warning + +# RCS1192: Unnecessary usage of verbatim string literal. +dotnet_diagnostic.RCS1192.severity = warning + +# RCS1193: Overriding member should not change 'params' modifier. +dotnet_diagnostic.RCS1193.severity = warning + +# RCS1194: Implement exception constructors. +dotnet_diagnostic.RCS1194.severity = warning + +# RCS1195: Use ^ operator. +dotnet_diagnostic.RCS1195.severity = warning + +# RCS1196: Call extension method as instance method. +dotnet_diagnostic.RCS1196.severity = warning + +# RCS1197: Optimize StringBuilder.Append/AppendLine call. +dotnet_diagnostic.RCS1197.severity = warning + +# RCS1198: Avoid unnecessary boxing of value type. +dotnet_diagnostic.RCS1198.severity = warning + +# RCS1199: Unnecessary null check. +dotnet_diagnostic.RCS1199.severity = warning + +# RCS1200: Call 'Enumerable.ThenBy' instead of 'Enumerable.OrderBy'. +dotnet_diagnostic.RCS1200.severity = warning + +# RCS1201: Use method chaining. +dotnet_diagnostic.RCS1201.severity = warning + +# RCS1202: Avoid NullReferenceException. +dotnet_diagnostic.RCS1202.severity = warning + +# RCS1203: Use AttributeUsageAttribute. +dotnet_diagnostic.RCS1203.severity = warning + +# RCS1204: Use EventArgs.Empty. +dotnet_diagnostic.RCS1204.severity = warning + +# RCS1205: Order named arguments according to the order of parameters. +dotnet_diagnostic.RCS1205.severity = warning + +# RCS1206: Use conditional access instead of conditional expression. +dotnet_diagnostic.RCS1206.severity = warning + +# RCS1207: Convert anonymous function to method group. +dotnet_diagnostic.RCS1207.severity = warning + +# RCS1207FadeOut: Convert anonymous function to method group. (NotConfigurable) +#dotnet_diagnostic.RCS1207FadeOut.severity = silent + +# RCS1208: Reduce 'if' nesting. +dotnet_diagnostic.RCS1208.severity = warning + +# RCS1209: Order type parameter constraints. +dotnet_diagnostic.RCS1209.severity = warning + +# RCS1210: Return Task.FromResult instead of returning null. +dotnet_diagnostic.RCS1210.severity = warning + +# RCS1211: Remove unnecessary 'else'. +dotnet_diagnostic.RCS1211.severity = warning + +# RCS1212: Remove redundant assignment. +dotnet_diagnostic.RCS1212.severity = warning + +# RCS1212FadeOut: Remove redundant assignment. (NotConfigurable) +#dotnet_diagnostic.RCS1212FadeOut.severity = silent + +# RCS1213: Remove unused member declaration. +dotnet_diagnostic.RCS1213.severity = warning + +# RCS1214: Unnecessary interpolated string. +dotnet_diagnostic.RCS1214.severity = warning + +# RCS1214FadeOut: Unnecessary interpolated string. (NotConfigurable) +#dotnet_diagnostic.RCS1214FadeOut.severity = silent + +# RCS1215: Expression is always equal to true/false. +dotnet_diagnostic.RCS1215.severity = warning + +# RCS1216: Unnecessary unsafe context. +dotnet_diagnostic.RCS1216.severity = warning + +# RCS1217: Convert interpolated string to concatenation. +dotnet_diagnostic.RCS1217.severity = warning + +# RCS1217FadeOut: Convert interpolated string to concatenation. (NotConfigurable) +#dotnet_diagnostic.RCS1217FadeOut.severity = silent + +# RCS1218: Simplify code branching. +dotnet_diagnostic.RCS1218.severity = warning + +# RCS1220: Use pattern matching instead of combination of 'is' operator and cast operator. +dotnet_diagnostic.RCS1220.severity = warning + +# RCS1221: Use pattern matching instead of combination of 'as' operator and null check. +dotnet_diagnostic.RCS1221.severity = warning + +# RCS1222: Merge preprocessor directives. +dotnet_diagnostic.RCS1222.severity = warning + +# RCS1223: Mark publicly visible type with DebuggerDisplay attribute. +dotnet_diagnostic.RCS1223.severity = silent + +# RCS1224: Make method an extension method. +dotnet_diagnostic.RCS1224.severity = warning + +# RCS1225: Make class sealed. +dotnet_diagnostic.RCS1225.severity = warning + +# RCS1226: Add paragraph to documentation comment. +dotnet_diagnostic.RCS1226.severity = warning + +# RCS1227: Validate arguments correctly. +dotnet_diagnostic.RCS1227.severity = warning + +# RCS1228: Unused element in documentation comment. +dotnet_diagnostic.RCS1228.severity = warning + +# RCS1228FadeOut: Unused element in documentation comment. (NotConfigurable) +#dotnet_diagnostic.RCS1228FadeOut.severity = silent + +# RCS1229: Use async/await when necessary. +dotnet_diagnostic.RCS1229.severity = warning + +# RCS1230: Unnecessary explicit use of enumerator. +dotnet_diagnostic.RCS1230.severity = warning + +# RCS1231: Make parameter ref read-only. +dotnet_diagnostic.RCS1231.severity = suggestion + +# RCS1232: Order elements in documentation comment. +dotnet_diagnostic.RCS1232.severity = warning + +# RCS1233: Use short-circuiting operator. +dotnet_diagnostic.RCS1233.severity = warning + +# RCS1234: Duplicate enum value. +dotnet_diagnostic.RCS1234.severity = warning + +# RCS1235: Optimize method call. +dotnet_diagnostic.RCS1235.severity = warning + +# RCS1236: Use exception filter. +dotnet_diagnostic.RCS1236.severity = warning + +# RCS1237: Use bit shift operator. +dotnet_diagnostic.RCS1237.severity = suggestion + +# RCS1238: Avoid nested ?: operators. +dotnet_diagnostic.RCS1238.severity = suggestion + +# RCS1239: Use 'for' statement instead of 'while' statement. +dotnet_diagnostic.RCS1239.severity = warning + +# RCS1240: Operator is unnecessary. +dotnet_diagnostic.RCS1240.severity = warning + +# RCS1241: Implement non-generic counterpart. +dotnet_diagnostic.RCS1241.severity = warning + +# RCS1242: Do not pass non-read-only struct by read-only reference. +dotnet_diagnostic.RCS1242.severity = warning + +# RCS1243: Duplicate word in a comment. +dotnet_diagnostic.RCS1243.severity = warning + +# RCS1244: Simplify 'default' expression. +dotnet_diagnostic.RCS1244.severity = warning + +# RCS1246: Use element access. +dotnet_diagnostic.RCS1246.severity = warning + +# RCS1247: Fix documentation comment tag. +dotnet_diagnostic.RCS1247.severity = warning + +# RCS1248: Normalize null check. +dotnet_diagnostic.RCS1248.severity = warning + +# RCS1249: Unnecessary null-forgiving operator. +dotnet_diagnostic.RCS1249.severity = warning + +# RCS1250: Use implicit/explicit object creation. +dotnet_diagnostic.RCS1250.severity = warning + +# RCS1251: Remove unnecessary braces from record declaration. +dotnet_diagnostic.RCS1251.severity = warning + +# RCS1252: Normalize usage of infinite loop. +dotnet_diagnostic.RCS1252.severity = warning + +# RCS1253: Format documentation comment summary. +dotnet_diagnostic.RCS1253.severity = warning + +# RCS1254: Normalize format of enum flag value. +dotnet_diagnostic.RCS1254.severity = warning + +# ROS0001: Analyzer is obsolete. +dotnet_diagnostic.ROS0001.severity = warning + +# ROS0002: Analyzer option is obsolete. +dotnet_diagnostic.ROS0002.severity = warning + +# ROS0003: Analyzer requires config option to be specified. +dotnet_diagnostic.ROS0003.severity = warning + +## SonarAnalyzer.CSharp + +# S100: Methods and properties should be named in PascalCase +dotnet_diagnostic.S100.severity = warning + +# S1006: Method overrides should not change parameter defaults +dotnet_diagnostic.S1006.severity = warning + +# S101: Types should be named in PascalCase +dotnet_diagnostic.S101.severity = warning + +# S103: Lines should not be too long +dotnet_diagnostic.S103.severity = suggestion + +# S104: Files should not have too many lines of code +dotnet_diagnostic.S104.severity = suggestion + +# S1048: Destructors should not throw exceptions +dotnet_diagnostic.S1048.severity = warning + +# S105: Tabulation characters should not be used +dotnet_diagnostic.S105.severity = none + +# S106: Standard outputs should not be used directly to log anything +dotnet_diagnostic.S106.severity = warning + +# S1066: Collapsible "if" statements should be merged +dotnet_diagnostic.S1066.severity = warning + +# S1067: Expressions should not be too complex +dotnet_diagnostic.S1067.severity = suggestion + +# S107: Methods should not have too many parameters +dotnet_diagnostic.S107.severity = suggestion + +# S1075: URIs should not be hardcoded +dotnet_diagnostic.S1075.severity = warning + +# S108: Nested blocks of code should not be left empty +dotnet_diagnostic.S108.severity = warning + +# S109: Magic numbers should not be used +dotnet_diagnostic.S109.severity = warning + +# S110: Inheritance tree of classes should not be too deep +dotnet_diagnostic.S110.severity = suggestion + +# S1104: Fields should not have public accessibility +dotnet_diagnostic.S1104.severity = warning + +# S1109: A close curly brace should be located at the beginning of a line +dotnet_diagnostic.S1109.severity = warning + +# S1110: Redundant pairs of parentheses should be removed +dotnet_diagnostic.S1110.severity = warning + +# S1116: Empty statements should be removed +dotnet_diagnostic.S1116.severity = warning + +# S1117: Local variables should not shadow class fields +dotnet_diagnostic.S1117.severity = warning + +# S1118: Utility classes should not have public constructors +dotnet_diagnostic.S1118.severity = warning + +# S112: General exceptions should never be thrown +dotnet_diagnostic.S112.severity = warning + +# S1121: Assignments should not be made from within sub-expressions +dotnet_diagnostic.S1121.severity = warning + +# S1123: "Obsolete" attributes should include explanations +dotnet_diagnostic.S1123.severity = warning + +# S1125: Boolean literals should not be redundant +dotnet_diagnostic.S1125.severity = warning + +# S1128: Unused "using" should be removed +dotnet_diagnostic.S1128.severity = warning + +# S113: Files should contain an empty newline at the end +dotnet_diagnostic.S113.severity = warning + +# S1134: Track uses of "FIXME" tags +dotnet_diagnostic.S1134.severity = warning + +# S1135: Track uses of "TODO" tags +dotnet_diagnostic.S1135.severity = warning + +# S1144: Unused private types or members should be removed +dotnet_diagnostic.S1144.severity = warning + +# S1147: Exit methods should not be called +dotnet_diagnostic.S1147.severity = warning + +# S1151: "switch case" clauses should not have too many lines of code +dotnet_diagnostic.S1151.severity = suggestion + +# S1155: "Any()" should be used to test for emptiness +dotnet_diagnostic.S1155.severity = warning + +# S1163: Exceptions should not be thrown in finally blocks +dotnet_diagnostic.S1163.severity = warning + +# S1168: Empty arrays and collections should be returned instead of null +dotnet_diagnostic.S1168.severity = warning + +# S1172: Unused method parameters should be removed +dotnet_diagnostic.S1172.severity = warning + +# S1185: Overriding members should do more than simply call the same member in the base class +dotnet_diagnostic.S1185.severity = warning + +# S1186: Methods should not be empty +dotnet_diagnostic.S1186.severity = warning + +# S1192: String literals should not be duplicated +dotnet_diagnostic.S1192.severity = warning + +# S1199: Nested code blocks should not be used +dotnet_diagnostic.S1199.severity = warning + +# S1200: Classes should not be coupled to too many other classes (Single Responsibility Principle) +dotnet_diagnostic.S1200.severity = suggestion + +# S1206: "Equals(Object)" and "GetHashCode()" should be overridden in pairs +dotnet_diagnostic.S1206.severity = warning + +# S121: Control structures should use curly braces +dotnet_diagnostic.S121.severity = warning + +# S1210: "Equals" and the comparison operators should be overridden when implementing "IComparable" +dotnet_diagnostic.S1210.severity = warning + +# S1215: "GC.Collect" should not be called +dotnet_diagnostic.S1215.severity = warning + +# S122: Statements should be on separate lines +dotnet_diagnostic.S122.severity = warning + +# S1226: Method parameters, caught exceptions and foreach variables' initial values should not be ignored +dotnet_diagnostic.S1226.severity = warning + +# S1227: break statements should not be used except for switch cases +dotnet_diagnostic.S1227.severity = warning + +# S1244: Floating point numbers should not be tested for equality +dotnet_diagnostic.S1244.severity = warning + +# S125: Sections of code should not be commented out +dotnet_diagnostic.S125.severity = warning + +# S126: "if ... else if" constructs should end with "else" clauses +dotnet_diagnostic.S126.severity = warning + +# S1264: A "while" loop should be used instead of a "for" loop +dotnet_diagnostic.S1264.severity = warning + +# S127: "for" loop stop conditions should be invariant +dotnet_diagnostic.S127.severity = warning + +# S1301: "switch" statements should have at least 3 "case" clauses +dotnet_diagnostic.S1301.severity = warning + +# S1309: Track uses of in-source issue suppressions +dotnet_diagnostic.S1309.severity = warning + +# S131: "switch/Select" statements should contain a "default/Case Else" clauses +dotnet_diagnostic.S131.severity = warning + +# S1313: Using hardcoded IP addresses is security-sensitive +dotnet_diagnostic.S1313.severity = warning + +# S134: Control flow statements "if", "switch", "for", "foreach", "while", "do" and "try" should not be nested too deeply +dotnet_diagnostic.S134.severity = suggestion + +# S138: Functions should not have too many lines of code +dotnet_diagnostic.S138.severity = suggestion + +# S1449: Culture should be specified for "string" operations +dotnet_diagnostic.S1449.severity = warning + +# S1450: Private fields only used as local variables in methods should become local variables +dotnet_diagnostic.S1450.severity = warning + +# S1451: Track lack of copyright and license headers +dotnet_diagnostic.S1451.severity = none + +# S1479: "switch" statements should not have too many "case" clauses +dotnet_diagnostic.S1479.severity = suggestion + +# S1481: Unused local variables should be removed +dotnet_diagnostic.S1481.severity = warning + +# S1541: Methods and properties should not be too complex +dotnet_diagnostic.S1541.severity = suggestion + +# S1607: Tests should not be ignored +dotnet_diagnostic.S1607.severity = warning + +# S1643: Strings should not be concatenated using '+' in a loop +dotnet_diagnostic.S1643.severity = warning + +# S1656: Variables should not be self-assigned +dotnet_diagnostic.S1656.severity = warning + +# S1659: Multiple variables should not be declared on the same line +dotnet_diagnostic.S1659.severity = warning + +# S1694: An abstract class should have both abstract and concrete methods +dotnet_diagnostic.S1694.severity = warning + +# S1696: NullReferenceException should not be caught +dotnet_diagnostic.S1696.severity = warning + +# S1698: "==" should not be used when "Equals" is overridden +dotnet_diagnostic.S1698.severity = warning + +# S1699: Constructors should only call non-overridable methods +dotnet_diagnostic.S1699.severity = warning + +# S1751: Loops with at most one iteration should be refactored +dotnet_diagnostic.S1751.severity = warning + +# S1764: Identical expressions should not be used on both sides of a binary operator +dotnet_diagnostic.S1764.severity = warning + +# S1821: "switch" statements should not be nested +dotnet_diagnostic.S1821.severity = warning + +# S1848: Objects should not be created to be dropped immediately without being used +dotnet_diagnostic.S1848.severity = warning + +# S1854: Unused assignments should be removed +dotnet_diagnostic.S1854.severity = warning + +# S1858: "ToString()" calls should not be redundant +dotnet_diagnostic.S1858.severity = warning + +# S1862: Related "if/else if" statements should not have the same condition +dotnet_diagnostic.S1862.severity = warning + +# S1871: Two branches in a conditional structure should not have exactly the same implementation +dotnet_diagnostic.S1871.severity = warning + +# S1905: Redundant casts should not be used +dotnet_diagnostic.S1905.severity = warning + +# S1939: Inheritance list should not be redundant +dotnet_diagnostic.S1939.severity = warning + +# S1940: Boolean checks should not be inverted +dotnet_diagnostic.S1940.severity = warning + +# S1944: Inappropriate casts should not be made +dotnet_diagnostic.S1944.severity = warning + +# S1994: "for" loop increment clauses should modify the loops' counters +dotnet_diagnostic.S1994.severity = warning + +# S2053: Hashes should include an unpredictable salt +dotnet_diagnostic.S2053.severity = warning + +# S2068: Hard-coded credentials are security-sensitive +dotnet_diagnostic.S2068.severity = warning + +# S2077: Formatting SQL queries is security-sensitive +dotnet_diagnostic.S2077.severity = warning + +# S2092: Creating cookies without the "secure" flag is security-sensitive +dotnet_diagnostic.S2092.severity = warning + +# S2114: Collections should not be passed as arguments to their own methods +dotnet_diagnostic.S2114.severity = warning + +# S2115: A secure password should be used when connecting to a database +dotnet_diagnostic.S2115.severity = warning + +# S2123: Values should not be uselessly incremented +dotnet_diagnostic.S2123.severity = warning + +# S2148: Underscores should be used to make large numbers readable +dotnet_diagnostic.S2148.severity = warning + +# S2156: "sealed" classes should not have "protected" members +dotnet_diagnostic.S2156.severity = warning + +# S2178: Short-circuit logic should be used in boolean contexts +dotnet_diagnostic.S2178.severity = warning + +# S2183: Integral numbers should not be shifted by zero or more than their number of bits-1 +dotnet_diagnostic.S2183.severity = warning + +# S2184: Results of integer division should not be assigned to floating point variables +dotnet_diagnostic.S2184.severity = warning + +# S2187: TestCases should contain tests +dotnet_diagnostic.S2187.severity = warning + +# S2190: Recursion should not be infinite +dotnet_diagnostic.S2190.severity = warning + +# S2197: Modulus results should not be checked for direct equality +dotnet_diagnostic.S2197.severity = warning + +# S2201: Return values from functions without side effects should not be ignored +dotnet_diagnostic.S2201.severity = warning + +# S2219: Runtime type checking should be simplified +dotnet_diagnostic.S2219.severity = warning + +# S2221: "Exception" should not be caught when not required by called methods +dotnet_diagnostic.S2221.severity = warning + +# S2222: Locks should be released +dotnet_diagnostic.S2222.severity = warning + +# S2223: Non-constant static fields should not be visible +dotnet_diagnostic.S2223.severity = warning + +# S2225: "ToString()" method should not return null +dotnet_diagnostic.S2225.severity = warning + +# S2228: Console logging should not be used +dotnet_diagnostic.S2228.severity = warning + +# S2234: Parameters should be passed in the correct order +dotnet_diagnostic.S2234.severity = warning + +# S2245: Using pseudorandom number generators (PRNGs) is security-sensitive +dotnet_diagnostic.S2245.severity = warning + +# S2251: A "for" loop update clause should move the counter in the right direction +dotnet_diagnostic.S2251.severity = warning + +# S2252: For-loop conditions should be true at least once +dotnet_diagnostic.S2252.severity = warning + +# S2255: Writing cookies is security-sensitive +dotnet_diagnostic.S2255.severity = warning + +# S2257: Using non-standard cryptographic algorithms is security-sensitive +dotnet_diagnostic.S2257.severity = warning + +# S2259: Null pointers should not be dereferenced +dotnet_diagnostic.S2259.severity = warning + +# S2275: Composite format strings should not lead to unexpected behavior at runtime +dotnet_diagnostic.S2275.severity = warning + +# S2290: Field-like events should not be virtual +dotnet_diagnostic.S2290.severity = warning + +# S2291: Overflow checking should not be disabled for "Enumerable.Sum" +dotnet_diagnostic.S2291.severity = warning + +# S2292: Trivial properties should be auto-implemented +dotnet_diagnostic.S2292.severity = warning + +# S2302: "nameof" should be used +dotnet_diagnostic.S2302.severity = warning + +# S2306: "async" and "await" should not be used as identifiers +dotnet_diagnostic.S2306.severity = warning + +# S2325: Methods and properties that don't access instance data should be static +dotnet_diagnostic.S2325.severity = warning + +# S2326: Unused type parameters should be removed +dotnet_diagnostic.S2326.severity = warning + +# S2327: "try" statements with identical "catch" and/or "finally" blocks should be merged +dotnet_diagnostic.S2327.severity = warning + +# S2328: "GetHashCode" should not reference mutable fields +dotnet_diagnostic.S2328.severity = warning + +# S2330: Array covariance should not be used +dotnet_diagnostic.S2330.severity = warning + +# S2333: Redundant modifiers should not be used +dotnet_diagnostic.S2333.severity = warning + +# S2339: Public constant members should not be used +dotnet_diagnostic.S2339.severity = warning + +# S2342: Enumeration types should comply with a naming convention +dotnet_diagnostic.S2342.severity = warning + +# S2344: Enumeration type names should not have "Flags" or "Enum" suffixes +dotnet_diagnostic.S2344.severity = warning + +# S2345: Flags enumerations should explicitly initialize all their members +dotnet_diagnostic.S2345.severity = warning + +# S2346: Flags enumerations zero-value members should be named "None" +dotnet_diagnostic.S2346.severity = warning + +# S2357: Fields should be private +dotnet_diagnostic.S2357.severity = warning + +# S2360: Optional parameters should not be used +dotnet_diagnostic.S2360.severity = warning + +# S2365: Properties should not make collection or array copies +dotnet_diagnostic.S2365.severity = warning + +# S2368: Public methods should not have multidimensional array parameters +dotnet_diagnostic.S2368.severity = suggestion + +# S2372: Exceptions should not be thrown from property getters +dotnet_diagnostic.S2372.severity = warning + +# S2376: Write-only properties should not be used +dotnet_diagnostic.S2376.severity = warning + +# S2386: Mutable fields should not be "public static" +dotnet_diagnostic.S2386.severity = warning + +# S2387: Child class fields should not shadow parent class fields +dotnet_diagnostic.S2387.severity = warning + +# S2436: Types and methods should not have too many generic parameters +dotnet_diagnostic.S2436.severity = suggestion + +# S2437: Silly bit operations should not be performed +dotnet_diagnostic.S2437.severity = warning + +# S2479: Whitespace and control characters in string literals should be explicit +dotnet_diagnostic.S2479.severity = warning + +# S2486: Generic exceptions should not be ignored +dotnet_diagnostic.S2486.severity = warning + +# S2551: Shared resources should not be used for locking +dotnet_diagnostic.S2551.severity = warning + +# S2583: Conditionally executed code should be reachable +dotnet_diagnostic.S2583.severity = warning + +# S2589: Boolean expressions should not be gratuitous +dotnet_diagnostic.S2589.severity = warning + +# S2612: Setting loose file permissions is security-sensitive +dotnet_diagnostic.S2612.severity = warning + +# S2674: The length returned from a stream read should be checked +dotnet_diagnostic.S2674.severity = warning + +# S2681: Multiline blocks should be enclosed in curly braces +dotnet_diagnostic.S2681.severity = warning + +# S2688: "NaN" should not be used in comparisons +dotnet_diagnostic.S2688.severity = warning + +# S2692: "IndexOf" checks should not be for positive numbers +dotnet_diagnostic.S2692.severity = warning + +# S2696: Instance members should not write to "static" fields +dotnet_diagnostic.S2696.severity = warning + +# S2699: Tests should include assertions +dotnet_diagnostic.S2699.severity = warning + +# S2701: Literal boolean values should not be used in assertions +dotnet_diagnostic.S2701.severity = warning + +# S2737: "catch" clauses should do more than rethrow +dotnet_diagnostic.S2737.severity = warning + +# S2743: Static fields should not be used in generic types +dotnet_diagnostic.S2743.severity = warning + +# S2755: XML parsers should not be vulnerable to XXE attacks +dotnet_diagnostic.S2755.severity = warning + +# S2757: "=+" should not be used instead of "+=" +dotnet_diagnostic.S2757.severity = warning + +# S2760: Sequential tests should not check the same condition +dotnet_diagnostic.S2760.severity = warning + +# S2761: Doubled prefix operators "!!" and "~~" should not be used +dotnet_diagnostic.S2761.severity = warning + +# S2857: SQL keywords should be delimited by whitespace +dotnet_diagnostic.S2857.severity = warning + +# S2930: "IDisposables" should be disposed +dotnet_diagnostic.S2930.severity = warning + +# S2931: Classes with "IDisposable" members should implement "IDisposable" +dotnet_diagnostic.S2931.severity = warning + +# S2933: Fields that are only assigned in the constructor should be "readonly" +dotnet_diagnostic.S2933.severity = warning + +# S2934: Property assignments should not be made for "readonly" fields not constrained to reference types +dotnet_diagnostic.S2934.severity = warning + +# S2952: Classes should "Dispose" of members from the classes' own "Dispose" methods +dotnet_diagnostic.S2952.severity = warning + +# S2953: Methods named "Dispose" should implement "IDisposable.Dispose" +dotnet_diagnostic.S2953.severity = warning + +# S2955: Generic parameters not constrained to reference types should not be compared to "null" +dotnet_diagnostic.S2955.severity = warning + +# S2971: "IEnumerable" LINQs should be simplified +dotnet_diagnostic.S2971.severity = warning + +# S2995: "Object.ReferenceEquals" should not be used for value types +dotnet_diagnostic.S2995.severity = warning + +# S2996: "ThreadStatic" fields should not be initialized +dotnet_diagnostic.S2996.severity = warning + +# S2997: "IDisposables" created in a "using" statement should not be returned +dotnet_diagnostic.S2997.severity = warning + +# S3005: "ThreadStatic" should not be used on non-static fields +dotnet_diagnostic.S3005.severity = warning + +# S3010: Static fields should not be updated in constructors +dotnet_diagnostic.S3010.severity = warning + +# S3011: Reflection should not be used to increase accessibility of classes, methods, or fields +dotnet_diagnostic.S3011.severity = warning + +# S3052: Members should not be initialized to default values +dotnet_diagnostic.S3052.severity = warning + +# S3059: Types should not have members with visibility set higher than the type's visibility +dotnet_diagnostic.S3059.severity = warning + +# S3060: "is" should not be used with "this" +dotnet_diagnostic.S3060.severity = warning + +# S3168: "async" methods should not return "void" +dotnet_diagnostic.S3168.severity = warning + +# S3169: Multiple "OrderBy" calls should not be used +dotnet_diagnostic.S3169.severity = warning + +# S3172: Delegates should not be subtracted +dotnet_diagnostic.S3172.severity = warning + +# S3215: "interface" instances should not be cast to concrete types +dotnet_diagnostic.S3215.severity = warning + +# S3216: "ConfigureAwait(false)" should be used +dotnet_diagnostic.S3216.severity = warning + +# S3217: "Explicit" conversions of "foreach" loops should not be used +dotnet_diagnostic.S3217.severity = warning + +# S3218: Inner class members should not shadow outer class "static" or type members +dotnet_diagnostic.S3218.severity = warning + +# S3220: Method calls should not resolve ambiguously to overloads with "params" +dotnet_diagnostic.S3220.severity = warning + +# S3234: "GC.SuppressFinalize" should not be invoked for types without destructors +dotnet_diagnostic.S3234.severity = warning + +# S3235: Redundant parentheses should not be used +dotnet_diagnostic.S3235.severity = none + +# S3236: Caller information arguments should not be provided explicitly +dotnet_diagnostic.S3236.severity = warning + +# S3237: "value" parameters should be used +dotnet_diagnostic.S3237.severity = warning + +# S3240: The simplest possible condition syntax should be used +dotnet_diagnostic.S3240.severity = warning + +# S3241: Methods should not return values that are never used +dotnet_diagnostic.S3241.severity = warning + +# S3242: Method parameters should be declared with base types +dotnet_diagnostic.S3242.severity = warning + +# S3244: Anonymous delegates should not be used to unsubscribe from Events +dotnet_diagnostic.S3244.severity = warning + +# S3246: Generic type parameters should be co/contravariant when possible +dotnet_diagnostic.S3246.severity = warning + +# S3247: Duplicate casts should not be made +dotnet_diagnostic.S3247.severity = warning + +# S3249: Classes directly extending "object" should not call "base" in "GetHashCode" or "Equals" +dotnet_diagnostic.S3249.severity = warning + +# S3251: Implementations should be provided for "partial" methods +dotnet_diagnostic.S3251.severity = warning + +# S3253: Constructor and destructor declarations should not be redundant +dotnet_diagnostic.S3253.severity = warning + +# S3254: Default parameter values should not be passed as arguments +dotnet_diagnostic.S3254.severity = warning + +# S3256: "string.IsNullOrEmpty" should be used +dotnet_diagnostic.S3256.severity = warning + +# S3257: Declarations and initializations should be as concise as possible +dotnet_diagnostic.S3257.severity = warning + +# S3260: Non-derived "private" classes and records should be "sealed" +dotnet_diagnostic.S3260.severity = warning + +# S3261: Namespaces should not be empty +dotnet_diagnostic.S3261.severity = warning + +# S3262: "params" should be used on overrides +dotnet_diagnostic.S3262.severity = warning + +# S3263: Static fields should appear in the order they must be initialized +dotnet_diagnostic.S3263.severity = warning + +# S3264: Events should be invoked +dotnet_diagnostic.S3264.severity = warning + +# S3265: Non-flags enums should not be used in bitwise operations +dotnet_diagnostic.S3265.severity = warning + +# S3267: Loops should be simplified with "LINQ" expressions +dotnet_diagnostic.S3267.severity = warning + +# S3329: Cipher Block Chaining IV's should be unpredictable +dotnet_diagnostic.S3329.severity = warning + +# S3330: Creating cookies without the "HttpOnly" flag is security-sensitive +dotnet_diagnostic.S3330.severity = warning + +# S3343: Caller information parameters should come at the end of the parameter list +dotnet_diagnostic.S3343.severity = warning + +# S3346: Expressions used in "Debug.Assert" should not produce side effects +dotnet_diagnostic.S3346.severity = warning + +# S3353: Unchanged local variables should be "const" +dotnet_diagnostic.S3353.severity = warning + +# S3358: Ternary operators should not be nested +dotnet_diagnostic.S3358.severity = suggestion + +# S3366: "this" should not be exposed from constructors +dotnet_diagnostic.S3366.severity = warning + +# S3376: Attribute, EventArgs, and Exception type names should end with the type being extended +dotnet_diagnostic.S3376.severity = warning + +# S3397: "base.Equals" should not be used to check for reference equality in "Equals" if "base" is not "object" +dotnet_diagnostic.S3397.severity = warning + +# S3400: Methods should not return constants +dotnet_diagnostic.S3400.severity = warning + +# S3415: Assertion arguments should be passed in the correct order +dotnet_diagnostic.S3415.severity = warning + +# S3427: Method overloads with default parameter values should not overlap +dotnet_diagnostic.S3427.severity = warning + +# S3431: "[ExpectedException]" should not be used +dotnet_diagnostic.S3431.severity = warning + +# S3433: Test method signatures should be correct +dotnet_diagnostic.S3433.severity = warning + +# S3440: Variables should not be checked against the values they're about to be assigned +dotnet_diagnostic.S3440.severity = warning + +# S3441: Redundant property names should be omitted in anonymous classes +dotnet_diagnostic.S3441.severity = warning + +# S3442: "abstract" classes should not have "public" constructors +dotnet_diagnostic.S3442.severity = warning + +# S3443: Type should not be examined on "System.Type" instances +dotnet_diagnostic.S3443.severity = warning + +# S3444: Interfaces should not simply inherit from base interfaces with colliding members +dotnet_diagnostic.S3444.severity = warning + +# S3445: Exceptions should not be explicitly rethrown +dotnet_diagnostic.S3445.severity = warning + +# S3447: "[Optional]" should not be used on "ref" or "out" parameters +dotnet_diagnostic.S3447.severity = warning + +# S3449: Right operands of shift operators should be integers +dotnet_diagnostic.S3449.severity = warning + +# S3450: Parameters with "[DefaultParameterValue]" attributes should also be marked "[Optional]" +dotnet_diagnostic.S3450.severity = warning + +# S3451: "[DefaultValue]" should not be used when "[DefaultParameterValue]" is meant +dotnet_diagnostic.S3451.severity = warning + +# S3453: Classes should not have only "private" constructors +dotnet_diagnostic.S3453.severity = warning + +# S3456: "string.ToCharArray()" should not be called redundantly +dotnet_diagnostic.S3456.severity = warning + +# S3457: Composite format strings should be used correctly +dotnet_diagnostic.S3457.severity = warning + +# S3458: Empty "case" clauses that fall through to the "default" should be omitted +dotnet_diagnostic.S3458.severity = warning + +# S3459: Unassigned members should be removed +dotnet_diagnostic.S3459.severity = warning + +# S3464: Type inheritance should not be recursive +dotnet_diagnostic.S3464.severity = warning + +# S3466: Optional parameters should be passed to "base" calls +dotnet_diagnostic.S3466.severity = warning + +# S3532: Empty "default" clauses should be removed +dotnet_diagnostic.S3532.severity = warning + +# S3597: "ServiceContract" and "OperationContract" attributes should be used together +dotnet_diagnostic.S3597.severity = warning + +# S3598: One-way "OperationContract" methods should have "void" return type +dotnet_diagnostic.S3598.severity = warning + +# S3600: "params" should not be introduced on overrides +dotnet_diagnostic.S3600.severity = warning + +# S3603: Methods with "Pure" attribute should return a value +dotnet_diagnostic.S3603.severity = warning + +# S3604: Member initializer values should not be redundant +dotnet_diagnostic.S3604.severity = warning + +# S3610: Nullable type comparison should not be redundant +dotnet_diagnostic.S3610.severity = warning + +# S3626: Jump statements should not be redundant +dotnet_diagnostic.S3626.severity = warning + +# S3655: Empty nullable value should not be accessed +dotnet_diagnostic.S3655.severity = warning + +# S3717: Track use of "NotImplementedException" +dotnet_diagnostic.S3717.severity = warning + +# S3776: Cognitive Complexity of methods should not be too high +dotnet_diagnostic.S3776.severity = suggestion + +# S3869: "SafeHandle.DangerousGetHandle" should not be called +dotnet_diagnostic.S3869.severity = warning + +# S3871: Exception types should be "public" +dotnet_diagnostic.S3871.severity = warning + +# S3872: Parameter names should not duplicate the names of their methods +dotnet_diagnostic.S3872.severity = warning + +# S3874: "out" and "ref" parameters should not be used +dotnet_diagnostic.S3874.severity = suggestion + +# S3875: "operator==" should not be overloaded on reference types +dotnet_diagnostic.S3875.severity = warning + +# S3876: Strings or integral types should be used for indexers +dotnet_diagnostic.S3876.severity = warning + +# S3877: Exceptions should not be thrown from unexpected methods +dotnet_diagnostic.S3877.severity = warning + +# S3880: Finalizers should not be empty +dotnet_diagnostic.S3880.severity = warning + +# S3881: "IDisposable" should be implemented correctly +dotnet_diagnostic.S3881.severity = warning + +# S3884: "CoSetProxyBlanket" and "CoInitializeSecurity" should not be used +dotnet_diagnostic.S3884.severity = warning + +# S3885: "Assembly.Load" should be used +dotnet_diagnostic.S3885.severity = warning + +# S3887: Mutable, non-private fields should not be "readonly" +dotnet_diagnostic.S3887.severity = warning + +# S3889: Neither "Thread.Resume" nor "Thread.Suspend" should be used +dotnet_diagnostic.S3889.severity = warning + +# S3897: Classes that provide "Equals()" should implement "IEquatable" +dotnet_diagnostic.S3897.severity = warning + +# S3898: Value types should implement "IEquatable" +dotnet_diagnostic.S3898.severity = warning + +# S3900: Arguments of public methods should be validated against null +dotnet_diagnostic.S3900.severity = warning + +# S3902: "Assembly.GetExecutingAssembly" should not be called +dotnet_diagnostic.S3902.severity = warning + +# S3903: Types should be defined in named namespaces +dotnet_diagnostic.S3903.severity = warning + +# S3904: Assemblies should have version information +dotnet_diagnostic.S3904.severity = warning + +# S3906: Event Handlers should have the correct signature +dotnet_diagnostic.S3906.severity = warning + +# S3908: Generic event handlers should be used +dotnet_diagnostic.S3908.severity = warning + +# S3909: Collections should implement the generic interface +dotnet_diagnostic.S3909.severity = warning + +# S3923: All branches in a conditional structure should not have exactly the same implementation +dotnet_diagnostic.S3923.severity = warning + +# S3925: "ISerializable" should be implemented correctly +dotnet_diagnostic.S3925.severity = warning + +# S3926: Deserialization methods should be provided for "OptionalField" members +dotnet_diagnostic.S3926.severity = warning + +# S3927: Serialization event handlers should be implemented correctly +dotnet_diagnostic.S3927.severity = warning + +# S3928: Parameter names used into ArgumentException constructors should match an existing one +dotnet_diagnostic.S3928.severity = warning + +# S3937: Number patterns should be regular +dotnet_diagnostic.S3937.severity = warning + +# S3949: Calculations should not overflow +dotnet_diagnostic.S3949.severity = warning + +# S3956: "Generic.List" instances should not be part of public APIs +dotnet_diagnostic.S3956.severity = warning + +# S3962: "static readonly" constants should be "const" instead +dotnet_diagnostic.S3962.severity = warning + +# S3963: "static" fields should be initialized inline +dotnet_diagnostic.S3963.severity = warning + +# S3966: Objects should not be disposed more than once +dotnet_diagnostic.S3966.severity = warning + +# S3967: Multidimensional arrays should not be used +dotnet_diagnostic.S3967.severity = suggestion + +# S3971: "GC.SuppressFinalize" should not be called +dotnet_diagnostic.S3971.severity = warning + +# S3972: Conditionals should start on new lines +dotnet_diagnostic.S3972.severity = warning + +# S3973: A conditionally executed single line should be denoted by indentation +dotnet_diagnostic.S3973.severity = warning + +# S3981: Collection sizes and array length comparisons should make sense +dotnet_diagnostic.S3981.severity = warning + +# S3984: Exceptions should not be created without being thrown +dotnet_diagnostic.S3984.severity = warning + +# S3990: Assemblies should be marked as CLS compliant +dotnet_diagnostic.S3990.severity = warning + +# S3992: Assemblies should explicitly specify COM visibility +dotnet_diagnostic.S3992.severity = warning + +# S3993: Custom attributes should be marked with "System.AttributeUsageAttribute" +dotnet_diagnostic.S3993.severity = warning + +# S3994: URI Parameters should not be strings +dotnet_diagnostic.S3994.severity = warning + +# S3995: URI return values should not be strings +dotnet_diagnostic.S3995.severity = warning + +# S3996: URI properties should not be strings +dotnet_diagnostic.S3996.severity = warning + +# S3997: String URI overloads should call "System.Uri" overloads +dotnet_diagnostic.S3997.severity = warning + +# S3998: Threads should not lock on objects with weak identity +dotnet_diagnostic.S3998.severity = warning + +# S4000: Pointers to unmanaged memory should not be visible +dotnet_diagnostic.S4000.severity = warning + +# S4002: Disposable types should declare finalizers +dotnet_diagnostic.S4002.severity = warning + +# S4004: Collection properties should be readonly +dotnet_diagnostic.S4004.severity = suggestion + +# S4005: "System.Uri" arguments should be used instead of strings +dotnet_diagnostic.S4005.severity = warning + +# S4015: Inherited member visibility should not be decreased +dotnet_diagnostic.S4015.severity = warning + +# S4016: Enumeration members should not be named "Reserved" +dotnet_diagnostic.S4016.severity = warning + +# S4017: Method signatures should not contain nested generic types +dotnet_diagnostic.S4017.severity = suggestion + +# S4018: Generic methods should provide type parameters +dotnet_diagnostic.S4018.severity = warning + +# S4019: Base class methods should not be hidden +dotnet_diagnostic.S4019.severity = warning + +# S4022: Enumerations should have "Int32" storage +dotnet_diagnostic.S4022.severity = warning + +# S4023: Interfaces should not be empty +dotnet_diagnostic.S4023.severity = suggestion + +# S4025: Child class fields should not differ from parent class fields only by capitalization +dotnet_diagnostic.S4025.severity = warning + +# S4026: Assemblies should be marked with "NeutralResourcesLanguageAttribute" +dotnet_diagnostic.S4026.severity = warning + +# S4027: Exceptions should provide standard constructors +dotnet_diagnostic.S4027.severity = warning + +# S4035: Classes implementing "IEquatable" should be sealed +dotnet_diagnostic.S4035.severity = warning + +# S4036: Searching OS commands in PATH is security-sensitive +dotnet_diagnostic.S4036.severity = warning + +# S4039: Interface methods should be callable by derived types +dotnet_diagnostic.S4039.severity = warning + +# S4040: Strings should be normalized to uppercase +dotnet_diagnostic.S4040.severity = warning + +# S4041: Type names should not match namespaces +dotnet_diagnostic.S4041.severity = warning + +# S4047: Generics should be used when appropriate +dotnet_diagnostic.S4047.severity = warning + +# S4049: Properties should be preferred +dotnet_diagnostic.S4049.severity = suggestion + +# S4050: Operators should be overloaded consistently +dotnet_diagnostic.S4050.severity = warning + +# S4052: Types should not extend outdated base types +dotnet_diagnostic.S4052.severity = warning + +# S4055: Literals should not be passed as localized parameters +dotnet_diagnostic.S4055.severity = warning + +# S4056: Overloads with a "CultureInfo" or an "IFormatProvider" parameter should be used +dotnet_diagnostic.S4056.severity = warning + +# S4057: Locales should be set for data types +dotnet_diagnostic.S4057.severity = warning + +# S4058: Overloads with a "StringComparison" parameter should be used +dotnet_diagnostic.S4058.severity = warning + +# S4059: Property names should not match get methods +dotnet_diagnostic.S4059.severity = warning + +# S4060: Non-abstract attributes should be sealed +dotnet_diagnostic.S4060.severity = suggestion + +# S4061: "params" should be used instead of "varargs" +dotnet_diagnostic.S4061.severity = warning + +# S4069: Operator overloads should have named alternatives +dotnet_diagnostic.S4069.severity = warning + +# S4070: Non-flags enums should not be marked with "FlagsAttribute" +dotnet_diagnostic.S4070.severity = warning + +# S4136: Method overloads should be grouped together +dotnet_diagnostic.S4136.severity = warning + +# S4143: Collection elements should not be replaced unconditionally +dotnet_diagnostic.S4143.severity = warning + +# S4144: Methods should not have identical implementations +dotnet_diagnostic.S4144.severity = warning + +# S4158: Empty collections should not be accessed or iterated +dotnet_diagnostic.S4158.severity = warning + +# S4159: Classes should implement their "ExportAttribute" interfaces +dotnet_diagnostic.S4159.severity = warning + +# S4200: Native methods should be wrapped +dotnet_diagnostic.S4200.severity = warning + +# S4201: Null checks should not be used with "is" +dotnet_diagnostic.S4201.severity = warning + +# S4210: Windows Forms entry points should be marked with STAThread +dotnet_diagnostic.S4210.severity = warning + +# S4211: Members should not have conflicting transparency annotations +dotnet_diagnostic.S4211.severity = warning + +# S4212: Serialization constructors should be secured +dotnet_diagnostic.S4212.severity = warning + +# S4214: "P/Invoke" methods should not be visible +dotnet_diagnostic.S4214.severity = warning + +# S4220: Events should have proper arguments +dotnet_diagnostic.S4220.severity = warning + +# S4225: Extension methods should not extend "object" +dotnet_diagnostic.S4225.severity = warning + +# S4226: Extensions should be in separate namespaces +dotnet_diagnostic.S4226.severity = warning + +# S4260: "ConstructorArgument" parameters should exist in constructors +dotnet_diagnostic.S4260.severity = warning + +# S4261: Methods should be named according to their synchronicities +dotnet_diagnostic.S4261.severity = warning + +# S4275: Getters and setters should access the expected fields +dotnet_diagnostic.S4275.severity = warning + +# S4277: "Shared" parts should not be created with "new" +dotnet_diagnostic.S4277.severity = warning + +# S4423: Weak SSL/TLS protocols should not be used +dotnet_diagnostic.S4423.severity = warning + +# S4426: Cryptographic keys should be robust +dotnet_diagnostic.S4426.severity = warning + +# S4428: "PartCreationPolicyAttribute" should be used with "ExportAttribute" +dotnet_diagnostic.S4428.severity = warning + +# S4433: LDAP connections should be authenticated +dotnet_diagnostic.S4433.severity = warning + +# S4456: Parameter validation in yielding methods should be wrapped +dotnet_diagnostic.S4456.severity = warning + +# S4457: Parameter validation in "async"/"await" methods should be wrapped +dotnet_diagnostic.S4457.severity = warning + +# S4462: Calls to "async" methods should not be blocking +dotnet_diagnostic.S4462.severity = warning + +# S4487: Unread "private" fields should be removed +dotnet_diagnostic.S4487.severity = warning + +# S4502: Disabling CSRF protections is security-sensitive +dotnet_diagnostic.S4502.severity = warning + +# S4507: Delivering code in production with debug features activated is security-sensitive +dotnet_diagnostic.S4507.severity = warning + +# S4524: "default" clauses should be first or last +dotnet_diagnostic.S4524.severity = warning + +# S4564: ASP.NET HTTP request validation feature should not be disabled +dotnet_diagnostic.S4564.severity = warning + +# S4581: "new Guid()" should not be used +dotnet_diagnostic.S4581.severity = warning + +# S4583: Calls to delegate's method "BeginInvoke" should be paired with calls to "EndInvoke" +dotnet_diagnostic.S4583.severity = warning + +# S4586: Non-async "Task/Task" methods should not return null +dotnet_diagnostic.S4586.severity = warning + +# S4635: String offset-based methods should be preferred for finding substrings from offsets +dotnet_diagnostic.S4635.severity = warning + +# S4784: Using regular expressions is security-sensitive +dotnet_diagnostic.S4784.severity = warning + +# S4787: Encrypting data is security-sensitive +dotnet_diagnostic.S4787.severity = warning + +# S4790: Using weak hashing algorithms is security-sensitive +dotnet_diagnostic.S4790.severity = warning + +# S4792: Configuring loggers is security-sensitive +dotnet_diagnostic.S4792.severity = warning + +# S4818: Using Sockets is security-sensitive +dotnet_diagnostic.S4818.severity = warning + +# S4823: Using command line arguments is security-sensitive +dotnet_diagnostic.S4823.severity = warning + +# S4829: Reading the Standard Input is security-sensitive +dotnet_diagnostic.S4829.severity = warning + +# S4830: Server certificates should be verified during SSL/TLS connections +dotnet_diagnostic.S4830.severity = warning + +# S4834: Controlling permissions is security-sensitive +dotnet_diagnostic.S4834.severity = warning + +# S5034: "ValueTask" should be consumed correctly +dotnet_diagnostic.S5034.severity = warning + +# S5042: Expanding archive files is security-sensitive +dotnet_diagnostic.S5042.severity = warning + +# S5122: Having a permissive Cross-Origin Resource Sharing policy is security-sensitive +dotnet_diagnostic.S5122.severity = warning + +# S5332: Using clear-text protocols is security-sensitive +dotnet_diagnostic.S5332.severity = warning + +# S5443: Using publicly writable directories is security-sensitive +dotnet_diagnostic.S5443.severity = warning + +# S5445: Insecure temporary file creation methods should not be used +dotnet_diagnostic.S5445.severity = warning + +# S5542: Encryption algorithms should be used with secure mode and padding scheme +dotnet_diagnostic.S5542.severity = warning + +# S5547: Cipher algorithms should be robust +dotnet_diagnostic.S5547.severity = warning + +# S5659: JWT should be signed and verified with strong cipher algorithms +dotnet_diagnostic.S5659.severity = warning + +# S5693: Allowing requests with excessive content length is security-sensitive +dotnet_diagnostic.S5693.severity = warning + +# S5753: Disabling ASP.NET "Request Validation" feature is security-sensitive +dotnet_diagnostic.S5753.severity = warning + +# S5766: Deserializing objects without performing data validation is security-sensitive +dotnet_diagnostic.S5766.severity = warning + +# S5773: Types allowed to be deserialized should be restricted +dotnet_diagnostic.S5773.severity = warning + +# S6354: Use a testable date/time provider. +dotnet_diagnostic.S6354.severity = suggestion + +# S6419: Azure Functions should be stateless +dotnet_diagnostic.S6419.severity = warning + +# S6420: Client instances should not be recreated on each Azure Function invocation +dotnet_diagnostic.S6420.severity = warning + +# S6421: Azure Functions should use Structured Error Handling +dotnet_diagnostic.S6421.severity = warning + +# S6422: Calls to "async" methods should not be blocking in Azure Functions +dotnet_diagnostic.S6422.severity = warning + +# S6423: Azure Functions should log all failures +dotnet_diagnostic.S6423.severity = warning + +# S6424: Interfaces for durable entities should satisfy the restrictions +dotnet_diagnostic.S6424.severity = warning + +# S818: Literal suffixes should be upper case +dotnet_diagnostic.S818.severity = warning + +# S881: Increment (++) and decrement (--) operators should not be used in a method call or mixed with other operators in an expression +dotnet_diagnostic.S881.severity = warning + +# S907: "goto" statement should not be used +dotnet_diagnostic.S907.severity = warning + +# S927: parameter names should match base declaration and other partial definitions +dotnet_diagnostic.S927.severity = warning + +# S9999-cpd: Copy-paste token calculator (NotConfigurable) +#dotnet_diagnostic.S9999-cpd.severity = warning + +# S9999-log: Log generator (NotConfigurable) +#dotnet_diagnostic.S9999-log.severity = warning + +# S9999-metadata: File metadata generator (NotConfigurable) +#dotnet_diagnostic.S9999-metadata.severity = warning + +# S9999-metrics: Metrics calculator (NotConfigurable) +#dotnet_diagnostic.S9999-metrics.severity = warning + +# S9999-symbolRef: Symbol reference calculator (NotConfigurable) +#dotnet_diagnostic.S9999-symbolRef.severity = warning + +# S9999-token-type: Token type calculator (NotConfigurable) +#dotnet_diagnostic.S9999-token-type.severity = warning + +## StyleCop.Analyzers + +# SA0001: XML comment analysis disabled +dotnet_diagnostic.SA0001.severity = warning + +# SA0002: Invalid settings file +dotnet_diagnostic.SA0002.severity = warning + +# SA1000: Keywords should be spaced correctly +dotnet_diagnostic.SA1000.severity = warning + +# SA1001: Commas should be spaced correctly +dotnet_diagnostic.SA1001.severity = warning + +# SA1002: Semicolons should be spaced correctly +dotnet_diagnostic.SA1002.severity = warning + +# SA1003: Symbols should be spaced correctly +dotnet_diagnostic.SA1003.severity = warning + +# SA1004: Documentation lines should begin with single space +dotnet_diagnostic.SA1004.severity = warning + +# SA1005: Single line comments should begin with single space +dotnet_diagnostic.SA1005.severity = warning + +# SA1006: Preprocessor keywords should not be preceded by space +dotnet_diagnostic.SA1006.severity = warning + +# SA1007: Operator keyword should be followed by space +dotnet_diagnostic.SA1007.severity = warning + +# SA1008: Opening parenthesis should be spaced correctly +dotnet_diagnostic.SA1008.severity = warning + +# SA1009: Closing parenthesis should be spaced correctly +dotnet_diagnostic.SA1009.severity = warning + +# SA1010: Opening square brackets should be spaced correctly +dotnet_diagnostic.SA1010.severity = warning + +# SA1011: Closing square brackets should be spaced correctly +dotnet_diagnostic.SA1011.severity = warning + +# SA1012: Opening braces should be spaced correctly +dotnet_diagnostic.SA1012.severity = warning + +# SA1013: Closing braces should be spaced correctly +dotnet_diagnostic.SA1013.severity = warning + +# SA1014: Opening generic brackets should be spaced correctly +dotnet_diagnostic.SA1014.severity = warning + +# SA1015: Closing generic brackets should be spaced correctly +dotnet_diagnostic.SA1015.severity = warning + +# SA1016: Opening attribute brackets should be spaced correctly +dotnet_diagnostic.SA1016.severity = warning + +# SA1017: Closing attribute brackets should be spaced correctly +dotnet_diagnostic.SA1017.severity = warning + +# SA1018: Nullable type symbols should be spaced correctly +dotnet_diagnostic.SA1018.severity = warning + +# SA1019: Member access symbols should be spaced correctly +dotnet_diagnostic.SA1019.severity = warning + +# SA1020: Increment decrement symbols should be spaced correctly +dotnet_diagnostic.SA1020.severity = warning + +# SA1021: Negative signs should be spaced correctly +dotnet_diagnostic.SA1021.severity = warning + +# SA1022: Positive signs should be spaced correctly +dotnet_diagnostic.SA1022.severity = warning + +# SA1023: Dereference and access of symbols should be spaced correctly +dotnet_diagnostic.SA1023.severity = warning + +# SA1024: Colons Should Be Spaced Correctly +dotnet_diagnostic.SA1024.severity = warning + +# SA1025: Code should not contain multiple whitespace in a row +dotnet_diagnostic.SA1025.severity = warning + +# SA1026: Code should not contain space after new or stackalloc keyword in implicitly typed array allocation +dotnet_diagnostic.SA1026.severity = warning + +# SA1027: Use tabs correctly +dotnet_diagnostic.SA1027.severity = warning + +# SA1028: Code should not contain trailing whitespace +dotnet_diagnostic.SA1028.severity = warning + +# SA1100: Do not prefix calls with base unless local implementation exists +dotnet_diagnostic.SA1100.severity = warning + +# SA1101: Prefix local calls with this +dotnet_diagnostic.SA1101.severity = warning + +# SA1102: Query clause should follow previous clause +dotnet_diagnostic.SA1102.severity = warning + +# SA1103: Query clauses should be on separate lines or all on one line +dotnet_diagnostic.SA1103.severity = warning + +# SA1104: Query clause should begin on new line when previous clause spans multiple lines +dotnet_diagnostic.SA1104.severity = warning + +# SA1105: Query clauses spanning multiple lines should begin on own line +dotnet_diagnostic.SA1105.severity = warning + +# SA1106: Code should not contain empty statements +dotnet_diagnostic.SA1106.severity = warning + +# SA1107: Code should not contain multiple statements on one line +dotnet_diagnostic.SA1107.severity = warning + +# SA1108: Block statements should not contain embedded comments +dotnet_diagnostic.SA1108.severity = warning + +# SA1109: Block statements should not contain embedded regions (NotConfigurable) +#dotnet_diagnostic.SA1109.severity = none + +# SA1110: Opening parenthesis or bracket should be on declaration line +dotnet_diagnostic.SA1110.severity = none + +# SA1111: Closing parenthesis should be on line of last parameter +dotnet_diagnostic.SA1111.severity = none + +# SA1112: Closing parenthesis should be on line of opening parenthesis +dotnet_diagnostic.SA1112.severity = warning + +# SA1113: Comma should be on the same line as previous parameter +dotnet_diagnostic.SA1113.severity = warning + +# SA1114: Parameter list should follow declaration +dotnet_diagnostic.SA1114.severity = warning + +# SA1115: Parameter should follow comma +dotnet_diagnostic.SA1115.severity = warning + +# SA1116: Split parameters should start on line after declaration +dotnet_diagnostic.SA1116.severity = warning + +# SA1117: Parameters should be on same line or separate lines +dotnet_diagnostic.SA1117.severity = warning + +# SA1118: Parameter should not span multiple lines +dotnet_diagnostic.SA1118.severity = warning + +# SA1119: Statement should not use unnecessary parenthesis +dotnet_diagnostic.SA1119.severity = warning + +# SA1119_p: Statement should not use unnecessary parenthesis (NotConfigurable) +#dotnet_diagnostic.SA1119_p.severity = silent + +# SA1120: Comments should contain text +dotnet_diagnostic.SA1120.severity = warning + +# SA1121: Use built-in type alias +dotnet_diagnostic.SA1121.severity = warning + +# SA1122: Use string.Empty for empty strings +dotnet_diagnostic.SA1122.severity = warning + +# SA1123: Do not place regions within elements +dotnet_diagnostic.SA1123.severity = warning + +# SA1124: Do not use regions +dotnet_diagnostic.SA1124.severity = warning + +# SA1125: Use shorthand for nullable types +dotnet_diagnostic.SA1125.severity = warning + +# SA1126: Prefix calls correctly (NotConfigurable) +#dotnet_diagnostic.SA1126.severity = none + +# SA1127: Generic type constraints should be on their own line +dotnet_diagnostic.SA1127.severity = warning + +# SA1128: Put constructor initializers on their own line +dotnet_diagnostic.SA1128.severity = none + +# SA1129: Do not use default value type constructor +dotnet_diagnostic.SA1129.severity = warning + +# SA1130: Use lambda syntax +dotnet_diagnostic.SA1130.severity = warning + +# SA1131: Use readable conditions +dotnet_diagnostic.SA1131.severity = warning + +# SA1132: Do not combine fields +dotnet_diagnostic.SA1132.severity = warning + +# SA1133: Do not combine attributes +dotnet_diagnostic.SA1133.severity = warning + +# SA1134: Attributes should not share line +dotnet_diagnostic.SA1134.severity = warning + +# SA1135: Using directives should be qualified +dotnet_diagnostic.SA1135.severity = warning + +# SA1136: Enum values should be on separate lines +dotnet_diagnostic.SA1136.severity = warning + +# SA1137: Elements should have the same indentation +dotnet_diagnostic.SA1137.severity = warning + +# SA1139: Use literal suffix notation instead of casting +dotnet_diagnostic.SA1139.severity = warning + +# SA1141: Use tuple syntax +dotnet_diagnostic.SA1141.severity = warning + +# SA1142: Refer to tuple fields by name +dotnet_diagnostic.SA1142.severity = warning + +# SA1200: Using directives should be placed correctly +dotnet_diagnostic.SA1200.severity = warning + +# SA1201: Elements should appear in the correct order +dotnet_diagnostic.SA1201.severity = warning + +# SA1202: Elements should be ordered by access +dotnet_diagnostic.SA1202.severity = warning + +# SA1203: Constants should appear before fields +dotnet_diagnostic.SA1203.severity = warning + +# SA1204: Static elements should appear before instance elements +dotnet_diagnostic.SA1204.severity = warning + +# SA1205: Partial elements should declare access +dotnet_diagnostic.SA1205.severity = warning + +# SA1206: Declaration keywords should follow order +dotnet_diagnostic.SA1206.severity = warning + +# SA1207: Protected should come before internal +dotnet_diagnostic.SA1207.severity = warning + +# SA1208: System using directives should be placed before other using directives +dotnet_diagnostic.SA1208.severity = warning + +# SA1209: Using alias directives should be placed after other using directives +dotnet_diagnostic.SA1209.severity = warning + +# SA1210: Using directives should be ordered alphabetically by namespace +dotnet_diagnostic.SA1210.severity = warning + +# SA1211: Using alias directives should be ordered alphabetically by alias name +dotnet_diagnostic.SA1211.severity = warning + +# SA1212: Property accessors should follow order +dotnet_diagnostic.SA1212.severity = warning + +# SA1213: Event accessors should follow order +dotnet_diagnostic.SA1213.severity = warning + +# SA1214: Readonly fields should appear before non-readonly fields +dotnet_diagnostic.SA1214.severity = warning + +# SA1216: Using static directives should be placed at the correct location. +dotnet_diagnostic.SA1216.severity = warning + +# SA1217: Using static directives should be ordered alphabetically +dotnet_diagnostic.SA1217.severity = warning + +# SA1300: Element should begin with upper-case letter +dotnet_diagnostic.SA1300.severity = warning + +# SA1301: Element should begin with lower-case letter (NotConfigurable) +#dotnet_diagnostic.SA1301.severity = none + +# SA1302: Interface names should begin with I +dotnet_diagnostic.SA1302.severity = warning + +# SA1303: Const field names should begin with upper-case letter +dotnet_diagnostic.SA1303.severity = warning + +# SA1304: Non-private readonly fields should begin with upper-case letter +dotnet_diagnostic.SA1304.severity = warning + +# SA1305: Field names should not use Hungarian notation +dotnet_diagnostic.SA1305.severity = warning + +# SA1306: Field names should begin with lower-case letter +dotnet_diagnostic.SA1306.severity = warning + +# SA1307: Accessible fields should begin with upper-case letter +dotnet_diagnostic.SA1307.severity = warning + +# SA1308: Variable names should not be prefixed +dotnet_diagnostic.SA1308.severity = warning + +# SA1309: Field names should not begin with underscore +dotnet_diagnostic.SA1309.severity = warning + +# SA1310: Field names should not contain underscore +dotnet_diagnostic.SA1310.severity = warning + +# SA1311: Static readonly fields should begin with upper-case letter +dotnet_diagnostic.SA1311.severity = warning + +# SA1312: Variable names should begin with lower-case letter +dotnet_diagnostic.SA1312.severity = warning + +# SA1313: Parameter names should begin with lower-case letter +dotnet_diagnostic.SA1313.severity = warning + +# SA1314: Type parameter names should begin with T +dotnet_diagnostic.SA1314.severity = warning + +# SA1316: Tuple element names should use correct casing +dotnet_diagnostic.SA1316.severity = warning + +# SA1400: Access modifier should be declared +dotnet_diagnostic.SA1400.severity = warning + +# SA1401: Fields should be private +dotnet_diagnostic.SA1401.severity = warning + +# SA1402: File may only contain a single type +dotnet_diagnostic.SA1402.severity = warning + +# SA1403: File may only contain a single namespace +dotnet_diagnostic.SA1403.severity = warning + +# SA1404: Code analysis suppression should have justification +dotnet_diagnostic.SA1404.severity = warning + +# SA1405: Debug.Assert should provide message text +dotnet_diagnostic.SA1405.severity = warning + +# SA1406: Debug.Fail should provide message text +dotnet_diagnostic.SA1406.severity = warning + +# SA1407: Arithmetic expressions should declare precedence +dotnet_diagnostic.SA1407.severity = warning + +# SA1408: Conditional expressions should declare precedence +dotnet_diagnostic.SA1408.severity = warning + +# SA1409: Remove unnecessary code (NotConfigurable) +#dotnet_diagnostic.SA1409.severity = none + +# SA1410: Remove delegate parenthesis when possible +dotnet_diagnostic.SA1410.severity = none + +# SA1411: Attribute constructor should not use unnecessary parenthesis +dotnet_diagnostic.SA1411.severity = warning + +# SA1412: Store files as UTF-8 with byte order mark +dotnet_diagnostic.SA1412.severity = none + +# SA1413: Use trailing comma in multi-line initializers +dotnet_diagnostic.SA1413.severity = none + +# SA1414: Tuple types in signatures should have element names +dotnet_diagnostic.SA1414.severity = warning + +# SA1500: Braces for multi-line statements should not share line +dotnet_diagnostic.SA1500.severity = warning + +# SA1501: Statement should not be on a single line +dotnet_diagnostic.SA1501.severity = warning + +# SA1502: Element should not be on a single line +dotnet_diagnostic.SA1502.severity = warning + +# SA1503: Braces should not be omitted +dotnet_diagnostic.SA1503.severity = warning + +# SA1504: All accessors should be single-line or multi-line +dotnet_diagnostic.SA1504.severity = warning + +# SA1505: Opening braces should not be followed by blank line +dotnet_diagnostic.SA1505.severity = warning + +# SA1506: Element documentation headers should not be followed by blank line +dotnet_diagnostic.SA1506.severity = warning + +# SA1507: Code should not contain multiple blank lines in a row +dotnet_diagnostic.SA1507.severity = warning + +# SA1508: Closing braces should not be preceded by blank line +dotnet_diagnostic.SA1508.severity = warning + +# SA1509: Opening braces should not be preceded by blank line +dotnet_diagnostic.SA1509.severity = warning + +# SA1510: Chained statement blocks should not be preceded by blank line +dotnet_diagnostic.SA1510.severity = warning + +# SA1511: While-do footer should not be preceded by blank line +dotnet_diagnostic.SA1511.severity = warning + +# SA1512: Single-line comments should not be followed by blank line +dotnet_diagnostic.SA1512.severity = warning + +# SA1513: Closing brace should be followed by blank line +dotnet_diagnostic.SA1513.severity = warning + +# SA1514: Element documentation header should be preceded by blank line +dotnet_diagnostic.SA1514.severity = warning + +# SA1515: Single-line comment should be preceded by blank line +dotnet_diagnostic.SA1515.severity = warning + +# SA1516: Elements should be separated by blank line +dotnet_diagnostic.SA1516.severity = warning + +# SA1517: Code should not contain blank lines at start of file +dotnet_diagnostic.SA1517.severity = warning + +# SA1518: Use line endings correctly at end of file +dotnet_diagnostic.SA1518.severity = warning + +# SA1519: Braces should not be omitted from multi-line child statement +dotnet_diagnostic.SA1519.severity = warning + +# SA1520: Use braces consistently +dotnet_diagnostic.SA1520.severity = warning + +# SA1600: Elements should be documented +dotnet_diagnostic.SA1600.severity = warning + +# SA1601: Partial elements should be documented +dotnet_diagnostic.SA1601.severity = warning + +# SA1602: Enumeration items should be documented +dotnet_diagnostic.SA1602.severity = warning + +# SA1603: Documentation should contain valid XML (NotConfigurable) +#dotnet_diagnostic.SA1603.severity = none + +# SA1604: Element documentation should have summary +dotnet_diagnostic.SA1604.severity = warning + +# SA1605: Partial element documentation should have summary +dotnet_diagnostic.SA1605.severity = warning + +# SA1606: Element documentation should have summary text +dotnet_diagnostic.SA1606.severity = warning + +# SA1607: Partial element documentation should have summary text +dotnet_diagnostic.SA1607.severity = warning + +# SA1608: Element documentation should not have default summary +dotnet_diagnostic.SA1608.severity = warning + +# SA1609: Property documentation should have value +dotnet_diagnostic.SA1609.severity = warning + +# SA1610: Property documentation should have value text +dotnet_diagnostic.SA1610.severity = warning + +# SA1611: Element parameters should be documented +dotnet_diagnostic.SA1611.severity = warning + +# SA1612: Element parameter documentation should match element parameters +dotnet_diagnostic.SA1612.severity = warning + +# SA1613: Element parameter documentation should declare parameter name +dotnet_diagnostic.SA1613.severity = warning + +# SA1614: Element parameter documentation should have text +dotnet_diagnostic.SA1614.severity = warning + +# SA1615: Element return value should be documented +dotnet_diagnostic.SA1615.severity = warning + +# SA1616: Element return value documentation should have text +dotnet_diagnostic.SA1616.severity = warning + +# SA1617: Void return value should not be documented +dotnet_diagnostic.SA1617.severity = warning + +# SA1618: Generic type parameters should be documented +dotnet_diagnostic.SA1618.severity = warning + +# SA1619: Generic type parameters should be documented partial class +dotnet_diagnostic.SA1619.severity = warning + +# SA1620: Generic type parameter documentation should match type parameters +dotnet_diagnostic.SA1620.severity = warning + +# SA1621: Generic type parameter documentation should declare parameter name +dotnet_diagnostic.SA1621.severity = warning + +# SA1622: Generic type parameter documentation should have text +dotnet_diagnostic.SA1622.severity = warning + +# SA1623: Property summary documentation should match accessors +dotnet_diagnostic.SA1623.severity = warning + +# SA1624: Property summary documentation should omit accessor with restricted access +dotnet_diagnostic.SA1624.severity = warning + +# SA1625: Element documentation should not be copied and pasted +dotnet_diagnostic.SA1625.severity = warning + +# SA1626: Single-line comments should not use documentation style slashes +dotnet_diagnostic.SA1626.severity = warning + +# SA1627: Documentation text should not be empty +dotnet_diagnostic.SA1627.severity = warning + +# SA1628: Documentation text should begin with a capital letter (NotConfigurable) +#dotnet_diagnostic.SA1628.severity = none + +# SA1629: Documentation text should end with a period +dotnet_diagnostic.SA1629.severity = warning + +# SA1630: Documentation text should contain whitespace (NotConfigurable) +#dotnet_diagnostic.SA1630.severity = none + +# SA1631: Documentation should meet character percentage (NotConfigurable) +#dotnet_diagnostic.SA1631.severity = none + +# SA1632: Documentation text should meet minimum character length (NotConfigurable) +#dotnet_diagnostic.SA1632.severity = none + +# SA1633: File should have header +dotnet_diagnostic.SA1633.severity = none + +# SA1634: File header should show copyright +dotnet_diagnostic.SA1634.severity = warning + +# SA1635: File header should have copyright text +dotnet_diagnostic.SA1635.severity = warning + +# SA1636: File header copyright text should match +dotnet_diagnostic.SA1636.severity = warning + +# SA1637: File header should contain file name +dotnet_diagnostic.SA1637.severity = warning + +# SA1638: File header file name documentation should match file name +dotnet_diagnostic.SA1638.severity = warning + +# SA1639: File header should have summary +dotnet_diagnostic.SA1639.severity = none + +# SA1640: File header should have valid company text +dotnet_diagnostic.SA1640.severity = warning + +# SA1641: File header company name text should match +dotnet_diagnostic.SA1641.severity = warning + +# SA1642: Constructor summary documentation should begin with standard text +dotnet_diagnostic.SA1642.severity = warning + +# SA1643: Destructor summary documentation should begin with standard text +dotnet_diagnostic.SA1643.severity = warning + +# SA1644: Documentation headers should not contain blank lines (NotConfigurable) +#dotnet_diagnostic.SA1644.severity = none + +# SA1645: Included documentation file does not exist (NotConfigurable) +#dotnet_diagnostic.SA1645.severity = none + +# SA1646: Included documentation XPath does not exist (NotConfigurable) +#dotnet_diagnostic.SA1646.severity = none + +# SA1647: Include node does not contain valid file and path (NotConfigurable) +#dotnet_diagnostic.SA1647.severity = none + +# SA1648: inheritdoc should be used with inheriting class +dotnet_diagnostic.SA1648.severity = warning + +# SA1649: File name should match first type name +dotnet_diagnostic.SA1649.severity = warning + +# SA1650: Element documentation should be spelled correctly (NotConfigurable) +#dotnet_diagnostic.SA1650.severity = none + +# SA1651: Do not use placeholder elements +dotnet_diagnostic.SA1651.severity = warning + +# SX1101: Do not prefix local calls with 'this.' +dotnet_diagnostic.SX1101.severity = none + +# SX1309: Field names should begin with underscore +dotnet_diagnostic.SX1309.severity = none + +# SX1309S: Static field names should begin with underscore +dotnet_diagnostic.SX1309S.severity = none + +## ClrHeapAllocationAnalyzer + +# HAA0101: Array allocation for params parameter +dotnet_diagnostic.HAA0101.severity = suggestion + +# HAA0102: Non-overridden virtual method call on value type +dotnet_diagnostic.HAA0102.severity = suggestion + +# HAA0201: Implicit string concatenation allocation +dotnet_diagnostic.HAA0201.severity = suggestion + +# HAA0202: Value type to reference type conversion allocation for string concatenation +dotnet_diagnostic.HAA0202.severity = suggestion + +# HAA0301: Closure Allocation Source +dotnet_diagnostic.HAA0301.severity = suggestion + +# HAA0302: Display class allocation to capture closure +dotnet_diagnostic.HAA0302.severity = suggestion + +# HAA0303: Lambda or anonymous method in a generic method allocates a delegate instance +dotnet_diagnostic.HAA0303.severity = suggestion + +# HAA0401: Possible allocation of reference type enumerator +dotnet_diagnostic.HAA0401.severity = suggestion + +# HAA0501: Explicit new array type allocation +dotnet_diagnostic.HAA0501.severity = suggestion + +# HAA0502: Explicit new reference type allocation +dotnet_diagnostic.HAA0502.severity = suggestion + +# HAA0503: Explicit new anonymous object allocation +dotnet_diagnostic.HAA0503.severity = suggestion + +# HAA0504: Implicit new array creation allocation +dotnet_diagnostic.HAA0504.severity = suggestion + +# HAA0505: Initializer reference type allocation +dotnet_diagnostic.HAA0505.severity = suggestion + +# HAA0506: Let clause induced allocation +dotnet_diagnostic.HAA0506.severity = suggestion + +# HAA0601: Value type to reference type conversion causing boxing allocation +dotnet_diagnostic.HAA0601.severity = suggestion + +# HAA0602: Delegate on struct instance caused a boxing allocation +dotnet_diagnostic.HAA0602.severity = suggestion + +# HAA0603: Delegate allocation from a method group +dotnet_diagnostic.HAA0603.severity = suggestion + +# HAA0604: Delegate allocation from a method group +dotnet_diagnostic.HAA0604.severity = suggestion + +## xunit.analyzers + +# xUnit1000: Test classes must be public +dotnet_diagnostic.xUnit1000.severity = warning + +# xUnit1001: Fact methods cannot have parameters +dotnet_diagnostic.xUnit1001.severity = warning + +# xUnit1002: Test methods cannot have multiple Fact or Theory attributes +dotnet_diagnostic.xUnit1002.severity = warning + +# xUnit1003: Theory methods must have test data +dotnet_diagnostic.xUnit1003.severity = warning + +# xUnit1004: Test methods should not be skipped +dotnet_diagnostic.xUnit1004.severity = warning + +# xUnit1005: Fact methods should not have test data +dotnet_diagnostic.xUnit1005.severity = warning + +# xUnit1006: Theory methods should have parameters +dotnet_diagnostic.xUnit1006.severity = warning + +# xUnit1007: ClassData must point at a valid class +dotnet_diagnostic.xUnit1007.severity = warning + +# xUnit1008: Test data attribute should only be used on a Theory +dotnet_diagnostic.xUnit1008.severity = warning + +# xUnit1009: InlineData values must match the number of method parameters +dotnet_diagnostic.xUnit1009.severity = warning + +# xUnit1010: The value is not convertible to the method parameter type +dotnet_diagnostic.xUnit1010.severity = warning + +# xUnit1011: There is no matching method parameter +dotnet_diagnostic.xUnit1011.severity = warning + +# xUnit1012: Null should not be used for value type parameters +dotnet_diagnostic.xUnit1012.severity = warning + +# xUnit1013: Public method should be marked as test +dotnet_diagnostic.xUnit1013.severity = warning + +# xUnit1014: MemberData should use nameof operator for member name +dotnet_diagnostic.xUnit1014.severity = warning + +# xUnit1015: MemberData must reference an existing member +dotnet_diagnostic.xUnit1015.severity = warning + +# xUnit1016: MemberData must reference a public member +dotnet_diagnostic.xUnit1016.severity = warning + +# xUnit1017: MemberData must reference a static member +dotnet_diagnostic.xUnit1017.severity = warning + +# xUnit1018: MemberData must reference a valid member kind +dotnet_diagnostic.xUnit1018.severity = warning + +# xUnit1019: MemberData must reference a member providing a valid data type +dotnet_diagnostic.xUnit1019.severity = warning + +# xUnit1020: MemberData must reference a property with a getter +dotnet_diagnostic.xUnit1020.severity = warning + +# xUnit1021: MemberData should not have parameters if the referenced member is not a method +dotnet_diagnostic.xUnit1021.severity = warning + +# xUnit1022: Theory methods cannot have a parameter array +dotnet_diagnostic.xUnit1022.severity = warning + +# xUnit1023: Theory methods cannot have default parameter values +dotnet_diagnostic.xUnit1023.severity = warning + +# xUnit1024: Test methods cannot have overloads +dotnet_diagnostic.xUnit1024.severity = warning + +# xUnit1025: InlineData should be unique within the Theory it belongs to +dotnet_diagnostic.xUnit1025.severity = warning + +# xUnit1026: Theory methods should use all of their parameters +dotnet_diagnostic.xUnit1026.severity = warning + +# xUnit1027: Collection definition classes must be public +dotnet_diagnostic.xUnit1027.severity = error + +# xUnit1033: Test classes decorated with 'Xunit.IClassFixture' or 'Xunit.ICollectionFixture' should add a constructor argument of type TFixture +dotnet_diagnostic.xUnit1033.severity = warning + +# xUnit2000: Constants and literals should be the expected argument +dotnet_diagnostic.xUnit2000.severity = warning + +# xUnit2001: Do not use invalid equality check +dotnet_diagnostic.xUnit2001.severity = warning + +# xUnit2002: Do not use null check on value type +dotnet_diagnostic.xUnit2002.severity = warning + +# xUnit2003: Do not use equality check to test for null value +dotnet_diagnostic.xUnit2003.severity = warning + +# xUnit2004: Do not use equality check to test for boolean conditions +dotnet_diagnostic.xUnit2004.severity = warning + +# xUnit2005: Do not use identity check on value type +dotnet_diagnostic.xUnit2005.severity = warning + +# xUnit2006: Do not use invalid string equality check +dotnet_diagnostic.xUnit2006.severity = warning + +# xUnit2007: Do not use typeof expression to check the type +dotnet_diagnostic.xUnit2007.severity = warning + +# xUnit2008: Do not use boolean check to match on regular expressions +dotnet_diagnostic.xUnit2008.severity = warning + +# xUnit2009: Do not use boolean check to check for substrings +dotnet_diagnostic.xUnit2009.severity = warning + +# xUnit2010: Do not use boolean check to check for string equality +dotnet_diagnostic.xUnit2010.severity = warning + +# xUnit2011: Do not use empty collection check +dotnet_diagnostic.xUnit2011.severity = warning + +# xUnit2012: Do not use Enumerable.Any() to check if a value exists in a collection +dotnet_diagnostic.xUnit2012.severity = warning + +# xUnit2013: Do not use equality check to check for collection size. +dotnet_diagnostic.xUnit2013.severity = warning + +# xUnit2014: Do not use throws check to check for asynchronously thrown exception +dotnet_diagnostic.xUnit2014.severity = warning + +# xUnit2015: Do not use typeof expression to check the exception type +dotnet_diagnostic.xUnit2015.severity = warning + +# xUnit2016: Keep precision in the allowed range when asserting equality of doubles or decimals. +dotnet_diagnostic.xUnit2016.severity = warning + +# xUnit2017: Do not use Contains() to check if a value exists in a collection +dotnet_diagnostic.xUnit2017.severity = warning + +# xUnit2018: Do not compare an object's exact type to an abstract class or interface +dotnet_diagnostic.xUnit2018.severity = warning + +# xUnit2019: Do not use obsolete throws check to check for asynchronously thrown exception +dotnet_diagnostic.xUnit2019.severity = none + +# xUnit3000: Test case classes must derive directly or indirectly from Xunit.LongLivedMarshalByRefObject +dotnet_diagnostic.xUnit3000.severity = warning + +# xUnit3001: Classes that implement Xunit.Abstractions.IXunitSerializable must have a public parameterless constructor +dotnet_diagnostic.xUnit3001.severity = warning \ No newline at end of file diff --git a/src/LogExpert.sln b/src/LogExpert.sln index 81360b89..45a59acb 100644 --- a/src/LogExpert.sln +++ b/src/LogExpert.sln @@ -23,6 +23,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlashIconHighlighter", "Fla EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DE6375A4-B4C4-4620-8FFB-B9D5A4E21144}" ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig Solution Items\AssemblyVersion.cs = Solution Items\AssemblyVersion.cs Solution Items\usedComponents.json = Solution Items\usedComponents.json EndProjectSection From 124454de905d348c61110a40d47c99c42e13a12f Mon Sep 17 00:00:00 2001 From: Hirogen Date: Tue, 27 May 2025 11:28:30 +0200 Subject: [PATCH 035/142] update editor_config --- src/.editorconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/.editorconfig b/src/.editorconfig index 32adb03c..7225b5c0 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -95,7 +95,7 @@ csharp_style_var_when_type_is_apparent = true:warning # Expression-bodied members csharp_style_expression_bodied_accessors = true:suggestion -csharp_style_expression_bodied_constructors = true:suggestion +csharp_style_expression_bodied_constructors = false:warning csharp_style_expression_bodied_indexers = true:suggestion csharp_style_expression_bodied_lambdas = true:suggestion csharp_style_expression_bodied_local_functions = true:suggestion @@ -301,7 +301,7 @@ dotnet_diagnostic.IDE0020.severity = warning dotnet_diagnostic.IDE0021.severity = suggestion # IDE0022: Use expression body for methods -dotnet_diagnostic.IDE0022.severity = suggestion +dotnet_diagnostic.IDE0022.severity = none # IDE0023: Use expression body for conversion operators dotnet_diagnostic.IDE0023.severity = suggestion From aa5a3ac42b8fb3d11d205dbf61583c36f9bbb944 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Thu, 29 May 2025 17:21:51 +0300 Subject: [PATCH 036/142] Moved Win32 dll imports from Core to UI --- src/{LogExpert.Core/Classes => LogExpert.UI/Extensions}/Win32.cs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{LogExpert.Core/Classes => LogExpert.UI/Extensions}/Win32.cs (100%) diff --git a/src/LogExpert.Core/Classes/Win32.cs b/src/LogExpert.UI/Extensions/Win32.cs similarity index 100% rename from src/LogExpert.Core/Classes/Win32.cs rename to src/LogExpert.UI/Extensions/Win32.cs From 94f5caed09e5ba17b574b19b04f524889978f241 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Thu, 29 May 2025 17:49:48 +0300 Subject: [PATCH 037/142] Moved the last dllimport from CORE to UI --- src/LogExpert.Core/Config/ColorMode.cs | 29 ----------------- .../Controls/LogWindow/TimeSpreadigControl.cs | 10 ++---- src/LogExpert.UI/Dialogs/ChooseIconDlg.cs | 3 +- .../Dialogs/LogTabWindow/LogTabWindow.cs | 6 ++-- .../LogTabWindow/LogTabWindowPrivate.cs | 1 + .../Dialogs/LogTabWindow/SettingsDialog.cs | 7 +--- src/LogExpert.UI/Extensions/Win32.cs | 32 +++++++++++++++++-- src/LogExpert.UI/LogExpert.UI.csproj | 1 - 8 files changed, 39 insertions(+), 50 deletions(-) diff --git a/src/LogExpert.Core/Config/ColorMode.cs b/src/LogExpert.Core/Config/ColorMode.cs index 391d16e7..ac7c3690 100644 --- a/src/LogExpert.Core/Config/ColorMode.cs +++ b/src/LogExpert.Core/Config/ColorMode.cs @@ -74,34 +74,5 @@ private static void SetBrightMode() InactiveTabColor = LessBrightBackgroundColor; DarkModeEnabled = false; } - - #region TitleBarDarkMode - [DllImport("dwmapi.dll")] - private static extern int DwmSetWindowAttribute(nint hwnd, int attr, ref int attrValue, int attrSize); - - private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19; - private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20; - - public static bool UseImmersiveDarkMode(nint handle, bool enabled) - { - - var attribute = DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1; - if (IsWindows10OrGreater(18985)) - { - attribute = DWMWA_USE_IMMERSIVE_DARK_MODE; - } - - int useImmersiveDarkMode = enabled ? 1 : 0; - return DwmSetWindowAttribute(handle, attribute, ref useImmersiveDarkMode, sizeof(int)) == 0; - - } - - private static bool IsWindows10OrGreater(int build = -1) - { - return Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= build; - } - - #endregion TitleBarDarkMode - } } diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs index f5035e25..24f5dca7 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs @@ -1,14 +1,8 @@ -using LogExpert.Classes; -using LogExpert.Core.Classes; +using LogExpert.Core.Classes; using LogExpert.Core.EventArguments; -using LogExpert.UI.Controls.LogWindow; +using LogExpert.UI.Extensions; using NLog; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Windows.Forms; - namespace LogExpert.UI.Controls.LogWindow { internal partial class TimeSpreadingControl : UserControl diff --git a/src/LogExpert.UI/Dialogs/ChooseIconDlg.cs b/src/LogExpert.UI/Dialogs/ChooseIconDlg.cs index bfc8cfad..b88fd6c4 100644 --- a/src/LogExpert.UI/Dialogs/ChooseIconDlg.cs +++ b/src/LogExpert.UI/Dialogs/ChooseIconDlg.cs @@ -1,5 +1,4 @@ -using LogExpert.Core.Classes; - +using LogExpert.UI.Extensions; using System.Runtime.Versioning; namespace LogExpert.UI.Dialogs; diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs index 4c4533b9..e7093759 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs @@ -1,7 +1,9 @@ -using LogExpert.Core.Config; +using LogExpert.Core.Classes; +using LogExpert.Core.Config; using LogExpert.Core.Entities; using LogExpert.Core.Interface; using LogExpert.Dialogs; +using LogExpert.UI.Extensions; using LogExpert.UI.Extensions.Forms; using NLog; using System.Reflection; @@ -159,7 +161,7 @@ public LogTabWindow(string[] fileNames, int instanceNumber, bool showInstanceNum public void ChangeTheme(Control.ControlCollection container) { ColorMode.LoadColorMode(ConfigManager.Settings.Preferences.darkMode); - ColorMode.UseImmersiveDarkMode(Handle, ColorMode.DarkModeEnabled); + Win32.UseImmersiveDarkMode(Handle, ColorMode.DarkModeEnabled); #region ApplyColorToAllControls foreach (Control component in container) diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs index e27b60db..e58b7521 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs @@ -9,6 +9,7 @@ using LogExpert.Dialogs; using LogExpert.PluginRegistry.FileSystem; using LogExpert.UI.Dialogs; +using LogExpert.UI.Extensions; using System.ComponentModel; using System.Diagnostics; using System.Runtime.InteropServices; diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs index a6bce039..0e06cdbd 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs @@ -6,14 +6,9 @@ using LogExpert.Core.Interface; using LogExpert.UI.Controls.LogTabWindow; using LogExpert.UI.Dialogs; - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; +using LogExpert.UI.Extensions; using System.Runtime.InteropServices; using System.Text; -using System.Windows.Forms; namespace LogExpert.Dialogs; diff --git a/src/LogExpert.UI/Extensions/Win32.cs b/src/LogExpert.UI/Extensions/Win32.cs index 15134978..a2b2c97c 100644 --- a/src/LogExpert.UI/Extensions/Win32.cs +++ b/src/LogExpert.UI/Extensions/Win32.cs @@ -2,10 +2,10 @@ using System.Runtime.InteropServices; using System.Runtime.Versioning; -namespace LogExpert.Core.Classes +namespace LogExpert.UI.Extensions { [SupportedOSPlatform("windows")] - public static class Win32 + internal static class Win32 { #region Fields @@ -115,6 +115,34 @@ private static extern uint ExtractIconEx(string fileName, uint numIcons ); + #region TitleBarDarkMode + [DllImport("dwmapi.dll")] + private static extern int DwmSetWindowAttribute(nint hwnd, int attr, ref int attrValue, int attrSize); + + private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19; + private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20; + + public static bool UseImmersiveDarkMode(nint handle, bool enabled) + { + + var attribute = DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1; + if (IsWindows10OrGreater(18985)) + { + attribute = DWMWA_USE_IMMERSIVE_DARK_MODE; + } + + int useImmersiveDarkMode = enabled ? 1 : 0; + return DwmSetWindowAttribute(handle, attribute, ref useImmersiveDarkMode, sizeof(int)) == 0; + + } + + private static bool IsWindows10OrGreater(int build = -1) + { + return Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= build; + } + + #endregion TitleBarDarkMode + #endregion } } \ No newline at end of file diff --git a/src/LogExpert.UI/LogExpert.UI.csproj b/src/LogExpert.UI/LogExpert.UI.csproj index 518bb32d..2a7be52e 100644 --- a/src/LogExpert.UI/LogExpert.UI.csproj +++ b/src/LogExpert.UI/LogExpert.UI.csproj @@ -23,7 +23,6 @@ - From ab45d005b957087f691d5be4f3a426d5deaa3496 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Thu, 29 May 2025 20:34:43 +0300 Subject: [PATCH 038/142] Changed from DllImport to LibraryImport --- .../LogTabWindow/LogTabWindowPrivate.cs | 5 +- .../LogTabWindow/LogTabWindowPublic.cs | 6 +- .../Dialogs/LogTabWindow/SettingsDialog.cs | 5 +- src/LogExpert.UI/Extensions/Win32.cs | 85 ++++++++++--------- src/LogExpert.UI/LogExpert.UI.csproj | 13 +-- 5 files changed, 55 insertions(+), 59 deletions(-) diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs index e58b7521..e293b8c2 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs @@ -1001,9 +1001,6 @@ private void SetTabIcons(Preferences preferences) } } - [DllImport("user32.dll", CharSet = CharSet.Auto)] - private static extern bool DestroyIcon(IntPtr handle); - private void SetToolIcon(ToolEntry entry, ToolStripItem item) { Icon icon = Win32.LoadIconFromExe(entry.iconFile, entry.iconIndex); @@ -1019,7 +1016,7 @@ private void SetToolIcon(ToolEntry entry, ToolStripItem item) item.DisplayStyle = ToolStripItemDisplayStyle.Image; } - DestroyIcon(icon.Handle); + Win32.DestroyIcon(icon.Handle); icon.Dispose(); } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs index 147d8275..5bddf768 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs @@ -5,6 +5,7 @@ using LogExpert.Core.Interface; using LogExpert.Dialogs; using LogExpert.UI.Entities; +using LogExpert.UI.Extensions; using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; @@ -283,7 +284,7 @@ public void SelectTab(ILogWindow logWindow) public void SetForeground() { - SetForegroundWindow(Handle); + Win32.SetForegroundWindow(Handle); if (WindowState == FormWindowState.Minimized) { if (_wasMaximized) @@ -297,9 +298,6 @@ public void SetForeground() } } - [DllImport("User32.dll")] - public static extern int SetForegroundWindow(IntPtr hWnd); - // called from LogWindow when follow tail was changed public void FollowTailChanged(LogWindow.LogWindow logWindow, bool isEnabled, bool offByTrigger) { diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs index 0e06cdbd..03035118 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs @@ -56,9 +56,6 @@ public SettingsDialog(Preferences prefs, LogTabWindow logTabWin, int tabToOpen, #region Private Methods - [DllImport("user32.dll", CharSet = CharSet.Auto)] - private static extern bool DestroyIcon(IntPtr handle); - private void FillDialog() { Preferences ??= new Preferences(); @@ -564,7 +561,7 @@ private void DisplayCurrentIcon() { Image image = icon.ToBitmap(); buttonIcon.Image = image; - DestroyIcon(icon.Handle); + Win32.DestroyIcon(icon.Handle); icon.Dispose(); } else diff --git a/src/LogExpert.UI/Extensions/Win32.cs b/src/LogExpert.UI/Extensions/Win32.cs index a2b2c97c..b0f9e92e 100644 --- a/src/LogExpert.UI/Extensions/Win32.cs +++ b/src/LogExpert.UI/Extensions/Win32.cs @@ -5,7 +5,7 @@ namespace LogExpert.UI.Extensions { [SupportedOSPlatform("windows")] - internal static class Win32 + internal static partial class Win32 //NativeMethods { #region Fields @@ -13,13 +13,53 @@ internal static class Win32 public const long SM_CXHSCROLL = 21; public const long SM_CXVSCROLL = 2; public const long SM_CYHSCROLL = 3; + private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19; + private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20; #endregion - #region Public methods + #region Library Imports + [LibraryImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool DestroyIcon(nint hIcon); + + [LibraryImport("User32.dll")] + public static partial int SetForegroundWindow(nint hWnd); + + [LibraryImport("user32.dll")] + public static partial long GetSystemMetricsForDpi(long index); + + [LibraryImport("user32.dll")] + public static partial long GetSystemMetrics(long index); + + [LibraryImport("user32.dll")] + public static partial short GetKeyState(int vKey); + + /* + UINT ExtractIconEx( + LPCTSTR lpszFile, + int nIconIndex, + HICON *phiconLarge, + HICON *phiconSmall, + UINT nIcons + ); + * */ + [LibraryImport("shell32.dll", StringMarshalling = StringMarshalling.Utf16)] + public static partial uint ExtractIconEx( + string fileName, + int iconIndex, + ref nint iconsLarge, + ref nint iconsSmall, + uint numIcons + ); + + #region TitleBarDarkMode + [LibraryImport("dwmapi.dll")] + public static partial int DwmSetWindowAttribute(nint hwnd, int attr, ref int attrValue, int attrSize); + #endregion + #endregion - [DllImport("user32.dll")] - public static extern bool DestroyIcon(nint hIcon); + #region Public methods public static Icon LoadIconFromExe(string fileName, int index) { @@ -43,7 +83,6 @@ public static Icon LoadIconFromExe(string fileName, int index) return null; } - public static Icon[,] ExtractIcons(string fileName) { nint smallIcon = nint.Zero; @@ -83,45 +122,10 @@ public static Icon LoadIconFromExe(string fileName, int index) return result; } - [DllImport("user32.dll")] - public static extern long GetSystemMetricsForDpi(long index); - - - [DllImport("user32.dll")] - public static extern long GetSystemMetrics(long index); - - [DllImport("user32.dll")] - public static extern short GetKeyState(int vKey); - #endregion #region Private Methods - /* - UINT ExtractIconEx( - LPCTSTR lpszFile, - int nIconIndex, - HICON *phiconLarge, - HICON *phiconSmall, - UINT nIcons - ); - * */ - - [DllImport("shell32.dll")] - private static extern uint ExtractIconEx(string fileName, - int iconIndex, - ref nint iconsLarge, - ref nint iconsSmall, - uint numIcons - ); - - #region TitleBarDarkMode - [DllImport("dwmapi.dll")] - private static extern int DwmSetWindowAttribute(nint hwnd, int attr, ref int attrValue, int attrSize); - - private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19; - private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20; - public static bool UseImmersiveDarkMode(nint handle, bool enabled) { @@ -143,6 +147,5 @@ private static bool IsWindows10OrGreater(int build = -1) #endregion TitleBarDarkMode - #endregion } } \ No newline at end of file diff --git a/src/LogExpert.UI/LogExpert.UI.csproj b/src/LogExpert.UI/LogExpert.UI.csproj index 2a7be52e..7dbb6ab1 100644 --- a/src/LogExpert.UI/LogExpert.UI.csproj +++ b/src/LogExpert.UI/LogExpert.UI.csproj @@ -1,14 +1,15 @@  - net8.0-windows - disable - true - enable - false - True + True ..\Solution Items\Key.snk true + false + enable + disable + True + net8.0-windows + true From 6911a0792d41514a907d7178d5b2fef1c4801b1c Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sat, 31 May 2025 22:51:02 +0300 Subject: [PATCH 039/142] Remove all UI code from the Core project --- src/LogExpert.Core/Classes/Filter/Filter.cs | 5 -- src/LogExpert.Core/Classes/Util.cs | 54 ------------------ .../Entities/FileViewContext.cs | 2 +- .../Interface/IFileViewContext.cs | 10 ++++ .../Interface/ILogPaintContext.cs | 32 +---------- .../Interface/ISharedToolWindow.cs | 3 +- src/LogExpert.Core/LogExpert.Core.csproj | 3 +- .../Controls/LogWindow/LogWindow.cs | 3 +- src/LogExpert.UI/Dialogs/BookmarkWindow.cs | 14 ++--- src/LogExpert.UI/Entities/PaintHelper.cs | 7 ++- src/LogExpert.UI/Extensions/Utils.cs | 57 +++++++++++++++++++ .../Interface/ILogPaintContextUI.cs | 35 ++++++++++++ src/LogExpert.UI/LogExpert.UI.csproj | 4 +- .../LogExpert.PluginRegistry.csproj | 1 + 14 files changed, 121 insertions(+), 109 deletions(-) create mode 100644 src/LogExpert.Core/Interface/IFileViewContext.cs create mode 100644 src/LogExpert.UI/Extensions/Utils.cs create mode 100644 src/LogExpert.UI/Interface/ILogPaintContextUI.cs diff --git a/src/LogExpert.Core/Classes/Filter/Filter.cs b/src/LogExpert.Core/Classes/Filter/Filter.cs index 80ec7d4b..f716fad9 100644 --- a/src/LogExpert.Core/Classes/Filter/Filter.cs +++ b/src/LogExpert.Core/Classes/Filter/Filter.cs @@ -1,13 +1,8 @@ using LogExpert.Classes.ILogLineColumnizerCallback; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Filter; - using NLog; -using System; -using System.Collections.Generic; -using System.Windows.Forms; - namespace LogExpert.Classes.Filter { internal delegate void FilterFx(FilterParams filterParams, List filterResultLines, List lastFilterResultLines, List filterHitList); diff --git a/src/LogExpert.Core/Classes/Util.cs b/src/LogExpert.Core/Classes/Util.cs index 935f15b1..f4ab307a 100644 --- a/src/LogExpert.Core/Classes/Util.cs +++ b/src/LogExpert.Core/Classes/Util.cs @@ -1,5 +1,4 @@ using LogExpert.Core.Classes.Filter; - using System.Diagnostics; using System.Drawing; using System.Runtime.Versioning; @@ -402,59 +401,6 @@ public static void AssertTrue(bool condition, string msg) } } - [SupportedOSPlatform("windows")] - public string GetWordFromPos(int xPos, string text, Graphics g, Font font) - { - string[] words = text.Split([' ', '.', ':', ';']); - - int index = 0; - - List crList = []; - - for (int i = 0; i < words.Length; ++i) - { - crList.Add(new CharacterRange(index, words[i].Length)); - index += words[i].Length; - } - - CharacterRange[] crArray = [.. crList]; - - StringFormat stringFormat = new(StringFormat.GenericTypographic) - { - Trimming = StringTrimming.None, - FormatFlags = StringFormatFlags.NoClip - }; - - stringFormat.SetMeasurableCharacterRanges(crArray); - - RectangleF rect = new(0, 0, 3000, 20); - Region[] stringRegions = g.MeasureCharacterRanges(text, font, rect, stringFormat); - - bool found = false; - - int y = 0; - - foreach (Region regio in stringRegions) - { - if (regio.IsVisible(xPos, 3, g)) - { - found = true; - break; - } - - y++; - } - - if (found) - { - return words[y]; - } - else - { - return null; - } - } - #endregion #region Private Methods diff --git a/src/LogExpert.Core/Entities/FileViewContext.cs b/src/LogExpert.Core/Entities/FileViewContext.cs index 07f4d20f..efcc7577 100644 --- a/src/LogExpert.Core/Entities/FileViewContext.cs +++ b/src/LogExpert.Core/Entities/FileViewContext.cs @@ -2,7 +2,7 @@ namespace LogExpert.Core.Entities { - public class FileViewContext(ILogPaintContext logPaintContext, ILogView logView) + public class FileViewContext(ILogPaintContext logPaintContext, ILogView logView) : IFileViewContext, ILogPaintContext { #region Properties diff --git a/src/LogExpert.Core/Interface/IFileViewContext.cs b/src/LogExpert.Core/Interface/IFileViewContext.cs new file mode 100644 index 00000000..da0b33f3 --- /dev/null +++ b/src/LogExpert.Core/Interface/IFileViewContext.cs @@ -0,0 +1,10 @@ +using LogExpert.Core.Entities; + +namespace LogExpert.Core.Interface +{ + public interface IFileViewContext + { + ILogView LogView { get; } + ILogPaintContext LogPaintContext { get; } + } +} \ No newline at end of file diff --git a/src/LogExpert.Core/Interface/ILogPaintContext.cs b/src/LogExpert.Core/Interface/ILogPaintContext.cs index e123d5f3..2fae38fa 100644 --- a/src/LogExpert.Core/Interface/ILogPaintContext.cs +++ b/src/LogExpert.Core/Interface/ILogPaintContext.cs @@ -1,36 +1,6 @@ -using LogExpert.Core.Classes.Highlight; -using LogExpert.Core.Entities; - -using System.Drawing; - -namespace LogExpert.Core.Interface +namespace LogExpert.Core.Interface { - /// - /// Declares methods that are needed for drawing log lines. Used by PaintHelper. - /// public interface ILogPaintContext { - #region Properties - - Font MonospacedFont { get; } // Font font = new Font("Courier New", this.Preferences.fontSize, FontStyle.Bold); - Font NormalFont { get; } - Font BoldFont { get; } - Color BookmarkColor { get; } - - #endregion - - #region Public methods - - ILogLine GetLogLine(int lineNum); - - IColumn GetCellValue(int rowIndex, int columnIndex); - - Bookmark GetBookmarkForLine(int lineNum); - - HighlightEntry FindHighlightEntry(ITextValue line, bool noWordMatches); - - IList FindHighlightMatches(ITextValue line); - - #endregion } } \ No newline at end of file diff --git a/src/LogExpert.Core/Interface/ISharedToolWindow.cs b/src/LogExpert.Core/Interface/ISharedToolWindow.cs index d8253b19..3178206d 100644 --- a/src/LogExpert.Core/Interface/ISharedToolWindow.cs +++ b/src/LogExpert.Core/Interface/ISharedToolWindow.cs @@ -1,5 +1,4 @@ using LogExpert.Core.Config; -using LogExpert.Core.Entities; namespace LogExpert.Core.Interface { @@ -16,7 +15,7 @@ public interface ISharedToolWindow /// Called when a file becomes the active file (e.g. when user selects a tab). /// /// - void SetCurrentFile(FileViewContext ctx); + void SetCurrentFile(IFileViewContext ctx); /// /// Called whenever the current file has been changed. diff --git a/src/LogExpert.Core/LogExpert.Core.csproj b/src/LogExpert.Core/LogExpert.Core.csproj index e5f95874..0062fbbf 100644 --- a/src/LogExpert.Core/LogExpert.Core.csproj +++ b/src/LogExpert.Core/LogExpert.Core.csproj @@ -8,6 +8,8 @@ true True ..\Solution Items\Key.snk + false + CS8625;CS8603;CS8618;CS8600;CS8603;CS8602;CS8604;CS8622;CS8601; @@ -21,7 +23,6 @@ - diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index a80a4b71..a3aa74ca 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -14,6 +14,7 @@ using LogExpert.UI.Controls.LogTabWindow; using LogExpert.UI.Dialogs; using LogExpert.UI.Extensions.Forms; +using LogExpert.UI.Interface; using NLog; using WeifenLuo.WinFormsUI.Docking; //using static LogExpert.PluginRegistry.PluginRegistry; //TODO: Adjust the instance name so using static can be used. @@ -21,7 +22,7 @@ namespace LogExpert.UI.Controls.LogWindow { //TODO: Implemented 4 interfaces explicitly. Find them by searcginh: ILogWindow. - internal partial class LogWindow : DockContent, ILogPaintContext, ILogView, ILogWindow + internal partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILogWindow { #region Fields diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs index 328a7366..6259de88 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs @@ -4,14 +4,8 @@ using LogExpert.Core.Interface; using LogExpert.UI.Entities; using LogExpert.UI.Extensions.Forms; - +using LogExpert.UI.Interface; using NLog; - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Windows.Forms; - using WeifenLuo.WinFormsUI.Docking; namespace LogExpert.Dialogs; @@ -25,7 +19,7 @@ public partial class BookmarkWindow : DockContent, ISharedToolWindow, IBookmarkV private readonly object paintLock = new(); private IBookmarkData bookmarkData; - private ILogPaintContext logPaintContext; + private ILogPaintContextUI logPaintContext; private ILogView logView; #endregion @@ -218,7 +212,7 @@ public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, Sett PreferencesChanged(newPreferences, isLoadTime, flags, null); } - public void SetCurrentFile(FileViewContext ctx) + public void SetCurrentFile(IFileViewContext ctx) { if (ctx != null) { @@ -226,7 +220,7 @@ public void SetCurrentFile(FileViewContext ctx) lock (paintLock) { logView = ctx.LogView; - logPaintContext = ctx.LogPaintContext; + logPaintContext = (ILogPaintContextUI)ctx.LogPaintContext; } SetColumnizer(ctx.LogView.CurrentColumnizer); diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index 6b7331f4..eeb499e6 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -4,6 +4,7 @@ using LogExpert.Core.Interface; using LogExpert.Dialogs; using LogExpert.UI.Controls; +using LogExpert.UI.Interface; using NLog; namespace LogExpert.UI.Entities @@ -29,7 +30,7 @@ internal static class PaintHelper #region Public methods - public static void CellPainting(ILogPaintContext logPaintCtx, BufferedDataGridView gridView, int rowIndex, + public static void CellPainting(ILogPaintContextUI logPaintCtx, BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) { if (rowIndex < 0 || e.ColumnIndex < 0) @@ -293,12 +294,12 @@ public static Rectangle BorderWidths(DataGridViewAdvancedBorderStyle advancedBor #region Private Methods - private static void PaintCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) + private static void PaintCell(ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) { PaintHighlightedCell(logPaintCtx, e, gridView, noBackgroundFill, groundEntry); } - private static void PaintHighlightedCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) + private static void PaintHighlightedCell(ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) { object value = e.Value ?? string.Empty; diff --git a/src/LogExpert.UI/Extensions/Utils.cs b/src/LogExpert.UI/Extensions/Utils.cs new file mode 100644 index 00000000..f753a1fd --- /dev/null +++ b/src/LogExpert.UI/Extensions/Utils.cs @@ -0,0 +1,57 @@ +namespace LogExpert.UI.Extensions +{ + internal static class Utils + { + public static string GetWordFromPos(int xPos, string text, Graphics g, Font font) + { + string[] words = text.Split([' ', '.', ':', ';']); + + int index = 0; + + List crList = []; + + for (int i = 0; i < words.Length; ++i) + { + crList.Add(new CharacterRange(index, words[i].Length)); + index += words[i].Length; + } + + CharacterRange[] crArray = [.. crList]; + + StringFormat stringFormat = new(StringFormat.GenericTypographic) + { + Trimming = StringTrimming.None, + FormatFlags = StringFormatFlags.NoClip + }; + + stringFormat.SetMeasurableCharacterRanges(crArray); + + RectangleF rect = new(0, 0, 3000, 20); + Region[] stringRegions = g.MeasureCharacterRanges(text, font, rect, stringFormat); + + bool found = false; + + int y = 0; + + foreach (Region regio in stringRegions) + { + if (regio.IsVisible(xPos, 3, g)) + { + found = true; + break; + } + + y++; + } + + if (found) + { + return words[y]; + } + else + { + return null; + } + } + } +} diff --git a/src/LogExpert.UI/Interface/ILogPaintContextUI.cs b/src/LogExpert.UI/Interface/ILogPaintContextUI.cs new file mode 100644 index 00000000..dcd8ae41 --- /dev/null +++ b/src/LogExpert.UI/Interface/ILogPaintContextUI.cs @@ -0,0 +1,35 @@ +using LogExpert.Core.Classes.Highlight; +using LogExpert.Core.Entities; +using LogExpert.Core.Interface; + +namespace LogExpert.UI.Interface +{ + /// + /// Declares methods that are needed for drawing log lines. Used by PaintHelper. + /// + public interface ILogPaintContextUI : ILogPaintContext + { + #region Properties + + Font MonospacedFont { get; } // Font font = new Font("Courier New", this.Preferences.fontSize, FontStyle.Bold); + Font NormalFont { get; } + Font BoldFont { get; } + Color BookmarkColor { get; } + + #endregion + + #region Public methods + + ILogLine GetLogLine(int lineNum); + + IColumn GetCellValue(int rowIndex, int columnIndex); + + Bookmark GetBookmarkForLine(int lineNum); + + HighlightEntry FindHighlightEntry(ITextValue line, bool noWordMatches); + + IList FindHighlightMatches(ITextValue line); + + #endregion + } +} \ No newline at end of file diff --git a/src/LogExpert.UI/LogExpert.UI.csproj b/src/LogExpert.UI/LogExpert.UI.csproj index 7dbb6ab1..d6b22f11 100644 --- a/src/LogExpert.UI/LogExpert.UI.csproj +++ b/src/LogExpert.UI/LogExpert.UI.csproj @@ -6,7 +6,9 @@ true false enable - disable + CS8625;CS8603;CS8618;CS8600;CS8603;CS8602;CS8604;CS8622;CS8601;CS8605; + enable + false True net8.0-windows true diff --git a/src/PluginRegistry/LogExpert.PluginRegistry.csproj b/src/PluginRegistry/LogExpert.PluginRegistry.csproj index a63bd451..56a2d733 100644 --- a/src/PluginRegistry/LogExpert.PluginRegistry.csproj +++ b/src/PluginRegistry/LogExpert.PluginRegistry.csproj @@ -7,6 +7,7 @@ enable True ..\Solution Items\Key.snk + CS8600;CS8603;CS8618; From d7a84fb7838e02108fa13975d5896f712de66505 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sat, 31 May 2025 23:38:19 +0300 Subject: [PATCH 040/142] Removed UI dependencies from DefaultPlugins by removing relevant code to the UI project. changed other projects to be .net8 and not .net8-windows. --- src/AutoColumnizer/AutoColumnizer.csproj | 4 +- .../ColumnizerLib.UnitTests.csproj | 2 +- src/DefaultPlugins/DefaultPlugins.csproj | 10 +- src/DefaultPlugins/ProcessLauncher.cs | 3 +- .../GlassfishColumnizer.csproj | 4 +- src/JsonColumnizer/JsonColumnizer.csproj | 10 +- .../JsonCompactColumnizer.csproj | 10 +- .../Log4jXmlColumnizer.csproj | 2 +- .../Dialogs/Eminus}/Eminus.cs | 607 +++++++++--------- .../Dialogs/Eminus}/EminusConfig.cs | 60 +- .../Eminus}/EminusConfigDlg.Designer.cs | 268 ++++---- .../Dialogs/Eminus}/EminusConfigDlg.cs | 118 ++-- .../Dialogs/Eminus}/EminusConfigDlg.resx | 260 ++++---- src/LogExpert.UI/LogExpert.UI.csproj | 3 + src/RegexColumnizer/RegexColumnizer.csproj | 2 +- 15 files changed, 683 insertions(+), 680 deletions(-) rename src/{DefaultPlugins => LogExpert.UI/Dialogs/Eminus}/Eminus.cs (95%) rename src/{DefaultPlugins => LogExpert.UI/Dialogs/Eminus}/EminusConfig.cs (89%) rename src/{DefaultPlugins => LogExpert.UI/Dialogs/Eminus}/EminusConfigDlg.Designer.cs (97%) rename src/{DefaultPlugins => LogExpert.UI/Dialogs/Eminus}/EminusConfigDlg.cs (91%) rename src/{DefaultPlugins => LogExpert.UI/Dialogs/Eminus}/EminusConfigDlg.resx (98%) diff --git a/src/AutoColumnizer/AutoColumnizer.csproj b/src/AutoColumnizer/AutoColumnizer.csproj index 1bed4e34..e77962e3 100644 --- a/src/AutoColumnizer/AutoColumnizer.csproj +++ b/src/AutoColumnizer/AutoColumnizer.csproj @@ -1,12 +1,12 @@  - net8.0-windows + net8.0 Library false AutoColumnizer true ..\Solution Items\Key.snk - false + false false $(SolutionDir)..\bin\$(Configuration)\plugins diff --git a/src/ColumnizerLib.UnitTests/ColumnizerLib.UnitTests.csproj b/src/ColumnizerLib.UnitTests/ColumnizerLib.UnitTests.csproj index 68ad9cfc..339b9ce6 100644 --- a/src/ColumnizerLib.UnitTests/ColumnizerLib.UnitTests.csproj +++ b/src/ColumnizerLib.UnitTests/ColumnizerLib.UnitTests.csproj @@ -1,6 +1,6 @@  - net8.0-windows + net8.0 Library true false diff --git a/src/DefaultPlugins/DefaultPlugins.csproj b/src/DefaultPlugins/DefaultPlugins.csproj index d3c7b1c6..1b0a14ea 100644 --- a/src/DefaultPlugins/DefaultPlugins.csproj +++ b/src/DefaultPlugins/DefaultPlugins.csproj @@ -1,13 +1,13 @@  - net8.0-windows - true + net8.0 + False Library - false + false LogExpert false - true - true + False + False false $(SolutionDir)..\bin\$(Configuration)\plugins diff --git a/src/DefaultPlugins/ProcessLauncher.cs b/src/DefaultPlugins/ProcessLauncher.cs index 29e73229..7d0ce891 100644 --- a/src/DefaultPlugins/ProcessLauncher.cs +++ b/src/DefaultPlugins/ProcessLauncher.cs @@ -2,7 +2,8 @@ namespace LogExpert { - public class ProcessLauncher : IKeywordAction + //TODO: Not in use + internal class ProcessLauncher : IKeywordAction { #region Properties diff --git a/src/GlassfishColumnizer/GlassfishColumnizer.csproj b/src/GlassfishColumnizer/GlassfishColumnizer.csproj index c9928ba1..5bd15728 100644 --- a/src/GlassfishColumnizer/GlassfishColumnizer.csproj +++ b/src/GlassfishColumnizer/GlassfishColumnizer.csproj @@ -1,8 +1,8 @@  - net8.0-windows + net8.0 Library - false + false false false $(SolutionDir)..\bin\$(Configuration)\plugins diff --git a/src/JsonColumnizer/JsonColumnizer.csproj b/src/JsonColumnizer/JsonColumnizer.csproj index ffcc325e..d53c1966 100644 --- a/src/JsonColumnizer/JsonColumnizer.csproj +++ b/src/JsonColumnizer/JsonColumnizer.csproj @@ -1,12 +1,12 @@  - net8.0-windows - true + net8.0 + false Library - false + false false - true - true + false + false false $(SolutionDir)..\bin\$(Configuration)\plugins diff --git a/src/JsonCompactColumnizer/JsonCompactColumnizer.csproj b/src/JsonCompactColumnizer/JsonCompactColumnizer.csproj index 67cae4d8..4a9f2836 100644 --- a/src/JsonCompactColumnizer/JsonCompactColumnizer.csproj +++ b/src/JsonCompactColumnizer/JsonCompactColumnizer.csproj @@ -1,13 +1,13 @@  - net8.0-windows - true + net8.0 + false Library - false + false JsonColumnizer false - true - true + false + false false $(SolutionDir)..\bin\$(Configuration)\plugins diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.csproj b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.csproj index 11231a69..189b5254 100644 --- a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.csproj +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.csproj @@ -3,7 +3,7 @@ net8.0-windows true Library - false + false false true true diff --git a/src/DefaultPlugins/Eminus.cs b/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs similarity index 95% rename from src/DefaultPlugins/Eminus.cs rename to src/LogExpert.UI/Dialogs/Eminus/Eminus.cs index 27110d08..9d01c556 100644 --- a/src/DefaultPlugins/Eminus.cs +++ b/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs @@ -1,305 +1,304 @@ -using Newtonsoft.Json; - -using System; -using System.Collections.Generic; -using System.IO; -using System.Net.Sockets; -using System.Runtime.Serialization; -using System.Runtime.Versioning; -using System.Windows.Forms; -using System.Xml; - -[assembly: SupportedOSPlatform("windows")] -namespace LogExpert -{ - public class Eminus : IContextMenuEntry, ILogExpertPluginConfigurator - { - #region Fields - - private const string CFG_FILE_NAME = "eminus.json"; - private const string DOT = "."; - private const string DOUBLE_DOT = ":"; - private const string DISABLED = "_"; - - private EminusConfig _config = new(); - private EminusConfigDlg dlg; - private EminusConfig tmpConfig = new(); - - #endregion - - #region Properties - - public static string Text => "eminus"; - - #endregion - - #region Private Methods - - private XmlDocument BuildParam(ILogLine line) - { - string fullLogLine = line.FullLine; - // no Java stacktrace but some special logging of our applications at work: - if (fullLogLine.Contains("Exception of type", StringComparison.CurrentCulture) || - fullLogLine.Contains("Nested:", StringComparison.CurrentCulture)) - { - int pos = fullLogLine.IndexOf("created in "); - - if (pos == -1) - { - return null; - } - - pos += "created in ".Length; - int endPos = fullLogLine.IndexOf(DOT, pos); - - if (endPos == -1) - { - return null; - } - - string className = fullLogLine[pos..endPos]; - pos = fullLogLine.IndexOf(DOUBLE_DOT, pos); - - if (pos == -1) - { - return null; - } - - string lineNum = fullLogLine[(pos + 1)..]; - XmlDocument doc = BuildXmlDocument(className, lineNum); - return doc; - } - - if (fullLogLine.Contains("at ", StringComparison.CurrentCulture)) - { - string str = fullLogLine.Trim(); - string className = null; - string lineNum = null; - int pos = str.IndexOf("at ") + 3; - str = str[pos..]; // remove 'at ' - int idx = str.IndexOfAny(['(', '$', '<']); - - if (idx != -1) - { - if (str[idx] == '$') - { - className = str[..idx]; - } - else - { - pos = str.LastIndexOf(DOT, idx); - if (pos == -1) - { - return null; - } - className = str[..pos]; - } - - idx = str.LastIndexOf(DOUBLE_DOT); - - if (idx == -1) - { - return null; - } - - pos = str.IndexOf(')', idx); - - if (pos == -1) - { - return null; - } - - lineNum = str.Substring(idx + 1, pos - idx - 1); - } - /* - * - - - - - - - */ - - XmlDocument doc = BuildXmlDocument(className, lineNum); - return doc; - } - return null; - } - - private XmlDocument BuildXmlDocument(string className, string lineNum) - { - XmlDocument xmlDoc = new(); - xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); - XmlElement rootElement = xmlDoc.CreateElement("eminus"); - xmlDoc.AppendChild(rootElement); - rootElement.SetAttribute("authKey", _config.password); - - XmlElement loadElement = xmlDoc.CreateElement("loadclass"); - loadElement.SetAttribute("mode", "dialog"); - rootElement.AppendChild(loadElement); - - XmlElement elemClassName = xmlDoc.CreateElement("classname"); - XmlElement elemLineNum = xmlDoc.CreateElement("linenumber"); - elemClassName.InnerText = className; - elemLineNum.InnerText = lineNum; - loadElement.AppendChild(elemClassName); - loadElement.AppendChild(elemLineNum); - return xmlDoc; - } - - #endregion - - #region IContextMenuEntry Member - - public string GetMenuText(IList logLines, ILogLineColumnizer columnizer, ILogExpertCallback callback) - { - //not used - return string.Empty; - } - - public string GetMenuText(int logLinesCount, ILogLineColumnizer columnizer, ILogLine logline) - { - if (logLinesCount == 1 && BuildParam(logline) != null) - { - return "Load class in Eclipse"; - } - else - { - return $"{DISABLED}Load class in Eclipse"; - } - } - - public void MenuSelected(IList logLines, ILogLineColumnizer columnizer, ILogExpertCallback callback) - { - //Not used - } - - public void MenuSelected(int logLinesCount, ILogLineColumnizer columnizer, ILogLine logline) - { - if (logLinesCount != 1) - { - return; - } - - XmlDocument doc = BuildParam(logline); - - if (doc == null) - { - MessageBox.Show("Cannot parse Java stack trace line", "LogExpert"); - } - else - { - try - { - TcpClient client = new(_config.host, _config.port); - NetworkStream stream = client.GetStream(); - StreamWriter writer = new(stream); - doc.Save(writer); - writer.Flush(); - stream.Flush(); - writer.Close(); - stream.Close(500); - client.Close(); - } - catch (Exception e) - { - MessageBox.Show(e.Message, "LogExpert"); - } - } - } - - #endregion - - - #region ILogExpertPluginConfigurator Member - - public void LoadConfig(string configDir) - { - string configPath = configDir + CFG_FILE_NAME; - - FileInfo fileInfo = new(configDir + Path.DirectorySeparatorChar + CFG_FILE_NAME); - - if (!File.Exists(configPath)) - { - _config = new EminusConfig(); - } - else - { - try - { - _config = JsonConvert.DeserializeObject(File.ReadAllText($"{fileInfo.FullName}")); - } - catch (SerializationException e) - { - MessageBox.Show(e.Message, "Deserialize"); - _config = new EminusConfig(); - } - } - } - - - public void SaveConfig(string configDir) - { - FileInfo fileInfo = new(configDir + Path.DirectorySeparatorChar + CFG_FILE_NAME); - - dlg?.ApplyChanges(); - - _config = tmpConfig.Clone(); - - using StreamWriter sw = new(fileInfo.Create()); - JsonSerializer serializer = new(); - serializer.Serialize(sw, _config); - } - - public bool HasEmbeddedForm() - { - return true; - } - - public void ShowConfigForm(object panel) - { - dlg = new EminusConfigDlg(tmpConfig) - { - Parent = (Panel)panel - }; - dlg.Show(); - } - - /// - /// Implemented only for demonstration purposes. This function is called when the config button - /// is pressed (HasEmbeddedForm() must return false for this). - /// - /// - public void ShowConfigDialog(object owner) - { - dlg = new EminusConfigDlg(tmpConfig) - { - TopLevel = true, - Owner = (Form)owner - }; - - dlg.ShowDialog(); - dlg.ApplyChanges(); - } - - - public void HideConfigForm() - { - if (dlg != null) - { - dlg.ApplyChanges(); - dlg.Hide(); - dlg.Dispose(); - dlg = null; - } - } - - public void StartConfig() - { - tmpConfig = _config.Clone(); - } - - #endregion - } +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Net.Sockets; +using System.Runtime.Serialization; +using System.Runtime.Versioning; +//using System.Windows.Forms; +using System.Xml; + +//TODO: This whole Eminus folder is not in use. Can be deleted? What is it? +//[assembly: SupportedOSPlatform("windows")] +namespace LogExpert +{ + internal class Eminus : IContextMenuEntry, ILogExpertPluginConfigurator + { + #region Fields + + private const string CFG_FILE_NAME = "eminus.json"; + private const string DOT = "."; + private const string DOUBLE_DOT = ":"; + private const string DISABLED = "_"; + + private EminusConfig _config = new(); + private EminusConfigDlg dlg; + private EminusConfig tmpConfig = new(); + + #endregion + + #region Properties + + public static string Text => "eminus"; + + #endregion + + #region Private Methods + + private XmlDocument BuildParam(ILogLine line) + { + string fullLogLine = line.FullLine; + // no Java stacktrace but some special logging of our applications at work: + if (fullLogLine.Contains("Exception of type", StringComparison.CurrentCulture) || + fullLogLine.Contains("Nested:", StringComparison.CurrentCulture)) + { + int pos = fullLogLine.IndexOf("created in "); + + if (pos == -1) + { + return null; + } + + pos += "created in ".Length; + int endPos = fullLogLine.IndexOf(DOT, pos); + + if (endPos == -1) + { + return null; + } + + string className = fullLogLine[pos..endPos]; + pos = fullLogLine.IndexOf(DOUBLE_DOT, pos); + + if (pos == -1) + { + return null; + } + + string lineNum = fullLogLine[(pos + 1)..]; + XmlDocument doc = BuildXmlDocument(className, lineNum); + return doc; + } + + if (fullLogLine.Contains("at ", StringComparison.CurrentCulture)) + { + string str = fullLogLine.Trim(); + string className = null; + string lineNum = null; + int pos = str.IndexOf("at ") + 3; + str = str[pos..]; // remove 'at ' + int idx = str.IndexOfAny(['(', '$', '<']); + + if (idx != -1) + { + if (str[idx] == '$') + { + className = str[..idx]; + } + else + { + pos = str.LastIndexOf(DOT, idx); + if (pos == -1) + { + return null; + } + className = str[..pos]; + } + + idx = str.LastIndexOf(DOUBLE_DOT); + + if (idx == -1) + { + return null; + } + + pos = str.IndexOf(')', idx); + + if (pos == -1) + { + return null; + } + + lineNum = str.Substring(idx + 1, pos - idx - 1); + } + /* + * + + + + + + + */ + + XmlDocument doc = BuildXmlDocument(className, lineNum); + return doc; + } + return null; + } + + private XmlDocument BuildXmlDocument(string className, string lineNum) + { + XmlDocument xmlDoc = new(); + xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); + XmlElement rootElement = xmlDoc.CreateElement("eminus"); + xmlDoc.AppendChild(rootElement); + rootElement.SetAttribute("authKey", _config.password); + + XmlElement loadElement = xmlDoc.CreateElement("loadclass"); + loadElement.SetAttribute("mode", "dialog"); + rootElement.AppendChild(loadElement); + + XmlElement elemClassName = xmlDoc.CreateElement("classname"); + XmlElement elemLineNum = xmlDoc.CreateElement("linenumber"); + elemClassName.InnerText = className; + elemLineNum.InnerText = lineNum; + loadElement.AppendChild(elemClassName); + loadElement.AppendChild(elemLineNum); + return xmlDoc; + } + + #endregion + + #region IContextMenuEntry Member + + public string GetMenuText(IList logLines, ILogLineColumnizer columnizer, ILogExpertCallback callback) + { + //not used + return string.Empty; + } + + public string GetMenuText(int logLinesCount, ILogLineColumnizer columnizer, ILogLine logline) + { + if (logLinesCount == 1 && BuildParam(logline) != null) + { + return "Load class in Eclipse"; + } + else + { + return $"{DISABLED}Load class in Eclipse"; + } + } + + public void MenuSelected(IList logLines, ILogLineColumnizer columnizer, ILogExpertCallback callback) + { + //Not used + } + + public void MenuSelected(int logLinesCount, ILogLineColumnizer columnizer, ILogLine logline) + { + if (logLinesCount != 1) + { + return; + } + + XmlDocument doc = BuildParam(logline); + + if (doc == null) + { + MessageBox.Show("Cannot parse Java stack trace line", "LogExpert"); + } + else + { + try + { + TcpClient client = new(_config.host, _config.port); + NetworkStream stream = client.GetStream(); + StreamWriter writer = new(stream); + doc.Save(writer); + writer.Flush(); + stream.Flush(); + writer.Close(); + stream.Close(500); + client.Close(); + } + catch (Exception e) + { + MessageBox.Show(e.Message, "LogExpert"); + } + } + } + + #endregion + + #region ILogExpertPluginConfigurator Member + + public void LoadConfig(string configDir) + { + string configPath = configDir + CFG_FILE_NAME; + + FileInfo fileInfo = new(configDir + Path.DirectorySeparatorChar + CFG_FILE_NAME); + + if (!File.Exists(configPath)) + { + _config = new EminusConfig(); + } + else + { + try + { + _config = JsonConvert.DeserializeObject(File.ReadAllText($"{fileInfo.FullName}")); + } + catch (SerializationException e) + { + MessageBox.Show(e.Message, "Deserialize"); + _config = new EminusConfig(); + } + } + } + + + public void SaveConfig(string configDir) + { + FileInfo fileInfo = new(configDir + Path.DirectorySeparatorChar + CFG_FILE_NAME); + + dlg?.ApplyChanges(); + + _config = tmpConfig.Clone(); + + using StreamWriter sw = new(fileInfo.Create()); + JsonSerializer serializer = new(); + serializer.Serialize(sw, _config); + } + + public bool HasEmbeddedForm() + { + return true; + } + + public void ShowConfigForm(object panel) + { + dlg = new EminusConfigDlg(tmpConfig) + { + Parent = (Panel)panel + }; + dlg.Show(); + } + + /// + /// Implemented only for demonstration purposes. This function is called when the config button + /// is pressed (HasEmbeddedForm() must return false for this). + /// + /// + public void ShowConfigDialog(object owner) + { + dlg = new EminusConfigDlg(tmpConfig) + { + TopLevel = true, + Owner = (Form)owner + }; + + dlg.ShowDialog(); + dlg.ApplyChanges(); + } + + + public void HideConfigForm() + { + if (dlg != null) + { + dlg.ApplyChanges(); + dlg.Hide(); + dlg.Dispose(); + dlg = null; + } + } + + public void StartConfig() + { + tmpConfig = _config.Clone(); + } + + #endregion + } } \ No newline at end of file diff --git a/src/DefaultPlugins/EminusConfig.cs b/src/LogExpert.UI/Dialogs/Eminus/EminusConfig.cs similarity index 89% rename from src/DefaultPlugins/EminusConfig.cs rename to src/LogExpert.UI/Dialogs/Eminus/EminusConfig.cs index f8699a53..28586414 100644 --- a/src/DefaultPlugins/EminusConfig.cs +++ b/src/LogExpert.UI/Dialogs/Eminus/EminusConfig.cs @@ -1,31 +1,31 @@ -using System; - -namespace LogExpert -{ - [Serializable] - public class EminusConfig - { - #region Fields - - public string host = "127.0.0.1"; - public string password = ""; - public int port = 12345; - - #endregion - - #region Public methods - - public EminusConfig Clone() - { - EminusConfig config = new() - { - host = host, - port = port, - password = password - }; - return config; - } - - #endregion - } +using System; + +namespace LogExpert +{ + [Serializable] + internal class EminusConfig + { + #region Fields + + public string host = "127.0.0.1"; + public string password = ""; + public int port = 12345; + + #endregion + + #region Public methods + + public EminusConfig Clone() + { + EminusConfig config = new() + { + host = host, + port = port, + password = password + }; + return config; + } + + #endregion + } } \ No newline at end of file diff --git a/src/DefaultPlugins/EminusConfigDlg.Designer.cs b/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.Designer.cs similarity index 97% rename from src/DefaultPlugins/EminusConfigDlg.Designer.cs rename to src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.Designer.cs index 56617b77..267dc40d 100644 --- a/src/DefaultPlugins/EminusConfigDlg.Designer.cs +++ b/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.Designer.cs @@ -1,135 +1,135 @@ -namespace LogExpert -{ - partial class EminusConfigDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EminusConfigDlg)); - this.hostTextBox = new System.Windows.Forms.TextBox(); - this.passwordTextBox = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.portTextBox = new System.Windows.Forms.MaskedTextBox(); - this.SuspendLayout(); - // - // hostTextBox - // - this.hostTextBox.Location = new System.Drawing.Point(76, 69); - this.hostTextBox.Name = "hostTextBox"; - this.hostTextBox.Size = new System.Drawing.Size(175, 20); - this.hostTextBox.TabIndex = 0; - // - // passwordTextBox - // - this.passwordTextBox.Location = new System.Drawing.Point(76, 122); - this.passwordTextBox.Name = "passwordTextBox"; - this.passwordTextBox.Size = new System.Drawing.Size(175, 20); - this.passwordTextBox.TabIndex = 2; - this.passwordTextBox.UseSystemPasswordChar = true; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(17, 72); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(29, 13); - this.label1.TabIndex = 5; - this.label1.Text = "Host"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(17, 99); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(26, 13); - this.label2.TabIndex = 6; - this.label2.Text = "Port"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(17, 126); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(53, 13); - this.label3.TabIndex = 7; - this.label3.Text = "Password"; - // - // label4 - // - this.label4.Location = new System.Drawing.Point(13, 13); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(276, 41); - this.label4.TabIndex = 8; - this.label4.Text = "Enter the host and the port where the Eclipse plugin is listening to. If a passwo" + - "rd is configured, enter the password too."; - // - // portTextBox - // - this.portTextBox.Location = new System.Drawing.Point(76, 96); - this.portTextBox.Mask = "99999"; - this.portTextBox.Name = "portTextBox"; - this.portTextBox.Size = new System.Drawing.Size(100, 20); - this.portTextBox.TabIndex = 1; - // - // EminusConfigDlg - // - this.ClientSize = new System.Drawing.Size(295, 187); - this.ControlBox = false; - this.Controls.Add(this.portTextBox); - this.Controls.Add(this.label4); - this.Controls.Add(this.label3); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Controls.Add(this.passwordTextBox); - this.Controls.Add(this.hostTextBox); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "EminusConfigDlg"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Eclipse Remote Navigation"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TextBox hostTextBox; - private System.Windows.Forms.TextBox passwordTextBox; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.MaskedTextBox portTextBox; - } +namespace LogExpert +{ + partial class EminusConfigDlg + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EminusConfigDlg)); + this.hostTextBox = new System.Windows.Forms.TextBox(); + this.passwordTextBox = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.portTextBox = new System.Windows.Forms.MaskedTextBox(); + this.SuspendLayout(); + // + // hostTextBox + // + this.hostTextBox.Location = new System.Drawing.Point(76, 69); + this.hostTextBox.Name = "hostTextBox"; + this.hostTextBox.Size = new System.Drawing.Size(175, 20); + this.hostTextBox.TabIndex = 0; + // + // passwordTextBox + // + this.passwordTextBox.Location = new System.Drawing.Point(76, 122); + this.passwordTextBox.Name = "passwordTextBox"; + this.passwordTextBox.Size = new System.Drawing.Size(175, 20); + this.passwordTextBox.TabIndex = 2; + this.passwordTextBox.UseSystemPasswordChar = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(17, 72); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(29, 13); + this.label1.TabIndex = 5; + this.label1.Text = "Host"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(17, 99); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(26, 13); + this.label2.TabIndex = 6; + this.label2.Text = "Port"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(17, 126); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(53, 13); + this.label3.TabIndex = 7; + this.label3.Text = "Password"; + // + // label4 + // + this.label4.Location = new System.Drawing.Point(13, 13); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(276, 41); + this.label4.TabIndex = 8; + this.label4.Text = "Enter the host and the port where the Eclipse plugin is listening to. If a passwo" + + "rd is configured, enter the password too."; + // + // portTextBox + // + this.portTextBox.Location = new System.Drawing.Point(76, 96); + this.portTextBox.Mask = "99999"; + this.portTextBox.Name = "portTextBox"; + this.portTextBox.Size = new System.Drawing.Size(100, 20); + this.portTextBox.TabIndex = 1; + // + // EminusConfigDlg + // + this.ClientSize = new System.Drawing.Size(295, 187); + this.ControlBox = false; + this.Controls.Add(this.portTextBox); + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.passwordTextBox); + this.Controls.Add(this.hostTextBox); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "EminusConfigDlg"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Eclipse Remote Navigation"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox hostTextBox; + private System.Windows.Forms.TextBox passwordTextBox; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.MaskedTextBox portTextBox; + } } \ No newline at end of file diff --git a/src/DefaultPlugins/EminusConfigDlg.cs b/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.cs similarity index 91% rename from src/DefaultPlugins/EminusConfigDlg.cs rename to src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.cs index 672b7fa6..7568e0b1 100644 --- a/src/DefaultPlugins/EminusConfigDlg.cs +++ b/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.cs @@ -1,60 +1,60 @@ -using System; -using System.Drawing; -using System.Windows.Forms; - -namespace LogExpert -{ - public partial class EminusConfigDlg : Form - { - #region Fields - - #endregion - - #region cTor - - public EminusConfigDlg(EminusConfig config) - { - SuspendLayout(); - - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - InitializeComponent(); - - TopLevel = false; - Config = config; - - hostTextBox.Text = config.host; - portTextBox.Text = string.Empty + config.port; - passwordTextBox.Text = config.password; - - ResumeLayout(); - } - - #endregion - - #region Properties - - public EminusConfig Config { get; set; } - - #endregion - - #region Public methods - - public void ApplyChanges() - { - Config.host = hostTextBox.Text; - try - { - Config.port = short.Parse(portTextBox.Text); - } - catch (FormatException) - { - Config.port = 0; - } - Config.password = passwordTextBox.Text; - } - - #endregion - } +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace LogExpert +{ + internal partial class EminusConfigDlg : Form + { + #region Fields + + #endregion + + #region cTor + + public EminusConfigDlg(EminusConfig config) + { + SuspendLayout(); + + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + InitializeComponent(); + + TopLevel = false; + Config = config; + + hostTextBox.Text = config.host; + portTextBox.Text = string.Empty + config.port; + passwordTextBox.Text = config.password; + + ResumeLayout(); + } + + #endregion + + #region Properties + + public EminusConfig Config { get; set; } + + #endregion + + #region Public methods + + public void ApplyChanges() + { + Config.host = hostTextBox.Text; + try + { + Config.port = short.Parse(portTextBox.Text); + } + catch (FormatException) + { + Config.port = 0; + } + Config.password = passwordTextBox.Text; + } + + #endregion + } } \ No newline at end of file diff --git a/src/DefaultPlugins/EminusConfigDlg.resx b/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.resx similarity index 98% rename from src/DefaultPlugins/EminusConfigDlg.resx rename to src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.resx index 20cf2a6f..e97451d5 100644 --- a/src/DefaultPlugins/EminusConfigDlg.resx +++ b/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.resx @@ -1,131 +1,131 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA - AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// - AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// - //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA - AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAIABAAD//wAA - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// + //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA + AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAIABAAD//wAA + + \ No newline at end of file diff --git a/src/LogExpert.UI/LogExpert.UI.csproj b/src/LogExpert.UI/LogExpert.UI.csproj index d6b22f11..1b9222a5 100644 --- a/src/LogExpert.UI/LogExpert.UI.csproj +++ b/src/LogExpert.UI/LogExpert.UI.csproj @@ -40,6 +40,9 @@ + + Form + True True diff --git a/src/RegexColumnizer/RegexColumnizer.csproj b/src/RegexColumnizer/RegexColumnizer.csproj index 22af73ea..c83521b1 100644 --- a/src/RegexColumnizer/RegexColumnizer.csproj +++ b/src/RegexColumnizer/RegexColumnizer.csproj @@ -5,7 +5,7 @@ Library false true - false + false true false $(SolutionDir)..\bin\$(Configuration)\plugins From 92f942edcadfb5905aef6721a1c1232df1006861 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sun, 1 Jun 2025 02:15:52 +0300 Subject: [PATCH 041/142] Fix: Compile in Linux --- src/PluginRegistry/LogExpert.PluginRegistry.csproj | 2 +- src/PluginRegistry/PluginRegistry.cs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/PluginRegistry/LogExpert.PluginRegistry.csproj b/src/PluginRegistry/LogExpert.PluginRegistry.csproj index 56a2d733..4190d432 100644 --- a/src/PluginRegistry/LogExpert.PluginRegistry.csproj +++ b/src/PluginRegistry/LogExpert.PluginRegistry.csproj @@ -23,7 +23,7 @@ - + diff --git a/src/PluginRegistry/PluginRegistry.cs b/src/PluginRegistry/PluginRegistry.cs index 26bf5331..0ba17139 100644 --- a/src/PluginRegistry/PluginRegistry.cs +++ b/src/PluginRegistry/PluginRegistry.cs @@ -3,9 +3,7 @@ using LogExpert.Core.Entities; using LogExpert.Core.Interface; using LogExpert.PluginRegistry.FileSystem; - using NLog; - using System.Reflection; namespace LogExpert.PluginRegistry From 902237555336ff9f92d9329f4e96d19d4135ed2b Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sun, 1 Jun 2025 02:31:36 +0300 Subject: [PATCH 042/142] Fix: Compile in Linux --- src/LogExpert/LogExpert.csproj | 3 +-- src/RegexColumnizer/RegexColumnizer.csproj | 4 ---- src/SftpFileSystemx86/SftpFileSystemx86.csproj | 2 -- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/LogExpert/LogExpert.csproj b/src/LogExpert/LogExpert.csproj index 61859238..a145ea46 100644 --- a/src/LogExpert/LogExpert.csproj +++ b/src/LogExpert/LogExpert.csproj @@ -46,13 +46,12 @@ - - + diff --git a/src/RegexColumnizer/RegexColumnizer.csproj b/src/RegexColumnizer/RegexColumnizer.csproj index c83521b1..5cbe4fe9 100644 --- a/src/RegexColumnizer/RegexColumnizer.csproj +++ b/src/RegexColumnizer/RegexColumnizer.csproj @@ -35,8 +35,4 @@ Key.snk - - - - diff --git a/src/SftpFileSystemx86/SftpFileSystemx86.csproj b/src/SftpFileSystemx86/SftpFileSystemx86.csproj index 339e9ea5..b223e8ba 100644 --- a/src/SftpFileSystemx86/SftpFileSystemx86.csproj +++ b/src/SftpFileSystemx86/SftpFileSystemx86.csproj @@ -66,8 +66,6 @@ - - From 6afc9d8eb055bf0986a9fb905d46011ba7e18d9e Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sun, 1 Jun 2025 02:38:56 +0300 Subject: [PATCH 043/142] Fix: Compile in Linux --- src/LogExpert.UI/LogExpert.UI.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LogExpert.UI/LogExpert.UI.csproj b/src/LogExpert.UI/LogExpert.UI.csproj index 1b9222a5..75ec39ba 100644 --- a/src/LogExpert.UI/LogExpert.UI.csproj +++ b/src/LogExpert.UI/LogExpert.UI.csproj @@ -19,8 +19,8 @@ - - + + From d3b3018fb71b5ce205e34b720d9b926b0ee7db5c Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sun, 1 Jun 2025 02:46:14 +0300 Subject: [PATCH 044/142] Fix: Compile in Linux --- src/LogExpert.UI/LogExpert.UI.csproj | 1 + src/RegexColumnizer.UnitTests/RegexColumnizer.UnitTests.csproj | 1 + 2 files changed, 2 insertions(+) diff --git a/src/LogExpert.UI/LogExpert.UI.csproj b/src/LogExpert.UI/LogExpert.UI.csproj index 75ec39ba..94a3d5c1 100644 --- a/src/LogExpert.UI/LogExpert.UI.csproj +++ b/src/LogExpert.UI/LogExpert.UI.csproj @@ -3,6 +3,7 @@ True ..\Solution Items\Key.snk + true true false enable diff --git a/src/RegexColumnizer.UnitTests/RegexColumnizer.UnitTests.csproj b/src/RegexColumnizer.UnitTests/RegexColumnizer.UnitTests.csproj index 75cf507e..50c96688 100644 --- a/src/RegexColumnizer.UnitTests/RegexColumnizer.UnitTests.csproj +++ b/src/RegexColumnizer.UnitTests/RegexColumnizer.UnitTests.csproj @@ -6,6 +6,7 @@ false false bin\$(Configuration) + true true From c11b4c06063149e98b60d544dae127a537329271 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 1 Jun 2025 10:38:43 +0200 Subject: [PATCH 045/142] removed bookmark view, optimized a little bit --- .../Classes/Bookmark/BookmarkDataProvider.cs | 234 +++++++++--------- .../Classes/Bookmark/BookmarkExporter.cs | 101 ++++---- .../Classes/Bookmark/BookmarkView.cs | 46 ---- 3 files changed, 168 insertions(+), 213 deletions(-) delete mode 100644 src/LogExpert.Core/Classes/Bookmark/BookmarkView.cs diff --git a/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs b/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs index 30a2d94b..ed739fa4 100644 --- a/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs +++ b/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs @@ -1,176 +1,180 @@ -using LogExpert.Core.Entities; +using LogExpert.Core.Entities; using LogExpert.Core.Interface; using NLog; -namespace LogExpert.Core.Classes.Bookmark +namespace LogExpert.Core.Classes.Bookmark; + +public class BookmarkDataProvider : IBookmarkData { - public class BookmarkDataProvider : IBookmarkData - { - #region Fields + #region Fields - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); - #endregion + #endregion - #region cTor + #region cTor - public BookmarkDataProvider() - { - BookmarkList = []; - } + public BookmarkDataProvider () + { + BookmarkList = []; + } - public BookmarkDataProvider(SortedList bookmarkList) - { - BookmarkList = bookmarkList; - } + public BookmarkDataProvider (SortedList bookmarkList) + { + BookmarkList = bookmarkList; + } - #endregion + #endregion - #region Delegates + #region Delegates - public delegate void AllBookmarksRemovedEventHandler(object sender, System.EventArgs e); + public delegate void AllBookmarksRemovedEventHandler (object sender, EventArgs e); - public delegate void BookmarkAddedEventHandler(object sender, System.EventArgs e); + public delegate void BookmarkAddedEventHandler (object sender, EventArgs e); - public delegate void BookmarkRemovedEventHandler(object sender, System.EventArgs e); + public delegate void BookmarkRemovedEventHandler (object sender, EventArgs e); - #endregion + #endregion - #region Events + #region Events - public event BookmarkAddedEventHandler BookmarkAdded; - public event BookmarkRemovedEventHandler BookmarkRemoved; - public event AllBookmarksRemovedEventHandler AllBookmarksRemoved; + public event BookmarkAddedEventHandler BookmarkAdded; + public event BookmarkRemovedEventHandler BookmarkRemoved; + public event AllBookmarksRemovedEventHandler AllBookmarksRemoved; - #endregion + #endregion - #region Properties + #region Properties - public BookmarkCollection Bookmarks => new(BookmarkList); + public BookmarkCollection Bookmarks => new(BookmarkList); - public SortedList BookmarkList { get; set; } + public SortedList BookmarkList { get; private set; } - #endregion + #endregion - #region Public methods + #region Public methods - public void ToggleBookmark(int lineNum) + public void ToggleBookmark (int lineNum) + { + if (IsBookmarkAtLine(lineNum)) { - if (IsBookmarkAtLine(lineNum)) - { - RemoveBookmarkForLine(lineNum); - } - else - { - AddBookmark(new Entities.Bookmark(lineNum)); - } + RemoveBookmarkForLine(lineNum); } - - public bool IsBookmarkAtLine(int lineNum) + else { - return BookmarkList.ContainsKey(lineNum); + AddBookmark(new Entities.Bookmark(lineNum)); } + } - public int GetBookmarkIndexForLine(int lineNum) - { - return BookmarkList.IndexOfKey(lineNum); - } + public bool IsBookmarkAtLine (int lineNum) + { + return BookmarkList.ContainsKey(lineNum); + } - public Entities.Bookmark GetBookmarkForLine(int lineNum) - { - return BookmarkList[lineNum]; - } + public int GetBookmarkIndexForLine (int lineNum) + { + return BookmarkList.IndexOfKey(lineNum); + } - #endregion + public Entities.Bookmark GetBookmarkForLine (int lineNum) + { + return BookmarkList[lineNum]; + } - #region Internals + #endregion - public void ShiftBookmarks(int offset) - { - SortedList newBookmarkList = []; - foreach (Entities.Bookmark bookmark in BookmarkList.Values) - { - int line = bookmark.LineNum - offset; - if (line >= 0) - { - bookmark.LineNum = line; - newBookmarkList.Add(line, bookmark); - } - } - BookmarkList = newBookmarkList; - } + #region Internals + + public void ShiftBookmarks (int offset) + { + SortedList newBookmarkList = []; - public int FindPrevBookmarkIndex(int lineNum) + foreach (Entities.Bookmark bookmark in BookmarkList.Values) { - IList values = BookmarkList.Values; - for (int i = BookmarkList.Count - 1; i >= 0; --i) + var line = bookmark.LineNum - offset; + if (line >= 0) { - if (values[i].LineNum <= lineNum) - { - return i; - } + bookmark.LineNum = line; + newBookmarkList.Add(line, bookmark); } - return BookmarkList.Count - 1; } - public int FindNextBookmarkIndex(int lineNum) + BookmarkList = newBookmarkList; + } + + public int FindPrevBookmarkIndex (int lineNum) + { + IList values = BookmarkList.Values; + for (var i = BookmarkList.Count - 1; i >= 0; --i) { - IList values = BookmarkList.Values; - for (int i = 0; i < BookmarkList.Count; ++i) + if (values[i].LineNum <= lineNum) { - if (values[i].LineNum >= lineNum) - { - return i; - } + return i; } - return 0; } - public void RemoveBookmarkForLine(int lineNum) - { - BookmarkList.Remove(lineNum); - OnBookmarkRemoved(); - } + return BookmarkList.Count - 1; + } - public void RemoveBookmarksForLines(List lineNumList) + public int FindNextBookmarkIndex (int lineNum) + { + IList values = BookmarkList.Values; + for (var i = 0; i < BookmarkList.Count; ++i) { - foreach (int lineNum in lineNumList) + if (values[i].LineNum >= lineNum) { - BookmarkList.Remove(lineNum); + return i; } - OnBookmarkRemoved(); } + return 0; + } + public void RemoveBookmarkForLine (int lineNum) + { + _ = BookmarkList.Remove(lineNum); + OnBookmarkRemoved(); + } - public void AddBookmark(Entities.Bookmark bookmark) + public void RemoveBookmarksForLines (List lineNumList) + { + foreach (var lineNum in lineNumList) { - BookmarkList.Add(bookmark.LineNum, bookmark); - OnBookmarkAdded(); - } + _ = BookmarkList.Remove(lineNum); - public void ClearAllBookmarks() - { - _logger.Debug("Removing all bookmarks"); - BookmarkList.Clear(); - OnAllBookmarksRemoved(); } - #endregion + OnBookmarkRemoved(); + } - protected void OnBookmarkAdded() - { - BookmarkAdded?.Invoke(this, System.EventArgs.Empty); - } - protected void OnBookmarkRemoved() - { - BookmarkRemoved?.Invoke(this, System.EventArgs.Empty); - } + public void AddBookmark (Entities.Bookmark bookmark) + { + BookmarkList.Add(bookmark.LineNum, bookmark); + OnBookmarkAdded(); + } - protected void OnAllBookmarksRemoved() - { - AllBookmarksRemoved?.Invoke(this, System.EventArgs.Empty); - } + public void ClearAllBookmarks () + { + _logger.Debug("Removing all bookmarks"); + BookmarkList.Clear(); + OnAllBookmarksRemoved(); + } + + #endregion + + protected void OnBookmarkAdded () + { + BookmarkAdded?.Invoke(this, EventArgs.Empty); + } + + protected void OnBookmarkRemoved () + { + BookmarkRemoved?.Invoke(this, EventArgs.Empty); + } + + protected void OnAllBookmarksRemoved () + { + AllBookmarksRemoved?.Invoke(this, EventArgs.Empty); } } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs b/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs index ac4a34a5..6cd3fa13 100644 --- a/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs +++ b/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs @@ -1,73 +1,70 @@ -namespace LogExpert.Core.Classes.Bookmark +namespace LogExpert.Core.Classes.Bookmark; + +public static class BookmarkExporter { - public static class BookmarkExporter - { - #region Fields + #region Fields - private const string replacementForNewLine = @"\n"; + private const string replacementForNewLine = @"\n"; - #endregion + #endregion - #region Public methods + #region Public methods - public static void ExportBookmarkList(SortedList bookmarkList, string logfileName, - string fileName) + public static void ExportBookmarkList (SortedList bookmarkList, string logfileName, + string fileName) + { + FileStream fs = new(fileName, FileMode.Create, FileAccess.Write); + StreamWriter writer = new(fs); + writer.WriteLine("Log file name;Line number;Comment"); + foreach (Entities.Bookmark bookmark in bookmarkList.Values) { - FileStream fs = new(fileName, FileMode.Create, FileAccess.Write); - StreamWriter writer = new(fs); - writer.WriteLine("Log file name;Line number;Comment"); - foreach (Entities.Bookmark bookmark in bookmarkList.Values) - { - string line = logfileName + ";" + bookmark.LineNum + ";" + - bookmark.Text.Replace(replacementForNewLine, @"\" + replacementForNewLine).Replace("\r\n", replacementForNewLine); - writer.WriteLine(line); - } - writer.Close(); - fs.Close(); + string line = $"{logfileName};{bookmark.LineNum};{bookmark.Text.Replace(replacementForNewLine, @"\" + replacementForNewLine, StringComparison.OrdinalIgnoreCase).Replace("\r\n", replacementForNewLine, StringComparison.OrdinalIgnoreCase)}"; + writer.WriteLine(line); } + writer.Close(); + fs.Close(); + } - public static void ImportBookmarkList(string logfileName, string fileName, SortedList bookmarkList) + public static void ImportBookmarkList (string logfileName, string fileName, SortedList bookmarkList) + { + using FileStream fs = new(fileName, FileMode.Open, FileAccess.Read); + using StreamReader reader = new(fs); + if (!reader.EndOfStream) { - using FileStream fs = new(fileName, FileMode.Open, FileAccess.Read); - using StreamReader reader = new(fs); - if (!reader.EndOfStream) - { - reader.ReadLine(); // skip "Log file name;Line number;Comment" - } + _ = reader.ReadLine(); // skip "Log file name;Line number;Comment" + } - while (!reader.EndOfStream) + while (!reader.EndOfStream) + { + try { - try - { - string line = reader.ReadLine(); - line = line.Replace(replacementForNewLine, "\r\n").Replace("\\\r\n", replacementForNewLine); + var line = reader.ReadLine(); + line = line.Replace(replacementForNewLine, "\r\n", StringComparison.OrdinalIgnoreCase).Replace("\\\r\n", replacementForNewLine, StringComparison.OrdinalIgnoreCase); - // Line is formatted: logfileName ";" bookmark.LineNum ";" bookmark.Text; - int firstSeparator = line.IndexOf(';'); - int secondSeparator = line.IndexOf(';', firstSeparator + 1); + // Line is formatted: logfileName ";" bookmark.LineNum ";" bookmark.Text; + var firstSeparator = line.IndexOf(';', StringComparison.OrdinalIgnoreCase); + var secondSeparator = line.IndexOf(';', firstSeparator + 1); - string fileStr = line.Substring(0, firstSeparator); - string lineStr = line.Substring(firstSeparator + 1, secondSeparator - firstSeparator - 1); - string comment = line.Substring(secondSeparator + 1); + var fileStr = line[..firstSeparator]; + var lineStr = line.Substring(firstSeparator + 1, secondSeparator - firstSeparator - 1); + var comment = line[(secondSeparator + 1)..]; - int lineNum; - if (int.TryParse(lineStr, out lineNum)) - { - Entities.Bookmark bookmark = new(lineNum, comment); - bookmarkList.Add(lineNum, bookmark); - } - else - { - //!!!log error: skipping a line entry - } + if (int.TryParse(lineStr, out var lineNum)) + { + Entities.Bookmark bookmark = new(lineNum, comment); + bookmarkList.Add(lineNum, bookmark); } - catch + else { - //!!! + //!!!log error: skipping a line entry } } + catch + { + //!!! + } } - - #endregion } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Bookmark/BookmarkView.cs b/src/LogExpert.Core/Classes/Bookmark/BookmarkView.cs deleted file mode 100644 index 7812f91d..00000000 --- a/src/LogExpert.Core/Classes/Bookmark/BookmarkView.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; - -using LogExpert.Core.Interface; - -namespace LogExpert.Core.Classes.Bookmark -{ - //TODO: Not in use! - internal class BookmarkView : IBookmarkView - { - #region Fields - - #endregion - - - #region IBookmarkView Member - - public void UpdateView() - { - throw new NotImplementedException(); - } - - public void BookmarkTextChanged(Entities.Bookmark bookmark) - { - throw new NotImplementedException(); - } - - public void SelectBookmark(int lineNum) - { - throw new NotImplementedException(); - } - - public bool LineColumnVisible - { - set { throw new NotImplementedException(); } - } - - public bool IsActive { get; set; } = false; - - public void SetBookmarkData(IBookmarkData bookmarkData) - { - throw new NotImplementedException(); - } - - #endregion - } -} \ No newline at end of file From 75ff7c4e0ad8438203ad802e207da5db5916986e Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 1 Jun 2025 10:50:20 +0200 Subject: [PATCH 046/142] editor config optimizations --- .../IAutoLogLineColumnizerCallback.cs | 4 +- .../ILogLineColumnizerCallback.cs | 16 +- .../Callback/ColumnizerCallback.cs | 33 +- .../Columnizer/SquareBracketColumnizer.cs | 31 +- src/LogExpert.Core/Classes/Filter/Filter.cs | 33 +- .../Classes/Filter/FilterStarter.cs | 24 +- src/LogExpert.Core/Interface/ILogWindow.cs | 40 +- .../Controls/LogWindow/ColumnCache.cs | 53 +- .../Controls/LogWindow/LogWindow.cs | 2 +- .../LogWindow/LogWindowEventHandlers.cs | 379 ++++++------ .../Controls/LogWindow/LogWindowPrivate.cs | 546 +++++++++--------- 11 files changed, 585 insertions(+), 576 deletions(-) diff --git a/src/ColumnizerLib/IAutoLogLineColumnizerCallback.cs b/src/ColumnizerLib/IAutoLogLineColumnizerCallback.cs index 8889c8f9..25b315d9 100644 --- a/src/ColumnizerLib/IAutoLogLineColumnizerCallback.cs +++ b/src/ColumnizerLib/IAutoLogLineColumnizerCallback.cs @@ -1,4 +1,4 @@ -namespace LogExpert +namespace LogExpert { public interface IAutoLogLineColumnizerCallback { @@ -7,6 +7,6 @@ public interface IAutoLogLineColumnizerCallback /// /// Number of the line to be retrieved /// A string with line content or null if line number is out of range - ILogLine GetLogLine(int lineNum); + ILogLine GetLogLine (int lineNum); } } \ No newline at end of file diff --git a/src/ColumnizerLib/ILogLineColumnizerCallback.cs b/src/ColumnizerLib/ILogLineColumnizerCallback.cs index 270b9b40..439b6476 100644 --- a/src/ColumnizerLib/ILogLineColumnizerCallback.cs +++ b/src/ColumnizerLib/ILogLineColumnizerCallback.cs @@ -1,4 +1,4 @@ -namespace LogExpert +namespace LogExpert { /// ///This is a callback interface. Some of the ILogLineColumnizer functions @@ -21,26 +21,32 @@ public interface ILogLineColumnizerCallback /// a ILogLineColumnizer function is called for (e.g. the line that has to be painted). /// /// The current line number starting at 0 - int GetLineNum(); + int GetLineNum (); + /// + /// This function sets the current line number. That is the line number of the log line + /// a ILogLineColumnizer function is called for (e.g. the line that has to be painted). + /// + /// line number to be set + void SetLineNum (int lineNum); /// /// Returns the full file name (path + name) of the current log file. /// /// File name of current log file - string GetFileName(); + string GetFileName (); /// /// Returns the log line with the given index (zero-based). /// /// Number of the line to be retrieved /// A string with line content or null if line number is out of range - ILogLine GetLogLine(int lineNum); + ILogLine GetLogLine (int lineNum); /// /// Returns the number of lines of the logfile. /// /// Number of lines. - int GetLineCount(); + int GetLineCount (); #endregion } diff --git a/src/LogExpert.Core/Callback/ColumnizerCallback.cs b/src/LogExpert.Core/Callback/ColumnizerCallback.cs index 4168713e..ddf51448 100644 --- a/src/LogExpert.Core/Callback/ColumnizerCallback.cs +++ b/src/LogExpert.Core/Callback/ColumnizerCallback.cs @@ -1,4 +1,4 @@ -using LogExpert.Core.Interface; +using LogExpert.Core.Interface; namespace LogExpert.Classes.ILogLineColumnizerCallback { @@ -6,22 +6,22 @@ public class ColumnizerCallback : LogExpert.ILogLineColumnizerCallback, IAutoLog { #region Fields - protected ILogWindow _logWindow; - protected IPluginRegistry _pluginRegistry; + private protected ILogWindow _logWindow; + private protected IPluginRegistry _pluginRegistry; #endregion #region cTor - public ColumnizerCallback(ILogWindow logWindow) + public ColumnizerCallback (ILogWindow logWindow) { _logWindow = logWindow; } - private ColumnizerCallback(ColumnizerCallback original) + private ColumnizerCallback (ColumnizerCallback original) { _logWindow = original._logWindow; - LineNum = original.LineNum; + LineNum = original.GetLineNum(); } #endregion @@ -34,34 +34,39 @@ private ColumnizerCallback(ColumnizerCallback original) #region Public methods - public ColumnizerCallback CreateCopy() + public ColumnizerCallback CreateCopy () { return new ColumnizerCallback(this); } - public int GetLineNum() + public int GetLineNum () { return LineNum; } - public string GetFileName() + public string GetFileName () { - return _logWindow.GetCurrentFileName(LineNum); + return _logWindow.GetCurrentFileName(GetLineNum()); } - public ILogLine GetLogLine(int lineNum) + public ILogLine GetLogLine (int lineNum) { return _logWindow.GetLine(lineNum); } - public IList GetRegisteredColumnizers() + public IList GetRegisteredColumnizers () { return _pluginRegistry.RegisteredColumnizers; } - public int GetLineCount() + public int GetLineCount () { - return _logWindow._logFileReader.LineCount; + return _logWindow.LogFileReader.LineCount; + } + + public void SetLineNum (int lineNum) + { + LineNum = lineNum; } #endregion diff --git a/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs b/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs index 58f15b05..9ca62371 100644 --- a/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs +++ b/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; using System.Text.RegularExpressions; using static LogExpert.Core.Classes.Columnizer.TimeFormatDeterminer; @@ -18,11 +15,11 @@ public class SquareBracketColumnizer : ILogLineColumnizer, IColumnizerPriority private int _columnCount = 5; private bool _isTimeExists = false; - public SquareBracketColumnizer() + public SquareBracketColumnizer () { } - public SquareBracketColumnizer(int columnCount, bool isTimeExists) : this() + public SquareBracketColumnizer (int columnCount, bool isTimeExists) : this() { // Add message column _columnCount = columnCount + 1; @@ -34,22 +31,22 @@ public SquareBracketColumnizer(int columnCount, bool isTimeExists) : this() } } - public bool IsTimeshiftImplemented() + public bool IsTimeshiftImplemented () { return true; } - public void SetTimeOffset(int msecOffset) + public void SetTimeOffset (int msecOffset) { timeOffset = msecOffset; } - public int GetTimeOffset() + public int GetTimeOffset () { return timeOffset; } - public DateTime GetTimestamp(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + public DateTime GetTimestamp (LogExpert.ILogLineColumnizerCallback callback, ILogLine line) { IColumnizedLogLine cols = SplitLine(callback, line); if (cols == null || cols.ColumnValues == null || cols.ColumnValues.Length < 2) @@ -81,7 +78,7 @@ public DateTime GetTimestamp(LogExpert.ILogLineColumnizerCallback callback, ILog } } - public void PushValue(LogExpert.ILogLineColumnizerCallback callback, int column, string value, string oldValue) + public void PushValue (LogExpert.ILogLineColumnizerCallback callback, int column, string value, string oldValue) { if (column == 1) { @@ -105,22 +102,22 @@ public void PushValue(LogExpert.ILogLineColumnizerCallback callback, int column, } } - public string GetName() + public string GetName () { return "Square Bracket Columnizer"; } - public string GetDescription() + public string GetDescription () { return "Splits every line into n fields: Date, Time and the rest of the log message"; } - public int GetColumnCount() + public int GetColumnCount () { return _columnCount; } - public string[] GetColumnNames() + public string[] GetColumnNames () { var columnNames = new List(GetColumnCount()); if (_isTimeExists) @@ -151,7 +148,7 @@ public string[] GetColumnNames() return columnNames.ToArray(); } - public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + public IColumnizedLogLine SplitLine (LogExpert.ILogLineColumnizerCallback callback, ILogLine line) { // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 @@ -217,7 +214,7 @@ public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callbac return clogLine; } - void SquareSplit(ref Column[] columns, string line, int dateLen, int timeLen, int dateTimeEndPos, ColumnizedLogLine clogLine) + void SquareSplit (ref Column[] columns, string line, int dateLen, int timeLen, int dateTimeEndPos, ColumnizedLogLine clogLine) { List columnList = []; int restColumn = _columnCount; @@ -256,7 +253,7 @@ void SquareSplit(ref Column[] columns, string line, int dateLen, int timeLen, in columns = columnList.ToArray(); } - public Priority GetPriority(string fileName, IEnumerable samples) + public Priority GetPriority (string fileName, IEnumerable samples) { Priority result = Priority.NotSupport; TimeFormatDeterminer timeDeterminer = new(); diff --git a/src/LogExpert.Core/Classes/Filter/Filter.cs b/src/LogExpert.Core/Classes/Filter/Filter.cs index 80ec7d4b..ed396886 100644 --- a/src/LogExpert.Core/Classes/Filter/Filter.cs +++ b/src/LogExpert.Core/Classes/Filter/Filter.cs @@ -1,16 +1,12 @@ -using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Classes.ILogLineColumnizerCallback; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Filter; using NLog; -using System; -using System.Collections.Generic; -using System.Windows.Forms; - namespace LogExpert.Classes.Filter { - internal delegate void FilterFx(FilterParams filterParams, List filterResultLines, List lastFilterResultLines, List filterHitList); + internal delegate void FilterFx (FilterParams filterParams, List filterResultLines, List lastFilterResultLines, List filterHitList); internal class Filter { @@ -27,7 +23,7 @@ internal class Filter #region cTor //TODO Is the callback needed? - public Filter(ColumnizerCallback callback) + public Filter (ColumnizerCallback callback) { _callback = callback; FilterResultLines = []; @@ -51,7 +47,7 @@ public Filter(ColumnizerCallback callback) #region Public methods - public int DoFilter(FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) + public int DoFilter (FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) { return DoFilter(filterParams, startLine, maxCount, FilterResultLines, LastFilterLinesList, FilterHitList, progressCallback); } @@ -60,16 +56,16 @@ public int DoFilter(FilterParams filterParams, int startLine, int maxCount, Prog #region Private Methods - private int DoFilter(FilterParams filterParams, int startLine, int maxCount, List filterResultLines, - List lastFilterLinesList, List filterHitList, ProgressCallback progressCallback) + private int DoFilter (FilterParams filterParams, int startLine, int maxCount, List filterResultLines, List lastFilterLinesList, List filterHitList, ProgressCallback progressCallback) { - int lineNum = startLine; - int count = 0; - int callbackCounter = 0; + var lineNum = startLine; + var count = 0; + var callbackCounter = 0; try { filterParams.Reset(); + while ((count++ < maxCount || filterParams.IsInRange) && !ShouldCancel) { if (lineNum >= _callback.GetLineCount()) @@ -78,16 +74,17 @@ private int DoFilter(FilterParams filterParams, int startLine, int maxCount, Lis } ILogLine line = _callback.GetLogLine(lineNum); + if (line == null) { return count; } - _callback.LineNum = lineNum; + _callback.SetLineNum(lineNum); + if (Util.TestFilterCondition(filterParams, line, _callback)) { - AddFilterLine(lineNum, false, filterParams, filterResultLines, lastFilterLinesList, - filterHitList); + AddFilterLine(lineNum, false, filterParams, filterResultLines, lastFilterLinesList, filterHitList); } lineNum++; @@ -112,7 +109,7 @@ private int DoFilter(FilterParams filterParams, int startLine, int maxCount, Lis return count; } - private void AddFilterLine(int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) + private void AddFilterLine (int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) { filterHitList.Add(lineNum); IList filterResult = GetAdditionalFilterResults(filterParams, lineNum, lastFilterLinesList); @@ -137,7 +134,7 @@ private void AddFilterLine(int lineNum, bool immediate, FilterParams filterParam /// /// /// - private IList GetAdditionalFilterResults(FilterParams filterParams, int lineNum, IList checkList) + private IList GetAdditionalFilterResults (FilterParams filterParams, int lineNum, IList checkList) { IList resultList = []; diff --git a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs index 672f33c8..aeb5c3ce 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs @@ -1,16 +1,11 @@ -using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Classes.ILogLineColumnizerCallback; using LogExpert.Core.Classes.Filter; using NLog; -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - namespace LogExpert.Classes.Filter { - public delegate void ProgressCallback(int lineCount); + public delegate void ProgressCallback (int lineCount); public class FilterStarter { @@ -35,7 +30,7 @@ public class FilterStarter #region cTor - public FilterStarter(ColumnizerCallback callback, int minThreads) + public FilterStarter (ColumnizerCallback callback, int minThreads) { _callback = callback; FilterResultLines = []; @@ -69,7 +64,7 @@ public FilterStarter(ColumnizerCallback callback, int minThreads) #region Public methods - public async void DoFilter(FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) + public async void DoFilter (FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) { FilterResultLines.Clear(); LastFilterLinesList.Clear(); @@ -87,6 +82,7 @@ public async void DoFilter(FilterParams filterParams, int startLine, int maxCoun { interval = 1; } + int workStartLine = startLine; List handleList = []; _progressLineCount = 0; @@ -121,7 +117,7 @@ public async void DoFilter(FilterParams filterParams, int startLine, int maxCoun /// Requests the FilterStarter to stop all filter threads. Call this from another thread (e.g. GUI). The function returns /// immediately without waiting for filter end. /// - public void CancelFilter() + public void CancelFilter () { _shouldStop = true; lock (_filterWorkerList) @@ -138,13 +134,13 @@ public void CancelFilter() #region Private Methods - private void ThreadProgressCallback(int lineCount) + private void ThreadProgressCallback (int lineCount) { int count = Interlocked.Add(ref _progressLineCount, lineCount); _progressCallback(count); } - private Filter DoWork(FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) + private Filter DoWork (FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) { _logger.Info("Started Filter worker [{0}] for line {1}", Environment.CurrentManagedThreadId, startLine); @@ -174,7 +170,7 @@ private Filter DoWork(FilterParams filterParams, int startLine, int maxCount, Pr return filter; } - private void FilterDoneCallback(Task filterTask) + private void FilterDoneCallback (Task filterTask) { if (filterTask.IsCompleted) { @@ -187,7 +183,7 @@ private void FilterDoneCallback(Task filterTask) } } - private void MergeResults() + private void MergeResults () { _logger.Info("Merging filter results."); foreach (Filter filter in _filterReadyList) diff --git a/src/LogExpert.Core/Interface/ILogWindow.cs b/src/LogExpert.Core/Interface/ILogWindow.cs index abe821b3..c6f72f93 100644 --- a/src/LogExpert.Core/Interface/ILogWindow.cs +++ b/src/LogExpert.Core/Interface/ILogWindow.cs @@ -1,29 +1,41 @@ - + using LogExpert.Core.Classes.Log; using LogExpert.Core.Classes.Persister; -using LogExpert.Core.Entities; using LogExpert.Core.EventHandlers; -using static LogExpert.Core.Classes.Log.LogfileReader; namespace LogExpert.Core.Interface { //TODO: Add documentation public interface ILogWindow { - string GetCurrentFileName(int lineNum); - ILogLine GetLine(int lineNum); - DateTime GetTimestampForLineForward(ref int lineNum, bool v); - DateTime GetTimestampForLine(ref int lastLineNum, bool v); - int FindTimestampLine_Internal(int lineNum1, int lineNum2, int lastLineNum, DateTime searchTimeStamp, bool v); - void SelectLine(int lineNum, bool v1, bool v2); - PersistenceData GetPersistenceData(); - void AddTempFileTab(string fileName, string title); - void WritePipeTab(IList lineEntryList, string title); - void Activate(); - LogfileReader _logFileReader { get; } + string GetCurrentFileName (int lineNum); + + ILogLine GetLine (int lineNum); + + DateTime GetTimestampForLineForward (ref int lineNum, bool v); + + DateTime GetTimestampForLine (ref int lastLineNum, bool v); + + int FindTimestampLine_Internal (int lineNum1, int lineNum2, int lastLineNum, DateTime searchTimeStamp, bool v); + + void SelectLine (int lineNum, bool v1, bool v2); + + PersistenceData GetPersistenceData (); + + void AddTempFileTab (string fileName, string title); + + void WritePipeTab (IList lineEntryList, string title); + + void Activate (); + + LogfileReader LogFileReader { get; } + string Text { get; } + string FileName { get; } + event FileSizeChangedEventHandler FileSizeChanged; //TODO: All handlers should be moved to Core + event EventHandler TailFollowed; //LogExpert.UI.Controls.LogTabWindow.LogTabWindow.LogWindowData Tag { get; } } diff --git a/src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs b/src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs index 4d735027..6ebaced6 100644 --- a/src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs +++ b/src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs @@ -1,40 +1,41 @@ -using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Classes.ILogLineColumnizerCallback; using LogExpert.Core.Classes.Log; -namespace LogExpert.UI.Controls.LogWindow +namespace LogExpert.UI.Controls.LogWindow; + +internal class ColumnCache { - internal class ColumnCache - { - #region Fields + #region Fields - private IColumnizedLogLine _cachedColumns; - private ILogLineColumnizer _lastColumnizer; - private int _lastLineNumber = -1; + private IColumnizedLogLine _cachedColumns; + private ILogLineColumnizer _lastColumnizer; + private int _lastLineNumber = -1; - #endregion + #endregion - #region Internals + #region Internals - internal IColumnizedLogLine GetColumnsForLine(LogfileReader logFileReader, int lineNumber, ILogLineColumnizer columnizer, ColumnizerCallback columnizerCallback) + internal IColumnizedLogLine GetColumnsForLine (LogfileReader logFileReader, int lineNumber, ILogLineColumnizer columnizer, ColumnizerCallback columnizerCallback) + { + if (_lastColumnizer != columnizer || (_lastLineNumber != lineNumber && _cachedColumns != null) || columnizerCallback.GetLineNum() != lineNumber) { - if (_lastColumnizer != columnizer || _lastLineNumber != lineNumber && _cachedColumns != null || columnizerCallback.LineNum != lineNumber) + _lastColumnizer = columnizer; + _lastLineNumber = lineNumber; + ILogLine line = logFileReader.GetLogLineWithWait(lineNumber).Result; + + if (line != null) { - _lastColumnizer = columnizer; - _lastLineNumber = lineNumber; - ILogLine line = logFileReader.GetLogLineWithWait(lineNumber).Result; - if (line != null) - { - columnizerCallback.LineNum = lineNumber; - _cachedColumns = columnizer.SplitLine(columnizerCallback, line); - } - else - { - _cachedColumns = null; - } + columnizerCallback.SetLineNum(lineNumber); + _cachedColumns = columnizer.SplitLine(columnizerCallback, line); + } + else + { + _cachedColumns = null; } - return _cachedColumns; } - #endregion + return _cachedColumns; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index a80a4b71..e869dbe4 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -511,7 +511,7 @@ public string Title public Font BoldFont { get; private set; } - LogfileReader ILogWindow._logFileReader => _logFileReader; + LogfileReader ILogWindow.LogFileReader => _logFileReader; event FileSizeChangedEventHandler ILogWindow.FileSizeChanged { diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs index 5a4f2034..a61a0669 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs @@ -1,4 +1,6 @@ -using LogExpert.Classes.Filter; +using System.ComponentModel; + +using LogExpert.Classes.Filter; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Filter; using LogExpert.Core.Classes.Highlight; @@ -10,80 +12,79 @@ using LogExpert.UI.Dialogs; using LogExpert.UI.Entities; using LogExpert.UI.Extensions; -using System.ComponentModel; namespace LogExpert.UI.Controls.LogWindow { partial class LogWindow { - private void AutoResizeFilterBox() + private void AutoResizeFilterBox () { filterSplitContainer.SplitterDistance = filterComboBox.Left + filterComboBox.GetMaxTextWidth(); } #region Events handler - protected void OnProgressBarUpdate(ProgressEventArgs e) + protected void OnProgressBarUpdate (ProgressEventArgs e) { ProgressBarUpdate?.Invoke(this, e); } - protected void OnStatusLine(StatusLineEventArgs e) + protected void OnStatusLine (StatusLineEventArgs e) { StatusLineEvent?.Invoke(this, e); } - protected void OnGuiState(GuiStateArgs e) + protected void OnGuiState (GuiStateArgs e) { GuiStateUpdate?.Invoke(this, e); } - protected void OnTailFollowed(EventArgs e) + protected void OnTailFollowed (EventArgs e) { TailFollowed?.Invoke(this, e); } - protected void OnFileNotFound(EventArgs e) + protected void OnFileNotFound (EventArgs e) { FileNotFound?.Invoke(this, e); } - protected void OnFileRespawned(EventArgs e) + protected void OnFileRespawned (EventArgs e) { FileRespawned?.Invoke(this, e); } - protected void OnFilterListChanged(LogWindow source) + protected void OnFilterListChanged (LogWindow source) { FilterListChanged?.Invoke(this, new FilterListChangedEventArgs(source)); } - protected void OnCurrentHighlightListChanged() + protected void OnCurrentHighlightListChanged () { CurrentHighlightGroupChanged?.Invoke(this, new CurrentHighlightGroupChangedEventArgs(this, _currentHighlightGroup)); } - protected void OnBookmarkAdded() + protected void OnBookmarkAdded () { BookmarkAdded?.Invoke(this, EventArgs.Empty); } - protected void OnBookmarkRemoved() + protected void OnBookmarkRemoved () { BookmarkRemoved?.Invoke(this, EventArgs.Empty); } - protected void OnBookmarkTextChanged(Bookmark bookmark) + protected void OnBookmarkTextChanged (Bookmark bookmark) { BookmarkTextChanged?.Invoke(this, new BookmarkEventArgs(bookmark)); } - protected void OnColumnizerChanged(ILogLineColumnizer columnizer) + protected void OnColumnizerChanged (ILogLineColumnizer columnizer) { ColumnizerChanged?.Invoke(this, new ColumnizerEventArgs(columnizer)); } - protected void OnRegisterCancelHandler(IBackgroundProcessCancelHandler handler) + protected void OnRegisterCancelHandler (IBackgroundProcessCancelHandler handler) { lock (_cancelHandlerList) { @@ -91,7 +92,7 @@ protected void OnRegisterCancelHandler(IBackgroundProcessCancelHandler handler) } } - protected void OnDeRegisterCancelHandler(IBackgroundProcessCancelHandler handler) + protected void OnDeRegisterCancelHandler (IBackgroundProcessCancelHandler handler) { lock (_cancelHandlerList) { @@ -99,12 +100,12 @@ protected void OnDeRegisterCancelHandler(IBackgroundProcessCancelHandler handler } } - private void OnLogWindowLoad(object sender, EventArgs e) + private void OnLogWindowLoad (object sender, EventArgs e) { PreferencesChanged(_parentLogTabWin.Preferences, true, SettingsFlags.GuiOrColors); } - private void OnLogWindowDisposed(object sender, EventArgs e) + private void OnLogWindowDisposed (object sender, EventArgs e) { _waitingForClose = true; _parentLogTabWin.HighlightSettingsChanged -= OnParentHighlightSettingsChanged; @@ -113,12 +114,12 @@ private void OnLogWindowDisposed(object sender, EventArgs e) FreeFromTimeSync(); } - private void OnLogFileReaderLoadingStarted(object sender, LoadFileEventArgs e) + private void OnLogFileReaderLoadingStarted (object sender, LoadFileEventArgs e) { Invoke(LoadingStarted, e); } - private void OnLogFileReaderFinishedLoading(object sender, EventArgs e) + private void OnLogFileReaderFinishedLoading (object sender, EventArgs e) { //Thread.CurrentThread.Name = "FinishedLoading event thread"; _logger.Info("Finished loading."); @@ -150,7 +151,7 @@ private void OnLogFileReaderFinishedLoading(object sender, EventArgs e) _reloadMemento = null; } - private void OnLogFileReaderFileNotFound(object sender, EventArgs e) + private void OnLogFileReaderFileNotFound (object sender, EventArgs e) { if (!IsDisposed && !Disposing) { @@ -160,12 +161,12 @@ private void OnLogFileReaderFileNotFound(object sender, EventArgs e) } } - private void OnLogFileReaderRespawned(object sender, EventArgs e) + private void OnLogFileReaderRespawned (object sender, EventArgs e) { BeginInvoke(new MethodInvoker(LogfileRespawned)); } - private void OnLogWindowClosing(object sender, CancelEventArgs e) + private void OnLogWindowClosing (object sender, CancelEventArgs e) { if (Preferences.askForClose) { @@ -180,7 +181,7 @@ private void OnLogWindowClosing(object sender, CancelEventArgs e) CloseLogWindow(); } - private void OnDataGridViewColumnDividerDoubleClick(object sender, DataGridViewColumnDividerDoubleClickEventArgs e) + private void OnDataGridViewColumnDividerDoubleClick (object sender, DataGridViewColumnDividerDoubleClickEventArgs e) { e.Handled = true; AutoResizeColumns(dataGridView); @@ -189,7 +190,7 @@ private void OnDataGridViewColumnDividerDoubleClick(object sender, DataGridViewC /** * Event handler for the Load event from LogfileReader */ - private void OnLogFileReaderLoadFile(object sender, LoadFileEventArgs e) + private void OnLogFileReaderLoadFile (object sender, LoadFileEventArgs e) { if (e.NewFile) { @@ -211,7 +212,7 @@ private void OnLogFileReaderLoadFile(object sender, LoadFileEventArgs e) } } - private void OnFileSizeChanged(object sender, LogEventArgs e) + private void OnFileSizeChanged (object sender, LogEventArgs e) { //OnFileSizeChanged(e); // now done in UpdateGrid() _logger.Info("Got FileSizeChanged event. prevLines:{0}, curr lines: {1}", e.PrevLineCount, e.LineCount); @@ -232,9 +233,9 @@ private void OnFileSizeChanged(object sender, LogEventArgs e) } } - private void OnDataGridViewCellValueNeeded(object sender, DataGridViewCellValueEventArgs e) + private void OnDataGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e) { - int startCount = CurrentColumnizer?.GetColumnCount() ?? 0; + var startCount = CurrentColumnizer?.GetColumnCount() ?? 0; e.Value = GetCellValue(e.RowIndex, e.ColumnIndex); @@ -243,7 +244,7 @@ private void OnDataGridViewCellValueNeeded(object sender, DataGridViewCellValueE // TODO: Support reload all columns? if (CurrentColumnizer != null && CurrentColumnizer.GetColumnCount() > startCount) { - for (int i = startCount; i < CurrentColumnizer.GetColumnCount(); i++) + for (var i = startCount; i < CurrentColumnizer.GetColumnCount(); i++) { var colName = CurrentColumnizer.GetColumnNames()[i]; dataGridView.Columns.Add(PaintHelper.CreateTitleColumn(colName)); @@ -251,7 +252,7 @@ private void OnDataGridViewCellValueNeeded(object sender, DataGridViewCellValueE } } - private void OnDataGridViewCellValuePushed(object sender, DataGridViewCellValueEventArgs e) + private void OnDataGridViewCellValuePushed (object sender, DataGridViewCellValueEventArgs e) { if (!CurrentColumnizer.IsTimeshiftImplemented()) { @@ -259,9 +260,9 @@ private void OnDataGridViewCellValuePushed(object sender, DataGridViewCellValueE } ILogLine line = _logFileReader.GetLogLine(e.RowIndex); - int offset = CurrentColumnizer.GetTimeOffset(); + var offset = CurrentColumnizer.GetTimeOffset(); CurrentColumnizer.SetTimeOffset(0); - ColumnizerCallbackObject.LineNum = e.RowIndex; + ColumnizerCallbackObject.SetLineNum(e.RowIndex); IColumnizedLogLine cols = CurrentColumnizer.SplitLine(ColumnizerCallbackObject, line); CurrentColumnizer.SetTimeOffset(offset); if (cols.ColumnValues.Length <= e.ColumnIndex - 2) @@ -269,14 +270,14 @@ private void OnDataGridViewCellValuePushed(object sender, DataGridViewCellValueE return; } - string oldValue = cols.ColumnValues[e.ColumnIndex - 2].FullValue; - string newValue = (string)e.Value; + var oldValue = cols.ColumnValues[e.ColumnIndex - 2].FullValue; + var newValue = (string)e.Value; //string oldValue = (string) this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; CurrentColumnizer.PushValue(ColumnizerCallbackObject, e.ColumnIndex - 2, newValue, oldValue); dataGridView.Refresh(); TimeSpan timeSpan = new(CurrentColumnizer.GetTimeOffset() * TimeSpan.TicksPerMillisecond); - string span = timeSpan.ToString(); - int index = span.LastIndexOf('.'); + var span = timeSpan.ToString(); + var index = span.LastIndexOf('.'); if (index > 0) { span = span.Substring(0, index + 4); @@ -286,12 +287,12 @@ private void OnDataGridViewCellValuePushed(object sender, DataGridViewCellValueE SendGuiStateUpdate(); } - private void OnDataGridViewRowHeightInfoNeeded(object sender, DataGridViewRowHeightInfoNeededEventArgs e) + private void OnDataGridViewRowHeightInfoNeeded (object sender, DataGridViewRowHeightInfoNeededEventArgs e) { e.Height = GetRowHeight(e.RowIndex); } - private void OnDataGridViewCurrentCellChanged(object sender, EventArgs e) + private void OnDataGridViewCurrentCellChanged (object sender, EventArgs e) { if (dataGridView.CurrentRow != null) { @@ -312,32 +313,32 @@ private void OnDataGridViewCurrentCellChanged(object sender, EventArgs e) } } - private void OnDataGridViewCellEndEdit(object sender, DataGridViewCellEventArgs e) + private void OnDataGridViewCellEndEdit (object sender, DataGridViewCellEventArgs e) { StatusLineText(string.Empty); } - private void OnEditControlKeyUp(object sender, KeyEventArgs e) + private void OnEditControlKeyUp (object sender, KeyEventArgs e) { UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); } - private void OnEditControlKeyPress(object sender, KeyPressEventArgs e) + private void OnEditControlKeyPress (object sender, KeyPressEventArgs e) { UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); } - private void OnEditControlClick(object sender, EventArgs e) + private void OnEditControlClick (object sender, EventArgs e) { UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); } - private void OnEditControlKeyDown(object sender, KeyEventArgs e) + private void OnEditControlKeyDown (object sender, KeyEventArgs e) { UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); } - private void OnDataGridViewPaint(object sender, PaintEventArgs e) + private void OnDataGridViewPaint (object sender, PaintEventArgs e) { if (ShowBookmarkBubbles) { @@ -349,14 +350,14 @@ private void OnDataGridViewPaint(object sender, PaintEventArgs e) // Filter Grid stuff // ====================================================================================== - private void OnFilterSearchButtonClick(object sender, EventArgs e) + private void OnFilterSearchButtonClick (object sender, EventArgs e) { FilterSearch(); } - private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintingEventArgs e) + private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPaintingEventArgs e) { - BufferedDataGridView gridView = (BufferedDataGridView)sender; + var gridView = (BufferedDataGridView)sender; if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) { @@ -364,7 +365,7 @@ private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintin return; } - int lineNum = _filterResultList[e.RowIndex]; + var lineNum = _filterResultList[e.RowIndex]; ILogLine line = _logFileReader.GetLogLineWithWait(lineNum).Result; if (line != null) @@ -380,7 +381,7 @@ private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintin } else { - Color color = Color.FromArgb(255, 170, 170, 170); + var color = Color.FromArgb(255, 170, 170, 170); brush = new SolidBrush(color); } @@ -458,7 +459,7 @@ private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintin } } - private void OnFilterGridViewCellValueNeeded(object sender, DataGridViewCellValueEventArgs e) + private void OnFilterGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e) { if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) { @@ -466,16 +467,16 @@ private void OnFilterGridViewCellValueNeeded(object sender, DataGridViewCellValu return; } - int lineNum = _filterResultList[e.RowIndex]; + var lineNum = _filterResultList[e.RowIndex]; e.Value = GetCellValue(lineNum, e.ColumnIndex); } - private void OnFilterGridViewRowHeightInfoNeeded(object sender, DataGridViewRowHeightInfoNeededEventArgs e) + private void OnFilterGridViewRowHeightInfoNeeded (object sender, DataGridViewRowHeightInfoNeededEventArgs e) { e.Height = _lineHeight; } - private void OnFilterComboBoxKeyDown(object sender, KeyEventArgs e) + private void OnFilterComboBoxKeyDown (object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { @@ -483,7 +484,7 @@ private void OnFilterComboBoxKeyDown(object sender, KeyEventArgs e) } } - private void OnFilterGridViewColumnDividerDoubleClick(object sender, + private void OnFilterGridViewColumnDividerDoubleClick (object sender, DataGridViewColumnDividerDoubleClickEventArgs e) { e.Handled = true; @@ -491,7 +492,7 @@ private void OnFilterGridViewColumnDividerDoubleClick(object sender, BeginInvoke(fx, filterGridView); } - private void OnFilterGridViewCellDoubleClick(object sender, DataGridViewCellEventArgs e) + private void OnFilterGridViewCellDoubleClick (object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) { @@ -501,18 +502,18 @@ private void OnFilterGridViewCellDoubleClick(object sender, DataGridViewCellEven if (filterGridView.CurrentRow != null && e.RowIndex >= 0) { - int lineNum = _filterResultList[filterGridView.CurrentRow.Index]; + var lineNum = _filterResultList[filterGridView.CurrentRow.Index]; SelectAndEnsureVisible(lineNum, true); } } - private void OnRangeCheckBoxCheckedChanged(object sender, EventArgs e) + private void OnRangeCheckBoxCheckedChanged (object sender, EventArgs e) { filterRangeComboBox.Enabled = rangeCheckBox.Checked; CheckForFilterDirty(); } - private void OnDataGridViewScroll(object sender, ScrollEventArgs e) + private void OnDataGridViewScroll (object sender, ScrollEventArgs e) { if (e.ScrollOrientation == ScrollOrientation.VerticalScroll) { @@ -539,7 +540,7 @@ private void OnDataGridViewScroll(object sender, ScrollEventArgs e) } } - private void OnFilterGridViewKeyDown(object sender, KeyEventArgs e) + private void OnFilterGridViewKeyDown (object sender, KeyEventArgs e) { switch (e.KeyCode) { @@ -547,7 +548,7 @@ private void OnFilterGridViewKeyDown(object sender, KeyEventArgs e) { if (filterGridView.CurrentCellAddress.Y >= 0 && filterGridView.CurrentCellAddress.Y < _filterResultList.Count) { - int lineNum = _filterResultList[filterGridView.CurrentCellAddress.Y]; + var lineNum = _filterResultList[filterGridView.CurrentCellAddress.Y]; SelectLine(lineNum, false, true); e.Handled = true; } @@ -561,7 +562,7 @@ private void OnFilterGridViewKeyDown(object sender, KeyEventArgs e) } } - private void OnDataGridViewKeyDown(object sender, KeyEventArgs e) + private void OnDataGridViewKeyDown (object sender, KeyEventArgs e) { switch (e.KeyCode) { @@ -583,7 +584,7 @@ private void OnDataGridViewKeyDown(object sender, KeyEventArgs e) _shouldCallTimeSync = true; } - private void OnDataGridViewPreviewKeyDown(object sender, PreviewKeyDownEventArgs e) + private void OnDataGridViewPreviewKeyDown (object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Tab && e.Control) { @@ -591,7 +592,7 @@ private void OnDataGridViewPreviewKeyDown(object sender, PreviewKeyDownEventArgs } } - private void OnDataGridViewCellContentDoubleClick(object sender, DataGridViewCellEventArgs e) + private void OnDataGridViewCellContentDoubleClick (object sender, DataGridViewCellEventArgs e) { if (dataGridView.CurrentCell != null) { @@ -599,7 +600,7 @@ private void OnDataGridViewCellContentDoubleClick(object sender, DataGridViewCel } } - private void OnSyncFilterCheckBoxCheckedChanged(object sender, EventArgs e) + private void OnSyncFilterCheckBoxCheckedChanged (object sender, EventArgs e) { if (syncFilterCheckBox.Checked) { @@ -607,27 +608,27 @@ private void OnSyncFilterCheckBoxCheckedChanged(object sender, EventArgs e) } } - private void OnDataGridViewLeave(object sender, EventArgs e) + private void OnDataGridViewLeave (object sender, EventArgs e) { InvalidateCurrentRow(dataGridView); } - private void OnDataGridViewEnter(object sender, EventArgs e) + private void OnDataGridViewEnter (object sender, EventArgs e) { InvalidateCurrentRow(dataGridView); } - private void OnFilterGridViewEnter(object sender, EventArgs e) + private void OnFilterGridViewEnter (object sender, EventArgs e) { InvalidateCurrentRow(filterGridView); } - private void OnFilterGridViewLeave(object sender, EventArgs e) + private void OnFilterGridViewLeave (object sender, EventArgs e) { InvalidateCurrentRow(filterGridView); } - private void OnDataGridViewResize(object sender, EventArgs e) + private void OnDataGridViewResize (object sender, EventArgs e) { if (_logFileReader != null && dataGridView.RowCount > 0 && _guiStateArgs.FollowTail) { @@ -635,14 +636,14 @@ private void OnDataGridViewResize(object sender, EventArgs e) } } - private void OnDataGridViewSelectionChanged(object sender, EventArgs e) + private void OnDataGridViewSelectionChanged (object sender, EventArgs e) { UpdateSelectionDisplay(); } - private void OnSelectionChangedTriggerSignal(object sender, EventArgs e) + private void OnSelectionChangedTriggerSignal (object sender, EventArgs e) { - int selCount = 0; + var selCount = 0; try { _logger.Debug("Selection changed trigger"); @@ -670,17 +671,17 @@ private void OnSelectionChangedTriggerSignal(object sender, EventArgs e) } } - private void OnFilterKnobControlValueChanged(object sender, EventArgs e) + private void OnFilterKnobControlValueChanged (object sender, EventArgs e) { CheckForFilterDirty(); } - private void OnFilterToTabButtonClick(object sender, EventArgs e) + private void OnFilterToTabButtonClick (object sender, EventArgs e) { FilterToTab(); } - private void OnPipeDisconnected(object sender, EventArgs e) + private void OnPipeDisconnected (object sender, EventArgs e) { if (sender.GetType() == typeof(FilterPipe)) { @@ -696,25 +697,25 @@ private void OnPipeDisconnected(object sender, EventArgs e) } } - private void OnAdvancedButtonClick(object sender, EventArgs e) + private void OnAdvancedButtonClick (object sender, EventArgs e) { _showAdvanced = !_showAdvanced; ShowAdvancedFilterPanel(_showAdvanced); } - private void OnFilterSplitContainerMouseDown(object sender, MouseEventArgs e) + private void OnFilterSplitContainerMouseDown (object sender, MouseEventArgs e) { ((SplitContainer)sender).IsSplitterFixed = true; } - private void OnFilterSplitContainerMouseUp(object sender, MouseEventArgs e) + private void OnFilterSplitContainerMouseUp (object sender, MouseEventArgs e) { ((SplitContainer)sender).IsSplitterFixed = false; } - private void OnFilterSplitContainerMouseMove(object sender, MouseEventArgs e) + private void OnFilterSplitContainerMouseMove (object sender, MouseEventArgs e) { - SplitContainer splitContainer = (SplitContainer)sender; + var splitContainer = (SplitContainer)sender; if (splitContainer.IsSplitterFixed) { if (e.Button.Equals(MouseButtons.Left)) @@ -743,16 +744,16 @@ private void OnFilterSplitContainerMouseMove(object sender, MouseEventArgs e) } } - private void OnFilterSplitContainerMouseDoubleClick(object sender, MouseEventArgs e) + private void OnFilterSplitContainerMouseDoubleClick (object sender, MouseEventArgs e) { AutoResizeFilterBox(); } #region Context Menu - private void OnDataGridContextMenuStripOpening(object sender, CancelEventArgs e) + private void OnDataGridContextMenuStripOpening (object sender, CancelEventArgs e) { - int lineNum = -1; + var lineNum = -1; if (dataGridView.CurrentRow != null) { lineNum = dataGridView.CurrentRow.Index; @@ -763,7 +764,7 @@ private void OnDataGridContextMenuStripOpening(object sender, CancelEventArgs e) return; } - int refLineNum = lineNum; + var refLineNum = lineNum; copyToTabToolStripMenuItem.Enabled = dataGridView.SelectedCells.Count > 0; scrollAllTabsToTimestampToolStripMenuItem.Enabled = CurrentColumnizer.IsTimeshiftImplemented() @@ -778,29 +779,29 @@ private void OnDataGridContextMenuStripOpening(object sender, CancelEventArgs e) markEditModeToolStripMenuItem.Enabled = !dataGridView.CurrentCell.ReadOnly; // Remove all "old" plugin entries - int index = dataGridContextMenuStrip.Items.IndexOf(pluginSeparator); + var index = dataGridContextMenuStrip.Items.IndexOf(pluginSeparator); if (index > 0) { - for (int i = index + 1; i < dataGridContextMenuStrip.Items.Count;) + for (var i = index + 1; i < dataGridContextMenuStrip.Items.Count;) { dataGridContextMenuStrip.Items.RemoveAt(i); } } // Add plugin entries - bool isAdded = false; + var isAdded = false; if (PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins.Count > 0) { IList lines = GetSelectedContent(); foreach (IContextMenuEntry entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins) { LogExpertCallback callback = new(this); - string menuText = entry.GetMenuText(lines.Count, CurrentColumnizer, callback.GetLogLine(lines[0])); + var menuText = entry.GetMenuText(lines.Count, CurrentColumnizer, callback.GetLogLine(lines[0])); if (menuText != null) { - bool disabled = menuText.StartsWith('_'); + var disabled = menuText.StartsWith('_'); if (disabled) { menuText = menuText[1..]; @@ -833,7 +834,7 @@ private void OnDataGridContextMenuStripOpening(object sender, CancelEventArgs e) { if (fileEntry.LogWindow != this) { - ToolStripMenuItem item = syncTimestampsToToolStripMenuItem.DropDownItems.Add(fileEntry.Title, null, ev) as ToolStripMenuItem; + var item = syncTimestampsToToolStripMenuItem.DropDownItems.Add(fileEntry.Title, null, ev) as ToolStripMenuItem; item.Tag = fileEntry; item.Checked = TimeSyncList != null && TimeSyncList.Contains(fileEntry.LogWindow); if (fileEntry.LogWindow.TimeSyncList != null && !fileEntry.LogWindow.TimeSyncList.Contains(this)) @@ -855,21 +856,21 @@ private void OnDataGridContextMenuStripOpening(object sender, CancelEventArgs e) TimeSyncList.Count > 1; } - private void OnHandlePluginContextMenu(object sender, EventArgs args) + private void OnHandlePluginContextMenu (object sender, EventArgs args) { if (sender is ToolStripItem item) { - ContextMenuPluginEventArgs menuArgs = item.Tag as ContextMenuPluginEventArgs; + var menuArgs = item.Tag as ContextMenuPluginEventArgs; var logLines = menuArgs.LogLines; menuArgs.Entry.MenuSelected(logLines.Count, menuArgs.Columnizer, menuArgs.Callback.GetLogLine(logLines[0])); } } - private void OnHandleSyncContextMenu(object sender, EventArgs args) + private void OnHandleSyncContextMenu (object sender, EventArgs args) { if (sender is ToolStripItem item) { - WindowFileEntry entry = item.Tag as WindowFileEntry; + var entry = item.Tag as WindowFileEntry; if (TimeSyncList != null && TimeSyncList.Contains(entry.LogWindow)) { @@ -883,24 +884,24 @@ private void OnHandleSyncContextMenu(object sender, EventArgs args) } } - private void OnCopyToolStripMenuItemClick(object sender, EventArgs e) + private void OnCopyToolStripMenuItemClick (object sender, EventArgs e) { CopyMarkedLinesToClipboard(); } - private void OnCopyToTabToolStripMenuItemClick(object sender, EventArgs e) + private void OnCopyToTabToolStripMenuItemClick (object sender, EventArgs e) { CopyMarkedLinesToTab(); } - private void OnScrollAllTabsToTimestampToolStripMenuItemClick(object sender, EventArgs e) + private void OnScrollAllTabsToTimestampToolStripMenuItemClick (object sender, EventArgs e) { if (CurrentColumnizer.IsTimeshiftImplemented()) { - int currentLine = dataGridView.CurrentCellAddress.Y; + var currentLine = dataGridView.CurrentCellAddress.Y; if (currentLine > 0 && currentLine < dataGridView.RowCount) { - int lineNum = currentLine; + var lineNum = currentLine; DateTime timeStamp = GetTimestampForLine(ref lineNum, false); if (timeStamp.Equals(DateTime.MinValue)) // means: invalid { @@ -912,11 +913,11 @@ private void OnScrollAllTabsToTimestampToolStripMenuItemClick(object sender, Eve } } - private void OnLocateLineInOriginalFileToolStripMenuItemClick(object sender, EventArgs e) + private void OnLocateLineInOriginalFileToolStripMenuItemClick (object sender, EventArgs e) { if (dataGridView.CurrentRow != null && FilterPipe != null) { - int lineNum = FilterPipe.GetOriginalLineNum(dataGridView.CurrentRow.Index); + var lineNum = FilterPipe.GetOriginalLineNum(dataGridView.CurrentRow.Index); if (lineNum != -1) { FilterPipe.LogWindow.SelectLine(lineNum, false, true); @@ -925,17 +926,17 @@ private void OnLocateLineInOriginalFileToolStripMenuItemClick(object sender, Eve } } - private void OnToggleBoomarkToolStripMenuItemClick(object sender, EventArgs e) + private void OnToggleBoomarkToolStripMenuItemClick (object sender, EventArgs e) { ToggleBookmark(); } - private void OnMarkEditModeToolStripMenuItemClick(object sender, EventArgs e) + private void OnMarkEditModeToolStripMenuItemClick (object sender, EventArgs e) { StartEditMode(); } - private void OnLogWindowSizeChanged(object sender, EventArgs e) + private void OnLogWindowSizeChanged (object sender, EventArgs e) { //AdjustMinimumGridWith(); AdjustHighlightSplitterWidth(); @@ -943,7 +944,7 @@ private void OnLogWindowSizeChanged(object sender, EventArgs e) #region BookMarkList - private void OnColumnRestrictCheckBoxCheckedChanged(object sender, EventArgs e) + private void OnColumnRestrictCheckBoxCheckedChanged (object sender, EventArgs e) { columnButton.Enabled = columnRestrictCheckBox.Checked; if (columnRestrictCheckBox.Checked) // disable when nothing to filter @@ -960,7 +961,7 @@ private void OnColumnRestrictCheckBoxCheckedChanged(object sender, EventArgs e) CheckForFilterDirty(); } - private void OnColumnButtonClick(object sender, EventArgs e) + private void OnColumnButtonClick (object sender, EventArgs e) { _filterParams.CurrentColumnizer = _currentColumnizer; FilterColumnChooser chooser = new(_filterParams); @@ -978,7 +979,7 @@ private void OnColumnButtonClick(object sender, EventArgs e) #region Column Header Context Menu - private void OnDataGridViewCellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) + private void OnDataGridViewCellContextMenuStripNeeded (object sender, DataGridViewCellContextMenuStripNeededEventArgs e) { if (e.RowIndex >= 0 && e.RowIndex < dataGridView.RowCount && !dataGridView.Rows[e.RowIndex].Selected) { @@ -1009,7 +1010,7 @@ private void OnDataGridViewCellContextMenuStripNeeded(object sender, DataGridVie // } //} - private void OnFilterGridViewCellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) + private void OnFilterGridViewCellContextMenuStripNeeded (object sender, DataGridViewCellContextMenuStripNeededEventArgs e) { if (e.ContextMenuStrip == columnContextMenuStrip) { @@ -1017,12 +1018,12 @@ private void OnFilterGridViewCellContextMenuStripNeeded(object sender, DataGridV } } - private void OnColumnContextMenuStripOpening(object sender, CancelEventArgs e) + private void OnColumnContextMenuStripOpening (object sender, CancelEventArgs e) { Control ctl = columnContextMenuStrip.SourceControl; - BufferedDataGridView gridView = ctl as BufferedDataGridView; - bool frozen = false; - if (_freezeStateMap.TryGetValue(ctl, out bool value)) + var gridView = ctl as BufferedDataGridView; + var frozen = false; + if (_freezeStateMap.TryGetValue(ctl, out var value)) { frozen = value; } @@ -1072,29 +1073,29 @@ private void OnColumnContextMenuStripOpening(object sender, CancelEventArgs e) { if (column.HeaderText.Length > 0) { - ToolStripMenuItem item = allColumnsToolStripMenuItem.DropDownItems.Add(column.HeaderText, null, ev) as ToolStripMenuItem; + var item = allColumnsToolStripMenuItem.DropDownItems.Add(column.HeaderText, null, ev) as ToolStripMenuItem; item.Tag = column; item.Enabled = !column.Frozen; } } } - private void OnHandleColumnItemContextMenu(object sender, EventArgs args) + private void OnHandleColumnItemContextMenu (object sender, EventArgs args) { if (sender is ToolStripItem item) { - DataGridViewColumn column = item.Tag as DataGridViewColumn; + var column = item.Tag as DataGridViewColumn; column.Visible = true; column.DataGridView.FirstDisplayedScrollingColumnIndex = column.Index; } } - private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick(object sender, EventArgs e) + private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick (object sender, EventArgs e) { Control ctl = columnContextMenuStrip.SourceControl; - bool frozen = false; + var frozen = false; - if (_freezeStateMap.TryGetValue(ctl, out bool value)) + if (_freezeStateMap.TryGetValue(ctl, out var value)) { frozen = value; } @@ -1108,9 +1109,9 @@ private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick(object sender, E } } - private void OnMoveToLastColumnToolStripMenuItemClick(object sender, EventArgs e) + private void OnMoveToLastColumnToolStripMenuItemClick (object sender, EventArgs e) { - BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; DataGridViewColumn col = gridView.Columns[_selectedCol]; if (col != null) { @@ -1118,9 +1119,9 @@ private void OnMoveToLastColumnToolStripMenuItemClick(object sender, EventArgs e } } - private void OnMoveLeftToolStripMenuItemClick(object sender, EventArgs e) + private void OnMoveLeftToolStripMenuItemClick (object sender, EventArgs e) { - BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; DataGridViewColumn col = gridView.Columns[_selectedCol]; if (col != null && col.DisplayIndex > 0) { @@ -1128,9 +1129,9 @@ private void OnMoveLeftToolStripMenuItemClick(object sender, EventArgs e) } } - private void OnMoveRightToolStripMenuItemClick(object sender, EventArgs e) + private void OnMoveRightToolStripMenuItemClick (object sender, EventArgs e) { - BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; DataGridViewColumn col = gridView.Columns[_selectedCol]; if (col != null && col.DisplayIndex < gridView.Columns.Count - 1) { @@ -1138,33 +1139,33 @@ private void OnMoveRightToolStripMenuItemClick(object sender, EventArgs e) } } - private void OnHideColumnToolStripMenuItemClick(object sender, EventArgs e) + private void OnHideColumnToolStripMenuItemClick (object sender, EventArgs e) { - BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; DataGridViewColumn col = gridView.Columns[_selectedCol]; col.Visible = false; } - private void OnRestoreColumnsToolStripMenuItemClick(object sender, EventArgs e) + private void OnRestoreColumnsToolStripMenuItemClick (object sender, EventArgs e) { - BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; foreach (DataGridViewColumn col in gridView.Columns) { col.Visible = true; } } - private void OnTimeSpreadingControlLineSelected(object sender, SelectLineEventArgs e) + private void OnTimeSpreadingControlLineSelected (object sender, SelectLineEventArgs e) { SelectLine(e.Line, false, true); } - private void OnBookmarkCommentToolStripMenuItemClick(object sender, EventArgs e) + private void OnBookmarkCommentToolStripMenuItemClick (object sender, EventArgs e) { AddBookmarkAndEditComment(); } - private void OnHighlightSelectionInLogFileToolStripMenuItemClick(object sender, EventArgs e) + private void OnHighlightSelectionInLogFileToolStripMenuItemClick (object sender, EventArgs e) { if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) { @@ -1193,7 +1194,7 @@ private void OnHighlightSelectionInLogFileToolStripMenuItemClick(object sender, } } - private void OnHighlightSelectionInLogFilewordModeToolStripMenuItemClick(object sender, EventArgs e) + private void OnHighlightSelectionInLogFilewordModeToolStripMenuItemClick (object sender, EventArgs e) { if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) { @@ -1223,7 +1224,7 @@ private void OnHighlightSelectionInLogFilewordModeToolStripMenuItemClick(object } } - private void OnEditModeCopyToolStripMenuItemClick(object sender, EventArgs e) + private void OnEditModeCopyToolStripMenuItemClick (object sender, EventArgs e) { if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) { @@ -1234,12 +1235,12 @@ private void OnEditModeCopyToolStripMenuItemClick(object sender, EventArgs e) } } - private void OnRemoveAllToolStripMenuItemClick(object sender, EventArgs e) + private void OnRemoveAllToolStripMenuItemClick (object sender, EventArgs e) { RemoveTempHighlights(); } - private void OnMakePermanentToolStripMenuItemClick(object sender, EventArgs e) + private void OnMakePermanentToolStripMenuItemClick (object sender, EventArgs e) { lock (_tempHighlightEntryListLock) { @@ -1252,12 +1253,12 @@ private void OnMakePermanentToolStripMenuItemClick(object sender, EventArgs e) } } - private void OnMarkCurrentFilterRangeToolStripMenuItemClick(object sender, EventArgs e) + private void OnMarkCurrentFilterRangeToolStripMenuItemClick (object sender, EventArgs e) { MarkCurrentFilterRange(); } - private void OnFilterForSelectionToolStripMenuItemClick(object sender, EventArgs e) + private void OnFilterForSelectionToolStripMenuItemClick (object sender, EventArgs e) { if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) { @@ -1267,7 +1268,7 @@ private void OnFilterForSelectionToolStripMenuItemClick(object sender, EventArgs } } - private void OnSetSelectedTextAsBookmarkCommentToolStripMenuItemClick(object sender, EventArgs e) + private void OnSetSelectedTextAsBookmarkCommentToolStripMenuItemClick (object sender, EventArgs e) { if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) { @@ -1275,12 +1276,12 @@ private void OnSetSelectedTextAsBookmarkCommentToolStripMenuItemClick(object sen } } - private void OnDataGridViewCellClick(object sender, DataGridViewCellEventArgs e) + private void OnDataGridViewCellClick (object sender, DataGridViewCellEventArgs e) { _shouldCallTimeSync = true; } - private void OnDataGridViewCellDoubleClick(object sender, DataGridViewCellEventArgs e) + private void OnDataGridViewCellDoubleClick (object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) { @@ -1288,12 +1289,12 @@ private void OnDataGridViewCellDoubleClick(object sender, DataGridViewCellEventA } } - private void OnDataGridViewOverlayDoubleClicked(object sender, OverlayEventArgs e) + private void OnDataGridViewOverlayDoubleClicked (object sender, OverlayEventArgs e) { BookmarkComment(e.BookmarkOverlay.Bookmark); } - private void OnFilterRegexCheckBoxMouseUp(object sender, MouseEventArgs e) + private void OnFilterRegexCheckBoxMouseUp (object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { @@ -1323,12 +1324,12 @@ private void OnFilterRegexCheckBoxMouseUp(object sender, MouseEventArgs e) #region Filter-Highlight - private void OnToggleHighlightPanelButtonClick(object sender, EventArgs e) + private void OnToggleHighlightPanelButtonClick (object sender, EventArgs e) { ToggleHighlightPanel(highlightSplitContainer.Panel2Collapsed); } - private void OnSaveFilterButtonClick(object sender, EventArgs e) + private void OnSaveFilterButtonClick (object sender, EventArgs e) { FilterParams newParams = _filterParams.Clone(); newParams.Color = Color.FromKnownColor(KnownColor.Black); @@ -1336,12 +1337,12 @@ private void OnSaveFilterButtonClick(object sender, EventArgs e) OnFilterListChanged(this); } - private void OnDeleteFilterButtonClick(object sender, EventArgs e) + private void OnDeleteFilterButtonClick (object sender, EventArgs e) { - int index = filterListBox.SelectedIndex; + var index = filterListBox.SelectedIndex; if (index >= 0) { - FilterParams filterParams = (FilterParams)filterListBox.Items[index]; + var filterParams = (FilterParams)filterListBox.Items[index]; ConfigManager.Settings.filterList.Remove(filterParams); OnFilterListChanged(this); if (filterListBox.Items.Count > 0) @@ -1351,12 +1352,12 @@ private void OnDeleteFilterButtonClick(object sender, EventArgs e) } } - private void OnFilterUpButtonClick(object sender, EventArgs e) + private void OnFilterUpButtonClick (object sender, EventArgs e) { - int i = filterListBox.SelectedIndex; + var i = filterListBox.SelectedIndex; if (i > 0) { - FilterParams filterParams = (FilterParams)filterListBox.Items[i]; + var filterParams = (FilterParams)filterListBox.Items[i]; ConfigManager.Settings.filterList.RemoveAt(i); i--; ConfigManager.Settings.filterList.Insert(i, filterParams); @@ -1365,9 +1366,9 @@ private void OnFilterUpButtonClick(object sender, EventArgs e) } } - private void OnFilterDownButtonClick(object sender, EventArgs e) + private void OnFilterDownButtonClick (object sender, EventArgs e) { - int i = filterListBox.SelectedIndex; + var i = filterListBox.SelectedIndex; if (i < 0) { return; @@ -1375,7 +1376,7 @@ private void OnFilterDownButtonClick(object sender, EventArgs e) if (i < filterListBox.Items.Count - 1) { - FilterParams filterParams = (FilterParams)filterListBox.Items[i]; + var filterParams = (FilterParams)filterListBox.Items[i]; ConfigManager.Settings.filterList.RemoveAt(i); i++; ConfigManager.Settings.filterList.Insert(i, filterParams); @@ -1384,11 +1385,11 @@ private void OnFilterDownButtonClick(object sender, EventArgs e) } } - private void OnFilterListBoxMouseDoubleClick(object sender, MouseEventArgs e) + private void OnFilterListBoxMouseDoubleClick (object sender, MouseEventArgs e) { if (filterListBox.SelectedIndex >= 0) { - FilterParams filterParams = (FilterParams)filterListBox.Items[filterListBox.SelectedIndex]; + var filterParams = (FilterParams)filterListBox.Items[filterListBox.SelectedIndex]; FilterParams newParams = filterParams.Clone(); //newParams.historyList = ConfigManager.Settings.filterHistoryList; this._filterParams = newParams; @@ -1410,12 +1411,12 @@ private void OnFilterListBoxMouseDoubleClick(object sender, MouseEventArgs e) } } - private void OnFilterListBoxDrawItem(object sender, DrawItemEventArgs e) + private void OnFilterListBoxDrawItem (object sender, DrawItemEventArgs e) { e.DrawBackground(); if (e.Index >= 0) { - FilterParams filterParams = (FilterParams)filterListBox.Items[e.Index]; + var filterParams = (FilterParams)filterListBox.Items[e.Index]; Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); Brush brush; @@ -1437,12 +1438,12 @@ private void OnFilterListBoxDrawItem(object sender, DrawItemEventArgs e) } // Color for filter list entry - private void OnColorToolStripMenuItemClick(object sender, EventArgs e) + private void OnColorToolStripMenuItemClick (object sender, EventArgs e) { - int i = filterListBox.SelectedIndex; + var i = filterListBox.SelectedIndex; if (i < filterListBox.Items.Count && i >= 0) { - FilterParams filterParams = (FilterParams)filterListBox.Items[i]; + var filterParams = (FilterParams)filterListBox.Items[i]; ColorDialog dlg = new(); dlg.CustomColors = new[] { filterParams.Color.ToArgb() }; dlg.Color = filterParams.Color; @@ -1454,72 +1455,72 @@ private void OnColorToolStripMenuItemClick(object sender, EventArgs e) } } - private void OnFilterCaseSensitiveCheckBoxCheckedChanged(object sender, EventArgs e) + private void OnFilterCaseSensitiveCheckBoxCheckedChanged (object sender, EventArgs e) { CheckForFilterDirty(); } - private void OnFilterRegexCheckBoxCheckedChanged(object sender, EventArgs e) + private void OnFilterRegexCheckBoxCheckedChanged (object sender, EventArgs e) { fuzzyKnobControl.Enabled = !filterRegexCheckBox.Checked; fuzzyLabel.Enabled = !filterRegexCheckBox.Checked; CheckForFilterDirty(); } - private void OnInvertFilterCheckBoxCheckedChanged(object sender, EventArgs e) + private void OnInvertFilterCheckBoxCheckedChanged (object sender, EventArgs e) { CheckForFilterDirty(); } - private void OnFilterRangeComboBoxTextChanged(object sender, EventArgs e) + private void OnFilterRangeComboBoxTextChanged (object sender, EventArgs e) { CheckForFilterDirty(); } - private void OnFuzzyKnobControlValueChanged(object sender, EventArgs e) + private void OnFuzzyKnobControlValueChanged (object sender, EventArgs e) { CheckForFilterDirty(); } - private void OnFilterComboBoxTextChanged(object sender, EventArgs e) + private void OnFilterComboBoxTextChanged (object sender, EventArgs e) { CheckForFilterDirty(); } - private void OnSetBookmarksOnSelectedLinesToolStripMenuItemClick(object sender, EventArgs e) + private void OnSetBookmarksOnSelectedLinesToolStripMenuItemClick (object sender, EventArgs e) { SetBookmarksForSelectedFilterLines(); } - private void OnParentHighlightSettingsChanged(object sender, EventArgs e) + private void OnParentHighlightSettingsChanged (object sender, EventArgs e) { - string groupName = _guiStateArgs.HighlightGroupName; + var groupName = _guiStateArgs.HighlightGroupName; SetCurrentHighlightGroup(groupName); } - private void OnFilterOnLoadCheckBoxMouseClick(object sender, MouseEventArgs e) + private void OnFilterOnLoadCheckBoxMouseClick (object sender, MouseEventArgs e) { HandleChangedFilterOnLoadSetting(); } - private void OnFilterOnLoadCheckBoxKeyPress(object sender, KeyPressEventArgs e) + private void OnFilterOnLoadCheckBoxKeyPress (object sender, KeyPressEventArgs e) { HandleChangedFilterOnLoadSetting(); } - private void OnHideFilterListOnLoadCheckBoxMouseClick(object sender, MouseEventArgs e) + private void OnHideFilterListOnLoadCheckBoxMouseClick (object sender, MouseEventArgs e) { HandleChangedFilterOnLoadSetting(); } - private void OnFilterToTabToolStripMenuItemClick(object sender, EventArgs e) + private void OnFilterToTabToolStripMenuItemClick (object sender, EventArgs e) { FilterToTab(); } - private void OnTimeSyncListWindowRemoved(object sender, EventArgs e) + private void OnTimeSyncListWindowRemoved (object sender, EventArgs e) { - TimeSyncList syncList = sender as TimeSyncList; + var syncList = sender as TimeSyncList; lock (_timeSyncListLock) { if (syncList.Count == 0 || syncList.Count == 1 && syncList.Contains(this)) @@ -1533,17 +1534,17 @@ private void OnTimeSyncListWindowRemoved(object sender, EventArgs e) } } - private void OnFreeThisWindowFromTimeSyncToolStripMenuItemClick(object sender, EventArgs e) + private void OnFreeThisWindowFromTimeSyncToolStripMenuItemClick (object sender, EventArgs e) { FreeFromTimeSync(); } - private void OnSplitContainerSplitterMoved(object sender, SplitterEventArgs e) + private void OnSplitContainerSplitterMoved (object sender, SplitterEventArgs e) { advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; } - private void OnMarkFilterHitsInLogViewToolStripMenuItemClick(object sender, EventArgs e) + private void OnMarkFilterHitsInLogViewToolStripMenuItemClick (object sender, EventArgs e) { SearchParams p = new(); p.SearchText = _filterParams.SearchText; @@ -1552,12 +1553,12 @@ private void OnMarkFilterHitsInLogViewToolStripMenuItemClick(object sender, Even AddSearchHitHighlightEntry(p); } - private void OnColumnComboBoxSelectionChangeCommitted(object sender, EventArgs e) + private void OnColumnComboBoxSelectionChangeCommitted (object sender, EventArgs e) { SelectColumn(); } - private void OnColumnComboBoxKeyDown(object sender, KeyEventArgs e) + private void OnColumnComboBoxKeyDown (object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { @@ -1566,7 +1567,7 @@ private void OnColumnComboBoxKeyDown(object sender, KeyEventArgs e) } } - private void OnColumnComboBoxPreviewKeyDown(object sender, PreviewKeyDownEventArgs e) + private void OnColumnComboBoxPreviewKeyDown (object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt) { @@ -1579,7 +1580,7 @@ private void OnColumnComboBoxPreviewKeyDown(object sender, PreviewKeyDownEventAr } } - private void OnBookmarkProviderBookmarkRemoved(object sender, EventArgs e) + private void OnBookmarkProviderBookmarkRemoved (object sender, EventArgs e) { if (!_isLoading) { @@ -1588,7 +1589,7 @@ private void OnBookmarkProviderBookmarkRemoved(object sender, EventArgs e) } } - private void OnBookmarkProviderBookmarkAdded(object sender, EventArgs e) + private void OnBookmarkProviderBookmarkAdded (object sender, EventArgs e) { if (!_isLoading) { @@ -1597,22 +1598,22 @@ private void OnBookmarkProviderBookmarkAdded(object sender, EventArgs e) } } - private void OnBookmarkProviderAllBookmarksRemoved(object sender, EventArgs e) + private void OnBookmarkProviderAllBookmarksRemoved (object sender, EventArgs e) { // nothing } - private void OnLogWindowLeave(object sender, EventArgs e) + private void OnLogWindowLeave (object sender, EventArgs e) { InvalidateCurrentRow(); } - private void OnLogWindowEnter(object sender, EventArgs e) + private void OnLogWindowEnter (object sender, EventArgs e) { InvalidateCurrentRow(); } - private void OnDataGridViewRowUnshared(object sender, DataGridViewRowEventArgs e) + private void OnDataGridViewRowUnshared (object sender, DataGridViewRowEventArgs e) { if (_logger.IsTraceEnabled) { @@ -1626,7 +1627,7 @@ private void OnDataGridViewRowUnshared(object sender, DataGridViewRowEventArgs e #endregion - private void MeasureItem(object sender, MeasureItemEventArgs e) + private void MeasureItem (object sender, MeasureItemEventArgs e) { e.ItemHeight = filterListBox.Font.Height; } diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs index 5b5622ed..43ab063a 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs @@ -1,4 +1,8 @@ -using LogExpert.Classes.Filter; +using System.Globalization; +using System.Text; +using System.Text.RegularExpressions; + +using LogExpert.Classes.Filter; using LogExpert.Classes.ILogLineColumnizerCallback; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Columnizer; @@ -11,9 +15,6 @@ using LogExpert.Dialogs; using LogExpert.Extensions; using LogExpert.UI.Entities; -using System.Globalization; -using System.Text; -using System.Text.RegularExpressions; namespace LogExpert.UI.Controls.LogWindow { @@ -21,7 +22,7 @@ partial class LogWindow { #region Private Methods - private void RegisterLogFileReaderEvents() + private void RegisterLogFileReaderEvents () { _logFileReader.LoadFile += OnLogFileReaderLoadFile; _logFileReader.LoadingFinished += OnLogFileReaderFinishedLoading; @@ -31,7 +32,7 @@ private void RegisterLogFileReaderEvents() // FileSizeChanged is not registered here because it's registered after loading has finished } - private void UnRegisterLogFileReaderEvents() + private void UnRegisterLogFileReaderEvents () { if (_logFileReader != null) { @@ -44,7 +45,7 @@ private void UnRegisterLogFileReaderEvents() } } - private void CreateDefaultViewStyle() + private void CreateDefaultViewStyle () { DataGridViewCellStyle dataGridViewCellStyleMainGrid = new(); DataGridViewCellStyle dataGridViewCellStyleFilterGrid = new(); @@ -68,7 +69,7 @@ private void CreateDefaultViewStyle() filterGridView.DefaultCellStyle = dataGridViewCellStyleFilterGrid; } - private bool LoadPersistenceOptions() + private bool LoadPersistenceOptions () { if (InvokeRequired) { @@ -150,7 +151,7 @@ private bool LoadPersistenceOptions() } } - private void SetDefaultsFromPrefs() + private void SetDefaultsFromPrefs () { filterTailCheckBox.Checked = Preferences.filterTail; syncFilterCheckBox.Checked = Preferences.filterSync; @@ -158,7 +159,7 @@ private void SetDefaultsFromPrefs() _multiFileOptions = ObjectClone.Clone(Preferences.multiFileOptions); } - private void LoadPersistenceData() + private void LoadPersistenceData () { if (InvokeRequired) { @@ -247,7 +248,7 @@ private void LoadPersistenceData() } } - private void RestoreFilters(PersistenceData persistenceData) + private void RestoreFilters (PersistenceData persistenceData) { if (persistenceData.filterParamsList.Count > 0) { @@ -274,7 +275,7 @@ private void RestoreFilters(PersistenceData persistenceData) } } - private void RestoreFilterTabs(PersistenceData persistenceData) + private void RestoreFilterTabs (PersistenceData persistenceData) { foreach (FilterTabData data in persistenceData.filterTabDataList) { @@ -289,7 +290,7 @@ private void RestoreFilterTabs(PersistenceData persistenceData) } } - private void ReInitFilterParams(FilterParams filterParams) + private void ReInitFilterParams (FilterParams filterParams) { filterParams.SearchText = filterParams.SearchText; // init "lowerSearchText" filterParams.RangeSearchText = filterParams.RangeSearchText; // init "lowerRangesearchText" @@ -307,7 +308,7 @@ private void ReInitFilterParams(FilterParams filterParams) } } - private void EnterLoadFileStatus() + private void EnterLoadFileStatus () { _logger.Debug("EnterLoadFileStatus begin"); @@ -337,7 +338,7 @@ private void EnterLoadFileStatus() _logger.Debug("EnterLoadFileStatus end"); } - private void PositionAfterReload(ReloadMemento reloadMemento) + private void PositionAfterReload (ReloadMemento reloadMemento) { if (_reloadMemento.CurrentLine < dataGridView.RowCount && _reloadMemento.CurrentLine >= 0) { @@ -350,7 +351,7 @@ private void PositionAfterReload(ReloadMemento reloadMemento) } } - private void LogfileDead() + private void LogfileDead () { _logger.Info("File not found."); _isDeadFile = true; @@ -376,7 +377,7 @@ private void LogfileDead() OnFileNotFound(EventArgs.Empty); } - private void LogfileRespawned() + private void LogfileRespawned () { _logger.Info("LogfileDead(): Reloading file because it has been respawned."); _isDeadFile = false; @@ -386,7 +387,7 @@ private void LogfileRespawned() Reload(); } - private void SetGuiAfterLoading() + private void SetGuiAfterLoading () { if (Text.Length == 0) { @@ -465,7 +466,7 @@ private void SetGuiAfterLoading() locateLineInOriginalFileToolStripMenuItem.Enabled = FilterPipe != null; } - private ILogLineColumnizer FindColumnizer() + private ILogLineColumnizer FindColumnizer () { ILogLineColumnizer columnizer; if (Preferences.maskPrio) @@ -480,7 +481,7 @@ private ILogLineColumnizer FindColumnizer() return columnizer; } - private void ReloadNewFile() + private void ReloadNewFile () { // prevent "overloads". May occur on very fast rollovers (next rollover before the file is reloaded) lock (_reloadLock) @@ -518,7 +519,7 @@ private void ReloadNewFile() } } - private void ReloadFinishedThreadFx() + private void ReloadFinishedThreadFx () { _logger.Info("Waiting for loading to be complete."); _loadingFinishedEvent.WaitOne(); @@ -527,7 +528,7 @@ private void ReloadFinishedThreadFx() LoadFilterPipes(); } - private void UpdateProgress(LoadFileEventArgs e) + private void UpdateProgress (LoadFileEventArgs e) { try { @@ -550,7 +551,7 @@ private void UpdateProgress(LoadFileEventArgs e) } } - private void LoadingStarted(LoadFileEventArgs e) + private void LoadingStarted (LoadFileEventArgs e) { try { @@ -568,7 +569,7 @@ private void LoadingStarted(LoadFileEventArgs e) } } - private void LoadingFinished() + private void LoadingFinished () { _logger.Info("File loading complete."); @@ -600,7 +601,7 @@ private void LoadingFinished() //LoadPersistenceData(); } - private void LogEventWorker() + private void LogEventWorker () { Thread.CurrentThread.Name = "LogEventWorker"; while (true) @@ -611,7 +612,7 @@ private void LogEventWorker() while (true) { LogEventArgs e; - int lastLineCount = 0; + var lastLineCount = 0; lock (_logEventArgsList) { _logger.Info("{0} events in queue", _logEventArgsList.Count); @@ -647,7 +648,7 @@ private void LogEventWorker() } } - private void StopLogEventWorkerThread() + private void StopLogEventWorkerThread () { _logEventArgsEvent.Set(); cts.Cancel(); @@ -655,15 +656,15 @@ private void StopLogEventWorkerThread() //_logEventHandlerThread.Join(); } - private void OnFileSizeChanged(LogEventArgs e) + private void OnFileSizeChanged (LogEventArgs e) { FileSizeChanged?.Invoke(this, e); } - private void UpdateGrid(LogEventArgs e) + private void UpdateGrid (LogEventArgs e) { - int oldRowCount = dataGridView.RowCount; - int firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex; + var oldRowCount = dataGridView.RowCount; + var firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex; if (dataGridView.CurrentCellAddress.Y >= e.LineCount) { @@ -675,7 +676,7 @@ private void UpdateGrid(LogEventArgs e) { if (dataGridView.RowCount > e.LineCount) { - int currentLineNum = dataGridView.CurrentCellAddress.Y; + var currentLineNum = dataGridView.CurrentCellAddress.Y; dataGridView.RowCount = 0; dataGridView.RowCount = e.LineCount; if (_guiStateArgs.FollowTail == false) @@ -701,7 +702,7 @@ private void UpdateGrid(LogEventArgs e) // keep selection and view range, if no follow tail mode if (!_guiStateArgs.FollowTail) { - int currentLineNum = dataGridView.CurrentCellAddress.Y; + var currentLineNum = dataGridView.CurrentCellAddress.Y; currentLineNum -= e.RolloverOffset; if (currentLineNum < 0) { @@ -754,9 +755,9 @@ private void UpdateGrid(LogEventArgs e) //this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); } - private void CheckFilterAndHighlight(LogEventArgs e) + private void CheckFilterAndHighlight (LogEventArgs e) { - bool noLed = true; + var noLed = true; bool suppressLed; bool setBookmark; bool stopTail; @@ -764,17 +765,17 @@ private void CheckFilterAndHighlight(LogEventArgs e) if (filterTailCheckBox.Checked || _filterPipeList.Count > 0) { - int filterStart = e.PrevLineCount; + var filterStart = e.PrevLineCount; if (e.IsRollover) { ShiftFilterLines(e.RolloverOffset); filterStart -= e.RolloverOffset; } - bool firstStopTail = true; + var firstStopTail = true; ColumnizerCallback callback = new(this); - bool filterLineAdded = false; - for (int i = filterStart; i < e.LineCount; ++i) + var filterLineAdded = false; + for (var i = filterStart; i < e.LineCount; ++i) { ILogLine line = _logFileReader.GetLogLine(i); if (line == null) @@ -784,7 +785,7 @@ private void CheckFilterAndHighlight(LogEventArgs e) if (filterTailCheckBox.Checked) { - callback.LineNum = i; + callback.SetLineNum(i); if (Util.TestFilterCondition(_filterParams, line, callback)) { //AddFilterLineFx addFx = new AddFilterLineFx(AddFilterLine); @@ -810,7 +811,7 @@ private void CheckFilterAndHighlight(LogEventArgs e) if (stopTail && _guiStateArgs.FollowTail) { - bool wasFollow = _guiStateArgs.FollowTail; + var wasFollow = _guiStateArgs.FollowTail; FollowTailChanged(false, true); if (firstStopTail && wasFollow) { @@ -834,15 +835,15 @@ private void CheckFilterAndHighlight(LogEventArgs e) } else { - bool firstStopTail = true; - int startLine = e.PrevLineCount; + var firstStopTail = true; + var startLine = e.PrevLineCount; if (e.IsRollover) { ShiftFilterLines(e.RolloverOffset); startLine -= e.RolloverOffset; } - for (int i = startLine; i < e.LineCount; ++i) + for (var i = startLine; i < e.LineCount; ++i) { ILogLine line = _logFileReader.GetLogLine(i); if (line != null) @@ -859,7 +860,7 @@ private void CheckFilterAndHighlight(LogEventArgs e) if (stopTail && _guiStateArgs.FollowTail) { - bool wasFollow = _guiStateArgs.FollowTail; + var wasFollow = _guiStateArgs.FollowTail; FollowTailChanged(false, true); if (firstStopTail && wasFollow) { @@ -882,7 +883,7 @@ private void CheckFilterAndHighlight(LogEventArgs e) } } - private void LaunchHighlightPlugins(IList matchingList, int lineNum) + private void LaunchHighlightPlugins (IList matchingList, int lineNum) { LogExpertCallback callback = new(this) { @@ -897,31 +898,24 @@ private void LaunchHighlightPlugins(IList matchingList, int line if (plugin != null) { ActionPluginExecuteFx fx = plugin.Execute; - fx.BeginInvoke(entry.SearchText, entry.ActionEntry.ActionParam, callback, - CurrentColumnizer, null, null); + fx.BeginInvoke(entry.SearchText, entry.ActionEntry.ActionParam, callback, CurrentColumnizer, null, null); } } } } - private void PreSelectColumnizer(ILogLineColumnizer columnizer) + private void PreSelectColumnizer (ILogLineColumnizer columnizer) { - if (columnizer != null) - { - CurrentColumnizer = _forcedColumnizerForLoading = columnizer; - } - else - { - CurrentColumnizer = _forcedColumnizerForLoading = - ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - } + CurrentColumnizer = columnizer != null + ? (_forcedColumnizerForLoading = columnizer) + : (_forcedColumnizerForLoading = ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers)); } - private void SetColumnizer(ILogLineColumnizer columnizer) + private void SetColumnizer (ILogLineColumnizer columnizer) { columnizer = ColumnizerPicker.FindReplacementForAutoColumnizer(FileName, _logFileReader, columnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - int timeDiff = 0; + var timeDiff = 0; if (CurrentColumnizer != null && CurrentColumnizer.IsTimeshiftImplemented()) { timeDiff = CurrentColumnizer.GetTimeOffset(); @@ -935,24 +929,24 @@ private void SetColumnizer(ILogLineColumnizer columnizer) } } - private void SetColumnizerInternal(ILogLineColumnizer columnizer) + private void SetColumnizerInternal (ILogLineColumnizer columnizer) { _logger.Info("SetColumnizerInternal(): {0}", columnizer.GetName()); ILogLineColumnizer oldColumnizer = CurrentColumnizer; - bool oldColumnizerIsXmlType = CurrentColumnizer is ILogLineXmlColumnizer; - bool oldColumnizerIsPreProcess = CurrentColumnizer is IPreProcessColumnizer; - bool mustReload = false; + var oldColumnizerIsXmlType = CurrentColumnizer is ILogLineXmlColumnizer; + var oldColumnizerIsPreProcess = CurrentColumnizer is IPreProcessColumnizer; + var mustReload = false; // Check if the filtered columns disappeared, if so must refresh the UI if (_filterParams.ColumnRestrict) { - string[] newColumns = columnizer != null ? columnizer.GetColumnNames() : Array.Empty(); - bool colChanged = false; + var newColumns = columnizer != null ? columnizer.GetColumnNames() : Array.Empty(); + var colChanged = false; if (dataGridView.ColumnCount - 2 == newColumns.Length) // two first columns are 'marker' and 'line number' { - for (int i = 0; i < newColumns.Length; i++) + for (var i = 0; i < newColumns.Length; i++) { if (dataGridView.Columns[i].HeaderText != newColumns[i]) { @@ -1071,7 +1065,7 @@ private void SetColumnizerInternal(ILogLineColumnizer columnizer) columnComboBox.Items.Clear(); - foreach (string columnName in columnizer.GetColumnNames()) + foreach (var columnName in columnizer.GetColumnNames()) { columnComboBox.Items.Add(columnName); } @@ -1081,7 +1075,7 @@ private void SetColumnizerInternal(ILogLineColumnizer columnizer) OnColumnizerChanged(CurrentColumnizer); } - private void AutoResizeColumns(BufferedDataGridView gridView) + private void AutoResizeColumns (BufferedDataGridView gridView) { try { @@ -1105,13 +1099,13 @@ private void AutoResizeColumns(BufferedDataGridView gridView) } } - private void PaintCell(DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, + private void PaintCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) { PaintHighlightedCell(e, gridView, noBackgroundFill, groundEntry); } - private void PaintHighlightedCell(DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, + private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) { @@ -1148,7 +1142,7 @@ private void PaintHighlightedCell(DataGridViewCellPaintingEventArgs e, BufferedD matchList = MergeHighlightMatchEntries(matchList, hme); - int leftPad = e.CellStyle.Padding.Left; + var leftPad = e.CellStyle.Padding.Left; RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, e.CellBounds.Height); Rectangle borderWidths = PaintHelper.BorderWidths(e.AdvancedBorderStyle); @@ -1191,7 +1185,7 @@ private void PaintHighlightedCell(DataGridViewCellPaintingEventArgs e, BufferedD Brush bgBrush = matchEntry.HilightEntry.BackgroundColor != Color.Empty ? new SolidBrush(matchEntry.HilightEntry.BackgroundColor) : null; - string matchWord = column.DisplayValue.Substring(matchEntry.StartPos, matchEntry.Length); + var matchWord = column.DisplayValue.Substring(matchEntry.StartPos, matchEntry.Length); Size wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags); wordSize.Height = e.CellBounds.Height; Rectangle wordRect = new(wordPos, wordSize); @@ -1227,12 +1221,12 @@ private void PaintHighlightedCell(DataGridViewCellPaintingEventArgs e, BufferedD /// List of all highlight matches for the current cell /// The entry that is used as the default. /// List of HilightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring. - private IList MergeHighlightMatchEntries(IList matchList, + private IList MergeHighlightMatchEntries (IList matchList, HilightMatchEntry groundEntry) { // Fill an area with lenth of whole text with a default hilight entry - HighlightEntry[] entryArray = new HighlightEntry[groundEntry.Length]; - for (int i = 0; i < entryArray.Length; ++i) + var entryArray = new HighlightEntry[groundEntry.Length]; + for (var i = 0; i < entryArray.Length; ++i) { entryArray[i] = groundEntry.HilightEntry; } @@ -1241,8 +1235,8 @@ private IList MergeHighlightMatchEntries(IList MergeHighlightMatchEntries(IList 0) { HighlightEntry currentEntry = entryArray[0]; - int lastStartPos = 0; - int pos = 0; + var lastStartPos = 0; + var pos = 0; for (; pos < entryArray.Length; ++pos) { @@ -1297,17 +1291,17 @@ private IList MergeHighlightMatchEntries(IList /// Returns the first HilightEntry that matches the given line /// - private HighlightEntry FindHilightEntry(ITextValue line) + private HighlightEntry FindHilightEntry (ITextValue line) { return FindHighlightEntry(line, false); } - private HighlightEntry FindFirstNoWordMatchHilightEntry(ITextValue line) + private HighlightEntry FindFirstNoWordMatchHilightEntry (ITextValue line) { return FindHighlightEntry(line, true); } - private bool CheckHighlightEntryMatch(HighlightEntry entry, ITextValue column) + private bool CheckHighlightEntryMatch (HighlightEntry entry, ITextValue column) { if (entry.IsRegEx) { @@ -1341,7 +1335,7 @@ private bool CheckHighlightEntryMatch(HighlightEntry entry, ITextValue column) /// /// Returns all HilightEntry entries which matches the given line /// - private IList FindMatchingHilightEntries(ITextValue line) + private IList FindMatchingHilightEntries (ITextValue line) { IList resultList = []; if (line != null) @@ -1361,7 +1355,7 @@ private IList FindMatchingHilightEntries(ITextValue line) return resultList; } - private void GetHighlightEntryMatches(ITextValue line, IList hilightEntryList, IList resultList) + private void GetHighlightEntryMatches (ITextValue line, IList hilightEntryList, IList resultList) { foreach (HighlightEntry entry in hilightEntryList) { @@ -1391,7 +1385,7 @@ private void GetHighlightEntryMatches(ITextValue line, IList hil } } - private void GetHilightActions(IList matchingList, out bool noLed, out bool stopTail, + private void GetHilightActions (IList matchingList, out bool noLed, out bool stopTail, out bool setBookmark, out string bookmarkComment) { noLed = stopTail = setBookmark = false; @@ -1422,12 +1416,12 @@ private void GetHilightActions(IList matchingList, out bool noLe bookmarkComment = bookmarkComment.TrimEnd(['\r', '\n']); } - private void StopTimespreadThread() + private void StopTimespreadThread () { _timeSpreadCalc.Stop(); } - private void StopTimestampSyncThread() + private void StopTimestampSyncThread () { _shouldTimestampDisplaySyncingCancel = true; //_timeShiftSyncWakeupEvent.Set(); @@ -1436,7 +1430,7 @@ private void StopTimestampSyncThread() cts.Cancel(); } - private void SyncTimestampDisplay() + private void SyncTimestampDisplay () { if (CurrentColumnizer.IsTimeshiftImplemented()) { @@ -1447,14 +1441,14 @@ private void SyncTimestampDisplay() } } - private void SyncTimestampDisplay(int lineNum) + private void SyncTimestampDisplay (int lineNum) { _timeShiftSyncLine = lineNum; _timeShiftSyncTimerEvent.Set(); _timeShiftSyncWakeupEvent.Set(); } - private void SyncTimestampDisplayWorker() + private void SyncTimestampDisplayWorker () { const int WAIT_TIME = 500; Thread.CurrentThread.Name = "SyncTimestampDisplayWorker"; @@ -1473,7 +1467,7 @@ private void SyncTimestampDisplayWorker() while (!_shouldTimestampDisplaySyncingCancel) { - bool signaled = _timeShiftSyncTimerEvent.WaitOne(WAIT_TIME, true); + var signaled = _timeShiftSyncTimerEvent.WaitOne(WAIT_TIME, true); _timeShiftSyncTimerEvent.Reset(); if (!signaled) { @@ -1482,10 +1476,10 @@ private void SyncTimestampDisplayWorker() } // timeout with no new Trigger -> update display - int lineNum = _timeShiftSyncLine; + var lineNum = _timeShiftSyncLine; if (lineNum >= 0 && lineNum < dataGridView.RowCount) { - int refLine = lineNum; + var refLine = lineNum; DateTime timeStamp = GetTimestampForLine(ref refLine, true); if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel) { @@ -1504,14 +1498,14 @@ private void SyncTimestampDisplayWorker() // show time difference between 2 selected lines if (dataGridView.SelectedRows.Count == 2) { - int row1 = dataGridView.SelectedRows[0].Index; - int row2 = dataGridView.SelectedRows[1].Index; + var row1 = dataGridView.SelectedRows[0].Index; + var row2 = dataGridView.SelectedRows[1].Index; if (row1 > row2) { (row2, row1) = (row1, row2); } - int refLine = row1; + var refLine = row1; DateTime timeStamp1 = GetTimestampForLine(ref refLine, false); refLine = row2; DateTime timeStamp2 = GetTimestampForLine(ref refLine, false); @@ -1538,13 +1532,13 @@ private void SyncTimestampDisplayWorker() } } - private void SyncFilterGridPos() + private void SyncFilterGridPos () { try { if (_filterResultList.Count > 0) { - int index = _filterResultList.BinarySearch(dataGridView.CurrentRow.Index); + var index = _filterResultList.BinarySearch(dataGridView.CurrentRow.Index); if (index < 0) { index = ~index; @@ -1570,26 +1564,26 @@ private void SyncFilterGridPos() } } - private void StatusLineFileSize(long size) + private void StatusLineFileSize (long size) { _statusEventArgs.FileSize = size; SendStatusLineUpdate(); } - private int Search(SearchParams searchParams) + private int Search (SearchParams searchParams) { if (searchParams.SearchText == null) { return -1; } - int lineNum = searchParams.IsFromTop && !searchParams.IsFindNext + var lineNum = searchParams.IsFromTop && !searchParams.IsFindNext ? 0 : searchParams.CurrentLine; - string lowerSearchText = searchParams.SearchText.ToLower(); - int count = 0; - bool hasWrapped = false; + var lowerSearchText = searchParams.SearchText.ToLower(); + var count = 0; + var hasWrapped = false; while (true) { @@ -1689,19 +1683,19 @@ private int Search(SearchParams searchParams) } } - private void ResetProgressBar() + private void ResetProgressBar () { _progressEventArgs.Value = _progressEventArgs.MaxValue; _progressEventArgs.Visible = false; SendProgressBarUpdate(); } - private void SelectLine(int line, bool triggerSyncCall, bool shouldScroll) + private void SelectLine (int line, bool triggerSyncCall, bool shouldScroll) { try { _shouldCallTimeSync = triggerSyncCall; - bool wasCancelled = _shouldCancel; + var wasCancelled = _shouldCancel; _shouldCancel = false; _isSearching = false; StatusLineText(""); @@ -1744,7 +1738,7 @@ private void SelectLine(int line, bool triggerSyncCall, bool shouldScroll) } } - private void StartEditMode() + private void StartEditMode () { if (!dataGridView.CurrentCell.ReadOnly) { @@ -1768,20 +1762,20 @@ private void StartEditMode() } } - private void UpdateEditColumnDisplay(DataGridViewTextBoxEditingControl editControl) + private void UpdateEditColumnDisplay (DataGridViewTextBoxEditingControl editControl) { // prevents key events after edit mode has ended if (dataGridView.EditingControl != null) { - int pos = editControl.SelectionStart + editControl.SelectionLength; + var pos = editControl.SelectionStart + editControl.SelectionLength; StatusLineText(" " + pos); _logger.Debug("SelStart: {0}, SelLen: {1}", editControl.SelectionStart, editControl.SelectionLength); } } - private void SelectPrevHighlightLine() + private void SelectPrevHighlightLine () { - int lineNum = dataGridView.CurrentCellAddress.Y; + var lineNum = dataGridView.CurrentCellAddress.Y; while (lineNum > 0) { lineNum--; @@ -1798,9 +1792,9 @@ private void SelectPrevHighlightLine() } } - private void SelectNextHighlightLine() + private void SelectNextHighlightLine () { - int lineNum = dataGridView.CurrentCellAddress.Y; + var lineNum = dataGridView.CurrentCellAddress.Y; while (lineNum < _logFileReader.LineCount) { lineNum++; @@ -1817,7 +1811,7 @@ private void SelectNextHighlightLine() } } - private int FindNextBookmarkIndex(int lineNum) + private int FindNextBookmarkIndex (int lineNum) { if (lineNum >= dataGridView.RowCount) { @@ -1831,7 +1825,7 @@ private int FindNextBookmarkIndex(int lineNum) return _bookmarkProvider.FindNextBookmarkIndex(lineNum); } - private int FindPrevBookmarkIndex(int lineNum) + private int FindPrevBookmarkIndex (int lineNum) { if (lineNum <= 0) { @@ -1849,18 +1843,18 @@ private int FindPrevBookmarkIndex(int lineNum) * Shift bookmarks after a logfile rollover */ - private void ShiftBookmarks(int offset) + private void ShiftBookmarks (int offset) { _bookmarkProvider.ShiftBookmarks(offset); OnBookmarkRemoved(); } - private void ShiftRowHeightList(int offset) + private void ShiftRowHeightList (int offset) { SortedList newList = []; foreach (RowHeightEntry entry in _rowHeightList.Values) { - int line = entry.LineNum - offset; + var line = entry.LineNum - offset; if (line >= 0) { entry.LineNum = line; @@ -1871,7 +1865,7 @@ private void ShiftRowHeightList(int offset) _rowHeightList = newList; } - private void ShiftFilterPipes(int offset) + private void ShiftFilterPipes (int offset) { lock (_filterPipeList) { @@ -1882,7 +1876,7 @@ private void ShiftFilterPipes(int offset) } } - private void LoadFilterPipes() + private void LoadFilterPipes () { lock (_filterPipeList) { @@ -1894,14 +1888,14 @@ private void LoadFilterPipes() if (_filterPipeList.Count > 0) { - for (int i = 0; i < dataGridView.RowCount; ++i) + for (var i = 0; i < dataGridView.RowCount; ++i) { ProcessFilterPipes(i); } } } - private void DisconnectFilterPipes() + private void DisconnectFilterPipes () { lock (_filterPipeList) { @@ -1912,7 +1906,7 @@ private void DisconnectFilterPipes() } } - private void ApplyFilterParams() + private void ApplyFilterParams () { filterComboBox.Text = _filterParams.SearchText; filterCaseSensitiveCheckBox.Checked = _filterParams.IsCaseSensitive; @@ -1927,7 +1921,7 @@ private void ApplyFilterParams() filterRangeComboBox.Text = _filterParams.RangeSearchText; } - private void ResetFilterControls() + private void ResetFilterControls () { filterComboBox.Text = ""; filterCaseSensitiveCheckBox.Checked = false; @@ -1942,7 +1936,7 @@ private void ResetFilterControls() filterRangeComboBox.Text = ""; } - private void FilterSearch() + private void FilterSearch () { if (filterComboBox.Text.Length == 0) { @@ -1959,7 +1953,7 @@ private void FilterSearch() FilterSearch(filterComboBox.Text); } - private async void FilterSearch(string text) + private async void FilterSearch (string text) { FireCancelHandlers(); // make sure that there's no other filter running (maybe from filter restore) @@ -1967,7 +1961,7 @@ private async void FilterSearch(string text) _filterParams.LowerSearchText = text.ToLower(); ConfigManager.Settings.filterHistoryList.Remove(text); ConfigManager.Settings.filterHistoryList.Insert(0, text); - int maxHistory = ConfigManager.Settings.Preferences.maximumFilterEntries; + var maxHistory = ConfigManager.Settings.Preferences.maximumFilterEntries; if (ConfigManager.Settings.filterHistoryList.Count > maxHistory) { @@ -1975,7 +1969,7 @@ private async void FilterSearch(string text) } filterComboBox.Items.Clear(); - foreach (string item in ConfigManager.Settings.filterHistoryList) + foreach (var item in ConfigManager.Settings.filterHistoryList) { filterComboBox.Items.Add(item); } @@ -1994,7 +1988,7 @@ private async void FilterSearch(string text) } filterRangeComboBox.Items.Clear(); - foreach (string item in ConfigManager.Settings.filterRangeHistoryList) + foreach (var item in ConfigManager.Settings.filterRangeHistoryList) { filterRangeComboBox.Items.Add(item); } @@ -2045,7 +2039,7 @@ private async void FilterSearch(string text) FilterFxAction = settings.Preferences.multiThreadFilter ? MultiThreadedFilter : Filter; //Task.Run(() => fx.Invoke(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList)); - Task filterFxActionTask = Task.Run(() => Filter(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList)); + var filterFxActionTask = Task.Run(() => Filter(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList)); await filterFxActionTask; FilterComplete(); @@ -2054,7 +2048,7 @@ private async void FilterSearch(string text) CheckForFilterDirty(); } - private void MultiThreadedFilter(FilterParams filterParams, List filterResultLines, + private void MultiThreadedFilter (FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) { ColumnizerCallback callback = new(this); @@ -2076,19 +2070,19 @@ private void MultiThreadedFilter(FilterParams filterParams, List filterResu StatusLineText("Filter duration: " + (endTime - startTime) + " ms."); } - private void FilterProgressCallback(int lineCount) + private void FilterProgressCallback (int lineCount) { UpdateProgressBar(lineCount); } - private void Filter(FilterParams filterParams, List filterResultLines, List lastFilterLinesList, + private void Filter (FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) { long startTime = Environment.TickCount; try { filterParams.Reset(); - int lineNum = 0; + var lineNum = 0; //AddFilterLineFx addFx = new AddFilterLineFx(AddFilterLine); ColumnizerCallback callback = new(this); while (true) @@ -2142,7 +2136,7 @@ private void Filter(FilterParams filterParams, List filterResultLines, List /// /// /// - private IList GetAdditionalFilterResults(FilterParams filterParams, int lineNum, IList checkList) + private IList GetAdditionalFilterResults (FilterParams filterParams, int lineNum, IList checkList) { IList resultList = []; //string textLine = this.logFileReader.GetLogLine(lineNum); @@ -2156,7 +2150,7 @@ private IList GetAdditionalFilterResults(FilterParams filterParams, int lin } // back spread - for (int i = filterParams.SpreadBefore; i > 0; --i) + for (var i = filterParams.SpreadBefore; i > 0; --i) { if (lineNum - i > 0) { @@ -2174,7 +2168,7 @@ private IList GetAdditionalFilterResults(FilterParams filterParams, int lin } // after spread - for (int i = 1; i <= filterParams.SpreadBehind; ++i) + for (var i = 1; i <= filterParams.SpreadBehind; ++i) { if (lineNum + i < _logFileReader.LineCount) { @@ -2188,7 +2182,7 @@ private IList GetAdditionalFilterResults(FilterParams filterParams, int lin return resultList; } - private void AddFilterLine(int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, + private void AddFilterLine (int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) { int count; @@ -2216,7 +2210,7 @@ private void AddFilterLine(int lineNum, bool immediate, FilterParams filterParam } } - private void TriggerFilterLineGuiUpdate() + private void TriggerFilterLineGuiUpdate () { //lock (this.filterUpdateThread) //{ @@ -2278,7 +2272,7 @@ private void TriggerFilterLineGuiUpdate() // this.filterUpdateThread.Join(); //} - private void AddFilterLineGuiUpdate() + private void AddFilterLineGuiUpdate () { try { @@ -2310,7 +2304,7 @@ private void AddFilterLineGuiUpdate() } } - private void UpdateProgressBar(int value) + private void UpdateProgressBar (int value) { _progressEventArgs.Value = value; if (value > _progressEventArgs.MaxValue) @@ -2322,7 +2316,7 @@ private void UpdateProgressBar(int value) SendProgressBarUpdate(); } - private void FilterComplete() + private void FilterComplete () { if (!IsDisposed && !_waitingForClose && !Disposing) { @@ -2330,7 +2324,7 @@ private void FilterComplete() } } - private void FilterComplete(IAsyncResult result) + private void FilterComplete (IAsyncResult result) { if (!IsDisposed && !_waitingForClose && !Disposing) { @@ -2338,7 +2332,7 @@ private void FilterComplete(IAsyncResult result) } } - private void ResetStatusAfterFilter() + private void ResetStatusAfterFilter () { try { @@ -2367,7 +2361,7 @@ private void ResetStatusAfterFilter() } } - private void ClearFilterList() + private void ClearFilterList () { try { @@ -2392,7 +2386,7 @@ private void ClearFilterList() } } - private void ClearBookmarkList() + private void ClearBookmarkList () { _bookmarkProvider.ClearAllBookmarks(); } @@ -2401,14 +2395,14 @@ private void ClearBookmarkList() * Shift filter list line entries after a logfile rollover */ - private void ShiftFilterLines(int offset) + private void ShiftFilterLines (int offset) { List newFilterList = []; lock (_filterResultList) { - foreach (int lineNum in _filterResultList) + foreach (var lineNum in _filterResultList) { - int line = lineNum - offset; + var line = lineNum - offset; if (line >= 0) { newFilterList.Add(line); @@ -2419,9 +2413,9 @@ private void ShiftFilterLines(int offset) } newFilterList = []; - foreach (int lineNum in _filterHitList) + foreach (var lineNum in _filterHitList) { - int line = lineNum - offset; + var line = lineNum - offset; if (line >= 0) { newFilterList.Add(line); @@ -2430,7 +2424,7 @@ private void ShiftFilterLines(int offset) _filterHitList = newFilterList; - int count = SPREAD_MAX; + var count = SPREAD_MAX; if (_filterResultList.Count < SPREAD_MAX) { count = _filterResultList.Count; @@ -2445,7 +2439,7 @@ private void ShiftFilterLines(int offset) TriggerFilterLineGuiUpdate(); } - private void CheckForFilterDirty() + private void CheckForFilterDirty () { if (IsFilterSearchDirty(_filterParams)) { @@ -2459,7 +2453,7 @@ private void CheckForFilterDirty() } } - private bool IsFilterSearchDirty(FilterParams filterParams) + private bool IsFilterSearchDirty (FilterParams filterParams) { if (!filterParams.SearchText.Equals(filterComboBox.Text)) { @@ -2514,15 +2508,15 @@ private bool IsFilterSearchDirty(FilterParams filterParams) return false; } - private void AdjustMinimumGridWith() + private void AdjustMinimumGridWith () { if (dataGridView.Columns.Count > 1) { //this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); AutoResizeColumns(dataGridView); - int width = dataGridView.Columns.GetColumnsWidth(DataGridViewElementStates.Visible); - int diff = dataGridView.Width - width; + var width = dataGridView.Columns.GetColumnsWidth(DataGridViewElementStates.Visible); + var diff = dataGridView.Width - width; if (diff > 0) { diff -= dataGridView.RowHeadersWidth / 2; @@ -2532,7 +2526,7 @@ private void AdjustMinimumGridWith() } } - private void InvalidateCurrentRow(BufferedDataGridView gridView) + private void InvalidateCurrentRow (BufferedDataGridView gridView) { if (gridView.CurrentCellAddress.Y > -1) { @@ -2540,13 +2534,13 @@ private void InvalidateCurrentRow(BufferedDataGridView gridView) } } - private void InvalidateCurrentRow() + private void InvalidateCurrentRow () { InvalidateCurrentRow(dataGridView); InvalidateCurrentRow(filterGridView); } - private void DisplayCurrentFileOnStatusline() + private void DisplayCurrentFileOnStatusline () { if (_logFileReader.IsMultiFile) { @@ -2554,7 +2548,7 @@ private void DisplayCurrentFileOnStatusline() { if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index > -1) { - string fileName = _logFileReader.GetLogFileNameForLine(dataGridView.CurrentRow.Index); + var fileName = _logFileReader.GetLogFileNameForLine(dataGridView.CurrentRow.Index); if (fileName != null) { StatusLineText(Util.GetNameFromPath(fileName)); @@ -2572,7 +2566,7 @@ private void DisplayCurrentFileOnStatusline() } } - private void UpdateSelectionDisplay() + private void UpdateSelectionDisplay () { if (_noSelectionUpdates) { @@ -2580,56 +2574,56 @@ private void UpdateSelectionDisplay() } } - private void UpdateFilterHistoryFromSettings() + private void UpdateFilterHistoryFromSettings () { ConfigManager.Settings.filterHistoryList = ConfigManager.Settings.filterHistoryList; filterComboBox.Items.Clear(); - foreach (string item in ConfigManager.Settings.filterHistoryList) + foreach (var item in ConfigManager.Settings.filterHistoryList) { filterComboBox.Items.Add(item); } filterRangeComboBox.Items.Clear(); - foreach (string item in ConfigManager.Settings.filterRangeHistoryList) + foreach (var item in ConfigManager.Settings.filterRangeHistoryList) { filterRangeComboBox.Items.Add(item); } } - private void StatusLineText(string text) + private void StatusLineText (string text) { _statusEventArgs.StatusText = text; SendStatusLineUpdate(); } - private void StatusLineError(string text) + private void StatusLineError (string text) { StatusLineText(text); _isErrorShowing = true; } - private void RemoveStatusLineError() + private void RemoveStatusLineError () { StatusLineText(""); _isErrorShowing = false; } - private void SendGuiStateUpdate() + private void SendGuiStateUpdate () { OnGuiState(_guiStateArgs); } - private void SendProgressBarUpdate() + private void SendProgressBarUpdate () { OnProgressBarUpdate(_progressEventArgs); } - private void SendStatusLineUpdate() + private void SendStatusLineUpdate () { OnStatusLine(_statusEventArgs); } - private void ShowAdvancedFilterPanel(bool show) + private void ShowAdvancedFilterPanel (bool show) { if (show) { @@ -2647,7 +2641,7 @@ private void ShowAdvancedFilterPanel(bool show) _showAdvanced = show; } - private void CheckForAdvancedButtonDirty() + private void CheckForAdvancedButtonDirty () { if (IsAdvancedOptionActive() && !_showAdvanced) { @@ -2659,18 +2653,18 @@ private void CheckForAdvancedButtonDirty() } } - private void FilterToTab() + private void FilterToTab () { filterSearchButton.Enabled = false; Task.Run(() => WriteFilterToTab()); } - private void WriteFilterToTab() + private void WriteFilterToTab () { FilterPipe pipe = new(_filterParams.Clone(), this); lock (_filterResultList) { - string namePrefix = "->F"; + var namePrefix = "->F"; string title; if (IsTempFile) { @@ -2685,7 +2679,7 @@ private void WriteFilterToTab() } } - private void WritePipeToTab(FilterPipe pipe, IList lineNumberList, string name, PersistenceData persistenceData) + private void WritePipeToTab (FilterPipe pipe, IList lineNumberList, string name, PersistenceData persistenceData) { _logger.Info("WritePipeToTab(): {0} lines.", lineNumberList.Count); StatusLineText("Writing to temp file... Press ESC to cancel."); @@ -2705,10 +2699,10 @@ private void WritePipeToTab(FilterPipe pipe, IList lineNumberList, string n } pipe.Closed += OnPipeDisconnected; - int count = 0; + var count = 0; pipe.OpenFile(); LogExpertCallback callback = new(this); - foreach (int i in lineNumberList) + foreach (var i in lineNumberList) { if (_shouldCancel) { @@ -2735,12 +2729,12 @@ private void WritePipeToTab(FilterPipe pipe, IList lineNumberList, string n Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), pipe, name, persistenceData); } - private void WriteFilterToTabFinished(FilterPipe pipe, string name, PersistenceData persistenceData) + private void WriteFilterToTabFinished (FilterPipe pipe, string name, PersistenceData persistenceData) { _isSearching = false; if (!_shouldCancel) { - string title = name; + var title = name; ILogLineColumnizer preProcessColumnizer = null; if (CurrentColumnizer is not ILogLineXmlColumnizer) { @@ -2770,7 +2764,7 @@ private void WriteFilterToTabFinished(FilterPipe pipe, string name, PersistenceD /// /// /// - internal void WritePipeTab(IList lineEntryList, string title) + internal void WritePipeTab (IList lineEntryList, string title) { FilterPipe pipe = new(new FilterParams(), this); pipe.IsStopped = true; @@ -2785,7 +2779,7 @@ internal void WritePipeTab(IList lineEntryList, string title) Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), [pipe, title, null]); } - private void FilterRestore(LogWindow newWin, PersistenceData persistenceData) + private void FilterRestore (LogWindow newWin, PersistenceData persistenceData) { newWin.WaitForLoadingFinished(); ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(persistenceData.columnizerName, @@ -2803,7 +2797,7 @@ private void FilterRestore(LogWindow newWin, PersistenceData persistenceData) newWin.BeginInvoke(new RestoreFiltersFx(newWin.RestoreFilters), [persistenceData]); } - private void ProcessFilterPipes(int lineNum) + private void ProcessFilterPipes (int lineNum) { ILogLine searchLine = _logFileReader.GetLogLine(lineNum); if (searchLine == null) @@ -2829,7 +2823,7 @@ private void ProcessFilterPipes(int lineNum) IList filterResult = GetAdditionalFilterResults(pipe.FilterParams, lineNum, pipe.LastLinesHistoryList); pipe.OpenFile(); - foreach (int line in filterResult) + foreach (var line in filterResult) { pipe.LastLinesHistoryList.Add(line); if (pipe.LastLinesHistoryList.Count > SPREAD_MAX * 2) @@ -2838,7 +2832,7 @@ private void ProcessFilterPipes(int lineNum) } ILogLine textLine = _logFileReader.GetLogLine(line); - bool fileOk = pipe.WriteToPipe(textLine, line); + var fileOk = pipe.WriteToPipe(textLine, line); if (!fileOk) { deleteList.Add(pipe); @@ -2859,7 +2853,7 @@ private void ProcessFilterPipes(int lineNum) } } - private void CopyMarkedLinesToClipboard() + private void CopyMarkedLinesToClipboard () { if (_guiStateArgs.CellSelectMode) { @@ -2883,7 +2877,7 @@ private void CopyMarkedLinesToClipboard() var xmlColumnizer = _currentColumnizer as ILogLineXmlColumnizer; - foreach (int lineNum in lineNumList) + foreach (var lineNum in lineNumList) { ILogLine line = _logFileReader.GetLogLine(lineNum); if (xmlColumnizer != null) @@ -2903,12 +2897,12 @@ private void CopyMarkedLinesToClipboard() /// Set an Encoding which shall be used when loading a file. Used before a file is loaded. /// /// - private void SetExplicitEncoding(Encoding encoding) + private void SetExplicitEncoding (Encoding encoding) { EncodingOptions.Encoding = encoding; } - private void ApplyDataGridViewPrefs(BufferedDataGridView dataGridView, Preferences prefs) + private void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, Preferences prefs) { if (dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) > 1) { @@ -2935,7 +2929,7 @@ private void ApplyDataGridViewPrefs(BufferedDataGridView dataGridView, Preferenc AutoResizeColumns(dataGridView); } - private IList GetSelectedContent() + private IList GetSelectedContent () { if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) { @@ -2960,21 +2954,21 @@ private IList GetSelectedContent() * Timestamp stuff * =======================================================================*/ - private void SetTimestampLimits() + private void SetTimestampLimits () { if (!CurrentColumnizer.IsTimeshiftImplemented()) { return; } - int line = 0; + var line = 0; _guiStateArgs.MinTimestamp = GetTimestampForLineForward(ref line, true); line = dataGridView.RowCount - 1; _guiStateArgs.MaxTimestamp = GetTimestampForLine(ref line, true); SendGuiStateUpdate(); } - private void AdjustHighlightSplitterWidth() + private void AdjustHighlightSplitterWidth () { //int size = this.editHighlightsSplitContainer.Panel2Collapsed ? 600 : 660; //int distance = this.highlightSplitContainer.Width - size; @@ -2983,7 +2977,7 @@ private void AdjustHighlightSplitterWidth() //this.highlightSplitContainer.SplitterDistance = distance; } - private void BookmarkComment(Bookmark bookmark) + private void BookmarkComment (Bookmark bookmark) { BookmarkCommentDlg dlg = new(); dlg.Comment = bookmark.Text; @@ -3000,13 +2994,13 @@ private void BookmarkComment(Bookmark bookmark) /// /// /// - private string CalculateColumnNames(FilterParams filter) + private string CalculateColumnNames (FilterParams filter) { - string names = string.Empty; + var names = string.Empty; if (filter.ColumnRestrict) { - foreach (int colIndex in filter.ColumnList) + foreach (var colIndex in filter.ColumnList) { if (colIndex < dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 2) { @@ -3024,7 +3018,7 @@ private string CalculateColumnNames(FilterParams filter) return names; } - private void ApplyFrozenState(BufferedDataGridView gridView) + private void ApplyFrozenState (BufferedDataGridView gridView) { SortedDictionary dict = []; foreach (DataGridViewColumn col in gridView.Columns) @@ -3035,7 +3029,7 @@ private void ApplyFrozenState(BufferedDataGridView gridView) foreach (DataGridViewColumn col in dict.Values) { col.Frozen = _freezeStateMap.ContainsKey(gridView) && _freezeStateMap[gridView]; - bool sel = col.HeaderCell.Selected; + var sel = col.HeaderCell.Selected; if (col.Index == _selectedCol) { break; @@ -3043,7 +3037,7 @@ private void ApplyFrozenState(BufferedDataGridView gridView) } } - private void ShowTimeSpread(bool show) + private void ShowTimeSpread (bool show) { if (show) { @@ -3057,12 +3051,12 @@ private void ShowTimeSpread(bool show) _timeSpreadCalc.Enabled = show; } - protected internal void AddTempFileTab(string fileName, string title) + protected internal void AddTempFileTab (string fileName, string title) { _parentLogTabWin.AddTempFileTab(fileName, title); } - private void InitPatternWindow() + private void InitPatternWindow () { //PatternStatistic(this.patternArgs); _patternWindow = new PatternWindow(this); @@ -3076,14 +3070,14 @@ private void InitPatternWindow() //this.patternWindow.Show(); } - private void TestStatistic(PatternArgs patternArgs) + private void TestStatistic (PatternArgs patternArgs) { - int beginLine = patternArgs.StartLine; + var beginLine = patternArgs.StartLine; _logger.Info("TestStatistics() called with start line {0}", beginLine); _patternArgs = patternArgs; - int num = beginLine + 1; //this.dataGridView.RowCount; + var num = beginLine + 1; //this.dataGridView.RowCount; _progressEventArgs.MinValue = 0; _progressEventArgs.MaxValue = dataGridView.RowCount; @@ -3096,11 +3090,11 @@ private void TestStatistic(PatternArgs patternArgs) Dictionary processedLinesDict = []; List blockList = []; - int blockId = 0; + var blockId = 0; _isSearching = true; _shouldCancel = false; - int searchLine = -1; - for (int i = beginLine; i < num && !_shouldCancel; ++i) + var searchLine = -1; + for (var i = beginLine; i < num && !_shouldCancel; ++i) { if (processedLinesDict.ContainsKey(i)) { @@ -3108,7 +3102,7 @@ private void TestStatistic(PatternArgs patternArgs) } PatternBlock block; - int maxBlockLen = patternArgs.EndLine - patternArgs.StartLine; + var maxBlockLen = patternArgs.EndLine - patternArgs.StartLine; //int searchLine = i + 1; _logger.Debug("TestStatistic(): i={0} searchLine={1}", i, searchLine); //bool firstBlock = true; @@ -3169,9 +3163,9 @@ private void TestStatistic(PatternArgs patternArgs) _logger.Info("TestStatistics() ended"); } - private void addBlockTargetLinesToDict(Dictionary dict, PatternBlock block) + private void addBlockTargetLinesToDict (Dictionary dict, PatternBlock block) { - foreach (int lineNum in block.targetLines.Keys) + foreach (var lineNum in block.targetLines.Keys) { if (!dict.ContainsKey(lineNum)) { @@ -3181,7 +3175,7 @@ private void addBlockTargetLinesToDict(Dictionary dict, PatternBlock b } //Well keep this for the moment because there is some other commented code which calls this one - private PatternBlock FindExistingBlock(PatternBlock block, List blockList) + private PatternBlock FindExistingBlock (PatternBlock block, List blockList) { foreach (PatternBlock searchBlock in blockList) { @@ -3200,10 +3194,10 @@ private PatternBlock FindExistingBlock(PatternBlock block, List bl return null; } - private PatternBlock DetectBlock(int startNum, int startLineToSearch, int maxBlockLen, int maxDiffInBlock, + private PatternBlock DetectBlock (int startNum, int startLineToSearch, int maxBlockLen, int maxDiffInBlock, int maxMisses, Dictionary processedLinesDict) { - int targetLine = FindSimilarLine(startNum, startLineToSearch, processedLinesDict); + var targetLine = FindSimilarLine(startNum, startLineToSearch, processedLinesDict); if (targetLine == -1) { return null; @@ -3211,12 +3205,12 @@ private PatternBlock DetectBlock(int startNum, int startLineToSearch, int maxBlo PatternBlock block = new(); block.startLine = startNum; - int srcLine = block.startLine; + var srcLine = block.startLine; block.targetStart = targetLine; - int srcMisses = 0; + var srcMisses = 0; block.srcLines.Add(srcLine, srcLine); //block.targetLines.Add(targetLine, targetLine); - int len = 0; + var len = 0; QualityInfo qi = new(); qi.quality = block.weigth; block.qualityInfoList[targetLine] = qi; @@ -3232,7 +3226,7 @@ private PatternBlock DetectBlock(int startNum, int startLineToSearch, int maxBlo break; } - int nextTargetLine = FindSimilarLine(srcLine, targetLine + 1, processedLinesDict); + var nextTargetLine = FindSimilarLine(srcLine, targetLine + 1, processedLinesDict); if (nextTargetLine > -1 && nextTargetLine - targetLine - 1 <= maxDiffInBlock) { block.weigth += maxDiffInBlock - (nextTargetLine - targetLine - 1) + 1; @@ -3241,8 +3235,8 @@ private PatternBlock DetectBlock(int startNum, int startLineToSearch, int maxBlo block.srcLines.Add(srcLine, srcLine); if (nextTargetLine - targetLine > 1) { - int tempWeight = block.weigth; - for (int tl = targetLine + 1; tl < nextTargetLine; ++tl) + var tempWeight = block.weigth; + for (var tl = targetLine + 1; tl < nextTargetLine; ++tl) { qi = new QualityInfo(); qi.quality = --tempWeight; @@ -3274,7 +3268,7 @@ private PatternBlock DetectBlock(int startNum, int startLineToSearch, int maxBlo qi = new QualityInfo(); qi.quality = block.weigth; block.qualityInfoList[targetLine] = qi; - for (int k = block.targetStart; k <= block.targetEnd; ++k) + for (var k = block.targetStart; k <= block.targetEnd; ++k) { block.targetLines.Add(k, k); } @@ -3282,26 +3276,26 @@ private PatternBlock DetectBlock(int startNum, int startLineToSearch, int maxBlo return block; } - private void PrepareDict() + private void PrepareDict () { _lineHashList.Clear(); Regex regex = new("\\d"); Regex regex2 = new("\\S"); - int num = _logFileReader.LineCount; - for (int i = 0; i < num; ++i) + var num = _logFileReader.LineCount; + for (var i = 0; i < num; ++i) { - string msg = GetMsgForLine(i); + var msg = GetMsgForLine(i); if (msg != null) { msg = msg.ToLower(); msg = regex.Replace(msg, "0"); msg = regex2.Replace(msg, " "); - char[] chars = msg.ToCharArray(); - int value = 0; - int numOfE = 0; - int numOfA = 0; - int numOfI = 0; + var chars = msg.ToCharArray(); + var value = 0; + var numOfE = 0; + var numOfA = 0; + var numOfI = 0; foreach (var t in chars) { value += t; @@ -3327,12 +3321,12 @@ private void PrepareDict() } } - private int _FindSimilarLine(int srcLine, int startLine) + private int _FindSimilarLine (int srcLine, int startLine) { - int value = _lineHashList[srcLine]; + var value = _lineHashList[srcLine]; - int num = _lineHashList.Count; - for (int i = startLine; i < num; ++i) + var num = _lineHashList.Count; + for (var i = startLine; i < num; ++i) { if (Math.Abs(_lineHashList[i] - value) < 3) { @@ -3345,7 +3339,7 @@ private int _FindSimilarLine(int srcLine, int startLine) // int[,] similarCache; - private void ResetCache(int num) + private void ResetCache (int num) { //this.similarCache = new int[num, num]; //for (int i = 0; i < num; ++i) @@ -3357,18 +3351,18 @@ private void ResetCache(int num) //} } - private int FindSimilarLine(int srcLine, int startLine, Dictionary processedLinesDict) + private int FindSimilarLine (int srcLine, int startLine, Dictionary processedLinesDict) { - int threshold = _patternArgs.Fuzzy; + var threshold = _patternArgs.Fuzzy; - bool prepared = false; + var prepared = false; Regex regex = null; Regex regex2 = null; string msgToFind = null; CultureInfo culture = CultureInfo.CurrentCulture; - int num = _logFileReader.LineCount; - for (int i = startLine; i < num; ++i) + var num = _logFileReader.LineCount; + for (var i = startLine; i < num; ++i) { if (processedLinesDict.ContainsKey(i)) { @@ -3395,12 +3389,12 @@ private int FindSimilarLine(int srcLine, int startLine, Dictionary pro prepared = true; } - string msg = GetMsgForLine(i); + var msg = GetMsgForLine(i); if (msg != null) { msg = regex.Replace(msg, "0"); msg = regex2.Replace(msg, " "); - int lenDiff = Math.Abs(msg.Length - msgToFind.Length); + var lenDiff = Math.Abs(msg.Length - msgToFind.Length); if (lenDiff > threshold) { //this.similarCache[srcLine, i] = lenDiff; @@ -3408,7 +3402,7 @@ private int FindSimilarLine(int srcLine, int startLine, Dictionary pro } msg = msg.ToLower(culture); - int distance = Util.YetiLevenshtein(msgToFind, msg); + var distance = Util.YetiLevenshtein(msgToFind, msg); //this.similarCache[srcLine, i] = distance; if (distance < threshold) { @@ -3421,7 +3415,7 @@ private int FindSimilarLine(int srcLine, int startLine, Dictionary pro return -1; } - private string GetMsgForLine(int i) + private string GetMsgForLine (int i) { ILogLine line = _logFileReader.GetLogLine(i); ILogLineColumnizer columnizer = CurrentColumnizer; @@ -3430,9 +3424,9 @@ private string GetMsgForLine(int i) return cols.ColumnValues.Last().FullValue; } - private void ChangeRowHeight(bool decrease) + private void ChangeRowHeight (bool decrease) { - int rowNum = dataGridView.CurrentCellAddress.Y; + var rowNum = dataGridView.CurrentCellAddress.Y; if (rowNum < 0 || rowNum >= dataGridView.RowCount) { return; @@ -3481,7 +3475,7 @@ private void ChangeRowHeight(bool decrease) dataGridView.Refresh(); } - private int GetRowHeight(int rowNum) + private int GetRowHeight (int rowNum) { if (_rowHeightList.ContainsKey(rowNum)) { @@ -3493,7 +3487,7 @@ private int GetRowHeight(int rowNum) } } - private void AddBookmarkAtLineSilently(int lineNum) + private void AddBookmarkAtLineSilently (int lineNum) { if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) { @@ -3501,9 +3495,9 @@ private void AddBookmarkAtLineSilently(int lineNum) } } - private void AddBookmarkAndEditComment() + private void AddBookmarkAndEditComment () { - int lineNum = dataGridView.CurrentCellAddress.Y; + var lineNum = dataGridView.CurrentCellAddress.Y; if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) { ToggleBookmark(); @@ -3512,9 +3506,9 @@ private void AddBookmarkAndEditComment() BookmarkComment(_bookmarkProvider.GetBookmarkForLine(lineNum)); } - private void AddBookmarkComment(string text) + private void AddBookmarkComment (string text) { - int lineNum = dataGridView.CurrentCellAddress.Y; + var lineNum = dataGridView.CurrentCellAddress.Y; Bookmark bookmark; if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) { @@ -3531,7 +3525,7 @@ private void AddBookmarkComment(string text) OnBookmarkTextChanged(bookmark); } - private void MarkCurrentFilterRange() + private void MarkCurrentFilterRange () { _filterParams.RangeSearchText = filterRangeComboBox.Text; ColumnizerCallback callback = new(this); @@ -3541,7 +3535,7 @@ private void MarkCurrentFilterRange() { SetCellSelectionMode(false); _noSelectionUpdates = true; - for (int i = range.StartLine; i <= range.EndLine; ++i) + for (var i = range.StartLine; i <= range.EndLine; ++i) { dataGridView.Rows[i].Selected = true; } @@ -3551,7 +3545,7 @@ private void MarkCurrentFilterRange() } } - private void RemoveTempHighlights() + private void RemoveTempHighlights () { lock (_tempHighlightEntryListLock) { @@ -3561,7 +3555,7 @@ private void RemoveTempHighlights() RefreshAllGrids(); } - private void ToggleHighlightPanel(bool open) + private void ToggleHighlightPanel (bool open) { highlightSplitContainer.Panel2Collapsed = !open; btnToggleHighlightPanel.Image = open @@ -3569,13 +3563,13 @@ private void ToggleHighlightPanel(bool open) : new Bitmap(_panelOpenButtonImage, new Size(btnToggleHighlightPanel.Size.Height, btnToggleHighlightPanel.Size.Height)); } - private void SetBookmarksForSelectedFilterLines() + private void SetBookmarksForSelectedFilterLines () { lock (_filterResultList) { foreach (DataGridViewRow row in filterGridView.SelectedRows) { - int lineNum = _filterResultList[row.Index]; + var lineNum = _filterResultList[row.Index]; AddBookmarkAtLineSilently(lineNum); } } @@ -3585,7 +3579,7 @@ private void SetBookmarksForSelectedFilterLines() OnBookmarkAdded(); } - private void SetDefaultHighlightGroup() + private void SetDefaultHighlightGroup () { HighlightGroup group = _parentLogTabWin.FindHighlightGroupByFileMask(FileName); if (group != null) @@ -3598,14 +3592,14 @@ private void SetDefaultHighlightGroup() } } - private void HandleChangedFilterOnLoadSetting() + private void HandleChangedFilterOnLoadSetting () { _parentLogTabWin.Preferences.isFilterOnLoad = filterOnLoadCheckBox.Checked; _parentLogTabWin.Preferences.isAutoHideFilterList = hideFilterListOnLoadCheckBox.Checked; OnFilterListChanged(this); } - private void FireCancelHandlers() + private void FireCancelHandlers () { lock (_cancelHandlerList) { @@ -3616,7 +3610,7 @@ private void FireCancelHandlers() } } - private void SyncOtherWindows(DateTime timestamp) + private void SyncOtherWindows (DateTime timestamp) { lock (_timeSyncListLock) { @@ -3624,7 +3618,7 @@ private void SyncOtherWindows(DateTime timestamp) } } - private void AddSlaveToTimesync(LogWindow slave) + private void AddSlaveToTimesync (LogWindow slave) { lock (_timeSyncListLock) { @@ -3640,8 +3634,8 @@ private void AddSlaveToTimesync(LogWindow slave) TimeSyncList = slave.TimeSyncList; } - int currentLineNum = dataGridView.CurrentCellAddress.Y; - int refLine = currentLineNum; + var currentLineNum = dataGridView.CurrentCellAddress.Y; + var refLine = currentLineNum; DateTime timeStamp = GetTimestampForLine(ref refLine, true); if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel) { @@ -3656,17 +3650,17 @@ private void AddSlaveToTimesync(LogWindow slave) OnSyncModeChanged(); } - private void FreeSlaveFromTimesync(LogWindow slave) + private void FreeSlaveFromTimesync (LogWindow slave) { slave.FreeFromTimeSync(); } - private void OnSyncModeChanged() + private void OnSyncModeChanged () { SyncModeChanged?.Invoke(this, new SyncModeEventArgs(IsTimeSynced)); } - private void AddSearchHitHighlightEntry(SearchParams para) + private void AddSearchHitHighlightEntry (SearchParams para) { HighlightEntry he = new() { @@ -3692,7 +3686,7 @@ private void AddSearchHitHighlightEntry(SearchParams para) RefreshAllGrids(); } - private void RemoveAllSearchHighlightEntries() + private void RemoveAllSearchHighlightEntries () { lock (_tempHighlightEntryListLock) { @@ -3711,7 +3705,7 @@ private void RemoveAllSearchHighlightEntries() RefreshAllGrids(); } - private DataGridViewColumn GetColumnByName(BufferedDataGridView dataGridView, string name) + private DataGridViewColumn GetColumnByName (BufferedDataGridView dataGridView, string name) { foreach (DataGridViewColumn col in dataGridView.Columns) { @@ -3724,14 +3718,14 @@ private DataGridViewColumn GetColumnByName(BufferedDataGridView dataGridView, st return null; } - private void SelectColumn() + private void SelectColumn () { - string colName = columnComboBox.SelectedItem as string; + var colName = columnComboBox.SelectedItem as string; DataGridViewColumn col = GetColumnByName(dataGridView, colName); if (col != null && !col.Frozen) { dataGridView.FirstDisplayedScrollingColumnIndex = col.Index; - int currentLine = dataGridView.CurrentCellAddress.Y; + var currentLine = dataGridView.CurrentCellAddress.Y; if (currentLine >= 0) { dataGridView.CurrentCell = dataGridView.Rows[dataGridView.CurrentCellAddress.Y].Cells[col.Index]; From c99cdb93bac7ad41288aa69417672dd415193f60 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 1 Jun 2025 10:56:05 +0200 Subject: [PATCH 047/142] adding set function for the bookmarklist --- .../Classes/Bookmark/BookmarkDataProvider.cs | 5 + src/LogExpert.Core/Interface/IBookmarkData.cs | 29 +- .../Controls/LogWindow/LogWindowPrivate.cs | 299 +++++++++--------- 3 files changed, 170 insertions(+), 163 deletions(-) diff --git a/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs b/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs index ed739fa4..bf098ffc 100644 --- a/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs +++ b/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs @@ -55,6 +55,11 @@ public BookmarkDataProvider (SortedList bookmarkList) #region Public methods + public void SetBookmarks (SortedList bookmarkList) + { + BookmarkList = bookmarkList; + } + public void ToggleBookmark (int lineNum) { if (IsBookmarkAtLine(lineNum)) diff --git a/src/LogExpert.Core/Interface/IBookmarkData.cs b/src/LogExpert.Core/Interface/IBookmarkData.cs index c855f683..7abcedb7 100644 --- a/src/LogExpert.Core/Interface/IBookmarkData.cs +++ b/src/LogExpert.Core/Interface/IBookmarkData.cs @@ -1,25 +1,26 @@ -using LogExpert.Core.Entities; +using LogExpert.Core.Entities; -namespace LogExpert.Core.Interface +namespace LogExpert.Core.Interface; + +public interface IBookmarkData { - public interface IBookmarkData - { - #region Properties + #region Properties + + BookmarkCollection Bookmarks { get; } - BookmarkCollection Bookmarks { get; } + #endregion - #endregion + #region Public methods - #region Public methods + void ToggleBookmark (int lineNum); - void ToggleBookmark(int lineNum); + bool IsBookmarkAtLine (int lineNum); - bool IsBookmarkAtLine(int lineNum); + int GetBookmarkIndexForLine (int lineNum); - int GetBookmarkIndexForLine(int lineNum); + Bookmark GetBookmarkForLine (int lineNum); - Bookmark GetBookmarkForLine(int lineNum); + void SetBookmarks (SortedList bookmarkList); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs index 5b5622ed..1b9e9d78 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs @@ -1,4 +1,8 @@ -using LogExpert.Classes.Filter; +using System.Globalization; +using System.Text; +using System.Text.RegularExpressions; + +using LogExpert.Classes.Filter; using LogExpert.Classes.ILogLineColumnizerCallback; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Columnizer; @@ -11,9 +15,6 @@ using LogExpert.Dialogs; using LogExpert.Extensions; using LogExpert.UI.Entities; -using System.Globalization; -using System.Text; -using System.Text.RegularExpressions; namespace LogExpert.UI.Controls.LogWindow { @@ -21,7 +22,7 @@ partial class LogWindow { #region Private Methods - private void RegisterLogFileReaderEvents() + private void RegisterLogFileReaderEvents () { _logFileReader.LoadFile += OnLogFileReaderLoadFile; _logFileReader.LoadingFinished += OnLogFileReaderFinishedLoading; @@ -31,7 +32,7 @@ private void RegisterLogFileReaderEvents() // FileSizeChanged is not registered here because it's registered after loading has finished } - private void UnRegisterLogFileReaderEvents() + private void UnRegisterLogFileReaderEvents () { if (_logFileReader != null) { @@ -44,7 +45,7 @@ private void UnRegisterLogFileReaderEvents() } } - private void CreateDefaultViewStyle() + private void CreateDefaultViewStyle () { DataGridViewCellStyle dataGridViewCellStyleMainGrid = new(); DataGridViewCellStyle dataGridViewCellStyleFilterGrid = new(); @@ -68,7 +69,7 @@ private void CreateDefaultViewStyle() filterGridView.DefaultCellStyle = dataGridViewCellStyleFilterGrid; } - private bool LoadPersistenceOptions() + private bool LoadPersistenceOptions () { if (InvokeRequired) { @@ -150,7 +151,7 @@ private bool LoadPersistenceOptions() } } - private void SetDefaultsFromPrefs() + private void SetDefaultsFromPrefs () { filterTailCheckBox.Checked = Preferences.filterTail; syncFilterCheckBox.Checked = Preferences.filterSync; @@ -158,7 +159,7 @@ private void SetDefaultsFromPrefs() _multiFileOptions = ObjectClone.Clone(Preferences.multiFileOptions); } - private void LoadPersistenceData() + private void LoadPersistenceData () { if (InvokeRequired) { @@ -197,12 +198,12 @@ private void LoadPersistenceData() { // outdated persistence data (logfile rollover) // MessageBox.Show(this, "Persistence data for " + this.FileName + " is outdated. It was discarded.", "Log Expert"); - _logger.Info("Persistence data for {0} is outdated. It was discarded.", FileName); - LoadPersistenceOptions(); + _logger.Info($"Persistence data for {FileName} is outdated. It was discarded."); + _ = LoadPersistenceOptions(); return; } - _bookmarkProvider.BookmarkList = persistenceData.bookmarkList; + _bookmarkProvider.SetBookmarks(persistenceData.bookmarkList); _rowHeightList = persistenceData.rowHeightList; try { @@ -247,7 +248,7 @@ private void LoadPersistenceData() } } - private void RestoreFilters(PersistenceData persistenceData) + private void RestoreFilters (PersistenceData persistenceData) { if (persistenceData.filterParamsList.Count > 0) { @@ -274,7 +275,7 @@ private void RestoreFilters(PersistenceData persistenceData) } } - private void RestoreFilterTabs(PersistenceData persistenceData) + private void RestoreFilterTabs (PersistenceData persistenceData) { foreach (FilterTabData data in persistenceData.filterTabDataList) { @@ -289,7 +290,7 @@ private void RestoreFilterTabs(PersistenceData persistenceData) } } - private void ReInitFilterParams(FilterParams filterParams) + private void ReInitFilterParams (FilterParams filterParams) { filterParams.SearchText = filterParams.SearchText; // init "lowerSearchText" filterParams.RangeSearchText = filterParams.RangeSearchText; // init "lowerRangesearchText" @@ -307,7 +308,7 @@ private void ReInitFilterParams(FilterParams filterParams) } } - private void EnterLoadFileStatus() + private void EnterLoadFileStatus () { _logger.Debug("EnterLoadFileStatus begin"); @@ -337,7 +338,7 @@ private void EnterLoadFileStatus() _logger.Debug("EnterLoadFileStatus end"); } - private void PositionAfterReload(ReloadMemento reloadMemento) + private void PositionAfterReload (ReloadMemento reloadMemento) { if (_reloadMemento.CurrentLine < dataGridView.RowCount && _reloadMemento.CurrentLine >= 0) { @@ -350,7 +351,7 @@ private void PositionAfterReload(ReloadMemento reloadMemento) } } - private void LogfileDead() + private void LogfileDead () { _logger.Info("File not found."); _isDeadFile = true; @@ -376,7 +377,7 @@ private void LogfileDead() OnFileNotFound(EventArgs.Empty); } - private void LogfileRespawned() + private void LogfileRespawned () { _logger.Info("LogfileDead(): Reloading file because it has been respawned."); _isDeadFile = false; @@ -386,7 +387,7 @@ private void LogfileRespawned() Reload(); } - private void SetGuiAfterLoading() + private void SetGuiAfterLoading () { if (Text.Length == 0) { @@ -465,7 +466,7 @@ private void SetGuiAfterLoading() locateLineInOriginalFileToolStripMenuItem.Enabled = FilterPipe != null; } - private ILogLineColumnizer FindColumnizer() + private ILogLineColumnizer FindColumnizer () { ILogLineColumnizer columnizer; if (Preferences.maskPrio) @@ -480,7 +481,7 @@ private ILogLineColumnizer FindColumnizer() return columnizer; } - private void ReloadNewFile() + private void ReloadNewFile () { // prevent "overloads". May occur on very fast rollovers (next rollover before the file is reloaded) lock (_reloadLock) @@ -518,7 +519,7 @@ private void ReloadNewFile() } } - private void ReloadFinishedThreadFx() + private void ReloadFinishedThreadFx () { _logger.Info("Waiting for loading to be complete."); _loadingFinishedEvent.WaitOne(); @@ -527,7 +528,7 @@ private void ReloadFinishedThreadFx() LoadFilterPipes(); } - private void UpdateProgress(LoadFileEventArgs e) + private void UpdateProgress (LoadFileEventArgs e) { try { @@ -550,7 +551,7 @@ private void UpdateProgress(LoadFileEventArgs e) } } - private void LoadingStarted(LoadFileEventArgs e) + private void LoadingStarted (LoadFileEventArgs e) { try { @@ -568,7 +569,7 @@ private void LoadingStarted(LoadFileEventArgs e) } } - private void LoadingFinished() + private void LoadingFinished () { _logger.Info("File loading complete."); @@ -600,7 +601,7 @@ private void LoadingFinished() //LoadPersistenceData(); } - private void LogEventWorker() + private void LogEventWorker () { Thread.CurrentThread.Name = "LogEventWorker"; while (true) @@ -647,7 +648,7 @@ private void LogEventWorker() } } - private void StopLogEventWorkerThread() + private void StopLogEventWorkerThread () { _logEventArgsEvent.Set(); cts.Cancel(); @@ -655,12 +656,12 @@ private void StopLogEventWorkerThread() //_logEventHandlerThread.Join(); } - private void OnFileSizeChanged(LogEventArgs e) + private void OnFileSizeChanged (LogEventArgs e) { FileSizeChanged?.Invoke(this, e); } - private void UpdateGrid(LogEventArgs e) + private void UpdateGrid (LogEventArgs e) { int oldRowCount = dataGridView.RowCount; int firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex; @@ -754,7 +755,7 @@ private void UpdateGrid(LogEventArgs e) //this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); } - private void CheckFilterAndHighlight(LogEventArgs e) + private void CheckFilterAndHighlight (LogEventArgs e) { bool noLed = true; bool suppressLed; @@ -882,7 +883,7 @@ private void CheckFilterAndHighlight(LogEventArgs e) } } - private void LaunchHighlightPlugins(IList matchingList, int lineNum) + private void LaunchHighlightPlugins (IList matchingList, int lineNum) { LogExpertCallback callback = new(this) { @@ -904,7 +905,7 @@ private void LaunchHighlightPlugins(IList matchingList, int line } } - private void PreSelectColumnizer(ILogLineColumnizer columnizer) + private void PreSelectColumnizer (ILogLineColumnizer columnizer) { if (columnizer != null) { @@ -917,7 +918,7 @@ private void PreSelectColumnizer(ILogLineColumnizer columnizer) } } - private void SetColumnizer(ILogLineColumnizer columnizer) + private void SetColumnizer (ILogLineColumnizer columnizer) { columnizer = ColumnizerPicker.FindReplacementForAutoColumnizer(FileName, _logFileReader, columnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); @@ -935,7 +936,7 @@ private void SetColumnizer(ILogLineColumnizer columnizer) } } - private void SetColumnizerInternal(ILogLineColumnizer columnizer) + private void SetColumnizerInternal (ILogLineColumnizer columnizer) { _logger.Info("SetColumnizerInternal(): {0}", columnizer.GetName()); @@ -1081,7 +1082,7 @@ private void SetColumnizerInternal(ILogLineColumnizer columnizer) OnColumnizerChanged(CurrentColumnizer); } - private void AutoResizeColumns(BufferedDataGridView gridView) + private void AutoResizeColumns (BufferedDataGridView gridView) { try { @@ -1105,13 +1106,13 @@ private void AutoResizeColumns(BufferedDataGridView gridView) } } - private void PaintCell(DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, + private void PaintCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) { PaintHighlightedCell(e, gridView, noBackgroundFill, groundEntry); } - private void PaintHighlightedCell(DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, + private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) { @@ -1227,7 +1228,7 @@ private void PaintHighlightedCell(DataGridViewCellPaintingEventArgs e, BufferedD /// List of all highlight matches for the current cell /// The entry that is used as the default. /// List of HilightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring. - private IList MergeHighlightMatchEntries(IList matchList, + private IList MergeHighlightMatchEntries (IList matchList, HilightMatchEntry groundEntry) { // Fill an area with lenth of whole text with a default hilight entry @@ -1297,17 +1298,17 @@ private IList MergeHighlightMatchEntries(IList /// Returns the first HilightEntry that matches the given line /// - private HighlightEntry FindHilightEntry(ITextValue line) + private HighlightEntry FindHilightEntry (ITextValue line) { return FindHighlightEntry(line, false); } - private HighlightEntry FindFirstNoWordMatchHilightEntry(ITextValue line) + private HighlightEntry FindFirstNoWordMatchHilightEntry (ITextValue line) { return FindHighlightEntry(line, true); } - private bool CheckHighlightEntryMatch(HighlightEntry entry, ITextValue column) + private bool CheckHighlightEntryMatch (HighlightEntry entry, ITextValue column) { if (entry.IsRegEx) { @@ -1341,7 +1342,7 @@ private bool CheckHighlightEntryMatch(HighlightEntry entry, ITextValue column) /// /// Returns all HilightEntry entries which matches the given line /// - private IList FindMatchingHilightEntries(ITextValue line) + private IList FindMatchingHilightEntries (ITextValue line) { IList resultList = []; if (line != null) @@ -1361,7 +1362,7 @@ private IList FindMatchingHilightEntries(ITextValue line) return resultList; } - private void GetHighlightEntryMatches(ITextValue line, IList hilightEntryList, IList resultList) + private void GetHighlightEntryMatches (ITextValue line, IList hilightEntryList, IList resultList) { foreach (HighlightEntry entry in hilightEntryList) { @@ -1391,7 +1392,7 @@ private void GetHighlightEntryMatches(ITextValue line, IList hil } } - private void GetHilightActions(IList matchingList, out bool noLed, out bool stopTail, + private void GetHilightActions (IList matchingList, out bool noLed, out bool stopTail, out bool setBookmark, out string bookmarkComment) { noLed = stopTail = setBookmark = false; @@ -1422,12 +1423,12 @@ private void GetHilightActions(IList matchingList, out bool noLe bookmarkComment = bookmarkComment.TrimEnd(['\r', '\n']); } - private void StopTimespreadThread() + private void StopTimespreadThread () { _timeSpreadCalc.Stop(); } - private void StopTimestampSyncThread() + private void StopTimestampSyncThread () { _shouldTimestampDisplaySyncingCancel = true; //_timeShiftSyncWakeupEvent.Set(); @@ -1436,7 +1437,7 @@ private void StopTimestampSyncThread() cts.Cancel(); } - private void SyncTimestampDisplay() + private void SyncTimestampDisplay () { if (CurrentColumnizer.IsTimeshiftImplemented()) { @@ -1447,14 +1448,14 @@ private void SyncTimestampDisplay() } } - private void SyncTimestampDisplay(int lineNum) + private void SyncTimestampDisplay (int lineNum) { _timeShiftSyncLine = lineNum; _timeShiftSyncTimerEvent.Set(); _timeShiftSyncWakeupEvent.Set(); } - private void SyncTimestampDisplayWorker() + private void SyncTimestampDisplayWorker () { const int WAIT_TIME = 500; Thread.CurrentThread.Name = "SyncTimestampDisplayWorker"; @@ -1538,7 +1539,7 @@ private void SyncTimestampDisplayWorker() } } - private void SyncFilterGridPos() + private void SyncFilterGridPos () { try { @@ -1570,13 +1571,13 @@ private void SyncFilterGridPos() } } - private void StatusLineFileSize(long size) + private void StatusLineFileSize (long size) { _statusEventArgs.FileSize = size; SendStatusLineUpdate(); } - private int Search(SearchParams searchParams) + private int Search (SearchParams searchParams) { if (searchParams.SearchText == null) { @@ -1689,14 +1690,14 @@ private int Search(SearchParams searchParams) } } - private void ResetProgressBar() + private void ResetProgressBar () { _progressEventArgs.Value = _progressEventArgs.MaxValue; _progressEventArgs.Visible = false; SendProgressBarUpdate(); } - private void SelectLine(int line, bool triggerSyncCall, bool shouldScroll) + private void SelectLine (int line, bool triggerSyncCall, bool shouldScroll) { try { @@ -1744,7 +1745,7 @@ private void SelectLine(int line, bool triggerSyncCall, bool shouldScroll) } } - private void StartEditMode() + private void StartEditMode () { if (!dataGridView.CurrentCell.ReadOnly) { @@ -1768,7 +1769,7 @@ private void StartEditMode() } } - private void UpdateEditColumnDisplay(DataGridViewTextBoxEditingControl editControl) + private void UpdateEditColumnDisplay (DataGridViewTextBoxEditingControl editControl) { // prevents key events after edit mode has ended if (dataGridView.EditingControl != null) @@ -1779,7 +1780,7 @@ private void UpdateEditColumnDisplay(DataGridViewTextBoxEditingControl editContr } } - private void SelectPrevHighlightLine() + private void SelectPrevHighlightLine () { int lineNum = dataGridView.CurrentCellAddress.Y; while (lineNum > 0) @@ -1798,7 +1799,7 @@ private void SelectPrevHighlightLine() } } - private void SelectNextHighlightLine() + private void SelectNextHighlightLine () { int lineNum = dataGridView.CurrentCellAddress.Y; while (lineNum < _logFileReader.LineCount) @@ -1817,7 +1818,7 @@ private void SelectNextHighlightLine() } } - private int FindNextBookmarkIndex(int lineNum) + private int FindNextBookmarkIndex (int lineNum) { if (lineNum >= dataGridView.RowCount) { @@ -1831,7 +1832,7 @@ private int FindNextBookmarkIndex(int lineNum) return _bookmarkProvider.FindNextBookmarkIndex(lineNum); } - private int FindPrevBookmarkIndex(int lineNum) + private int FindPrevBookmarkIndex (int lineNum) { if (lineNum <= 0) { @@ -1849,13 +1850,13 @@ private int FindPrevBookmarkIndex(int lineNum) * Shift bookmarks after a logfile rollover */ - private void ShiftBookmarks(int offset) + private void ShiftBookmarks (int offset) { _bookmarkProvider.ShiftBookmarks(offset); OnBookmarkRemoved(); } - private void ShiftRowHeightList(int offset) + private void ShiftRowHeightList (int offset) { SortedList newList = []; foreach (RowHeightEntry entry in _rowHeightList.Values) @@ -1871,7 +1872,7 @@ private void ShiftRowHeightList(int offset) _rowHeightList = newList; } - private void ShiftFilterPipes(int offset) + private void ShiftFilterPipes (int offset) { lock (_filterPipeList) { @@ -1882,7 +1883,7 @@ private void ShiftFilterPipes(int offset) } } - private void LoadFilterPipes() + private void LoadFilterPipes () { lock (_filterPipeList) { @@ -1901,7 +1902,7 @@ private void LoadFilterPipes() } } - private void DisconnectFilterPipes() + private void DisconnectFilterPipes () { lock (_filterPipeList) { @@ -1912,7 +1913,7 @@ private void DisconnectFilterPipes() } } - private void ApplyFilterParams() + private void ApplyFilterParams () { filterComboBox.Text = _filterParams.SearchText; filterCaseSensitiveCheckBox.Checked = _filterParams.IsCaseSensitive; @@ -1927,7 +1928,7 @@ private void ApplyFilterParams() filterRangeComboBox.Text = _filterParams.RangeSearchText; } - private void ResetFilterControls() + private void ResetFilterControls () { filterComboBox.Text = ""; filterCaseSensitiveCheckBox.Checked = false; @@ -1942,7 +1943,7 @@ private void ResetFilterControls() filterRangeComboBox.Text = ""; } - private void FilterSearch() + private void FilterSearch () { if (filterComboBox.Text.Length == 0) { @@ -1959,7 +1960,7 @@ private void FilterSearch() FilterSearch(filterComboBox.Text); } - private async void FilterSearch(string text) + private async void FilterSearch (string text) { FireCancelHandlers(); // make sure that there's no other filter running (maybe from filter restore) @@ -2054,7 +2055,7 @@ private async void FilterSearch(string text) CheckForFilterDirty(); } - private void MultiThreadedFilter(FilterParams filterParams, List filterResultLines, + private void MultiThreadedFilter (FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) { ColumnizerCallback callback = new(this); @@ -2076,12 +2077,12 @@ private void MultiThreadedFilter(FilterParams filterParams, List filterResu StatusLineText("Filter duration: " + (endTime - startTime) + " ms."); } - private void FilterProgressCallback(int lineCount) + private void FilterProgressCallback (int lineCount) { UpdateProgressBar(lineCount); } - private void Filter(FilterParams filterParams, List filterResultLines, List lastFilterLinesList, + private void Filter (FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) { long startTime = Environment.TickCount; @@ -2142,7 +2143,7 @@ private void Filter(FilterParams filterParams, List filterResultLines, List /// /// /// - private IList GetAdditionalFilterResults(FilterParams filterParams, int lineNum, IList checkList) + private IList GetAdditionalFilterResults (FilterParams filterParams, int lineNum, IList checkList) { IList resultList = []; //string textLine = this.logFileReader.GetLogLine(lineNum); @@ -2188,7 +2189,7 @@ private IList GetAdditionalFilterResults(FilterParams filterParams, int lin return resultList; } - private void AddFilterLine(int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, + private void AddFilterLine (int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) { int count; @@ -2216,7 +2217,7 @@ private void AddFilterLine(int lineNum, bool immediate, FilterParams filterParam } } - private void TriggerFilterLineGuiUpdate() + private void TriggerFilterLineGuiUpdate () { //lock (this.filterUpdateThread) //{ @@ -2278,7 +2279,7 @@ private void TriggerFilterLineGuiUpdate() // this.filterUpdateThread.Join(); //} - private void AddFilterLineGuiUpdate() + private void AddFilterLineGuiUpdate () { try { @@ -2310,7 +2311,7 @@ private void AddFilterLineGuiUpdate() } } - private void UpdateProgressBar(int value) + private void UpdateProgressBar (int value) { _progressEventArgs.Value = value; if (value > _progressEventArgs.MaxValue) @@ -2322,7 +2323,7 @@ private void UpdateProgressBar(int value) SendProgressBarUpdate(); } - private void FilterComplete() + private void FilterComplete () { if (!IsDisposed && !_waitingForClose && !Disposing) { @@ -2330,7 +2331,7 @@ private void FilterComplete() } } - private void FilterComplete(IAsyncResult result) + private void FilterComplete (IAsyncResult result) { if (!IsDisposed && !_waitingForClose && !Disposing) { @@ -2338,7 +2339,7 @@ private void FilterComplete(IAsyncResult result) } } - private void ResetStatusAfterFilter() + private void ResetStatusAfterFilter () { try { @@ -2367,7 +2368,7 @@ private void ResetStatusAfterFilter() } } - private void ClearFilterList() + private void ClearFilterList () { try { @@ -2392,7 +2393,7 @@ private void ClearFilterList() } } - private void ClearBookmarkList() + private void ClearBookmarkList () { _bookmarkProvider.ClearAllBookmarks(); } @@ -2401,7 +2402,7 @@ private void ClearBookmarkList() * Shift filter list line entries after a logfile rollover */ - private void ShiftFilterLines(int offset) + private void ShiftFilterLines (int offset) { List newFilterList = []; lock (_filterResultList) @@ -2445,7 +2446,7 @@ private void ShiftFilterLines(int offset) TriggerFilterLineGuiUpdate(); } - private void CheckForFilterDirty() + private void CheckForFilterDirty () { if (IsFilterSearchDirty(_filterParams)) { @@ -2459,7 +2460,7 @@ private void CheckForFilterDirty() } } - private bool IsFilterSearchDirty(FilterParams filterParams) + private bool IsFilterSearchDirty (FilterParams filterParams) { if (!filterParams.SearchText.Equals(filterComboBox.Text)) { @@ -2514,7 +2515,7 @@ private bool IsFilterSearchDirty(FilterParams filterParams) return false; } - private void AdjustMinimumGridWith() + private void AdjustMinimumGridWith () { if (dataGridView.Columns.Count > 1) { @@ -2532,7 +2533,7 @@ private void AdjustMinimumGridWith() } } - private void InvalidateCurrentRow(BufferedDataGridView gridView) + private void InvalidateCurrentRow (BufferedDataGridView gridView) { if (gridView.CurrentCellAddress.Y > -1) { @@ -2540,13 +2541,13 @@ private void InvalidateCurrentRow(BufferedDataGridView gridView) } } - private void InvalidateCurrentRow() + private void InvalidateCurrentRow () { InvalidateCurrentRow(dataGridView); InvalidateCurrentRow(filterGridView); } - private void DisplayCurrentFileOnStatusline() + private void DisplayCurrentFileOnStatusline () { if (_logFileReader.IsMultiFile) { @@ -2572,7 +2573,7 @@ private void DisplayCurrentFileOnStatusline() } } - private void UpdateSelectionDisplay() + private void UpdateSelectionDisplay () { if (_noSelectionUpdates) { @@ -2580,7 +2581,7 @@ private void UpdateSelectionDisplay() } } - private void UpdateFilterHistoryFromSettings() + private void UpdateFilterHistoryFromSettings () { ConfigManager.Settings.filterHistoryList = ConfigManager.Settings.filterHistoryList; filterComboBox.Items.Clear(); @@ -2596,40 +2597,40 @@ private void UpdateFilterHistoryFromSettings() } } - private void StatusLineText(string text) + private void StatusLineText (string text) { _statusEventArgs.StatusText = text; SendStatusLineUpdate(); } - private void StatusLineError(string text) + private void StatusLineError (string text) { StatusLineText(text); _isErrorShowing = true; } - private void RemoveStatusLineError() + private void RemoveStatusLineError () { StatusLineText(""); _isErrorShowing = false; } - private void SendGuiStateUpdate() + private void SendGuiStateUpdate () { OnGuiState(_guiStateArgs); } - private void SendProgressBarUpdate() + private void SendProgressBarUpdate () { OnProgressBarUpdate(_progressEventArgs); } - private void SendStatusLineUpdate() + private void SendStatusLineUpdate () { OnStatusLine(_statusEventArgs); } - private void ShowAdvancedFilterPanel(bool show) + private void ShowAdvancedFilterPanel (bool show) { if (show) { @@ -2647,7 +2648,7 @@ private void ShowAdvancedFilterPanel(bool show) _showAdvanced = show; } - private void CheckForAdvancedButtonDirty() + private void CheckForAdvancedButtonDirty () { if (IsAdvancedOptionActive() && !_showAdvanced) { @@ -2659,13 +2660,13 @@ private void CheckForAdvancedButtonDirty() } } - private void FilterToTab() + private void FilterToTab () { filterSearchButton.Enabled = false; Task.Run(() => WriteFilterToTab()); } - private void WriteFilterToTab() + private void WriteFilterToTab () { FilterPipe pipe = new(_filterParams.Clone(), this); lock (_filterResultList) @@ -2685,7 +2686,7 @@ private void WriteFilterToTab() } } - private void WritePipeToTab(FilterPipe pipe, IList lineNumberList, string name, PersistenceData persistenceData) + private void WritePipeToTab (FilterPipe pipe, IList lineNumberList, string name, PersistenceData persistenceData) { _logger.Info("WritePipeToTab(): {0} lines.", lineNumberList.Count); StatusLineText("Writing to temp file... Press ESC to cancel."); @@ -2735,7 +2736,7 @@ private void WritePipeToTab(FilterPipe pipe, IList lineNumberList, string n Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), pipe, name, persistenceData); } - private void WriteFilterToTabFinished(FilterPipe pipe, string name, PersistenceData persistenceData) + private void WriteFilterToTabFinished (FilterPipe pipe, string name, PersistenceData persistenceData) { _isSearching = false; if (!_shouldCancel) @@ -2770,7 +2771,7 @@ private void WriteFilterToTabFinished(FilterPipe pipe, string name, PersistenceD /// /// /// - internal void WritePipeTab(IList lineEntryList, string title) + internal void WritePipeTab (IList lineEntryList, string title) { FilterPipe pipe = new(new FilterParams(), this); pipe.IsStopped = true; @@ -2785,7 +2786,7 @@ internal void WritePipeTab(IList lineEntryList, string title) Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), [pipe, title, null]); } - private void FilterRestore(LogWindow newWin, PersistenceData persistenceData) + private void FilterRestore (LogWindow newWin, PersistenceData persistenceData) { newWin.WaitForLoadingFinished(); ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(persistenceData.columnizerName, @@ -2803,7 +2804,7 @@ private void FilterRestore(LogWindow newWin, PersistenceData persistenceData) newWin.BeginInvoke(new RestoreFiltersFx(newWin.RestoreFilters), [persistenceData]); } - private void ProcessFilterPipes(int lineNum) + private void ProcessFilterPipes (int lineNum) { ILogLine searchLine = _logFileReader.GetLogLine(lineNum); if (searchLine == null) @@ -2859,7 +2860,7 @@ private void ProcessFilterPipes(int lineNum) } } - private void CopyMarkedLinesToClipboard() + private void CopyMarkedLinesToClipboard () { if (_guiStateArgs.CellSelectMode) { @@ -2903,12 +2904,12 @@ private void CopyMarkedLinesToClipboard() /// Set an Encoding which shall be used when loading a file. Used before a file is loaded. /// /// - private void SetExplicitEncoding(Encoding encoding) + private void SetExplicitEncoding (Encoding encoding) { EncodingOptions.Encoding = encoding; } - private void ApplyDataGridViewPrefs(BufferedDataGridView dataGridView, Preferences prefs) + private void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, Preferences prefs) { if (dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) > 1) { @@ -2935,7 +2936,7 @@ private void ApplyDataGridViewPrefs(BufferedDataGridView dataGridView, Preferenc AutoResizeColumns(dataGridView); } - private IList GetSelectedContent() + private IList GetSelectedContent () { if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) { @@ -2960,7 +2961,7 @@ private IList GetSelectedContent() * Timestamp stuff * =======================================================================*/ - private void SetTimestampLimits() + private void SetTimestampLimits () { if (!CurrentColumnizer.IsTimeshiftImplemented()) { @@ -2974,7 +2975,7 @@ private void SetTimestampLimits() SendGuiStateUpdate(); } - private void AdjustHighlightSplitterWidth() + private void AdjustHighlightSplitterWidth () { //int size = this.editHighlightsSplitContainer.Panel2Collapsed ? 600 : 660; //int distance = this.highlightSplitContainer.Width - size; @@ -2983,7 +2984,7 @@ private void AdjustHighlightSplitterWidth() //this.highlightSplitContainer.SplitterDistance = distance; } - private void BookmarkComment(Bookmark bookmark) + private void BookmarkComment (Bookmark bookmark) { BookmarkCommentDlg dlg = new(); dlg.Comment = bookmark.Text; @@ -3000,7 +3001,7 @@ private void BookmarkComment(Bookmark bookmark) /// /// /// - private string CalculateColumnNames(FilterParams filter) + private string CalculateColumnNames (FilterParams filter) { string names = string.Empty; @@ -3024,7 +3025,7 @@ private string CalculateColumnNames(FilterParams filter) return names; } - private void ApplyFrozenState(BufferedDataGridView gridView) + private void ApplyFrozenState (BufferedDataGridView gridView) { SortedDictionary dict = []; foreach (DataGridViewColumn col in gridView.Columns) @@ -3043,7 +3044,7 @@ private void ApplyFrozenState(BufferedDataGridView gridView) } } - private void ShowTimeSpread(bool show) + private void ShowTimeSpread (bool show) { if (show) { @@ -3057,12 +3058,12 @@ private void ShowTimeSpread(bool show) _timeSpreadCalc.Enabled = show; } - protected internal void AddTempFileTab(string fileName, string title) + protected internal void AddTempFileTab (string fileName, string title) { _parentLogTabWin.AddTempFileTab(fileName, title); } - private void InitPatternWindow() + private void InitPatternWindow () { //PatternStatistic(this.patternArgs); _patternWindow = new PatternWindow(this); @@ -3076,7 +3077,7 @@ private void InitPatternWindow() //this.patternWindow.Show(); } - private void TestStatistic(PatternArgs patternArgs) + private void TestStatistic (PatternArgs patternArgs) { int beginLine = patternArgs.StartLine; _logger.Info("TestStatistics() called with start line {0}", beginLine); @@ -3169,7 +3170,7 @@ private void TestStatistic(PatternArgs patternArgs) _logger.Info("TestStatistics() ended"); } - private void addBlockTargetLinesToDict(Dictionary dict, PatternBlock block) + private void addBlockTargetLinesToDict (Dictionary dict, PatternBlock block) { foreach (int lineNum in block.targetLines.Keys) { @@ -3181,7 +3182,7 @@ private void addBlockTargetLinesToDict(Dictionary dict, PatternBlock b } //Well keep this for the moment because there is some other commented code which calls this one - private PatternBlock FindExistingBlock(PatternBlock block, List blockList) + private PatternBlock FindExistingBlock (PatternBlock block, List blockList) { foreach (PatternBlock searchBlock in blockList) { @@ -3200,7 +3201,7 @@ private PatternBlock FindExistingBlock(PatternBlock block, List bl return null; } - private PatternBlock DetectBlock(int startNum, int startLineToSearch, int maxBlockLen, int maxDiffInBlock, + private PatternBlock DetectBlock (int startNum, int startLineToSearch, int maxBlockLen, int maxDiffInBlock, int maxMisses, Dictionary processedLinesDict) { int targetLine = FindSimilarLine(startNum, startLineToSearch, processedLinesDict); @@ -3282,7 +3283,7 @@ private PatternBlock DetectBlock(int startNum, int startLineToSearch, int maxBlo return block; } - private void PrepareDict() + private void PrepareDict () { _lineHashList.Clear(); Regex regex = new("\\d"); @@ -3327,7 +3328,7 @@ private void PrepareDict() } } - private int _FindSimilarLine(int srcLine, int startLine) + private int _FindSimilarLine (int srcLine, int startLine) { int value = _lineHashList[srcLine]; @@ -3345,7 +3346,7 @@ private int _FindSimilarLine(int srcLine, int startLine) // int[,] similarCache; - private void ResetCache(int num) + private void ResetCache (int num) { //this.similarCache = new int[num, num]; //for (int i = 0; i < num; ++i) @@ -3357,7 +3358,7 @@ private void ResetCache(int num) //} } - private int FindSimilarLine(int srcLine, int startLine, Dictionary processedLinesDict) + private int FindSimilarLine (int srcLine, int startLine, Dictionary processedLinesDict) { int threshold = _patternArgs.Fuzzy; @@ -3421,7 +3422,7 @@ private int FindSimilarLine(int srcLine, int startLine, Dictionary pro return -1; } - private string GetMsgForLine(int i) + private string GetMsgForLine (int i) { ILogLine line = _logFileReader.GetLogLine(i); ILogLineColumnizer columnizer = CurrentColumnizer; @@ -3430,7 +3431,7 @@ private string GetMsgForLine(int i) return cols.ColumnValues.Last().FullValue; } - private void ChangeRowHeight(bool decrease) + private void ChangeRowHeight (bool decrease) { int rowNum = dataGridView.CurrentCellAddress.Y; if (rowNum < 0 || rowNum >= dataGridView.RowCount) @@ -3481,7 +3482,7 @@ private void ChangeRowHeight(bool decrease) dataGridView.Refresh(); } - private int GetRowHeight(int rowNum) + private int GetRowHeight (int rowNum) { if (_rowHeightList.ContainsKey(rowNum)) { @@ -3493,7 +3494,7 @@ private int GetRowHeight(int rowNum) } } - private void AddBookmarkAtLineSilently(int lineNum) + private void AddBookmarkAtLineSilently (int lineNum) { if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) { @@ -3501,7 +3502,7 @@ private void AddBookmarkAtLineSilently(int lineNum) } } - private void AddBookmarkAndEditComment() + private void AddBookmarkAndEditComment () { int lineNum = dataGridView.CurrentCellAddress.Y; if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) @@ -3512,7 +3513,7 @@ private void AddBookmarkAndEditComment() BookmarkComment(_bookmarkProvider.GetBookmarkForLine(lineNum)); } - private void AddBookmarkComment(string text) + private void AddBookmarkComment (string text) { int lineNum = dataGridView.CurrentCellAddress.Y; Bookmark bookmark; @@ -3531,7 +3532,7 @@ private void AddBookmarkComment(string text) OnBookmarkTextChanged(bookmark); } - private void MarkCurrentFilterRange() + private void MarkCurrentFilterRange () { _filterParams.RangeSearchText = filterRangeComboBox.Text; ColumnizerCallback callback = new(this); @@ -3551,7 +3552,7 @@ private void MarkCurrentFilterRange() } } - private void RemoveTempHighlights() + private void RemoveTempHighlights () { lock (_tempHighlightEntryListLock) { @@ -3561,7 +3562,7 @@ private void RemoveTempHighlights() RefreshAllGrids(); } - private void ToggleHighlightPanel(bool open) + private void ToggleHighlightPanel (bool open) { highlightSplitContainer.Panel2Collapsed = !open; btnToggleHighlightPanel.Image = open @@ -3569,7 +3570,7 @@ private void ToggleHighlightPanel(bool open) : new Bitmap(_panelOpenButtonImage, new Size(btnToggleHighlightPanel.Size.Height, btnToggleHighlightPanel.Size.Height)); } - private void SetBookmarksForSelectedFilterLines() + private void SetBookmarksForSelectedFilterLines () { lock (_filterResultList) { @@ -3585,7 +3586,7 @@ private void SetBookmarksForSelectedFilterLines() OnBookmarkAdded(); } - private void SetDefaultHighlightGroup() + private void SetDefaultHighlightGroup () { HighlightGroup group = _parentLogTabWin.FindHighlightGroupByFileMask(FileName); if (group != null) @@ -3598,14 +3599,14 @@ private void SetDefaultHighlightGroup() } } - private void HandleChangedFilterOnLoadSetting() + private void HandleChangedFilterOnLoadSetting () { _parentLogTabWin.Preferences.isFilterOnLoad = filterOnLoadCheckBox.Checked; _parentLogTabWin.Preferences.isAutoHideFilterList = hideFilterListOnLoadCheckBox.Checked; OnFilterListChanged(this); } - private void FireCancelHandlers() + private void FireCancelHandlers () { lock (_cancelHandlerList) { @@ -3616,7 +3617,7 @@ private void FireCancelHandlers() } } - private void SyncOtherWindows(DateTime timestamp) + private void SyncOtherWindows (DateTime timestamp) { lock (_timeSyncListLock) { @@ -3624,7 +3625,7 @@ private void SyncOtherWindows(DateTime timestamp) } } - private void AddSlaveToTimesync(LogWindow slave) + private void AddSlaveToTimesync (LogWindow slave) { lock (_timeSyncListLock) { @@ -3656,17 +3657,17 @@ private void AddSlaveToTimesync(LogWindow slave) OnSyncModeChanged(); } - private void FreeSlaveFromTimesync(LogWindow slave) + private void FreeSlaveFromTimesync (LogWindow slave) { slave.FreeFromTimeSync(); } - private void OnSyncModeChanged() + private void OnSyncModeChanged () { SyncModeChanged?.Invoke(this, new SyncModeEventArgs(IsTimeSynced)); } - private void AddSearchHitHighlightEntry(SearchParams para) + private void AddSearchHitHighlightEntry (SearchParams para) { HighlightEntry he = new() { @@ -3692,7 +3693,7 @@ private void AddSearchHitHighlightEntry(SearchParams para) RefreshAllGrids(); } - private void RemoveAllSearchHighlightEntries() + private void RemoveAllSearchHighlightEntries () { lock (_tempHighlightEntryListLock) { @@ -3711,7 +3712,7 @@ private void RemoveAllSearchHighlightEntries() RefreshAllGrids(); } - private DataGridViewColumn GetColumnByName(BufferedDataGridView dataGridView, string name) + private DataGridViewColumn GetColumnByName (BufferedDataGridView dataGridView, string name) { foreach (DataGridViewColumn col in dataGridView.Columns) { @@ -3724,7 +3725,7 @@ private DataGridViewColumn GetColumnByName(BufferedDataGridView dataGridView, st return null; } - private void SelectColumn() + private void SelectColumn () { string colName = columnComboBox.SelectedItem as string; DataGridViewColumn col = GetColumnByName(dataGridView, colName); From 6d2e5bf517dc89377da543f1f15ef06cfec9abf9 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 1 Jun 2025 13:15:12 +0200 Subject: [PATCH 048/142] optimizations --- .../ILogLineColumnizerCallback.cs | 91 ++++++++-------- .../Callback/ColumnizerCallback.cs | 102 +++++++++--------- src/LogExpert.Core/Classes/Filter/Filter.cs | 2 +- .../Classes/Filter/FilterStarter.cs | 2 +- .../Controls/LogWindow/ColumnCache.cs | 2 +- .../Controls/LogWindow/LogExpertCallback.cs | 37 ++++--- .../Controls/LogWindow/LogWindow.cs | 4 +- .../Controls/LogWindow/LogWindowPrivate.cs | 2 +- .../Controls/LogWindow/RangeFinder.cs | 3 +- .../LogWindow/TimeSpreadCalculator.cs | 3 +- 10 files changed, 123 insertions(+), 125 deletions(-) diff --git a/src/ColumnizerLib/ILogLineColumnizerCallback.cs b/src/ColumnizerLib/ILogLineColumnizerCallback.cs index 439b6476..2c5f5811 100644 --- a/src/ColumnizerLib/ILogLineColumnizerCallback.cs +++ b/src/ColumnizerLib/ILogLineColumnizerCallback.cs @@ -1,53 +1,52 @@ -namespace LogExpert +namespace LogExpert; + +/// +///This is a callback interface. Some of the ILogLineColumnizer functions +///are called with this interface as an argument. You don't have to implement this interface. It's implemented +///by LogExpert. You can use it in your own columnizers, if you need it. +/// +/// +///Implementors of ILogLineColumnizer can use the provided functions to get some more informations +///about the log file. In the most cases you don't need this interface. It's provided here for special cases.

    +///

    +///An example would be when the log lines contains only the time of day but the date is coded in the file name. In this situation +///you can use the GetFileName() function to retrieve the name of the current file to build a complete timestamp. +///
    +public interface ILogLineColumnizerCallback { - /// - ///This is a callback interface. Some of the ILogLineColumnizer functions - ///are called with this interface as an argument. You don't have to implement this interface. It's implemented - ///by LogExpert. You can use it in your own columnizers, if you need it. - /// - /// - ///Implementors of ILogLineColumnizer can use the provided functions to get some more informations - ///about the log file. In the most cases you don't need this interface. It's provided here for special cases.

    - ///

    - ///An example would be when the log lines contains only the time of day but the date is coded in the file name. In this situation - ///you can use the GetFileName() function to retrieve the name of the current file to build a complete timestamp. - ///
    - public interface ILogLineColumnizerCallback - { - #region Public methods + #region Public methods - /// - /// This function returns the current line number. That is the line number of the log line - /// a ILogLineColumnizer function is called for (e.g. the line that has to be painted). - /// - /// The current line number starting at 0 - int GetLineNum (); + /// + /// This function returns the current line number. That is the line number of the log line + /// a ILogLineColumnizer function is called for (e.g. the line that has to be painted). + /// + /// The current line number starting at 0 + int GetLineNum (); - /// - /// This function sets the current line number. That is the line number of the log line - /// a ILogLineColumnizer function is called for (e.g. the line that has to be painted). - /// - /// line number to be set - void SetLineNum (int lineNum); - /// - /// Returns the full file name (path + name) of the current log file. - /// - /// File name of current log file - string GetFileName (); + /// + /// This function sets the current line number. That is the line number of the log line + /// a ILogLineColumnizer function is called for (e.g. the line that has to be painted). + /// + /// line number to be set + void SetLineNum (int lineNum); + /// + /// Returns the full file name (path + name) of the current log file. + /// + /// File name of current log file + string GetFileName (); - /// - /// Returns the log line with the given index (zero-based). - /// - /// Number of the line to be retrieved - /// A string with line content or null if line number is out of range - ILogLine GetLogLine (int lineNum); + /// + /// Returns the log line with the given index (zero-based). + /// + /// Number of the line to be retrieved + /// A string with line content or null if line number is out of range + ILogLine GetLogLine (int lineNum); - /// - /// Returns the number of lines of the logfile. - /// - /// Number of lines. - int GetLineCount (); + /// + /// Returns the number of lines of the logfile. + /// + /// Number of lines. + int GetLineCount (); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Callback/ColumnizerCallback.cs b/src/LogExpert.Core/Callback/ColumnizerCallback.cs index ddf51448..2d1266b1 100644 --- a/src/LogExpert.Core/Callback/ColumnizerCallback.cs +++ b/src/LogExpert.Core/Callback/ColumnizerCallback.cs @@ -1,74 +1,70 @@ using LogExpert.Core.Interface; -namespace LogExpert.Classes.ILogLineColumnizerCallback -{ - public class ColumnizerCallback : LogExpert.ILogLineColumnizerCallback, IAutoLogLineColumnizerCallback - { - #region Fields - - private protected ILogWindow _logWindow; - private protected IPluginRegistry _pluginRegistry; +namespace LogExpert.Core.Callback; - #endregion +public class ColumnizerCallback : ILogLineColumnizerCallback, IAutoLogLineColumnizerCallback +{ + #region cTor - #region cTor + public ColumnizerCallback (ILogWindow logWindow) + { + LogWindow = logWindow; + } - public ColumnizerCallback (ILogWindow logWindow) - { - _logWindow = logWindow; - } + private ColumnizerCallback (ColumnizerCallback original) + { + LogWindow = original.LogWindow; + LineNum = original.GetLineNum(); + } - private ColumnizerCallback (ColumnizerCallback original) - { - _logWindow = original._logWindow; - LineNum = original.GetLineNum(); - } + #endregion - #endregion + #region Properties - #region Properties + public int LineNum { get; set; } - public int LineNum { get; set; } + protected ILogWindow LogWindow { get; set; } - #endregion + protected IPluginRegistry PluginRegistry { get; set; } - #region Public methods + #endregion - public ColumnizerCallback CreateCopy () - { - return new ColumnizerCallback(this); - } + #region Public methods - public int GetLineNum () - { - return LineNum; - } + public ColumnizerCallback CreateCopy () + { + return new ColumnizerCallback(this); + } - public string GetFileName () - { - return _logWindow.GetCurrentFileName(GetLineNum()); - } + public int GetLineNum () + { + return LineNum; + } - public ILogLine GetLogLine (int lineNum) - { - return _logWindow.GetLine(lineNum); - } + public string GetFileName () + { + return LogWindow.GetCurrentFileName(GetLineNum()); + } - public IList GetRegisteredColumnizers () - { - return _pluginRegistry.RegisteredColumnizers; - } + public ILogLine GetLogLine (int lineNum) + { + return LogWindow.GetLine(lineNum); + } - public int GetLineCount () - { - return _logWindow.LogFileReader.LineCount; - } + public IList GetRegisteredColumnizers () + { + return PluginRegistry.RegisteredColumnizers; + } - public void SetLineNum (int lineNum) - { - LineNum = lineNum; - } + public int GetLineCount () + { + return LogWindow.LogFileReader.LineCount; + } - #endregion + public void SetLineNum (int lineNum) + { + LineNum = lineNum; } + + #endregion } diff --git a/src/LogExpert.Core/Classes/Filter/Filter.cs b/src/LogExpert.Core/Classes/Filter/Filter.cs index ed396886..37ae5710 100644 --- a/src/LogExpert.Core/Classes/Filter/Filter.cs +++ b/src/LogExpert.Core/Classes/Filter/Filter.cs @@ -1,4 +1,4 @@ -using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Callback; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Filter; diff --git a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs index aeb5c3ce..c3956c6d 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs @@ -1,4 +1,4 @@ -using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Callback; using LogExpert.Core.Classes.Filter; using NLog; diff --git a/src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs b/src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs index 6ebaced6..2ac878a7 100644 --- a/src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs +++ b/src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs @@ -1,4 +1,4 @@ -using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Callback; using LogExpert.Core.Classes.Log; namespace LogExpert.UI.Controls.LogWindow; diff --git a/src/LogExpert.UI/Controls/LogWindow/LogExpertCallback.cs b/src/LogExpert.UI/Controls/LogWindow/LogExpertCallback.cs index d3de849b..a42320d0 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogExpertCallback.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogExpertCallback.cs @@ -1,26 +1,25 @@ -using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Callback; -namespace LogExpert.UI.Controls.LogWindow -{ - internal class LogExpertCallback(LogWindow logWindow) : ColumnizerCallback(logWindow), ILogExpertCallback - { - #region Public methods +namespace LogExpert.UI.Controls.LogWindow; - public void AddTempFileTab(string fileName, string title) - { - _logWindow.AddTempFileTab(fileName, title); - } +internal class LogExpertCallback (LogWindow logWindow) : ColumnizerCallback(logWindow), ILogExpertCallback +{ + #region Public methods - public void AddPipedTab(IList lineEntryList, string title) - { - _logWindow.WritePipeTab(lineEntryList, title); - } + public void AddTempFileTab (string fileName, string title) + { + LogWindow.AddTempFileTab(fileName, title); + } - public string GetTabTitle() - { - return _logWindow.Text; - } + public void AddPipedTab (IList lineEntryList, string title) + { + LogWindow.WritePipeTab(lineEntryList, title); + } - #endregion + public string GetTabTitle () + { + return LogWindow.Text; } + + #endregion } diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index e869dbe4..0a48486f 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -1,5 +1,5 @@ using LogExpert.Classes.Filter; -using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Callback; using LogExpert.Core.Classes.Bookmark; using LogExpert.Core.Classes.Filter; using LogExpert.Core.Classes.Highlight; @@ -14,7 +14,9 @@ using LogExpert.UI.Controls.LogTabWindow; using LogExpert.UI.Dialogs; using LogExpert.UI.Extensions.Forms; + using NLog; + using WeifenLuo.WinFormsUI.Docking; //using static LogExpert.PluginRegistry.PluginRegistry; //TODO: Adjust the instance name so using static can be used. diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs index 43ab063a..7de8cbdd 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs @@ -3,7 +3,7 @@ using System.Text.RegularExpressions; using LogExpert.Classes.Filter; -using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Callback; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Columnizer; using LogExpert.Core.Classes.Filter; diff --git a/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs b/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs index 4852acea..2a822e02 100644 --- a/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs +++ b/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs @@ -1,7 +1,8 @@ -using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Callback; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Filter; using LogExpert.Core.Entities; + using NLog; using Range = LogExpert.Core.Entities.Range; diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs index f787bf21..47521d25 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs @@ -1,6 +1,7 @@ -using LogExpert.Classes.ILogLineColumnizerCallback; +using LogExpert.Core.Callback; using LogExpert.Core.Classes; using LogExpert.Core.Interface; + using NLog; using System; From 0611baf09d6fe374ab1a9a0f1f18d8333906ff32 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 1 Jun 2025 13:24:45 +0200 Subject: [PATCH 049/142] more editor config optimizations --- src/LogExpert.Core/Classes/Util.cs | 943 +++++++++++++++-------------- 1 file changed, 474 insertions(+), 469 deletions(-) diff --git a/src/LogExpert.Core/Classes/Util.cs b/src/LogExpert.Core/Classes/Util.cs index 935f15b1..662d45b2 100644 --- a/src/LogExpert.Core/Classes/Util.cs +++ b/src/LogExpert.Core/Classes/Util.cs @@ -1,624 +1,629 @@ -using LogExpert.Core.Classes.Filter; - using System.Diagnostics; using System.Drawing; using System.Runtime.Versioning; using System.Text.RegularExpressions; -namespace LogExpert.Core.Classes +using LogExpert.Core.Classes.Filter; + +namespace LogExpert.Core.Classes; + +public class Util { - public class Util + #region Public methods + + public static string GetNameFromPath (string fileName) { - #region Public methods + var i = fileName.LastIndexOf('\\'); - public static string GetNameFromPath(string fileName) + if (i < 0) { - int i = fileName.LastIndexOf('\\'); - if (i < 0) - { - i = fileName.LastIndexOf('/'); - } - if (i < 0) - { - i = -1; - } - return fileName[(i + 1)..]; + i = fileName.LastIndexOf('/'); } - public static string StripExtension(string fileName) + if (i < 0) { - int i = fileName.LastIndexOf('.'); - if (i < 0) - { - i = fileName.Length - 1; - } - return fileName[..i]; + i = -1; } - public static string GetExtension(string fileName) + return fileName[(i + 1)..]; + } + + //TODO Add Null Check + public static string StripExtension (string fileName) + { + var i = fileName.LastIndexOf('.'); + + if (i < 0) { - int i = fileName.LastIndexOf('.'); - if (i < 0 || i >= fileName.Length - 1) - { - return ""; - } - else - { - return fileName[(i + 1)..]; - } + i = fileName.Length - 1; } + return fileName[..i]; + } + + //TODO Add Null Check + public static string GetExtension (string fileName) + { + var i = fileName.LastIndexOf('.'); + + return i < 0 || i >= fileName.Length - 1 + ? string.Empty + : fileName[(i + 1)..]; + } + - public static string GetFileSizeAsText(long size) + public static string GetFileSizeAsText (long size) + { + return size < 1024 + ? string.Empty + size + " bytes" + : size < 1024 * 1024 + ? string.Empty + (size / 1024) + " KB" + : string.Empty + $"{size / 1048576.0:0.00}" + " MB"; + } + + public static bool TestFilterCondition (FilterParams filterParams, ILogLine line, ILogLineColumnizerCallback columnizerCallback) + { + if (filterParams.LastLine.Equals(line.FullLine)) { - if (size < 1024) - { - return "" + size + " bytes"; - } - else if (size < 1024 * 1024) - { - return "" + size / 1024 + " KB"; - } - else - { - return "" + string.Format("{0:0.00}", size / 1048576.0) + " MB"; - } + return filterParams.LastResult; } - public static bool TestFilterCondition(FilterParams filterParams, ILogLine line, - LogExpert.ILogLineColumnizerCallback columnizerCallback) + var match = TestFilterMatch(filterParams, line, columnizerCallback); + filterParams.LastLine = line.FullLine; + + if (filterParams.IsRangeSearch) { - if (filterParams.LastLine.Equals(line.FullLine)) + if (!filterParams.IsInRange) { - return filterParams.LastResult; + if (match) + { + filterParams.IsInRange = true; + } } - - bool match = TestFilterMatch(filterParams, line, columnizerCallback); - filterParams.LastLine = line.FullLine; - - if (filterParams.IsRangeSearch) + else { - if (!filterParams.IsInRange) + if (!match) { - if (match) - { - filterParams.IsInRange = true; - } + match = true; } else { - if (!match) - { - match = true; - } - else - { - filterParams.IsInRange = false; - } + filterParams.IsInRange = false; } } - if (filterParams.IsInvert) - { - match = !match; - } - filterParams.LastResult = match; - return match; } + if (filterParams.IsInvert) + { + match = !match; + } + + filterParams.LastResult = match; + return match; + } + + //TODO Add Null Checks + public static int DamerauLevenshteinDistance (string src, string dest) + { + var d = new int[src.Length + 1, dest.Length + 1]; + int i, j, cost; + var str1 = src.ToCharArray(); + var str2 = dest.ToCharArray(); - public static int DamerauLevenshteinDistance(string src, string dest) + for (i = 0; i <= str1.Length; i++) { - int[,] d = new int[src.Length + 1, dest.Length + 1]; - int i, j, cost; - char[] str1 = src.ToCharArray(); - char[] str2 = dest.ToCharArray(); + d[i, 0] = i; + } - for (i = 0; i <= str1.Length; i++) - { - d[i, 0] = i; - } - for (j = 0; j <= str2.Length; j++) - { - d[0, j] = j; - } - for (i = 1; i <= str1.Length; i++) + for (j = 0; j <= str2.Length; j++) + { + d[0, j] = j; + } + + for (i = 1; i <= str1.Length; i++) + { + for (j = 1; j <= str2.Length; j++) { - for (j = 1; j <= str2.Length; j++) - { - if (str1[i - 1] == str2[j - 1]) - { - cost = 0; - } - else - { - cost = 1; - } + cost = str1[i - 1] == str2[j - 1] + ? 0 + : 1; - d[i, j] = - Math.Min(d[i - 1, j] + 1, // Deletion - Math.Min(d[i, j - 1] + 1, // Insertion - d[i - 1, j - 1] + cost)); // Substitution + d[i, j] = + Math.Min(d[i - 1, j] + 1, // Deletion + Math.Min(d[i, j - 1] + 1, // Insertion + d[i - 1, j - 1] + cost)); // Substitution - if (i > 1 && j > 1 && str1[i - 1] == str2[j - 2] && str1[i - 2] == str2[j - 1]) - { - d[i, j] = Math.Min(d[i, j], d[i - 2, j - 2] + cost); - } + if (i > 1 && j > 1 && str1[i - 1] == str2[j - 2] && str1[i - 2] == str2[j - 1]) + { + d[i, j] = Math.Min(d[i, j], d[i - 2, j - 2] + cost); } } - return d[str1.Length, str2.Length]; } + return d[str1.Length, str2.Length]; + } + + //TODO Add Null Checks + public static unsafe int YetiLevenshtein (string s1, string s2) + { + fixed (char* p1 = s1) + fixed (char* p2 = s2) + { + return YetiLevenshtein(p1, s1.Length, p2, s2.Length, 0); // substitutionCost = 1 + } + } + public static unsafe int YetiLevenshtein (string s1, string s2, int substitionCost) + { + var xc = substitionCost - 1; - public static unsafe int YetiLevenshtein(string s1, string s2) + if (xc is < 0 or > 1) { - fixed (char* p1 = s1) - fixed (char* p2 = s2) - { - return YetiLevenshtein(p1, s1.Length, p2, s2.Length, 0); // substitutionCost = 1 - } + throw new ArgumentException("", nameof(substitionCost)); } - public static unsafe int YetiLevenshtein(string s1, string s2, int substitionCost) + fixed (char* p1 = s1) + fixed (char* p2 = s2) { - int xc = substitionCost - 1; - if (xc < 0 || xc > 1) - { - throw new ArgumentException("", "substitionCost"); - } + return YetiLevenshtein(p1, s1.Length, p2, s2.Length, xc); + } + } - fixed (char* p1 = s1) - fixed (char* p2 = s2) - { - return YetiLevenshtein(p1, s1.Length, p2, s2.Length, xc); - } + /// + /// Cetin Sert, David Necas + /// Source Code + /// + /// + /// + /// + /// + /// + /// + public static unsafe int YetiLevenshtein (char* s1, int l1, char* s2, int l2, int xcost) + { + int i; + //int *row; /* we only need to keep one row of costs */ + int* end; + int half; + + /* strip common prefix */ + while (l1 > 0 && l2 > 0 && *s1 == *s2) + { + l1--; + l2--; + s1++; + s2++; } - /// - /// Cetin Sert, David Necas - /// Source Code - /// - /// - /// - /// - /// - /// - /// - public static unsafe int YetiLevenshtein(char* s1, int l1, char* s2, int l2, int xcost) - { - int i; - //int *row; /* we only need to keep one row of costs */ - int* end; - int half; - - /* strip common prefix */ - while (l1 > 0 && l2 > 0 && *s1 == *s2) - { - l1--; - l2--; - s1++; - s2++; - } + /* strip common suffix */ + while (l1 > 0 && l2 > 0 && s1[l1 - 1] == s2[l2 - 1]) + { + l1--; + l2--; + } - /* strip common suffix */ - while (l1 > 0 && l2 > 0 && s1[l1 - 1] == s2[l2 - 1]) - { - l1--; - l2--; - } + /* catch trivial cases */ + if (l1 == 0) + { + return l2; + } - /* catch trivial cases */ - if (l1 == 0) - { - return l2; - } - if (l2 == 0) - { - return l1; - } + if (l2 == 0) + { + return l1; + } - /* make the inner cycle (i.e. string2) the longer one */ - if (l1 > l2) - { - int nx = l1; - char* sx = s1; - l1 = l2; - l2 = nx; - s1 = s2; - s2 = sx; - } + /* make the inner cycle (i.e. string2) the longer one */ + if (l1 > l2) + { + var nx = l1; + var sx = s1; + l1 = l2; + l2 = nx; + s1 = s2; + s2 = sx; + } - //check len1 == 1 separately - if (l1 == 1) - { - //throw new NotImplementedException(); - if (xcost > 0) - //return l2 + 1 - 2*(memchr(s2, *s1, l2) != NULL); - { - return l2 + 1 - 2 * memchrRPLC(s2, *s1, l2); - } - else - //return l2 - (memchr(s2, *s1, l2) != NULL); - { - return l2 - memchrRPLC(s2, *s1, l2); - } - } + //check len1 == 1 separately + if (l1 == 1) + { + //throw new NotImplementedException(); + return xcost > 0 + ? l2 + 1 - (2 * MemchrRPLC(s2, *s1, l2)) + : l2 - MemchrRPLC(s2, *s1, l2); + } - l1++; - l2++; - half = l1 >> 1; + l1++; + l2++; + half = l1 >> 1; - /* initalize first row */ - //row = (int*)malloc(l2*sizeof(int)); - int* row = stackalloc int[l2]; - if (l2 < 0) - //if (!row) - { - return -1; - } - end = row + l2 - 1; - for (i = 0; i < l2 - (xcost > 0 ? 0 : half); i++) - { - row[i] = i; - } + /* initalize first row */ + //row = (int*)malloc(l2*sizeof(int)); + var row = stackalloc int[l2]; + + if (l2 < 0) + //if (!row) + { + return -1; + } + + end = row + l2 - 1; + + for (i = 0; i < l2 - (xcost > 0 ? 0 : half); i++) + { + row[i] = i; + } - /* go through the matrix and compute the costs. yes, this is an extremely - * obfuscated version, but also extremely memory-conservative and - * relatively fast. - */ - if (xcost > 0) + /* go through the matrix and compute the costs. yes, this is an extremely + * obfuscated version, but also extremely memory-conservative and + * relatively fast. + */ + if (xcost > 0) + { + for (i = 1; i < l1; i++) { - for (i = 1; i < l1; i++) + var p = row + 1; + var char1 = s1[i - 1]; + var char2p = s2; + var D = i; + var x = i; + + while (p <= end) { - int* p = row + 1; - char char1 = s1[i - 1]; - char* char2p = s2; - int D = i; - int x = i; - while (p <= end) + if (char1 == *char2p++) { - if (char1 == *char2p++) - { - x = --D; - } - else - { - x++; - } - D = *p; - D++; - if (x > D) - { - x = D; - } - *p++ = x; + x = --D; } + else + { + x++; + } + + D = *p; + D++; + + if (x > D) + { + x = D; + } + + *p++ = x; } } - else - { - /* in this case we don't have to scan two corner triangles (of size len1/2) - * in the matrix because no best path can go throught them. note this - * breaks when len1 == len2 == 2 so the memchr() special case above is - * necessary */ - row[0] = l1 - half - 1; - for (i = 1; i < l1; i++) + } + else + { + /* in this case we don't have to scan two corner triangles (of size len1/2) + * in the matrix because no best path can go throught them. note this + * breaks when len1 == len2 == 2 so the memchr() special case above is + * necessary */ + row[0] = l1 - half - 1; + for (i = 1; i < l1; i++) + { + int* p; + var char1 = s1[i - 1]; + char* char2p; + int D, x; + + /* skip the upper triangle */ + if (i >= l1 - half) { - int* p; - char char1 = s1[i - 1]; - char* char2p; - int D, x; - /* skip the upper triangle */ - if (i >= l1 - half) - { - int offset = i - (l1 - half); - int c3; + var offset = i - (l1 - half); + int c3; - char2p = s2 + offset; - p = row + offset; - c3 = *p++ + (char1 != *char2p++ ? 1 : 0); - x = *p; - x++; - D = x; - if (x > c3) - { - x = c3; - } - *p++ = x; - } - else + char2p = s2 + offset; + p = row + offset; + c3 = *p++ + (char1 != *char2p++ ? 1 : 0); + x = *p; + x++; + D = x; + + if (x > c3) { - p = row + 1; - char2p = s2; - D = x = i; + x = c3; } - /* skip the lower triangle */ - if (i <= half + 1) + + *p++ = x; + } + else + { + p = row + 1; + char2p = s2; + D = x = i; + } + + /* skip the lower triangle */ + if (i <= half + 1) + { + end = row + l2 + i - half - 2; + } + + /* main */ + while (p <= end) + { + var c3 = --D + (char1 != *char2p++ ? 1 : 0); + x++; + + if (x > c3) { - end = row + l2 + i - half - 2; + x = c3; } - /* main */ - while (p <= end) + + D = *p; + D++; + + if (x > D) { - int c3 = --D + (char1 != *char2p++ ? 1 : 0); - x++; - if (x > c3) - { - x = c3; - } - D = *p; - D++; - if (x > D) - { - x = D; - } - *p++ = x; + x = D; } - /* lower triangle sentinel */ - if (i <= half) + + *p++ = x; + } + + /* lower triangle sentinel */ + if (i <= half) + { + var c3 = --D + (char1 != *char2p ? 1 : 0); + x++; + if (x > c3) { - int c3 = --D + (char1 != *char2p ? 1 : 0); - x++; - if (x > c3) - { - x = c3; - } - *p = x; + x = c3; } + + *p = x; } } - - i = *end; - return i; } - /// - /// Returns true, if the given string is null or empty - /// - /// - /// - public static bool IsNull(string toTest) - { - return toTest == null || toTest.Length == 0; - } + i = *end; + return i; + } - /// - /// Returns true, if the given string is null or empty or contains only spaces - /// - /// - /// - public static bool IsNullOrSpaces(string toTest) - { - return toTest == null || toTest.Trim().Length == 0; - } + /// + /// Returns true, if the given string is null or empty + /// + /// + /// + public static bool IsNull (string toTest) + { + return toTest == null || toTest.Length == 0; + } - [Conditional("DEBUG")] - public static void AssertTrue(bool condition, string msg) + /// + /// Returns true, if the given string is null or empty or contains only spaces + /// + /// + /// + public static bool IsNullOrSpaces (string toTest) + { + return toTest == null || toTest.Trim().Length == 0; + } + + [Conditional("DEBUG")] + public static void AssertTrue (bool condition, string msg) + { + if (!condition) { - if (!condition) - { - //Todo this should be done differently - //MessageBox.Show("Assertion: " + msg); - throw new Exception(msg); - } + //Todo this should be done differently + //MessageBox.Show("Assertion: " + msg); + throw new Exception(msg); } + } - [SupportedOSPlatform("windows")] - public string GetWordFromPos(int xPos, string text, Graphics g, Font font) - { - string[] words = text.Split([' ', '.', ':', ';']); + //TODO Add Null Check + [SupportedOSPlatform("windows")] + public string? GetWordFromPos (int xPos, string text, Graphics g, Font font) + { + var words = text.Split([' ', '.', ':', ';']); - int index = 0; + var index = 0; - List crList = []; + List crList = []; - for (int i = 0; i < words.Length; ++i) - { - crList.Add(new CharacterRange(index, words[i].Length)); - index += words[i].Length; - } + for (var i = 0; i < words.Length; ++i) + { + crList.Add(new CharacterRange(index, words[i].Length)); + index += words[i].Length; + } - CharacterRange[] crArray = [.. crList]; + CharacterRange[] crArray = [.. crList]; - StringFormat stringFormat = new(StringFormat.GenericTypographic) - { - Trimming = StringTrimming.None, - FormatFlags = StringFormatFlags.NoClip - }; + StringFormat stringFormat = new(StringFormat.GenericTypographic) + { + Trimming = StringTrimming.None, + FormatFlags = StringFormatFlags.NoClip + }; - stringFormat.SetMeasurableCharacterRanges(crArray); + stringFormat.SetMeasurableCharacterRanges(crArray); - RectangleF rect = new(0, 0, 3000, 20); - Region[] stringRegions = g.MeasureCharacterRanges(text, font, rect, stringFormat); + RectangleF rect = new(0, 0, 3000, 20); + Region[] stringRegions = g.MeasureCharacterRanges(text, font, rect, stringFormat); - bool found = false; + var found = false; - int y = 0; + var y = 0; - foreach (Region regio in stringRegions) + foreach (Region regio in stringRegions) + { + if (regio.IsVisible(xPos, 3, g)) { - if (regio.IsVisible(xPos, 3, g)) - { - found = true; - break; - } - - y++; + found = true; + break; } - if (found) - { - return words[y]; - } - else - { - return null; - } + y++; } - #endregion + return found + ? words[y] + : null; + } - #region Private Methods + #endregion - private static bool TestFilterMatch(FilterParams filterParams, ILogLine line, ILogLineColumnizerCallback columnizerCallback) - { - string lowerSearchText; - string searchText; - Regex rex; + #region Private Methods - if (filterParams.IsInRange) - { - lowerSearchText = filterParams.LowerRangeSearchText; - searchText = filterParams.RangeSearchText; - rex = filterParams.RangeRex; - } - else - { - lowerSearchText = filterParams.LowerSearchText; - searchText = filterParams.SearchText; - rex = filterParams.Rex; - } + private static bool TestFilterMatch (FilterParams filterParams, ILogLine line, ILogLineColumnizerCallback columnizerCallback) + { + string lowerSearchText; + string searchText; + Regex rex; - if (searchText == null || lowerSearchText == null || searchText.Length == 0) - { - return false; - } + if (filterParams.IsInRange) + { + lowerSearchText = filterParams.LowerRangeSearchText; + searchText = filterParams.RangeSearchText; + rex = filterParams.RangeRex; + } + else + { + lowerSearchText = filterParams.LowerSearchText; + searchText = filterParams.SearchText; + rex = filterParams.Rex; + } + + if (searchText == null || lowerSearchText == null || searchText.Length == 0) + { + return false; + } - if (filterParams.ColumnRestrict) + if (filterParams.ColumnRestrict) + { + IColumnizedLogLine columns = filterParams.CurrentColumnizer.SplitLine(columnizerCallback, line); + var found = false; + foreach (var colIndex in filterParams.ColumnList) { - IColumnizedLogLine columns = filterParams.CurrentColumnizer.SplitLine(columnizerCallback, line); - bool found = false; - foreach (int colIndex in filterParams.ColumnList) + if (colIndex < columns.ColumnValues.Length + ) // just to be sure, maybe the columnizer has changed anyhow { - if (colIndex < columns.ColumnValues.Length - ) // just to be sure, maybe the columnizer has changed anyhow + if (columns.ColumnValues[colIndex].FullValue.Trim().Length == 0) { - if (columns.ColumnValues[colIndex].FullValue.Trim().Length == 0) + if (filterParams.EmptyColumnUsePrev) { - if (filterParams.EmptyColumnUsePrev) + var prevValue = (string)filterParams.LastNonEmptyCols[colIndex]; + if (prevValue != null) { - string prevValue = (string)filterParams.LastNonEmptyCols[colIndex]; - if (prevValue != null) + if (TestMatchSub(filterParams, prevValue, lowerSearchText, searchText, rex, + filterParams.ExactColumnMatch)) { - if (TestMatchSub(filterParams, prevValue, lowerSearchText, searchText, rex, - filterParams.ExactColumnMatch)) - { - found = true; - } + found = true; } } - else if (filterParams.EmptyColumnHit) - { - return true; - } } - else + else if (filterParams.EmptyColumnHit) { - filterParams.LastNonEmptyCols[colIndex] = columns.ColumnValues[colIndex].FullValue; - if (TestMatchSub(filterParams, columns.ColumnValues[colIndex].FullValue, lowerSearchText, - searchText, rex, - filterParams.ExactColumnMatch)) - { - found = true; - } + return true; + } + } + else + { + filterParams.LastNonEmptyCols[colIndex] = columns.ColumnValues[colIndex].FullValue; + if (TestMatchSub(filterParams, columns.ColumnValues[colIndex].FullValue, lowerSearchText, + searchText, rex, + filterParams.ExactColumnMatch)) + { + found = true; } } } - return found; } - else + + return found; + } + else + { + return TestMatchSub(filterParams, line.FullLine, lowerSearchText, searchText, rex, false); + } + } + + private static bool TestMatchSub (FilterParams filterParams, string line, string lowerSearchText, string searchText, Regex rex, bool exactMatch) + { + if (filterParams.IsRegex) + { + if (rex.IsMatch(line)) { - return TestMatchSub(filterParams, line.FullLine, lowerSearchText, searchText, rex, false); + return true; } } - - private static bool TestMatchSub(FilterParams filterParams, string line, string lowerSearchText, string searchText, Regex rex, bool exactMatch) + else { - if (filterParams.IsRegex) + if (!filterParams.IsCaseSensitive) { - if (rex.IsMatch(line)) + if (exactMatch) { - return true; + if (line.ToLower().Trim().Equals(lowerSearchText)) + { + return true; + } + } + else + { + if (line.Contains(lowerSearchText, StringComparison.CurrentCultureIgnoreCase)) + { + return true; + } } } else { - if (!filterParams.IsCaseSensitive) + if (exactMatch) { - if (exactMatch) + if (line.Equals(searchText)) { - if (line.ToLower().Trim().Equals(lowerSearchText)) - { - return true; - } - } - else - { - if (line.Contains(lowerSearchText, StringComparison.CurrentCultureIgnoreCase)) - { - return true; - } + return true; } } else { - if (exactMatch) + if (line.Contains(searchText)) { - if (line.Equals(searchText)) - { - return true; - } - } - else - { - if (line.Contains(searchText)) - { - return true; - } + return true; } } + } - if (filterParams.FuzzyValue > 0) + if (filterParams.FuzzyValue > 0) + { + var range = line.Length - searchText.Length; + if (range > 0) { - int range = line.Length - searchText.Length; - if (range > 0) + for (var i = 0; i < range; ++i) { - for (int i = 0; i < range; ++i) - { - string src = line.Substring(i, searchText.Length); + var src = line.Substring(i, searchText.Length); - if (!filterParams.IsCaseSensitive) - { - src = src.ToLower(); - } + if (!filterParams.IsCaseSensitive) + { + src = src.ToLower(); + } - int dist = DamerauLevenshteinDistance(src, searchText); + var dist = DamerauLevenshteinDistance(src, searchText); - if ((searchText.Length + 1) / (float)(dist + 1) >= 11F / (float)(filterParams.FuzzyValue + 1F)) - { - return true; - } + if ((searchText.Length + 1) / (float)(dist + 1) >= 11F / (float)(filterParams.FuzzyValue + 1F)) + { + return true; } } - return false; } + return false; } - return false; } + return false; + } - private static unsafe int memchrRPLC(char* buffer, char c, int count) + private static unsafe int MemchrRPLC (char* buffer, char c, int count) + { + var p = buffer; + var e = buffer + count; + + while (p++ < e) { - char* p = buffer; - char* e = buffer + count; - while (p++ < e) + if (*p == c) { - if (*p == c) - { - return 1; - } + return 1; } - return 0; } - #endregion + return 0; } + + #endregion } \ No newline at end of file From a958b1ef52a6a8714ae199603c078ef781b34945 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 1 Jun 2025 13:34:58 +0200 Subject: [PATCH 050/142] added already created issues to todos --- src/LogExpert.Core/Classes/Filter/Filter.cs | 2 +- .../Classes/Log/LogfileReader.cs | 2787 +++++++++-------- src/LogExpert.Core/Classes/Util.cs | 10 +- src/LogExpert.Core/Interface/IBookmarkView.cs | 29 - src/LogExpert.Core/Interface/ILogTabWindow.cs | 23 +- src/LogExpert.Core/Interface/ILogWindow.cs | 43 +- 6 files changed, 1433 insertions(+), 1461 deletions(-) delete mode 100644 src/LogExpert.Core/Interface/IBookmarkView.cs diff --git a/src/LogExpert.Core/Classes/Filter/Filter.cs b/src/LogExpert.Core/Classes/Filter/Filter.cs index 37ae5710..dc35ffea 100644 --- a/src/LogExpert.Core/Classes/Filter/Filter.cs +++ b/src/LogExpert.Core/Classes/Filter/Filter.cs @@ -22,7 +22,7 @@ internal class Filter #region cTor - //TODO Is the callback needed? + //TODO Is the callback needed? (https://github.com/LogExperts/LogExpert/issues/401) public Filter (ColumnizerCallback callback) { _callback = callback; diff --git a/src/LogExpert.Core/Classes/Log/LogfileReader.cs b/src/LogExpert.Core/Classes/Log/LogfileReader.cs index 944e4624..aa236303 100644 --- a/src/LogExpert.Core/Classes/Log/LogfileReader.cs +++ b/src/LogExpert.Core/Classes/Log/LogfileReader.cs @@ -1,940 +1,955 @@ -using LogExpert.Core.Classes.xml; +using System.Text; + +using LogExpert.Core.Classes.xml; using LogExpert.Core.Entities; using LogExpert.Core.EventArguments; using LogExpert.Core.EventHandlers; using LogExpert.Core.Interface; + using NLog; -using System.Text; -namespace LogExpert.Core.Classes.Log +namespace LogExpert.Core.Classes.Log; + +public class LogfileReader : IAutoLogLineColumnizerCallback { - public class LogfileReader : IAutoLogLineColumnizerCallback - { - #region Fields + #region Fields - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - private readonly GetLogLineFx _logLineFx; + private readonly GetLogLineFx _logLineFx; - private readonly string _fileName; - private readonly int _MAX_BUFFERS = 10; - private readonly int _MAX_LINES_PER_BUFFER = 100; + private readonly string _fileName; + private readonly int _MAX_BUFFERS = 10; + private readonly int _MAX_LINES_PER_BUFFER = 100; - private readonly object _monitor = new(); - private readonly MultiFileOptions _multiFileOptions; - private readonly IPluginRegistry _pluginRegistry; - private IList _bufferList; - private ReaderWriterLock _bufferListLock; - private IList _bufferLru; - private bool _contentDeleted; - private int _currLineCount; - private ReaderWriterLock _disposeLock; - private EncodingOptions _encodingOptions; - private long _fileLength; + private readonly object _monitor = new(); + private readonly MultiFileOptions _multiFileOptions; + private readonly IPluginRegistry _pluginRegistry; + private IList _bufferList; + private ReaderWriterLock _bufferListLock; + private IList _bufferLru; + private bool _contentDeleted; + private int _currLineCount; + private ReaderWriterLock _disposeLock; + private EncodingOptions _encodingOptions; + private long _fileLength; - private Task _garbageCollectorTask; - private Task _monitorTask; - private readonly CancellationTokenSource cts = new(); + private Task _garbageCollectorTask; + private Task _monitorTask; + private readonly CancellationTokenSource cts = new(); - private bool _isDeleted; - private bool _isFailModeCheckCallPending; - private bool _isFastFailOnGetLogLine; - private bool _isLineCountDirty = true; - private IList _logFileInfoList = []; - private Dictionary _lruCacheDict; + private bool _isDeleted; + private bool _isFailModeCheckCallPending; + private bool _isFastFailOnGetLogLine; + private bool _isLineCountDirty = true; + private IList _logFileInfoList = []; + private Dictionary _lruCacheDict; - private ReaderWriterLock _lruCacheDictLock; + private ReaderWriterLock _lruCacheDictLock; - private bool _shouldStop; - private ILogFileInfo _watchedILogFileInfo; + private bool _shouldStop; + private ILogFileInfo _watchedILogFileInfo; - #endregion + #endregion - #region cTor + #region cTor - public LogfileReader(string fileName, EncodingOptions encodingOptions, bool multiFile, int bufferCount, int linesPerBuffer, MultiFileOptions multiFileOptions, IPluginRegistry pluginRegistry) + public LogfileReader (string fileName, EncodingOptions encodingOptions, bool multiFile, int bufferCount, int linesPerBuffer, MultiFileOptions multiFileOptions, IPluginRegistry pluginRegistry) + { + if (fileName == null) { - if (fileName == null) - { - return; - } + return; + } - _fileName = fileName; - EncodingOptions = encodingOptions; - IsMultiFile = multiFile; - _MAX_BUFFERS = bufferCount; - _MAX_LINES_PER_BUFFER = linesPerBuffer; - _multiFileOptions = multiFileOptions; - _pluginRegistry = pluginRegistry; - _logLineFx = GetLogLineInternal; - InitLruBuffers(); - - if (multiFile) - { - ILogFileInfo info = GetLogFileInfo(fileName); - RolloverFilenameHandler rolloverHandler = new(info, _multiFileOptions); - LinkedList nameList = rolloverHandler.GetNameList(_pluginRegistry); + _fileName = fileName; + EncodingOptions = encodingOptions; + IsMultiFile = multiFile; + _MAX_BUFFERS = bufferCount; + _MAX_LINES_PER_BUFFER = linesPerBuffer; + _multiFileOptions = multiFileOptions; + _pluginRegistry = pluginRegistry; + _logLineFx = GetLogLineInternal; + InitLruBuffers(); - ILogFileInfo fileInfo = null; - foreach (string name in nameList) - { - fileInfo = AddFile(name); - } + if (multiFile) + { + ILogFileInfo info = GetLogFileInfo(fileName); + RolloverFilenameHandler rolloverHandler = new(info, _multiFileOptions); + LinkedList nameList = rolloverHandler.GetNameList(_pluginRegistry); - _watchedILogFileInfo = fileInfo; // last added file in the list is the watched file - } - else + ILogFileInfo fileInfo = null; + foreach (string name in nameList) { - _watchedILogFileInfo = AddFile(fileName); + fileInfo = AddFile(name); } - StartGCThread(); + _watchedILogFileInfo = fileInfo; // last added file in the list is the watched file } - - public LogfileReader(string[] fileNames, EncodingOptions encodingOptions, int bufferCount, int linesPerBuffer, MultiFileOptions multiFileOptions, IPluginRegistry pluginRegistry) + else { - if (fileNames == null || fileNames.Length < 1) - { - return; - } + _watchedILogFileInfo = AddFile(fileName); + } - EncodingOptions = encodingOptions; - IsMultiFile = true; - _MAX_BUFFERS = bufferCount; - _MAX_LINES_PER_BUFFER = linesPerBuffer; - _multiFileOptions = multiFileOptions; - _pluginRegistry = pluginRegistry; - _logLineFx = GetLogLineInternal; + StartGCThread(); + } - InitLruBuffers(); + public LogfileReader (string[] fileNames, EncodingOptions encodingOptions, int bufferCount, int linesPerBuffer, MultiFileOptions multiFileOptions, IPluginRegistry pluginRegistry) + { + if (fileNames == null || fileNames.Length < 1) + { + return; + } - ILogFileInfo fileInfo = null; - foreach (string name in fileNames) - { - fileInfo = AddFile(name); - } + EncodingOptions = encodingOptions; + IsMultiFile = true; + _MAX_BUFFERS = bufferCount; + _MAX_LINES_PER_BUFFER = linesPerBuffer; + _multiFileOptions = multiFileOptions; + _pluginRegistry = pluginRegistry; + _logLineFx = GetLogLineInternal; - _watchedILogFileInfo = fileInfo; - _fileName = fileInfo.FullName; + InitLruBuffers(); - StartGCThread(); + ILogFileInfo fileInfo = null; + foreach (string name in fileNames) + { + fileInfo = AddFile(name); } - #endregion + _watchedILogFileInfo = fileInfo; + _fileName = fileInfo.FullName; - #region Delegates + StartGCThread(); + } - public delegate void BlockLoadedEventHandler(object sender, LoadFileEventArgs e); - public delegate void FileNotFoundEventHandler(object sender, EventArgs e); - public delegate void FileRespawnedEventHandler(object sender, EventArgs e); - public delegate void FinishedLoadingEventHandler(object sender, EventArgs e); - private delegate Task GetLogLineFx(int lineNum); - public delegate void LoadingStartedEventHandler(object sender, LoadFileEventArgs e); + #endregion - #endregion + #region Delegates - #region Events + public delegate void BlockLoadedEventHandler (object sender, LoadFileEventArgs e); + public delegate void FileNotFoundEventHandler (object sender, EventArgs e); + public delegate void FileRespawnedEventHandler (object sender, EventArgs e); + public delegate void FinishedLoadingEventHandler (object sender, EventArgs e); + private delegate Task GetLogLineFx (int lineNum); + public delegate void LoadingStartedEventHandler (object sender, LoadFileEventArgs e); - public event FileSizeChangedEventHandler FileSizeChanged; - public event BlockLoadedEventHandler LoadFile; - public event LoadingStartedEventHandler LoadingStarted; - public event FinishedLoadingEventHandler LoadingFinished; - public event FileNotFoundEventHandler FileNotFound; - public event FileRespawnedEventHandler Respawned; + #endregion - #endregion + #region Events - #region Properties + public event FileSizeChangedEventHandler FileSizeChanged; + public event BlockLoadedEventHandler LoadFile; + public event LoadingStartedEventHandler LoadingStarted; + public event FinishedLoadingEventHandler LoadingFinished; + public event FileNotFoundEventHandler FileNotFound; + public event FileRespawnedEventHandler Respawned; - public int LineCount + #endregion + + #region Properties + + public int LineCount + { + get { - get + if (_isLineCountDirty) { - if (_isLineCountDirty) + _currLineCount = 0; + AcquireBufferListReaderLock(); + foreach (LogBuffer buffer in _bufferList) { - _currLineCount = 0; - AcquireBufferListReaderLock(); - foreach (LogBuffer buffer in _bufferList) - { - _currLineCount += buffer.LineCount; - } - - ReleaseBufferListReaderLock(); - _isLineCountDirty = false; + _currLineCount += buffer.LineCount; } - return _currLineCount; + ReleaseBufferListReaderLock(); + _isLineCountDirty = false; } - set => _currLineCount = value; + + return _currLineCount; } + set => _currLineCount = value; + } - public bool IsMultiFile { get; } + public bool IsMultiFile { get; } - public Encoding CurrentEncoding { get; private set; } + public Encoding CurrentEncoding { get; private set; } - public long FileSize { get; private set; } + public long FileSize { get; private set; } - public bool IsXmlMode { get; set; } = false; + public bool IsXmlMode { get; set; } = false; - public IXmlLogConfiguration XmlLogConfig { get; set; } + public IXmlLogConfiguration XmlLogConfig { get; set; } - public IPreProcessColumnizer PreProcessColumnizer { get; set; } = null; + public IPreProcessColumnizer PreProcessColumnizer { get; set; } = null; - public EncodingOptions EncodingOptions + public EncodingOptions EncodingOptions + { + get => _encodingOptions; + set { - get => _encodingOptions; - set { + _encodingOptions = new EncodingOptions { - _encodingOptions = new EncodingOptions - { - DefaultEncoding = value.DefaultEncoding, - Encoding = value.Encoding - }; - } + DefaultEncoding = value.DefaultEncoding, + Encoding = value.Encoding + }; } } + } - public bool UseNewReader { get; set; } + public bool UseNewReader { get; set; } - #endregion + #endregion - #region Public methods + #region Public methods - /// - /// Public for unit test reasons - /// - public void ReadFiles() + /// + /// Public for unit test reasons + /// + public void ReadFiles () + { + FileSize = 0; + LineCount = 0; + //this.lastReturnedLine = ""; + //this.lastReturnedLineNum = -1; + //this.lastReturnedLineNumForBuffer = -1; + _isDeleted = false; + ClearLru(); + AcquireBufferListWriterLock(); + _bufferList.Clear(); + ReleaseBufferListWriterLock(); + try { - FileSize = 0; - LineCount = 0; - //this.lastReturnedLine = ""; - //this.lastReturnedLineNum = -1; - //this.lastReturnedLineNumForBuffer = -1; - _isDeleted = false; - ClearLru(); - AcquireBufferListWriterLock(); - _bufferList.Clear(); - ReleaseBufferListWriterLock(); - try + foreach (ILogFileInfo info in _logFileInfoList) { - foreach (ILogFileInfo info in _logFileInfoList) - { - //info.OpenFile(); - ReadToBufferList(info, 0, LineCount); - } - - if (_logFileInfoList.Count > 0) - { - ILogFileInfo info = _logFileInfoList[_logFileInfoList.Count - 1]; - _fileLength = info.Length; - _watchedILogFileInfo = info; - } + //info.OpenFile(); + ReadToBufferList(info, 0, LineCount); } - catch (IOException e) + + if (_logFileInfoList.Count > 0) { - _logger.Warn(e, "IOException"); - _fileLength = 0; - _isDeleted = true; - LineCount = 0; + ILogFileInfo info = _logFileInfoList[_logFileInfoList.Count - 1]; + _fileLength = info.Length; + _watchedILogFileInfo = info; } + } + catch (IOException e) + { + _logger.Warn(e, "IOException"); + _fileLength = 0; + _isDeleted = true; + LineCount = 0; + } - LogEventArgs args = new() - { - PrevFileSize = 0, - PrevLineCount = 0, - LineCount = LineCount, - FileSize = FileSize - }; + LogEventArgs args = new() + { + PrevFileSize = 0, + PrevLineCount = 0, + LineCount = LineCount, + FileSize = FileSize + }; - OnFileSizeChanged(args); - } + OnFileSizeChanged(args); + } - /// - /// Public for unit tests. - /// - /// - public int ShiftBuffers() + /// + /// Public for unit tests. + /// + /// + public int ShiftBuffers () + { + _logger.Info("ShiftBuffers() begin for {0}{1}", _fileName, IsMultiFile ? " (MultiFile)" : ""); + AcquireBufferListWriterLock(); + int offset = 0; + _isLineCountDirty = true; + lock (_monitor) { - _logger.Info("ShiftBuffers() begin for {0}{1}", _fileName, IsMultiFile ? " (MultiFile)" : ""); - AcquireBufferListWriterLock(); - int offset = 0; - _isLineCountDirty = true; - lock (_monitor) - { - RolloverFilenameHandler rolloverHandler = new(_watchedILogFileInfo, _multiFileOptions); - LinkedList fileNameList = rolloverHandler.GetNameList(_pluginRegistry); - - ResetBufferCache(); - IList lostILogFileInfoList = []; - IList readNewILogFileInfoList = []; - IList newFileInfoList = []; - IEnumerator enumerator = _logFileInfoList.GetEnumerator(); - while (enumerator.MoveNext()) + RolloverFilenameHandler rolloverHandler = new(_watchedILogFileInfo, _multiFileOptions); + LinkedList fileNameList = rolloverHandler.GetNameList(_pluginRegistry); + + ResetBufferCache(); + IList lostILogFileInfoList = []; + IList readNewILogFileInfoList = []; + IList newFileInfoList = []; + IEnumerator enumerator = _logFileInfoList.GetEnumerator(); + while (enumerator.MoveNext()) + { + ILogFileInfo logFileInfo = enumerator.Current; + string fileName = logFileInfo.FullName; + _logger.Debug("Testing file {0}", fileName); + LinkedListNode node = fileNameList.Find(fileName); + if (node == null) { - ILogFileInfo logFileInfo = enumerator.Current; - string fileName = logFileInfo.FullName; - _logger.Debug("Testing file {0}", fileName); - LinkedListNode node = fileNameList.Find(fileName); - if (node == null) + _logger.Warn("File {0} not found", fileName); + continue; + } + + if (node.Previous != null) + { + fileName = node.Previous.Value; + ILogFileInfo newILogFileInfo = GetLogFileInfo(fileName); + _logger.Debug("{0} exists\r\nOld size={1}, new size={2}", fileName, logFileInfo.OriginalLength, newILogFileInfo.Length); + // is the new file the same as the old buffer info? + if (newILogFileInfo.Length == logFileInfo.OriginalLength) { - _logger.Warn("File {0} not found", fileName); - continue; + ReplaceBufferInfos(logFileInfo, newILogFileInfo); + newFileInfoList.Add(newILogFileInfo); } - - if (node.Previous != null) + else { - fileName = node.Previous.Value; - ILogFileInfo newILogFileInfo = GetLogFileInfo(fileName); - _logger.Debug("{0} exists\r\nOld size={1}, new size={2}", fileName, logFileInfo.OriginalLength, newILogFileInfo.Length); - // is the new file the same as the old buffer info? - if (newILogFileInfo.Length == logFileInfo.OriginalLength) - { - ReplaceBufferInfos(logFileInfo, newILogFileInfo); - newFileInfoList.Add(newILogFileInfo); - } - else + _logger.Debug("Buffer for {0} must be re-read.", fileName); + // not the same. so must read the rest of the list anew from the files + readNewILogFileInfoList.Add(newILogFileInfo); + while (enumerator.MoveNext()) { - _logger.Debug("Buffer for {0} must be re-read.", fileName); - // not the same. so must read the rest of the list anew from the files - readNewILogFileInfoList.Add(newILogFileInfo); - while (enumerator.MoveNext()) + fileName = enumerator.Current.FullName; + node = fileNameList.Find(fileName); + if (node == null) { - fileName = enumerator.Current.FullName; - node = fileNameList.Find(fileName); - if (node == null) - { - _logger.Warn("File {0} not found", fileName); - continue; - } - - if (node.Previous != null) - { - fileName = node.Previous.Value; - _logger.Debug("New name is {0}", fileName); - readNewILogFileInfoList.Add(GetLogFileInfo(fileName)); - } - else - { - _logger.Warn("No previous file for {0} found", fileName); - } + _logger.Warn("File {0} not found", fileName); + continue; + } + + if (node.Previous != null) + { + fileName = node.Previous.Value; + _logger.Debug("New name is {0}", fileName); + readNewILogFileInfoList.Add(GetLogFileInfo(fileName)); + } + else + { + _logger.Warn("No previous file for {0} found", fileName); } } } - else - { - _logger.Info("{0} does not exist", fileName); - lostILogFileInfoList.Add(logFileInfo); + } + else + { + _logger.Info("{0} does not exist", fileName); + lostILogFileInfoList.Add(logFileInfo); #if DEBUG // for better overview in logfile: - //ILogFileInfo newILogFileInfo = new ILogFileInfo(fileName); - //ReplaceBufferInfos(ILogFileInfo, newILogFileInfo); + //ILogFileInfo newILogFileInfo = new ILogFileInfo(fileName); + //ReplaceBufferInfos(ILogFileInfo, newILogFileInfo); #endif - } } + } - if (lostILogFileInfoList.Count > 0) + if (lostILogFileInfoList.Count > 0) + { + _logger.Info("Deleting buffers for lost files"); + foreach (ILogFileInfo ILogFileInfo in lostILogFileInfoList) { - _logger.Info("Deleting buffers for lost files"); - foreach (ILogFileInfo ILogFileInfo in lostILogFileInfoList) - { - //this.ILogFileInfoList.Remove(ILogFileInfo); - LogBuffer lastBuffer = DeleteBuffersForInfo(ILogFileInfo, false); - if (lastBuffer != null) - { - offset += lastBuffer.StartLine + lastBuffer.LineCount; - } - } - - _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); - _logger.Info("Adjusting StartLine values in {0} buffers by offset {1}", _bufferList.Count, offset); - foreach (LogBuffer buffer in _bufferList) - { - SetNewStartLineForBuffer(buffer, buffer.StartLine - offset); - } - - _lruCacheDictLock.ReleaseWriterLock(); -#if DEBUG - if (_bufferList.Count > 0) + //this.ILogFileInfoList.Remove(ILogFileInfo); + LogBuffer lastBuffer = DeleteBuffersForInfo(ILogFileInfo, false); + if (lastBuffer != null) { - _logger.Debug("First buffer now has StartLine {0}", _bufferList[0].StartLine); + offset += lastBuffer.StartLine + lastBuffer.LineCount; } -#endif } - // Read anew all buffers following a buffer info that couldn't be matched with the corresponding existing file - _logger.Info("Deleting buffers for files that must be re-read"); - foreach (ILogFileInfo ILogFileInfo in readNewILogFileInfoList) + _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); + _logger.Info("Adjusting StartLine values in {0} buffers by offset {1}", _bufferList.Count, offset); + foreach (LogBuffer buffer in _bufferList) { - DeleteBuffersForInfo(ILogFileInfo, true); - //this.ILogFileInfoList.Remove(ILogFileInfo); + SetNewStartLineForBuffer(buffer, buffer.StartLine - offset); } - _logger.Info("Deleting buffers for the watched file"); - DeleteBuffersForInfo(_watchedILogFileInfo, true); - int startLine = LineCount - 1; - _logger.Info("Re-Reading files"); - foreach (ILogFileInfo ILogFileInfo in readNewILogFileInfoList) + _lruCacheDictLock.ReleaseWriterLock(); +#if DEBUG + if (_bufferList.Count > 0) { - //ILogFileInfo.OpenFile(); - ReadToBufferList(ILogFileInfo, 0, LineCount); - //this.ILogFileInfoList.Add(ILogFileInfo); - newFileInfoList.Add(ILogFileInfo); + _logger.Debug("First buffer now has StartLine {0}", _bufferList[0].StartLine); } +#endif + } - //this.watchedILogFileInfo = this.ILogFileInfoList[this.ILogFileInfoList.Count - 1]; - _logFileInfoList = newFileInfoList; - _watchedILogFileInfo = GetLogFileInfo(_watchedILogFileInfo.FullName); - _logFileInfoList.Add(_watchedILogFileInfo); - _logger.Info("Reading watched file"); - ReadToBufferList(_watchedILogFileInfo, 0, LineCount); + // Read anew all buffers following a buffer info that couldn't be matched with the corresponding existing file + _logger.Info("Deleting buffers for files that must be re-read"); + foreach (ILogFileInfo ILogFileInfo in readNewILogFileInfoList) + { + DeleteBuffersForInfo(ILogFileInfo, true); + //this.ILogFileInfoList.Remove(ILogFileInfo); } - _logger.Info("ShiftBuffers() end. offset={0}", offset); - ReleaseBufferListWriterLock(); - return offset; - } + _logger.Info("Deleting buffers for the watched file"); + DeleteBuffersForInfo(_watchedILogFileInfo, true); + int startLine = LineCount - 1; + _logger.Info("Re-Reading files"); + foreach (ILogFileInfo ILogFileInfo in readNewILogFileInfoList) + { + //ILogFileInfo.OpenFile(); + ReadToBufferList(ILogFileInfo, 0, LineCount); + //this.ILogFileInfoList.Add(ILogFileInfo); + newFileInfoList.Add(ILogFileInfo); + } - public ILogLine GetLogLine(int lineNum) - { - return GetLogLineInternal(lineNum).Result; + //this.watchedILogFileInfo = this.ILogFileInfoList[this.ILogFileInfoList.Count - 1]; + _logFileInfoList = newFileInfoList; + _watchedILogFileInfo = GetLogFileInfo(_watchedILogFileInfo.FullName); + _logFileInfoList.Add(_watchedILogFileInfo); + _logger.Info("Reading watched file"); + ReadToBufferList(_watchedILogFileInfo, 0, LineCount); } - /// - /// Get the text content of the given line number. - /// The actual work is done in an async thread. This method waits for thread completion for only 1 second. If the async - /// thread has not returned, the method will return null. This is because this method is also called from GUI thread - /// (e.g. LogWindow draw events). Under some circumstances, repeated calls to this method would lead the GUI to freeze. E.g. when - /// trying to re-load content from disk but the file was deleted. Especially on network shares. - /// - /// - /// Once the method detects a timeout it will enter a kind of 'fast fail mode'. That means all following calls will be returned with - /// null immediately (without 1 second wait). A background call to GetLogLineInternal() will check if a result is available. - /// If so, the 'fast fail mode' is switched off. In most cases a fail is caused by a deleted file. But it may also be caused by slow - /// network connections. So all this effort is needed to prevent entering an endless 'fast fail mode' just because of temporary problems. - /// - /// line to retrieve - /// - public async Task GetLogLineWithWait(int lineNum) - { - const int WAIT_TIME = 1000; + _logger.Info("ShiftBuffers() end. offset={0}", offset); + ReleaseBufferListWriterLock(); + return offset; + } + + public ILogLine GetLogLine (int lineNum) + { + return GetLogLineInternal(lineNum).Result; + } + + /// + /// Get the text content of the given line number. + /// The actual work is done in an async thread. This method waits for thread completion for only 1 second. If the async + /// thread has not returned, the method will return null. This is because this method is also called from GUI thread + /// (e.g. LogWindow draw events). Under some circumstances, repeated calls to this method would lead the GUI to freeze. E.g. when + /// trying to re-load content from disk but the file was deleted. Especially on network shares. + /// + /// + /// Once the method detects a timeout it will enter a kind of 'fast fail mode'. That means all following calls will be returned with + /// null immediately (without 1 second wait). A background call to GetLogLineInternal() will check if a result is available. + /// If so, the 'fast fail mode' is switched off. In most cases a fail is caused by a deleted file. But it may also be caused by slow + /// network connections. So all this effort is needed to prevent entering an endless 'fast fail mode' just because of temporary problems. + /// + /// line to retrieve + /// + public async Task GetLogLineWithWait (int lineNum) + { + const int WAIT_TIME = 1000; - ILogLine result = null; + ILogLine result = null; - if (!_isFastFailOnGetLogLine) + if (!_isFastFailOnGetLogLine) + { + var task = Task.Run(() => _logLineFx(lineNum)); + if (task.Wait(WAIT_TIME)) { - var task = Task.Run(() => _logLineFx(lineNum)); - if (task.Wait(WAIT_TIME)) - { - result = task.Result; - _isFastFailOnGetLogLine = false; - } - else - { - _isFastFailOnGetLogLine = true; - _logger.Debug("No result after {0}ms. Returning .", WAIT_TIME); - } + result = task.Result; + _isFastFailOnGetLogLine = false; } else { - _logger.Debug("Fast failing GetLogLine()"); - if (!_isFailModeCheckCallPending) - { - _isFailModeCheckCallPending = true; - var logLine = await _logLineFx(lineNum); - GetLineFinishedCallback(logLine); - } + _isFastFailOnGetLogLine = true; + _logger.Debug("No result after {0}ms. Returning .", WAIT_TIME); } - - return result; } - - /// - /// Returns the file name of the actual file for the given line. Needed for MultiFile. - /// - /// - /// - public string GetLogFileNameForLine(int lineNum) + else { - AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); - string fileName = logBuffer?.FileInfo.FullName; - ReleaseBufferListReaderLock(); - return fileName; + _logger.Debug("Fast failing GetLogLine()"); + if (!_isFailModeCheckCallPending) + { + _isFailModeCheckCallPending = true; + var logLine = await _logLineFx(lineNum); + GetLineFinishedCallback(logLine); + } } - /// - /// Returns the ILogFileInfo for the actual file for the given line. Needed for MultiFile. - /// - /// - /// - public ILogFileInfo GetLogFileInfoForLine(int lineNum) - { - AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); - ILogFileInfo info = logBuffer?.FileInfo; - ReleaseBufferListReaderLock(); - return info; - } + return result; + } + + /// + /// Returns the file name of the actual file for the given line. Needed for MultiFile. + /// + /// + /// + public string GetLogFileNameForLine (int lineNum) + { + AcquireBufferListReaderLock(); + LogBuffer logBuffer = GetBufferForLine(lineNum); + string fileName = logBuffer?.FileInfo.FullName; + ReleaseBufferListReaderLock(); + return fileName; + } + + /// + /// Returns the ILogFileInfo for the actual file for the given line. Needed for MultiFile. + /// + /// + /// + public ILogFileInfo GetLogFileInfoForLine (int lineNum) + { + AcquireBufferListReaderLock(); + LogBuffer logBuffer = GetBufferForLine(lineNum); + ILogFileInfo info = logBuffer?.FileInfo; + ReleaseBufferListReaderLock(); + return info; + } - /// - /// Returns the line number (starting from the given number) where the next multi file - /// starts. - /// - /// - /// - public int GetNextMultiFileLine(int lineNum) + /// + /// Returns the line number (starting from the given number) where the next multi file + /// starts. + /// + /// + /// + public int GetNextMultiFileLine (int lineNum) + { + int result = -1; + AcquireBufferListReaderLock(); + LogBuffer logBuffer = GetBufferForLine(lineNum); + if (logBuffer != null) { - int result = -1; - AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); - if (logBuffer != null) + int index = _bufferList.IndexOf(logBuffer); + if (index != -1) { - int index = _bufferList.IndexOf(logBuffer); - if (index != -1) + for (int i = index; i < _bufferList.Count; ++i) { - for (int i = index; i < _bufferList.Count; ++i) + if (_bufferList[i].FileInfo != logBuffer.FileInfo) { - if (_bufferList[i].FileInfo != logBuffer.FileInfo) - { - result = _bufferList[i].StartLine; - break; - } + result = _bufferList[i].StartLine; + break; } } } - - ReleaseBufferListReaderLock(); - return result; } - public int GetPrevMultiFileLine(int lineNum) + ReleaseBufferListReaderLock(); + return result; + } + + public int GetPrevMultiFileLine (int lineNum) + { + int result = -1; + AcquireBufferListReaderLock(); + LogBuffer logBuffer = GetBufferForLine(lineNum); + if (logBuffer != null) { - int result = -1; - AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); - if (logBuffer != null) + int index = _bufferList.IndexOf(logBuffer); + if (index != -1) { - int index = _bufferList.IndexOf(logBuffer); - if (index != -1) + for (int i = index; i >= 0; --i) { - for (int i = index; i >= 0; --i) + if (_bufferList[i].FileInfo != logBuffer.FileInfo) { - if (_bufferList[i].FileInfo != logBuffer.FileInfo) - { - result = _bufferList[i].StartLine + _bufferList[i].LineCount; - break; - } + result = _bufferList[i].StartLine + _bufferList[i].LineCount; + break; } } } + } - ReleaseBufferListReaderLock(); - return result; - } - - /// - /// Returns the actual line number in the file for the given 'virtual line num'. - /// This is needed for multi file mode. 'Virtual' means that the given line num is a line - /// number in the collections of the files currently viewed together in multi file mode as one large virtual file. - /// This method finds the real file for the line number and maps the line number to the correct position - /// in that file. This is needed when launching external tools to provide correct line number arguments. - /// - /// - /// - public int GetRealLineNumForVirtualLineNum(int lineNum) - { - AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); - int result = -1; + ReleaseBufferListReaderLock(); + return result; + } + + /// + /// Returns the actual line number in the file for the given 'virtual line num'. + /// This is needed for multi file mode. 'Virtual' means that the given line num is a line + /// number in the collections of the files currently viewed together in multi file mode as one large virtual file. + /// This method finds the real file for the line number and maps the line number to the correct position + /// in that file. This is needed when launching external tools to provide correct line number arguments. + /// + /// + /// + public int GetRealLineNumForVirtualLineNum (int lineNum) + { + AcquireBufferListReaderLock(); + LogBuffer logBuffer = GetBufferForLine(lineNum); + int result = -1; + if (logBuffer != null) + { + logBuffer = GetFirstBufferForFileByLogBuffer(logBuffer); if (logBuffer != null) { - logBuffer = GetFirstBufferForFileByLogBuffer(logBuffer); - if (logBuffer != null) - { - result = lineNum - logBuffer.StartLine; - } + result = lineNum - logBuffer.StartLine; } - - ReleaseBufferListReaderLock(); - return result; } - public void StartMonitoring() - { - _logger.Info("startMonitoring()"); - _monitorTask = Task.Run(MonitorThreadProc, cts.Token); - _shouldStop = false; - } + ReleaseBufferListReaderLock(); + return result; + } - public void StopMonitoring() - { - _logger.Info("stopMonitoring()"); - _shouldStop = true; + public void StartMonitoring () + { + _logger.Info("startMonitoring()"); + _monitorTask = Task.Run(MonitorThreadProc, cts.Token); + _shouldStop = false; + } + + public void StopMonitoring () + { + _logger.Info("stopMonitoring()"); + _shouldStop = true; - Thread.Sleep(_watchedILogFileInfo.PollInterval); // leave time for the threads to stop by themselves + Thread.Sleep(_watchedILogFileInfo.PollInterval); // leave time for the threads to stop by themselves - if (_monitorTask != null) + if (_monitorTask != null) + { + if (_monitorTask.Status == TaskStatus.Running) // if thread has not finished, abort it { - if (_monitorTask.Status == TaskStatus.Running) // if thread has not finished, abort it - { - cts.Cancel(); - } + cts.Cancel(); } + } - if (_garbageCollectorTask.IsCanceled == false) + if (_garbageCollectorTask.IsCanceled == false) + { + if (_garbageCollectorTask.Status == TaskStatus.Running) // if thread has not finished, abort it { - if (_garbageCollectorTask.Status == TaskStatus.Running) // if thread has not finished, abort it - { - cts.Cancel(); - } + cts.Cancel(); } - - //this.loadThread = null; - //_monitorThread = null; - //_garbageCollectorThread = null; // preventive call - CloseFiles(); } - /// - /// calls stopMonitoring() in a background thread and returns to the caller immediately. - /// This is useful for a fast responding GUI (e.g. when closing a file tab) - /// - public void StopMonitoringAsync() - { - Task task = Task.Run(StopMonitoring); + //this.loadThread = null; + //_monitorThread = null; + //_garbageCollectorThread = null; // preventive call + CloseFiles(); + } - //Thread stopperThread = new(new ThreadStart(StopMonitoring)) - //{ - // IsBackground = true - //}; - //stopperThread.Start(); - } + /// + /// calls stopMonitoring() in a background thread and returns to the caller immediately. + /// This is useful for a fast responding GUI (e.g. when closing a file tab) + /// + public void StopMonitoringAsync () + { + Task task = Task.Run(StopMonitoring); + + //Thread stopperThread = new(new ThreadStart(StopMonitoring)) + //{ + // IsBackground = true + //}; + //stopperThread.Start(); + } - /// - /// Deletes all buffer lines and disposes their content. Use only when the LogfileReader - /// is about to be closed! - /// - public void DeleteAllContent() + /// + /// Deletes all buffer lines and disposes their content. Use only when the LogfileReader + /// is about to be closed! + /// + public void DeleteAllContent () + { + if (_contentDeleted) { - if (_contentDeleted) - { - _logger.Debug("Buffers for {0} already deleted.", Util.GetNameFromPath(_fileName)); - return; - } + _logger.Debug("Buffers for {0} already deleted.", Util.GetNameFromPath(_fileName)); + return; + } - _logger.Info("Deleting all log buffers for {0}. Used mem: {1:N0}", Util.GetNameFromPath(_fileName), GC.GetTotalMemory(true)); //TODO [Z] uh GC collect calls creepy - AcquireBufferListWriterLock(); - _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); - _disposeLock.AcquireWriterLock(Timeout.Infinite); + _logger.Info("Deleting all log buffers for {0}. Used mem: {1:N0}", Util.GetNameFromPath(_fileName), GC.GetTotalMemory(true)); //TODO [Z] uh GC collect calls creepy + AcquireBufferListWriterLock(); + _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); + _disposeLock.AcquireWriterLock(Timeout.Infinite); - foreach (LogBuffer logBuffer in _bufferList) + foreach (LogBuffer logBuffer in _bufferList) + { + if (!logBuffer.IsDisposed) { - if (!logBuffer.IsDisposed) - { - logBuffer.DisposeContent(); - } + logBuffer.DisposeContent(); } + } - _lruCacheDict.Clear(); - _bufferList.Clear(); + _lruCacheDict.Clear(); + _bufferList.Clear(); - _disposeLock.ReleaseWriterLock(); - _lruCacheDictLock.ReleaseWriterLock(); - ReleaseBufferListWriterLock(); - GC.Collect(); - _contentDeleted = true; - _logger.Info("Deleting complete. Used mem: {0:N0}", GC.GetTotalMemory(true)); //TODO [Z] uh GC collect calls creepy - } + _disposeLock.ReleaseWriterLock(); + _lruCacheDictLock.ReleaseWriterLock(); + ReleaseBufferListWriterLock(); + GC.Collect(); + _contentDeleted = true; + _logger.Info("Deleting complete. Used mem: {0:N0}", GC.GetTotalMemory(true)); //TODO [Z] uh GC collect calls creepy + } - /// - /// Explicit change the encoding. - /// - /// - public void ChangeEncoding(Encoding encoding) - { - CurrentEncoding = encoding; - EncodingOptions.Encoding = encoding; - ResetBufferCache(); - ClearLru(); - } + /// + /// Explicit change the encoding. + /// + /// + public void ChangeEncoding (Encoding encoding) + { + CurrentEncoding = encoding; + EncodingOptions.Encoding = encoding; + ResetBufferCache(); + ClearLru(); + } - /// - /// For unit tests only. - /// - /// - public IList GetLogFileInfoList() - { - return _logFileInfoList; - } + /// + /// For unit tests only. + /// + /// + public IList GetLogFileInfoList () + { + return _logFileInfoList; + } - /// - /// For unit tests only - /// - /// - public IList GetBufferList() - { - return _bufferList; - } + /// + /// For unit tests only + /// + /// + public IList GetBufferList () + { + return _bufferList; + } - #endregion + #endregion - #region Internals + #region Internals #if DEBUG - public void LogBufferInfoForLine(int lineNum) + public void LogBufferInfoForLine (int lineNum) + { + AcquireBufferListReaderLock(); + LogBuffer buffer = GetBufferForLine(lineNum); + if (buffer == null) { - AcquireBufferListReaderLock(); - LogBuffer buffer = GetBufferForLine(lineNum); - if (buffer == null) - { - ReleaseBufferListReaderLock(); - _logger.Error("Cannot find buffer for line {0}, file: {1}{2}", lineNum, _fileName, IsMultiFile ? " (MultiFile)" : ""); - return; - } - - _logger.Info("-----------------------------------"); - _disposeLock.AcquireReaderLock(Timeout.Infinite); - _logger.Info("Buffer info for line {0}", lineNum); - DumpBufferInfos(buffer); - _logger.Info("File pos for current line: {0}", buffer.GetFilePosForLineOfBlock(lineNum - buffer.StartLine)); - _disposeLock.ReleaseReaderLock(); - _logger.Info("-----------------------------------"); ReleaseBufferListReaderLock(); - } + _logger.Error("Cannot find buffer for line {0}, file: {1}{2}", lineNum, _fileName, IsMultiFile ? " (MultiFile)" : ""); + return; + } + + _logger.Info("-----------------------------------"); + _disposeLock.AcquireReaderLock(Timeout.Infinite); + _logger.Info("Buffer info for line {0}", lineNum); + DumpBufferInfos(buffer); + _logger.Info("File pos for current line: {0}", buffer.GetFilePosForLineOfBlock(lineNum - buffer.StartLine)); + _disposeLock.ReleaseReaderLock(); + _logger.Info("-----------------------------------"); + ReleaseBufferListReaderLock(); + } #endif #if DEBUG - public void LogBufferDiagnostic() - { - _logger.Info("-------- Buffer diagnostics -------"); - _lruCacheDictLock.AcquireReaderLock(Timeout.Infinite); - int cacheCount = _lruCacheDict.Count; - _logger.Info("LRU entries: {0}", cacheCount); - _lruCacheDictLock.ReleaseReaderLock(); - - AcquireBufferListReaderLock(); - _logger.Info("File: {0}\r\nBuffer count: {1}\r\nDisposed buffers: {2}", _fileName, _bufferList.Count, _bufferList.Count - cacheCount); - int lineNum = 0; - long disposeSum = 0; - long maxDispose = 0; - long minDispose = int.MaxValue; - for (int i = 0; i < _bufferList.Count; ++i) + public void LogBufferDiagnostic () + { + _logger.Info("-------- Buffer diagnostics -------"); + _lruCacheDictLock.AcquireReaderLock(Timeout.Infinite); + int cacheCount = _lruCacheDict.Count; + _logger.Info("LRU entries: {0}", cacheCount); + _lruCacheDictLock.ReleaseReaderLock(); + + AcquireBufferListReaderLock(); + _logger.Info("File: {0}\r\nBuffer count: {1}\r\nDisposed buffers: {2}", _fileName, _bufferList.Count, _bufferList.Count - cacheCount); + int lineNum = 0; + long disposeSum = 0; + long maxDispose = 0; + long minDispose = int.MaxValue; + for (int i = 0; i < _bufferList.Count; ++i) + { + LogBuffer buffer = _bufferList[i]; + _disposeLock.AcquireReaderLock(Timeout.Infinite); + if (buffer.StartLine != lineNum) { - LogBuffer buffer = _bufferList[i]; - _disposeLock.AcquireReaderLock(Timeout.Infinite); - if (buffer.StartLine != lineNum) - { - _logger.Error("Start line of buffer is: {0}, expected: {1}", buffer.StartLine, lineNum); - _logger.Info("Info of buffer follows:"); - DumpBufferInfos(buffer); - } - - lineNum += buffer.LineCount; - disposeSum += buffer.DisposeCount; - maxDispose = Math.Max(maxDispose, buffer.DisposeCount); - minDispose = Math.Min(minDispose, buffer.DisposeCount); - _disposeLock.ReleaseReaderLock(); + _logger.Error("Start line of buffer is: {0}, expected: {1}", buffer.StartLine, lineNum); + _logger.Info("Info of buffer follows:"); + DumpBufferInfos(buffer); } - ReleaseBufferListReaderLock(); - _logger.Info("Dispose count sum is: {0}\r\nMin dispose count is: {1}\r\nMax dispose count is: {2}\r\n-----------------------------------", disposeSum, minDispose, maxDispose); + lineNum += buffer.LineCount; + disposeSum += buffer.DisposeCount; + maxDispose = Math.Max(maxDispose, buffer.DisposeCount); + minDispose = Math.Min(minDispose, buffer.DisposeCount); + _disposeLock.ReleaseReaderLock(); } + ReleaseBufferListReaderLock(); + _logger.Info("Dispose count sum is: {0}\r\nMin dispose count is: {1}\r\nMax dispose count is: {2}\r\n-----------------------------------", disposeSum, minDispose, maxDispose); + } + #endif - #endregion + #endregion + + #region Private Methods - #region Private Methods + private ILogFileInfo AddFile (string fileName) + { + _logger.Info("Adding file to ILogFileInfoList: " + fileName); + ILogFileInfo info = GetLogFileInfo(fileName); + _logFileInfoList.Add(info); + return info; + } - private ILogFileInfo AddFile(string fileName) + private Task GetLogLineInternal (int lineNum) + { + if (_isDeleted) { - _logger.Info("Adding file to ILogFileInfoList: " + fileName); - ILogFileInfo info = GetLogFileInfo(fileName); - _logFileInfoList.Add(info); - return info; + _logger.Debug("Returning null for line {0} because file is deleted.", lineNum); + + // fast fail if dead file was detected. Prevents repeated lags in GUI thread caused by callbacks from control (e.g. repaint) + return null; } - private Task GetLogLineInternal(int lineNum) + AcquireBufferListReaderLock(); + LogBuffer logBuffer = GetBufferForLine(lineNum); + if (logBuffer == null) { - if (_isDeleted) - { - _logger.Debug("Returning null for line {0} because file is deleted.", lineNum); - - // fast fail if dead file was detected. Prevents repeated lags in GUI thread caused by callbacks from control (e.g. repaint) - return null; - } + ReleaseBufferListReaderLock(); + _logger.Error("Cannot find buffer for line {0}, file: {1}{2}", lineNum, _fileName, IsMultiFile ? " (MultiFile)" : ""); + return null; + } - AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); - if (logBuffer == null) + // disposeLock prevents that the garbage collector is disposing just in the moment we use the buffer + _disposeLock.AcquireReaderLock(Timeout.Infinite); + if (logBuffer.IsDisposed) + { + LockCookie cookie = _disposeLock.UpgradeToWriterLock(Timeout.Infinite); + lock (logBuffer.FileInfo) { - ReleaseBufferListReaderLock(); - _logger.Error("Cannot find buffer for line {0}, file: {1}{2}", lineNum, _fileName, IsMultiFile ? " (MultiFile)" : ""); - return null; + ReReadBuffer(logBuffer); } - // disposeLock prevents that the garbage collector is disposing just in the moment we use the buffer - _disposeLock.AcquireReaderLock(Timeout.Infinite); - if (logBuffer.IsDisposed) - { - LockCookie cookie = _disposeLock.UpgradeToWriterLock(Timeout.Infinite); - lock (logBuffer.FileInfo) - { - ReReadBuffer(logBuffer); - } + _disposeLock.DowngradeFromWriterLock(ref cookie); + } - _disposeLock.DowngradeFromWriterLock(ref cookie); - } + ILogLine line = logBuffer.GetLineOfBlock(lineNum - logBuffer.StartLine); + _disposeLock.ReleaseReaderLock(); + ReleaseBufferListReaderLock(); - ILogLine line = logBuffer.GetLineOfBlock(lineNum - logBuffer.StartLine); - _disposeLock.ReleaseReaderLock(); - ReleaseBufferListReaderLock(); + return Task.FromResult(line); + } - return Task.FromResult(line); - } + private void InitLruBuffers () + { + _bufferList = []; + _bufferLru = new List(_MAX_BUFFERS + 1); + //this.lruDict = new Dictionary(this.MAX_BUFFERS + 1); // key=startline, value = index in bufferLru + _lruCacheDict = new Dictionary(_MAX_BUFFERS + 1); + _lruCacheDictLock = new ReaderWriterLock(); + _bufferListLock = new ReaderWriterLock(); + _disposeLock = new ReaderWriterLock(); + } - private void InitLruBuffers() - { - _bufferList = []; - _bufferLru = new List(_MAX_BUFFERS + 1); - //this.lruDict = new Dictionary(this.MAX_BUFFERS + 1); // key=startline, value = index in bufferLru - _lruCacheDict = new Dictionary(_MAX_BUFFERS + 1); - _lruCacheDictLock = new ReaderWriterLock(); - _bufferListLock = new ReaderWriterLock(); - _disposeLock = new ReaderWriterLock(); - } + private void StartGCThread () + { + _garbageCollectorTask = Task.Run(GarbageCollectorThreadProc, cts.Token); + //_garbageCollectorThread = new Thread(new ThreadStart(GarbageCollectorThreadProc)); + //_garbageCollectorThread.IsBackground = true; + //_garbageCollectorThread.Start(); + } - private void StartGCThread() - { - _garbageCollectorTask = Task.Run(GarbageCollectorThreadProc, cts.Token); - //_garbageCollectorThread = new Thread(new ThreadStart(GarbageCollectorThreadProc)); - //_garbageCollectorThread.IsBackground = true; - //_garbageCollectorThread.Start(); - } + private void ResetBufferCache () + { + FileSize = 0; + LineCount = 0; + //this.lastReturnedLine = ""; + //this.lastReturnedLineNum = -1; + //this.lastReturnedLineNumForBuffer = -1; + } - private void ResetBufferCache() - { - FileSize = 0; - LineCount = 0; - //this.lastReturnedLine = ""; - //this.lastReturnedLineNum = -1; - //this.lastReturnedLineNumForBuffer = -1; - } + private void CloseFiles () + { + //foreach (ILogFileInfo info in this.ILogFileInfoList) + //{ + // info.CloseFile(); + //} + FileSize = 0; + LineCount = 0; + //this.lastReturnedLine = ""; + //this.lastReturnedLineNum = -1; + //this.lastReturnedLineNumForBuffer = -1; + } - private void CloseFiles() - { - //foreach (ILogFileInfo info in this.ILogFileInfoList) - //{ - // info.CloseFile(); - //} - FileSize = 0; - LineCount = 0; - //this.lastReturnedLine = ""; - //this.lastReturnedLineNum = -1; - //this.lastReturnedLineNumForBuffer = -1; - } + private ILogFileInfo GetLogFileInfo (string fileNameOrUri) //TODO: I changed to static + { + //TODO this must be fixed and should be given to the logfilereader not just called (https://github.com/LogExperts/LogExpert/issues/402) + IFileSystemPlugin fs = _pluginRegistry.FindFileSystemForUri(fileNameOrUri) ?? throw new LogFileException("No file system plugin found for " + fileNameOrUri); + ILogFileInfo logFileInfo = fs.GetLogfileInfo(fileNameOrUri); + return logFileInfo ?? throw new LogFileException("Cannot find " + fileNameOrUri); + } - private ILogFileInfo GetLogFileInfo(string fileNameOrUri) //TODO: I changed to static + private void ReplaceBufferInfos (ILogFileInfo oldLogFileInfo, ILogFileInfo newLogFileInfo) + { + _logger.Debug("ReplaceBufferInfos() " + oldLogFileInfo.FullName + " -> " + newLogFileInfo.FullName); + AcquireBufferListReaderLock(); + foreach (LogBuffer buffer in _bufferList) { - //TODO this must be fixed and should be given to the logfilereader not just called - IFileSystemPlugin fs = _pluginRegistry.FindFileSystemForUri(fileNameOrUri) ?? throw new LogFileException("No file system plugin found for " + fileNameOrUri); - ILogFileInfo logFileInfo = fs.GetLogfileInfo(fileNameOrUri); - return logFileInfo ?? throw new LogFileException("Cannot find " + fileNameOrUri); + if (buffer.FileInfo == oldLogFileInfo) + { + _logger.Debug("Buffer with startLine={0}, lineCount={1}, filePos={2}, size={3} gets new filename {4}", buffer.StartLine, buffer.LineCount, buffer.StartPos, buffer.Size, newLogFileInfo.FullName); + buffer.FileInfo = newLogFileInfo; + } } - private void ReplaceBufferInfos(ILogFileInfo oldLogFileInfo, ILogFileInfo newLogFileInfo) + ReleaseBufferListReaderLock(); + } + + private LogBuffer DeleteBuffersForInfo (ILogFileInfo ILogFileInfo, bool matchNamesOnly) + { + _logger.Info("Deleting buffers for file {0}", ILogFileInfo.FullName); + LogBuffer lastRemovedBuffer = null; + IList deleteList = []; + AcquireBufferListWriterLock(); + _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); + if (matchNamesOnly) { - _logger.Debug("ReplaceBufferInfos() " + oldLogFileInfo.FullName + " -> " + newLogFileInfo.FullName); - AcquireBufferListReaderLock(); foreach (LogBuffer buffer in _bufferList) { - if (buffer.FileInfo == oldLogFileInfo) + if (buffer.FileInfo.FullName.ToLower().Equals(ILogFileInfo.FullName.ToLower())) { - _logger.Debug("Buffer with startLine={0}, lineCount={1}, filePos={2}, size={3} gets new filename {4}", buffer.StartLine, buffer.LineCount, buffer.StartPos, buffer.Size, newLogFileInfo.FullName); - buffer.FileInfo = newLogFileInfo; + lastRemovedBuffer = buffer; + deleteList.Add(buffer); } } - - ReleaseBufferListReaderLock(); } - - private LogBuffer DeleteBuffersForInfo(ILogFileInfo ILogFileInfo, bool matchNamesOnly) + else { - _logger.Info("Deleting buffers for file {0}", ILogFileInfo.FullName); - LogBuffer lastRemovedBuffer = null; - IList deleteList = []; - AcquireBufferListWriterLock(); - _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); - if (matchNamesOnly) - { - foreach (LogBuffer buffer in _bufferList) - { - if (buffer.FileInfo.FullName.ToLower().Equals(ILogFileInfo.FullName.ToLower())) - { - lastRemovedBuffer = buffer; - deleteList.Add(buffer); - } - } - } - else + foreach (LogBuffer buffer in _bufferList) { - foreach (LogBuffer buffer in _bufferList) + if (buffer.FileInfo == ILogFileInfo) { - if (buffer.FileInfo == ILogFileInfo) - { - lastRemovedBuffer = buffer; - deleteList.Add(buffer); - } + lastRemovedBuffer = buffer; + deleteList.Add(buffer); } } + } - foreach (LogBuffer buffer in deleteList) - { - RemoveFromBufferList(buffer); - } - - _lruCacheDictLock.ReleaseWriterLock(); - ReleaseBufferListWriterLock(); - if (lastRemovedBuffer == null) - { - _logger.Info("lastRemovedBuffer is null"); - } - else - { - _logger.Info("lastRemovedBuffer: startLine={0}", lastRemovedBuffer.StartLine); - } - - return lastRemovedBuffer; + foreach (LogBuffer buffer in deleteList) + { + RemoveFromBufferList(buffer); } - /// - /// The caller must have writer locks for lruCache and buffer list! - /// - /// - private void RemoveFromBufferList(LogBuffer buffer) + _lruCacheDictLock.ReleaseWriterLock(); + ReleaseBufferListWriterLock(); + if (lastRemovedBuffer == null) + { + _logger.Info("lastRemovedBuffer is null"); + } + else { - Util.AssertTrue(_lruCacheDictLock.IsWriterLockHeld, "No writer lock for lru cache"); - Util.AssertTrue(_bufferListLock.IsWriterLockHeld, "No writer lock for buffer list"); - _lruCacheDict.Remove(buffer.StartLine); - _bufferList.Remove(buffer); + _logger.Info("lastRemovedBuffer: startLine={0}", lastRemovedBuffer.StartLine); } - private void ReadToBufferList(ILogFileInfo logFileInfo, long filePos, int startLine) + return lastRemovedBuffer; + } + + /// + /// The caller must have writer locks for lruCache and buffer list! + /// + /// + private void RemoveFromBufferList (LogBuffer buffer) + { + Util.AssertTrue(_lruCacheDictLock.IsWriterLockHeld, "No writer lock for lru cache"); + Util.AssertTrue(_bufferListLock.IsWriterLockHeld, "No writer lock for buffer list"); + _lruCacheDict.Remove(buffer.StartLine); + _bufferList.Remove(buffer); + } + + private void ReadToBufferList (ILogFileInfo logFileInfo, long filePos, int startLine) + { + try { + using Stream fileStream = logFileInfo.OpenStream(); try { - using Stream fileStream = logFileInfo.OpenStream(); - try + using ILogStreamReader reader = GetLogStreamReader(fileStream, EncodingOptions, UseNewReader); + reader.Position = filePos; + _fileLength = logFileInfo.Length; + + int lineNum = startLine; + LogBuffer logBuffer; + AcquireBufferListReaderLock(); + if (_bufferList.Count == 0) + { + logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER); + logBuffer.StartLine = startLine; + logBuffer.StartPos = filePos; + LockCookie cookie = UpgradeBufferListLockToWriter(); + AddBufferToList(logBuffer); + DowngradeBufferListLockFromWriter(ref cookie); + } + else { - using ILogStreamReader reader = GetLogStreamReader(fileStream, EncodingOptions, UseNewReader); - reader.Position = filePos; - _fileLength = logFileInfo.Length; - - int lineNum = startLine; - LogBuffer logBuffer; - AcquireBufferListReaderLock(); - if (_bufferList.Count == 0) + logBuffer = _bufferList[_bufferList.Count - 1]; + + if (!logBuffer.FileInfo.FullName.Equals(logFileInfo.FullName)) { logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER); logBuffer.StartLine = startLine; @@ -943,891 +958,877 @@ private void ReadToBufferList(ILogFileInfo logFileInfo, long filePos, int startL AddBufferToList(logBuffer); DowngradeBufferListLockFromWriter(ref cookie); } - else + + _disposeLock.AcquireReaderLock(Timeout.Infinite); + if (logBuffer.IsDisposed) { - logBuffer = _bufferList[_bufferList.Count - 1]; + LockCookie cookie = _disposeLock.UpgradeToWriterLock(Timeout.Infinite); + ReReadBuffer(logBuffer); + _disposeLock.DowngradeFromWriterLock(ref cookie); + } - if (!logBuffer.FileInfo.FullName.Equals(logFileInfo.FullName)) - { - logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER); - logBuffer.StartLine = startLine; - logBuffer.StartPos = filePos; - LockCookie cookie = UpgradeBufferListLockToWriter(); - AddBufferToList(logBuffer); - DowngradeBufferListLockFromWriter(ref cookie); - } + _disposeLock.ReleaseReaderLock(); + } - _disposeLock.AcquireReaderLock(Timeout.Infinite); - if (logBuffer.IsDisposed) - { - LockCookie cookie = _disposeLock.UpgradeToWriterLock(Timeout.Infinite); - ReReadBuffer(logBuffer); - _disposeLock.DowngradeFromWriterLock(ref cookie); - } + Monitor.Enter(logBuffer); // Lock the buffer + ReleaseBufferListReaderLock(); + int lineCount = logBuffer.LineCount; + int droppedLines = logBuffer.PrevBuffersDroppedLinesSum; + filePos = reader.Position; - _disposeLock.ReleaseReaderLock(); + while (ReadLine(reader, logBuffer.StartLine + logBuffer.LineCount, logBuffer.StartLine + logBuffer.LineCount + droppedLines, out var line)) + { + LogLine logLine = new(); + if (_shouldStop) + { + Monitor.Exit(logBuffer); + return; } - Monitor.Enter(logBuffer); // Lock the buffer - ReleaseBufferListReaderLock(); - int lineCount = logBuffer.LineCount; - int droppedLines = logBuffer.PrevBuffersDroppedLinesSum; - filePos = reader.Position; - - while (ReadLine(reader, logBuffer.StartLine + logBuffer.LineCount, logBuffer.StartLine + logBuffer.LineCount + droppedLines, out var line)) + if (line == null) { - LogLine logLine = new(); - if (_shouldStop) - { - Monitor.Exit(logBuffer); - return; - } - - if (line == null) - { - logBuffer.DroppedLinesCount += 1; - droppedLines++; - continue; - } - - lineCount++; - if (lineCount > _MAX_LINES_PER_BUFFER && reader.IsBufferComplete) - { - OnLoadFile(new LoadFileEventArgs(logFileInfo.FullName, filePos, false, logFileInfo.Length, false)); - - Monitor.Exit(logBuffer); - logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER); - Monitor.Enter(logBuffer); - logBuffer.StartLine = lineNum; - logBuffer.StartPos = filePos; - logBuffer.PrevBuffersDroppedLinesSum = droppedLines; - AcquireBufferListWriterLock(); - AddBufferToList(logBuffer); - ReleaseBufferListWriterLock(); - lineCount = 1; - } - - logLine.FullLine = line; - logLine.LineNumber = logBuffer.StartLine + logBuffer.LineCount; - - logBuffer.AddLine(logLine, filePos); - filePos = reader.Position; - lineNum++; + logBuffer.DroppedLinesCount += 1; + droppedLines++; + continue; } - logBuffer.Size = filePos - logBuffer.StartPos; - Monitor.Exit(logBuffer); - _isLineCountDirty = true; - FileSize = reader.Position; - CurrentEncoding = reader.Encoding; // Reader may have detected another encoding - if (!_shouldStop) + lineCount++; + if (lineCount > _MAX_LINES_PER_BUFFER && reader.IsBufferComplete) { - OnLoadFile(new LoadFileEventArgs(logFileInfo.FullName, filePos, true, _fileLength, false)); - // Fire "Ready" Event + OnLoadFile(new LoadFileEventArgs(logFileInfo.FullName, filePos, false, logFileInfo.Length, false)); + + Monitor.Exit(logBuffer); + logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER); + Monitor.Enter(logBuffer); + logBuffer.StartLine = lineNum; + logBuffer.StartPos = filePos; + logBuffer.PrevBuffersDroppedLinesSum = droppedLines; + AcquireBufferListWriterLock(); + AddBufferToList(logBuffer); + ReleaseBufferListWriterLock(); + lineCount = 1; } + + logLine.FullLine = line; + logLine.LineNumber = logBuffer.StartLine + logBuffer.LineCount; + + logBuffer.AddLine(logLine, filePos); + filePos = reader.Position; + lineNum++; } - catch (IOException ioex) + + logBuffer.Size = filePos - logBuffer.StartPos; + Monitor.Exit(logBuffer); + _isLineCountDirty = true; + FileSize = reader.Position; + CurrentEncoding = reader.Encoding; // Reader may have detected another encoding + if (!_shouldStop) { - _logger.Warn(ioex); + OnLoadFile(new LoadFileEventArgs(logFileInfo.FullName, filePos, true, _fileLength, false)); + // Fire "Ready" Event } } - catch (IOException fe) + catch (IOException ioex) { - _logger.Warn(fe, "IOException: "); - _isDeleted = true; - LineCount = 0; - FileSize = 0; - OnFileNotFound(); // notify LogWindow + _logger.Warn(ioex); } } - - private void AddBufferToList(LogBuffer logBuffer) + catch (IOException fe) { + _logger.Warn(fe, "IOException: "); + _isDeleted = true; + LineCount = 0; + FileSize = 0; + OnFileNotFound(); // notify LogWindow + } + } + + private void AddBufferToList (LogBuffer logBuffer) + { #if DEBUG - _logger.Debug("AddBufferToList(): {0}/{1}/{2}", logBuffer.StartLine, logBuffer.LineCount, logBuffer.FileInfo.FullName); + _logger.Debug("AddBufferToList(): {0}/{1}/{2}", logBuffer.StartLine, logBuffer.LineCount, logBuffer.FileInfo.FullName); #endif - _bufferList.Add(logBuffer); - //UpdateLru(logBuffer); - UpdateLruCache(logBuffer); - } + _bufferList.Add(logBuffer); + //UpdateLru(logBuffer); + UpdateLruCache(logBuffer); + } - private void UpdateLruCache(LogBuffer logBuffer) + private void UpdateLruCache (LogBuffer logBuffer) + { + _lruCacheDictLock.AcquireReaderLock(Timeout.Infinite); + if (_lruCacheDict.TryGetValue(logBuffer.StartLine, out LogBufferCacheEntry cacheEntry)) { - _lruCacheDictLock.AcquireReaderLock(Timeout.Infinite); - if (_lruCacheDict.TryGetValue(logBuffer.StartLine, out LogBufferCacheEntry cacheEntry)) - { - cacheEntry.Touch(); - } - else + cacheEntry.Touch(); + } + else + { + LockCookie cookie = _lruCacheDictLock.UpgradeToWriterLock(Timeout.Infinite); + if (!_lruCacheDict.TryGetValue(logBuffer.StartLine, out cacheEntry) + ) // #536: re-test, because multiple threads may have been waiting for writer lock { - LockCookie cookie = _lruCacheDictLock.UpgradeToWriterLock(Timeout.Infinite); - if (!_lruCacheDict.TryGetValue(logBuffer.StartLine, out cacheEntry) - ) // #536: re-test, because multiple threads may have been waiting for writer lock + cacheEntry = new LogBufferCacheEntry(); + cacheEntry.LogBuffer = logBuffer; + try { - cacheEntry = new LogBufferCacheEntry(); - cacheEntry.LogBuffer = logBuffer; - try + _lruCacheDict.Add(logBuffer.StartLine, cacheEntry); + } + catch (ArgumentException e) + { + _logger.Error(e, "Error in LRU cache: " + e.Message); +#if DEBUG // there seems to be a bug with double added key + + _logger.Info("Added buffer:"); + DumpBufferInfos(logBuffer); + if (_lruCacheDict.TryGetValue(logBuffer.StartLine, out LogBufferCacheEntry existingEntry)) { - _lruCacheDict.Add(logBuffer.StartLine, cacheEntry); + _logger.Info("Existing buffer: "); + DumpBufferInfos(existingEntry.LogBuffer); } - catch (ArgumentException e) + else { - _logger.Error(e, "Error in LRU cache: " + e.Message); -#if DEBUG // there seems to be a bug with double added key - - _logger.Info("Added buffer:"); - DumpBufferInfos(logBuffer); - if (_lruCacheDict.TryGetValue(logBuffer.StartLine, out LogBufferCacheEntry existingEntry)) - { - _logger.Info("Existing buffer: "); - DumpBufferInfos(existingEntry.LogBuffer); - } - else - { - _logger.Warn("Ooops? Cannot find the already existing entry in LRU."); - } -#endif - _lruCacheDictLock.ReleaseLock(); - throw; + _logger.Warn("Ooops? Cannot find the already existing entry in LRU."); } +#endif + _lruCacheDictLock.ReleaseLock(); + throw; } - - _lruCacheDictLock.DowngradeFromWriterLock(ref cookie); } - _lruCacheDictLock.ReleaseReaderLock(); + _lruCacheDictLock.DowngradeFromWriterLock(ref cookie); } - /// - /// Sets a new start line in the given buffer and updates the LRU cache, if the buffer - /// is present in the cache. The caller must have write lock for 'lruCacheDictLock'; - /// - /// - /// - private void SetNewStartLineForBuffer(LogBuffer logBuffer, int newLineNum) + _lruCacheDictLock.ReleaseReaderLock(); + } + + /// + /// Sets a new start line in the given buffer and updates the LRU cache, if the buffer + /// is present in the cache. The caller must have write lock for 'lruCacheDictLock'; + /// + /// + /// + private void SetNewStartLineForBuffer (LogBuffer logBuffer, int newLineNum) + { + Util.AssertTrue(_lruCacheDictLock.IsWriterLockHeld, "No writer lock for lru cache"); + if (_lruCacheDict.ContainsKey(logBuffer.StartLine)) { - Util.AssertTrue(_lruCacheDictLock.IsWriterLockHeld, "No writer lock for lru cache"); - if (_lruCacheDict.ContainsKey(logBuffer.StartLine)) - { - _lruCacheDict.Remove(logBuffer.StartLine); - logBuffer.StartLine = newLineNum; - LogBufferCacheEntry cacheEntry = new(); - cacheEntry.LogBuffer = logBuffer; - _lruCacheDict.Add(logBuffer.StartLine, cacheEntry); - } - else - { - logBuffer.StartLine = newLineNum; - } + _lruCacheDict.Remove(logBuffer.StartLine); + logBuffer.StartLine = newLineNum; + LogBufferCacheEntry cacheEntry = new(); + cacheEntry.LogBuffer = logBuffer; + _lruCacheDict.Add(logBuffer.StartLine, cacheEntry); } - - private void GarbageCollectLruCache() + else { + logBuffer.StartLine = newLineNum; + } + } + + private void GarbageCollectLruCache () + { #if DEBUG - long startTime = Environment.TickCount; + long startTime = Environment.TickCount; #endif - _logger.Debug("Starting garbage collection"); - int threshold = 10; - _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); - int diff = 0; - if (_lruCacheDict.Count - (_MAX_BUFFERS + threshold) > 0) - { - diff = _lruCacheDict.Count - _MAX_BUFFERS; + _logger.Debug("Starting garbage collection"); + int threshold = 10; + _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); + int diff = 0; + if (_lruCacheDict.Count - (_MAX_BUFFERS + threshold) > 0) + { + diff = _lruCacheDict.Count - _MAX_BUFFERS; #if DEBUG - if (diff > 0) - { - _logger.Info("Removing {0} entries from LRU cache for {1}", diff, Util.GetNameFromPath(_fileName)); - } + if (diff > 0) + { + _logger.Info("Removing {0} entries from LRU cache for {1}", diff, Util.GetNameFromPath(_fileName)); + } #endif - SortedList useSorterList = []; - // sort by usage counter - foreach (LogBufferCacheEntry entry in _lruCacheDict.Values) + SortedList useSorterList = []; + // sort by usage counter + foreach (LogBufferCacheEntry entry in _lruCacheDict.Values) + { + if (!useSorterList.ContainsKey(entry.LastUseTimeStamp)) { - if (!useSorterList.ContainsKey(entry.LastUseTimeStamp)) - { - useSorterList.Add(entry.LastUseTimeStamp, entry.LogBuffer.StartLine); - } + useSorterList.Add(entry.LastUseTimeStamp, entry.LogBuffer.StartLine); } + } - // remove first entries (least usage) - _disposeLock.AcquireWriterLock(Timeout.Infinite); - for (int i = 0; i < diff; ++i) + // remove first entries (least usage) + _disposeLock.AcquireWriterLock(Timeout.Infinite); + for (int i = 0; i < diff; ++i) + { + if (i >= useSorterList.Count) { - if (i >= useSorterList.Count) - { - break; - } - - int startLine = useSorterList.Values[i]; - LogBufferCacheEntry entry = _lruCacheDict[startLine]; - _lruCacheDict.Remove(startLine); - entry.LogBuffer.DisposeContent(); + break; } - _disposeLock.ReleaseWriterLock(); + int startLine = useSorterList.Values[i]; + LogBufferCacheEntry entry = _lruCacheDict[startLine]; + _lruCacheDict.Remove(startLine); + entry.LogBuffer.DisposeContent(); } - _lruCacheDictLock.ReleaseWriterLock(); + _disposeLock.ReleaseWriterLock(); + } + + _lruCacheDictLock.ReleaseWriterLock(); #if DEBUG - if (diff > 0) - { - long endTime = Environment.TickCount; - _logger.Info("Garbage collector time: " + (endTime - startTime) + " ms."); - } -#endif + if (diff > 0) + { + long endTime = Environment.TickCount; + _logger.Info("Garbage collector time: " + (endTime - startTime) + " ms."); } +#endif + } - private void GarbageCollectorThreadProc() + private void GarbageCollectorThreadProc () + { + while (!_shouldStop) { - while (!_shouldStop) + try + { + Thread.Sleep(10000); + } + catch (Exception) { - try - { - Thread.Sleep(10000); - } - catch (Exception) - { - } - - GarbageCollectLruCache(); } - } - - // private void UpdateLru(LogBuffer logBuffer) - // { - // lock (this.monitor) - // { - // int index; - // if (this.lruDict.TryGetValue(logBuffer.StartLine, out index)) - // { - // RemoveBufferFromLru(logBuffer, index); - // AddBufferToLru(logBuffer); - // } - // else - // { - // if (this.bufferLru.Count > MAX_BUFFERS - 1) - // { - // LogBuffer looser = this.bufferLru[0]; - // if (looser != null) - // { - //#if DEBUG - // _logger.logDebug("Disposing buffer: " + looser.StartLine + "/" + looser.LineCount + "/" + looser.FileInfo.FileName); - //#endif - // looser.DisposeContent(); - // RemoveBufferFromLru(looser); - // } - // } - // AddBufferToLru(logBuffer); - // } - // } - // } - - ///// - ///// Removes a LogBuffer from the LRU. Note that the LogBuffer is searched in the lruDict - ///// via StartLine. So this property must have a consistent value. - ///// - ///// - //private void RemoveBufferFromLru(LogBuffer buffer) - //{ - // int index; - // lock (this.monitor) - // { - // if (this.lruDict.TryGetValue(buffer.StartLine, out index)) - // { - // RemoveBufferFromLru(buffer, index); - // } - // } - //} - ///// - ///// Removes a LogBuffer from the LRU with known index. Note that the LogBuffer is searched in the lruDict - ///// via StartLine. So this property must have a consistent value. - ///// - ///// - ///// - //private void RemoveBufferFromLru(LogBuffer buffer, int index) - //{ - // lock (this.monitor) - // { - // this.bufferLru.RemoveAt(index); - // this.lruDict.Remove(buffer.StartLine); - // // adjust indizes, they have changed because of the remove - // for (int i = index; i < this.bufferLru.Count; ++i) - // { - // this.lruDict[this.bufferLru[i].StartLine] = this.lruDict[this.bufferLru[i].StartLine] - 1; - // } - // } - //} + GarbageCollectLruCache(); + } + } - //private void AddBufferToLru(LogBuffer logBuffer) + // private void UpdateLru(LogBuffer logBuffer) + // { + // lock (this.monitor) + // { + // int index; + // if (this.lruDict.TryGetValue(logBuffer.StartLine, out index)) + // { + // RemoveBufferFromLru(logBuffer, index); + // AddBufferToLru(logBuffer); + // } + // else + // { + // if (this.bufferLru.Count > MAX_BUFFERS - 1) + // { + // LogBuffer looser = this.bufferLru[0]; + // if (looser != null) + // { + //#if DEBUG + // _logger.logDebug("Disposing buffer: " + looser.StartLine + "/" + looser.LineCount + "/" + looser.FileInfo.FileName); + //#endif + // looser.DisposeContent(); + // RemoveBufferFromLru(looser); + // } + // } + // AddBufferToLru(logBuffer); + // } + // } + // } + + ///// + ///// Removes a LogBuffer from the LRU. Note that the LogBuffer is searched in the lruDict + ///// via StartLine. So this property must have a consistent value. + ///// + ///// + //private void RemoveBufferFromLru(LogBuffer buffer) + //{ + // int index; + // lock (this.monitor) + // { + // if (this.lruDict.TryGetValue(buffer.StartLine, out index)) + // { + // RemoveBufferFromLru(buffer, index); + // } + // } + //} + + ///// + ///// Removes a LogBuffer from the LRU with known index. Note that the LogBuffer is searched in the lruDict + ///// via StartLine. So this property must have a consistent value. + ///// + ///// + ///// + //private void RemoveBufferFromLru(LogBuffer buffer, int index) + //{ + // lock (this.monitor) + // { + // this.bufferLru.RemoveAt(index); + // this.lruDict.Remove(buffer.StartLine); + // // adjust indizes, they have changed because of the remove + // for (int i = index; i < this.bufferLru.Count; ++i) + // { + // this.lruDict[this.bufferLru[i].StartLine] = this.lruDict[this.bufferLru[i].StartLine] - 1; + // } + // } + //} + + //private void AddBufferToLru(LogBuffer logBuffer) + //{ + // lock (this.monitor) + // { + // this.bufferLru.Add(logBuffer); + // int newIndex = this.bufferLru.Count - 1; + // this.lruDict[logBuffer.StartLine] = newIndex; + // } + //} + + private void ClearLru () + { + //lock (this.monitor) //{ - // lock (this.monitor) + // foreach (LogBuffer buffer in this.bufferLru) // { - // this.bufferLru.Add(logBuffer); - // int newIndex = this.bufferLru.Count - 1; - // this.lruDict[logBuffer.StartLine] = newIndex; + // buffer.DisposeContent(); // } + // this.bufferLru.Clear(); + // this.lruDict.Clear(); //} - - private void ClearLru() - { - //lock (this.monitor) - //{ - // foreach (LogBuffer buffer in this.bufferLru) - // { - // buffer.DisposeContent(); - // } - // this.bufferLru.Clear(); - // this.lruDict.Clear(); - //} - _logger.Info("Clearing LRU cache."); - _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); - _disposeLock.AcquireWriterLock(Timeout.Infinite); - foreach (LogBufferCacheEntry entry in _lruCacheDict.Values) - { - entry.LogBuffer.DisposeContent(); - } - - _lruCacheDict.Clear(); - _disposeLock.ReleaseWriterLock(); - _lruCacheDictLock.ReleaseWriterLock(); - _logger.Info("Clearing done."); + _logger.Info("Clearing LRU cache."); + _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); + _disposeLock.AcquireWriterLock(Timeout.Infinite); + foreach (LogBufferCacheEntry entry in _lruCacheDict.Values) + { + entry.LogBuffer.DisposeContent(); } - private void ReReadBuffer(LogBuffer logBuffer) - { + _lruCacheDict.Clear(); + _disposeLock.ReleaseWriterLock(); + _lruCacheDictLock.ReleaseWriterLock(); + _logger.Info("Clearing done."); + } + + private void ReReadBuffer (LogBuffer logBuffer) + { #if DEBUG - _logger.Info("re-reading buffer: {0}/{1}/{2}", logBuffer.StartLine, logBuffer.LineCount, logBuffer.FileInfo.FullName); + _logger.Info("re-reading buffer: {0}/{1}/{2}", logBuffer.StartLine, logBuffer.LineCount, logBuffer.FileInfo.FullName); #endif + try + { + Monitor.Enter(logBuffer); + Stream fileStream = null; try { - Monitor.Enter(logBuffer); - Stream fileStream = null; - try - { - fileStream = logBuffer.FileInfo.OpenStream(); - } - catch (IOException e) - { - _logger.Warn(e); - return; - } + fileStream = logBuffer.FileInfo.OpenStream(); + } + catch (IOException e) + { + _logger.Warn(e); + return; + } - try - { - ILogStreamReader reader = GetLogStreamReader(fileStream, EncodingOptions, UseNewReader); + try + { + ILogStreamReader reader = GetLogStreamReader(fileStream, EncodingOptions, UseNewReader); - long filePos = logBuffer.StartPos; - reader.Position = logBuffer.StartPos; - int maxLinesCount = logBuffer.LineCount; - int lineCount = 0; - int dropCount = logBuffer.PrevBuffersDroppedLinesSum; - logBuffer.ClearLines(); + long filePos = logBuffer.StartPos; + reader.Position = logBuffer.StartPos; + int maxLinesCount = logBuffer.LineCount; + int lineCount = 0; + int dropCount = logBuffer.PrevBuffersDroppedLinesSum; + logBuffer.ClearLines(); - while (ReadLine(reader, logBuffer.StartLine + logBuffer.LineCount, logBuffer.StartLine + logBuffer.LineCount + dropCount, out string line)) + while (ReadLine(reader, logBuffer.StartLine + logBuffer.LineCount, logBuffer.StartLine + logBuffer.LineCount + dropCount, out string line)) + { + if (lineCount >= maxLinesCount) { - if (lineCount >= maxLinesCount) - { - break; - } - - if (line == null) - { - dropCount++; - continue; - } - - LogLine logLine = new() - { - FullLine = line, - LineNumber = logBuffer.StartLine + logBuffer.LineCount - }; - - logBuffer.AddLine(logLine, filePos); - filePos = reader.Position; - lineCount++; + break; } - if (maxLinesCount != logBuffer.LineCount) + if (line == null) { - _logger.Warn("LineCount in buffer differs after re-reading. old={0}, new={1}", maxLinesCount, logBuffer.LineCount); + dropCount++; + continue; } - if (dropCount - logBuffer.PrevBuffersDroppedLinesSum != logBuffer.DroppedLinesCount) + LogLine logLine = new() { - _logger.Warn("DroppedLinesCount in buffer differs after re-reading. old={0}, new={1}", logBuffer.DroppedLinesCount, dropCount); - logBuffer.DroppedLinesCount = dropCount - logBuffer.PrevBuffersDroppedLinesSum; - } + FullLine = line, + LineNumber = logBuffer.StartLine + logBuffer.LineCount + }; - GC.KeepAlive(fileStream); + logBuffer.AddLine(logLine, filePos); + filePos = reader.Position; + lineCount++; } - catch (IOException e) + + if (maxLinesCount != logBuffer.LineCount) { - _logger.Warn(e); + _logger.Warn("LineCount in buffer differs after re-reading. old={0}, new={1}", maxLinesCount, logBuffer.LineCount); } - finally + + if (dropCount - logBuffer.PrevBuffersDroppedLinesSum != logBuffer.DroppedLinesCount) { - fileStream.Close(); + _logger.Warn("DroppedLinesCount in buffer differs after re-reading. old={0}, new={1}", logBuffer.DroppedLinesCount, dropCount); + logBuffer.DroppedLinesCount = dropCount - logBuffer.PrevBuffersDroppedLinesSum; } + + GC.KeepAlive(fileStream); + } + catch (IOException e) + { + _logger.Warn(e); } finally { - Monitor.Exit(logBuffer); + fileStream.Close(); } } - - private LogBuffer GetBufferForLine(int lineNum) + finally { + Monitor.Exit(logBuffer); + } + } + + private LogBuffer GetBufferForLine (int lineNum) + { #if DEBUG - long startTime = Environment.TickCount; + long startTime = Environment.TickCount; #endif - LogBuffer logBuffer = null; - AcquireBufferListReaderLock(); - //if (lineNum == this.lastReturnedLineNumForBuffer) - //{ - // return this.lastReturnedBuffer; - //} - - //int startIndex = lineNum / LogBuffer.MAX_LINES; // doesn't work anymore since XML buffer may contain more lines than MAX_LINES - int startIndex = 0; - int count = _bufferList.Count; - for (int i = startIndex; i < count; ++i) + LogBuffer logBuffer = null; + AcquireBufferListReaderLock(); + //if (lineNum == this.lastReturnedLineNumForBuffer) + //{ + // return this.lastReturnedBuffer; + //} + + //int startIndex = lineNum / LogBuffer.MAX_LINES; // doesn't work anymore since XML buffer may contain more lines than MAX_LINES + int startIndex = 0; + int count = _bufferList.Count; + for (int i = startIndex; i < count; ++i) + { + logBuffer = _bufferList[i]; + if (lineNum >= logBuffer.StartLine && lineNum < logBuffer.StartLine + logBuffer.LineCount) { - logBuffer = _bufferList[i]; - if (lineNum >= logBuffer.StartLine && lineNum < logBuffer.StartLine + logBuffer.LineCount) - { - //UpdateLru(logBuffer); - UpdateLruCache(logBuffer); - //this.lastReturnedLineNumForBuffer = lineNum; - //this.lastReturnedBuffer = logBuffer; - break; - } + //UpdateLru(logBuffer); + UpdateLruCache(logBuffer); + //this.lastReturnedLineNumForBuffer = lineNum; + //this.lastReturnedBuffer = logBuffer; + break; } + } #if DEBUG - long endTime = Environment.TickCount; - //_logger.logDebug("getBufferForLine(" + lineNum + ") duration: " + ((endTime - startTime)) + " ms. Buffer start line: " + logBuffer.StartLine); + long endTime = Environment.TickCount; + //_logger.logDebug("getBufferForLine(" + lineNum + ") duration: " + ((endTime - startTime)) + " ms. Buffer start line: " + logBuffer.StartLine); #endif + ReleaseBufferListReaderLock(); + return logBuffer; + } + + /// + /// Async callback used to check if the GetLogLine() call is succeeding again after a detected timeout. + /// + private void GetLineFinishedCallback (ILogLine line) + { + _isFailModeCheckCallPending = false; + if (line != null) + { + _logger.Debug("'isFastFailOnGetLogLine' flag was reset"); + _isFastFailOnGetLogLine = false; + } + + _logger.Debug("'isLogLineCallPending' flag was reset."); + } + + private LogBuffer GetFirstBufferForFileByLogBuffer (LogBuffer logBuffer) + { + ILogFileInfo info = logBuffer.FileInfo; + AcquireBufferListReaderLock(); + int index = _bufferList.IndexOf(logBuffer); + if (index == -1) + { ReleaseBufferListReaderLock(); - return logBuffer; + return null; } - /// - /// Async callback used to check if the GetLogLine() call is succeeding again after a detected timeout. - /// - private void GetLineFinishedCallback(ILogLine line) + LogBuffer resultBuffer = logBuffer; + while (true) { - _isFailModeCheckCallPending = false; - if (line != null) + index--; + if (index < 0 || _bufferList[index].FileInfo != info) { - _logger.Debug("'isFastFailOnGetLogLine' flag was reset"); - _isFastFailOnGetLogLine = false; + break; } - _logger.Debug("'isLogLineCallPending' flag was reset."); + resultBuffer = _bufferList[index]; } - private LogBuffer GetFirstBufferForFileByLogBuffer(LogBuffer logBuffer) - { - ILogFileInfo info = logBuffer.FileInfo; - AcquireBufferListReaderLock(); - int index = _bufferList.IndexOf(logBuffer); - if (index == -1) - { - ReleaseBufferListReaderLock(); - return null; - } + ReleaseBufferListReaderLock(); + return resultBuffer; + } - LogBuffer resultBuffer = logBuffer; - while (true) - { - index--; - if (index < 0 || _bufferList[index].FileInfo != info) - { - break; - } + private void MonitorThreadProc () + { + Thread.CurrentThread.Name = "MonitorThread"; + //IFileSystemPlugin fs = PluginRegistry.GetInstance().FindFileSystemForUri(this.watchedILogFileInfo.FullName); + _logger.Info("MonitorThreadProc() for file {0}", _watchedILogFileInfo.FullName); - resultBuffer = _bufferList[index]; + long oldSize = 0; + try + { + OnLoadingStarted(new LoadFileEventArgs(_fileName, 0, false, 0, false)); + ReadFiles(); + if (!_isDeleted) + { + oldSize = _fileLength; + OnLoadingFinished(); } - - ReleaseBufferListReaderLock(); - return resultBuffer; } - - private void MonitorThreadProc() + catch (Exception e) { - Thread.CurrentThread.Name = "MonitorThread"; - //IFileSystemPlugin fs = PluginRegistry.GetInstance().FindFileSystemForUri(this.watchedILogFileInfo.FullName); - _logger.Info("MonitorThreadProc() for file {0}", _watchedILogFileInfo.FullName); + _logger.Error(e); + } - long oldSize = 0; + while (!_shouldStop) + { try { - OnLoadingStarted(new LoadFileEventArgs(_fileName, 0, false, 0, false)); - ReadFiles(); - if (!_isDeleted) - { - oldSize = _fileLength; - OnLoadingFinished(); - } + int pollInterval = _watchedILogFileInfo.PollInterval; + //#if DEBUG + // if (_logger.IsDebug) + // { + // _logger.logDebug("Poll interval for " + this.fileName + ": " + pollInterval); + // } + //#endif + Thread.Sleep(pollInterval); } catch (Exception e) { _logger.Error(e); } - while (!_shouldStop) + if (_shouldStop) { - try - { - int pollInterval = _watchedILogFileInfo.PollInterval; - //#if DEBUG - // if (_logger.IsDebug) - // { - // _logger.logDebug("Poll interval for " + this.fileName + ": " + pollInterval); - // } - //#endif - Thread.Sleep(pollInterval); - } - catch (Exception e) - { - _logger.Error(e); - } - - if (_shouldStop) - { - return; - } + return; + } - try + try + { + if (_watchedILogFileInfo.FileHasChanged()) { - if (_watchedILogFileInfo.FileHasChanged()) + _fileLength = _watchedILogFileInfo.Length; + if (_fileLength == -1) { - _fileLength = _watchedILogFileInfo.Length; - if (_fileLength == -1) - { - MonitoredFileNotFound(); - } - else - { - oldSize = _fileLength; - FileChanged(); - } + MonitoredFileNotFound(); + } + else + { + oldSize = _fileLength; + FileChanged(); } } - catch (FileNotFoundException) - { - MonitoredFileNotFound(); - } + } + catch (FileNotFoundException) + { + MonitoredFileNotFound(); } } + } - private void MonitoredFileNotFound() + private void MonitoredFileNotFound () + { + long oldSize; + if (!_isDeleted) { - long oldSize; - if (!_isDeleted) - { - _logger.Debug("File not FileNotFoundException catched. Switching to 'deleted' mode."); - _isDeleted = true; - oldSize = _fileLength = -1; - FileSize = 0; - OnFileNotFound(); // notify LogWindow - } + _logger.Debug("File not FileNotFoundException catched. Switching to 'deleted' mode."); + _isDeleted = true; + oldSize = _fileLength = -1; + FileSize = 0; + OnFileNotFound(); // notify LogWindow + } #if DEBUG - else - { - _logger.Debug("File not FileNotFoundException catched. Already in deleted mode."); - } -#endif + else + { + _logger.Debug("File not FileNotFoundException catched. Already in deleted mode."); } +#endif + } - private void FileChanged() + private void FileChanged () + { + if (_isDeleted) { - if (_isDeleted) - { - OnRespawned(); - // prevent size update events. The window should reload the complete file. - FileSize = _fileLength; - } - - long newSize = _fileLength; - //if (this.currFileSize != newSize) - { - _logger.Info("file size changed. new size={0}, file: {1}", newSize, _fileName); - FireChangeEvent(); - } + OnRespawned(); + // prevent size update events. The window should reload the complete file. + FileSize = _fileLength; } - private void FireChangeEvent() + long newSize = _fileLength; + //if (this.currFileSize != newSize) { - LogEventArgs args = new(); - args.PrevFileSize = FileSize; - args.PrevLineCount = LineCount; - long newSize = _fileLength; - if (newSize < FileSize || _isDeleted) + _logger.Info("file size changed. new size={0}, file: {1}", newSize, _fileName); + FireChangeEvent(); + } + } + + private void FireChangeEvent () + { + LogEventArgs args = new(); + args.PrevFileSize = FileSize; + args.PrevLineCount = LineCount; + long newSize = _fileLength; + if (newSize < FileSize || _isDeleted) + { + _logger.Info("File was created anew: new size={0}, oldSize={1}", newSize, FileSize); + // Fire "New File" event + FileSize = 0; + LineCount = 0; + try { - _logger.Info("File was created anew: new size={0}, oldSize={1}", newSize, FileSize); - // Fire "New File" event - FileSize = 0; - LineCount = 0; - try + if (!IsMultiFile) { - if (!IsMultiFile) - { - // ReloadBufferList(); // removed because reloading is triggered by owning LogWindow - // Trigger "new file" handling (reload) - OnLoadFile(new LoadFileEventArgs(_fileName, 0, true, _fileLength, true)); + // ReloadBufferList(); // removed because reloading is triggered by owning LogWindow + // Trigger "new file" handling (reload) + OnLoadFile(new LoadFileEventArgs(_fileName, 0, true, _fileLength, true)); - if (_isDeleted) - { - args.FileSize = newSize; - args.LineCount = LineCount; - if (args.PrevLineCount != args.LineCount && !_shouldStop) - { - OnFileSizeChanged(args); - } - } - - _isDeleted = false; - } - else + if (_isDeleted) { - int offset = ShiftBuffers(); - //this.currFileSize = newSize; // removed because ShiftBuffers() calls ReadToBuffer() which will set the actual read size args.FileSize = newSize; args.LineCount = LineCount; - args.IsRollover = true; - args.RolloverOffset = offset; - _isDeleted = false; - if (!_shouldStop) + if (args.PrevLineCount != args.LineCount && !_shouldStop) { OnFileSizeChanged(args); } } + + _isDeleted = false; } - catch (FileNotFoundException e) + else { - // trying anew in next poll intervall. So let currFileSize untouched. - _logger.Warn(e); + int offset = ShiftBuffers(); + //this.currFileSize = newSize; // removed because ShiftBuffers() calls ReadToBuffer() which will set the actual read size + args.FileSize = newSize; + args.LineCount = LineCount; + args.IsRollover = true; + args.RolloverOffset = offset; + _isDeleted = false; + if (!_shouldStop) + { + OnFileSizeChanged(args); + } } } - else + catch (FileNotFoundException e) { - ReadToBufferList(_watchedILogFileInfo, FileSize, LineCount); - args.FileSize = newSize; - args.LineCount = LineCount; - //if (args.PrevLineCount != args.LineCount && !this.shouldStop) - OnFileSizeChanged(args); + // trying anew in next poll intervall. So let currFileSize untouched. + _logger.Warn(e); } } - - private ILogStreamReader GetLogStreamReader(Stream stream, EncodingOptions encodingOptions, bool useNewReader) + else { - ILogStreamReader reader = CreateLogStreamReader(stream, encodingOptions, useNewReader); - - return IsXmlMode ? new XmlBlockSplitter(new XmlLogReader(reader), XmlLogConfig) : reader; + ReadToBufferList(_watchedILogFileInfo, FileSize, LineCount); + args.FileSize = newSize; + args.LineCount = LineCount; + //if (args.PrevLineCount != args.LineCount && !this.shouldStop) + OnFileSizeChanged(args); } + } - private ILogStreamReader CreateLogStreamReader(Stream stream, EncodingOptions encodingOptions, bool useSystemReader) - { - if (useSystemReader) - { - return new PositionAwareStreamReaderSystem(stream, encodingOptions); - } + private ILogStreamReader GetLogStreamReader (Stream stream, EncodingOptions encodingOptions, bool useNewReader) + { + ILogStreamReader reader = CreateLogStreamReader(stream, encodingOptions, useNewReader); - return new PositionAwareStreamReaderLegacy(stream, encodingOptions); - } + return IsXmlMode ? new XmlBlockSplitter(new XmlLogReader(reader), XmlLogConfig) : reader; + } - private bool ReadLine(ILogStreamReader reader, int lineNum, int realLineNum, out string outLine) + private ILogStreamReader CreateLogStreamReader (Stream stream, EncodingOptions encodingOptions, bool useSystemReader) + { + if (useSystemReader) { - string line = null; - try - { - line = reader.ReadLine(); - } - catch (IOException e) - { - _logger.Warn(e); - } - catch (NotSupportedException e) - { - // Bug#11: "Reading operations are not supported by the stream" - // Currently not reproducible. Probably happens at an unlucky time interval (after opening the file) - // when the file is being deleted (rolling) - // This will be handled as EOF. - _logger.Warn(e); - } + return new PositionAwareStreamReaderSystem(stream, encodingOptions); + } - if (line == null) // EOF or catched Exception - { - outLine = null; - return false; - } + return new PositionAwareStreamReaderLegacy(stream, encodingOptions); + } - if (PreProcessColumnizer != null) - { - line = PreProcessColumnizer.PreProcessLine(line, lineNum, realLineNum); - } + private bool ReadLine (ILogStreamReader reader, int lineNum, int realLineNum, out string outLine) + { + string line = null; + try + { + line = reader.ReadLine(); + } + catch (IOException e) + { + _logger.Warn(e); + } + catch (NotSupportedException e) + { + // Bug#11: "Reading operations are not supported by the stream" + // Currently not reproducible. Probably happens at an unlucky time interval (after opening the file) + // when the file is being deleted (rolling) + // This will be handled as EOF. + _logger.Warn(e); + } - outLine = line; - return true; + if (line == null) // EOF or catched Exception + { + outLine = null; + return false; } - private void AcquireBufferListReaderLock() + if (PreProcessColumnizer != null) { - try - { - _bufferListLock.AcquireReaderLock(10000); + line = PreProcessColumnizer.PreProcessLine(line, lineNum, realLineNum); + } + + outLine = line; + return true; + } + + private void AcquireBufferListReaderLock () + { + try + { + _bufferListLock.AcquireReaderLock(10000); #if DEBUG && TRACE_LOCKS - StackTrace st = new StackTrace(true); - StackFrame callerFrame = st.GetFrame(2); - this.bufferListLockInfo = + StackTrace st = new StackTrace(true); + StackFrame callerFrame = st.GetFrame(2); + this.bufferListLockInfo = "Read lock from " + callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "() " + callerFrame.GetFileLineNumber(); #endif - } - catch (ApplicationException e) - { - _logger.Warn(e, "Reader lock wait for bufferList timed out. Now trying infinite."); + } + catch (ApplicationException e) + { + _logger.Warn(e, "Reader lock wait for bufferList timed out. Now trying infinite."); #if DEBUG && TRACE_LOCKS - _logger.logInfo(this.bufferListLockInfo); + _logger.logInfo(this.bufferListLockInfo); #endif - _bufferListLock.AcquireReaderLock(Timeout.Infinite); - } + _bufferListLock.AcquireReaderLock(Timeout.Infinite); } + } - private void ReleaseBufferListReaderLock() - { - _bufferListLock.ReleaseReaderLock(); - } + private void ReleaseBufferListReaderLock () + { + _bufferListLock.ReleaseReaderLock(); + } - private void AcquireBufferListWriterLock() + private void AcquireBufferListWriterLock () + { + try { - try - { - _bufferListLock.AcquireWriterLock(10000); + _bufferListLock.AcquireWriterLock(10000); #if DEBUG && TRACE_LOCKS - StackTrace st = new StackTrace(true); - StackFrame callerFrame = st.GetFrame(1); - this.bufferListLockInfo = + StackTrace st = new StackTrace(true); + StackFrame callerFrame = st.GetFrame(1); + this.bufferListLockInfo = "Write lock from " + callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "() " + callerFrame.GetFileLineNumber(); - callerFrame.GetFileName(); + callerFrame.GetFileName(); #endif - } - catch (ApplicationException e) - { - _logger.Warn(e, "Writer lock wait for bufferList timed out. Now trying infinite."); + } + catch (ApplicationException e) + { + _logger.Warn(e, "Writer lock wait for bufferList timed out. Now trying infinite."); #if DEBUG && TRACE_LOCKS - _logger.logInfo(this.bufferListLockInfo); + _logger.logInfo(this.bufferListLockInfo); #endif - _bufferListLock.AcquireWriterLock(Timeout.Infinite); - } + _bufferListLock.AcquireWriterLock(Timeout.Infinite); } + } - private void ReleaseBufferListWriterLock() - { - _bufferListLock.ReleaseWriterLock(); - } + private void ReleaseBufferListWriterLock () + { + _bufferListLock.ReleaseWriterLock(); + } - private LockCookie UpgradeBufferListLockToWriter() + private LockCookie UpgradeBufferListLockToWriter () + { + try { - try - { - LockCookie cookie = _bufferListLock.UpgradeToWriterLock(10000); + LockCookie cookie = _bufferListLock.UpgradeToWriterLock(10000); #if DEBUG && TRACE_LOCKS - StackTrace st = new StackTrace(true); - StackFrame callerFrame = st.GetFrame(2); - this.bufferListLockInfo += + StackTrace st = new StackTrace(true); + StackFrame callerFrame = st.GetFrame(2); + this.bufferListLockInfo += ", upgraded to writer from " + callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "() " + callerFrame.GetFileLineNumber(); #endif - return cookie; - } - catch (ApplicationException e) - { - _logger.Warn(e, "Writer lock update wait for bufferList timed out. Now trying infinite."); + return cookie; + } + catch (ApplicationException e) + { + _logger.Warn(e, "Writer lock update wait for bufferList timed out. Now trying infinite."); #if DEBUG && TRACE_LOCKS - _logger.logInfo(this.bufferListLockInfo); + _logger.logInfo(this.bufferListLockInfo); #endif - return _bufferListLock.UpgradeToWriterLock(Timeout.Infinite); - } + return _bufferListLock.UpgradeToWriterLock(Timeout.Infinite); } + } - private void DowngradeBufferListLockFromWriter(ref LockCookie cookie) - { - _bufferListLock.DowngradeFromWriterLock(ref cookie); + private void DowngradeBufferListLockFromWriter (ref LockCookie cookie) + { + _bufferListLock.DowngradeFromWriterLock(ref cookie); #if DEBUG && TRACE_LOCKS - StackTrace st = new StackTrace(true); - StackFrame callerFrame = st.GetFrame(2); - this.bufferListLockInfo += + StackTrace st = new StackTrace(true); + StackFrame callerFrame = st.GetFrame(2); + this.bufferListLockInfo += ", downgraded to reader from " + callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "() " + callerFrame.GetFileLineNumber(); #endif - } + } #if DEBUG - private void DumpBufferInfos(LogBuffer buffer) + private void DumpBufferInfos (LogBuffer buffer) + { + if (_logger.IsTraceEnabled) { - if (_logger.IsTraceEnabled) - { - _logger.Trace("StartLine: {0}\r\nLineCount: {1}\r\nStartPos: {2}\r\nSize: {3}\r\nDisposed: {4}\r\nDisposeCount: {5}\r\nFile: {6}", - buffer.StartLine, - buffer.LineCount, - buffer.StartPos, - buffer.Size, - buffer.IsDisposed ? "yes" : "no", - buffer.DisposeCount, - buffer.FileInfo.FullName); - } + _logger.Trace("StartLine: {0}\r\nLineCount: {1}\r\nStartPos: {2}\r\nSize: {3}\r\nDisposed: {4}\r\nDisposeCount: {5}\r\nFile: {6}", + buffer.StartLine, + buffer.LineCount, + buffer.StartPos, + buffer.Size, + buffer.IsDisposed ? "yes" : "no", + buffer.DisposeCount, + buffer.FileInfo.FullName); } + } #endif - #endregion + #endregion - ~LogfileReader() - { - DeleteAllContent(); - } + ~LogfileReader () + { + DeleteAllContent(); + } - protected virtual void OnFileSizeChanged(LogEventArgs e) - { - FileSizeChanged?.Invoke(this, e); - } + protected virtual void OnFileSizeChanged (LogEventArgs e) + { + FileSizeChanged?.Invoke(this, e); + } - protected virtual void OnLoadFile(LoadFileEventArgs e) - { - LoadFile?.Invoke(this, e); - } + protected virtual void OnLoadFile (LoadFileEventArgs e) + { + LoadFile?.Invoke(this, e); + } - protected virtual void OnLoadingStarted(LoadFileEventArgs e) - { - LoadingStarted?.Invoke(this, e); - } + protected virtual void OnLoadingStarted (LoadFileEventArgs e) + { + LoadingStarted?.Invoke(this, e); + } - protected virtual void OnLoadingFinished() - { - LoadingFinished?.Invoke(this, EventArgs.Empty); - } + protected virtual void OnLoadingFinished () + { + LoadingFinished?.Invoke(this, EventArgs.Empty); + } - protected virtual void OnFileNotFound() - { - FileNotFound?.Invoke(this, EventArgs.Empty); - } + protected virtual void OnFileNotFound () + { + FileNotFound?.Invoke(this, EventArgs.Empty); + } - protected virtual void OnRespawned() - { - _logger.Info("OnRespawned()"); - Respawned?.Invoke(this, EventArgs.Empty); - } + protected virtual void OnRespawned () + { + _logger.Info("OnRespawned()"); + Respawned?.Invoke(this, EventArgs.Empty); + } - private class LogLine : ILogLine - { - #region Properties + private class LogLine : ILogLine + { + #region Properties - public string FullLine { get; set; } + public string FullLine { get; set; } - public int LineNumber { get; set; } + public int LineNumber { get; set; } - string ITextValue.Text => FullLine; + string ITextValue.Text => FullLine; - #endregion - } + #endregion } } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Util.cs b/src/LogExpert.Core/Classes/Util.cs index 662d45b2..b8b7c904 100644 --- a/src/LogExpert.Core/Classes/Util.cs +++ b/src/LogExpert.Core/Classes/Util.cs @@ -28,7 +28,7 @@ public static string GetNameFromPath (string fileName) return fileName[(i + 1)..]; } - //TODO Add Null Check + //TODO Add Null Check (https://github.com/LogExperts/LogExpert/issues/403) public static string StripExtension (string fileName) { var i = fileName.LastIndexOf('.'); @@ -41,7 +41,7 @@ public static string StripExtension (string fileName) return fileName[..i]; } - //TODO Add Null Check + //TODO Add Null Check (https://github.com/LogExperts/LogExpert/issues/403) public static string GetExtension (string fileName) { var i = fileName.LastIndexOf('.'); @@ -102,7 +102,7 @@ public static bool TestFilterCondition (FilterParams filterParams, ILogLine line return match; } - //TODO Add Null Checks + //TODO Add Null Checks (https://github.com/LogExperts/LogExpert/issues/403) public static int DamerauLevenshteinDistance (string src, string dest) { var d = new int[src.Length + 1, dest.Length + 1]; @@ -142,7 +142,7 @@ public static int DamerauLevenshteinDistance (string src, string dest) return d[str1.Length, str2.Length]; } - //TODO Add Null Checks + //TODO Add Null Checks (https://github.com/LogExperts/LogExpert/issues/403) public static unsafe int YetiLevenshtein (string s1, string s2) { fixed (char* p1 = s1) @@ -409,7 +409,7 @@ public static void AssertTrue (bool condition, string msg) } } - //TODO Add Null Check + //TODO Add Null Check (https://github.com/LogExperts/LogExpert/issues/403) [SupportedOSPlatform("windows")] public string? GetWordFromPos (int xPos, string text, Graphics g, Font font) { diff --git a/src/LogExpert.Core/Interface/IBookmarkView.cs b/src/LogExpert.Core/Interface/IBookmarkView.cs deleted file mode 100644 index f626c004..00000000 --- a/src/LogExpert.Core/Interface/IBookmarkView.cs +++ /dev/null @@ -1,29 +0,0 @@ -using LogExpert.Core.Entities; - -namespace LogExpert.Core.Interface -{ - /// - /// To be implemented by the bookmark window. Will be informed from LogWindow about changes in bookmarks. - /// - //TODO: Not in use! - public interface IBookmarkView - { - #region Properties - - bool LineColumnVisible { set; } - - #endregion - - #region Public methods - - void UpdateView(); - - void BookmarkTextChanged(Bookmark bookmark); - - void SelectBookmark(int lineNum); - - void SetBookmarkData(IBookmarkData bookmarkData); - - #endregion - } -} \ No newline at end of file diff --git a/src/LogExpert.Core/Interface/ILogTabWindow.cs b/src/LogExpert.Core/Interface/ILogTabWindow.cs index 518b3c01..822d464d 100644 --- a/src/LogExpert.Core/Interface/ILogTabWindow.cs +++ b/src/LogExpert.Core/Interface/ILogTabWindow.cs @@ -1,15 +1,14 @@ -namespace LogExpert.Core.Interface +namespace LogExpert.Core.Interface; + +//TODO: Add documentation +public interface ILogTabWindow { - //TODO: Add documentation - public interface ILogTabWindow - { - ILogExpertProxy LogExpertProxy { get; set; } - bool IsDisposed { get; } + ILogExpertProxy LogExpertProxy { get; set; } + bool IsDisposed { get; } - void Activate(); - object Invoke(Delegate method, params object?[]? objects); - void LoadFiles(string[] fileNames); - void SetForeground(); - void Show(); - } + void Activate (); + object Invoke (Delegate method, params object?[]? objects); + void LoadFiles (string[] fileNames); + void SetForeground (); + void Show (); } \ No newline at end of file diff --git a/src/LogExpert.Core/Interface/ILogWindow.cs b/src/LogExpert.Core/Interface/ILogWindow.cs index c6f72f93..9072cdcb 100644 --- a/src/LogExpert.Core/Interface/ILogWindow.cs +++ b/src/LogExpert.Core/Interface/ILogWindow.cs @@ -3,40 +3,41 @@ using LogExpert.Core.Classes.Persister; using LogExpert.Core.EventHandlers; -namespace LogExpert.Core.Interface +namespace LogExpert.Core.Interface; + +//TODO: Add documentation +public interface ILogWindow { - //TODO: Add documentation - public interface ILogWindow - { - string GetCurrentFileName (int lineNum); + string GetCurrentFileName (int lineNum); - ILogLine GetLine (int lineNum); + ILogLine GetLine (int lineNum); - DateTime GetTimestampForLineForward (ref int lineNum, bool v); + //TODO Find a way to not use a referenced int (https://github.com/LogExperts/LogExpert/issues/404) + DateTime GetTimestampForLineForward (ref int lineNum, bool v); - DateTime GetTimestampForLine (ref int lastLineNum, bool v); + //TODO Find a way to not use a referenced int (https://github.com/LogExperts/LogExpert/issues/404) + DateTime GetTimestampForLine (ref int lastLineNum, bool v); - int FindTimestampLine_Internal (int lineNum1, int lineNum2, int lastLineNum, DateTime searchTimeStamp, bool v); + int FindTimestampLine_Internal (int lineNum1, int lineNum2, int lastLineNum, DateTime searchTimeStamp, bool v); - void SelectLine (int lineNum, bool v1, bool v2); + void SelectLine (int lineNum, bool v1, bool v2); - PersistenceData GetPersistenceData (); + PersistenceData GetPersistenceData (); - void AddTempFileTab (string fileName, string title); + void AddTempFileTab (string fileName, string title); - void WritePipeTab (IList lineEntryList, string title); + void WritePipeTab (IList lineEntryList, string title); - void Activate (); + void Activate (); - LogfileReader LogFileReader { get; } + LogfileReader LogFileReader { get; } - string Text { get; } + string Text { get; } - string FileName { get; } + string FileName { get; } - event FileSizeChangedEventHandler FileSizeChanged; //TODO: All handlers should be moved to Core + event FileSizeChangedEventHandler FileSizeChanged; //TODO: All handlers should be moved to Core - event EventHandler TailFollowed; - //LogExpert.UI.Controls.LogTabWindow.LogTabWindow.LogWindowData Tag { get; } - } + event EventHandler TailFollowed; + //LogExpert.UI.Controls.LogTabWindow.LogTabWindow.LogWindowData Tag { get; } } \ No newline at end of file From 57f9136d0c2aa9227e399bebc583d9733b9d1793 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sun, 1 Jun 2025 16:59:37 +0300 Subject: [PATCH 051/142] Organize projects in folders --- src/LogExpert.sln | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/LogExpert.sln b/src/LogExpert.sln index 4560627e..d4494be0 100644 --- a/src/LogExpert.sln +++ b/src/LogExpert.sln @@ -65,6 +65,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.UI", "LogExpert.U EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.PluginRegistry", "PluginRegistry\LogExpert.PluginRegistry.csproj", "{E2D8E653-B7DF-4ACE-8314-8059B1E20751}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Columnizers", "Columnizers", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{848C24BA-BEBA-48EC-90E6-526ECAB6BB4A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -158,7 +162,17 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution + {2563526E-4566-40CB-AA27-587B904FD25B} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {C41A517B-7502-4B17-9119-55D5716FAD65} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {43B3857D-4341-41A6-9E77-4F3BA4F2C7AB} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {4C899885-E361-410A-B6AC-C2F236C436FA} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {B5A7DFA4-48A8-4616-8008-7441699EC946} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {0DBBCBEF-4A91-4031-AEAB-B7EEE802F496} = {848C24BA-BEBA-48EC-90E6-526ECAB6BB4A} + {1FFB09A8-DAE4-4DEB-AFF6-8BAE6D01C7AC} = {848C24BA-BEBA-48EC-90E6-526ECAB6BB4A} + {003535EC-4186-4958-9DD9-C641F089AEED} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {B57259A3-4ED7-4F8B-A252-29E799A56B9E} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} {C625E7C2-AF15-4C40-8C35-3E166D46F939} = {DE6375A4-B4C4-4620-8FFB-B9D5A4E21144} + {FBFB598D-B94A-4AD3-A355-0D5A618CEEE3} = {848C24BA-BEBA-48EC-90E6-526ECAB6BB4A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {15924D5F-B90B-4BC7-9E7D-BCCB62EBABAD} From 3210ccc0eb63f82eb94d7839e6a49def45e2738d Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 1 Jun 2025 19:36:57 +0200 Subject: [PATCH 052/142] update after system.drawing.common is needed --- src/Directory.Packages.props | 2 +- src/LogExpert.Core/LogExpert.Core.csproj | 1 + .../Controls/LogWindow/LogWindow.cs | 958 +++++++++--------- src/LogExpert.UI/Dialogs/BookmarkWindow.cs | 87 +- 4 files changed, 526 insertions(+), 522 deletions(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 533ca233..4fff1524 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -28,7 +28,7 @@ - +
    diff --git a/src/LogExpert.Core/LogExpert.Core.csproj b/src/LogExpert.Core/LogExpert.Core.csproj index 0062fbbf..c922c133 100644 --- a/src/LogExpert.Core/LogExpert.Core.csproj +++ b/src/LogExpert.Core/LogExpert.Core.csproj @@ -23,6 +23,7 @@ + diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index c3649e73..3d2334b6 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -1,4 +1,4 @@ -using LogExpert.Classes.Filter; +using LogExpert.Classes.Filter; using LogExpert.Core.Callback; using LogExpert.Core.Classes.Bookmark; using LogExpert.Core.Classes.Filter; @@ -11,693 +11,693 @@ using LogExpert.Core.EventHandlers; using LogExpert.Core.Interface; using LogExpert.Dialogs; -using LogExpert.UI.Controls.LogTabWindow; using LogExpert.UI.Dialogs; using LogExpert.UI.Extensions.Forms; +using LogExpert.UI.Interface; + using NLog; using WeifenLuo.WinFormsUI.Docking; //using static LogExpert.PluginRegistry.PluginRegistry; //TODO: Adjust the instance name so using static can be used. -namespace LogExpert.UI.Controls.LogWindow -{ - //TODO: Implemented 4 interfaces explicitly. Find them by searcginh: ILogWindow. - internal partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILogWindow - { - #region Fields +namespace LogExpert.UI.Controls.LogWindow; - private const int SPREAD_MAX = 99; - private const int PROGRESS_BAR_MODULO = 1000; - private const int FILTER_ADVANCED_SPLITTER_DISTANCE = 150; - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); +//TODO: Implemented 4 interfaces explicitly. Find them by searcginh: ILogWindow. +internal partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILogWindow +{ + #region Fields - private readonly Image _advancedButtonImage; + private const int SPREAD_MAX = 99; + private const int PROGRESS_BAR_MODULO = 1000; + private const int FILTER_ADVANCED_SPLITTER_DISTANCE = 150; + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - private readonly object _bookmarkLock = new(); - private readonly BookmarkDataProvider _bookmarkProvider = new(); + private readonly Image _advancedButtonImage; - private readonly IList _cancelHandlerList = new List(); + private readonly object _bookmarkLock = new(); + private readonly BookmarkDataProvider _bookmarkProvider = new(); - private readonly object _currentColumnizerLock = new(); + private readonly IList _cancelHandlerList = new List(); - private readonly object _currentHighlightGroupLock = new(); + private readonly object _currentColumnizerLock = new(); - private readonly EventWaitHandle _externaLoadingFinishedEvent = new ManualResetEvent(false); + private readonly object _currentHighlightGroupLock = new(); - private readonly IList _filterPipeList = new List(); - private readonly Dictionary _freezeStateMap = []; - private readonly GuiStateArgs _guiStateArgs = new(); + private readonly EventWaitHandle _externaLoadingFinishedEvent = new ManualResetEvent(false); - private readonly List _lineHashList = []; + private readonly IList _filterPipeList = new List(); + private readonly Dictionary _freezeStateMap = []; + private readonly GuiStateArgs _guiStateArgs = new(); - private readonly EventWaitHandle _loadingFinishedEvent = new ManualResetEvent(false); + private readonly List _lineHashList = []; - private readonly EventWaitHandle _logEventArgsEvent = new ManualResetEvent(false); + private readonly EventWaitHandle _loadingFinishedEvent = new ManualResetEvent(false); - private readonly List _logEventArgsList = []; - private readonly Task _logEventHandlerTask; - //private readonly Thread _logEventHandlerThread; - private readonly Image _panelCloseButtonImage; + private readonly EventWaitHandle _logEventArgsEvent = new ManualResetEvent(false); - private readonly Image _panelOpenButtonImage; - private readonly LogTabWindow.LogTabWindow _parentLogTabWin; + private readonly List _logEventArgsList = []; + private readonly Task _logEventHandlerTask; + //private readonly Thread _logEventHandlerThread; + private readonly Image _panelCloseButtonImage; - private readonly ProgressEventArgs _progressEventArgs = new(); - private readonly object _reloadLock = new(); - private readonly Image _searchButtonImage; - private readonly StatusLineEventArgs _statusEventArgs = new(); + private readonly Image _panelOpenButtonImage; + private readonly LogTabWindow.LogTabWindow _parentLogTabWin; - private readonly object _tempHighlightEntryListLock = new(); + private readonly ProgressEventArgs _progressEventArgs = new(); + private readonly object _reloadLock = new(); + private readonly Image _searchButtonImage; + private readonly StatusLineEventArgs _statusEventArgs = new(); - private readonly Task _timeShiftSyncTask; - private readonly CancellationTokenSource cts = new(); + private readonly object _tempHighlightEntryListLock = new(); - //private readonly Thread _timeShiftSyncThread; - private readonly EventWaitHandle _timeShiftSyncTimerEvent = new ManualResetEvent(false); - private readonly EventWaitHandle _timeShiftSyncWakeupEvent = new ManualResetEvent(false); + private readonly Task _timeShiftSyncTask; + private readonly CancellationTokenSource cts = new(); - private readonly TimeSpreadCalculator _timeSpreadCalc; + //private readonly Thread _timeShiftSyncThread; + private readonly EventWaitHandle _timeShiftSyncTimerEvent = new ManualResetEvent(false); + private readonly EventWaitHandle _timeShiftSyncWakeupEvent = new ManualResetEvent(false); - private readonly object _timeSyncListLock = new(); + private readonly TimeSpreadCalculator _timeSpreadCalc; - private ColumnCache _columnCache = new(); + private readonly object _timeSyncListLock = new(); - private ILogLineColumnizer _currentColumnizer; + private ColumnCache _columnCache = new(); - //List currentHilightEntryList = new List(); - private HighlightGroup _currentHighlightGroup = new(); + private ILogLineColumnizer _currentColumnizer; - private SearchParams _currentSearchParams; + //List currentHilightEntryList = new List(); + private HighlightGroup _currentHighlightGroup = new(); - private string[] _fileNames; - private List _filterHitList = []; - private FilterParams _filterParams = new(); - private int _filterPipeNameCounter = 0; - private List _filterResultList = []; + private SearchParams _currentSearchParams; - private EventWaitHandle _filterUpdateEvent = new ManualResetEvent(false); + private string[] _fileNames; + private List _filterHitList = []; + private FilterParams _filterParams = new(); + private int _filterPipeNameCounter = 0; + private List _filterResultList = []; - private ILogLineColumnizer _forcedColumnizer; - private ILogLineColumnizer _forcedColumnizerForLoading; - private bool _isDeadFile; - private bool _isErrorShowing; - private bool _isLoadError; - private bool _isLoading; - private bool _isMultiFile; - private bool _isSearching; - private bool _isTimestampDisplaySyncing; - private List _lastFilterLinesList = []; + private EventWaitHandle _filterUpdateEvent = new ManualResetEvent(false); - private int _lineHeight = 0; + private ILogLineColumnizer _forcedColumnizer; + private ILogLineColumnizer _forcedColumnizerForLoading; + private bool _isDeadFile; + private bool _isErrorShowing; + private bool _isLoadError; + private bool _isLoading; + private bool _isMultiFile; + private bool _isSearching; + private bool _isTimestampDisplaySyncing; + private List _lastFilterLinesList = []; - internal LogfileReader _logFileReader; - private MultiFileOptions _multiFileOptions = new(); - private bool _noSelectionUpdates; - private PatternArgs _patternArgs = new(); - private PatternWindow _patternWindow; + private int _lineHeight = 0; - private ReloadMemento _reloadMemento; - private int _reloadOverloadCounter = 0; - private SortedList _rowHeightList = []; - private int _selectedCol = 0; // set by context menu event for column headers only - private bool _shouldCallTimeSync; - private bool _shouldCancel; - private bool _shouldTimestampDisplaySyncingCancel; - private bool _showAdvanced; - private List _tempHighlightEntryList = []; - private int _timeShiftSyncLine = 0; + internal LogfileReader _logFileReader; + private MultiFileOptions _multiFileOptions = new(); + private bool _noSelectionUpdates; + private PatternArgs _patternArgs = new(); + private PatternWindow _patternWindow; - private bool _waitingForClose; + private ReloadMemento _reloadMemento; + private int _reloadOverloadCounter = 0; + private SortedList _rowHeightList = []; + private int _selectedCol = 0; // set by context menu event for column headers only + private bool _shouldCallTimeSync; + private bool _shouldCancel; + private bool _shouldTimestampDisplaySyncingCancel; + private bool _showAdvanced; + private List _tempHighlightEntryList = []; + private int _timeShiftSyncLine = 0; - #endregion + private bool _waitingForClose; - #region cTor + #endregion - public LogWindow(LogTabWindow.LogTabWindow parent, string fileName, bool isTempFile, bool forcePersistenceLoading, IConfigManager configManager) - { - SuspendLayout(); + #region cTor - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; + public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTempFile, bool forcePersistenceLoading, IConfigManager configManager) + { + SuspendLayout(); - InitializeComponent(); //TODO: Move this to be the first line of the constructor? + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; - CreateDefaultViewStyle(); + InitializeComponent(); //TODO: Move this to be the first line of the constructor? - columnNamesLabel.Text = ""; // no filtering on columns by default + CreateDefaultViewStyle(); - _parentLogTabWin = parent; - IsTempFile = isTempFile; - ConfigManager = configManager; //TODO: This should be changed to DI - //Thread.CurrentThread.Name = "LogWindowThread"; - ColumnizerCallbackObject = new ColumnizerCallback(this); + columnNamesLabel.Text = ""; // no filtering on columns by default - FileName = fileName; - ForcePersistenceLoading = forcePersistenceLoading; + _parentLogTabWin = parent; + IsTempFile = isTempFile; + ConfigManager = configManager; //TODO: This should be changed to DI + //Thread.CurrentThread.Name = "LogWindowThread"; + ColumnizerCallbackObject = new ColumnizerCallback(this); - dataGridView.CellValueNeeded += OnDataGridViewCellValueNeeded; - dataGridView.CellPainting += OnDataGridView_CellPainting; + FileName = fileName; + ForcePersistenceLoading = forcePersistenceLoading; - filterGridView.CellValueNeeded += OnFilterGridViewCellValueNeeded; - filterGridView.CellPainting += OnFilterGridViewCellPainting; - filterListBox.DrawMode = DrawMode.OwnerDrawVariable; - filterListBox.MeasureItem += MeasureItem; + dataGridView.CellValueNeeded += OnDataGridViewCellValueNeeded; + dataGridView.CellPainting += OnDataGridView_CellPainting; - Closing += OnLogWindowClosing; - Disposed += OnLogWindowDisposed; - Load += OnLogWindowLoad; + filterGridView.CellValueNeeded += OnFilterGridViewCellValueNeeded; + filterGridView.CellPainting += OnFilterGridViewCellPainting; + filterListBox.DrawMode = DrawMode.OwnerDrawVariable; + filterListBox.MeasureItem += MeasureItem; - _timeSpreadCalc = new TimeSpreadCalculator(this); - timeSpreadingControl.TimeSpreadCalc = _timeSpreadCalc; - timeSpreadingControl.LineSelected += OnTimeSpreadingControlLineSelected; - tableLayoutPanel1.ColumnStyles[1].SizeType = SizeType.Absolute; - tableLayoutPanel1.ColumnStyles[1].Width = 20; - tableLayoutPanel1.ColumnStyles[0].SizeType = SizeType.Percent; - tableLayoutPanel1.ColumnStyles[0].Width = 100; + Closing += OnLogWindowClosing; + Disposed += OnLogWindowDisposed; + Load += OnLogWindowLoad; - _parentLogTabWin.HighlightSettingsChanged += OnParentHighlightSettingsChanged; - SetColumnizer(PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers[0]); + _timeSpreadCalc = new TimeSpreadCalculator(this); + timeSpreadingControl.TimeSpreadCalc = _timeSpreadCalc; + timeSpreadingControl.LineSelected += OnTimeSpreadingControlLineSelected; + tableLayoutPanel1.ColumnStyles[1].SizeType = SizeType.Absolute; + tableLayoutPanel1.ColumnStyles[1].Width = 20; + tableLayoutPanel1.ColumnStyles[0].SizeType = SizeType.Percent; + tableLayoutPanel1.ColumnStyles[0].Width = 100; - _patternArgs.MaxMisses = 5; - _patternArgs.MinWeight = 1; - _patternArgs.MaxDiffInBlock = 5; - _patternArgs.Fuzzy = 5; + _parentLogTabWin.HighlightSettingsChanged += OnParentHighlightSettingsChanged; + SetColumnizer(PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers[0]); - //InitPatternWindow(); + _patternArgs.MaxMisses = 5; + _patternArgs.MinWeight = 1; + _patternArgs.MaxDiffInBlock = 5; + _patternArgs.Fuzzy = 5; - //this.toolwinTabControl.TabPages.Add(this.patternWindow); - //this.toolwinTabControl.TabPages.Add(this.bookmarkWindow); + //InitPatternWindow(); - _filterParams = new FilterParams(); - foreach (string item in configManager.Settings.filterHistoryList) - { - filterComboBox.Items.Add(item); - } + //this.toolwinTabControl.TabPages.Add(this.patternWindow); + //this.toolwinTabControl.TabPages.Add(this.bookmarkWindow); - filterComboBox.DropDownHeight = filterComboBox.ItemHeight * configManager.Settings.Preferences.maximumFilterEntriesDisplayed; - AutoResizeFilterBox(); + _filterParams = new FilterParams(); + foreach (string item in configManager.Settings.filterHistoryList) + { + filterComboBox.Items.Add(item); + } - filterRegexCheckBox.Checked = _filterParams.IsRegex; - filterCaseSensitiveCheckBox.Checked = _filterParams.IsCaseSensitive; - filterTailCheckBox.Checked = _filterParams.IsFilterTail; + filterComboBox.DropDownHeight = filterComboBox.ItemHeight * configManager.Settings.Preferences.maximumFilterEntriesDisplayed; + AutoResizeFilterBox(); - splitContainerLogWindow.Panel2Collapsed = true; - advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; + filterRegexCheckBox.Checked = _filterParams.IsRegex; + filterCaseSensitiveCheckBox.Checked = _filterParams.IsCaseSensitive; + filterTailCheckBox.Checked = _filterParams.IsFilterTail; - _timeShiftSyncTask = new Task(SyncTimestampDisplayWorker, cts.Token); - _timeShiftSyncTask.Start(); - //_timeShiftSyncThread = new Thread(SyncTimestampDisplayWorker); - //_timeShiftSyncThread.IsBackground = true; - //_timeShiftSyncThread.Start(); + splitContainerLogWindow.Panel2Collapsed = true; + advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; - _logEventHandlerTask = new Task(LogEventWorker, cts.Token); - _logEventHandlerTask.Start(); - //_logEventHandlerThread = new Thread(LogEventWorker); - //_logEventHandlerThread.IsBackground = true; - //_logEventHandlerThread.Start(); + _timeShiftSyncTask = new Task(SyncTimestampDisplayWorker, cts.Token); + _timeShiftSyncTask.Start(); + //_timeShiftSyncThread = new Thread(SyncTimestampDisplayWorker); + //_timeShiftSyncThread.IsBackground = true; + //_timeShiftSyncThread.Start(); - //this.filterUpdateThread = new Thread(new ThreadStart(this.FilterUpdateWorker)); - //this.filterUpdateThread.Start(); + _logEventHandlerTask = new Task(LogEventWorker, cts.Token); + _logEventHandlerTask.Start(); + //_logEventHandlerThread = new Thread(LogEventWorker); + //_logEventHandlerThread.IsBackground = true; + //_logEventHandlerThread.Start(); - _advancedButtonImage = advancedButton.Image; - _searchButtonImage = filterSearchButton.Image; - filterSearchButton.Image = null; + //this.filterUpdateThread = new Thread(new ThreadStart(this.FilterUpdateWorker)); + //this.filterUpdateThread.Start(); - dataGridView.EditModeMenuStrip = editModeContextMenuStrip; - markEditModeToolStripMenuItem.Enabled = true; + _advancedButtonImage = advancedButton.Image; + _searchButtonImage = filterSearchButton.Image; + filterSearchButton.Image = null; - _panelOpenButtonImage = Resources.Resources.Arrow_menu_open; - _panelCloseButtonImage = Resources.Resources.Arrow_menu_close; + dataGridView.EditModeMenuStrip = editModeContextMenuStrip; + markEditModeToolStripMenuItem.Enabled = true; - Settings settings = configManager.Settings; + _panelOpenButtonImage = Resources.Resources.Arrow_menu_open; + _panelCloseButtonImage = Resources.Resources.Arrow_menu_close; - if (settings.appBounds.Right > 0) - { - Bounds = settings.appBounds; - } + Settings settings = configManager.Settings; - _waitingForClose = false; - dataGridView.Enabled = false; - dataGridView.ColumnDividerDoubleClick += OnDataGridViewColumnDividerDoubleClick; - ShowAdvancedFilterPanel(false); - filterKnobBackSpread.MinValue = 0; - filterKnobBackSpread.MaxValue = SPREAD_MAX; - filterKnobBackSpread.ValueChanged += OnFilterKnobControlValueChanged; - filterKnobForeSpread.MinValue = 0; - filterKnobForeSpread.MaxValue = SPREAD_MAX; - filterKnobForeSpread.ValueChanged += OnFilterKnobControlValueChanged; - fuzzyKnobControl.MinValue = 0; - fuzzyKnobControl.MaxValue = 10; - //PreferencesChanged(settings.preferences, true); - AdjustHighlightSplitterWidth(); - ToggleHighlightPanel(false); // hidden - - _bookmarkProvider.BookmarkAdded += OnBookmarkProviderBookmarkAdded; - _bookmarkProvider.BookmarkRemoved += OnBookmarkProviderBookmarkRemoved; - _bookmarkProvider.AllBookmarksRemoved += OnBookmarkProviderAllBookmarksRemoved; - - ResumeLayout(); - - ChangeTheme(Controls); + if (settings.appBounds.Right > 0) + { + Bounds = settings.appBounds; } - + _waitingForClose = false; + dataGridView.Enabled = false; + dataGridView.ColumnDividerDoubleClick += OnDataGridViewColumnDividerDoubleClick; + ShowAdvancedFilterPanel(false); + filterKnobBackSpread.MinValue = 0; + filterKnobBackSpread.MaxValue = SPREAD_MAX; + filterKnobBackSpread.ValueChanged += OnFilterKnobControlValueChanged; + filterKnobForeSpread.MinValue = 0; + filterKnobForeSpread.MaxValue = SPREAD_MAX; + filterKnobForeSpread.ValueChanged += OnFilterKnobControlValueChanged; + fuzzyKnobControl.MinValue = 0; + fuzzyKnobControl.MaxValue = 10; + //PreferencesChanged(settings.preferences, true); + AdjustHighlightSplitterWidth(); + ToggleHighlightPanel(false); // hidden + + _bookmarkProvider.BookmarkAdded += OnBookmarkProviderBookmarkAdded; + _bookmarkProvider.BookmarkRemoved += OnBookmarkProviderBookmarkRemoved; + _bookmarkProvider.AllBookmarksRemoved += OnBookmarkProviderAllBookmarksRemoved; + + ResumeLayout(); + + ChangeTheme(Controls); + } + - #endregion - #region ColorTheme - public void ChangeTheme(Control.ControlCollection container) + #endregion + + #region ColorTheme + public void ChangeTheme (Control.ControlCollection container) + { + #region ApplyColorToAllControls + foreach (Control component in container) { - #region ApplyColorToAllControls - foreach (Control component in container) + if (component.Controls != null && component.Controls.Count > 0) { - if (component.Controls != null && component.Controls.Count > 0) - { - ChangeTheme(component.Controls); - component.BackColor = ColorMode.BackgroundColor; - component.ForeColor = ColorMode.ForeColor; - } - else - { - component.BackColor = ColorMode.BackgroundColor; - component.ForeColor = ColorMode.ForeColor; - } - + ChangeTheme(component.Controls); + component.BackColor = ColorMode.BackgroundColor; + component.ForeColor = ColorMode.ForeColor; } - #endregion - - #region DataGridView - - // Main DataGridView - dataGridView.BackgroundColor = ColorMode.DockBackgroundColor; - dataGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor; - dataGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor; - dataGridView.EnableHeadersVisualStyles = false; - - // Filter dataGridView - filterGridView.BackgroundColor = ColorMode.DockBackgroundColor; - filterGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor; - filterGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor; - filterGridView.EnableHeadersVisualStyles = false; - - // Colors for menu - dataGridContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - bookmarkContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - columnContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - editModeContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - filterContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - filterListContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - - foreach (ToolStripItem item in dataGridContextMenuStrip.Items) + else { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; + component.BackColor = ColorMode.BackgroundColor; + component.ForeColor = ColorMode.ForeColor; } - foreach (ToolStripItem item in bookmarkContextMenuStrip.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } + } + #endregion - foreach (ToolStripItem item in columnContextMenuStrip.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } + #region DataGridView + + // Main DataGridView + dataGridView.BackgroundColor = ColorMode.DockBackgroundColor; + dataGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor; + dataGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor; + dataGridView.EnableHeadersVisualStyles = false; + + // Filter dataGridView + filterGridView.BackgroundColor = ColorMode.DockBackgroundColor; + filterGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor; + filterGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor; + filterGridView.EnableHeadersVisualStyles = false; + + // Colors for menu + dataGridContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); + bookmarkContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); + columnContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); + editModeContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); + filterContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); + filterListContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); + + foreach (ToolStripItem item in dataGridContextMenuStrip.Items) + { + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.MenuBackgroundColor; + } - foreach (ToolStripItem item in editModeContextMenuStrip.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } + foreach (ToolStripItem item in bookmarkContextMenuStrip.Items) + { + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.MenuBackgroundColor; + } - foreach (ToolStripItem item in filterContextMenuStrip.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } + foreach (ToolStripItem item in columnContextMenuStrip.Items) + { + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.MenuBackgroundColor; + } - foreach (ToolStripItem item in filterListContextMenuStrip.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } + foreach (ToolStripItem item in editModeContextMenuStrip.Items) + { + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.MenuBackgroundColor; + } - // Colors for menu - filterContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); + foreach (ToolStripItem item in filterContextMenuStrip.Items) + { + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.MenuBackgroundColor; + } - for (var y = 0; y < filterContextMenuStrip.Items.Count; y++) - { - var item = filterContextMenuStrip.Items[y]; - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } + foreach (ToolStripItem item in filterListContextMenuStrip.Items) + { + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.MenuBackgroundColor; + } - #endregion DataGridView + // Colors for menu + filterContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - filterComboBox.BackColor = ColorMode.DockBackgroundColor; + for (var y = 0; y < filterContextMenuStrip.Items.Count; y++) + { + var item = filterContextMenuStrip.Items[y]; + item.ForeColor = ColorMode.ForeColor; + item.BackColor = ColorMode.MenuBackgroundColor; } - #endregion + #endregion DataGridView - #region Delegates + filterComboBox.BackColor = ColorMode.DockBackgroundColor; + } - public delegate void BookmarkAddedEventHandler(object sender, EventArgs e); + #endregion - public delegate void BookmarkRemovedEventHandler(object sender, EventArgs e); + #region Delegates - public delegate void BookmarkTextChangedEventHandler(object sender, BookmarkEventArgs e); + public delegate void BookmarkAddedEventHandler (object sender, EventArgs e); - public delegate void ColumnizerChangedEventHandler(object sender, ColumnizerEventArgs e); + public delegate void BookmarkRemovedEventHandler (object sender, EventArgs e); - public delegate void CurrentHighlightGroupChangedEventHandler(object sender, CurrentHighlightGroupChangedEventArgs e); + public delegate void BookmarkTextChangedEventHandler (object sender, BookmarkEventArgs e); - public delegate void FileNotFoundEventHandler(object sender, EventArgs e); + public delegate void ColumnizerChangedEventHandler (object sender, ColumnizerEventArgs e); - public delegate void FileRespawnedEventHandler(object sender, EventArgs e); + public delegate void CurrentHighlightGroupChangedEventHandler (object sender, CurrentHighlightGroupChangedEventArgs e); - public delegate void FilterListChangedEventHandler(object sender, FilterListChangedEventArgs e); + public delegate void FileNotFoundEventHandler (object sender, EventArgs e); - // used for filterTab restore - public delegate void FilterRestoreFx(LogWindow newWin, PersistenceData persistenceData); + public delegate void FileRespawnedEventHandler (object sender, EventArgs e); - public delegate void GuiStateEventHandler(object sender, GuiStateArgs e); + public delegate void FilterListChangedEventHandler (object sender, FilterListChangedEventArgs e); - public delegate void ProgressBarEventHandler(object sender, ProgressEventArgs e); + // used for filterTab restore + public delegate void FilterRestoreFx (LogWindow newWin, PersistenceData persistenceData); - public delegate void RestoreFiltersFx(PersistenceData persistenceData); + public delegate void GuiStateEventHandler (object sender, GuiStateArgs e); - public delegate bool ScrollToTimestampFx(DateTime timestamp, bool roundToSeconds, bool triggerSyncCall); + public delegate void ProgressBarEventHandler (object sender, ProgressEventArgs e); - public delegate void StatusLineEventHandler(object sender, StatusLineEventArgs e); + public delegate void RestoreFiltersFx (PersistenceData persistenceData); - public delegate void SyncModeChangedEventHandler(object sender, SyncModeEventArgs e); + public delegate bool ScrollToTimestampFx (DateTime timestamp, bool roundToSeconds, bool triggerSyncCall); - public delegate void TailFollowedEventHandler(object sender, EventArgs e); + public delegate void StatusLineEventHandler (object sender, StatusLineEventArgs e); - #endregion + public delegate void SyncModeChangedEventHandler (object sender, SyncModeEventArgs e); - #region Events + public delegate void TailFollowedEventHandler (object sender, EventArgs e); - public event FileSizeChangedEventHandler FileSizeChanged; + #endregion - public event ProgressBarEventHandler ProgressBarUpdate; + #region Events - public event StatusLineEventHandler StatusLineEvent; + public event FileSizeChangedEventHandler FileSizeChanged; - public event GuiStateEventHandler GuiStateUpdate; + public event ProgressBarEventHandler ProgressBarUpdate; - public event TailFollowedEventHandler TailFollowed; + public event StatusLineEventHandler StatusLineEvent; - public event FileNotFoundEventHandler FileNotFound; + public event GuiStateEventHandler GuiStateUpdate; - public event FileRespawnedEventHandler FileRespawned; + public event TailFollowedEventHandler TailFollowed; - public event FilterListChangedEventHandler FilterListChanged; + public event FileNotFoundEventHandler FileNotFound; - public event CurrentHighlightGroupChangedEventHandler CurrentHighlightGroupChanged; + public event FileRespawnedEventHandler FileRespawned; - public event BookmarkAddedEventHandler BookmarkAdded; + public event FilterListChangedEventHandler FilterListChanged; - public event BookmarkRemovedEventHandler BookmarkRemoved; + public event CurrentHighlightGroupChangedEventHandler CurrentHighlightGroupChanged; - public event BookmarkTextChangedEventHandler BookmarkTextChanged; + public event BookmarkAddedEventHandler BookmarkAdded; - public event ColumnizerChangedEventHandler ColumnizerChanged; + public event BookmarkRemovedEventHandler BookmarkRemoved; - public event SyncModeChangedEventHandler SyncModeChanged; + public event BookmarkTextChangedEventHandler BookmarkTextChanged; - #endregion + public event ColumnizerChangedEventHandler ColumnizerChanged; - #region Properties + public event SyncModeChangedEventHandler SyncModeChanged; - public Color BookmarkColor { get; set; } = Color.FromArgb(165, 200, 225); + #endregion - public ILogLineColumnizer CurrentColumnizer + #region Properties + + public Color BookmarkColor { get; set; } = Color.FromArgb(165, 200, 225); + + public ILogLineColumnizer CurrentColumnizer + { + get => _currentColumnizer; + private set { - get => _currentColumnizer; - private set + lock (_currentColumnizerLock) { - lock (_currentColumnizerLock) - { - _currentColumnizer = value; - _logger.Debug($"Setting columnizer {_currentColumnizer.GetName()} "); - } + _currentColumnizer = value; + _logger.Debug($"Setting columnizer {_currentColumnizer.GetName()} "); } } + } - public bool ShowBookmarkBubbles + public bool ShowBookmarkBubbles + { + get => _guiStateArgs.ShowBookmarkBubbles; + set { - get => _guiStateArgs.ShowBookmarkBubbles; - set - { - _guiStateArgs.ShowBookmarkBubbles = dataGridView.PaintWithOverlays = value; - dataGridView.Refresh(); - } + _guiStateArgs.ShowBookmarkBubbles = dataGridView.PaintWithOverlays = value; + dataGridView.Refresh(); } + } - public string FileName { get; private set; } + public string FileName { get; private set; } - public string SessionFileName { get; set; } = null; + public string SessionFileName { get; set; } = null; - public bool IsMultiFile - { - get => _isMultiFile; - private set => _guiStateArgs.IsMultiFileActive = _isMultiFile = value; - } + public bool IsMultiFile + { + get => _isMultiFile; + private set => _guiStateArgs.IsMultiFileActive = _isMultiFile = value; + } - public bool IsTempFile { get; } + public bool IsTempFile { get; } - private readonly IConfigManager ConfigManager; + private readonly IConfigManager ConfigManager; - public string TempTitleName { get; set; } = ""; + public string TempTitleName { get; set; } = ""; - internal FilterPipe FilterPipe { get; set; } = null; + internal FilterPipe FilterPipe { get; set; } = null; - public string Title + public string Title + { + get { - get + if (IsTempFile) { - if (IsTempFile) - { - return TempTitleName; - } - - return FileName; + return TempTitleName; } + + return FileName; } + } - public ColumnizerCallback ColumnizerCallbackObject { get; } + public ColumnizerCallback ColumnizerCallbackObject { get; } - public bool ForcePersistenceLoading { get; set; } + public bool ForcePersistenceLoading { get; set; } - public string ForcedPersistenceFileName { get; set; } = null; + public string ForcedPersistenceFileName { get; set; } = null; - public Preferences Preferences => ConfigManager.Settings.Preferences; + public Preferences Preferences => ConfigManager.Settings.Preferences; - public string GivenFileName { get; set; } = null; + public string GivenFileName { get; set; } = null; - public TimeSyncList TimeSyncList { get; private set; } + public TimeSyncList TimeSyncList { get; private set; } - public bool IsTimeSynced => TimeSyncList != null; + public bool IsTimeSynced => TimeSyncList != null; - protected EncodingOptions EncodingOptions { get; set; } + protected EncodingOptions EncodingOptions { get; set; } - public IBookmarkData BookmarkData => _bookmarkProvider; + public IBookmarkData BookmarkData => _bookmarkProvider; - public Font MonospacedFont { get; private set; } + public Font MonospacedFont { get; private set; } - public Font NormalFont { get; private set; } + public Font NormalFont { get; private set; } - public Font BoldFont { get; private set; } + public Font BoldFont { get; private set; } - LogfileReader ILogWindow.LogFileReader => _logFileReader; + LogfileReader ILogWindow.LogFileReader => _logFileReader; - event FileSizeChangedEventHandler ILogWindow.FileSizeChanged + event FileSizeChangedEventHandler ILogWindow.FileSizeChanged + { + add { - add - { - this.FileSizeChanged += new FileSizeChangedEventHandler(value); - } - - remove - { - this.FileSizeChanged -= new FileSizeChangedEventHandler(value); - } + this.FileSizeChanged += new FileSizeChangedEventHandler(value); } - event EventHandler ILogWindow.TailFollowed + remove { - add - { - this.TailFollowed += new TailFollowedEventHandler(value); - } - - remove - { - this.TailFollowed -= new TailFollowedEventHandler(value); - } + this.FileSizeChanged -= new FileSizeChangedEventHandler(value); } + } - #endregion - - #region Public methods - - public ILogLine GetLogLine(int lineNum) + event EventHandler ILogWindow.TailFollowed + { + add { - return _logFileReader.GetLogLine(lineNum); + this.TailFollowed += new TailFollowedEventHandler(value); } - public Bookmark GetBookmarkForLine(int lineNum) + remove { - return _bookmarkProvider.GetBookmarkForLine(lineNum); + this.TailFollowed -= new TailFollowedEventHandler(value); } + } - #endregion + #endregion - #region Internals + #region Public methods - internal IColumnizedLogLine GetColumnsForLine(int lineNumber) - { - return _columnCache.GetColumnsForLine(_logFileReader, lineNumber, CurrentColumnizer, ColumnizerCallbackObject); - - //string line = this.logFileReader.GetLogLine(lineNumber); - //if (line != null) - //{ - // string[] cols; - // this.columnizerCallback.LineNum = lineNumber; - // cols = this.CurrentColumnizer.SplitLine(this.columnizerCallback, line); - // return cols; - //} - //else - //{ - // return null; - //} - } + public ILogLine GetLogLine (int lineNum) + { + return _logFileReader.GetLogLine(lineNum); + } - internal void RefreshAllGrids() - { - dataGridView.Refresh(); - filterGridView.Refresh(); - } + public Bookmark GetBookmarkForLine (int lineNum) + { + return _bookmarkProvider.GetBookmarkForLine(lineNum); + } + + #endregion + + #region Internals + + internal IColumnizedLogLine GetColumnsForLine (int lineNumber) + { + return _columnCache.GetColumnsForLine(_logFileReader, lineNumber, CurrentColumnizer, ColumnizerCallbackObject); + + //string line = this.logFileReader.GetLogLine(lineNumber); + //if (line != null) + //{ + // string[] cols; + // this.columnizerCallback.LineNum = lineNumber; + // cols = this.CurrentColumnizer.SplitLine(this.columnizerCallback, line); + // return cols; + //} + //else + //{ + // return null; + //} + } + + internal void RefreshAllGrids () + { + dataGridView.Refresh(); + filterGridView.Refresh(); + } - internal void ChangeMultifileMask() + internal void ChangeMultifileMask () + { + MultiFileMaskDialog dlg = new(this, FileName) { - MultiFileMaskDialog dlg = new(this, FileName) - { - Owner = this, - MaxDays = _multiFileOptions.MaxDayTry, - FileNamePattern = _multiFileOptions.FormatPattern - }; + Owner = this, + MaxDays = _multiFileOptions.MaxDayTry, + FileNamePattern = _multiFileOptions.FormatPattern + }; - if (dlg.ShowDialog() == DialogResult.OK) + if (dlg.ShowDialog() == DialogResult.OK) + { + _multiFileOptions.FormatPattern = dlg.FileNamePattern; + _multiFileOptions.MaxDayTry = dlg.MaxDays; + if (IsMultiFile) { - _multiFileOptions.FormatPattern = dlg.FileNamePattern; - _multiFileOptions.MaxDayTry = dlg.MaxDays; - if (IsMultiFile) - { - Reload(); - } + Reload(); } } + } - internal void ToggleColumnFinder(bool show, bool setFocus) + internal void ToggleColumnFinder (bool show, bool setFocus) + { + _guiStateArgs.ColumnFinderVisible = show; + if (show) { - _guiStateArgs.ColumnFinderVisible = show; - if (show) - { - columnComboBox.AutoCompleteMode = AutoCompleteMode.Suggest; - columnComboBox.AutoCompleteSource = AutoCompleteSource.CustomSource; - columnComboBox.AutoCompleteCustomSource = [.. CurrentColumnizer.GetColumnNames()]; - if (setFocus) - { - columnComboBox.Focus(); - } - } - else + columnComboBox.AutoCompleteMode = AutoCompleteMode.Suggest; + columnComboBox.AutoCompleteSource = AutoCompleteSource.CustomSource; + columnComboBox.AutoCompleteCustomSource = [.. CurrentColumnizer.GetColumnNames()]; + if (setFocus) { - dataGridView.Focus(); + columnComboBox.Focus(); } - - tableLayoutPanel1.RowStyles[0].Height = show ? 28 : 0; + } + else + { + dataGridView.Focus(); } - #endregion + tableLayoutPanel1.RowStyles[0].Height = show ? 28 : 0; + } - #region Overrides + #endregion - protected override string GetPersistString() - { - return "LogWindow#" + FileName; - } + #region Overrides - #endregion + protected override string GetPersistString () + { + return "LogWindow#" + FileName; + } + + #endregion - private void OnButtonSizeChanged(object sender, EventArgs e) + private void OnButtonSizeChanged (object sender, EventArgs e) + { + if (sender is Button button && button.Image != null) { - if (sender is Button button && button.Image != null) - { - button.ImageAlign = ContentAlignment.MiddleCenter; - button.Image = new Bitmap(button.Image, new Size(button.Size.Height, button.Size.Height)); - } + button.ImageAlign = ContentAlignment.MiddleCenter; + button.Image = new Bitmap(button.Image, new Size(button.Size.Height, button.Size.Height)); } + } - // used for external wait fx WaitForLoadFinished() + // used for external wait fx WaitForLoadFinished() - private delegate void SelectLineFx(int line, bool triggerSyncCall); + private delegate void SelectLineFx (int line, bool triggerSyncCall); - private Action, List, List> FilterFxAction; - //private delegate void FilterFx(FilterParams filterParams, List filterResultLines, List lastFilterResultLines, List filterHitList); + private Action, List, List> FilterFxAction; + //private delegate void FilterFx(FilterParams filterParams, List filterResultLines, List lastFilterResultLines, List filterHitList); - private delegate void UpdateProgressBarFx(int lineNum); + private delegate void UpdateProgressBarFx (int lineNum); - private delegate void SetColumnizerFx(ILogLineColumnizer columnizer); + private delegate void SetColumnizerFx (ILogLineColumnizer columnizer); - private delegate void WriteFilterToTabFinishedFx(FilterPipe pipe, string namePrefix, PersistenceData persistenceData); + private delegate void WriteFilterToTabFinishedFx (FilterPipe pipe, string namePrefix, PersistenceData persistenceData); - private delegate void SetBookmarkFx(int lineNum, string comment); + private delegate void SetBookmarkFx (int lineNum, string comment); - private delegate void FunctionWith1BoolParam(bool arg); + private delegate void FunctionWith1BoolParam (bool arg); - private delegate void PatternStatisticFx(PatternArgs patternArgs); + private delegate void PatternStatisticFx (PatternArgs patternArgs); - private delegate void ActionPluginExecuteFx(string keyword, string param, ILogExpertCallback callback, ILogLineColumnizer columnizer); + private delegate void ActionPluginExecuteFx (string keyword, string param, ILogExpertCallback callback, ILogLineColumnizer columnizer); - private delegate void PositionAfterReloadFx(ReloadMemento reloadMemento); + private delegate void PositionAfterReloadFx (ReloadMemento reloadMemento); - private delegate void AutoResizeColumnsFx(BufferedDataGridView gridView); + private delegate void AutoResizeColumnsFx (BufferedDataGridView gridView); - private delegate bool BoolReturnDelegate(); + private delegate bool BoolReturnDelegate (); - // =================== ILogLineColumnizerCallback ============================ + // =================== ILogLineColumnizerCallback ============================ #if DEBUG - internal void DumpBufferInfo() - { - int currentLineNum = dataGridView.CurrentCellAddress.Y; - _logFileReader.LogBufferInfoForLine(currentLineNum); - } + internal void DumpBufferInfo () + { + int currentLineNum = dataGridView.CurrentCellAddress.Y; + _logFileReader.LogBufferInfoForLine(currentLineNum); + } - internal void DumpBufferDiagnostic() - { - _logFileReader.LogBufferDiagnostic(); - } + internal void DumpBufferDiagnostic () + { + _logFileReader.LogBufferDiagnostic(); + } - void ILogWindow.SelectLine(int lineNum, bool v1, bool v2) - { - SelectLine(lineNum, v1, v2); - } + void ILogWindow.SelectLine (int lineNum, bool v1, bool v2) + { + SelectLine(lineNum, v1, v2); + } - void ILogWindow.AddTempFileTab(string fileName, string title) - { - AddTempFileTab(fileName, title); - } + void ILogWindow.AddTempFileTab (string fileName, string title) + { + AddTempFileTab(fileName, title); + } - void ILogWindow.WritePipeTab(IList lineEntryList, string title) - { - WritePipeTab(lineEntryList, title); - } -#endif + void ILogWindow.WritePipeTab (IList lineEntryList, string title) + { + WritePipeTab(lineEntryList, title); } +#endif } \ No newline at end of file diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs index 6259de88..45366680 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs @@ -1,17 +1,19 @@ -using LogExpert.Core.Config; +using LogExpert.Core.Config; using LogExpert.Core.Entities; using LogExpert.Core.Enums; using LogExpert.Core.Interface; using LogExpert.UI.Entities; using LogExpert.UI.Extensions.Forms; using LogExpert.UI.Interface; + using NLog; + using WeifenLuo.WinFormsUI.Docking; namespace LogExpert.Dialogs; //TODO can be moved to Logexpert.UI if the PaintHelper has been refactored -public partial class BookmarkWindow : DockContent, ISharedToolWindow, IBookmarkView +public partial class BookmarkWindow : DockContent, ISharedToolWindow { #region Fields @@ -26,7 +28,7 @@ public partial class BookmarkWindow : DockContent, ISharedToolWindow, IBookmarkV #region cTor - public BookmarkWindow() + public BookmarkWindow () { InitializeComponent(); AutoScaleDimensions = new SizeF(96F, 96F); @@ -42,7 +44,7 @@ public BookmarkWindow() #region ColorTheme - public void ChangeTheme(Control.ControlCollection container) + public void ChangeTheme (Control.ControlCollection container) { #region ApplyColorToAllControls foreach (Control component in container) @@ -108,7 +110,7 @@ public bool ShowBookmarkCommentColumn #region Public methods - public void SetColumnizer(ILogLineColumnizer columnizer) + public void SetColumnizer (ILogLineColumnizer columnizer) { PaintHelper.SetColumnizer(columnizer, bookmarkDataGridView); @@ -133,7 +135,7 @@ public void SetColumnizer(ILogLineColumnizer columnizer) /// /// Called from LogWindow after reloading and when double clicking a header divider. /// - public void ResizeColumns() + public void ResizeColumns () { // this.bookmarkDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); for (int i = 2; i < bookmarkDataGridView.ColumnCount; ++i) @@ -142,7 +144,7 @@ public void ResizeColumns() } } - public void UpdateView() + public void UpdateView () { bookmarkDataGridView.RowCount = bookmarkData?.Bookmarks.Count ?? 0; ResizeColumns(); @@ -153,7 +155,7 @@ public void UpdateView() /// Called from LogWindow if the bookmark text was changed via popup window /// /// - public void BookmarkTextChanged(Bookmark bookmark) + public void BookmarkTextChanged (Bookmark bookmark) { int rowIndex = bookmarkDataGridView.CurrentCellAddress.Y; if (rowIndex == -1) @@ -169,7 +171,7 @@ public void BookmarkTextChanged(Bookmark bookmark) bookmarkDataGridView.Refresh(); } - public void SelectBookmark(int lineNum) + public void SelectBookmark (int lineNum) { if (bookmarkData.IsBookmarkAtLine(lineNum)) { @@ -184,7 +186,7 @@ public void SelectBookmark(int lineNum) } } - public void SetBookmarkData(IBookmarkData bookmarkData) + public void SetBookmarkData (IBookmarkData bookmarkData) { this.bookmarkData = bookmarkData; bookmarkDataGridView.RowCount = bookmarkData?.Bookmarks.Count ?? 0; @@ -192,7 +194,8 @@ public void SetBookmarkData(IBookmarkData bookmarkData) } //TODO: BAD DESIGN! FIX!!! - public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags, IConfigManager configManager) { + public void PreferencesChanged (Preferences newPreferences, bool isLoadTime, SettingsFlags flags, IConfigManager configManager) + { if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors) { SetFont(newPreferences.fontName, newPreferences.fontSize); @@ -207,12 +210,12 @@ public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, Sett } //TODO: BAD DESIGN! FIX!!! - public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags) + public void PreferencesChanged (Preferences newPreferences, bool isLoadTime, SettingsFlags flags) { PreferencesChanged(newPreferences, isLoadTime, flags, null); } - public void SetCurrentFile(IFileViewContext ctx) + public void SetCurrentFile (IFileViewContext ctx) { if (ctx != null) { @@ -234,7 +237,7 @@ public void SetCurrentFile(IFileViewContext ctx) UpdateView(); } - public void FileChanged() + public void FileChanged () { // nothing to do } @@ -243,12 +246,12 @@ public void FileChanged() #region Overrides - protected override string GetPersistString() + protected override string GetPersistString () { return WindowTypes.BookmarkWindow.ToString(); } - protected override void OnPaint(PaintEventArgs e) + protected override void OnPaint (PaintEventArgs e) { if (!splitContainer1.Visible) { @@ -270,7 +273,7 @@ protected override void OnPaint(PaintEventArgs e) #region Private Methods - private void SetFont(string fontName, float fontSize) + private void SetFont (string fontName, float fontSize) { Font font = new(new FontFamily(fontName), fontSize); bookmarkDataGridView.DefaultCellStyle.Font = font; @@ -278,7 +281,7 @@ private void SetFont(string fontName, float fontSize) bookmarkDataGridView.Refresh(); } - private void CommentPainting(BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) + private void CommentPainting (BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) { Color backColor = ColorMode.DockBackgroundColor; @@ -309,7 +312,7 @@ private void CommentPainting(BufferedDataGridView gridView, int rowIndex, DataGr e.PaintContent(e.CellBounds); } - private void DeleteSelectedBookmarks() + private void DeleteSelectedBookmarks () { List lineNumList = []; foreach (DataGridViewRow row in bookmarkDataGridView.SelectedRows) @@ -323,7 +326,7 @@ private void DeleteSelectedBookmarks() logView?.DeleteBookmarks(lineNumList); } - private static void InvalidateCurrentRow(BufferedDataGridView gridView) + private static void InvalidateCurrentRow (BufferedDataGridView gridView) { if (gridView.CurrentCellAddress.Y > -1) { @@ -331,7 +334,7 @@ private static void InvalidateCurrentRow(BufferedDataGridView gridView) } } - private void CurrentRowChanged(int rowIndex) + private void CurrentRowChanged (int rowIndex) { if (rowIndex == -1) { @@ -349,12 +352,12 @@ private void CurrentRowChanged(int rowIndex) } } - private void ShowCommentColumn(bool show) + private void ShowCommentColumn (bool show) { bookmarkDataGridView.Columns[1].Visible = show; } - private void HideIfNeeded() + private void HideIfNeeded () { splitContainer1.Visible = bookmarkDataGridView.RowCount > 0; } @@ -363,7 +366,7 @@ private void HideIfNeeded() #region Events handler - private void boomarkDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) + private void boomarkDataGridView_CellPainting (object sender, DataGridViewCellPaintingEventArgs e) { if (bookmarkData == null) { @@ -398,7 +401,7 @@ private void boomarkDataGridView_CellPainting(object sender, DataGridViewCellPai } } - private void OnBoomarkDataGridViewCellValueNeeded(object sender, DataGridViewCellValueEventArgs e) + private void OnBoomarkDataGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e) { if (bookmarkData == null) { @@ -425,7 +428,7 @@ private void OnBoomarkDataGridViewCellValueNeeded(object sender, DataGridViewCel } - private void boomarkDataGridView_MouseDoubleClick(object sender, MouseEventArgs e) + private void boomarkDataGridView_MouseDoubleClick (object sender, MouseEventArgs e) { // if (this.bookmarkDataGridView.CurrentRow != null) // { @@ -434,14 +437,14 @@ private void boomarkDataGridView_MouseDoubleClick(object sender, MouseEventArgs // } } - private void boomarkDataGridView_ColumnDividerDoubleClick(object sender, + private void boomarkDataGridView_ColumnDividerDoubleClick (object sender, DataGridViewColumnDividerDoubleClickEventArgs e) { e.Handled = true; ResizeColumns(); } - private void bookmarkGridView_KeyDown(object sender, KeyEventArgs e) + private void bookmarkGridView_KeyDown (object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { @@ -470,22 +473,22 @@ private void bookmarkGridView_KeyDown(object sender, KeyEventArgs e) } } - private void bookmarkGridView_Enter(object sender, EventArgs e) + private void bookmarkGridView_Enter (object sender, EventArgs e) { InvalidateCurrentRow(bookmarkDataGridView); } - private void bookmarkGridView_Leave(object sender, EventArgs e) + private void bookmarkGridView_Leave (object sender, EventArgs e) { InvalidateCurrentRow(bookmarkDataGridView); } - private void deleteBookmarksToolStripMenuItem_Click(object sender, EventArgs e) + private void deleteBookmarksToolStripMenuItem_Click (object sender, EventArgs e) { DeleteSelectedBookmarks(); } - private void bookmarkTextBox_TextChanged(object sender, EventArgs e) + private void bookmarkTextBox_TextChanged (object sender, EventArgs e) { if (!bookmarkTextBox.Enabled) { @@ -508,7 +511,7 @@ private void bookmarkTextBox_TextChanged(object sender, EventArgs e) logView?.RefreshLogView(); } - private void bookmarkDataGridView_SelectionChanged(object sender, EventArgs e) + private void bookmarkDataGridView_SelectionChanged (object sender, EventArgs e) { if (bookmarkDataGridView.SelectedRows.Count != 1 || bookmarkDataGridView.SelectedRows[0].Index >= bookmarkData.Bookmarks.Count) @@ -521,7 +524,7 @@ private void bookmarkDataGridView_SelectionChanged(object sender, EventArgs e) } } - private void bookmarkDataGridView_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) + private void bookmarkDataGridView_PreviewKeyDown (object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Tab) { @@ -529,7 +532,7 @@ private void bookmarkDataGridView_PreviewKeyDown(object sender, PreviewKeyDownEv } } - private void bookmarkDataGridView_CellToolTipTextNeeded(object sender, + private void bookmarkDataGridView_CellToolTipTextNeeded (object sender, DataGridViewCellToolTipTextNeededEventArgs e) { if (e.ColumnIndex != 0 || e.RowIndex <= -1 || e.RowIndex >= bookmarkData.Bookmarks.Count) @@ -545,7 +548,7 @@ private void bookmarkDataGridView_CellToolTipTextNeeded(object sender, } } - private void bookmarkDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) + private void bookmarkDataGridView_CellDoubleClick (object sender, DataGridViewCellEventArgs e) { // Toggle bookmark when double-clicking on the first column if (e.ColumnIndex == 0 && e.RowIndex >= 0 && bookmarkDataGridView.CurrentRow != null) @@ -597,7 +600,7 @@ private void bookmarkDataGridView_CellDoubleClick(object sender, DataGridViewCel } } - private void removeCommentsToolStripMenuItem_Click(object sender, EventArgs e) + private void removeCommentsToolStripMenuItem_Click (object sender, EventArgs e) { if ( MessageBox.Show("Really remove bookmark comments for selected lines?", "LogExpert", @@ -619,12 +622,12 @@ private void removeCommentsToolStripMenuItem_Click(object sender, EventArgs e) } } - private void commentColumnCheckBox_CheckedChanged(object sender, EventArgs e) + private void commentColumnCheckBox_CheckedChanged (object sender, EventArgs e) { ShowCommentColumn(commentColumnCheckBox.Checked); } - private void BookmarkWindow_ClientSizeChanged(object sender, EventArgs e) + private void BookmarkWindow_ClientSizeChanged (object sender, EventArgs e) { if (Width > 0 && Height > 0) { @@ -653,17 +656,17 @@ private void BookmarkWindow_ClientSizeChanged(object sender, EventArgs e) } } - private void bookmarkDataGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) + private void bookmarkDataGridView_RowsAdded (object sender, DataGridViewRowsAddedEventArgs e) { HideIfNeeded(); } - private void bookmarkDataGridView_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e) + private void bookmarkDataGridView_RowsRemoved (object sender, DataGridViewRowsRemovedEventArgs e) { HideIfNeeded(); } - private void BookmarkWindow_SizeChanged(object sender, EventArgs e) + private void BookmarkWindow_SizeChanged (object sender, EventArgs e) { // if (!this.splitContainer1.Visible) // { From 7e7e6e97885795c1ce292d5c3a4b5d8b414ba4c7 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 1 Jun 2025 21:15:04 +0200 Subject: [PATCH 053/142] readded IBookmarkView since its used other optimizations --- .../Controls/LogWindow/LogWindow.cs | 4 +- .../Controls/LogWindow/TimeSyncList.cs | 121 ++++--- src/LogExpert.UI/Dialogs/BookmarkWindow.cs | 4 +- .../Dialogs/LogTabWindow/LogTabWindow.cs | 54 +-- .../LogTabWindow/LogTabWindowEventHandlers.cs | 219 ++++++------ .../LogTabWindow/LogTabWindowPrivate.cs | 320 ++++++++++-------- .../LogTabWindow/LogTabWindowPublic.cs | 46 +-- src/LogExpert.UI/Entities/WindowFileEntry.cs | 55 ++- src/LogExpert/Classes/LogExpertProxy.cs | 4 +- src/LogExpert/Program.cs | 5 +- src/Logexpert.Core/Interface/IBookmarkView.cs | 27 ++ .../LogTabWindow/AbstractLogTabWindow.cs | 13 + .../LogTabWindow/StaticLogTabWindowData.cs | 12 + 13 files changed, 478 insertions(+), 406 deletions(-) create mode 100644 src/Logexpert.Core/Interface/IBookmarkView.cs create mode 100644 src/Logexpert.UI/Dialogs/LogTabWindow/AbstractLogTabWindow.cs create mode 100644 src/Logexpert.UI/Dialogs/LogTabWindow/StaticLogTabWindowData.cs diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index 3d2334b6..9cd0514e 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -22,8 +22,8 @@ namespace LogExpert.UI.Controls.LogWindow; -//TODO: Implemented 4 interfaces explicitly. Find them by searcginh: ILogWindow. -internal partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILogWindow +//TODO: Implemented 4 interfaces explicitly. Find them by searching: ILogWindow. +public partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILogWindow { #region Fields diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs index 67d5c392..5ed65d2c 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs @@ -1,101 +1,100 @@ -namespace LogExpert.UI.Controls.LogWindow +namespace LogExpert.UI.Controls.LogWindow; + +/// +/// Holds all windows which are in sync via timestamp +/// +public class TimeSyncList { - /// - /// Holds all windows which are in sync via timestamp - /// - internal class TimeSyncList - { - #region Fields + #region Fields - private readonly IList logWindowList = new List(); + private readonly IList logWindowList = new List(); - #endregion + #endregion - #region Delegates + #region Delegates - public delegate void WindowRemovedEventHandler(object sender, EventArgs e); + public delegate void WindowRemovedEventHandler (object sender, EventArgs e); - #endregion + #endregion - #region Events + #region Events - public event WindowRemovedEventHandler WindowRemoved; + public event WindowRemovedEventHandler WindowRemoved; - #endregion + #endregion - #region Properties + #region Properties - public DateTime CurrentTimestamp { get; set; } + public DateTime CurrentTimestamp { get; set; } - public int Count - { - get { return logWindowList.Count; } - } + public int Count + { + get { return logWindowList.Count; } + } - #endregion + #endregion - #region Public methods + #region Public methods - public void AddWindow(LogWindow logWindow) + public void AddWindow (LogWindow logWindow) + { + lock (logWindowList) { - lock (logWindowList) + if (!logWindowList.Contains(logWindow)) { - if (!logWindowList.Contains(logWindow)) - { - logWindowList.Add(logWindow); - } + logWindowList.Add(logWindow); } } + } - public void RemoveWindow(LogWindow logWindow) + public void RemoveWindow (LogWindow logWindow) + { + lock (logWindowList) { - lock (logWindowList) - { - logWindowList.Remove(logWindow); - } - OnWindowRemoved(); + logWindowList.Remove(logWindow); } + OnWindowRemoved(); + } - /// - /// Scrolls all LogWindows to the given timestamp - /// - /// - /// - public void NavigateToTimestamp(DateTime timestamp, LogWindow sender) + /// + /// Scrolls all LogWindows to the given timestamp + /// + /// + /// + public void NavigateToTimestamp (DateTime timestamp, LogWindow sender) + { + CurrentTimestamp = timestamp; + lock (logWindowList) { - CurrentTimestamp = timestamp; - lock (logWindowList) + foreach (LogWindow logWindow in logWindowList) { - foreach (LogWindow logWindow in logWindowList) + if (sender != logWindow) { - if (sender != logWindow) - { - logWindow.ScrollToTimestamp(timestamp, false, false); - } + logWindow.ScrollToTimestamp(timestamp, false, false); } } } + } - public bool Contains(LogWindow logWindow) - { - return logWindowList.Contains(logWindow); - } + public bool Contains (LogWindow logWindow) + { + return logWindowList.Contains(logWindow); + } - #endregion + #endregion - #region Private Methods + #region Private Methods - private void OnWindowRemoved() + private void OnWindowRemoved () + { + if (WindowRemoved != null) { - if (WindowRemoved != null) - { - WindowRemoved(this, new EventArgs()); - } + WindowRemoved(this, new EventArgs()); } - - #endregion } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs index 45366680..eb79c2b7 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs @@ -13,7 +13,7 @@ namespace LogExpert.Dialogs; //TODO can be moved to Logexpert.UI if the PaintHelper has been refactored -public partial class BookmarkWindow : DockContent, ISharedToolWindow +public partial class BookmarkWindow : DockContent, ISharedToolWindow, IBookmarkView { #region Fields @@ -219,7 +219,7 @@ public void SetCurrentFile (IFileViewContext ctx) { if (ctx != null) { - _logger.Debug("Current file changed to {0}", ctx.LogView.FileName); + _logger.Debug($"Current file changed to {ctx.LogView.FileName}"); lock (paintLock) { logView = ctx.LogView; diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs index e7093759..fba25456 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs @@ -1,20 +1,20 @@ -using LogExpert.Core.Classes; +using System.Reflection; +using System.Text; + using LogExpert.Core.Config; using LogExpert.Core.Entities; using LogExpert.Core.Interface; using LogExpert.Dialogs; using LogExpert.UI.Extensions; using LogExpert.UI.Extensions.Forms; + using NLog; -using System.Reflection; -using System.Text; -using static LogExpert.UI.Controls.LogTabWindow.LogTabWindow; namespace LogExpert.UI.Controls.LogTabWindow; // Data shared over all LogTabWindow instances //TODO: Can we get rid of this class? -internal partial class LogTabWindow : Form, ILogTabWindow +public partial class LogTabWindow : Form, ILogTabWindow { #region Fields @@ -64,7 +64,7 @@ internal partial class LogTabWindow : Form, ILogTabWindow #endregion #region cTor - public LogTabWindow(string[] fileNames, int instanceNumber, bool showInstanceNumbers, IConfigManager configManager) + public LogTabWindow (string[] fileNames, int instanceNumber, bool showInstanceNumbers, IConfigManager configManager) { AutoScaleDimensions = new SizeF(96F, 96F); AutoScaleMode = AutoScaleMode.Dpi; @@ -158,7 +158,7 @@ public LogTabWindow(string[] fileNames, int instanceNumber, bool showInstanceNum #endregion #region ColorTheme - public void ChangeTheme(Control.ControlCollection container) + public void ChangeTheme (Control.ControlCollection container) { ColorMode.LoadColorMode(ConfigManager.Settings.Preferences.darkMode); Win32.UseImmersiveDarkMode(Handle, ColorMode.DarkModeEnabled); @@ -258,21 +258,21 @@ public void ChangeTheme(Control.ControlCollection container) #region Delegates - private delegate void AddFileTabsDelegate(string[] fileNames); + private delegate void AddFileTabsDelegate (string[] fileNames); - private delegate void ExceptionFx(); + private delegate void ExceptionFx (); - private delegate void FileNotFoundDelegate(LogWindow.LogWindow logWin); + private delegate void FileNotFoundDelegate (LogWindow.LogWindow logWin); - private delegate void FileRespawnedDelegate(LogWindow.LogWindow logWin); + private delegate void FileRespawnedDelegate (LogWindow.LogWindow logWin); - public delegate void HighlightSettingsChangedEventHandler(object sender, EventArgs e); + public delegate void HighlightSettingsChangedEventHandler (object sender, EventArgs e); - private delegate void LoadMultiFilesDelegate(string[] fileName, EncodingOptions encodingOptions); + private delegate void LoadMultiFilesDelegate (string[] fileName, EncodingOptions encodingOptions); - private delegate void SetColumnizerFx(ILogLineColumnizer columnizer); + private delegate void SetColumnizerFx (ILogLineColumnizer columnizer); - private delegate void SetTabIconDelegate(LogWindow.LogWindow logWindow, Icon icon); + private delegate void SetTabIconDelegate (LogWindow.LogWindow logWindow, Icon icon); #endregion @@ -308,7 +308,7 @@ public LogWindow.LogWindow CurrentLogWindow #region Internals - internal HighlightGroup FindHighlightGroup(string groupName) + internal HighlightGroup FindHighlightGroup (string groupName) { lock (HighlightGroupList) { @@ -340,24 +340,4 @@ private class LogWindowData #endregion } -} - -public class StaticLogTabWindowData -{ - #region Properties - - public ILogTabWindow CurrentLockedMainWindow { get; set; } - - #endregion -} - -public abstract class AbstractLogTabWindow() -{ - public static StaticLogTabWindowData StaticData { get; set; } = new StaticLogTabWindowData(); - - public static ILogTabWindow Create(string[] fileNames, int instanceNumber, bool showInstanceNumbers, IConfigManager configManager) - { - return new LogTabWindow(fileNames, instanceNumber, showInstanceNumbers, configManager); - } - -} +} \ No newline at end of file diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs index 5da464b5..b515cdcb 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs @@ -1,13 +1,16 @@ -using LogExpert.Core.Classes; +using System.ComponentModel; +using System.Diagnostics; +using System.Text; + +using LogExpert.Core.Classes; using LogExpert.Core.Classes.Persister; using LogExpert.Core.Config; using LogExpert.Core.Entities; using LogExpert.Core.EventArguments; using LogExpert.Dialogs; using LogExpert.UI.Dialogs; -using System.ComponentModel; -using System.Diagnostics; -using System.Text; +using LogExpert.UI.Dialogs.LogTabWindow; + using WeifenLuo.WinFormsUI.Docking; namespace LogExpert.UI.Controls.LogTabWindow; @@ -15,12 +18,12 @@ partial class LogTabWindow { #region Events handler - private void OnBookmarkWindowVisibleChanged(object sender, EventArgs e) + private void OnBookmarkWindowVisibleChanged (object sender, EventArgs e) { _firstBookmarkWindowShow = false; } - private void OnLogTabWindowLoad(object sender, EventArgs e) + private void OnLogTabWindowLoad (object sender, EventArgs e) { ApplySettings(ConfigManager.Settings, SettingsFlags.All); if (ConfigManager.Settings.isMaximized) @@ -64,7 +67,7 @@ private void OnLogTabWindowLoad(object sender, EventArgs e) #endif } - private void OnLogTabWindowClosing(object sender, CancelEventArgs e) + private void OnLogTabWindowClosing (object sender, CancelEventArgs e) { try { @@ -105,7 +108,7 @@ private void OnLogTabWindowClosing(object sender, CancelEventArgs e) } } - private void OnStripMouseUp(object sender, MouseEventArgs e) + private void OnStripMouseUp (object sender, MouseEventArgs e) { if (sender is ToolStripDropDown dropDown) { @@ -113,7 +116,7 @@ private void OnStripMouseUp(object sender, MouseEventArgs e) } } - private void OnHistoryItemClicked(object sender, ToolStripItemClickedEventArgs e) + private void OnHistoryItemClicked (object sender, ToolStripItemClickedEventArgs e) { if (string.IsNullOrEmpty(e.ClickedItem.Text) == false) { @@ -121,7 +124,7 @@ private void OnHistoryItemClicked(object sender, ToolStripItemClickedEventArgs e } } - private void OnLogWindowDisposed(object sender, EventArgs e) + private void OnLogWindowDisposed (object sender, EventArgs e) { LogWindow.LogWindow logWindow = sender as LogWindow.LogWindow; @@ -135,12 +138,12 @@ private void OnLogWindowDisposed(object sender, EventArgs e) logWindow.Tag = null; } - private void OnExitToolStripMenuItemClick(object sender, EventArgs e) + private void OnExitToolStripMenuItemClick (object sender, EventArgs e) { Close(); } - private void OnSelectFilterToolStripMenuItemClick(object sender, EventArgs e) + private void OnSelectFilterToolStripMenuItemClick (object sender, EventArgs e) { if (CurrentLogWindow == null) { @@ -204,7 +207,7 @@ private void OnSelectFilterToolStripMenuItemClick(object sender, EventArgs e) } } - private void OnGoToLineToolStripMenuItemClick(object sender, EventArgs e) + private void OnGoToLineToolStripMenuItemClick (object sender, EventArgs e) { if (CurrentLogWindow == null) { @@ -223,22 +226,22 @@ private void OnGoToLineToolStripMenuItemClick(object sender, EventArgs e) } } - private void OnHighlightingToolStripMenuItemClick(object sender, EventArgs e) + private void OnHighlightingToolStripMenuItemClick (object sender, EventArgs e) { ShowHighlightSettingsDialog(); } - private void OnSearchToolStripMenuItemClick(object sender, EventArgs e) + private void OnSearchToolStripMenuItemClick (object sender, EventArgs e) { OpenSearchDialog(); } - private void OnOpenToolStripMenuItemClick(object sender, EventArgs e) + private void OnOpenToolStripMenuItemClick (object sender, EventArgs e) { OpenFileDialog(); } - private void OnLogTabWindowDragEnter(object sender, DragEventArgs e) + private void OnLogTabWindowDragEnter (object sender, DragEventArgs e) { #if DEBUG string[] formats = e.Data.GetFormats(); @@ -253,7 +256,7 @@ private void OnLogTabWindowDragEnter(object sender, DragEventArgs e) #endif } - private void OnLogWindowDragOver(object sender, DragEventArgs e) + private void OnLogWindowDragOver (object sender, DragEventArgs e) { if (!e.Data.GetDataPresent(DataFormats.FileDrop)) { @@ -265,7 +268,7 @@ private void OnLogWindowDragOver(object sender, DragEventArgs e) } } - private void OnLogWindowDragDrop(object sender, DragEventArgs e) + private void OnLogWindowDragDrop (object sender, DragEventArgs e) { #if DEBUG string[] formats = e.Data.GetFormats(); @@ -290,7 +293,7 @@ private void OnLogWindowDragDrop(object sender, DragEventArgs e) } } - private void OnTimeShiftToolStripMenuItemCheckStateChanged(object sender, EventArgs e) + private void OnTimeShiftToolStripMenuItemCheckStateChanged (object sender, EventArgs e) { if (!_skipEvents && CurrentLogWindow != null) { @@ -301,65 +304,65 @@ private void OnTimeShiftToolStripMenuItemCheckStateChanged(object sender, EventA } } - private void OnAboutToolStripMenuItemClick(object sender, EventArgs e) + private void OnAboutToolStripMenuItemClick (object sender, EventArgs e) { AboutBox aboutBox = new(); aboutBox.TopMost = TopMost; aboutBox.ShowDialog(); } - private void OnFilterToolStripMenuItemClick(object sender, EventArgs e) + private void OnFilterToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ToggleFilterPanel(); } - private void OnMultiFileToolStripMenuItemClick(object sender, EventArgs e) + private void OnMultiFileToolStripMenuItemClick (object sender, EventArgs e) { ToggleMultiFile(); fileToolStripMenuItem.HideDropDown(); } - private void OnGuiStateUpdate(object sender, GuiStateArgs e) + private void OnGuiStateUpdate (object sender, GuiStateArgs e) { BeginInvoke(GuiStateUpdateWorker, e); } - private void OnColumnizerChanged(object sender, ColumnizerEventArgs e) + private void OnColumnizerChanged (object sender, ColumnizerEventArgs e) { _bookmarkWindow?.SetColumnizer(e.Columnizer); } - private void OnBookmarkAdded(object sender, EventArgs e) + private void OnBookmarkAdded (object sender, EventArgs e) { _bookmarkWindow.UpdateView(); } - private void OnBookmarkTextChanged(object sender, BookmarkEventArgs e) + private void OnBookmarkTextChanged (object sender, BookmarkEventArgs e) { _bookmarkWindow.BookmarkTextChanged(e.Bookmark); } - private void OnBookmarkRemoved(object sender, EventArgs e) + private void OnBookmarkRemoved (object sender, EventArgs e) { _bookmarkWindow.UpdateView(); } - private void OnProgressBarUpdate(object sender, ProgressEventArgs e) + private void OnProgressBarUpdate (object sender, ProgressEventArgs e) { Invoke(ProgressBarUpdateWorker, e); } - private void OnStatusLineEvent(object sender, StatusLineEventArgs e) + private void OnStatusLineEvent (object sender, StatusLineEventArgs e) { StatusLineEventWorker(e); } - private void OnFollowTailCheckBoxClick(object sender, EventArgs e) + private void OnFollowTailCheckBoxClick (object sender, EventArgs e) { CurrentLogWindow?.FollowTailChanged(checkBoxFollowTail.Checked, false); } - private void OnLogTabWindowKeyDown(object sender, KeyEventArgs e) + private void OnLogTabWindowKeyDown (object sender, KeyEventArgs e) { if (e.KeyCode == Keys.W && e.Control) { @@ -375,22 +378,22 @@ private void OnLogTabWindowKeyDown(object sender, KeyEventArgs e) } } - private void OnCloseFileToolStripMenuItemClick(object sender, EventArgs e) + private void OnCloseFileToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.Close(); } - private void OnCellSelectModeToolStripMenuItemClick(object sender, EventArgs e) + private void OnCellSelectModeToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.SetCellSelectionMode(cellSelectModeToolStripMenuItem.Checked); } - private void OnCopyMarkedLinesIntoNewTabToolStripMenuItemClick(object sender, EventArgs e) + private void OnCopyMarkedLinesIntoNewTabToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.CopyMarkedLinesToTab(); } - private void OnTimeShiftMenuTextBoxKeyDown(object sender, KeyEventArgs e) + private void OnTimeShiftMenuTextBoxKeyDown (object sender, KeyEventArgs e) { if (CurrentLogWindow == null) { @@ -404,12 +407,12 @@ private void OnTimeShiftMenuTextBoxKeyDown(object sender, KeyEventArgs e) } } - private void OnAlwaysOnTopToolStripMenuItemClick(object sender, EventArgs e) + private void OnAlwaysOnTopToolStripMenuItemClick (object sender, EventArgs e) { TopMost = alwaysOnTopToolStripMenuItem.Checked; } - private void OnFileSizeChanged(object sender, LogEventArgs e) + private void OnFileSizeChanged (object sender, LogEventArgs e) { if (sender.GetType().IsAssignableFrom(typeof(LogWindow.LogWindow))) { @@ -443,17 +446,17 @@ private void OnFileSizeChanged(object sender, LogEventArgs e) } } - private void OnLogWindowFileNotFound(object sender, EventArgs e) + private void OnLogWindowFileNotFound (object sender, EventArgs e) { Invoke(new FileNotFoundDelegate(FileNotFound), sender); } - private void OnLogWindowFileRespawned(object sender, EventArgs e) + private void OnLogWindowFileRespawned (object sender, EventArgs e) { Invoke(new FileRespawnedDelegate(FileRespawned), sender); } - private void OnLogWindowFilterListChanged(object sender, FilterListChangedEventArgs e) + private void OnLogWindowFilterListChanged (object sender, FilterListChangedEventArgs e) { lock (_logWindowList) { @@ -468,14 +471,14 @@ private void OnLogWindowFilterListChanged(object sender, FilterListChangedEventA ConfigManager.Save(SettingsFlags.FilterList); } - private void OnLogWindowCurrentHighlightGroupChanged(object sender, CurrentHighlightGroupChangedEventArgs e) + private void OnLogWindowCurrentHighlightGroupChanged (object sender, CurrentHighlightGroupChangedEventArgs e) { OnHighlightSettingsChanged(); ConfigManager.Settings.Preferences.HighlightGroupList = HighlightGroupList; ConfigManager.Save(SettingsFlags.HighlightSettings); } - private void OnTailFollowed(object sender, EventArgs e) + private void OnTailFollowed (object sender, EventArgs e) { if (dockPanel.ActiveContent == null) { @@ -493,7 +496,7 @@ private void OnTailFollowed(object sender, EventArgs e) } } - private void OnLogWindowSyncModeChanged(object sender, SyncModeEventArgs e) + private void OnLogWindowSyncModeChanged (object sender, SyncModeEventArgs e) { if (!Disposing) { @@ -508,47 +511,47 @@ private void OnLogWindowSyncModeChanged(object sender, SyncModeEventArgs e) } } - private void OnToggleBookmarkToolStripMenuItemClick(object sender, EventArgs e) + private void OnToggleBookmarkToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ToggleBookmark(); } - private void OnJumpToNextToolStripMenuItemClick(object sender, EventArgs e) + private void OnJumpToNextToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.JumpNextBookmark(); } - private void OnJumpToPrevToolStripMenuItemClick(object sender, EventArgs e) + private void OnJumpToPrevToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.JumpPrevBookmark(); } - private void OnASCIIToolStripMenuItemClick(object sender, EventArgs e) + private void OnASCIIToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ChangeEncoding(Encoding.ASCII); } - private void OnANSIToolStripMenuItemClick(object sender, EventArgs e) + private void OnANSIToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ChangeEncoding(Encoding.Default); } - private void OnUTF8ToolStripMenuItemClick(object sender, EventArgs e) + private void OnUTF8ToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ChangeEncoding(new UTF8Encoding(false)); } - private void OnUTF16ToolStripMenuItemClick(object sender, EventArgs e) + private void OnUTF16ToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ChangeEncoding(Encoding.Unicode); } - private void OnISO88591ToolStripMenuItemClick(object sender, EventArgs e) + private void OnISO88591ToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ChangeEncoding(Encoding.GetEncoding("iso-8859-1")); } - private void OnReloadToolStripMenuItemClick(object sender, EventArgs e) + private void OnReloadToolStripMenuItemClick (object sender, EventArgs e) { if (CurrentLogWindow != null) { @@ -559,12 +562,12 @@ private void OnReloadToolStripMenuItemClick(object sender, EventArgs e) } } - private void OnSettingsToolStripMenuItemClick(object sender, EventArgs e) + private void OnSettingsToolStripMenuItemClick (object sender, EventArgs e) { OpenSettings(0); } - private void OnDateTimeDragControlValueDragged(object sender, EventArgs e) + private void OnDateTimeDragControlValueDragged (object sender, EventArgs e) { if (CurrentLogWindow != null) { @@ -572,22 +575,22 @@ private void OnDateTimeDragControlValueDragged(object sender, EventArgs e) } } - private void OnDateTimeDragControlValueChanged(object sender, EventArgs e) + private void OnDateTimeDragControlValueChanged (object sender, EventArgs e) { CurrentLogWindow?.ScrollToTimestamp(dragControlDateTime.DateTime, true, true); } - private void OnLogTabWindowDeactivate(object sender, EventArgs e) + private void OnLogTabWindowDeactivate (object sender, EventArgs e) { CurrentLogWindow?.AppFocusLost(); } - private void OnLogTabWindowActivated(object sender, EventArgs e) + private void OnLogTabWindowActivated (object sender, EventArgs e) { CurrentLogWindow?.AppFocusGained(); } - private void OnShowBookmarkListToolStripMenuItemClick(object sender, EventArgs e) + private void OnShowBookmarkListToolStripMenuItemClick (object sender, EventArgs e) { if (_bookmarkWindow.Visible) { @@ -606,42 +609,42 @@ private void OnShowBookmarkListToolStripMenuItemClick(object sender, EventArgs e } } - private void OnToolStripButtonOpenClick(object sender, EventArgs e) + private void OnToolStripButtonOpenClick (object sender, EventArgs e) { OpenFileDialog(); } - private void OnToolStripButtonSearchClick(object sender, EventArgs e) + private void OnToolStripButtonSearchClick (object sender, EventArgs e) { OpenSearchDialog(); } - private void OnToolStripButtonFilterClick(object sender, EventArgs e) + private void OnToolStripButtonFilterClick (object sender, EventArgs e) { CurrentLogWindow?.ToggleFilterPanel(); } - private void OnToolStripButtonBookmarkClick(object sender, EventArgs e) + private void OnToolStripButtonBookmarkClick (object sender, EventArgs e) { CurrentLogWindow?.ToggleBookmark(); } - private void OnToolStripButtonUpClick(object sender, EventArgs e) + private void OnToolStripButtonUpClick (object sender, EventArgs e) { CurrentLogWindow?.JumpPrevBookmark(); } - private void OnToolStripButtonDownClick(object sender, EventArgs e) + private void OnToolStripButtonDownClick (object sender, EventArgs e) { CurrentLogWindow?.JumpNextBookmark(); } - private void OnShowHelpToolStripMenuItemClick(object sender, EventArgs e) + private void OnShowHelpToolStripMenuItemClick (object sender, EventArgs e) { Help.ShowHelp(this, "LogExpert.chm"); } - private void OnHideLineColumnToolStripMenuItemClick(object sender, EventArgs e) + private void OnHideLineColumnToolStripMenuItemClick (object sender, EventArgs e) { ConfigManager.Settings.hideLineColumn = hideLineColumnToolStripMenuItem.Checked; lock (_logWindowList) @@ -658,12 +661,12 @@ private void OnHideLineColumnToolStripMenuItemClick(object sender, EventArgs e) // Tab context menu stuff // ================================================================== - private void OnCloseThisTabToolStripMenuItemClick(object sender, EventArgs e) + private void OnCloseThisTabToolStripMenuItemClick (object sender, EventArgs e) { (dockPanel.ActiveContent as LogWindow.LogWindow).Close(); } - private void OnCloseOtherTabsToolStripMenuItemClick(object sender, EventArgs e) + private void OnCloseOtherTabsToolStripMenuItemClick (object sender, EventArgs e) { IList closeList = new List(); lock (_logWindowList) @@ -682,12 +685,12 @@ private void OnCloseOtherTabsToolStripMenuItemClick(object sender, EventArgs e) } } - private void OnCloseAllTabsToolStripMenuItemClick(object sender, EventArgs e) + private void OnCloseAllTabsToolStripMenuItemClick (object sender, EventArgs e) { CloseAllTabs(); } - private void OnTabColorToolStripMenuItemClick(object sender, EventArgs e) + private void OnTabColorToolStripMenuItemClick (object sender, EventArgs e) { LogWindow.LogWindow logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; @@ -727,7 +730,7 @@ private void OnTabColorToolStripMenuItemClick(object sender, EventArgs e) } } - private void OnLogTabWindowSizeChanged(object sender, EventArgs e) + private void OnLogTabWindowSizeChanged (object sender, EventArgs e) { if (WindowState != FormWindowState.Minimized) { @@ -735,7 +738,7 @@ private void OnLogTabWindowSizeChanged(object sender, EventArgs e) } } - private void OnSaveProjectToolStripMenuItemClick(object sender, EventArgs e) + private void OnSaveProjectToolStripMenuItemClick (object sender, EventArgs e) { SaveFileDialog dlg = new(); dlg.DefaultExt = "lxj"; @@ -766,7 +769,7 @@ private void OnSaveProjectToolStripMenuItemClick(object sender, EventArgs e) } } - private void OnLoadProjectToolStripMenuItemClick(object sender, EventArgs e) + private void OnLoadProjectToolStripMenuItemClick (object sender, EventArgs e) { OpenFileDialog dlg = new(); dlg.DefaultExt = "lxj"; @@ -779,7 +782,7 @@ private void OnLoadProjectToolStripMenuItemClick(object sender, EventArgs e) } } - private void OnToolStripButtonBubblesClick(object sender, EventArgs e) + private void OnToolStripButtonBubblesClick (object sender, EventArgs e) { if (CurrentLogWindow != null) { @@ -787,13 +790,13 @@ private void OnToolStripButtonBubblesClick(object sender, EventArgs e) } } - private void OnCopyPathToClipboardToolStripMenuItemClick(object sender, EventArgs e) + private void OnCopyPathToClipboardToolStripMenuItemClick (object sender, EventArgs e) { LogWindow.LogWindow logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; Clipboard.SetText(logWindow.Title); } - private void OnFindInExplorerToolStripMenuItemClick(object sender, EventArgs e) + private void OnFindInExplorerToolStripMenuItemClick (object sender, EventArgs e) { LogWindow.LogWindow logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; @@ -804,22 +807,22 @@ private void OnFindInExplorerToolStripMenuItemClick(object sender, EventArgs e) explorer.Start(); } - private void OnExportBookmarksToolStripMenuItemClick(object sender, EventArgs e) + private void OnExportBookmarksToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ExportBookmarkList(); } - private void OnHighlightGroupsComboBoxDropDownClosed(object sender, EventArgs e) + private void OnHighlightGroupsComboBoxDropDownClosed (object sender, EventArgs e) { ApplySelectedHighlightGroup(); } - private void OnHighlightGroupsComboBoxSelectedIndexChanged(object sender, EventArgs e) + private void OnHighlightGroupsComboBoxSelectedIndexChanged (object sender, EventArgs e) { ApplySelectedHighlightGroup(); } - private void OnHighlightGroupsComboBoxMouseUp(object sender, MouseEventArgs e) + private void OnHighlightGroupsComboBoxMouseUp (object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { @@ -828,7 +831,7 @@ private void OnHighlightGroupsComboBoxMouseUp(object sender, MouseEventArgs e) } - private void OnConfigChanged(object sender, ConfigChangedEventArgs e) + private void OnConfigChanged (object sender, ConfigChangedEventArgs e) { if (LogExpertProxy != null) { @@ -836,31 +839,31 @@ private void OnConfigChanged(object sender, ConfigChangedEventArgs e) } } - private void OnDumpLogBufferInfoToolStripMenuItemClick(object sender, EventArgs e) + private void OnDumpLogBufferInfoToolStripMenuItemClick (object sender, EventArgs e) { #if DEBUG CurrentLogWindow?.DumpBufferInfo(); #endif } - private void OnDumpBufferDiagnosticToolStripMenuItemClick(object sender, EventArgs e) + private void OnDumpBufferDiagnosticToolStripMenuItemClick (object sender, EventArgs e) { #if DEBUG CurrentLogWindow?.DumpBufferDiagnostic(); #endif } - private void OnRunGCToolStripMenuItemClick(object sender, EventArgs e) + private void OnRunGCToolStripMenuItemClick (object sender, EventArgs e) { RunGC(); } - private void OnGCInfoToolStripMenuItemClick(object sender, EventArgs e) + private void OnGCInfoToolStripMenuItemClick (object sender, EventArgs e) { DumpGCInfo(); } - private void OnToolsToolStripMenuItemDropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) + private void OnToolsToolStripMenuItemDropDownItemClicked (object sender, ToolStripItemClickedEventArgs e) { if (e.ClickedItem.Tag is ToolEntry tag) { @@ -868,98 +871,98 @@ private void OnToolsToolStripMenuItemDropDownItemClicked(object sender, ToolStri } } - private void OnExternalToolsToolStripItemClicked(object sender, ToolStripItemClickedEventArgs e) + private void OnExternalToolsToolStripItemClicked (object sender, ToolStripItemClickedEventArgs e) { ToolButtonClick(e.ClickedItem.Tag as ToolEntry); } - private void OnConfigureToolStripMenuItemClick(object sender, EventArgs e) + private void OnConfigureToolStripMenuItemClick (object sender, EventArgs e) { OpenSettings(2); } - private void OnThrowExceptionGUIThreadToolStripMenuItemClick(object sender, EventArgs e) + private void OnThrowExceptionGUIThreadToolStripMenuItemClick (object sender, EventArgs e) { throw new Exception("This is a test exception thrown by the GUI thread"); } - private void OnThrowExceptionBackgroundThToolStripMenuItemClick(object sender, EventArgs e) + private void OnThrowExceptionBackgroundThToolStripMenuItemClick (object sender, EventArgs e) { ExceptionFx fx = ThrowExceptionFx; fx.BeginInvoke(null, null); } - private void OnThrowExceptionBackgroundThreadToolStripMenuItemClick(object sender, EventArgs e) + private void OnThrowExceptionBackgroundThreadToolStripMenuItemClick (object sender, EventArgs e) { Thread thread = new(ThrowExceptionThreadFx); thread.IsBackground = true; thread.Start(); } - private void OnWarnToolStripMenuItemClick(object sender, EventArgs e) + private void OnWarnToolStripMenuItemClick (object sender, EventArgs e) { //_logger.GetLogger().LogLevel = _logger.Level.WARN; } - private void OnInfoToolStripMenuItemClick(object sender, EventArgs e) + private void OnInfoToolStripMenuItemClick (object sender, EventArgs e) { //_logger.Get_logger().LogLevel = _logger.Level.INFO; } - private void OnDebugToolStripMenuItemClick(object sender, EventArgs e) + private void OnDebugToolStripMenuItemClick (object sender, EventArgs e) { //_logger.Get_logger().LogLevel = _logger.Level.DEBUG; } - private void OnLogLevelToolStripMenuItemClick(object sender, EventArgs e) + private void OnLogLevelToolStripMenuItemClick (object sender, EventArgs e) { } - private void OnLogLevelToolStripMenuItemDropDownOpening(object sender, EventArgs e) + private void OnLogLevelToolStripMenuItemDropDownOpening (object sender, EventArgs e) { //warnToolStripMenuItem.Checked = _logger.Get_logger().LogLevel == _logger.Level.WARN; //infoToolStripMenuItem.Checked = _logger.Get_logger().LogLevel == _logger.Level.INFO; //debugToolStripMenuItem1.Checked = _logger.Get_logger().LogLevel == _logger.Level.DEBUG; } - private void OnDisableWordHighlightModeToolStripMenuItemClick(object sender, EventArgs e) + private void OnDisableWordHighlightModeToolStripMenuItemClick (object sender, EventArgs e) { DebugOptions.DisableWordHighlight = disableWordHighlightModeToolStripMenuItem.Checked; CurrentLogWindow?.RefreshAllGrids(); } - private void OnMultiFileMaskToolStripMenuItemClick(object sender, EventArgs e) + private void OnMultiFileMaskToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ChangeMultifileMask(); } - private void OnMultiFileEnabledStripMenuItemClick(object sender, EventArgs e) + private void OnMultiFileEnabledStripMenuItemClick (object sender, EventArgs e) { ToggleMultiFile(); } - private void OnLockInstanceToolStripMenuItemClick(object sender, EventArgs e) + private void OnLockInstanceToolStripMenuItemClick (object sender, EventArgs e) { AbstractLogTabWindow.StaticData.CurrentLockedMainWindow = lockInstanceToolStripMenuItem.Checked ? null : this; } - private void OnOptionToolStripMenuItemDropDownOpening(object sender, EventArgs e) + private void OnOptionToolStripMenuItemDropDownOpening (object sender, EventArgs e) { lockInstanceToolStripMenuItem.Enabled = !ConfigManager.Settings.Preferences.allowOnlyOneInstance; lockInstanceToolStripMenuItem.Checked = AbstractLogTabWindow.StaticData.CurrentLockedMainWindow == this; } - private void OnFileToolStripMenuItemDropDownOpening(object sender, EventArgs e) + private void OnFileToolStripMenuItemDropDownOpening (object sender, EventArgs e) { newFromClipboardToolStripMenuItem.Enabled = Clipboard.ContainsText(); } - private void OnNewFromClipboardToolStripMenuItemClick(object sender, EventArgs e) + private void OnNewFromClipboardToolStripMenuItemClick (object sender, EventArgs e) { PasteFromClipboard(); } - private void OnOpenURIToolStripMenuItemClick(object sender, EventArgs e) + private void OnOpenURIToolStripMenuItemClick (object sender, EventArgs e) { OpenUriDialog dlg = new() { @@ -977,7 +980,7 @@ private void OnOpenURIToolStripMenuItemClick(object sender, EventArgs e) } } - private void OnColumnFinderToolStripMenuItemClick(object sender, EventArgs e) + private void OnColumnFinderToolStripMenuItemClick (object sender, EventArgs e) { if (CurrentLogWindow != null && !_skipEvents) { @@ -985,7 +988,7 @@ private void OnColumnFinderToolStripMenuItemClick(object sender, EventArgs e) } } - private void OnDockPanelActiveContentChanged(object sender, EventArgs e) + private void OnDockPanelActiveContentChanged (object sender, EventArgs e) { if (dockPanel.ActiveContent is LogWindow.LogWindow window) { @@ -995,7 +998,7 @@ private void OnDockPanelActiveContentChanged(object sender, EventArgs e) } } - private void OnTabRenameToolStripMenuItemClick(object sender, EventArgs e) + private void OnTabRenameToolStripMenuItemClick (object sender, EventArgs e) { if (CurrentLogWindow != null) { diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs index e293b8c2..d6b6c722 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs @@ -1,4 +1,10 @@ -using LogExpert.Classes; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.Versioning; +using System.Security; +using System.Text; + +using LogExpert.Classes; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Columnizer; using LogExpert.Core.Classes.Persister; @@ -10,27 +16,25 @@ using LogExpert.PluginRegistry.FileSystem; using LogExpert.UI.Dialogs; using LogExpert.UI.Extensions; -using System.ComponentModel; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; + using WeifenLuo.WinFormsUI.Docking; namespace LogExpert.UI.Controls.LogTabWindow; -partial class LogTabWindow + +public partial class LogTabWindow { #region Private Methods /// /// Creates a temp file with the text content of the clipboard and opens the temp file in a new tab. /// - private void PasteFromClipboard() + [SupportedOSPlatform("windows")] + private void PasteFromClipboard () { if (Clipboard.ContainsText()) { - string text = Clipboard.GetText(); - string fileName = Path.GetTempFileName(); + var text = Clipboard.GetText(); + var fileName = Path.GetTempFileName(); using (FileStream fStream = new(fileName, FileMode.Append, FileAccess.Write, FileShare.Read)) using (StreamWriter writer = new(fStream, Encoding.Unicode)) @@ -39,27 +43,27 @@ private void PasteFromClipboard() writer.Close(); } - string title = "Clipboard"; + var title = "Clipboard"; LogWindow.LogWindow logWindow = AddTempFileTab(fileName, title); - LogWindowData data = logWindow.Tag as LogWindowData; - if (data != null) + if (logWindow.Tag is LogWindowData data) { SetTooltipText(logWindow, "Pasted on " + DateTime.Now); } } } - private void InitToolWindows() + private void InitToolWindows () { InitBookmarkWindow(); } - private void DestroyToolWindows() + private void DestroyToolWindows () { DestroyBookmarkWindow(); } - private void InitBookmarkWindow() + [SupportedOSPlatform("windows")] + private void InitBookmarkWindow () { _bookmarkWindow = new BookmarkWindow { @@ -72,13 +76,14 @@ private void InitBookmarkWindow() _firstBookmarkWindowShow = true; } - private void DestroyBookmarkWindow() + [SupportedOSPlatform("windows")] + private void DestroyBookmarkWindow () { _bookmarkWindow.HideOnClose = false; _bookmarkWindow.Close(); } - private void SaveLastOpenFilesList() + private void SaveLastOpenFilesList () { ConfigManager.Settings.lastOpenFilesList.Clear(); foreach (DockContent content in dockPanel.Contents) @@ -93,7 +98,8 @@ private void SaveLastOpenFilesList() } } - private void SaveWindowPosition() + [SupportedOSPlatform("windows")] + private void SaveWindowPosition () { SuspendLayout(); if (WindowState == FormWindowState.Normal) @@ -112,12 +118,12 @@ private void SaveWindowPosition() ResumeLayout(); } - private void SetTooltipText(LogWindow.LogWindow logWindow, string logFileName) + private void SetTooltipText (LogWindow.LogWindow logWindow, string logFileName) { logWindow.ToolTipText = logFileName; } - private void FillDefaultEncodingFromSettings(EncodingOptions encodingOptions) + private void FillDefaultEncodingFromSettings (EncodingOptions encodingOptions) { if (ConfigManager.Settings.Preferences.defaultEncoding != null) { @@ -133,9 +139,10 @@ private void FillDefaultEncodingFromSettings(EncodingOptions encodingOptions) } } - private void AddFileTabs(string[] fileNames) + [SupportedOSPlatform("windows")] + private void AddFileTabs (string[] fileNames) { - foreach (string fileName in fileNames) + foreach (var fileName in fileNames) { if (!string.IsNullOrEmpty(fileName)) { @@ -153,7 +160,8 @@ private void AddFileTabs(string[] fileNames) Activate(); } - private void AddLogWindow(LogWindow.LogWindow logWindow, string title, bool doNotAddToPanel) + [SupportedOSPlatform("windows")] + private void AddLogWindow (LogWindow.LogWindow logWindow, string title, bool doNotAddToPanel) { logWindow.CloseButton = true; logWindow.TabPageContextMenuStrip = tabContextMenuStrip; @@ -165,9 +173,13 @@ private void AddLogWindow(LogWindow.LogWindow logWindow, string title, bool doNo logWindow.Show(dockPanel); } - LogWindowData data = new(); - data.diffSum = 0; + LogWindowData data = new() + { + diffSum = 0 + }; + logWindow.Tag = data; + lock (_logWindowList) { _logWindowList.Add(logWindow); @@ -185,7 +197,8 @@ private void AddLogWindow(LogWindow.LogWindow logWindow, string title, bool doNo logWindow.Visible = true; } - private void DisconnectEventHandlers(LogWindow.LogWindow logWindow) + [SupportedOSPlatform("windows")] + private void DisconnectEventHandlers (LogWindow.LogWindow logWindow) { logWindow.FileSizeChanged -= OnFileSizeChanged; logWindow.TailFollowed -= OnTailFollowed; @@ -196,21 +209,18 @@ private void DisconnectEventHandlers(LogWindow.LogWindow logWindow) logWindow.CurrentHighlightGroupChanged -= OnLogWindowCurrentHighlightGroupChanged; logWindow.SyncModeChanged -= OnLogWindowSyncModeChanged; - LogWindowData data = logWindow.Tag as LogWindowData; + var data = logWindow.Tag as LogWindowData; //data.tabPage.MouseClick -= tabPage_MouseClick; //data.tabPage.TabDoubleClick -= tabPage_TabDoubleClick; //data.tabPage.ContextMenuStrip = null; //data.tabPage = null; } - private void AddToFileHistory(string fileName) + private void AddToFileHistory (string fileName) { - bool FindName(string s) - { - return s.ToLower().Equals(fileName.ToLower()); - } + bool FindName (string s) => s.ToUpperInvariant().Equals(fileName.ToUpperInvariant(), StringComparison.Ordinal); - int index = ConfigManager.Settings.fileHistoryList.FindIndex(FindName); + var index = ConfigManager.Settings.fileHistoryList.FindIndex(FindName); if (index != -1) { @@ -229,13 +239,14 @@ bool FindName(string s) FillHistoryMenu(); } - private LogWindow.LogWindow FindWindowForFile(string fileName) + [SupportedOSPlatform("windows")] + private LogWindow.LogWindow FindWindowForFile (string fileName) { lock (_logWindowList) { foreach (LogWindow.LogWindow logWindow in _logWindowList) { - if (logWindow.FileName.ToLower().Equals(fileName.ToLower())) + if (logWindow.FileName.ToUpperInvariant().Equals(fileName.ToUpperInvariant(), StringComparison.Ordinal)) { return logWindow; } @@ -251,7 +262,7 @@ private LogWindow.LogWindow FindWindowForFile(string fileName) /// /// /// - private string FindFilenameForSettings(string fileName) + private string FindFilenameForSettings (string fileName) { if (fileName.EndsWith(".lxp")) { @@ -277,7 +288,7 @@ private string FindFilenameForSettings(string fileName) } // handle relative paths in .lxp files - string dir = Path.GetDirectoryName(fileName); + var dir = Path.GetDirectoryName(fileName); return Path.Combine(dir, persistenceData.fileName); } } @@ -285,11 +296,12 @@ private string FindFilenameForSettings(string fileName) return fileName; } - private void FillHistoryMenu() + [SupportedOSPlatform("windows")] + private void FillHistoryMenu () { ToolStripDropDown strip = new ToolStripDropDownMenu(); - foreach (string file in ConfigManager.Settings.fileHistoryList) + foreach (var file in ConfigManager.Settings.fileHistoryList) { ToolStripItem item = new ToolStripMenuItem(file); strip.Items.Add(item); @@ -300,7 +312,8 @@ private void FillHistoryMenu() lastUsedToolStripMenuItem.DropDown = strip; } - private void RemoveLogWindow(LogWindow.LogWindow logWindow) + [SupportedOSPlatform("windows")] + private void RemoveLogWindow (LogWindow.LogWindow logWindow) { lock (_logWindowList) { @@ -310,7 +323,8 @@ private void RemoveLogWindow(LogWindow.LogWindow logWindow) DisconnectEventHandlers(logWindow); } - private void RemoveAndDisposeLogWindow(LogWindow.LogWindow logWindow, bool dontAsk) + [SupportedOSPlatform("windows")] + private void RemoveAndDisposeLogWindow (LogWindow.LogWindow logWindow, bool dontAsk) { if (CurrentLogWindow == logWindow) { @@ -325,7 +339,8 @@ private void RemoveAndDisposeLogWindow(LogWindow.LogWindow logWindow, bool dontA logWindow.Close(dontAsk); } - private void ShowHighlightSettingsDialog() + [SupportedOSPlatform("windows")] + private void ShowHighlightSettingsDialog () { HighlightDialog dlg = new(ConfigManager) { @@ -348,21 +363,23 @@ private void ShowHighlightSettingsDialog() } } - private void FillHighlightComboBox() + [SupportedOSPlatform("windows")] + private void FillHighlightComboBox () { - string currentGroupName = groupsComboBoxHighlightGroups.Text; + var currentGroupName = groupsComboBoxHighlightGroups.Text; groupsComboBoxHighlightGroups.Items.Clear(); foreach (HighlightGroup group in HighlightGroupList) { groupsComboBoxHighlightGroups.Items.Add(group.GroupName); - if (group.GroupName.Equals(currentGroupName)) + if (group.GroupName.Equals(currentGroupName, StringComparison.Ordinal)) { groupsComboBoxHighlightGroups.Text = group.GroupName; } } } - private void OpenFileDialog() + [SupportedOSPlatform("windows")] + private void OpenFileDialog () { OpenFileDialog openFileDialog = new(); @@ -409,7 +426,8 @@ private void OpenFileDialog() } } - private void LoadFiles(string[] names, bool invertLogic) + [SupportedOSPlatform("windows")] + private void LoadFiles (string[] names, bool invertLogic) { Array.Sort(names); @@ -448,14 +466,9 @@ private void LoadFiles(string[] names, bool invertLogic) { if (invertLogic) { - if (option == MultiFileOption.SingleFiles) - { - option = MultiFileOption.MultiFile; - } - else - { - option = MultiFileOption.SingleFiles; - } + option = option == MultiFileOption.SingleFiles + ? MultiFileOption.MultiFile + : MultiFileOption.SingleFiles; } } @@ -469,12 +482,13 @@ private void LoadFiles(string[] names, bool invertLogic) } } - private void SetColumnizerHistoryEntry(string fileName, ILogLineColumnizer columnizer) + private void SetColumnizerHistoryEntry (string fileName, ILogLineColumnizer columnizer) { ColumnizerHistoryEntry entry = FindColumnizerHistoryEntry(fileName); if (entry != null) { - ConfigManager.Settings.columnizerHistoryList.Remove(entry); + _ = ConfigManager.Settings.columnizerHistoryList.Remove(entry); + } ConfigManager.Settings.columnizerHistoryList.Add(new ColumnizerHistoryEntry(fileName, columnizer.GetName())); @@ -485,11 +499,11 @@ private void SetColumnizerHistoryEntry(string fileName, ILogLineColumnizer colum } } - private ColumnizerHistoryEntry FindColumnizerHistoryEntry(string fileName) + private ColumnizerHistoryEntry FindColumnizerHistoryEntry (string fileName) { foreach (ColumnizerHistoryEntry entry in ConfigManager.Settings.columnizerHistoryList) { - if (entry.FileName.Equals(fileName)) + if (entry.FileName.Equals(fileName, StringComparison.Ordinal)) { return entry; } @@ -498,7 +512,8 @@ private ColumnizerHistoryEntry FindColumnizerHistoryEntry(string fileName) return null; } - private void ToggleMultiFile() + [SupportedOSPlatform("windows")] + private void ToggleMultiFile () { if (CurrentLogWindow != null) { @@ -508,7 +523,8 @@ private void ToggleMultiFile() } } - private void ChangeCurrentLogWindow(LogWindow.LogWindow newLogWindow) + [SupportedOSPlatform("windows")] + private void ChangeCurrentLogWindow (LogWindow.LogWindow newLogWindow) { if (newLogWindow == _currentLogWindow) { @@ -517,7 +533,7 @@ private void ChangeCurrentLogWindow(LogWindow.LogWindow newLogWindow) LogWindow.LogWindow oldLogWindow = _currentLogWindow; _currentLogWindow = newLogWindow; - string titleName = _showInstanceNumbers ? "LogExpert #" + _instanceNumber : "LogExpert"; + var titleName = _showInstanceNumbers ? "LogExpert #" + _instanceNumber : "LogExpert"; if (oldLogWindow != null) { @@ -541,14 +557,9 @@ private void ChangeCurrentLogWindow(LogWindow.LogWindow newLogWindow) newLogWindow.BookmarkRemoved += OnBookmarkRemoved; newLogWindow.BookmarkTextChanged += OnBookmarkTextChanged; - if (newLogWindow.IsTempFile) - { - Text = titleName + @" - " + newLogWindow.TempTitleName; - } - else - { - Text = titleName + @" - " + newLogWindow.FileName; - } + Text = newLogWindow.IsTempFile + ? titleName + @" - " + newLogWindow.TempTitleName + : titleName + @" - " + newLogWindow.FileName; multiFileToolStripMenuItem.Checked = CurrentLogWindow.IsMultiFile; multiFileToolStripMenuItem.Enabled = true; @@ -583,30 +594,31 @@ private void ChangeCurrentLogWindow(LogWindow.LogWindow newLogWindow) } } - private void ConnectToolWindows(LogWindow.LogWindow logWindow) + private void ConnectToolWindows (LogWindow.LogWindow logWindow) { ConnectBookmarkWindow(logWindow); } - private void ConnectBookmarkWindow(LogWindow.LogWindow logWindow) + private void ConnectBookmarkWindow (LogWindow.LogWindow logWindow) { FileViewContext ctx = new(logWindow, logWindow); _bookmarkWindow.SetBookmarkData(logWindow.BookmarkData); _bookmarkWindow.SetCurrentFile(ctx); } - private void DisconnectToolWindows(LogWindow.LogWindow logWindow) + private void DisconnectToolWindows (LogWindow.LogWindow logWindow) { DisconnectBookmarkWindow(logWindow); } - private void DisconnectBookmarkWindow(LogWindow.LogWindow logWindow) + private void DisconnectBookmarkWindow (LogWindow.LogWindow logWindow) { _bookmarkWindow.SetBookmarkData(null); _bookmarkWindow.SetCurrentFile(null); } - private void GuiStateUpdateWorker(GuiStateArgs e) + [SupportedOSPlatform("windows")] + private void GuiStateUpdateWorker (GuiStateArgs e) { _skipEvents = true; checkBoxFollowTail.Checked = e.FollowTail; @@ -643,7 +655,8 @@ private void GuiStateUpdateWorker(GuiStateArgs e) _skipEvents = false; } - private void ProgressBarUpdateWorker(ProgressEventArgs e) + [SupportedOSPlatform("windows")] + private void ProgressBarUpdateWorker (ProgressEventArgs e) { if (e.Value <= e.MaxValue && e.Value >= e.MinValue) { @@ -663,7 +676,8 @@ private void ProgressBarUpdateWorker(ProgressEventArgs e) } } - private void StatusLineEventWorker(StatusLineEventArgs e) + [SupportedOSPlatform("windows")] + private void StatusLineEventWorker (StatusLineEventArgs e) { if (e != null) { @@ -678,7 +692,7 @@ private void StatusLineEventWorker(StatusLineEventArgs e) labelCurrentLine.Size = TextRenderer.MeasureText(labelCurrentLine.Text, labelCurrentLine.Font); if (statusStrip.InvokeRequired) { - statusStrip.BeginInvoke(new MethodInvoker(delegate { statusStrip.Refresh(); })); + statusStrip.BeginInvoke(new MethodInvoker(statusStrip.Refresh)); } else { @@ -689,17 +703,18 @@ private void StatusLineEventWorker(StatusLineEventArgs e) // tailState: 0,1,2 = on/off/off by Trigger // syncMode: 0 = normal (no), 1 = time synced - private Icon CreateLedIcon(int level, bool dirty, int tailState, int syncMode) + [SupportedOSPlatform("windows")] + private Icon CreateLedIcon (int level, bool dirty, int tailState, int syncMode) { Rectangle iconRect = _leds[0]; iconRect.Height = 16; // (DockPanel's damn hardcoded height) // this.leds[this.leds.Length - 1].Bottom; iconRect.Width = iconRect.Right + 6; Bitmap bmp = new(iconRect.Width, iconRect.Height); - Graphics gfx = Graphics.FromImage(bmp); + var gfx = Graphics.FromImage(bmp); - int offsetFromTop = 4; + var offsetFromTop = 4; - for (int i = 0; i < _leds.Length; ++i) + for (var i = 0; i < _leds.Length; ++i) { Rectangle ledRect = _leds[i]; ledRect.Offset(0, offsetFromTop); @@ -714,8 +729,8 @@ private Icon CreateLedIcon(int level, bool dirty, int tailState, int syncMode) } } - int ledSize = 3; - int ledGap = 1; + var ledSize = 3; + var ledGap = 1; Rectangle lastLed = _leds[^1]; Rectangle dirtyLed = new(lastLed.Right + 2, lastLed.Bottom - ledSize, ledSize, ledSize); Rectangle tailLed = new(dirtyLed.Location, dirtyLed.Size); @@ -754,8 +769,8 @@ private Icon CreateLedIcon(int level, bool dirty, int tailState, int syncMode) // see http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=345656 // GetHicon() creates an unmanaged handle which must be destroyed. The Clone() workaround creates // a managed copy of icon. then the unmanaged win32 handle is destroyed - IntPtr iconHandle = bmp.GetHicon(); - Icon icon = Icon.FromHandle(iconHandle).Clone() as Icon; + var iconHandle = bmp.GetHicon(); + var icon = Icon.FromHandle(iconHandle).Clone() as Icon; Win32.DestroyIcon(iconHandle); gfx.Dispose(); @@ -763,18 +778,18 @@ private Icon CreateLedIcon(int level, bool dirty, int tailState, int syncMode) return icon; } - private void CreateIcons() + private void CreateIcons () { - for (int syncMode = 0; syncMode <= 1; syncMode++) // LED indicating time synced tabs + for (var syncMode = 0; syncMode <= 1; syncMode++) // LED indicating time synced tabs { - for (int tailMode = 0; tailMode < 4; tailMode++) + for (var tailMode = 0; tailMode < 4; tailMode++) { - for (int i = 0; i < 6; ++i) + for (var i = 0; i < 6; ++i) { _ledIcons[i, 0, tailMode, syncMode] = CreateLedIcon(i, false, tailMode, syncMode); } - for (int i = 0; i < 6; ++i) + for (var i = 0; i < 6; ++i) { _ledIcons[i, 1, tailMode, syncMode] = CreateLedIcon(i, true, tailMode, syncMode); } @@ -782,23 +797,26 @@ private void CreateIcons() } } - private void FileNotFound(LogWindow.LogWindow logWin) + [SupportedOSPlatform("windows")] + private void FileNotFound (LogWindow.LogWindow logWin) { - LogWindowData data = logWin.Tag as LogWindowData; + var data = logWin.Tag as LogWindowData; BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, _deadIcon); dragControlDateTime.Visible = false; } - private void FileRespawned(LogWindow.LogWindow logWin) + [SupportedOSPlatform("windows")] + private void FileRespawned (LogWindow.LogWindow logWin) { - LogWindowData data = logWin.Tag as LogWindowData; + var data = logWin.Tag as LogWindowData; Icon icon = GetIcon(0, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, icon); } - private void ShowLedPeak(LogWindow.LogWindow logWin) + [SupportedOSPlatform("windows")] + private void ShowLedPeak (LogWindow.LogWindow logWin) { - LogWindowData data = logWin.Tag as LogWindowData; + var data = logWin.Tag as LogWindowData; lock (data) { data.diffSum = DIFF_MAX; @@ -808,14 +826,14 @@ private void ShowLedPeak(LogWindow.LogWindow logWin) BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, icon); } - private int GetLevelFromDiff(int diff) + private int GetLevelFromDiff (int diff) { if (diff > 60) { diff = 60; } - int level = diff / 10; + var level = diff / 10; if (diff > 0 && level == 0) { level = 2; @@ -828,7 +846,8 @@ private int GetLevelFromDiff(int diff) return level - 1; } - private void LedThreadProc() + [SupportedOSPlatform("windows")] + private void LedThreadProc () { Thread.CurrentThread.Name = "LED Thread"; while (!_shouldStop) @@ -846,7 +865,7 @@ private void LedThreadProc() { foreach (LogWindow.LogWindow logWindow in _logWindowList) { - LogWindowData data = logWindow.Tag as LogWindowData; + var data = logWindow.Tag as LogWindowData; if (data.diffSum > 0) { data.diffSum -= 10; @@ -863,7 +882,8 @@ private void LedThreadProc() } } - private void SetTabIcon(LogWindow.LogWindow logWindow, Icon icon) + [SupportedOSPlatform("windows")] + private void SetTabIcon (LogWindow.LogWindow logWindow, Icon icon) { if (logWindow != null) { @@ -872,7 +892,7 @@ private void SetTabIcon(LogWindow.LogWindow logWindow, Icon icon) } } - private Icon GetIcon(int diff, LogWindowData data) + private Icon GetIcon (int diff, LogWindowData data) { Icon icon = _ledIcons[ @@ -882,7 +902,8 @@ private Icon GetIcon(int diff, LogWindowData data) return icon; } - private void RefreshEncodingMenuBar(Encoding encoding) + [SupportedOSPlatform("windows")] + private void RefreshEncodingMenuBar (Encoding encoding) { toolStripEncodingASCIIItem.Checked = false; toolStripEncodingANSIItem.Checked = false; @@ -919,7 +940,7 @@ private void RefreshEncodingMenuBar(Encoding encoding) toolStripEncodingANSIItem.Text = Encoding.Default.HeaderName; } - private void OpenSettings(int tabToOpen) + private void OpenSettings (int tabToOpen) { SettingsDialog dlg = new(ConfigManager.Settings.Preferences, this, tabToOpen, ConfigManager) { @@ -934,7 +955,7 @@ private void OpenSettings(int tabToOpen) } } - private void NotifyWindowsForChangedPrefs(SettingsFlags flags) + private void NotifyWindowsForChangedPrefs (SettingsFlags flags) { _logger.Info("The preferences have changed"); ApplySettings(ConfigManager.Settings, flags); @@ -956,7 +977,8 @@ private void NotifyWindowsForChangedPrefs(SettingsFlags flags) } } - private void ApplySettings(Settings settings, SettingsFlags flags) + [SupportedOSPlatform("windows")] + private void ApplySettings (Settings settings, SettingsFlags flags) { if ((flags & SettingsFlags.WindowPosition) == SettingsFlags.WindowPosition) { @@ -986,7 +1008,8 @@ private void ApplySettings(Settings settings, SettingsFlags flags) } } - private void SetTabIcons(Preferences preferences) + [SupportedOSPlatform("windows")] + private void SetTabIcons (Preferences preferences) { _tailLedBrush[0] = new SolidBrush(preferences.showTailColor); CreateIcons(); @@ -994,14 +1017,15 @@ private void SetTabIcons(Preferences preferences) { foreach (LogWindow.LogWindow logWindow in _logWindowList) { - LogWindowData data = logWindow.Tag as LogWindowData; + var data = logWindow.Tag as LogWindowData; Icon icon = GetIcon(data.diffSum, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); } } } - private void SetToolIcon(ToolEntry entry, ToolStripItem item) + [SupportedOSPlatform("windows")] + private void SetToolIcon (ToolEntry entry, ToolStripItem item) { Icon icon = Win32.LoadIconFromExe(entry.iconFile, entry.iconIndex); if (icon != null) @@ -1026,7 +1050,7 @@ private void SetToolIcon(ToolEntry entry, ToolStripItem item) } } - private void ToolButtonClick(ToolEntry toolEntry) + private void ToolButtonClick (ToolEntry toolEntry) { if (string.IsNullOrEmpty(toolEntry.cmd)) { @@ -1042,7 +1066,7 @@ private void ToolButtonClick(ToolEntry toolEntry) if (line != null && info != null) { ArgParser parser = new(toolEntry.args); - string argLine = parser.BuildArgs(line, CurrentLogWindow.GetRealLineNum() + 1, info, this); + var argLine = parser.BuildArgs(line, CurrentLogWindow.GetRealLineNum() + 1, info, this); if (argLine != null) { StartTool(toolEntry.cmd, argLine, toolEntry.sysout, toolEntry.columnizerName, @@ -1052,7 +1076,8 @@ private void ToolButtonClick(ToolEntry toolEntry) } } - private void StartTool(string cmd, string args, bool sysoutPipe, string columnizerName, string workingDir) + [SupportedOSPlatform("windows")] + private void StartTool (string cmd, string args, bool sysoutPipe, string columnizerName, string workingDir) { if (string.IsNullOrEmpty(cmd)) { @@ -1079,7 +1104,7 @@ private void StartTool(string cmd, string args, bool sysoutPipe, string columniz //process.OutputDataReceived += pipe.DataReceivedEventHandler; try { - process.Start(); + _ = process.Start(); } catch (Win32Exception e) { @@ -1106,7 +1131,7 @@ private void StartTool(string cmd, string args, bool sysoutPipe, string columniz try { startInfo.UseShellExecute = false; - process.Start(); + _ = process.Start(); } catch (Exception e) { @@ -1116,7 +1141,8 @@ private void StartTool(string cmd, string args, bool sysoutPipe, string columniz } } - private void CloseAllTabs() + [SupportedOSPlatform("windows")] + private void CloseAllTabs () { IList closeList = []; lock (_logWindowList) @@ -1136,7 +1162,7 @@ private void CloseAllTabs() } } - private void SetTabColor(LogWindow.LogWindow logWindow, Color color) + private void SetTabColor (LogWindow.LogWindow logWindow, Color color) { //tabPage.BackLowColor = color; //tabPage.BackLowColorDisabled = Color.FromArgb(255, @@ -1146,10 +1172,11 @@ private void SetTabColor(LogWindow.LogWindow logWindow, Color color) // ); } - private void LoadProject(string projectFileName, bool restoreLayout) + [SupportedOSPlatform("windows")] + private void LoadProject (string projectFileName, bool restoreLayout) { ProjectData projectData = ProjectPersister.LoadProjectData(projectFileName); - bool hasLayoutData = projectData.tabLayoutXml != null; + var hasLayoutData = projectData.tabLayoutXml != null; if (hasLayoutData && restoreLayout && _logWindowList.Count > 0) { @@ -1173,7 +1200,7 @@ private void LoadProject(string projectFileName, bool restoreLayout) if (projectData != null) { - foreach (string fileName in projectData.memberList) + foreach (var fileName in projectData.memberList) { if (hasLayoutData) { @@ -1195,13 +1222,15 @@ private void LoadProject(string projectFileName, bool restoreLayout) } } - private void ApplySelectedHighlightGroup() + [SupportedOSPlatform("windows")] + private void ApplySelectedHighlightGroup () { - string groupName = groupsComboBoxHighlightGroups.Text; + var groupName = groupsComboBoxHighlightGroups.Text; CurrentLogWindow?.SetCurrentHighlightGroup(groupName); } - private void FillToolLauncherBar() + [SupportedOSPlatform("windows")] + private void FillToolLauncherBar () { char[] labels = { @@ -1212,7 +1241,7 @@ private void FillToolLauncherBar() toolsToolStripMenuItem.DropDownItems.Add(configureToolStripMenuItem); toolsToolStripMenuItem.DropDownItems.Add(configureToolStripSeparator); externalToolsToolStrip.Items.Clear(); - int num = 0; + var num = 0; externalToolsToolStrip.SuspendLayout(); foreach (ToolEntry tool in Preferences.toolEntries) { @@ -1229,8 +1258,11 @@ private void FillToolLauncherBar() } num++; - ToolStripMenuItem menuItem = new(tool.name); - menuItem.Tag = tool; + ToolStripMenuItem menuItem = new(tool.name) + { + Tag = tool + }; + SetToolIcon(tool, menuItem); toolsToolStripMenuItem.DropDownItems.Add(menuItem); } @@ -1240,49 +1272,49 @@ private void FillToolLauncherBar() externalToolsToolStrip.Visible = num > 0; // do not show bar if no tool uses it } - private void RunGC() + private void RunGC () { - _logger.Info("Running GC. Used mem before: {0:N0}", GC.GetTotalMemory(false)); + _logger.Info($"Running GC. Used mem before: {GC.GetTotalMemory(false):N0}"); GC.Collect(); - _logger.Info("GC done. Used mem after: {0:N0}", GC.GetTotalMemory(true)); + _logger.Info($"GC done. Used mem after: {GC.GetTotalMemory(true):N0}"); } - private void DumpGCInfo() + private void DumpGCInfo () { - _logger.Info("-------- GC info -----------\r\nUsed mem: {0:N0}", GC.GetTotalMemory(false)); - for (int i = 0; i < GC.MaxGeneration; ++i) + _logger.Info($"-------- GC info -----------\r\nUsed mem: {GC.GetTotalMemory(false):N0}"); + for (var i = 0; i < GC.MaxGeneration; ++i) { - _logger.Info("Generation {0} collect count: {1}", i, GC.CollectionCount(i)); + _logger.Info($"Generation {i} collect count: {GC.CollectionCount(i)}"); } _logger.Info("----------------------------"); } - private void ThrowExceptionFx() + private void ThrowExceptionFx () { throw new Exception("This is a test exception thrown by an async delegate"); } - private void ThrowExceptionThreadFx() + private void ThrowExceptionThreadFx () { throw new Exception("This is a test exception thrown by a background thread"); } - private string SaveLayout() + private string SaveLayout () { using MemoryStream memStream = new(2000); using StreamReader r = new(memStream); dockPanel.SaveAsXml(memStream, Encoding.UTF8, true); memStream.Seek(0, SeekOrigin.Begin); - string resultXml = r.ReadToEnd(); + var resultXml = r.ReadToEnd(); r.Close(); return resultXml; } - private void RestoreLayout(string layoutXml) + private void RestoreLayout (string layoutXml) { using MemoryStream memStream = new(2000); using StreamWriter w = new(memStream); @@ -1294,29 +1326,29 @@ private void RestoreLayout(string layoutXml) dockPanel.LoadFromXml(memStream, DeserializeDockContent, true); } - private IDockContent DeserializeDockContent(string persistString) + private IDockContent DeserializeDockContent (string persistString) { - if (persistString.Equals(WindowTypes.BookmarkWindow.ToString())) + if (persistString.Equals(WindowTypes.BookmarkWindow.ToString(), StringComparison.Ordinal)) { return _bookmarkWindow; } if (persistString.StartsWith(WindowTypes.LogWindow.ToString())) { - string fileName = persistString.Substring(WindowTypes.LogWindow.ToString().Length + 1); + var fileName = persistString.Substring(WindowTypes.LogWindow.ToString().Length + 1); LogWindow.LogWindow win = FindWindowForFile(fileName); if (win != null) { return win; } - _logger.Warn("Layout data contains non-existing LogWindow for {0}", fileName); + _logger.Warn($"Layout data contains non-existing LogWindow for {fileName}"); } return null; } - private void OnHighlightSettingsChanged() + private void OnHighlightSettingsChanged () { HighlightSettingsChanged?.Invoke(this, EventArgs.Empty); } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs index 5bddf768..d264fbe3 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs @@ -1,4 +1,7 @@ -using LogExpert.Classes.Filter; +using System.Text; +using System.Text.RegularExpressions; + +using LogExpert.Classes.Filter; using LogExpert.Core.Classes.Columnizer; using LogExpert.Core.Config; using LogExpert.Core.Entities; @@ -6,22 +9,21 @@ using LogExpert.Dialogs; using LogExpert.UI.Entities; using LogExpert.UI.Extensions; -using System.Runtime.InteropServices; -using System.Text; -using System.Text.RegularExpressions; + using WeifenLuo.WinFormsUI.Docking; namespace LogExpert.UI.Controls.LogTabWindow; -partial class LogTabWindow + +public partial class LogTabWindow { #region Public methods - public LogWindow.LogWindow AddTempFileTab(string fileName, string title) + public LogWindow.LogWindow AddTempFileTab (string fileName, string title) { return AddFileTab(fileName, true, title, false, null); } - public LogWindow.LogWindow AddFilterTab(FilterPipe pipe, string title, ILogLineColumnizer preProcessColumnizer) + public LogWindow.LogWindow AddFilterTab (FilterPipe pipe, string title, ILogLineColumnizer preProcessColumnizer) { LogWindow.LogWindow logWin = AddFileTab(pipe.FileName, true, title, false, preProcessColumnizer); if (pipe.FilterParams.SearchText.Length > 0) @@ -41,12 +43,12 @@ public LogWindow.LogWindow AddFilterTab(FilterPipe pipe, string title, ILogLineC return logWin; } - public LogWindow.LogWindow AddFileTabDeferred(string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer) + public LogWindow.LogWindow AddFileTabDeferred (string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer) { return AddFileTab(givenFileName, isTempFile, title, forcePersistenceLoading, preProcessColumnizer, true); } - public LogWindow.LogWindow AddFileTab(string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer, bool doNotAddToDockPanel = false) + public LogWindow.LogWindow AddFileTab (string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer, bool doNotAddToDockPanel = false) { string logFileName = FindFilenameForSettings(givenFileName); LogWindow.LogWindow win = FindWindowForFile(logFileName); @@ -116,7 +118,7 @@ public LogWindow.LogWindow AddFileTab(string givenFileName, bool isTempFile, str return logWindow; } - public LogWindow.LogWindow AddMultiFileTab(string[] fileNames) + public LogWindow.LogWindow AddMultiFileTab (string[] fileNames) { if (fileNames.Length < 1) { @@ -134,12 +136,12 @@ public LogWindow.LogWindow AddMultiFileTab(string[] fileNames) return logWindow; } - public void LoadFiles(string[] fileNames) + public void LoadFiles (string[] fileNames) { Invoke(new AddFileTabsDelegate(AddFileTabs), [fileNames]); } - public void OpenSearchDialog() + public void OpenSearchDialog () { if (CurrentLogWindow == null) { @@ -160,7 +162,7 @@ public void OpenSearchDialog() } } - public ILogLineColumnizer GetColumnizerHistoryEntry(string fileName) + public ILogLineColumnizer GetColumnizerHistoryEntry (string fileName) { ColumnizerHistoryEntry entry = FindColumnizerHistoryEntry(fileName); if (entry != null) @@ -179,7 +181,7 @@ public ILogLineColumnizer GetColumnizerHistoryEntry(string fileName) return null; } - public void SwitchTab(bool shiftPressed) + public void SwitchTab (bool shiftPressed) { int index = dockPanel.Contents.IndexOf(dockPanel.ActiveContent); if (shiftPressed) @@ -210,7 +212,7 @@ public void SwitchTab(bool shiftPressed) } } - public void ScrollAllTabsToTimestamp(DateTime timestamp, LogWindow.LogWindow senderWindow) + public void ScrollAllTabsToTimestamp (DateTime timestamp, LogWindow.LogWindow senderWindow) { lock (_logWindowList) { @@ -227,7 +229,7 @@ public void ScrollAllTabsToTimestamp(DateTime timestamp, LogWindow.LogWindow sen } } - public ILogLineColumnizer FindColumnizerByFileMask(string fileName) + public ILogLineColumnizer FindColumnizerByFileMask (string fileName) { foreach (ColumnizerMaskEntry entry in ConfigManager.Settings.Preferences.columnizerMaskList) { @@ -252,7 +254,7 @@ public ILogLineColumnizer FindColumnizerByFileMask(string fileName) return null; } - public HighlightGroup FindHighlightGroupByFileMask(string fileName) + public HighlightGroup FindHighlightGroupByFileMask (string fileName) { foreach (HighlightMaskEntry entry in ConfigManager.Settings.Preferences.highlightMaskList) { @@ -277,12 +279,12 @@ public HighlightGroup FindHighlightGroupByFileMask(string fileName) return null; } - public void SelectTab(ILogWindow logWindow) + public void SelectTab (ILogWindow logWindow) { logWindow.Activate(); } - public void SetForeground() + public void SetForeground () { Win32.SetForegroundWindow(Handle); if (WindowState == FormWindowState.Minimized) @@ -299,7 +301,7 @@ public void SetForeground() } // called from LogWindow when follow tail was changed - public void FollowTailChanged(LogWindow.LogWindow logWindow, bool isEnabled, bool offByTrigger) + public void FollowTailChanged (LogWindow.LogWindow logWindow, bool isEnabled, bool offByTrigger) { LogWindowData data = logWindow.Tag as LogWindowData; if (data == null) @@ -323,7 +325,7 @@ public void FollowTailChanged(LogWindow.LogWindow logWindow, bool isEnabled, boo } } - public void NotifySettingsChanged(object sender, SettingsFlags flags) + public void NotifySettingsChanged (object sender, SettingsFlags flags) { if (sender != this) { @@ -331,7 +333,7 @@ public void NotifySettingsChanged(object sender, SettingsFlags flags) } } - public IList GetListOfOpenFiles() + public IList GetListOfOpenFiles () { IList list = new List(); lock (_logWindowList) diff --git a/src/LogExpert.UI/Entities/WindowFileEntry.cs b/src/LogExpert.UI/Entities/WindowFileEntry.cs index 7bd57c46..34eea500 100644 --- a/src/LogExpert.UI/Entities/WindowFileEntry.cs +++ b/src/LogExpert.UI/Entities/WindowFileEntry.cs @@ -1,42 +1,41 @@ -using LogExpert.UI.Controls.LogWindow; +using System.Runtime.Versioning; -namespace LogExpert.UI.Entities -{ - /// - /// Represents a log file and its window. Used as a kind of handle for menus or list of open files. - /// - internal class WindowFileEntry(LogWindow logWindow) - { - #region Fields +using LogExpert.UI.Controls.LogWindow; + +namespace LogExpert.UI.Entities; - private const int MAX_LEN = 40; +/// +/// Represents a log file and its window. Used as a kind of handle for menus or list of open files. +/// +public class WindowFileEntry (LogWindow logWindow) +{ + #region Fields - #endregion - #region cTor + private const int MAX_LEN = 40; - #endregion + #endregion - #region Properties + #region Properties - public string Title + [SupportedOSPlatform("windows")] + public string Title + { + get { - get - { - string title = LogWindow.Text; + var title = LogWindow.Text; - if (title.Length > MAX_LEN) - { - title = string.Concat("...", title.AsSpan(title.Length - MAX_LEN)); - } - return title; + if (title.Length > MAX_LEN) + { + title = string.Concat("...", title.AsSpan(title.Length - MAX_LEN)); } - } - public string FileName => LogWindow.FileName; + return title; + } + } + public string FileName => LogWindow.FileName; - public LogWindow LogWindow { get; } = logWindow; + public LogWindow LogWindow { get; } = logWindow; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert/Classes/LogExpertProxy.cs b/src/LogExpert/Classes/LogExpertProxy.cs index 9fda5004..25f514f1 100644 --- a/src/LogExpert/Classes/LogExpertProxy.cs +++ b/src/LogExpert/Classes/LogExpertProxy.cs @@ -1,7 +1,9 @@ using LogExpert.Config; using LogExpert.Core.Interface; -using LogExpert.UI.Controls.LogTabWindow; +using LogExpert.UI.Dialogs.LogTabWindow; + using NLog; + using System; using System.Collections.Generic; using System.Windows.Forms; diff --git a/src/LogExpert/Program.cs b/src/LogExpert/Program.cs index 1e043a20..347bc900 100644 --- a/src/LogExpert/Program.cs +++ b/src/LogExpert/Program.cs @@ -5,11 +5,14 @@ using LogExpert.Core.Config; using LogExpert.Core.Interface; using LogExpert.Dialogs; -using LogExpert.UI.Controls.LogTabWindow; using LogExpert.UI.Dialogs; +using LogExpert.UI.Dialogs.LogTabWindow; + using Newtonsoft.Json; using Newtonsoft.Json.Linq; + using NLog; + using System.Diagnostics; using System.IO.Pipes; using System.Reflection; diff --git a/src/Logexpert.Core/Interface/IBookmarkView.cs b/src/Logexpert.Core/Interface/IBookmarkView.cs new file mode 100644 index 00000000..d22a7791 --- /dev/null +++ b/src/Logexpert.Core/Interface/IBookmarkView.cs @@ -0,0 +1,27 @@ +using LogExpert.Core.Entities; + +namespace LogExpert.Core.Interface; + +/// +/// To be implemented by the bookmark window. Will be informed from LogWindow about changes in bookmarks. +/// +public interface IBookmarkView +{ + #region Properties + + bool LineColumnVisible { set; } + + #endregion + + #region Public methods + + void UpdateView (); + + void BookmarkTextChanged (Bookmark bookmark); + + void SelectBookmark (int lineNum); + + void SetBookmarkData (IBookmarkData bookmarkData); + + #endregion +} \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/AbstractLogTabWindow.cs b/src/Logexpert.UI/Dialogs/LogTabWindow/AbstractLogTabWindow.cs new file mode 100644 index 00000000..7336d535 --- /dev/null +++ b/src/Logexpert.UI/Dialogs/LogTabWindow/AbstractLogTabWindow.cs @@ -0,0 +1,13 @@ +using LogExpert.Core.Interface; + +namespace LogExpert.UI.Dialogs.LogTabWindow; + +public abstract class AbstractLogTabWindow () +{ + public static StaticLogTabWindowData StaticData { get; set; } = new StaticLogTabWindowData(); + + public static ILogTabWindow Create (string[] fileNames, int instanceNumber, bool showInstanceNumbers, IConfigManager configManager) + { + return new Controls.LogTabWindow.LogTabWindow(fileNames, instanceNumber, showInstanceNumbers, configManager); + } +} \ No newline at end of file diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/StaticLogTabWindowData.cs b/src/Logexpert.UI/Dialogs/LogTabWindow/StaticLogTabWindowData.cs new file mode 100644 index 00000000..88e8e1bf --- /dev/null +++ b/src/Logexpert.UI/Dialogs/LogTabWindow/StaticLogTabWindowData.cs @@ -0,0 +1,12 @@ +using LogExpert.Core.Interface; + +namespace LogExpert.UI.Dialogs.LogTabWindow; + +public class StaticLogTabWindowData +{ + #region Properties + + public ILogTabWindow CurrentLockedMainWindow { get; set; } + + #endregion +} \ No newline at end of file From db1ba818ff05b17cb07dc4d698125a71988b4abe Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 1 Jun 2025 21:34:27 +0200 Subject: [PATCH 054/142] var in all the solution --- build/Build.cs | 6 +- src/ColumnizerLib.UnitTests/ColumnTests.cs | 8 +- src/ColumnizerLib/Column.cs | 8 +- src/CsvColumnizer/CsvColumnizer.cs | 20 +-- src/DefaultPlugins/ProcessLauncher.cs | 120 +++++++++--------- src/FlashIconHighlighter/FlashIconPlugin.cs | 5 +- .../GlassfishColumnizer.cs | 20 +-- src/GlassfishColumnizer/XmlConfig.cs | 2 +- src/JsonColumnizer/JsonColumnizer.cs | 4 +- src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs | 24 ++-- .../Log4jXmlColumnizerConfig.cs | 8 +- .../Log4jXmlColumnizerConfigDlg.cs | 12 +- src/Log4jXmlColumnizer/XmlConfig.cs | 5 +- .../Classes/Bookmark/BookmarkExporter.cs | 2 +- .../Classes/Columnizer/ClfColumnizer.cs | 22 ++-- .../Classes/Columnizer/ColumnizerPicker.cs | 2 +- .../Columnizer/SquareBracketColumnizer.cs | 50 ++++---- .../Columnizer/TimeFormatDeterminer.cs | 9 +- .../Classes/Columnizer/TimestampColumnizer.cs | 32 ++--- .../DateTimeParser/DateFormatPartAdjuster.cs | 2 +- .../Classes/DateTimeParser/Parser.cs | 5 +- .../Classes/DateTimeParser/Tokenizer.cs | 6 +- src/LogExpert.Core/Classes/Filter/Filter.cs | 6 +- .../Classes/Filter/FilterParams.cs | 6 +- .../Classes/Filter/FilterPipe.cs | 6 +- .../Classes/Filter/FilterStarter.cs | 12 +- src/LogExpert.Core/Classes/Log/LogBuffer.cs | 8 +- .../Classes/Log/LogfileReader.cs | 80 ++++++------ .../Log/PositionAwareStreamReaderBase.cs | 14 +- .../Log/PositionAwareStreamReaderLegacy.cs | 6 +- .../Log/PositionAwareStreamReaderSystem.cs | 10 +- .../Classes/Log/RolloverFilenameBuilder.cs | 26 ++-- .../Classes/Log/RolloverFilenameHandler.cs | 8 +- src/LogExpert.Core/Classes/ParamParser.cs | 13 +- .../Classes/Persister/Persister.cs | 48 +++---- .../Classes/Persister/ProjectData.cs | 2 +- .../Classes/Persister/ProjectPersister.cs | 6 +- src/LogExpert.Core/Classes/SysoutPipe.cs | 4 +- .../Classes/xml/XmlBlockSplitter.cs | 16 +-- .../Classes/xml/XmlLogReader.cs | 14 +- src/LogExpert.Core/Config/Preferences.cs | 12 +- src/LogExpert.Core/Config/ToolEntry.cs | 2 +- src/LogExpert.Core/Entities/DebugOptions.cs | 2 +- .../Entities/DefaultLogfileColumnizer.cs | 5 +- src/LogExpert.Core/Entities/LogEventData.cs | 4 +- src/LogExpert.Core/Entities/SearchParams.cs | 6 +- .../EventArguments/GuiStateArgs.cs | 4 +- .../EventArguments/PatternArgs.cs | 4 +- .../EventArguments/StatusEventArgs.cs | 6 +- src/LogExpert.Tests/BufferShiftTest.cs | 12 +- src/LogExpert.Tests/CSVColumnizerTest.cs | 4 +- src/LogExpert.Tests/ColumnizerPickerTest.cs | 8 +- src/LogExpert.Tests/DateFormatParserTest.cs | 10 +- src/LogExpert.Tests/JSONSaveTest.cs | 4 +- src/LogExpert.Tests/JsonColumnizerTest.cs | 2 +- .../JsonCompactColumnizerTest.cs | 2 +- src/LogExpert.Tests/LocalFileSystemTest.cs | 4 +- src/LogExpert.Tests/LogStreamReaderTest.cs | 12 +- src/LogExpert.Tests/ReaderTest.cs | 8 +- src/LogExpert.Tests/RollingNameTest.cs | 8 +- src/LogExpert.Tests/RolloverHandlerTest.cs | 4 +- .../RolloverHandlerTestBase.cs | 8 +- .../SquareBracketColumnizerTest.cs | 2 +- .../Controls/BufferedDataGridView.cs | 14 +- src/LogExpert.UI/Controls/ColorComboBox.cs | 2 +- .../Controls/DateTimeDragControl.cs | 26 ++-- src/LogExpert.UI/Controls/KnobControl.cs | 25 ++-- .../Controls/LogWindow/LogWindow.cs | 44 +++---- .../LogWindow/LogWindowEventHandlers.cs | 4 +- .../Controls/LogWindow/LogWindowPublic.cs | 106 ++++++++-------- .../Controls/LogWindow/PatternWindow.cs | 50 ++++---- .../Controls/LogWindow/RangeFinder.cs | 6 +- .../LogWindow/TimeSpreadCalculator.cs | 42 +++--- .../Controls/LogWindow/TimeSpreadigControl.cs | 14 +- .../Controls/LogWindow/TimeSyncList.cs | 11 +- src/LogExpert.UI/Dialogs/AboutBox.cs | 18 +-- src/LogExpert.UI/Dialogs/BookmarkWindow.cs | 30 ++--- src/LogExpert.UI/Dialogs/ChooseIconDlg.cs | 2 +- src/LogExpert.UI/Dialogs/Eminus/Eminus.cs | 18 +-- .../Dialogs/FilterColumnChooser.cs | 6 +- .../LogTabWindow/FilterSelectorForm.cs | 4 +- .../Dialogs/LogTabWindow/HighlightDialog.cs | 52 ++++---- .../Dialogs/LogTabWindow/LogTabWindow.cs | 10 +- .../LogTabWindow/LogTabWindowEventHandlers.cs | 47 +++---- .../LogTabWindow/LogTabWindowPublic.cs | 10 +- .../Dialogs/LogTabWindow/SettingsDialog.cs | 46 +++---- src/LogExpert.UI/Dialogs/OpenUriDialog.cs | 4 +- .../Dialogs/ParamRequesterDialog.cs | 2 +- src/LogExpert.UI/Dialogs/RegexHelperDialog.cs | 2 +- src/LogExpert.UI/Dialogs/SearchDialog.cs | 2 +- src/LogExpert.UI/Dialogs/ToolArgsDialog.cs | 2 +- src/LogExpert.UI/Entities/ArgParser.cs | 23 ++-- src/LogExpert.UI/Entities/PaintHelper.cs | 28 ++-- .../Forms/LineToolStripSeparatorExtension.cs | 6 +- .../Forms/MenuToolStripSeparatorExtension.cs | 6 +- src/LogExpert.UI/Extensions/Utils.cs | 10 +- src/LogExpert.UI/Extensions/Win32.cs | 20 +-- src/LogExpert/Classes/CommandLine/CmdLine.cs | 18 +-- .../Classes/CommandLine/CmdLineInt.cs | 2 +- .../Classes/CommandLine/CmdLineParameter.cs | 2 +- .../Classes/CommandLine/ConsoleCmdLine.cs | 2 +- src/LogExpert/Config/ConfigManager.cs | 2 +- src/LogExpert/Program.cs | 14 +- src/PluginRegistry/FileSystem/LogFileInfo.cs | 24 +--- src/PluginRegistry/PluginRegistry.cs | 18 +-- src/RegexColumnizer/RegexColumnizer.cs | 10 +- .../RegexColumnizerConfigDialog.cs | 4 +- src/SftpFileSystemx64/LoginDialog.cs | 2 +- src/SftpFileSystemx64/SftpFileSystem.cs | 2 +- src/SftpFileSystemx64/SftpLogFileInfo.cs | 22 ++-- 110 files changed, 776 insertions(+), 828 deletions(-) diff --git a/build/Build.cs b/build/Build.cs index 43dc4947..fc83e858 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -443,7 +443,7 @@ protected override void OnBuildInitialized() AppveyorArtifacts.ForEach((artifact) => { - Process proc = new Process(); + var proc = new Process(); proc.StartInfo = new ProcessStartInfo("appveyor", $"PushArtifact \"{artifact}\""); if (!proc.Start()) { @@ -464,7 +464,7 @@ protected override void OnBuildInitialized() { AbsolutePath logExpertApplicationData = SpecialFolder(SpecialFolders.ApplicationData) / "LogExpert"; - DirectoryInfo info = new DirectoryInfo(logExpertApplicationData); + var info = new DirectoryInfo(logExpertApplicationData); info.GetDirectories().ForEach(a => a.Delete(true)); logExpertApplicationData.DeleteDirectory(); }); @@ -474,7 +474,7 @@ protected override void OnBuildInitialized() { AbsolutePath logExpertDocuments = SpecialFolder(SpecialFolders.UserProfile) / "Documents" / "LogExpert"; - DirectoryInfo info = new DirectoryInfo(logExpertDocuments); + var info = new DirectoryInfo(logExpertDocuments); info.GetDirectories().ForEach(a => a.Delete(true)); logExpertDocuments.DeleteDirectory(); }); diff --git a/src/ColumnizerLib.UnitTests/ColumnTests.cs b/src/ColumnizerLib.UnitTests/ColumnTests.cs index e61e57c5..78c8c57c 100644 --- a/src/ColumnizerLib.UnitTests/ColumnTests.cs +++ b/src/ColumnizerLib.UnitTests/ColumnTests.cs @@ -15,12 +15,12 @@ public void Column_LineCutOf() StringBuilder builder = new(); - for (int i = 0; i < 4675; i++) + for (var i = 0; i < 4675; i++) { builder.Append("6"); } - string expected = builder + "..."; + var expected = builder + "..."; builder.Append("1234"); column.FullValue = builder.ToString(); @@ -36,12 +36,12 @@ public void Column_NoLineCutOf() StringBuilder builder = new(); - for (int i = 0; i < 4675; i++) + for (var i = 0; i < 4675; i++) { builder.Append("6"); } - string expected = builder.ToString(); + var expected = builder.ToString(); column.FullValue = expected; diff --git a/src/ColumnizerLib/Column.cs b/src/ColumnizerLib/Column.cs index ff5bf308..a0425b2c 100644 --- a/src/ColumnizerLib/Column.cs +++ b/src/ColumnizerLib/Column.cs @@ -20,7 +20,7 @@ public class Column : IColumn static Column() { - List> replacements = new List>( + var replacements = new List>( new Func[] { //replace tab with 3 spaces, from old coding. Needed??? @@ -71,7 +71,7 @@ public string FullValue { _fullValue = value; - string temp = FullValue; + var temp = FullValue; foreach (var replacement in _replacements) { @@ -97,9 +97,9 @@ public static Column[] CreateColumns(int count, IColumnizedLogLine parent) public static Column[] CreateColumns(int count, IColumnizedLogLine parent, string defaultValue) { - Column[] output = new Column[count]; + var output = new Column[count]; - for (int i = 0; i < count; i++) + for (var i = 0; i < count; i++) { output[i] = new Column {FullValue = defaultValue, Parent = parent}; } diff --git a/src/CsvColumnizer/CsvColumnizer.cs b/src/CsvColumnizer/CsvColumnizer.cs index 3f5491bc..26d36ad3 100644 --- a/src/CsvColumnizer/CsvColumnizer.cs +++ b/src/CsvColumnizer/CsvColumnizer.cs @@ -89,10 +89,10 @@ public int GetColumnCount() public string[] GetColumnNames() { - string[] names = new string[GetColumnCount()]; + var names = new string[GetColumnCount()]; if (_isValidCsv) { - int i = 0; + var i = 0; foreach (CsvColumn column in _columnList) { names[i++] = column.Name; @@ -164,20 +164,20 @@ public void Selected(ILogLineColumnizerCallback callback) csv.Read(); csv.ReadHeader(); - int fieldCount = csv.Parser.Count; + var fieldCount = csv.Parser.Count; - string[] headerRecord = csv.HeaderRecord; + var headerRecord = csv.HeaderRecord; if (_config.HasFieldNames && headerRecord != null) { - foreach (string headerColumn in headerRecord) + foreach (var headerColumn in headerRecord) { _columnList.Add(new CsvColumn(headerColumn)); } } else { - for (int i = 0; i < fieldCount; ++i) + for (var i = 0; i < fieldCount; ++i) { _columnList.Add(new CsvColumn("Column " + i + 1)); } @@ -193,7 +193,7 @@ public void DeSelected(ILogLineColumnizerCallback callback) public void Configure(ILogLineColumnizerCallback callback, string configDir) { - string configPath = configDir + "\\" + _configFileName; + var configPath = configDir + "\\" + _configFileName; FileInfo fileInfo = new(configPath); CsvColumnizerConfigDlg dlg = new(_config); @@ -216,7 +216,7 @@ public void Configure(ILogLineColumnizerCallback callback, string configDir) public void LoadConfig(string configDir) { - string configPath = Path.Combine(configDir, _configFileName); + var configPath = Path.Combine(configDir, _configFileName); if (!File.Exists(configPath)) { @@ -267,13 +267,13 @@ private IColumnizedLogLine SplitCsvLine(ILogLine line) csv.ReadHeader(); //we only read line by line and not the whole file so it is always the header - string[] records = csv.HeaderRecord; + var records = csv.HeaderRecord; if (records != null) { List columns = []; - foreach (string record in records) + foreach (var record in records) { columns.Add(new Column { FullValue = record, Parent = cLogLine }); } diff --git a/src/DefaultPlugins/ProcessLauncher.cs b/src/DefaultPlugins/ProcessLauncher.cs index 7d0ce891..8e381867 100644 --- a/src/DefaultPlugins/ProcessLauncher.cs +++ b/src/DefaultPlugins/ProcessLauncher.cs @@ -1,80 +1,78 @@ -using System.Diagnostics; +using System.Diagnostics; -namespace LogExpert +namespace LogExpert; + +internal class ProcessLauncher : IKeywordAction { - //TODO: Not in use - internal class ProcessLauncher : IKeywordAction - { - #region Properties + #region Properties - public string Text => GetName(); + public string Text => GetName(); - #endregion + #endregion - #region IKeywordAction Member + #region IKeywordAction Member - private readonly object _callbackLock = new object(); + private readonly object _callbackLock = new(); + + public void Execute (string keyword, string param, ILogExpertCallback callback, ILogLineColumnizer columnizer) + { + var start = 0; + int end; - public void Execute(string keyword, string param, ILogExpertCallback callback, ILogLineColumnizer columnizer) + if (param.StartsWith('"')) { - int start = 0; - int end = 0; - - if (param.StartsWith('"')) - { - start = 1; - end = param.IndexOf('"', start); - } - else - { - end = param.IndexOf(' '); - } - - if (end == -1) - { - end = param.Length; - } - - string procName = param[start..end]; - - lock (_callbackLock) - { - string parameters = param[end..].Trim(); - parameters = parameters.Replace("%F", callback.GetFileName()); - parameters = parameters.Replace("%K", keyword); - - int lineNumber = callback.GetLineNum(); //Line Numbers start at 0, but are displayed (+1) - string logline = callback.GetLogLine(lineNumber).FullLine; - parameters = parameters.Replace("%L", string.Empty + lineNumber); - parameters = parameters.Replace("%T", callback.GetTabTitle()); - parameters = parameters.Replace("%C", logline); - - Process explorer = new(); - explorer.StartInfo.FileName = procName; - explorer.StartInfo.Arguments = parameters; - explorer.StartInfo.UseShellExecute = false; - explorer.Start(); - } + start = 1; + end = param.IndexOf('"', start); + } + else + { + end = param.IndexOf(' '); } - public string GetName() + if (end == -1) { - return "ProcessLauncher keyword plugin"; + end = param.Length; } + var procName = param[start..end]; - public string GetDescription() + lock (_callbackLock) { - return "Launches an external process. The plugin's parameter is the process name " + - "and its (optional) command line.\r\n" + - "Use the following variables for command line replacements:\r\n" + - "%F = Log file name (full path)\r\n" + - "%T = Tab title\r\n" + - "%L = Line number of keyword hit\r\n" + - "%K = Keyword\r\n" + - "%C = Complete line content"; + var parameters = param[end..].Trim(); + parameters = parameters.Replace("%F", callback.GetFileName()); + parameters = parameters.Replace("%K", keyword); + + var lineNumber = callback.GetLineNum(); //Line Numbers start at 0, but are displayed (+1) + var logline = callback.GetLogLine(lineNumber).FullLine; + parameters = parameters.Replace("%L", string.Empty + lineNumber); + parameters = parameters.Replace("%T", callback.GetTabTitle()); + parameters = parameters.Replace("%C", logline); + + Process explorer = new(); + explorer.StartInfo.FileName = procName; + explorer.StartInfo.Arguments = parameters; + explorer.StartInfo.UseShellExecute = false; + explorer.Start(); } + } - #endregion + public string GetName () + { + return "ProcessLauncher keyword plugin"; + } + + + public string GetDescription () + { + return "Launches an external process. The plugin's parameter is the process name " + + "and its (optional) command line.\r\n" + + "Use the following variables for command line replacements:\r\n" + + "%F = Log file name (full path)\r\n" + + "%T = Tab title\r\n" + + "%L = Line number of keyword hit\r\n" + + "%K = Keyword\r\n" + + "%C = Complete line content"; } + + #endregion } \ No newline at end of file diff --git a/src/FlashIconHighlighter/FlashIconPlugin.cs b/src/FlashIconHighlighter/FlashIconPlugin.cs index 3e4b0341..2ffe69b0 100644 --- a/src/FlashIconHighlighter/FlashIconPlugin.cs +++ b/src/FlashIconHighlighter/FlashIconPlugin.cs @@ -12,10 +12,7 @@ internal class FlashIconPlugin : IKeywordAction { #region Properties - public string Text - { - get { return GetName(); } - } + public string Text => GetName(); #endregion diff --git a/src/GlassfishColumnizer/GlassfishColumnizer.cs b/src/GlassfishColumnizer/GlassfishColumnizer.cs index f5f93951..ded86f18 100644 --- a/src/GlassfishColumnizer/GlassfishColumnizer.cs +++ b/src/GlassfishColumnizer/GlassfishColumnizer.cs @@ -18,7 +18,7 @@ internal class GlassfishColumnizer : ILogLineXmlColumnizer private readonly char separatorChar = '|'; private readonly char[] trimChars = ['|']; protected CultureInfo cultureInfo = new("en-US"); - protected int timeOffset = 0; + protected int timeOffset; #endregion @@ -73,7 +73,7 @@ public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLin ColumnizedLogLine cLogLine = new(); cLogLine.LogLine = line; - string temp = line.FullLine; + var temp = line.FullLine; Column[] columns = Column.CreateColumns(COLUMN_COUNT, cLogLine); cLogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); @@ -105,7 +105,7 @@ public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLin columns[1].FullValue = temp; } - string newDate = dateTime.ToString(DATETIME_FORMAT_OUT); + var newDate = dateTime.ToString(DATETIME_FORMAT_OUT); columns[0].FullValue = newDate; } catch (Exception) @@ -150,7 +150,7 @@ public int GetTimeOffset() public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine logLine) { - string temp = logLine.FullLine; + var temp = logLine.FullLine; // delete '[#|' and '|#]' if (temp.StartsWith("[#|")) @@ -168,13 +168,13 @@ public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine logLi return DateTime.MinValue; } - int endIndex = temp.IndexOf(separatorChar, 1); + var endIndex = temp.IndexOf(separatorChar, 1); if (endIndex > 28 || endIndex < 0) { return DateTime.MinValue; } - string value = temp[..endIndex]; + var value = temp[..endIndex]; try { @@ -198,10 +198,10 @@ public void PushValue(ILogLineColumnizerCallback callback, int column, string va { try { - DateTime newDateTime = DateTime.ParseExact(value, DATETIME_FORMAT_OUT, cultureInfo); - DateTime oldDateTime = DateTime.ParseExact(oldValue, DATETIME_FORMAT_OUT, cultureInfo); - long mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; - long mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; + var newDateTime = DateTime.ParseExact(value, DATETIME_FORMAT_OUT, cultureInfo); + var oldDateTime = DateTime.ParseExact(oldValue, DATETIME_FORMAT_OUT, cultureInfo); + var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; + var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; timeOffset = (int)(mSecsNew - mSecsOld); } catch (FormatException) diff --git a/src/GlassfishColumnizer/XmlConfig.cs b/src/GlassfishColumnizer/XmlConfig.cs index 44ecec47..4dab78d5 100644 --- a/src/GlassfishColumnizer/XmlConfig.cs +++ b/src/GlassfishColumnizer/XmlConfig.cs @@ -10,7 +10,7 @@ internal class XmlConfig : IXmlLogConfiguration public string XmlEndTag { get; } = "|#]"; - public string Stylesheet { get; } = null; + public string Stylesheet { get; } public string[] Namespace => null; diff --git a/src/JsonColumnizer/JsonColumnizer.cs b/src/JsonColumnizer/JsonColumnizer.cs index c77b45d6..250105f3 100644 --- a/src/JsonColumnizer/JsonColumnizer.cs +++ b/src/JsonColumnizer/JsonColumnizer.cs @@ -94,8 +94,8 @@ public virtual int GetColumnCount() public virtual string[] GetColumnNames() { - string[] names = new string[GetColumnCount()]; - int i = 0; + var names = new string[GetColumnCount()]; + var i = 0; foreach (var column in ColumnList) { names[i++] = column.Name; diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs index a221c39b..29d2fa3b 100644 --- a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs @@ -26,7 +26,7 @@ public class Log4jXmlColumnizer : ILogLineXmlColumnizer, IColumnizerConfigurator private readonly char[] trimChars = ['\xFFFD']; private Log4jXmlColumnizerConfig _config; protected CultureInfo cultureInfo = new("de-DE"); - protected int timeOffset = 0; + protected int timeOffset; #endregion @@ -101,7 +101,7 @@ public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLin columns[8].FullValue = line.FullLine; } - string newDate = dateTime.ToString(DATETIME_FORMAT); + var newDate = dateTime.ToString(DATETIME_FORMAT); columns[0].FullValue = newDate; } catch (Exception) @@ -130,7 +130,7 @@ public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLin { columns[0] = timestmp; - for (int i = 1; i < cols.Length; i++) + for (var i = 1; i < cols.Length; i++) { columns[i].FullValue = cols[i]; } @@ -168,18 +168,18 @@ public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) return DateTime.MinValue; } - int endIndex = line.FullLine.IndexOf(separatorChar, 1); + var endIndex = line.FullLine.IndexOf(separatorChar, 1); if (endIndex > 20 || endIndex < 0) { return DateTime.MinValue; } - string value = line.FullLine.Substring(0, endIndex); + var value = line.FullLine.Substring(0, endIndex); try { // convert log4j timestamp into a readable format: - if (long.TryParse(value, out long timestamp)) + if (long.TryParse(value, out var timestamp)) { // Add the time offset before returning DateTime dateTime = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); @@ -208,10 +208,10 @@ public void PushValue(ILogLineColumnizerCallback callback, int column, string va { try { - DateTime newDateTime = DateTime.ParseExact(value, DATETIME_FORMAT, cultureInfo); - DateTime oldDateTime = DateTime.ParseExact(oldValue, DATETIME_FORMAT, cultureInfo); - long mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; - long mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; + var newDateTime = DateTime.ParseExact(value, DATETIME_FORMAT, cultureInfo); + var oldDateTime = DateTime.ParseExact(oldValue, DATETIME_FORMAT, cultureInfo); + var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; + var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; timeOffset = (int)(mSecsNew - mSecsOld); } catch (FormatException) @@ -236,7 +236,7 @@ public void Configure(ILogLineColumnizerCallback callback, string configDir) public void LoadConfig(string configDir) { - string configPath = configDir + Path.DirectorySeparatorChar + "log4jxmlcolumnizer.json"; + var configPath = configDir + Path.DirectorySeparatorChar + "log4jxmlcolumnizer.json"; FileInfo fileInfo = new(configDir + Path.DirectorySeparatorChar + "log4jxmlcolumnizer.json"); @@ -286,7 +286,7 @@ public Priority GetPriority(string fileName, IEnumerable samples) private Column[] MapColumns(Column[] cols) { List output = []; - int index = 0; + var index = 0; foreach (Log4jColumnEntry entry in _config.columnList) { if (entry.Visible) diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfig.cs b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfig.cs index 7954f47c..92a2c3c5 100644 --- a/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfig.cs +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfig.cs @@ -32,7 +32,7 @@ public int ActiveColumnCount { get { - int count = 0; + var count = 0; foreach (Log4jColumnEntry entry in columnList) { if (entry.Visible) @@ -51,8 +51,8 @@ public string[] ActiveColumnNames { get { - string[] names = new string[ActiveColumnCount]; - int index = 0; + var names = new string[ActiveColumnCount]; + var index = 0; foreach (Log4jColumnEntry entry in columnList) { if (entry.Visible) @@ -71,7 +71,7 @@ public string[] ActiveColumnNames public void FillDefaults(string[] columnNames) { columnList.Clear(); - for (int i = 0; i < columnNames.Length; ++i) + for (var i = 0; i < columnNames.Length; ++i) { columnList.Add(new Log4jColumnEntry(columnNames[i], i, 0)); } diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs index 5ce046d7..74eedaab 100644 --- a/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs @@ -35,9 +35,9 @@ public Log4jXmlColumnizerConfigDlg(Log4jXmlColumnizerConfig config) private void FillListBox() { - DataGridViewCheckBoxColumn checkColumn = (DataGridViewCheckBoxColumn)columnGridView.Columns[0]; - DataGridViewTextBoxColumn nameColumn = (DataGridViewTextBoxColumn)columnGridView.Columns[1]; - DataGridViewTextBoxColumn lenColumn = (DataGridViewTextBoxColumn)columnGridView.Columns[2]; + var checkColumn = (DataGridViewCheckBoxColumn)columnGridView.Columns[0]; + var nameColumn = (DataGridViewTextBoxColumn)columnGridView.Columns[1]; + var lenColumn = (DataGridViewTextBoxColumn)columnGridView.Columns[2]; foreach (Log4jColumnEntry entry in _config.columnList) { @@ -62,12 +62,12 @@ private void OkButton_Click(object sender, EventArgs e) // { // this.config.columnList[i]. visible = this.columnListBox.GetItemChecked(i); // } - for (int i = 0; i < columnGridView.Rows.Count; ++i) + for (var i = 0; i < columnGridView.Rows.Count; ++i) { _config.columnList[i].Visible = (bool)columnGridView.Rows[i].Cells[0].Value; - string sLen = (string)columnGridView.Rows[i].Cells[2].Value; + var sLen = (string)columnGridView.Rows[i].Cells[2].Value; - if (int.TryParse(sLen, out int len)) + if (int.TryParse(sLen, out var len)) { _config.columnList[i].MaxLen = len; } diff --git a/src/Log4jXmlColumnizer/XmlConfig.cs b/src/Log4jXmlColumnizer/XmlConfig.cs index cd84e535..6e4888a8 100644 --- a/src/Log4jXmlColumnizer/XmlConfig.cs +++ b/src/Log4jXmlColumnizer/XmlConfig.cs @@ -26,10 +26,7 @@ internal class XmlConfig : IXmlLogConfiguration "" + ""; - public string[] Namespace - { - get { return ["log4j", "http://jakarta.apache.org/log4j"]; } - } + public string[] Namespace => ["log4j", "http://jakarta.apache.org/log4j"]; #endregion } diff --git a/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs b/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs index 6cd3fa13..2100f803 100644 --- a/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs +++ b/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs @@ -18,7 +18,7 @@ public static void ExportBookmarkList (SortedList bookma writer.WriteLine("Log file name;Line number;Comment"); foreach (Entities.Bookmark bookmark in bookmarkList.Values) { - string line = $"{logfileName};{bookmark.LineNum};{bookmark.Text.Replace(replacementForNewLine, @"\" + replacementForNewLine, StringComparison.OrdinalIgnoreCase).Replace("\r\n", replacementForNewLine, StringComparison.OrdinalIgnoreCase)}"; + var line = $"{logfileName};{bookmark.LineNum};{bookmark.Text.Replace(replacementForNewLine, @"\" + replacementForNewLine, StringComparison.OrdinalIgnoreCase).Replace("\r\n", replacementForNewLine, StringComparison.OrdinalIgnoreCase)}"; writer.WriteLine(line); } writer.Close(); diff --git a/src/LogExpert.Core/Classes/Columnizer/ClfColumnizer.cs b/src/LogExpert.Core/Classes/Columnizer/ClfColumnizer.cs index 14dbe3f0..6c20cb96 100644 --- a/src/LogExpert.Core/Classes/Columnizer/ClfColumnizer.cs +++ b/src/LogExpert.Core/Classes/Columnizer/ClfColumnizer.cs @@ -12,7 +12,7 @@ public class ClfColumnizer : ILogLineColumnizer private readonly Regex lineRegex = new("(.*) (-) (.*) (\\[.*\\]) (\".*\") (.*) (.*) (\".*\") (\".*\")"); protected CultureInfo cultureInfo = new("de-DE"); - protected int timeOffset = 0; + protected int timeOffset; #endregion @@ -58,7 +58,7 @@ public DateTime GetTimestamp(LogExpert.ILogLineColumnizerCallback callback, ILog try { - DateTime dateTime = DateTime.ParseExact(cols.ColumnValues[2].FullValue, "dd/MMM/yyyy:HH:mm:ss zzz", + var dateTime = DateTime.ParseExact(cols.ColumnValues[2].FullValue, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US")); return dateTime; } @@ -74,12 +74,12 @@ public void PushValue(LogExpert.ILogLineColumnizerCallback callback, int column, { try { - DateTime newDateTime = + var newDateTime = DateTime.ParseExact(value, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US")); - DateTime oldDateTime = + var oldDateTime = DateTime.ParseExact(oldValue, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US")); - long mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; - long mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; + var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; + var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; timeOffset = (int)(mSecsNew - mSecsOld); } catch (FormatException) @@ -115,7 +115,7 @@ public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callbac LogLine = line }; - Column[] columns = new Column[8] + var columns = new Column[8] { new() {FullValue = "", Parent = cLogLine}, new() {FullValue = "", Parent = cLogLine}, @@ -129,7 +129,7 @@ public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callbac cLogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); - string temp = line.FullLine; + var temp = line.FullLine; if (temp.Length > 1024) { // spam @@ -154,7 +154,7 @@ public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callbac columns[6].FullValue = groups[8].Value; columns[7].FullValue = groups[9].Value; - string dateTimeStr = groups[4].Value.Substring(1, 26); + var dateTimeStr = groups[4].Value.Substring(1, 26); // dirty probing of date/time format (much faster than DateTime.ParseExact() if (dateTimeStr[2] == '/' && dateTimeStr[6] == '/' && dateTimeStr[11] == ':') @@ -163,10 +163,10 @@ public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callbac { try { - DateTime dateTime = DateTime.ParseExact(dateTimeStr, "dd/MMM/yyyy:HH:mm:ss zzz", + var dateTime = DateTime.ParseExact(dateTimeStr, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US")); dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); - string newDate = dateTime.ToString("dd/MMM/yyyy:HH:mm:ss zzz", + var newDate = dateTime.ToString("dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US")); columns[2].FullValue = newDate; } diff --git a/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs b/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs index abb616a0..aada7351 100644 --- a/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs +++ b/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs @@ -41,7 +41,7 @@ public static ILogLineColumnizer CloneColumnizer(ILogLineColumnizer columnizer, if (cti != null) { - object o = cti.Invoke([]); + var o = cti.Invoke([]); if (o is IColumnizerConfigurator configurator) { diff --git a/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs b/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs index 9ca62371..d1331b3c 100644 --- a/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs +++ b/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs @@ -8,12 +8,12 @@ public class SquareBracketColumnizer : ILogLineColumnizer, IColumnizerPriority { #region ILogLineColumnizer implementation - protected int timeOffset = 0; + protected int timeOffset; private TimeFormatDeterminer _timeFormatDeterminer = new(); // TODO: need preparing this columnizer with sample log lines before use it. private int _columnCount = 5; - private bool _isTimeExists = false; + private bool _isTimeExists; public SquareBracketColumnizer () { @@ -67,7 +67,7 @@ public DateTime GetTimestamp (LogExpert.ILogLineColumnizerCallback callback, ILo try { - DateTime dateTime = DateTime.ParseExact( + var dateTime = DateTime.ParseExact( cols.ColumnValues[0].FullValue + " " + cols.ColumnValues[1].FullValue, formatInfo.DateTimeFormat, formatInfo.CultureInfo); return dateTime; @@ -90,10 +90,10 @@ public void PushValue (LogExpert.ILogLineColumnizerCallback callback, int column return; } - DateTime newDateTime = DateTime.ParseExact(value, formatInfo.TimeFormat, formatInfo.CultureInfo); - DateTime oldDateTime = DateTime.ParseExact(oldValue, formatInfo.TimeFormat, formatInfo.CultureInfo); - long mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; - long mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; + var newDateTime = DateTime.ParseExact(value, formatInfo.TimeFormat, formatInfo.CultureInfo); + var oldDateTime = DateTime.ParseExact(oldValue, formatInfo.TimeFormat, formatInfo.CultureInfo); + var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; + var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; timeOffset = (int)(mSecsNew - mSecsOld); } catch (FormatException) @@ -139,7 +139,7 @@ public string[] GetColumnNames () // Last column is the message columnNames.Add("Message"); - int i = 1; + var i = 1; while (columnNames.Count < GetColumnCount()) { columnNames.Insert(columnNames.Count - 1, "Source" + i++.ToString()); @@ -159,14 +159,14 @@ public IColumnizedLogLine SplitLine (LogExpert.ILogLineColumnizerCallback callba LogLine = line }; - Column[] columns = new Column[] + var columns = new Column[] { new() {FullValue = "", Parent = clogLine}, new() {FullValue = "", Parent = clogLine}, new() {FullValue = "", Parent = clogLine}, }; - string temp = line.FullLine; + var temp = line.FullLine; if (temp.Length < 3) { @@ -182,17 +182,17 @@ public IColumnizedLogLine SplitLine (LogExpert.ILogLineColumnizerCallback callba } else { - int endPos = formatInfo.DateTimeFormat.Length; - int timeLen = formatInfo.TimeFormat.Length; - int dateLen = formatInfo.DateFormat.Length; + var endPos = formatInfo.DateTimeFormat.Length; + var timeLen = formatInfo.TimeFormat.Length; + var dateLen = formatInfo.DateFormat.Length; try { if (timeOffset != 0) { - DateTime dateTime = DateTime.ParseExact(temp.Substring(0, endPos), formatInfo.DateTimeFormat, + var dateTime = DateTime.ParseExact(temp.Substring(0, endPos), formatInfo.DateTimeFormat, formatInfo.CultureInfo); dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); - string newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); + var newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); SquareSplit(ref columns, newDate, dateLen, timeLen, endPos, clogLine); } @@ -217,7 +217,7 @@ public IColumnizedLogLine SplitLine (LogExpert.ILogLineColumnizerCallback callba void SquareSplit (ref Column[] columns, string line, int dateLen, int timeLen, int dateTimeEndPos, ColumnizedLogLine clogLine) { List columnList = []; - int restColumn = _columnCount; + var restColumn = _columnCount; if (_isTimeExists) { columnList.Add(new Column { FullValue = line.Substring(0, dateLen), Parent = clogLine }); @@ -225,11 +225,11 @@ void SquareSplit (ref Column[] columns, string line, int dateLen, int timeLen, i restColumn -= 2; } - int nextPos = dateTimeEndPos; + var nextPos = dateTimeEndPos; - string rest = line; + var rest = line; - for (int i = 0; i < restColumn; i++) + for (var i = 0; i < restColumn; i++) { rest = rest.Substring(nextPos); //var fullValue = rest.Substring(0, rest.IndexOf(']')).TrimStart(new char[] {' '}).TrimEnd(new char[] { ' ' }); @@ -257,19 +257,19 @@ public Priority GetPriority (string fileName, IEnumerable samples) { Priority result = Priority.NotSupport; TimeFormatDeterminer timeDeterminer = new(); - int timeStampExistsCount = 0; - int bracketsExistsCount = 0; - int maxBracketNumbers = 1; + var timeStampExistsCount = 0; + var bracketsExistsCount = 0; + var maxBracketNumbers = 1; foreach (var logline in samples) { - string line = logline?.FullLine; + var line = logline?.FullLine; if (string.IsNullOrEmpty(line)) { continue; } - int bracketNumbers = 1; + var bracketNumbers = 1; if (null != timeDeterminer.DetermineDateTimeFormatInfo(line)) { timeStampExistsCount++; @@ -279,7 +279,7 @@ public Priority GetPriority (string fileName, IEnumerable samples) timeStampExistsCount--; } - string noSpaceLine = line.Replace(" ", string.Empty); + var noSpaceLine = line.Replace(" ", string.Empty); if (noSpaceLine.IndexOf('[') >= 0 && noSpaceLine.IndexOf(']') >= 0 && noSpaceLine.IndexOf('[') < noSpaceLine.IndexOf(']')) { diff --git a/src/LogExpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs b/src/LogExpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs index 77da6cbd..46ea6327 100644 --- a/src/LogExpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs +++ b/src/LogExpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs @@ -27,10 +27,7 @@ public FormatInfo(string dateFormat, string timeFormat, CultureInfo cultureInfo) public CultureInfo CultureInfo { get; } - public string DateTimeFormat - { - get { return DateFormat + " " + TimeFormat; } - } + public string DateTimeFormat => DateFormat + " " + TimeFormat; public bool IgnoreFirstChar { get; set; } @@ -69,8 +66,8 @@ public FormatInfo DetermineDateTimeFormatInfo(string line) return null; } - string temp = line; - bool ignoreFirst = false; + var temp = line; + var ignoreFirst = false; // determine if string starts with bracket and remove it if (temp[0] == '[' || temp[0] == '(' || temp[0] == '{') diff --git a/src/LogExpert.Core/Classes/Columnizer/TimestampColumnizer.cs b/src/LogExpert.Core/Classes/Columnizer/TimestampColumnizer.cs index fd033f9a..ea89f963 100644 --- a/src/LogExpert.Core/Classes/Columnizer/TimestampColumnizer.cs +++ b/src/LogExpert.Core/Classes/Columnizer/TimestampColumnizer.cs @@ -6,7 +6,7 @@ public class TimestampColumnizer : ILogLineColumnizer, IColumnizerPriority { #region ILogLineColumnizer implementation - protected int timeOffset = 0; + protected int timeOffset; private TimeFormatDeterminer _timeFormatDeterminer = new(); public bool IsTimeshiftImplemented() @@ -44,7 +44,7 @@ public DateTime GetTimestamp(LogExpert.ILogLineColumnizerCallback callback, ILog try { - DateTime dateTime = DateTime.ParseExact( + var dateTime = DateTime.ParseExact( cols.ColumnValues[0].FullValue + " " + cols.ColumnValues[1].FullValue, formatInfo.DateTimeFormat, formatInfo.CultureInfo); return dateTime; @@ -67,10 +67,10 @@ public void PushValue(LogExpert.ILogLineColumnizerCallback callback, int column, { return; } - DateTime newDateTime = DateTime.ParseExact(value, formatInfo.TimeFormat, formatInfo.CultureInfo); - DateTime oldDateTime = DateTime.ParseExact(oldValue, formatInfo.TimeFormat, formatInfo.CultureInfo); - long mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; - long mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; + var newDateTime = DateTime.ParseExact(value, formatInfo.TimeFormat, formatInfo.CultureInfo); + var oldDateTime = DateTime.ParseExact(oldValue, formatInfo.TimeFormat, formatInfo.CultureInfo); + var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; + var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; timeOffset = (int)(mSecsNew - mSecsOld); } catch (FormatException) @@ -108,7 +108,7 @@ public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callbac ColumnizedLogLine clogLine = new(); clogLine.LogLine = line; - Column[] columns = new Column[3] + var columns = new Column[3] { new() {FullValue = "", Parent = clogLine}, new() {FullValue = "", Parent = clogLine}, @@ -117,7 +117,7 @@ public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callbac clogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); - string temp = line.FullLine; + var temp = line.FullLine; FormatInfo formatInfo = _timeFormatDeterminer.DetermineDateTimeFormatInfo(temp); if (formatInfo == null) @@ -125,9 +125,9 @@ public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callbac columns[2].FullValue = temp; return clogLine; } - int endPos = formatInfo.DateTimeFormat.Length; - int timeLen = formatInfo.TimeFormat.Length; - int dateLen = formatInfo.DateFormat.Length; + var endPos = formatInfo.DateTimeFormat.Length; + var timeLen = formatInfo.TimeFormat.Length; + var dateLen = formatInfo.DateFormat.Length; try { if (timeOffset != 0) @@ -135,20 +135,20 @@ public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callbac if (formatInfo.IgnoreFirstChar) { // First character is a bracket and should be ignored - DateTime dateTime = DateTime.ParseExact(temp.Substring(1, endPos), formatInfo.DateTimeFormat, + var dateTime = DateTime.ParseExact(temp.Substring(1, endPos), formatInfo.DateTimeFormat, formatInfo.CultureInfo); dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); - string newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); + var newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); columns[0].FullValue = newDate.Substring(0, dateLen); // date columns[1].FullValue = newDate.Substring(dateLen + 1, timeLen); // time columns[2].FullValue = temp.Substring(endPos + 2); // rest of line } else { - DateTime dateTime = DateTime.ParseExact(temp.Substring(0, endPos), formatInfo.DateTimeFormat, + var dateTime = DateTime.ParseExact(temp.Substring(0, endPos), formatInfo.DateTimeFormat, formatInfo.CultureInfo); dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); - string newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); + var newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); columns[0].FullValue = newDate.Substring(0, dateLen); // date columns[1].FullValue = newDate.Substring(dateLen + 1, timeLen); // time columns[2].FullValue = temp.Substring(endPos); // rest of line @@ -184,7 +184,7 @@ public Priority GetPriority(string fileName, IEnumerable samples) { Priority result = Priority.NotSupport; - int timeStampCount = 0; + var timeStampCount = 0; foreach (var line in samples) { if (line == null || string.IsNullOrEmpty(line.FullLine)) diff --git a/src/LogExpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs b/src/LogExpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs index 0855f9e5..d637d03d 100644 --- a/src/LogExpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs +++ b/src/LogExpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs @@ -18,7 +18,7 @@ public static class DateFormatPartAdjuster public static string AdjustDateTimeFormatPart(string part) { - if (!_dateTimePartReplacements.TryGetValue(part, out string adjustedPart)) + if (!_dateTimePartReplacements.TryGetValue(part, out var adjustedPart)) { return part; } diff --git a/src/LogExpert.Core/Classes/DateTimeParser/Parser.cs b/src/LogExpert.Core/Classes/DateTimeParser/Parser.cs index cb558c06..5828d843 100644 --- a/src/LogExpert.Core/Classes/DateTimeParser/Parser.cs +++ b/src/LogExpert.Core/Classes/DateTimeParser/Parser.cs @@ -29,7 +29,7 @@ public static List
    ParseSections(string formatString, out bool syntaxEr private static Section ParseSection(Tokenizer reader, int index, out bool syntaxError) { - bool hasDateParts = false; + var hasDateParts = false; string token; List tokens = []; @@ -56,8 +56,7 @@ private static Section ParseSection(Tokenizer reader, int index, out bool syntax return null; } - List generalTextDateDuration = null; - + List generalTextDateDuration; if (hasDateParts) { ParseMilliseconds(tokens, out generalTextDateDuration); diff --git a/src/LogExpert.Core/Classes/DateTimeParser/Tokenizer.cs b/src/LogExpert.Core/Classes/DateTimeParser/Tokenizer.cs index baf16dba..46fa909f 100644 --- a/src/LogExpert.Core/Classes/DateTimeParser/Tokenizer.cs +++ b/src/LogExpert.Core/Classes/DateTimeParser/Tokenizer.cs @@ -5,7 +5,7 @@ namespace LogExpert.Core.Classes.DateTimeParser internal class Tokenizer { private string formatString; - private int formatStringPosition = 0; + private int formatStringPosition; public Tokenizer(string fmt) { @@ -33,7 +33,7 @@ public int Peek(int offset = 0) public int PeekUntil(int startOffset, int until) { - int offset = startOffset; + var offset = startOffset; while (true) { var c = Peek(offset++); @@ -127,7 +127,7 @@ public bool ReadEnclosed(char open, char close) { if (Peek() == open) { - int length = PeekUntil(1, close); + var length = PeekUntil(1, close); if (length > 0) { Advance(1 + length); diff --git a/src/LogExpert.Core/Classes/Filter/Filter.cs b/src/LogExpert.Core/Classes/Filter/Filter.cs index f7ee2603..7b6914bf 100644 --- a/src/LogExpert.Core/Classes/Filter/Filter.cs +++ b/src/LogExpert.Core/Classes/Filter/Filter.cs @@ -40,7 +40,7 @@ public Filter (ColumnizerCallback callback) public List FilterHitList { get; } - public bool ShouldCancel { get; set; } = false; + public bool ShouldCancel { get; set; } #endregion @@ -144,7 +144,7 @@ private IList GetAdditionalFilterResults (FilterParams filterParams, int li } // back spread - for (int i = filterParams.SpreadBefore; i > 0; --i) + for (var i = filterParams.SpreadBefore; i > 0; --i) { if (lineNum - i > 0) { @@ -160,7 +160,7 @@ private IList GetAdditionalFilterResults (FilterParams filterParams, int li resultList.Add(lineNum); } // after spread - for (int i = 1; i <= filterParams.SpreadBehind; ++i) + for (var i = 1; i <= filterParams.SpreadBehind; ++i) { if (lineNum + i < _callback.GetLineCount()) { diff --git a/src/LogExpert.Core/Classes/Filter/FilterParams.cs b/src/LogExpert.Core/Classes/Filter/FilterParams.cs index d59c9deb..29da3de9 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterParams.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterParams.cs @@ -52,7 +52,7 @@ public string RangeSearchText public bool EmptyColumnHit { get; set; } - public bool ExactColumnMatch { get; set; } = false; + public bool ExactColumnMatch { get; set; } public bool ColumnRestrict { get; set; } @@ -64,7 +64,7 @@ public string RangeSearchText public bool IsInvert { get; set; } - public bool IsRangeSearch { get; set; } = false; + public bool IsRangeSearch { get; set; } public bool IsRegex { get; set; } @@ -80,7 +80,7 @@ public string RangeSearchText /// true=looking for end /// [field: NonSerialized] - public bool IsInRange { get; set; } = false; + public bool IsInRange { get; set; } [field: NonSerialized] public string LastLine { get; set; } = string.Empty; diff --git a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs index fecae37f..4464023e 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs @@ -127,9 +127,9 @@ public void ShiftLineNums(int offset) List newList = []; lock (_lineMappingList) { - foreach (int lineNum in _lineMappingList) + foreach (var lineNum in _lineMappingList) { - int line = lineNum - offset; + var line = lineNum - offset; if (line >= 0) { newList.Add(line); @@ -148,7 +148,7 @@ public void ClearLineNums() _logger.Debug("FilterPipe.ClearLineNums()"); lock (_lineMappingList) { - for (int i = 0; i < _lineMappingList.Count; ++i) + for (var i = 0; i < _lineMappingList.Count; ++i) { _lineMappingList[i] = -1; } diff --git a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs index c3956c6d..4bc5f8c6 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs @@ -76,14 +76,14 @@ public async void DoFilter (FilterParams filterParams, int startLine, int maxCou _filterWorkerList.Clear(); _shouldStop = false; - int interval = maxCount / ThreadCount; + var interval = maxCount / ThreadCount; if (interval < 1) { interval = 1; } - int workStartLine = startLine; + var workStartLine = startLine; List handleList = []; _progressLineCount = 0; _progressCallback = progressCallback; @@ -136,7 +136,7 @@ public void CancelFilter () private void ThreadProgressCallback (int lineCount) { - int count = Interlocked.Add(ref _progressLineCount, lineCount); + var count = Interlocked.Add(ref _progressLineCount, lineCount); _progressCallback(count); } @@ -188,21 +188,21 @@ private void MergeResults () _logger.Info("Merging filter results."); foreach (Filter filter in _filterReadyList) { - foreach (int lineNum in filter.FilterHitList) + foreach (var lineNum in filter.FilterHitList) { if (!_filterHitDict.ContainsKey(lineNum)) { _filterHitDict.Add(lineNum, lineNum); } } - foreach (int lineNum in filter.FilterResultLines) + foreach (var lineNum in filter.FilterResultLines) { if (!_filterResultDict.ContainsKey(lineNum)) { _filterResultDict.Add(lineNum, lineNum); } } - foreach (int lineNum in filter.LastFilterLinesList) + foreach (var lineNum in filter.LastFilterLinesList) { if (!_lastFilterLinesDict.ContainsKey(lineNum)) { diff --git a/src/LogExpert.Core/Classes/Log/LogBuffer.cs b/src/LogExpert.Core/Classes/Log/LogBuffer.cs index 896ca8b3..5f607e68 100644 --- a/src/LogExpert.Core/Classes/Log/LogBuffer.cs +++ b/src/LogExpert.Core/Classes/Log/LogBuffer.cs @@ -32,7 +32,7 @@ public LogBuffer(ILogFileInfo fileInfo, int maxLines) #region Properties - public long StartPos { set; get; } = 0; + public long StartPos { set; get; } public long Size { @@ -52,7 +52,7 @@ public long Size get => _size; } - public int StartLine { set; get; } = 0; + public int StartLine { set; get; } public int LineCount { get; private set; } @@ -60,9 +60,9 @@ public long Size public ILogFileInfo FileInfo { get; set; } - public int DroppedLinesCount { get; set; } = 0; + public int DroppedLinesCount { get; set; } - public int PrevBuffersDroppedLinesSum { get; set; } = 0; + public int PrevBuffersDroppedLinesSum { get; set; } #endregion diff --git a/src/LogExpert.Core/Classes/Log/LogfileReader.cs b/src/LogExpert.Core/Classes/Log/LogfileReader.cs index aa236303..87be8741 100644 --- a/src/LogExpert.Core/Classes/Log/LogfileReader.cs +++ b/src/LogExpert.Core/Classes/Log/LogfileReader.cs @@ -78,7 +78,7 @@ public LogfileReader (string fileName, EncodingOptions encodingOptions, bool mul LinkedList nameList = rolloverHandler.GetNameList(_pluginRegistry); ILogFileInfo fileInfo = null; - foreach (string name in nameList) + foreach (var name in nameList) { fileInfo = AddFile(name); } @@ -111,7 +111,7 @@ public LogfileReader (string[] fileNames, EncodingOptions encodingOptions, int b InitLruBuffers(); ILogFileInfo fileInfo = null; - foreach (string name in fileNames) + foreach (var name in fileNames) { fileInfo = AddFile(name); } @@ -176,11 +176,11 @@ public int LineCount public long FileSize { get; private set; } - public bool IsXmlMode { get; set; } = false; + public bool IsXmlMode { get; set; } public IXmlLogConfiguration XmlLogConfig { get; set; } - public IPreProcessColumnizer PreProcessColumnizer { get; set; } = null; + public IPreProcessColumnizer PreProcessColumnizer { get; set; } public EncodingOptions EncodingOptions { @@ -260,7 +260,7 @@ public int ShiftBuffers () { _logger.Info("ShiftBuffers() begin for {0}{1}", _fileName, IsMultiFile ? " (MultiFile)" : ""); AcquireBufferListWriterLock(); - int offset = 0; + var offset = 0; _isLineCountDirty = true; lock (_monitor) { @@ -275,7 +275,7 @@ public int ShiftBuffers () while (enumerator.MoveNext()) { ILogFileInfo logFileInfo = enumerator.Current; - string fileName = logFileInfo.FullName; + var fileName = logFileInfo.FullName; _logger.Debug("Testing file {0}", fileName); LinkedListNode node = fileNameList.Find(fileName); if (node == null) @@ -373,7 +373,7 @@ public int ShiftBuffers () _logger.Info("Deleting buffers for the watched file"); DeleteBuffersForInfo(_watchedILogFileInfo, true); - int startLine = LineCount - 1; + var startLine = LineCount - 1; _logger.Info("Re-Reading files"); foreach (ILogFileInfo ILogFileInfo in readNewILogFileInfoList) { @@ -459,7 +459,7 @@ public string GetLogFileNameForLine (int lineNum) { AcquireBufferListReaderLock(); LogBuffer logBuffer = GetBufferForLine(lineNum); - string fileName = logBuffer?.FileInfo.FullName; + var fileName = logBuffer?.FileInfo.FullName; ReleaseBufferListReaderLock(); return fileName; } @@ -486,15 +486,15 @@ public ILogFileInfo GetLogFileInfoForLine (int lineNum) /// public int GetNextMultiFileLine (int lineNum) { - int result = -1; + var result = -1; AcquireBufferListReaderLock(); LogBuffer logBuffer = GetBufferForLine(lineNum); if (logBuffer != null) { - int index = _bufferList.IndexOf(logBuffer); + var index = _bufferList.IndexOf(logBuffer); if (index != -1) { - for (int i = index; i < _bufferList.Count; ++i) + for (var i = index; i < _bufferList.Count; ++i) { if (_bufferList[i].FileInfo != logBuffer.FileInfo) { @@ -511,15 +511,15 @@ public int GetNextMultiFileLine (int lineNum) public int GetPrevMultiFileLine (int lineNum) { - int result = -1; + var result = -1; AcquireBufferListReaderLock(); LogBuffer logBuffer = GetBufferForLine(lineNum); if (logBuffer != null) { - int index = _bufferList.IndexOf(logBuffer); + var index = _bufferList.IndexOf(logBuffer); if (index != -1) { - for (int i = index; i >= 0; --i) + for (var i = index; i >= 0; --i) { if (_bufferList[i].FileInfo != logBuffer.FileInfo) { @@ -547,7 +547,7 @@ public int GetRealLineNumForVirtualLineNum (int lineNum) { AcquireBufferListReaderLock(); LogBuffer logBuffer = GetBufferForLine(lineNum); - int result = -1; + var result = -1; if (logBuffer != null) { logBuffer = GetFirstBufferForFileByLogBuffer(logBuffer); @@ -603,7 +603,7 @@ public void StopMonitoring () /// public void StopMonitoringAsync () { - Task task = Task.Run(StopMonitoring); + var task = Task.Run(StopMonitoring); //Thread stopperThread = new(new ThreadStart(StopMonitoring)) //{ @@ -711,17 +711,17 @@ public void LogBufferDiagnostic () { _logger.Info("-------- Buffer diagnostics -------"); _lruCacheDictLock.AcquireReaderLock(Timeout.Infinite); - int cacheCount = _lruCacheDict.Count; + var cacheCount = _lruCacheDict.Count; _logger.Info("LRU entries: {0}", cacheCount); _lruCacheDictLock.ReleaseReaderLock(); AcquireBufferListReaderLock(); _logger.Info("File: {0}\r\nBuffer count: {1}\r\nDisposed buffers: {2}", _fileName, _bufferList.Count, _bufferList.Count - cacheCount); - int lineNum = 0; + var lineNum = 0; long disposeSum = 0; long maxDispose = 0; long minDispose = int.MaxValue; - for (int i = 0; i < _bufferList.Count; ++i) + for (var i = 0; i < _bufferList.Count; ++i) { LogBuffer buffer = _bufferList[i]; _disposeLock.AcquireReaderLock(Timeout.Infinite); @@ -933,7 +933,7 @@ private void ReadToBufferList (ILogFileInfo logFileInfo, long filePos, int start reader.Position = filePos; _fileLength = logFileInfo.Length; - int lineNum = startLine; + var lineNum = startLine; LogBuffer logBuffer; AcquireBufferListReaderLock(); if (_bufferList.Count == 0) @@ -972,8 +972,8 @@ private void ReadToBufferList (ILogFileInfo logFileInfo, long filePos, int start Monitor.Enter(logBuffer); // Lock the buffer ReleaseBufferListReaderLock(); - int lineCount = logBuffer.LineCount; - int droppedLines = logBuffer.PrevBuffersDroppedLinesSum; + var lineCount = logBuffer.LineCount; + var droppedLines = logBuffer.PrevBuffersDroppedLinesSum; filePos = reader.Position; while (ReadLine(reader, logBuffer.StartLine + logBuffer.LineCount, logBuffer.StartLine + logBuffer.LineCount + droppedLines, out var line)) @@ -1129,9 +1129,9 @@ private void GarbageCollectLruCache () long startTime = Environment.TickCount; #endif _logger.Debug("Starting garbage collection"); - int threshold = 10; + var threshold = 10; _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); - int diff = 0; + var diff = 0; if (_lruCacheDict.Count - (_MAX_BUFFERS + threshold) > 0) { diff = _lruCacheDict.Count - _MAX_BUFFERS; @@ -1153,14 +1153,14 @@ private void GarbageCollectLruCache () // remove first entries (least usage) _disposeLock.AcquireWriterLock(Timeout.Infinite); - for (int i = 0; i < diff; ++i) + for (var i = 0; i < diff; ++i) { if (i >= useSorterList.Count) { break; } - int startLine = useSorterList.Values[i]; + var startLine = useSorterList.Values[i]; LogBufferCacheEntry entry = _lruCacheDict[startLine]; _lruCacheDict.Remove(startLine); entry.LogBuffer.DisposeContent(); @@ -1319,14 +1319,14 @@ private void ReReadBuffer (LogBuffer logBuffer) { ILogStreamReader reader = GetLogStreamReader(fileStream, EncodingOptions, UseNewReader); - long filePos = logBuffer.StartPos; + var filePos = logBuffer.StartPos; reader.Position = logBuffer.StartPos; - int maxLinesCount = logBuffer.LineCount; - int lineCount = 0; - int dropCount = logBuffer.PrevBuffersDroppedLinesSum; + var maxLinesCount = logBuffer.LineCount; + var lineCount = 0; + var dropCount = logBuffer.PrevBuffersDroppedLinesSum; logBuffer.ClearLines(); - while (ReadLine(reader, logBuffer.StartLine + logBuffer.LineCount, logBuffer.StartLine + logBuffer.LineCount + dropCount, out string line)) + while (ReadLine(reader, logBuffer.StartLine + logBuffer.LineCount, logBuffer.StartLine + logBuffer.LineCount + dropCount, out var line)) { if (lineCount >= maxLinesCount) { @@ -1391,9 +1391,9 @@ private LogBuffer GetBufferForLine (int lineNum) //} //int startIndex = lineNum / LogBuffer.MAX_LINES; // doesn't work anymore since XML buffer may contain more lines than MAX_LINES - int startIndex = 0; - int count = _bufferList.Count; - for (int i = startIndex; i < count; ++i) + var startIndex = 0; + var count = _bufferList.Count; + for (var i = startIndex; i < count; ++i) { logBuffer = _bufferList[i]; if (lineNum >= logBuffer.StartLine && lineNum < logBuffer.StartLine + logBuffer.LineCount) @@ -1432,7 +1432,7 @@ private LogBuffer GetFirstBufferForFileByLogBuffer (LogBuffer logBuffer) { ILogFileInfo info = logBuffer.FileInfo; AcquireBufferListReaderLock(); - int index = _bufferList.IndexOf(logBuffer); + var index = _bufferList.IndexOf(logBuffer); if (index == -1) { ReleaseBufferListReaderLock(); @@ -1461,7 +1461,7 @@ private void MonitorThreadProc () //IFileSystemPlugin fs = PluginRegistry.GetInstance().FindFileSystemForUri(this.watchedILogFileInfo.FullName); _logger.Info("MonitorThreadProc() for file {0}", _watchedILogFileInfo.FullName); - long oldSize = 0; + long oldSize; try { OnLoadingStarted(new LoadFileEventArgs(_fileName, 0, false, 0, false)); @@ -1481,7 +1481,7 @@ private void MonitorThreadProc () { try { - int pollInterval = _watchedILogFileInfo.PollInterval; + var pollInterval = _watchedILogFileInfo.PollInterval; //#if DEBUG // if (_logger.IsDebug) // { @@ -1551,7 +1551,7 @@ private void FileChanged () FileSize = _fileLength; } - long newSize = _fileLength; + var newSize = _fileLength; //if (this.currFileSize != newSize) { _logger.Info("file size changed. new size={0}, file: {1}", newSize, _fileName); @@ -1564,7 +1564,7 @@ private void FireChangeEvent () LogEventArgs args = new(); args.PrevFileSize = FileSize; args.PrevLineCount = LineCount; - long newSize = _fileLength; + var newSize = _fileLength; if (newSize < FileSize || _isDeleted) { _logger.Info("File was created anew: new size={0}, oldSize={1}", newSize, FileSize); @@ -1593,7 +1593,7 @@ private void FireChangeEvent () } else { - int offset = ShiftBuffers(); + var offset = ShiftBuffers(); //this.currFileSize = newSize; // removed because ShiftBuffers() calls ReadToBuffer() which will set the actual read size args.FileSize = newSize; args.LineCount = LineCount; diff --git a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs index 7d567301..76caf5e9 100644 --- a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs +++ b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs @@ -102,10 +102,10 @@ public override unsafe int ReadChar() try { - int readInt = _reader.Read(); + var readInt = _reader.Read(); if (readInt != -1) { - char readChar = (char)readInt; + var readChar = (char)readInt; if (_posIncPrecomputed != 0) { _position += _posIncPrecomputed; @@ -156,17 +156,17 @@ private int DetectPreambleLengthAndEncoding(out Encoding detectedEncoding) UTF-32-Little-Endian-Byteorder: FF FE 00 00 */ - byte[] readPreamble = new byte[4]; + var readPreamble = new byte[4]; - int readLen = _stream.Read(readPreamble, 0, 4); + var readLen = _stream.Read(readPreamble, 0, 4); if (readLen >= 2) { foreach (Encoding encoding in _preambleEncodings) { - byte[] preamble = encoding.GetPreamble(); - bool fail = false; - for (int i = 0; i < readLen && i < preamble.Length; ++i) + var preamble = encoding.GetPreamble(); + var fail = false; + for (var i = 0; i < readLen && i < preamble.Length; ++i) { if (readPreamble[i] != preamble[i]) { diff --git a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs index c408d15f..76bf10ec 100644 --- a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs +++ b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs @@ -30,7 +30,7 @@ public override string ReadLine() while (-1 != (readInt = ReadChar())) { - char readChar = (char)readInt; + var readChar = (char)readInt; switch (readChar) { @@ -54,7 +54,7 @@ public override string ReadLine() if (_crDetect) { _crDetect = false; - string line = GetLineAndResetCharBufferPos(); + var line = GetLineAndResetCharBufferPos(); AppendToCharBuffer(readChar); return line; } @@ -65,7 +65,7 @@ public override string ReadLine() } } - string result = GetLineAndResetCharBufferPos(); + var result = GetLineAndResetCharBufferPos(); if (readInt == -1 && result.Length == 0 && !_crDetect) { return null; // EOF diff --git a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs index 28495436..736d39a5 100644 --- a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs +++ b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs @@ -39,7 +39,7 @@ public override string ReadLine() _newLineSequenceLength = GuessNewLineSequenceLength(reader); } - string line = reader.ReadLine(); + var line = reader.ReadLine(); if (line != null) { @@ -60,20 +60,20 @@ public override string ReadLine() private int GuessNewLineSequenceLength(StreamReader reader) { - long currentPos = Position; + var currentPos = Position; try { - string line = reader.ReadLine(); + var line = reader.ReadLine(); if (line != null) { Position += Encoding.GetByteCount(line); - int firstChar = reader.Read(); + var firstChar = reader.Read(); if (firstChar == CHAR_CR) // check \r { - int secondChar = reader.Read(); + var secondChar = reader.Read(); if (secondChar == CHAR_LF) // check \n { return Encoding.GetByteCount("\r\n"); diff --git a/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs b/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs index faca9c2a..7bc6e22a 100644 --- a/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs +++ b/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs @@ -75,7 +75,7 @@ public void SetFileName(string fileName) _dateGroup = match.Groups["date"]; if (_dateGroup.Success) { - string date = fileName.Substring(_dateGroup.Index, _dateGroup.Length); + var date = fileName.Substring(_dateGroup.Index, _dateGroup.Length); if (DateTime.TryParseExact(date, _dateTimeFormat, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None, out _dateTime)) @@ -104,10 +104,10 @@ public void DecrementDate() public string BuildFileName() { - string fileName = _currentFileName; + var fileName = _currentFileName; if (_dateGroup != null && _dateGroup.Success) { - string newDate = _dateTime.ToString(_dateTimeFormat, DateTimeFormatInfo.InvariantInfo); + var newDate = _dateTime.ToString(_dateTimeFormat, DateTimeFormatInfo.InvariantInfo); fileName = fileName.Remove(_dateGroup.Index, _dateGroup.Length); fileName = fileName.Insert(_dateGroup.Index, newDate); } @@ -118,7 +118,7 @@ public string BuildFileName() if (!_hideZeroIndex || Index > 0) { - string format = "D" + _indexGroup.Length; + var format = "D" + _indexGroup.Length; fileName = fileName.Insert(_indexGroup.Index, Index.ToString(format)); if (_hideZeroIndex && _condContent != null) { @@ -138,18 +138,18 @@ public string BuildFileName() private void ParseFormatString(string formatString) { - string fmt = EscapeNonvarRegions(formatString); - int datePos = formatString.IndexOf("$D("); + var fmt = EscapeNonvarRegions(formatString); + var datePos = formatString.IndexOf("$D("); if (datePos != -1) { - int endPos = formatString.IndexOf(')', datePos); + var endPos = formatString.IndexOf(')', datePos); if (endPos != -1) { _dateTimeFormat = formatString.Substring(datePos + 3, endPos - datePos - 3); _dateTimeFormat = _dateTimeFormat.ToUpper(); _dateTimeFormat = _dateTimeFormat.Replace('D', 'd').Replace('Y', 'y'); - string dtf = _dateTimeFormat; + var dtf = _dateTimeFormat; dtf = dtf.ToUpper(); dtf = dtf.Replace("D", "\\d"); dtf = dtf.Replace("Y", "\\d"); @@ -161,10 +161,10 @@ private void ParseFormatString(string formatString) } } - int condPos = fmt.IndexOf("$J("); + var condPos = fmt.IndexOf("$J("); if (condPos != -1) { - int endPos = fmt.IndexOf(')', condPos); + var endPos = fmt.IndexOf(')', condPos); if (endPos != -1) { _condContent = fmt.Substring(condPos + 3, endPos - condPos - 3); @@ -182,11 +182,11 @@ private void ParseFormatString(string formatString) private string EscapeNonvarRegions(string formatString) { - string fmt = formatString.Replace('*', '\xFFFD'); + var fmt = formatString.Replace('*', '\xFFFD'); StringBuilder result = new(); - int state = 0; + var state = 0; StringBuilder segment = new(); - for (int i = 0; i < fmt.Length; ++i) + for (var i = 0; i < fmt.Length; ++i) { switch (state) { diff --git a/src/LogExpert.Core/Classes/Log/RolloverFilenameHandler.cs b/src/LogExpert.Core/Classes/Log/RolloverFilenameHandler.cs index 9880af25..78639390 100644 --- a/src/LogExpert.Core/Classes/Log/RolloverFilenameHandler.cs +++ b/src/LogExpert.Core/Classes/Log/RolloverFilenameHandler.cs @@ -50,10 +50,10 @@ public RolloverFilenameHandler(ILogFileInfo logFileInfo, MultiFileOptions option public LinkedList GetNameList(IPluginRegistry pluginRegistry) { LinkedList fileList = new(); - string fileName = _filenameBuilder.BuildFileName(); - string filePath = _logFileInfo.DirectoryName + _logFileInfo.DirectorySeparatorChar + fileName; + var fileName = _filenameBuilder.BuildFileName(); + var filePath = _logFileInfo.DirectoryName + _logFileInfo.DirectorySeparatorChar + fileName; fileList.AddFirst(filePath); - bool found = true; + var found = true; while (found) { found = false; @@ -73,7 +73,7 @@ public LinkedList GetNameList(IPluginRegistry pluginRegistry) // if file with index isn't found or no index is in format pattern, decrement the current date if (_filenameBuilder.IsDatePattern) { - int tryCounter = 0; + var tryCounter = 0; _filenameBuilder.Index = 0; while (tryCounter < _options.MaxDayTry) { diff --git a/src/LogExpert.Core/Classes/ParamParser.cs b/src/LogExpert.Core/Classes/ParamParser.cs index 10cda0f7..f1a4529c 100644 --- a/src/LogExpert.Core/Classes/ParamParser.cs +++ b/src/LogExpert.Core/Classes/ParamParser.cs @@ -34,9 +34,9 @@ public string ReplaceParams(ILogLine logLine, int lineNum, string fileName) fileInfo.FullName.Contains(" ") ? "\"" + fileInfo.FullName + "\"" : fileInfo.FullName); builder.Replace("%E", fileInfo.Extension.Contains(" ") ? "\"" + fileInfo.Extension + "\"" : fileInfo.Extension); - string stripped = StripExtension(fileInfo.Name); + var stripped = StripExtension(fileInfo.Name); builder.Replace("%M", stripped.Contains(" ") ? "\"" + stripped + "\"" : stripped); - int sPos = 0; + var sPos = 0; string reg; string replace; do @@ -45,7 +45,7 @@ public string ReplaceParams(ILogLine logLine, int lineNum, string fileName) replace = GetNextGroup(builder, ref sPos); if (reg != null && replace != null) { - string result = Regex.Replace(logLine.FullLine, reg, replace); + var result = Regex.Replace(logLine.FullLine, reg, replace); builder.Insert(sPos, result); } } while (replace != null); @@ -54,7 +54,7 @@ public string ReplaceParams(ILogLine logLine, int lineNum, string fileName) public static string StripExtension(string fileName) { - int i = fileName.LastIndexOf('.'); + var i = fileName.LastIndexOf('.'); if (i < 0) { i = fileName.Length - 1; @@ -68,14 +68,13 @@ public static string StripExtension(string fileName) private string GetNextGroup(StringBuilder builder, ref int sPos) { - int count = 0; int ePos; while (sPos < builder.Length) { if (builder[sPos] == '{') { ePos = sPos + 1; - count = 1; + var count = 1; while (ePos < builder.Length) { if (builder[ePos] == '{') @@ -88,7 +87,7 @@ private string GetNextGroup(StringBuilder builder, ref int sPos) } if (count == 0) { - string reg = builder.ToString(sPos + 1, ePos - sPos - 1); + var reg = builder.ToString(sPos + 1, ePos - sPos - 1); builder.Remove(sPos, ePos - sPos + 1); return reg; } diff --git a/src/LogExpert.Core/Classes/Persister/Persister.cs b/src/LogExpert.Core/Classes/Persister/Persister.cs index c5057224..6889e31c 100644 --- a/src/LogExpert.Core/Classes/Persister/Persister.cs +++ b/src/LogExpert.Core/Classes/Persister/Persister.cs @@ -17,30 +17,30 @@ public class PersistenceData public SortedList bookmarkList = []; public int bookmarkListPosition = 300; - public bool bookmarkListVisible = false; + public bool bookmarkListVisible; public string columnizerName; public int currentLine = -1; public Encoding encoding; - public string fileName = null; - public bool filterAdvanced = false; + public string fileName; + public bool filterAdvanced; public List filterParamsList = []; public int filterPosition = 222; - public bool filterSaveListVisible = false; + public bool filterSaveListVisible; public List filterTabDataList = []; - public bool filterVisible = false; + public bool filterVisible; public int firstDisplayedLine = -1; public bool followTail = true; public string highlightGroupName; public int lineCount; - public bool multiFile = false; + public bool multiFile; public int multiFileMaxDays; public List multiFileNames = []; public string multiFilePattern; public SortedList rowHeightList = []; - public string sessionFileName = null; + public string sessionFileName; public bool showBookmarkCommentColumn; - public string tabName = null; + public string tabName; public string settingsSaveLoadLocation; @@ -73,7 +73,7 @@ public static string SavePersistenceData(string logFileName, PersistenceData per if (preferences.saveLocation == SessionSaveLocation.SameDir) { // make to log file in .lxp file relative - string filePart = Path.GetFileName(persistenceData.fileName); + var filePart = Path.GetFileName(persistenceData.fileName); persistenceData.fileName = filePart; } @@ -91,13 +91,13 @@ public static string SavePersistenceDataWithFixedName(string persistenceFileName public static PersistenceData LoadPersistenceData(string logFileName, Preferences preferences) { - string fileName = BuildPersisterFileName(logFileName, preferences); + var fileName = BuildPersisterFileName(logFileName, preferences); return Load(fileName); } public static PersistenceData LoadPersistenceDataOptionsOnly(string logFileName, Preferences preferences) { - string fileName = BuildPersisterFileName(logFileName, preferences); + var fileName = BuildPersisterFileName(logFileName, preferences); return LoadOptionsOnly(fileName); } @@ -132,7 +132,7 @@ public static PersistenceData LoadOptionsOnly(string fileName) XmlNode fileNode = xmlDoc.SelectSingleNode("logexpert/file"); if (fileNode != null) { - XmlElement fileElement = fileNode as XmlElement; + var fileElement = fileNode as XmlElement; ReadOptions(fileElement, persistenceData); persistenceData.fileName = fileElement.GetAttribute("fileName"); persistenceData.encoding = ReadEncoding(fileElement); @@ -199,7 +199,7 @@ private static string BuildPersisterFileName(string logFileName, Preferences pre private static string BuildSessionFileNameFromPath(string logFileName) { - string result = logFileName; + var result = logFileName; result = result.Replace(Path.DirectorySeparatorChar, '_'); result = result.Replace(Path.AltDirectorySeparatorChar, '_'); result = result.Replace(Path.VolumeSeparatorChar, '_'); @@ -303,7 +303,7 @@ private static void WriteFilter(XmlDocument xmlDoc, XmlElement rootElement, List MemoryStream stream = new(capacity: 200); JsonSerializer.Serialize(stream, filterParams); - string base64Data = Convert.ToBase64String(stream.ToArray()); + var base64Data = Convert.ToBase64String(stream.ToArray()); paramsElement.InnerText = base64Data; filterElement.AppendChild(paramsElement); filtersElement.AppendChild(filterElement); @@ -324,8 +324,8 @@ private static List ReadFilter(XmlElement startNode) { if (subNode.Name.Equals("params")) { - string base64Text = subNode.InnerText; - byte[] data = Convert.FromBase64String(base64Text); + var base64Text = subNode.InnerText; + var data = Convert.FromBase64String(base64Text); MemoryStream stream = new(data); try @@ -385,12 +385,12 @@ private static PersistenceData Load(string fileName) private static PersistenceData ReadPersistenceDataFromNode(XmlNode node) { PersistenceData persistenceData = new(); - XmlElement fileElement = node as XmlElement; + var fileElement = node as XmlElement; persistenceData.bookmarkList = ReadBookmarks(fileElement); persistenceData.rowHeightList = ReadRowHeightList(fileElement); ReadOptions(fileElement, persistenceData); persistenceData.fileName = fileElement.GetAttribute("fileName"); - string sLineCount = fileElement.GetAttribute("lineCount"); + var sLineCount = fileElement.GetAttribute("lineCount"); if (sLineCount != null && sLineCount.Length > 0) { persistenceData.lineCount = int.Parse(sLineCount); @@ -468,7 +468,7 @@ private static Encoding ReadEncoding(XmlElement fileElement) _logger.Error("Invalid XML format for bookmark: {0}", node.InnerText); continue; } - int lineNum = int.Parse(line); + var lineNum = int.Parse(line); Entities.Bookmark bookmark = new(lineNum) { @@ -520,8 +520,8 @@ private static SortedList ReadRowHeightList(XmlElement star height = attr.InnerText; } } - int lineNum = int.Parse(line); - int heightValue = int.Parse(height); + var lineNum = int.Parse(line); + var heightValue = int.Parse(height); rowHeightList.Add(lineNum, new RowHeightEntry(lineNum, heightValue)); } } @@ -538,7 +538,7 @@ private static void WriteOptions(XmlDocument xmlDoc, XmlElement rootElement, Per element.SetAttribute("enabled", persistenceData.multiFile ? "1" : "0"); element.SetAttribute("pattern", persistenceData.multiFilePattern); element.SetAttribute("maxDays", "" + persistenceData.multiFileMaxDays); - foreach (string fileName in persistenceData.multiFileNames) + foreach (var fileName in persistenceData.multiFileNames) { XmlElement entryElement = xmlDoc.CreateElement("fileEntry"); entryElement.SetAttribute("fileName", "" + fileName); @@ -594,7 +594,7 @@ private static void WriteOptions(XmlDocument xmlDoc, XmlElement rootElement, Per private static void ReadOptions(XmlElement startNode, PersistenceData persistenceData) { XmlNode optionsNode = startNode.SelectSingleNode("options"); - string value = GetOptionsAttribute(optionsNode, "multifile", "enabled"); + var value = GetOptionsAttribute(optionsNode, "multifile", "enabled"); persistenceData.multiFile = value != null && value.Equals("1"); persistenceData.multiFilePattern = GetOptionsAttribute(optionsNode, "multifile", "pattern"); value = GetOptionsAttribute(optionsNode, "multifile", "maxDays"); @@ -690,7 +690,7 @@ private static string GetOptionsAttribute(XmlNode optionsNode, string elementNam } if (node is XmlElement) { - string value = (node as XmlElement).GetAttribute(attrName); + var value = (node as XmlElement).GetAttribute(attrName); return value; } else diff --git a/src/LogExpert.Core/Classes/Persister/ProjectData.cs b/src/LogExpert.Core/Classes/Persister/ProjectData.cs index bc4df6ab..b1fad7c5 100644 --- a/src/LogExpert.Core/Classes/Persister/ProjectData.cs +++ b/src/LogExpert.Core/Classes/Persister/ProjectData.cs @@ -7,7 +7,7 @@ public class ProjectData #region Fields public List memberList = []; - public string tabLayoutXml = null; + public string tabLayoutXml; #endregion } diff --git a/src/LogExpert.Core/Classes/Persister/ProjectPersister.cs b/src/LogExpert.Core/Classes/Persister/ProjectPersister.cs index 5e0a2948..cbbb1ee1 100644 --- a/src/LogExpert.Core/Classes/Persister/ProjectPersister.cs +++ b/src/LogExpert.Core/Classes/Persister/ProjectPersister.cs @@ -15,8 +15,8 @@ public static ProjectData LoadProjectData(string projectFileName) XmlNodeList fileList = xmlDoc.GetElementsByTagName("member"); foreach (XmlNode fileNode in fileList) { - XmlElement fileElement = fileNode as XmlElement; - string fileName = fileElement.GetAttribute("fileName"); + var fileElement = fileNode as XmlElement; + var fileName = fileElement.GetAttribute("fileName"); projectData.memberList.Add(fileName); } XmlNodeList layoutElements = xmlDoc.GetElementsByTagName("layout"); @@ -55,7 +55,7 @@ public static void SaveProjectData(string projectFileName, ProjectData projectDa private static void SaveProjectMembers(XmlDocument xmlDoc, XmlNode membersNode, List memberList) { - foreach (string fileName in memberList) + foreach (var fileName in memberList) { XmlElement memberElement = xmlDoc.CreateElement("member"); membersNode.AppendChild(memberElement); diff --git a/src/LogExpert.Core/Classes/SysoutPipe.cs b/src/LogExpert.Core/Classes/SysoutPipe.cs index fbe40830..763f368b 100644 --- a/src/LogExpert.Core/Classes/SysoutPipe.cs +++ b/src/LogExpert.Core/Classes/SysoutPipe.cs @@ -70,13 +70,13 @@ public void ProcessExitedEventHandler(object sender, System.EventArgs e) protected void ReaderThread() { - char[] buff = new char[256]; + var buff = new char[256]; while (true) { try { - int read = sysout.Read(buff, 0, 256); + var read = sysout.Read(buff, 0, 256); if (read == 0) { break; diff --git a/src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs b/src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs index 8b8a643c..ccc0b9f8 100644 --- a/src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs +++ b/src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs @@ -71,7 +71,7 @@ public string Stylesheet _stylesheet = value; if (_stylesheet != null) { - XmlReader stylesheetReader = XmlReader.Create(new StringReader(_stylesheet)); + var stylesheetReader = XmlReader.Create(new StringReader(_stylesheet)); _xslt = new XslCompiledTransform(); _xslt.Load(stylesheetReader); @@ -91,7 +91,7 @@ private void ParseXmlBlock(string block) { if (_stylesheet != null) { - XmlReader xmlReader = XmlReader.Create(new StringReader(block), _settings, _context); + var xmlReader = XmlReader.Create(new StringReader(block), _settings, _context); xmlReader.Read(); xmlReader.MoveToContent(); @@ -99,7 +99,7 @@ private void ParseXmlBlock(string block) StringWriter textWriter = new(); _xslt.Transform(xmlReader, null, textWriter); - string message = textWriter.ToString(); + var message = textWriter.ToString(); SplitToLinesList(message); } else @@ -112,13 +112,13 @@ private void ParseXmlBlock(string block) private void SplitToLinesList(string message) { const int MAX_LEN = 3000; - string[] lines = message.Split(_splitStrings, StringSplitOptions.None); - foreach (string theLine in lines) + var lines = message.Split(_splitStrings, StringSplitOptions.None); + foreach (var theLine in lines) { - string line = theLine.Trim(_newLineChar); + var line = theLine.Trim(_newLineChar); while (line.Length > MAX_LEN) { - string part = line.Substring(0, MAX_LEN); + var part = line.Substring(0, MAX_LEN); line = line.Substring(MAX_LEN); _lineList.Enqueue(part); } @@ -147,7 +147,7 @@ public override string ReadLine() { if (_lineList.Count == 0) { - string block = _reader.ReadLine(); + var block = _reader.ReadLine(); if (block == null) { return null; diff --git a/src/LogExpert.Core/Classes/xml/XmlLogReader.cs b/src/LogExpert.Core/Classes/xml/XmlLogReader.cs index 09da8017..b5d21839 100644 --- a/src/LogExpert.Core/Classes/xml/XmlLogReader.cs +++ b/src/LogExpert.Core/Classes/xml/XmlLogReader.cs @@ -58,16 +58,16 @@ public override int ReadChar() public override string ReadLine() { short state = 0; - int tagIndex = 0; - bool blockComplete = false; - bool eof = false; - int tryCounter = 5; + var tagIndex = 0; + var blockComplete = false; + var eof = false; + var tryCounter = 5; StringBuilder builder = new(); while (!eof && !blockComplete) { - int readInt = ReadChar(); + var readInt = ReadChar(); if (readInt == -1) { // if eof before the block is complete, wait some msecs for the logger to flush the complete xml struct @@ -80,18 +80,16 @@ public override string ReadLine() } else { - eof = true; break; } } else { - eof = true; break; } } - char readChar = (char)readInt; + var readChar = (char)readInt; // state: // 0 = looking for tag start // 1 = reading into buffer as long as the read data matches the start tag diff --git a/src/LogExpert.Core/Config/Preferences.cs b/src/LogExpert.Core/Config/Preferences.cs index a757b1bb..f4a571bf 100644 --- a/src/LogExpert.Core/Config/Preferences.cs +++ b/src/LogExpert.Core/Config/Preferences.cs @@ -12,9 +12,9 @@ public class Preferences public bool allowOnlyOneInstance; - public bool askForClose = false; + public bool askForClose; - public bool darkMode = false; + public bool darkMode; public int bufferCount = 100; @@ -36,7 +36,7 @@ public class Preferences public List HighlightGroupList { get; set; } = []; - public bool isAutoHideFilterList = false; + public bool isAutoHideFilterList; public bool isFilterOnLoad; @@ -64,14 +64,14 @@ public class Preferences public int pollingInterval = 250; - public bool reverseAlpha = false; + public bool reverseAlpha; public bool PortableMode { get; set; } /// /// Save Directory of the last logfile /// - public string sessionSaveDirectory = null; + public string sessionSaveDirectory; public bool saveFilters = true; @@ -89,7 +89,7 @@ public class Preferences public bool showTailState = true; - public bool showTimeSpread = false; + public bool showTimeSpread; public Color timeSpreadColor = Color.FromKnownColor(KnownColor.Gray); diff --git a/src/LogExpert.Core/Config/ToolEntry.cs b/src/LogExpert.Core/Config/ToolEntry.cs index 137eef32..f563150a 100644 --- a/src/LogExpert.Core/Config/ToolEntry.cs +++ b/src/LogExpert.Core/Config/ToolEntry.cs @@ -16,7 +16,7 @@ public class ToolEntry public int iconIndex; public bool isFavourite; public string name; - public bool sysout = false; + public bool sysout; public string workingDir = ""; #endregion diff --git a/src/LogExpert.Core/Entities/DebugOptions.cs b/src/LogExpert.Core/Entities/DebugOptions.cs index 10f0b768..738b2c02 100644 --- a/src/LogExpert.Core/Entities/DebugOptions.cs +++ b/src/LogExpert.Core/Entities/DebugOptions.cs @@ -2,6 +2,6 @@ { public class DebugOptions { - public static bool DisableWordHighlight { get; set; } = false; + public static bool DisableWordHighlight { get; set; } } } \ No newline at end of file diff --git a/src/LogExpert.Core/Entities/DefaultLogfileColumnizer.cs b/src/LogExpert.Core/Entities/DefaultLogfileColumnizer.cs index 9f1a327e..4a2ac39a 100644 --- a/src/LogExpert.Core/Entities/DefaultLogfileColumnizer.cs +++ b/src/LogExpert.Core/Entities/DefaultLogfileColumnizer.cs @@ -44,10 +44,7 @@ public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLin return cLogLine; } - public string Text - { - get { return GetName(); } - } + public string Text => GetName(); public Priority GetPriority(string fileName, IEnumerable samples) { diff --git a/src/LogExpert.Core/Entities/LogEventData.cs b/src/LogExpert.Core/Entities/LogEventData.cs index 923b47ab..00feadb0 100644 --- a/src/LogExpert.Core/Entities/LogEventData.cs +++ b/src/LogExpert.Core/Entities/LogEventData.cs @@ -8,9 +8,9 @@ public class LogEventArgs : System.EventArgs #region Properties - public int RolloverOffset { get; set; } = 0; + public int RolloverOffset { get; set; } - public bool IsRollover { get; set; } = false; + public bool IsRollover { get; set; } public long FileSize { get; set; } diff --git a/src/LogExpert.Core/Entities/SearchParams.cs b/src/LogExpert.Core/Entities/SearchParams.cs index a3e8e75f..d5d16be3 100644 --- a/src/LogExpert.Core/Entities/SearchParams.cs +++ b/src/LogExpert.Core/Entities/SearchParams.cs @@ -7,15 +7,15 @@ public class SearchParams public List HistoryList { get; set; } = []; - public bool IsCaseSensitive { get; set; } = false; + public bool IsCaseSensitive { get; set; } public bool IsFindNext { get; set; } public bool IsForward { get; set; } = true; - public bool IsFromTop { get; set; } = false; + public bool IsFromTop { get; set; } - public bool IsRegex { get; set; } = false; + public bool IsRegex { get; set; } public string SearchText { get; set; } = string.Empty; diff --git a/src/LogExpert.Core/EventArguments/GuiStateArgs.cs b/src/LogExpert.Core/EventArguments/GuiStateArgs.cs index 25faf023..e14c92a6 100644 --- a/src/LogExpert.Core/EventArguments/GuiStateArgs.cs +++ b/src/LogExpert.Core/EventArguments/GuiStateArgs.cs @@ -14,13 +14,13 @@ public class GuiStateArgs : System.EventArgs public string TimeshiftText { get; set; } = string.Empty; - public bool TimeshiftPossible { get; set; } = false; + public bool TimeshiftPossible { get; set; } public bool MultiFileEnabled { get; set; } = true; public bool FilterEnabled { get; set; } = true; - public bool CellSelectMode { get; set; } = false; + public bool CellSelectMode { get; set; } public Encoding CurrentEncoding { get; set; } diff --git a/src/LogExpert.Core/EventArguments/PatternArgs.cs b/src/LogExpert.Core/EventArguments/PatternArgs.cs index b8b63a60..60d26042 100644 --- a/src/LogExpert.Core/EventArguments/PatternArgs.cs +++ b/src/LogExpert.Core/EventArguments/PatternArgs.cs @@ -4,7 +4,7 @@ public class PatternArgs { #region Properties - public int EndLine { get; set; } = 0; + public int EndLine { get; set; } public int Fuzzy { get; set; } = 6; @@ -14,7 +14,7 @@ public class PatternArgs public int MinWeight { get; set; } = 15; - public int StartLine { get; set; } = 0; + public int StartLine { get; set; } #endregion } diff --git a/src/LogExpert.Core/EventArguments/StatusEventArgs.cs b/src/LogExpert.Core/EventArguments/StatusEventArgs.cs index 43d6f99d..2640a1a2 100644 --- a/src/LogExpert.Core/EventArguments/StatusEventArgs.cs +++ b/src/LogExpert.Core/EventArguments/StatusEventArgs.cs @@ -4,13 +4,13 @@ public class StatusLineEventArgs : System.EventArgs { #region Properties - public long FileSize { get; set; } = 0; + public long FileSize { get; set; } public string StatusText { get; set; } = string.Empty; - public int LineCount { get; set; } = 0; + public int LineCount { get; set; } - public int CurrentLineNum { get; set; } = 0; + public int CurrentLineNum { get; set; } #endregion diff --git a/src/LogExpert.Tests/BufferShiftTest.cs b/src/LogExpert.Tests/BufferShiftTest.cs index cde669e0..fc824ad3 100644 --- a/src/LogExpert.Tests/BufferShiftTest.cs +++ b/src/LogExpert.Tests/BufferShiftTest.cs @@ -27,7 +27,7 @@ public void Boot() [Test] public void TestShiftBuffers1() { - int linesPerFile = 10; + var linesPerFile = 10; MultiFileOptions options = new() { MaxDayTry = 0, @@ -51,11 +51,11 @@ public void TestShiftBuffers1() foreach (LogFileInfo li in lil.Cast()) { - string fileName = enumerator.Current; + var fileName = enumerator.Current; Assert.That(li.FullName, Is.EqualTo(fileName)); enumerator.MoveNext(); } - int oldCount = lil.Count; + var oldCount = lil.Count; // Simulate rollover // @@ -77,7 +77,7 @@ public void TestShiftBuffers1() enumerator.MoveNext(); foreach (LogFileInfo li in lil) { - string fileName = enumerator.Current; + var fileName = enumerator.Current; Assert.That(li.FullName, Is.EqualTo(fileName)); enumerator.MoveNext(); } @@ -88,7 +88,7 @@ public void TestShiftBuffers1() enumerator = files.GetEnumerator(); enumerator.MoveNext(); IList logBuffers = reader.GetBufferList(); - int startLine = 0; + var startLine = 0; foreach (LogBuffer logBuffer in logBuffers) { Assert.That(enumerator.Current, Is.EqualTo(logBuffer.FileInfo.FullName)); @@ -138,7 +138,7 @@ public void TestShiftBuffers1() // Check first line to see if buffers are correct // ILogLine firstLine = reader.GetLogLine(0); - string[] names = new string[files.Count]; + var names = new string[files.Count]; files.CopyTo(names, 0); Assert.That(firstLine.FullLine.Contains(names[2])); } diff --git a/src/LogExpert.Tests/CSVColumnizerTest.cs b/src/LogExpert.Tests/CSVColumnizerTest.cs index 5e9c2de0..a90167bc 100644 --- a/src/LogExpert.Tests/CSVColumnizerTest.cs +++ b/src/LogExpert.Tests/CSVColumnizerTest.cs @@ -17,7 +17,7 @@ public class CSVColumnizerTest public void Instantiat_CSVFile_BuildCorrectColumnizer(string filename, string[] expectedHeaders) { CsvColumnizer.CsvColumnizer csvColumnizer = new(); - string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename); + var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename); LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); reader.ReadFiles(); ILogLine line = reader.GetLogLine(0); @@ -26,7 +26,7 @@ public void Instantiat_CSVFile_BuildCorrectColumnizer(string filename, string[] { logline = csvColumnizer.SplitLine(null, line); } - string expectedResult = string.Join(",", expectedHeaders); + var expectedResult = string.Join(",", expectedHeaders); Assert.That(logline.LogLine.FullLine, Is.EqualTo(expectedResult)); } } diff --git a/src/LogExpert.Tests/ColumnizerPickerTest.cs b/src/LogExpert.Tests/ColumnizerPickerTest.cs index 585a99e3..59d7a23b 100644 --- a/src/LogExpert.Tests/ColumnizerPickerTest.cs +++ b/src/LogExpert.Tests/ColumnizerPickerTest.cs @@ -21,7 +21,7 @@ public class ColumnizerPickerTest [TestCase("Timestamp Columnizer", "30/08/2018 08:51:42.712 no bracket 1", "30/08/2018 08:51:42.712 no bracket 2", "30/08/2018 08:51:42.712 [TRACE] with bracket 1", "30/08/2018 08:51:42.712 [TRACE] with bracket 2", "no bracket 3")] public void FindColumnizer_ReturnCorrectColumnizer(string expectedColumnizerName, string line0, string line1, string line2, string line3, string line4) { - string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test"); + var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test"); Mock autoLogLineColumnizerCallbackMock = new(); @@ -65,7 +65,7 @@ public void FindColumnizer_ReturnCorrectColumnizer(string expectedColumnizerName public void FindReplacementForAutoColumnizer_ValidTextFile_ReturnCorrectColumnizer( string fileName, Type columnizerType) { - string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); + var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); reader.ReadFiles(); @@ -83,7 +83,7 @@ public void FindReplacementForAutoColumnizer_ValidTextFile_ReturnCorrectColumniz public void DecideColumnizerByName_WhenReaderIsNotReady_ReturnCorrectColumnizer( string fileName, Type columnizerType) { - string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); + var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); // TODO: When DI container is ready, we can mock this set up. PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers.Add(new JsonCompactColumnizer()); @@ -97,7 +97,7 @@ public void DecideColumnizerByName_WhenReaderIsNotReady_ReturnCorrectColumnizer( public void DecideColumnizerByName_ValidTextFile_ReturnCorrectColumnizer( string columnizerName, Type columnizerType) { - string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, columnizerName); + var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, columnizerName); // TODO: When DI container is ready, we can mock this set up. PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers.Add(new JsonColumnizer.JsonColumnizer()); diff --git a/src/LogExpert.Tests/DateFormatParserTest.cs b/src/LogExpert.Tests/DateFormatParserTest.cs index 3bbe1af2..ece598d2 100644 --- a/src/LogExpert.Tests/DateFormatParserTest.cs +++ b/src/LogExpert.Tests/DateFormatParserTest.cs @@ -37,7 +37,7 @@ public void CanParseAllCultures() } var message = $"Culture: {culture.Name} ({culture.EnglishName} {datePattern})"; - var sections = Parser.ParseSections(datePattern, out bool syntaxError); + var sections = Parser.ParseSections(datePattern, out var syntaxError); Assert.That(syntaxError, Is.False, message); @@ -64,7 +64,7 @@ public void TestDateFormatParserFromCulture(string cultureInfoName, params strin var datePattern = GetDateAndTimeFormat(culture); - var sections = Parser.ParseSections(datePattern, out bool syntaxError); + var sections = Parser.ParseSections(datePattern, out var syntaxError); var message = $"Culture: {culture.EnglishName}, Actual date pattern: {datePattern}"; @@ -94,7 +94,7 @@ static string RemoveCharacters(string input, string charsToRemove) HashSet charsToRemoveSet = new(charsToRemove); StringBuilder result = new(); - foreach (char c in input) + foreach (var c in input) { if (!charsToRemoveSet.Contains(c)) { @@ -108,7 +108,7 @@ static string RemoveCharacters(string input, string charsToRemove) private string GetDateAndTimeFormat(CultureInfo culture) { - string InvisibleUNICODEmarkers = + var InvisibleUNICODEmarkers = "\u00AD\u034F\u061C\u115F\u1160\u17B4\u17B5" + "\u180B\u180C\u180D\u180E\u200B\u200C\u200D\u200E\u200F" + "\u202A\u202B\u202C\u202D\u202E\u202F\u205F\u2060\u2062" + @@ -117,7 +117,7 @@ private string GetDateAndTimeFormat(CultureInfo culture) "\uFE0A\uFE0B\uFE0C\uFE0D\uFE0E\uFE0F"; - string dateTime = string.Concat(culture.DateTimeFormat.ShortDatePattern.ToString(), + var dateTime = string.Concat(culture.DateTimeFormat.ShortDatePattern.ToString(), " ", culture.DateTimeFormat.LongTimePattern.ToString()); diff --git a/src/LogExpert.Tests/JSONSaveTest.cs b/src/LogExpert.Tests/JSONSaveTest.cs index 35b4834c..234c272b 100644 --- a/src/LogExpert.Tests/JSONSaveTest.cs +++ b/src/LogExpert.Tests/JSONSaveTest.cs @@ -17,8 +17,8 @@ public void SaveOptionsAsJSON() { ConfigManager.Instance.Settings.alwaysOnTop = true; ConfigManager.Instance.Save(SettingsFlags.All); - string configDir = ConfigManager.Instance.ConfigDir; - string settingsFile = configDir + "\\settings.json"; + var configDir = ConfigManager.Instance.ConfigDir; + var settingsFile = configDir + "\\settings.json"; Settings settings = null; diff --git a/src/LogExpert.Tests/JsonColumnizerTest.cs b/src/LogExpert.Tests/JsonColumnizerTest.cs index 72a85d60..3058866f 100644 --- a/src/LogExpert.Tests/JsonColumnizerTest.cs +++ b/src/LogExpert.Tests/JsonColumnizerTest.cs @@ -15,7 +15,7 @@ public class JsonColumnizerTest public void GetColumnNames_HappyFile_ColumnNameMatches(string fileName, string expectedHeaders) { var jsonColumnizer = new JsonColumnizer.JsonColumnizer(); - string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); + var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); reader.ReadFiles(); diff --git a/src/LogExpert.Tests/JsonCompactColumnizerTest.cs b/src/LogExpert.Tests/JsonCompactColumnizerTest.cs index 73e49d09..1bc85ed4 100644 --- a/src/LogExpert.Tests/JsonCompactColumnizerTest.cs +++ b/src/LogExpert.Tests/JsonCompactColumnizerTest.cs @@ -19,7 +19,7 @@ public class JsonCompactColumnizerTest public void GetPriority_HappyFile_PriorityMatches(string fileName, Priority priority) { var jsonCompactColumnizer = new JsonColumnizer.JsonCompactColumnizer(); - string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); + var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); LogfileReader logFileReader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); logFileReader.ReadFiles(); List loglines = new() diff --git a/src/LogExpert.Tests/LocalFileSystemTest.cs b/src/LogExpert.Tests/LocalFileSystemTest.cs index ab765ef3..444ccdf4 100644 --- a/src/LogExpert.Tests/LocalFileSystemTest.cs +++ b/src/LogExpert.Tests/LocalFileSystemTest.cs @@ -37,7 +37,7 @@ public void TestUriHandle() public void TestUriToFileStream() { DirectoryInfo dInfo = Directory.CreateDirectory(RolloverHandlerTest.TEST_DIR_NAME); - string fullName = CreateFile(dInfo, "test.log"); + var fullName = CreateFile(dInfo, "test.log"); LocalFileSystem fs = new(); ILogFileInfo info = fs.GetLogfileInfo(fullName); @@ -46,7 +46,7 @@ public void TestUriToFileStream() Stream stream = info.OpenStream(); Assert.That(stream.CanSeek, Is.True); StreamReader reader = new(stream); - string line = reader.ReadLine(); + var line = reader.ReadLine(); Assert.That(line.StartsWith("line number", StringComparison.InvariantCultureIgnoreCase), Is.True); reader.Close(); } diff --git a/src/LogExpert.Tests/LogStreamReaderTest.cs b/src/LogExpert.Tests/LogStreamReaderTest.cs index f7e0d6f0..48774eba 100644 --- a/src/LogExpert.Tests/LogStreamReaderTest.cs +++ b/src/LogExpert.Tests/LogStreamReaderTest.cs @@ -22,10 +22,10 @@ public void ReadLinesWithSystemNewLine(string text, int expectedLines) { using var stream = new MemoryStream(Encoding.ASCII.GetBytes(text)); using var reader = new PositionAwareStreamReaderSystem(stream, new EncodingOptions()); - int lineCount = 0; + var lineCount = 0; while (true) { - string line = reader.ReadLine(); + var line = reader.ReadLine(); if (line == null) { break; @@ -47,7 +47,7 @@ public void CountLinesWithSystemNewLine(string text, int expectedLines) { using var stream = new MemoryStream(Encoding.ASCII.GetBytes(text)); using var reader = new PositionAwareStreamReaderSystem(stream, new EncodingOptions()); - int lineCount = 0; + var lineCount = 0; while (reader.ReadLine() != null) { lineCount += 1; @@ -68,10 +68,10 @@ public void ReadLinesWithLegacyNewLine(string text, int expectedLines) using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(text))) using (var reader = new PositionAwareStreamReaderLegacy(stream, new EncodingOptions())) { - int lineCount = 0; + var lineCount = 0; while (true) { - string line = reader.ReadLine(); + var line = reader.ReadLine(); if (line == null) { break; @@ -94,7 +94,7 @@ public void CountLinesWithLegacyNewLine(string text, int expectedLines) using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(text))) using (var reader = new PositionAwareStreamReaderLegacy(stream, new EncodingOptions())) { - int lineCount = 0; + var lineCount = 0; while (reader.ReadLine() != null) { lineCount += 1; diff --git a/src/LogExpert.Tests/ReaderTest.cs b/src/LogExpert.Tests/ReaderTest.cs index 4e59a5bd..8651ab64 100644 --- a/src/LogExpert.Tests/ReaderTest.cs +++ b/src/LogExpert.Tests/ReaderTest.cs @@ -25,7 +25,7 @@ public void Boot() private void CompareReaderImplementationsInternal(string fileName, Encoding enc, int maxPosition) { - string path = Environment.CurrentDirectory + "\\data\\"; + var path = Environment.CurrentDirectory + "\\data\\"; EncodingOptions encOpts = new(); encOpts.Encoding = enc; @@ -33,10 +33,10 @@ private void CompareReaderImplementationsInternal(string fileName, Encoding enc, using Stream s2 = new FileStream(path + fileName, FileMode.Open, FileAccess.Read); using ILogStreamReader r1 = new PositionAwareStreamReaderLegacy(s1, encOpts); using ILogStreamReader r2 = new PositionAwareStreamReaderSystem(s2, encOpts); - for (int lineNum = 0; ; lineNum++) + for (var lineNum = 0; ; lineNum++) { - string line1 = r1.ReadLine(); - string line2 = r2.ReadLine(); + var line1 = r1.ReadLine(); + var line2 = r2.ReadLine(); if (line1 == null && line2 == null) { break; diff --git a/src/LogExpert.Tests/RollingNameTest.cs b/src/LogExpert.Tests/RollingNameTest.cs index 783bd2fa..9d25b28e 100644 --- a/src/LogExpert.Tests/RollingNameTest.cs +++ b/src/LogExpert.Tests/RollingNameTest.cs @@ -20,7 +20,7 @@ public void TestFilename1(string expectedResult, string formatString) { RolloverFilenameBuilder fnb = new(formatString); fnb.SetFileName(expectedResult); - string name = fnb.BuildFileName(); + var name = fnb.BuildFileName(); Assert.That(name, Is.EqualTo(expectedResult)); } @@ -38,7 +38,7 @@ public void TestFilenameAnd1(string fileName, string expectedResult, string form RolloverFilenameBuilder fnb = new(formatString); fnb.SetFileName(fileName); fnb.Index += 1; - string name = fnb.BuildFileName(); + var name = fnb.BuildFileName(); Assert.That(name, Is.EqualTo(expectedResult)); } @@ -50,7 +50,7 @@ public void TestFilenameAnd2(string fileName, string expectedResult, string form RolloverFilenameBuilder fnb = new(formatString); fnb.SetFileName(fileName); fnb.Index += 2; - string name = fnb.BuildFileName(); + var name = fnb.BuildFileName(); Assert.That(name, Is.EqualTo(expectedResult)); } @@ -62,7 +62,7 @@ public void TestFilenameMinus1(string fileName, string expectedResult, string fo RolloverFilenameBuilder fnb = new(formatString); fnb.SetFileName(fileName); fnb.Index -= 1; - string name = fnb.BuildFileName(); + var name = fnb.BuildFileName(); Assert.That(name, Is.EqualTo("engine.log")); } } diff --git a/src/LogExpert.Tests/RolloverHandlerTest.cs b/src/LogExpert.Tests/RolloverHandlerTest.cs index 9c4e7557..f6795864 100644 --- a/src/LogExpert.Tests/RolloverHandlerTest.cs +++ b/src/LogExpert.Tests/RolloverHandlerTest.cs @@ -22,7 +22,7 @@ public void TestFilenameListWithAppendedIndex(string format, int retries) LinkedList files = CreateTestFilesWithoutDate(); - string firstFile = files.Last.Value; + var firstFile = files.Last.Value; ILogFileInfo info = new LogFileInfo(new Uri(firstFile)); RolloverFilenameHandler handler = new(info, options); @@ -43,7 +43,7 @@ public void TestFilenameListWithDate(string format, int retries) LinkedList files = CreateTestFilesWithDate(); - string firstFile = files.Last.Value; + var firstFile = files.Last.Value; ILogFileInfo info = new LogFileInfo(new Uri(firstFile)); RolloverFilenameHandler handler = new(info, options); diff --git a/src/LogExpert.Tests/RolloverHandlerTestBase.cs b/src/LogExpert.Tests/RolloverHandlerTestBase.cs index 06617bf0..922ee287 100644 --- a/src/LogExpert.Tests/RolloverHandlerTestBase.cs +++ b/src/LogExpert.Tests/RolloverHandlerTestBase.cs @@ -54,7 +54,7 @@ protected LinkedList RolloverSimulation(LinkedList files, string RolloverFilenameBuilder fnb = new(formatPattern); fnb.SetFileName(fileList.Last.Value); fnb.Index += fileList.Count; - string newFileName = fnb.BuildFileName(); + var newFileName = fnb.BuildFileName(); fileList.AddFirst(newFileName); LinkedList.Enumerator enumerator = fileList.GetEnumerator(); LinkedList.Enumerator nextEnumerator = fileList.GetEnumerator(); @@ -89,12 +89,12 @@ protected void Cleanup() protected string CreateFile(DirectoryInfo dInfo, string fileName) { - int lineCount = 10; - string fullName = dInfo == null ? fileName : dInfo.FullName + Path.DirectorySeparatorChar + fileName; + var lineCount = 10; + var fullName = dInfo == null ? fileName : dInfo.FullName + Path.DirectorySeparatorChar + fileName; using (StreamWriter writer = new(File.Create(fullName))) { - for (int i = 1; i <= lineCount; ++i) + for (var i = 1; i <= lineCount; ++i) { writer.WriteLine("Line number " + i.ToString("D3") + " of File " + fullName); } diff --git a/src/LogExpert.Tests/SquareBracketColumnizerTest.cs b/src/LogExpert.Tests/SquareBracketColumnizerTest.cs index e972f658..3104c2a7 100644 --- a/src/LogExpert.Tests/SquareBracketColumnizerTest.cs +++ b/src/LogExpert.Tests/SquareBracketColumnizerTest.cs @@ -20,7 +20,7 @@ public class SquareBracketColumnizerTest public void GetPriority_HappyFile_ColumnCountMatches(string fileName, int count) { SquareBracketColumnizer squareBracketColumnizer = new(); - string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); + var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); LogfileReader logFileReader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); logFileReader.ReadFiles(); diff --git a/src/LogExpert.UI/Controls/BufferedDataGridView.cs b/src/LogExpert.UI/Controls/BufferedDataGridView.cs index afb248a2..bf382750 100644 --- a/src/LogExpert.UI/Controls/BufferedDataGridView.cs +++ b/src/LogExpert.UI/Controls/BufferedDataGridView.cs @@ -68,9 +68,9 @@ public Graphics Buffer } */ - public ContextMenuStrip EditModeMenuStrip { get; set; } = null; + public ContextMenuStrip EditModeMenuStrip { get; set; } - public bool PaintWithOverlays { get; set; } = false; + public bool PaintWithOverlays { get; set; } #endregion @@ -112,7 +112,7 @@ protected override void OnEditingControlShowing(DataGridViewEditingControlShowin base.OnEditingControlShowing(e); e.Control.KeyDown -= OnControlKeyDown; e.Control.KeyDown += OnControlKeyDown; - DataGridViewTextBoxEditingControl editControl = (DataGridViewTextBoxEditingControl)e.Control; + var editControl = (DataGridViewTextBoxEditingControl)e.Control; e.Control.PreviewKeyDown -= Control_PreviewKeyDown; e.Control.PreviewKeyDown += Control_PreviewKeyDown; @@ -297,7 +297,7 @@ private void OnControlKeyDown(object sender, KeyEventArgs e) if (EditingControl is LogCellEditingControl editControl) { editControl.EditingControlDataGridView.EndEdit(); - int line = editControl.EditingControlDataGridView.CurrentCellAddress.Y; + var line = editControl.EditingControlDataGridView.CurrentCellAddress.Y; if (e.KeyCode == Keys.Up) { if (line > 0) @@ -314,9 +314,9 @@ private void OnControlKeyDown(object sender, KeyEventArgs e) } } - int col = editControl.EditingControlDataGridView.CurrentCellAddress.X; - int scrollIndex = editControl.EditingControlDataGridView.HorizontalScrollingOffset; - int selStart = editControl.SelectionStart; + var col = editControl.EditingControlDataGridView.CurrentCellAddress.X; + var scrollIndex = editControl.EditingControlDataGridView.HorizontalScrollingOffset; + var selStart = editControl.SelectionStart; editControl.EditingControlDataGridView.CurrentCell = editControl.EditingControlDataGridView.Rows[line].Cells[col]; editControl.EditingControlDataGridView.BeginEdit(false); editControl.SelectionStart = selStart; diff --git a/src/LogExpert.UI/Controls/ColorComboBox.cs b/src/LogExpert.UI/Controls/ColorComboBox.cs index 352eead1..2cc8dcd1 100644 --- a/src/LogExpert.UI/Controls/ColorComboBox.cs +++ b/src/LogExpert.UI/Controls/ColorComboBox.cs @@ -69,7 +69,7 @@ private void OnColorComboBoxDrawItem(object sender, DrawItemEventArgs e) if (e.Index >= 0) { Rectangle rectangle = new(4, e.Bounds.Top + 2, 30, e.Bounds.Height - 4); - Color rectColor = (Color)Items[e.Index]; + var rectColor = (Color)Items[e.Index]; e.Graphics.FillRectangle(new SolidBrush(rectColor), rectangle); e.Graphics.DrawRectangle(Pens.Black, rectangle); diff --git a/src/LogExpert.UI/Controls/DateTimeDragControl.cs b/src/LogExpert.UI/Controls/DateTimeDragControl.cs index ad17a7fd..0b7ef570 100644 --- a/src/LogExpert.UI/Controls/DateTimeDragControl.cs +++ b/src/LogExpert.UI/Controls/DateTimeDragControl.cs @@ -126,7 +126,7 @@ public DateTime DateTime // Returns the index of the rectangle (digitRects) under the mouse cursor private int DetermineDraggedDigit(MouseEventArgs e) { - for (int i = 0; i < _digitRects.Count; ++i) + for (var i = 0; i < _digitRects.Count; ++i) { if (_digitRects[i].Contains(e.Location) && Token.IsDatePart(_dateParts[i])) { @@ -140,7 +140,7 @@ private int DetermineDraggedDigit(MouseEventArgs e) // Return the value corresponding to current dragged digit private int GetDraggedValue() { - string datePart = _dateParts[_draggedDigit]; + var datePart = _dateParts[_draggedDigit]; if (datePart.StartsWith("y", StringComparison.OrdinalIgnoreCase)) { @@ -177,10 +177,10 @@ private bool SetDraggedValue(int delta) return false; } - bool changed = true; + var changed = true; try { - string datePart = _dateParts[_draggedDigit]; + var datePart = _dateParts[_draggedDigit]; if (datePart.StartsWith("y", StringComparison.OrdinalIgnoreCase)) { @@ -234,14 +234,14 @@ private void InitCustomRects(Section dateSection) .ToArray(); Rectangle rect = ClientRectangle; - int oneCharWidth = rect.Width / _dateParts.Sum(s => s.Length); - int left = rect.Left; + var oneCharWidth = rect.Width / _dateParts.Sum(s => s.Length); + var left = rect.Left; _digitRects.Clear(); - foreach (string datePart in _dateParts) + foreach (var datePart in _dateParts) { - int s = datePart.Length * oneCharWidth; + var s = datePart.Length * oneCharWidth; _digitRects.Add(new Rectangle(left, rect.Top, s, rect.Height)); left += s; } @@ -252,14 +252,14 @@ private void InitDigitRects() { CultureInfo culture = System.Threading.Thread.CurrentThread.CurrentCulture; - string datePattern = string.Concat(culture.DateTimeFormat.ShortDatePattern, " ", culture.DateTimeFormat.LongTimePattern); + var datePattern = string.Concat(culture.DateTimeFormat.ShortDatePattern, " ", culture.DateTimeFormat.LongTimePattern); List
    sections = Parser.ParseSections(datePattern, out _); Section dateSection = sections.FirstOrDefault(); if (dateSection == null) { - sections = Parser.ParseSections("dd.MM.yyyy HH:mm:ss", out bool _); + sections = Parser.ParseSections("dd.MM.yyyy HH:mm:ss", out var _); dateSection = sections.Single(); } @@ -372,9 +372,9 @@ protected override void OnPaint(PaintEventArgs e) // Display current value with user-defined date format and fixed time format ("HH:mm:ss") using (Brush brush = new SolidBrush(Color.Black)) { - for (int i = 0; i < _dateParts.Length; i++) + for (var i = 0; i < _dateParts.Length; i++) { - string datePart = _dateParts[i]; + var datePart = _dateParts[i]; Rectangle rect = _digitRects[i]; string value; @@ -479,7 +479,7 @@ protected override void OnMouseMove(MouseEventArgs e) } } - int delta = diff / 5 - _addedValue; // one unit per 5 pixels move + var delta = diff / 5 - _addedValue; // one unit per 5 pixels move if (delta == 0) { diff --git a/src/LogExpert.UI/Controls/KnobControl.cs b/src/LogExpert.UI/Controls/KnobControl.cs index fc2c1c0e..b63eb5c4 100644 --- a/src/LogExpert.UI/Controls/KnobControl.cs +++ b/src/LogExpert.UI/Controls/KnobControl.cs @@ -14,10 +14,10 @@ public partial class KnobControl : UserControl private readonly StringFormat _stringFormat = new(); - private bool _isShiftPressed = false; + private bool _isShiftPressed; - private int _oldValue = 0; - private int _startMouseY = 0; + private int _oldValue; + private int _startMouseY; private int _value; #endregion @@ -53,7 +53,7 @@ public KnobControl() public int Value { - get { return _value; } + get => _value; set { _value = value; @@ -62,10 +62,7 @@ public int Value } - public int Range - { - get { return MaxValue - MinValue; } - } + public int Range => MaxValue - MinValue; public int DragSensitivity { get; set; } = 3; @@ -83,7 +80,7 @@ protected override void OnPaint(PaintEventArgs e) Pen greyPen = new(Color.Gray, 1); Rectangle rect = ClientRectangle; - int height = Font.Height + 3; + var height = Font.Height + 3; if (height > rect.Height) { height = rect.Height + 3; @@ -95,8 +92,8 @@ protected override void OnPaint(PaintEventArgs e) //rect = this.ClientRectangle; rect.Inflate(-2, -2); - float startAngle = 135.0F + 270F * ((float)_value / (float)Range); - float sweepAngle = 0.1F; + var startAngle = 135.0F + 270F * ((float)_value / (float)Range); + var sweepAngle = 0.1F; e.Graphics.DrawPie(blackPen, rect, startAngle, sweepAngle); Brush brush = new SolidBrush(foregroundColor); @@ -147,11 +144,11 @@ protected override void OnMouseMove(MouseEventArgs e) return; } - int sense = _isShiftPressed ? DragSensitivity * 2 : DragSensitivity; + var sense = _isShiftPressed ? DragSensitivity * 2 : DragSensitivity; - int diff = _startMouseY - e.Y; + var diff = _startMouseY - e.Y; _logger.Debug("KnobDiff: {0}", diff); - int range = MaxValue - MinValue; + var range = MaxValue - MinValue; _value = _oldValue + diff / sense; if (_value < MinValue) diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index 9cd0514e..dec9982f 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -93,7 +93,7 @@ public partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILog private string[] _fileNames; private List _filterHitList = []; private FilterParams _filterParams = new(); - private int _filterPipeNameCounter = 0; + private int _filterPipeNameCounter; private List _filterResultList = []; private EventWaitHandle _filterUpdateEvent = new ManualResetEvent(false); @@ -109,7 +109,7 @@ public partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILog private bool _isTimestampDisplaySyncing; private List _lastFilterLinesList = []; - private int _lineHeight = 0; + private int _lineHeight; internal LogfileReader _logFileReader; private MultiFileOptions _multiFileOptions = new(); @@ -118,15 +118,15 @@ public partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILog private PatternWindow _patternWindow; private ReloadMemento _reloadMemento; - private int _reloadOverloadCounter = 0; + private int _reloadOverloadCounter; private SortedList _rowHeightList = []; - private int _selectedCol = 0; // set by context menu event for column headers only + private int _selectedCol; // set by context menu event for column headers only private bool _shouldCallTimeSync; private bool _shouldCancel; private bool _shouldTimestampDisplaySyncingCancel; private bool _showAdvanced; private List _tempHighlightEntryList = []; - private int _timeShiftSyncLine = 0; + private int _timeShiftSyncLine; private bool _waitingForClose; @@ -190,7 +190,7 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp //this.toolwinTabControl.TabPages.Add(this.bookmarkWindow); _filterParams = new FilterParams(); - foreach (string item in configManager.Settings.filterHistoryList) + foreach (var item in configManager.Settings.filterHistoryList) { filterComboBox.Items.Add(item); } @@ -460,7 +460,7 @@ public bool ShowBookmarkBubbles public string FileName { get; private set; } - public string SessionFileName { get; set; } = null; + public string SessionFileName { get; set; } public bool IsMultiFile { @@ -474,7 +474,7 @@ public bool IsMultiFile public string TempTitleName { get; set; } = ""; - internal FilterPipe FilterPipe { get; set; } = null; + internal FilterPipe FilterPipe { get; set; } public string Title { @@ -493,11 +493,11 @@ public string Title public bool ForcePersistenceLoading { get; set; } - public string ForcedPersistenceFileName { get; set; } = null; + public string ForcedPersistenceFileName { get; set; } public Preferences Preferences => ConfigManager.Settings.Preferences; - public string GivenFileName { get; set; } = null; + public string GivenFileName { get; set; } public TimeSyncList TimeSyncList { get; private set; } @@ -517,28 +517,14 @@ public string Title event FileSizeChangedEventHandler ILogWindow.FileSizeChanged { - add - { - this.FileSizeChanged += new FileSizeChangedEventHandler(value); - } - - remove - { - this.FileSizeChanged -= new FileSizeChangedEventHandler(value); - } + add => FileSizeChanged += new FileSizeChangedEventHandler(value); + remove => FileSizeChanged -= new FileSizeChangedEventHandler(value); } event EventHandler ILogWindow.TailFollowed { - add - { - this.TailFollowed += new TailFollowedEventHandler(value); - } - - remove - { - this.TailFollowed -= new TailFollowedEventHandler(value); - } + add => TailFollowed += new TailFollowedEventHandler(value); + remove => TailFollowed -= new TailFollowedEventHandler(value); } #endregion @@ -676,7 +662,7 @@ private void OnButtonSizeChanged (object sender, EventArgs e) #if DEBUG internal void DumpBufferInfo () { - int currentLineNum = dataGridView.CurrentCellAddress.Y; + var currentLineNum = dataGridView.CurrentCellAddress.Y; _logFileReader.LogBufferInfoForLine(currentLineNum); } diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs index a61a0669..c3279ba9 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs @@ -1392,8 +1392,8 @@ private void OnFilterListBoxMouseDoubleClick (object sender, MouseEventArgs e) var filterParams = (FilterParams)filterListBox.Items[filterListBox.SelectedIndex]; FilterParams newParams = filterParams.Clone(); //newParams.historyList = ConfigManager.Settings.filterHistoryList; - this._filterParams = newParams; - ReInitFilterParams(this._filterParams); + _filterParams = newParams; + ReInitFilterParams(_filterParams); ApplyFilterParams(); CheckForAdvancedButtonDirty(); CheckForFilterDirty(); diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs index afb29b12..458839c4 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs @@ -42,7 +42,7 @@ public void LoadFile(string fileName, EncodingOptions encodingOptions) // One possible solution is, using raw file stream to read the sample lines to help // the ColumnizerPicker to determine the priority. // - bool isUsingDefaultColumnizer = false; + var isUsingDefaultColumnizer = false; if (!LoadPersistenceOptions()) { if (!IsTempFile) @@ -139,7 +139,7 @@ public void LoadFilesAsMulti(string[] fileNames, EncodingOptions encodingOptions EnterLoadFileStatus(); - foreach (string name in fileNames) + foreach (var name in fileNames) { _logger.Info("File: {0}", name); } @@ -502,7 +502,7 @@ public void CellPainting(BufferedDataGridView gridView, int rowIndex, DataGridVi public void OnDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { - BufferedDataGridView gridView = (BufferedDataGridView)sender; + var gridView = (BufferedDataGridView)sender; CellPainting(gridView, e.RowIndex, e); } @@ -640,7 +640,7 @@ private void SearchComplete(Task task) try { Invoke(new MethodInvoker(ResetProgressBar)); - int line = task.Result; + var line = task.Result; _guiStateArgs.MenuEnabled = true; GuiStateUpdate(this, _guiStateArgs); if (line == -1) @@ -671,7 +671,7 @@ public void SelectAndEnsureVisible(int line, bool triggerSyncCall) if (line < dataGridView.FirstDisplayedScrollingRowIndex || line > dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false)) { dataGridView.FirstDisplayedScrollingRowIndex = line; - for (int i = 0; i < 8 && dataGridView.FirstDisplayedScrollingRowIndex > 0 && line < dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false); ++i) + for (var i = 0; i < 8 && dataGridView.FirstDisplayedScrollingRowIndex > 0 && line < dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false); ++i) { dataGridView.FirstDisplayedScrollingRowIndex -= 1; } @@ -730,7 +730,7 @@ public void OnLogWindowKeyDown(object sender, KeyEventArgs e) } case Keys.Down when e.Modifiers == Keys.Alt: { - int newLine = _logFileReader.GetNextMultiFileLine(dataGridView.CurrentCellAddress.Y); + var newLine = _logFileReader.GetNextMultiFileLine(dataGridView.CurrentCellAddress.Y); if (newLine != -1) { @@ -743,7 +743,7 @@ public void OnLogWindowKeyDown(object sender, KeyEventArgs e) } case Keys.Up when e.Modifiers == Keys.Alt: { - int newLine = _logFileReader.GetPrevMultiFileLine(dataGridView.CurrentCellAddress.Y); + var newLine = _logFileReader.GetPrevMultiFileLine(dataGridView.CurrentCellAddress.Y); if (newLine != -1) { @@ -794,7 +794,7 @@ public void AddBookmarkOverlays() { const int OVERSCAN = 20; - int firstLine = dataGridView.FirstDisplayedScrollingRowIndex; + var firstLine = dataGridView.FirstDisplayedScrollingRowIndex; if (firstLine < 0) { return; @@ -806,9 +806,9 @@ public void AddBookmarkOverlays() firstLine = 0; } - int oversizeCount = OVERSCAN; + var oversizeCount = OVERSCAN; - for (int i = firstLine; i < dataGridView.RowCount; ++i) + for (var i = firstLine; i < dataGridView.RowCount; ++i) { if (!dataGridView.Rows[i].Displayed && i > dataGridView.FirstDisplayedScrollingRowIndex) { @@ -835,10 +835,10 @@ public void AddBookmarkOverlays() { r = dataGridView.GetCellDisplayRectangle(0, dataGridView.FirstDisplayedScrollingRowIndex, false); //int count = i - this.dataGridView.FirstDisplayedScrollingRowIndex; - int heightSum = 0; + var heightSum = 0; if (dataGridView.FirstDisplayedScrollingRowIndex < i) { - for (int rn = dataGridView.FirstDisplayedScrollingRowIndex + 1; rn < i; ++rn) + for (var rn = dataGridView.FirstDisplayedScrollingRowIndex + 1; rn < i; ++rn) { //Rectangle rr = this.dataGridView.GetCellDisplayRectangle(0, rn, false); //heightSum += rr.Height; @@ -848,7 +848,7 @@ public void AddBookmarkOverlays() } else { - for (int rn = dataGridView.FirstDisplayedScrollingRowIndex + 1; rn > i; --rn) + for (var rn = dataGridView.FirstDisplayedScrollingRowIndex + 1; rn > i; --rn) { //Rectangle rr = this.dataGridView.GetCellDisplayRectangle(0, rn, false); //heightSum += rr.Height; @@ -931,7 +931,7 @@ public void SetBookmarkFromTrigger(int lineNum, string comment) { return; } - ParamParser paramParser = new ParamParser(comment); + var paramParser = new ParamParser(comment); try { comment = paramParser.ReplaceParams(line, lineNum, FileName); @@ -955,15 +955,15 @@ public void JumpNextBookmark() { if (filterGridView.Focused) { - int index = FindNextBookmarkIndex(_filterResultList[filterGridView.CurrentCellAddress.Y]); - int startIndex = index; - bool wrapped = false; + var index = FindNextBookmarkIndex(_filterResultList[filterGridView.CurrentCellAddress.Y]); + var startIndex = index; + var wrapped = false; while (true) { - int lineNum = _bookmarkProvider.Bookmarks[index].LineNum; + var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; if (_filterResultList.Contains(lineNum)) { - int filterLine = _filterResultList.IndexOf(lineNum); + var filterLine = _filterResultList.IndexOf(lineNum); filterGridView.Rows[filterLine].Selected = true; filterGridView.CurrentCell = filterGridView.Rows[filterLine].Cells[0]; break; @@ -982,13 +982,13 @@ public void JumpNextBookmark() } else { - int index = FindNextBookmarkIndex(dataGridView.CurrentCellAddress.Y); + var index = FindNextBookmarkIndex(dataGridView.CurrentCellAddress.Y); if (index > _bookmarkProvider.Bookmarks.Count - 1) { index = 0; } - int lineNum = _bookmarkProvider.Bookmarks[index].LineNum; + var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; SelectLine(lineNum, true, true); } } @@ -1004,19 +1004,19 @@ public void JumpPrevBookmark() //if (index < 0) // index = ~index; //index--; - int index = FindPrevBookmarkIndex(_filterResultList[filterGridView.CurrentCellAddress.Y]); + var index = FindPrevBookmarkIndex(_filterResultList[filterGridView.CurrentCellAddress.Y]); if (index < 0) { index = _bookmarkProvider.Bookmarks.Count - 1; } - int startIndex = index; - bool wrapped = false; + var startIndex = index; + var wrapped = false; while (true) { - int lineNum = _bookmarkProvider.Bookmarks[index].LineNum; + var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; if (_filterResultList.Contains(lineNum)) { - int filterLine = _filterResultList.IndexOf(lineNum); + var filterLine = _filterResultList.IndexOf(lineNum); filterGridView.Rows[filterLine].Selected = true; filterGridView.CurrentCell = filterGridView.Rows[filterLine].Cells[0]; break; @@ -1035,13 +1035,13 @@ public void JumpPrevBookmark() } else { - int index = FindPrevBookmarkIndex(dataGridView.CurrentCellAddress.Y); + var index = FindPrevBookmarkIndex(dataGridView.CurrentCellAddress.Y); if (index < 0) { index = _bookmarkProvider.Bookmarks.Count - 1; } - int lineNum = _bookmarkProvider.Bookmarks[index].LineNum; + var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; SelectLine(lineNum, false, true); } } @@ -1049,8 +1049,8 @@ public void JumpPrevBookmark() public void DeleteBookmarks(List lineNumList) { - bool bookmarksPresent = false; - foreach (int lineNum in lineNumList) + var bookmarksPresent = false; + foreach (var lineNum in lineNumList) { if (lineNum != -1) { @@ -1085,13 +1085,13 @@ public void SetTimeshiftValue(string value) { try { - string text = _guiStateArgs.TimeshiftText; + var text = _guiStateArgs.TimeshiftText; if (text.StartsWith("+")) { text = text.Substring(1); } - TimeSpan timeSpan = TimeSpan.Parse(text); - int diff = (int)(timeSpan.Ticks / TimeSpan.TicksPerMillisecond); + var timeSpan = TimeSpan.Parse(text); + var diff = (int)(timeSpan.Ticks / TimeSpan.TicksPerMillisecond); CurrentColumnizer.SetTimeOffset(diff); } catch (Exception) @@ -1175,7 +1175,7 @@ public void CopyMarkedLinesToTab() { if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) { - List lineNumList = new List(); + var lineNumList = new List(); foreach (DataGridViewRow row in dataGridView.SelectedRows) { if (row.Index != -1) @@ -1186,7 +1186,7 @@ public void CopyMarkedLinesToTab() lineNumList.Sort(); // create dummy FilterPipe for connecting line numbers to original window // setting IsStopped to true prevents further filter processing - FilterPipe pipe = new FilterPipe(new FilterParams(), this) + var pipe = new FilterPipe(new FilterParams(), this) { IsStopped = true }; @@ -1194,16 +1194,16 @@ public void CopyMarkedLinesToTab() } else { - string fileName = Path.GetTempFileName(); - FileStream fStream = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.Read); - StreamWriter writer = new StreamWriter(fStream, Encoding.Unicode); + var fileName = Path.GetTempFileName(); + var fStream = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.Read); + var writer = new StreamWriter(fStream, Encoding.Unicode); DataObject data = dataGridView.GetClipboardContent(); - string text = data.GetText(TextDataFormat.Text); + var text = data.GetText(TextDataFormat.Text); writer.Write(text); writer.Close(); - string title = Util.GetNameFromPath(FileName) + "->Clip"; + var title = Util.GetNameFromPath(FileName) + "->Clip"; _parentLogTabWin.AddTempFileTab(fileName, title); } } @@ -1268,8 +1268,8 @@ public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, Sett BoldFont = new Font(NormalFont, FontStyle.Bold); MonospacedFont = new Font("Courier New", Preferences.fontSize, FontStyle.Bold); - int lineSpacing = NormalFont.FontFamily.GetLineSpacing(FontStyle.Regular); - float lineSpacingPixel = NormalFont.Size * lineSpacing / NormalFont.FontFamily.GetEmHeight(FontStyle.Regular); + var lineSpacing = NormalFont.FontFamily.GetLineSpacing(FontStyle.Regular); + var lineSpacingPixel = NormalFont.Size * lineSpacing / NormalFont.FontFamily.GetEmHeight(FontStyle.Regular); dataGridView.DefaultCellStyle.Font = NormalFont; filterGridView.DefaultCellStyle.Font = NormalFont; @@ -1333,19 +1333,19 @@ public bool ScrollToTimestamp(DateTime timestamp, bool roundToSeconds, bool trig public bool ScrollToTimestampWorker(DateTime timestamp, bool roundToSeconds, bool triggerSyncCall) { - bool hasScrolled = false; + var hasScrolled = false; if (!CurrentColumnizer.IsTimeshiftImplemented() || dataGridView.RowCount == 0) { return false; } //this.Cursor = Cursors.WaitCursor; - int currentLine = dataGridView.CurrentCellAddress.Y; + var currentLine = dataGridView.CurrentCellAddress.Y; if (currentLine < 0 || currentLine >= dataGridView.RowCount) { currentLine = 0; } - int foundLine = FindTimestampLine(currentLine, timestamp, roundToSeconds); + var foundLine = FindTimestampLine(currentLine, timestamp, roundToSeconds); if (foundLine >= 0) { SelectAndEnsureVisible(foundLine, triggerSyncCall); @@ -1357,7 +1357,7 @@ public bool ScrollToTimestampWorker(DateTime timestamp, bool roundToSeconds, boo public int FindTimestampLine(int lineNum, DateTime timestamp, bool roundToSeconds) { - int foundLine = + var foundLine = FindTimestampLine_Internal(lineNum, 0, dataGridView.RowCount - 1, timestamp, roundToSeconds); if (foundLine >= 0) { @@ -1384,7 +1384,7 @@ public int FindTimestampLine_Internal(int lineNum, int rangeStart, int rangeEnd, bool roundToSeconds) { _logger.Debug("FindTimestampLine_Internal(): timestamp={0}, lineNum={1}, rangeStart={2}, rangeEnd={3}", timestamp, lineNum, rangeStart, rangeEnd); - int refLine = lineNum; + var refLine = lineNum; DateTime currentTimestamp = GetTimestampForLine(ref refLine, roundToSeconds); if (currentTimestamp.CompareTo(timestamp) == 0) { @@ -1442,7 +1442,7 @@ public DateTime GetTimestampForLine(ref int lineNum, bool roundToSeconds) } _logger.Debug("GetTimestampForLine({0}) enter", lineNum); DateTime timeStamp = DateTime.MinValue; - bool lookBack = false; + var lookBack = false; if (lineNum >= 0 && lineNum < dataGridView.RowCount) { while (timeStamp.CompareTo(DateTime.MinValue) == 0 && lineNum >= 0) @@ -1491,7 +1491,7 @@ public DateTime GetTimestampForLineForward(ref int lineNum, bool roundToSeconds) } DateTime timeStamp = DateTime.MinValue; - bool lookFwd = false; + var lookFwd = false; if (lineNum >= 0 && lineNum < dataGridView.RowCount) { while (timeStamp.CompareTo(DateTime.MinValue) == 0 && lineNum < dataGridView.RowCount) @@ -1558,7 +1558,7 @@ public int GetCurrentLineNum() public int GetRealLineNum() { - int lineNum = GetCurrentLineNum(); + var lineNum = GetCurrentLineNum(); if (lineNum == -1) { return -1; @@ -1634,7 +1634,7 @@ public void PatternStatisticSelectRange(PatternArgs patternArgs) public void PatternStatistic(PatternArgs patternArgs) { - PatternStatisticFx fx = new PatternStatisticFx(TestStatistic); + var fx = new PatternStatisticFx(TestStatistic); fx.BeginInvoke(patternArgs, null, null); } @@ -1686,7 +1686,7 @@ public void ImportBookmarkList() BookmarkExporter.ImportBookmarkList(FileName, dlg.FileName, newBookmarks); // Add (or replace) to existing bookmark list - bool bookmarkAdded = false; + var bookmarkAdded = false; foreach (Bookmark b in newBookmarks.Values) { if (!_bookmarkProvider.BookmarkList.ContainsKey(b.LineNum)) @@ -1736,7 +1736,7 @@ public void HandleChangedFilterList() public void HandleChangedFilterListWorker() { - int index = filterListBox.SelectedIndex; + var index = filterListBox.SelectedIndex; filterListBox.Items.Clear(); foreach (FilterParams filterParam in ConfigManager.Settings.filterList) { diff --git a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs index b003c8bb..8c961e4e 100644 --- a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs @@ -41,26 +41,26 @@ public PatternWindow(LogWindow logWindow) public int Fuzzy { - set { fuzzyKnobControl.Value = value; } - get { return fuzzyKnobControl.Value; } + set => fuzzyKnobControl.Value = value; + get => fuzzyKnobControl.Value; } public int MaxDiff { - set { maxDiffKnobControl.Value = value; } - get { return maxDiffKnobControl.Value; } + set => maxDiffKnobControl.Value = value; + get => maxDiffKnobControl.Value; } public int MaxMisses { - set { maxMissesKnobControl.Value = value; } - get { return maxMissesKnobControl.Value; } + set => maxMissesKnobControl.Value = value; + get => maxMissesKnobControl.Value; } public int Weight { - set { weigthKnobControl.Value = value; } - get { return weigthKnobControl.Value; } + set => weigthKnobControl.Value = value; + get => weigthKnobControl.Value; } #endregion @@ -73,7 +73,7 @@ public void SetBlockList(List flatBlockList, PatternArgs patternAr blockList.Clear(); List singeList = []; //int blockId = -1; - for (int i = 0; i < flatBlockList.Count; ++i) + for (var i = 0; i < flatBlockList.Count; ++i) { PatternBlock block = flatBlockList[i]; singeList.Add(block); @@ -129,8 +129,8 @@ public void SetColumnizer(ILogLineColumnizer columnizer) public void SetFont(string fontName, float fontSize) { Font font = new(new FontFamily(fontName), fontSize); - int lineSpacing = font.FontFamily.GetLineSpacing(FontStyle.Regular); - float lineSpacingPixel = font.Size * lineSpacing / font.FontFamily.GetEmHeight(FontStyle.Regular); + var lineSpacing = font.FontFamily.GetLineSpacing(FontStyle.Regular); + var lineSpacingPixel = font.Size * lineSpacing / font.FontFamily.GetEmHeight(FontStyle.Regular); patternHitsDataGridView.DefaultCellStyle.Font = font; contentDataGridView.DefaultCellStyle.Font = font; @@ -190,8 +190,8 @@ private void patternHitsDataGridView_CellValueNeeded(object sender, DataGridView { return; } - int rowIndex = GetLineForHitGrid(e.RowIndex); - int colIndex = e.ColumnIndex; + var rowIndex = GetLineForHitGrid(e.RowIndex); + var colIndex = e.ColumnIndex; if (colIndex == 1) { e.Value = currentList[e.RowIndex].weigth; @@ -215,14 +215,14 @@ private void patternHitsDataGridView_CellPainting(object sender, DataGridViewCel if (e.ColumnIndex == 1) { e.PaintBackground(e.CellBounds, false); - int selCount = patternArgs.EndLine - patternArgs.StartLine; - int maxWeight = patternArgs.MaxDiffInBlock * selCount + selCount; + var selCount = patternArgs.EndLine - patternArgs.StartLine; + var maxWeight = patternArgs.MaxDiffInBlock * selCount + selCount; if (maxWeight > 0) { - int width = (int)((int)e.Value / (double)maxWeight * e.CellBounds.Width); + var width = (int)((int)e.Value / (double)maxWeight * e.CellBounds.Width); Rectangle rect = new(e.CellBounds.X, e.CellBounds.Y, width, e.CellBounds.Height); - int alpha = 90 + (int)((int)e.Value / (double)maxWeight * 165); - Color color = Color.FromArgb(alpha, 170, 180, 150); + var alpha = 90 + (int)((int)e.Value / (double)maxWeight * 165); + var color = Color.FromArgb(alpha, 170, 180, 150); Brush brush = new SolidBrush(color); rect.Inflate(-2, -1); e.Graphics.FillRectangle(brush, rect); @@ -233,8 +233,8 @@ private void patternHitsDataGridView_CellPainting(object sender, DataGridViewCel } else { - BufferedDataGridView gridView = (BufferedDataGridView)sender; - int rowIndex = GetLineForHitGrid(e.RowIndex); + var gridView = (BufferedDataGridView)sender; + var rowIndex = GetLineForHitGrid(e.RowIndex); logWindow.CellPainting(gridView, rowIndex, e); } } @@ -272,8 +272,8 @@ private void contentDataGridView_CellValueNeeded(object sender, DataGridViewCell { return; } - int rowIndex = GetLineForContentGrid(e.RowIndex); - int colIndex = e.ColumnIndex; + var rowIndex = GetLineForContentGrid(e.RowIndex); + var colIndex = e.ColumnIndex; if (colIndex == 1) { QualityInfo qi; @@ -302,8 +302,8 @@ private void contentDataGridView_CellPainting(object sender, DataGridViewCellPai { return; } - BufferedDataGridView gridView = (BufferedDataGridView)sender; - int rowIndex = GetLineForContentGrid(e.RowIndex); + var gridView = (BufferedDataGridView)sender; + var rowIndex = GetLineForContentGrid(e.RowIndex); logWindow.CellPainting(gridView, rowIndex, e); } @@ -313,7 +313,7 @@ private void contentDataGridView_CellMouseDoubleClick(object sender, DataGridVie { return; } - int rowIndex = GetLineForContentGrid(contentDataGridView.CurrentRow.Index); + var rowIndex = GetLineForContentGrid(contentDataGridView.CurrentRow.Index); logWindow.SelectLogLine(rowIndex); } diff --git a/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs b/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs index 2a822e02..726c072c 100644 --- a/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs +++ b/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs @@ -41,9 +41,9 @@ public Range FindRange(int startLine) _filterParams.IsRangeSearch = false; _filterParams.IsInRange = false; - int lineCount = callback.GetLineCount(); - int lineNum = startLine; - bool foundStartLine = false; + var lineCount = callback.GetLineCount(); + var lineNum = startLine; + var foundStartLine = false; Range range = new(); FilterParams tmpParam = _filterParams.CloneWithCurrentColumnizer(); diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs index 47521d25..93ae8c72 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs @@ -33,10 +33,10 @@ internal class TimeSpreadCalculator private double _average; private int _contrast = 400; - private int _displayHeight = 0; + private int _displayHeight; private bool _enabled; private DateTime _endTimestamp; - private int _lineCount = 0; + private int _lineCount; private int _maxDiff; private TimeSpan _maxSpan; private bool _shouldStop; @@ -187,7 +187,7 @@ private void WorkerFx() { // wait for unbusy moments _logger.Debug("TimeSpreadCalculator: wait for unbusy moments"); - bool signaled = _calcEvent.WaitOne(INACTIVITY_TIME, false); + var signaled = _calcEvent.WaitOne(INACTIVITY_TIME, false); if (signaled == false) { _logger.Debug("TimeSpreadCalculator: unbusy. starting calc."); @@ -221,17 +221,17 @@ private void DoCalc() return; } - int lineNum = 0; - int lastLineNum = _callback.GetLineCount() - 1; + var lineNum = 0; + var lastLineNum = _callback.GetLineCount() - 1; _startTimestamp = _logWindow.GetTimestampForLineForward(ref lineNum, false); _endTimestamp = _logWindow.GetTimestampForLine(ref lastLineNum, false); - int timePerLineSum = 0; + var timePerLineSum = 0; if (_startTimestamp != DateTime.MinValue && _endTimestamp != DateTime.MinValue) { TimeSpan overallSpan = _endTimestamp - _startTimestamp; - int overallSpanMillis = (int)(overallSpan.Ticks / TimeSpan.TicksPerMillisecond); + var overallSpanMillis = (int)(overallSpan.Ticks / TimeSpan.TicksPerMillisecond); _timePerLine = (int)Math.Round(overallSpanMillis / (double)_lineCount); DateTime oldTime = _logWindow.GetTimestampForLineForward(ref lineNum, false); int step; @@ -251,9 +251,9 @@ private void DoCalc() List maxList = []; lineNum++; - for (int i = lineNum; i < lastLineNum; i += step) + for (var i = lineNum; i < lastLineNum; i += step) { - int currLineNum = i; + var currLineNum = i; DateTime time = _logWindow.GetTimestampForLineForward(ref currLineNum, false); if (time != DateTime.MinValue) { @@ -296,15 +296,15 @@ private void DoCalc_via_Time() return; } - int lineNum = 0; - int lastLineNum = _callback.GetLineCount() - 1; + var lineNum = 0; + var lastLineNum = _callback.GetLineCount() - 1; _startTimestamp = _logWindow.GetTimestampForLineForward(ref lineNum, false); _endTimestamp = _logWindow.GetTimestampForLine(ref lastLineNum, false); if (_startTimestamp != DateTime.MinValue && _endTimestamp != DateTime.MinValue) { TimeSpan overallSpan = _endTimestamp - _startTimestamp; - long overallSpanMillis = overallSpan.Ticks / TimeSpan.TicksPerMillisecond; + var overallSpanMillis = overallSpan.Ticks / TimeSpan.TicksPerMillisecond; //int timePerLine = (int)Math.Round((double)overallSpanMillis / (double)this.lineCount); long step; @@ -322,10 +322,10 @@ private void DoCalc_via_Time() lineNum = 0; DateTime searchTimeStamp = _startTimestamp; - int oldLineNum = lineNum; - int loopCount = 0; - int lineDiffSum = 0; - int minDiff = int.MaxValue; + var oldLineNum = lineNum; + var loopCount = 0; + var lineDiffSum = 0; + var minDiff = int.MaxValue; _maxDiff = 0; List maxList = []; List newDiffList = []; @@ -337,7 +337,7 @@ private void DoCalc_via_Time() { lineNum = -lineNum; } - int lineDiff = lineNum - oldLineNum; + var lineDiff = lineNum - oldLineNum; _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() test time {0:HH:mm:ss.fff} line diff={1}", searchTimeStamp, lineDiff); @@ -412,7 +412,7 @@ private DateTime CalcValuesViaLines(int timePerLine, TimeSpan maxSpan) diffFromAverage = 0; } - int value = (int)(diffFromAverage / (timePerLine / TimeSpan.TicksPerMillisecond) * _contrast); + var value = (int)(diffFromAverage / (timePerLine / TimeSpan.TicksPerMillisecond) * _contrast); entry.Value = 255 - value; oldTime = entry.Timestamp; } @@ -425,14 +425,14 @@ private void CalcValuesViaTime(int maxDiff, double average) { foreach (SpreadEntry entry in DiffList) { - int lineDiff = entry.Diff; - double diffFromAverage = entry.Diff - average; + var lineDiff = entry.Diff; + var diffFromAverage = entry.Diff - average; if (diffFromAverage < 0) { diffFromAverage = 0; } - int value = (int)(diffFromAverage / maxDiff * _contrast); + var value = (int)(diffFromAverage / maxDiff * _contrast); entry.Value = 255 - value; _logger.Debug("TimeSpreadCalculator.DoCalc() test time {0:HH:mm:ss.fff} line diff={1} value={2}", entry.Timestamp, lineDiff, value); diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs index 24f5dca7..4f4eaaed 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs @@ -14,7 +14,7 @@ internal partial class TimeSpreadingControl : UserControl private Bitmap _bitmap = new(1, 1); private int _displayHeight = 1; private readonly int _edgeOffset = (int)Win32.GetSystemMetricsForDpi(Win32.SM_CYVSCROLL); - private int _lastMouseY = 0; + private int _lastMouseY; private readonly object _monitor = new(); private int _rectHeight = 1; @@ -97,7 +97,7 @@ protected override void OnPaint(PaintEventArgs e) private SpreadEntry GetEntryForMouse(MouseEventArgs e) { List list = TimeSpreadCalc.DiffList; - int y = e.Y - _edgeOffset; + var y = e.Y - _edgeOffset; if (y < 0) { y = 0; @@ -157,7 +157,7 @@ private void TimeSpreadCalc_CalcDone(object sender, EventArgs e) } _bitmap = new Bitmap(rect.Width, rect.Height); - Graphics gfx = Graphics.FromImage(_bitmap); + var gfx = Graphics.FromImage(_bitmap); Brush bgBrush = new SolidBrush(BackColor); gfx.FillRectangle(bgBrush, rect); bgBrush.Dispose(); @@ -180,10 +180,10 @@ private void TimeSpreadCalc_CalcDone(object sender, EventArgs e) lock (list) { - for (int i = 0; i < list.Count; i += step) + for (var i = 0; i < list.Count; i += step) { SpreadEntry entry = list[i]; - int color = ReverseAlpha ? entry.Value : 255 - entry.Value; + var color = ReverseAlpha ? entry.Value : 255 - entry.Value; if (color > 255) { @@ -220,7 +220,7 @@ private void TimeSpreadCalc_StartCalc(object sender, EventArgs e) } //this.bmp = new Bitmap(rect.Width, rect.Height); - Graphics gfx = Graphics.FromImage(_bitmap); + var gfx = Graphics.FromImage(_bitmap); Brush bgBrush = new SolidBrush(BackColor); Brush fgBrush = new SolidBrush(ForeColor); @@ -297,7 +297,7 @@ private void TimeSpreadingControl_MouseMove(object sender, MouseEventArgs e) return; } _lastMouseY = e.Y; - string dts = entry.Timestamp.ToString("dd.MM.yyyy HH:mm:ss"); + var dts = entry.Timestamp.ToString("dd.MM.yyyy HH:mm:ss"); _toolTip.SetToolTip(this, "Line " + (entry.LineNum + 1) + "\n" + dts); } diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs index 5ed65d2c..bb5ac3c1 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs @@ -27,10 +27,7 @@ public class TimeSyncList public DateTime CurrentTimestamp { get; set; } - public int Count - { - get { return logWindowList.Count; } - } + public int Count => logWindowList.Count; #endregion @@ -54,6 +51,7 @@ public void RemoveWindow (LogWindow logWindow) { logWindowList.Remove(logWindow); } + OnWindowRemoved(); } @@ -90,10 +88,7 @@ public bool Contains (LogWindow logWindow) private void OnWindowRemoved () { - if (WindowRemoved != null) - { - WindowRemoved(this, new EventArgs()); - } + WindowRemoved?.Invoke(this, new EventArgs()); } #endregion diff --git a/src/LogExpert.UI/Dialogs/AboutBox.cs b/src/LogExpert.UI/Dialogs/AboutBox.cs index 129ff99b..632dd07c 100644 --- a/src/LogExpert.UI/Dialogs/AboutBox.cs +++ b/src/LogExpert.UI/Dialogs/AboutBox.cs @@ -31,7 +31,7 @@ public AboutBox() labelProductName.Text = AssemblyProduct; labelVersion.Text = AssemblyVersion; labelCopyright.Text = AssemblyCopyright; - string link = "https://github.com/LogExperts/LogExpert"; + var link = "https://github.com/LogExperts/LogExpert"; linkLabelURL.Links.Add(new LinkLabel.Link(0, link.Length, link)); LoadUsedComponents(); } @@ -40,7 +40,7 @@ public AboutBox() private void LoadUsedComponents() { - string json = File.ReadAllText($"{Application.StartupPath}files\\json\\usedComponents.json"); + var json = File.ReadAllText($"{Application.StartupPath}files\\json\\usedComponents.json"); var usedComponents = JsonConvert.DeserializeObject(json); usedComponents = usedComponents?.OrderBy(x => x.PackageId).ToArray(); usedComponentsDataGrid.DataSource = usedComponents; @@ -60,10 +60,10 @@ public string AssemblyTitle { get { - object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); + var attributes = _assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); if (attributes.Length > 0) { - AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; + var titleAttribute = (AssemblyTitleAttribute)attributes[0]; if (titleAttribute.Title != string.Empty) { return titleAttribute.Title; @@ -81,7 +81,7 @@ public string AssemblyVersion if (assembly.Version != null) { - string version = $"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}.{assembly.Version.Revision}"; + var version = $"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}.{assembly.Version.Revision}"; if (assembly.Version.Revision >= 9000) { version += " Testrelease"; @@ -99,7 +99,7 @@ public string AssemblyDescription { get { - object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); + var attributes = _assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); if (attributes.Length == 0) { @@ -113,7 +113,7 @@ public string AssemblyProduct { get { - object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false); + var attributes = _assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false); if (attributes.Length == 0) { return string.Empty; @@ -126,7 +126,7 @@ public string AssemblyCopyright { get { - object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + var attributes = _assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); if (attributes.Length == 0) { return string.Empty; @@ -141,7 +141,7 @@ public string AssemblyCopyright private void OnLinkLabelURLClicked(object sender, LinkLabelLinkClickedEventArgs e) { - string? target = string.Empty; + var target = string.Empty; if (e.Link != null) { diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs index eb79c2b7..6853a51e 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs @@ -138,7 +138,7 @@ public void SetColumnizer (ILogLineColumnizer columnizer) public void ResizeColumns () { // this.bookmarkDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - for (int i = 2; i < bookmarkDataGridView.ColumnCount; ++i) + for (var i = 2; i < bookmarkDataGridView.ColumnCount; ++i) { bookmarkDataGridView.AutoResizeColumn(i, DataGridViewAutoSizeColumnMode.DisplayedCells); } @@ -157,7 +157,7 @@ public void UpdateView () /// public void BookmarkTextChanged (Bookmark bookmark) { - int rowIndex = bookmarkDataGridView.CurrentCellAddress.Y; + var rowIndex = bookmarkDataGridView.CurrentCellAddress.Y; if (rowIndex == -1) { return; @@ -181,7 +181,7 @@ public void SelectBookmark (int lineNum) UpdateView(); } - int row = bookmarkData.GetBookmarkIndexForLine(lineNum); + var row = bookmarkData.GetBookmarkIndexForLine(lineNum); bookmarkDataGridView.CurrentCell = bookmarkDataGridView.Rows[row].Cells[0]; } } @@ -296,7 +296,7 @@ private void CommentPainting (BufferedDataGridView gridView, int rowIndex, DataG else { // _logger.logDebug("CellPaint No Focus"); - Color color = Color.FromArgb(255, 170, 170, 170); + var color = Color.FromArgb(255, 170, 170, 170); brush = new SolidBrush(color); } @@ -383,7 +383,7 @@ private void boomarkDataGridView_CellPainting (object sender, DataGridViewCellPa return; } - int lineNum = bookmarkData.Bookmarks[e.RowIndex].LineNum; + var lineNum = bookmarkData.Bookmarks[e.RowIndex].LineNum; // if (e.ColumnIndex == 1) // { @@ -415,14 +415,14 @@ private void OnBoomarkDataGridViewCellValueNeeded (object sender, DataGridViewCe } Bookmark bookmarkForLine = bookmarkData.Bookmarks[e.RowIndex]; - int lineNum = bookmarkForLine.LineNum; + var lineNum = bookmarkForLine.LineNum; if (e.ColumnIndex == 1) { e.Value = bookmarkForLine.Text?.Replace('\n', ' ').Replace('\r', ' '); } else { - int columnIndex = e.ColumnIndex > 1 ? e.ColumnIndex - 1 : e.ColumnIndex; + var columnIndex = e.ColumnIndex > 1 ? e.ColumnIndex - 1 : e.ColumnIndex; e.Value = logPaintContext.GetCellValue(lineNum, columnIndex); } } @@ -451,7 +451,7 @@ private void bookmarkGridView_KeyDown (object sender, KeyEventArgs e) if (bookmarkDataGridView.CurrentCellAddress.Y >= 0 && bookmarkDataGridView.CurrentCellAddress.Y < bookmarkData.Bookmarks.Count) { - int lineNum = bookmarkData.Bookmarks[bookmarkDataGridView.CurrentCellAddress.Y].LineNum; + var lineNum = bookmarkData.Bookmarks[bookmarkDataGridView.CurrentCellAddress.Y].LineNum; logView.SelectLogLine(lineNum); } @@ -495,7 +495,7 @@ private void bookmarkTextBox_TextChanged (object sender, EventArgs e) return; // ignore all changes done while the control is disabled } - int rowIndex = bookmarkDataGridView.CurrentCellAddress.Y; + var rowIndex = bookmarkDataGridView.CurrentCellAddress.Y; if (rowIndex == -1) { return; @@ -553,12 +553,12 @@ private void bookmarkDataGridView_CellDoubleClick (object sender, DataGridViewCe // Toggle bookmark when double-clicking on the first column if (e.ColumnIndex == 0 && e.RowIndex >= 0 && bookmarkDataGridView.CurrentRow != null) { - int index = bookmarkDataGridView.CurrentRow.Index; - int lineNum = bookmarkData.Bookmarks[bookmarkDataGridView.CurrentRow.Index].LineNum; + var index = bookmarkDataGridView.CurrentRow.Index; + var lineNum = bookmarkData.Bookmarks[bookmarkDataGridView.CurrentRow.Index].LineNum; bookmarkData.ToggleBookmark(lineNum); // we don't ask for confirmation if the bookmark has an associated comment... - int boomarkCount = bookmarkData.Bookmarks.Count; + var boomarkCount = bookmarkData.Bookmarks.Count; bookmarkDataGridView.RowCount = boomarkCount; if (index < boomarkCount) @@ -595,7 +595,7 @@ private void bookmarkDataGridView_CellDoubleClick (object sender, DataGridViewCe if (bookmarkDataGridView.CurrentRow != null && e.RowIndex >= 0) { - int lineNum = bookmarkData.Bookmarks[bookmarkDataGridView.CurrentRow.Index].LineNum; + var lineNum = bookmarkData.Bookmarks[bookmarkDataGridView.CurrentRow.Index].LineNum; logView.SelectAndEnsureVisible(lineNum, true); } } @@ -634,7 +634,7 @@ private void BookmarkWindow_ClientSizeChanged (object sender, EventArgs e) if (Width > Height) { splitContainer1.Orientation = Orientation.Vertical; - int distance = Width - 200; + var distance = Width - 200; splitContainer1.SplitterDistance = distance > splitContainer1.Panel1MinSize ? distance : splitContainer1.Panel1MinSize; @@ -642,7 +642,7 @@ private void BookmarkWindow_ClientSizeChanged (object sender, EventArgs e) else { splitContainer1.Orientation = Orientation.Horizontal; - int distance = Height - 200; + var distance = Height - 200; splitContainer1.SplitterDistance = distance > splitContainer1.Panel1MinSize ? distance : splitContainer1.Panel1MinSize; diff --git a/src/LogExpert.UI/Dialogs/ChooseIconDlg.cs b/src/LogExpert.UI/Dialogs/ChooseIconDlg.cs index b88fd6c4..ddce747d 100644 --- a/src/LogExpert.UI/Dialogs/ChooseIconDlg.cs +++ b/src/LogExpert.UI/Dialogs/ChooseIconDlg.cs @@ -52,7 +52,7 @@ private void FillIconList() imageList.ImageSize = icons[1, 0].Size; iconListView.LargeImageList = imageList; - for (int i = 0; i < icons.GetLength(1); ++i) + for (var i = 0; i < icons.GetLength(1); ++i) { imageList.Images.Add(icons[1, i]); ListViewItem item = new() diff --git a/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs b/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs index 9d01c556..a772597b 100644 --- a/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs +++ b/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs @@ -37,12 +37,12 @@ internal class Eminus : IContextMenuEntry, ILogExpertPluginConfigurator private XmlDocument BuildParam(ILogLine line) { - string fullLogLine = line.FullLine; + var fullLogLine = line.FullLine; // no Java stacktrace but some special logging of our applications at work: if (fullLogLine.Contains("Exception of type", StringComparison.CurrentCulture) || fullLogLine.Contains("Nested:", StringComparison.CurrentCulture)) { - int pos = fullLogLine.IndexOf("created in "); + var pos = fullLogLine.IndexOf("created in "); if (pos == -1) { @@ -50,14 +50,14 @@ private XmlDocument BuildParam(ILogLine line) } pos += "created in ".Length; - int endPos = fullLogLine.IndexOf(DOT, pos); + var endPos = fullLogLine.IndexOf(DOT, pos); if (endPos == -1) { return null; } - string className = fullLogLine[pos..endPos]; + var className = fullLogLine[pos..endPos]; pos = fullLogLine.IndexOf(DOUBLE_DOT, pos); if (pos == -1) @@ -65,19 +65,19 @@ private XmlDocument BuildParam(ILogLine line) return null; } - string lineNum = fullLogLine[(pos + 1)..]; + var lineNum = fullLogLine[(pos + 1)..]; XmlDocument doc = BuildXmlDocument(className, lineNum); return doc; } if (fullLogLine.Contains("at ", StringComparison.CurrentCulture)) { - string str = fullLogLine.Trim(); + var str = fullLogLine.Trim(); string className = null; string lineNum = null; - int pos = str.IndexOf("at ") + 3; + var pos = str.IndexOf("at ") + 3; str = str[pos..]; // remove 'at ' - int idx = str.IndexOfAny(['(', '$', '<']); + var idx = str.IndexOfAny(['(', '$', '<']); if (idx != -1) { @@ -215,7 +215,7 @@ public void MenuSelected(int logLinesCount, ILogLineColumnizer columnizer, ILogL public void LoadConfig(string configDir) { - string configPath = configDir + CFG_FILE_NAME; + var configPath = configDir + CFG_FILE_NAME; FileInfo fileInfo = new(configDir + Path.DirectorySeparatorChar + CFG_FILE_NAME); diff --git a/src/LogExpert.UI/Dialogs/FilterColumnChooser.cs b/src/LogExpert.UI/Dialogs/FilterColumnChooser.cs index eb99587b..4a62edb8 100644 --- a/src/LogExpert.UI/Dialogs/FilterColumnChooser.cs +++ b/src/LogExpert.UI/Dialogs/FilterColumnChooser.cs @@ -38,10 +38,10 @@ public FilterColumnChooser(FilterParams filterParams) private void Init() { - int count = _columnizer.GetColumnCount(); - string[] names = _columnizer.GetColumnNames(); + var count = _columnizer.GetColumnCount(); + var names = _columnizer.GetColumnNames(); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) { columnListBox.Items.Add(names[i], _filterParams.ColumnList.Contains(i)); } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.cs index f0261e74..a23c253a 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.cs @@ -74,7 +74,7 @@ private void OnFilterComboBoxSelectedIndexChanged(object sender, EventArgs e) { ILogLineColumnizer col = _columnizerList[filterComboBox.SelectedIndex]; SelectedColumnizer = col; - string description = col.GetDescription(); + var description = col.GetDescription(); description += "\r\nSupports timeshift: " + (SelectedColumnizer.IsTimeshiftImplemented() ? "Yes" : "No"); commentTextBox.Text = description; configButton.Enabled = SelectedColumnizer is IColumnizerConfigurator; @@ -86,7 +86,7 @@ private void OnConfigButtonClick(object sender, EventArgs e) { if (SelectedColumnizer is IColumnizerConfigurator configurator) { - string configDir = ConfigManager.ConfigDir; + var configDir = ConfigManager.ConfigDir; if (ConfigManager.Settings.Preferences.PortableMode) { diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs index 6ccfcb29..1b7a06a0 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs @@ -101,7 +101,7 @@ private void OnBtnCopyGroupClick(object sender, EventArgs e) { if (comboBoxGroups.SelectedIndex >= 0 && comboBoxGroups.SelectedIndex < HighlightGroupList.Count) { - HighlightGroup newGroup = (HighlightGroup)HighlightGroupList[comboBoxGroups.SelectedIndex].Clone(); + var newGroup = (HighlightGroup)HighlightGroupList[comboBoxGroups.SelectedIndex].Clone(); newGroup.GroupName = "Copy of " + newGroup.GroupName; HighlightGroupList.Add(newGroup); @@ -132,7 +132,7 @@ private void OnBtnDelGroupClick(object sender, EventArgs e) if (comboBoxGroups.SelectedIndex >= 0 && comboBoxGroups.SelectedIndex < HighlightGroupList.Count) { - int index = comboBoxGroups.SelectedIndex; + var index = comboBoxGroups.SelectedIndex; HighlightGroupList.RemoveAt(comboBoxGroups.SelectedIndex); FillGroupComboBox(); if (index < HighlightGroupList.Count) @@ -166,7 +166,7 @@ private void OnBtnExportGroupClick(object sender, EventArgs e) private void OnBtnGroupDownClick(object sender, EventArgs e) { - int index = comboBoxGroups.SelectedIndex; + var index = comboBoxGroups.SelectedIndex; if (index > -1 && index < _highlightGroupList.Count - 1) { _highlightGroupList.Reverse(index, 2); @@ -178,7 +178,7 @@ private void OnBtnGroupDownClick(object sender, EventArgs e) private void OnBtnGroupUpClick(object sender, EventArgs e) { - int index = comboBoxGroups.SelectedIndex; + var index = comboBoxGroups.SelectedIndex; if (index > 0) { _highlightGroupList.Reverse(index - 1, 2); @@ -240,11 +240,11 @@ private void OnBtnImportGroupClick(object sender, EventArgs e) private void OnBtnMoveDownClick(object sender, EventArgs e) { - int index = listBoxHighlight.SelectedIndex; + var index = listBoxHighlight.SelectedIndex; if (index > -1 && index < listBoxHighlight.Items.Count - 1) { - object item = listBoxHighlight.SelectedItem; + var item = listBoxHighlight.SelectedItem; listBoxHighlight.Items.RemoveAt(index); listBoxHighlight.Items.Insert(index + 1, item); listBoxHighlight.SelectedIndex = index + 1; @@ -254,10 +254,10 @@ private void OnBtnMoveDownClick(object sender, EventArgs e) private void OnBtnMoveUpClick(object sender, EventArgs e) { - int index = listBoxHighlight.SelectedIndex; + var index = listBoxHighlight.SelectedIndex; if (index > 0) { - object item = listBoxHighlight.SelectedItem; + var item = listBoxHighlight.SelectedItem; listBoxHighlight.Items.RemoveAt(index); // will also clear the selection listBoxHighlight.Items.Insert(index - 1, item); listBoxHighlight.SelectedIndex = index - 1; // restore the selection @@ -269,9 +269,9 @@ private void OnBtnNewGroupClick(object sender, EventArgs e) { // Propose a unique name const string baseName = "New group"; - string name = baseName; - bool uniqueName = false; - int i = 1; + var name = baseName; + var uniqueName = false; + var i = 1; while (!uniqueName) { uniqueName = HighlightGroupList.FindIndex(delegate (HighlightGroup g) { return g.GroupName == name; }) < 0; @@ -370,12 +370,12 @@ private void OnDeleteButtonClick(object sender, EventArgs e) { if (listBoxHighlight.SelectedIndex >= 0) { - int removeIndex = listBoxHighlight.SelectedIndex; + var removeIndex = listBoxHighlight.SelectedIndex; _currentGroup.HighlightEntryList.RemoveAt(removeIndex); listBoxHighlight.Items.RemoveAt(removeIndex); // Select previous (or first if none before) - int nextSelectIndex = removeIndex; + var nextSelectIndex = removeIndex; if (nextSelectIndex >= listBoxHighlight.Items.Count) { nextSelectIndex--; // if last item was removed, go one up @@ -412,7 +412,7 @@ private void OnHighlightListBoxDrawItem(object sender, DrawItemEventArgs e) e.DrawBackground(); if (e.Index >= 0) { - HighlightEntry entry = (HighlightEntry)listBoxHighlight.Items[e.Index]; + var entry = (HighlightEntry)listBoxHighlight.Items[e.Index]; Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); if ((e.State & DrawItemState.Selected) != DrawItemState.Selected) @@ -519,7 +519,7 @@ private void ChooseColor(ColorComboBox comboBox) private void Dirty() { - int index = listBoxHighlight.SelectedIndex; + var index = listBoxHighlight.SelectedIndex; if (index > -1) { btnApply.Enabled = true; @@ -574,7 +574,7 @@ private void InitData() FillGroupComboBox(); _currentGroup = null; - string groupToSelect = PreSelectedGroupName; + var groupToSelect = PreSelectedGroupName; if (string.IsNullOrEmpty(groupToSelect)) { groupToSelect = def; @@ -599,10 +599,10 @@ private void InitData() private void ReEvaluateGroupButtonStates() { // Refresh button states based on the selection in the combobox - bool atLeastOneSelected = comboBoxGroups.SelectedItem != null; - bool moreThanOne = comboBoxGroups.Items.Count > 1; - bool firstSelected = atLeastOneSelected && comboBoxGroups.SelectedIndex == 0; - bool lastSelected = atLeastOneSelected && comboBoxGroups.SelectedIndex == comboBoxGroups.Items.Count - 1; + var atLeastOneSelected = comboBoxGroups.SelectedItem != null; + var moreThanOne = comboBoxGroups.Items.Count > 1; + var firstSelected = atLeastOneSelected && comboBoxGroups.SelectedIndex == 0; + var lastSelected = atLeastOneSelected && comboBoxGroups.SelectedIndex == comboBoxGroups.Items.Count - 1; btnDeleteGroup.Enabled = atLeastOneSelected; btnCopyGroup.Enabled = atLeastOneSelected; @@ -613,10 +613,10 @@ private void ReEvaluateGroupButtonStates() private void ReEvaluateHighlightButtonStates() { // Refresh button states based on the selection in the combobox - bool atLeastOneSelected = listBoxHighlight.SelectedItem != null; - bool moreThanOne = listBoxHighlight.Items.Count > 1; - bool firstSelected = atLeastOneSelected && listBoxHighlight.SelectedIndex == 0; - bool lastSelected = atLeastOneSelected && listBoxHighlight.SelectedIndex == listBoxHighlight.Items.Count - 1; + var atLeastOneSelected = listBoxHighlight.SelectedItem != null; + var moreThanOne = listBoxHighlight.Items.Count > 1; + var firstSelected = atLeastOneSelected && listBoxHighlight.SelectedIndex == 0; + var lastSelected = atLeastOneSelected && listBoxHighlight.SelectedIndex == listBoxHighlight.Items.Count - 1; btnDelete.Enabled = atLeastOneSelected; btnMoveUp.Enabled = atLeastOneSelected && moreThanOne && !firstSelected; @@ -629,7 +629,7 @@ private void SaveEntry() { CheckRegex(); - HighlightEntry entry = (HighlightEntry)listBoxHighlight.SelectedItem; + var entry = (HighlightEntry)listBoxHighlight.SelectedItem; entry.ForegroundColor = (Color)colorBoxForeground.SelectedItem; entry.BackgroundColor = (Color)colorBoxBackground.SelectedItem; @@ -679,7 +679,7 @@ private void SelectGroup(int index) private void StartEditEntry() { - HighlightEntry entry = (HighlightEntry)listBoxHighlight.SelectedItem; + var entry = (HighlightEntry)listBoxHighlight.SelectedItem; if (entry != null) { diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs index fba25456..55e54962 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs @@ -90,13 +90,13 @@ public LogTabWindow (string[] fileNames, int instanceNumber, bool showInstanceNu Rectangle led = new(0, 0, 8, 2); - for (int i = 0; i < _leds.Length; ++i) + for (var i = 0; i < _leds.Length; ++i) { _leds[i] = led; led.Offset(0, led.Height + 0); } - int grayAlpha = 50; + var grayAlpha = 50; _ledBrushes[0] = new SolidBrush(Color.FromArgb(255, 220, 0, 0)); _ledBrushes[1] = new SolidBrush(Color.FromArgb(255, 220, 220, 0)); @@ -124,7 +124,7 @@ public LogTabWindow (string[] fileNames, int instanceNumber, bool showInstanceNu host.Padding = new Padding(20, 0, 0, 0); host.BackColor = Color.FromKnownColor(KnownColor.Transparent); - int index = buttonToolStrip.Items.IndexOfKey("toolStripButtonTail"); + var index = buttonToolStrip.Items.IndexOfKey("toolStripButtonTail"); toolStripEncodingASCIIItem.Text = Encoding.ASCII.HeaderName; toolStripEncodingANSIItem.Text = Encoding.Default.HeaderName; @@ -142,10 +142,10 @@ public LogTabWindow (string[] fileNames, int instanceNumber, bool showInstanceNu loadProgessBar.Visible = false; // get a reference to the current assembly - Assembly a = Assembly.GetExecutingAssembly(); + var a = Assembly.GetExecutingAssembly(); // get a list of resource names from the manifest - string[] resNames = a.GetManifestResourceNames(); + var resNames = a.GetManifestResourceNames(); Bitmap bmp = Resources.Resources.Deceased; _deadIcon = Icon.FromHandle(bmp.GetHicon()); diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs index b515cdcb..885879cd 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs @@ -14,7 +14,8 @@ using WeifenLuo.WinFormsUI.Docking; namespace LogExpert.UI.Controls.LogTabWindow; -partial class LogTabWindow + +public partial class LogTabWindow { #region Events handler @@ -44,7 +45,7 @@ private void OnLogTabWindowLoad (object sender, EventArgs e) { List tmpList = ObjectClone.Clone(ConfigManager.Settings.lastOpenFilesList); - foreach (string name in tmpList) + foreach (var name in tmpList) { if (string.IsNullOrEmpty(name) == false) { @@ -126,7 +127,7 @@ private void OnHistoryItemClicked (object sender, ToolStripItemClickedEventArgs private void OnLogWindowDisposed (object sender, EventArgs e) { - LogWindow.LogWindow logWindow = sender as LogWindow.LogWindow; + var logWindow = sender as LogWindow.LogWindow; if (sender == CurrentLogWindow) { @@ -218,7 +219,7 @@ private void OnGoToLineToolStripMenuItemClick (object sender, EventArgs e) DialogResult res = dlg.ShowDialog(); if (res == DialogResult.OK) { - int line = dlg.Line - 1; + var line = dlg.Line - 1; if (line >= 0) { CurrentLogWindow.GotoLine(line); @@ -244,9 +245,9 @@ private void OnOpenToolStripMenuItemClick (object sender, EventArgs e) private void OnLogTabWindowDragEnter (object sender, DragEventArgs e) { #if DEBUG - string[] formats = e.Data.GetFormats(); - string s = "Dragging something over LogExpert. Formats: "; - foreach (string format in formats) + var formats = e.Data.GetFormats(); + var s = "Dragging something over LogExpert. Formats: "; + foreach (var format in formats) { s += format; s += " , "; @@ -271,9 +272,9 @@ private void OnLogWindowDragOver (object sender, DragEventArgs e) private void OnLogWindowDragDrop (object sender, DragEventArgs e) { #if DEBUG - string[] formats = e.Data.GetFormats(); - string s = "Dropped formats: "; - foreach (string format in formats) + var formats = e.Data.GetFormats(); + var s = "Dropped formats: "; + foreach (var format in formats) { s += format; s += " , "; @@ -284,7 +285,7 @@ private void OnLogWindowDragDrop (object sender, DragEventArgs e) if (e.Data.GetDataPresent(DataFormats.FileDrop)) { - object o = e.Data.GetData(DataFormats.FileDrop); + var o = e.Data.GetData(DataFormats.FileDrop); if (o is string[] names) { LoadFiles(names, (e.KeyState & 4) == 4); // (shift pressed?) @@ -416,7 +417,7 @@ private void OnFileSizeChanged (object sender, LogEventArgs e) { if (sender.GetType().IsAssignableFrom(typeof(LogWindow.LogWindow))) { - int diff = e.LineCount - e.PrevLineCount; + var diff = e.LineCount - e.PrevLineCount; if (diff < 0) { return; @@ -488,7 +489,7 @@ private void OnTailFollowed (object sender, EventArgs e) { if (dockPanel.ActiveContent == sender) { - LogWindowData data = ((LogWindow.LogWindow)sender).Tag as LogWindowData; + var data = ((LogWindow.LogWindow)sender).Tag as LogWindowData; data.dirty = false; Icon icon = GetIcon(data.diffSum, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); @@ -500,7 +501,7 @@ private void OnLogWindowSyncModeChanged (object sender, SyncModeEventArgs e) { if (!Disposing) { - LogWindowData data = ((LogWindow.LogWindow)sender).Tag as LogWindowData; + var data = ((LogWindow.LogWindow)sender).Tag as LogWindowData; data.syncMode = e.IsTimeSynced ? 1 : 0; Icon icon = GetIcon(data.diffSum, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); @@ -555,7 +556,7 @@ private void OnReloadToolStripMenuItemClick (object sender, EventArgs e) { if (CurrentLogWindow != null) { - LogWindowData data = CurrentLogWindow.Tag as LogWindowData; + var data = CurrentLogWindow.Tag as LogWindowData; Icon icon = GetIcon(0, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), CurrentLogWindow, icon); CurrentLogWindow.Reload(); @@ -692,9 +693,9 @@ private void OnCloseAllTabsToolStripMenuItemClick (object sender, EventArgs e) private void OnTabColorToolStripMenuItemClick (object sender, EventArgs e) { - LogWindow.LogWindow logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; + var logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; - LogWindowData data = logWindow.Tag as LogWindowData; + var data = logWindow.Tag as LogWindowData; if (data == null) { @@ -746,15 +747,15 @@ private void OnSaveProjectToolStripMenuItemClick (object sender, EventArgs e) if (dlg.ShowDialog() == DialogResult.OK) { - string fileName = dlg.FileName; + var fileName = dlg.FileName; List fileNames = []; lock (_logWindowList) { foreach (DockContent content in dockPanel.Contents) { - LogWindow.LogWindow logWindow = content as LogWindow.LogWindow; - string persistenceFileName = logWindow?.SavePersistenceData(true); + var logWindow = content as LogWindow.LogWindow; + var persistenceFileName = logWindow?.SavePersistenceData(true); if (persistenceFileName != null) { fileNames.Add(persistenceFileName); @@ -777,7 +778,7 @@ private void OnLoadProjectToolStripMenuItemClick (object sender, EventArgs e) if (dlg.ShowDialog() == DialogResult.OK) { - string projectFileName = dlg.FileName; + var projectFileName = dlg.FileName; LoadProject(projectFileName, true); } } @@ -792,13 +793,13 @@ private void OnToolStripButtonBubblesClick (object sender, EventArgs e) private void OnCopyPathToClipboardToolStripMenuItemClick (object sender, EventArgs e) { - LogWindow.LogWindow logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; + var logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; Clipboard.SetText(logWindow.Title); } private void OnFindInExplorerToolStripMenuItemClick (object sender, EventArgs e) { - LogWindow.LogWindow logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; + var logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; Process explorer = new(); explorer.StartInfo.FileName = "explorer.exe"; diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs index d264fbe3..a324dec3 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs @@ -36,7 +36,7 @@ public LogWindow.LogWindow AddFilterTab (FilterPipe pipe, string title, ILogLine ); tip.AutomaticDelay = 10; tip.AutoPopDelay = 5000; - LogWindowData data = logWin.Tag as LogWindowData; + var data = logWin.Tag as LogWindowData; data.toolTip = tip; } @@ -50,7 +50,7 @@ public LogWindow.LogWindow AddFileTabDeferred (string givenFileName, bool isTemp public LogWindow.LogWindow AddFileTab (string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer, bool doNotAddToDockPanel = false) { - string logFileName = FindFilenameForSettings(givenFileName); + var logFileName = FindFilenameForSettings(givenFileName); LogWindow.LogWindow win = FindWindowForFile(logFileName); if (win != null) { @@ -86,7 +86,7 @@ public LogWindow.LogWindow AddFileTab (string givenFileName, bool isTempFile, st AddToFileHistory(givenFileName); } - LogWindowData data = logWindow.Tag as LogWindowData; + var data = logWindow.Tag as LogWindowData; data.color = _defaultTabColor; SetTabColor(logWindow, _defaultTabColor); //data.tabPage.BorderColor = this.defaultTabBorderColor; @@ -183,7 +183,7 @@ public ILogLineColumnizer GetColumnizerHistoryEntry (string fileName) public void SwitchTab (bool shiftPressed) { - int index = dockPanel.Contents.IndexOf(dockPanel.ActiveContent); + var index = dockPanel.Contents.IndexOf(dockPanel.ActiveContent); if (shiftPressed) { index--; @@ -303,7 +303,7 @@ public void SetForeground () // called from LogWindow when follow tail was changed public void FollowTailChanged (LogWindow.LogWindow logWindow, bool isEnabled, bool offByTrigger) { - LogWindowData data = logWindow.Tag as LogWindowData; + var data = logWindow.Tag as LogWindowData; if (data == null) { return; diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs index 03035118..0d5308c7 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs @@ -273,13 +273,13 @@ private void FillColumnizerForToolsList() private void FillColumnizerForToolsList(ComboBox comboBox, string columnizerName) { - int selIndex = 0; + var selIndex = 0; comboBox.Items.Clear(); IList columnizers = PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers; foreach (ILogLineColumnizer columnizer in columnizers) { - int index = comboBox.Items.Add(columnizer.GetName()); + var index = comboBox.Items.Add(columnizer.GetName()); if (columnizer.GetName().Equals(columnizerName)) { selIndex = index; @@ -296,10 +296,10 @@ private void FillColumnizerList() { dataGridViewColumnizer.Rows.Clear(); - DataGridViewComboBoxColumn comboColumn = (DataGridViewComboBoxColumn)dataGridViewColumnizer.Columns[1]; + var comboColumn = (DataGridViewComboBoxColumn)dataGridViewColumnizer.Columns[1]; comboColumn.Items.Clear(); - DataGridViewTextBoxColumn textColumn = (DataGridViewTextBoxColumn)dataGridViewColumnizer.Columns[0]; + var textColumn = (DataGridViewTextBoxColumn)dataGridViewColumnizer.Columns[0]; IList columnizers = PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers; @@ -330,11 +330,11 @@ private void FillColumnizerList() dataGridViewColumnizer.Rows.Add(row); } - int count = dataGridViewColumnizer.RowCount; + var count = dataGridViewColumnizer.RowCount; if (count > 0 && !dataGridViewColumnizer.Rows[count - 1].IsNewRow) { - DataGridViewComboBoxCell comboCell = (DataGridViewComboBoxCell)dataGridViewColumnizer.Rows[count - 1].Cells[1]; + var comboCell = (DataGridViewComboBoxCell)dataGridViewColumnizer.Rows[count - 1].Cells[1]; comboCell.Value = comboCell.Items[0]; } } @@ -343,11 +343,11 @@ private void FillHighlightMaskList() { dataGridViewHighlightMask.Rows.Clear(); - DataGridViewComboBoxColumn comboColumn = (DataGridViewComboBoxColumn)dataGridViewHighlightMask.Columns[1]; + var comboColumn = (DataGridViewComboBoxColumn)dataGridViewHighlightMask.Columns[1]; comboColumn.Items.Clear(); //TODO Remove if not necessary - DataGridViewTextBoxColumn textColumn = (DataGridViewTextBoxColumn)dataGridViewHighlightMask.Columns[0]; + var textColumn = (DataGridViewTextBoxColumn)dataGridViewHighlightMask.Columns[0]; foreach (HighlightGroup group in (IList)_logTabWin.HighlightGroupList) { @@ -376,11 +376,11 @@ private void FillHighlightMaskList() dataGridViewHighlightMask.Rows.Add(row); } - int count = dataGridViewHighlightMask.RowCount; + var count = dataGridViewHighlightMask.RowCount; if (count > 0 && !dataGridViewHighlightMask.Rows[count - 1].IsNewRow) { - DataGridViewComboBoxCell comboCell = + var comboCell = (DataGridViewComboBoxCell)dataGridViewHighlightMask.Rows[count - 1].Cells[1]; comboCell.Value = comboCell.Items[0]; } @@ -518,7 +518,7 @@ private void GetToolListBoxData() GetCurrentToolValues(); Preferences.toolEntries.Clear(); - for (int i = 0; i < listBoxTools.Items.Count; ++i) + for (var i = 0; i < listBoxTools.Items.Count; ++i) { Preferences.toolEntries.Add(listBoxTools.Items[i] as ToolEntry); (listBoxTools.Items[i] as ToolEntry).isFavourite = listBoxTools.GetItemChecked(i); @@ -701,7 +701,7 @@ private void OnBtnArgClick(object sender, EventArgs e) //TODO Remove or refactor this function private void OnDataGridViewColumnizerRowsAdded(object sender, DataGridViewRowsAddedEventArgs e) { - DataGridViewComboBoxCell comboCell = (DataGridViewComboBoxCell)dataGridViewColumnizer.Rows[e.RowIndex].Cells[1]; + var comboCell = (DataGridViewComboBoxCell)dataGridViewColumnizer.Rows[e.RowIndex].Cells[1]; if (comboCell.Items.Count > 0) { // comboCell.Value = comboCell.Items[0]; @@ -712,7 +712,7 @@ private void OnBtnDeleteClick(object sender, EventArgs e) { if (dataGridViewColumnizer.CurrentRow != null && !dataGridViewColumnizer.CurrentRow.IsNewRow) { - int index = dataGridViewColumnizer.CurrentRow.Index; + var index = dataGridViewColumnizer.CurrentRow.Index; dataGridViewColumnizer.EndEdit(); dataGridViewColumnizer.Rows.RemoveAt(index); } @@ -763,7 +763,7 @@ private void OnListBoxPluginSelectedIndexChanged(object sender, EventArgs e) { _selectedPlugin?.HideConfigForm(); - object o = listBoxPlugin.SelectedItem; + var o = listBoxPlugin.SelectedItem; if (o != null) { @@ -883,12 +883,12 @@ private void OnListBoxToolSelectedIndexChanged(object sender, EventArgs e) private void OnBtnToolUpClick(object sender, EventArgs e) { - int i = listBoxTools.SelectedIndex; + var i = listBoxTools.SelectedIndex; if (i > 0) { - bool isChecked = listBoxTools.GetItemChecked(i); - object item = listBoxTools.Items[i]; + var isChecked = listBoxTools.GetItemChecked(i); + var item = listBoxTools.Items[i]; listBoxTools.Items.RemoveAt(i); i--; listBoxTools.Items.Insert(i, item); @@ -899,12 +899,12 @@ private void OnBtnToolUpClick(object sender, EventArgs e) private void OnBtnToolDownClick(object sender, EventArgs e) { - int i = listBoxTools.SelectedIndex; + var i = listBoxTools.SelectedIndex; if (i < listBoxTools.Items.Count - 1) { - bool isChecked = listBoxTools.GetItemChecked(i); - object item = listBoxTools.Items[i]; + var isChecked = listBoxTools.GetItemChecked(i); + var item = listBoxTools.Items[i]; listBoxTools.Items.RemoveAt(i); i++; listBoxTools.Items.Insert(i, item); @@ -921,7 +921,7 @@ private void OnBtnToolAddClick(object sender, EventArgs e) private void OnToolDeleteButtonClick(object sender, EventArgs e) { - int i = listBoxTools.SelectedIndex; + var i = listBoxTools.SelectedIndex; if (i < listBoxTools.Items.Count && i >= 0) { @@ -944,7 +944,7 @@ private void OnBtnIconClick(object sender, EventArgs e) { if (_selectedTool != null) { - string iconFile = _selectedTool.iconFile; + var iconFile = _selectedTool.iconFile; if (Util.IsNullOrSpaces(iconFile)) { @@ -974,7 +974,7 @@ private void OnBtnWorkingDirClick(object sender, EventArgs e) private void OnMultiFilePatternTextChanged(object sender, EventArgs e) { - string pattern = textBoxMultifilePattern.Text; + var pattern = textBoxMultifilePattern.Text; upDownMultifileDays.Enabled = pattern.Contains("$D"); } diff --git a/src/LogExpert.UI/Dialogs/OpenUriDialog.cs b/src/LogExpert.UI/Dialogs/OpenUriDialog.cs index fc079883..290a2471 100644 --- a/src/LogExpert.UI/Dialogs/OpenUriDialog.cs +++ b/src/LogExpert.UI/Dialogs/OpenUriDialog.cs @@ -39,7 +39,7 @@ private void OnOpenUriDialogLoad(object sender, EventArgs e) if (UriHistory != null) { cmbUri.Items.Clear(); - foreach (string uri in UriHistory) + foreach (var uri in UriHistory) { cmbUri.Items.Add(uri); } @@ -50,7 +50,7 @@ private void OnBtnOkClick(object sender, EventArgs e) { UriHistory = []; - foreach (object item in cmbUri.Items) + foreach (var item in cmbUri.Items) { UriHistory.Add(item.ToString()); } diff --git a/src/LogExpert.UI/Dialogs/ParamRequesterDialog.cs b/src/LogExpert.UI/Dialogs/ParamRequesterDialog.cs index 8953650d..26d38846 100644 --- a/src/LogExpert.UI/Dialogs/ParamRequesterDialog.cs +++ b/src/LogExpert.UI/Dialogs/ParamRequesterDialog.cs @@ -44,7 +44,7 @@ private void ParamRequesterDialog_Shown(object sender, EventArgs e) if (Values != null) { - foreach (string value in Values) + foreach (var value in Values) { comboBoxValue.Items.Add(value); } diff --git a/src/LogExpert.UI/Dialogs/RegexHelperDialog.cs b/src/LogExpert.UI/Dialogs/RegexHelperDialog.cs index 36c2749a..d564884b 100644 --- a/src/LogExpert.UI/Dialogs/RegexHelperDialog.cs +++ b/src/LogExpert.UI/Dialogs/RegexHelperDialog.cs @@ -108,7 +108,7 @@ private void OnCaseSensitiveCheckBoxCheckedChanged(object sender, EventArgs e) private void OnButtonOkClick(object sender, EventArgs e) { - string text = comboBoxRegex.Text; + var text = comboBoxRegex.Text; comboBoxRegex.Items.Remove(text); comboBoxRegex.Items.Insert(0, text); diff --git a/src/LogExpert.UI/Dialogs/SearchDialog.cs b/src/LogExpert.UI/Dialogs/SearchDialog.cs index b74ee792..e4542dc5 100644 --- a/src/LogExpert.UI/Dialogs/SearchDialog.cs +++ b/src/LogExpert.UI/Dialogs/SearchDialog.cs @@ -61,7 +61,7 @@ private void OnSearchDialogLoad(object? sender, EventArgs e) checkBoxRegex.Checked = SearchParams.IsRegex; checkBoxCaseSensitive.Checked = SearchParams.IsCaseSensitive; - foreach (string item in SearchParams.HistoryList) + foreach (var item in SearchParams.HistoryList) { comboBoxSearchFor.Items.Add(item); } diff --git a/src/LogExpert.UI/Dialogs/ToolArgsDialog.cs b/src/LogExpert.UI/Dialogs/ToolArgsDialog.cs index da95f186..60271fdf 100644 --- a/src/LogExpert.UI/Dialogs/ToolArgsDialog.cs +++ b/src/LogExpert.UI/Dialogs/ToolArgsDialog.cs @@ -81,7 +81,7 @@ private void OnButtonTestClick(object sender, EventArgs e) if (line != null && info != null) { ArgParser parser = new(textBoxArguments.Text); - string args = parser.BuildArgs(line, logTabWin.CurrentLogWindow.GetRealLineNum() + 1, info, this); + var args = parser.BuildArgs(line, logTabWin.CurrentLogWindow.GetRealLineNum() + 1, info, this); labelTestResult.Text = args; } } diff --git a/src/LogExpert.UI/Entities/ArgParser.cs b/src/LogExpert.UI/Entities/ArgParser.cs index 3b187342..91b7b20c 100644 --- a/src/LogExpert.UI/Entities/ArgParser.cs +++ b/src/LogExpert.UI/Entities/ArgParser.cs @@ -35,11 +35,11 @@ public string BuildArgs(ILogLine logLine, int lineNum, ILogFileInfo logFileInfo, builder.Replace("%N", logFileInfo.FileName); builder.Replace("%F", logFileInfo.FullName); builder.Replace("%E", Util.GetExtension(logFileInfo.FileName)); - string stripped = Util.StripExtension(logFileInfo.FileName); + var stripped = Util.StripExtension(logFileInfo.FileName); builder.Replace("%M", stripped); builder.Replace("%URI", logFileInfo.Uri.AbsoluteUri); - string user = logFileInfo.Uri.UserInfo; + var user = logFileInfo.Uri.UserInfo; if (user.Contains(":")) { user = user.Substring(0, user.IndexOf(':')); @@ -49,7 +49,7 @@ public string BuildArgs(ILogLine logLine, int lineNum, ILogFileInfo logFileInfo, builder.Replace("%H", logFileInfo.Uri.Host); builder.Replace("%T", logFileInfo.Uri.Port.ToString()); - int sPos = 0; + var sPos = 0; string reg; string replace; do @@ -58,19 +58,19 @@ public string BuildArgs(ILogLine logLine, int lineNum, ILogFileInfo logFileInfo, replace = GetNextGroup(builder, ref sPos); if (reg != null && replace != null) { - string result = Regex.Replace(logLine.FullLine, reg, replace); + var result = Regex.Replace(logLine.FullLine, reg, replace); builder.Insert(sPos, result); } } while (replace != null); - int i = 0; + var i = 0; while (i < builder.Length) { // ?"Pinpad-type?"(thales,dione) if (builder[i] == '?') { - int end = i; - string ask = "Parameter"; + var end = i; + var ask = "Parameter"; if (builder[i + 1] == '"') { end = builder.ToString().IndexOf('"', i + 2); @@ -83,12 +83,12 @@ public string BuildArgs(ILogLine logLine, int lineNum, ILogFileInfo logFileInfo, string[] values = null; if (builder[end + 1] == '(') { - int end2 = builder.ToString().IndexOf(')'); + var end2 = builder.ToString().IndexOf(')'); if (end2 == -1) { end2 = builder.Length - 1; } - string valueStr = builder.ToString().Substring(end + 2, end2 - end - 2); + var valueStr = builder.ToString().Substring(end + 2, end2 - end - 2); values = valueStr.Split(new char[] { ',' }, StringSplitOptions.None); end = end2; } @@ -119,14 +119,13 @@ public string BuildArgs(ILogLine logLine, int lineNum, ILogFileInfo logFileInfo, private string GetNextGroup(StringBuilder builder, ref int sPos) { - int count = 0; int ePos; while (sPos < builder.Length) { if (builder[sPos] == '{') { ePos = sPos + 1; - count = 1; + var count = 1; while (ePos < builder.Length) { if (builder[ePos] == '{') @@ -139,7 +138,7 @@ private string GetNextGroup(StringBuilder builder, ref int sPos) } if (count == 0) { - string reg = builder.ToString(sPos + 1, ePos - sPos - 1); + var reg = builder.ToString(sPos + 1, ePos - sPos - 1); builder.Remove(sPos, ePos - sPos + 1); return reg; } diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index eeb499e6..064edb6b 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -53,7 +53,7 @@ public static void CellPainting(ILogPaintContextUI logPaintCtx, BufferedDataGrid } else { - Color color = Color.FromArgb(255, 170, 170, 170); + var color = Color.FromArgb(255, 170, 170, 170); brush = new SolidBrush(color); } e.Graphics.FillRectangle(brush, e.CellBounds); @@ -159,9 +159,9 @@ public static DataGridViewColumn CreateTitleColumn(string colName) public static void SetColumnizer(ILogLineColumnizer columnizer, BufferedDataGridView gridView) { - int rowCount = gridView.RowCount; - int currLine = gridView.CurrentCellAddress.Y; - int currFirstLine = gridView.FirstDisplayedScrollingRowIndex; + var rowCount = gridView.RowCount; + var currLine = gridView.CurrentCellAddress.Y; + var currFirstLine = gridView.FirstDisplayedScrollingRowIndex; try { @@ -178,7 +178,7 @@ public static void SetColumnizer(ILogLineColumnizer columnizer, BufferedDataGrid gridView.Columns.Add(CreateLineNumberColumn()); - foreach (string colName in columnizer.GetColumnNames()) + foreach (var colName in columnizer.GetColumnNames()) { gridView.Columns.Add(CreateTitleColumn(colName)); } @@ -301,7 +301,7 @@ private static void PaintCell(ILogPaintContextUI logPaintCtx, DataGridViewCellPa private static void PaintHighlightedCell(ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) { - object value = e.Value ?? string.Empty; + var value = e.Value ?? string.Empty; IList matchList = logPaintCtx.FindHighlightMatches(value as ILogLine); // too many entries per line seem to cause problems with the GDI @@ -338,7 +338,7 @@ private static void PaintHighlightedCell(ILogPaintContextUI logPaintCtx, DataGri } } - int leftPad = e.CellStyle.Padding.Left; + var leftPad = e.CellStyle.Padding.Left; RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, e.CellBounds.Height); Rectangle borderWidths = BorderWidths(e.AdvancedBorderStyle); Rectangle valBounds = e.CellBounds; @@ -383,7 +383,7 @@ private static void PaintHighlightedCell(ILogPaintContextUI logPaintCtx, DataGri ? new SolidBrush(matchEntry.HilightEntry.BackgroundColor) : null; - string matchWord = string.Empty; + var matchWord = string.Empty; if (value is Column again) { if (string.IsNullOrEmpty(again.FullValue) == false) @@ -431,8 +431,8 @@ private static void PaintHighlightedCell(ILogPaintContextUI logPaintCtx, DataGri private static IList MergeHighlightMatchEntries(IList matchList, HilightMatchEntry groundEntry) { // Fill an area with lenth of whole text with a default hilight entry - HighlightEntry[] entryArray = new HighlightEntry[groundEntry.Length]; - for (int i = 0; i < entryArray.Length; ++i) + var entryArray = new HighlightEntry[groundEntry.Length]; + for (var i = 0; i < entryArray.Length; ++i) { entryArray[i] = groundEntry.HilightEntry; } @@ -441,8 +441,8 @@ private static IList MergeHighlightMatchEntries(IList MergeHighlightMatchEntries(IList 0) { HighlightEntry currentEntry = entryArray[0]; - int lastStartPos = 0; - int pos = 0; + var lastStartPos = 0; + var pos = 0; for (; pos < entryArray.Length; ++pos) { if (entryArray[pos] != currentEntry) diff --git a/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs b/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs index f63b4bb1..4c30c9a4 100644 --- a/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs +++ b/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs @@ -15,9 +15,9 @@ public LineToolStripSeparatorExtension() private void OnExtendedToolStripSeparatorPaint(object sender, PaintEventArgs e) { // Get the separator's width and height. - ToolStripSeparator toolStripSeparator = (ToolStripSeparator)sender; - int width = toolStripSeparator.Width; - int height = toolStripSeparator.Height; + var toolStripSeparator = (ToolStripSeparator)sender; + var width = toolStripSeparator.Width; + var height = toolStripSeparator.Height; // Choose the colors for drawing. // I've used Color.White as the foreColor. diff --git a/src/LogExpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs b/src/LogExpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs index b2dc6af7..82e44e39 100644 --- a/src/LogExpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs +++ b/src/LogExpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs @@ -20,9 +20,9 @@ private void OnExtendedToolStripSeparatorPaint(object? sender, PaintEventArgs e) } // Get the separator's width and height. - ToolStripSeparator toolStripSeparator = sender as ToolStripSeparator; - int width = toolStripSeparator.Width; - int height = toolStripSeparator.Height; + var toolStripSeparator = sender as ToolStripSeparator; + var width = toolStripSeparator.Width; + var height = toolStripSeparator.Height; // Choose the colors for drawing. // I've used Color.White as the foreColor. diff --git a/src/LogExpert.UI/Extensions/Utils.cs b/src/LogExpert.UI/Extensions/Utils.cs index f753a1fd..9e3507d1 100644 --- a/src/LogExpert.UI/Extensions/Utils.cs +++ b/src/LogExpert.UI/Extensions/Utils.cs @@ -4,13 +4,13 @@ internal static class Utils { public static string GetWordFromPos(int xPos, string text, Graphics g, Font font) { - string[] words = text.Split([' ', '.', ':', ';']); + var words = text.Split([' ', '.', ':', ';']); - int index = 0; + var index = 0; List crList = []; - for (int i = 0; i < words.Length; ++i) + for (var i = 0; i < words.Length; ++i) { crList.Add(new CharacterRange(index, words[i].Length)); index += words[i].Length; @@ -29,9 +29,9 @@ public static string GetWordFromPos(int xPos, string text, Graphics g, Font font RectangleF rect = new(0, 0, 3000, 20); Region[] stringRegions = g.MeasureCharacterRanges(text, font, rect, stringFormat); - bool found = false; + var found = false; - int y = 0; + var y = 0; foreach (Region regio in stringRegions) { diff --git a/src/LogExpert.UI/Extensions/Win32.cs b/src/LogExpert.UI/Extensions/Win32.cs index b0f9e92e..3fef2b52 100644 --- a/src/LogExpert.UI/Extensions/Win32.cs +++ b/src/LogExpert.UI/Extensions/Win32.cs @@ -67,16 +67,16 @@ public static Icon LoadIconFromExe(string fileName, int index) //IntPtr[] largeIcons = new IntPtr[1]; nint smallIcons = new(); nint largeIcons = new(); - int num = (int)ExtractIconEx(fileName, index, ref largeIcons, ref smallIcons, 1); + var num = (int)ExtractIconEx(fileName, index, ref largeIcons, ref smallIcons, 1); if (num > 0 && smallIcons != nint.Zero) { - Icon icon = (Icon)Icon.FromHandle(smallIcons).Clone(); + var icon = (Icon)Icon.FromHandle(smallIcons).Clone(); DestroyIcon(smallIcons); return icon; } if (num > 0 && largeIcons != nint.Zero) { - Icon icon = (Icon)Icon.FromHandle(largeIcons).Clone(); + var icon = (Icon)Icon.FromHandle(largeIcons).Clone(); DestroyIcon(largeIcons); return icon; } @@ -85,9 +85,9 @@ public static Icon LoadIconFromExe(string fileName, int index) public static Icon[,] ExtractIcons(string fileName) { - nint smallIcon = nint.Zero; - nint largeIcon = nint.Zero; - int iconCount = (int)ExtractIconEx(fileName, -1, ref largeIcon, ref smallIcon, 0); + var smallIcon = nint.Zero; + var largeIcon = nint.Zero; + var iconCount = (int)ExtractIconEx(fileName, -1, ref largeIcon, ref smallIcon, 0); if (iconCount <= 0) { return null; @@ -95,11 +95,11 @@ public static Icon LoadIconFromExe(string fileName, int index) nint smallIcons = new(); nint largeIcons = new(); - Icon[,] result = new Icon[2, iconCount]; + var result = new Icon[2, iconCount]; - for (int i = 0; i < iconCount; ++i) + for (var i = 0; i < iconCount; ++i) { - int num = (int)ExtractIconEx(fileName, i, ref largeIcons, ref smallIcons, 1); + var num = (int)ExtractIconEx(fileName, i, ref largeIcons, ref smallIcons, 1); if (smallIcons != nint.Zero) { result[0, i] = (Icon)Icon.FromHandle(smallIcons).Clone(); @@ -135,7 +135,7 @@ public static bool UseImmersiveDarkMode(nint handle, bool enabled) attribute = DWMWA_USE_IMMERSIVE_DARK_MODE; } - int useImmersiveDarkMode = enabled ? 1 : 0; + var useImmersiveDarkMode = enabled ? 1 : 0; return DwmSetWindowAttribute(handle, attribute, ref useImmersiveDarkMode, sizeof(int)) == 0; } diff --git a/src/LogExpert/Classes/CommandLine/CmdLine.cs b/src/LogExpert/Classes/CommandLine/CmdLine.cs index 19ad74d0..878c1e66 100644 --- a/src/LogExpert/Classes/CommandLine/CmdLine.cs +++ b/src/LogExpert/Classes/CommandLine/CmdLine.cs @@ -102,7 +102,7 @@ public void RegisterParameter(CmdLineParameter[] parameters) /// Any reminding strings after arguments has been processed. public string[] Parse(string[] args) { - int i = 0; + var i = 0; List new_args = []; @@ -111,8 +111,8 @@ public string[] Parse(string[] args) if (args[i].Length > 1 && args[i][0] == '-') { // The current string is a parameter name - string key = args[i][1..].ToLower(); - string argsValue = string.Empty; + var key = args[i][1..].ToLower(); + var argsValue = string.Empty; i++; if (i < args.Length) { @@ -148,7 +148,7 @@ public string[] Parse(string[] args) // Check that required parameters are present in the command line. - foreach (string key in parameters.Keys) + foreach (var key in parameters.Keys) { if (parameters[key].Required && parameters[key].Exists == false) { @@ -164,16 +164,16 @@ public string[] Parse(string[] args) /// public string HelpScreen() { - int len = 0; - foreach (string key in parameters.Keys) + var len = 0; + foreach (var key in parameters.Keys) { len = Math.Max(len, key.Length); } - string help = "\nParameters:\n\n"; - foreach (string key in parameters.Keys) + var help = "\nParameters:\n\n"; + foreach (var key in parameters.Keys) { - string s = "-" + parameters[key].Name; + var s = "-" + parameters[key].Name; while (s.Length < len + 3) { s += " "; diff --git a/src/LogExpert/Classes/CommandLine/CmdLineInt.cs b/src/LogExpert/Classes/CommandLine/CmdLineInt.cs index de6394b8..949e6cd6 100644 --- a/src/LogExpert/Classes/CommandLine/CmdLineInt.cs +++ b/src/LogExpert/Classes/CommandLine/CmdLineInt.cs @@ -67,7 +67,7 @@ public CmdLineInt(string name, bool required, string helpMessage, int min, int m public override void SetValue(string value) { base.SetValue(value); - int i = 0; + int i; try { i = Convert.ToInt32(value); diff --git a/src/LogExpert/Classes/CommandLine/CmdLineParameter.cs b/src/LogExpert/Classes/CommandLine/CmdLineParameter.cs index 9f7f9db8..12d1d48a 100644 --- a/src/LogExpert/Classes/CommandLine/CmdLineParameter.cs +++ b/src/LogExpert/Classes/CommandLine/CmdLineParameter.cs @@ -35,7 +35,7 @@ public class CmdLineParameter(string name, bool required, string helpMessage) /// /// Returns true if the parameter was found in the command line. /// - public bool Exists { get; private set; } = false; + public bool Exists { get; private set; } /// /// Returns true if the parameter is required in the command line. diff --git a/src/LogExpert/Classes/CommandLine/ConsoleCmdLine.cs b/src/LogExpert/Classes/CommandLine/ConsoleCmdLine.cs index 80474c83..0d93f533 100644 --- a/src/LogExpert/Classes/CommandLine/ConsoleCmdLine.cs +++ b/src/LogExpert/Classes/CommandLine/ConsoleCmdLine.cs @@ -29,7 +29,7 @@ public ConsoleCmdLine() { string[] ret = []; - string error = string.Empty; + var error = string.Empty; try { diff --git a/src/LogExpert/Config/ConfigManager.cs b/src/LogExpert/Config/ConfigManager.cs index 28efa83f..175caef9 100644 --- a/src/LogExpert/Config/ConfigManager.cs +++ b/src/LogExpert/Config/ConfigManager.cs @@ -274,7 +274,7 @@ private void Save(Settings settings, SettingsFlags flags) _logger.Info("Saving settings"); lock (this) { - string dir = Settings.Preferences.PortableMode ? Application.StartupPath : ConfigDir; + var dir = Settings.Preferences.PortableMode ? Application.StartupPath : ConfigDir; if (!Directory.Exists(dir)) { diff --git a/src/LogExpert/Program.cs b/src/LogExpert/Program.cs index 347bc900..a46932b4 100644 --- a/src/LogExpert/Program.cs +++ b/src/LogExpert/Program.cs @@ -98,7 +98,7 @@ private static void Main(string[] args) } else { - int counter = 3; + var counter = 3; Exception errMsg = null; Settings settings = ConfigManager.Instance.Settings; @@ -106,7 +106,7 @@ private static void Main(string[] args) { try { - WindowsIdentity wi = WindowsIdentity.GetCurrent(); + var wi = WindowsIdentity.GetCurrent(); var command = SerializeCommandIntoNonFormattedJSON(absoluteFilePaths, settings.Preferences.allowOnlyOneInstance); SendCommandToServer(command); break; @@ -172,7 +172,7 @@ private static string[] GenerateAbsoluteFilePaths(string[] remainingArgs) { List argsList = []; - foreach (string fileArg in remainingArgs) + foreach (var fileArg in remainingArgs) { try { @@ -280,7 +280,7 @@ private static async Task RunServerLoopAsync(Action { await server.WaitForConnectionAsync(cancellationToken); using var reader = new StreamReader(server, Encoding.UTF8); - string line = await reader.ReadLineAsync(cancellationToken); + var line = await reader.ReadLineAsync(cancellationToken); if (line != null) { @@ -302,7 +302,7 @@ private static async Task RunServerLoopAsync(Action [STAThread] private static void ShowUnhandledException(object exceptionObject) { - string errorText = string.Empty; + var errorText = string.Empty; string stackTrace; if (exceptionObject is Exception exception) @@ -313,7 +313,7 @@ private static void ShowUnhandledException(object exceptionObject) else { stackTrace = exceptionObject.ToString(); - string[] lines = stackTrace.Split('\n'); + var lines = stackTrace.Split('\n'); if (lines != null && lines.Length > 0) { @@ -347,7 +347,7 @@ private static void CurrentDomain_UnhandledException(object sender, UnhandledExc { _logger.Fatal(e); - object exceptionObject = e.ExceptionObject; + var exceptionObject = e.ExceptionObject; Thread thread = new(ShowUnhandledException) { diff --git a/src/PluginRegistry/FileSystem/LogFileInfo.cs b/src/PluginRegistry/FileSystem/LogFileInfo.cs index 7c8c4438..6b0d96a7 100644 --- a/src/PluginRegistry/FileSystem/LogFileInfo.cs +++ b/src/PluginRegistry/FileSystem/LogFileInfo.cs @@ -31,26 +31,14 @@ public LogFileInfo(Uri fileUri) #region Properties - public string FullName - { - get { return fInfo.FullName; } - } + public string FullName => fInfo.FullName; - public string FileName - { - get { return fInfo.Name; } - } + public string FileName => fInfo.Name; - public string DirectoryName - { - get { return fInfo.DirectoryName; } - } + public string DirectoryName => fInfo.DirectoryName; - public char DirectorySeparatorChar - { - get { return Path.DirectorySeparatorChar; } - } + public char DirectorySeparatorChar => Path.DirectorySeparatorChar; public Uri Uri { get; } @@ -63,7 +51,7 @@ public long Length return -1; } - int retry = RETRY_COUNT; + var retry = RETRY_COUNT; while (retry > 0) { @@ -134,7 +122,7 @@ public long LengthWithoutRetry /// public Stream OpenStream() { - int retry = RETRY_COUNT; + var retry = RETRY_COUNT; while (true) { diff --git a/src/PluginRegistry/PluginRegistry.cs b/src/PluginRegistry/PluginRegistry.cs index 0ba17139..6a282f21 100644 --- a/src/PluginRegistry/PluginRegistry.cs +++ b/src/PluginRegistry/PluginRegistry.cs @@ -97,7 +97,7 @@ internal void LoadPlugins() ]; RegisteredFileSystemPlugins.Add(new LocalFileSystem()); - string pluginDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins"); + var pluginDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins"); //TODO: FIXME: This is a hack for the tests to pass. Need to find a better approach if (!Directory.Exists(pluginDir)) { @@ -110,7 +110,7 @@ internal void LoadPlugins() if (interfaceName == null) { throw new NotImplementedException("The interface name is null. How did this happen? Let's fix this."); } - foreach (string dllName in Directory.EnumerateFiles(pluginDir, "*.dll")) + foreach (var dllName in Directory.EnumerateFiles(pluginDir, "*.dll")) { try { @@ -147,7 +147,7 @@ internal void LoadPlugins() private void LoadPluginAssembly(string dllName, string interfaceName) { - Assembly assembly = Assembly.LoadFrom(dllName); + var assembly = Assembly.LoadFrom(dllName); var types = assembly.GetTypes(); foreach (var type in types) @@ -159,7 +159,7 @@ private void LoadPluginAssembly(string dllName, string interfaceName) ConstructorInfo cti = type.GetConstructor(Type.EmptyTypes); if (cti != null) { - object instance = cti.Invoke([]); + var instance = cti.Invoke([]); RegisteredColumnizers.Add((ILogLineColumnizer)instance); if (instance is IColumnizerConfigurator configurator) @@ -332,7 +332,7 @@ private static T TryInstantiate(Type loadedType) where T : class ConstructorInfo cti = loadedType.GetConstructor(Type.EmptyTypes); if (cti != null) { - object o = cti.Invoke([]); + var o = cti.Invoke([]); return o as T; } } @@ -349,7 +349,7 @@ private static T TryInstantiate(Type loadedType, IFileSystemCallback fsCallba ConstructorInfo cti = loadedType.GetConstructor([typeof(IFileSystemCallback)]); if (cti != null) { - object o = cti.Invoke([fsCallback]); + var o = cti.Invoke([fsCallback]); return o as T; } } @@ -363,10 +363,10 @@ private static T TryInstantiate(Type loadedType, IFileSystemCallback fsCallba private static Assembly ColumnizerResolveEventHandler(object? sender, ResolveEventArgs args) { - string fileName = new AssemblyName(args.Name).Name + ".dll"; + var fileName = new AssemblyName(args.Name).Name + ".dll"; - string mainDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - string pluginDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins", fileName); + var mainDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); + var pluginDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins", fileName); if (File.Exists(mainDir)) { diff --git a/src/RegexColumnizer/RegexColumnizer.cs b/src/RegexColumnizer/RegexColumnizer.cs index 89143937..dbc3ecc0 100644 --- a/src/RegexColumnizer/RegexColumnizer.cs +++ b/src/RegexColumnizer/RegexColumnizer.cs @@ -46,7 +46,7 @@ public string GetName() public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) { - ColumnizedLogLine logLine = new ColumnizedLogLine(); + var logLine = new ColumnizedLogLine(); logLine.ColumnValues = new IColumn[columns.Length]; if (Regex != null) @@ -55,7 +55,7 @@ public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLin if (m.Success) { - for (int i = m.Groups.Count - 1; i > 0; i--) + for (var i = m.Groups.Count - 1; i > 0; i--) { logLine.ColumnValues[i - 1] = new Column { @@ -124,7 +124,7 @@ public void PushValue(ILogLineColumnizerCallback callback, int column, string va public void Configure(ILogLineColumnizerCallback callback, string configDir) { - RegexColumnizerConfigDialog dialog = new RegexColumnizerConfigDialog {Config = Config}; + var dialog = new RegexColumnizerConfigDialog {Config = Config}; if (dialog.ShowDialog() == DialogResult.OK) { var configFile = GetConfigFile(configDir); @@ -162,7 +162,7 @@ public void LoadConfig(string configDir) public string GetConfigFile(string configDir) { var name = GetType().Name; - string configPath = Path.Combine(configDir, name); + var configPath = Path.Combine(configDir, name); configPath = Path.ChangeExtension(configPath, "xml"); //todo change to json return configPath; } @@ -189,7 +189,7 @@ public void Init(RegexColumnizerConfig config) try { Regex = new Regex(Config.Expression, RegexOptions.Compiled); - int skip = Regex.GetGroupNames().Length == 1 ? 0 : 1; + var skip = Regex.GetGroupNames().Length == 1 ? 0 : 1; columns = Regex.GetGroupNames().Skip(skip).ToArray(); } catch diff --git a/src/RegexColumnizer/RegexColumnizerConfigDialog.cs b/src/RegexColumnizer/RegexColumnizerConfigDialog.cs index b44cf02f..5e388d5c 100644 --- a/src/RegexColumnizer/RegexColumnizerConfigDialog.cs +++ b/src/RegexColumnizer/RegexColumnizerConfigDialog.cs @@ -50,9 +50,9 @@ private bool Check() { Regex regex = new(tbExpression.Text); var groupNames = regex.GetGroupNames(); - int offset = groupNames.Length > 1 ? 1 : 0; + var offset = groupNames.Length > 1 ? 1 : 0; - for (int i = offset; i < groupNames.Length; i++) + for (var i = offset; i < groupNames.Length; i++) { table.Columns.Add(groupNames[i]); } diff --git a/src/SftpFileSystemx64/LoginDialog.cs b/src/SftpFileSystemx64/LoginDialog.cs index 936d0c41..a458cd35 100644 --- a/src/SftpFileSystemx64/LoginDialog.cs +++ b/src/SftpFileSystemx64/LoginDialog.cs @@ -25,7 +25,7 @@ public LoginDialog(string host, IList userNames, bool hidePasswordField) serverNameLabel.Text = host; if (userNames != null) { - foreach (string name in userNames) + foreach (var name in userNames) { if (name != null) { diff --git a/src/SftpFileSystemx64/SftpFileSystem.cs b/src/SftpFileSystemx64/SftpFileSystem.cs index fbefdff0..41355951 100644 --- a/src/SftpFileSystemx64/SftpFileSystem.cs +++ b/src/SftpFileSystemx64/SftpFileSystem.cs @@ -182,7 +182,7 @@ internal Credentials GetCredentials(Uri uri, bool cacheAllowed, bool hidePasswor string password = null; if (uri.UserInfo != null && uri.UserInfo.Length > 0) { - string[] split = uri.UserInfo.Split(':'); + var split = uri.UserInfo.Split(':'); if (split.Length > 0) { userName = split[0]; diff --git a/src/SftpFileSystemx64/SftpLogFileInfo.cs b/src/SftpFileSystemx64/SftpLogFileInfo.cs index 6323c202..83c3e4ce 100644 --- a/src/SftpFileSystemx64/SftpLogFileInfo.cs +++ b/src/SftpFileSystemx64/SftpLogFileInfo.cs @@ -38,10 +38,10 @@ internal SftpLogFileInfo(SftpFileSystem sftpFileSystem, Uri fileUri, ILogExpertL Uri = fileUri; _remoteFileName = Uri.PathAndQuery; - int port = Uri.Port != -1 ? Uri.Port : 22; + var port = Uri.Port != -1 ? Uri.Port : 22; - bool success = false; - bool cancelled = false; + var success = false; + var cancelled = false; if (sftFileSystem.ConfigData.UseKeyfile) { lock (_sshKeyMonitor) // prevent multiple password dialogs when opening multiple files at once @@ -149,8 +149,8 @@ public string DirectoryName { get { - string full = FullName; - int i = full.LastIndexOf(DirectorySeparatorChar); + var full = FullName; + var i = full.LastIndexOf(DirectorySeparatorChar); if (i != -1) { return full.Substring(0, i); @@ -168,8 +168,8 @@ public bool FileExists { try { - SftpFile file = (SftpFile) _sftp.Get(_remoteFileName); - long len = file.Attributes.Size; + var file = (SftpFile) _sftp.Get(_remoteFileName); + var len = file.Attributes.Size; return len != -1; } catch (Exception e) @@ -184,8 +184,8 @@ public string FileName { get { - string full = FullName; - int i = full.LastIndexOf(DirectorySeparatorChar); + var full = FullName; + var i = full.LastIndexOf(DirectorySeparatorChar); return full.Substring(i + 1); } } @@ -196,7 +196,7 @@ public long Length { get { - SftpFile file = (SftpFile)_sftp.Get(_remoteFileName); + var file = (SftpFile)_sftp.Get(_remoteFileName); return file.Attributes.Size; } } @@ -238,7 +238,7 @@ public bool FileHasChanged() public Stream OpenStream() { - int retry = RETRY_COUNT; + var retry = RETRY_COUNT; while (true) { try From 7efbe92478fcdbe902fcebe75e244cbecf283784 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Mon, 2 Jun 2025 09:42:45 +0200 Subject: [PATCH 055/142] file namespace --- src/.editorconfig | 8 +- src/AutoColumnizer/AutoColumnizer.cs | 91 +- src/ColumnizerLib.UnitTests/ColumnTests.cs | 113 +- .../Extensions/LogLineExtensionsTests.cs | 39 +- src/ColumnizerLib/Column.cs | 157 +- src/ColumnizerLib/ColumnizedLogLine.cs | 15 +- .../Extensions/LogLineExtensions.cs | 11 +- .../IAutoLogLineColumnizerCallback.cs | 19 +- src/ColumnizerLib/IColumn.cs | 17 +- src/ColumnizerLib/IColumnizedLogLine.cs | 15 +- src/ColumnizerLib/IColumnizerConfigurator.cs | 77 +- src/ColumnizerLib/IColumnizerPriority.cs | 21 +- src/ColumnizerLib/IContextMenuEntry.cs | 101 +- src/ColumnizerLib/IFileSystemCallback.cs | 25 +- src/ColumnizerLib/IFileSystemPlugin.cs | 83 +- src/ColumnizerLib/IInitColumnizer.cs | 63 +- src/ColumnizerLib/IKeywordAction.cs | 79 +- src/ColumnizerLib/ILogExpertCallback.cs | 113 +- src/ColumnizerLib/ILogExpertLogger.cs | 63 +- src/ColumnizerLib/ILogExpertPlugin.cs | 35 +- .../ILogExpertPluginConfigurator.cs | 155 +- src/ColumnizerLib/ILogFileInfo.cs | 155 +- src/ColumnizerLib/ILogLine.cs | 15 +- src/ColumnizerLib/ILogLineColumnizer.cs | 211 +- src/ColumnizerLib/ILogLineXmlColumnizer.cs | 131 +- src/ColumnizerLib/IPreProcessColumnizer.cs | 99 +- src/ColumnizerLib/ITextValue.cs | 13 +- src/ColumnizerLib/IXmlLogConfiguration.cs | 57 +- src/ColumnizerLib/LineEntry.cs | 29 +- src/ColumnizerLib/Priority.cs | 49 +- src/CsvColumnizer/CsvColumn.cs | 13 +- src/CsvColumnizer/CsvColumnizer.cs | 379 +- src/CsvColumnizer/CsvColumnizerConfig.cs | 93 +- src/CsvColumnizer/CsvColumnizerConfigDlg.cs | 103 +- src/CsvColumnizer/CsvLogLine.cs | 17 +- src/FlashIconHighlighter/FlashIconPlugin.cs | 71 +- src/FlashIconHighlighter/Win32Stuff.cs | 41 +- src/GlassfishColumnizer/GlassFishLogLine.cs | 17 +- .../GlassfishColumnizer.cs | 298 +- src/GlassfishColumnizer/XmlConfig.cs | 19 +- src/JsonColumnizer/JsonColumn.cs | 13 +- src/JsonColumnizer/JsonColumnizer.cs | 301 +- .../JsonCompactColumnizer.cs | 163 +- src/Log4jXmlColumnizer/Log4JLogLine.cs | 17 +- src/Log4jXmlColumnizer/Log4jColumnEntry.cs | 23 +- src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs | 415 +- .../Log4jXmlColumnizerConfig.cs | 101 +- .../Log4jXmlColumnizerConfigDlg.cs | 115 +- src/Log4jXmlColumnizer/XmlConfig.cs | 47 +- .../Classes/Columnizer/ClfColumnizer.cs | 279 +- .../Classes/Columnizer/ColumnizerPicker.cs | 203 +- .../Columnizer/SquareBracketColumnizer.cs | 469 +- .../Columnizer/TimeFormatDeterminer.cs | 359 +- .../Classes/Columnizer/TimestampColumnizer.cs | 319 +- .../DateTimeParser/DateFormatPartAdjuster.cs | 49 +- .../Classes/DateTimeParser/Parser.cs | 255 +- .../Classes/DateTimeParser/Section.cs | 11 +- .../Classes/DateTimeParser/Token.cs | 23 +- .../Classes/DateTimeParser/Tokenizer.cs | 177 +- .../Classes/FileSystemCallback.cs | 65 +- src/LogExpert.Core/Classes/Filter/Filter.cs | 241 +- .../Classes/Filter/FilterCancelHandler.cs | 41 +- .../Classes/Filter/FilterParams.cs | 235 +- .../Classes/Filter/FilterPipe.cs | 245 +- .../Classes/Filter/FilterStarter.cs | 303 +- .../Classes/Highlight/ActionEntry.cs | 33 +- .../Classes/Highlight/HighlightEntry.cs | 137 +- .../Classes/Highlight/HilightMatchEntry.cs | 35 +- src/LogExpert.Core/Classes/IPC/IpcMessage.cs | 13 +- .../Classes/IPC/IpcMessageType.cs | 13 +- src/LogExpert.Core/Classes/IPC/LoadPayload.cs | 9 +- src/LogExpert.Core/Classes/Log/LogBuffer.cs | 147 +- .../Classes/Log/LogBufferCacheEntry.cs | 43 +- .../Classes/Log/LogStreamReaderBase.cs | 93 +- .../Log/PositionAwareStreamReaderBase.cs | 323 +- .../Log/PositionAwareStreamReaderLegacy.cs | 143 +- .../Log/PositionAwareStreamReaderSystem.cs | 121 +- .../Classes/Log/RolloverFilenameBuilder.cs | 351 +- .../Classes/Log/RolloverFilenameHandler.cs | 157 +- src/LogExpert.Core/Classes/ObjectClone.cs | 25 +- src/LogExpert.Core/Classes/ParamParser.cs | 149 +- src/LogExpert.Core/Classes/PatternBlock.cs | 57 +- .../Classes/Persister/FilterTabData.cs | 11 +- .../Classes/Persister/Persister.cs | 1069 ++-- .../Classes/Persister/ProjectData.cs | 16 +- .../Classes/Persister/ProjectPersister.cs | 99 +- src/LogExpert.Core/Classes/SpreadEntry.cs | 35 +- src/LogExpert.Core/Classes/SysoutPipe.cs | 121 +- src/LogExpert.Core/Classes/UsedComponents.cs | 23 +- .../Classes/xml/XmlBlockSplitter.cs | 231 +- .../Classes/xml/XmlLogReader.cs | 241 +- src/LogExpert.Core/Config/ColorEntry.cs | 31 +- src/LogExpert.Core/Config/ColorMode.cs | 125 +- .../Config/ColumnizerHistoryEntry.cs | 31 +- .../Config/ColumnizerMaskEntry.cs | 17 +- .../Config/ExportImportFlags.cs | 27 +- .../Config/HighlightMaskEntry.cs | 17 +- src/LogExpert.Core/Config/MultiFileOption.cs | 15 +- src/LogExpert.Core/Config/Preferences.cs | 115 +- src/LogExpert.Core/Config/RegexHistory.cs | 13 +- .../Config/SessionSaveLocation.cs | 43 +- src/LogExpert.Core/Config/Settings.cs | 55 +- src/LogExpert.Core/Config/SettingsFlags.cs | 35 +- src/LogExpert.Core/Config/ToolEntry.cs | 79 +- src/LogExpert.Core/Entities/Bookmark.cs | 53 +- .../Entities/BookmarkCollection.cs | 27 +- .../Entities/BookmarkOverlay.cs | 17 +- src/LogExpert.Core/Entities/DebugOptions.cs | 9 +- .../Entities/DefaultLogfileColumnizer.cs | 123 +- .../Entities/EncodingOptions.cs | 31 +- .../Entities/FileViewContext.cs | 15 +- src/LogExpert.Core/Entities/HighlightGroup.cs | 37 +- src/LogExpert.Core/Entities/LogEventData.cs | 27 +- .../Entities/LogFileException.cs | 29 +- .../Entities/MultifileOptions.cs | 17 +- src/LogExpert.Core/Entities/Range.cs | 39 +- src/LogExpert.Core/Entities/ReloadMemento.cs | 11 +- src/LogExpert.Core/Entities/RowHeightEntry.cs | 39 +- src/LogExpert.Core/Entities/SearchParams.cs | 29 +- .../Enums/DragOrientationsEnum.cs | 13 +- .../Enums/ProjectLoadDlgResult.cs | 15 +- src/LogExpert.Core/Enums/WindowTypes.cs | 11 +- .../EventArguments/BookmarkEventArgs.cs | 13 +- .../EventArguments/ColumnizerEventArgs.cs | 13 +- .../EventArguments/ConfigChangedEventArgs.cs | 13 +- .../ContextMenuPluginEventArgs.cs | 21 +- .../CurrentHighlightGroupChangedEventArgs.cs | 15 +- .../FilterListChangedEventArgs.cs | 13 +- .../EventArguments/GuiStateArgs.cs | 45 +- .../EventArguments/LoadFileEventArgs.cs | 7 +- .../EventArguments/OverlayEventArgs.cs | 13 +- .../EventArguments/PatternArgs.cs | 23 +- .../EventArguments/ProgressEventArgs.cs | 19 +- .../EventArguments/SelectLineEventArgs.cs | 13 +- .../EventArguments/StatusEventArgs.cs | 43 +- .../EventArguments/SyncModeEventArgs.cs | 13 +- .../EventHandlers/EventHandlers.cs | 9 +- src/LogExpert.Core/Extensions/IEnumerable.cs | 31 +- .../IBackgroundProcessCancelHandler.cs | 25 +- .../Interface/IConfigManager.cs | 31 +- .../Interface/IFileViewContext.cs | 11 +- .../Interface/ILogExpertProxy.cs | 55 +- .../Interface/ILogPaintContext.cs | 7 +- .../Interface/ILogStreamReader.cs | 25 +- src/LogExpert.Core/Interface/ILogView.cs | 33 +- .../Interface/IPluginRegistry.cs | 13 +- .../Interface/ISharedToolWindow.cs | 41 +- src/LogExpert.Core/Structs/ActEntry.cs | 11 +- src/LogExpert.Tests/BufferShiftTest.cs | 247 +- src/LogExpert.Tests/CSVColumnizerTest.cs | 37 +- src/LogExpert.Tests/ColumnizerPickerTest.cs | 181 +- src/LogExpert.Tests/DateFormatParserTest.cs | 165 +- .../Extensions/EnumerableTests.cs | 77 +- src/LogExpert.Tests/JSONSaveTest.cs | 59 +- src/LogExpert.Tests/JsonColumnizerTest.cs | 47 +- .../JsonCompactColumnizerTest.cs | 57 +- src/LogExpert.Tests/LocalFileSystemTest.cs | 85 +- src/LogExpert.Tests/LogStreamReaderTest.cs | 139 +- src/LogExpert.Tests/LogWindowTest.cs | 47 +- src/LogExpert.Tests/ReaderTest.cs | 93 +- src/LogExpert.Tests/RollingNameTest.cs | 113 +- src/LogExpert.Tests/RolloverHandlerTest.cs | 65 +- .../RolloverHandlerTestBase.cs | 157 +- .../SquareBracketColumnizerTest.cs | 61 +- .../Controls/BufferedDataGridView.cs | 43 +- .../Controls/DateTimeDragControl.cs | 713 ++- src/LogExpert.UI/Controls/LogGridCell.cs | 13 +- src/LogExpert.UI/Controls/LogTextColumn.cs | 17 +- .../LogWindow/LogWindowEventHandlers.cs | 2437 ++++---- .../Controls/LogWindow/LogWindowPrivate.cs | 5513 ++++++++--------- .../Controls/LogWindow/LogWindowPublic.cs | 2704 ++++---- .../Controls/LogWindow/PatternWindow.cs | 557 +- .../Controls/LogWindow/RangeFinder.cs | 141 +- .../LogWindow/TimeSpreadCalculator.cs | 625 +- .../Controls/LogWindow/TimeSpreadigControl.cs | 427 +- src/LogExpert.UI/Dialogs/Eminus/Eminus.cs | 429 +- .../Dialogs/Eminus/EminusConfig.cs | 41 +- .../Dialogs/Eminus/EminusConfigDlg.cs | 73 +- .../LogTabWindow/LogTabWindowEventHandlers.cs | 4 +- .../LogTabWindow/LogTabWindowPrivate.cs | 10 +- src/LogExpert.UI/Entities/ArgParser.cs | 227 +- src/LogExpert.UI/Entities/PaintHelper.cs | 741 ++- src/LogExpert.UI/Extensions/Utils.cs | 77 +- src/LogExpert.UI/Extensions/Win32.cs | 247 +- .../Interface/ILogPaintContextUI.cs | 39 +- src/LogExpert/Classes/CommandLine/CmdLine.cs | 259 +- .../Classes/CommandLine/CmdLineException.cs | 37 +- .../Classes/CommandLine/CmdLineInt.cs | 151 +- .../Classes/CommandLine/CmdLineParameter.cs | 93 +- .../Classes/CommandLine/ConsoleCmdLine.cs | 83 +- .../Classes/LogExpertApplicationContext.cs | 43 +- src/LogExpert/Classes/LogExpertProxy.cs | 237 +- src/LogExpert/Config/ConfigManager.cs | 612 +- src/LogExpert/Program.cs | 509 +- .../Classes/Persister/PersistenceData.cs | 42 + .../FileSystem/LocalFileSystem.cs | 57 +- src/PluginRegistry/FileSystem/LogFileInfo.cs | 233 +- src/PluginRegistry/PluginRegistry.cs | 532 +- .../RegexColumnizerTests.cs | 95 +- src/RegexColumnizer/RegexColumnizer.cs | 337 +- src/RegexColumnizer/RegexColumnizerConfig.cs | 15 +- .../RegexColumnizerConfigDialog.cs | 109 +- src/SftpFileSystemx64/ConfigData.cs | 17 +- src/SftpFileSystemx64/ConfigDialog.cs | 97 +- src/SftpFileSystemx64/CredentialCache.cs | 73 +- src/SftpFileSystemx64/Credentials.cs | 33 +- src/SftpFileSystemx64/FailedKeyDialog.cs | 71 +- src/SftpFileSystemx64/KeyType.cs | 11 +- src/SftpFileSystemx64/LoginDialog.cs | 101 +- .../PrivateKeyPasswordDialog.cs | 53 +- src/SftpFileSystemx64/SftpFileSystem.cs | 327 +- src/SftpFileSystemx64/SftpLogFileInfo.cs | 349 +- 212 files changed, 17027 insertions(+), 17232 deletions(-) create mode 100644 src/Logexpert.Core/Classes/Persister/PersistenceData.cs diff --git a/src/.editorconfig b/src/.editorconfig index 7225b5c0..17f73e3d 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -555,7 +555,7 @@ dotnet_code_quality.CA1001.excluded_symbol_names = dotnet_code_quality.CA1001.excluded_type_names_with_derived_types = # CA1002: Do not expose generic lists -dotnet_diagnostic.CA1002.severity = warning +dotnet_diagnostic.CA1002.severity = suggestion dotnet_code_quality.CA1002.api_surface = all # CA1003: Use generic event handler instances @@ -906,7 +906,7 @@ dotnet_code_quality.CA1806.additional_use_results_methods = dotnet_diagnostic.CA1810.severity = warning # CA1812: Avoid uninstantiated internal classes -dotnet_diagnostic.CA1812.severity = warning +dotnet_diagnostic.CA1812.severity = None # CA1813: Avoid unsealed attributes dotnet_diagnostic.CA1813.severity = suggestion @@ -1021,7 +1021,7 @@ dotnet_diagnostic.CA1849.severity = warning dotnet_diagnostic.CA1850.severity = warning # CA2000: Dispose objects before losing scope -dotnet_diagnostic.CA2000.severity = warning +dotnet_diagnostic.CA2000.severity = None dotnet_code_quality.CA2000.excluded_symbol_names = dotnet_code_quality.CA2000.excluded_type_names_with_derived_types = dotnet_code_quality.CA2000.dispose_analysis_kind = NonExceptionPaths @@ -1100,7 +1100,7 @@ dotnet_code_quality.CA2208.api_surface = all dotnet_diagnostic.CA2211.severity = warning # CA2213: Disposable fields should be disposed -dotnet_diagnostic.CA2213.severity = warning +dotnet_diagnostic.CA2213.severity = None # CA2214: Do not call overridable methods in constructors dotnet_diagnostic.CA2214.severity = warning diff --git a/src/AutoColumnizer/AutoColumnizer.cs b/src/AutoColumnizer/AutoColumnizer.cs index c699274c..bed59327 100644 --- a/src/AutoColumnizer/AutoColumnizer.cs +++ b/src/AutoColumnizer/AutoColumnizer.cs @@ -2,64 +2,63 @@ using System; -namespace AutoColumnizer -{ - public class AutoColumnizer : ILogLineColumnizer - { - #region ILogLineColumnizer implementation +namespace AutoColumnizer; - public string Text => GetName(); +public class AutoColumnizer : ILogLineColumnizer +{ + #region ILogLineColumnizer implementation - public bool IsTimeshiftImplemented() - { - return true; - } + public string Text => GetName(); - public string GetName() - { - return "Auto Columnizer"; - } + public bool IsTimeshiftImplemented() + { + return true; + } - public string GetDescription() - { - return "Automatically find the right columnizer for any file"; - } + public string GetName() + { + return "Auto Columnizer"; + } + public string GetDescription() + { + return "Automatically find the right columnizer for any file"; + } - public int GetColumnCount() - { - throw new NotImplementedException(); - } - public string[] GetColumnNames() - { - throw new NotImplementedException(); - } + public int GetColumnCount() + { + throw new NotImplementedException(); + } - public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) - { - throw new NotImplementedException(); - } + public string[] GetColumnNames() + { + throw new NotImplementedException(); + } - public void SetTimeOffset(int msecOffset) - { - throw new NotImplementedException(); - } + public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) + { + throw new NotImplementedException(); + } - public int GetTimeOffset() - { - throw new NotImplementedException(); - } + public void SetTimeOffset(int msecOffset) + { + throw new NotImplementedException(); + } - public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) - { - throw new NotImplementedException(); - } + public int GetTimeOffset() + { + throw new NotImplementedException(); + } - public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) - { - } + public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) + { + throw new NotImplementedException(); + } - #endregion ILogLineColumnizer implementation + public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) + { } + + #endregion ILogLineColumnizer implementation } \ No newline at end of file diff --git a/src/ColumnizerLib.UnitTests/ColumnTests.cs b/src/ColumnizerLib.UnitTests/ColumnTests.cs index 78c8c57c..649b132a 100644 --- a/src/ColumnizerLib.UnitTests/ColumnTests.cs +++ b/src/ColumnizerLib.UnitTests/ColumnTests.cs @@ -3,83 +3,82 @@ using System; using System.Text; -namespace ColumnizerLib.UnitTests +namespace ColumnizerLib.UnitTests; + +[TestFixture] +public class ColumnTests { - [TestFixture] - public class ColumnTests + [Test] + public void Column_LineCutOf() { - [Test] - public void Column_LineCutOf() + Column column = new(); + + StringBuilder builder = new(); + + for (var i = 0; i < 4675; i++) { - Column column = new(); + builder.Append("6"); + } - StringBuilder builder = new(); + var expected = builder + "..."; + builder.Append("1234"); - for (var i = 0; i < 4675; i++) - { - builder.Append("6"); - } + column.FullValue = builder.ToString(); - var expected = builder + "..."; - builder.Append("1234"); + Assert.That(column.DisplayValue, Is.EqualTo(expected)); + Assert.That(column.FullValue, Is.EqualTo(builder.ToString())); + } - column.FullValue = builder.ToString(); + [Test] + public void Column_NoLineCutOf() + { + Column column = new(); - Assert.That(column.DisplayValue, Is.EqualTo(expected)); - Assert.That(column.FullValue, Is.EqualTo(builder.ToString())); - } + StringBuilder builder = new(); - [Test] - public void Column_NoLineCutOf() + for (var i = 0; i < 4675; i++) { - Column column = new(); + builder.Append("6"); + } + + var expected = builder.ToString(); - StringBuilder builder = new(); + column.FullValue = expected; - for (var i = 0; i < 4675; i++) - { - builder.Append("6"); - } + Assert.That(column.DisplayValue, Is.EqualTo(expected)); + Assert.That(column.FullValue, Is.EqualTo(expected)); + } - var expected = builder.ToString(); + [Test] + public void Column_NullCharReplacement() + { + Column column = new(); - column.FullValue = expected; + column.FullValue = "asdf\0"; - Assert.That(column.DisplayValue, Is.EqualTo(expected)); - Assert.That(column.FullValue, Is.EqualTo(expected)); + //Switch between the different implementation for the windows versions + //Not that great solution but currently I'm out of ideas, I know that currently + //only one implementation depending on the windows version is executed + if (Environment.Version >= Version.Parse("6.2")) + { + Assert.That(column.DisplayValue, Is.EqualTo("asdf␀")); } - - [Test] - public void Column_NullCharReplacement() + else { - Column column = new(); - - column.FullValue = "asdf\0"; - - //Switch between the different implementation for the windows versions - //Not that great solution but currently I'm out of ideas, I know that currently - //only one implementation depending on the windows version is executed - if (Environment.Version >= Version.Parse("6.2")) - { - Assert.That(column.DisplayValue, Is.EqualTo("asdf␀")); - } - else - { - Assert.That(column.DisplayValue, Is.EqualTo("asdf ")); - } - - Assert.That(column.FullValue, Is.EqualTo("asdf\0")); + Assert.That(column.DisplayValue, Is.EqualTo("asdf ")); } - [Test] - public void Column_TabReplacement() - { - Column column = new(); + Assert.That(column.FullValue, Is.EqualTo("asdf\0")); + } + + [Test] + public void Column_TabReplacement() + { + Column column = new(); - column.FullValue = "asdf\t"; + column.FullValue = "asdf\t"; - Assert.That(column.DisplayValue, Is.EqualTo("asdf ")); - Assert.That(column.FullValue, Is.EqualTo("asdf\t")); - } + Assert.That(column.DisplayValue, Is.EqualTo("asdf ")); + Assert.That(column.FullValue, Is.EqualTo("asdf\t")); } } \ No newline at end of file diff --git a/src/ColumnizerLib.UnitTests/Extensions/LogLineExtensionsTests.cs b/src/ColumnizerLib.UnitTests/Extensions/LogLineExtensionsTests.cs index 47ace2eb..c6746b62 100644 --- a/src/ColumnizerLib.UnitTests/Extensions/LogLineExtensionsTests.cs +++ b/src/ColumnizerLib.UnitTests/Extensions/LogLineExtensionsTests.cs @@ -3,31 +3,30 @@ using NUnit.Framework; -namespace ColumnizerLib.UnitTests.Extensions -{ - [TestFixture] +namespace ColumnizerLib.UnitTests.Extensions; + +[TestFixture] - internal class LogLineExtensionsTests +internal class LogLineExtensionsTests +{ + private class TestingLogLine : ILogLine { - private class TestingLogLine : ILogLine - { - public string FullLine { get; set; } + public string FullLine { get; set; } - public int LineNumber { get; set; } + public int LineNumber { get; set; } - public string Text { get; set; } - } + public string Text { get; set; } + } - [Test] - public void ToClipBoardText_ReturnsExpected() + [Test] + public void ToClipBoardText_ReturnsExpected() + { + var underTest = new TestingLogLine { - var underTest = new TestingLogLine - { - FullLine = "a fullLine", - LineNumber = 89, - Text = "a text" - }; - Assert.That(underTest.ToClipBoardText(), Is.EqualTo("\t90\ta fullLine")); - } + FullLine = "a fullLine", + LineNumber = 89, + Text = "a text" + }; + Assert.That(underTest.ToClipBoardText(), Is.EqualTo("\t90\ta fullLine")); } } diff --git a/src/ColumnizerLib/Column.cs b/src/ColumnizerLib/Column.cs index a0425b2c..03fb37b6 100644 --- a/src/ColumnizerLib/Column.cs +++ b/src/ColumnizerLib/Column.cs @@ -1,117 +1,116 @@ using System; using System.Collections.Generic; -namespace LogExpert +namespace LogExpert; + +public class Column : IColumn { - public class Column : IColumn - { - #region Fields + #region Fields - private static readonly int _maxLength = 4678 - 3; - private static readonly string _replacement = "..."; + private static readonly int _maxLength = 4678 - 3; + private static readonly string _replacement = "..."; - private static readonly IEnumerable> _replacements; + private static readonly IEnumerable> _replacements; - private string _fullValue; + private string _fullValue; - #endregion + #endregion - #region cTor + #region cTor - static Column() - { - var replacements = new List>( - new Func[] - { - //replace tab with 3 spaces, from old coding. Needed??? - input => input.Replace("\t", " "), + static Column() + { + var replacements = new List>( + new Func[] + { + //replace tab with 3 spaces, from old coding. Needed??? + input => input.Replace("\t", " "), - //shorten string if it exceeds maxLength - input => + //shorten string if it exceeds maxLength + input => + { + if (input.Length > _maxLength) { - if (input.Length > _maxLength) - { - return input.Substring(0, _maxLength) + _replacement; - } - - return input; + return input.Substring(0, _maxLength) + _replacement; } - }); - - if (Environment.Version >= Version.Parse("6.2")) - { - //Win8 or newer support full UTF8 chars with the preinstalled fonts. - //Replace null char with UTF8 Symbol U+2400 (␀) - replacements.Add(input => input.Replace("\0", "␀")); - } - else - { - //Everything below Win8 the installed fonts seems to not to support reliabel - //Replace null char with space - replacements.Add(input => input.Replace("\0", " ")); - } - _replacements = replacements; + return input; + } + }); - EmptyColumn = new Column {FullValue = string.Empty}; + if (Environment.Version >= Version.Parse("6.2")) + { + //Win8 or newer support full UTF8 chars with the preinstalled fonts. + //Replace null char with UTF8 Symbol U+2400 (␀) + replacements.Add(input => input.Replace("\0", "␀")); + } + else + { + //Everything below Win8 the installed fonts seems to not to support reliabel + //Replace null char with space + replacements.Add(input => input.Replace("\0", " ")); } - #endregion + _replacements = replacements; - #region Properties + EmptyColumn = new Column {FullValue = string.Empty}; + } - public static IColumn EmptyColumn { get; } + #endregion - public IColumnizedLogLine Parent { get; set; } + #region Properties - public string FullValue - { - get => _fullValue; - set - { - _fullValue = value; + public static IColumn EmptyColumn { get; } - var temp = FullValue; + public IColumnizedLogLine Parent { get; set; } - foreach (var replacement in _replacements) - { - temp = replacement(temp); - } + public string FullValue + { + get => _fullValue; + set + { + _fullValue = value; - DisplayValue = temp; - } - } + var temp = FullValue; - public string DisplayValue { get; private set; } + foreach (var replacement in _replacements) + { + temp = replacement(temp); + } - string ITextValue.Text => DisplayValue; + DisplayValue = temp; + } + } - #endregion + public string DisplayValue { get; private set; } - #region Public methods + string ITextValue.Text => DisplayValue; - public static Column[] CreateColumns(int count, IColumnizedLogLine parent) - { - return CreateColumns(count, parent, string.Empty); - } + #endregion - public static Column[] CreateColumns(int count, IColumnizedLogLine parent, string defaultValue) - { - var output = new Column[count]; + #region Public methods - for (var i = 0; i < count; i++) - { - output[i] = new Column {FullValue = defaultValue, Parent = parent}; - } + public static Column[] CreateColumns(int count, IColumnizedLogLine parent) + { + return CreateColumns(count, parent, string.Empty); + } - return output; - } + public static Column[] CreateColumns(int count, IColumnizedLogLine parent, string defaultValue) + { + var output = new Column[count]; - public override string ToString() + for (var i = 0; i < count; i++) { - return DisplayValue ?? string.Empty; + output[i] = new Column {FullValue = defaultValue, Parent = parent}; } - #endregion + return output; } + + public override string ToString() + { + return DisplayValue ?? string.Empty; + } + + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/ColumnizedLogLine.cs b/src/ColumnizerLib/ColumnizedLogLine.cs index 41a14e6f..47891d74 100644 --- a/src/ColumnizerLib/ColumnizedLogLine.cs +++ b/src/ColumnizerLib/ColumnizedLogLine.cs @@ -1,13 +1,12 @@ -namespace LogExpert +namespace LogExpert; + +public class ColumnizedLogLine : IColumnizedLogLine { - public class ColumnizedLogLine : IColumnizedLogLine - { - #region Properties + #region Properties - public ILogLine LogLine { get; set; } + public ILogLine LogLine { get; set; } - public IColumn[] ColumnValues { get; set; } + public IColumn[] ColumnValues { get; set; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/Extensions/LogLineExtensions.cs b/src/ColumnizerLib/Extensions/LogLineExtensions.cs index 44077eb7..659ff75e 100644 --- a/src/ColumnizerLib/Extensions/LogLineExtensions.cs +++ b/src/ColumnizerLib/Extensions/LogLineExtensions.cs @@ -1,10 +1,9 @@ -namespace LogExpert.Extensions +namespace LogExpert.Extensions; + +public static class LogLineExtensions { - public static class LogLineExtensions + public static string ToClipBoardText(this ILogLine logLine) { - public static string ToClipBoardText(this ILogLine logLine) - { - return "\t" + (logLine.LineNumber + 1).ToString() + "\t" + logLine.FullLine; - } + return "\t" + (logLine.LineNumber + 1).ToString() + "\t" + logLine.FullLine; } } \ No newline at end of file diff --git a/src/ColumnizerLib/IAutoLogLineColumnizerCallback.cs b/src/ColumnizerLib/IAutoLogLineColumnizerCallback.cs index 25b315d9..7206b8c9 100644 --- a/src/ColumnizerLib/IAutoLogLineColumnizerCallback.cs +++ b/src/ColumnizerLib/IAutoLogLineColumnizerCallback.cs @@ -1,12 +1,11 @@ -namespace LogExpert +namespace LogExpert; + +public interface IAutoLogLineColumnizerCallback { - public interface IAutoLogLineColumnizerCallback - { - /// - /// Returns the log line with the given index (zero-based). - /// - /// Number of the line to be retrieved - /// A string with line content or null if line number is out of range - ILogLine GetLogLine (int lineNum); - } + /// + /// Returns the log line with the given index (zero-based). + /// + /// Number of the line to be retrieved + /// A string with line content or null if line number is out of range + ILogLine GetLogLine (int lineNum); } \ No newline at end of file diff --git a/src/ColumnizerLib/IColumn.cs b/src/ColumnizerLib/IColumn.cs index d9abc0ab..57ba40bd 100644 --- a/src/ColumnizerLib/IColumn.cs +++ b/src/ColumnizerLib/IColumn.cs @@ -3,18 +3,17 @@ using System.Linq; using System.Text; -namespace LogExpert +namespace LogExpert; + +public interface IColumn : ITextValue { - public interface IColumn : ITextValue - { - #region Properties + #region Properties - IColumnizedLogLine Parent { get; } + IColumnizedLogLine Parent { get; } - string FullValue { get; } + string FullValue { get; } - string DisplayValue { get; } + string DisplayValue { get; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/IColumnizedLogLine.cs b/src/ColumnizerLib/IColumnizedLogLine.cs index 491c78f3..dad1ee46 100644 --- a/src/ColumnizerLib/IColumnizedLogLine.cs +++ b/src/ColumnizerLib/IColumnizedLogLine.cs @@ -3,17 +3,16 @@ using System.Linq; using System.Text; -namespace LogExpert +namespace LogExpert; + +public interface IColumnizedLogLine { - public interface IColumnizedLogLine - { - #region Properties + #region Properties - ILogLine LogLine { get; } + ILogLine LogLine { get; } - IColumn[] ColumnValues { get; } + IColumn[] ColumnValues { get; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/IColumnizerConfigurator.cs b/src/ColumnizerLib/IColumnizerConfigurator.cs index a9a953e2..a9249d06 100644 --- a/src/ColumnizerLib/IColumnizerConfigurator.cs +++ b/src/ColumnizerLib/IColumnizerConfigurator.cs @@ -1,46 +1,45 @@  -namespace LogExpert +namespace LogExpert; + +/// +/// A Columnizer can implement this interface if it has to show an own settings dialog to the user. +/// The Config button in LogExpert's columnizer dialog is enabled if a Columnizer implements this interface. +/// If you don't need a config dialog you don't have to implement this interface. +/// +public interface IColumnizerConfigurator { + #region Public methods + /// - /// A Columnizer can implement this interface if it has to show an own settings dialog to the user. - /// The Config button in LogExpert's columnizer dialog is enabled if a Columnizer implements this interface. - /// If you don't need a config dialog you don't have to implement this interface. + /// This function is called if the user presses the Config button on the Columnizer dialog. + /// Its up to the Columnizer plugin to show an own configuration dialog and store all + /// required settings. /// - public interface IColumnizerConfigurator - { - #region Public methods - - /// - /// This function is called if the user presses the Config button on the Columnizer dialog. - /// Its up to the Columnizer plugin to show an own configuration dialog and store all - /// required settings. - /// - /// Callback interface with functions which can be used by the columnizer - /// The complete path to the directory where LogExpert stores its settings. - /// You can use this directory, if you want to. Please don't use the file name "settings.dat", because this - /// name is used by LogExpert. - /// - /// - /// This is the place to show a configuration dialog to the user. You have to handle all dialog stuff by yourself. - /// It's also your own job to store the configuration in a config file or on the registry. - /// The callback is passed to this function just in case you need the file name of the current log file - /// or the line count etc. You can also use it to store different settings for every log file. - /// You can use the callback to distinguish between different files. Its passed to all important - /// functions in the Columnizer. - /// - void Configure(ILogLineColumnizerCallback callback, string configDir); + /// Callback interface with functions which can be used by the columnizer + /// The complete path to the directory where LogExpert stores its settings. + /// You can use this directory, if you want to. Please don't use the file name "settings.dat", because this + /// name is used by LogExpert. + /// + /// + /// This is the place to show a configuration dialog to the user. You have to handle all dialog stuff by yourself. + /// It's also your own job to store the configuration in a config file or on the registry. + /// The callback is passed to this function just in case you need the file name of the current log file + /// or the line count etc. You can also use it to store different settings for every log file. + /// You can use the callback to distinguish between different files. Its passed to all important + /// functions in the Columnizer. + /// + void Configure(ILogLineColumnizerCallback callback, string configDir); - /// - /// This function will be called right after LogExpert has loaded your Columnizer class. Use this - /// to load the configuration which was saved in the Configure() function. - /// You have to hold the loaded config data in your Columnizer object. - /// - /// The complete path to the directory where LogExpert stores its settings. - /// You can use this directory, if you want to. Please don't use the file name "settings.dat", because this - /// name is used by LogExpert. - /// - void LoadConfig(string configDir); + /// + /// This function will be called right after LogExpert has loaded your Columnizer class. Use this + /// to load the configuration which was saved in the Configure() function. + /// You have to hold the loaded config data in your Columnizer object. + /// + /// The complete path to the directory where LogExpert stores its settings. + /// You can use this directory, if you want to. Please don't use the file name "settings.dat", because this + /// name is used by LogExpert. + /// + void LoadConfig(string configDir); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/IColumnizerPriority.cs b/src/ColumnizerLib/IColumnizerPriority.cs index 5cf85770..2ee01840 100644 --- a/src/ColumnizerLib/IColumnizerPriority.cs +++ b/src/ColumnizerLib/IColumnizerPriority.cs @@ -3,16 +3,15 @@ using System.Linq; using System.Text; -namespace LogExpert +namespace LogExpert; + +public interface IColumnizerPriority { - public interface IColumnizerPriority - { - /// - /// Get the priority for this columnizer so the up layer can decide which columnizer is the best fitted one. - /// - /// - /// - /// - Priority GetPriority(string fileName, IEnumerable samples); - } + /// + /// Get the priority for this columnizer so the up layer can decide which columnizer is the best fitted one. + /// + /// + /// + /// + Priority GetPriority(string fileName, IEnumerable samples); } \ No newline at end of file diff --git a/src/ColumnizerLib/IContextMenuEntry.cs b/src/ColumnizerLib/IContextMenuEntry.cs index c23f78c7..bc59df1e 100644 --- a/src/ColumnizerLib/IContextMenuEntry.cs +++ b/src/ColumnizerLib/IContextMenuEntry.cs @@ -1,58 +1,57 @@ using System.Collections.Generic; -namespace LogExpert +namespace LogExpert; + +/// +/// Implement this interface to add a menu entry to the context menu of LogExpert. +/// +/// +/// +/// The methods in this interface will be called in the GUI thread. So make sure that there's no +/// heavyweight work to do in your implementations. +/// +/// +public interface IContextMenuEntry { + #region Public methods + /// - /// Implement this interface to add a menu entry to the context menu of LogExpert. + /// This function is called from LogExpert if the context menu is about to be displayed. + /// Your implementation can control whether LogExpert will show a menu entry by returning + /// an appropriate value.

    ///
    - /// - /// - /// The methods in this interface will be called in the GUI thread. So make sure that there's no - /// heavyweight work to do in your implementations. - /// - /// - public interface IContextMenuEntry - { - #region Public methods - - /// - /// This function is called from LogExpert if the context menu is about to be displayed. - /// Your implementation can control whether LogExpert will show a menu entry by returning - /// an appropriate value.

    - ///
    - /// A list containing all selected line numbers. - /// The currently selected Columnizer. You can use it to split log lines, - /// if necessary. - /// The callback interface implemented by LogExpert. You can use the functions - /// for retrieving log lines or pass it along to functions of the Columnizer if needed. - /// - /// Return the string which should be displayed in the context menu.

    - /// You can control the menu behaviour by returning the the following values:

    - ///
      - ///
    • Normal string: The string is displayed as a menu entry
    • - ///
    • String starting with underscore: The string is displayed as a disabled menu entry
    • - ///
    • null: No menu entry is displayed.
    • - ///
    - ///
    - string GetMenuText(IList lines, ILogLineColumnizer columnizer, ILogExpertCallback callback); - - string GetMenuText(int linesCount, ILogLineColumnizer columnizer, ILogLine line); - - - /// - /// This function is called from LogExpert if the menu entry is choosen by the user.

    - /// Note that this function is called from the GUI thread. So try to avoid time consuming operations. - ///
    - /// A list containing all selected line numbers. - /// The currently selected Columnizer. You can use it to split log lines, - /// if necessary. - /// The callback interface implemented by LogExpert. You can use the functions - /// for retrieving log lines or pass it along to functions of the Columnizer if needed. - void MenuSelected(IList lines, ILogLineColumnizer columnizer, ILogExpertCallback callback); - - void MenuSelected(int linesCount, ILogLineColumnizer columnizer, ILogLine line); - - #endregion - } + /// A list containing all selected line numbers. + /// The currently selected Columnizer. You can use it to split log lines, + /// if necessary. + /// The callback interface implemented by LogExpert. You can use the functions + /// for retrieving log lines or pass it along to functions of the Columnizer if needed. + /// + /// Return the string which should be displayed in the context menu.

    + /// You can control the menu behaviour by returning the the following values:

    + ///
      + ///
    • Normal string: The string is displayed as a menu entry
    • + ///
    • String starting with underscore: The string is displayed as a disabled menu entry
    • + ///
    • null: No menu entry is displayed.
    • + ///
    + ///
    + string GetMenuText(IList lines, ILogLineColumnizer columnizer, ILogExpertCallback callback); + + string GetMenuText(int linesCount, ILogLineColumnizer columnizer, ILogLine line); + + + /// + /// This function is called from LogExpert if the menu entry is choosen by the user.

    + /// Note that this function is called from the GUI thread. So try to avoid time consuming operations. + ///
    + /// A list containing all selected line numbers. + /// The currently selected Columnizer. You can use it to split log lines, + /// if necessary. + /// The callback interface implemented by LogExpert. You can use the functions + /// for retrieving log lines or pass it along to functions of the Columnizer if needed. + void MenuSelected(IList lines, ILogLineColumnizer columnizer, ILogExpertCallback callback); + + void MenuSelected(int linesCount, ILogLineColumnizer columnizer, ILogLine line); + + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/IFileSystemCallback.cs b/src/ColumnizerLib/IFileSystemCallback.cs index bac789b7..faac1728 100644 --- a/src/ColumnizerLib/IFileSystemCallback.cs +++ b/src/ColumnizerLib/IFileSystemCallback.cs @@ -2,21 +2,20 @@ using System.Collections.Generic; using System.Text; -namespace LogExpert +namespace LogExpert; + +/// +/// Service interface implemented by LogExpert. This can be used by IFileSystemPlugin implementations to get certain services. +/// +public interface IFileSystemCallback { + #region Public methods + /// - /// Service interface implemented by LogExpert. This can be used by IFileSystemPlugin implementations to get certain services. + /// Retrieve a logger. The plugin can use the logger to write log messages into LogExpert's log file. /// - public interface IFileSystemCallback - { - #region Public methods - - /// - /// Retrieve a logger. The plugin can use the logger to write log messages into LogExpert's log file. - /// - /// - ILogExpertLogger GetLogger(); + /// + ILogExpertLogger GetLogger(); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/IFileSystemPlugin.cs b/src/ColumnizerLib/IFileSystemPlugin.cs index 985edf9b..8e86be48 100644 --- a/src/ColumnizerLib/IFileSystemPlugin.cs +++ b/src/ColumnizerLib/IFileSystemPlugin.cs @@ -1,46 +1,45 @@ -namespace LogExpert +namespace LogExpert; + +/// +/// Interface for file system plugins. A file system plugin is responsible for feeding file data to LogExpert. +/// +/// +/// LogExperts file handling is done via file system plugins. The selection if the appropriate plugin for a file is based +/// on URI schemes. If a file system plugin returns true to the method, it will be selected +/// to handle a file. +/// +public interface IFileSystemPlugin { + #region Properties + + /// + /// Name of the plugin. Will be used in the Settings dialog. + /// + string Text { get; } + + /// + /// Short description. Currently unused, but maybe used later for displaying a short info about the plugin. + /// + string Description { get; } + + #endregion + + #region Public methods + /// - /// Interface for file system plugins. A file system plugin is responsible for feeding file data to LogExpert. + /// Called from LogExpert to determine a file system plugin for a given URI. /// - /// - /// LogExperts file handling is done via file system plugins. The selection if the appropriate plugin for a file is based - /// on URI schemes. If a file system plugin returns true to the method, it will be selected - /// to handle a file. - /// - public interface IFileSystemPlugin - { - #region Properties - - /// - /// Name of the plugin. Will be used in the Settings dialog. - /// - string Text { get; } - - /// - /// Short description. Currently unused, but maybe used later for displaying a short info about the plugin. - /// - string Description { get; } - - #endregion - - #region Public methods - - /// - /// Called from LogExpert to determine a file system plugin for a given URI. - /// - /// The URI of the file to be loaded. - /// Return true if the file system plugin can handle the URI. - bool CanHandleUri(string uriString); - - /// - /// Return a file system specific implementation of here. - /// The method is called from LogExpert when a file is about to be opened. It's called after was called. - /// - /// - /// - ILogFileInfo GetLogfileInfo(string uriString); - - #endregion - } + /// The URI of the file to be loaded. + /// Return true if the file system plugin can handle the URI. + bool CanHandleUri(string uriString); + + /// + /// Return a file system specific implementation of here. + /// The method is called from LogExpert when a file is about to be opened. It's called after was called. + /// + /// + /// + ILogFileInfo GetLogfileInfo(string uriString); + + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/IInitColumnizer.cs b/src/ColumnizerLib/IInitColumnizer.cs index 6c90ae49..586f9af5 100644 --- a/src/ColumnizerLib/IInitColumnizer.cs +++ b/src/ColumnizerLib/IInitColumnizer.cs @@ -2,41 +2,40 @@ using System.Collections.Generic; using System.Text; -namespace LogExpert +namespace LogExpert; + +/// +/// Implement this interface in your columnizer if you need to do some initialization work +/// every time the columnizer is selected. +/// +/// +/// +/// The methods in this interface will be called in the GUI thread. So make sure that there's no +/// heavyweight work to do in your implementations. +/// +/// If a file is reloaded, the current Columnizer is set again. That means that the methods of this +/// interface will be called again. Generally you should do no assumptions about how often the +/// methods will be called. The file is already loaded when the columnizer is set. So +/// you can use the methods in the given callbacks to get informations about the file or to +/// retrieve specific lines. +/// +/// +public interface IInitColumnizer { + #region Public methods + /// - /// Implement this interface in your columnizer if you need to do some initialization work - /// every time the columnizer is selected. + /// This method is called when the Columnizer is selected as the current columnizer. /// - /// - /// - /// The methods in this interface will be called in the GUI thread. So make sure that there's no - /// heavyweight work to do in your implementations. - /// - /// If a file is reloaded, the current Columnizer is set again. That means that the methods of this - /// interface will be called again. Generally you should do no assumptions about how often the - /// methods will be called. The file is already loaded when the columnizer is set. So - /// you can use the methods in the given callbacks to get informations about the file or to - /// retrieve specific lines. - /// - /// - public interface IInitColumnizer - { - #region Public methods - - /// - /// This method is called when the Columnizer is selected as the current columnizer. - /// - /// Callback that can be used to retrieve some informations, if needed. - void Selected(ILogLineColumnizerCallback callback); + /// Callback that can be used to retrieve some informations, if needed. + void Selected(ILogLineColumnizerCallback callback); - /// - /// This method is called when the Columnizer is de-selected (i.e. when another Columnizer is - /// selected). - /// - /// Callback that can be used to retrieve some informations, if needed. - void DeSelected(ILogLineColumnizerCallback callback); + /// + /// This method is called when the Columnizer is de-selected (i.e. when another Columnizer is + /// selected). + /// + /// Callback that can be used to retrieve some informations, if needed. + void DeSelected(ILogLineColumnizerCallback callback); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/IKeywordAction.cs b/src/ColumnizerLib/IKeywordAction.cs index 1329f36d..04d6259d 100644 --- a/src/ColumnizerLib/IKeywordAction.cs +++ b/src/ColumnizerLib/IKeywordAction.cs @@ -2,50 +2,49 @@ using System.Collections.Generic; using System.Text; -namespace LogExpert +namespace LogExpert; + +/// +/// Implement this interface to execute a self defined action when LogExpert detects a +/// keyword on incomig log file content. +/// These kind of plugins can be used in the "Highlight and Action Triggers" dialog. +/// +public interface IKeywordAction { + #region Public methods + /// - /// Implement this interface to execute a self defined action when LogExpert detects a - /// keyword on incomig log file content. - /// These kind of plugins can be used in the "Highlight and Action Triggers" dialog. + /// Is called when LogExpert detects a keyword match which is configured for this plugin. + /// The keywords are configured in the Highlight dialog. + /// You have to implement this method to execute your desired actions. /// - public interface IKeywordAction - { - #region Public methods + /// The keyword which triggered the call. + /// The parameter configured for the plugin launch (in the Highlight dialog). + /// A callback which can be used by the plugin. + /// The current columnizer. Can be used to obtain timestamps + /// (if supported by Columnizer) or to split the log line into fields. + /// + /// This method is called in a background thread from the process' thread pool (using BeginInvoke()). + /// So you cannot rely on state information retrieved by the given callback. E.g. the line count + /// may change during the execution of the method. The only exception from this rule is the current line number + /// retrieved from the callback. This is of course the line number of the line that has triggered + /// the keyword match. + /// + void Execute(string keyword, string param, ILogExpertCallback callback, ILogLineColumnizer columnizer); - /// - /// Is called when LogExpert detects a keyword match which is configured for this plugin. - /// The keywords are configured in the Highlight dialog. - /// You have to implement this method to execute your desired actions. - /// - /// The keyword which triggered the call. - /// The parameter configured for the plugin launch (in the Highlight dialog). - /// A callback which can be used by the plugin. - /// The current columnizer. Can be used to obtain timestamps - /// (if supported by Columnizer) or to split the log line into fields. - /// - /// This method is called in a background thread from the process' thread pool (using BeginInvoke()). - /// So you cannot rely on state information retrieved by the given callback. E.g. the line count - /// may change during the execution of the method. The only exception from this rule is the current line number - /// retrieved from the callback. This is of course the line number of the line that has triggered - /// the keyword match. - /// - void Execute(string keyword, string param, ILogExpertCallback callback, ILogLineColumnizer columnizer); - - /// - /// Return the name of your plugin here. The returned name is used for displaying the plugin list - /// in the settings. - /// - /// The name of the plugin. - string GetName(); + /// + /// Return the name of your plugin here. The returned name is used for displaying the plugin list + /// in the settings. + /// + /// The name of the plugin. + string GetName(); - /// - /// Return a description of your plugin here. E.g. a short explanation of parameters. The descriptions - /// will be displayed in the plugin chooser dialog which is used by the Highlight settings. - /// - /// The description of the plugin. - string GetDescription(); + /// + /// Return a description of your plugin here. E.g. a short explanation of parameters. The descriptions + /// will be displayed in the plugin chooser dialog which is used by the Highlight settings. + /// + /// The description of the plugin. + string GetDescription(); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/ILogExpertCallback.cs b/src/ColumnizerLib/ILogExpertCallback.cs index 9f1a96d9..d1ddca26 100644 --- a/src/ColumnizerLib/ILogExpertCallback.cs +++ b/src/ColumnizerLib/ILogExpertCallback.cs @@ -1,66 +1,65 @@ using System.Collections.Generic; -namespace LogExpert +namespace LogExpert; + +/// +/// This callback interface is implemented by LogExpert. You can use it e.g. when implementing a +/// context menu plugin. +/// +public interface ILogExpertCallback : ILogLineColumnizerCallback { + #region Public methods + /// - /// This callback interface is implemented by LogExpert. You can use it e.g. when implementing a - /// context menu plugin. + /// Call this function to add a new temporary file tab to LogExpert. This may be usefull + /// if your plugin creates some output into a file which has to be shown in LogExpert. /// - public interface ILogExpertCallback : ILogLineColumnizerCallback - { - #region Public methods + /// Path of the file to be loaded. + /// Title shown on the tab. + /// + /// The file tab is internally handled like the temp file tabs which LogExpert uses for + /// FilterTabs or clipboard copy tabs. + /// This has some implications: + ///
      + ///
    • The file path is not shown. Only the title is shown.
    • + ///
    • The encoding of the file is expected to be 2-byte Unicode!
    • + ///
    • The file will not be added to the history of opened files.
    • + ///
    • The file will be deleted when closing the tab!
    • + ///
    + ///
    + void AddTempFileTab(string fileName, string title); - /// - /// Call this function to add a new temporary file tab to LogExpert. This may be usefull - /// if your plugin creates some output into a file which has to be shown in LogExpert. - /// - /// Path of the file to be loaded. - /// Title shown on the tab. - /// - /// The file tab is internally handled like the temp file tabs which LogExpert uses for - /// FilterTabs or clipboard copy tabs. - /// This has some implications: - ///
      - ///
    • The file path is not shown. Only the title is shown.
    • - ///
    • The encoding of the file is expected to be 2-byte Unicode!
    • - ///
    • The file will not be added to the history of opened files.
    • - ///
    • The file will be deleted when closing the tab!
    • - ///
    - ///
    - void AddTempFileTab(string fileName, string title); - - /// - /// With this function you can create a new tab and add a bunch of text lines to it. - /// - /// A list with LineEntry items containing text and an - /// optional reference to the original file location. - /// The title for the new tab. - /// - /// - /// The lines are given by a list of . If you set the lineNumber field - /// in each LineEntry to a lineNumber of the original logfile (the logfile for which the context - /// menu is called for), you can create a 'link' from the line of your 'target output' to a line - /// in the 'source tab'. - /// - /// - /// The user can then navigate from the line in the new tab to the referenced - /// line in the original file (by using "locate in original file" from the context menu). - /// This is especially useful for plugins that generate output lines which are directly associated - /// to the selected input lines. - /// - /// - /// If you can't provide a reference to a location in the logfile, set the line number to -1. This - /// will disable the "locate in original file" menu entry. - /// - /// - void AddPipedTab(IList lineEntryList, string title); + /// + /// With this function you can create a new tab and add a bunch of text lines to it. + /// + /// A list with LineEntry items containing text and an + /// optional reference to the original file location. + /// The title for the new tab. + /// + /// + /// The lines are given by a list of . If you set the lineNumber field + /// in each LineEntry to a lineNumber of the original logfile (the logfile for which the context + /// menu is called for), you can create a 'link' from the line of your 'target output' to a line + /// in the 'source tab'. + /// + /// + /// The user can then navigate from the line in the new tab to the referenced + /// line in the original file (by using "locate in original file" from the context menu). + /// This is especially useful for plugins that generate output lines which are directly associated + /// to the selected input lines. + /// + /// + /// If you can't provide a reference to a location in the logfile, set the line number to -1. This + /// will disable the "locate in original file" menu entry. + /// + /// + void AddPipedTab(IList lineEntryList, string title); - /// - /// Returns the title of the current tab (the tab for which the context menu plugin was called for). - /// - /// - string GetTabTitle(); + /// + /// Returns the title of the current tab (the tab for which the context menu plugin was called for). + /// + /// + string GetTabTitle(); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/ILogExpertLogger.cs b/src/ColumnizerLib/ILogExpertLogger.cs index aec36cfe..cb9405d2 100644 --- a/src/ColumnizerLib/ILogExpertLogger.cs +++ b/src/ColumnizerLib/ILogExpertLogger.cs @@ -2,43 +2,42 @@ using System.Collections.Generic; using System.Text; -namespace LogExpert +namespace LogExpert; + +/// +/// Simple Logger interface to let plugins log into LogExpert's application log file. +/// +public interface ILogExpertLogger { + #region Public methods + /// - /// Simple Logger interface to let plugins log into LogExpert's application log file. + /// Logs a message on INFO level to LogExpert#s log file. The logfile is only active in debug builds. + /// The logger in LogExpert will automatically add the class and the method name of the caller. /// - public interface ILogExpertLogger - { - #region Public methods - - /// - /// Logs a message on INFO level to LogExpert#s log file. The logfile is only active in debug builds. - /// The logger in LogExpert will automatically add the class and the method name of the caller. - /// - /// A message to be logged. - void Info(string msg); + /// A message to be logged. + void Info(string msg); - /// - /// Logs a message on DEBUG level to LogExpert#s log file. The logfile is only active in debug builds. - /// The logger in LogExpert will automatically add the class and the method name of the caller. - /// - /// A message to be logged. - void Debug(string msg); + /// + /// Logs a message on DEBUG level to LogExpert#s log file. The logfile is only active in debug builds. + /// The logger in LogExpert will automatically add the class and the method name of the caller. + /// + /// A message to be logged. + void Debug(string msg); - /// - /// Logs a message on WARN level to LogExpert#s log file. The logfile is only active in debug builds. - /// The logger in LogExpert will automatically add the class and the method name of the caller. - /// - /// A message to be logged. - void LogWarn(string msg); + /// + /// Logs a message on WARN level to LogExpert#s log file. The logfile is only active in debug builds. + /// The logger in LogExpert will automatically add the class and the method name of the caller. + /// + /// A message to be logged. + void LogWarn(string msg); - /// - /// Logs a message on ERROR level to LogExpert#s log file. The logfile is only active in debug builds. - /// The logger in LogExpert will automatically add the class and the method name of the caller. - /// - /// A message to be logged. - void LogError(string msg); + /// + /// Logs a message on ERROR level to LogExpert#s log file. The logfile is only active in debug builds. + /// The logger in LogExpert will automatically add the class and the method name of the caller. + /// + /// A message to be logged. + void LogError(string msg); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/ILogExpertPlugin.cs b/src/ColumnizerLib/ILogExpertPlugin.cs index 041e64d5..51c40971 100644 --- a/src/ColumnizerLib/ILogExpertPlugin.cs +++ b/src/ColumnizerLib/ILogExpertPlugin.cs @@ -2,27 +2,26 @@ using System.Collections.Generic; using System.Text; -namespace LogExpert +namespace LogExpert; + +/// +/// Implement this interface to get notified of various global events in LogExpert. +/// The interface can be implemented by all currently known type of LogExpert plugins (Columnizers, +/// keyword plugins, context menu plugins). +/// +public interface ILogExpertPlugin { + #region Public methods + /// - /// Implement this interface to get notified of various global events in LogExpert. - /// The interface can be implemented by all currently known type of LogExpert plugins (Columnizers, - /// keyword plugins, context menu plugins). + /// Called on application exit. May be used for cleanup purposes, /// - public interface ILogExpertPlugin - { - #region Public methods - - /// - /// Called on application exit. May be used for cleanup purposes, - /// - void AppExiting(); + void AppExiting(); - /// - /// Called when the plugin is loaded at plugin registration while LogExpert startup. - /// - void PluginLoaded(); + /// + /// Called when the plugin is loaded at plugin registration while LogExpert startup. + /// + void PluginLoaded(); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/ILogExpertPluginConfigurator.cs b/src/ColumnizerLib/ILogExpertPluginConfigurator.cs index c142541b..9981528c 100644 --- a/src/ColumnizerLib/ILogExpertPluginConfigurator.cs +++ b/src/ColumnizerLib/ILogExpertPluginConfigurator.cs @@ -2,92 +2,91 @@ using System.Collections.Generic; using System.Text; -namespace LogExpert +namespace LogExpert; + +/// +/// If your context menu plugin or keyword action plugin has some configuration it should +/// implement this interface. +/// When your plugin has implemented this interface, it will get notified if it has to +/// show a config dialog and to save/load config data.

    +/// Like in the IColumnizerConfigurator, you have to do all the saving and loading stuff +/// by yourself. +///
    +public interface ILogExpertPluginConfigurator { + #region Public methods + /// - /// If your context menu plugin or keyword action plugin has some configuration it should - /// implement this interface. - /// When your plugin has implemented this interface, it will get notified if it has to - /// show a config dialog and to save/load config data.

    - /// Like in the IColumnizerConfigurator, you have to do all the saving and loading stuff - /// by yourself. + /// Return whether your plugin will provide an embedded config dialog or wants to provide + /// a 'popup' dialog for the configuration.



    + /// 'Embedded' means that the dialog is shown directly in the Settings dialog of LogExpert on the + /// right pane of the plugin config tab. ///
    - public interface ILogExpertPluginConfigurator - { - #region Public methods + /// Return true if your plugin config dialog should be displayed embedded. + bool HasEmbeddedForm(); - /// - /// Return whether your plugin will provide an embedded config dialog or wants to provide - /// a 'popup' dialog for the configuration.



    - /// 'Embedded' means that the dialog is shown directly in the Settings dialog of LogExpert on the - /// right pane of the plugin config tab. - ///
    - /// Return true if your plugin config dialog should be displayed embedded. - bool HasEmbeddedForm(); - - /// - /// This function is called when LogExpert fills the list of plugins in the Settings dialog. - /// This is the right time to create a 'temporary copy' of your current settings. The temporary copy - /// can be used for initializing the config dialogs. - /// - void StartConfig(); + /// + /// This function is called when LogExpert fills the list of plugins in the Settings dialog. + /// This is the right time to create a 'temporary copy' of your current settings. The temporary copy + /// can be used for initializing the config dialogs. + /// + void StartConfig(); - /// - /// Implement this function if your plugins uses an embedded config dialog. - /// This function is called when the user selects the plugin in the list of the Settings dialog - /// and the plugin uses an embedded dialog.



    - /// You have to create a non-toplevel dialog and set the given parentPanel as the parent of your - /// dialog. Then make your dialog visible (using Show()). - /// You don't need an OK or Cancel button. Changes made in the dialog should be retrieved - /// to a temporary config every time the function is called. - /// The temporary config should be permanently stored when the function - /// is called. - ///
    - /// - /// Set this panel as the parent for you config dialog. - void ShowConfigForm(object parentPanel); + /// + /// Implement this function if your plugins uses an embedded config dialog. + /// This function is called when the user selects the plugin in the list of the Settings dialog + /// and the plugin uses an embedded dialog.



    + /// You have to create a non-toplevel dialog and set the given parentPanel as the parent of your + /// dialog. Then make your dialog visible (using Show()). + /// You don't need an OK or Cancel button. Changes made in the dialog should be retrieved + /// to a temporary config every time the function is called. + /// The temporary config should be permanently stored when the function + /// is called. + ///
    + /// + /// Set this panel as the parent for you config dialog. + void ShowConfigForm(object parentPanel); - /// - /// Implement this function if your plugin uses an own top level dialog for the configuration (modal config dialog). - /// This function is called if the user clicks on the 'Config' button on the plugin settings. - ///



    - /// You have to create a top level dialog and set the given Form as the owner. Then show - /// the dialog as a modal window (Form.ShowDialog()). Changes made in the dialog should be retrieved - /// after Form.ShowDialog() returns and then put to the temporary copy of your config. - /// The temporary copy config should be permanently stored when the function - /// is called. - ///
    - /// - /// Set the given Form as the owner of your dialog. - void ShowConfigDialog(object owner); + /// + /// Implement this function if your plugin uses an own top level dialog for the configuration (modal config dialog). + /// This function is called if the user clicks on the 'Config' button on the plugin settings. + ///



    + /// You have to create a top level dialog and set the given Form as the owner. Then show + /// the dialog as a modal window (Form.ShowDialog()). Changes made in the dialog should be retrieved + /// after Form.ShowDialog() returns and then put to the temporary copy of your config. + /// The temporary copy config should be permanently stored when the function + /// is called. + ///
    + /// + /// Set the given Form as the owner of your dialog. + void ShowConfigDialog(object owner); - /// - /// This function is called when the user selects another plugin in the list. You should retrieve - /// the changes made in the config dialog to a temporary copy of the config and destroy your dialog. - /// Don't make the changes permanent here, because the user may click the cancel button of LogExpert's - /// Settings dialog. In this case he/she would expect the changes to be discarded.

    - /// The right place for making changes permanent is the function. - ///
    - /// - /// The method is also called when the settings dialog is closed. If the settings dialog is closed - /// by OK button this method is called before the method. - /// - void HideConfigForm(); + /// + /// This function is called when the user selects another plugin in the list. You should retrieve + /// the changes made in the config dialog to a temporary copy of the config and destroy your dialog. + /// Don't make the changes permanent here, because the user may click the cancel button of LogExpert's + /// Settings dialog. In this case he/she would expect the changes to be discarded.

    + /// The right place for making changes permanent is the function. + ///
    + /// + /// The method is also called when the settings dialog is closed. If the settings dialog is closed + /// by OK button this method is called before the method. + /// + void HideConfigForm(); - /// - /// Called by LogExpert if the user clicks the OK button in LogExpert's Settings dialog. - /// Save your temporary copy of the config here. - /// - /// The location where LogExpert stores its settings. - void SaveConfig(string configDir); + /// + /// Called by LogExpert if the user clicks the OK button in LogExpert's Settings dialog. + /// Save your temporary copy of the config here. + /// + /// The location where LogExpert stores its settings. + void SaveConfig(string configDir); - /// - /// This function is called when LogExpert is started and scans the plugin directory. - /// You should load your settings here. - /// - /// The location where LogExpert stores its settings. - void LoadConfig(string configDir); + /// + /// This function is called when LogExpert is started and scans the plugin directory. + /// You should load your settings here. + /// + /// The location where LogExpert stores its settings. + void LoadConfig(string configDir); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/ILogFileInfo.cs b/src/ColumnizerLib/ILogFileInfo.cs index 8a028472..a65ee5b1 100644 --- a/src/ColumnizerLib/ILogFileInfo.cs +++ b/src/ColumnizerLib/ILogFileInfo.cs @@ -1,85 +1,84 @@ using System; using System.IO; -namespace LogExpert +namespace LogExpert; + +/// +/// Interface which represents a file in LogExpert. 'File' could be anything that represents text data to be displayed in LogExpert. +/// +public interface ILogFileInfo { + #region Properties + + /// + /// The file name (complete path) of the log file. This should be a unique name. E.g. an URI or a path on local disk. + /// + string FullName { get; } + + /// + /// The file name without path. + /// + string FileName { get; } + + /// + /// The directory of the log file. In most cases this is the FullName minus FileName. + /// + string DirectoryName { get; } + + /// + /// Character used to separate directories in a path string. + /// + char DirectorySeparatorChar { get; } + /// - /// Interface which represents a file in LogExpert. 'File' could be anything that represents text data to be displayed in LogExpert. + /// The URI of the log file. /// - public interface ILogFileInfo - { - #region Properties - - /// - /// The file name (complete path) of the log file. This should be a unique name. E.g. an URI or a path on local disk. - /// - string FullName { get; } - - /// - /// The file name without path. - /// - string FileName { get; } - - /// - /// The directory of the log file. In most cases this is the FullName minus FileName. - /// - string DirectoryName { get; } - - /// - /// Character used to separate directories in a path string. - /// - char DirectorySeparatorChar { get; } - - /// - /// The URI of the log file. - /// - Uri Uri { get; } - - /// - /// Current length of the file. Return -1 if the file is not found. - /// - long Length { get; } - - /// - /// Initial file length at the time the ILogFileInfo instance was created. This is used for the buffer shifting when - /// using the multi file feature. This value should not change after the instance has been created. - /// - long OriginalLength { get; } - - /// - /// Whether the file exists. - /// - bool FileExists { get; } - - /// - /// The interval (in ms) LogExpert should check for file changes. The property is checked by LogExpert repeatedly in the loop which - /// checks for file changes. So you can adjust the poll interval as needed. E.g. you can lower the interval when many changes occur and - /// raise the interval when the file has not been changed for a certain amount of time. - /// - int PollInterval { get; } - - #endregion - - #region Public methods - - /// - /// Returns a stream for the log file file. The actual type of stream depends on the implementation. - /// The caller (LogExpert) is responsible for closing the stream. - /// - /// - /// The returned Stream must support read and seek. Writing is not needed. - /// - /// A Stream open for reading - Stream OpenStream(); - - /// - /// Return true if the file has been changed since the last call to this method. - /// - /// - /// LogExpert will poll this method with the interval returned from PollInterval. - /// - bool FileHasChanged(); - - #endregion - } + Uri Uri { get; } + + /// + /// Current length of the file. Return -1 if the file is not found. + /// + long Length { get; } + + /// + /// Initial file length at the time the ILogFileInfo instance was created. This is used for the buffer shifting when + /// using the multi file feature. This value should not change after the instance has been created. + /// + long OriginalLength { get; } + + /// + /// Whether the file exists. + /// + bool FileExists { get; } + + /// + /// The interval (in ms) LogExpert should check for file changes. The property is checked by LogExpert repeatedly in the loop which + /// checks for file changes. So you can adjust the poll interval as needed. E.g. you can lower the interval when many changes occur and + /// raise the interval when the file has not been changed for a certain amount of time. + /// + int PollInterval { get; } + + #endregion + + #region Public methods + + /// + /// Returns a stream for the log file file. The actual type of stream depends on the implementation. + /// The caller (LogExpert) is responsible for closing the stream. + /// + /// + /// The returned Stream must support read and seek. Writing is not needed. + /// + /// A Stream open for reading + Stream OpenStream(); + + /// + /// Return true if the file has been changed since the last call to this method. + /// + /// + /// LogExpert will poll this method with the interval returned from PollInterval. + /// + bool FileHasChanged(); + + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/ILogLine.cs b/src/ColumnizerLib/ILogLine.cs index 8ffe7e9f..7599acbf 100644 --- a/src/ColumnizerLib/ILogLine.cs +++ b/src/ColumnizerLib/ILogLine.cs @@ -1,13 +1,12 @@ -namespace LogExpert +namespace LogExpert; + +public interface ILogLine : ITextValue { - public interface ILogLine : ITextValue - { - #region Properties + #region Properties - string FullLine { get; } + string FullLine { get; } - int LineNumber { get; } + int LineNumber { get; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/ILogLineColumnizer.cs b/src/ColumnizerLib/ILogLineColumnizer.cs index e12988ac..70ccc8a2 100644 --- a/src/ColumnizerLib/ILogLineColumnizer.cs +++ b/src/ColumnizerLib/ILogLineColumnizer.cs @@ -1,121 +1,120 @@ using System; -namespace LogExpert +namespace LogExpert; + +/// +/// This interface defines a so-called 'Columnizer' for LogExpert. +/// A columnizer splits a single text line into well defined columns. These columns +/// are used in the data grid view of LogExpert. +///



    +/// Optionally a columnizer can parse the log line to determine the date/time of +/// the log line (assuming that all log lines have a timestamp). This is needed for +/// some of the features of LogExpert (see user documentation for more information). +///



    +/// You can implement your own columnizers for your logfile format, if needed. +///
    +public interface ILogLineColumnizer { - /// - /// This interface defines a so-called 'Columnizer' for LogExpert. - /// A columnizer splits a single text line into well defined columns. These columns - /// are used in the data grid view of LogExpert. - ///



    - /// Optionally a columnizer can parse the log line to determine the date/time of - /// the log line (assuming that all log lines have a timestamp). This is needed for - /// some of the features of LogExpert (see user documentation for more information). - ///



    - /// You can implement your own columnizers for your logfile format, if needed. - ///
    - public interface ILogLineColumnizer - { - #region Public methods + #region Public methods - /// - /// Returns the name for the columnizer. This name is used for the columnizer selection dialog. - /// - string GetName(); + /// + /// Returns the name for the columnizer. This name is used for the columnizer selection dialog. + /// + string GetName(); - /// - /// Returns the description of the columnizer. This text is used in the columnizer selection dialog. - /// - string GetDescription(); + /// + /// Returns the description of the columnizer. This text is used in the columnizer selection dialog. + /// + string GetDescription(); - /// - /// Returns the number of columns the columnizer will split lines into. - /// - /// - /// This value does not include the column for displaying the line number. The line number column - /// is added by LogExpert and is not handled by columnizers. - /// - int GetColumnCount(); + /// + /// Returns the number of columns the columnizer will split lines into. + /// + /// + /// This value does not include the column for displaying the line number. The line number column + /// is added by LogExpert and is not handled by columnizers. + /// + int GetColumnCount(); - /// - /// Returns the names of the columns. The returned names are used by LogExpert for the column headers in the data grid view. - /// The names are expected in order from left to right. - /// - string[] GetColumnNames(); + /// + /// Returns the names of the columns. The returned names are used by LogExpert for the column headers in the data grid view. + /// The names are expected in order from left to right. + /// + string[] GetColumnNames(); - /// - /// Given a single line of the logfile this function splits the line content into columns. The function returns - /// a string array containing the splitted content. - /// - /// - /// This function is called by LogExpert for every line that has to be drawn in the grid view. The faster your code - /// handles the splitting, the faster LogExpert can draw the grid view content.

    - ///

    - /// Notes about timeshift handling:

    - /// If your columnizer implementation supports timeshift (see IsTimeshiftImplemented) - /// you have to add the timestamp offset to the columns representing the timestamp (e.g. columns like 'date' and 'time'). - /// In practice this means you have to parse the date/time value of your log line (see GetTimestamp) - /// add the offset and convert the timestamp back to string value(s). - ///
    - /// Callback interface with functions which can be used by the columnizer - /// The line content to be splitted - IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line); + /// + /// Given a single line of the logfile this function splits the line content into columns. The function returns + /// a string array containing the splitted content. + /// + /// + /// This function is called by LogExpert for every line that has to be drawn in the grid view. The faster your code + /// handles the splitting, the faster LogExpert can draw the grid view content.

    + ///

    + /// Notes about timeshift handling:

    + /// If your columnizer implementation supports timeshift (see IsTimeshiftImplemented) + /// you have to add the timestamp offset to the columns representing the timestamp (e.g. columns like 'date' and 'time'). + /// In practice this means you have to parse the date/time value of your log line (see GetTimestamp) + /// add the offset and convert the timestamp back to string value(s). + ///
    + /// Callback interface with functions which can be used by the columnizer + /// The line content to be splitted + IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line); - /// - /// Returns true, if the columnizer supports timeshift handling. - /// - /// - /// If you return true, you also have to implement the function SetTimeOffset(), GetTimeOffset() and GetTimestamp(). - /// You also must handle PushValue() for the column(s) that displays the timestamp. - /// - bool IsTimeshiftImplemented(); + /// + /// Returns true, if the columnizer supports timeshift handling. + /// + /// + /// If you return true, you also have to implement the function SetTimeOffset(), GetTimeOffset() and GetTimestamp(). + /// You also must handle PushValue() for the column(s) that displays the timestamp. + /// + bool IsTimeshiftImplemented(); - /// - /// Sets an offset to be used for displaying timestamp values. You have to implement this function, if - /// your IsTimeshiftImplemented() function return true. - /// - /// - /// You have to store the given value in the Columnizer instance and add this offset to the timestamp column(s) returned by SplitLine() - /// (e.g. in the date and time columns). - /// - /// The timestamp offset in milliseconds. - void SetTimeOffset(int msecOffset); + /// + /// Sets an offset to be used for displaying timestamp values. You have to implement this function, if + /// your IsTimeshiftImplemented() function return true. + /// + /// + /// You have to store the given value in the Columnizer instance and add this offset to the timestamp column(s) returned by SplitLine() + /// (e.g. in the date and time columns). + /// + /// The timestamp offset in milliseconds. + void SetTimeOffset(int msecOffset); - /// - /// Returns the current stored timestamp offset (set by SetTimeOffset()). - /// - int GetTimeOffset(); + /// + /// Returns the current stored timestamp offset (set by SetTimeOffset()). + /// + int GetTimeOffset(); - /// - /// Returns the timestamp value of the given line as a .NET DateTime object. If there's no valid timestamp in the - /// given line you have to return DateTime.MinValue. - /// - /// - /// When implementing this function you have to parse the given log line for a valid date/time to get a DateTime object. - /// Before returning the DateTime object you have to add the offset which was set by SetTimeOffset().

    - ///

    - /// Note: If not all lines of your log files contain a valid date/time it's recommended to do some fail-fast pre checks before - /// calling the parse functions of DateTime. This saves a lot of time because DateTime.ParseExact() is very slow when fed with - /// invalid input. - ///
    - /// Callback interface with functions which can be used by the columnizer - /// The line content which timestamp has to be returned. - DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line); + /// + /// Returns the timestamp value of the given line as a .NET DateTime object. If there's no valid timestamp in the + /// given line you have to return DateTime.MinValue. + /// + /// + /// When implementing this function you have to parse the given log line for a valid date/time to get a DateTime object. + /// Before returning the DateTime object you have to add the offset which was set by SetTimeOffset().

    + ///

    + /// Note: If not all lines of your log files contain a valid date/time it's recommended to do some fail-fast pre checks before + /// calling the parse functions of DateTime. This saves a lot of time because DateTime.ParseExact() is very slow when fed with + /// invalid input. + ///
    + /// Callback interface with functions which can be used by the columnizer + /// The line content which timestamp has to be returned. + DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line); - /// - /// This function is called if the user changes a value in a column (edit mode in the log view). - /// The purpose of the function is to determine a new timestamp offset. So you have to handle the - /// call only if the given column displays a timestamp. - /// - /// - /// You should parse both values (oldValue, value) for valid timestamps, determine the time offset and store the offset as - /// the new timeshift offset (and of course use this offset in the GetTimestamp() and SplitLine() functions). - /// - /// Callback interface with functions which can be used by the columnizer - /// The column number which value has changed. - /// The new value. - /// The old value. - void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue); + /// + /// This function is called if the user changes a value in a column (edit mode in the log view). + /// The purpose of the function is to determine a new timestamp offset. So you have to handle the + /// call only if the given column displays a timestamp. + /// + /// + /// You should parse both values (oldValue, value) for valid timestamps, determine the time offset and store the offset as + /// the new timeshift offset (and of course use this offset in the GetTimestamp() and SplitLine() functions). + /// + /// Callback interface with functions which can be used by the columnizer + /// The column number which value has changed. + /// The new value. + /// The old value. + void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/ILogLineXmlColumnizer.cs b/src/ColumnizerLib/ILogLineXmlColumnizer.cs index cc79e1dd..9ab6845b 100644 --- a/src/ColumnizerLib/ILogLineXmlColumnizer.cs +++ b/src/ColumnizerLib/ILogLineXmlColumnizer.cs @@ -1,77 +1,72 @@ -using System; -using System.Collections.Generic; -using System.Text; +namespace LogExpert; -namespace LogExpert +/// +/// This is the interface for a Columnizer which supports XML log files. This interface extends +/// the interface. +/// LogExpert will automatically load a log file in XML mode if the current Columnizer implements +/// this interface. +/// +/// +/// +/// Note that the ILogLineXmlColumnizer interface is also a marker interface. If the user selects a +/// Columnizer that implements ILogLineXmlColumnizer then the log file will be treatet as XML file. +///

    +/// When in XML mode, LogExpert will scan for XML fragmets. These fragments are defined by opening +/// and closing tags (e.g. <log4j:event> and </log4j:event>). Every fragment is +/// transformed by using a XSLT template. The result of the transformation (which may be multi-lined) +/// is splitted into single lines. These single lines are the lines you will see in LogExpert's display. +///
    +/// +/// If you implement a XML Columnizer you have to provide the start tag and end tag and a +/// XSLT. Also you have to provide a namespace declaration, if your logfile uses name spaces. +/// All this stuff must be provided by returning a IXmlLogConfiguration in the method. +/// +/// +/// The processing of XML log files is done in the following steps: +///
      +///
    1. LogExpert reads the file and separates it into fragments of XML content using the given +/// start/end tags ()
    2. +///
    3. The fragments will be translated using the given XSLT () +/// The result is one or more lines of text content. These lines will be the lines LogExpert will 'see' +/// in its internal buffer and line management. They will be handled like normal text lines in other +/// (non-XML) log files. +///
    4. +///
    5. The lines will be passed to the usual methods before displaying. So you can handle +/// field splitting in the way known from . +///
    6. +///
    +///
    +///
    +public interface ILogLineXmlColumnizer : ILogLineColumnizer { + #region Public methods + + /// + /// You have to implement this function to provide a configuration for LogExpert's XML reader. + /// + /// + IXmlLogConfiguration GetXmlLogConfiguration (); + /// - /// This is the interface for a Columnizer which supports XML log files. This interface extends - /// the interface. - /// LogExpert will automatically load a log file in XML mode if the current Columnizer implements - /// this interface. + /// Returns the text which should be copied into the clipboard when the user want to copy selected + /// lines to clipboard. /// + /// The line as retrieved from the internal log reader. This is + /// the result of the XSLT processing with your provided stylesheet. + /// + /// Callback which may be used by the Columnizer + /// A string which is placed into the clipboard /// - /// - /// Note that the ILogLineXmlColumnizer interface is also a marker interface. If the user selects a - /// Columnizer that implements ILogLineXmlColumnizer then the log file will be treatet as XML file. + /// This function is intended to convert the representation of a log line produced by XSLT transformation into + /// a format suitable for clipboard. + /// The method can be used in the case that the XSLT transformation result is not very 'human readable'. ///

    - /// When in XML mode, LogExpert will scan for XML fragmets. These fragments are defined by opening - /// and closing tags (e.g. <log4j:event> and </log4j:event>). Every fragment is - /// transformed by using a XSLT template. The result of the transformation (which may be multi-lined) - /// is splitted into single lines. These single lines are the lines you will see in LogExpert's display. - ///
    - /// - /// If you implement a XML Columnizer you have to provide the start tag and end tag and a - /// XSLT. Also you have to provide a namespace declaration, if your logfile uses name spaces. - /// All this stuff must be provided by returning a IXmlLogConfiguration in the method. - /// - /// - /// The processing of XML log files is done in the following steps: - ///
      - ///
    1. LogExpert reads the file and separates it into fragments of XML content using the given - /// start/end tags ()
    2. - ///
    3. The fragments will be translated using the given XSLT () - /// The result is one or more lines of text content. These lines will be the lines LogExpert will 'see' - /// in its internal buffer and line management. They will be handled like normal text lines in other - /// (non-XML) log files. - ///
    4. - ///
    5. The lines will be passed to the usual methods before displaying. So you can handle - /// field splitting in the way known from . - ///
    6. - ///
    - ///
    + /// An example is the included Log4jXMLColumnizer. It uses special characters to separate the fields. + /// The characters are added while XSLT transformation. The usual Columnizer functions (e.g. SplitLIne()) will + /// use these markers for line splitting. + /// When copying to clipboard, this method will remove the special characters and replace them with spaces. ///
    - public interface ILogLineXmlColumnizer : ILogLineColumnizer - { - #region Public methods - - /// - /// You have to implement this function to provide a configuration for LogExpert's XML reader. - /// - /// - IXmlLogConfiguration GetXmlLogConfiguration(); - - /// - /// Returns the text which should be copied into the clipboard when the user want to copy selected - /// lines to clipboard. - /// - /// The line as retrieved from the internal log reader. This is - /// the result of the XSLT processing with your provided stylesheet. - /// - /// Callback which may be used by the Columnizer - /// A string which is placed into the clipboard - /// - /// This function is intended to convert the representation of a log line produced by XSLT transformation into - /// a format suitable for clipboard. - /// The method can be used in the case that the XSLT transformation result is not very 'human readable'. - ///

    - /// An example is the included Log4jXMLColumnizer. It uses special characters to separate the fields. - /// The characters are added while XSLT transformation. The usual Columnizer functions (e.g. SplitLIne()) will - /// use these markers for line splitting. - /// When copying to clipboard, this method will remove the special characters and replace them with spaces. - ///
    - ILogLine GetLineTextForClipboard(ILogLine logLine, ILogLineColumnizerCallback callback); + ILogLine GetLineTextForClipboard (ILogLine logLine, ILogLineColumnizerCallback callback); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/IPreProcessColumnizer.cs b/src/ColumnizerLib/IPreProcessColumnizer.cs index 6c8e9cbd..92a1ea86 100644 --- a/src/ColumnizerLib/IPreProcessColumnizer.cs +++ b/src/ColumnizerLib/IPreProcessColumnizer.cs @@ -2,64 +2,63 @@ using System.Collections.Generic; using System.Text; -namespace LogExpert +namespace LogExpert; + +/// +/// +/// Implement this interface in your columnizer if you want to pre-process every line +/// directly when it's loaded from file system. +/// +/// You can also use this to drop lines. +/// +/// +/// +/// +/// By implementing this interface with your Columnizer you get the ability to modify the +/// content of a log file right before it will be seen by LogExpert. +/// +/// +/// Note that the +/// method is only used when loading a line from disk. Because of internal buffering a log line may +/// be read only once or multiple times. You have to ensure that the behaviour is consistent +/// for every call to for a specific line. That's especially true +/// when dropping lines. Dropping a line changes the line count seen by LogExpert. That has implications +/// for things like bookmarks etc. +/// +/// +public interface IPreProcessColumnizer { + #region Public methods + /// - /// - /// Implement this interface in your columnizer if you want to pre-process every line - /// directly when it's loaded from file system. - /// - /// You can also use this to drop lines. - /// + /// This function is called for every line read from the log file. You can change the content + /// by returning a different string. You can also drop the complete line by returning null. /// + /// Line content + /// Line number as seen by LogExpert + /// Actual line number in the file + /// The changed content or null to drop the line /// /// - /// By implementing this interface with your Columnizer you get the ability to modify the - /// content of a log file right before it will be seen by LogExpert. + /// The values of lineNum and realLineNum differ only if you drop lines (by returning null). + /// When you drop a line, this line is hidden completely from LogExpert's log buffers. No chance + /// to bring it back later. When you drop a line, the lineNum will stay the same for the next + /// method call (for the next line). But realLineNum will increase for every call. + /// + /// + /// A usage example is the CsvColumnizer: If configuration says that there are field names + /// in the first line if the CSV file, the CsvColumnizer will store the first line for later + /// field name retrieval. But then the line is dropped. So the line isn't seen by LogExpert. + /// Detecting the first line in the file is only possible by checking the realLineNum parameter. /// /// - /// Note that the - /// method is only used when loading a line from disk. Because of internal buffering a log line may - /// be read only once or multiple times. You have to ensure that the behaviour is consistent - /// for every call to for a specific line. That's especially true - /// when dropping lines. Dropping a line changes the line count seen by LogExpert. That has implications - /// for things like bookmarks etc. + /// Remember that the method is called in an early state + /// when loading the file. So the file isn't loaded completely and the internal state + /// of LogExpert isn't complete. You cannot make any assumptions about file size or other + /// things. The given parameters are the only 'stateful' informations you can rely on. /// /// - public interface IPreProcessColumnizer - { - #region Public methods - - /// - /// This function is called for every line read from the log file. You can change the content - /// by returning a different string. You can also drop the complete line by returning null. - /// - /// Line content - /// Line number as seen by LogExpert - /// Actual line number in the file - /// The changed content or null to drop the line - /// - /// - /// The values of lineNum and realLineNum differ only if you drop lines (by returning null). - /// When you drop a line, this line is hidden completely from LogExpert's log buffers. No chance - /// to bring it back later. When you drop a line, the lineNum will stay the same for the next - /// method call (for the next line). But realLineNum will increase for every call. - /// - /// - /// A usage example is the CsvColumnizer: If configuration says that there are field names - /// in the first line if the CSV file, the CsvColumnizer will store the first line for later - /// field name retrieval. But then the line is dropped. So the line isn't seen by LogExpert. - /// Detecting the first line in the file is only possible by checking the realLineNum parameter. - /// - /// - /// Remember that the method is called in an early state - /// when loading the file. So the file isn't loaded completely and the internal state - /// of LogExpert isn't complete. You cannot make any assumptions about file size or other - /// things. The given parameters are the only 'stateful' informations you can rely on. - /// - /// - string PreProcessLine(string logLine, int lineNum, int realLineNum); + string PreProcessLine(string logLine, int lineNum, int realLineNum); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/ITextValue.cs b/src/ColumnizerLib/ITextValue.cs index bc6a218c..80b36fe9 100644 --- a/src/ColumnizerLib/ITextValue.cs +++ b/src/ColumnizerLib/ITextValue.cs @@ -1,11 +1,10 @@ -namespace LogExpert +namespace LogExpert; + +public interface ITextValue { - public interface ITextValue - { - #region Properties + #region Properties - string Text { get; } + string Text { get; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/IXmlLogConfiguration.cs b/src/ColumnizerLib/IXmlLogConfiguration.cs index b88419b8..c48d7535 100644 --- a/src/ColumnizerLib/IXmlLogConfiguration.cs +++ b/src/ColumnizerLib/IXmlLogConfiguration.cs @@ -1,37 +1,36 @@ -namespace LogExpert +namespace LogExpert; + +/// +/// This interface declares the configuration data which is needed for XML log file parsing. +/// +public interface IXmlLogConfiguration { + #region Properties + /// - /// This interface declares the configuration data which is needed for XML log file parsing. + /// The opening XML tag for a log entry. Every log entry starts with this tag.

    + /// Example: <log4j:event> ///
    - public interface IXmlLogConfiguration - { - #region Properties - - /// - /// The opening XML tag for a log entry. Every log entry starts with this tag.

    - /// Example: <log4j:event> - ///
    - string XmlStartTag { get; } + string XmlStartTag { get; } - /// - /// The closing tag for a log entry.

    - /// Example: </log4j:event> - ///
    - string XmlEndTag { get; } + /// + /// The closing tag for a log entry.

    + /// Example: </log4j:event> + ///
    + string XmlEndTag { get; } - /// - /// A complete XSLT which is used to transform the XML fragments into text lines which can be - /// processed by the Columnizer. - /// - string Stylesheet { get; } + /// + /// A complete XSLT which is used to transform the XML fragments into text lines which can be + /// processed by the Columnizer. + /// + string Stylesheet { get; } - /// - /// A namespace declaration. The returned array must contain 2 strings: The namespace and its declaration.

    - /// Example: {"log4j", "http://jakarta.apache.org/log4j"} - /// - ///
    - string[] Namespace { get; } + /// + /// A namespace declaration. The returned array must contain 2 strings: The namespace and its declaration.

    + /// Example: {"log4j", "http://jakarta.apache.org/log4j"} + /// + ///
    + string[] Namespace { get; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/LineEntry.cs b/src/ColumnizerLib/LineEntry.cs index c0f02c17..bcbb4699 100644 --- a/src/ColumnizerLib/LineEntry.cs +++ b/src/ColumnizerLib/LineEntry.cs @@ -1,20 +1,19 @@ -namespace LogExpert +namespace LogExpert; + +/// +/// This helper struct holds a log line and its line number (zero based). +/// This struct is used by . +/// +/// +public struct LineEntry { /// - /// This helper struct holds a log line and its line number (zero based). - /// This struct is used by . + /// The content of the line. /// - /// - public struct LineEntry - { - /// - /// The content of the line. - /// - public ILogLine logLine; + public ILogLine logLine; - /// - /// The line number. See for an explanation of the line number. - /// - public int lineNum; - } + /// + /// The line number. See for an explanation of the line number. + /// + public int lineNum; } \ No newline at end of file diff --git a/src/ColumnizerLib/Priority.cs b/src/ColumnizerLib/Priority.cs index de968b24..964820aa 100644 --- a/src/ColumnizerLib/Priority.cs +++ b/src/ColumnizerLib/Priority.cs @@ -1,33 +1,32 @@ -namespace LogExpert +namespace LogExpert; + +/// +/// Priority for columnizer. +/// +public enum Priority { /// - /// Priority for columnizer. + /// Not support target file. /// - public enum Priority - { - /// - /// Not support target file. - /// - NotSupport = 0, + NotSupport = 0, - /// - /// Can support target file. E.g. default one CanSupport most of the files. - /// - CanSupport, + /// + /// Can support target file. E.g. default one CanSupport most of the files. + /// + CanSupport, - /// - /// Target file is soundly supported. E.g. JsonColumnizer WellSupport all json files. - /// - WellSupport, + /// + /// Target file is soundly supported. E.g. JsonColumnizer WellSupport all json files. + /// + WellSupport, - /// - /// The columnizer is designed to support target file. E.g. JsonCompactColumnizer PerfectlySupport all compact Json files. - /// - PerfectlySupport, + /// + /// The columnizer is designed to support target file. E.g. JsonCompactColumnizer PerfectlySupport all compact Json files. + /// + PerfectlySupport, - /// - /// Target file is only supported by this columnizer. - /// - Exclusive - } + /// + /// Target file is only supported by this columnizer. + /// + Exclusive } \ No newline at end of file diff --git a/src/CsvColumnizer/CsvColumn.cs b/src/CsvColumnizer/CsvColumn.cs index 4b209a5c..c899c940 100644 --- a/src/CsvColumnizer/CsvColumn.cs +++ b/src/CsvColumnizer/CsvColumn.cs @@ -1,11 +1,10 @@ -namespace CsvColumnizer +namespace CsvColumnizer; + +internal class CsvColumn(string name) { - internal class CsvColumn(string name) - { - #region Properties + #region Properties - public string Name { get; } = name; + public string Name { get; } = name; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/CsvColumnizer/CsvColumnizer.cs b/src/CsvColumnizer/CsvColumnizer.cs index 26d36ad3..8d6bffe5 100644 --- a/src/CsvColumnizer/CsvColumnizer.cs +++ b/src/CsvColumnizer/CsvColumnizer.cs @@ -13,277 +13,276 @@ using System.Windows.Forms; [assembly: SupportedOSPlatform("windows")] -namespace CsvColumnizer +namespace CsvColumnizer; + +/// +/// This Columnizer can parse CSV files. It uses the IInitColumnizer interface for support of dynamic field count. +/// The IPreProcessColumnizer is implemented to read field names from the very first line of the file. Then +/// the line is dropped. So it's not seen by LogExpert. The field names will be used as column names. +/// +public class CsvColumnizer : ILogLineColumnizer, IInitColumnizer, IColumnizerConfigurator, IPreProcessColumnizer, IColumnizerPriority { - /// - /// This Columnizer can parse CSV files. It uses the IInitColumnizer interface for support of dynamic field count. - /// The IPreProcessColumnizer is implemented to read field names from the very first line of the file. Then - /// the line is dropped. So it's not seen by LogExpert. The field names will be used as column names. - /// - public class CsvColumnizer : ILogLineColumnizer, IInitColumnizer, IColumnizerConfigurator, IPreProcessColumnizer, IColumnizerPriority - { - #region Fields + #region Fields - private static readonly string _configFileName = "csvcolumnizer.json"; + private static readonly string _configFileName = "csvcolumnizer.json"; - private readonly IList _columnList = []; - private CsvColumnizerConfig _config; + private readonly IList _columnList = []; + private CsvColumnizerConfig _config; - private ILogLine _firstLine; + private ILogLine _firstLine; - // if CSV is detected to be 'invalid' the columnizer will behave like a default columnizer - private bool _isValidCsv; + // if CSV is detected to be 'invalid' the columnizer will behave like a default columnizer + private bool _isValidCsv; - #endregion + #endregion - #region Public methods + #region Public methods - public string PreProcessLine(string logLine, int lineNum, int realLineNum) + public string PreProcessLine(string logLine, int lineNum, int realLineNum) + { + if (realLineNum == 0) { - if (realLineNum == 0) - { - // store for later field names and field count retrieval - _firstLine = new CsvLogLine(logLine, 0); + // store for later field names and field count retrieval + _firstLine = new CsvLogLine(logLine, 0); - if (_config.MinColumns > 0) + if (_config.MinColumns > 0) + { + using CsvReader csv = new(new StringReader(logLine), _config.ReaderConfiguration); + if (csv.Parser.Count < _config.MinColumns) { - using CsvReader csv = new(new StringReader(logLine), _config.ReaderConfiguration); - if (csv.Parser.Count < _config.MinColumns) - { - // on invalid CSV don't hide the first line from LogExpert, since the file will be displayed in plain mode - _isValidCsv = false; - return logLine; - } + // on invalid CSV don't hide the first line from LogExpert, since the file will be displayed in plain mode + _isValidCsv = false; + return logLine; } - - _isValidCsv = true; } - if (_config.HasFieldNames && realLineNum == 0) - { - return null; // hide from LogExpert - } - - if (_config.CommentChar != ' ' && logLine.StartsWith("" + _config.CommentChar)) - { - return null; - } - - return logLine; + _isValidCsv = true; } - public string GetName() + if (_config.HasFieldNames && realLineNum == 0) { - return "CSV Columnizer"; + return null; // hide from LogExpert } - public string GetDescription() + if (_config.CommentChar != ' ' && logLine.StartsWith("" + _config.CommentChar)) { - return "Splits CSV files into columns.\r\n\r\nCredits:\r\nThis Columnizer uses the CsvHelper. https://github.com/JoshClose/CsvHelper. \r\n"; + return null; } - public int GetColumnCount() - { - return _isValidCsv ? _columnList.Count : 1; - } + return logLine; + } - public string[] GetColumnNames() - { - var names = new string[GetColumnCount()]; - if (_isValidCsv) - { - var i = 0; - foreach (CsvColumn column in _columnList) - { - names[i++] = column.Name; - } - } - else - { - names[0] = "Text"; - } + public string GetName() + { + return "CSV Columnizer"; + } - return names; - } + public string GetDescription() + { + return "Splits CSV files into columns.\r\n\r\nCredits:\r\nThis Columnizer uses the CsvHelper. https://github.com/JoshClose/CsvHelper. \r\n"; + } + + public int GetColumnCount() + { + return _isValidCsv ? _columnList.Count : 1; + } - public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) + public string[] GetColumnNames() + { + var names = new string[GetColumnCount()]; + if (_isValidCsv) { - if (_isValidCsv) + var i = 0; + foreach (CsvColumn column in _columnList) { - return SplitCsvLine(line); + names[i++] = column.Name; } - - return CreateColumnizedLogLine(line); } - - private static ColumnizedLogLine CreateColumnizedLogLine(ILogLine line) + else { - ColumnizedLogLine cLogLine = new() - { - LogLine = line - }; - cLogLine.ColumnValues = [new Column { FullValue = line.FullLine, Parent = cLogLine }]; - return cLogLine; + names[0] = "Text"; } - public bool IsTimeshiftImplemented() - { - return false; - } + return names; + } - public void SetTimeOffset(int msecOffset) + public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) + { + if (_isValidCsv) { - throw new NotImplementedException(); + return SplitCsvLine(line); } - public int GetTimeOffset() - { - throw new NotImplementedException(); - } + return CreateColumnizedLogLine(line); + } - public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) + private static ColumnizedLogLine CreateColumnizedLogLine(ILogLine line) + { + ColumnizedLogLine cLogLine = new() { - throw new NotImplementedException(); - } + LogLine = line + }; + cLogLine.ColumnValues = [new Column { FullValue = line.FullLine, Parent = cLogLine }]; + return cLogLine; + } - public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) - { - throw new NotImplementedException(); - } + public bool IsTimeshiftImplemented() + { + return false; + } + + public void SetTimeOffset(int msecOffset) + { + throw new NotImplementedException(); + } + + public int GetTimeOffset() + { + throw new NotImplementedException(); + } + + public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) + { + throw new NotImplementedException(); + } - public void Selected(ILogLineColumnizerCallback callback) + public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) + { + throw new NotImplementedException(); + } + + public void Selected(ILogLineColumnizerCallback callback) + { + if (_isValidCsv) // see PreProcessLine() { - if (_isValidCsv) // see PreProcessLine() - { - _columnList.Clear(); - ILogLine line = _config.HasFieldNames ? _firstLine : callback.GetLogLine(0); + _columnList.Clear(); + ILogLine line = _config.HasFieldNames ? _firstLine : callback.GetLogLine(0); - if (line != null) - { - using CsvReader csv = new(new StringReader(line.FullLine), _config.ReaderConfiguration); - csv.Read(); - csv.ReadHeader(); + if (line != null) + { + using CsvReader csv = new(new StringReader(line.FullLine), _config.ReaderConfiguration); + csv.Read(); + csv.ReadHeader(); - var fieldCount = csv.Parser.Count; + var fieldCount = csv.Parser.Count; - var headerRecord = csv.HeaderRecord; + var headerRecord = csv.HeaderRecord; - if (_config.HasFieldNames && headerRecord != null) + if (_config.HasFieldNames && headerRecord != null) + { + foreach (var headerColumn in headerRecord) { - foreach (var headerColumn in headerRecord) - { - _columnList.Add(new CsvColumn(headerColumn)); - } + _columnList.Add(new CsvColumn(headerColumn)); } - else + } + else + { + for (var i = 0; i < fieldCount; ++i) { - for (var i = 0; i < fieldCount; ++i) - { - _columnList.Add(new CsvColumn("Column " + i + 1)); - } + _columnList.Add(new CsvColumn("Column " + i + 1)); } } } } + } - public void DeSelected(ILogLineColumnizerCallback callback) - { - // nothing to do - } + public void DeSelected(ILogLineColumnizerCallback callback) + { + // nothing to do + } - public void Configure(ILogLineColumnizerCallback callback, string configDir) - { - var configPath = configDir + "\\" + _configFileName; - FileInfo fileInfo = new(configPath); + public void Configure(ILogLineColumnizerCallback callback, string configDir) + { + var configPath = configDir + "\\" + _configFileName; + FileInfo fileInfo = new(configPath); - CsvColumnizerConfigDlg dlg = new(_config); + CsvColumnizerConfigDlg dlg = new(_config); - if (dlg.ShowDialog() == DialogResult.OK) - { - _config.VersionBuild = Assembly.GetExecutingAssembly().GetName().Version.Build; + if (dlg.ShowDialog() == DialogResult.OK) + { + _config.VersionBuild = Assembly.GetExecutingAssembly().GetName().Version.Build; - using (StreamWriter sw = new(fileInfo.Create())) - { - JsonSerializer serializer = new(); - serializer.Serialize(sw, _config); - } + using (StreamWriter sw = new(fileInfo.Create())) + { + JsonSerializer serializer = new(); + serializer.Serialize(sw, _config); + } - _config.ConfigureReaderConfiguration(); + _config.ConfigureReaderConfiguration(); - Selected(callback); - } + Selected(callback); } + } - public void LoadConfig(string configDir) - { - var configPath = Path.Combine(configDir, _configFileName); + public void LoadConfig(string configDir) + { + var configPath = Path.Combine(configDir, _configFileName); - if (!File.Exists(configPath)) + if (!File.Exists(configPath)) + { + _config = new CsvColumnizerConfig(); + _config.InitDefaults(); + } + else + { + try { - _config = new CsvColumnizerConfig(); - _config.InitDefaults(); + _config = JsonConvert.DeserializeObject(File.ReadAllText(configPath)); + _config.ConfigureReaderConfiguration(); } - else + catch (Exception e) { - try - { - _config = JsonConvert.DeserializeObject(File.ReadAllText(configPath)); - _config.ConfigureReaderConfiguration(); - } - catch (Exception e) - { - MessageBox.Show($"Error while deserializing config data: {e.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - _config = new CsvColumnizerConfig(); - _config.InitDefaults(); - } + MessageBox.Show($"Error while deserializing config data: {e.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + _config = new CsvColumnizerConfig(); + _config.InitDefaults(); } } + } - public Priority GetPriority(string fileName, IEnumerable samples) - { - Priority result = Priority.NotSupport; - - if (fileName.EndsWith("csv", StringComparison.OrdinalIgnoreCase)) - { - result = Priority.CanSupport; - } + public Priority GetPriority(string fileName, IEnumerable samples) + { + Priority result = Priority.NotSupport; - return result; + if (fileName.EndsWith("csv", StringComparison.OrdinalIgnoreCase)) + { + result = Priority.CanSupport; } - #endregion + return result; + } - #region Private Methods + #endregion - private IColumnizedLogLine SplitCsvLine(ILogLine line) - { - ColumnizedLogLine cLogLine = new() - { - LogLine = line - }; + #region Private Methods - using CsvReader csv = new(new StringReader(line.FullLine), _config.ReaderConfiguration); - csv.Read(); - csv.ReadHeader(); + private IColumnizedLogLine SplitCsvLine(ILogLine line) + { + ColumnizedLogLine cLogLine = new() + { + LogLine = line + }; - //we only read line by line and not the whole file so it is always the header - var records = csv.HeaderRecord; + using CsvReader csv = new(new StringReader(line.FullLine), _config.ReaderConfiguration); + csv.Read(); + csv.ReadHeader(); - if (records != null) - { - List columns = []; + //we only read line by line and not the whole file so it is always the header + var records = csv.HeaderRecord; - foreach (var record in records) - { - columns.Add(new Column { FullValue = record, Parent = cLogLine }); - } + if (records != null) + { + List columns = []; - cLogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); + foreach (var record in records) + { + columns.Add(new Column { FullValue = record, Parent = cLogLine }); } - return cLogLine; + cLogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); } - #endregion + return cLogLine; } + + #endregion } \ No newline at end of file diff --git a/src/CsvColumnizer/CsvColumnizerConfig.cs b/src/CsvColumnizer/CsvColumnizerConfig.cs index f9b04908..e2841bcf 100644 --- a/src/CsvColumnizer/CsvColumnizerConfig.cs +++ b/src/CsvColumnizer/CsvColumnizerConfig.cs @@ -5,66 +5,65 @@ using System; using System.Globalization; -namespace CsvColumnizer +namespace CsvColumnizer; + +[Serializable] +public class CsvColumnizerConfig { - [Serializable] - public class CsvColumnizerConfig - { - #region Fields + #region Fields - public char CommentChar { get; set; } + public char CommentChar { get; set; } - public string DelimiterChar { get; set; } + public string DelimiterChar { get; set; } - public char EscapeChar { get; set; } + public char EscapeChar { get; set; } - public bool HasFieldNames { get; set; } + public bool HasFieldNames { get; set; } - public int MinColumns { get; set; } + public int MinColumns { get; set; } - public char QuoteChar { get; set; } + public char QuoteChar { get; set; } - public int VersionBuild { get; set; } + public int VersionBuild { get; set; } - [JsonIgnore] - public IReaderConfiguration ReaderConfiguration { get; set; } + [JsonIgnore] + public IReaderConfiguration ReaderConfiguration { get; set; } - #endregion + #endregion - #region Public methods + #region Public methods - public void InitDefaults() + public void InitDefaults() + { + ReaderConfiguration = new CsvConfiguration(CultureInfo.InvariantCulture) { - ReaderConfiguration = new CsvConfiguration(CultureInfo.InvariantCulture) - { - Delimiter = ";", - Escape = '"', - Quote = '"', - Comment = '#', - HasHeaderRecord = true, - TrimOptions = TrimOptions.None - }; - - DelimiterChar = ReaderConfiguration.Delimiter; - EscapeChar = ReaderConfiguration.Escape; - QuoteChar = ReaderConfiguration.Quote; - CommentChar = ReaderConfiguration.Comment; - HasFieldNames = ReaderConfiguration.HasHeaderRecord; - MinColumns = 0; - } - - public void ConfigureReaderConfiguration() + Delimiter = ";", + Escape = '"', + Quote = '"', + Comment = '#', + HasHeaderRecord = true, + TrimOptions = TrimOptions.None + }; + + DelimiterChar = ReaderConfiguration.Delimiter; + EscapeChar = ReaderConfiguration.Escape; + QuoteChar = ReaderConfiguration.Quote; + CommentChar = ReaderConfiguration.Comment; + HasFieldNames = ReaderConfiguration.HasHeaderRecord; + MinColumns = 0; + } + + public void ConfigureReaderConfiguration() + { + ReaderConfiguration = new CsvConfiguration(CultureInfo.InvariantCulture) { - ReaderConfiguration = new CsvConfiguration(CultureInfo.InvariantCulture) - { - Delimiter = DelimiterChar, - Escape = EscapeChar, - Quote = QuoteChar, - Comment = CommentChar, - HasHeaderRecord = HasFieldNames - }; - } - - #endregion + Delimiter = DelimiterChar, + Escape = EscapeChar, + Quote = QuoteChar, + Comment = CommentChar, + HasHeaderRecord = HasFieldNames + }; } + + #endregion } \ No newline at end of file diff --git a/src/CsvColumnizer/CsvColumnizerConfigDlg.cs b/src/CsvColumnizer/CsvColumnizerConfigDlg.cs index 4c2fd0ab..61d421f9 100644 --- a/src/CsvColumnizer/CsvColumnizerConfigDlg.cs +++ b/src/CsvColumnizer/CsvColumnizerConfigDlg.cs @@ -2,71 +2,70 @@ using System.Drawing; using System.Windows.Forms; -namespace CsvColumnizer -{ - public partial class CsvColumnizerConfigDlg : Form - { - #region Fields +namespace CsvColumnizer; - private readonly CsvColumnizerConfig _config; +public partial class CsvColumnizerConfigDlg : Form +{ + #region Fields - #endregion + private readonly CsvColumnizerConfig _config; - #region cTor + #endregion - public CsvColumnizerConfigDlg(CsvColumnizerConfig config) - { - SuspendLayout(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; + #region cTor - _config = config; - InitializeComponent(); - FillValues(); - ResumeLayout(); - } + public CsvColumnizerConfigDlg(CsvColumnizerConfig config) + { + SuspendLayout(); + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + _config = config; + InitializeComponent(); + FillValues(); + ResumeLayout(); + } - #endregion + #endregion - #region Private Methods + #region Private Methods - private void FillValues() - { - delimiterTextBox.Text = _config.DelimiterChar; - textBoxQuoteChar.Text = _config.QuoteChar.ToString(); - textboxEscapeChar.Text = _config.EscapeChar.ToString(); - checkBoxEscape.Checked = _config.EscapeChar != '\0'; - textBoxCommentChar.Text = _config.CommentChar.ToString(); - checkBoxFieldNames.Checked = _config.HasFieldNames; - textboxEscapeChar.Enabled = checkBoxEscape.Checked; - numericUpDownMinColumns.Value = _config.MinColumns; - } + private void FillValues() + { + delimiterTextBox.Text = _config.DelimiterChar; + textBoxQuoteChar.Text = _config.QuoteChar.ToString(); + textboxEscapeChar.Text = _config.EscapeChar.ToString(); + checkBoxEscape.Checked = _config.EscapeChar != '\0'; + textBoxCommentChar.Text = _config.CommentChar.ToString(); + checkBoxFieldNames.Checked = _config.HasFieldNames; + textboxEscapeChar.Enabled = checkBoxEscape.Checked; + numericUpDownMinColumns.Value = _config.MinColumns; + } - private void RetrieveValues() - { - _config.DelimiterChar = delimiterTextBox.Text; - _config.QuoteChar = textBoxQuoteChar.Text[0]; - _config.EscapeChar = checkBoxEscape.Checked ? textboxEscapeChar.Text[0] : '\0'; - _config.CommentChar = textBoxCommentChar.Text[0]; - _config.HasFieldNames = checkBoxFieldNames.Checked; - _config.MinColumns = (int)numericUpDownMinColumns.Value; - } + private void RetrieveValues() + { + _config.DelimiterChar = delimiterTextBox.Text; + _config.QuoteChar = textBoxQuoteChar.Text[0]; + _config.EscapeChar = checkBoxEscape.Checked ? textboxEscapeChar.Text[0] : '\0'; + _config.CommentChar = textBoxCommentChar.Text[0]; + _config.HasFieldNames = checkBoxFieldNames.Checked; + _config.MinColumns = (int)numericUpDownMinColumns.Value; + } - #endregion + #endregion - #region Events handler + #region Events handler - private void OnOkButtonClick(object sender, EventArgs e) - { - RetrieveValues(); - } + private void OnOkButtonClick(object sender, EventArgs e) + { + RetrieveValues(); + } - private void OnEscapeCheckBoxCheckedChanged(object sender, EventArgs e) - { - textboxEscapeChar.Enabled = checkBoxEscape.Checked; - } + private void OnEscapeCheckBoxCheckedChanged(object sender, EventArgs e) + { + textboxEscapeChar.Enabled = checkBoxEscape.Checked; + } - #endregion + #endregion - } } \ No newline at end of file diff --git a/src/CsvColumnizer/CsvLogLine.cs b/src/CsvColumnizer/CsvLogLine.cs index 6fdef11d..8187a496 100644 --- a/src/CsvColumnizer/CsvLogLine.cs +++ b/src/CsvColumnizer/CsvLogLine.cs @@ -1,17 +1,16 @@ using LogExpert; -namespace CsvColumnizer +namespace CsvColumnizer; + +public class CsvLogLine(string fullLine, int lineNumber) : ILogLine { - public class CsvLogLine(string fullLine, int lineNumber) : ILogLine - { - #region Properties + #region Properties - public string FullLine { get; set; } = fullLine; + public string FullLine { get; set; } = fullLine; - public int LineNumber { get; set; } = lineNumber; + public int LineNumber { get; set; } = lineNumber; - string ITextValue.Text => FullLine; + string ITextValue.Text => FullLine; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/FlashIconHighlighter/FlashIconPlugin.cs b/src/FlashIconHighlighter/FlashIconPlugin.cs index 2ffe69b0..fdf4e2f3 100644 --- a/src/FlashIconHighlighter/FlashIconPlugin.cs +++ b/src/FlashIconHighlighter/FlashIconPlugin.cs @@ -1,58 +1,57 @@ -using LogExpert; - using System; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Windows.Forms; +using LogExpert; + [assembly: SupportedOSPlatform("windows")] -namespace FlashIconHighlighter +namespace FlashIconHighlighter; + +internal class FlashIconPlugin : IKeywordAction { - internal class FlashIconPlugin : IKeywordAction - { - #region Properties + #region Properties - public string Text => GetName(); + public string Text => GetName(); - #endregion + #endregion - #region IKeywordAction Member + #region IKeywordAction Member - public void Execute(string keyword, string param, ILogExpertCallback callback, ILogLineColumnizer columnizer) + public void Execute (string keyword, string param, ILogExpertCallback callback, ILogLineColumnizer columnizer) + { + FormCollection openForms = Application.OpenForms; + foreach (Form form in openForms) { - FormCollection openForms = Application.OpenForms; - foreach (Form form in openForms) + if (form.TopLevel && form.Name.Equals("LogTabWindow", StringComparison.OrdinalIgnoreCase) && form.Text.Contains(callback.GetFileName(), StringComparison.Ordinal)) { - if (form.TopLevel && form.Name.Equals("LogTabWindow") && form.Text.Contains(callback.GetFileName())) - { - form.BeginInvoke(FlashWindow, [form]); - } + form.BeginInvoke(FlashWindow, [form]); } } + } - private void FlashWindow(Form form) + private void FlashWindow (Form form) + { + FLASHWINFO fw = new() { - FLASHWINFO fw = new() - { - cbSize = Convert.ToUInt32(Marshal.SizeOf(typeof(FLASHWINFO))), - hwnd = form.Handle, - dwFlags = 14, - uCount = 0 - }; - - Win32Stuff.FlashWindowEx(ref fw); - } + cbSize = Convert.ToUInt32(Marshal.SizeOf(typeof(FLASHWINFO))), + hwnd = form.Handle, + dwFlags = 14, + uCount = 0 + }; - public string GetDescription() - { - return "Let the taskbar icon flash "; - } + Win32Stuff.FlashWindowEx(ref fw); + } - public string GetName() - { - return "Flash Icon"; - } + public string GetDescription () + { + return "Let the taskbar icon flash "; + } - #endregion + public string GetName () + { + return "Flash Icon"; } + + #endregion } \ No newline at end of file diff --git a/src/FlashIconHighlighter/Win32Stuff.cs b/src/FlashIconHighlighter/Win32Stuff.cs index fbb008f3..bc68f3c0 100644 --- a/src/FlashIconHighlighter/Win32Stuff.cs +++ b/src/FlashIconHighlighter/Win32Stuff.cs @@ -1,29 +1,28 @@ using System; using System.Runtime.InteropServices; -namespace FlashIconHighlighter -{ - /* - * Flash stuff stolen from http://blogs.x2line.com/al/archive/2008/04/19/3392.aspx - */ +namespace FlashIconHighlighter; + +/* + * Flash stuff stolen from http://blogs.x2line.com/al/archive/2008/04/19/3392.aspx + */ - [StructLayout(LayoutKind.Sequential)] - public struct FLASHWINFO - { - public uint cbSize; - public IntPtr hwnd; - public int dwFlags; - public uint uCount; - public int dwTimeout; - } +[StructLayout(LayoutKind.Sequential)] +public struct FLASHWINFO +{ + public uint cbSize; + public IntPtr hwnd; + public int dwFlags; + public uint uCount; + public int dwTimeout; +} - public partial class Win32Stuff - { - #region Public methods +public partial class Win32Stuff +{ + #region Public methods - [LibraryImport("user32.dll")] - public static partial int FlashWindowEx(ref FLASHWINFO pwfi); + [LibraryImport("user32.dll")] + public static partial int FlashWindowEx(ref FLASHWINFO pwfi); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/GlassfishColumnizer/GlassFishLogLine.cs b/src/GlassfishColumnizer/GlassFishLogLine.cs index 4d12c799..284b4073 100644 --- a/src/GlassfishColumnizer/GlassFishLogLine.cs +++ b/src/GlassfishColumnizer/GlassFishLogLine.cs @@ -1,17 +1,16 @@ using LogExpert; -namespace GlassfishColumnizer +namespace GlassfishColumnizer; + +internal class GlassFishLogLine : ILogLine { - internal class GlassFishLogLine : ILogLine - { - #region Properties + #region Properties - public string FullLine { get; set; } + public string FullLine { get; set; } - public int LineNumber { get; set; } + public int LineNumber { get; set; } - string ITextValue.Text => FullLine; + string ITextValue.Text => FullLine; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/GlassfishColumnizer/GlassfishColumnizer.cs b/src/GlassfishColumnizer/GlassfishColumnizer.cs index ded86f18..d80cc0c9 100644 --- a/src/GlassfishColumnizer/GlassfishColumnizer.cs +++ b/src/GlassfishColumnizer/GlassfishColumnizer.cs @@ -1,215 +1,215 @@ -using LogExpert; - using System; using System.Globalization; using System.Linq; -namespace GlassfishColumnizer +using LogExpert; + +namespace GlassfishColumnizer; + +internal class GlassfishColumnizer : ILogLineXmlColumnizer { - internal class GlassfishColumnizer : ILogLineXmlColumnizer - { - #region Fields + #region Fields - public const int COLUMN_COUNT = 2; - protected const string DATETIME_FORMAT = "yyyy-MM-ddTHH:mm:ss.fffzzzz"; - protected const string DATETIME_FORMAT_OUT = "yyyy-MM-dd HH:mm:ss.fff"; + public const int COLUMN_COUNT = 2; + private const string DATETIME_FORMAT = "yyyy-MM-ddTHH:mm:ss.fffzzzz"; + private const string DATETIME_FORMAT_OUT = "yyyy-MM-dd HH:mm:ss.fff"; + private const char separatorChar = '|'; - private static readonly XmlConfig xmlConfig = new(); - private readonly char separatorChar = '|'; - private readonly char[] trimChars = ['|']; - protected CultureInfo cultureInfo = new("en-US"); - protected int timeOffset; + private static readonly XmlConfig xmlConfig = new(); - #endregion + private readonly char[] trimChars = ['|']; + private readonly CultureInfo cultureInfo = new("en-US"); + private int timeOffset; - #region cTor + #endregion - public GlassfishColumnizer() - { - } + #region cTor - #endregion + public GlassfishColumnizer () + { + } - #region Public methods + #endregion - public IXmlLogConfiguration GetXmlLogConfiguration() - { - return xmlConfig; - } + #region Public methods + + public IXmlLogConfiguration GetXmlLogConfiguration () + { + return xmlConfig; + } - public ILogLine GetLineTextForClipboard(ILogLine logLine, ILogLineColumnizerCallback callback) + public ILogLine GetLineTextForClipboard (ILogLine logLine, ILogLineColumnizerCallback callback) + { + GlassFishLogLine line = new() { - GlassFishLogLine line = new() - { - FullLine = logLine.FullLine.Replace(separatorChar, '|'), - LineNumber = logLine.LineNumber - }; + FullLine = logLine.FullLine.Replace(separatorChar, '|'), + LineNumber = logLine.LineNumber + }; - return line; - } + return line; + } - public string GetName() - { - return "Classfish"; - } + public string GetName () + { + return "Classfish"; + } + + public string GetDescription () + { + return "Parse the timestamps in Glassfish logfiles."; + } + + public int GetColumnCount () + { + return COLUMN_COUNT; + } + + public string[] GetColumnNames () + { + return ["Date/Time", "Message"]; + } + + public IColumnizedLogLine SplitLine (ILogLineColumnizerCallback callback, ILogLine line) + { + ColumnizedLogLine cLogLine = new(); + cLogLine.LogLine = line; - public string GetDescription() + var temp = line.FullLine; + + Column[] columns = Column.CreateColumns(COLUMN_COUNT, cLogLine); + cLogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); + + // delete '[#|' and '|#]' + if (temp.StartsWith("[#|")) { - return "Parse the timestamps in Glassfish logfiles."; + temp = temp[3..]; } - public int GetColumnCount() + if (temp.EndsWith("|#]")) { - return COLUMN_COUNT; + temp = temp[..^3]; } - public string[] GetColumnNames() + // If the line is too short (i.e. does not follow the format for this columnizer) return the whole line content + // in colum 8 (the log message column). Date and time column will be left blank. + if (temp.Length < 28) { - return ["Date/Time", "Message"]; + columns[1].FullValue = temp; } - - public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) + else { - ColumnizedLogLine cLogLine = new(); - cLogLine.LogLine = line; - - var temp = line.FullLine; - - Column[] columns = Column.CreateColumns(COLUMN_COUNT, cLogLine); - cLogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); - - // delete '[#|' and '|#]' - if (temp.StartsWith("[#|")) + try { - temp = temp[3..]; - } + DateTime dateTime = GetTimestamp(callback, line); + if (dateTime == DateTime.MinValue) + { + columns[1].FullValue = temp; + } - if (temp.EndsWith("|#]")) + var newDate = dateTime.ToString(DATETIME_FORMAT_OUT); + columns[0].FullValue = newDate; + } + catch (Exception) { - temp = temp[..^3]; + columns[0].FullValue = "n/a"; } - // If the line is too short (i.e. does not follow the format for this columnizer) return the whole line content - // in colum 8 (the log message column). Date and time column will be left blank. - if (temp.Length < 28) + Column timestmp = columns[0]; + + string[] cols; + cols = temp.Split(trimChars, COLUMN_COUNT, StringSplitOptions.None); + + if (cols.Length != COLUMN_COUNT) { + columns[0].FullValue = string.Empty; columns[1].FullValue = temp; } else { - try - { - DateTime dateTime = GetTimestamp(callback, line); - if (dateTime == DateTime.MinValue) - { - columns[1].FullValue = temp; - } - - var newDate = dateTime.ToString(DATETIME_FORMAT_OUT); - columns[0].FullValue = newDate; - } - catch (Exception) - { - columns[0].FullValue = "n/a"; - } + columns[0] = timestmp; + columns[1].FullValue = cols[1]; + } + } - Column timestmp = columns[0]; + return cLogLine; + } - string[] cols; - cols = temp.Split(trimChars, COLUMN_COUNT, StringSplitOptions.None); + public bool IsTimeshiftImplemented () + { + return true; + } - if (cols.Length != COLUMN_COUNT) - { - columns[0].FullValue = string.Empty; - columns[1].FullValue = temp; - } - else - { - columns[0] = timestmp; - columns[1].FullValue = cols[1]; - } - } + public void SetTimeOffset (int msecOffset) + { + timeOffset = msecOffset; + } - return cLogLine; - } + public int GetTimeOffset () + { + return timeOffset; + } + + public DateTime GetTimestamp (ILogLineColumnizerCallback callback, ILogLine logLine) + { + var temp = logLine.FullLine; - public bool IsTimeshiftImplemented() + // delete '[#|' and '|#]' + if (temp.StartsWith("[#|")) { - return true; + temp = temp[3..]; } - public void SetTimeOffset(int msecOffset) + if (temp.EndsWith("|#]")) { - timeOffset = msecOffset; + temp = temp[..^3]; } - public int GetTimeOffset() + if (temp.Length < 28) { - return timeOffset; + return DateTime.MinValue; } - public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine logLine) + var endIndex = temp.IndexOf(separatorChar, 1); + if (endIndex > 28 || endIndex < 0) { - var temp = logLine.FullLine; - - // delete '[#|' and '|#]' - if (temp.StartsWith("[#|")) - { - temp = temp[3..]; - } - - if (temp.EndsWith("|#]")) - { - temp = temp[..^3]; - } + return DateTime.MinValue; + } - if (temp.Length < 28) - { - return DateTime.MinValue; - } + var value = temp[..endIndex]; - var endIndex = temp.IndexOf(separatorChar, 1); - if (endIndex > 28 || endIndex < 0) + try + { + // convert glassfish timestamp into a readable format: + if (DateTime.TryParseExact(value, DATETIME_FORMAT, cultureInfo, DateTimeStyles.None, out DateTime timestamp)) { - return DateTime.MinValue; + return timestamp.AddMilliseconds(timeOffset); } - var value = temp[..endIndex]; + return DateTime.MinValue; + } + catch (Exception) + { + return DateTime.MinValue; + } + } + public void PushValue (ILogLineColumnizerCallback callback, int column, string value, string oldValue) + { + if (column == 0) + { try { - // convert glassfish timestamp into a readable format: - if (DateTime.TryParseExact(value, DATETIME_FORMAT, cultureInfo, DateTimeStyles.None, out DateTime timestamp)) - { - return timestamp.AddMilliseconds(timeOffset); - } - - return DateTime.MinValue; + var newDateTime = DateTime.ParseExact(value, DATETIME_FORMAT_OUT, cultureInfo); + var oldDateTime = DateTime.ParseExact(oldValue, DATETIME_FORMAT_OUT, cultureInfo); + var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; + var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; + timeOffset = (int)(mSecsNew - mSecsOld); } - catch (Exception) - { - return DateTime.MinValue; - } - } - - public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) - { - if (column == 0) + catch (FormatException) { - try - { - var newDateTime = DateTime.ParseExact(value, DATETIME_FORMAT_OUT, cultureInfo); - var oldDateTime = DateTime.ParseExact(oldValue, DATETIME_FORMAT_OUT, cultureInfo); - var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; - var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; - timeOffset = (int)(mSecsNew - mSecsOld); - } - catch (FormatException) - { - } } } - - #endregion } + + #endregion } \ No newline at end of file diff --git a/src/GlassfishColumnizer/XmlConfig.cs b/src/GlassfishColumnizer/XmlConfig.cs index 4dab78d5..0d81e05a 100644 --- a/src/GlassfishColumnizer/XmlConfig.cs +++ b/src/GlassfishColumnizer/XmlConfig.cs @@ -1,19 +1,18 @@ using LogExpert; -namespace GlassfishColumnizer +namespace GlassfishColumnizer; + +internal class XmlConfig : IXmlLogConfiguration { - internal class XmlConfig : IXmlLogConfiguration - { - #region Properties + #region Properties - public string XmlStartTag { get; } = "[#|"; + public string XmlStartTag { get; } = "[#|"; - public string XmlEndTag { get; } = "|#]"; + public string XmlEndTag { get; } = "|#]"; - public string Stylesheet { get; } + public string Stylesheet { get; } - public string[] Namespace => null; + public string[] Namespace => null; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/JsonColumnizer/JsonColumn.cs b/src/JsonColumnizer/JsonColumn.cs index 5279533a..5ac9ed9e 100644 --- a/src/JsonColumnizer/JsonColumn.cs +++ b/src/JsonColumnizer/JsonColumn.cs @@ -1,11 +1,10 @@ -namespace JsonColumnizer +namespace JsonColumnizer; + +public class JsonColumn(string name) { - public class JsonColumn(string name) - { - #region Properties + #region Properties - public string Name { get; } = name; + public string Name { get; } = name; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/JsonColumnizer/JsonColumnizer.cs b/src/JsonColumnizer/JsonColumnizer.cs index 250105f3..04c6f071 100644 --- a/src/JsonColumnizer/JsonColumnizer.cs +++ b/src/JsonColumnizer/JsonColumnizer.cs @@ -7,225 +7,224 @@ using System.Collections.Generic; using System.Linq; -namespace JsonColumnizer +namespace JsonColumnizer; + +/// +/// This Columnizer can parse JSON files. +/// +public class JsonColumnizer : ILogLineColumnizer, IInitColumnizer, IColumnizerPriority { - /// - /// This Columnizer can parse JSON files. - /// - public class JsonColumnizer : ILogLineColumnizer, IInitColumnizer, IColumnizerPriority - { - #region Fields + #region Fields - private static readonly JsonColumn _initialColumn = new JsonColumn("Text"); + private static readonly JsonColumn _initialColumn = new JsonColumn("Text"); - private readonly IList _columnList = new List([InitialColumn]); + private readonly IList _columnList = new List([InitialColumn]); - #endregion + #endregion - #region Properties + #region Properties - public HashSet ColumnSet { get; set; } = []; + public HashSet ColumnSet { get; set; } = []; - protected IList ColumnList => _columnList; + protected IList ColumnList => _columnList; - protected static JsonColumn InitialColumn => _initialColumn; + protected static JsonColumn InitialColumn => _initialColumn; - #endregion + #endregion - #region Public methods + #region Public methods - public virtual void Selected(ILogLineColumnizerCallback callback) - { - ColumnList.Clear(); - ColumnSet.Clear(); + public virtual void Selected(ILogLineColumnizerCallback callback) + { + ColumnList.Clear(); + ColumnSet.Clear(); - var line = callback.GetLogLine(0); + var line = callback.GetLogLine(0); - if (line != null) + if (line != null) + { + var json = ParseJson(line); + if (json != null) { - var json = ParseJson(line); - if (json != null) - { - var fieldCount = json.Properties().Count(); + var fieldCount = json.Properties().Count(); - for (var i = 0; i < fieldCount; ++i) + for (var i = 0; i < fieldCount; ++i) + { + var columeName = json.Properties().ToArray()[i].Name; + if (!ColumnSet.Contains(columeName)) { - var columeName = json.Properties().ToArray()[i].Name; - if (!ColumnSet.Contains(columeName)) - { - ColumnSet.Add(columeName); - ColumnList.Add(new JsonColumn(columeName)); - } + ColumnSet.Add(columeName); + ColumnList.Add(new JsonColumn(columeName)); } } - else - { - ColumnSet.Add("Text"); - ColumnList.Add(InitialColumn); - } } - - if (ColumnList.Count() == 0) + else { ColumnSet.Add("Text"); ColumnList.Add(InitialColumn); } } - public virtual void DeSelected(ILogLineColumnizerCallback callback) + if (ColumnList.Count() == 0) { - // nothing to do + ColumnSet.Add("Text"); + ColumnList.Add(InitialColumn); } + } - public virtual string GetName() - { - return "JSON Columnizer"; - } + public virtual void DeSelected(ILogLineColumnizerCallback callback) + { + // nothing to do + } - public virtual string GetDescription() + public virtual string GetName() + { + return "JSON Columnizer"; + } + + public virtual string GetDescription() + { + return "Splits JSON files into columns.\r\n\r\nCredits:\r\nThis Columnizer uses the Newtonsoft json package.\r\n\r\nFirst line must be valid or else only one column will be displayed and the other values dropped!"; + } + + public virtual int GetColumnCount() + { + return ColumnList.Count; + } + + public virtual string[] GetColumnNames() + { + var names = new string[GetColumnCount()]; + var i = 0; + foreach (var column in ColumnList) { - return "Splits JSON files into columns.\r\n\r\nCredits:\r\nThis Columnizer uses the Newtonsoft json package.\r\n\r\nFirst line must be valid or else only one column will be displayed and the other values dropped!"; + names[i++] = column.Name; } - public virtual int GetColumnCount() + return names; + } + + public virtual IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) + { + JObject json = ParseJson(line); + + if (json != null) { - return ColumnList.Count; + return SplitJsonLine(line, json); } - public virtual string[] GetColumnNames() - { - var names = new string[GetColumnCount()]; - var i = 0; - foreach (var column in ColumnList) - { - names[i++] = column.Name; - } + var cLogLine = new ColumnizedLogLine { LogLine = line }; - return names; - } + var columns = Column.CreateColumns(ColumnList.Count, cLogLine); - public virtual IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) - { - JObject json = ParseJson(line); + columns.Last().FullValue = line.FullLine; - if (json != null) - { - return SplitJsonLine(line, json); - } + cLogLine.ColumnValues = columns.Select(a => (IColumn)a).ToArray(); - var cLogLine = new ColumnizedLogLine { LogLine = line }; + return cLogLine; + } - var columns = Column.CreateColumns(ColumnList.Count, cLogLine); + public virtual bool IsTimeshiftImplemented() + { + return false; + } - columns.Last().FullValue = line.FullLine; + public virtual void SetTimeOffset(int msecOffset) + { + throw new NotImplementedException(); + } - cLogLine.ColumnValues = columns.Select(a => (IColumn)a).ToArray(); + public virtual int GetTimeOffset() + { + throw new NotImplementedException(); + } - return cLogLine; - } + public virtual DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) + { + throw new NotImplementedException(); + } - public virtual bool IsTimeshiftImplemented() - { - return false; - } + public virtual void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) + { + throw new NotImplementedException(); + } - public virtual void SetTimeOffset(int msecOffset) + public virtual Priority GetPriority(string fileName, IEnumerable samples) + { + Priority result = Priority.NotSupport; + if (fileName.EndsWith("json", StringComparison.OrdinalIgnoreCase)) { - throw new NotImplementedException(); + result = Priority.WellSupport; } - public virtual int GetTimeOffset() - { - throw new NotImplementedException(); - } + return result; + } - public virtual DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) - { - throw new NotImplementedException(); - } + #endregion - public virtual void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) - { - throw new NotImplementedException(); - } + #region Private Methods - public virtual Priority GetPriority(string fileName, IEnumerable samples) + protected static JObject ParseJson(ILogLine line) + { + return JsonConvert.DeserializeObject(line.FullLine, new JsonSerializerSettings() { - Priority result = Priority.NotSupport; - if (fileName.EndsWith("json", StringComparison.OrdinalIgnoreCase)) - { - result = Priority.WellSupport; - } + Error = (sender, args) => { args.ErrorContext.Handled = true; } //We ignore the error and handle the null value + }); + } - return result; - } + public class ColumnWithName : Column + { + public string ColumnName { get; set; } + } - #endregion + // + // Following two log lines should be loaded and displayed in correct grid. + // {"time":"2019-02-13T02:55:35.5186240Z","message":"Hosting starting"} + // {"time":"2019-02-13T02:55:35.5186240Z","level":"warning", "message":"invalid host."} + // + protected virtual IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) + { + var cLogLine = new ColumnizedLogLine { LogLine = line }; - #region Private Methods + var columns = json.Properties().Select(property => new ColumnWithName { FullValue = property.Value.ToString(), ColumnName = property.Name.ToString(), Parent = cLogLine }).ToList(); - protected static JObject ParseJson(ILogLine line) + foreach (var jsonColumn in columns) { - return JsonConvert.DeserializeObject(line.FullLine, new JsonSerializerSettings() + // When find new column in a log line, add a new column in the end of the list. + if (!ColumnSet.Contains(jsonColumn.ColumnName)) { - Error = (sender, args) => { args.ErrorContext.Handled = true; } //We ignore the error and handle the null value - }); - } + if (ColumnList.Count == 1 && !ColumnSet.Contains(ColumnList[0].Name)) + { + ColumnList.Clear(); + } - public class ColumnWithName : Column - { - public string ColumnName { get; set; } + ColumnSet.Add(jsonColumn.ColumnName); + ColumnList.Add(new JsonColumn(jsonColumn.ColumnName)); + } } // - // Following two log lines should be loaded and displayed in correct grid. - // {"time":"2019-02-13T02:55:35.5186240Z","message":"Hosting starting"} - // {"time":"2019-02-13T02:55:35.5186240Z","level":"warning", "message":"invalid host."} + // Always rearrage the order of all json fields within a line to follow the sequence of columnNameList. + // This will make sure the log line displayed correct even the order of json fields changed. // - protected virtual IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) + List returnColumns = []; + foreach (var column in ColumnList) { - var cLogLine = new ColumnizedLogLine { LogLine = line }; - - var columns = json.Properties().Select(property => new ColumnWithName { FullValue = property.Value.ToString(), ColumnName = property.Name.ToString(), Parent = cLogLine }).ToList(); - - foreach (var jsonColumn in columns) - { - // When find new column in a log line, add a new column in the end of the list. - if (!ColumnSet.Contains(jsonColumn.ColumnName)) - { - if (ColumnList.Count == 1 && !ColumnSet.Contains(ColumnList[0].Name)) - { - ColumnList.Clear(); - } - - ColumnSet.Add(jsonColumn.ColumnName); - ColumnList.Add(new JsonColumn(jsonColumn.ColumnName)); - } - } - - // - // Always rearrage the order of all json fields within a line to follow the sequence of columnNameList. - // This will make sure the log line displayed correct even the order of json fields changed. - // - List returnColumns = []; - foreach (var column in ColumnList) + var existingColumn = columns.Find(x => x.ColumnName == column.Name); + if (existingColumn != null) { - var existingColumn = columns.Find(x => x.ColumnName == column.Name); - if (existingColumn != null) - { - returnColumns.Add(new Column() { FullValue = existingColumn.FullValue, Parent = cLogLine }); - continue; - } - - // Fields that is missing in current line should be shown as empty. - returnColumns.Add(new Column() { FullValue = "", Parent = cLogLine }); + returnColumns.Add(new Column() { FullValue = existingColumn.FullValue, Parent = cLogLine }); + continue; } - cLogLine.ColumnValues = [.. returnColumns]; - - return cLogLine; + // Fields that is missing in current line should be shown as empty. + returnColumns.Add(new Column() { FullValue = "", Parent = cLogLine }); } - #endregion + cLogLine.ColumnValues = [.. returnColumns]; + + return cLogLine; } + + #endregion } \ No newline at end of file diff --git a/src/JsonCompactColumnizer/JsonCompactColumnizer.cs b/src/JsonCompactColumnizer/JsonCompactColumnizer.cs index 32acccf8..d286ac88 100644 --- a/src/JsonCompactColumnizer/JsonCompactColumnizer.cs +++ b/src/JsonCompactColumnizer/JsonCompactColumnizer.cs @@ -6,116 +6,115 @@ using System.Collections.Generic; using System.Linq; -namespace JsonColumnizer +namespace JsonColumnizer; + +/// +/// This Columnizer can parse JSON files. +/// +public class JsonCompactColumnizer : JsonColumnizer, IColumnizerPriority { - /// - /// This Columnizer can parse JSON files. - /// - public class JsonCompactColumnizer : JsonColumnizer, IColumnizerPriority + #region Public methods + + public override string GetName() { - #region Public methods + return "JSON Compact Columnizer"; + } - public override string GetName() - { - return "JSON Compact Columnizer"; - } + public override string GetDescription() + { + return "A JSON columnier for Serilog.Formatting.Compact format."; + } - public override string GetDescription() + public override void Selected(ILogLineColumnizerCallback callback) + { + ColumnList.Clear(); + // Create column header with cached column list. + + foreach (var col in _tagDict.Keys) { - return "A JSON columnier for Serilog.Formatting.Compact format."; + ColumnList.Add(new JsonColumn(_tagDict[col])); } + } - public override void Selected(ILogLineColumnizerCallback callback) + public override Priority GetPriority(string fileName, IEnumerable samples) + { + Priority result = Priority.NotSupport; + if (fileName.EndsWith("json", StringComparison.OrdinalIgnoreCase)) { - ColumnList.Clear(); - // Create column header with cached column list. - - foreach (var col in _tagDict.Keys) - { - ColumnList.Add(new JsonColumn(_tagDict[col])); - } + result = Priority.WellSupport; } - public override Priority GetPriority(string fileName, IEnumerable samples) + if (samples != null && samples.Any()) { - Priority result = Priority.NotSupport; - if (fileName.EndsWith("json", StringComparison.OrdinalIgnoreCase)) - { - result = Priority.WellSupport; - } - - if (samples != null && samples.Any()) + try { - try + var line = samples.First(); + JObject json = ParseJson(line); + if (json != null) { - var line = samples.First(); - JObject json = ParseJson(line); - if (json != null) + var columns = SplitJsonLine(samples.First(), json); + if (columns.ColumnValues.Length > 0 && Array.Exists(columns.ColumnValues, x => !string.IsNullOrEmpty(x.FullValue))) { - var columns = SplitJsonLine(samples.First(), json); - if (columns.ColumnValues.Length > 0 && Array.Exists(columns.ColumnValues, x => !string.IsNullOrEmpty(x.FullValue))) - { - result = Priority.PerfectlySupport; - } + result = Priority.PerfectlySupport; } } - catch (Exception) - { - // Ignore errors when determine priority. - } } - - return result; + catch (Exception) + { + // Ignore errors when determine priority. + } } - #endregion + return result; + } - #region Private Methods + #endregion - protected Dictionary _tagDict = new() - { - {"@t", "Timestamp"}, - {"@l", "Level"}, - {"@m", "Message"}, - {"@x", "Exception"}, - {"@i", "Event id"}, - {"@r", "Renderings"}, - {"@mt", "Message Template"}, - }; - - protected override IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) - { - List returnColumns = []; - var cLogLine = new ColumnizedLogLine { LogLine = line }; + #region Private Methods - var columns = json.Properties().Select(property => new ColumnWithName { FullValue = property.Value.ToString(), ColumnName = property.Name.ToString(), Parent = cLogLine }).ToList(); + protected Dictionary _tagDict = new() + { + {"@t", "Timestamp"}, + {"@l", "Level"}, + {"@m", "Message"}, + {"@x", "Exception"}, + {"@i", "Event id"}, + {"@r", "Renderings"}, + {"@mt", "Message Template"}, + }; + + protected override IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) + { + List returnColumns = []; + var cLogLine = new ColumnizedLogLine { LogLine = line }; - // - // Always rearrage the order of all json fields within a line to follow the sequence of columnNameList. - // This will make sure the log line displayed correct even the order of json fields changed. - // - foreach (var column in _tagDict.Keys) - { - if (column.StartsWith('@')) - { - var existingColumn = columns.Find(x => x.ColumnName == column); + var columns = json.Properties().Select(property => new ColumnWithName { FullValue = property.Value.ToString(), ColumnName = property.Name.ToString(), Parent = cLogLine }).ToList(); - if (existingColumn != null) - { - returnColumns.Add(new Column() { FullValue = existingColumn.FullValue, Parent = cLogLine }); - continue; - } + // + // Always rearrage the order of all json fields within a line to follow the sequence of columnNameList. + // This will make sure the log line displayed correct even the order of json fields changed. + // + foreach (var column in _tagDict.Keys) + { + if (column.StartsWith('@')) + { + var existingColumn = columns.Find(x => x.ColumnName == column); - // Fields that is missing in current line should be shown as empty. - returnColumns.Add(new Column() { FullValue = "", Parent = cLogLine }); + if (existingColumn != null) + { + returnColumns.Add(new Column() { FullValue = existingColumn.FullValue, Parent = cLogLine }); + continue; } - } - cLogLine.ColumnValues = [.. returnColumns]; - - return cLogLine; + // Fields that is missing in current line should be shown as empty. + returnColumns.Add(new Column() { FullValue = "", Parent = cLogLine }); + } } - #endregion + cLogLine.ColumnValues = [.. returnColumns]; + + return cLogLine; } + + #endregion } \ No newline at end of file diff --git a/src/Log4jXmlColumnizer/Log4JLogLine.cs b/src/Log4jXmlColumnizer/Log4JLogLine.cs index d6b09125..616a1939 100644 --- a/src/Log4jXmlColumnizer/Log4JLogLine.cs +++ b/src/Log4jXmlColumnizer/Log4JLogLine.cs @@ -1,17 +1,16 @@ using LogExpert; -namespace Log4jXmlColumnizer +namespace Log4jXmlColumnizer; + +internal class Log4JLogLine : ILogLine { - internal class Log4JLogLine : ILogLine - { - #region Properties + #region Properties - public string FullLine { get; set; } + public string FullLine { get; set; } - public int LineNumber { get; set; } + public int LineNumber { get; set; } - string ITextValue.Text => FullLine; + string ITextValue.Text => FullLine; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/Log4jXmlColumnizer/Log4jColumnEntry.cs b/src/Log4jXmlColumnizer/Log4jColumnEntry.cs index b1d7869a..ad0e4f39 100644 --- a/src/Log4jXmlColumnizer/Log4jColumnEntry.cs +++ b/src/Log4jXmlColumnizer/Log4jColumnEntry.cs @@ -1,19 +1,18 @@ using System; -namespace Log4jXmlColumnizer +namespace Log4jXmlColumnizer; + +/// +/// Helper class for configuration of the columns. +/// +[Serializable] +public class Log4jColumnEntry(string name, int index, int maxLen) { - /// - /// Helper class for configuration of the columns. - /// - [Serializable] - public class Log4jColumnEntry(string name, int index, int maxLen) - { - public int ColumnIndex { get; set; } = index; + public int ColumnIndex { get; set; } = index; - public string ColumnName { get; set; } = name; + public string ColumnName { get; set; } = name; - public int MaxLen { get; set; } = maxLen; + public int MaxLen { get; set; } = maxLen; - public bool Visible { get; set; } - } + public bool Visible { get; set; } } \ No newline at end of file diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs index 29d2fa3b..012bd06b 100644 --- a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs @@ -12,300 +12,299 @@ using System.Windows.Forms; [assembly: SupportedOSPlatform("windows")] -namespace Log4jXmlColumnizer +namespace Log4jXmlColumnizer; + +public class Log4jXmlColumnizer : ILogLineXmlColumnizer, IColumnizerConfigurator, IColumnizerPriority { - public class Log4jXmlColumnizer : ILogLineXmlColumnizer, IColumnizerConfigurator, IColumnizerPriority - { - #region Fields + #region Fields - public const int COLUMN_COUNT = 9; - protected const string DATETIME_FORMAT = "dd.MM.yyyy HH:mm:ss.fff"; + public const int COLUMN_COUNT = 9; + protected const string DATETIME_FORMAT = "dd.MM.yyyy HH:mm:ss.fff"; - private static readonly XmlConfig xmlConfig = new(); - private readonly char separatorChar = '\xFFFD'; - private readonly char[] trimChars = ['\xFFFD']; - private Log4jXmlColumnizerConfig _config; - protected CultureInfo cultureInfo = new("de-DE"); - protected int timeOffset; + private static readonly XmlConfig xmlConfig = new(); + private readonly char separatorChar = '\xFFFD'; + private readonly char[] trimChars = ['\xFFFD']; + private Log4jXmlColumnizerConfig _config; + protected CultureInfo cultureInfo = new("de-DE"); + protected int timeOffset; - #endregion + #endregion - #region cTor + #region cTor - public Log4jXmlColumnizer() - { - _config = new Log4jXmlColumnizerConfig(GetAllColumnNames()); - } + public Log4jXmlColumnizer() + { + _config = new Log4jXmlColumnizerConfig(GetAllColumnNames()); + } - #endregion + #endregion - #region Public methods + #region Public methods - public IXmlLogConfiguration GetXmlLogConfiguration() - { - return xmlConfig; - } + public IXmlLogConfiguration GetXmlLogConfiguration() + { + return xmlConfig; + } - public ILogLine GetLineTextForClipboard(ILogLine logLine, ILogLineColumnizerCallback callback) + public ILogLine GetLineTextForClipboard(ILogLine logLine, ILogLineColumnizerCallback callback) + { + Log4JLogLine line = new() { - Log4JLogLine line = new() - { - FullLine = logLine.FullLine.Replace(separatorChar, '|'), - LineNumber = logLine.LineNumber - }; + FullLine = logLine.FullLine.Replace(separatorChar, '|'), + LineNumber = logLine.LineNumber + }; - return line; - } + return line; + } - public string GetName() - { - return "Log4j XML"; - } + public string GetName() + { + return "Log4j XML"; + } - public string GetDescription() - { - return "Reads and formats XML log files written with log4j."; - } + public string GetDescription() + { + return "Reads and formats XML log files written with log4j."; + } - public int GetColumnCount() - { - return _config.ActiveColumnCount; - } + public int GetColumnCount() + { + return _config.ActiveColumnCount; + } + + public string[] GetColumnNames() + { + return _config.ActiveColumnNames; + } + + public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) + { + ColumnizedLogLine clogLine = new(); + clogLine.LogLine = line; - public string[] GetColumnNames() + Column[] columns = Column.CreateColumns(COLUMN_COUNT, clogLine); + + // If the line is too short (i.e. does not follow the format for this columnizer) return the whole line content + // in colum 8 (the log message column). Date and time column will be left blank. + if (line.FullLine.Length < 15) { - return _config.ActiveColumnNames; + columns[8].FullValue = line.FullLine; } - - public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) + else { - ColumnizedLogLine clogLine = new(); - clogLine.LogLine = line; + try + { + DateTime dateTime = GetTimestamp(callback, line); + + if (dateTime == DateTime.MinValue) + { + columns[8].FullValue = line.FullLine; + } - Column[] columns = Column.CreateColumns(COLUMN_COUNT, clogLine); + var newDate = dateTime.ToString(DATETIME_FORMAT); + columns[0].FullValue = newDate; + } + catch (Exception) + { + columns[0].FullValue = "n/a"; + } - // If the line is too short (i.e. does not follow the format for this columnizer) return the whole line content - // in colum 8 (the log message column). Date and time column will be left blank. - if (line.FullLine.Length < 15) + Column timestmp = columns[0]; + + string[] cols; + cols = line.FullLine.Split(trimChars, COLUMN_COUNT, StringSplitOptions.None); + + if (cols.Length != COLUMN_COUNT) { + columns[0].FullValue = ""; + columns[1].FullValue = ""; + columns[2].FullValue = ""; + columns[3].FullValue = ""; + columns[4].FullValue = ""; + columns[5].FullValue = ""; + columns[6].FullValue = ""; + columns[7].FullValue = ""; columns[8].FullValue = line.FullLine; } else { - try - { - DateTime dateTime = GetTimestamp(callback, line); - - if (dateTime == DateTime.MinValue) - { - columns[8].FullValue = line.FullLine; - } + columns[0] = timestmp; - var newDate = dateTime.ToString(DATETIME_FORMAT); - columns[0].FullValue = newDate; - } - catch (Exception) + for (var i = 1; i < cols.Length; i++) { - columns[0].FullValue = "n/a"; + columns[i].FullValue = cols[i]; } + } + } - Column timestmp = columns[0]; - - string[] cols; - cols = line.FullLine.Split(trimChars, COLUMN_COUNT, StringSplitOptions.None); + Column[] filteredColumns = MapColumns(columns); - if (cols.Length != COLUMN_COUNT) - { - columns[0].FullValue = ""; - columns[1].FullValue = ""; - columns[2].FullValue = ""; - columns[3].FullValue = ""; - columns[4].FullValue = ""; - columns[5].FullValue = ""; - columns[6].FullValue = ""; - columns[7].FullValue = ""; - columns[8].FullValue = line.FullLine; - } - else - { - columns[0] = timestmp; + clogLine.ColumnValues = filteredColumns.Select(a => a as IColumn).ToArray(); - for (var i = 1; i < cols.Length; i++) - { - columns[i].FullValue = cols[i]; - } - } - } - Column[] filteredColumns = MapColumns(columns); + return clogLine; + } - clogLine.ColumnValues = filteredColumns.Select(a => a as IColumn).ToArray(); + public bool IsTimeshiftImplemented() + { + return true; + } - return clogLine; - } + public void SetTimeOffset(int msecOffset) + { + timeOffset = msecOffset; + } + public int GetTimeOffset() + { + return timeOffset; + } - public bool IsTimeshiftImplemented() + public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) + { + if (line.FullLine.Length < 15) { - return true; + return DateTime.MinValue; } - public void SetTimeOffset(int msecOffset) - { - timeOffset = msecOffset; - } + var endIndex = line.FullLine.IndexOf(separatorChar, 1); - public int GetTimeOffset() + if (endIndex > 20 || endIndex < 0) { - return timeOffset; + return DateTime.MinValue; } + var value = line.FullLine.Substring(0, endIndex); - public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) + try { - if (line.FullLine.Length < 15) - { - return DateTime.MinValue; - } - - var endIndex = line.FullLine.IndexOf(separatorChar, 1); - - if (endIndex > 20 || endIndex < 0) + // convert log4j timestamp into a readable format: + if (long.TryParse(value, out var timestamp)) { - return DateTime.MinValue; - } - var value = line.FullLine.Substring(0, endIndex); + // Add the time offset before returning + DateTime dateTime = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + dateTime = dateTime.AddMilliseconds(timestamp); - try - { - // convert log4j timestamp into a readable format: - if (long.TryParse(value, out var timestamp)) - { - // Add the time offset before returning - DateTime dateTime = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - dateTime = dateTime.AddMilliseconds(timestamp); - - if (_config.localTimestamps) - { - dateTime = dateTime.ToLocalTime(); - } - return dateTime.AddMilliseconds(timeOffset); - } - else + if (_config.localTimestamps) { - return DateTime.MinValue; + dateTime = dateTime.ToLocalTime(); } + return dateTime.AddMilliseconds(timeOffset); } - catch (Exception) + else { return DateTime.MinValue; } } + catch (Exception) + { + return DateTime.MinValue; + } + } - public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) + public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) + { + if (column == 0) { - if (column == 0) + try + { + var newDateTime = DateTime.ParseExact(value, DATETIME_FORMAT, cultureInfo); + var oldDateTime = DateTime.ParseExact(oldValue, DATETIME_FORMAT, cultureInfo); + var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; + var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; + timeOffset = (int)(mSecsNew - mSecsOld); + } + catch (FormatException) { - try - { - var newDateTime = DateTime.ParseExact(value, DATETIME_FORMAT, cultureInfo); - var oldDateTime = DateTime.ParseExact(oldValue, DATETIME_FORMAT, cultureInfo); - var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; - var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; - timeOffset = (int)(mSecsNew - mSecsOld); - } - catch (FormatException) - { - } } } + } - public void Configure(ILogLineColumnizerCallback callback, string configDir) - { - FileInfo fileInfo = new(configDir + Path.DirectorySeparatorChar + "log4jxmlcolumnizer.json"); + public void Configure(ILogLineColumnizerCallback callback, string configDir) + { + FileInfo fileInfo = new(configDir + Path.DirectorySeparatorChar + "log4jxmlcolumnizer.json"); - Log4jXmlColumnizerConfigDlg dlg = new(_config); + Log4jXmlColumnizerConfigDlg dlg = new(_config); - if (dlg.ShowDialog() == DialogResult.OK) - { - using StreamWriter sw = new(fileInfo.Create()); - JsonSerializer serializer = new(); - serializer.Serialize(sw, _config); - } + if (dlg.ShowDialog() == DialogResult.OK) + { + using StreamWriter sw = new(fileInfo.Create()); + JsonSerializer serializer = new(); + serializer.Serialize(sw, _config); } + } - public void LoadConfig(string configDir) - { - var configPath = configDir + Path.DirectorySeparatorChar + "log4jxmlcolumnizer.json"; + public void LoadConfig(string configDir) + { + var configPath = configDir + Path.DirectorySeparatorChar + "log4jxmlcolumnizer.json"; - FileInfo fileInfo = new(configDir + Path.DirectorySeparatorChar + "log4jxmlcolumnizer.json"); + FileInfo fileInfo = new(configDir + Path.DirectorySeparatorChar + "log4jxmlcolumnizer.json"); - if (!File.Exists(configPath)) - { - _config = new Log4jXmlColumnizerConfig(GetAllColumnNames()); - } - else + if (!File.Exists(configPath)) + { + _config = new Log4jXmlColumnizerConfig(GetAllColumnNames()); + } + else + { + try { - try - { - _config = JsonConvert.DeserializeObject(File.ReadAllText($"{fileInfo.FullName}")); - if (_config.columnList.Count < COLUMN_COUNT) - { - _config = new Log4jXmlColumnizerConfig(GetAllColumnNames()); - } - } - catch (SerializationException e) + _config = JsonConvert.DeserializeObject(File.ReadAllText($"{fileInfo.FullName}")); + if (_config.columnList.Count < COLUMN_COUNT) { - MessageBox.Show(e.Message, "Deserialize"); _config = new Log4jXmlColumnizerConfig(GetAllColumnNames()); } } + catch (SerializationException e) + { + MessageBox.Show(e.Message, "Deserialize"); + _config = new Log4jXmlColumnizerConfig(GetAllColumnNames()); + } } + } - public Priority GetPriority(string fileName, IEnumerable samples) + public Priority GetPriority(string fileName, IEnumerable samples) + { + Priority result = Priority.NotSupport; + if (fileName.EndsWith("xml", StringComparison.OrdinalIgnoreCase)) { - Priority result = Priority.NotSupport; - if (fileName.EndsWith("xml", StringComparison.OrdinalIgnoreCase)) - { - result = Priority.CanSupport; - } - return result; + result = Priority.CanSupport; } + return result; + } - #endregion + #endregion - #region Private Methods + #region Private Methods - private string[] GetAllColumnNames() => ["Timestamp", "Level", "Logger", "Thread", "Class", "Method", "File", "Line", "Message"]; + private string[] GetAllColumnNames() => ["Timestamp", "Level", "Logger", "Thread", "Class", "Method", "File", "Line", "Message"]; - /// - /// Returns only the columns which are "active". The order of the columns depends on the column order in the config - /// - /// - /// - private Column[] MapColumns(Column[] cols) + /// + /// Returns only the columns which are "active". The order of the columns depends on the column order in the config + /// + /// + /// + private Column[] MapColumns(Column[] cols) + { + List output = []; + var index = 0; + foreach (Log4jColumnEntry entry in _config.columnList) { - List output = []; - var index = 0; - foreach (Log4jColumnEntry entry in _config.columnList) + if (entry.Visible) { - if (entry.Visible) - { - Column column = cols[index]; - output.Add(column); + Column column = cols[index]; + output.Add(column); - if (entry.MaxLen > 0 && column.FullValue.Length > entry.MaxLen) - { - column.FullValue = column.FullValue.Substring(column.FullValue.Length - entry.MaxLen); - } + if (entry.MaxLen > 0 && column.FullValue.Length > entry.MaxLen) + { + column.FullValue = column.FullValue.Substring(column.FullValue.Length - entry.MaxLen); } - index++; } - - - return [.. output]; + index++; } - #endregion + + return [.. output]; } + + #endregion } \ No newline at end of file diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfig.cs b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfig.cs index 92a2c3c5..186a7cfd 100644 --- a/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfig.cs +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfig.cs @@ -1,82 +1,81 @@ using System; using System.Collections.Generic; -namespace Log4jXmlColumnizer +namespace Log4jXmlColumnizer; + +[Serializable] +public class Log4jXmlColumnizerConfig { - [Serializable] - public class Log4jXmlColumnizerConfig - { - #region Fields + #region Fields - public List columnList = []; - public bool localTimestamps = true; + public List columnList = []; + public bool localTimestamps = true; - #endregion + #endregion - #region cTor + #region cTor - public Log4jXmlColumnizerConfig(string[] columnNames) - { - FillDefaults(columnNames); - } + public Log4jXmlColumnizerConfig(string[] columnNames) + { + FillDefaults(columnNames); + } - #endregion + #endregion - #region Properties + #region Properties - /// - /// Returns the column count. Because the user can deactivate columns in the config - /// the actual column count may be smaller than the number of available columns. - /// - public int ActiveColumnCount + /// + /// Returns the column count. Because the user can deactivate columns in the config + /// the actual column count may be smaller than the number of available columns. + /// + public int ActiveColumnCount + { + get { - get + var count = 0; + foreach (Log4jColumnEntry entry in columnList) { - var count = 0; - foreach (Log4jColumnEntry entry in columnList) + if (entry.Visible) { - if (entry.Visible) - { - count++; - } + count++; } - return count; } + return count; } + } - /// - /// Returns the names of all active columns. - /// - public string[] ActiveColumnNames + /// + /// Returns the names of all active columns. + /// + public string[] ActiveColumnNames + { + get { - get + var names = new string[ActiveColumnCount]; + var index = 0; + foreach (Log4jColumnEntry entry in columnList) { - var names = new string[ActiveColumnCount]; - var index = 0; - foreach (Log4jColumnEntry entry in columnList) + if (entry.Visible) { - if (entry.Visible) - { - names[index++] = entry.ColumnName; - } + names[index++] = entry.ColumnName; } - return names; } + return names; } + } - #endregion + #endregion - #region Public methods + #region Public methods - public void FillDefaults(string[] columnNames) + public void FillDefaults(string[] columnNames) + { + columnList.Clear(); + for (var i = 0; i < columnNames.Length; ++i) { - columnList.Clear(); - for (var i = 0; i < columnNames.Length; ++i) - { - columnList.Add(new Log4jColumnEntry(columnNames[i], i, 0)); - } + columnList.Add(new Log4jColumnEntry(columnNames[i], i, 0)); } - - #endregion } + + #endregion } \ No newline at end of file diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs index 74eedaab..a07ff9b3 100644 --- a/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs @@ -4,81 +4,80 @@ using System.Drawing; using System.Windows.Forms; -namespace LogExpert +namespace LogExpert; + +public partial class Log4jXmlColumnizerConfigDlg : Form { - public partial class Log4jXmlColumnizerConfigDlg : Form + #region Fields + + private readonly Log4jXmlColumnizerConfig _config; + + #endregion + + #region cTor + + public Log4jXmlColumnizerConfigDlg(Log4jXmlColumnizerConfig config) { - #region Fields + SuspendLayout(); + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + + _config = config; + InitializeComponent(); + FillListBox(); + localTimeCheckBox.Checked = _config.localTimestamps; + ResumeLayout(); + } - private readonly Log4jXmlColumnizerConfig _config; + #endregion - #endregion + #region Private Methods - #region cTor + private void FillListBox() + { + var checkColumn = (DataGridViewCheckBoxColumn)columnGridView.Columns[0]; + var nameColumn = (DataGridViewTextBoxColumn)columnGridView.Columns[1]; + var lenColumn = (DataGridViewTextBoxColumn)columnGridView.Columns[2]; - public Log4jXmlColumnizerConfigDlg(Log4jXmlColumnizerConfig config) + foreach (Log4jColumnEntry entry in _config.columnList) { - SuspendLayout(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - _config = config; - InitializeComponent(); - FillListBox(); - localTimeCheckBox.Checked = _config.localTimestamps; - ResumeLayout(); + DataGridViewRow row = new(); + row.Cells.Add(new DataGridViewCheckBoxCell()); + row.Cells.Add(new DataGridViewTextBoxCell()); + row.Cells.Add(new DataGridViewTextBoxCell()); + row.Cells[0].Value = entry.Visible; + row.Cells[1].Value = entry.ColumnName; + row.Cells[2].Value = entry.MaxLen > 0 ? "" + entry.MaxLen : ""; + columnGridView.Rows.Add(row); } + } - #endregion + #endregion - #region Private Methods + #region Events handler - private void FillListBox() + private void OkButton_Click(object sender, EventArgs e) + { + // for (int i = 0; i < this.config.columnList.Count; ++i) + // { + // this.config.columnList[i]. visible = this.columnListBox.GetItemChecked(i); + // } + for (var i = 0; i < columnGridView.Rows.Count; ++i) { - var checkColumn = (DataGridViewCheckBoxColumn)columnGridView.Columns[0]; - var nameColumn = (DataGridViewTextBoxColumn)columnGridView.Columns[1]; - var lenColumn = (DataGridViewTextBoxColumn)columnGridView.Columns[2]; + _config.columnList[i].Visible = (bool)columnGridView.Rows[i].Cells[0].Value; + var sLen = (string)columnGridView.Rows[i].Cells[2].Value; - foreach (Log4jColumnEntry entry in _config.columnList) + if (int.TryParse(sLen, out var len)) { - DataGridViewRow row = new(); - row.Cells.Add(new DataGridViewCheckBoxCell()); - row.Cells.Add(new DataGridViewTextBoxCell()); - row.Cells.Add(new DataGridViewTextBoxCell()); - row.Cells[0].Value = entry.Visible; - row.Cells[1].Value = entry.ColumnName; - row.Cells[2].Value = entry.MaxLen > 0 ? "" + entry.MaxLen : ""; - columnGridView.Rows.Add(row); + _config.columnList[i].MaxLen = len; } - } - - #endregion - - #region Events handler - - private void OkButton_Click(object sender, EventArgs e) - { - // for (int i = 0; i < this.config.columnList.Count; ++i) - // { - // this.config.columnList[i]. visible = this.columnListBox.GetItemChecked(i); - // } - for (var i = 0; i < columnGridView.Rows.Count; ++i) + else { - _config.columnList[i].Visible = (bool)columnGridView.Rows[i].Cells[0].Value; - var sLen = (string)columnGridView.Rows[i].Cells[2].Value; - - if (int.TryParse(sLen, out var len)) - { - _config.columnList[i].MaxLen = len; - } - else - { - _config.columnList[i].MaxLen = 0; - } + _config.columnList[i].MaxLen = 0; } - _config.localTimestamps = localTimeCheckBox.Checked; } - - #endregion + _config.localTimestamps = localTimeCheckBox.Checked; } + + #endregion } \ No newline at end of file diff --git a/src/Log4jXmlColumnizer/XmlConfig.cs b/src/Log4jXmlColumnizer/XmlConfig.cs index 6e4888a8..24620b82 100644 --- a/src/Log4jXmlColumnizer/XmlConfig.cs +++ b/src/Log4jXmlColumnizer/XmlConfig.cs @@ -1,33 +1,32 @@ using LogExpert; -namespace Log4jXmlColumnizer +namespace Log4jXmlColumnizer; + +/// +/// XMl configuration for parsing log4j XML files. The XSL will transform every block of log entries +/// into text lines. The fields in the text lines are separated by a special character (0xFFFD). +/// The special character will be used in the Split() function of the columnizer to split the line +/// into columns. +/// +internal class XmlConfig : IXmlLogConfiguration { - /// - /// XMl configuration for parsing log4j XML files. The XSL will transform every block of log entries - /// into text lines. The fields in the text lines are separated by a special character (0xFFFD). - /// The special character will be used in the Split() function of the columnizer to split the line - /// into columns. - /// - internal class XmlConfig : IXmlLogConfiguration - { - #region Properties + #region Properties - public string XmlStartTag { get; } = "" + - "" + - "" + - "" + - "" + - ""; + public string Stylesheet { get; } = "" + + "" + + "" + + "" + + "" + + "" + + ""; - public string[] Namespace => ["log4j", "http://jakarta.apache.org/log4j"]; + public string[] Namespace => ["log4j", "http://jakarta.apache.org/log4j"]; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Columnizer/ClfColumnizer.cs b/src/LogExpert.Core/Classes/Columnizer/ClfColumnizer.cs index 6c20cb96..d5cf9614 100644 --- a/src/LogExpert.Core/Classes/Columnizer/ClfColumnizer.cs +++ b/src/LogExpert.Core/Classes/Columnizer/ClfColumnizer.cs @@ -3,181 +3,176 @@ using System.Linq; using System.Text.RegularExpressions; -namespace LogExpert.Core.Classes.Columnizer +namespace LogExpert.Core.Classes.Columnizer; + +public class ClfColumnizer : ILogLineColumnizer { - public class ClfColumnizer : ILogLineColumnizer - { - #region Fields + #region Fields - private readonly Regex lineRegex = new("(.*) (-) (.*) (\\[.*\\]) (\".*\") (.*) (.*) (\".*\") (\".*\")"); + private readonly Regex lineRegex = new("(.*) (-) (.*) (\\[.*\\]) (\".*\") (.*) (.*) (\".*\") (\".*\")"); - protected CultureInfo cultureInfo = new("de-DE"); - protected int timeOffset; + protected CultureInfo cultureInfo = new("de-DE"); + protected int timeOffset; - #endregion + #endregion - #region cTor + #region cTor - // anon-212-34-174-126.suchen.de - - [08/Mar/2008:00:41:10 +0100] "GET /wiki/index.php?title=Bild:Poster_small.jpg&printable=yes&printable=yes HTTP/1.1" 304 0 "http://www.captain-kloppi.de/wiki/index.php?title=Bild:Poster_small.jpg&printable=yes" "gonzo1[P] +http://www.suchen.de/faq.html" + // anon-212-34-174-126.suchen.de - - [08/Mar/2008:00:41:10 +0100] "GET /wiki/index.php?title=Bild:Poster_small.jpg&printable=yes&printable=yes HTTP/1.1" 304 0 "http://www.captain-kloppi.de/wiki/index.php?title=Bild:Poster_small.jpg&printable=yes" "gonzo1[P] +http://www.suchen.de/faq.html" - public ClfColumnizer() - { - } + public ClfColumnizer() + { + } + + #endregion + + #region Public methods - #endregion + public bool IsTimeshiftImplemented() + { + return true; + } - #region Public methods + public void SetTimeOffset(int msecOffset) + { + timeOffset = msecOffset; + } - public bool IsTimeshiftImplemented() + public int GetTimeOffset() + { + return timeOffset; + } + + public DateTime GetTimestamp(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + { + IColumnizedLogLine cols = SplitLine(callback, line); + if (cols == null || cols.ColumnValues.Length < 8) { - return true; + return DateTime.MinValue; } - public void SetTimeOffset(int msecOffset) + if (cols.ColumnValues[2].FullValue.Length == 0) { - timeOffset = msecOffset; + return DateTime.MinValue; } - public int GetTimeOffset() + try { - return timeOffset; + var dateTime = DateTime.ParseExact(cols.ColumnValues[2].FullValue, "dd/MMM/yyyy:HH:mm:ss zzz", + new CultureInfo("en-US")); + return dateTime; } - - public DateTime GetTimestamp(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + catch (Exception) { - IColumnizedLogLine cols = SplitLine(callback, line); - if (cols == null || cols.ColumnValues.Length < 8) - { - return DateTime.MinValue; - } - - if (cols.ColumnValues[2].FullValue.Length == 0) - { - return DateTime.MinValue; - } + return DateTime.MinValue; + } + } + public void PushValue(LogExpert.ILogLineColumnizerCallback callback, int column, string value, string oldValue) + { + if (column == 2) + { try { - var dateTime = DateTime.ParseExact(cols.ColumnValues[2].FullValue, "dd/MMM/yyyy:HH:mm:ss zzz", - new CultureInfo("en-US")); - return dateTime; + var newDateTime = + DateTime.ParseExact(value, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US")); + var oldDateTime = + DateTime.ParseExact(oldValue, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US")); + var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; + var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; + timeOffset = (int)(mSecsNew - mSecsOld); } - catch (Exception) + catch (FormatException) { - return DateTime.MinValue; } } + } - public void PushValue(LogExpert.ILogLineColumnizerCallback callback, int column, string value, string oldValue) - { - if (column == 2) - { - try - { - var newDateTime = - DateTime.ParseExact(value, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US")); - var oldDateTime = - DateTime.ParseExact(oldValue, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US")); - var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; - var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; - timeOffset = (int)(mSecsNew - mSecsOld); - } - catch (FormatException) - { - } - } - } + public string GetName() + { + return "Webserver CLF Columnizer"; + } - public string GetName() - { - return "Webserver CLF Columnizer"; - } + public string GetDescription() + { + return "Common Logfile Format used by webservers."; + } - public string GetDescription() - { - return "Common Logfile Format used by webservers."; - } + public int GetColumnCount() + { + return 8; + } + + public string[] GetColumnNames() + { + return ["IP", "User", "Date/Time", "Request", "Status", "Bytes", "Referrer", "User agent"]; + } - public int GetColumnCount() + public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + { + ColumnizedLogLine cLogLine = new() { - return 8; - } + LogLine = line + }; - public string[] GetColumnNames() + var columns = new Column[8] + { + new() {FullValue = "", Parent = cLogLine}, + new() {FullValue = "", Parent = cLogLine}, + new() {FullValue = "", Parent = cLogLine}, + new() {FullValue = "", Parent = cLogLine}, + new() {FullValue = "", Parent = cLogLine}, + new() {FullValue = "", Parent = cLogLine}, + new() {FullValue = "", Parent = cLogLine}, + new() {FullValue = "", Parent = cLogLine} + }; + + cLogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); + + var temp = line.FullLine; + if (temp.Length > 1024) { - return new string[] { "IP", "User", "Date/Time", "Request", "Status", "Bytes", "Referrer", "User agent" }; + // spam + temp = temp.Substring(0, 1024); + columns[3].FullValue = temp; + return cLogLine; } + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 + // anon-212-34-174-126.suchen.de - - [08/Mar/2008:00:41:10 +0100] "GET /wiki/index.php?title=Bild:Poster_small.jpg&printable=yes&printable=yes HTTP/1.1" 304 0 "http://www.captain-kloppi.de/wiki/index.php?title=Bild:Poster_small.jpg&printable=yes" "gonzo1[P] +http://www.suchen.de/faq.html" - public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + if (lineRegex.IsMatch(temp)) { - ColumnizedLogLine cLogLine = new() - { - LogLine = line - }; - - var columns = new Column[8] - { - new() {FullValue = "", Parent = cLogLine}, - new() {FullValue = "", Parent = cLogLine}, - new() {FullValue = "", Parent = cLogLine}, - new() {FullValue = "", Parent = cLogLine}, - new() {FullValue = "", Parent = cLogLine}, - new() {FullValue = "", Parent = cLogLine}, - new() {FullValue = "", Parent = cLogLine}, - new() {FullValue = "", Parent = cLogLine} - }; - - cLogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); - - var temp = line.FullLine; - if (temp.Length > 1024) + Match match = lineRegex.Match(temp); + GroupCollection groups = match.Groups; + if (groups.Count == 10) { - // spam - temp = temp.Substring(0, 1024); - columns[3].FullValue = temp; - return cLogLine; - } - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 - // anon-212-34-174-126.suchen.de - - [08/Mar/2008:00:41:10 +0100] "GET /wiki/index.php?title=Bild:Poster_small.jpg&printable=yes&printable=yes HTTP/1.1" 304 0 "http://www.captain-kloppi.de/wiki/index.php?title=Bild:Poster_small.jpg&printable=yes" "gonzo1[P] +http://www.suchen.de/faq.html" - - if (lineRegex.IsMatch(temp)) - { - Match match = lineRegex.Match(temp); - GroupCollection groups = match.Groups; - if (groups.Count == 10) + columns[0].FullValue = groups[1].Value; + columns[1].FullValue = groups[3].Value; + columns[3].FullValue = groups[5].Value; + columns[4].FullValue = groups[6].Value; + columns[5].FullValue = groups[7].Value; + columns[6].FullValue = groups[8].Value; + columns[7].FullValue = groups[9].Value; + + var dateTimeStr = groups[4].Value.Substring(1, 26); + + // dirty probing of date/time format (much faster than DateTime.ParseExact() + if (dateTimeStr[2] == '/' && dateTimeStr[6] == '/' && dateTimeStr[11] == ':') { - columns[0].FullValue = groups[1].Value; - columns[1].FullValue = groups[3].Value; - columns[3].FullValue = groups[5].Value; - columns[4].FullValue = groups[6].Value; - columns[5].FullValue = groups[7].Value; - columns[6].FullValue = groups[8].Value; - columns[7].FullValue = groups[9].Value; - - var dateTimeStr = groups[4].Value.Substring(1, 26); - - // dirty probing of date/time format (much faster than DateTime.ParseExact() - if (dateTimeStr[2] == '/' && dateTimeStr[6] == '/' && dateTimeStr[11] == ':') + if (timeOffset != 0) { - if (timeOffset != 0) + try { - try - { - var dateTime = DateTime.ParseExact(dateTimeStr, "dd/MMM/yyyy:HH:mm:ss zzz", - new CultureInfo("en-US")); - dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); - var newDate = dateTime.ToString("dd/MMM/yyyy:HH:mm:ss zzz", - new CultureInfo("en-US")); - columns[2].FullValue = newDate; - } - catch (Exception) - { - columns[2].FullValue = "n/a"; - } + var dateTime = DateTime.ParseExact(dateTimeStr, "dd/MMM/yyyy:HH:mm:ss zzz", + new CultureInfo("en-US")); + dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); + var newDate = dateTime.ToString("dd/MMM/yyyy:HH:mm:ss zzz", + new CultureInfo("en-US")); + columns[2].FullValue = newDate; } - else + catch (Exception) { - columns[2].FullValue = dateTimeStr; + columns[2].FullValue = "n/a"; } } else @@ -185,15 +180,19 @@ public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callbac columns[2].FullValue = dateTimeStr; } } + else + { + columns[2].FullValue = dateTimeStr; + } } - else - { - columns[3].FullValue = temp; - } - - return cLogLine; + } + else + { + columns[3].FullValue = temp; } - #endregion + return cLogLine; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs b/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs index aada7351..33cf2ac8 100644 --- a/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs +++ b/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs @@ -2,142 +2,141 @@ using System.Reflection; -namespace LogExpert.Core.Classes.Columnizer +namespace LogExpert.Core.Classes.Columnizer; + +public class ColumnizerPicker { - public class ColumnizerPicker + public static ILogLineColumnizer FindColumnizerByName(string name, IList list) { - public static ILogLineColumnizer FindColumnizerByName(string name, IList list) + foreach (ILogLineColumnizer columnizer in list) { - foreach (ILogLineColumnizer columnizer in list) + if (columnizer.GetName().Equals(name)) { - if (columnizer.GetName().Equals(name)) - { - return columnizer; - } + return columnizer; } - return null; } + return null; + } - public static ILogLineColumnizer DecideColumnizerByName(string name, IList list) + public static ILogLineColumnizer DecideColumnizerByName(string name, IList list) + { + foreach (ILogLineColumnizer columnizer in list) { - foreach (ILogLineColumnizer columnizer in list) + if (columnizer.GetName().Equals(name)) { - if (columnizer.GetName().Equals(name)) - { - return columnizer; - } + return columnizer; } - - return FindColumnizer(null, null, list); } - public static ILogLineColumnizer CloneColumnizer(ILogLineColumnizer columnizer, string directory) - { - if (columnizer == null) - { - return null; - } - ConstructorInfo cti = columnizer.GetType().GetConstructor(Type.EmptyTypes); - - if (cti != null) - { - var o = cti.Invoke([]); + return FindColumnizer(null, null, list); + } - if (o is IColumnizerConfigurator configurator) - { - configurator.LoadConfig(directory); - } - return (ILogLineColumnizer)o; - } + public static ILogLineColumnizer CloneColumnizer(ILogLineColumnizer columnizer, string directory) + { + if (columnizer == null) + { return null; } + ConstructorInfo cti = columnizer.GetType().GetConstructor(Type.EmptyTypes); - /// - /// This method implemented the "auto columnizer" feature. - /// This method should be called after each columnizer is changed to update the columizer. - /// - /// - /// - /// - /// - public static ILogLineColumnizer FindReplacementForAutoColumnizer(string fileName, - IAutoLogLineColumnizerCallback logFileReader, - ILogLineColumnizer logLineColumnizer, - IList list) + if (cti != null) { - if (logLineColumnizer == null || logLineColumnizer.GetName() == "Auto Columnizer") + var o = cti.Invoke([]); + + if (o is IColumnizerConfigurator configurator) { - return FindColumnizer(fileName, logFileReader, list); + configurator.LoadConfig(directory); } - return logLineColumnizer; + return (ILogLineColumnizer)o; } + return null; + } - public static ILogLineColumnizer FindBetterColumnizer(string fileName, - IAutoLogLineColumnizerCallback logFileReader, - ILogLineColumnizer logLineColumnizer, - IList list) + /// + /// This method implemented the "auto columnizer" feature. + /// This method should be called after each columnizer is changed to update the columizer. + /// + /// + /// + /// + /// + public static ILogLineColumnizer FindReplacementForAutoColumnizer(string fileName, + IAutoLogLineColumnizerCallback logFileReader, + ILogLineColumnizer logLineColumnizer, + IList list) + { + if (logLineColumnizer == null || logLineColumnizer.GetName() == "Auto Columnizer") { - var newColumnizer = FindColumnizer(fileName, logFileReader, list); + return FindColumnizer(fileName, logFileReader, list); + } + return logLineColumnizer; + } - if (newColumnizer.GetType().Equals(logLineColumnizer.GetType())) - { - return null; - } - return newColumnizer; + public static ILogLineColumnizer FindBetterColumnizer(string fileName, + IAutoLogLineColumnizerCallback logFileReader, + ILogLineColumnizer logLineColumnizer, + IList list) + { + var newColumnizer = FindColumnizer(fileName, logFileReader, list); + + if (newColumnizer.GetType().Equals(logLineColumnizer.GetType())) + { + return null; } + return newColumnizer; + } - /// - /// This method will search all registered columnizer and return one according to the priority that returned - /// by the each columnizer. - /// - /// - /// - /// - public static ILogLineColumnizer FindColumnizer(string fileName, IAutoLogLineColumnizerCallback logFileReader, IList list) + /// + /// This method will search all registered columnizer and return one according to the priority that returned + /// by the each columnizer. + /// + /// + /// + /// + public static ILogLineColumnizer FindColumnizer(string fileName, IAutoLogLineColumnizerCallback logFileReader, IList list) + { + if (string.IsNullOrEmpty(fileName)) { - if (string.IsNullOrEmpty(fileName)) - { - return new DefaultLogfileColumnizer(); - } + return new DefaultLogfileColumnizer(); + } - List loglines = []; + List loglines = []; - if (logFileReader != null) - { - loglines = - [ - // Sampling a few lines to select the correct columnizer - logFileReader.GetLogLine(0), - logFileReader.GetLogLine(1), - logFileReader.GetLogLine(2), - logFileReader.GetLogLine(3), - logFileReader.GetLogLine(4), - logFileReader.GetLogLine(5), - logFileReader.GetLogLine(25), - logFileReader.GetLogLine(100), - logFileReader.GetLogLine(200), - logFileReader.GetLogLine(400) - ]; - } + if (logFileReader != null) + { + loglines = + [ + // Sampling a few lines to select the correct columnizer + logFileReader.GetLogLine(0), + logFileReader.GetLogLine(1), + logFileReader.GetLogLine(2), + logFileReader.GetLogLine(3), + logFileReader.GetLogLine(4), + logFileReader.GetLogLine(5), + logFileReader.GetLogLine(25), + logFileReader.GetLogLine(100), + logFileReader.GetLogLine(200), + logFileReader.GetLogLine(400) + ]; + } - var registeredColumnizer = list; + var registeredColumnizer = list; - List> priorityListOfColumnizers = []; + List> priorityListOfColumnizers = []; - foreach (ILogLineColumnizer logLineColumnizer in registeredColumnizer) + foreach (ILogLineColumnizer logLineColumnizer in registeredColumnizer) + { + Priority priority = default; + if (logLineColumnizer is IColumnizerPriority columnizerPriority) { - Priority priority = default; - if (logLineColumnizer is IColumnizerPriority columnizerPriority) - { - priority = columnizerPriority.GetPriority(fileName, loglines); - } - - priorityListOfColumnizers.Add(new Tuple(priority, logLineColumnizer)); + priority = columnizerPriority.GetPriority(fileName, loglines); } - ILogLineColumnizer lineColumnizer = priorityListOfColumnizers.OrderByDescending(a => a.Item1).Select(a => a.Item2).First(); - - return lineColumnizer; + priorityListOfColumnizers.Add(new Tuple(priority, logLineColumnizer)); } + + ILogLineColumnizer lineColumnizer = priorityListOfColumnizers.OrderByDescending(a => a.Item1).Select(a => a.Item2).First(); + + return lineColumnizer; } } diff --git a/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs b/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs index d1331b3c..769cf4c4 100644 --- a/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs +++ b/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs @@ -2,318 +2,317 @@ using static LogExpert.Core.Classes.Columnizer.TimeFormatDeterminer; -namespace LogExpert.Core.Classes.Columnizer +namespace LogExpert.Core.Classes.Columnizer; + +public class SquareBracketColumnizer : ILogLineColumnizer, IColumnizerPriority { - public class SquareBracketColumnizer : ILogLineColumnizer, IColumnizerPriority - { - #region ILogLineColumnizer implementation + #region ILogLineColumnizer implementation + + protected int timeOffset; + private TimeFormatDeterminer _timeFormatDeterminer = new(); - protected int timeOffset; - private TimeFormatDeterminer _timeFormatDeterminer = new(); + // TODO: need preparing this columnizer with sample log lines before use it. + private int _columnCount = 5; + private bool _isTimeExists; - // TODO: need preparing this columnizer with sample log lines before use it. - private int _columnCount = 5; - private bool _isTimeExists; + public SquareBracketColumnizer () + { + } - public SquareBracketColumnizer () + public SquareBracketColumnizer (int columnCount, bool isTimeExists) : this() + { + // Add message column + _columnCount = columnCount + 1; + _isTimeExists = isTimeExists; + if (_isTimeExists) { + // Time and date + _columnCount += 2; } + } + + public bool IsTimeshiftImplemented () + { + return true; + } - public SquareBracketColumnizer (int columnCount, bool isTimeExists) : this() + public void SetTimeOffset (int msecOffset) + { + timeOffset = msecOffset; + } + + public int GetTimeOffset () + { + return timeOffset; + } + + public DateTime GetTimestamp (LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + { + IColumnizedLogLine cols = SplitLine(callback, line); + if (cols == null || cols.ColumnValues == null || cols.ColumnValues.Length < 2) { - // Add message column - _columnCount = columnCount + 1; - _isTimeExists = isTimeExists; - if (_isTimeExists) - { - // Time and date - _columnCount += 2; - } + return DateTime.MinValue; } - public bool IsTimeshiftImplemented () + if (cols.ColumnValues[0].FullValue.Length == 0 || cols.ColumnValues[1].FullValue.Length == 0) { - return true; + return DateTime.MinValue; } - public void SetTimeOffset (int msecOffset) + FormatInfo formatInfo = _timeFormatDeterminer.DetermineDateTimeFormatInfo(line.FullLine); + if (formatInfo == null) { - timeOffset = msecOffset; + return DateTime.MinValue; } - public int GetTimeOffset () + try { - return timeOffset; + var dateTime = DateTime.ParseExact( + cols.ColumnValues[0].FullValue + " " + cols.ColumnValues[1].FullValue, formatInfo.DateTimeFormat, + formatInfo.CultureInfo); + return dateTime; } - - public DateTime GetTimestamp (LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + catch (Exception) { - IColumnizedLogLine cols = SplitLine(callback, line); - if (cols == null || cols.ColumnValues == null || cols.ColumnValues.Length < 2) - { - return DateTime.MinValue; - } - - if (cols.ColumnValues[0].FullValue.Length == 0 || cols.ColumnValues[1].FullValue.Length == 0) - { - return DateTime.MinValue; - } - - FormatInfo formatInfo = _timeFormatDeterminer.DetermineDateTimeFormatInfo(line.FullLine); - if (formatInfo == null) - { - return DateTime.MinValue; - } - - try - { - var dateTime = DateTime.ParseExact( - cols.ColumnValues[0].FullValue + " " + cols.ColumnValues[1].FullValue, formatInfo.DateTimeFormat, - formatInfo.CultureInfo); - return dateTime; - } - catch (Exception) - { - return DateTime.MinValue; - } + return DateTime.MinValue; } + } - public void PushValue (LogExpert.ILogLineColumnizerCallback callback, int column, string value, string oldValue) + public void PushValue (LogExpert.ILogLineColumnizerCallback callback, int column, string value, string oldValue) + { + if (column == 1) { - if (column == 1) + try { - try - { - FormatInfo formatInfo = _timeFormatDeterminer.DetermineTimeFormatInfo(oldValue); - if (formatInfo == null) - { - return; - } - - var newDateTime = DateTime.ParseExact(value, formatInfo.TimeFormat, formatInfo.CultureInfo); - var oldDateTime = DateTime.ParseExact(oldValue, formatInfo.TimeFormat, formatInfo.CultureInfo); - var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; - var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; - timeOffset = (int)(mSecsNew - mSecsOld); - } - catch (FormatException) + FormatInfo formatInfo = _timeFormatDeterminer.DetermineTimeFormatInfo(oldValue); + if (formatInfo == null) { + return; } + + var newDateTime = DateTime.ParseExact(value, formatInfo.TimeFormat, formatInfo.CultureInfo); + var oldDateTime = DateTime.ParseExact(oldValue, formatInfo.TimeFormat, formatInfo.CultureInfo); + var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; + var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; + timeOffset = (int)(mSecsNew - mSecsOld); + } + catch (FormatException) + { } } + } + + public string GetName () + { + return "Square Bracket Columnizer"; + } + + public string GetDescription () + { + return "Splits every line into n fields: Date, Time and the rest of the log message"; + } - public string GetName () + public int GetColumnCount () + { + return _columnCount; + } + + public string[] GetColumnNames () + { + var columnNames = new List(GetColumnCount()); + if (_isTimeExists) { - return "Square Bracket Columnizer"; + columnNames.Add("Date"); + columnNames.Add("Time"); } - public string GetDescription () + // TODO: Make this configurable. + if (GetColumnCount() > 3) { - return "Splits every line into n fields: Date, Time and the rest of the log message"; + columnNames.Add("Level"); } - public int GetColumnCount () + if (GetColumnCount() > 4) { - return _columnCount; + columnNames.Add("Source"); } - public string[] GetColumnNames () + // Last column is the message + columnNames.Add("Message"); + var i = 1; + while (columnNames.Count < GetColumnCount()) { - var columnNames = new List(GetColumnCount()); - if (_isTimeExists) - { - columnNames.Add("Date"); - columnNames.Add("Time"); - } - - // TODO: Make this configurable. - if (GetColumnCount() > 3) - { - columnNames.Add("Level"); - } - - if (GetColumnCount() > 4) - { - columnNames.Add("Source"); - } + columnNames.Insert(columnNames.Count - 1, "Source" + i++.ToString()); + } - // Last column is the message - columnNames.Add("Message"); - var i = 1; - while (columnNames.Count < GetColumnCount()) - { - columnNames.Insert(columnNames.Count - 1, "Source" + i++.ToString()); - } + return columnNames.ToArray(); + } - return columnNames.ToArray(); - } + public IColumnizedLogLine SplitLine (LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + { + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 + // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + // 03.01.2008 14:48:00.066 - public IColumnizedLogLine SplitLine (LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + ColumnizedLogLine clogLine = new() { - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 - // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 - // 03.01.2008 14:48:00.066 + LogLine = line + }; - ColumnizedLogLine clogLine = new() - { - LogLine = line - }; - - var columns = new Column[] - { - new() {FullValue = "", Parent = clogLine}, - new() {FullValue = "", Parent = clogLine}, - new() {FullValue = "", Parent = clogLine}, - }; + var columns = new Column[] + { + new() {FullValue = "", Parent = clogLine}, + new() {FullValue = "", Parent = clogLine}, + new() {FullValue = "", Parent = clogLine}, + }; - var temp = line.FullLine; + var temp = line.FullLine; - if (temp.Length < 3) - { - columns[2].FullValue = temp; - return clogLine; - } + if (temp.Length < 3) + { + columns[2].FullValue = temp; + return clogLine; + } - FormatInfo formatInfo = _timeFormatDeterminer.DetermineDateTimeFormatInfo(line.FullLine); - if (formatInfo == null) - { - columns[2].FullValue = temp; - SquareSplit(ref columns, temp, 0, 0, 0, clogLine); - } - else + FormatInfo formatInfo = _timeFormatDeterminer.DetermineDateTimeFormatInfo(line.FullLine); + if (formatInfo == null) + { + columns[2].FullValue = temp; + SquareSplit(ref columns, temp, 0, 0, 0, clogLine); + } + else + { + var endPos = formatInfo.DateTimeFormat.Length; + var timeLen = formatInfo.TimeFormat.Length; + var dateLen = formatInfo.DateFormat.Length; + try { - var endPos = formatInfo.DateTimeFormat.Length; - var timeLen = formatInfo.TimeFormat.Length; - var dateLen = formatInfo.DateFormat.Length; - try + if (timeOffset != 0) { - if (timeOffset != 0) - { - var dateTime = DateTime.ParseExact(temp.Substring(0, endPos), formatInfo.DateTimeFormat, - formatInfo.CultureInfo); - dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); - var newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); - - SquareSplit(ref columns, newDate, dateLen, timeLen, endPos, clogLine); - } - else - { - SquareSplit(ref columns, temp, dateLen, timeLen, endPos, clogLine); - } + var dateTime = DateTime.ParseExact(temp.Substring(0, endPos), formatInfo.DateTimeFormat, + formatInfo.CultureInfo); + dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); + var newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); + + SquareSplit(ref columns, newDate, dateLen, timeLen, endPos, clogLine); } - catch (Exception) + else { - columns[0].FullValue = "n/a"; - columns[1].FullValue = "n/a"; - columns[2].FullValue = temp; + SquareSplit(ref columns, temp, dateLen, timeLen, endPos, clogLine); } } - - clogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); - - return clogLine; - } - - void SquareSplit (ref Column[] columns, string line, int dateLen, int timeLen, int dateTimeEndPos, ColumnizedLogLine clogLine) - { - List columnList = []; - var restColumn = _columnCount; - if (_isTimeExists) + catch (Exception) { - columnList.Add(new Column { FullValue = line.Substring(0, dateLen), Parent = clogLine }); - columnList.Add(new Column { FullValue = line.Substring(dateLen + 1, timeLen), Parent = clogLine }); - restColumn -= 2; + columns[0].FullValue = "n/a"; + columns[1].FullValue = "n/a"; + columns[2].FullValue = temp; } + } - var nextPos = dateTimeEndPos; + clogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); - var rest = line; + return clogLine; + } - for (var i = 0; i < restColumn; i++) - { - rest = rest.Substring(nextPos); - //var fullValue = rest.Substring(0, rest.IndexOf(']')).TrimStart(new char[] {' '}).TrimEnd(new char[] { ' ' }); - var trimmed = rest.TrimStart(new char[] { ' ' }); - if (string.IsNullOrEmpty(trimmed) || trimmed[0] != '[' || rest.IndexOf(']') < 0 || i == restColumn - 1) - { - columnList.Add(new Column { FullValue = rest, Parent = clogLine }); - break; - } + void SquareSplit (ref Column[] columns, string line, int dateLen, int timeLen, int dateTimeEndPos, ColumnizedLogLine clogLine) + { + List columnList = []; + var restColumn = _columnCount; + if (_isTimeExists) + { + columnList.Add(new Column { FullValue = line.Substring(0, dateLen), Parent = clogLine }); + columnList.Add(new Column { FullValue = line.Substring(dateLen + 1, timeLen), Parent = clogLine }); + restColumn -= 2; + } - nextPos = rest.IndexOf(']') + 1; - var fullValue = rest.Substring(0, nextPos); - columnList.Add(new Column { FullValue = fullValue, Parent = clogLine }); - } + var nextPos = dateTimeEndPos; + + var rest = line; - while (columnList.Count < _columnCount) + for (var i = 0; i < restColumn; i++) + { + rest = rest.Substring(nextPos); + //var fullValue = rest.Substring(0, rest.IndexOf(']')).TrimStart(new char[] {' '}).TrimEnd(new char[] { ' ' }); + var trimmed = rest.TrimStart([' ']); + if (string.IsNullOrEmpty(trimmed) || trimmed[0] != '[' || rest.IndexOf(']') < 0 || i == restColumn - 1) { - columnList.Insert(columnList.Count - 1, new Column { FullValue = "", Parent = clogLine }); + columnList.Add(new Column { FullValue = rest, Parent = clogLine }); + break; } - columns = columnList.ToArray(); + nextPos = rest.IndexOf(']') + 1; + var fullValue = rest.Substring(0, nextPos); + columnList.Add(new Column { FullValue = fullValue, Parent = clogLine }); } - public Priority GetPriority (string fileName, IEnumerable samples) + while (columnList.Count < _columnCount) { - Priority result = Priority.NotSupport; - TimeFormatDeterminer timeDeterminer = new(); - var timeStampExistsCount = 0; - var bracketsExistsCount = 0; - var maxBracketNumbers = 1; - - foreach (var logline in samples) - { - var line = logline?.FullLine; - if (string.IsNullOrEmpty(line)) - { - continue; - } + columnList.Insert(columnList.Count - 1, new Column { FullValue = "", Parent = clogLine }); + } - var bracketNumbers = 1; - if (null != timeDeterminer.DetermineDateTimeFormatInfo(line)) - { - timeStampExistsCount++; - } - else - { - timeStampExistsCount--; - } + columns = columnList.ToArray(); + } - var noSpaceLine = line.Replace(" ", string.Empty); - if (noSpaceLine.IndexOf('[') >= 0 && noSpaceLine.IndexOf(']') >= 0 - && noSpaceLine.IndexOf('[') < noSpaceLine.IndexOf(']')) - { - bracketNumbers += Regex.Matches(noSpaceLine, @"\]\[").Count; - bracketsExistsCount++; - } - else - { - bracketsExistsCount--; - } + public Priority GetPriority (string fileName, IEnumerable samples) + { + Priority result = Priority.NotSupport; + TimeFormatDeterminer timeDeterminer = new(); + var timeStampExistsCount = 0; + var bracketsExistsCount = 0; + var maxBracketNumbers = 1; - maxBracketNumbers = Math.Max(bracketNumbers, maxBracketNumbers); + foreach (var logline in samples) + { + var line = logline?.FullLine; + if (string.IsNullOrEmpty(line)) + { + continue; } - // Add message - _columnCount = maxBracketNumbers + 1; - _isTimeExists = timeStampExistsCount > 0; - if (_isTimeExists) + var bracketNumbers = 1; + if (null != timeDeterminer.DetermineDateTimeFormatInfo(line)) { - _columnCount += 2; + timeStampExistsCount++; + } + else + { + timeStampExistsCount--; } - if (maxBracketNumbers > 1) + var noSpaceLine = line.Replace(" ", string.Empty); + if (noSpaceLine.IndexOf('[') >= 0 && noSpaceLine.IndexOf(']') >= 0 + && noSpaceLine.IndexOf('[') < noSpaceLine.IndexOf(']')) { - result = Priority.WellSupport; - if (bracketsExistsCount > 0) - { - result = Priority.PerfectlySupport; - } + bracketNumbers += Regex.Matches(noSpaceLine, @"\]\[").Count; + bracketsExistsCount++; + } + else + { + bracketsExistsCount--; } - return result; + maxBracketNumbers = Math.Max(bracketNumbers, maxBracketNumbers); } - #endregion + // Add message + _columnCount = maxBracketNumbers + 1; + _isTimeExists = timeStampExistsCount > 0; + if (_isTimeExists) + { + _columnCount += 2; + } + + if (maxBracketNumbers > 1) + { + result = Priority.WellSupport; + if (bracketsExistsCount > 0) + { + result = Priority.PerfectlySupport; + } + } + + return result; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs b/src/LogExpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs index 46ea6327..cf438dc1 100644 --- a/src/LogExpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs +++ b/src/LogExpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs @@ -1,239 +1,238 @@ using System.Globalization; -namespace LogExpert.Core.Classes.Columnizer +namespace LogExpert.Core.Classes.Columnizer; + +internal class TimeFormatDeterminer { - internal class TimeFormatDeterminer + #region FormatInfo helper class + + public class FormatInfo { - #region FormatInfo helper class + #region cTor - public class FormatInfo + public FormatInfo(string dateFormat, string timeFormat, CultureInfo cultureInfo) { - #region cTor + DateFormat = dateFormat; + TimeFormat = timeFormat; + CultureInfo = cultureInfo; + } - public FormatInfo(string dateFormat, string timeFormat, CultureInfo cultureInfo) - { - DateFormat = dateFormat; - TimeFormat = timeFormat; - CultureInfo = cultureInfo; - } + #endregion - #endregion + #region Properties - #region Properties + public string DateFormat { get; } - public string DateFormat { get; } + public string TimeFormat { get; } - public string TimeFormat { get; } + public CultureInfo CultureInfo { get; } - public CultureInfo CultureInfo { get; } + public string DateTimeFormat => DateFormat + " " + TimeFormat; - public string DateTimeFormat => DateFormat + " " + TimeFormat; + public bool IgnoreFirstChar { get; set; } - public bool IgnoreFirstChar { get; set; } + #endregion + } - #endregion + #endregion + + protected FormatInfo formatInfo1 = new("dd.MM.yyyy", "HH:mm:ss.fff", new CultureInfo("de-DE")); + protected FormatInfo formatInfo2 = new("dd.MM.yyyy", "HH:mm:ss", new CultureInfo("de-DE")); + protected FormatInfo formatInfo3 = new("yyyy/MM/dd", "HH:mm:ss.fff", new CultureInfo("en-US")); + protected FormatInfo formatInfo4 = new("yyyy/MM/dd", "HH:mm:ss", new CultureInfo("en-US")); + protected FormatInfo formatInfo5 = new("yyyy.MM.dd", "HH:mm:ss.fff", new CultureInfo("de-DE")); + protected FormatInfo formatInfo6 = new("yyyy.MM.dd", "HH:mm:ss", new CultureInfo("de-DE")); + protected FormatInfo formatInfo7 = new("dd.MM.yyyy", "HH:mm:ss,fff", new CultureInfo("de-DE")); + protected FormatInfo formatInfo8 = new("yyyy/MM/dd", "HH:mm:ss,fff", new CultureInfo("en-US")); + protected FormatInfo formatInfo9 = new("yyyy.MM.dd", "HH:mm:ss,fff", new CultureInfo("de-DE")); + protected FormatInfo formatInfo10 = new("yyyy-MM-dd", "HH:mm:ss.fff", new CultureInfo("en-US")); + protected FormatInfo formatInfo11 = new("yyyy-MM-dd", "HH:mm:ss,fff", new CultureInfo("en-US")); + protected FormatInfo formatInfo12 = new("yyyy-MM-dd", "HH:mm:ss", new CultureInfo("en-US")); + protected FormatInfo formatInfo13 = new("dd MMM yyyy", "HH:mm:ss,fff", new CultureInfo("de-DE")); + protected FormatInfo formatInfo14 = new("dd MMM yyyy", "HH:mm:ss.fff", new CultureInfo("de-DE")); + protected FormatInfo formatInfo15 = new("dd MMM yyyy", "HH:mm:ss", new CultureInfo("de-DE")); + protected FormatInfo formatInfo16 = new("dd.MM.yy", "HH:mm:ss.fff", new CultureInfo("de-DE")); + protected FormatInfo formatInfo17 = new("yyyy-MM-dd", "HH:mm:ss:ffff", new CultureInfo("en-US")); + protected FormatInfo formatInfo18 = new("dd/MM/yyyy", "HH:mm:ss.fff", new CultureInfo("en-US")); + protected FormatInfo formatInfo19 = new("dd/MM/yyyy", "HH:mm:ss:fff", new CultureInfo("en-US")); + protected FormatInfo formatInfo20 = new("yyyy-MM-dd", "HH:mm:ss.ffff", new CultureInfo("en-US")); + protected FormatInfo formatInfo21 = new("yyyy-MM-dd", "HH:mm:ss,ffff", new CultureInfo("en-US")); + + + public FormatInfo DetermineDateTimeFormatInfo(string line) + { + if (line.Length < 21) + { + return null; } - #endregion + var temp = line; + var ignoreFirst = false; - protected FormatInfo formatInfo1 = new("dd.MM.yyyy", "HH:mm:ss.fff", new CultureInfo("de-DE")); - protected FormatInfo formatInfo2 = new("dd.MM.yyyy", "HH:mm:ss", new CultureInfo("de-DE")); - protected FormatInfo formatInfo3 = new("yyyy/MM/dd", "HH:mm:ss.fff", new CultureInfo("en-US")); - protected FormatInfo formatInfo4 = new("yyyy/MM/dd", "HH:mm:ss", new CultureInfo("en-US")); - protected FormatInfo formatInfo5 = new("yyyy.MM.dd", "HH:mm:ss.fff", new CultureInfo("de-DE")); - protected FormatInfo formatInfo6 = new("yyyy.MM.dd", "HH:mm:ss", new CultureInfo("de-DE")); - protected FormatInfo formatInfo7 = new("dd.MM.yyyy", "HH:mm:ss,fff", new CultureInfo("de-DE")); - protected FormatInfo formatInfo8 = new("yyyy/MM/dd", "HH:mm:ss,fff", new CultureInfo("en-US")); - protected FormatInfo formatInfo9 = new("yyyy.MM.dd", "HH:mm:ss,fff", new CultureInfo("de-DE")); - protected FormatInfo formatInfo10 = new("yyyy-MM-dd", "HH:mm:ss.fff", new CultureInfo("en-US")); - protected FormatInfo formatInfo11 = new("yyyy-MM-dd", "HH:mm:ss,fff", new CultureInfo("en-US")); - protected FormatInfo formatInfo12 = new("yyyy-MM-dd", "HH:mm:ss", new CultureInfo("en-US")); - protected FormatInfo formatInfo13 = new("dd MMM yyyy", "HH:mm:ss,fff", new CultureInfo("de-DE")); - protected FormatInfo formatInfo14 = new("dd MMM yyyy", "HH:mm:ss.fff", new CultureInfo("de-DE")); - protected FormatInfo formatInfo15 = new("dd MMM yyyy", "HH:mm:ss", new CultureInfo("de-DE")); - protected FormatInfo formatInfo16 = new("dd.MM.yy", "HH:mm:ss.fff", new CultureInfo("de-DE")); - protected FormatInfo formatInfo17 = new("yyyy-MM-dd", "HH:mm:ss:ffff", new CultureInfo("en-US")); - protected FormatInfo formatInfo18 = new("dd/MM/yyyy", "HH:mm:ss.fff", new CultureInfo("en-US")); - protected FormatInfo formatInfo19 = new("dd/MM/yyyy", "HH:mm:ss:fff", new CultureInfo("en-US")); - protected FormatInfo formatInfo20 = new("yyyy-MM-dd", "HH:mm:ss.ffff", new CultureInfo("en-US")); - protected FormatInfo formatInfo21 = new("yyyy-MM-dd", "HH:mm:ss,ffff", new CultureInfo("en-US")); - - - public FormatInfo DetermineDateTimeFormatInfo(string line) + // determine if string starts with bracket and remove it + if (temp[0] == '[' || temp[0] == '(' || temp[0] == '{') { - if (line.Length < 21) - { - return null; - } + temp = temp.Substring(1); + ignoreFirst = true; - var temp = line; - var ignoreFirst = false; + } - // determine if string starts with bracket and remove it - if (temp[0] == '[' || temp[0] == '(' || temp[0] == '{') + // dirty hardcoded probing of date/time format (much faster than DateTime.ParseExact() + if (temp[2] == '.' && temp[5] == '.' && temp[13] == ':' && temp[16] == ':') + { + if (temp[19] == '.') { - temp = temp.Substring(1); - ignoreFirst = true; - + formatInfo1.IgnoreFirstChar = ignoreFirst; + return formatInfo1; } - - // dirty hardcoded probing of date/time format (much faster than DateTime.ParseExact() - if (temp[2] == '.' && temp[5] == '.' && temp[13] == ':' && temp[16] == ':') + else if (temp[19] == ',') { - if (temp[19] == '.') - { - formatInfo1.IgnoreFirstChar = ignoreFirst; - return formatInfo1; - } - else if (temp[19] == ',') - { - formatInfo7.IgnoreFirstChar = ignoreFirst; - return formatInfo7; - } - else - { - formatInfo2.IgnoreFirstChar = ignoreFirst; - return formatInfo2; - } + formatInfo7.IgnoreFirstChar = ignoreFirst; + return formatInfo7; } - else if (temp[2] == '/' && temp[5] == '/' && temp[13] == ':' && temp[16] == ':') + else { - if (temp[19] == '.') - { - formatInfo18.IgnoreFirstChar = ignoreFirst; - return formatInfo18; - } - else if (temp[19] == ':') - { - formatInfo19.IgnoreFirstChar = ignoreFirst; - return formatInfo19; - } + formatInfo2.IgnoreFirstChar = ignoreFirst; + return formatInfo2; } - else if (temp[4] == '/' && temp[7] == '/' && temp[13] == ':' && temp[16] == ':') + } + else if (temp[2] == '/' && temp[5] == '/' && temp[13] == ':' && temp[16] == ':') + { + if (temp[19] == '.') { - if (temp[19] == '.') - { - formatInfo3.IgnoreFirstChar = ignoreFirst; - return formatInfo3; - } - else if (temp[19] == ',') - { - formatInfo8.IgnoreFirstChar = ignoreFirst; - return formatInfo8; - } - else - { - formatInfo4.IgnoreFirstChar = ignoreFirst; - return formatInfo4; - } + formatInfo18.IgnoreFirstChar = ignoreFirst; + return formatInfo18; } - else if (temp[4] == '.' && temp[7] == '.' && temp[13] == ':' && temp[16] == ':') + else if (temp[19] == ':') { - if (temp[19] == '.') - { - formatInfo5.IgnoreFirstChar = ignoreFirst; - return formatInfo5; - } - else if (temp[19] == ',') - { - formatInfo9.IgnoreFirstChar = ignoreFirst; - return formatInfo9; - } - else - { - formatInfo6.IgnoreFirstChar = ignoreFirst; - return formatInfo6; - } + formatInfo19.IgnoreFirstChar = ignoreFirst; + return formatInfo19; } - else if (temp[4] == '-' && temp[7] == '-' && temp[13] == ':' && temp[16] == ':') + } + else if (temp[4] == '/' && temp[7] == '/' && temp[13] == ':' && temp[16] == ':') + { + if (temp[19] == '.') { - if (temp[19] == '.') - { - if (temp.Length > 23 && char.IsDigit(temp[23])) - { - formatInfo20.IgnoreFirstChar = ignoreFirst; - return formatInfo20; - } - else - { - formatInfo10.IgnoreFirstChar = ignoreFirst; - return formatInfo10; - } - } - else if (temp[19] == ',') - { - if (temp.Length > 23 && char.IsDigit(temp[23])) - { - formatInfo21.IgnoreFirstChar = ignoreFirst; - return formatInfo21; - } - else - { - formatInfo11.IgnoreFirstChar = ignoreFirst; - return formatInfo11; - } - } - else if (temp[19] == ':') + formatInfo3.IgnoreFirstChar = ignoreFirst; + return formatInfo3; + } + else if (temp[19] == ',') + { + formatInfo8.IgnoreFirstChar = ignoreFirst; + return formatInfo8; + } + else + { + formatInfo4.IgnoreFirstChar = ignoreFirst; + return formatInfo4; + } + } + else if (temp[4] == '.' && temp[7] == '.' && temp[13] == ':' && temp[16] == ':') + { + if (temp[19] == '.') + { + formatInfo5.IgnoreFirstChar = ignoreFirst; + return formatInfo5; + } + else if (temp[19] == ',') + { + formatInfo9.IgnoreFirstChar = ignoreFirst; + return formatInfo9; + } + else + { + formatInfo6.IgnoreFirstChar = ignoreFirst; + return formatInfo6; + } + } + else if (temp[4] == '-' && temp[7] == '-' && temp[13] == ':' && temp[16] == ':') + { + if (temp[19] == '.') + { + if (temp.Length > 23 && char.IsDigit(temp[23])) { - formatInfo17.IgnoreFirstChar = ignoreFirst; - return formatInfo17; + formatInfo20.IgnoreFirstChar = ignoreFirst; + return formatInfo20; } else { - formatInfo12.IgnoreFirstChar = ignoreFirst; - return formatInfo12; + formatInfo10.IgnoreFirstChar = ignoreFirst; + return formatInfo10; } } - else if (temp[2] == ' ' && temp[6] == ' ' && temp[14] == ':' && temp[17] == ':') + else if (temp[19] == ',') { - if (temp[20] == ',') - { - formatInfo13.IgnoreFirstChar = ignoreFirst; - return formatInfo13; - } - else if (temp[20] == '.') + if (temp.Length > 23 && char.IsDigit(temp[23])) { - formatInfo14.IgnoreFirstChar = ignoreFirst; - return formatInfo14; + formatInfo21.IgnoreFirstChar = ignoreFirst; + return formatInfo21; } else { - formatInfo15.IgnoreFirstChar = ignoreFirst; - return formatInfo15; + formatInfo11.IgnoreFirstChar = ignoreFirst; + return formatInfo11; } } - //dd.MM.yy HH:mm:ss.fff - else if (temp[2] == '.' && temp[5] == '.' && temp[11] == ':' && temp[14] == ':' && temp[17] == '.') + else if (temp[19] == ':') { - formatInfo16.IgnoreFirstChar = ignoreFirst; - return formatInfo16; + formatInfo17.IgnoreFirstChar = ignoreFirst; + return formatInfo17; + } + else + { + formatInfo12.IgnoreFirstChar = ignoreFirst; + return formatInfo12; + } + } + else if (temp[2] == ' ' && temp[6] == ' ' && temp[14] == ':' && temp[17] == ':') + { + if (temp[20] == ',') + { + formatInfo13.IgnoreFirstChar = ignoreFirst; + return formatInfo13; + } + else if (temp[20] == '.') + { + formatInfo14.IgnoreFirstChar = ignoreFirst; + return formatInfo14; + } + else + { + formatInfo15.IgnoreFirstChar = ignoreFirst; + return formatInfo15; } - - return null; } + //dd.MM.yy HH:mm:ss.fff + else if (temp[2] == '.' && temp[5] == '.' && temp[11] == ':' && temp[14] == ':' && temp[17] == '.') + { + formatInfo16.IgnoreFirstChar = ignoreFirst; + return formatInfo16; + } + + return null; + } - public FormatInfo DetermineTimeFormatInfo(string field) + public FormatInfo DetermineTimeFormatInfo(string field) + { + // dirty hardcoded probing of time format (much faster than DateTime.ParseExact() + if (field[2] == ':' && field[5] == ':') { - // dirty hardcoded probing of time format (much faster than DateTime.ParseExact() - if (field[2] == ':' && field[5] == ':') + if (field.Length > 8) { - if (field.Length > 8) + if (field[8] == '.') { - if (field[8] == '.') - { - return formatInfo1; - } - else if (field[8] == ',') - { - return formatInfo7; - } + return formatInfo1; } - else + else if (field[8] == ',') { - return formatInfo2; + return formatInfo7; } } - return null; + else + { + return formatInfo2; + } } + return null; } } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Columnizer/TimestampColumnizer.cs b/src/LogExpert.Core/Classes/Columnizer/TimestampColumnizer.cs index ea89f963..20239ceb 100644 --- a/src/LogExpert.Core/Classes/Columnizer/TimestampColumnizer.cs +++ b/src/LogExpert.Core/Classes/Columnizer/TimestampColumnizer.cs @@ -1,215 +1,214 @@ using static LogExpert.Core.Classes.Columnizer.TimeFormatDeterminer; -namespace LogExpert.Core.Classes.Columnizer +namespace LogExpert.Core.Classes.Columnizer; + +public class TimestampColumnizer : ILogLineColumnizer, IColumnizerPriority { - public class TimestampColumnizer : ILogLineColumnizer, IColumnizerPriority + #region ILogLineColumnizer implementation + + private int timeOffset; + private readonly TimeFormatDeterminer _timeFormatDeterminer = new(); + + public bool IsTimeshiftImplemented () { - #region ILogLineColumnizer implementation + return true; + } - protected int timeOffset; - private TimeFormatDeterminer _timeFormatDeterminer = new(); + public void SetTimeOffset (int msecOffset) + { + timeOffset = msecOffset; + } - public bool IsTimeshiftImplemented() + public int GetTimeOffset () + { + return timeOffset; + } + + + public DateTime GetTimestamp (ILogLineColumnizerCallback callback, ILogLine line) + { + IColumnizedLogLine cols = SplitLine(callback, line); + if (cols == null || cols.ColumnValues == null || cols.ColumnValues.Length < 2) { - return true; + return DateTime.MinValue; } - - public void SetTimeOffset(int msecOffset) + if (cols.ColumnValues[0].FullValue.Length == 0 || cols.ColumnValues[1].FullValue.Length == 0) { - timeOffset = msecOffset; + return DateTime.MinValue; } - - public int GetTimeOffset() + FormatInfo formatInfo = _timeFormatDeterminer.DetermineDateTimeFormatInfo(line.FullLine); + if (formatInfo == null) { - return timeOffset; + return DateTime.MinValue; } - - public DateTime GetTimestamp(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + try { - IColumnizedLogLine cols = SplitLine(callback, line); - if (cols == null || cols.ColumnValues == null || cols.ColumnValues.Length < 2) - { - return DateTime.MinValue; - } - if (cols.ColumnValues[0].FullValue.Length == 0 || cols.ColumnValues[1].FullValue.Length == 0) - { - return DateTime.MinValue; - } - FormatInfo formatInfo = _timeFormatDeterminer.DetermineDateTimeFormatInfo(line.FullLine); - if (formatInfo == null) - { - return DateTime.MinValue; - } - - try - { - var dateTime = DateTime.ParseExact( - cols.ColumnValues[0].FullValue + " " + cols.ColumnValues[1].FullValue, formatInfo.DateTimeFormat, - formatInfo.CultureInfo); - return dateTime; - } - catch (Exception) - { - return DateTime.MinValue; - } + var dateTime = DateTime.ParseExact( + cols.ColumnValues[0].FullValue + " " + cols.ColumnValues[1].FullValue, formatInfo.DateTimeFormat, + formatInfo.CultureInfo); + return dateTime; + } + catch (Exception) + { + return DateTime.MinValue; } + } - public void PushValue(LogExpert.ILogLineColumnizerCallback callback, int column, string value, string oldValue) + public void PushValue (ILogLineColumnizerCallback callback, int column, string value, string oldValue) + { + if (column == 1) { - if (column == 1) + try { - try - { - FormatInfo formatInfo = _timeFormatDeterminer.DetermineTimeFormatInfo(oldValue); - if (formatInfo == null) - { - return; - } - var newDateTime = DateTime.ParseExact(value, formatInfo.TimeFormat, formatInfo.CultureInfo); - var oldDateTime = DateTime.ParseExact(oldValue, formatInfo.TimeFormat, formatInfo.CultureInfo); - var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; - var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; - timeOffset = (int)(mSecsNew - mSecsOld); - } - catch (FormatException) + FormatInfo formatInfo = _timeFormatDeterminer.DetermineTimeFormatInfo(oldValue); + if (formatInfo == null) { + return; } + var newDateTime = DateTime.ParseExact(value, formatInfo.TimeFormat, formatInfo.CultureInfo); + var oldDateTime = DateTime.ParseExact(oldValue, formatInfo.TimeFormat, formatInfo.CultureInfo); + var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; + var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; + timeOffset = (int)(mSecsNew - mSecsOld); + } + catch (FormatException) + { } } + } - public string GetName() - { - return "Timestamp Columnizer"; - } + public string GetName () + { + return "Timestamp Columnizer"; + } - public string GetDescription() - { - return "Splits every line into 3 fields: Date, Time and the rest of the log message"; - } + public string GetDescription () + { + return "Splits every line into 3 fields: Date, Time and the rest of the log message"; + } - public int GetColumnCount() - { - return 3; - } + public int GetColumnCount () + { + return 3; + } - public string[] GetColumnNames() - { - return new string[] { "Date", "Time", "Message" }; - } + public string[] GetColumnNames () + { + return ["Date", "Time", "Message"]; + } - public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) - { - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 - // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 - // 03.01.2008 14:48:00.066 + public IColumnizedLogLine SplitLine (ILogLineColumnizerCallback callback, ILogLine line) + { + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 + // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + // 03.01.2008 14:48:00.066 - ColumnizedLogLine clogLine = new(); - clogLine.LogLine = line; + ColumnizedLogLine clogLine = new(); + clogLine.LogLine = line; - var columns = new Column[3] - { - new() {FullValue = "", Parent = clogLine}, - new() {FullValue = "", Parent = clogLine}, - new() {FullValue = "", Parent = clogLine}, - }; + var columns = new Column[3] + { + new() {FullValue = "", Parent = clogLine}, + new() {FullValue = "", Parent = clogLine}, + new() {FullValue = "", Parent = clogLine}, + }; - clogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); + clogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray(); - var temp = line.FullLine; + var temp = line.FullLine; - FormatInfo formatInfo = _timeFormatDeterminer.DetermineDateTimeFormatInfo(temp); - if (formatInfo == null) - { - columns[2].FullValue = temp; - return clogLine; - } - var endPos = formatInfo.DateTimeFormat.Length; - var timeLen = formatInfo.TimeFormat.Length; - var dateLen = formatInfo.DateFormat.Length; - try + FormatInfo formatInfo = _timeFormatDeterminer.DetermineDateTimeFormatInfo(temp); + if (formatInfo == null) + { + columns[2].FullValue = temp; + return clogLine; + } + var endPos = formatInfo.DateTimeFormat.Length; + var timeLen = formatInfo.TimeFormat.Length; + var dateLen = formatInfo.DateFormat.Length; + try + { + if (timeOffset != 0) { - if (timeOffset != 0) + if (formatInfo.IgnoreFirstChar) { - if (formatInfo.IgnoreFirstChar) - { - // First character is a bracket and should be ignored - var dateTime = DateTime.ParseExact(temp.Substring(1, endPos), formatInfo.DateTimeFormat, - formatInfo.CultureInfo); - dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); - var newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); - columns[0].FullValue = newDate.Substring(0, dateLen); // date - columns[1].FullValue = newDate.Substring(dateLen + 1, timeLen); // time - columns[2].FullValue = temp.Substring(endPos + 2); // rest of line - } - else - { - var dateTime = DateTime.ParseExact(temp.Substring(0, endPos), formatInfo.DateTimeFormat, - formatInfo.CultureInfo); - dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); - var newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); - columns[0].FullValue = newDate.Substring(0, dateLen); // date - columns[1].FullValue = newDate.Substring(dateLen + 1, timeLen); // time - columns[2].FullValue = temp.Substring(endPos); // rest of line - } + // First character is a bracket and should be ignored + var dateTime = DateTime.ParseExact(temp.Substring(1, endPos), formatInfo.DateTimeFormat, + formatInfo.CultureInfo); + dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); + var newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); + columns[0].FullValue = newDate.Substring(0, dateLen); // date + columns[1].FullValue = newDate.Substring(dateLen + 1, timeLen); // time + columns[2].FullValue = temp.Substring(endPos + 2); // rest of line } else { - if (formatInfo.IgnoreFirstChar) - { - // First character is a bracket and should be ignored - columns[0].FullValue = temp.Substring(1, dateLen); // date - columns[1].FullValue = temp.Substring(dateLen + 2, timeLen); // time - columns[2].FullValue = temp.Substring(endPos + 2); // rest of line - } - else - { - columns[0].FullValue = temp.Substring(0, dateLen); // date - columns[1].FullValue = temp.Substring(dateLen + 1, timeLen); // time - columns[2].FullValue = temp.Substring(endPos); // rest of line - } + var dateTime = DateTime.ParseExact(temp.Substring(0, endPos), formatInfo.DateTimeFormat, + formatInfo.CultureInfo); + dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); + var newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); + columns[0].FullValue = newDate.Substring(0, dateLen); // date + columns[1].FullValue = newDate.Substring(dateLen + 1, timeLen); // time + columns[2].FullValue = temp.Substring(endPos); // rest of line } } - catch (Exception) + else { - columns[0].FullValue = "n/a"; - columns[1].FullValue = "n/a"; - columns[2].FullValue = temp; - } - return clogLine; - } - - public Priority GetPriority(string fileName, IEnumerable samples) - { - Priority result = Priority.NotSupport; - - var timeStampCount = 0; - foreach (var line in samples) - { - if (line == null || string.IsNullOrEmpty(line.FullLine)) + if (formatInfo.IgnoreFirstChar) { - continue; - } - var timeDeterminer = new TimeFormatDeterminer(); - if (null != timeDeterminer.DetermineDateTimeFormatInfo(line.FullLine)) - { - timeStampCount++; + // First character is a bracket and should be ignored + columns[0].FullValue = temp.Substring(1, dateLen); // date + columns[1].FullValue = temp.Substring(dateLen + 2, timeLen); // time + columns[2].FullValue = temp.Substring(endPos + 2); // rest of line } else { - timeStampCount--; + columns[0].FullValue = temp.Substring(0, dateLen); // date + columns[1].FullValue = temp.Substring(dateLen + 1, timeLen); // time + columns[2].FullValue = temp.Substring(endPos); // rest of line } } + } + catch (Exception) + { + columns[0].FullValue = "n/a"; + columns[1].FullValue = "n/a"; + columns[2].FullValue = temp; + } + return clogLine; + } - if (timeStampCount > 0) + public Priority GetPriority (string fileName, IEnumerable samples) + { + Priority result = Priority.NotSupport; + + var timeStampCount = 0; + foreach (ILogLine line in samples) + { + if (line == null || string.IsNullOrEmpty(line.FullLine)) + { + continue; + } + var timeDeterminer = new TimeFormatDeterminer(); + if (null != timeDeterminer.DetermineDateTimeFormatInfo(line.FullLine)) { - result = Priority.WellSupport; + timeStampCount++; } + else + { + timeStampCount--; + } + } - return result; + if (timeStampCount > 0) + { + result = Priority.WellSupport; } - #endregion + return result; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs b/src/LogExpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs index d637d03d..b0277ee5 100644 --- a/src/LogExpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs +++ b/src/LogExpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs @@ -1,36 +1,35 @@ using System; using System.Collections.Generic; -namespace LogExpert.Core.Classes.DateTimeParser +namespace LogExpert.Core.Classes.DateTimeParser; + +// Ensures we have constant width (number of characters) date formats +public static class DateFormatPartAdjuster { - // Ensures we have constant width (number of characters) date formats - public static class DateFormatPartAdjuster + private static readonly IDictionary _dateTimePartReplacements = new Dictionary(StringComparer.OrdinalIgnoreCase) { - private static readonly IDictionary _dateTimePartReplacements = new Dictionary(StringComparer.OrdinalIgnoreCase) - { - ["y"] = "yyy", - ["yyy"] = "yyyy", - ["m"] = "mm", - ["d"] = "dd", - ["h"] = "hh", - ["s"] = "ss" - }; + ["y"] = "yyy", + ["yyy"] = "yyyy", + ["m"] = "mm", + ["d"] = "dd", + ["h"] = "hh", + ["s"] = "ss" + }; - public static string AdjustDateTimeFormatPart(string part) + public static string AdjustDateTimeFormatPart(string part) + { + if (!_dateTimePartReplacements.TryGetValue(part, out var adjustedPart)) { - if (!_dateTimePartReplacements.TryGetValue(part, out var adjustedPart)) - { - return part; - } + return part; + } - if (char.IsUpper(part[0])) - { - return adjustedPart.ToUpper(); - } - else - { - return adjustedPart.ToLower(); - } + if (char.IsUpper(part[0])) + { + return adjustedPart.ToUpper(); + } + else + { + return adjustedPart.ToLower(); } } } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/DateTimeParser/Parser.cs b/src/LogExpert.Core/Classes/DateTimeParser/Parser.cs index 5828d843..a6528267 100644 --- a/src/LogExpert.Core/Classes/DateTimeParser/Parser.cs +++ b/src/LogExpert.Core/Classes/DateTimeParser/Parser.cs @@ -1,171 +1,170 @@ -namespace LogExpert.Core.Classes.DateTimeParser +namespace LogExpert.Core.Classes.DateTimeParser; + +public static class Parser { - public static class Parser + public static List
    ParseSections(string formatString, out bool syntaxError) { - public static List
    ParseSections(string formatString, out bool syntaxError) + var tokenizer = new Tokenizer(formatString); + var sections = new List
    (); + syntaxError = false; + while (true) { - var tokenizer = new Tokenizer(formatString); - var sections = new List
    (); - syntaxError = false; - while (true) - { - var section = ParseSection(tokenizer, sections.Count, out var sectionSyntaxError); - - if (sectionSyntaxError) - { - syntaxError = true; - } + var section = ParseSection(tokenizer, sections.Count, out var sectionSyntaxError); - if (section == null) - { - break; - } + if (sectionSyntaxError) + { + syntaxError = true; + } - sections.Add(section); + if (section == null) + { + break; } - return sections; + sections.Add(section); } - private static Section ParseSection(Tokenizer reader, int index, out bool syntaxError) - { - var hasDateParts = false; - string token; - List tokens = []; - - while ((token = ReadToken(reader, out syntaxError)) != null) - { - if (token == ";") - { - break; - } + return sections; + } - if (Token.IsDatePart(token)) - { - hasDateParts |= true; - tokens.Add(token); - } - else - { - tokens.Add(token); - } - } + private static Section ParseSection(Tokenizer reader, int index, out bool syntaxError) + { + var hasDateParts = false; + string token; + List tokens = []; - if (syntaxError || tokens.Count == 0) + while ((token = ReadToken(reader, out syntaxError)) != null) + { + if (token == ";") { - return null; + break; } - List generalTextDateDuration; - if (hasDateParts) + if (Token.IsDatePart(token)) { - ParseMilliseconds(tokens, out generalTextDateDuration); + hasDateParts |= true; + tokens.Add(token); } else { - // Unable to parse format string - syntaxError = true; - return null; + tokens.Add(token); } + } - return new Section() - { - SectionIndex = index, - GeneralTextDateDurationParts = generalTextDateDuration - }; + if (syntaxError || tokens.Count == 0) + { + return null; + } + + List generalTextDateDuration; + if (hasDateParts) + { + ParseMilliseconds(tokens, out generalTextDateDuration); } + else + { + // Unable to parse format string + syntaxError = true; + return null; + } + + return new Section() + { + SectionIndex = index, + GeneralTextDateDurationParts = generalTextDateDuration + }; + } - private static void ParseMilliseconds(List tokens, out List result) + private static void ParseMilliseconds(List tokens, out List result) + { + // if tokens form .0 through .000.., combine to single subsecond token + result = []; + for (var i = 0; i < tokens.Count; i++) { - // if tokens form .0 through .000.., combine to single subsecond token - result = []; - for (var i = 0; i < tokens.Count; i++) + var token = tokens[i]; + if (token == ".") { - var token = tokens[i]; - if (token == ".") + var zeros = 0; + while (i + 1 < tokens.Count && tokens[i + 1] == "0") + { + i++; + zeros++; + } + + if (zeros > 0) { - var zeros = 0; - while (i + 1 < tokens.Count && tokens[i + 1] == "0") - { - i++; - zeros++; - } - - if (zeros > 0) - { - result.Add("." + new string('0', zeros)); - } - else - { - result.Add("."); - } + result.Add("." + new string('0', zeros)); } else { - result.Add(token); + result.Add("."); } } - } - - private static string ReadToken(Tokenizer reader, out bool syntaxError) - { - var offset = reader.Position; - if (ReadLiteral(reader)) + else { - syntaxError = false; - var length = reader.Position - offset; - return reader.Substring(offset, length); + result.Add(token); } + } + } - if ( - // Symbols - reader.ReadOneOf("#?,!&%+-$€£0123456789{}():;/.@ ") || - - // Date - reader.ReadString("tt", true) || //AM / PM - reader.ReadOneOrMore('y') || - reader.ReadOneOrMore('Y') || - reader.ReadOneOrMore('m') || - reader.ReadOneOrMore('M') || - reader.ReadOneOrMore('d') || - reader.ReadOneOrMore('D') || - reader.ReadOneOrMore('h') || - reader.ReadOneOrMore('H') || - reader.ReadOneOrMore('s') || - reader.ReadOneOrMore('S') || - //Latin Date String: (a.C.n. ante Christum natum) - reader.ReadString("gg")) - { - syntaxError = false; - var length = reader.Position - offset; - return reader.Substring(offset, length); - } + private static string ReadToken(Tokenizer reader, out bool syntaxError) + { + var offset = reader.Position; + if (ReadLiteral(reader)) + { + syntaxError = false; + var length = reader.Position - offset; + return reader.Substring(offset, length); + } + if ( // Symbols - - syntaxError = reader.Position < reader.Length; - return null; + reader.ReadOneOf("#?,!&%+-$€£0123456789{}():;/.@ ") || + + // Date + reader.ReadString("tt", true) || //AM / PM + reader.ReadOneOrMore('y') || + reader.ReadOneOrMore('Y') || + reader.ReadOneOrMore('m') || + reader.ReadOneOrMore('M') || + reader.ReadOneOrMore('d') || + reader.ReadOneOrMore('D') || + reader.ReadOneOrMore('h') || + reader.ReadOneOrMore('H') || + reader.ReadOneOrMore('s') || + reader.ReadOneOrMore('S') || + //Latin Date String: (a.C.n. ante Christum natum) + reader.ReadString("gg")) + { + syntaxError = false; + var length = reader.Position - offset; + return reader.Substring(offset, length); } - private static bool ReadLiteral(Tokenizer reader) - { - if (reader.Peek() == '\\' || reader.Peek() == '*' || reader.Peek() == '_') - { - reader.Advance(2); - return true; - } + // Symbols - if (reader.ReadEnclosed('"', '"')) - { - return true; - } + syntaxError = reader.Position < reader.Length; + return null; + } - if (reader.ReadEnclosed('\'', '\'')) - { - return true; - } + private static bool ReadLiteral(Tokenizer reader) + { + if (reader.Peek() == '\\' || reader.Peek() == '*' || reader.Peek() == '_') + { + reader.Advance(2); + return true; + } - return false; + if (reader.ReadEnclosed('"', '"')) + { + return true; } + + if (reader.ReadEnclosed('\'', '\'')) + { + return true; + } + + return false; } } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/DateTimeParser/Section.cs b/src/LogExpert.Core/Classes/DateTimeParser/Section.cs index 5f492b0e..a6d14c82 100644 --- a/src/LogExpert.Core/Classes/DateTimeParser/Section.cs +++ b/src/LogExpert.Core/Classes/DateTimeParser/Section.cs @@ -1,11 +1,10 @@ using System.Collections.Generic; -namespace LogExpert.Core.Classes.DateTimeParser +namespace LogExpert.Core.Classes.DateTimeParser; + +public class Section { - public class Section - { - public int SectionIndex { get; set; } + public int SectionIndex { get; set; } - public List GeneralTextDateDurationParts { get; set; } - } + public List GeneralTextDateDurationParts { get; set; } } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/DateTimeParser/Token.cs b/src/LogExpert.Core/Classes/DateTimeParser/Token.cs index 07483b9a..a9869b55 100644 --- a/src/LogExpert.Core/Classes/DateTimeParser/Token.cs +++ b/src/LogExpert.Core/Classes/DateTimeParser/Token.cs @@ -1,18 +1,17 @@ using System; -namespace LogExpert.Core.Classes.DateTimeParser +namespace LogExpert.Core.Classes.DateTimeParser; + +public static class Token { - public static class Token + public static bool IsDatePart(string token) { - public static bool IsDatePart(string token) - { - return - token.StartsWith("y", StringComparison.OrdinalIgnoreCase) || - token.StartsWith("m", StringComparison.OrdinalIgnoreCase) || - token.StartsWith("d", StringComparison.OrdinalIgnoreCase) || - token.StartsWith("s", StringComparison.OrdinalIgnoreCase) || - token.StartsWith("h", StringComparison.OrdinalIgnoreCase) || - string.Compare(token, "tt", StringComparison.OrdinalIgnoreCase) == 0; - } + return + token.StartsWith("y", StringComparison.OrdinalIgnoreCase) || + token.StartsWith("m", StringComparison.OrdinalIgnoreCase) || + token.StartsWith("d", StringComparison.OrdinalIgnoreCase) || + token.StartsWith("s", StringComparison.OrdinalIgnoreCase) || + token.StartsWith("h", StringComparison.OrdinalIgnoreCase) || + string.Compare(token, "tt", StringComparison.OrdinalIgnoreCase) == 0; } } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/DateTimeParser/Tokenizer.cs b/src/LogExpert.Core/Classes/DateTimeParser/Tokenizer.cs index 46fa909f..ae68743c 100644 --- a/src/LogExpert.Core/Classes/DateTimeParser/Tokenizer.cs +++ b/src/LogExpert.Core/Classes/DateTimeParser/Tokenizer.cs @@ -1,141 +1,140 @@ using System; -namespace LogExpert.Core.Classes.DateTimeParser +namespace LogExpert.Core.Classes.DateTimeParser; + +internal class Tokenizer { - internal class Tokenizer + private string formatString; + private int formatStringPosition; + + public Tokenizer(string fmt) { - private string formatString; - private int formatStringPosition; + formatString = fmt; + } - public Tokenizer(string fmt) - { - formatString = fmt; - } + public int Position => formatStringPosition; - public int Position => formatStringPosition; + public int Length => formatString.Length; - public int Length => formatString.Length; + public string Substring(int startIndex, int length) + { + return formatString.Substring(startIndex, length); + } - public string Substring(int startIndex, int length) + public int Peek(int offset = 0) + { + if (formatStringPosition + offset >= formatString.Length) { - return formatString.Substring(startIndex, length); + return -1; } - public int Peek(int offset = 0) + return formatString[formatStringPosition + offset]; + } + + public int PeekUntil(int startOffset, int until) + { + var offset = startOffset; + while (true) { - if (formatStringPosition + offset >= formatString.Length) + var c = Peek(offset++); + if (c == -1) { - return -1; + break; } - return formatString[formatStringPosition + offset]; - } - - public int PeekUntil(int startOffset, int until) - { - var offset = startOffset; - while (true) + if (c == until) { - var c = Peek(offset++); - if (c == -1) - { - break; - } - - if (c == until) - { - return offset - startOffset; - } + return offset - startOffset; } - return 0; } + return 0; + } - public bool PeekOneOf(int offset, string s) + public bool PeekOneOf(int offset, string s) + { + foreach (var c in s) { - foreach (var c in s) + if (Peek(offset) == c) { - if (Peek(offset) == c) - { - return true; - } + return true; } - return false; } + return false; + } - public void Advance(int characters = 1) + public void Advance(int characters = 1) + { + formatStringPosition = Math.Min(formatStringPosition + characters, formatString.Length); + } + + public bool ReadOneOrMore(int c) + { + if (Peek() != c) { - formatStringPosition = Math.Min(formatStringPosition + characters, formatString.Length); + return false; } - public bool ReadOneOrMore(int c) + while (Peek() == c) { - if (Peek() != c) - { - return false; - } + Advance(); + } - while (Peek() == c) - { - Advance(); - } + return true; + } + public bool ReadOneOf(string s) + { + if (PeekOneOf(0, s)) + { + Advance(); return true; } + return false; + } - public bool ReadOneOf(string s) + public bool ReadString(string s, bool ignoreCase = false) + { + if (formatStringPosition + s.Length > formatString.Length) { - if (PeekOneOf(0, s)) - { - Advance(); - return true; - } return false; } - public bool ReadString(string s, bool ignoreCase = false) + for (var i = 0; i < s.Length; i++) { - if (formatStringPosition + s.Length > formatString.Length) - { - return false; - } - - for (var i = 0; i < s.Length; i++) + var c1 = s[i]; + var c2 = (char)Peek(i); + if (ignoreCase) { - var c1 = s[i]; - var c2 = (char)Peek(i); - if (ignoreCase) + if (char.ToLower(c1) != char.ToLower(c2)) { - if (char.ToLower(c1) != char.ToLower(c2)) - { - return false; - } + return false; } - else + } + else + { + if (c1 != c2) { - if (c1 != c2) - { - return false; - } + return false; } } - - Advance(s.Length); - return true; } - public bool ReadEnclosed(char open, char close) + Advance(s.Length); + return true; + } + + public bool ReadEnclosed(char open, char close) + { + if (Peek() == open) { - if (Peek() == open) + var length = PeekUntil(1, close); + if (length > 0) { - var length = PeekUntil(1, close); - if (length > 0) - { - Advance(1 + length); - return true; - } + Advance(1 + length); + return true; } - - return false; } + + return false; } } diff --git a/src/LogExpert.Core/Classes/FileSystemCallback.cs b/src/LogExpert.Core/Classes/FileSystemCallback.cs index 0fe50759..008f2b29 100644 --- a/src/LogExpert.Core/Classes/FileSystemCallback.cs +++ b/src/LogExpert.Core/Classes/FileSystemCallback.cs @@ -1,49 +1,48 @@ using NLog; -namespace LogExpert.Core.Classes -{ - public class FileSystemCallback : IFileSystemCallback - { - #region Public methods +namespace LogExpert.Core.Classes; - public ILogExpertLogger GetLogger() - { - return new NLogLogExpertWrapper(); - } +public class FileSystemCallback : IFileSystemCallback +{ + #region Public methods - #endregion + public ILogExpertLogger GetLogger() + { + return new NLogLogExpertWrapper(); + } - private class NLogLogExpertWrapper : ILogExpertLogger - { - #region Fields + #endregion - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private class NLogLogExpertWrapper : ILogExpertLogger + { + #region Fields - #endregion + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - #region Public methods + #endregion - public void Info(string msg) - { - _logger.Info(msg); - } + #region Public methods - public void Debug(string msg) - { - _logger.Debug(msg); - } + public void Info(string msg) + { + _logger.Info(msg); + } - public void LogWarn(string msg) - { - _logger.Warn(msg); - } + public void Debug(string msg) + { + _logger.Debug(msg); + } - public void LogError(string msg) - { - _logger.Error(msg); - } + public void LogWarn(string msg) + { + _logger.Warn(msg); + } - #endregion + public void LogError(string msg) + { + _logger.Error(msg); } + + #endregion } } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Filter/Filter.cs b/src/LogExpert.Core/Classes/Filter/Filter.cs index 7b6914bf..d1374c79 100644 --- a/src/LogExpert.Core/Classes/Filter/Filter.cs +++ b/src/LogExpert.Core/Classes/Filter/Filter.cs @@ -3,176 +3,175 @@ using LogExpert.Core.Classes.Filter; using NLog; -namespace LogExpert.Classes.Filter +namespace LogExpert.Classes.Filter; + +internal delegate void FilterFx (FilterParams filterParams, List filterResultLines, List lastFilterResultLines, List filterHitList); + +internal class Filter { - internal delegate void FilterFx (FilterParams filterParams, List filterResultLines, List lastFilterResultLines, List filterHitList); + #region Fields - internal class Filter - { - #region Fields + private const int PROGRESS_BAR_MODULO = 1000; + private const int SPREAD_MAX = 50; + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - private const int PROGRESS_BAR_MODULO = 1000; - private const int SPREAD_MAX = 50; - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private readonly ColumnizerCallback _callback; - private readonly ColumnizerCallback _callback; + #endregion - #endregion + #region cTor - #region cTor + //TODO Is the callback needed? (https://github.com/LogExperts/LogExpert/issues/401) + public Filter (ColumnizerCallback callback) + { + _callback = callback; + FilterResultLines = []; + LastFilterLinesList = []; + FilterHitList = []; + } - //TODO Is the callback needed? (https://github.com/LogExperts/LogExpert/issues/401) - public Filter (ColumnizerCallback callback) - { - _callback = callback; - FilterResultLines = []; - LastFilterLinesList = []; - FilterHitList = []; - } + #endregion - #endregion + #region Properties - #region Properties + public List FilterResultLines { get; } - public List FilterResultLines { get; } + public List LastFilterLinesList { get; } - public List LastFilterLinesList { get; } + public List FilterHitList { get; } - public List FilterHitList { get; } + public bool ShouldCancel { get; set; } - public bool ShouldCancel { get; set; } + #endregion - #endregion + #region Public methods - #region Public methods + public int DoFilter (FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) + { + return DoFilter(filterParams, startLine, maxCount, FilterResultLines, LastFilterLinesList, FilterHitList, progressCallback); + } - public int DoFilter (FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) - { - return DoFilter(filterParams, startLine, maxCount, FilterResultLines, LastFilterLinesList, FilterHitList, progressCallback); - } + #endregion - #endregion + #region Private Methods - #region Private Methods + private int DoFilter (FilterParams filterParams, int startLine, int maxCount, List filterResultLines, List lastFilterLinesList, List filterHitList, ProgressCallback progressCallback) + { + var lineNum = startLine; + var count = 0; + var callbackCounter = 0; - private int DoFilter (FilterParams filterParams, int startLine, int maxCount, List filterResultLines, List lastFilterLinesList, List filterHitList, ProgressCallback progressCallback) + try { - var lineNum = startLine; - var count = 0; - var callbackCounter = 0; + filterParams.Reset(); - try + while ((count++ < maxCount || filterParams.IsInRange) && !ShouldCancel) { - filterParams.Reset(); - - while ((count++ < maxCount || filterParams.IsInRange) && !ShouldCancel) + if (lineNum >= _callback.GetLineCount()) { - if (lineNum >= _callback.GetLineCount()) - { - return count; - } + return count; + } - ILogLine line = _callback.GetLogLine(lineNum); + ILogLine line = _callback.GetLogLine(lineNum); - if (line == null) - { - return count; - } + if (line == null) + { + return count; + } - _callback.SetLineNum(lineNum); + _callback.SetLineNum(lineNum); - if (Util.TestFilterCondition(filterParams, line, _callback)) - { - AddFilterLine(lineNum, false, filterParams, filterResultLines, lastFilterLinesList, filterHitList); - } + if (Util.TestFilterCondition(filterParams, line, _callback)) + { + AddFilterLine(lineNum, false, filterParams, filterResultLines, lastFilterLinesList, filterHitList); + } - lineNum++; - callbackCounter++; + lineNum++; + callbackCounter++; - if (lineNum % PROGRESS_BAR_MODULO == 0) - { - progressCallback(callbackCounter); - callbackCounter = 0; - } + if (lineNum % PROGRESS_BAR_MODULO == 0) + { + progressCallback(callbackCounter); + callbackCounter = 0; } } - catch (Exception ex) - { - _logger.Error(ex, "Exception while filtering. Please report to developer"); - //TODO: This information should be handled from the LogExpert project and not from LogExpert.Core. - //MessageBox.Show(null, - // "Exception while filtering. Please report to developer: \n\n" + ex + "\n\n" + ex.StackTrace, - // "LogExpert"); - } - - return count; } - - private void AddFilterLine (int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) + catch (Exception ex) { - filterHitList.Add(lineNum); - IList filterResult = GetAdditionalFilterResults(filterParams, lineNum, lastFilterLinesList); + _logger.Error(ex, "Exception while filtering. Please report to developer"); + //TODO: This information should be handled from the LogExpert project and not from LogExpert.Core. + //MessageBox.Show(null, + // "Exception while filtering. Please report to developer: \n\n" + ex + "\n\n" + ex.StackTrace, + // "LogExpert"); + } - filterResultLines.AddRange(filterResult); + return count; + } - lastFilterLinesList.AddRange(filterResult); + private void AddFilterLine (int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) + { + filterHitList.Add(lineNum); + IList filterResult = GetAdditionalFilterResults(filterParams, lineNum, lastFilterLinesList); - if (lastFilterLinesList.Count > SPREAD_MAX * 2) - { - lastFilterLinesList.RemoveRange(0, lastFilterLinesList.Count - SPREAD_MAX * 2); - } - } + filterResultLines.AddRange(filterResult); + lastFilterLinesList.AddRange(filterResult); - /// - /// Returns a list with 'additional filter results'. This is the given line number - /// and (if back spread and/or fore spread is enabled) some additional lines. - /// This function doesn't check the filter condition! - /// - /// - /// - /// - /// - private IList GetAdditionalFilterResults (FilterParams filterParams, int lineNum, IList checkList) + if (lastFilterLinesList.Count > SPREAD_MAX * 2) { - IList resultList = []; + lastFilterLinesList.RemoveRange(0, lastFilterLinesList.Count - SPREAD_MAX * 2); + } + } - if (filterParams.SpreadBefore == 0 && filterParams.SpreadBehind == 0) - { - resultList.Add(lineNum); - return resultList; - } - // back spread - for (var i = filterParams.SpreadBefore; i > 0; --i) + /// + /// Returns a list with 'additional filter results'. This is the given line number + /// and (if back spread and/or fore spread is enabled) some additional lines. + /// This function doesn't check the filter condition! + /// + /// + /// + /// + /// + private IList GetAdditionalFilterResults (FilterParams filterParams, int lineNum, IList checkList) + { + IList resultList = []; + + if (filterParams.SpreadBefore == 0 && filterParams.SpreadBehind == 0) + { + resultList.Add(lineNum); + return resultList; + } + + // back spread + for (var i = filterParams.SpreadBefore; i > 0; --i) + { + if (lineNum - i > 0) { - if (lineNum - i > 0) + if (!resultList.Contains(lineNum - i) && !checkList.Contains(lineNum - i)) { - if (!resultList.Contains(lineNum - i) && !checkList.Contains(lineNum - i)) - { - resultList.Add(lineNum - i); - } + resultList.Add(lineNum - i); } } - // direct filter hit - if (!resultList.Contains(lineNum) && !checkList.Contains(lineNum)) - { - resultList.Add(lineNum); - } - // after spread - for (var i = 1; i <= filterParams.SpreadBehind; ++i) + } + // direct filter hit + if (!resultList.Contains(lineNum) && !checkList.Contains(lineNum)) + { + resultList.Add(lineNum); + } + // after spread + for (var i = 1; i <= filterParams.SpreadBehind; ++i) + { + if (lineNum + i < _callback.GetLineCount()) { - if (lineNum + i < _callback.GetLineCount()) + if (!resultList.Contains(lineNum + i) && !checkList.Contains(lineNum + i)) { - if (!resultList.Contains(lineNum + i) && !checkList.Contains(lineNum + i)) - { - resultList.Add(lineNum + i); - } + resultList.Add(lineNum + i); } } - return resultList; } - - #endregion + return resultList; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Filter/FilterCancelHandler.cs b/src/LogExpert.Core/Classes/Filter/FilterCancelHandler.cs index 6a4c8c6b..18b7dd50 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterCancelHandler.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterCancelHandler.cs @@ -2,34 +2,33 @@ using NLog; -namespace LogExpert.Classes.Filter -{ - public class FilterCancelHandler : IBackgroundProcessCancelHandler - { - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - #region Fields +namespace LogExpert.Classes.Filter; - private readonly FilterStarter _filterStarter; +public class FilterCancelHandler : IBackgroundProcessCancelHandler +{ + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + #region Fields - #endregion + private readonly FilterStarter _filterStarter; - #region cTor + #endregion - public FilterCancelHandler(FilterStarter filterStarter) - { - _filterStarter = filterStarter; - } + #region cTor - #endregion + public FilterCancelHandler(FilterStarter filterStarter) + { + _filterStarter = filterStarter; + } - #region Public methods + #endregion - public void EscapePressed() - { - _logger.Info("FilterCancelHandler called."); - _filterStarter.CancelFilter(); - } + #region Public methods - #endregion + public void EscapePressed() + { + _logger.Info("FilterCancelHandler called."); + _filterStarter.CancelFilter(); } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Filter/FilterParams.cs b/src/LogExpert.Core/Classes/Filter/FilterParams.cs index 29da3de9..57ff7ec2 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterParams.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterParams.cs @@ -3,170 +3,169 @@ using System.Text.Json.Serialization; using System.Text.RegularExpressions; -namespace LogExpert.Core.Classes.Filter +namespace LogExpert.Core.Classes.Filter; + +[Serializable] +public class FilterParams : ICloneable { - [Serializable] - public class FilterParams : ICloneable - { - #region Fields + #region Fields - private string _rangeSearchText = string.Empty; - private string _searchText = string.Empty; + private string _rangeSearchText = string.Empty; + private string _searchText = string.Empty; - //public List historyList = new List(); - //public List rangeHistoryList = new List(); + //public List historyList = new List(); + //public List rangeHistoryList = new List(); - #endregion + #endregion - #region Properties + #region Properties - public string SearchText + public string SearchText + { + get => _searchText; + set { - get => _searchText; - set - { - _searchText = value; - LowerSearchText = _searchText.ToLowerInvariant(); - } + _searchText = value; + LowerSearchText = _searchText.ToLowerInvariant(); } + } - public string RangeSearchText + public string RangeSearchText + { + get => _rangeSearchText; + set { - get => _rangeSearchText; - set - { - _rangeSearchText = value; - LowerRangeSearchText = _rangeSearchText.ToLowerInvariant(); - } + _rangeSearchText = value; + LowerRangeSearchText = _rangeSearchText.ToLowerInvariant(); } + } - public bool SpreadEnabled => SpreadBefore > 0 || SpreadBehind > 0; + public bool SpreadEnabled => SpreadBefore > 0 || SpreadBehind > 0; - public bool IsCaseSensitive { get; set; } + public bool IsCaseSensitive { get; set; } - public bool IsFilterTail { get; set; } + public bool IsFilterTail { get; set; } - public int FuzzyValue { get; set; } + public int FuzzyValue { get; set; } - public bool EmptyColumnUsePrev { get; set; } + public bool EmptyColumnUsePrev { get; set; } - public bool EmptyColumnHit { get; set; } + public bool EmptyColumnHit { get; set; } - public bool ExactColumnMatch { get; set; } + public bool ExactColumnMatch { get; set; } - public bool ColumnRestrict { get; set; } + public bool ColumnRestrict { get; set; } - public Color Color { get; set; } = Color.Black; + public Color Color { get; set; } = Color.Black; - public int SpreadBefore { get; set; } + public int SpreadBefore { get; set; } - public int SpreadBehind { get; set; } + public int SpreadBehind { get; set; } - public bool IsInvert { get; set; } + public bool IsInvert { get; set; } - public bool IsRangeSearch { get; set; } + public bool IsRangeSearch { get; set; } - public bool IsRegex { get; set; } + public bool IsRegex { get; set; } - // list of columns in which to search - public List ColumnList { get; set; } = []; + // list of columns in which to search + public List ColumnList { get; set; } = []; - [JsonIgnore] - [field: NonSerialized] - public ILogLineColumnizer CurrentColumnizer { get; set; } + [JsonIgnore] + [field: NonSerialized] + public ILogLineColumnizer CurrentColumnizer { get; set; } - /// - /// false=looking for start - /// true=looking for end - /// - [field: NonSerialized] - public bool IsInRange { get; set; } + /// + /// false=looking for start + /// true=looking for end + /// + [field: NonSerialized] + public bool IsInRange { get; set; } - [field: NonSerialized] - public string LastLine { get; set; } = string.Empty; + [field: NonSerialized] + public string LastLine { get; set; } = string.Empty; - [field: NonSerialized] - public Hashtable LastNonEmptyCols { get; set; } = []; + [field: NonSerialized] + public Hashtable LastNonEmptyCols { get; set; } = []; - [field: NonSerialized] - public bool LastResult { get; set; } + [field: NonSerialized] + public bool LastResult { get; set; } - [field: NonSerialized] - public string LowerRangeSearchText { get; set; } = string.Empty; + [field: NonSerialized] + public string LowerRangeSearchText { get; set; } = string.Empty; - [field: NonSerialized] - public string LowerSearchText { get; set; } = string.Empty; + [field: NonSerialized] + public string LowerSearchText { get; set; } = string.Empty; - [field: NonSerialized] - public Regex RangeRex { get; set; } + [field: NonSerialized] + public Regex RangeRex { get; set; } - [field: NonSerialized] - public Regex Rex { get; set; } + [field: NonSerialized] + public Regex Rex { get; set; } - #endregion + #endregion - #region Public methods + #region Public methods - /// - /// Returns a new FilterParams object with the current columnizer set to the one used in this object. - /// - /// - public FilterParams CloneWithCurrentColumnizer() - { - FilterParams newParams = Clone(); - newParams.Init(); - // removed cloning of columnizer for filtering, because this causes issues with columnizers that hold internal states (like CsvColumnizer) - // newParams.currentColumnizer = Util.CloneColumnizer(this.currentColumnizer); - newParams.CurrentColumnizer = CurrentColumnizer; - return newParams; - } + /// + /// Returns a new FilterParams object with the current columnizer set to the one used in this object. + /// + /// + public FilterParams CloneWithCurrentColumnizer() + { + FilterParams newParams = Clone(); + newParams.Init(); + // removed cloning of columnizer for filtering, because this causes issues with columnizers that hold internal states (like CsvColumnizer) + // newParams.currentColumnizer = Util.CloneColumnizer(this.currentColumnizer); + newParams.CurrentColumnizer = CurrentColumnizer; + return newParams; + } - // call after deserialization! - public void Init() - { - LastNonEmptyCols = []; - LowerRangeSearchText = RangeSearchText.ToLower(); - LowerSearchText = SearchText.ToLower(); - LastLine = string.Empty; - } + // call after deserialization! + public void Init() + { + LastNonEmptyCols = []; + LowerRangeSearchText = RangeSearchText.ToLower(); + LowerSearchText = SearchText.ToLower(); + LastLine = string.Empty; + } - // Reset before a new search - public void Reset() - { - LastNonEmptyCols.Clear(); - IsInRange = false; - } + // Reset before a new search + public void Reset() + { + LastNonEmptyCols.Clear(); + IsInRange = false; + } - public void CreateRegex() + public void CreateRegex() + { + if (SearchText != null) { - if (SearchText != null) - { - Rex = new Regex(SearchText, IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); - } - if (RangeSearchText != null && IsRangeSearch) - { - RangeRex = new Regex(RangeSearchText, IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); - } + Rex = new Regex(SearchText, IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); } - - /// - /// Shallow Copy - /// - /// - public FilterParams Clone() + if (RangeSearchText != null && IsRangeSearch) { - return (FilterParams)MemberwiseClone(); + RangeRex = new Regex(RangeSearchText, IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); } + } - /// - /// Shallow Copy - /// - /// - object ICloneable.Clone() - { - return Clone(); - } + /// + /// Shallow Copy + /// + /// + public FilterParams Clone() + { + return (FilterParams)MemberwiseClone(); + } - #endregion + /// + /// Shallow Copy + /// + /// + object ICloneable.Clone() + { + return Clone(); } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs index 4464023e..e99ce716 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs @@ -7,193 +7,192 @@ using System.IO; using System.Text; -namespace LogExpert.Classes.Filter +namespace LogExpert.Classes.Filter; + +public class FilterPipe { - public class FilterPipe - { - #region Fields + #region Fields - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - private IList _lineMappingList = new List(); - private StreamWriter _writer; + private IList _lineMappingList = new List(); + private StreamWriter _writer; - #endregion + #endregion - #region cTor + #region cTor - public FilterPipe(FilterParams filterParams, ILogWindow logWindow) - { - FilterParams = filterParams; - LogWindow = logWindow; - IsStopped = false; - FileName = Path.GetTempFileName(); + public FilterPipe(FilterParams filterParams, ILogWindow logWindow) + { + FilterParams = filterParams; + LogWindow = logWindow; + IsStopped = false; + FileName = Path.GetTempFileName(); - _logger.Info("Created temp file: {0}", FileName); - } + _logger.Info("Created temp file: {0}", FileName); + } - #endregion + #endregion - #region Delegates + #region Delegates - public delegate void ClosedEventHandler(object sender, EventArgs e); + public delegate void ClosedEventHandler(object sender, EventArgs e); - #endregion + #endregion - #region Events + #region Events - public event ClosedEventHandler Closed; + public event ClosedEventHandler Closed; - #endregion + #endregion - #region Properties + #region Properties - public bool IsStopped { get; set; } + public bool IsStopped { get; set; } - public string FileName { get; } + public string FileName { get; } - public FilterParams FilterParams { get; } + public FilterParams FilterParams { get; } - public IList LastLinesHistoryList { get; } = new List(); + public IList LastLinesHistoryList { get; } = new List(); - public ILogWindow LogWindow { get; } + public ILogWindow LogWindow { get; } - public ILogWindow OwnLogWindow { get; set; } + public ILogWindow OwnLogWindow { get; set; } - #endregion + #endregion - #region Public methods + #region Public methods - public void OpenFile() - { - FileStream fStream = new(FileName, FileMode.Append, FileAccess.Write, FileShare.Read); - _writer = new StreamWriter(fStream, new UnicodeEncoding(false, false)); - } + public void OpenFile() + { + FileStream fStream = new(FileName, FileMode.Append, FileAccess.Write, FileShare.Read); + _writer = new StreamWriter(fStream, new UnicodeEncoding(false, false)); + } - public void CloseFile() + public void CloseFile() + { + if (_writer != null) { - if (_writer != null) - { - _writer.Close(); - _writer = null; - } + _writer.Close(); + _writer = null; } + } - public bool WriteToPipe(ILogLine textLine, int orgLineNum) + public bool WriteToPipe(ILogLine textLine, int orgLineNum) + { + try { - try + lock (FileName) { - lock (FileName) + lock (_lineMappingList) { - lock (_lineMappingList) + try + { + _writer.WriteLine(textLine.FullLine); + _lineMappingList.Add(orgLineNum); + return true; + } + catch (IOException e) { - try - { - _writer.WriteLine(textLine.FullLine); - _lineMappingList.Add(orgLineNum); - return true; - } - catch (IOException e) - { - _logger.Error(e, "writeToPipe()"); - return false; - } + _logger.Error(e, "writeToPipe()"); + return false; } } } - catch (IOException ex) - { - _logger.Error(ex, "writeToPipe(): file was closed"); - return false; - } } - - public int GetOriginalLineNum(int lineNum) + catch (IOException ex) { - lock (_lineMappingList) - { - if (_lineMappingList.Count > lineNum) - { - return _lineMappingList[lineNum]; - } - - return -1; - } + _logger.Error(ex, "writeToPipe(): file was closed"); + return false; } + } - public void ShiftLineNums(int offset) + public int GetOriginalLineNum(int lineNum) + { + lock (_lineMappingList) { - _logger.Debug("FilterPipe.ShiftLineNums() offset={0}", offset); - List newList = []; - lock (_lineMappingList) + if (_lineMappingList.Count > lineNum) { - foreach (var lineNum in _lineMappingList) - { - var line = lineNum - offset; - if (line >= 0) - { - newList.Add(line); - } - else - { - newList.Add(-1); - } - } - _lineMappingList = newList; + return _lineMappingList[lineNum]; } + + return -1; } + } - public void ClearLineNums() + public void ShiftLineNums(int offset) + { + _logger.Debug("FilterPipe.ShiftLineNums() offset={0}", offset); + List newList = []; + lock (_lineMappingList) { - _logger.Debug("FilterPipe.ClearLineNums()"); - lock (_lineMappingList) + foreach (var lineNum in _lineMappingList) { - for (var i = 0; i < _lineMappingList.Count; ++i) + var line = lineNum - offset; + if (line >= 0) { - _lineMappingList[i] = -1; + newList.Add(line); + } + else + { + newList.Add(-1); } } + _lineMappingList = newList; } + } - public void ClearLineList() + public void ClearLineNums() + { + _logger.Debug("FilterPipe.ClearLineNums()"); + lock (_lineMappingList) { - lock (_lineMappingList) + for (var i = 0; i < _lineMappingList.Count; ++i) { - _lineMappingList.Clear(); + _lineMappingList[i] = -1; } } + } - public void RecreateTempFile() + public void ClearLineList() + { + lock (_lineMappingList) { - lock (_lineMappingList) - { - _lineMappingList = new List(); - } - lock (FileName) - { - CloseFile(); - // trunc file - FileStream fStream = new(FileName, FileMode.Truncate, FileAccess.Write, FileShare.Read); - fStream.SetLength(0); - fStream.Close(); - } + _lineMappingList.Clear(); } + } - public void CloseAndDisconnect() + public void RecreateTempFile() + { + lock (_lineMappingList) + { + _lineMappingList = new List(); + } + lock (FileName) { - ClearLineList(); - OnClosed(); + CloseFile(); + // trunc file + FileStream fStream = new(FileName, FileMode.Truncate, FileAccess.Write, FileShare.Read); + fStream.SetLength(0); + fStream.Close(); } + } - #endregion + public void CloseAndDisconnect() + { + ClearLineList(); + OnClosed(); + } - #region Private Methods + #endregion - private void OnClosed() - { - Closed?.Invoke(this, EventArgs.Empty); - } + #region Private Methods - #endregion + private void OnClosed() + { + Closed?.Invoke(this, EventArgs.Empty); } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs index 4bc5f8c6..7a2ba26a 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs @@ -3,219 +3,218 @@ using NLog; -namespace LogExpert.Classes.Filter -{ - public delegate void ProgressCallback (int lineCount); +namespace LogExpert.Classes.Filter; - public class FilterStarter - { - #region Fields +public delegate void ProgressCallback (int lineCount); - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); +public class FilterStarter +{ + #region Fields - private readonly ColumnizerCallback _callback; - private readonly SortedDictionary _filterHitDict; - private readonly List _filterReadyList; - private readonly SortedDictionary _filterResultDict; + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - private readonly List _filterWorkerList; + private readonly ColumnizerCallback _callback; + private readonly SortedDictionary _filterHitDict; + private readonly List _filterReadyList; + private readonly SortedDictionary _filterResultDict; - private readonly SortedDictionary _lastFilterLinesDict; + private readonly List _filterWorkerList; - private ProgressCallback _progressCallback; - private int _progressLineCount; - private bool _shouldStop; + private readonly SortedDictionary _lastFilterLinesDict; - #endregion + private ProgressCallback _progressCallback; + private int _progressLineCount; + private bool _shouldStop; - #region cTor + #endregion - public FilterStarter (ColumnizerCallback callback, int minThreads) - { - _callback = callback; - FilterResultLines = []; - LastFilterLinesList = []; - FilterHitList = []; - _filterReadyList = []; - _filterWorkerList = []; - _filterHitDict = []; - _filterResultDict = []; - _lastFilterLinesDict = []; - ThreadCount = Environment.ProcessorCount * 4; - ThreadCount = minThreads; - ThreadPool.GetMinThreads(out _, out var completion); - ThreadPool.SetMinThreads(minThreads, completion); - ThreadPool.GetMaxThreads(out _, out _); - } + #region cTor + + public FilterStarter (ColumnizerCallback callback, int minThreads) + { + _callback = callback; + FilterResultLines = []; + LastFilterLinesList = []; + FilterHitList = []; + _filterReadyList = []; + _filterWorkerList = []; + _filterHitDict = []; + _filterResultDict = []; + _lastFilterLinesDict = []; + ThreadCount = Environment.ProcessorCount * 4; + ThreadCount = minThreads; + ThreadPool.GetMinThreads(out _, out var completion); + ThreadPool.SetMinThreads(minThreads, completion); + ThreadPool.GetMaxThreads(out _, out _); + } - #endregion + #endregion - #region Properties + #region Properties - public List FilterResultLines { get; set; } + public List FilterResultLines { get; set; } - public List LastFilterLinesList { get; set; } + public List LastFilterLinesList { get; set; } - public List FilterHitList { get; set; } + public List FilterHitList { get; set; } - public int ThreadCount { get; set; } + public int ThreadCount { get; set; } - #endregion + #endregion - #region Public methods + #region Public methods - public async void DoFilter (FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) + public async void DoFilter (FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) + { + FilterResultLines.Clear(); + LastFilterLinesList.Clear(); + FilterHitList.Clear(); + _filterHitDict.Clear(); + _filterReadyList.Clear(); + _filterResultDict.Clear(); + _lastFilterLinesDict.Clear(); + _filterWorkerList.Clear(); + _shouldStop = false; + + var interval = maxCount / ThreadCount; + + if (interval < 1) { - FilterResultLines.Clear(); - LastFilterLinesList.Clear(); - FilterHitList.Clear(); - _filterHitDict.Clear(); - _filterReadyList.Clear(); - _filterResultDict.Clear(); - _lastFilterLinesDict.Clear(); - _filterWorkerList.Clear(); - _shouldStop = false; - - var interval = maxCount / ThreadCount; - - if (interval < 1) - { - interval = 1; - } + interval = 1; + } - var workStartLine = startLine; - List handleList = []; - _progressLineCount = 0; - _progressCallback = progressCallback; - while (workStartLine < startLine + maxCount) + var workStartLine = startLine; + List handleList = []; + _progressLineCount = 0; + _progressCallback = progressCallback; + while (workStartLine < startLine + maxCount) + { + if (workStartLine + interval > maxCount) { - if (workStartLine + interval > maxCount) + interval = maxCount - workStartLine; + if (interval == 0) { - interval = maxCount - workStartLine; - if (interval == 0) - { - break; - } + break; } - _logger.Info("FilterStarter starts worker for line {0}, lineCount {1}", workStartLine, interval); - - await Task.Run(() => DoWork(filterParams, workStartLine, interval, ThreadProgressCallback)).ContinueWith(FilterDoneCallback); - workStartLine += interval; } + _logger.Info("FilterStarter starts worker for line {0}, lineCount {1}", workStartLine, interval); - WaitHandle[] handles = [.. handleList]; - // wait for worker threads completion - if (handles.Length > 0) - { - WaitHandle.WaitAll(handles); - } + await Task.Run(() => DoWork(filterParams, workStartLine, interval, ThreadProgressCallback)).ContinueWith(FilterDoneCallback); + workStartLine += interval; + } - MergeResults(); + WaitHandle[] handles = [.. handleList]; + // wait for worker threads completion + if (handles.Length > 0) + { + WaitHandle.WaitAll(handles); } - /// - /// Requests the FilterStarter to stop all filter threads. Call this from another thread (e.g. GUI). The function returns - /// immediately without waiting for filter end. - /// - public void CancelFilter () + MergeResults(); + } + + /// + /// Requests the FilterStarter to stop all filter threads. Call this from another thread (e.g. GUI). The function returns + /// immediately without waiting for filter end. + /// + public void CancelFilter () + { + _shouldStop = true; + lock (_filterWorkerList) { - _shouldStop = true; - lock (_filterWorkerList) + _logger.Info("Filter cancel requested. Stopping all {0} threads.", _filterWorkerList.Count); + foreach (Filter filter in _filterWorkerList) { - _logger.Info("Filter cancel requested. Stopping all {0} threads.", _filterWorkerList.Count); - foreach (Filter filter in _filterWorkerList) - { - filter.ShouldCancel = true; - } + filter.ShouldCancel = true; } } + } - #endregion + #endregion - #region Private Methods + #region Private Methods - private void ThreadProgressCallback (int lineCount) + private void ThreadProgressCallback (int lineCount) + { + var count = Interlocked.Add(ref _progressLineCount, lineCount); + _progressCallback(count); + } + + private Filter DoWork (FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) + { + _logger.Info("Started Filter worker [{0}] for line {1}", Environment.CurrentManagedThreadId, startLine); + + // Give every thread own copies of ColumnizerCallback and FilterParams, because the state of the objects changes while filtering + FilterParams threadFilterParams = filterParams.CloneWithCurrentColumnizer(); + ColumnizerCallback threadColumnizerCallback = _callback.CreateCopy(); + + Filter filter = new(threadColumnizerCallback); + lock (_filterWorkerList) { - var count = Interlocked.Add(ref _progressLineCount, lineCount); - _progressCallback(count); + _filterWorkerList.Add(filter); } - private Filter DoWork (FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) + if (_shouldStop) { - _logger.Info("Started Filter worker [{0}] for line {1}", Environment.CurrentManagedThreadId, startLine); + return filter; + } - // Give every thread own copies of ColumnizerCallback and FilterParams, because the state of the objects changes while filtering - FilterParams threadFilterParams = filterParams.CloneWithCurrentColumnizer(); - ColumnizerCallback threadColumnizerCallback = _callback.CreateCopy(); + _ = filter.DoFilter(threadFilterParams, startLine, maxCount, progressCallback); + _logger.Info("Filter worker [{0}] for line {1} has completed.", Thread.CurrentThread.ManagedThreadId, startLine); - Filter filter = new(threadColumnizerCallback); - lock (_filterWorkerList) - { - _filterWorkerList.Add(filter); - } + lock (_filterReadyList) + { + _filterReadyList.Add(filter); + } - if (_shouldStop) - { - return filter; - } + return filter; + } - _ = filter.DoFilter(threadFilterParams, startLine, maxCount, progressCallback); - _logger.Info("Filter worker [{0}] for line {1} has completed.", Thread.CurrentThread.ManagedThreadId, startLine); + private void FilterDoneCallback (Task filterTask) + { + if (filterTask.IsCompleted) + { + Filter filter = filterTask.Result; lock (_filterReadyList) { _filterReadyList.Add(filter); } - - return filter; } + } - private void FilterDoneCallback (Task filterTask) + private void MergeResults () + { + _logger.Info("Merging filter results."); + foreach (Filter filter in _filterReadyList) { - if (filterTask.IsCompleted) + foreach (var lineNum in filter.FilterHitList) { - Filter filter = filterTask.Result; - - lock (_filterReadyList) + if (!_filterHitDict.ContainsKey(lineNum)) { - _filterReadyList.Add(filter); + _filterHitDict.Add(lineNum, lineNum); } } - } - - private void MergeResults () - { - _logger.Info("Merging filter results."); - foreach (Filter filter in _filterReadyList) + foreach (var lineNum in filter.FilterResultLines) { - foreach (var lineNum in filter.FilterHitList) + if (!_filterResultDict.ContainsKey(lineNum)) { - if (!_filterHitDict.ContainsKey(lineNum)) - { - _filterHitDict.Add(lineNum, lineNum); - } + _filterResultDict.Add(lineNum, lineNum); } - foreach (var lineNum in filter.FilterResultLines) - { - if (!_filterResultDict.ContainsKey(lineNum)) - { - _filterResultDict.Add(lineNum, lineNum); - } - } - foreach (var lineNum in filter.LastFilterLinesList) + } + foreach (var lineNum in filter.LastFilterLinesList) + { + if (!_lastFilterLinesDict.ContainsKey(lineNum)) { - if (!_lastFilterLinesDict.ContainsKey(lineNum)) - { - _lastFilterLinesDict.Add(lineNum, lineNum); - } + _lastFilterLinesDict.Add(lineNum, lineNum); } } - FilterHitList.AddRange(_filterHitDict.Keys); - FilterResultLines.AddRange(_filterResultDict.Keys); - LastFilterLinesList.AddRange(_lastFilterLinesDict.Keys); - _logger.Info("Merging done."); } - - #endregion + FilterHitList.AddRange(_filterHitDict.Keys); + FilterResultLines.AddRange(_filterResultDict.Keys); + LastFilterLinesList.AddRange(_lastFilterLinesDict.Keys); + _logger.Info("Merging done."); } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Highlight/ActionEntry.cs b/src/LogExpert.Core/Classes/Highlight/ActionEntry.cs index 85442e15..7db9d052 100644 --- a/src/LogExpert.Core/Classes/Highlight/ActionEntry.cs +++ b/src/LogExpert.Core/Classes/Highlight/ActionEntry.cs @@ -1,25 +1,24 @@ -namespace LogExpert.Core.Classes.Highlight +namespace LogExpert.Core.Classes.Highlight; + +[Serializable] +public class ActionEntry : ICloneable { - [Serializable] - public class ActionEntry : ICloneable - { - #region Fields + #region Fields - public string ActionParam { get; set; } + public string ActionParam { get; set; } - public string PluginName { get; set; } + public string PluginName { get; set; } - public object Clone() + public object Clone() + { + var actionEntry = new ActionEntry { - var actionEntry = new ActionEntry - { - PluginName = PluginName, - ActionParam = ActionParam - }; + PluginName = PluginName, + ActionParam = ActionParam + }; - return actionEntry; - } - - #endregion + return actionEntry; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Highlight/HighlightEntry.cs b/src/LogExpert.Core/Classes/Highlight/HighlightEntry.cs index 19701967..aed89b99 100644 --- a/src/LogExpert.Core/Classes/Highlight/HighlightEntry.cs +++ b/src/LogExpert.Core/Classes/Highlight/HighlightEntry.cs @@ -3,105 +3,104 @@ using System.Drawing; using System.Text.RegularExpressions; -namespace LogExpert.Core.Classes.Highlight +namespace LogExpert.Core.Classes.Highlight; + +[Serializable] +[method: JsonConstructor] +public class HighlightEntry() : ICloneable { - [Serializable] - [method: JsonConstructor] - public class HighlightEntry() : ICloneable - { - #region Fields + #region Fields - [NonSerialized] private Regex regex = null; + [NonSerialized] private Regex regex = null; - private string _searchText = string.Empty; + private string _searchText = string.Empty; - #endregion Fields + #endregion Fields - #region Properties + #region Properties - public bool IsStopTail { get; set; } + public bool IsStopTail { get; set; } - public bool IsSetBookmark { get; set; } + public bool IsSetBookmark { get; set; } - public bool IsRegEx { get; set; } + public bool IsRegEx { get; set; } - public bool IsCaseSensitive { get; set; } + public bool IsCaseSensitive { get; set; } - public Color ForegroundColor { get; set; } + public Color ForegroundColor { get; set; } - public Color BackgroundColor { get; set; } + public Color BackgroundColor { get; set; } - public string SearchText + public string SearchText + { + get => _searchText; + set { - get => _searchText; - set - { - _searchText = value; - regex = null; - } + _searchText = value; + regex = null; } + } - public bool IsLedSwitch { get; set; } + public bool IsLedSwitch { get; set; } - public ActionEntry ActionEntry { get; set; } + public ActionEntry ActionEntry { get; set; } - public bool IsActionEntry { get; set; } + public bool IsActionEntry { get; set; } - public string BookmarkComment { get; set; } + public string BookmarkComment { get; set; } - public Regex Regex + public Regex Regex + { + get { - get + if (regex == null) { - if (regex == null) + if (IsRegEx) { - if (IsRegEx) - { - regex = new Regex(SearchText, IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); - } - else - { - regex = new Regex(Regex.Escape(SearchText), IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); - } + regex = new Regex(SearchText, IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); + } + else + { + regex = new Regex(Regex.Escape(SearchText), IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); } - return regex; } + return regex; } + } - public bool IsWordMatch { get; set; } + public bool IsWordMatch { get; set; } - // highlightes search result - [field: NonSerialized] - public bool IsSearchHit { get; set; } + // highlightes search result + [field: NonSerialized] + public bool IsSearchHit { get; set; } - public bool IsBold { get; set; } + public bool IsBold { get; set; } - public bool NoBackground { get; set; } + public bool NoBackground { get; set; } - public object Clone() + public object Clone() + { + var highLightEntry = new HighlightEntry { - var highLightEntry = new HighlightEntry - { - SearchText = SearchText, - ForegroundColor = ForegroundColor, - BackgroundColor = BackgroundColor, - IsRegEx = IsRegEx, - IsCaseSensitive = IsCaseSensitive, - IsLedSwitch = IsLedSwitch, - IsStopTail = IsStopTail, - IsSetBookmark = IsSetBookmark, - IsActionEntry = IsActionEntry, - ActionEntry = ActionEntry != null ? (ActionEntry)ActionEntry.Clone() : null, - IsWordMatch = IsWordMatch, - IsBold = IsBold, - BookmarkComment = BookmarkComment, - NoBackground = NoBackground, - IsSearchHit = IsSearchHit - }; - - return highLightEntry; - } - - #endregion Properties + SearchText = SearchText, + ForegroundColor = ForegroundColor, + BackgroundColor = BackgroundColor, + IsRegEx = IsRegEx, + IsCaseSensitive = IsCaseSensitive, + IsLedSwitch = IsLedSwitch, + IsStopTail = IsStopTail, + IsSetBookmark = IsSetBookmark, + IsActionEntry = IsActionEntry, + ActionEntry = ActionEntry != null ? (ActionEntry)ActionEntry.Clone() : null, + IsWordMatch = IsWordMatch, + IsBold = IsBold, + BookmarkComment = BookmarkComment, + NoBackground = NoBackground, + IsSearchHit = IsSearchHit + }; + + return highLightEntry; } + + #endregion Properties } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Highlight/HilightMatchEntry.cs b/src/LogExpert.Core/Classes/Highlight/HilightMatchEntry.cs index 21bda173..1052ac4b 100644 --- a/src/LogExpert.Core/Classes/Highlight/HilightMatchEntry.cs +++ b/src/LogExpert.Core/Classes/Highlight/HilightMatchEntry.cs @@ -1,27 +1,26 @@ -namespace LogExpert.Core.Classes.Highlight -{ - /// - /// Class for storing word-wise hilight matches. Used for colouring different matches on one line. - /// - public class HilightMatchEntry - { - #region Properties +namespace LogExpert.Core.Classes.Highlight; - public HighlightEntry HilightEntry { get; set; } +/// +/// Class for storing word-wise hilight matches. Used for colouring different matches on one line. +/// +public class HilightMatchEntry +{ + #region Properties - public int StartPos { get; set; } + public HighlightEntry HilightEntry { get; set; } - public int Length { get; set; } + public int StartPos { get; set; } - #endregion + public int Length { get; set; } - #region Public methods + #endregion - public override string ToString() - { - return $"{HilightEntry.SearchText}/{StartPos}/{Length}"; - } + #region Public methods - #endregion + public override string ToString() + { + return $"{HilightEntry.SearchText}/{StartPos}/{Length}"; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/IPC/IpcMessage.cs b/src/LogExpert.Core/Classes/IPC/IpcMessage.cs index 2549ed89..d52fd1f1 100644 --- a/src/LogExpert.Core/Classes/IPC/IpcMessage.cs +++ b/src/LogExpert.Core/Classes/IPC/IpcMessage.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json.Linq; -namespace LogExpert.Core.Classes.IPC +namespace LogExpert.Core.Classes.IPC; + +public class IpcMessage { - public class IpcMessage - { - public int Version { get; set; } + public int Version { get; set; } - public IpcMessageType Type { get; set; } = IpcMessageType.Load; + public IpcMessageType Type { get; set; } = IpcMessageType.Load; - public JObject Payload { get; set; } = []; - } + public JObject Payload { get; set; } = []; } diff --git a/src/LogExpert.Core/Classes/IPC/IpcMessageType.cs b/src/LogExpert.Core/Classes/IPC/IpcMessageType.cs index cd4a4f7f..cd22d52c 100644 --- a/src/LogExpert.Core/Classes/IPC/IpcMessageType.cs +++ b/src/LogExpert.Core/Classes/IPC/IpcMessageType.cs @@ -1,9 +1,8 @@ -namespace LogExpert.Core.Classes.IPC +namespace LogExpert.Core.Classes.IPC; + +public enum IpcMessageType { - public enum IpcMessageType - { - Load, - NewWindow, - NewWindowOrLockedWindow - } + Load, + NewWindow, + NewWindowOrLockedWindow } diff --git a/src/LogExpert.Core/Classes/IPC/LoadPayload.cs b/src/LogExpert.Core/Classes/IPC/LoadPayload.cs index 6d5252a3..80e3f114 100644 --- a/src/LogExpert.Core/Classes/IPC/LoadPayload.cs +++ b/src/LogExpert.Core/Classes/IPC/LoadPayload.cs @@ -1,7 +1,6 @@ -namespace LogExpert.Core.Classes.IPC +namespace LogExpert.Core.Classes.IPC; + +public class LoadPayload { - public class LoadPayload - { - public List Files { get; set; } = []; - } + public List Files { get; set; } = []; } diff --git a/src/LogExpert.Core/Classes/Log/LogBuffer.cs b/src/LogExpert.Core/Classes/Log/LogBuffer.cs index 5f607e68..72ee1062 100644 --- a/src/LogExpert.Core/Classes/Log/LogBuffer.cs +++ b/src/LogExpert.Core/Classes/Log/LogBuffer.cs @@ -1,124 +1,123 @@ using NLog; -namespace LogExpert.Core.Classes.Log +namespace LogExpert.Core.Classes.Log; + +public class LogBuffer { - public class LogBuffer - { - #region Fields + #region Fields - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); #if DEBUG - private readonly IList _filePositions = new List(); // file position for every line + private readonly IList _filePositions = new List(); // file position for every line #endif - private readonly IList _logLines = new List(); - private int MAX_LINES = 500; - private long _size; + private readonly IList _logLines = new List(); + private int MAX_LINES = 500; + private long _size; - #endregion + #endregion - #region cTor + #region cTor - //public LogBuffer() { } + //public LogBuffer() { } - public LogBuffer(ILogFileInfo fileInfo, int maxLines) - { - FileInfo = fileInfo; - MAX_LINES = maxLines; - } + public LogBuffer(ILogFileInfo fileInfo, int maxLines) + { + FileInfo = fileInfo; + MAX_LINES = maxLines; + } - #endregion + #endregion - #region Properties + #region Properties - public long StartPos { set; get; } + public long StartPos { set; get; } - public long Size + public long Size + { + set { - set - { - _size = value; + _size = value; #if DEBUG - if (_filePositions.Count > 0) + if (_filePositions.Count > 0) + { + if (_size < _filePositions[_filePositions.Count - 1] - StartPos) { - if (_size < _filePositions[_filePositions.Count - 1] - StartPos) - { - _logger.Error("LogBuffer overall Size must be greater than last line file position!"); - } + _logger.Error("LogBuffer overall Size must be greater than last line file position!"); } -#endif } - get => _size; +#endif } + get => _size; + } - public int StartLine { set; get; } + public int StartLine { set; get; } - public int LineCount { get; private set; } + public int LineCount { get; private set; } - public bool IsDisposed { get; private set; } + public bool IsDisposed { get; private set; } - public ILogFileInfo FileInfo { get; set; } + public ILogFileInfo FileInfo { get; set; } - public int DroppedLinesCount { get; set; } + public int DroppedLinesCount { get; set; } - public int PrevBuffersDroppedLinesSum { get; set; } + public int PrevBuffersDroppedLinesSum { get; set; } - #endregion + #endregion - #region Public methods + #region Public methods - public void AddLine(ILogLine line, long filePos) - { - _logLines.Add(line); + public void AddLine(ILogLine line, long filePos) + { + _logLines.Add(line); #if DEBUG - _filePositions.Add(filePos); + _filePositions.Add(filePos); #endif - LineCount++; - IsDisposed = false; - } + LineCount++; + IsDisposed = false; + } - public void ClearLines() - { - _logLines.Clear(); - LineCount = 0; - } + public void ClearLines() + { + _logLines.Clear(); + LineCount = 0; + } - public void DisposeContent() - { - _logLines.Clear(); - IsDisposed = true; + public void DisposeContent() + { + _logLines.Clear(); + IsDisposed = true; #if DEBUG - DisposeCount++; + DisposeCount++; #endif - } + } - public ILogLine GetLineOfBlock(int num) + public ILogLine GetLineOfBlock(int num) + { + if (num < _logLines.Count && num >= 0) { - if (num < _logLines.Count && num >= 0) - { - return _logLines[num]; - } - - return null; + return _logLines[num]; } - #endregion + return null; + } + + #endregion #if DEBUG - public long DisposeCount { get; private set; } + public long DisposeCount { get; private set; } - public long GetFilePosForLineOfBlock(int line) + public long GetFilePosForLineOfBlock(int line) + { + if (line >= 0 && line < _filePositions.Count) { - if (line >= 0 && line < _filePositions.Count) - { - return _filePositions[line]; - } - - return -1; + return _filePositions[line]; } -#endif + return -1; } + +#endif } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Log/LogBufferCacheEntry.cs b/src/LogExpert.Core/Classes/Log/LogBufferCacheEntry.cs index 72230efc..0683012e 100644 --- a/src/LogExpert.Core/Classes/Log/LogBufferCacheEntry.cs +++ b/src/LogExpert.Core/Classes/Log/LogBufferCacheEntry.cs @@ -1,35 +1,34 @@ -namespace LogExpert.Core.Classes.Log -{ - public class LogBufferCacheEntry - { - #region Fields +namespace LogExpert.Core.Classes.Log; - #endregion +public class LogBufferCacheEntry +{ + #region Fields - #region cTor + #endregion - public LogBufferCacheEntry() - { - Touch(); - } + #region cTor - #endregion + public LogBufferCacheEntry() + { + Touch(); + } - #region Properties + #endregion - public LogBuffer LogBuffer { get; set; } + #region Properties - public long LastUseTimeStamp { get; private set; } + public LogBuffer LogBuffer { get; set; } - #endregion + public long LastUseTimeStamp { get; private set; } - #region Public methods + #endregion - public void Touch() - { - LastUseTimeStamp = Environment.TickCount & int.MaxValue; - } + #region Public methods - #endregion + public void Touch() + { + LastUseTimeStamp = Environment.TickCount & int.MaxValue; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Log/LogStreamReaderBase.cs b/src/LogExpert.Core/Classes/Log/LogStreamReaderBase.cs index 0b8c649a..d5800faf 100644 --- a/src/LogExpert.Core/Classes/Log/LogStreamReaderBase.cs +++ b/src/LogExpert.Core/Classes/Log/LogStreamReaderBase.cs @@ -3,69 +3,68 @@ using LogExpert.Core.Interface; -namespace LogExpert.Core.Classes.Log +namespace LogExpert.Core.Classes.Log; + +public abstract class LogStreamReaderBase : ILogStreamReader { - public abstract class LogStreamReaderBase : ILogStreamReader - { - #region cTor + #region cTor - protected LogStreamReaderBase() - { + protected LogStreamReaderBase() + { - } + } - ~LogStreamReaderBase() - { - Dispose(false); - } + ~LogStreamReaderBase() + { + Dispose(false); + } - #endregion + #endregion - #region Properties + #region Properties - /// - /// Current position in the stream. - /// - public abstract long Position { get; set; } + /// + /// Current position in the stream. + /// + public abstract long Position { get; set; } - public abstract bool IsBufferComplete { get; } + public abstract bool IsBufferComplete { get; } - public abstract Encoding Encoding { get; } + public abstract Encoding Encoding { get; } - /// - /// Indicates whether or not the stream reader has already been disposed. - /// - public bool IsDisposed { get; private set; } + /// + /// Indicates whether or not the stream reader has already been disposed. + /// + public bool IsDisposed { get; private set; } - #endregion + #endregion - #region Public methods + #region Public methods - /// - /// Destroy and release the current stream reader. - /// - public void Dispose() + /// + /// Destroy and release the current stream reader. + /// + public void Dispose() + { + try { - try - { - Dispose(true); - GC.SuppressFinalize(this); - } - finally - { - IsDisposed = true; - } + Dispose(true); + GC.SuppressFinalize(this); } - /// - /// Destroy and release the current stream reader. - /// - /// Specifies whether or not the managed objects should be released. - protected abstract void Dispose(bool disposing); + finally + { + IsDisposed = true; + } + } + /// + /// Destroy and release the current stream reader. + /// + /// Specifies whether or not the managed objects should be released. + protected abstract void Dispose(bool disposing); - public abstract int ReadChar(); + public abstract int ReadChar(); - public abstract string ReadLine(); + public abstract string ReadLine(); - #endregion - } + #endregion } diff --git a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs index 76caf5e9..dd142b44 100644 --- a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs +++ b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs @@ -2,226 +2,225 @@ using System.Text; -namespace LogExpert.Core.Classes.Log +namespace LogExpert.Core.Classes.Log; + +public abstract class PositionAwareStreamReaderBase : LogStreamReaderBase { - public abstract class PositionAwareStreamReaderBase : LogStreamReaderBase - { - #region Fields + #region Fields - private const int MAX_LINE_LEN = 20000; + private const int MAX_LINE_LEN = 20000; - private static readonly Encoding[] _preambleEncodings = { Encoding.UTF8, Encoding.Unicode, Encoding.BigEndianUnicode, Encoding.UTF32 }; + private static readonly Encoding[] _preambleEncodings = [Encoding.UTF8, Encoding.Unicode, Encoding.BigEndianUnicode, Encoding.UTF32]; - private readonly BufferedStream _stream; - private readonly StreamReader _reader; + private readonly BufferedStream _stream; + private readonly StreamReader _reader; - private readonly int _preambleLength; - private readonly int _posIncPrecomputed; + private readonly int _preambleLength; + private readonly int _posIncPrecomputed; - private long _position; + private long _position; - #endregion + #endregion - #region cTor + #region cTor - protected PositionAwareStreamReaderBase(Stream stream, EncodingOptions encodingOptions) - { - _stream = new BufferedStream(stream); + protected PositionAwareStreamReaderBase(Stream stream, EncodingOptions encodingOptions) + { + _stream = new BufferedStream(stream); - _preambleLength = DetectPreambleLengthAndEncoding(out Encoding detectedEncoding); + _preambleLength = DetectPreambleLengthAndEncoding(out Encoding detectedEncoding); - Encoding usedEncoding = GetUsedEncoding(encodingOptions, detectedEncoding); - _posIncPrecomputed = GetPosIncPrecomputed(usedEncoding); + Encoding usedEncoding = GetUsedEncoding(encodingOptions, detectedEncoding); + _posIncPrecomputed = GetPosIncPrecomputed(usedEncoding); - _reader = new StreamReader(_stream, usedEncoding, true); + _reader = new StreamReader(_stream, usedEncoding, true); - Position = 0; - } + Position = 0; + } - #endregion + #endregion - #region Properties + #region Properties - /// - /// Current position in the stream. - /// - public sealed override long Position + /// + /// Current position in the stream. + /// + public sealed override long Position + { + get => _position; + set { - get => _position; - set - { - /* - * 1: Sometime commented (+Encoding.GetPreamble().Length) - * 2: Date 1.1 3207 - * 3: Error Message from Piet because of Unicode-Bugs. - * No Idea, if this is OK. - * 4: 27.07.09: Preamble-Length is now calculated in CT, because Encoding.GetPreamble().Length - * always delivers a fixed length (does not mater what kind of data) - */ - _position = value; // +Encoding.GetPreamble().Length; // 1 - //stream.Seek(pos, SeekOrigin.Begin); // 2 - //stream.Seek(pos + Encoding.GetPreamble().Length, SeekOrigin.Begin); // 3 - _stream.Seek(_position + _preambleLength, SeekOrigin.Begin); // 4 - - ResetReader(); - } + /* + * 1: Sometime commented (+Encoding.GetPreamble().Length) + * 2: Date 1.1 3207 + * 3: Error Message from Piet because of Unicode-Bugs. + * No Idea, if this is OK. + * 4: 27.07.09: Preamble-Length is now calculated in CT, because Encoding.GetPreamble().Length + * always delivers a fixed length (does not mater what kind of data) + */ + _position = value; // +Encoding.GetPreamble().Length; // 1 + //stream.Seek(pos, SeekOrigin.Begin); // 2 + //stream.Seek(pos + Encoding.GetPreamble().Length, SeekOrigin.Begin); // 3 + _stream.Seek(_position + _preambleLength, SeekOrigin.Begin); // 4 + + ResetReader(); } + } - public sealed override Encoding Encoding => _reader.CurrentEncoding; + public sealed override Encoding Encoding => _reader.CurrentEncoding; - public sealed override bool IsBufferComplete => true; + public sealed override bool IsBufferComplete => true; - //Refactor this needs to be given and should not be added like this - protected static int MaxLineLen => 500;//ConfigManager.Settings.Preferences.MaxLineLength; + //Refactor this needs to be given and should not be added like this + protected static int MaxLineLen => 500;//ConfigManager.Settings.Preferences.MaxLineLength; - #endregion + #endregion - #region Public methods + #region Public methods - /// - /// Destroy and release the current stream reader. - /// - /// Specifies whether or not the managed objects should be released. - protected override void Dispose(bool disposing) + /// + /// Destroy and release the current stream reader. + /// + /// Specifies whether or not the managed objects should be released. + protected override void Dispose(bool disposing) + { + if (disposing) { - if (disposing) - { - _stream.Dispose(); - _reader.Dispose(); - } + _stream.Dispose(); + _reader.Dispose(); } + } - //TODO This is unsafe and should be refactored - public override unsafe int ReadChar() + //TODO This is unsafe and should be refactored + public override unsafe int ReadChar() + { + //ObjectDisposedException.ThrowIf + if (IsDisposed) { - //ObjectDisposedException.ThrowIf - if (IsDisposed) - { - throw new ObjectDisposedException(ToString()); - } + throw new ObjectDisposedException(ToString()); + } - try + try + { + var readInt = _reader.Read(); + if (readInt != -1) { - var readInt = _reader.Read(); - if (readInt != -1) + var readChar = (char)readInt; + if (_posIncPrecomputed != 0) { - var readChar = (char)readInt; - if (_posIncPrecomputed != 0) - { - _position += _posIncPrecomputed; - } - else - { - _position += _reader.CurrentEncoding.GetByteCount(&readChar, 1); - } + _position += _posIncPrecomputed; + } + else + { + _position += _reader.CurrentEncoding.GetByteCount(&readChar, 1); } - return readInt; - } - catch (IOException) - { - return -1; } + return readInt; } - - protected virtual void ResetReader() + catch (IOException) { - _reader.DiscardBufferedData(); + return -1; } + } - protected StreamReader GetStreamReader() - { - return IsDisposed ? throw new ObjectDisposedException(ToString()) : _reader; - } + protected virtual void ResetReader() + { + _reader.DiscardBufferedData(); + } - protected void MovePosition(int offset) - { - _position += offset; - } + protected StreamReader GetStreamReader() + { + return IsDisposed ? throw new ObjectDisposedException(ToString()) : _reader; + } - #endregion + protected void MovePosition(int offset) + { + _position += offset; + } - #region Private Methods + #endregion - /// - /// Determines the actual number of preamble bytes in the file. - /// - /// Number of preamble bytes in the file - private int DetectPreambleLengthAndEncoding(out Encoding detectedEncoding) - { - /* - UTF-8: EF BB BF - UTF-16-Big-Endian-Byteorder: FE FF - UTF-16-Little-Endian-Byteorder: FF FE - UTF-32-Big-Endian-Byteorder: 00 00 FE FF - UTF-32-Little-Endian-Byteorder: FF FE 00 00 - */ + #region Private Methods - var readPreamble = new byte[4]; + /// + /// Determines the actual number of preamble bytes in the file. + /// + /// Number of preamble bytes in the file + private int DetectPreambleLengthAndEncoding(out Encoding detectedEncoding) + { + /* + UTF-8: EF BB BF + UTF-16-Big-Endian-Byteorder: FE FF + UTF-16-Little-Endian-Byteorder: FF FE + UTF-32-Big-Endian-Byteorder: 00 00 FE FF + UTF-32-Little-Endian-Byteorder: FF FE 00 00 + */ - var readLen = _stream.Read(readPreamble, 0, 4); + var readPreamble = new byte[4]; - if (readLen >= 2) + var readLen = _stream.Read(readPreamble, 0, 4); + + if (readLen >= 2) + { + foreach (Encoding encoding in _preambleEncodings) { - foreach (Encoding encoding in _preambleEncodings) + var preamble = encoding.GetPreamble(); + var fail = false; + for (var i = 0; i < readLen && i < preamble.Length; ++i) { - var preamble = encoding.GetPreamble(); - var fail = false; - for (var i = 0; i < readLen && i < preamble.Length; ++i) + if (readPreamble[i] != preamble[i]) { - if (readPreamble[i] != preamble[i]) - { - fail = true; - break; - } + fail = true; + break; } + } - if (!fail) - { - detectedEncoding = encoding; - return preamble.Length; - } + if (!fail) + { + detectedEncoding = encoding; + return preamble.Length; } } - - // not found or less than 2 byte read - detectedEncoding = null; - - return 0; } - private Encoding GetUsedEncoding(EncodingOptions encodingOptions, Encoding detectedEncoding) - { - if (encodingOptions.Encoding != null) - { - return encodingOptions.Encoding; - } + // not found or less than 2 byte read + detectedEncoding = null; - if (detectedEncoding != null) - { - return detectedEncoding; - } + return 0; + } - return encodingOptions.DefaultEncoding ?? Encoding.Default; + private Encoding GetUsedEncoding(EncodingOptions encodingOptions, Encoding detectedEncoding) + { + if (encodingOptions.Encoding != null) + { + return encodingOptions.Encoding; } - private int GetPosIncPrecomputed(Encoding usedEncoding) + + if (detectedEncoding != null) { - switch (usedEncoding) - { - case UTF8Encoding _: - { - return 0; - } - case UnicodeEncoding _: - { - return 2; - } - default: - { - return 1; - } - } + return detectedEncoding; } - #endregion + return encodingOptions.DefaultEncoding ?? Encoding.Default; } + private int GetPosIncPrecomputed(Encoding usedEncoding) + { + switch (usedEncoding) + { + case UTF8Encoding _: + { + return 0; + } + case UnicodeEncoding _: + { + return 2; + } + default: + { + return 1; + } + } + } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs index 76bf10ec..8b8f7c9d 100644 --- a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs +++ b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs @@ -1,110 +1,109 @@ using LogExpert.Core.Entities; -namespace LogExpert.Core.Classes.Log +namespace LogExpert.Core.Classes.Log; + +public class PositionAwareStreamReaderLegacy : PositionAwareStreamReaderBase { - public class PositionAwareStreamReaderLegacy : PositionAwareStreamReaderBase - { - #region Fields + #region Fields - private readonly char[] _charBuffer = new char[MaxLineLen]; + private readonly char[] _charBuffer = new char[MaxLineLen]; - private int _charBufferPos; - private bool _crDetect; + private int _charBufferPos; + private bool _crDetect; - #endregion + #endregion - #region cTor + #region cTor - public PositionAwareStreamReaderLegacy(Stream stream, EncodingOptions encodingOptions) : base(stream, encodingOptions) - { + public PositionAwareStreamReaderLegacy(Stream stream, EncodingOptions encodingOptions) : base(stream, encodingOptions) + { - } + } + + #endregion - #endregion + #region Public methods - #region Public methods + public override string ReadLine() + { + int readInt; - public override string ReadLine() + while (-1 != (readInt = ReadChar())) { - int readInt; + var readChar = (char)readInt; - while (-1 != (readInt = ReadChar())) + switch (readChar) { - var readChar = (char)readInt; - - switch (readChar) - { - case '\n': + case '\n': + { + _crDetect = false; + return GetLineAndResetCharBufferPos(); + } + case '\r': + { + if (_crDetect) { - _crDetect = false; return GetLineAndResetCharBufferPos(); } - case '\r': - { - if (_crDetect) - { - return GetLineAndResetCharBufferPos(); - } - _crDetect = true; - break; - } - default: + _crDetect = true; + break; + } + default: + { + if (_crDetect) { - if (_crDetect) - { - _crDetect = false; - var line = GetLineAndResetCharBufferPos(); - AppendToCharBuffer(readChar); - return line; - } - + _crDetect = false; + var line = GetLineAndResetCharBufferPos(); AppendToCharBuffer(readChar); - break; + return line; } - } - } - var result = GetLineAndResetCharBufferPos(); - if (readInt == -1 && result.Length == 0 && !_crDetect) - { - return null; // EOF + AppendToCharBuffer(readChar); + break; + } } - _crDetect = false; - return result; } - protected override void ResetReader() + var result = GetLineAndResetCharBufferPos(); + if (readInt == -1 && result.Length == 0 && !_crDetect) { - ResetCharBufferPos(); - - base.ResetReader(); + return null; // EOF } + _crDetect = false; + return result; + } - #endregion + protected override void ResetReader() + { + ResetCharBufferPos(); - #region Private Methods + base.ResetReader(); + } - private string GetLineAndResetCharBufferPos() - { - string result = new(_charBuffer, 0, _charBufferPos); - ResetCharBufferPos(); - return result; - } + #endregion - private void AppendToCharBuffer(char readChar) - { - if (_charBufferPos < MaxLineLen) - { - _charBuffer[_charBufferPos++] = readChar; - } - } + #region Private Methods + + private string GetLineAndResetCharBufferPos() + { + string result = new(_charBuffer, 0, _charBufferPos); + ResetCharBufferPos(); + return result; + } - private void ResetCharBufferPos() + private void AppendToCharBuffer(char readChar) + { + if (_charBufferPos < MaxLineLen) { - _charBufferPos = 0; + _charBuffer[_charBufferPos++] = readChar; } + } - #endregion + private void ResetCharBufferPos() + { + _charBufferPos = 0; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs index 736d39a5..354703a0 100644 --- a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs +++ b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs @@ -1,95 +1,94 @@ using LogExpert.Core.Entities; -namespace LogExpert.Core.Classes.Log +namespace LogExpert.Core.Classes.Log; + +/// +/// This class is responsible for reading line from the log file. It also decodes characters with the appropriate charset encoding. +/// PositionAwareStreamReaderSystem tries a BOM detection to determine correct file offsets when directly seeking into the file (on re-loading flushed buffers). +/// UTF-8 handling is a bit slower, because after reading a character the byte length of the character must be determined. +/// Lines are read char-by-char. StreamReader.ReadLine() is not used because StreamReader cannot tell a file position. +/// +public class PositionAwareStreamReaderSystem : PositionAwareStreamReaderBase { - /// - /// This class is responsible for reading line from the log file. It also decodes characters with the appropriate charset encoding. - /// PositionAwareStreamReaderSystem tries a BOM detection to determine correct file offsets when directly seeking into the file (on re-loading flushed buffers). - /// UTF-8 handling is a bit slower, because after reading a character the byte length of the character must be determined. - /// Lines are read char-by-char. StreamReader.ReadLine() is not used because StreamReader cannot tell a file position. - /// - public class PositionAwareStreamReaderSystem : PositionAwareStreamReaderBase - { - #region Fields + #region Fields - private const int CHAR_CR = 0x0D; - private const int CHAR_LF = 0x0A; + private const int CHAR_CR = 0x0D; + private const int CHAR_LF = 0x0A; - private int _newLineSequenceLength; + private int _newLineSequenceLength; - #endregion + #endregion - #region cTor + #region cTor - public PositionAwareStreamReaderSystem(Stream stream, EncodingOptions encodingOptions) : base(stream, encodingOptions) - { + public PositionAwareStreamReaderSystem(Stream stream, EncodingOptions encodingOptions) : base(stream, encodingOptions) + { - } + } + + #endregion - #endregion + #region Public methods - #region Public methods + public override string ReadLine() + { + StreamReader reader = GetStreamReader(); - public override string ReadLine() + if (_newLineSequenceLength == 0) { - StreamReader reader = GetStreamReader(); + _newLineSequenceLength = GuessNewLineSequenceLength(reader); + } - if (_newLineSequenceLength == 0) - { - _newLineSequenceLength = GuessNewLineSequenceLength(reader); - } + var line = reader.ReadLine(); - var line = reader.ReadLine(); + if (line != null) + { + MovePosition(Encoding.GetByteCount(line) + _newLineSequenceLength); - if (line != null) + if (line.Length > MaxLineLen) { - MovePosition(Encoding.GetByteCount(line) + _newLineSequenceLength); - - if (line.Length > MaxLineLen) - { - line = line.Remove(MaxLineLen); - } + line = line.Remove(MaxLineLen); } - - return line; } - #endregion + return line; + } + + #endregion + + #region Private Methods - #region Private Methods + private int GuessNewLineSequenceLength(StreamReader reader) + { + var currentPos = Position; - private int GuessNewLineSequenceLength(StreamReader reader) + try { - var currentPos = Position; + var line = reader.ReadLine(); - try + if (line != null) { - var line = reader.ReadLine(); + Position += Encoding.GetByteCount(line); - if (line != null) + var firstChar = reader.Read(); + if (firstChar == CHAR_CR) // check \r { - Position += Encoding.GetByteCount(line); - - var firstChar = reader.Read(); - if (firstChar == CHAR_CR) // check \r + var secondChar = reader.Read(); + if (secondChar == CHAR_LF) // check \n { - var secondChar = reader.Read(); - if (secondChar == CHAR_LF) // check \n - { - return Encoding.GetByteCount("\r\n"); - } + return Encoding.GetByteCount("\r\n"); } - return Encoding.GetByteCount(((char)firstChar).ToString()); } - - return 0; - } - finally - { - Position = currentPos; + return Encoding.GetByteCount(((char)firstChar).ToString()); } - } - #endregion + return 0; + } + finally + { + Position = currentPos; + } } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs b/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs index 7bc6e22a..e9327051 100644 --- a/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs +++ b/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs @@ -2,236 +2,235 @@ using System.Text; using System.Text.RegularExpressions; -namespace LogExpert.Core.Classes.Log +namespace LogExpert.Core.Classes.Log; + +/* Needed info: + * - Date/time mask + * - index counters + * - counter direction (up/down) + * - counter limit + * - whether the files are shifted or not + * - whether the indexes start with zero (or n/a) on a new date period + * + * Format: + * *$D(yyyy-MM-dd)$I + * *$J(.) + * + * *(yyyy-MM-dd)[I] + * + */ + +/// +/// This class is responsible for building file names for multifile. +/// +public class RolloverFilenameBuilder { - /* Needed info: - * - Date/time mask - * - index counters - * - counter direction (up/down) - * - counter limit - * - whether the files are shifted or not - * - whether the indexes start with zero (or n/a) on a new date period - * - * Format: - * *$D(yyyy-MM-dd)$I - * *$J(.) - * - * *(yyyy-MM-dd)[I] - * - */ - - /// - /// This class is responsible for building file names for multifile. - /// - public class RolloverFilenameBuilder - { - #region Fields + #region Fields - private string _condContent; - private Group _condGroup; - private string _currentFileName; + private string _condContent; + private Group _condGroup; + private string _currentFileName; - private Group _dateGroup; + private Group _dateGroup; - //private Regex regexCond; - private DateTime _dateTime; + //private Regex regexCond; + private DateTime _dateTime; - //private DateTimeFormatInfo dateFormat; - private string _dateTimeFormat; + //private DateTimeFormatInfo dateFormat; + private string _dateTimeFormat; - private bool _hideZeroIndex; - private Group _indexGroup; - private Regex _regex; + private bool _hideZeroIndex; + private Group _indexGroup; + private Regex _regex; - #endregion + #endregion - #region cTor + #region cTor - public RolloverFilenameBuilder(string formatString) - { - ParseFormatString(formatString); - } + public RolloverFilenameBuilder(string formatString) + { + ParseFormatString(formatString); + } - #endregion + #endregion - #region Properties + #region Properties - public int Index { get; set; } + public int Index { get; set; } - public bool IsDatePattern => _dateGroup != null && _dateGroup.Success; + public bool IsDatePattern => _dateGroup != null && _dateGroup.Success; - public bool IsIndexPattern => _indexGroup != null && _indexGroup.Success; + public bool IsIndexPattern => _indexGroup != null && _indexGroup.Success; - #endregion + #endregion - #region Public methods + #region Public methods - public void SetFileName(string fileName) + public void SetFileName(string fileName) + { + _currentFileName = fileName; + Match match = _regex.Match(fileName); + if (match.Success) { - _currentFileName = fileName; - Match match = _regex.Match(fileName); - if (match.Success) + _dateGroup = match.Groups["date"]; + if (_dateGroup.Success) { - _dateGroup = match.Groups["date"]; - if (_dateGroup.Success) - { - var date = fileName.Substring(_dateGroup.Index, _dateGroup.Length); - if (DateTime.TryParseExact(date, _dateTimeFormat, DateTimeFormatInfo.InvariantInfo, - DateTimeStyles.None, - out _dateTime)) - { - } - } - _indexGroup = match.Groups["index"]; - if (_indexGroup.Success) + var date = fileName.Substring(_dateGroup.Index, _dateGroup.Length); + if (DateTime.TryParseExact(date, _dateTimeFormat, DateTimeFormatInfo.InvariantInfo, + DateTimeStyles.None, + out _dateTime)) { - Index = _indexGroup.Value.Length > 0 ? int.Parse(_indexGroup.Value) : 0; } - _condGroup = match.Groups["cond"]; } + _indexGroup = match.Groups["index"]; + if (_indexGroup.Success) + { + Index = _indexGroup.Value.Length > 0 ? int.Parse(_indexGroup.Value) : 0; + } + _condGroup = match.Groups["cond"]; } + } + + public void IncrementDate() + { + _dateTime = _dateTime.AddDays(1); + } + + public void DecrementDate() + { + _dateTime = _dateTime.AddDays(-1); + } - public void IncrementDate() - { - _dateTime = _dateTime.AddDays(1); - } - public void DecrementDate() + public string BuildFileName() + { + var fileName = _currentFileName; + if (_dateGroup != null && _dateGroup.Success) { - _dateTime = _dateTime.AddDays(-1); + var newDate = _dateTime.ToString(_dateTimeFormat, DateTimeFormatInfo.InvariantInfo); + fileName = fileName.Remove(_dateGroup.Index, _dateGroup.Length); + fileName = fileName.Insert(_dateGroup.Index, newDate); } - - public string BuildFileName() + if (_indexGroup != null && _indexGroup.Success) { - var fileName = _currentFileName; - if (_dateGroup != null && _dateGroup.Success) - { - var newDate = _dateTime.ToString(_dateTimeFormat, DateTimeFormatInfo.InvariantInfo); - fileName = fileName.Remove(_dateGroup.Index, _dateGroup.Length); - fileName = fileName.Insert(_dateGroup.Index, newDate); - } + fileName = fileName.Remove(_indexGroup.Index, _indexGroup.Length); - if (_indexGroup != null && _indexGroup.Success) + if (!_hideZeroIndex || Index > 0) { - fileName = fileName.Remove(_indexGroup.Index, _indexGroup.Length); - - if (!_hideZeroIndex || Index > 0) + var format = "D" + _indexGroup.Length; + fileName = fileName.Insert(_indexGroup.Index, Index.ToString(format)); + if (_hideZeroIndex && _condContent != null) { - var format = "D" + _indexGroup.Length; - fileName = fileName.Insert(_indexGroup.Index, Index.ToString(format)); - if (_hideZeroIndex && _condContent != null) - { - fileName = fileName.Insert(_indexGroup.Index, _condContent); - } + fileName = fileName.Insert(_indexGroup.Index, _condContent); } } - - // this.currentFileName = fileName; - // SetFileName(fileName); - return fileName; } - #endregion + // this.currentFileName = fileName; + // SetFileName(fileName); + return fileName; + } + + #endregion - #region Private Methods + #region Private Methods - private void ParseFormatString(string formatString) + private void ParseFormatString(string formatString) + { + var fmt = EscapeNonvarRegions(formatString); + var datePos = formatString.IndexOf("$D("); + if (datePos != -1) { - var fmt = EscapeNonvarRegions(formatString); - var datePos = formatString.IndexOf("$D("); - if (datePos != -1) + var endPos = formatString.IndexOf(')', datePos); + if (endPos != -1) { - var endPos = formatString.IndexOf(')', datePos); - if (endPos != -1) - { - _dateTimeFormat = formatString.Substring(datePos + 3, endPos - datePos - 3); - _dateTimeFormat = _dateTimeFormat.ToUpper(); - _dateTimeFormat = _dateTimeFormat.Replace('D', 'd').Replace('Y', 'y'); - - var dtf = _dateTimeFormat; - dtf = dtf.ToUpper(); - dtf = dtf.Replace("D", "\\d"); - dtf = dtf.Replace("Y", "\\d"); - dtf = dtf.Replace("M", "\\d"); - fmt = fmt.Remove(datePos, 2); // remove $D - fmt = fmt.Remove(datePos + 1, _dateTimeFormat.Length); // replace with regex version of format - fmt = fmt.Insert(datePos + 1, dtf); - fmt = fmt.Insert(datePos + 1, "?'date'"); // name the regex group - } + _dateTimeFormat = formatString.Substring(datePos + 3, endPos - datePos - 3); + _dateTimeFormat = _dateTimeFormat.ToUpper(); + _dateTimeFormat = _dateTimeFormat.Replace('D', 'd').Replace('Y', 'y'); + + var dtf = _dateTimeFormat; + dtf = dtf.ToUpper(); + dtf = dtf.Replace("D", "\\d"); + dtf = dtf.Replace("Y", "\\d"); + dtf = dtf.Replace("M", "\\d"); + fmt = fmt.Remove(datePos, 2); // remove $D + fmt = fmt.Remove(datePos + 1, _dateTimeFormat.Length); // replace with regex version of format + fmt = fmt.Insert(datePos + 1, dtf); + fmt = fmt.Insert(datePos + 1, "?'date'"); // name the regex group } + } - var condPos = fmt.IndexOf("$J("); - if (condPos != -1) + var condPos = fmt.IndexOf("$J("); + if (condPos != -1) + { + var endPos = fmt.IndexOf(')', condPos); + if (endPos != -1) { - var endPos = fmt.IndexOf(')', condPos); - if (endPos != -1) - { - _condContent = fmt.Substring(condPos + 3, endPos - condPos - 3); - fmt = fmt.Remove(condPos + 2, endPos - condPos - 1); - } + _condContent = fmt.Substring(condPos + 3, endPos - condPos - 3); + fmt = fmt.Remove(condPos + 2, endPos - condPos - 1); } + } - fmt = fmt.Replace("*", ".*"); - _hideZeroIndex = fmt.Contains("$J"); - fmt = fmt.Replace("$I", "(?'index'[\\d]+)"); - fmt = fmt.Replace("$J", "(?'index'[\\d]*)"); + fmt = fmt.Replace("*", ".*"); + _hideZeroIndex = fmt.Contains("$J"); + fmt = fmt.Replace("$I", "(?'index'[\\d]+)"); + fmt = fmt.Replace("$J", "(?'index'[\\d]*)"); - _regex = new Regex(fmt); - } + _regex = new Regex(fmt); + } - private string EscapeNonvarRegions(string formatString) + private string EscapeNonvarRegions(string formatString) + { + var fmt = formatString.Replace('*', '\xFFFD'); + StringBuilder result = new(); + var state = 0; + StringBuilder segment = new(); + for (var i = 0; i < fmt.Length; ++i) { - var fmt = formatString.Replace('*', '\xFFFD'); - StringBuilder result = new(); - var state = 0; - StringBuilder segment = new(); - for (var i = 0; i < fmt.Length; ++i) + switch (state) { - switch (state) - { - case 0: // looking for $ - if (fmt[i] == '$') - { - result.Append(Regex.Escape(segment.ToString())); - segment = new StringBuilder(); - state = 1; - } + case 0: // looking for $ + if (fmt[i] == '$') + { + result.Append(Regex.Escape(segment.ToString())); + segment = new StringBuilder(); + state = 1; + } + segment.Append(fmt[i]); + break; + case 1: // the char behind $ + segment.Append(fmt[i]); + result.Append(segment.ToString()); + segment = new StringBuilder(); + state = 2; + break; + case 2: // checking if ( or other char + if (fmt[i] == '(') + { segment.Append(fmt[i]); - break; - case 1: // the char behind $ + state = 3; + } + else + { segment.Append(fmt[i]); + state = 0; + } + break; + case 3: // looking for ) + segment.Append(fmt[i]); + if (fmt[i] == ')') + { result.Append(segment.ToString()); segment = new StringBuilder(); - state = 2; - break; - case 2: // checking if ( or other char - if (fmt[i] == '(') - { - segment.Append(fmt[i]); - state = 3; - } - else - { - segment.Append(fmt[i]); - state = 0; - } - break; - case 3: // looking for ) - segment.Append(fmt[i]); - if (fmt[i] == ')') - { - result.Append(segment.ToString()); - segment = new StringBuilder(); - state = 0; - } - break; - } + state = 0; + } + break; } - fmt = result.ToString().Replace('\xFFFD', '*'); - return fmt; } - - #endregion + fmt = result.ToString().Replace('\xFFFD', '*'); + return fmt; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Log/RolloverFilenameHandler.cs b/src/LogExpert.Core/Classes/Log/RolloverFilenameHandler.cs index 78639390..673eebfe 100644 --- a/src/LogExpert.Core/Classes/Log/RolloverFilenameHandler.cs +++ b/src/LogExpert.Core/Classes/Log/RolloverFilenameHandler.cs @@ -2,109 +2,108 @@ using LogExpert.Core.Interface; using System.Collections.Generic; -namespace LogExpert.Core.Classes.Log +namespace LogExpert.Core.Classes.Log; + +/// +/// Handles rollover naming. The names built by the RolloverFilenameBuilder will be used +/// to check if the file exist. Names will be built by incrmenting an index and decrementing a date. +/// A configurable number of days in the past will be checked (date gaps may occur on days without log file activity). +/// Date checking is only performed if the format pattern contains a date format. Index checking +/// is only performed of the format pattern contains an index placeholder. +/// +public class RolloverFilenameHandler { - /// - /// Handles rollover naming. The names built by the RolloverFilenameBuilder will be used - /// to check if the file exist. Names will be built by incrmenting an index and decrementing a date. - /// A configurable number of days in the past will be checked (date gaps may occur on days without log file activity). - /// Date checking is only performed if the format pattern contains a date format. Index checking - /// is only performed of the format pattern contains an index placeholder. - /// - public class RolloverFilenameHandler - { - #region Fields + #region Fields - private readonly RolloverFilenameBuilder _filenameBuilder; - private readonly ILogFileInfo _logFileInfo; - private readonly MultiFileOptions _options; + private readonly RolloverFilenameBuilder _filenameBuilder; + private readonly ILogFileInfo _logFileInfo; + private readonly MultiFileOptions _options; - #endregion + #endregion - #region cTor + #region cTor - /// - /// Constructor. - /// - /// The complete path of the logfile - /// Multifile option (e.g. format pattern) - public RolloverFilenameHandler(ILogFileInfo logFileInfo, MultiFileOptions options) - { - _options = options; - _logFileInfo = logFileInfo; - _filenameBuilder = new RolloverFilenameBuilder(_options.FormatPattern); - _filenameBuilder.SetFileName(logFileInfo.FileName); - } + /// + /// Constructor. + /// + /// The complete path of the logfile + /// Multifile option (e.g. format pattern) + public RolloverFilenameHandler(ILogFileInfo logFileInfo, MultiFileOptions options) + { + _options = options; + _logFileInfo = logFileInfo; + _filenameBuilder = new RolloverFilenameBuilder(_options.FormatPattern); + _filenameBuilder.SetFileName(logFileInfo.FileName); + } - #endregion + #endregion - #region Public methods + #region Public methods - /// - /// Returns a list of the built file names (complete path) which also exists on disk. - /// The list is created by using the RolloverFilenameBuilder and checking for file existence. - /// The first entry in the list contains the oldest file. The last entry contains the file given - /// in the contructor. - /// - /// - public LinkedList GetNameList(IPluginRegistry pluginRegistry) + /// + /// Returns a list of the built file names (complete path) which also exists on disk. + /// The list is created by using the RolloverFilenameBuilder and checking for file existence. + /// The first entry in the list contains the oldest file. The last entry contains the file given + /// in the contructor. + /// + /// + public LinkedList GetNameList(IPluginRegistry pluginRegistry) + { + LinkedList fileList = new(); + var fileName = _filenameBuilder.BuildFileName(); + var filePath = _logFileInfo.DirectoryName + _logFileInfo.DirectorySeparatorChar + fileName; + fileList.AddFirst(filePath); + var found = true; + while (found) { - LinkedList fileList = new(); - var fileName = _filenameBuilder.BuildFileName(); - var filePath = _logFileInfo.DirectoryName + _logFileInfo.DirectorySeparatorChar + fileName; - fileList.AddFirst(filePath); - var found = true; - while (found) + found = false; + // increment index and check if file exists + if (_filenameBuilder.IsIndexPattern) { - found = false; - // increment index and check if file exists - if (_filenameBuilder.IsIndexPattern) + _filenameBuilder.Index += 1; + fileName = _filenameBuilder.BuildFileName(); + filePath = _logFileInfo.DirectoryName + _logFileInfo.DirectorySeparatorChar + fileName;//TODO: Change to Directory.Combine + if (FileExists(filePath, pluginRegistry)) { - _filenameBuilder.Index += 1; + fileList.AddFirst(filePath); + found = true; + continue; + } + } + // if file with index isn't found or no index is in format pattern, decrement the current date + if (_filenameBuilder.IsDatePattern) + { + var tryCounter = 0; + _filenameBuilder.Index = 0; + while (tryCounter < _options.MaxDayTry) + { + _filenameBuilder.DecrementDate(); fileName = _filenameBuilder.BuildFileName(); filePath = _logFileInfo.DirectoryName + _logFileInfo.DirectorySeparatorChar + fileName;//TODO: Change to Directory.Combine if (FileExists(filePath, pluginRegistry)) { fileList.AddFirst(filePath); found = true; - continue; + break; } - } - // if file with index isn't found or no index is in format pattern, decrement the current date - if (_filenameBuilder.IsDatePattern) - { - var tryCounter = 0; - _filenameBuilder.Index = 0; - while (tryCounter < _options.MaxDayTry) - { - _filenameBuilder.DecrementDate(); - fileName = _filenameBuilder.BuildFileName(); - filePath = _logFileInfo.DirectoryName + _logFileInfo.DirectorySeparatorChar + fileName;//TODO: Change to Directory.Combine - if (FileExists(filePath, pluginRegistry)) - { - fileList.AddFirst(filePath); - found = true; - break; - } - tryCounter++; - } + tryCounter++; } } - return fileList; } + return fileList; + } - #endregion - - #region Private Methods + #endregion - private bool FileExists(string filePath, IPluginRegistry pluginRegistry) - { - IFileSystemPlugin fs = pluginRegistry.FindFileSystemForUri(filePath); - ILogFileInfo info = fs.GetLogfileInfo(filePath); - return info.FileExists; - } + #region Private Methods - #endregion + private bool FileExists(string filePath, IPluginRegistry pluginRegistry) + { + IFileSystemPlugin fs = pluginRegistry.FindFileSystemForUri(filePath); + ILogFileInfo info = fs.GetLogfileInfo(filePath); + return info.FileExists; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/ObjectClone.cs b/src/LogExpert.Core/Classes/ObjectClone.cs index 76cd00c6..9c6a352b 100644 --- a/src/LogExpert.Core/Classes/ObjectClone.cs +++ b/src/LogExpert.Core/Classes/ObjectClone.cs @@ -1,21 +1,20 @@ using System.IO; using System.Text.Json; -namespace LogExpert.Core.Classes -{ - public static class ObjectClone - { - #region Public methods +namespace LogExpert.Core.Classes; - public static T Clone(T RealObject) - { - using MemoryStream objectStream = new(); +public static class ObjectClone +{ + #region Public methods - JsonSerializer.Serialize(objectStream, RealObject); - objectStream.Seek(0, SeekOrigin.Begin); - return JsonSerializer.Deserialize(objectStream); - } + public static T Clone(T RealObject) + { + using MemoryStream objectStream = new(); - #endregion + JsonSerializer.Serialize(objectStream, RealObject); + objectStream.Seek(0, SeekOrigin.Begin); + return JsonSerializer.Deserialize(objectStream); } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/ParamParser.cs b/src/LogExpert.Core/Classes/ParamParser.cs index f1a4529c..42fbee75 100644 --- a/src/LogExpert.Core/Classes/ParamParser.cs +++ b/src/LogExpert.Core/Classes/ParamParser.cs @@ -1,104 +1,103 @@ using System.Text; using System.Text.RegularExpressions; -namespace LogExpert.Core.Classes +namespace LogExpert.Core.Classes; + +public class ParamParser { - public class ParamParser - { - #region Fields + #region Fields - private readonly string argLine; + private readonly string argLine; - #endregion + #endregion - #region cTor + #region cTor - public ParamParser(string argTemplate) - { - argLine = argTemplate; - } + public ParamParser(string argTemplate) + { + argLine = argTemplate; + } - #endregion + #endregion - #region Public methods + #region Public methods - public string ReplaceParams(ILogLine logLine, int lineNum, string fileName) + public string ReplaceParams(ILogLine logLine, int lineNum, string fileName) + { + FileInfo fileInfo = new(fileName); + StringBuilder builder = new(argLine); + builder.Replace("%L", "" + lineNum); + builder.Replace("%P", + fileInfo.DirectoryName.Contains(" ") ? "\"" + fileInfo.DirectoryName + "\"" : fileInfo.DirectoryName); + builder.Replace("%N", fileInfo.Name.Contains(" ") ? "\"" + fileInfo.Name + "\"" : fileInfo.Name); + builder.Replace("%F", + fileInfo.FullName.Contains(" ") ? "\"" + fileInfo.FullName + "\"" : fileInfo.FullName); + builder.Replace("%E", + fileInfo.Extension.Contains(" ") ? "\"" + fileInfo.Extension + "\"" : fileInfo.Extension); + var stripped = StripExtension(fileInfo.Name); + builder.Replace("%M", stripped.Contains(" ") ? "\"" + stripped + "\"" : stripped); + var sPos = 0; + string reg; + string replace; + do { - FileInfo fileInfo = new(fileName); - StringBuilder builder = new(argLine); - builder.Replace("%L", "" + lineNum); - builder.Replace("%P", - fileInfo.DirectoryName.Contains(" ") ? "\"" + fileInfo.DirectoryName + "\"" : fileInfo.DirectoryName); - builder.Replace("%N", fileInfo.Name.Contains(" ") ? "\"" + fileInfo.Name + "\"" : fileInfo.Name); - builder.Replace("%F", - fileInfo.FullName.Contains(" ") ? "\"" + fileInfo.FullName + "\"" : fileInfo.FullName); - builder.Replace("%E", - fileInfo.Extension.Contains(" ") ? "\"" + fileInfo.Extension + "\"" : fileInfo.Extension); - var stripped = StripExtension(fileInfo.Name); - builder.Replace("%M", stripped.Contains(" ") ? "\"" + stripped + "\"" : stripped); - var sPos = 0; - string reg; - string replace; - do + reg = GetNextGroup(builder, ref sPos); + replace = GetNextGroup(builder, ref sPos); + if (reg != null && replace != null) { - reg = GetNextGroup(builder, ref sPos); - replace = GetNextGroup(builder, ref sPos); - if (reg != null && replace != null) - { - var result = Regex.Replace(logLine.FullLine, reg, replace); - builder.Insert(sPos, result); - } - } while (replace != null); - return builder.ToString(); - } + var result = Regex.Replace(logLine.FullLine, reg, replace); + builder.Insert(sPos, result); + } + } while (replace != null); + return builder.ToString(); + } - public static string StripExtension(string fileName) + public static string StripExtension(string fileName) + { + var i = fileName.LastIndexOf('.'); + if (i < 0) { - var i = fileName.LastIndexOf('.'); - if (i < 0) - { - i = fileName.Length - 1; - } - return fileName.Substring(0, i); + i = fileName.Length - 1; } + return fileName.Substring(0, i); + } - #endregion + #endregion - #region Private Methods + #region Private Methods - private string GetNextGroup(StringBuilder builder, ref int sPos) + private string GetNextGroup(StringBuilder builder, ref int sPos) + { + int ePos; + while (sPos < builder.Length) { - int ePos; - while (sPos < builder.Length) + if (builder[sPos] == '{') { - if (builder[sPos] == '{') + ePos = sPos + 1; + var count = 1; + while (ePos < builder.Length) { - ePos = sPos + 1; - var count = 1; - while (ePos < builder.Length) + if (builder[ePos] == '{') { - if (builder[ePos] == '{') - { - count++; - } - if (builder[ePos] == '}') - { - count--; - } - if (count == 0) - { - var reg = builder.ToString(sPos + 1, ePos - sPos - 1); - builder.Remove(sPos, ePos - sPos + 1); - return reg; - } - ePos++; + count++; } + if (builder[ePos] == '}') + { + count--; + } + if (count == 0) + { + var reg = builder.ToString(sPos + 1, ePos - sPos - 1); + builder.Remove(sPos, ePos - sPos + 1); + return reg; + } + ePos++; } - sPos++; } - return null; + sPos++; } - - #endregion + return null; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/PatternBlock.cs b/src/LogExpert.Core/Classes/PatternBlock.cs index a5a80ebe..2fc6b6ba 100644 --- a/src/LogExpert.Core/Classes/PatternBlock.cs +++ b/src/LogExpert.Core/Classes/PatternBlock.cs @@ -1,44 +1,43 @@ using System.Collections.Generic; -namespace LogExpert.Core.Classes -{ - public class QualityInfo - { - #region Fields +namespace LogExpert.Core.Classes; - public int quality; +public class QualityInfo +{ + #region Fields - #endregion - } + public int quality; - public class PatternBlock - { - #region Fields + #endregion +} - public int blockId; +public class PatternBlock +{ + #region Fields - public int endLine; + public int blockId; - // key: line num - public Dictionary qualityInfoList = []; + public int endLine; - public SortedDictionary srcLines = []; - public int startLine; - public int targetEnd; - public SortedDictionary targetLines = []; - public int targetStart; - public int weigth; + // key: line num + public Dictionary qualityInfoList = []; - #endregion + public SortedDictionary srcLines = []; + public int startLine; + public int targetEnd; + public SortedDictionary targetLines = []; + public int targetStart; + public int weigth; - #region Public methods + #endregion - public override string ToString() - { - return "srcStart=" + startLine + ", srcEnd=" + endLine + ", targetStart=" + targetStart + - ", targetEnd=" + targetEnd + ", weight=" + weigth; - } + #region Public methods - #endregion + public override string ToString() + { + return "srcStart=" + startLine + ", srcEnd=" + endLine + ", targetStart=" + targetStart + + ", targetEnd=" + targetEnd + ", weight=" + weigth; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Persister/FilterTabData.cs b/src/LogExpert.Core/Classes/Persister/FilterTabData.cs index 99ba728a..f1fc8fc6 100644 --- a/src/LogExpert.Core/Classes/Persister/FilterTabData.cs +++ b/src/LogExpert.Core/Classes/Persister/FilterTabData.cs @@ -1,11 +1,10 @@ using LogExpert.Core.Classes.Filter; -namespace LogExpert.Core.Classes.Persister +namespace LogExpert.Core.Classes.Persister; + +public class FilterTabData { - public class FilterTabData - { - public FilterParams FilterParams { get; set; } = new(); + public FilterParams FilterParams { get; set; } = new(); - public PersistenceData PersistenceData { get; set; } = new(); - } + public PersistenceData PersistenceData { get; set; } = new(); } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Persister/Persister.cs b/src/LogExpert.Core/Classes/Persister/Persister.cs index 6889e31c..c1bf9ce4 100644 --- a/src/LogExpert.Core/Classes/Persister/Persister.cs +++ b/src/LogExpert.Core/Classes/Persister/Persister.cs @@ -1,704 +1,661 @@ -using LogExpert.Core.Classes.Filter; +using System.Drawing; +using System.Text; +using System.Text.Json; +using System.Xml; + +using LogExpert.Core.Classes.Filter; using LogExpert.Core.Config; using LogExpert.Core.Entities; using NLog; -using System.Drawing; -using System.Text; -using System.Text.Json; -using System.Xml; +namespace LogExpert.Core.Classes.Persister; -namespace LogExpert.Core.Classes.Persister +//TODO Rewrite as json Persister, xml is outdated and difficult to parse and write +public class Persister { - public class PersistenceData + #region Fields + + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); + + #endregion + + #region Public methods + + public static string SavePersistenceData (string logFileName, PersistenceData persistenceData, Preferences preferences) { - #region Fields - - public SortedList bookmarkList = []; - public int bookmarkListPosition = 300; - public bool bookmarkListVisible; - public string columnizerName; - public int currentLine = -1; - public Encoding encoding; - public string fileName; - public bool filterAdvanced; - public List filterParamsList = []; - public int filterPosition = 222; - public bool filterSaveListVisible; - public List filterTabDataList = []; - public bool filterVisible; - public int firstDisplayedLine = -1; - public bool followTail = true; - public string highlightGroupName; - public int lineCount; - - public bool multiFile; - public int multiFileMaxDays; - public List multiFileNames = []; - public string multiFilePattern; - public SortedList rowHeightList = []; - public string sessionFileName; - public bool showBookmarkCommentColumn; - public string tabName; - - public string settingsSaveLoadLocation; - - #endregion + var fileName = persistenceData.sessionFileName ?? BuildPersisterFileName(logFileName, preferences); + + if (preferences.saveLocation == SessionSaveLocation.SameDir) + { + // make to log file in .lxp file relative + var filePart = Path.GetFileName(persistenceData.fileName); + persistenceData.fileName = filePart; + } + + Save(fileName, persistenceData); + return fileName; } - //TODO Rewrite as json Persister, xml is outdated and difficult to parse and write - public class Persister + public static string SavePersistenceDataWithFixedName (string persistenceFileName, + PersistenceData persistenceData) { - #region Fields + Save(persistenceFileName, persistenceData); + return persistenceFileName; + } - private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); - #endregion + public static PersistenceData LoadPersistenceData (string logFileName, Preferences preferences) + { + var fileName = BuildPersisterFileName(logFileName, preferences); + return Load(fileName); + } - #region Public methods + public static PersistenceData LoadPersistenceDataOptionsOnly (string logFileName, Preferences preferences) + { + var fileName = BuildPersisterFileName(logFileName, preferences); + return LoadOptionsOnly(fileName); + } - public static string SavePersistenceData(string logFileName, PersistenceData persistenceData, Preferences preferences) - { - string fileName; + public static PersistenceData LoadPersistenceDataOptionsOnlyFromFixedFile (string persistenceFile) + { + return LoadOptionsOnly(persistenceFile); + } - if (persistenceData.sessionFileName != null) - { - fileName = persistenceData.sessionFileName; - } - else - { - fileName = BuildPersisterFileName(logFileName, preferences); - } - if (preferences.saveLocation == SessionSaveLocation.SameDir) - { - // make to log file in .lxp file relative - var filePart = Path.GetFileName(persistenceData.fileName); - persistenceData.fileName = filePart; - } + public static PersistenceData LoadPersistenceDataFromFixedFile (string persistenceFile) + { + return Load(persistenceFile); + } - Save(fileName, persistenceData); - return fileName; - } - public static string SavePersistenceDataWithFixedName(string persistenceFileName, - PersistenceData persistenceData) + /// + /// Loads the persistence options out of the given persistence file name. + /// + /// + /// + public static PersistenceData LoadOptionsOnly (string fileName) + { + PersistenceData persistenceData = new(); + XmlDocument xmlDoc = new(); + try { - Save(persistenceFileName, persistenceData); - return persistenceFileName; + xmlDoc.Load(fileName); } - - - public static PersistenceData LoadPersistenceData(string logFileName, Preferences preferences) + catch (IOException) { - var fileName = BuildPersisterFileName(logFileName, preferences); - return Load(fileName); + return null; } - public static PersistenceData LoadPersistenceDataOptionsOnly(string logFileName, Preferences preferences) + XmlNode fileNode = xmlDoc.SelectSingleNode("logexpert/file"); + if (fileNode != null) { - var fileName = BuildPersisterFileName(logFileName, preferences); - return LoadOptionsOnly(fileName); + var fileElement = fileNode as XmlElement; + ReadOptions(fileElement, persistenceData); + persistenceData.fileName = fileElement.GetAttribute("fileName"); + persistenceData.encoding = ReadEncoding(fileElement); } + return persistenceData; + } - public static PersistenceData LoadPersistenceDataOptionsOnlyFromFixedFile(string persistenceFile) - { - return LoadOptionsOnly(persistenceFile); - } + #endregion - public static PersistenceData LoadPersistenceDataFromFixedFile(string persistenceFile) + #region Private Methods + + private static string BuildPersisterFileName (string logFileName, Preferences preferences) + { + string dir; + string file; + + switch (preferences.saveLocation) { - return Load(persistenceFile); + case SessionSaveLocation.SameDir: + default: + { + FileInfo fileInfo = new(logFileName); + dir = fileInfo.DirectoryName; + file = fileInfo.DirectoryName + Path.DirectorySeparatorChar + fileInfo.Name + ".lxp"; + break; + } + case SessionSaveLocation.DocumentsDir: + { + dir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + + Path.DirectorySeparatorChar + + "LogExpert"; + file = dir + Path.DirectorySeparatorChar + BuildSessionFileNameFromPath(logFileName); + break; + } + case SessionSaveLocation.OwnDir: + { + dir = preferences.sessionSaveDirectory; + file = dir + Path.DirectorySeparatorChar + BuildSessionFileNameFromPath(logFileName); + break; + } + case SessionSaveLocation.ApplicationStartupDir: + { + //TODO Add Application.StartupPath as Variable + dir = string.Empty;// Application.StartupPath + Path.DirectorySeparatorChar + "sessionfiles"; + file = dir + Path.DirectorySeparatorChar + BuildSessionFileNameFromPath(logFileName); + break; + } } - - /// - /// Loads the persistence options out of the given persistence file name. - /// - /// - /// - public static PersistenceData LoadOptionsOnly(string fileName) + if (string.IsNullOrWhiteSpace(dir) == false && Directory.Exists(dir) == false) { - PersistenceData persistenceData = new(); - XmlDocument xmlDoc = new(); try { - xmlDoc.Load(fileName); - } - catch (IOException) - { - return null; + Directory.CreateDirectory(dir); } - XmlNode fileNode = xmlDoc.SelectSingleNode("logexpert/file"); - if (fileNode != null) + catch (Exception e) { - var fileElement = fileNode as XmlElement; - ReadOptions(fileElement, persistenceData); - persistenceData.fileName = fileElement.GetAttribute("fileName"); - persistenceData.encoding = ReadEncoding(fileElement); + //TODO this needs to be handled differently + //MessageBox.Show(e.Message, "LogExpert"); } - return persistenceData; } - #endregion + return file; + } - #region Private Methods + private static string BuildSessionFileNameFromPath (string logFileName) + { + var result = logFileName; + result = result.Replace(Path.DirectorySeparatorChar, '_'); + result = result.Replace(Path.AltDirectorySeparatorChar, '_'); + result = result.Replace(Path.VolumeSeparatorChar, '_'); + result += ".lxp"; + return result; + } - private static string BuildPersisterFileName(string logFileName, Preferences preferences) + private static void Save (string fileName, PersistenceData persistenceData) + { + XmlDocument xmlDoc = new(); + XmlElement rootElement = xmlDoc.CreateElement("logexpert"); + xmlDoc.AppendChild(rootElement); + XmlElement fileElement = xmlDoc.CreateElement("file"); + rootElement.AppendChild(fileElement); + fileElement.SetAttribute("fileName", persistenceData.fileName); + fileElement.SetAttribute("lineCount", "" + persistenceData.lineCount); + WriteBookmarks(xmlDoc, fileElement, persistenceData.bookmarkList); + WriteRowHeightList(xmlDoc, fileElement, persistenceData.rowHeightList); + WriteOptions(xmlDoc, fileElement, persistenceData); + WriteFilter(xmlDoc, fileElement, persistenceData.filterParamsList); + WriteFilterTabs(xmlDoc, fileElement, persistenceData.filterTabDataList); + WriteEncoding(xmlDoc, fileElement, persistenceData.encoding); + if (xmlDoc.HasChildNodes) { - string dir; - string file; - - switch (preferences.saveLocation) - { - case SessionSaveLocation.SameDir: - default: - { - FileInfo fileInfo = new(logFileName); - dir = fileInfo.DirectoryName; - file = fileInfo.DirectoryName + Path.DirectorySeparatorChar + fileInfo.Name + ".lxp"; - break; - } - case SessionSaveLocation.DocumentsDir: - { - dir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + - Path.DirectorySeparatorChar + - "LogExpert"; - file = dir + Path.DirectorySeparatorChar + BuildSessionFileNameFromPath(logFileName); - break; - } - case SessionSaveLocation.OwnDir: - { - dir = preferences.sessionSaveDirectory; - file = dir + Path.DirectorySeparatorChar + BuildSessionFileNameFromPath(logFileName); - break; - } - case SessionSaveLocation.ApplicationStartupDir: - { - //TODO Add Application.StartupPath as Variable - dir = string.Empty;// Application.StartupPath + Path.DirectorySeparatorChar + "sessionfiles"; - file = dir + Path.DirectorySeparatorChar + BuildSessionFileNameFromPath(logFileName); - break; - } - } - - if (string.IsNullOrWhiteSpace(dir) == false && Directory.Exists(dir) == false) - { - try - { - Directory.CreateDirectory(dir); - } - catch (Exception e) - { - //TODO this needs to be handled differently - //MessageBox.Show(e.Message, "LogExpert"); - } - } - return file; - } - - private static string BuildSessionFileNameFromPath(string logFileName) - { - var result = logFileName; - result = result.Replace(Path.DirectorySeparatorChar, '_'); - result = result.Replace(Path.AltDirectorySeparatorChar, '_'); - result = result.Replace(Path.VolumeSeparatorChar, '_'); - result += ".lxp"; - return result; - } - - private static void Save(string fileName, PersistenceData persistenceData) - { - XmlDocument xmlDoc = new(); - XmlElement rootElement = xmlDoc.CreateElement("logexpert"); - xmlDoc.AppendChild(rootElement); - XmlElement fileElement = xmlDoc.CreateElement("file"); - rootElement.AppendChild(fileElement); - fileElement.SetAttribute("fileName", persistenceData.fileName); - fileElement.SetAttribute("lineCount", "" + persistenceData.lineCount); - WriteBookmarks(xmlDoc, fileElement, persistenceData.bookmarkList); - WriteRowHeightList(xmlDoc, fileElement, persistenceData.rowHeightList); - WriteOptions(xmlDoc, fileElement, persistenceData); - WriteFilter(xmlDoc, fileElement, persistenceData.filterParamsList); - WriteFilterTabs(xmlDoc, fileElement, persistenceData.filterTabDataList); - WriteEncoding(xmlDoc, fileElement, persistenceData.encoding); - if (xmlDoc.HasChildNodes) - { - xmlDoc.Save(fileName); - } + xmlDoc.Save(fileName); } + } - private static void WriteEncoding(XmlDocument xmlDoc, XmlElement rootElement, Encoding encoding) + private static void WriteEncoding (XmlDocument xmlDoc, XmlElement rootElement, Encoding encoding) + { + if (encoding != null) { - if (encoding != null) - { - XmlElement encodingElement = xmlDoc.CreateElement("encoding"); - rootElement.AppendChild(encodingElement); - encodingElement.SetAttribute("name", encoding.WebName); - } + XmlElement encodingElement = xmlDoc.CreateElement("encoding"); + rootElement.AppendChild(encodingElement); + encodingElement.SetAttribute("name", encoding.WebName); } + } - private static void WriteFilterTabs(XmlDocument xmlDoc, XmlElement rootElement, List dataList) + private static void WriteFilterTabs (XmlDocument xmlDoc, XmlElement rootElement, List dataList) + { + if (dataList.Count > 0) { - if (dataList.Count > 0) - { - XmlElement filterTabsElement = xmlDoc.CreateElement("filterTabs"); - rootElement.AppendChild(filterTabsElement); - foreach (FilterTabData data in dataList) - { - PersistenceData persistenceData = data.PersistenceData; - XmlElement filterTabElement = xmlDoc.CreateElement("filterTab"); - filterTabsElement.AppendChild(filterTabElement); - WriteBookmarks(xmlDoc, filterTabElement, persistenceData.bookmarkList); - WriteRowHeightList(xmlDoc, filterTabElement, persistenceData.rowHeightList); - WriteOptions(xmlDoc, filterTabElement, persistenceData); - WriteFilter(xmlDoc, filterTabElement, persistenceData.filterParamsList); - WriteFilterTabs(xmlDoc, filterTabElement, persistenceData.filterTabDataList); - XmlElement filterElement = xmlDoc.CreateElement("tabFilter"); - filterTabElement.AppendChild(filterElement); - List filterList = [data.FilterParams]; - WriteFilter(xmlDoc, filterElement, filterList); - } + XmlElement filterTabsElement = xmlDoc.CreateElement("filterTabs"); + rootElement.AppendChild(filterTabsElement); + foreach (FilterTabData data in dataList) + { + PersistenceData persistenceData = data.PersistenceData; + XmlElement filterTabElement = xmlDoc.CreateElement("filterTab"); + filterTabsElement.AppendChild(filterTabElement); + WriteBookmarks(xmlDoc, filterTabElement, persistenceData.bookmarkList); + WriteRowHeightList(xmlDoc, filterTabElement, persistenceData.rowHeightList); + WriteOptions(xmlDoc, filterTabElement, persistenceData); + WriteFilter(xmlDoc, filterTabElement, persistenceData.filterParamsList); + WriteFilterTabs(xmlDoc, filterTabElement, persistenceData.filterTabDataList); + XmlElement filterElement = xmlDoc.CreateElement("tabFilter"); + filterTabElement.AppendChild(filterElement); + List filterList = [data.FilterParams]; + WriteFilter(xmlDoc, filterElement, filterList); } } + } - private static List ReadFilterTabs(XmlElement startNode) + private static List ReadFilterTabs (XmlElement startNode) + { + List dataList = []; + XmlNode filterTabsNode = startNode.SelectSingleNode("filterTabs"); + if (filterTabsNode != null) { - List dataList = []; - XmlNode filterTabsNode = startNode.SelectSingleNode("filterTabs"); - if (filterTabsNode != null) + XmlNodeList filterTabNodeList = filterTabsNode.ChildNodes; // all "filterTab" nodes + + foreach (XmlNode node in filterTabNodeList) { - XmlNodeList filterTabNodeList = filterTabsNode.ChildNodes; // all "filterTab" nodes + PersistenceData persistenceData = ReadPersistenceDataFromNode(node); + XmlNode filterNode = node.SelectSingleNode("tabFilter"); - foreach (XmlNode node in filterTabNodeList) + if (filterNode != null) { - PersistenceData persistenceData = ReadPersistenceDataFromNode(node); - XmlNode filterNode = node.SelectSingleNode("tabFilter"); - - if (filterNode != null) + List filterList = ReadFilter(filterNode as XmlElement); + FilterTabData data = new() { - List filterList = ReadFilter(filterNode as XmlElement); - FilterTabData data = new() - { - PersistenceData = persistenceData, - FilterParams = filterList[0] // there's only 1 - }; + PersistenceData = persistenceData, + FilterParams = filterList[0] // there's only 1 + }; - dataList.Add(data); - } + dataList.Add(data); } } - return dataList; } + return dataList; + } - private static void WriteFilter(XmlDocument xmlDoc, XmlElement rootElement, List filterList) + private static void WriteFilter (XmlDocument xmlDoc, XmlElement rootElement, List filterList) + { + XmlElement filtersElement = xmlDoc.CreateElement("filters"); + rootElement.AppendChild(filtersElement); + foreach (FilterParams filterParams in filterList) { - XmlElement filtersElement = xmlDoc.CreateElement("filters"); - rootElement.AppendChild(filtersElement); - foreach (FilterParams filterParams in filterList) - { - XmlElement filterElement = xmlDoc.CreateElement("filter"); - XmlElement paramsElement = xmlDoc.CreateElement("params"); - - MemoryStream stream = new(capacity: 200); - JsonSerializer.Serialize(stream, filterParams); - var base64Data = Convert.ToBase64String(stream.ToArray()); - paramsElement.InnerText = base64Data; - filterElement.AppendChild(paramsElement); - filtersElement.AppendChild(filterElement); - } + XmlElement filterElement = xmlDoc.CreateElement("filter"); + XmlElement paramsElement = xmlDoc.CreateElement("params"); + + MemoryStream stream = new(capacity: 200); + JsonSerializer.Serialize(stream, filterParams); + var base64Data = Convert.ToBase64String(stream.ToArray()); + paramsElement.InnerText = base64Data; + filterElement.AppendChild(paramsElement); + filtersElement.AppendChild(filterElement); } + } - private static List ReadFilter(XmlElement startNode) + private static List ReadFilter (XmlElement startNode) + { + List filterList = []; + XmlNode filtersNode = startNode.SelectSingleNode("filters"); + if (filtersNode != null) { - List filterList = []; - XmlNode filtersNode = startNode.SelectSingleNode("filters"); - if (filtersNode != null) + XmlNodeList filterNodeList = filtersNode.ChildNodes; // all "filter" nodes + foreach (XmlNode node in filterNodeList) { - XmlNodeList filterNodeList = filtersNode.ChildNodes; // all "filter" nodes - foreach (XmlNode node in filterNodeList) + foreach (XmlNode subNode in node.ChildNodes) { - foreach (XmlNode subNode in node.ChildNodes) + if (subNode.Name.Equals("params")) { - if (subNode.Name.Equals("params")) + var base64Text = subNode.InnerText; + var data = Convert.FromBase64String(base64Text); + MemoryStream stream = new(data); + + try + { + FilterParams filterParams = JsonSerializer.Deserialize(stream); + filterParams.Init(); + filterList.Add(filterParams); + } + catch (JsonException ex) { - var base64Text = subNode.InnerText; - var data = Convert.FromBase64String(base64Text); - MemoryStream stream = new(data); - - try - { - FilterParams filterParams = JsonSerializer.Deserialize(stream); - filterParams.Init(); - filterList.Add(filterParams); - } - catch (JsonException ex) - { - _logger.Error($"Error while deserializing filter params. Exception Message: {ex.Message}"); - } + _logger.Error($"Error while deserializing filter params. Exception Message: {ex.Message}"); } } } } - return filterList; } + return filterList; + } - private static void WriteBookmarks(XmlDocument xmlDoc, XmlElement rootElement, - SortedList bookmarkList) + private static void WriteBookmarks (XmlDocument xmlDoc, XmlElement rootElement, + SortedList bookmarkList) + { + XmlElement bookmarksElement = xmlDoc.CreateElement("bookmarks"); + rootElement.AppendChild(bookmarksElement); + foreach (Entities.Bookmark bookmark in bookmarkList.Values) { - XmlElement bookmarksElement = xmlDoc.CreateElement("bookmarks"); - rootElement.AppendChild(bookmarksElement); - foreach (Entities.Bookmark bookmark in bookmarkList.Values) - { - XmlElement bookmarkElement = xmlDoc.CreateElement("bookmark"); - bookmarkElement.SetAttribute("line", "" + bookmark.LineNum); - XmlElement textElement = xmlDoc.CreateElement("text"); - textElement.InnerText = bookmark.Text; - XmlElement posXElement = xmlDoc.CreateElement("posX"); - XmlElement posYElement = xmlDoc.CreateElement("posY"); - posXElement.InnerText = "" + bookmark.OverlayOffset.Width; - posYElement.InnerText = "" + bookmark.OverlayOffset.Height; - bookmarkElement.AppendChild(textElement); - bookmarkElement.AppendChild(posXElement); - bookmarkElement.AppendChild(posYElement); - bookmarksElement.AppendChild(bookmarkElement); - } + XmlElement bookmarkElement = xmlDoc.CreateElement("bookmark"); + bookmarkElement.SetAttribute("line", "" + bookmark.LineNum); + XmlElement textElement = xmlDoc.CreateElement("text"); + textElement.InnerText = bookmark.Text; + XmlElement posXElement = xmlDoc.CreateElement("posX"); + XmlElement posYElement = xmlDoc.CreateElement("posY"); + posXElement.InnerText = "" + bookmark.OverlayOffset.Width; + posYElement.InnerText = "" + bookmark.OverlayOffset.Height; + bookmarkElement.AppendChild(textElement); + bookmarkElement.AppendChild(posXElement); + bookmarkElement.AppendChild(posYElement); + bookmarksElement.AppendChild(bookmarkElement); } + } - private static PersistenceData Load(string fileName) + private static PersistenceData Load (string fileName) + { + XmlDocument xmlDoc = new(); + xmlDoc.Load(fileName); + XmlNode fileNode = xmlDoc.SelectSingleNode("logexpert/file"); + PersistenceData persistenceData = new(); + if (fileNode != null) { - XmlDocument xmlDoc = new(); - xmlDoc.Load(fileName); - XmlNode fileNode = xmlDoc.SelectSingleNode("logexpert/file"); - PersistenceData persistenceData = new(); - if (fileNode != null) - { - persistenceData = ReadPersistenceDataFromNode(fileNode); - } - return persistenceData; + persistenceData = ReadPersistenceDataFromNode(fileNode); } + return persistenceData; + } - private static PersistenceData ReadPersistenceDataFromNode(XmlNode node) + private static PersistenceData ReadPersistenceDataFromNode (XmlNode node) + { + PersistenceData persistenceData = new(); + var fileElement = node as XmlElement; + persistenceData.bookmarkList = ReadBookmarks(fileElement); + persistenceData.rowHeightList = ReadRowHeightList(fileElement); + ReadOptions(fileElement, persistenceData); + persistenceData.fileName = fileElement.GetAttribute("fileName"); + var sLineCount = fileElement.GetAttribute("lineCount"); + if (sLineCount != null && sLineCount.Length > 0) { - PersistenceData persistenceData = new(); - var fileElement = node as XmlElement; - persistenceData.bookmarkList = ReadBookmarks(fileElement); - persistenceData.rowHeightList = ReadRowHeightList(fileElement); - ReadOptions(fileElement, persistenceData); - persistenceData.fileName = fileElement.GetAttribute("fileName"); - var sLineCount = fileElement.GetAttribute("lineCount"); - if (sLineCount != null && sLineCount.Length > 0) - { - persistenceData.lineCount = int.Parse(sLineCount); - } - persistenceData.filterParamsList = ReadFilter(fileElement); - persistenceData.filterTabDataList = ReadFilterTabs(fileElement); - persistenceData.encoding = ReadEncoding(fileElement); - return persistenceData; + persistenceData.lineCount = int.Parse(sLineCount); } + persistenceData.filterParamsList = ReadFilter(fileElement); + persistenceData.filterTabDataList = ReadFilterTabs(fileElement); + persistenceData.encoding = ReadEncoding(fileElement); + return persistenceData; + } - private static Encoding ReadEncoding(XmlElement fileElement) + private static Encoding ReadEncoding (XmlElement fileElement) + { + XmlNode encodingNode = fileElement.SelectSingleNode("encoding"); + if (encodingNode != null) { - XmlNode encodingNode = fileElement.SelectSingleNode("encoding"); - if (encodingNode != null) + XmlAttribute encAttr = encodingNode.Attributes["name"]; + try { - XmlAttribute encAttr = encodingNode.Attributes["name"]; - try - { - return encAttr == null ? null : Encoding.GetEncoding(encAttr.Value); - } - catch (ArgumentException e) - { - _logger.Error(e); - return Encoding.Default; - } - catch (NotSupportedException e) - { - _logger.Error(e); - return Encoding.Default; - } + return encAttr == null ? null : Encoding.GetEncoding(encAttr.Value); + } + catch (ArgumentException e) + { + _logger.Error(e); + return Encoding.Default; + } + catch (NotSupportedException e) + { + _logger.Error(e); + return Encoding.Default; } - return null; } + return null; + } - private static SortedList ReadBookmarks(XmlElement startNode) + private static SortedList ReadBookmarks (XmlElement startNode) + { + SortedList bookmarkList = []; + XmlNode boomarksNode = startNode.SelectSingleNode("bookmarks"); + if (boomarksNode != null) { - SortedList bookmarkList = []; - XmlNode boomarksNode = startNode.SelectSingleNode("bookmarks"); - if (boomarksNode != null) + XmlNodeList bookmarkNodeList = boomarksNode.ChildNodes; // all "bookmark" nodes + foreach (XmlNode node in bookmarkNodeList) { - XmlNodeList bookmarkNodeList = boomarksNode.ChildNodes; // all "bookmark" nodes - foreach (XmlNode node in bookmarkNodeList) - { - string text = null; - string posX = null; - string posY = null; - string line = null; + string text = null; + string posX = null; + string posY = null; + string line = null; - foreach (XmlAttribute attr in node.Attributes) + foreach (XmlAttribute attr in node.Attributes) + { + if (attr.Name.Equals("line")) { - if (attr.Name.Equals("line")) - { - line = attr.InnerText; - } + line = attr.InnerText; } - foreach (XmlNode subNode in node.ChildNodes) + } + foreach (XmlNode subNode in node.ChildNodes) + { + if (subNode.Name.Equals("text")) { - if (subNode.Name.Equals("text")) - { - text = subNode.InnerText; - } - else if (subNode.Name.Equals("posX")) - { - posX = subNode.InnerText; - } - else if (subNode.Name.Equals("posY")) - { - posY = subNode.InnerText; - } + text = subNode.InnerText; } - if (line == null || posX == null || posY == null) + else if (subNode.Name.Equals("posX")) { - _logger.Error("Invalid XML format for bookmark: {0}", node.InnerText); - continue; + posX = subNode.InnerText; } - var lineNum = int.Parse(line); - - Entities.Bookmark bookmark = new(lineNum) - { - OverlayOffset = new Size(int.Parse(posX), int.Parse(posY)) - }; - - if (text != null) + else if (subNode.Name.Equals("posY")) { - bookmark.Text = text; + posY = subNode.InnerText; } - bookmarkList.Add(lineNum, bookmark); } + if (line == null || posX == null || posY == null) + { + _logger.Error("Invalid XML format for bookmark: {0}", node.InnerText); + continue; + } + var lineNum = int.Parse(line); + + Entities.Bookmark bookmark = new(lineNum) + { + OverlayOffset = new Size(int.Parse(posX), int.Parse(posY)) + }; + + if (text != null) + { + bookmark.Text = text; + } + bookmarkList.Add(lineNum, bookmark); } - return bookmarkList; } + return bookmarkList; + } - private static void WriteRowHeightList(XmlDocument xmlDoc, XmlElement rootElement, SortedList rowHeightList) + private static void WriteRowHeightList (XmlDocument xmlDoc, XmlElement rootElement, SortedList rowHeightList) + { + XmlElement rowheightElement = xmlDoc.CreateElement("rowheights"); + rootElement.AppendChild(rowheightElement); + foreach (RowHeightEntry entry in rowHeightList.Values) { - XmlElement rowheightElement = xmlDoc.CreateElement("rowheights"); - rootElement.AppendChild(rowheightElement); - foreach (RowHeightEntry entry in rowHeightList.Values) - { - XmlElement entryElement = xmlDoc.CreateElement("rowheight"); - entryElement.SetAttribute("line", "" + entry.LineNum); - entryElement.SetAttribute("height", "" + entry.Height); - rowheightElement.AppendChild(entryElement); - } + XmlElement entryElement = xmlDoc.CreateElement("rowheight"); + entryElement.SetAttribute("line", "" + entry.LineNum); + entryElement.SetAttribute("height", "" + entry.Height); + rowheightElement.AppendChild(entryElement); } + } - private static SortedList ReadRowHeightList(XmlElement startNode) + private static SortedList ReadRowHeightList (XmlElement startNode) + { + SortedList rowHeightList = []; + XmlNode rowHeightsNode = startNode.SelectSingleNode("rowheights"); + if (rowHeightsNode != null) { - SortedList rowHeightList = []; - XmlNode rowHeightsNode = startNode.SelectSingleNode("rowheights"); - if (rowHeightsNode != null) + XmlNodeList rowHeightNodeList = rowHeightsNode.ChildNodes; // all "rowheight" nodes + foreach (XmlNode node in rowHeightNodeList) { - XmlNodeList rowHeightNodeList = rowHeightsNode.ChildNodes; // all "rowheight" nodes - foreach (XmlNode node in rowHeightNodeList) + string height = null; + string line = null; + foreach (XmlAttribute attr in node.Attributes) { - string height = null; - string line = null; - foreach (XmlAttribute attr in node.Attributes) + if (attr.Name.Equals("line")) { - if (attr.Name.Equals("line")) - { - line = attr.InnerText; - } - else if (attr.Name.Equals("height")) - { - height = attr.InnerText; - } + line = attr.InnerText; + } + else if (attr.Name.Equals("height")) + { + height = attr.InnerText; } - var lineNum = int.Parse(line); - var heightValue = int.Parse(height); - rowHeightList.Add(lineNum, new RowHeightEntry(lineNum, heightValue)); } + var lineNum = int.Parse(line); + var heightValue = int.Parse(height); + rowHeightList.Add(lineNum, new RowHeightEntry(lineNum, heightValue)); } - return rowHeightList; } + return rowHeightList; + } - private static void WriteOptions(XmlDocument xmlDoc, XmlElement rootElement, PersistenceData persistenceData) + private static void WriteOptions (XmlDocument xmlDoc, XmlElement rootElement, PersistenceData persistenceData) + { + XmlElement optionsElement = xmlDoc.CreateElement("options"); + rootElement.AppendChild(optionsElement); + + XmlElement element = xmlDoc.CreateElement("multifile"); + element.SetAttribute("enabled", persistenceData.multiFile ? "1" : "0"); + element.SetAttribute("pattern", persistenceData.multiFilePattern); + element.SetAttribute("maxDays", "" + persistenceData.multiFileMaxDays); + foreach (var fileName in persistenceData.multiFileNames) { - XmlElement optionsElement = xmlDoc.CreateElement("options"); - rootElement.AppendChild(optionsElement); - - XmlElement element = xmlDoc.CreateElement("multifile"); - element.SetAttribute("enabled", persistenceData.multiFile ? "1" : "0"); - element.SetAttribute("pattern", persistenceData.multiFilePattern); - element.SetAttribute("maxDays", "" + persistenceData.multiFileMaxDays); - foreach (var fileName in persistenceData.multiFileNames) - { - XmlElement entryElement = xmlDoc.CreateElement("fileEntry"); - entryElement.SetAttribute("fileName", "" + fileName); - element.AppendChild(entryElement); - } - optionsElement.AppendChild(element); - - element = xmlDoc.CreateElement("currentline"); - element.SetAttribute("line", "" + persistenceData.currentLine); - optionsElement.AppendChild(element); - - element = xmlDoc.CreateElement("firstDisplayedLine"); - element.SetAttribute("line", "" + persistenceData.firstDisplayedLine); - optionsElement.AppendChild(element); - - element = xmlDoc.CreateElement("filter"); - element.SetAttribute("visible", persistenceData.filterVisible ? "1" : "0"); - element.SetAttribute("advanced", persistenceData.filterAdvanced ? "1" : "0"); - element.SetAttribute("position", "" + persistenceData.filterPosition); - optionsElement.AppendChild(element); - - element = xmlDoc.CreateElement("bookmarklist"); - element.SetAttribute("visible", persistenceData.bookmarkListVisible ? "1" : "0"); - element.SetAttribute("position", "" + persistenceData.bookmarkListPosition); - optionsElement.AppendChild(element); - - element = xmlDoc.CreateElement("followTail"); - element.SetAttribute("enabled", persistenceData.followTail ? "1" : "0"); - optionsElement.AppendChild(element); - - element = xmlDoc.CreateElement("tab"); - element.SetAttribute("name", persistenceData.tabName); - rootElement.AppendChild(element); - - element = xmlDoc.CreateElement("columnizer"); - element.SetAttribute("name", persistenceData.columnizerName); - rootElement.AppendChild(element); - - element = xmlDoc.CreateElement("highlightGroup"); - element.SetAttribute("name", persistenceData.highlightGroupName); - rootElement.AppendChild(element); - - element = xmlDoc.CreateElement("bookmarkCommentColumn"); - element.SetAttribute("visible", persistenceData.showBookmarkCommentColumn ? "1" : "0"); - optionsElement.AppendChild(element); - - element = xmlDoc.CreateElement("filterSaveList"); - element.SetAttribute("visible", persistenceData.filterSaveListVisible ? "1" : "0"); - optionsElement.AppendChild(element); + XmlElement entryElement = xmlDoc.CreateElement("fileEntry"); + entryElement.SetAttribute("fileName", "" + fileName); + element.AppendChild(entryElement); } + optionsElement.AppendChild(element); + + element = xmlDoc.CreateElement("currentline"); + element.SetAttribute("line", "" + persistenceData.currentLine); + optionsElement.AppendChild(element); + + element = xmlDoc.CreateElement("firstDisplayedLine"); + element.SetAttribute("line", "" + persistenceData.firstDisplayedLine); + optionsElement.AppendChild(element); + + element = xmlDoc.CreateElement("filter"); + element.SetAttribute("visible", persistenceData.filterVisible ? "1" : "0"); + element.SetAttribute("advanced", persistenceData.filterAdvanced ? "1" : "0"); + element.SetAttribute("position", "" + persistenceData.filterPosition); + optionsElement.AppendChild(element); + + element = xmlDoc.CreateElement("bookmarklist"); + element.SetAttribute("visible", persistenceData.bookmarkListVisible ? "1" : "0"); + element.SetAttribute("position", "" + persistenceData.bookmarkListPosition); + optionsElement.AppendChild(element); + + element = xmlDoc.CreateElement("followTail"); + element.SetAttribute("enabled", persistenceData.followTail ? "1" : "0"); + optionsElement.AppendChild(element); + + element = xmlDoc.CreateElement("tab"); + element.SetAttribute("name", persistenceData.tabName); + rootElement.AppendChild(element); + + element = xmlDoc.CreateElement("columnizer"); + element.SetAttribute("name", persistenceData.columnizerName); + rootElement.AppendChild(element); + + element = xmlDoc.CreateElement("highlightGroup"); + element.SetAttribute("name", persistenceData.highlightGroupName); + rootElement.AppendChild(element); + + element = xmlDoc.CreateElement("bookmarkCommentColumn"); + element.SetAttribute("visible", persistenceData.showBookmarkCommentColumn ? "1" : "0"); + optionsElement.AppendChild(element); + + element = xmlDoc.CreateElement("filterSaveList"); + element.SetAttribute("visible", persistenceData.filterSaveListVisible ? "1" : "0"); + optionsElement.AppendChild(element); + } - private static void ReadOptions(XmlElement startNode, PersistenceData persistenceData) + private static void ReadOptions (XmlElement startNode, PersistenceData persistenceData) + { + XmlNode optionsNode = startNode.SelectSingleNode("options"); + var value = GetOptionsAttribute(optionsNode, "multifile", "enabled"); + persistenceData.multiFile = value != null && value.Equals("1"); + persistenceData.multiFilePattern = GetOptionsAttribute(optionsNode, "multifile", "pattern"); + value = GetOptionsAttribute(optionsNode, "multifile", "maxDays"); + try { - XmlNode optionsNode = startNode.SelectSingleNode("options"); - var value = GetOptionsAttribute(optionsNode, "multifile", "enabled"); - persistenceData.multiFile = value != null && value.Equals("1"); - persistenceData.multiFilePattern = GetOptionsAttribute(optionsNode, "multifile", "pattern"); - value = GetOptionsAttribute(optionsNode, "multifile", "maxDays"); - try - { - persistenceData.multiFileMaxDays = value != null ? short.Parse(value) : 0; - } - catch (Exception) - { - persistenceData.multiFileMaxDays = 0; - } + persistenceData.multiFileMaxDays = value != null ? short.Parse(value) : 0; + } + catch (Exception) + { + persistenceData.multiFileMaxDays = 0; + } - XmlNode multiFileNode = optionsNode.SelectSingleNode("multifile"); - if (multiFileNode != null) + XmlNode multiFileNode = optionsNode.SelectSingleNode("multifile"); + if (multiFileNode != null) + { + XmlNodeList multiFileNodeList = multiFileNode.ChildNodes; // all "fileEntry" nodes + foreach (XmlNode node in multiFileNodeList) { - XmlNodeList multiFileNodeList = multiFileNode.ChildNodes; // all "fileEntry" nodes - foreach (XmlNode node in multiFileNodeList) + string fileName = null; + foreach (XmlAttribute attr in node.Attributes) { - string fileName = null; - foreach (XmlAttribute attr in node.Attributes) + if (attr.Name.Equals("fileName")) { - if (attr.Name.Equals("fileName")) - { - fileName = attr.InnerText; - } + fileName = attr.InnerText; } - persistenceData.multiFileNames.Add(fileName); } + persistenceData.multiFileNames.Add(fileName); } + } - value = GetOptionsAttribute(optionsNode, "currentline", "line"); - if (value != null) - { - persistenceData.currentLine = int.Parse(value); - } - value = GetOptionsAttribute(optionsNode, "firstDisplayedLine", "line"); - if (value != null) - { - persistenceData.firstDisplayedLine = int.Parse(value); - } + value = GetOptionsAttribute(optionsNode, "currentline", "line"); + if (value != null) + { + persistenceData.currentLine = int.Parse(value); + } + value = GetOptionsAttribute(optionsNode, "firstDisplayedLine", "line"); + if (value != null) + { + persistenceData.firstDisplayedLine = int.Parse(value); + } - value = GetOptionsAttribute(optionsNode, "filter", "visible"); - persistenceData.filterVisible = value != null && value.Equals("1"); - value = GetOptionsAttribute(optionsNode, "filter", "advanced"); - persistenceData.filterAdvanced = value != null && value.Equals("1"); - value = GetOptionsAttribute(optionsNode, "filter", "position"); - if (value != null) - { - persistenceData.filterPosition = int.Parse(value); - } + value = GetOptionsAttribute(optionsNode, "filter", "visible"); + persistenceData.filterVisible = value != null && value.Equals("1"); + value = GetOptionsAttribute(optionsNode, "filter", "advanced"); + persistenceData.filterAdvanced = value != null && value.Equals("1"); + value = GetOptionsAttribute(optionsNode, "filter", "position"); + if (value != null) + { + persistenceData.filterPosition = int.Parse(value); + } - value = GetOptionsAttribute(optionsNode, "bookmarklist", "visible"); - persistenceData.bookmarkListVisible = value != null && value.Equals("1"); - value = GetOptionsAttribute(optionsNode, "bookmarklist", "position"); - if (value != null) - { - persistenceData.bookmarkListPosition = int.Parse(value); - } + value = GetOptionsAttribute(optionsNode, "bookmarklist", "visible"); + persistenceData.bookmarkListVisible = value != null && value.Equals("1"); + value = GetOptionsAttribute(optionsNode, "bookmarklist", "position"); + if (value != null) + { + persistenceData.bookmarkListPosition = int.Parse(value); + } - value = GetOptionsAttribute(optionsNode, "followTail", "enabled"); - persistenceData.followTail = value != null && value.Equals("1"); + value = GetOptionsAttribute(optionsNode, "followTail", "enabled"); + persistenceData.followTail = value != null && value.Equals("1"); - value = GetOptionsAttribute(optionsNode, "bookmarkCommentColumn", "visible"); - persistenceData.showBookmarkCommentColumn = value != null && value.Equals("1"); + value = GetOptionsAttribute(optionsNode, "bookmarkCommentColumn", "visible"); + persistenceData.showBookmarkCommentColumn = value != null && value.Equals("1"); - value = GetOptionsAttribute(optionsNode, "filterSaveList", "visible"); - persistenceData.filterSaveListVisible = value != null && value.Equals("1"); + value = GetOptionsAttribute(optionsNode, "filterSaveList", "visible"); + persistenceData.filterSaveListVisible = value != null && value.Equals("1"); - XmlNode tabNode = startNode.SelectSingleNode("tab"); - if (tabNode != null) - { - persistenceData.tabName = (tabNode as XmlElement).GetAttribute("name"); - } - XmlNode columnizerNode = startNode.SelectSingleNode("columnizer"); - if (columnizerNode != null) - { - persistenceData.columnizerName = (columnizerNode as XmlElement).GetAttribute("name"); - } - XmlNode highlightGroupNode = startNode.SelectSingleNode("highlightGroup"); - if (highlightGroupNode != null) - { - persistenceData.highlightGroupName = (highlightGroupNode as XmlElement).GetAttribute("name"); - } + XmlNode tabNode = startNode.SelectSingleNode("tab"); + if (tabNode != null) + { + persistenceData.tabName = (tabNode as XmlElement).GetAttribute("name"); + } + XmlNode columnizerNode = startNode.SelectSingleNode("columnizer"); + if (columnizerNode != null) + { + persistenceData.columnizerName = (columnizerNode as XmlElement).GetAttribute("name"); } + XmlNode highlightGroupNode = startNode.SelectSingleNode("highlightGroup"); + if (highlightGroupNode != null) + { + persistenceData.highlightGroupName = (highlightGroupNode as XmlElement).GetAttribute("name"); + } + } - private static string GetOptionsAttribute(XmlNode optionsNode, string elementName, string attrName) + private static string GetOptionsAttribute (XmlNode optionsNode, string elementName, string attrName) + { + XmlNode node = optionsNode.SelectSingleNode(elementName); + if (node == null) { - XmlNode node = optionsNode.SelectSingleNode(elementName); - if (node == null) - { - return null; - } - if (node is XmlElement) - { - var value = (node as XmlElement).GetAttribute(attrName); - return value; - } - else - { - return null; - } + return null; + } + if (node is XmlElement) + { + var value = (node as XmlElement).GetAttribute(attrName); + return value; + } + else + { + return null; } - - #endregion } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Persister/ProjectData.cs b/src/LogExpert.Core/Classes/Persister/ProjectData.cs index b1fad7c5..8b9dcaf3 100644 --- a/src/LogExpert.Core/Classes/Persister/ProjectData.cs +++ b/src/LogExpert.Core/Classes/Persister/ProjectData.cs @@ -1,14 +1,12 @@ -using System.Collections.Generic; +namespace LogExpert.Core.Classes.Persister; -namespace LogExpert.Core.Classes.Persister +public class ProjectData { - public class ProjectData - { - #region Fields + #region Fields - public List memberList = []; - public string tabLayoutXml; + public List MemberList { get; set; } = []; - #endregion - } + public string TabLayoutXml { get; set; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Persister/ProjectPersister.cs b/src/LogExpert.Core/Classes/Persister/ProjectPersister.cs index cbbb1ee1..12963b28 100644 --- a/src/LogExpert.Core/Classes/Persister/ProjectPersister.cs +++ b/src/LogExpert.Core/Classes/Persister/ProjectPersister.cs @@ -1,68 +1,67 @@ using System.Collections.Generic; using System.Xml; -namespace LogExpert.Core.Classes.Persister +namespace LogExpert.Core.Classes.Persister; + +public static class ProjectPersister { - public static class ProjectPersister - { - #region Public methods + #region Public methods - public static ProjectData LoadProjectData(string projectFileName) + public static ProjectData LoadProjectData(string projectFileName) + { + ProjectData projectData = new(); + XmlDocument xmlDoc = new(); + xmlDoc.Load(projectFileName); + XmlNodeList fileList = xmlDoc.GetElementsByTagName("member"); + foreach (XmlNode fileNode in fileList) { - ProjectData projectData = new(); - XmlDocument xmlDoc = new(); - xmlDoc.Load(projectFileName); - XmlNodeList fileList = xmlDoc.GetElementsByTagName("member"); - foreach (XmlNode fileNode in fileList) - { - var fileElement = fileNode as XmlElement; - var fileName = fileElement.GetAttribute("fileName"); - projectData.memberList.Add(fileName); - } - XmlNodeList layoutElements = xmlDoc.GetElementsByTagName("layout"); - if (layoutElements.Count > 0) - { - projectData.tabLayoutXml = layoutElements[0].InnerXml; - } - return projectData; + var fileElement = fileNode as XmlElement; + var fileName = fileElement.GetAttribute("fileName"); + projectData.MemberList.Add(fileName); } - - - public static void SaveProjectData(string projectFileName, ProjectData projectData) + XmlNodeList layoutElements = xmlDoc.GetElementsByTagName("layout"); + if (layoutElements.Count > 0) { - XmlDocument xmlDoc = new(); - XmlElement rootElement = xmlDoc.CreateElement("logexpert"); - xmlDoc.AppendChild(rootElement); - XmlElement projectElement = xmlDoc.CreateElement("project"); - rootElement.AppendChild(projectElement); - XmlElement membersElement = xmlDoc.CreateElement("members"); - projectElement.AppendChild(membersElement); - SaveProjectMembers(xmlDoc, membersElement, projectData.memberList); + projectData.TabLayoutXml = layoutElements[0].InnerXml; + } + return projectData; + } - if (projectData.tabLayoutXml != null) - { - XmlElement layoutElement = xmlDoc.CreateElement("layout"); - layoutElement.InnerXml = projectData.tabLayoutXml; - rootElement.AppendChild(layoutElement); - } - xmlDoc.Save(projectFileName); + public static void SaveProjectData(string projectFileName, ProjectData projectData) + { + XmlDocument xmlDoc = new(); + XmlElement rootElement = xmlDoc.CreateElement("logexpert"); + xmlDoc.AppendChild(rootElement); + XmlElement projectElement = xmlDoc.CreateElement("project"); + rootElement.AppendChild(projectElement); + XmlElement membersElement = xmlDoc.CreateElement("members"); + projectElement.AppendChild(membersElement); + SaveProjectMembers(xmlDoc, membersElement, projectData.MemberList); + + if (projectData.TabLayoutXml != null) + { + XmlElement layoutElement = xmlDoc.CreateElement("layout"); + layoutElement.InnerXml = projectData.TabLayoutXml; + rootElement.AppendChild(layoutElement); } - #endregion + xmlDoc.Save(projectFileName); + } + + #endregion - #region Private Methods + #region Private Methods - private static void SaveProjectMembers(XmlDocument xmlDoc, XmlNode membersNode, List memberList) + private static void SaveProjectMembers(XmlDocument xmlDoc, XmlNode membersNode, List memberList) + { + foreach (var fileName in memberList) { - foreach (var fileName in memberList) - { - XmlElement memberElement = xmlDoc.CreateElement("member"); - membersNode.AppendChild(memberElement); - memberElement.SetAttribute("fileName", fileName); - } + XmlElement memberElement = xmlDoc.CreateElement("member"); + membersNode.AppendChild(memberElement); + memberElement.SetAttribute("fileName", fileName); } - - #endregion } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/SpreadEntry.cs b/src/LogExpert.Core/Classes/SpreadEntry.cs index f83c81c2..090c4847 100644 --- a/src/LogExpert.Core/Classes/SpreadEntry.cs +++ b/src/LogExpert.Core/Classes/SpreadEntry.cs @@ -1,28 +1,27 @@ -namespace LogExpert.Core.Classes -{ - public class SpreadEntry - { - #region Fields +namespace LogExpert.Core.Classes; - public int Diff { get; set; } +public class SpreadEntry +{ + #region Fields - public DateTime Timestamp { get; set; } + public int Diff { get; set; } - public int LineNum { get; set; } + public DateTime Timestamp { get; set; } - public int Value { get; set; } + public int LineNum { get; set; } - #endregion + public int Value { get; set; } - #region cTor + #endregion - public SpreadEntry(int lineNum, int diff, DateTime timestamp) - { - LineNum = lineNum; - Diff = diff; - Timestamp = timestamp; - } + #region cTor - #endregion + public SpreadEntry(int lineNum, int diff, DateTime timestamp) + { + LineNum = lineNum; + Diff = diff; + Timestamp = timestamp; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/SysoutPipe.cs b/src/LogExpert.Core/Classes/SysoutPipe.cs index 763f368b..86460221 100644 --- a/src/LogExpert.Core/Classes/SysoutPipe.cs +++ b/src/LogExpert.Core/Classes/SysoutPipe.cs @@ -3,94 +3,93 @@ using System.Diagnostics; using System.Text; -namespace LogExpert.Core.Classes +namespace LogExpert.Core.Classes; + +public class SysoutPipe { - public class SysoutPipe - { - #region Fields + #region Fields - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - private readonly StreamReader sysout; - private StreamWriter writer; + private readonly StreamReader sysout; + private StreamWriter writer; - #endregion + #endregion - #region cTor + #region cTor - public SysoutPipe(StreamReader sysout) - { - this.sysout = sysout; - FileName = Path.GetTempFileName(); - _logger.Info("sysoutPipe created temp file: {0}", FileName); + public SysoutPipe(StreamReader sysout) + { + this.sysout = sysout; + FileName = Path.GetTempFileName(); + _logger.Info("sysoutPipe created temp file: {0}", FileName); - FileStream fStream = new(FileName, FileMode.Append, FileAccess.Write, FileShare.Read); - writer = new StreamWriter(fStream, Encoding.Unicode); + FileStream fStream = new(FileName, FileMode.Append, FileAccess.Write, FileShare.Read); + writer = new StreamWriter(fStream, Encoding.Unicode); - Thread thread = new(new ThreadStart(ReaderThread)) - { - IsBackground = true - }; - thread.Start(); - } + Thread thread = new(new ThreadStart(ReaderThread)) + { + IsBackground = true + }; + thread.Start(); + } - #endregion + #endregion - #region Properties + #region Properties - public string FileName { get; } + public string FileName { get; } - #endregion + #endregion - #region Public methods + #region Public methods - public void ClosePipe() - { - writer.Close(); - writer = null; - } + public void ClosePipe() + { + writer.Close(); + writer = null; + } - public void DataReceivedEventHandler(object sender, DataReceivedEventArgs e) - { - writer.WriteLine(e.Data); - } + public void DataReceivedEventHandler(object sender, DataReceivedEventArgs e) + { + writer.WriteLine(e.Data); + } - public void ProcessExitedEventHandler(object sender, System.EventArgs e) + public void ProcessExitedEventHandler(object sender, System.EventArgs e) + { + //ClosePipe(); + if (sender.GetType() == typeof(Process)) { - //ClosePipe(); - if (sender.GetType() == typeof(Process)) - { - ((Process)sender).Exited -= ProcessExitedEventHandler; - ((Process)sender).OutputDataReceived -= DataReceivedEventHandler; - } + ((Process)sender).Exited -= ProcessExitedEventHandler; + ((Process)sender).OutputDataReceived -= DataReceivedEventHandler; } + } - #endregion + #endregion - protected void ReaderThread() - { - var buff = new char[256]; + protected void ReaderThread() + { + var buff = new char[256]; - while (true) + while (true) + { + try { - try - { - var read = sysout.Read(buff, 0, 256); - if (read == 0) - { - break; - } - writer.Write(buff, 0, read); - } - catch (IOException e) + var read = sysout.Read(buff, 0, 256); + if (read == 0) { - _logger.Error(e); break; } + writer.Write(buff, 0, read); + } + catch (IOException e) + { + _logger.Error(e); + break; } - - ClosePipe(); } + + ClosePipe(); } } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/UsedComponents.cs b/src/LogExpert.Core/Classes/UsedComponents.cs index 39e176f4..6f62b6cd 100644 --- a/src/LogExpert.Core/Classes/UsedComponents.cs +++ b/src/LogExpert.Core/Classes/UsedComponents.cs @@ -1,20 +1,19 @@ -namespace LogExpert.Core.Classes +namespace LogExpert.Core.Classes; + +[Serializable] +public class UsedComponents { - [Serializable] - public class UsedComponents - { - public string PackageId { get; set; } + public string PackageId { get; set; } - public string PackageVersion { get; set; } + public string PackageVersion { get; set; } - public string PackageProjectUrl { get; set; } + public string PackageProjectUrl { get; set; } - public string Copyright { get; set; } + public string Copyright { get; set; } - public string Authors { get; set; } + public string Authors { get; set; } - public string License { get; set; } + public string License { get; set; } - public string LicenseUrl { get; set; } - } + public string LicenseUrl { get; set; } } diff --git a/src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs b/src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs index ccc0b9f8..469f5ab2 100644 --- a/src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs +++ b/src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs @@ -4,167 +4,166 @@ using System.Xml; using System.Xml.Xsl; -namespace LogExpert.Core.Classes.xml -{ - public class XmlBlockSplitter : LogStreamReaderBase - { - #region Fields - - private static readonly string[] _splitStrings = { "\r\n", "\n", "\r" }; +namespace LogExpert.Core.Classes.xml; - private static readonly char[] _newLineChar = { '\n' }; - - private readonly XmlLogReader _reader; +public class XmlBlockSplitter : LogStreamReaderBase +{ + #region Fields - private readonly XmlParserContext _context; - private readonly XmlReaderSettings _settings; + private static readonly string[] _splitStrings = ["\r\n", "\n", "\r"]; - private readonly Queue _lineList = new(); + private static readonly char[] _newLineChar = ['\n']; - private string _stylesheet; - private XslCompiledTransform _xslt; + private readonly XmlLogReader _reader; - #endregion + private readonly XmlParserContext _context; + private readonly XmlReaderSettings _settings; - #region cTor + private readonly Queue _lineList = new(); - public XmlBlockSplitter(XmlLogReader reader, IXmlLogConfiguration xmlLogConfig) - { - _reader = reader; - _reader.StartTag = xmlLogConfig.XmlStartTag; - _reader.EndTag = xmlLogConfig.XmlEndTag; + private string _stylesheet; + private XslCompiledTransform _xslt; - Stylesheet = xmlLogConfig.Stylesheet; + #endregion - // Create the XmlNamespaceManager. - NameTable nt = new(); - XmlNamespaceManager nsmgr = new(nt); - if (xmlLogConfig.Namespace != null) - { - nsmgr.AddNamespace(xmlLogConfig.Namespace[0], xmlLogConfig.Namespace[1]); - } - // Create the XmlParserContext. - _context = new XmlParserContext(nt, nsmgr, null, XmlSpace.None); - _settings = new XmlReaderSettings(); - _settings.ConformanceLevel = ConformanceLevel.Fragment; - } + #region cTor - #endregion + public XmlBlockSplitter(XmlLogReader reader, IXmlLogConfiguration xmlLogConfig) + { + _reader = reader; + _reader.StartTag = xmlLogConfig.XmlStartTag; + _reader.EndTag = xmlLogConfig.XmlEndTag; - #region Properties + Stylesheet = xmlLogConfig.Stylesheet; - public override long Position + // Create the XmlNamespaceManager. + NameTable nt = new(); + XmlNamespaceManager nsmgr = new(nt); + if (xmlLogConfig.Namespace != null) { - get => _reader.Position; - set => _reader.Position = value; + nsmgr.AddNamespace(xmlLogConfig.Namespace[0], xmlLogConfig.Namespace[1]); } + // Create the XmlParserContext. + _context = new XmlParserContext(nt, nsmgr, null, XmlSpace.None); + _settings = new XmlReaderSettings(); + _settings.ConformanceLevel = ConformanceLevel.Fragment; + } - public override Encoding Encoding => _reader.Encoding; + #endregion - public override bool IsBufferComplete => _lineList.Count == 0; + #region Properties - public string Stylesheet - { - get => _stylesheet; - set - { - _stylesheet = value; - if (_stylesheet != null) - { - var stylesheetReader = XmlReader.Create(new StringReader(_stylesheet)); - - _xslt = new XslCompiledTransform(); - _xslt.Load(stylesheetReader); - } - else - { - _xslt = null; - } - } - } + public override long Position + { + get => _reader.Position; + set => _reader.Position = value; + } - #endregion + public override Encoding Encoding => _reader.Encoding; - #region Private Methods + public override bool IsBufferComplete => _lineList.Count == 0; - private void ParseXmlBlock(string block) + public string Stylesheet + { + get => _stylesheet; + set { + _stylesheet = value; if (_stylesheet != null) { - var xmlReader = XmlReader.Create(new StringReader(block), _settings, _context); + var stylesheetReader = XmlReader.Create(new StringReader(_stylesheet)); - xmlReader.Read(); - xmlReader.MoveToContent(); - //xmlReader.MoveToContent(); - StringWriter textWriter = new(); - - _xslt.Transform(xmlReader, null, textWriter); - var message = textWriter.ToString(); - SplitToLinesList(message); + _xslt = new XslCompiledTransform(); + _xslt.Load(stylesheetReader); } else { - SplitToLinesList(block); - //this.lineList.Add(block); // TODO: make configurable, if block has to be splitted + _xslt = null; } } + } + + #endregion - private void SplitToLinesList(string message) + #region Private Methods + + private void ParseXmlBlock(string block) + { + if (_stylesheet != null) { - const int MAX_LEN = 3000; - var lines = message.Split(_splitStrings, StringSplitOptions.None); - foreach (var theLine in lines) - { - var line = theLine.Trim(_newLineChar); - while (line.Length > MAX_LEN) - { - var part = line.Substring(0, MAX_LEN); - line = line.Substring(MAX_LEN); - _lineList.Enqueue(part); - } - _lineList.Enqueue(line); - } - } + var xmlReader = XmlReader.Create(new StringReader(block), _settings, _context); - #endregion + xmlReader.Read(); + xmlReader.MoveToContent(); + //xmlReader.MoveToContent(); + StringWriter textWriter = new(); - #region Public Methods + _xslt.Transform(xmlReader, null, textWriter); + var message = textWriter.ToString(); + SplitToLinesList(message); + } + else + { + SplitToLinesList(block); + //this.lineList.Add(block); // TODO: make configurable, if block has to be splitted + } + } - protected override void Dispose(bool disposing) + private void SplitToLinesList(string message) + { + const int MAX_LEN = 3000; + var lines = message.Split(_splitStrings, StringSplitOptions.None); + foreach (var theLine in lines) { - if (disposing) + var line = theLine.Trim(_newLineChar); + while (line.Length > MAX_LEN) { - _reader.Dispose(); + var part = line.Substring(0, MAX_LEN); + line = line.Substring(MAX_LEN); + _lineList.Enqueue(part); } + _lineList.Enqueue(line); } + } + + #endregion - public override int ReadChar() + #region Public Methods + + protected override void Dispose(bool disposing) + { + if (disposing) { - return _reader.ReadChar(); + _reader.Dispose(); } + } - public override string ReadLine() + public override int ReadChar() + { + return _reader.ReadChar(); + } + + public override string ReadLine() + { + if (_lineList.Count == 0) { - if (_lineList.Count == 0) + var block = _reader.ReadLine(); + if (block == null) { - var block = _reader.ReadLine(); - if (block == null) - { - return null; - } - - try - { - ParseXmlBlock(block); - } - catch (XmlException) - { - _lineList.Enqueue("[XML Parser error] " + block); - } + return null; } - return _lineList.Dequeue(); - } - #endregion + try + { + ParseXmlBlock(block); + } + catch (XmlException) + { + _lineList.Enqueue("[XML Parser error] " + block); + } + } + return _lineList.Dequeue(); } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/xml/XmlLogReader.cs b/src/LogExpert.Core/Classes/xml/XmlLogReader.cs index b5d21839..9334cbbd 100644 --- a/src/LogExpert.Core/Classes/xml/XmlLogReader.cs +++ b/src/LogExpert.Core/Classes/xml/XmlLogReader.cs @@ -3,167 +3,166 @@ using System.Text; -namespace LogExpert.Core.Classes.xml +namespace LogExpert.Core.Classes.xml; + +public class XmlLogReader : LogStreamReaderBase { - public class XmlLogReader : LogStreamReaderBase - { - #region Fields + #region Fields - private readonly ILogStreamReader reader; + private readonly ILogStreamReader reader; - #endregion + #endregion - #region cTor + #region cTor - public XmlLogReader(ILogStreamReader reader) - { - this.reader = reader; - } + public XmlLogReader(ILogStreamReader reader) + { + this.reader = reader; + } - #endregion + #endregion - #region Properties + #region Properties - public override long Position - { - get => reader.Position; - set => reader.Position = value; - } + public override long Position + { + get => reader.Position; + set => reader.Position = value; + } - public override Encoding Encoding => reader.Encoding; + public override Encoding Encoding => reader.Encoding; - public override bool IsBufferComplete => reader.IsBufferComplete; + public override bool IsBufferComplete => reader.IsBufferComplete; - public string StartTag { get; set; } = " 0) { - if (--tryCounter > 0) - { - Thread.Sleep(100); - continue; - } - else - { - break; - } + Thread.Sleep(100); + continue; } else { break; } } - - var readChar = (char)readInt; - // state: - // 0 = looking for tag start - // 1 = reading into buffer as long as the read data matches the start tag - // 2 = reading into buffer while waiting for the begin of the end tag - // 3 = reading into buffer as long as data matches the end tag. stopping when tag complete - switch (state) + else { - case 0: - if (readChar == StartTag[0]) - { - //_logger.logInfo("state = 1"); - state = 1; - tagIndex = 1; - builder.Append(readChar); - } - //else - //{ - // _logger.logInfo("char: " + readChar); - //} - break; - case 1: - if (readChar == StartTag[tagIndex]) - { - builder.Append(readChar); - - if (++tagIndex >= StartTag.Length) - { - //_logger.logInfo("state = 2"); - state = 2; // start Tag complete - tagIndex = 0; - } - } - else - { - // tag doesn't match anymore - //_logger.logInfo("state = 0 [" + buffer.ToString() + readChar + "]"); - state = 0; - builder.Clear(); - } - break; - case 2: - builder.Append(readChar); + break; + } + } - if (readChar == EndTag[0]) - { - //_logger.logInfo("state = 3"); - state = 3; - tagIndex = 1; - } - break; - case 3: + var readChar = (char)readInt; + // state: + // 0 = looking for tag start + // 1 = reading into buffer as long as the read data matches the start tag + // 2 = reading into buffer while waiting for the begin of the end tag + // 3 = reading into buffer as long as data matches the end tag. stopping when tag complete + switch (state) + { + case 0: + if (readChar == StartTag[0]) + { + //_logger.logInfo("state = 1"); + state = 1; + tagIndex = 1; + builder.Append(readChar); + } + //else + //{ + // _logger.logInfo("char: " + readChar); + //} + break; + case 1: + if (readChar == StartTag[tagIndex]) + { builder.Append(readChar); - if (readChar == EndTag[tagIndex]) + if (++tagIndex >= StartTag.Length) { - tagIndex++; - if (tagIndex >= EndTag.Length) - { - blockComplete = true; - break; - } + //_logger.logInfo("state = 2"); + state = 2; // start Tag complete + tagIndex = 0; } - else + } + else + { + // tag doesn't match anymore + //_logger.logInfo("state = 0 [" + buffer.ToString() + readChar + "]"); + state = 0; + builder.Clear(); + } + break; + case 2: + builder.Append(readChar); + + if (readChar == EndTag[0]) + { + //_logger.logInfo("state = 3"); + state = 3; + tagIndex = 1; + } + break; + case 3: + builder.Append(readChar); + + if (readChar == EndTag[tagIndex]) + { + tagIndex++; + if (tagIndex >= EndTag.Length) { - //_logger.logInfo("state = 2"); - state = 2; + blockComplete = true; + break; } - break; - } + } + else + { + //_logger.logInfo("state = 2"); + state = 2; + } + break; } - - return blockComplete ? builder.ToString() : null; } - #endregion + return blockComplete ? builder.ToString() : null; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Config/ColorEntry.cs b/src/LogExpert.Core/Config/ColorEntry.cs index 6a2dc251..ceeaf244 100644 --- a/src/LogExpert.Core/Config/ColorEntry.cs +++ b/src/LogExpert.Core/Config/ColorEntry.cs @@ -4,27 +4,26 @@ #endregion -namespace LogExpert.Core.Config +namespace LogExpert.Core.Config; + +[Serializable] +public class ColorEntry { - [Serializable] - public class ColorEntry - { - #region cTor + #region cTor - public ColorEntry(string fileName, Color color) - { - FileName = fileName; - Color = color; - } + public ColorEntry(string fileName, Color color) + { + FileName = fileName; + Color = color; + } - #endregion + #endregion - public Color Color { get; } + public Color Color { get; } - public string FileName { get; } + public string FileName { get; } - #region Fields + #region Fields - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Config/ColorMode.cs b/src/LogExpert.Core/Config/ColorMode.cs index ac7c3690..b8297b95 100644 --- a/src/LogExpert.Core/Config/ColorMode.cs +++ b/src/LogExpert.Core/Config/ColorMode.cs @@ -1,78 +1,77 @@ using System.Drawing; using System.Runtime.InteropServices; -namespace LogExpert.Core.Config +namespace LogExpert.Core.Config; + +public static class ColorMode { - public static class ColorMode - { - // Bright Theme - // https://paletton.com/#uid=15-0u0k00sH00kJ0pq+00RL00RL - private static readonly Color BrightBookmarkDefaultSystemColor = SystemColors.Control; // Important: only supports SystemColors - private static readonly Color LessBrightBackgroundColor = Color.FromArgb(208, 205, 206); - private static readonly Color BrightBackgroundColor = Color.FromArgb(221, 221, 221); - private static readonly Color BrighterBackgroundColor = Color.FromArgb(253, 253, 253); - private static readonly Color BrightForeColor = Color.FromArgb(0, 0, 0); + // Bright Theme + // https://paletton.com/#uid=15-0u0k00sH00kJ0pq+00RL00RL + private static readonly Color BrightBookmarkDefaultSystemColor = SystemColors.Control; // Important: only supports SystemColors + private static readonly Color LessBrightBackgroundColor = Color.FromArgb(208, 205, 206); + private static readonly Color BrightBackgroundColor = Color.FromArgb(221, 221, 221); + private static readonly Color BrighterBackgroundColor = Color.FromArgb(253, 253, 253); + private static readonly Color BrightForeColor = Color.FromArgb(0, 0, 0); - // Dark Theme - // https://paletton.com/#uid=15-0u0k005U0670008J003Y003Y - private static readonly Color DarkBookmarkDefaultSystemColor = SystemColors.ControlDarkDark; // Important: only supports SystemColors - private static readonly Color LessLessDarkBackgroundColor = Color.FromArgb(90, 90, 90); - private static readonly Color LessDarkBackgroundColor = Color.FromArgb(67, 67, 67); - private static readonly Color DarkBackgroundColor = Color.FromArgb(45, 45, 45); - private static readonly Color DarkerBackgroundColor = Color.FromArgb(30, 30, 30); - private static readonly Color DarkForeColor = Color.FromArgb(255, 255, 255); + // Dark Theme + // https://paletton.com/#uid=15-0u0k005U0670008J003Y003Y + private static readonly Color DarkBookmarkDefaultSystemColor = SystemColors.ControlDarkDark; // Important: only supports SystemColors + private static readonly Color LessLessDarkBackgroundColor = Color.FromArgb(90, 90, 90); + private static readonly Color LessDarkBackgroundColor = Color.FromArgb(67, 67, 67); + private static readonly Color DarkBackgroundColor = Color.FromArgb(45, 45, 45); + private static readonly Color DarkerBackgroundColor = Color.FromArgb(30, 30, 30); + private static readonly Color DarkForeColor = Color.FromArgb(255, 255, 255); - // Default - public static Color BackgroundColor = BrightBackgroundColor; - public static Color DockBackgroundColor = BrighterBackgroundColor; - public static Color BookmarksDefaultBackgroundColor = BrightBookmarkDefaultSystemColor; - public static Color ForeColor = BrightForeColor; - public static Color MenuBackgroundColor = BrighterBackgroundColor; - public static Color HoverMenuBackgroundColor = LessBrightBackgroundColor; - public static Color ActiveTabColor = BrighterBackgroundColor; - public static Color InactiveTabColor = LessBrightBackgroundColor; - public static Color TabsBackgroundStripColor = LessBrightBackgroundColor; + // Default + public static Color BackgroundColor = BrightBackgroundColor; + public static Color DockBackgroundColor = BrighterBackgroundColor; + public static Color BookmarksDefaultBackgroundColor = BrightBookmarkDefaultSystemColor; + public static Color ForeColor = BrightForeColor; + public static Color MenuBackgroundColor = BrighterBackgroundColor; + public static Color HoverMenuBackgroundColor = LessBrightBackgroundColor; + public static Color ActiveTabColor = BrighterBackgroundColor; + public static Color InactiveTabColor = LessBrightBackgroundColor; + public static Color TabsBackgroundStripColor = LessBrightBackgroundColor; - public static bool DarkModeEnabled; + public static bool DarkModeEnabled; - public static void LoadColorMode(bool darkMode) + public static void LoadColorMode(bool darkMode) + { + if (darkMode) { - if (darkMode) - { - SetDarkMode(); - } - else - { - SetBrightMode(); - } + SetDarkMode(); } - - private static void SetDarkMode() + else { - BackgroundColor = DarkBackgroundColor; - ForeColor = DarkForeColor; - MenuBackgroundColor = DarkerBackgroundColor; - DockBackgroundColor = LessDarkBackgroundColor; - HoverMenuBackgroundColor = LessDarkBackgroundColor; - BookmarksDefaultBackgroundColor = DarkBookmarkDefaultSystemColor; - TabsBackgroundStripColor = LessDarkBackgroundColor; - ActiveTabColor = LessLessDarkBackgroundColor; - InactiveTabColor = LessDarkBackgroundColor; - DarkModeEnabled = true; + SetBrightMode(); } + } - private static void SetBrightMode() - { - BackgroundColor = BrightBackgroundColor; - ForeColor = BrightForeColor; - MenuBackgroundColor = BrighterBackgroundColor; - DockBackgroundColor = BrighterBackgroundColor; - BookmarksDefaultBackgroundColor = BrightBookmarkDefaultSystemColor; - HoverMenuBackgroundColor = LessBrightBackgroundColor; - TabsBackgroundStripColor = BrighterBackgroundColor; - ActiveTabColor = BrighterBackgroundColor; - InactiveTabColor = LessBrightBackgroundColor; - DarkModeEnabled = false; - } + private static void SetDarkMode() + { + BackgroundColor = DarkBackgroundColor; + ForeColor = DarkForeColor; + MenuBackgroundColor = DarkerBackgroundColor; + DockBackgroundColor = LessDarkBackgroundColor; + HoverMenuBackgroundColor = LessDarkBackgroundColor; + BookmarksDefaultBackgroundColor = DarkBookmarkDefaultSystemColor; + TabsBackgroundStripColor = LessDarkBackgroundColor; + ActiveTabColor = LessLessDarkBackgroundColor; + InactiveTabColor = LessDarkBackgroundColor; + DarkModeEnabled = true; + } + + private static void SetBrightMode() + { + BackgroundColor = BrightBackgroundColor; + ForeColor = BrightForeColor; + MenuBackgroundColor = BrighterBackgroundColor; + DockBackgroundColor = BrighterBackgroundColor; + BookmarksDefaultBackgroundColor = BrightBookmarkDefaultSystemColor; + HoverMenuBackgroundColor = LessBrightBackgroundColor; + TabsBackgroundStripColor = BrighterBackgroundColor; + ActiveTabColor = BrighterBackgroundColor; + InactiveTabColor = LessBrightBackgroundColor; + DarkModeEnabled = false; } } diff --git a/src/LogExpert.Core/Config/ColumnizerHistoryEntry.cs b/src/LogExpert.Core/Config/ColumnizerHistoryEntry.cs index 1320bba6..88948893 100644 --- a/src/LogExpert.Core/Config/ColumnizerHistoryEntry.cs +++ b/src/LogExpert.Core/Config/ColumnizerHistoryEntry.cs @@ -4,27 +4,26 @@ #endregion -namespace LogExpert.Core.Config +namespace LogExpert.Core.Config; + +[Serializable] +public class ColumnizerHistoryEntry { - [Serializable] - public class ColumnizerHistoryEntry - { - #region cTor + #region cTor - public ColumnizerHistoryEntry(string fileName, string columnizerName) - { - FileName = fileName; - ColumnizerName = columnizerName; - } + public ColumnizerHistoryEntry(string fileName, string columnizerName) + { + FileName = fileName; + ColumnizerName = columnizerName; + } - #endregion + #endregion - #region Fields + #region Fields - public string FileName { get; } + public string FileName { get; } - #endregion + #endregion - public string ColumnizerName { get; } - } + public string ColumnizerName { get; } } \ No newline at end of file diff --git a/src/LogExpert.Core/Config/ColumnizerMaskEntry.cs b/src/LogExpert.Core/Config/ColumnizerMaskEntry.cs index d15d0fc1..37586ec5 100644 --- a/src/LogExpert.Core/Config/ColumnizerMaskEntry.cs +++ b/src/LogExpert.Core/Config/ColumnizerMaskEntry.cs @@ -1,15 +1,14 @@ using System; -namespace LogExpert.Core.Config +namespace LogExpert.Core.Config; + +[Serializable] +public class ColumnizerMaskEntry { - [Serializable] - public class ColumnizerMaskEntry - { - #region Fields + #region Fields - public string columnizerName; - public string mask; + public string columnizerName; + public string mask; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Config/ExportImportFlags.cs b/src/LogExpert.Core/Config/ExportImportFlags.cs index 7eea55a7..1e3326e5 100644 --- a/src/LogExpert.Core/Config/ExportImportFlags.cs +++ b/src/LogExpert.Core/Config/ExportImportFlags.cs @@ -1,16 +1,15 @@ -namespace LogExpert.Core.Config +namespace LogExpert.Core.Config; + +[Flags] +public enum ExportImportFlags : long { - [Flags] - public enum ExportImportFlags : long - { - None = 0, - HighlightSettings = 1, - ColumnizerMasks = 2, - HighlightMasks = 4, - ToolEntries = 8, - Other = 16, - KeepExisting = 32, - All = HighlightSettings | ColumnizerMasks | HighlightMasks | ToolEntries | Other, - AllKeepExisting = All | KeepExisting - } + None = 0, + HighlightSettings = 1, + ColumnizerMasks = 2, + HighlightMasks = 4, + ToolEntries = 8, + Other = 16, + KeepExisting = 32, + All = HighlightSettings | ColumnizerMasks | HighlightMasks | ToolEntries | Other, + AllKeepExisting = All | KeepExisting } \ No newline at end of file diff --git a/src/LogExpert.Core/Config/HighlightMaskEntry.cs b/src/LogExpert.Core/Config/HighlightMaskEntry.cs index 7435222d..cf1f40d2 100644 --- a/src/LogExpert.Core/Config/HighlightMaskEntry.cs +++ b/src/LogExpert.Core/Config/HighlightMaskEntry.cs @@ -1,15 +1,14 @@ using System; -namespace LogExpert.Core.Config +namespace LogExpert.Core.Config; + +[Serializable] +public class HighlightMaskEntry { - [Serializable] - public class HighlightMaskEntry - { - #region Fields + #region Fields - public string highlightGroupName; - public string mask; + public string highlightGroupName; + public string mask; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Config/MultiFileOption.cs b/src/LogExpert.Core/Config/MultiFileOption.cs index 5dbb3ab8..7dce5106 100644 --- a/src/LogExpert.Core/Config/MultiFileOption.cs +++ b/src/LogExpert.Core/Config/MultiFileOption.cs @@ -1,12 +1,11 @@ using System; -namespace LogExpert.Core.Config +namespace LogExpert.Core.Config; + +[Serializable] +public enum MultiFileOption { - [Serializable] - public enum MultiFileOption - { - SingleFiles, - MultiFile, - Ask - } + SingleFiles, + MultiFile, + Ask } \ No newline at end of file diff --git a/src/LogExpert.Core/Config/Preferences.cs b/src/LogExpert.Core/Config/Preferences.cs index f4a571bf..333465ec 100644 --- a/src/LogExpert.Core/Config/Preferences.cs +++ b/src/LogExpert.Core/Config/Preferences.cs @@ -3,110 +3,109 @@ using System.Drawing; -namespace LogExpert.Core.Config +namespace LogExpert.Core.Config; + +[Serializable] +public class Preferences { - [Serializable] - public class Preferences - { - #region Fields + #region Fields - public bool allowOnlyOneInstance; + public bool allowOnlyOneInstance; - public bool askForClose; + public bool askForClose; - public bool darkMode; + public bool darkMode; - public int bufferCount = 100; + public int bufferCount = 100; - public List columnizerMaskList = []; + public List columnizerMaskList = []; - public string defaultEncoding; + public string defaultEncoding; - public bool filterSync = true; + public bool filterSync = true; - public bool filterTail = true; + public bool filterTail = true; - public bool followTail = true; + public bool followTail = true; - public string fontName = "Courier New"; + public string fontName = "Courier New"; - public float fontSize = 9; + public float fontSize = 9; - public List highlightMaskList = []; + public List highlightMaskList = []; - public List HighlightGroupList { get; set; } = []; + public List HighlightGroupList { get; set; } = []; - public bool isAutoHideFilterList; + public bool isAutoHideFilterList; - public bool isFilterOnLoad; + public bool isFilterOnLoad; - public int lastColumnWidth = 2000; + public int lastColumnWidth = 2000; - public int linesPerBuffer = 500; + public int linesPerBuffer = 500; - public int maximumFilterEntries = 30; + public int maximumFilterEntries = 30; - public int maximumFilterEntriesDisplayed = 20; + public int maximumFilterEntriesDisplayed = 20; - public bool maskPrio; + public bool maskPrio; - public bool autoPick; + public bool autoPick; - //Refactor Enum - public MultiFileOption multiFileOption; + //Refactor Enum + public MultiFileOption multiFileOption; - //Refactor class? - public MultiFileOptions multiFileOptions; + //Refactor class? + public MultiFileOptions multiFileOptions; - public bool multiThreadFilter = true; + public bool multiThreadFilter = true; - public bool openLastFiles = true; + public bool openLastFiles = true; - public int pollingInterval = 250; + public int pollingInterval = 250; - public bool reverseAlpha; + public bool reverseAlpha; - public bool PortableMode { get; set; } + public bool PortableMode { get; set; } - /// - /// Save Directory of the last logfile - /// - public string sessionSaveDirectory; + /// + /// Save Directory of the last logfile + /// + public string sessionSaveDirectory; - public bool saveFilters = true; + public bool saveFilters = true; - public SessionSaveLocation saveLocation = SessionSaveLocation.DocumentsDir; + public SessionSaveLocation saveLocation = SessionSaveLocation.DocumentsDir; - public bool saveSessions = true; + public bool saveSessions = true; - public bool setLastColumnWidth; + public bool setLastColumnWidth; - public bool showBubbles = true; + public bool showBubbles = true; - public bool showColumnFinder; + public bool showColumnFinder; - public Color showTailColor = Color.FromKnownColor(KnownColor.Blue); + public Color showTailColor = Color.FromKnownColor(KnownColor.Blue); - public bool showTailState = true; + public bool showTailState = true; - public bool showTimeSpread; + public bool showTimeSpread; - public Color timeSpreadColor = Color.FromKnownColor(KnownColor.Gray); + public Color timeSpreadColor = Color.FromKnownColor(KnownColor.Gray); - public bool timeSpreadTimeMode; + public bool timeSpreadTimeMode; - public bool timestampControl = true; + public bool timestampControl = true; - public DragOrientationsEnum timestampControlDragOrientation = DragOrientationsEnum.Horizontal; + public DragOrientationsEnum timestampControlDragOrientation = DragOrientationsEnum.Horizontal; - public List toolEntries = []; + public List toolEntries = []; - public bool useLegacyReader; + public bool useLegacyReader; - public bool ShowErrorMessageAllowOnlyOneInstances { get; set; } + public bool ShowErrorMessageAllowOnlyOneInstances { get; set; } - public int MaxLineLength { get; set; } = 20000; + public int MaxLineLength { get; set; } = 20000; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Config/RegexHistory.cs b/src/LogExpert.Core/Config/RegexHistory.cs index a00fd630..994b21b5 100644 --- a/src/LogExpert.Core/Config/RegexHistory.cs +++ b/src/LogExpert.Core/Config/RegexHistory.cs @@ -1,13 +1,12 @@ using System; using System.Collections.Generic; -namespace LogExpert.Core.Config +namespace LogExpert.Core.Config; + +[Serializable] +public class RegexHistory { - [Serializable] - public class RegexHistory - { - public List ExpressionHistoryList { get; set; } = []; + public List ExpressionHistoryList { get; set; } = []; - public List TesttextHistoryList { get; set; } = []; - } + public List TesttextHistoryList { get; set; } = []; } \ No newline at end of file diff --git a/src/LogExpert.Core/Config/SessionSaveLocation.cs b/src/LogExpert.Core/Config/SessionSaveLocation.cs index 2b9b6ce8..7e559d6c 100644 --- a/src/LogExpert.Core/Config/SessionSaveLocation.cs +++ b/src/LogExpert.Core/Config/SessionSaveLocation.cs @@ -1,26 +1,25 @@ using System; -namespace LogExpert.Core.Config +namespace LogExpert.Core.Config; + +[Serializable] +public enum SessionSaveLocation { - [Serializable] - public enum SessionSaveLocation - { - //Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + Path.DirectorySeparatorChar + "LogExpert" - /// - /// - /// - DocumentsDir, - //same directory as the logfile - SameDir, - //uses configured folder to save the session files - /// - /// - /// - OwnDir, - /// - /// - /// - ApplicationStartupDir, - LoadedSessionFile - } + //Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + Path.DirectorySeparatorChar + "LogExpert" + /// + /// + /// + DocumentsDir, + //same directory as the logfile + SameDir, + //uses configured folder to save the session files + /// + /// + /// + OwnDir, + /// + /// + /// + ApplicationStartupDir, + LoadedSessionFile } \ No newline at end of file diff --git a/src/LogExpert.Core/Config/Settings.cs b/src/LogExpert.Core/Config/Settings.cs index 275bd2c1..461ec6d9 100644 --- a/src/LogExpert.Core/Config/Settings.cs +++ b/src/LogExpert.Core/Config/Settings.cs @@ -1,55 +1,54 @@ +using System.Drawing; + using LogExpert.Core.Classes.Filter; using LogExpert.Core.Entities; -using System.Drawing; +namespace LogExpert.Core.Config; -namespace LogExpert.Core.Config +[Serializable] +public class Settings { - [Serializable] - public class Settings - { - #region Fields + #region Fields - public bool alwaysOnTop; + public bool alwaysOnTop; - public Rectangle appBounds; + public Rectangle appBounds; - public Rectangle appBoundsFullscreen; + public Rectangle appBoundsFullscreen; - public IList columnizerHistoryList = []; + public IList columnizerHistoryList = []; - public List fileColors = []; + public List fileColors = []; - public List fileHistoryList = []; + public List fileHistoryList = []; - public List filterHistoryList = []; + public List filterHistoryList = []; - public List filterList = []; + public List filterList = []; - public FilterParams filterParams = new(); + public FilterParams filterParams = new(); - public List filterRangeHistoryList = []; + public List filterRangeHistoryList = []; - public bool hideLineColumn; + public bool hideLineColumn; - public bool isMaximized; + public bool isMaximized; - public string lastDirectory; + public string lastDirectory; - public List lastOpenFilesList = []; + public List lastOpenFilesList = []; - public Preferences Preferences { get; set; } = new(); + public Preferences Preferences { get; set; } = new(); - public RegexHistory RegexHistory { get; set; } = new(); + public RegexHistory RegexHistory { get; set; } = new(); - public List searchHistoryList = []; + public List searchHistoryList = []; - public SearchParams searchParams = new(); + public SearchParams searchParams = new(); - public IList uriHistoryList = []; + public IList uriHistoryList = []; - public int versionBuild; + public int versionBuild; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Config/SettingsFlags.cs b/src/LogExpert.Core/Config/SettingsFlags.cs index 303874da..36299106 100644 --- a/src/LogExpert.Core/Config/SettingsFlags.cs +++ b/src/LogExpert.Core/Config/SettingsFlags.cs @@ -1,24 +1,23 @@ using System; -namespace LogExpert.Core.Config +namespace LogExpert.Core.Config; + +[Flags] +public enum SettingsFlags : long { - [Flags] - public enum SettingsFlags : long - { - None = 0, - WindowPosition = 1, - FileHistory = 2, - HighlightSettings = 4, - FilterList = 8, - RegexHistory = 16, - ToolSettings = 32, - GuiOrColors = 64, - FilterHistory = 128, + None = 0, + WindowPosition = 1, + FileHistory = 2, + HighlightSettings = 4, + FilterList = 8, + RegexHistory = 16, + ToolSettings = 32, + GuiOrColors = 64, + FilterHistory = 128, - All = WindowPosition | FileHistory | HighlightSettings | - FilterList | RegexHistory | ToolSettings | GuiOrColors | - FilterHistory, + All = WindowPosition | FileHistory | HighlightSettings | + FilterList | RegexHistory | ToolSettings | GuiOrColors | + FilterHistory, - Settings = All & ~WindowPosition & ~FileHistory, - } + Settings = All & ~WindowPosition & ~FileHistory, } \ No newline at end of file diff --git a/src/LogExpert.Core/Config/ToolEntry.cs b/src/LogExpert.Core/Config/ToolEntry.cs index f563150a..bb5d4d1e 100644 --- a/src/LogExpert.Core/Config/ToolEntry.cs +++ b/src/LogExpert.Core/Config/ToolEntry.cs @@ -2,47 +2,46 @@ using LogExpert.Core.Classes; -namespace LogExpert.Core.Config +namespace LogExpert.Core.Config; + +[Serializable] +public class ToolEntry { - [Serializable] - public class ToolEntry + #region Fields + + public string args = ""; + public string cmd = ""; + public string columnizerName = ""; + public string iconFile; + public int iconIndex; + public bool isFavourite; + public string name; + public bool sysout; + public string workingDir = ""; + + #endregion + + #region Public methods + + public override string ToString() { - #region Fields - - public string args = ""; - public string cmd = ""; - public string columnizerName = ""; - public string iconFile; - public int iconIndex; - public bool isFavourite; - public string name; - public bool sysout; - public string workingDir = ""; - - #endregion - - #region Public methods - - public override string ToString() - { - return Util.IsNull(name) ? cmd : name; - } - - public ToolEntry Clone() - { - ToolEntry clone = new(); - clone.cmd = cmd; - clone.args = args; - clone.name = name; - clone.sysout = sysout; - clone.columnizerName = columnizerName; - clone.isFavourite = isFavourite; - clone.iconFile = iconFile; - clone.iconIndex = iconIndex; - clone.workingDir = workingDir; - return clone; - } - - #endregion + return Util.IsNull(name) ? cmd : name; } + + public ToolEntry Clone() + { + ToolEntry clone = new(); + clone.cmd = cmd; + clone.args = args; + clone.name = name; + clone.sysout = sysout; + clone.columnizerName = columnizerName; + clone.isFavourite = isFavourite; + clone.iconFile = iconFile; + clone.iconIndex = iconIndex; + clone.workingDir = workingDir; + return clone; + } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Entities/Bookmark.cs b/src/LogExpert.Core/Entities/Bookmark.cs index a150b8f3..4ebb1e80 100644 --- a/src/LogExpert.Core/Entities/Bookmark.cs +++ b/src/LogExpert.Core/Entities/Bookmark.cs @@ -1,40 +1,39 @@ using System.Drawing; -namespace LogExpert.Core.Entities +namespace LogExpert.Core.Entities; + +public class Bookmark { - public class Bookmark - { - #region cTor + #region cTor - public Bookmark(int lineNum) - { - LineNum = lineNum; - Text = string.Empty; - Overlay = new BookmarkOverlay(); - } + public Bookmark(int lineNum) + { + LineNum = lineNum; + Text = string.Empty; + Overlay = new BookmarkOverlay(); + } - public Bookmark(int lineNum, string comment) - { - LineNum = lineNum; - Text = comment; - Overlay = new BookmarkOverlay(); - } + public Bookmark(int lineNum, string comment) + { + LineNum = lineNum; + Text = comment; + Overlay = new BookmarkOverlay(); + } - #endregion + #endregion - #region Properties + #region Properties - public int LineNum { get; set; } + public int LineNum { get; set; } - public string Text { get; set; } + public string Text { get; set; } - public BookmarkOverlay Overlay { get; set; } + public BookmarkOverlay Overlay { get; set; } - /// - /// Position offset of the overlay as set by the user by dragging the overlay with the mouse. - /// - public Size OverlayOffset { get; set; } + /// + /// Position offset of the overlay as set by the user by dragging the overlay with the mouse. + /// + public Size OverlayOffset { get; set; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Entities/BookmarkCollection.cs b/src/LogExpert.Core/Entities/BookmarkCollection.cs index a5d48b8a..0cc0917c 100644 --- a/src/LogExpert.Core/Entities/BookmarkCollection.cs +++ b/src/LogExpert.Core/Entities/BookmarkCollection.cs @@ -1,23 +1,22 @@ using System.Collections.ObjectModel; -namespace LogExpert.Core.Entities -{ - public class BookmarkCollection : ReadOnlyCollection - { - #region Fields +namespace LogExpert.Core.Entities; - private SortedList bookmarkList; +public class BookmarkCollection : ReadOnlyCollection +{ + #region Fields - #endregion + private SortedList bookmarkList; - #region cTor + #endregion - internal BookmarkCollection(SortedList bookmarkList) - : base(bookmarkList.Values) - { - this.bookmarkList = bookmarkList; - } + #region cTor - #endregion + internal BookmarkCollection(SortedList bookmarkList) + : base(bookmarkList.Values) + { + this.bookmarkList = bookmarkList; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Entities/BookmarkOverlay.cs b/src/LogExpert.Core/Entities/BookmarkOverlay.cs index b4ccff75..805ee15d 100644 --- a/src/LogExpert.Core/Entities/BookmarkOverlay.cs +++ b/src/LogExpert.Core/Entities/BookmarkOverlay.cs @@ -1,17 +1,16 @@ using System.Drawing; -namespace LogExpert.Core.Entities +namespace LogExpert.Core.Entities; + +public class BookmarkOverlay { - public class BookmarkOverlay - { - #region Properties + #region Properties - public Bookmark Bookmark { get; set; } + public Bookmark Bookmark { get; set; } - public Point Position { get; set; } + public Point Position { get; set; } - public Rectangle BubbleRect { get; set; } + public Rectangle BubbleRect { get; set; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Entities/DebugOptions.cs b/src/LogExpert.Core/Entities/DebugOptions.cs index 738b2c02..f6e1fcfd 100644 --- a/src/LogExpert.Core/Entities/DebugOptions.cs +++ b/src/LogExpert.Core/Entities/DebugOptions.cs @@ -1,7 +1,6 @@ -namespace LogExpert.Core.Entities +namespace LogExpert.Core.Entities; + +public class DebugOptions { - public class DebugOptions - { - public static bool DisableWordHighlight { get; set; } - } + public static bool DisableWordHighlight { get; set; } } \ No newline at end of file diff --git a/src/LogExpert.Core/Entities/DefaultLogfileColumnizer.cs b/src/LogExpert.Core/Entities/DefaultLogfileColumnizer.cs index 4a2ac39a..ab955862 100644 --- a/src/LogExpert.Core/Entities/DefaultLogfileColumnizer.cs +++ b/src/LogExpert.Core/Entities/DefaultLogfileColumnizer.cs @@ -1,83 +1,82 @@ -namespace LogExpert.Core.Entities +namespace LogExpert.Core.Entities; + +public class DefaultLogfileColumnizer : ILogLineColumnizer { - public class DefaultLogfileColumnizer : ILogLineColumnizer + #region ILogLineColumnizer Members + + public string GetName() { - #region ILogLineColumnizer Members + return "Default (single line)"; + } - public string GetName() - { - return "Default (single line)"; - } + public string GetDescription() + { + return "No column splitting. The whole line is displayed in a single column."; + } - public string GetDescription() - { - return "No column splitting. The whole line is displayed in a single column."; - } + public int GetColumnCount() + { + return 1; + } - public int GetColumnCount() - { - return 1; - } + public string[] GetColumnNames() + { + return ["Text"]; + } - public string[] GetColumnNames() + public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) + { + ColumnizedLogLine cLogLine = new() { - return ["Text"]; - } + LogLine = line + }; - public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) - { - ColumnizedLogLine cLogLine = new() + cLogLine.ColumnValues = + [ + new Column { - LogLine = line - }; + FullValue = line.FullLine, + Parent = cLogLine + } + ]; - cLogLine.ColumnValues = - [ - new Column - { - FullValue = line.FullLine, - Parent = cLogLine - } - ]; + return cLogLine; + } - return cLogLine; - } - - public string Text => GetName(); - - public Priority GetPriority(string fileName, IEnumerable samples) - { - return Priority.CanSupport; - } - #endregion + public string Text => GetName(); - #region ILogLineColumnizer Not implemented Members + public Priority GetPriority(string fileName, IEnumerable samples) + { + return Priority.CanSupport; + } + #endregion - public bool IsTimeshiftImplemented() - { - return false; - } + #region ILogLineColumnizer Not implemented Members - public void SetTimeOffset(int msecOffset) - { - throw new NotImplementedException(); - } + public bool IsTimeshiftImplemented() + { + return false; + } - public int GetTimeOffset() - { - throw new NotImplementedException(); - } + public void SetTimeOffset(int msecOffset) + { + throw new NotImplementedException(); + } - public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) - { - throw new NotImplementedException(); - } + public int GetTimeOffset() + { + throw new NotImplementedException(); + } - public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) - { - } + public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) + { + throw new NotImplementedException(); + } - #endregion + public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) + { } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Entities/EncodingOptions.cs b/src/LogExpert.Core/Entities/EncodingOptions.cs index d66bd336..dae7e680 100644 --- a/src/LogExpert.Core/Entities/EncodingOptions.cs +++ b/src/LogExpert.Core/Entities/EncodingOptions.cs @@ -1,24 +1,23 @@ using System.Text; -namespace LogExpert.Core.Entities +namespace LogExpert.Core.Entities; + +/// +/// Holds some encoding options. +/// +public class EncodingOptions { + #region Properties + /// - /// Holds some encoding options. + /// Sets or gets the Encoding which shall be used when reading a file. A value of null means 'please autodetect' via BOM. /// - public class EncodingOptions - { - #region Properties - - /// - /// Sets or gets the Encoding which shall be used when reading a file. A value of null means 'please autodetect' via BOM. - /// - public Encoding Encoding { get; set; } + public Encoding Encoding { get; set; } - /// - /// The Encoding to be used when autodetect cannot be applied (missing BOM). Only used when Encoding is set to null. - /// - public Encoding DefaultEncoding { get; set; } + /// + /// The Encoding to be used when autodetect cannot be applied (missing BOM). Only used when Encoding is set to null. + /// + public Encoding DefaultEncoding { get; set; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Entities/FileViewContext.cs b/src/LogExpert.Core/Entities/FileViewContext.cs index efcc7577..8cc0a27a 100644 --- a/src/LogExpert.Core/Entities/FileViewContext.cs +++ b/src/LogExpert.Core/Entities/FileViewContext.cs @@ -1,15 +1,14 @@ using LogExpert.Core.Interface; -namespace LogExpert.Core.Entities +namespace LogExpert.Core.Entities; + +public class FileViewContext(ILogPaintContext logPaintContext, ILogView logView) : IFileViewContext, ILogPaintContext { - public class FileViewContext(ILogPaintContext logPaintContext, ILogView logView) : IFileViewContext, ILogPaintContext - { - #region Properties + #region Properties - public ILogPaintContext LogPaintContext { get; } = logPaintContext; + public ILogPaintContext LogPaintContext { get; } = logPaintContext; - public ILogView LogView { get; } = logView; + public ILogView LogView { get; } = logView; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Entities/HighlightGroup.cs b/src/LogExpert.Core/Entities/HighlightGroup.cs index 1ce4471b..a599d198 100644 --- a/src/LogExpert.Core/Entities/HighlightGroup.cs +++ b/src/LogExpert.Core/Entities/HighlightGroup.cs @@ -1,31 +1,30 @@ using LogExpert.Core.Classes.Highlight; -namespace LogExpert.Core.Entities +namespace LogExpert.Core.Entities; + +[Serializable] +public class HighlightGroup : ICloneable { - [Serializable] - public class HighlightGroup : ICloneable - { - #region Properties + #region Properties - public string GroupName { get; set; } = string.Empty; + public string GroupName { get; set; } = string.Empty; - public List HighlightEntryList { get; set; } = []; + public List HighlightEntryList { get; set; } = []; - public object Clone() + public object Clone() + { + HighlightGroup clone = new() { - HighlightGroup clone = new() - { - GroupName = GroupName - }; + GroupName = GroupName + }; - foreach (HighlightEntry entry in HighlightEntryList) - { - clone.HighlightEntryList.Add((HighlightEntry)entry.Clone()); - } - - return clone; + foreach (HighlightEntry entry in HighlightEntryList) + { + clone.HighlightEntryList.Add((HighlightEntry)entry.Clone()); } - #endregion + return clone; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Entities/LogEventData.cs b/src/LogExpert.Core/Entities/LogEventData.cs index 00feadb0..70b368b5 100644 --- a/src/LogExpert.Core/Entities/LogEventData.cs +++ b/src/LogExpert.Core/Entities/LogEventData.cs @@ -1,25 +1,24 @@ -namespace LogExpert.Core.Entities +namespace LogExpert.Core.Entities; + +public class LogEventArgs : System.EventArgs { - public class LogEventArgs : System.EventArgs - { - #region Fields + #region Fields - #endregion + #endregion - #region Properties + #region Properties - public int RolloverOffset { get; set; } + public int RolloverOffset { get; set; } - public bool IsRollover { get; set; } + public bool IsRollover { get; set; } - public long FileSize { get; set; } + public long FileSize { get; set; } - public int LineCount { get; set; } + public int LineCount { get; set; } - public int PrevLineCount { get; set; } + public int PrevLineCount { get; set; } - public long PrevFileSize { get; set; } + public long PrevFileSize { get; set; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Entities/LogFileException.cs b/src/LogExpert.Core/Entities/LogFileException.cs index 3368e8c3..08384374 100644 --- a/src/LogExpert.Core/Entities/LogFileException.cs +++ b/src/LogExpert.Core/Entities/LogFileException.cs @@ -1,19 +1,22 @@ -namespace LogExpert.Core.Entities +namespace LogExpert.Core.Entities; + +public class LogFileException : Exception { - public class LogFileException : ApplicationException - { - #region cTor + #region cTor - public LogFileException(string msg) - : base(msg) - { - } + public LogFileException (string msg) + : base(msg) + { + } - public LogFileException(string msg, Exception inner) - : base(msg, inner) - { - } + public LogFileException (string msg, Exception inner) + : base(msg, inner) + { + } - #endregion + public LogFileException () + { } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Entities/MultifileOptions.cs b/src/LogExpert.Core/Entities/MultifileOptions.cs index 04858e4e..b9ab6d78 100644 --- a/src/LogExpert.Core/Entities/MultifileOptions.cs +++ b/src/LogExpert.Core/Entities/MultifileOptions.cs @@ -1,14 +1,13 @@ -namespace LogExpert.Core.Entities +namespace LogExpert.Core.Entities; + +[Serializable] +public class MultiFileOptions { - [Serializable] - public class MultiFileOptions - { - #region Properties + #region Properties - public int MaxDayTry { get; set; } = 3; + public int MaxDayTry { get; set; } = 3; - public string FormatPattern { get; set; } = "*$J(.)"; + public string FormatPattern { get; set; } = "*$J(.)"; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Entities/Range.cs b/src/LogExpert.Core/Entities/Range.cs index c2c9f1b3..e9d40540 100644 --- a/src/LogExpert.Core/Entities/Range.cs +++ b/src/LogExpert.Core/Entities/Range.cs @@ -1,31 +1,30 @@ -namespace LogExpert.Core.Entities +namespace LogExpert.Core.Entities; + +public class Range { - public class Range - { - #region Fields + #region Fields - #endregion + #endregion - #region cTor + #region cTor - public Range() - { - } + public Range() + { + } - public Range(int startLine, int endLine) - { - StartLine = startLine; - EndLine = endLine; - } + public Range(int startLine, int endLine) + { + StartLine = startLine; + EndLine = endLine; + } - #endregion + #endregion - #region Properties + #region Properties - public int StartLine { get; set; } + public int StartLine { get; set; } - public int EndLine { get; set; } + public int EndLine { get; set; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Entities/ReloadMemento.cs b/src/LogExpert.Core/Entities/ReloadMemento.cs index 03f9cfa9..bbb82015 100644 --- a/src/LogExpert.Core/Entities/ReloadMemento.cs +++ b/src/LogExpert.Core/Entities/ReloadMemento.cs @@ -1,9 +1,8 @@ -namespace LogExpert.Core.Entities +namespace LogExpert.Core.Entities; + +public class ReloadMemento { - public class ReloadMemento - { - public int CurrentLine { get; set; } + public int CurrentLine { get; set; } - public int FirstDisplayedLine { get; set; } - } + public int FirstDisplayedLine { get; set; } } \ No newline at end of file diff --git a/src/LogExpert.Core/Entities/RowHeightEntry.cs b/src/LogExpert.Core/Entities/RowHeightEntry.cs index 26c879a2..00c79bc7 100644 --- a/src/LogExpert.Core/Entities/RowHeightEntry.cs +++ b/src/LogExpert.Core/Entities/RowHeightEntry.cs @@ -1,29 +1,28 @@ -namespace LogExpert.Core.Entities +namespace LogExpert.Core.Entities; + +public class RowHeightEntry { - public class RowHeightEntry - { - #region cTor + #region cTor - public RowHeightEntry() - { - LineNum = 0; - Height = 0; - } + public RowHeightEntry() + { + LineNum = 0; + Height = 0; + } - public RowHeightEntry(int lineNum, int height) - { - LineNum = lineNum; - Height = height; - } + public RowHeightEntry(int lineNum, int height) + { + LineNum = lineNum; + Height = height; + } - #endregion + #endregion - #region Properties + #region Properties - public int LineNum { get; set; } + public int LineNum { get; set; } - public int Height { get; set; } + public int Height { get; set; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Entities/SearchParams.cs b/src/LogExpert.Core/Entities/SearchParams.cs index d5d16be3..ed4b2748 100644 --- a/src/LogExpert.Core/Entities/SearchParams.cs +++ b/src/LogExpert.Core/Entities/SearchParams.cs @@ -1,25 +1,24 @@ -namespace LogExpert.Core.Entities +namespace LogExpert.Core.Entities; + +[Serializable] +public class SearchParams { - [Serializable] - public class SearchParams - { - public int CurrentLine { get; set; } + public int CurrentLine { get; set; } - public List HistoryList { get; set; } = []; + public List HistoryList { get; set; } = []; - public bool IsCaseSensitive { get; set; } + public bool IsCaseSensitive { get; set; } - public bool IsFindNext { get; set; } + public bool IsFindNext { get; set; } - public bool IsForward { get; set; } = true; + public bool IsForward { get; set; } = true; - public bool IsFromTop { get; set; } + public bool IsFromTop { get; set; } - public bool IsRegex { get; set; } + public bool IsRegex { get; set; } - public string SearchText { get; set; } = string.Empty; + public string SearchText { get; set; } = string.Empty; - [field: NonSerialized] - public bool IsShiftF3Pressed { get; set; } - } + [field: NonSerialized] + public bool IsShiftF3Pressed { get; set; } } \ No newline at end of file diff --git a/src/LogExpert.Core/Enums/DragOrientationsEnum.cs b/src/LogExpert.Core/Enums/DragOrientationsEnum.cs index ccb32aa5..fb6465c4 100644 --- a/src/LogExpert.Core/Enums/DragOrientationsEnum.cs +++ b/src/LogExpert.Core/Enums/DragOrientationsEnum.cs @@ -1,9 +1,8 @@ -namespace LogExpert.Core.Enums +namespace LogExpert.Core.Enums; + +public enum DragOrientationsEnum { - public enum DragOrientationsEnum - { - Horizontal, - Vertical, - InvertedVertical - } + Horizontal, + Vertical, + InvertedVertical } diff --git a/src/LogExpert.Core/Enums/ProjectLoadDlgResult.cs b/src/LogExpert.Core/Enums/ProjectLoadDlgResult.cs index aa1f648b..c32b6c2c 100644 --- a/src/LogExpert.Core/Enums/ProjectLoadDlgResult.cs +++ b/src/LogExpert.Core/Enums/ProjectLoadDlgResult.cs @@ -1,10 +1,9 @@ -namespace LogExpert.Core.Enums +namespace LogExpert.Core.Enums; + +public enum ProjectLoadDlgResult { - public enum ProjectLoadDlgResult - { - Cancel, - CloseTabs, - NewWindow, - IgnoreLayout - } + Cancel, + CloseTabs, + NewWindow, + IgnoreLayout } \ No newline at end of file diff --git a/src/LogExpert.Core/Enums/WindowTypes.cs b/src/LogExpert.Core/Enums/WindowTypes.cs index f9ee40b2..6a726c9c 100644 --- a/src/LogExpert.Core/Enums/WindowTypes.cs +++ b/src/LogExpert.Core/Enums/WindowTypes.cs @@ -1,8 +1,7 @@ -namespace LogExpert.Core.Enums +namespace LogExpert.Core.Enums; + +public enum WindowTypes { - public enum WindowTypes - { - BookmarkWindow, - LogWindow, - } + BookmarkWindow, + LogWindow, } \ No newline at end of file diff --git a/src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs b/src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs index 2a600219..869b34be 100644 --- a/src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs +++ b/src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs @@ -1,13 +1,12 @@ using LogExpert.Core.Entities; -namespace LogExpert.Core.EventArguments +namespace LogExpert.Core.EventArguments; + +public class BookmarkEventArgs(Bookmark bookmark) : System.EventArgs { - public class BookmarkEventArgs(Bookmark bookmark) : System.EventArgs - { - #region Properties + #region Properties - public Bookmark Bookmark { get; } = bookmark; + public Bookmark Bookmark { get; } = bookmark; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/EventArguments/ColumnizerEventArgs.cs b/src/LogExpert.Core/EventArguments/ColumnizerEventArgs.cs index ad8ef92a..9e8bb006 100644 --- a/src/LogExpert.Core/EventArguments/ColumnizerEventArgs.cs +++ b/src/LogExpert.Core/EventArguments/ColumnizerEventArgs.cs @@ -1,11 +1,10 @@ -namespace LogExpert.Core.EventArguments +namespace LogExpert.Core.EventArguments; + +public class ColumnizerEventArgs(ILogLineColumnizer columnizer) : System.EventArgs { - public class ColumnizerEventArgs(ILogLineColumnizer columnizer) : System.EventArgs - { - #region Properties + #region Properties - public ILogLineColumnizer Columnizer { get; } = columnizer; + public ILogLineColumnizer Columnizer { get; } = columnizer; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/EventArguments/ConfigChangedEventArgs.cs b/src/LogExpert.Core/EventArguments/ConfigChangedEventArgs.cs index 243faa0d..c931dccf 100644 --- a/src/LogExpert.Core/EventArguments/ConfigChangedEventArgs.cs +++ b/src/LogExpert.Core/EventArguments/ConfigChangedEventArgs.cs @@ -1,13 +1,12 @@ using LogExpert.Core.Config; -namespace LogExpert.Core.EventArguments +namespace LogExpert.Core.EventArguments; + +public class ConfigChangedEventArgs(SettingsFlags changeFlags) : System.EventArgs { - public class ConfigChangedEventArgs(SettingsFlags changeFlags) : System.EventArgs - { - #region Properties + #region Properties - public SettingsFlags Flags { get; } = changeFlags; + public SettingsFlags Flags { get; } = changeFlags; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/EventArguments/ContextMenuPluginEventArgs.cs b/src/LogExpert.Core/EventArguments/ContextMenuPluginEventArgs.cs index 28df85f7..76d129cc 100644 --- a/src/LogExpert.Core/EventArguments/ContextMenuPluginEventArgs.cs +++ b/src/LogExpert.Core/EventArguments/ContextMenuPluginEventArgs.cs @@ -1,19 +1,18 @@ -namespace LogExpert.Core.EventArguments +namespace LogExpert.Core.EventArguments; + +public class ContextMenuPluginEventArgs(IContextMenuEntry entry, IList logLines, ILogLineColumnizer columnizer, + ILogExpertCallback callback) : System.EventArgs { - public class ContextMenuPluginEventArgs(IContextMenuEntry entry, IList logLines, ILogLineColumnizer columnizer, - ILogExpertCallback callback) : System.EventArgs - { - #region Properties + #region Properties - public IContextMenuEntry Entry { get; } = entry; + public IContextMenuEntry Entry { get; } = entry; - public IList LogLines { get; } = logLines; + public IList LogLines { get; } = logLines; - public ILogLineColumnizer Columnizer { get; } = columnizer; + public ILogLineColumnizer Columnizer { get; } = columnizer; - public ILogExpertCallback Callback { get; } = callback; + public ILogExpertCallback Callback { get; } = callback; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/EventArguments/CurrentHighlightGroupChangedEventArgs.cs b/src/LogExpert.Core/EventArguments/CurrentHighlightGroupChangedEventArgs.cs index efc33f45..7633e06c 100644 --- a/src/LogExpert.Core/EventArguments/CurrentHighlightGroupChangedEventArgs.cs +++ b/src/LogExpert.Core/EventArguments/CurrentHighlightGroupChangedEventArgs.cs @@ -1,16 +1,15 @@ using LogExpert.Core.Entities; using LogExpert.Core.Interface; -namespace LogExpert.Core.EventArguments +namespace LogExpert.Core.EventArguments; + +public class CurrentHighlightGroupChangedEventArgs(ILogWindow logWindow, HighlightGroup currentGroup) { - public class CurrentHighlightGroupChangedEventArgs(ILogWindow logWindow, HighlightGroup currentGroup) - { - #region Properties + #region Properties - public ILogWindow LogWindow { get; } = logWindow; + public ILogWindow LogWindow { get; } = logWindow; - public HighlightGroup CurrentGroup { get; } = currentGroup; + public HighlightGroup CurrentGroup { get; } = currentGroup; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/EventArguments/FilterListChangedEventArgs.cs b/src/LogExpert.Core/EventArguments/FilterListChangedEventArgs.cs index 684f993c..610bf8f3 100644 --- a/src/LogExpert.Core/EventArguments/FilterListChangedEventArgs.cs +++ b/src/LogExpert.Core/EventArguments/FilterListChangedEventArgs.cs @@ -1,14 +1,13 @@  using LogExpert.Core.Interface; -namespace LogExpert.Core.EventArguments +namespace LogExpert.Core.EventArguments; + +public class FilterListChangedEventArgs(ILogWindow logWindow) { - public class FilterListChangedEventArgs(ILogWindow logWindow) - { - #region Properties + #region Properties - public ILogWindow LogWindow { get; } = logWindow; + public ILogWindow LogWindow { get; } = logWindow; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/EventArguments/GuiStateArgs.cs b/src/LogExpert.Core/EventArguments/GuiStateArgs.cs index e14c92a6..82ccc963 100644 --- a/src/LogExpert.Core/EventArguments/GuiStateArgs.cs +++ b/src/LogExpert.Core/EventArguments/GuiStateArgs.cs @@ -1,45 +1,44 @@ using System.Text; -namespace LogExpert.Core.EventArguments +namespace LogExpert.Core.EventArguments; + +public class GuiStateArgs : System.EventArgs { - public class GuiStateArgs : System.EventArgs - { - #region Properties + #region Properties - public bool TimeshiftEnabled { get; set; } + public bool TimeshiftEnabled { get; set; } - public bool FollowTail { get; set; } + public bool FollowTail { get; set; } - public bool MenuEnabled { get; set; } = true; + public bool MenuEnabled { get; set; } = true; - public string TimeshiftText { get; set; } = string.Empty; + public string TimeshiftText { get; set; } = string.Empty; - public bool TimeshiftPossible { get; set; } + public bool TimeshiftPossible { get; set; } - public bool MultiFileEnabled { get; set; } = true; + public bool MultiFileEnabled { get; set; } = true; - public bool FilterEnabled { get; set; } = true; + public bool FilterEnabled { get; set; } = true; - public bool CellSelectMode { get; set; } + public bool CellSelectMode { get; set; } - public Encoding CurrentEncoding { get; set; } + public Encoding CurrentEncoding { get; set; } - public DateTime Timestamp { get; set; } + public DateTime Timestamp { get; set; } - public DateTime MinTimestamp { get; set; } + public DateTime MinTimestamp { get; set; } - public DateTime MaxTimestamp { get; set; } + public DateTime MaxTimestamp { get; set; } - public bool ShowBookmarkBubbles { get; set; } + public bool ShowBookmarkBubbles { get; set; } - public bool IsMultiFileActive { get; set; } + public bool IsMultiFileActive { get; set; } - public bool ShowHiddenLines { get; set; } = true; + public bool ShowHiddenLines { get; set; } = true; - public string HighlightGroupName { get; set; } = string.Empty; + public string HighlightGroupName { get; set; } = string.Empty; - public bool ColumnFinderVisible { get; set; } + public bool ColumnFinderVisible { get; set; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/EventArguments/LoadFileEventArgs.cs b/src/LogExpert.Core/EventArguments/LoadFileEventArgs.cs index 18f786b9..b7daa31a 100644 --- a/src/LogExpert.Core/EventArguments/LoadFileEventArgs.cs +++ b/src/LogExpert.Core/EventArguments/LoadFileEventArgs.cs @@ -1,4 +1,3 @@ -namespace LogExpert.Core.EventArguments -{ - public record LoadFileEventArgs(string FileName, long ReadPos, bool Finished, long FileSize, bool NewFile); -} \ No newline at end of file +namespace LogExpert.Core.EventArguments; + +public record LoadFileEventArgs(string FileName, long ReadPos, bool Finished, long FileSize, bool NewFile); \ No newline at end of file diff --git a/src/LogExpert.Core/EventArguments/OverlayEventArgs.cs b/src/LogExpert.Core/EventArguments/OverlayEventArgs.cs index ef826147..91faf48b 100644 --- a/src/LogExpert.Core/EventArguments/OverlayEventArgs.cs +++ b/src/LogExpert.Core/EventArguments/OverlayEventArgs.cs @@ -1,13 +1,12 @@ using LogExpert.Core.Entities; -namespace LogExpert.Core.EventArguments +namespace LogExpert.Core.EventArguments; + +public class OverlayEventArgs(BookmarkOverlay overlay) : System.EventArgs { - public class OverlayEventArgs(BookmarkOverlay overlay) : System.EventArgs - { - #region Properties + #region Properties - public BookmarkOverlay BookmarkOverlay { get; set; } = overlay; + public BookmarkOverlay BookmarkOverlay { get; set; } = overlay; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/EventArguments/PatternArgs.cs b/src/LogExpert.Core/EventArguments/PatternArgs.cs index 60d26042..3cfe2e69 100644 --- a/src/LogExpert.Core/EventArguments/PatternArgs.cs +++ b/src/LogExpert.Core/EventArguments/PatternArgs.cs @@ -1,21 +1,20 @@ -namespace LogExpert.Core.EventArguments +namespace LogExpert.Core.EventArguments; + +public class PatternArgs { - public class PatternArgs - { - #region Properties + #region Properties - public int EndLine { get; set; } + public int EndLine { get; set; } - public int Fuzzy { get; set; } = 6; + public int Fuzzy { get; set; } = 6; - public int MaxDiffInBlock { get; set; } = 5; + public int MaxDiffInBlock { get; set; } = 5; - public int MaxMisses { get; set; } = 5; + public int MaxMisses { get; set; } = 5; - public int MinWeight { get; set; } = 15; + public int MinWeight { get; set; } = 15; - public int StartLine { get; set; } + public int StartLine { get; set; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/EventArguments/ProgressEventArgs.cs b/src/LogExpert.Core/EventArguments/ProgressEventArgs.cs index f91c15fc..58db9efb 100644 --- a/src/LogExpert.Core/EventArguments/ProgressEventArgs.cs +++ b/src/LogExpert.Core/EventArguments/ProgressEventArgs.cs @@ -1,17 +1,16 @@ -namespace LogExpert.Core.EventArguments +namespace LogExpert.Core.EventArguments; + +public class ProgressEventArgs : System.EventArgs { - public class ProgressEventArgs : System.EventArgs - { - #region Properties + #region Properties - public int Value { get; set; } + public int Value { get; set; } - public int MinValue { get; set; } + public int MinValue { get; set; } - public int MaxValue { get; set; } + public int MaxValue { get; set; } - public bool Visible { get; set; } + public bool Visible { get; set; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/EventArguments/SelectLineEventArgs.cs b/src/LogExpert.Core/EventArguments/SelectLineEventArgs.cs index b667872b..ac94ccfc 100644 --- a/src/LogExpert.Core/EventArguments/SelectLineEventArgs.cs +++ b/src/LogExpert.Core/EventArguments/SelectLineEventArgs.cs @@ -1,11 +1,10 @@ -namespace LogExpert.Core.EventArguments +namespace LogExpert.Core.EventArguments; + +public class SelectLineEventArgs(int line) : System.EventArgs { - public class SelectLineEventArgs(int line) : System.EventArgs - { - #region Properties + #region Properties - public int Line { get; } = line; + public int Line { get; } = line; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/EventArguments/StatusEventArgs.cs b/src/LogExpert.Core/EventArguments/StatusEventArgs.cs index 2640a1a2..21786a3b 100644 --- a/src/LogExpert.Core/EventArguments/StatusEventArgs.cs +++ b/src/LogExpert.Core/EventArguments/StatusEventArgs.cs @@ -1,33 +1,32 @@ -namespace LogExpert.Core.EventArguments +namespace LogExpert.Core.EventArguments; + +public class StatusLineEventArgs : System.EventArgs { - public class StatusLineEventArgs : System.EventArgs - { - #region Properties + #region Properties - public long FileSize { get; set; } + public long FileSize { get; set; } - public string StatusText { get; set; } = string.Empty; + public string StatusText { get; set; } = string.Empty; - public int LineCount { get; set; } + public int LineCount { get; set; } - public int CurrentLineNum { get; set; } + public int CurrentLineNum { get; set; } - #endregion + #endregion - #region Public methods + #region Public methods - public StatusLineEventArgs Clone() + public StatusLineEventArgs Clone() + { + StatusLineEventArgs e = new() { - StatusLineEventArgs e = new() - { - StatusText = StatusText, - CurrentLineNum = CurrentLineNum, - LineCount = LineCount, - FileSize = FileSize - }; - return e; - } - - #endregion + StatusText = StatusText, + CurrentLineNum = CurrentLineNum, + LineCount = LineCount, + FileSize = FileSize + }; + return e; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/EventArguments/SyncModeEventArgs.cs b/src/LogExpert.Core/EventArguments/SyncModeEventArgs.cs index f595c0d4..97378d4c 100644 --- a/src/LogExpert.Core/EventArguments/SyncModeEventArgs.cs +++ b/src/LogExpert.Core/EventArguments/SyncModeEventArgs.cs @@ -1,11 +1,10 @@ -namespace LogExpert.Core.EventArguments +namespace LogExpert.Core.EventArguments; + +public class SyncModeEventArgs(bool isSynced) : System.EventArgs { - public class SyncModeEventArgs(bool isSynced) : System.EventArgs - { - #region Properties + #region Properties - public bool IsTimeSynced { get; } = isSynced; + public bool IsTimeSynced { get; } = isSynced; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/EventHandlers/EventHandlers.cs b/src/LogExpert.Core/EventHandlers/EventHandlers.cs index 2254b17a..63f44923 100644 --- a/src/LogExpert.Core/EventHandlers/EventHandlers.cs +++ b/src/LogExpert.Core/EventHandlers/EventHandlers.cs @@ -1,8 +1,7 @@ using LogExpert.Core.Entities; using LogExpert.Core.EventArguments; -namespace LogExpert.Core.EventHandlers -{ - public delegate void ConfigChangedEventHandler(object sender, ConfigChangedEventArgs e); - public delegate void FileSizeChangedEventHandler(object sender, LogEventArgs e); -} +namespace LogExpert.Core.EventHandlers; + +public delegate void ConfigChangedEventHandler(object sender, ConfigChangedEventArgs e); +public delegate void FileSizeChangedEventHandler(object sender, LogEventArgs e); diff --git a/src/LogExpert.Core/Extensions/IEnumerable.cs b/src/LogExpert.Core/Extensions/IEnumerable.cs index 3a7524d9..d8357fb4 100644 --- a/src/LogExpert.Core/Extensions/IEnumerable.cs +++ b/src/LogExpert.Core/Extensions/IEnumerable.cs @@ -1,25 +1,24 @@ -namespace LogExpert.Core.Extensions +namespace LogExpert.Core.Extensions; + +public static class Extensions { - public static class Extensions + public static bool IsEmpty(this IEnumerable collection) { - public static bool IsEmpty(this IEnumerable collection) + if (collection == null) { - if (collection == null) - { - return true; - } - - return !collection.Any(); + return true; } - public static bool IsEmpty(this IList list) - { - if (list == null) - { - return true; - } + return !collection.Any(); + } - return list.Count == 0; + public static bool IsEmpty(this IList list) + { + if (list == null) + { + return true; } + + return list.Count == 0; } } \ No newline at end of file diff --git a/src/LogExpert.Core/Interface/IBackgroundProcessCancelHandler.cs b/src/LogExpert.Core/Interface/IBackgroundProcessCancelHandler.cs index 132589e0..b1a0ce37 100644 --- a/src/LogExpert.Core/Interface/IBackgroundProcessCancelHandler.cs +++ b/src/LogExpert.Core/Interface/IBackgroundProcessCancelHandler.cs @@ -1,18 +1,17 @@ -namespace LogExpert.Core.Interface +namespace LogExpert.Core.Interface; + +/// +/// Interface which can register at the LogWindow to be informed of pressing ESC. +/// Used e.g. for cancelling a filter. +/// +public interface IBackgroundProcessCancelHandler { + #region Public methods + /// - /// Interface which can register at the LogWindow to be informed of pressing ESC. - /// Used e.g. for cancelling a filter. + /// Called when ESC was pressed. /// - public interface IBackgroundProcessCancelHandler - { - #region Public methods - - /// - /// Called when ESC was pressed. - /// - void EscapePressed(); + void EscapePressed(); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Interface/IConfigManager.cs b/src/LogExpert.Core/Interface/IConfigManager.cs index e2de05f0..57638394 100644 --- a/src/LogExpert.Core/Interface/IConfigManager.cs +++ b/src/LogExpert.Core/Interface/IConfigManager.cs @@ -2,21 +2,20 @@ using LogExpert.Core.EventArguments; using LogExpert.Core.EventHandlers; -namespace LogExpert.Core.Interface +namespace LogExpert.Core.Interface; + +//TODO: Add documentation +public interface IConfigManager { - //TODO: Add documentation - public interface IConfigManager - { - Settings Settings { get; } - string PortableModeDir { get; } - string ConfigDir { get; } - IConfigManager Instance { get; } - string PortableModeSettingsFileName { get; } - void Export(FileInfo fileInfo, SettingsFlags highlightSettings); - void Export(FileInfo fileInfo); - void Import(FileInfo fileInfo, ExportImportFlags importFlags); - void ImportHighlightSettings(FileInfo fileInfo, ExportImportFlags importFlags); - event ConfigChangedEventHandler ConfigChanged; //TODO: All handlers that are public shoulld be in Core - void Save(SettingsFlags flags); - } + Settings Settings { get; } + string PortableModeDir { get; } + string ConfigDir { get; } + IConfigManager Instance { get; } + string PortableModeSettingsFileName { get; } + void Export(FileInfo fileInfo, SettingsFlags highlightSettings); + void Export(FileInfo fileInfo); + void Import(FileInfo fileInfo, ExportImportFlags importFlags); + void ImportHighlightSettings(FileInfo fileInfo, ExportImportFlags importFlags); + event ConfigChangedEventHandler ConfigChanged; //TODO: All handlers that are public shoulld be in Core + void Save(SettingsFlags flags); } \ No newline at end of file diff --git a/src/LogExpert.Core/Interface/IFileViewContext.cs b/src/LogExpert.Core/Interface/IFileViewContext.cs index da0b33f3..15ae41b2 100644 --- a/src/LogExpert.Core/Interface/IFileViewContext.cs +++ b/src/LogExpert.Core/Interface/IFileViewContext.cs @@ -1,10 +1,9 @@ using LogExpert.Core.Entities; -namespace LogExpert.Core.Interface +namespace LogExpert.Core.Interface; + +public interface IFileViewContext { - public interface IFileViewContext - { - ILogView LogView { get; } - ILogPaintContext LogPaintContext { get; } - } + ILogView LogView { get; } + ILogPaintContext LogPaintContext { get; } } \ No newline at end of file diff --git a/src/LogExpert.Core/Interface/ILogExpertProxy.cs b/src/LogExpert.Core/Interface/ILogExpertProxy.cs index 1bf43bcc..be0ed347 100644 --- a/src/LogExpert.Core/Interface/ILogExpertProxy.cs +++ b/src/LogExpert.Core/Interface/ILogExpertProxy.cs @@ -1,38 +1,37 @@ -namespace LogExpert.Core.Interface +namespace LogExpert.Core.Interface; + +public interface ILogExpertProxy { - public interface ILogExpertProxy - { - #region Public methods + #region Public methods - /// - /// Load the given files into the existing window. - /// - /// - void LoadFiles(string[] fileNames); + /// + /// Load the given files into the existing window. + /// + /// + void LoadFiles(string[] fileNames); - /// - /// Open a new LogExpert window and load the given files. - /// - /// - void NewWindow(string[] fileNames); + /// + /// Open a new LogExpert window and load the given files. + /// + /// + void NewWindow(string[] fileNames); - /// - /// load given files into the locked window or open a new window if no window is locked. - /// - /// - void NewWindowOrLockedWindow(string[] fileNames); + /// + /// load given files into the locked window or open a new window if no window is locked. + /// + /// + void NewWindowOrLockedWindow(string[] fileNames); - /// - /// Called from LogTabWindow when the window is about to be closed. - /// - /// - void WindowClosed(ILogTabWindow logWin); + /// + /// Called from LogTabWindow when the window is about to be closed. + /// + /// + void WindowClosed(ILogTabWindow logWin); - int GetLogWindowCount(); + int GetLogWindowCount(); - #endregion + #endregion - //void BroadcastSettingsChanged(Object cookie); - } + //void BroadcastSettingsChanged(Object cookie); } \ No newline at end of file diff --git a/src/LogExpert.Core/Interface/ILogPaintContext.cs b/src/LogExpert.Core/Interface/ILogPaintContext.cs index 2fae38fa..2cf7ad03 100644 --- a/src/LogExpert.Core/Interface/ILogPaintContext.cs +++ b/src/LogExpert.Core/Interface/ILogPaintContext.cs @@ -1,6 +1,5 @@ -namespace LogExpert.Core.Interface +namespace LogExpert.Core.Interface; + +public interface ILogPaintContext { - public interface ILogPaintContext - { - } } \ No newline at end of file diff --git a/src/LogExpert.Core/Interface/ILogStreamReader.cs b/src/LogExpert.Core/Interface/ILogStreamReader.cs index 11ce40f2..cfe4af05 100644 --- a/src/LogExpert.Core/Interface/ILogStreamReader.cs +++ b/src/LogExpert.Core/Interface/ILogStreamReader.cs @@ -1,24 +1,23 @@ using System.Text; -namespace LogExpert.Core.Interface +namespace LogExpert.Core.Interface; + +public interface ILogStreamReader : IDisposable { - public interface ILogStreamReader : IDisposable - { - #region Properties + #region Properties - long Position { get; set; } + long Position { get; set; } - bool IsBufferComplete { get; } + bool IsBufferComplete { get; } - Encoding Encoding { get; } + Encoding Encoding { get; } - #endregion + #endregion - #region Public methods + #region Public methods - int ReadChar(); - string ReadLine(); + int ReadChar(); + string ReadLine(); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Interface/ILogView.cs b/src/LogExpert.Core/Interface/ILogView.cs index c1009b55..d56bc759 100644 --- a/src/LogExpert.Core/Interface/ILogView.cs +++ b/src/LogExpert.Core/Interface/ILogView.cs @@ -1,24 +1,23 @@ -namespace LogExpert.Core.Interface +namespace LogExpert.Core.Interface; + +/// +/// Methods to control the LogWindow from other views. +/// +public interface ILogView { - /// - /// Methods to control the LogWindow from other views. - /// - public interface ILogView - { - #region Properties + #region Properties - ILogLineColumnizer CurrentColumnizer { get; } - string FileName { get; } + ILogLineColumnizer CurrentColumnizer { get; } + string FileName { get; } - #endregion + #endregion - #region Public methods + #region Public methods - void SelectLogLine(int lineNumber); - void SelectAndEnsureVisible(int line, bool triggerSyncCall); - void RefreshLogView(); - void DeleteBookmarks(List lineNumList); + void SelectLogLine(int lineNumber); + void SelectAndEnsureVisible(int line, bool triggerSyncCall); + void RefreshLogView(); + void DeleteBookmarks(List lineNumList); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Interface/IPluginRegistry.cs b/src/LogExpert.Core/Interface/IPluginRegistry.cs index 82f42f71..bca099ff 100644 --- a/src/LogExpert.Core/Interface/IPluginRegistry.cs +++ b/src/LogExpert.Core/Interface/IPluginRegistry.cs @@ -1,10 +1,9 @@ -namespace LogExpert.Core.Interface +namespace LogExpert.Core.Interface; + +//TODO: Add documentation +public interface IPluginRegistry { - //TODO: Add documentation - public interface IPluginRegistry - { - IList RegisteredColumnizers { get; } + IList RegisteredColumnizers { get; } - IFileSystemPlugin FindFileSystemForUri(string fileNameOrUri); - } + IFileSystemPlugin FindFileSystemForUri (string fileNameOrUri); } \ No newline at end of file diff --git a/src/LogExpert.Core/Interface/ISharedToolWindow.cs b/src/LogExpert.Core/Interface/ISharedToolWindow.cs index 3178206d..1d2a80e8 100644 --- a/src/LogExpert.Core/Interface/ISharedToolWindow.cs +++ b/src/LogExpert.Core/Interface/ISharedToolWindow.cs @@ -1,31 +1,30 @@ using LogExpert.Core.Config; -namespace LogExpert.Core.Interface +namespace LogExpert.Core.Interface; + +/// +/// Interface to be implemented by tools windows that are shared across multiple log files. +/// The implementor will be called whenever the current log file changes. So it can draw new content +/// according to the current active log file. +/// +public interface ISharedToolWindow { + #region Public methods + /// - /// Interface to be implemented by tools windows that are shared across multiple log files. - /// The implementor will be called whenever the current log file changes. So it can draw new content - /// according to the current active log file. + /// Called when a file becomes the active file (e.g. when user selects a tab). /// - public interface ISharedToolWindow - { - #region Public methods - - /// - /// Called when a file becomes the active file (e.g. when user selects a tab). - /// - /// - void SetCurrentFile(IFileViewContext ctx); + /// + void SetCurrentFile(IFileViewContext ctx); - /// - /// Called whenever the current file has been changed. - /// - void FileChanged(); + /// + /// Called whenever the current file has been changed. + /// + void FileChanged(); - void SetColumnizer(ILogLineColumnizer columnizer); + void SetColumnizer(ILogLineColumnizer columnizer); - void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags); + void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Structs/ActEntry.cs b/src/LogExpert.Core/Structs/ActEntry.cs index b3ea1331..1328fc1a 100644 --- a/src/LogExpert.Core/Structs/ActEntry.cs +++ b/src/LogExpert.Core/Structs/ActEntry.cs @@ -1,9 +1,8 @@ -namespace LogExpert.Core.Structs +namespace LogExpert.Core.Structs; + +public struct ActEntry { - public struct ActEntry - { - public string Name { get; set; } + public string Name { get; set; } - public IKeywordAction Plugin { get; set; } - } + public IKeywordAction Plugin { get; set; } } \ No newline at end of file diff --git a/src/LogExpert.Tests/BufferShiftTest.cs b/src/LogExpert.Tests/BufferShiftTest.cs index fc824ad3..bbbefee5 100644 --- a/src/LogExpert.Tests/BufferShiftTest.cs +++ b/src/LogExpert.Tests/BufferShiftTest.cs @@ -1,146 +1,147 @@ -using LogExpert.Core.Classes.Log; -using LogExpert.Core.Entities; -using LogExpert.PluginRegistry.FileSystem; -using NUnit.Framework; using System.Collections.Generic; using System.Linq; using System.Text; -namespace LogExpert.Tests +using LogExpert.Core.Classes.Log; +using LogExpert.Core.Entities; +using LogExpert.PluginRegistry.FileSystem; + +using NUnit.Framework; + +namespace LogExpert.Tests; + +[TestFixture] +internal class BufferShiftTest : RolloverHandlerTestBase { - [TestFixture] - internal class BufferShiftTest : RolloverHandlerTestBase + [TearDown] + public void TearDown () { - [TearDown] - public void TearDown() - { - Cleanup(); - } + Cleanup(); + } + + [OneTimeSetUp] + public void Boot () + { + Cleanup(); + } - [OneTimeSetUp] - public void Boot() + + [Test] + public void TestShiftBuffers1 () + { + var linesPerFile = 10; + MultiFileOptions options = new() { - Cleanup(); - } + MaxDayTry = 0, + FormatPattern = "*$J(.)" + }; + LinkedList files = CreateTestFilesWithoutDate(); + EncodingOptions encodingOptions = new() + { + Encoding = Encoding.Default + }; + PluginRegistry.PluginRegistry.Instance.Create(testDirectory.FullName, 500); + LogfileReader reader = new(files.Last.Value, encodingOptions, true, 40, 50, options, PluginRegistry.PluginRegistry.Instance); + reader.ReadFiles(); - [Test] - public void TestShiftBuffers1() + IList lil = reader.GetLogFileInfoList(); + Assert.That(lil.Count, Is.EqualTo(files.Count)); + + LinkedList.Enumerator enumerator = files.GetEnumerator(); + enumerator.MoveNext(); + + foreach (LogFileInfo li in lil.Cast()) { - var linesPerFile = 10; - MultiFileOptions options = new() - { - MaxDayTry = 0, - FormatPattern = "*$J(.)" - }; - LinkedList files = CreateTestFilesWithoutDate(); - EncodingOptions encodingOptions = new() - { - Encoding = Encoding.Default - }; - - PluginRegistry.PluginRegistry.Instance.Create(testDirectory.FullName, 500); - LogfileReader reader = new(files.Last.Value, encodingOptions, true, 40, 50, options, PluginRegistry.PluginRegistry.Instance); - reader.ReadFiles(); - - IList lil = reader.GetLogFileInfoList(); - Assert.That(lil.Count, Is.EqualTo(files.Count)); - - LinkedList.Enumerator enumerator = files.GetEnumerator(); + var fileName = enumerator.Current; + Assert.That(li.FullName, Is.EqualTo(fileName)); enumerator.MoveNext(); + } + var oldCount = lil.Count; - foreach (LogFileInfo li in lil.Cast()) - { - var fileName = enumerator.Current; - Assert.That(li.FullName, Is.EqualTo(fileName)); - enumerator.MoveNext(); - } - var oldCount = lil.Count; - - // Simulate rollover - // - files = RolloverSimulation(files, "*$J(.)", false); + // Simulate rollover + // + files = RolloverSimulation(files, "*$J(.)", false); - // Simulate rollover detection - // - reader.ShiftBuffers(); + // Simulate rollover detection + // + reader.ShiftBuffers(); - lil = reader.GetLogFileInfoList(); - Assert.That(lil.Count, Is.EqualTo(oldCount + 1)); + lil = reader.GetLogFileInfoList(); + Assert.That(lil.Count, Is.EqualTo(oldCount + 1)); - Assert.That(reader.LineCount, Is.EqualTo(linesPerFile * lil.Count)); + Assert.That(reader.LineCount, Is.EqualTo(linesPerFile * lil.Count)); - // Check if rollover'd file names have been handled by LogfileReader - // - Assert.That(lil.Count, Is.EqualTo(files.Count)); - enumerator = files.GetEnumerator(); - enumerator.MoveNext(); - foreach (LogFileInfo li in lil) - { - var fileName = enumerator.Current; - Assert.That(li.FullName, Is.EqualTo(fileName)); - enumerator.MoveNext(); - } - - // Check if file buffers have correct files. Assuming here that one buffer fits for a - // complete file - // - enumerator = files.GetEnumerator(); + // Check if rollover'd file names have been handled by LogfileReader + // + Assert.That(lil.Count, Is.EqualTo(files.Count)); + enumerator = files.GetEnumerator(); + enumerator.MoveNext(); + foreach (LogFileInfo li in lil) + { + var fileName = enumerator.Current; + Assert.That(li.FullName, Is.EqualTo(fileName)); enumerator.MoveNext(); - IList logBuffers = reader.GetBufferList(); - var startLine = 0; - foreach (LogBuffer logBuffer in logBuffers) - { - Assert.That(enumerator.Current, Is.EqualTo(logBuffer.FileInfo.FullName)); - Assert.That(logBuffer.StartLine, Is.EqualTo(startLine)); - startLine += 10; - enumerator.MoveNext(); - } - - // Checking file content - // - enumerator = files.GetEnumerator(); + } + + // Check if file buffers have correct files. Assuming here that one buffer fits for a + // complete file + // + enumerator = files.GetEnumerator(); + enumerator.MoveNext(); + IList logBuffers = reader.GetBufferList(); + var startLine = 0; + foreach (LogBuffer logBuffer in logBuffers) + { + Assert.That(enumerator.Current, Is.EqualTo(logBuffer.FileInfo.FullName)); + Assert.That(logBuffer.StartLine, Is.EqualTo(startLine)); + startLine += 10; enumerator.MoveNext(); - enumerator.MoveNext(); // move to 2nd entry. The first file now contains 2nd file's content (because rollover) - logBuffers = reader.GetBufferList(); - int i; - for (i = 0; i < logBuffers.Count - 2; ++i) - { - LogBuffer logBuffer = logBuffers[i]; - ILogLine line = logBuffer.GetLineOfBlock(0); - Assert.That(line.FullLine.Contains(enumerator.Current)); - enumerator.MoveNext(); - } + } + + // Checking file content + // + enumerator = files.GetEnumerator(); + enumerator.MoveNext(); + enumerator.MoveNext(); // move to 2nd entry. The first file now contains 2nd file's content (because rollover) + logBuffers = reader.GetBufferList(); + int i; + for (i = 0; i < logBuffers.Count - 2; ++i) + { + LogBuffer logBuffer = logBuffers[i]; + ILogLine line = logBuffer.GetLineOfBlock(0); + Assert.That(line.FullLine.Contains(enumerator.Current)); enumerator.MoveNext(); - // the last 2 files now contain the content of the previously watched file - for (; i < logBuffers.Count; ++i) - { - LogBuffer logBuffer = logBuffers[i]; - ILogLine line = logBuffer.GetLineOfBlock(0); - Assert.That(line.FullLine.Contains(enumerator.Current)); - } - - oldCount = lil.Count; - - // Simulate rollover again - now latest file will be deleted (simulates logger's rollover history limit) - // - files = RolloverSimulation(files, "*$J(.)", true); - - // Simulate rollover detection - // - reader.ShiftBuffers(); - lil = reader.GetLogFileInfoList(); - - Assert.That(lil.Count, Is.EqualTo(oldCount)); // same count because oldest file is deleted - Assert.That(lil.Count, Is.EqualTo(files.Count)); - Assert.That(reader.LineCount, Is.EqualTo(linesPerFile * lil.Count)); - - // Check first line to see if buffers are correct - // - ILogLine firstLine = reader.GetLogLine(0); - var names = new string[files.Count]; - files.CopyTo(names, 0); - Assert.That(firstLine.FullLine.Contains(names[2])); } + enumerator.MoveNext(); + // the last 2 files now contain the content of the previously watched file + for (; i < logBuffers.Count; ++i) + { + LogBuffer logBuffer = logBuffers[i]; + ILogLine line = logBuffer.GetLineOfBlock(0); + Assert.That(line.FullLine.Contains(enumerator.Current)); + } + + oldCount = lil.Count; + + // Simulate rollover again - now latest file will be deleted (simulates logger's rollover history limit) + // + files = RolloverSimulation(files, "*$J(.)", true); + + // Simulate rollover detection + // + reader.ShiftBuffers(); + lil = reader.GetLogFileInfoList(); + + Assert.That(lil.Count, Is.EqualTo(oldCount)); // same count because oldest file is deleted + Assert.That(lil.Count, Is.EqualTo(files.Count)); + Assert.That(reader.LineCount, Is.EqualTo(linesPerFile * lil.Count)); + + // Check first line to see if buffers are correct + // + ILogLine firstLine = reader.GetLogLine(0); + var names = new string[files.Count]; + files.CopyTo(names, 0); + Assert.That(firstLine.FullLine.Contains(names[2])); } } \ No newline at end of file diff --git a/src/LogExpert.Tests/CSVColumnizerTest.cs b/src/LogExpert.Tests/CSVColumnizerTest.cs index a90167bc..1c9ccce1 100644 --- a/src/LogExpert.Tests/CSVColumnizerTest.cs +++ b/src/LogExpert.Tests/CSVColumnizerTest.cs @@ -6,28 +6,27 @@ using System; using System.IO; -namespace LogExpert.Tests +namespace LogExpert.Tests; + +[TestFixture] +public class CSVColumnizerTest { - [TestFixture] - public class CSVColumnizerTest + [TestCase(@".\TestData\organizations-10000.csv", new[] { "Index", "Organization Id", "Name", "Website", "Country", "Description", "Founded", "Industry", "Number of employees" })] + [TestCase(@".\TestData\organizations-1000.csv", new[] { "Index", "Organization Id", "Name", "Website", "Country", "Description", "Founded", "Industry", "Number of employees" })] + [TestCase(@".\TestData\people-10000.csv", new[] { "Index", "User Id", "First Name", "Last Name", "Sex", "Email", "Phone", "Date of birth", "Job Title" })] + public void Instantiat_CSVFile_BuildCorrectColumnizer(string filename, string[] expectedHeaders) { - [TestCase(@".\TestData\organizations-10000.csv", new[] { "Index", "Organization Id", "Name", "Website", "Country", "Description", "Founded", "Industry", "Number of employees" })] - [TestCase(@".\TestData\organizations-1000.csv", new[] { "Index", "Organization Id", "Name", "Website", "Country", "Description", "Founded", "Industry", "Number of employees" })] - [TestCase(@".\TestData\people-10000.csv", new[] { "Index", "User Id", "First Name", "Last Name", "Sex", "Email", "Phone", "Date of birth", "Job Title" })] - public void Instantiat_CSVFile_BuildCorrectColumnizer(string filename, string[] expectedHeaders) + CsvColumnizer.CsvColumnizer csvColumnizer = new(); + var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename); + LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); + reader.ReadFiles(); + ILogLine line = reader.GetLogLine(0); + IColumnizedLogLine logline = new ColumnizedLogLine(); + if (line != null) { - CsvColumnizer.CsvColumnizer csvColumnizer = new(); - var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename); - LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); - reader.ReadFiles(); - ILogLine line = reader.GetLogLine(0); - IColumnizedLogLine logline = new ColumnizedLogLine(); - if (line != null) - { - logline = csvColumnizer.SplitLine(null, line); - } - var expectedResult = string.Join(",", expectedHeaders); - Assert.That(logline.LogLine.FullLine, Is.EqualTo(expectedResult)); + logline = csvColumnizer.SplitLine(null, line); } + var expectedResult = string.Join(",", expectedHeaders); + Assert.That(logline.LogLine.FullLine, Is.EqualTo(expectedResult)); } } diff --git a/src/LogExpert.Tests/ColumnizerPickerTest.cs b/src/LogExpert.Tests/ColumnizerPickerTest.cs index 59d7a23b..f6204673 100644 --- a/src/LogExpert.Tests/ColumnizerPickerTest.cs +++ b/src/LogExpert.Tests/ColumnizerPickerTest.cs @@ -7,111 +7,110 @@ using System; using System.IO; -namespace LogExpert.Tests +namespace LogExpert.Tests; + +/// +/// Summary description for AutoColumnizerTest +/// +[TestFixture] +public class ColumnizerPickerTest { - /// - /// Summary description for AutoColumnizerTest - /// - [TestFixture] - public class ColumnizerPickerTest + [TestCase("Square Bracket Columnizer", "30/08/2018 08:51:42.712 [TRACE] [a] hello", "30/08/2018 08:51:42.712 [DATAIO] [b] world", null, null, null)] + [TestCase("Square Bracket Columnizer", "30/08/2018 08:51:42.712 [TRACE] hello", "30/08/2018 08:51:42.712 [DATAIO][] world", null, null, null)] + [TestCase("Square Bracket Columnizer", "", "30/08/2018 08:51:42.712 [TRACE] hello", "30/08/2018 08:51:42.712 [TRACE] hello", "[DATAIO][b][c] world", null)] + [TestCase("Timestamp Columnizer", "30/08/2018 08:51:42.712 no bracket 1", "30/08/2018 08:51:42.712 no bracket 2", "30/08/2018 08:51:42.712 [TRACE] with bracket 1", "30/08/2018 08:51:42.712 [TRACE] with bracket 2", "no bracket 3")] + public void FindColumnizer_ReturnCorrectColumnizer(string expectedColumnizerName, string line0, string line1, string line2, string line3, string line4) { - [TestCase("Square Bracket Columnizer", "30/08/2018 08:51:42.712 [TRACE] [a] hello", "30/08/2018 08:51:42.712 [DATAIO] [b] world", null, null, null)] - [TestCase("Square Bracket Columnizer", "30/08/2018 08:51:42.712 [TRACE] hello", "30/08/2018 08:51:42.712 [DATAIO][] world", null, null, null)] - [TestCase("Square Bracket Columnizer", "", "30/08/2018 08:51:42.712 [TRACE] hello", "30/08/2018 08:51:42.712 [TRACE] hello", "[DATAIO][b][c] world", null)] - [TestCase("Timestamp Columnizer", "30/08/2018 08:51:42.712 no bracket 1", "30/08/2018 08:51:42.712 no bracket 2", "30/08/2018 08:51:42.712 [TRACE] with bracket 1", "30/08/2018 08:51:42.712 [TRACE] with bracket 2", "no bracket 3")] - public void FindColumnizer_ReturnCorrectColumnizer(string expectedColumnizerName, string line0, string line1, string line2, string line3, string line4) + var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test"); + + Mock autoLogLineColumnizerCallbackMock = new(); + + autoLogLineColumnizerCallbackMock.Setup(a => a.GetLogLine(0)).Returns(new TestLogLine() { - var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test"); - - Mock autoLogLineColumnizerCallbackMock = new(); - - autoLogLineColumnizerCallbackMock.Setup(a => a.GetLogLine(0)).Returns(new TestLogLine() - { - FullLine = line0, - LineNumber = 0 - }); - - autoLogLineColumnizerCallbackMock.Setup(a => a.GetLogLine(1)).Returns(new TestLogLine() - { - FullLine = line1, - LineNumber = 1 - }); - - autoLogLineColumnizerCallbackMock.Setup(a => a.GetLogLine(2)).Returns(new TestLogLine() - { - FullLine = line2, - LineNumber = 2 - }); - - autoLogLineColumnizerCallbackMock.Setup(a => a.GetLogLine(3)).Returns(new TestLogLine() - { - FullLine = line3, - LineNumber = 3 - }); - autoLogLineColumnizerCallbackMock.Setup(a => a.GetLogLine(4)).Returns(new TestLogLine() - { - FullLine = line4, - LineNumber = 4 - }); - - var result = ColumnizerPicker.FindColumnizer(path, autoLogLineColumnizerCallbackMock.Object, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - - Assert.That(result.GetName(), Is.EqualTo(expectedColumnizerName)); - } - - - [TestCase(@".\TestData\JsonColumnizerTest_01.txt", typeof(JsonCompactColumnizer))] - [TestCase(@".\TestData\SquareBracketColumnizerTest_02.txt", typeof(SquareBracketColumnizer))] - public void FindReplacementForAutoColumnizer_ValidTextFile_ReturnCorrectColumnizer( - string fileName, Type columnizerType) + FullLine = line0, + LineNumber = 0 + }); + + autoLogLineColumnizerCallbackMock.Setup(a => a.GetLogLine(1)).Returns(new TestLogLine() + { + FullLine = line1, + LineNumber = 1 + }); + + autoLogLineColumnizerCallbackMock.Setup(a => a.GetLogLine(2)).Returns(new TestLogLine() { - var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); - reader.ReadFiles(); + FullLine = line2, + LineNumber = 2 + }); - Mock autoColumnizer = new(); - autoColumnizer.Setup(a => a.GetName()).Returns("Auto Columnizer"); + autoLogLineColumnizerCallbackMock.Setup(a => a.GetLogLine(3)).Returns(new TestLogLine() + { + FullLine = line3, + LineNumber = 3 + }); + autoLogLineColumnizerCallbackMock.Setup(a => a.GetLogLine(4)).Returns(new TestLogLine() + { + FullLine = line4, + LineNumber = 4 + }); - // TODO: When DI container is ready, we can mock this set up. - PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers.Add(new JsonCompactColumnizer()); - var result = ColumnizerPicker.FindReplacementForAutoColumnizer(fileName, reader, autoColumnizer.Object, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + var result = ColumnizerPicker.FindColumnizer(path, autoLogLineColumnizerCallbackMock.Object, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - Assert.That(columnizerType, Is.EqualTo(result.GetType())); - } + Assert.That(result.GetName(), Is.EqualTo(expectedColumnizerName)); + } - [TestCase(@".\TestData\FileNotExists.txt", typeof(DefaultLogfileColumnizer))] - public void DecideColumnizerByName_WhenReaderIsNotReady_ReturnCorrectColumnizer( - string fileName, Type columnizerType) - { - var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - // TODO: When DI container is ready, we can mock this set up. - PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers.Add(new JsonCompactColumnizer()); - var result = ColumnizerPicker.DecideColumnizerByName(fileName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + [TestCase(@".\TestData\JsonColumnizerTest_01.txt", typeof(JsonCompactColumnizer))] + [TestCase(@".\TestData\SquareBracketColumnizerTest_02.txt", typeof(SquareBracketColumnizer))] + public void FindReplacementForAutoColumnizer_ValidTextFile_ReturnCorrectColumnizer( + string fileName, Type columnizerType) + { + var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); + LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); + reader.ReadFiles(); - Assert.That(columnizerType, Is.EqualTo(result.GetType())); - } + Mock autoColumnizer = new(); + autoColumnizer.Setup(a => a.GetName()).Returns("Auto Columnizer"); - [TestCase(@"Invalid Name", typeof(DefaultLogfileColumnizer))] - [TestCase(@"JSON Columnizer", typeof(JsonColumnizer.JsonColumnizer))] - public void DecideColumnizerByName_ValidTextFile_ReturnCorrectColumnizer( - string columnizerName, Type columnizerType) - { - var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, columnizerName); + // TODO: When DI container is ready, we can mock this set up. + PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers.Add(new JsonCompactColumnizer()); + var result = ColumnizerPicker.FindReplacementForAutoColumnizer(fileName, reader, autoColumnizer.Object, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - // TODO: When DI container is ready, we can mock this set up. - PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers.Add(new JsonColumnizer.JsonColumnizer()); + Assert.That(columnizerType, Is.EqualTo(result.GetType())); + } - var result = ColumnizerPicker.DecideColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + [TestCase(@".\TestData\FileNotExists.txt", typeof(DefaultLogfileColumnizer))] + public void DecideColumnizerByName_WhenReaderIsNotReady_ReturnCorrectColumnizer( + string fileName, Type columnizerType) + { + var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - Assert.That(columnizerType, Is.EqualTo(result.GetType())); - } + // TODO: When DI container is ready, we can mock this set up. + PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers.Add(new JsonCompactColumnizer()); + var result = ColumnizerPicker.DecideColumnizerByName(fileName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - private class TestLogLine : ILogLine - { - public string Text => FullLine; - public string FullLine { get; set; } - public int LineNumber { get; set; } - } + Assert.That(columnizerType, Is.EqualTo(result.GetType())); + } + + [TestCase(@"Invalid Name", typeof(DefaultLogfileColumnizer))] + [TestCase(@"JSON Columnizer", typeof(JsonColumnizer.JsonColumnizer))] + public void DecideColumnizerByName_ValidTextFile_ReturnCorrectColumnizer( + string columnizerName, Type columnizerType) + { + var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, columnizerName); + + // TODO: When DI container is ready, we can mock this set up. + PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers.Add(new JsonColumnizer.JsonColumnizer()); + + var result = ColumnizerPicker.DecideColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + + Assert.That(columnizerType, Is.EqualTo(result.GetType())); + } + + private class TestLogLine : ILogLine + { + public string Text => FullLine; + public string FullLine { get; set; } + public int LineNumber { get; set; } } } \ No newline at end of file diff --git a/src/LogExpert.Tests/DateFormatParserTest.cs b/src/LogExpert.Tests/DateFormatParserTest.cs index ece598d2..ca8622ee 100644 --- a/src/LogExpert.Tests/DateFormatParserTest.cs +++ b/src/LogExpert.Tests/DateFormatParserTest.cs @@ -8,121 +8,120 @@ using System.Linq; using System.Text; -namespace LogExpert.Tests +namespace LogExpert.Tests; + +[TestFixture] +public class DateFormatParserTest { - [TestFixture] - public class DateFormatParserTest + [Test] + public void CanParseAllCultures() { - [Test] - public void CanParseAllCultures() - { - var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); + var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); - // HashSet exclude = ["dz", "ckb-IR", "ar-SA", "lrc" , "lrc-IR", "mzn" , "mzn-IR", "ps"]; + // HashSet exclude = ["dz", "ckb-IR", "ar-SA", "lrc" , "lrc-IR", "mzn" , "mzn-IR", "ps"]; - foreach (var culture in cultures) + foreach (var culture in cultures) + { + if (culture.Name == "dz" || culture.Name == "ar" || culture.Name.StartsWith("ar-") || culture.Name.StartsWith("dz-")) { - if (culture.Name == "dz" || culture.Name == "ar" || culture.Name.StartsWith("ar-") || culture.Name.StartsWith("dz-")) - { - Console.WriteLine($"The ${culture.Name} (${culture.DisplayName}) time format is not supported yet."); - continue; - } + Console.WriteLine($"The ${culture.Name} (${culture.DisplayName}) time format is not supported yet."); + continue; + } - var datePattern = GetDateAndTimeFormat(culture); + var datePattern = GetDateAndTimeFormat(culture); - if (datePattern.StartsWith('g')) - { - Console.WriteLine("time format that starts with g is not supported yet."); - continue; - } + if (datePattern.StartsWith('g')) + { + Console.WriteLine("time format that starts with g is not supported yet."); + continue; + } - var message = $"Culture: {culture.Name} ({culture.EnglishName} {datePattern})"; - var sections = Parser.ParseSections(datePattern, out var syntaxError); + var message = $"Culture: {culture.Name} ({culture.EnglishName} {datePattern})"; + var sections = Parser.ParseSections(datePattern, out var syntaxError); - Assert.That(syntaxError, Is.False, message); + Assert.That(syntaxError, Is.False, message); - var dateSection = sections.FirstOrDefault(); - Assert.That(dateSection, Is.Not.Null, message); + var dateSection = sections.FirstOrDefault(); + Assert.That(dateSection, Is.Not.Null, message); - var now = DateTime.Now; - var expectedFormattedDate = now.ToString(datePattern); - var actualFormattedDate = now.ToString(string.Join("", dateSection.GeneralTextDateDurationParts)); - Assert.That(actualFormattedDate, Is.EqualTo(expectedFormattedDate), message); - } + var now = DateTime.Now; + var expectedFormattedDate = now.ToString(datePattern); + var actualFormattedDate = now.ToString(string.Join("", dateSection.GeneralTextDateDurationParts)); + Assert.That(actualFormattedDate, Is.EqualTo(expectedFormattedDate), message); } + } - [Test] - [TestCase("en-US", "MM", "dd", "yyyy", "hh", "mm", "ss", "tt")] - [TestCase("fr-FR", "dd", "MM", "yyyy", "HH", "mm", "ss")] - [TestCase("de-DE", "dd", "MM", "yyyy", "HH", "mm", "ss")] - [TestCase("ar-TN", "dd", "MM", "yyyy", "hh", "mm", "ss", "tt")] - [TestCase("as", "dd", "MM", "yyyy", "tt", "hh", "mm", "ss")] - [TestCase("bg", "dd", "MM", "yyyy", "HH", "mm", "ss")] - public void TestDateFormatParserFromCulture(string cultureInfoName, params string[] expectedDateParts) - { - var culture = CultureInfo.GetCultureInfo(cultureInfoName); + [Test] + [TestCase("en-US", "MM", "dd", "yyyy", "hh", "mm", "ss", "tt")] + [TestCase("fr-FR", "dd", "MM", "yyyy", "HH", "mm", "ss")] + [TestCase("de-DE", "dd", "MM", "yyyy", "HH", "mm", "ss")] + [TestCase("ar-TN", "dd", "MM", "yyyy", "hh", "mm", "ss", "tt")] + [TestCase("as", "dd", "MM", "yyyy", "tt", "hh", "mm", "ss")] + [TestCase("bg", "dd", "MM", "yyyy", "HH", "mm", "ss")] + public void TestDateFormatParserFromCulture(string cultureInfoName, params string[] expectedDateParts) + { + var culture = CultureInfo.GetCultureInfo(cultureInfoName); - var datePattern = GetDateAndTimeFormat(culture); + var datePattern = GetDateAndTimeFormat(culture); - var sections = Parser.ParseSections(datePattern, out var syntaxError); + var sections = Parser.ParseSections(datePattern, out var syntaxError); - var message = $"Culture: {culture.EnglishName}, Actual date pattern: {datePattern}"; + var message = $"Culture: {culture.EnglishName}, Actual date pattern: {datePattern}"; - Assert.That(syntaxError, Is.False, message); + Assert.That(syntaxError, Is.False, message); - var dateSection = sections.FirstOrDefault(); - Assert.That(dateSection, Is.Not.Null); + var dateSection = sections.FirstOrDefault(); + Assert.That(dateSection, Is.Not.Null); - var dateParts = dateSection - .GeneralTextDateDurationParts - .Where(Token.IsDatePart) - .Select(p => DateFormatPartAdjuster.AdjustDateTimeFormatPart(p)) - .ToArray(); + var dateParts = dateSection + .GeneralTextDateDurationParts + .Where(Token.IsDatePart) + .Select(p => DateFormatPartAdjuster.AdjustDateTimeFormatPart(p)) + .ToArray(); - Assert.That(dateParts.Length, Is.EqualTo(expectedDateParts.Length), message); + Assert.That(dateParts.Length, Is.EqualTo(expectedDateParts.Length), message); - for (var i = 0; i < expectedDateParts.Length; i++) - { - var expected = expectedDateParts[i]; - var actual = dateParts[i]; - Assert.That(actual, Is.EqualTo(expected), message); - } + for (var i = 0; i < expectedDateParts.Length; i++) + { + var expected = expectedDateParts[i]; + var actual = dateParts[i]; + Assert.That(actual, Is.EqualTo(expected), message); } + } - static string RemoveCharacters(string input, string charsToRemove) - { - HashSet charsToRemoveSet = new(charsToRemove); - StringBuilder result = new(); + static string RemoveCharacters(string input, string charsToRemove) + { + HashSet charsToRemoveSet = new(charsToRemove); + StringBuilder result = new(); - foreach (var c in input) + foreach (var c in input) + { + if (!charsToRemoveSet.Contains(c)) { - if (!charsToRemoveSet.Contains(c)) - { - result.Append(c); - } + result.Append(c); } - - return result.ToString(); } - private string GetDateAndTimeFormat(CultureInfo culture) - { + return result.ToString(); + } - var InvisibleUNICODEmarkers = - "\u00AD\u034F\u061C\u115F\u1160\u17B4\u17B5" + - "\u180B\u180C\u180D\u180E\u200B\u200C\u200D\u200E\u200F" + - "\u202A\u202B\u202C\u202D\u202E\u202F\u205F\u2060\u2062" + - "\u2063\u2064\u2066\u2067\u2068\u2069\u2800\u3164\uFE00" + - "\uFE01\uFE02\uFE03\uFE04\uFE05\uFE06\uFE07\uFE08\uFE09" + - "\uFE0A\uFE0B\uFE0C\uFE0D\uFE0E\uFE0F"; + private string GetDateAndTimeFormat(CultureInfo culture) + { + var InvisibleUNICODEmarkers = + "\u00AD\u034F\u061C\u115F\u1160\u17B4\u17B5" + + "\u180B\u180C\u180D\u180E\u200B\u200C\u200D\u200E\u200F" + + "\u202A\u202B\u202C\u202D\u202E\u202F\u205F\u2060\u2062" + + "\u2063\u2064\u2066\u2067\u2068\u2069\u2800\u3164\uFE00" + + "\uFE01\uFE02\uFE03\uFE04\uFE05\uFE06\uFE07\uFE08\uFE09" + + "\uFE0A\uFE0B\uFE0C\uFE0D\uFE0E\uFE0F"; - var dateTime = string.Concat(culture.DateTimeFormat.ShortDatePattern.ToString(), - " ", - culture.DateTimeFormat.LongTimePattern.ToString()); - return RemoveCharacters(dateTime, InvisibleUNICODEmarkers); + var dateTime = string.Concat(culture.DateTimeFormat.ShortDatePattern.ToString(), + " ", + culture.DateTimeFormat.LongTimePattern.ToString()); + + return RemoveCharacters(dateTime, InvisibleUNICODEmarkers); - } } } diff --git a/src/LogExpert.Tests/Extensions/EnumerableTests.cs b/src/LogExpert.Tests/Extensions/EnumerableTests.cs index 2c7548c1..cbc4fd7d 100644 --- a/src/LogExpert.Tests/Extensions/EnumerableTests.cs +++ b/src/LogExpert.Tests/Extensions/EnumerableTests.cs @@ -4,57 +4,56 @@ using System.Collections.Generic; -namespace LogExpert.Tests.Extensions +namespace LogExpert.Tests.Extensions; + +[TestFixture] +public class EnumerableTests { - [TestFixture] - public class EnumerableTests + [Test] + public void Extensions_IsEmpty_NullArray() { - [Test] - public void Extensions_IsEmpty_NullArray() - { - object[] arrayObject = null; + object[] arrayObject = null; - Assert.That(arrayObject.IsEmpty(), Is.True); - } + Assert.That(arrayObject.IsEmpty(), Is.True); + } - [Test] - public void Extensions_IsEmpty_EmptyArray() - { - object[] arrayObject = []; + [Test] + public void Extensions_IsEmpty_EmptyArray() + { + object[] arrayObject = []; - Assert.That(arrayObject.IsEmpty(), Is.True); - } + Assert.That(arrayObject.IsEmpty(), Is.True); + } - [Test] - public void Extensions_IsEmpty_FilledArray() - { - object[] arrayObject = [new()]; + [Test] + public void Extensions_IsEmpty_FilledArray() + { + object[] arrayObject = [new()]; - Assert.That(!arrayObject.IsEmpty(), Is.True); - } + Assert.That(!arrayObject.IsEmpty(), Is.True); + } - [Test] - public void Extensions_IsEmpty_NullIEnumerable() - { - IEnumerable arrayObject = null; + [Test] + public void Extensions_IsEmpty_NullIEnumerable() + { + IEnumerable arrayObject = null; - Assert.That(arrayObject.IsEmpty(), Is.True); - } + Assert.That(arrayObject.IsEmpty(), Is.True); + } - [Test] - public void Extensions_IsEmpty_EmptyIEnumerable() - { - IEnumerable arrayObject = []; + [Test] + public void Extensions_IsEmpty_EmptyIEnumerable() + { + IEnumerable arrayObject = []; - Assert.That(arrayObject.IsEmpty(), Is.True); - } + Assert.That(arrayObject.IsEmpty(), Is.True); + } - [Test] - public void Extensions_IsEmpty_FilledIEnumerable() - { - IEnumerable arrayObject = new List([new object()]); + [Test] + public void Extensions_IsEmpty_FilledIEnumerable() + { + IEnumerable arrayObject = new List([new object()]); - Assert.That(!arrayObject.IsEmpty(), Is.True); - } + Assert.That(!arrayObject.IsEmpty(), Is.True); } } diff --git a/src/LogExpert.Tests/JSONSaveTest.cs b/src/LogExpert.Tests/JSONSaveTest.cs index 234c272b..e4193294 100644 --- a/src/LogExpert.Tests/JSONSaveTest.cs +++ b/src/LogExpert.Tests/JSONSaveTest.cs @@ -7,39 +7,38 @@ using System.IO; -namespace LogExpert.Tests +namespace LogExpert.Tests; + +[TestFixture] +public class JSONSaveTest { - [TestFixture] - public class JSONSaveTest + [Test(Author = "Hirogen", Description = "Save Options as JSON and Check if the written file can be cast again into the settings object")] + public void SaveOptionsAsJSON() { - [Test(Author = "Hirogen", Description = "Save Options as JSON and Check if the written file can be cast again into the settings object")] - public void SaveOptionsAsJSON() + ConfigManager.Instance.Settings.alwaysOnTop = true; + ConfigManager.Instance.Save(SettingsFlags.All); + var configDir = ConfigManager.Instance.ConfigDir; + var settingsFile = configDir + "\\settings.json"; + + Settings settings = null; + + Assert.DoesNotThrow(CastSettings); + Assert.That(settings, Is.Not.Null); + Assert.That(settings.alwaysOnTop, Is.True); + + ConfigManager.Instance.Settings.alwaysOnTop = false; + ConfigManager.Instance.Save(SettingsFlags.All); + + settings = null; + Assert.DoesNotThrow(CastSettings); + + Assert.That(settings, !Is.Null); + Assert.That(settings.alwaysOnTop, Is.False); + + + void CastSettings() { - ConfigManager.Instance.Settings.alwaysOnTop = true; - ConfigManager.Instance.Save(SettingsFlags.All); - var configDir = ConfigManager.Instance.ConfigDir; - var settingsFile = configDir + "\\settings.json"; - - Settings settings = null; - - Assert.DoesNotThrow(CastSettings); - Assert.That(settings, Is.Not.Null); - Assert.That(settings.alwaysOnTop, Is.True); - - ConfigManager.Instance.Settings.alwaysOnTop = false; - ConfigManager.Instance.Save(SettingsFlags.All); - - settings = null; - Assert.DoesNotThrow(CastSettings); - - Assert.That(settings, !Is.Null); - Assert.That(settings.alwaysOnTop, Is.False); - - - void CastSettings() - { - settings = JsonConvert.DeserializeObject(File.ReadAllText(settingsFile)); - } + settings = JsonConvert.DeserializeObject(File.ReadAllText(settingsFile)); } } } diff --git a/src/LogExpert.Tests/JsonColumnizerTest.cs b/src/LogExpert.Tests/JsonColumnizerTest.cs index 3058866f..87e5c369 100644 --- a/src/LogExpert.Tests/JsonColumnizerTest.cs +++ b/src/LogExpert.Tests/JsonColumnizerTest.cs @@ -6,34 +6,33 @@ using System; using System.IO; -namespace LogExpert.Tests +namespace LogExpert.Tests; + +[TestFixture] +public class JsonColumnizerTest { - [TestFixture] - public class JsonColumnizerTest + [TestCase(@".\TestData\JsonColumnizerTest_01.txt", "time @m level")] + public void GetColumnNames_HappyFile_ColumnNameMatches(string fileName, string expectedHeaders) { - [TestCase(@".\TestData\JsonColumnizerTest_01.txt", "time @m level")] - public void GetColumnNames_HappyFile_ColumnNameMatches(string fileName, string expectedHeaders) - { - var jsonColumnizer = new JsonColumnizer.JsonColumnizer(); - var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); - reader.ReadFiles(); + var jsonColumnizer = new JsonColumnizer.JsonColumnizer(); + var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); + LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); + reader.ReadFiles(); - ILogLine line = reader.GetLogLine(0); - if (line != null) - { - jsonColumnizer.SplitLine(null, line); - } - - line = reader.GetLogLine(1); - if (line != null) - { - jsonColumnizer.SplitLine(null, line); - } + ILogLine line = reader.GetLogLine(0); + if (line != null) + { + jsonColumnizer.SplitLine(null, line); + } - var columnHeaders = jsonColumnizer.GetColumnNames(); - var result = string.Join(" ", columnHeaders); - Assert.That(expectedHeaders, Is.EqualTo(result)); + line = reader.GetLogLine(1); + if (line != null) + { + jsonColumnizer.SplitLine(null, line); } + + var columnHeaders = jsonColumnizer.GetColumnNames(); + var result = string.Join(" ", columnHeaders); + Assert.That(expectedHeaders, Is.EqualTo(result)); } } diff --git a/src/LogExpert.Tests/JsonCompactColumnizerTest.cs b/src/LogExpert.Tests/JsonCompactColumnizerTest.cs index 1bc85ed4..5811be64 100644 --- a/src/LogExpert.Tests/JsonCompactColumnizerTest.cs +++ b/src/LogExpert.Tests/JsonCompactColumnizerTest.cs @@ -7,38 +7,37 @@ using System.Collections.Generic; using System.IO; -namespace LogExpert.Tests +namespace LogExpert.Tests; + +[TestFixture] +public class JsonCompactColumnizerTest { - [TestFixture] - public class JsonCompactColumnizerTest + [TestCase(@".\TestData\JsonCompactColumnizerTest_01.json", Priority.PerfectlySupport)] + // As long as the json file contains one of the pre-defined key, it's perfectly supported. + [TestCase(@".\TestData\JsonCompactColumnizerTest_02.json", Priority.PerfectlySupport)] + [TestCase(@".\TestData\JsonCompactColumnizerTest_03.json", Priority.WellSupport)] + public void GetPriority_HappyFile_PriorityMatches(string fileName, Priority priority) { - [TestCase(@".\TestData\JsonCompactColumnizerTest_01.json", Priority.PerfectlySupport)] - // As long as the json file contains one of the pre-defined key, it's perfectly supported. - [TestCase(@".\TestData\JsonCompactColumnizerTest_02.json", Priority.PerfectlySupport)] - [TestCase(@".\TestData\JsonCompactColumnizerTest_03.json", Priority.WellSupport)] - public void GetPriority_HappyFile_PriorityMatches(string fileName, Priority priority) + var jsonCompactColumnizer = new JsonColumnizer.JsonCompactColumnizer(); + var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); + LogfileReader logFileReader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); + logFileReader.ReadFiles(); + List loglines = new() { - var jsonCompactColumnizer = new JsonColumnizer.JsonCompactColumnizer(); - var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - LogfileReader logFileReader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); - logFileReader.ReadFiles(); - List loglines = new() - { - // Sampling a few lines to select the correct columnizer - logFileReader.GetLogLine(0), - logFileReader.GetLogLine(1), - logFileReader.GetLogLine(2), - logFileReader.GetLogLine(3), - logFileReader.GetLogLine(4), - logFileReader.GetLogLine(5), - logFileReader.GetLogLine(25), - logFileReader.GetLogLine(100), - logFileReader.GetLogLine(200), - logFileReader.GetLogLine(400) - }; + // Sampling a few lines to select the correct columnizer + logFileReader.GetLogLine(0), + logFileReader.GetLogLine(1), + logFileReader.GetLogLine(2), + logFileReader.GetLogLine(3), + logFileReader.GetLogLine(4), + logFileReader.GetLogLine(5), + logFileReader.GetLogLine(25), + logFileReader.GetLogLine(100), + logFileReader.GetLogLine(200), + logFileReader.GetLogLine(400) + }; - var result = jsonCompactColumnizer.GetPriority(path, loglines); - Assert.That(result, Is.EqualTo(priority)); - } + var result = jsonCompactColumnizer.GetPriority(path, loglines); + Assert.That(result, Is.EqualTo(priority)); } } diff --git a/src/LogExpert.Tests/LocalFileSystemTest.cs b/src/LogExpert.Tests/LocalFileSystemTest.cs index 444ccdf4..76a6ee1a 100644 --- a/src/LogExpert.Tests/LocalFileSystemTest.cs +++ b/src/LogExpert.Tests/LocalFileSystemTest.cs @@ -5,50 +5,49 @@ using System; using System.IO; -namespace LogExpert.Tests +namespace LogExpert.Tests; + +[TestFixture] +internal class LocalFileSystemTest : RolloverHandlerTestBase { - [TestFixture] - internal class LocalFileSystemTest : RolloverHandlerTestBase + [TearDown] + public void TearDown() + { + Cleanup(); + } + + [OneTimeSetUp] + public void Boot() + { + Cleanup(); + } + + + [Test] + public void TestUriHandle() + { + LocalFileSystem fs = new(); + Assert.That(fs.CanHandleUri("file:///c:/logfile.txt"), Is.True); + Assert.That(fs.CanHandleUri("file:///c:\\logfile.txt"), Is.True); + Assert.That(fs.CanHandleUri("c:/logfile.txt"), Is.True); + Assert.That(fs.CanHandleUri("c:\\logfile.txt"), Is.True); + } + + [Test] + public void TestUriToFileStream() { - [TearDown] - public void TearDown() - { - Cleanup(); - } - - [OneTimeSetUp] - public void Boot() - { - Cleanup(); - } - - - [Test] - public void TestUriHandle() - { - LocalFileSystem fs = new(); - Assert.That(fs.CanHandleUri("file:///c:/logfile.txt"), Is.True); - Assert.That(fs.CanHandleUri("file:///c:\\logfile.txt"), Is.True); - Assert.That(fs.CanHandleUri("c:/logfile.txt"), Is.True); - Assert.That(fs.CanHandleUri("c:\\logfile.txt"), Is.True); - } - - [Test] - public void TestUriToFileStream() - { - DirectoryInfo dInfo = Directory.CreateDirectory(RolloverHandlerTest.TEST_DIR_NAME); - var fullName = CreateFile(dInfo, "test.log"); - - LocalFileSystem fs = new(); - ILogFileInfo info = fs.GetLogfileInfo(fullName); - Assert.That(info.Length > 0, Is.True); - Assert.That(info.OriginalLength == info.Length, Is.True); - Stream stream = info.OpenStream(); - Assert.That(stream.CanSeek, Is.True); - StreamReader reader = new(stream); - var line = reader.ReadLine(); - Assert.That(line.StartsWith("line number", StringComparison.InvariantCultureIgnoreCase), Is.True); - reader.Close(); - } + DirectoryInfo dInfo = Directory.CreateDirectory(RolloverHandlerTest.TEST_DIR_NAME); + var fullName = CreateFile(dInfo, "test.log"); + + LocalFileSystem fs = new(); + ILogFileInfo info = fs.GetLogfileInfo(fullName); + Assert.That(info.Length > 0, Is.True); + Assert.That(info.OriginalLength == info.Length, Is.True); + Stream stream = info.OpenStream(); + Assert.That(stream.CanSeek, Is.True); + StreamReader reader = new(stream); + var line = reader.ReadLine(); + Assert.That(line.StartsWith("line number", StringComparison.InvariantCultureIgnoreCase), Is.True); + reader.Close(); } } \ No newline at end of file diff --git a/src/LogExpert.Tests/LogStreamReaderTest.cs b/src/LogExpert.Tests/LogStreamReaderTest.cs index 48774eba..4ee9dd35 100644 --- a/src/LogExpert.Tests/LogStreamReaderTest.cs +++ b/src/LogExpert.Tests/LogStreamReaderTest.cs @@ -6,22 +6,68 @@ using System.IO; using System.Text; -namespace LogExpert.Tests +namespace LogExpert.Tests; + +[TestFixture] +public class LogStreamReaderTest { - [TestFixture] - public class LogStreamReaderTest + [Test] + [TestCase("Line 1\nLine 2\nLine 3", 3)] + [TestCase("Line 1\nLine 2\nLine 3\n", 3)] + [TestCase("Line 1\r\nLine 2\r\nLine 3", 3)] + [TestCase("Line 1\r\nLine 2\r\nLine 3\r\n", 3)] + [TestCase("Line 1\rLine 2\rLine 3", 3)] + [TestCase("Line 1\rLine 2\rLine 3\r", 3)] + public void ReadLinesWithSystemNewLine(string text, int expectedLines) + { + using var stream = new MemoryStream(Encoding.ASCII.GetBytes(text)); + using var reader = new PositionAwareStreamReaderSystem(stream, new EncodingOptions()); + var lineCount = 0; + while (true) + { + var line = reader.ReadLine(); + if (line == null) + { + break; + } + + lineCount += 1; + + Assert.That(line.StartsWith($"Line {lineCount}"), $"Invalid line: {line}"); + } + + Assert.That(expectedLines, Is.EqualTo(lineCount), $"Unexpected lines:\n{text}"); + } + + [Test] + [TestCase("\n\n\n", 3)] + [TestCase("\r\n\r\n\r\n", 3)] + [TestCase("\r\r\r", 3)] + public void CountLinesWithSystemNewLine(string text, int expectedLines) + { + using var stream = new MemoryStream(Encoding.ASCII.GetBytes(text)); + using var reader = new PositionAwareStreamReaderSystem(stream, new EncodingOptions()); + var lineCount = 0; + while (reader.ReadLine() != null) + { + lineCount += 1; + } + + Assert.That(expectedLines, Is.EqualTo(lineCount), $"Unexpected lines:\n{text}"); + } + + [Test] + [TestCase("Line 1\nLine 2\nLine 3", 3)] + [TestCase("Line 1\nLine 2\nLine 3\n", 3)] + [TestCase("Line 1\r\nLine 2\r\nLine 3", 3)] + [TestCase("Line 1\r\nLine 2\r\nLine 3\r\n", 3)] + [TestCase("Line 1\rLine 2\rLine 3", 3)] + [TestCase("Line 1\rLine 2\rLine 3\r", 3)] + public void ReadLinesWithLegacyNewLine(string text, int expectedLines) { - [Test] - [TestCase("Line 1\nLine 2\nLine 3", 3)] - [TestCase("Line 1\nLine 2\nLine 3\n", 3)] - [TestCase("Line 1\r\nLine 2\r\nLine 3", 3)] - [TestCase("Line 1\r\nLine 2\r\nLine 3\r\n", 3)] - [TestCase("Line 1\rLine 2\rLine 3", 3)] - [TestCase("Line 1\rLine 2\rLine 3\r", 3)] - public void ReadLinesWithSystemNewLine(string text, int expectedLines) + using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(text))) + using (var reader = new PositionAwareStreamReaderLegacy(stream, new EncodingOptions())) { - using var stream = new MemoryStream(Encoding.ASCII.GetBytes(text)); - using var reader = new PositionAwareStreamReaderSystem(stream, new EncodingOptions()); var lineCount = 0; while (true) { @@ -38,71 +84,24 @@ public void ReadLinesWithSystemNewLine(string text, int expectedLines) Assert.That(expectedLines, Is.EqualTo(lineCount), $"Unexpected lines:\n{text}"); } - - [Test] - [TestCase("\n\n\n", 3)] - [TestCase("\r\n\r\n\r\n", 3)] - [TestCase("\r\r\r", 3)] - public void CountLinesWithSystemNewLine(string text, int expectedLines) + } + [Test] + [TestCase("\n\n\n", 3)] + [TestCase("\r\n\r\n\r\n", 3)] + [TestCase("\r\r\r", 3)] + public void CountLinesWithLegacyNewLine(string text, int expectedLines) + { + using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(text))) + using (var reader = new PositionAwareStreamReaderLegacy(stream, new EncodingOptions())) { - using var stream = new MemoryStream(Encoding.ASCII.GetBytes(text)); - using var reader = new PositionAwareStreamReaderSystem(stream, new EncodingOptions()); var lineCount = 0; while (reader.ReadLine() != null) { lineCount += 1; } - Assert.That(expectedLines, Is.EqualTo(lineCount), $"Unexpected lines:\n{text}"); - } - - [Test] - [TestCase("Line 1\nLine 2\nLine 3", 3)] - [TestCase("Line 1\nLine 2\nLine 3\n", 3)] - [TestCase("Line 1\r\nLine 2\r\nLine 3", 3)] - [TestCase("Line 1\r\nLine 2\r\nLine 3\r\n", 3)] - [TestCase("Line 1\rLine 2\rLine 3", 3)] - [TestCase("Line 1\rLine 2\rLine 3\r", 3)] - public void ReadLinesWithLegacyNewLine(string text, int expectedLines) - { - using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(text))) - using (var reader = new PositionAwareStreamReaderLegacy(stream, new EncodingOptions())) - { - var lineCount = 0; - while (true) - { - var line = reader.ReadLine(); - if (line == null) - { - break; - } - - lineCount += 1; - Assert.That(line.StartsWith($"Line {lineCount}"), $"Invalid line: {line}"); - } - - Assert.That(expectedLines, Is.EqualTo(lineCount), $"Unexpected lines:\n{text}"); - } - } - [Test] - [TestCase("\n\n\n", 3)] - [TestCase("\r\n\r\n\r\n", 3)] - [TestCase("\r\r\r", 3)] - public void CountLinesWithLegacyNewLine(string text, int expectedLines) - { - using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(text))) - using (var reader = new PositionAwareStreamReaderLegacy(stream, new EncodingOptions())) - { - var lineCount = 0; - while (reader.ReadLine() != null) - { - lineCount += 1; - } - - - Assert.That(expectedLines, Is.EqualTo(lineCount), $"Unexpected lines:\n{text}"); - } + Assert.That(expectedLines, Is.EqualTo(lineCount), $"Unexpected lines:\n{text}"); } } } diff --git a/src/LogExpert.Tests/LogWindowTest.cs b/src/LogExpert.Tests/LogWindowTest.cs index 6391bf0e..93880fc9 100644 --- a/src/LogExpert.Tests/LogWindowTest.cs +++ b/src/LogExpert.Tests/LogWindowTest.cs @@ -1,32 +1,31 @@ using NUnit.Framework; -namespace LogExpert.Tests +namespace LogExpert.Tests; + +//TODO Find out why there is a "Drag and Drop Exception" until then, this 2 Tests can not be executed the block the build pipeline +[TestFixture] +public class LogWindowTest { - //TODO Find out why there is a "Drag and Drop Exception" until then, this 2 Tests can not be executed the block the build pipeline - [TestFixture] - public class LogWindowTest - { - //// TODO: Add more tests when DI container is ready. - //[TestCase(@".\TestData\JsonColumnizerTest_01.txt", typeof(DefaultLogfileColumnizer))] - //public void Instantiate_JsonFile_BuildCorrectColumnizer(string fileName, Type columnizerType) - //{ - // LogTabWindow logTabWindow = new(null, 0, false); - // LogWindow logWindow = new(logTabWindow, fileName, false, false); + //// TODO: Add more tests when DI container is ready. + //[TestCase(@".\TestData\JsonColumnizerTest_01.txt", typeof(DefaultLogfileColumnizer))] + //public void Instantiate_JsonFile_BuildCorrectColumnizer(string fileName, Type columnizerType) + //{ + // LogTabWindow logTabWindow = new(null, 0, false); + // LogWindow logWindow = new(logTabWindow, fileName, false, false); - // Assert.That(columnizerType, Is.EqualTo(logWindow.CurrentColumnizer.GetType())); - //} + // Assert.That(columnizerType, Is.EqualTo(logWindow.CurrentColumnizer.GetType())); + //} - //[TestCase(@".\TestData\XmlTest_01.xml")] - //[TestCase(@".\TestData\CsvTest_01.csv")] - //public void Instantiate_AnyFile_NotCrash(string fileName) - //{ - // PluginRegistry.GetInstance().RegisteredColumnizers.Add(new Log4jXmlColumnizer()); - // PluginRegistry.GetInstance().RegisteredColumnizers.Add(new CsvColumnizerType()); + //[TestCase(@".\TestData\XmlTest_01.xml")] + //[TestCase(@".\TestData\CsvTest_01.csv")] + //public void Instantiate_AnyFile_NotCrash(string fileName) + //{ + // PluginRegistry.GetInstance().RegisteredColumnizers.Add(new Log4jXmlColumnizer()); + // PluginRegistry.GetInstance().RegisteredColumnizers.Add(new CsvColumnizerType()); - // LogTabWindow logTabWindow = new(null, 0, false); - // LogWindow logWindow = new(logTabWindow, fileName, false, false); + // LogTabWindow logTabWindow = new(null, 0, false); + // LogWindow logWindow = new(logTabWindow, fileName, false, false); - // Assert.That(true, Is.True); - //} - } + // Assert.That(true, Is.True); + //} } diff --git a/src/LogExpert.Tests/ReaderTest.cs b/src/LogExpert.Tests/ReaderTest.cs index 8651ab64..98367143 100644 --- a/src/LogExpert.Tests/ReaderTest.cs +++ b/src/LogExpert.Tests/ReaderTest.cs @@ -8,62 +8,61 @@ using System.IO; using System.Text; -namespace LogExpert.Tests +namespace LogExpert.Tests; + +[TestFixture] +internal class ReaderTest { - [TestFixture] - internal class ReaderTest + [TearDown] + public void TearDown() { - [TearDown] - public void TearDown() - { - } + } - [OneTimeSetUp] - public void Boot() - { - } + [OneTimeSetUp] + public void Boot() + { + } - private void CompareReaderImplementationsInternal(string fileName, Encoding enc, int maxPosition) - { - var path = Environment.CurrentDirectory + "\\data\\"; - EncodingOptions encOpts = new(); - encOpts.Encoding = enc; + private void CompareReaderImplementationsInternal(string fileName, Encoding enc, int maxPosition) + { + var path = Environment.CurrentDirectory + "\\data\\"; + EncodingOptions encOpts = new(); + encOpts.Encoding = enc; - using Stream s1 = new FileStream(path + fileName, FileMode.Open, FileAccess.Read); - using Stream s2 = new FileStream(path + fileName, FileMode.Open, FileAccess.Read); - using ILogStreamReader r1 = new PositionAwareStreamReaderLegacy(s1, encOpts); - using ILogStreamReader r2 = new PositionAwareStreamReaderSystem(s2, encOpts); - for (var lineNum = 0; ; lineNum++) + using Stream s1 = new FileStream(path + fileName, FileMode.Open, FileAccess.Read); + using Stream s2 = new FileStream(path + fileName, FileMode.Open, FileAccess.Read); + using ILogStreamReader r1 = new PositionAwareStreamReaderLegacy(s1, encOpts); + using ILogStreamReader r2 = new PositionAwareStreamReaderSystem(s2, encOpts); + for (var lineNum = 0; ; lineNum++) + { + var line1 = r1.ReadLine(); + var line2 = r2.ReadLine(); + if (line1 == null && line2 == null) { - var line1 = r1.ReadLine(); - var line2 = r2.ReadLine(); - if (line1 == null && line2 == null) - { - break; - } + break; + } - Assert.That(line1, Is.EqualTo(line2), "File " + fileName); + Assert.That(line1, Is.EqualTo(line2), "File " + fileName); - if (r1.Position != maxPosition) - { - Assert.That(r2.Position, Is.EqualTo(r1.Position), "Line " + lineNum + ", File: " + fileName); - } - else - { - //Its desired that the position of the new implementation is 2 bytes ahead to fix the problem of empty lines every time a new line is appended. - Assert.That(r2.Position - 2, Is.EqualTo(r1.Position), "Line " + lineNum + ", File: " + fileName); - } + if (r1.Position != maxPosition) + { + Assert.That(r2.Position, Is.EqualTo(r1.Position), "Line " + lineNum + ", File: " + fileName); + } + else + { + //Its desired that the position of the new implementation is 2 bytes ahead to fix the problem of empty lines every time a new line is appended. + Assert.That(r2.Position - 2, Is.EqualTo(r1.Position), "Line " + lineNum + ", File: " + fileName); } } - - //TODO find out why it does not work with appveyor, but works fine with normal environment! - //[Test] - //[TestCase("50 MB.txt", "Windows-1252", 50000000)] - //[TestCase("50 MB UTF16.txt", "Unicode", 49999998)] - //[TestCase("50 MB UTF8.txt", "UTF-8", 50000000)] - //public void CompareReaderImplementations(string fileName, string encoding, int maxPosition) - //{ - // CompareReaderImplementationsInternal(fileName, Encoding.GetEncoding(encoding), maxPosition); - //} } + + //TODO find out why it does not work with appveyor, but works fine with normal environment! + //[Test] + //[TestCase("50 MB.txt", "Windows-1252", 50000000)] + //[TestCase("50 MB UTF16.txt", "Unicode", 49999998)] + //[TestCase("50 MB UTF8.txt", "UTF-8", 50000000)] + //public void CompareReaderImplementations(string fileName, string encoding, int maxPosition) + //{ + // CompareReaderImplementationsInternal(fileName, Encoding.GetEncoding(encoding), maxPosition); + //} } \ No newline at end of file diff --git a/src/LogExpert.Tests/RollingNameTest.cs b/src/LogExpert.Tests/RollingNameTest.cs index 9d25b28e..a85f94b4 100644 --- a/src/LogExpert.Tests/RollingNameTest.cs +++ b/src/LogExpert.Tests/RollingNameTest.cs @@ -2,68 +2,67 @@ using NUnit.Framework; -namespace LogExpert.Tests +namespace LogExpert.Tests; + +[TestFixture] +internal class RollingNameTest { - [TestFixture] - internal class RollingNameTest + [Test] + [TestCase("engine_2010-06-12_0.log", "*$D(yyyy-MM-dd)_$I.log")] + [TestCase("engine_2010-06-12.log", "*$D(yyyy-MM-dd).log")] + [TestCase("engine_0.log", "*_$I.log")] + [TestCase("engine.log","*.log$J(.)")] + [TestCase("engine.log","engine$J.log")] + [TestCase("engine1.log","engine$J.log")] + [TestCase("engine.log", "*$J(.)")] + [TestCase("engine_2010-06-12.log", "*$D(yyyy-MM-dd).log$J(.)")] + public void TestFilename1(string expectedResult, string formatString) { - [Test] - [TestCase("engine_2010-06-12_0.log", "*$D(yyyy-MM-dd)_$I.log")] - [TestCase("engine_2010-06-12.log", "*$D(yyyy-MM-dd).log")] - [TestCase("engine_0.log", "*_$I.log")] - [TestCase("engine.log","*.log$J(.)")] - [TestCase("engine.log","engine$J.log")] - [TestCase("engine1.log","engine$J.log")] - [TestCase("engine.log", "*$J(.)")] - [TestCase("engine_2010-06-12.log", "*$D(yyyy-MM-dd).log$J(.)")] - public void TestFilename1(string expectedResult, string formatString) - { - RolloverFilenameBuilder fnb = new(formatString); - fnb.SetFileName(expectedResult); - var name = fnb.BuildFileName(); - Assert.That(name, Is.EqualTo(expectedResult)); - } + RolloverFilenameBuilder fnb = new(formatString); + fnb.SetFileName(expectedResult); + var name = fnb.BuildFileName(); + Assert.That(name, Is.EqualTo(expectedResult)); + } - [Test] - [TestCase("engine_2010-06-12_0.log", "engine_2010-06-12_1.log", "*$D(yyyy-MM-dd)_$I.log")] - [TestCase("engine_2010-06-12.log", "engine_2010-06-12.log", "*$D(yyyy-MM-dd).log")] - [TestCase("engine_0.log", "engine_1.log","*_$I.log")] - [TestCase("engine.log", "engine.log.1","*.log$J(.)")] - [TestCase("engine.log", "engine1.log","engine$J.log")] - [TestCase("engine1.log", "engine2.log","engine$J.log")] - [TestCase("engine.log", "engine.log.1","*$J(.)")] - [TestCase("engine_2010-06-12.log", "engine_2010-06-12.log.1", "*$D(yyyy-MM-dd).log$J(.)")] - public void TestFilenameAnd1(string fileName, string expectedResult, string formatString) - { - RolloverFilenameBuilder fnb = new(formatString); - fnb.SetFileName(fileName); - fnb.Index += 1; - var name = fnb.BuildFileName(); - Assert.That(name, Is.EqualTo(expectedResult)); - } + [Test] + [TestCase("engine_2010-06-12_0.log", "engine_2010-06-12_1.log", "*$D(yyyy-MM-dd)_$I.log")] + [TestCase("engine_2010-06-12.log", "engine_2010-06-12.log", "*$D(yyyy-MM-dd).log")] + [TestCase("engine_0.log", "engine_1.log","*_$I.log")] + [TestCase("engine.log", "engine.log.1","*.log$J(.)")] + [TestCase("engine.log", "engine1.log","engine$J.log")] + [TestCase("engine1.log", "engine2.log","engine$J.log")] + [TestCase("engine.log", "engine.log.1","*$J(.)")] + [TestCase("engine_2010-06-12.log", "engine_2010-06-12.log.1", "*$D(yyyy-MM-dd).log$J(.)")] + public void TestFilenameAnd1(string fileName, string expectedResult, string formatString) + { + RolloverFilenameBuilder fnb = new(formatString); + fnb.SetFileName(fileName); + fnb.Index += 1; + var name = fnb.BuildFileName(); + Assert.That(name, Is.EqualTo(expectedResult)); + } - [Test] - [TestCase("engine.log", "engine.log.2","*$J(.)")] - [TestCase("engine.log", "engine.log.2","*.log$J(.)")] - public void TestFilenameAnd2(string fileName, string expectedResult, string formatString) - { - RolloverFilenameBuilder fnb = new(formatString); - fnb.SetFileName(fileName); - fnb.Index += 2; - var name = fnb.BuildFileName(); - Assert.That(name, Is.EqualTo(expectedResult)); - } + [Test] + [TestCase("engine.log", "engine.log.2","*$J(.)")] + [TestCase("engine.log", "engine.log.2","*.log$J(.)")] + public void TestFilenameAnd2(string fileName, string expectedResult, string formatString) + { + RolloverFilenameBuilder fnb = new(formatString); + fnb.SetFileName(fileName); + fnb.Index += 2; + var name = fnb.BuildFileName(); + Assert.That(name, Is.EqualTo(expectedResult)); + } - [Test] - [TestCase("engine1.log", "engine.log","engine$J.log")] - public void TestFilenameMinus1(string fileName, string expectedResult, string formatString) - { - RolloverFilenameBuilder fnb = new(formatString); - fnb.SetFileName(fileName); - fnb.Index -= 1; - var name = fnb.BuildFileName(); - Assert.That(name, Is.EqualTo("engine.log")); - } + [Test] + [TestCase("engine1.log", "engine.log","engine$J.log")] + public void TestFilenameMinus1(string fileName, string expectedResult, string formatString) + { + RolloverFilenameBuilder fnb = new(formatString); + fnb.SetFileName(fileName); + fnb.Index -= 1; + var name = fnb.BuildFileName(); + Assert.That(name, Is.EqualTo("engine.log")); } } \ No newline at end of file diff --git a/src/LogExpert.Tests/RolloverHandlerTest.cs b/src/LogExpert.Tests/RolloverHandlerTest.cs index f6795864..f93e4045 100644 --- a/src/LogExpert.Tests/RolloverHandlerTest.cs +++ b/src/LogExpert.Tests/RolloverHandlerTest.cs @@ -7,51 +7,50 @@ using System; using System.Collections.Generic; -namespace LogExpert.Tests +namespace LogExpert.Tests; + +[TestFixture] +internal class RolloverHandlerTest : RolloverHandlerTestBase { - [TestFixture] - internal class RolloverHandlerTest : RolloverHandlerTestBase + [Test] + [TestCase("*$J(.)", 66)] + public void TestFilenameListWithAppendedIndex(string format, int retries) { - [Test] - [TestCase("*$J(.)", 66)] - public void TestFilenameListWithAppendedIndex(string format, int retries) - { - MultiFileOptions options = new(); - options.FormatPattern = format; - options.MaxDayTry = retries; + MultiFileOptions options = new(); + options.FormatPattern = format; + options.MaxDayTry = retries; - LinkedList files = CreateTestFilesWithoutDate(); + LinkedList files = CreateTestFilesWithoutDate(); - var firstFile = files.Last.Value; + var firstFile = files.Last.Value; - ILogFileInfo info = new LogFileInfo(new Uri(firstFile)); - RolloverFilenameHandler handler = new(info, options); - LinkedList fileList = handler.GetNameList(PluginRegistry.PluginRegistry.Instance); + ILogFileInfo info = new LogFileInfo(new Uri(firstFile)); + RolloverFilenameHandler handler = new(info, options); + LinkedList fileList = handler.GetNameList(PluginRegistry.PluginRegistry.Instance); - Assert.That(fileList, Is.EqualTo(files)); + Assert.That(fileList, Is.EqualTo(files)); - Cleanup(); - } + Cleanup(); + } - [Test] - [TestCase("*$D(YYYY-mm-DD)_$I.log", 3)] - public void TestFilenameListWithDate(string format, int retries) - { - MultiFileOptions options = new(); - options.FormatPattern = format; - options.MaxDayTry = retries; + [Test] + [TestCase("*$D(YYYY-mm-DD)_$I.log", 3)] + public void TestFilenameListWithDate(string format, int retries) + { + MultiFileOptions options = new(); + options.FormatPattern = format; + options.MaxDayTry = retries; - LinkedList files = CreateTestFilesWithDate(); + LinkedList files = CreateTestFilesWithDate(); - var firstFile = files.Last.Value; + var firstFile = files.Last.Value; - ILogFileInfo info = new LogFileInfo(new Uri(firstFile)); - RolloverFilenameHandler handler = new(info, options); - LinkedList fileList = handler.GetNameList(PluginRegistry.PluginRegistry.Instance); + ILogFileInfo info = new LogFileInfo(new Uri(firstFile)); + RolloverFilenameHandler handler = new(info, options); + LinkedList fileList = handler.GetNameList(PluginRegistry.PluginRegistry.Instance); - Assert.That(fileList, Is.EqualTo(files)); + Assert.That(fileList, Is.EqualTo(files)); - Cleanup(); - } + Cleanup(); } } \ No newline at end of file diff --git a/src/LogExpert.Tests/RolloverHandlerTestBase.cs b/src/LogExpert.Tests/RolloverHandlerTestBase.cs index 922ee287..ea84c2cd 100644 --- a/src/LogExpert.Tests/RolloverHandlerTestBase.cs +++ b/src/LogExpert.Tests/RolloverHandlerTestBase.cs @@ -4,105 +4,104 @@ using System.Collections.Generic; using System.IO; -namespace LogExpert.Tests +namespace LogExpert.Tests; + +internal class RolloverHandlerTestBase { - internal class RolloverHandlerTestBase - { - #region Fields + #region Fields - public const string TEST_DIR_NAME = "test"; - public DirectoryInfo testDirectory; + public const string TEST_DIR_NAME = "test"; + public DirectoryInfo testDirectory; - #endregion + #endregion - protected LinkedList CreateTestFilesWithDate() - { - LinkedList createdFiles = new(); - DirectoryInfo dInfo = Directory.CreateDirectory(TEST_DIR_NAME); - testDirectory = dInfo; - createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-08_1.log")); - createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-08_0.log")); - createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-10_0.log")); - createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-11_1.log")); - createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-11_0.log")); - createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-12_2.log")); - createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-12_1.log")); - createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-12_0.log")); - return createdFiles; - } + protected LinkedList CreateTestFilesWithDate() + { + LinkedList createdFiles = new(); + DirectoryInfo dInfo = Directory.CreateDirectory(TEST_DIR_NAME); + testDirectory = dInfo; + createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-08_1.log")); + createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-08_0.log")); + createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-10_0.log")); + createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-11_1.log")); + createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-11_0.log")); + createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-12_2.log")); + createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-12_1.log")); + createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-12_0.log")); + return createdFiles; + } - protected LinkedList CreateTestFilesWithoutDate() - { - LinkedList createdFiles = new(); - DirectoryInfo dInfo = Directory.CreateDirectory(TEST_DIR_NAME); - testDirectory = dInfo; - createdFiles.AddLast(CreateFile(dInfo, "engine.log.6")); - createdFiles.AddLast(CreateFile(dInfo, "engine.log.5")); - createdFiles.AddLast(CreateFile(dInfo, "engine.log.4")); - createdFiles.AddLast(CreateFile(dInfo, "engine.log.3")); - createdFiles.AddLast(CreateFile(dInfo, "engine.log.2")); - createdFiles.AddLast(CreateFile(dInfo, "engine.log.1")); - createdFiles.AddLast(CreateFile(dInfo, "engine.log")); - return createdFiles; - } + protected LinkedList CreateTestFilesWithoutDate() + { + LinkedList createdFiles = new(); + DirectoryInfo dInfo = Directory.CreateDirectory(TEST_DIR_NAME); + testDirectory = dInfo; + createdFiles.AddLast(CreateFile(dInfo, "engine.log.6")); + createdFiles.AddLast(CreateFile(dInfo, "engine.log.5")); + createdFiles.AddLast(CreateFile(dInfo, "engine.log.4")); + createdFiles.AddLast(CreateFile(dInfo, "engine.log.3")); + createdFiles.AddLast(CreateFile(dInfo, "engine.log.2")); + createdFiles.AddLast(CreateFile(dInfo, "engine.log.1")); + createdFiles.AddLast(CreateFile(dInfo, "engine.log")); + return createdFiles; + } - protected LinkedList RolloverSimulation(LinkedList files, string formatPattern, - bool deleteLatestFile) + protected LinkedList RolloverSimulation(LinkedList files, string formatPattern, + bool deleteLatestFile) + { + LinkedList fileList = files; + RolloverFilenameBuilder fnb = new(formatPattern); + fnb.SetFileName(fileList.Last.Value); + fnb.Index += fileList.Count; + var newFileName = fnb.BuildFileName(); + fileList.AddFirst(newFileName); + LinkedList.Enumerator enumerator = fileList.GetEnumerator(); + LinkedList.Enumerator nextEnumerator = fileList.GetEnumerator(); + nextEnumerator.MoveNext(); // move on 2nd entry + enumerator.MoveNext(); + while (nextEnumerator.MoveNext()) { - LinkedList fileList = files; - RolloverFilenameBuilder fnb = new(formatPattern); - fnb.SetFileName(fileList.Last.Value); - fnb.Index += fileList.Count; - var newFileName = fnb.BuildFileName(); - fileList.AddFirst(newFileName); - LinkedList.Enumerator enumerator = fileList.GetEnumerator(); - LinkedList.Enumerator nextEnumerator = fileList.GetEnumerator(); - nextEnumerator.MoveNext(); // move on 2nd entry + File.Move(nextEnumerator.Current, enumerator.Current); enumerator.MoveNext(); - while (nextEnumerator.MoveNext()) - { - File.Move(nextEnumerator.Current, enumerator.Current); - enumerator.MoveNext(); - } - CreateFile(null, nextEnumerator.Current); + } + CreateFile(null, nextEnumerator.Current); - if (deleteLatestFile) - { - File.Delete(fileList.First.Value); - fileList.RemoveFirst(); - } - return fileList; + if (deleteLatestFile) + { + File.Delete(fileList.First.Value); + fileList.RemoveFirst(); } + return fileList; + } - protected void Cleanup() + protected void Cleanup() + { + try { - try - { - Directory.Delete(TEST_DIR_NAME, true); - } - catch (Exception) - { - } + Directory.Delete(TEST_DIR_NAME, true); } - - protected string CreateFile(DirectoryInfo dInfo, string fileName) + catch (Exception) { - var lineCount = 10; - var fullName = dInfo == null ? fileName : dInfo.FullName + Path.DirectorySeparatorChar + fileName; + } + } - using (StreamWriter writer = new(File.Create(fullName))) - { - for (var i = 1; i <= lineCount; ++i) - { - writer.WriteLine("Line number " + i.ToString("D3") + " of File " + fullName); - } + protected string CreateFile(DirectoryInfo dInfo, string fileName) + { + var lineCount = 10; + var fullName = dInfo == null ? fileName : dInfo.FullName + Path.DirectorySeparatorChar + fileName; - writer.Flush(); + using (StreamWriter writer = new(File.Create(fullName))) + { + for (var i = 1; i <= lineCount; ++i) + { + writer.WriteLine("Line number " + i.ToString("D3") + " of File " + fullName); } - return fullName; + writer.Flush(); } + + return fullName; } } \ No newline at end of file diff --git a/src/LogExpert.Tests/SquareBracketColumnizerTest.cs b/src/LogExpert.Tests/SquareBracketColumnizerTest.cs index 3104c2a7..49f5db6c 100644 --- a/src/LogExpert.Tests/SquareBracketColumnizerTest.cs +++ b/src/LogExpert.Tests/SquareBracketColumnizerTest.cs @@ -8,40 +8,39 @@ using System.Collections.Generic; using System.IO; -namespace LogExpert.Tests +namespace LogExpert.Tests; + +[TestFixture] +public class SquareBracketColumnizerTest { - [TestFixture] - public class SquareBracketColumnizerTest + [TestCase(@".\TestData\SquareBracketColumnizerTest_01.txt", 5)] + [TestCase(@".\TestData\SquareBracketColumnizerTest_02.txt", 5)] + [TestCase(@".\TestData\SquareBracketColumnizerTest_03.txt", 6)] + [TestCase(@".\TestData\SquareBracketColumnizerTest_05.txt", 3)] + public void GetPriority_HappyFile_ColumnCountMatches(string fileName, int count) { - [TestCase(@".\TestData\SquareBracketColumnizerTest_01.txt", 5)] - [TestCase(@".\TestData\SquareBracketColumnizerTest_02.txt", 5)] - [TestCase(@".\TestData\SquareBracketColumnizerTest_03.txt", 6)] - [TestCase(@".\TestData\SquareBracketColumnizerTest_05.txt", 3)] - public void GetPriority_HappyFile_ColumnCountMatches(string fileName, int count) - { - SquareBracketColumnizer squareBracketColumnizer = new(); - var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - - LogfileReader logFileReader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); - logFileReader.ReadFiles(); - List loglines = new() - { - // Sampling a few lines to select the correct columnizer - logFileReader.GetLogLine(0), - logFileReader.GetLogLine(1), - logFileReader.GetLogLine(2), - logFileReader.GetLogLine(3), - logFileReader.GetLogLine(4), - logFileReader.GetLogLine(5), - logFileReader.GetLogLine(25), - logFileReader.GetLogLine(100), - logFileReader.GetLogLine(200), - logFileReader.GetLogLine(400) - }; + SquareBracketColumnizer squareBracketColumnizer = new(); + var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - squareBracketColumnizer.GetPriority(path, loglines); - Assert.That(count, Is.EqualTo(squareBracketColumnizer.GetColumnCount())); - } + LogfileReader logFileReader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); + logFileReader.ReadFiles(); + List loglines = new() + { + // Sampling a few lines to select the correct columnizer + logFileReader.GetLogLine(0), + logFileReader.GetLogLine(1), + logFileReader.GetLogLine(2), + logFileReader.GetLogLine(3), + logFileReader.GetLogLine(4), + logFileReader.GetLogLine(5), + logFileReader.GetLogLine(25), + logFileReader.GetLogLine(100), + logFileReader.GetLogLine(200), + logFileReader.GetLogLine(400) + }; + squareBracketColumnizer.GetPriority(path, loglines); + Assert.That(count, Is.EqualTo(squareBracketColumnizer.GetColumnCount())); } + } \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/BufferedDataGridView.cs b/src/LogExpert.UI/Controls/BufferedDataGridView.cs index bf382750..e279178f 100644 --- a/src/LogExpert.UI/Controls/BufferedDataGridView.cs +++ b/src/LogExpert.UI/Controls/BufferedDataGridView.cs @@ -1,13 +1,10 @@ -using LogExpert.Core.Entities; +using System.Drawing.Drawing2D; + +using LogExpert.Core.Entities; using LogExpert.Core.EventArguments; using LogExpert.UI.Controls; -using NLog; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Windows.Forms; +using NLog; namespace LogExpert.Dialogs; @@ -35,7 +32,7 @@ public partial class BufferedDataGridView : DataGridView #region cTor - public BufferedDataGridView() + public BufferedDataGridView () { _pen = new Pen(_bubbleColor, (float)3.0); _brush = new SolidBrush(_bubbleColor); @@ -49,7 +46,7 @@ public BufferedDataGridView() #region Delegates - public delegate void OverlayDoubleClickedEventHandler(object sender, OverlayEventArgs e); + public delegate void OverlayDoubleClickedEventHandler (object sender, OverlayEventArgs e); #endregion @@ -76,7 +73,7 @@ public Graphics Buffer #region Public methods - public void AddOverlay(BookmarkOverlay overlay) + public void AddOverlay (BookmarkOverlay overlay) { lock (_overlayList) { @@ -88,7 +85,7 @@ public void AddOverlay(BookmarkOverlay overlay) #region Overrides - protected override void OnPaint(PaintEventArgs e) + protected override void OnPaint (PaintEventArgs e) { try { @@ -107,7 +104,7 @@ protected override void OnPaint(PaintEventArgs e) } } - protected override void OnEditingControlShowing(DataGridViewEditingControlShowingEventArgs e) + protected override void OnEditingControlShowing (DataGridViewEditingControlShowingEventArgs e) { base.OnEditingControlShowing(e); e.Control.KeyDown -= OnControlKeyDown; @@ -119,7 +116,7 @@ protected override void OnEditingControlShowing(DataGridViewEditingControlShowin editControl.ContextMenuStrip = EditModeMenuStrip; } - protected override void OnMouseDown(MouseEventArgs e) + protected override void OnMouseDown (MouseEventArgs e) { BookmarkOverlay overlay = GetOverlayForPosition(e.Location); if (overlay != null) @@ -148,7 +145,7 @@ protected override void OnMouseDown(MouseEventArgs e) } } - protected override void OnMouseUp(MouseEventArgs e) + protected override void OnMouseUp (MouseEventArgs e) { if (_isDrag) { @@ -161,7 +158,7 @@ protected override void OnMouseUp(MouseEventArgs e) } } - protected override void OnMouseMove(MouseEventArgs e) + protected override void OnMouseMove (MouseEventArgs e) { if (_isDrag) { @@ -178,7 +175,7 @@ protected override void OnMouseMove(MouseEventArgs e) } } - protected override void OnMouseDoubleClick(MouseEventArgs e) + protected override void OnMouseDoubleClick (MouseEventArgs e) { BookmarkOverlay overlay = GetOverlayForPosition(e.Location); if (overlay != null) @@ -198,7 +195,7 @@ protected override void OnMouseDoubleClick(MouseEventArgs e) #region Private Methods - private BookmarkOverlay GetOverlayForPosition(Point pos) + private BookmarkOverlay GetOverlayForPosition (Point pos) { lock (_overlayList) { @@ -214,7 +211,7 @@ private BookmarkOverlay GetOverlayForPosition(Point pos) return null; } - private void PaintOverlays(PaintEventArgs e) + private void PaintOverlays (PaintEventArgs e) { BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current; @@ -277,7 +274,7 @@ private void PaintOverlays(PaintEventArgs e) #region Events handler - private void Control_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) + private void Control_PreviewKeyDown (object sender, PreviewKeyDownEventArgs e) { if ((e.KeyCode == Keys.C || e.KeyCode == Keys.Insert) && e.Control) { @@ -288,7 +285,7 @@ private void Control_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) } } - private void OnControlKeyDown(object sender, KeyEventArgs e) + private void OnControlKeyDown (object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down) { @@ -332,10 +329,10 @@ private void OnControlKeyDown(object sender, KeyEventArgs e) } } - #endregion - - protected virtual void OnOverlayDoubleClicked(OverlayEventArgs e) + protected virtual void OnOverlayDoubleClicked (OverlayEventArgs e) { OverlayDoubleClicked?.Invoke(this, e); } + + #endregion } diff --git a/src/LogExpert.UI/Controls/DateTimeDragControl.cs b/src/LogExpert.UI/Controls/DateTimeDragControl.cs index 0b7ef570..8ae0e23f 100644 --- a/src/LogExpert.UI/Controls/DateTimeDragControl.cs +++ b/src/LogExpert.UI/Controls/DateTimeDragControl.cs @@ -10,503 +10,502 @@ using System.Linq; using System.Windows.Forms; -namespace LogExpert.Dialogs +namespace LogExpert.Dialogs; + +/// +/// This control displays date and time and allows user to interact with the individual parts using the mouse +/// to increment and decrement the values. The date format displayed is derived from the application UI locale. +/// We currently support only three: US (mm/dd/yyyy), French (yyyy-mm-dd) and German (dd.mm.yyyy). +/// The control raises events (ValueChanged, ValueDragged) when the date/time changes so that owner can react accordingly. +/// +public partial class DateTimeDragControl : UserControl { - /// - /// This control displays date and time and allows user to interact with the individual parts using the mouse - /// to increment and decrement the values. The date format displayed is derived from the application UI locale. - /// We currently support only three: US (mm/dd/yyyy), French (yyyy-mm-dd) and German (dd.mm.yyyy). - /// The control raises events (ValueChanged, ValueDragged) when the date/time changes so that owner can react accordingly. - /// - public partial class DateTimeDragControl : UserControl - { - #region Fields + #region Fields - private const int NO_DIGIT_DRAGGED = -1; - private int _addedValue; + private const int NO_DIGIT_DRAGGED = -1; + private int _addedValue; - private DateTime _dateTime; - private readonly IList _digitRects = new List(); - private readonly StringFormat _digitsFormat = new(); - private int _draggedDigit; + private DateTime _dateTime; + private readonly IList _digitRects = new List(); + private readonly StringFormat _digitsFormat = new(); + private int _draggedDigit; - public DragOrientationsEnum dragOrientation = DragOrientationsEnum.Vertical; + public DragOrientationsEnum dragOrientation = DragOrientationsEnum.Vertical; - private readonly ToolStripItem toolStripItemHorizontalDrag = new ToolStripMenuItem(); - private readonly ToolStripItem toolStripItemVerticalDrag = new ToolStripMenuItem(); - private readonly ToolStripItem toolStripItemVerticalInvertedDrag = new ToolStripMenuItem(); + private readonly ToolStripItem toolStripItemHorizontalDrag = new ToolStripMenuItem(); + private readonly ToolStripItem toolStripItemVerticalDrag = new ToolStripMenuItem(); + private readonly ToolStripItem toolStripItemVerticalInvertedDrag = new ToolStripMenuItem(); - private int _oldValue; + private int _oldValue; - private string[] _dateParts; + private string[] _dateParts; - private int _startMouseX; - private int _startMouseY; + private int _startMouseX; + private int _startMouseY; - #endregion + #endregion - #region cTor + #region cTor - /// - /// Default Constructor - /// - public DateTimeDragControl() - { - InitializeComponent(); + /// + /// Default Constructor + /// + public DateTimeDragControl() + { + InitializeComponent(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; - _digitsFormat.LineAlignment = StringAlignment.Center; - _digitsFormat.Alignment = StringAlignment.Near; - _digitsFormat.Trimming = StringTrimming.None; - _digitsFormat.FormatFlags = StringFormatFlags.FitBlackBox | StringFormatFlags.NoClip | StringFormatFlags.NoWrap; + _digitsFormat.LineAlignment = StringAlignment.Center; + _digitsFormat.Alignment = StringAlignment.Near; + _digitsFormat.Trimming = StringTrimming.None; + _digitsFormat.FormatFlags = StringFormatFlags.FitBlackBox | StringFormatFlags.NoClip | StringFormatFlags.NoWrap; - _draggedDigit = NO_DIGIT_DRAGGED; - } + _draggedDigit = NO_DIGIT_DRAGGED; + } - #endregion + #endregion - #region Delegates + #region Delegates - public delegate void ValueChangedEventHandler(object sender, EventArgs e); + public delegate void ValueChangedEventHandler(object sender, EventArgs e); - public delegate void ValueDraggedEventHandler(object sender, EventArgs e); + public delegate void ValueDraggedEventHandler(object sender, EventArgs e); - #endregion + #endregion - #region Events + #region Events - public event ValueChangedEventHandler ValueChanged; - public event ValueDraggedEventHandler ValueDragged; + public event ValueChangedEventHandler ValueChanged; + public event ValueDraggedEventHandler ValueDragged; - #endregion + #endregion - #region Properties + #region Properties - public DateTime MinDateTime { get; set; } = DateTime.MinValue; + public DateTime MinDateTime { get; set; } = DateTime.MinValue; - public DateTime MaxDateTime { get; set; } = DateTime.MaxValue; + public DateTime MaxDateTime { get; set; } = DateTime.MaxValue; - public DragOrientationsEnum DragOrientation + public DragOrientationsEnum DragOrientation + { + get => dragOrientation; + set { - get => dragOrientation; - set - { - dragOrientation = value; - UpdateContextMenu(); - } + dragOrientation = value; + UpdateContextMenu(); } + } - public Color HoverColor { get; set; } + public Color HoverColor { get; set; } - public DateTime DateTime + public DateTime DateTime + { + get => _dateTime.Subtract(TimeSpan.FromMilliseconds(_dateTime.Millisecond)); + set { - get => _dateTime.Subtract(TimeSpan.FromMilliseconds(_dateTime.Millisecond)); - set - { - _dateTime = value; + _dateTime = value; - if (_dateTime < MinDateTime) - { - _dateTime = MinDateTime; - } - if (_dateTime > MaxDateTime) - { - _dateTime = MaxDateTime; - } + if (_dateTime < MinDateTime) + { + _dateTime = MinDateTime; + } + if (_dateTime > MaxDateTime) + { + _dateTime = MaxDateTime; } } + } - #endregion + #endregion - #region Private Methods + #region Private Methods - // Returns the index of the rectangle (digitRects) under the mouse cursor - private int DetermineDraggedDigit(MouseEventArgs e) + // Returns the index of the rectangle (digitRects) under the mouse cursor + private int DetermineDraggedDigit(MouseEventArgs e) + { + for (var i = 0; i < _digitRects.Count; ++i) { - for (var i = 0; i < _digitRects.Count; ++i) + if (_digitRects[i].Contains(e.Location) && Token.IsDatePart(_dateParts[i])) { - if (_digitRects[i].Contains(e.Location) && Token.IsDatePart(_dateParts[i])) - { - return i; - } + return i; } - - return NO_DIGIT_DRAGGED; } - // Return the value corresponding to current dragged digit - private int GetDraggedValue() + return NO_DIGIT_DRAGGED; + } + + // Return the value corresponding to current dragged digit + private int GetDraggedValue() + { + var datePart = _dateParts[_draggedDigit]; + + if (datePart.StartsWith("y", StringComparison.OrdinalIgnoreCase)) { - var datePart = _dateParts[_draggedDigit]; + return _dateTime.Year; + } - if (datePart.StartsWith("y", StringComparison.OrdinalIgnoreCase)) - { - return _dateTime.Year; - } + if (datePart.StartsWith("M")) + { + return _dateTime.Month; + } - if (datePart.StartsWith("M")) - { - return _dateTime.Month; - } + if (datePart.StartsWith("d", StringComparison.OrdinalIgnoreCase)) + { + return _dateTime.Day; + } - if (datePart.StartsWith("d", StringComparison.OrdinalIgnoreCase)) - { - return _dateTime.Day; - } + if (datePart.StartsWith("h", StringComparison.OrdinalIgnoreCase)) + { + return _dateTime.Hour; + } - if (datePart.StartsWith("h", StringComparison.OrdinalIgnoreCase)) - { - return _dateTime.Hour; - } + if (datePart.StartsWith("m")) + { + return _dateTime.Minute; + } - if (datePart.StartsWith("m")) - { - return _dateTime.Minute; - } + return datePart.StartsWith("s", StringComparison.OrdinalIgnoreCase) ? _dateTime.Second : NO_DIGIT_DRAGGED; + } - return datePart.StartsWith("s", StringComparison.OrdinalIgnoreCase) ? _dateTime.Second : NO_DIGIT_DRAGGED; + private bool SetDraggedValue(int delta) + { + if (_draggedDigit == NO_DIGIT_DRAGGED) + { + return false; } - private bool SetDraggedValue(int delta) + var changed = true; + try { - if (_draggedDigit == NO_DIGIT_DRAGGED) + var datePart = _dateParts[_draggedDigit]; + + if (datePart.StartsWith("y", StringComparison.OrdinalIgnoreCase)) { - return false; + _dateTime = _dateTime.AddYears(delta); } - - var changed = true; - try + else if (datePart.StartsWith("M")) { - var datePart = _dateParts[_draggedDigit]; - - if (datePart.StartsWith("y", StringComparison.OrdinalIgnoreCase)) - { - _dateTime = _dateTime.AddYears(delta); - } - else if (datePart.StartsWith("M")) - { - _dateTime = _dateTime.AddMonths(delta); - } - else if (datePart.StartsWith("d", StringComparison.OrdinalIgnoreCase)) - { - _dateTime = _dateTime.AddDays(delta); - } - else if (datePart.StartsWith("h", StringComparison.OrdinalIgnoreCase)) - { - _dateTime = _dateTime.AddHours(delta); - } - else if (datePart.StartsWith("m")) - { - _dateTime = _dateTime.AddMinutes(delta); - } - else if (datePart.StartsWith("s", StringComparison.OrdinalIgnoreCase)) - { - _dateTime = _dateTime.AddSeconds(delta); - } + _dateTime = _dateTime.AddMonths(delta); } - catch (Exception) + else if (datePart.StartsWith("d", StringComparison.OrdinalIgnoreCase)) { - // invalid value dragged + _dateTime = _dateTime.AddDays(delta); } - - if (_dateTime > MaxDateTime) + else if (datePart.StartsWith("h", StringComparison.OrdinalIgnoreCase)) { - _dateTime = MaxDateTime; - changed = false; + _dateTime = _dateTime.AddHours(delta); } - if (_dateTime < MinDateTime) + else if (datePart.StartsWith("m")) { - _dateTime = MinDateTime; - changed = false; + _dateTime = _dateTime.AddMinutes(delta); + } + else if (datePart.StartsWith("s", StringComparison.OrdinalIgnoreCase)) + { + _dateTime = _dateTime.AddSeconds(delta); } - - return changed; + } + catch (Exception) + { + // invalid value dragged } - private void InitCustomRects(Section dateSection) + if (_dateTime > MaxDateTime) + { + _dateTime = MaxDateTime; + changed = false; + } + if (_dateTime < MinDateTime) { - _dateParts = dateSection - .GeneralTextDateDurationParts - .Select(DateFormatPartAdjuster.AdjustDateTimeFormatPart) - .ToArray(); + _dateTime = MinDateTime; + changed = false; + } - Rectangle rect = ClientRectangle; - var oneCharWidth = rect.Width / _dateParts.Sum(s => s.Length); - var left = rect.Left; + return changed; + } - _digitRects.Clear(); + private void InitCustomRects(Section dateSection) + { + _dateParts = dateSection + .GeneralTextDateDurationParts + .Select(DateFormatPartAdjuster.AdjustDateTimeFormatPart) + .ToArray(); - foreach (var datePart in _dateParts) - { - var s = datePart.Length * oneCharWidth; - _digitRects.Add(new Rectangle(left, rect.Top, s, rect.Height)); - left += s; - } + Rectangle rect = ClientRectangle; + var oneCharWidth = rect.Width / _dateParts.Sum(s => s.Length); + var left = rect.Left; - } + _digitRects.Clear(); - private void InitDigitRects() + foreach (var datePart in _dateParts) { - CultureInfo culture = System.Threading.Thread.CurrentThread.CurrentCulture; + var s = datePart.Length * oneCharWidth; + _digitRects.Add(new Rectangle(left, rect.Top, s, rect.Height)); + left += s; + } - var datePattern = string.Concat(culture.DateTimeFormat.ShortDatePattern, " ", culture.DateTimeFormat.LongTimePattern); + } - List
    sections = Parser.ParseSections(datePattern, out _); - Section dateSection = sections.FirstOrDefault(); + private void InitDigitRects() + { + CultureInfo culture = System.Threading.Thread.CurrentThread.CurrentCulture; - if (dateSection == null) - { - sections = Parser.ParseSections("dd.MM.yyyy HH:mm:ss", out var _); - dateSection = sections.Single(); - } + var datePattern = string.Concat(culture.DateTimeFormat.ShortDatePattern, " ", culture.DateTimeFormat.LongTimePattern); - InitCustomRects(dateSection); + List
    sections = Parser.ParseSections(datePattern, out _); + Section dateSection = sections.FirstOrDefault(); + + if (dateSection == null) + { + sections = Parser.ParseSections("dd.MM.yyyy HH:mm:ss", out var _); + dateSection = sections.Single(); } - #endregion + InitCustomRects(dateSection); + } - #region Events handler + #endregion - private void DateTimeDragControl_Load(object sender, EventArgs e) - { - InitDigitRects(); + #region Events handler - BuildContextualMenu(); - } + private void DateTimeDragControl_Load(object sender, EventArgs e) + { + InitDigitRects(); - #endregion + BuildContextualMenu(); + } - protected void OnValueChanged(EventArgs e) - { - ValueChanged?.Invoke(this, e); - } + #endregion - protected void OnValueDragged(EventArgs e) - { - ValueDragged?.Invoke(this, e); - } + protected void OnValueChanged(EventArgs e) + { + ValueChanged?.Invoke(this, e); + } - #region Contextual Menu + protected void OnValueDragged(EventArgs e) + { + ValueDragged?.Invoke(this, e); + } - private void BuildContextualMenu() - { - ContextMenuStrip = new ContextMenuStrip(); - ContextMenuStrip.Name = "Timestamp selector"; - ContextMenuStrip.Items.Add(toolStripItemHorizontalDrag); - ContextMenuStrip.Items.Add(toolStripItemVerticalDrag); - ContextMenuStrip.Items.Add(toolStripItemVerticalInvertedDrag); + #region Contextual Menu - toolStripItemHorizontalDrag.Click += OnToolStripItemHorizontalDragClick; - toolStripItemHorizontalDrag.Text = "Drag horizontal"; + private void BuildContextualMenu() + { + ContextMenuStrip = new ContextMenuStrip(); + ContextMenuStrip.Name = "Timestamp selector"; + ContextMenuStrip.Items.Add(toolStripItemHorizontalDrag); + ContextMenuStrip.Items.Add(toolStripItemVerticalDrag); + ContextMenuStrip.Items.Add(toolStripItemVerticalInvertedDrag); - toolStripItemVerticalDrag.Click += OnToolStripItemVerticalDragClick; - toolStripItemVerticalDrag.Text = "Drag vertical"; + toolStripItemHorizontalDrag.Click += OnToolStripItemHorizontalDragClick; + toolStripItemHorizontalDrag.Text = "Drag horizontal"; - toolStripItemVerticalInvertedDrag.Click += OnToolStripItemVerticalInvertedDragClick; - toolStripItemVerticalInvertedDrag.Text = "Drag vertical inverted"; + toolStripItemVerticalDrag.Click += OnToolStripItemVerticalDragClick; + toolStripItemVerticalDrag.Text = "Drag vertical"; - ContextMenuStrip.Opening += OnContextMenuStripOpening; + toolStripItemVerticalInvertedDrag.Click += OnToolStripItemVerticalInvertedDragClick; + toolStripItemVerticalInvertedDrag.Text = "Drag vertical inverted"; - UpdateContextMenu(); - } + ContextMenuStrip.Opening += OnContextMenuStripOpening; - private void UpdateContextMenu() - { - toolStripItemHorizontalDrag.Enabled = DragOrientation != DragOrientationsEnum.Horizontal; - toolStripItemVerticalDrag.Enabled = DragOrientation != DragOrientationsEnum.Vertical; - toolStripItemVerticalInvertedDrag.Enabled = DragOrientation != DragOrientationsEnum.InvertedVertical; - } + UpdateContextMenu(); + } - private void OnContextMenuStripOpening(object sender, CancelEventArgs e) - { - if (Capture) - { - e.Cancel = true; - } - } + private void UpdateContextMenu() + { + toolStripItemHorizontalDrag.Enabled = DragOrientation != DragOrientationsEnum.Horizontal; + toolStripItemVerticalDrag.Enabled = DragOrientation != DragOrientationsEnum.Vertical; + toolStripItemVerticalInvertedDrag.Enabled = DragOrientation != DragOrientationsEnum.InvertedVertical; + } - private void OnToolStripItemHorizontalDragClick(object sender, EventArgs e) + private void OnContextMenuStripOpening(object sender, CancelEventArgs e) + { + if (Capture) { - DragOrientation = DragOrientationsEnum.Horizontal; - toolStripItemHorizontalDrag.Enabled = false; - toolStripItemVerticalDrag.Enabled = true; - toolStripItemVerticalInvertedDrag.Enabled = true; + e.Cancel = true; } + } - private void OnToolStripItemVerticalDragClick(object sender, EventArgs e) - { - DragOrientation = DragOrientationsEnum.Vertical; - toolStripItemHorizontalDrag.Enabled = true; - toolStripItemVerticalDrag.Enabled = false; - toolStripItemVerticalInvertedDrag.Enabled = true; - } + private void OnToolStripItemHorizontalDragClick(object sender, EventArgs e) + { + DragOrientation = DragOrientationsEnum.Horizontal; + toolStripItemHorizontalDrag.Enabled = false; + toolStripItemVerticalDrag.Enabled = true; + toolStripItemVerticalInvertedDrag.Enabled = true; + } - private void OnToolStripItemVerticalInvertedDragClick(object sender, EventArgs e) - { - DragOrientation = DragOrientationsEnum.InvertedVertical; - toolStripItemHorizontalDrag.Enabled = true; - toolStripItemVerticalDrag.Enabled = true; - toolStripItemVerticalInvertedDrag.Enabled = false; - } + private void OnToolStripItemVerticalDragClick(object sender, EventArgs e) + { + DragOrientation = DragOrientationsEnum.Vertical; + toolStripItemHorizontalDrag.Enabled = true; + toolStripItemVerticalDrag.Enabled = false; + toolStripItemVerticalInvertedDrag.Enabled = true; + } - #endregion + private void OnToolStripItemVerticalInvertedDragClick(object sender, EventArgs e) + { + DragOrientation = DragOrientationsEnum.InvertedVertical; + toolStripItemHorizontalDrag.Enabled = true; + toolStripItemVerticalDrag.Enabled = true; + toolStripItemVerticalInvertedDrag.Enabled = false; + } - #region Rendering + #endregion - protected override void OnPaint(PaintEventArgs e) - { - base.OnPaint(e); + #region Rendering - // Show what digit is dragged - using (Brush hoverBrush = new SolidBrush(HoverColor)) + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + + // Show what digit is dragged + using (Brush hoverBrush = new SolidBrush(HoverColor)) + { + if (_draggedDigit != NO_DIGIT_DRAGGED) { - if (_draggedDigit != NO_DIGIT_DRAGGED) - { - e.Graphics.FillRectangle(hoverBrush, _digitRects[_draggedDigit]); - } + e.Graphics.FillRectangle(hoverBrush, _digitRects[_draggedDigit]); } + } - // Display current value with user-defined date format and fixed time format ("HH:mm:ss") - using (Brush brush = new SolidBrush(Color.Black)) + // Display current value with user-defined date format and fixed time format ("HH:mm:ss") + using (Brush brush = new SolidBrush(Color.Black)) + { + for (var i = 0; i < _dateParts.Length; i++) { - for (var i = 0; i < _dateParts.Length; i++) - { - var datePart = _dateParts[i]; - Rectangle rect = _digitRects[i]; - string value; + var datePart = _dateParts[i]; + Rectangle rect = _digitRects[i]; + string value; - if (Token.IsDatePart(datePart)) + if (Token.IsDatePart(datePart)) + { + try { - try - { - value = _dateTime.ToString("-" + datePart + "-"); - value = value.Substring(1, value.Length - 2); - } - catch - { - value = datePart; - } + value = _dateTime.ToString("-" + datePart + "-"); + value = value.Substring(1, value.Length - 2); } - else + catch { value = datePart; } - - e.Graphics.DrawString(value, Font, brush, rect, _digitsFormat); } - } - } + else + { + value = datePart; + } - private void DateTimeDragControl_Resize(object sender, EventArgs e) - { - InitDigitRects(); + e.Graphics.DrawString(value, Font, brush, rect, _digitsFormat); + } } + } - #endregion + private void DateTimeDragControl_Resize(object sender, EventArgs e) + { + InitDigitRects(); + } - #region Mouse callbacks + #endregion - protected override void OnMouseDown(MouseEventArgs e) - { - base.OnMouseDown(e); + #region Mouse callbacks - if (e.Button == MouseButtons.Left) - { - _draggedDigit = DetermineDraggedDigit(e); - if (_draggedDigit == NO_DIGIT_DRAGGED) - { - return; - } - Capture = true; - _startMouseY = e.Y; - _startMouseX = e.X; - _oldValue = GetDraggedValue(); - _addedValue = 0; - } - else if (e.Button == MouseButtons.Right && Capture) - { - Capture = false; - SetDraggedValue(0); //undo - } - Invalidate(); // repaint with the selected item (or none) - } + protected override void OnMouseDown(MouseEventArgs e) + { + base.OnMouseDown(e); - protected override void OnMouseUp(MouseEventArgs e) + if (e.Button == MouseButtons.Left) { - if (!Capture) + _draggedDigit = DetermineDraggedDigit(e); + if (_draggedDigit == NO_DIGIT_DRAGGED) { return; } - - base.OnMouseUp(e); - + Capture = true; + _startMouseY = e.Y; + _startMouseX = e.X; + _oldValue = GetDraggedValue(); + _addedValue = 0; + } + else if (e.Button == MouseButtons.Right && Capture) + { Capture = false; - _draggedDigit = NO_DIGIT_DRAGGED; - Invalidate(); // repaint without the selected item - - OnValueChanged(EventArgs.Empty); + SetDraggedValue(0); //undo } + Invalidate(); // repaint with the selected item (or none) + } - protected override void OnMouseMove(MouseEventArgs e) + protected override void OnMouseUp(MouseEventArgs e) + { + if (!Capture) { - base.OnMouseMove(e); + return; + } - if (!Capture) - { - return; - } + base.OnMouseUp(e); - int diff; - switch (DragOrientation) - { - case DragOrientationsEnum.Vertical: - { - diff = _startMouseY - e.Y; - break; - } - case DragOrientationsEnum.InvertedVertical: - { - diff = _startMouseY + e.Y; - break; - } - default: - { - diff = e.X - _startMouseX; - break; - } - } + Capture = false; + _draggedDigit = NO_DIGIT_DRAGGED; + Invalidate(); // repaint without the selected item - var delta = diff / 5 - _addedValue; // one unit per 5 pixels move + OnValueChanged(EventArgs.Empty); + } - if (delta == 0) - { - return; - } + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); - if (SetDraggedValue(delta)) - { - _addedValue += delta; - } + if (!Capture) + { + return; + } - Invalidate(); + int diff; + switch (DragOrientation) + { + case DragOrientationsEnum.Vertical: + { + diff = _startMouseY - e.Y; + break; + } + case DragOrientationsEnum.InvertedVertical: + { + diff = _startMouseY + e.Y; + break; + } + default: + { + diff = e.X - _startMouseX; + break; + } + } + + var delta = diff / 5 - _addedValue; // one unit per 5 pixels move - OnValueDragged(EventArgs.Empty); + if (delta == 0) + { + return; } - private void DateTimeDragControl_MouseLeave(object sender, EventArgs e) + if (SetDraggedValue(delta)) { - if (Capture) - { - return; - } + _addedValue += delta; + } - _draggedDigit = NO_DIGIT_DRAGGED; - Refresh(); + Invalidate(); + + OnValueDragged(EventArgs.Empty); + } + + private void DateTimeDragControl_MouseLeave(object sender, EventArgs e) + { + if (Capture) + { + return; } - #endregion + _draggedDigit = NO_DIGIT_DRAGGED; + Refresh(); } + + #endregion } diff --git a/src/LogExpert.UI/Controls/LogGridCell.cs b/src/LogExpert.UI/Controls/LogGridCell.cs index 70ca04bd..fe870e1b 100644 --- a/src/LogExpert.UI/Controls/LogGridCell.cs +++ b/src/LogExpert.UI/Controls/LogGridCell.cs @@ -1,14 +1,13 @@ using System; using System.Windows.Forms; -namespace LogExpert.UI.Controls +namespace LogExpert.UI.Controls; + +public class LogGridCell : DataGridViewTextBoxCell { - public class LogGridCell : DataGridViewTextBoxCell - { - #region Properties + #region Properties - public override Type EditType => typeof(LogCellEditingControl); + public override Type EditType => typeof(LogCellEditingControl); - #endregion - } + #endregion } diff --git a/src/LogExpert.UI/Controls/LogTextColumn.cs b/src/LogExpert.UI/Controls/LogTextColumn.cs index a4f5e291..2bca5e54 100644 --- a/src/LogExpert.UI/Controls/LogTextColumn.cs +++ b/src/LogExpert.UI/Controls/LogTextColumn.cs @@ -1,15 +1,14 @@ using System.Windows.Forms; -namespace LogExpert.UI.Controls -{ - public class LogTextColumn : DataGridViewColumn - { - #region cTor +namespace LogExpert.UI.Controls; - public LogTextColumn() : base(new LogGridCell()) - { - } +public class LogTextColumn : DataGridViewColumn +{ + #region cTor - #endregion + public LogTextColumn() : base(new LogGridCell()) + { } + + #endregion } diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs index c3279ba9..d18bf035 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs @@ -13,1623 +13,1622 @@ using LogExpert.UI.Entities; using LogExpert.UI.Extensions; -namespace LogExpert.UI.Controls.LogWindow +namespace LogExpert.UI.Controls.LogWindow; + +partial class LogWindow { - partial class LogWindow + private void AutoResizeFilterBox () { - private void AutoResizeFilterBox () - { - filterSplitContainer.SplitterDistance = filterComboBox.Left + filterComboBox.GetMaxTextWidth(); - } + filterSplitContainer.SplitterDistance = filterComboBox.Left + filterComboBox.GetMaxTextWidth(); + } - #region Events handler + #region Events handler - protected void OnProgressBarUpdate (ProgressEventArgs e) - { - ProgressBarUpdate?.Invoke(this, e); - } + protected void OnProgressBarUpdate (ProgressEventArgs e) + { + ProgressBarUpdate?.Invoke(this, e); + } - protected void OnStatusLine (StatusLineEventArgs e) - { - StatusLineEvent?.Invoke(this, e); - } + protected void OnStatusLine (StatusLineEventArgs e) + { + StatusLineEvent?.Invoke(this, e); + } - protected void OnGuiState (GuiStateArgs e) - { - GuiStateUpdate?.Invoke(this, e); - } + protected void OnGuiState (GuiStateArgs e) + { + GuiStateUpdate?.Invoke(this, e); + } - protected void OnTailFollowed (EventArgs e) - { - TailFollowed?.Invoke(this, e); - } + protected void OnTailFollowed (EventArgs e) + { + TailFollowed?.Invoke(this, e); + } - protected void OnFileNotFound (EventArgs e) - { - FileNotFound?.Invoke(this, e); - } + protected void OnFileNotFound (EventArgs e) + { + FileNotFound?.Invoke(this, e); + } - protected void OnFileRespawned (EventArgs e) - { - FileRespawned?.Invoke(this, e); - } + protected void OnFileRespawned (EventArgs e) + { + FileRespawned?.Invoke(this, e); + } - protected void OnFilterListChanged (LogWindow source) - { - FilterListChanged?.Invoke(this, new FilterListChangedEventArgs(source)); - } + protected void OnFilterListChanged (LogWindow source) + { + FilterListChanged?.Invoke(this, new FilterListChangedEventArgs(source)); + } - protected void OnCurrentHighlightListChanged () - { - CurrentHighlightGroupChanged?.Invoke(this, new CurrentHighlightGroupChangedEventArgs(this, _currentHighlightGroup)); - } + protected void OnCurrentHighlightListChanged () + { + CurrentHighlightGroupChanged?.Invoke(this, new CurrentHighlightGroupChangedEventArgs(this, _currentHighlightGroup)); + } - protected void OnBookmarkAdded () - { - BookmarkAdded?.Invoke(this, EventArgs.Empty); - } + protected void OnBookmarkAdded () + { + BookmarkAdded?.Invoke(this, EventArgs.Empty); + } - protected void OnBookmarkRemoved () - { - BookmarkRemoved?.Invoke(this, EventArgs.Empty); - } + protected void OnBookmarkRemoved () + { + BookmarkRemoved?.Invoke(this, EventArgs.Empty); + } - protected void OnBookmarkTextChanged (Bookmark bookmark) - { - BookmarkTextChanged?.Invoke(this, new BookmarkEventArgs(bookmark)); - } + protected void OnBookmarkTextChanged (Bookmark bookmark) + { + BookmarkTextChanged?.Invoke(this, new BookmarkEventArgs(bookmark)); + } - protected void OnColumnizerChanged (ILogLineColumnizer columnizer) - { - ColumnizerChanged?.Invoke(this, new ColumnizerEventArgs(columnizer)); - } + protected void OnColumnizerChanged (ILogLineColumnizer columnizer) + { + ColumnizerChanged?.Invoke(this, new ColumnizerEventArgs(columnizer)); + } - protected void OnRegisterCancelHandler (IBackgroundProcessCancelHandler handler) + protected void OnRegisterCancelHandler (IBackgroundProcessCancelHandler handler) + { + lock (_cancelHandlerList) { - lock (_cancelHandlerList) - { - _cancelHandlerList.Add(handler); - } + _cancelHandlerList.Add(handler); } + } - protected void OnDeRegisterCancelHandler (IBackgroundProcessCancelHandler handler) + protected void OnDeRegisterCancelHandler (IBackgroundProcessCancelHandler handler) + { + lock (_cancelHandlerList) { - lock (_cancelHandlerList) - { - _cancelHandlerList.Remove(handler); - } + _cancelHandlerList.Remove(handler); } + } - private void OnLogWindowLoad (object sender, EventArgs e) - { - PreferencesChanged(_parentLogTabWin.Preferences, true, SettingsFlags.GuiOrColors); - } + private void OnLogWindowLoad (object sender, EventArgs e) + { + PreferencesChanged(_parentLogTabWin.Preferences, true, SettingsFlags.GuiOrColors); + } - private void OnLogWindowDisposed (object sender, EventArgs e) - { - _waitingForClose = true; - _parentLogTabWin.HighlightSettingsChanged -= OnParentHighlightSettingsChanged; - _logFileReader?.DeleteAllContent(); + private void OnLogWindowDisposed (object sender, EventArgs e) + { + _waitingForClose = true; + _parentLogTabWin.HighlightSettingsChanged -= OnParentHighlightSettingsChanged; + _logFileReader?.DeleteAllContent(); - FreeFromTimeSync(); - } + FreeFromTimeSync(); + } - private void OnLogFileReaderLoadingStarted (object sender, LoadFileEventArgs e) - { - Invoke(LoadingStarted, e); - } + private void OnLogFileReaderLoadingStarted (object sender, LoadFileEventArgs e) + { + Invoke(LoadingStarted, e); + } - private void OnLogFileReaderFinishedLoading (object sender, EventArgs e) + private void OnLogFileReaderFinishedLoading (object sender, EventArgs e) + { + //Thread.CurrentThread.Name = "FinishedLoading event thread"; + _logger.Info("Finished loading."); + _isLoading = false; + _isDeadFile = false; + if (!_waitingForClose) { - //Thread.CurrentThread.Name = "FinishedLoading event thread"; - _logger.Info("Finished loading."); - _isLoading = false; - _isDeadFile = false; - if (!_waitingForClose) - { - Invoke(new MethodInvoker(LoadingFinished)); - Invoke(new MethodInvoker(LoadPersistenceData)); - Invoke(new MethodInvoker(SetGuiAfterLoading)); - _loadingFinishedEvent.Set(); - _externaLoadingFinishedEvent.Set(); - _timeSpreadCalc.SetLineCount(_logFileReader.LineCount); - - if (_reloadMemento != null) - { - Invoke(new PositionAfterReloadFx(PositionAfterReload), _reloadMemento); - } - - if (filterTailCheckBox.Checked) - { - _logger.Info("Refreshing filter view because of reload."); - Invoke(new MethodInvoker(FilterSearch)); // call on proper thread - } - - HandleChangedFilterList(); - } - - _reloadMemento = null; - } + Invoke(new MethodInvoker(LoadingFinished)); + Invoke(new MethodInvoker(LoadPersistenceData)); + Invoke(new MethodInvoker(SetGuiAfterLoading)); + _loadingFinishedEvent.Set(); + _externaLoadingFinishedEvent.Set(); + _timeSpreadCalc.SetLineCount(_logFileReader.LineCount); - private void OnLogFileReaderFileNotFound (object sender, EventArgs e) - { - if (!IsDisposed && !Disposing) + if (_reloadMemento != null) { - _logger.Info("Handling file not found event."); - _isDeadFile = true; - BeginInvoke(new MethodInvoker(LogfileDead)); + Invoke(new PositionAfterReloadFx(PositionAfterReload), _reloadMemento); } - } - - private void OnLogFileReaderRespawned (object sender, EventArgs e) - { - BeginInvoke(new MethodInvoker(LogfileRespawned)); - } - private void OnLogWindowClosing (object sender, CancelEventArgs e) - { - if (Preferences.askForClose) + if (filterTailCheckBox.Checked) { - if (MessageBox.Show("Sure to close?", "LogExpert", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) - { - e.Cancel = true; - return; - } + _logger.Info("Refreshing filter view because of reload."); + Invoke(new MethodInvoker(FilterSearch)); // call on proper thread } - SavePersistenceData(false); - CloseLogWindow(); - } - - private void OnDataGridViewColumnDividerDoubleClick (object sender, DataGridViewColumnDividerDoubleClickEventArgs e) - { - e.Handled = true; - AutoResizeColumns(dataGridView); + HandleChangedFilterList(); } - /** - * Event handler for the Load event from LogfileReader - */ - private void OnLogFileReaderLoadFile (object sender, LoadFileEventArgs e) - { - if (e.NewFile) - { - _logger.Info("File created anew."); - - // File was new created (e.g. rollover) - _isDeadFile = false; - UnRegisterLogFileReaderEvents(); - dataGridView.CurrentCellChanged -= OnDataGridViewCurrentCellChanged; - MethodInvoker invoker = ReloadNewFile; - BeginInvoke(invoker); - //Thread loadThread = new Thread(new ThreadStart(ReloadNewFile)); - //loadThread.Start(); - _logger.Debug("Reloading invoked."); - } - else if (_isLoading) - { - BeginInvoke(UpdateProgress, e); - } - } + _reloadMemento = null; + } - private void OnFileSizeChanged (object sender, LogEventArgs e) + private void OnLogFileReaderFileNotFound (object sender, EventArgs e) + { + if (!IsDisposed && !Disposing) { - //OnFileSizeChanged(e); // now done in UpdateGrid() - _logger.Info("Got FileSizeChanged event. prevLines:{0}, curr lines: {1}", e.PrevLineCount, e.LineCount); - - // - now done in the thread that works on the event args list - //if (e.IsRollover) - //{ - // ShiftBookmarks(e.RolloverOffset); - // ShiftFilterPipes(e.RolloverOffset); - //} - - //UpdateGridCallback callback = new UpdateGridCallback(UpdateGrid); - //this.BeginInvoke(callback, new object[] { e }); - lock (_logEventArgsList) - { - _logEventArgsList.Add(e); - _logEventArgsEvent.Set(); - } + _logger.Info("Handling file not found event."); + _isDeadFile = true; + BeginInvoke(new MethodInvoker(LogfileDead)); } + } - private void OnDataGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e) - { - var startCount = CurrentColumnizer?.GetColumnCount() ?? 0; - - e.Value = GetCellValue(e.RowIndex, e.ColumnIndex); - - // The new column could be find dynamically. - // Only support add new columns for now. - // TODO: Support reload all columns? - if (CurrentColumnizer != null && CurrentColumnizer.GetColumnCount() > startCount) - { - for (var i = startCount; i < CurrentColumnizer.GetColumnCount(); i++) - { - var colName = CurrentColumnizer.GetColumnNames()[i]; - dataGridView.Columns.Add(PaintHelper.CreateTitleColumn(colName)); - } - } - } + private void OnLogFileReaderRespawned (object sender, EventArgs e) + { + BeginInvoke(new MethodInvoker(LogfileRespawned)); + } - private void OnDataGridViewCellValuePushed (object sender, DataGridViewCellValueEventArgs e) + private void OnLogWindowClosing (object sender, CancelEventArgs e) + { + if (Preferences.askForClose) { - if (!CurrentColumnizer.IsTimeshiftImplemented()) - { - return; - } - - ILogLine line = _logFileReader.GetLogLine(e.RowIndex); - var offset = CurrentColumnizer.GetTimeOffset(); - CurrentColumnizer.SetTimeOffset(0); - ColumnizerCallbackObject.SetLineNum(e.RowIndex); - IColumnizedLogLine cols = CurrentColumnizer.SplitLine(ColumnizerCallbackObject, line); - CurrentColumnizer.SetTimeOffset(offset); - if (cols.ColumnValues.Length <= e.ColumnIndex - 2) + if (MessageBox.Show("Sure to close?", "LogExpert", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { + e.Cancel = true; return; } - - var oldValue = cols.ColumnValues[e.ColumnIndex - 2].FullValue; - var newValue = (string)e.Value; - //string oldValue = (string) this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; - CurrentColumnizer.PushValue(ColumnizerCallbackObject, e.ColumnIndex - 2, newValue, oldValue); - dataGridView.Refresh(); - TimeSpan timeSpan = new(CurrentColumnizer.GetTimeOffset() * TimeSpan.TicksPerMillisecond); - var span = timeSpan.ToString(); - var index = span.LastIndexOf('.'); - if (index > 0) - { - span = span.Substring(0, index + 4); - } - - SetTimeshiftValue(span); - SendGuiStateUpdate(); - } - - private void OnDataGridViewRowHeightInfoNeeded (object sender, DataGridViewRowHeightInfoNeededEventArgs e) - { - e.Height = GetRowHeight(e.RowIndex); } - private void OnDataGridViewCurrentCellChanged (object sender, EventArgs e) - { - if (dataGridView.CurrentRow != null) - { - _statusEventArgs.CurrentLineNum = dataGridView.CurrentRow.Index + 1; - SendStatusLineUpdate(); - if (syncFilterCheckBox.Checked) - { - SyncFilterGridPos(); - } - - if (CurrentColumnizer.IsTimeshiftImplemented() && Preferences.timestampControl) - { - SyncTimestampDisplay(); - } - - //MethodInvoker invoker = new MethodInvoker(DisplayCurrentFileOnStatusline); - //invoker.BeginInvoke(null, null); - } - } - - private void OnDataGridViewCellEndEdit (object sender, DataGridViewCellEventArgs e) - { - StatusLineText(string.Empty); - } + SavePersistenceData(false); + CloseLogWindow(); + } - private void OnEditControlKeyUp (object sender, KeyEventArgs e) - { - UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); - } + private void OnDataGridViewColumnDividerDoubleClick (object sender, DataGridViewColumnDividerDoubleClickEventArgs e) + { + e.Handled = true; + AutoResizeColumns(dataGridView); + } - private void OnEditControlKeyPress (object sender, KeyPressEventArgs e) + /** + * Event handler for the Load event from LogfileReader + */ + private void OnLogFileReaderLoadFile (object sender, LoadFileEventArgs e) + { + if (e.NewFile) { - UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); - } + _logger.Info("File created anew."); - private void OnEditControlClick (object sender, EventArgs e) - { - UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); + // File was new created (e.g. rollover) + _isDeadFile = false; + UnRegisterLogFileReaderEvents(); + dataGridView.CurrentCellChanged -= OnDataGridViewCurrentCellChanged; + MethodInvoker invoker = ReloadNewFile; + BeginInvoke(invoker); + //Thread loadThread = new Thread(new ThreadStart(ReloadNewFile)); + //loadThread.Start(); + _logger.Debug("Reloading invoked."); } - - private void OnEditControlKeyDown (object sender, KeyEventArgs e) + else if (_isLoading) { - UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); + BeginInvoke(UpdateProgress, e); } + } - private void OnDataGridViewPaint (object sender, PaintEventArgs e) - { - if (ShowBookmarkBubbles) - { - AddBookmarkOverlays(); - } - } + private void OnFileSizeChanged (object sender, LogEventArgs e) + { + //OnFileSizeChanged(e); // now done in UpdateGrid() + _logger.Info("Got FileSizeChanged event. prevLines:{0}, curr lines: {1}", e.PrevLineCount, e.LineCount); - // ====================================================================================== - // Filter Grid stuff - // ====================================================================================== + // - now done in the thread that works on the event args list + //if (e.IsRollover) + //{ + // ShiftBookmarks(e.RolloverOffset); + // ShiftFilterPipes(e.RolloverOffset); + //} - private void OnFilterSearchButtonClick (object sender, EventArgs e) + //UpdateGridCallback callback = new UpdateGridCallback(UpdateGrid); + //this.BeginInvoke(callback, new object[] { e }); + lock (_logEventArgsList) { - FilterSearch(); + _logEventArgsList.Add(e); + _logEventArgsEvent.Set(); } + } - private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPaintingEventArgs e) - { - var gridView = (BufferedDataGridView)sender; - - if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) - { - e.Handled = false; - return; - } - - var lineNum = _filterResultList[e.RowIndex]; - ILogLine line = _logFileReader.GetLogLineWithWait(lineNum).Result; - - if (line != null) - { - HighlightEntry entry = FindFirstNoWordMatchHilightEntry(line); - e.Graphics.SetClip(e.CellBounds); - if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) - { - Brush brush; - if (gridView.Focused) - { - brush = new SolidBrush(e.CellStyle.SelectionBackColor); - } - else - { - var color = Color.FromArgb(255, 170, 170, 170); - brush = new SolidBrush(color); - } - - e.Graphics.FillRectangle(brush, e.CellBounds); - brush.Dispose(); - } - else - { - Color bgColor = Color.White; - // paint direct filter hits with different bg color - //if (this.filterParams.SpreadEnabled && this.filterHitList.Contains(lineNum)) - //{ - // bgColor = Color.FromArgb(255, 220, 220, 220); - //} - if (!DebugOptions.DisableWordHighlight) - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - else - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - - e.CellStyle.BackColor = bgColor; - e.PaintBackground(e.ClipBounds, false); - } - - if (DebugOptions.DisableWordHighlight) - { - e.PaintContent(e.CellBounds); - } - else - { - PaintCell(e, filterGridView, false, entry); - } - - if (e.ColumnIndex == 0) - { - if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - Rectangle r = new(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); - r = e.CellBounds; - r.Inflate(-2, -2); - Brush brush = new SolidBrush(BookmarkColor); - e.Graphics.FillRectangle(brush, r); - brush.Dispose(); - - Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); - - if (bookmark.Text.Length > 0) - { - StringFormat format = new() - { - LineAlignment = StringAlignment.Center, - Alignment = StringAlignment.Center - }; - - Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); - Font font = new("Verdana", Preferences.fontSize, FontStyle.Bold); - e.Graphics.DrawString("!", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); - font.Dispose(); - brush2.Dispose(); - } - } - } + private void OnDataGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e) + { + var startCount = CurrentColumnizer?.GetColumnCount() ?? 0; - e.Paint(e.CellBounds, DataGridViewPaintParts.Border); - e.Handled = true; - } - } + e.Value = GetCellValue(e.RowIndex, e.ColumnIndex); - private void OnFilterGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e) + // The new column could be find dynamically. + // Only support add new columns for now. + // TODO: Support reload all columns? + if (CurrentColumnizer != null && CurrentColumnizer.GetColumnCount() > startCount) { - if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) + for (var i = startCount; i < CurrentColumnizer.GetColumnCount(); i++) { - e.Value = ""; - return; + var colName = CurrentColumnizer.GetColumnNames()[i]; + dataGridView.Columns.Add(PaintHelper.CreateTitleColumn(colName)); } - - var lineNum = _filterResultList[e.RowIndex]; - e.Value = GetCellValue(lineNum, e.ColumnIndex); } + } - private void OnFilterGridViewRowHeightInfoNeeded (object sender, DataGridViewRowHeightInfoNeededEventArgs e) + private void OnDataGridViewCellValuePushed (object sender, DataGridViewCellValueEventArgs e) + { + if (!CurrentColumnizer.IsTimeshiftImplemented()) { - e.Height = _lineHeight; + return; } - private void OnFilterComboBoxKeyDown (object sender, KeyEventArgs e) + ILogLine line = _logFileReader.GetLogLine(e.RowIndex); + var offset = CurrentColumnizer.GetTimeOffset(); + CurrentColumnizer.SetTimeOffset(0); + ColumnizerCallbackObject.SetLineNum(e.RowIndex); + IColumnizedLogLine cols = CurrentColumnizer.SplitLine(ColumnizerCallbackObject, line); + CurrentColumnizer.SetTimeOffset(offset); + if (cols.ColumnValues.Length <= e.ColumnIndex - 2) { - if (e.KeyCode == Keys.Enter) - { - FilterSearch(); - } + return; } - private void OnFilterGridViewColumnDividerDoubleClick (object sender, - DataGridViewColumnDividerDoubleClickEventArgs e) + var oldValue = cols.ColumnValues[e.ColumnIndex - 2].FullValue; + var newValue = (string)e.Value; + //string oldValue = (string) this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; + CurrentColumnizer.PushValue(ColumnizerCallbackObject, e.ColumnIndex - 2, newValue, oldValue); + dataGridView.Refresh(); + TimeSpan timeSpan = new(CurrentColumnizer.GetTimeOffset() * TimeSpan.TicksPerMillisecond); + var span = timeSpan.ToString(); + var index = span.LastIndexOf('.'); + if (index > 0) { - e.Handled = true; - AutoResizeColumnsFx fx = AutoResizeColumns; - BeginInvoke(fx, filterGridView); + span = span.Substring(0, index + 4); } - private void OnFilterGridViewCellDoubleClick (object sender, DataGridViewCellEventArgs e) - { - if (e.ColumnIndex == 0) - { - ToggleBookmark(); - return; - } - - if (filterGridView.CurrentRow != null && e.RowIndex >= 0) - { - var lineNum = _filterResultList[filterGridView.CurrentRow.Index]; - SelectAndEnsureVisible(lineNum, true); - } - } + SetTimeshiftValue(span); + SendGuiStateUpdate(); + } - private void OnRangeCheckBoxCheckedChanged (object sender, EventArgs e) - { - filterRangeComboBox.Enabled = rangeCheckBox.Checked; - CheckForFilterDirty(); - } + private void OnDataGridViewRowHeightInfoNeeded (object sender, DataGridViewRowHeightInfoNeededEventArgs e) + { + e.Height = GetRowHeight(e.RowIndex); + } - private void OnDataGridViewScroll (object sender, ScrollEventArgs e) + private void OnDataGridViewCurrentCellChanged (object sender, EventArgs e) + { + if (dataGridView.CurrentRow != null) { - if (e.ScrollOrientation == ScrollOrientation.VerticalScroll) + _statusEventArgs.CurrentLineNum = dataGridView.CurrentRow.Index + 1; + SendStatusLineUpdate(); + if (syncFilterCheckBox.Checked) { - if (dataGridView.DisplayedRowCount(false) + dataGridView.FirstDisplayedScrollingRowIndex >= dataGridView.RowCount) - { - //this.guiStateArgs.FollowTail = true; - if (!_guiStateArgs.FollowTail) - { - FollowTailChanged(true, false); - } - - OnTailFollowed(EventArgs.Empty); - } - else - { - //this.guiStateArgs.FollowTail = false; - if (_guiStateArgs.FollowTail) - { - FollowTailChanged(false, false); - } - } - - SendGuiStateUpdate(); + SyncFilterGridPos(); } - } - private void OnFilterGridViewKeyDown (object sender, KeyEventArgs e) - { - switch (e.KeyCode) + if (CurrentColumnizer.IsTimeshiftImplemented() && Preferences.timestampControl) { - case Keys.Enter: - { - if (filterGridView.CurrentCellAddress.Y >= 0 && filterGridView.CurrentCellAddress.Y < _filterResultList.Count) - { - var lineNum = _filterResultList[filterGridView.CurrentCellAddress.Y]; - SelectLine(lineNum, false, true); - e.Handled = true; - } - - break; - } - case Keys.Tab when e.Modifiers == Keys.None: - dataGridView.Focus(); - e.Handled = true; - break; + SyncTimestampDisplay(); } - } - private void OnDataGridViewKeyDown (object sender, KeyEventArgs e) - { - switch (e.KeyCode) - { - case Keys.Tab when e.Modifiers == Keys.None: - { - filterGridView.Focus(); - e.Handled = true; - break; - } - } + //MethodInvoker invoker = new MethodInvoker(DisplayCurrentFileOnStatusline); + //invoker.BeginInvoke(null, null); + } + } - //switch (e.KeyCode) - //{ - // case Keys.Tab when e.Modifiers == Keys.Control: - // //this.parentLogTabWin.SwitchTab(e.Shift); - // break; - //} + private void OnDataGridViewCellEndEdit (object sender, DataGridViewCellEventArgs e) + { + StatusLineText(string.Empty); + } - _shouldCallTimeSync = true; - } + private void OnEditControlKeyUp (object sender, KeyEventArgs e) + { + UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); + } - private void OnDataGridViewPreviewKeyDown (object sender, PreviewKeyDownEventArgs e) - { - if (e.KeyCode == Keys.Tab && e.Control) - { - e.IsInputKey = true; - } - } + private void OnEditControlKeyPress (object sender, KeyPressEventArgs e) + { + UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); + } - private void OnDataGridViewCellContentDoubleClick (object sender, DataGridViewCellEventArgs e) - { - if (dataGridView.CurrentCell != null) - { - dataGridView.BeginEdit(false); - } - } + private void OnEditControlClick (object sender, EventArgs e) + { + UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); + } - private void OnSyncFilterCheckBoxCheckedChanged (object sender, EventArgs e) - { - if (syncFilterCheckBox.Checked) - { - SyncFilterGridPos(); - } - } + private void OnEditControlKeyDown (object sender, KeyEventArgs e) + { + UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); + } - private void OnDataGridViewLeave (object sender, EventArgs e) + private void OnDataGridViewPaint (object sender, PaintEventArgs e) + { + if (ShowBookmarkBubbles) { - InvalidateCurrentRow(dataGridView); + AddBookmarkOverlays(); } + } - private void OnDataGridViewEnter (object sender, EventArgs e) - { - InvalidateCurrentRow(dataGridView); - } + // ====================================================================================== + // Filter Grid stuff + // ====================================================================================== - private void OnFilterGridViewEnter (object sender, EventArgs e) - { - InvalidateCurrentRow(filterGridView); - } + private void OnFilterSearchButtonClick (object sender, EventArgs e) + { + FilterSearch(); + } - private void OnFilterGridViewLeave (object sender, EventArgs e) - { - InvalidateCurrentRow(filterGridView); - } + private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPaintingEventArgs e) + { + var gridView = (BufferedDataGridView)sender; - private void OnDataGridViewResize (object sender, EventArgs e) + if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) { - if (_logFileReader != null && dataGridView.RowCount > 0 && _guiStateArgs.FollowTail) - { - dataGridView.FirstDisplayedScrollingRowIndex = dataGridView.RowCount - 1; - } + e.Handled = false; + return; } - private void OnDataGridViewSelectionChanged (object sender, EventArgs e) - { - UpdateSelectionDisplay(); - } + var lineNum = _filterResultList[e.RowIndex]; + ILogLine line = _logFileReader.GetLogLineWithWait(lineNum).Result; - private void OnSelectionChangedTriggerSignal (object sender, EventArgs e) + if (line != null) { - var selCount = 0; - try + HighlightEntry entry = FindFirstNoWordMatchHilightEntry(line); + e.Graphics.SetClip(e.CellBounds); + if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) { - _logger.Debug("Selection changed trigger"); - selCount = dataGridView.SelectedRows.Count; - if (selCount > 1) + Brush brush; + if (gridView.Focused) { - StatusLineText(selCount + " selected lines"); + brush = new SolidBrush(e.CellStyle.SelectionBackColor); } else { - if (IsMultiFile) - { - MethodInvoker invoker = DisplayCurrentFileOnStatusline; - invoker.BeginInvoke(null, null); - } - else - { - StatusLineText(""); - } + var color = Color.FromArgb(255, 170, 170, 170); + brush = new SolidBrush(color); } - } - catch (Exception ex) - { - _logger.Error(ex, "Error in selectionChangedTrigger_Signal selcount {0}", selCount); - } - } - - private void OnFilterKnobControlValueChanged (object sender, EventArgs e) - { - CheckForFilterDirty(); - } - private void OnFilterToTabButtonClick (object sender, EventArgs e) - { - FilterToTab(); - } - - private void OnPipeDisconnected (object sender, EventArgs e) - { - if (sender.GetType() == typeof(FilterPipe)) - { - lock (_filterPipeList) - { - _filterPipeList.Remove((FilterPipe)sender); - if (_filterPipeList.Count == 0) - // reset naming counter to 0 if no more open filter tabs for this source window - { - _filterPipeNameCounter = 0; - } - } + e.Graphics.FillRectangle(brush, e.CellBounds); + brush.Dispose(); } - } - - private void OnAdvancedButtonClick (object sender, EventArgs e) - { - _showAdvanced = !_showAdvanced; - ShowAdvancedFilterPanel(_showAdvanced); - } - - private void OnFilterSplitContainerMouseDown (object sender, MouseEventArgs e) - { - ((SplitContainer)sender).IsSplitterFixed = true; - } - - private void OnFilterSplitContainerMouseUp (object sender, MouseEventArgs e) - { - ((SplitContainer)sender).IsSplitterFixed = false; - } - - private void OnFilterSplitContainerMouseMove (object sender, MouseEventArgs e) - { - var splitContainer = (SplitContainer)sender; - if (splitContainer.IsSplitterFixed) + else { - if (e.Button.Equals(MouseButtons.Left)) + Color bgColor = Color.White; + // paint direct filter hits with different bg color + //if (this.filterParams.SpreadEnabled && this.filterHitList.Contains(lineNum)) + //{ + // bgColor = Color.FromArgb(255, 220, 220, 220); + //} + if (!DebugOptions.DisableWordHighlight) { - if (splitContainer.Orientation.Equals(Orientation.Vertical)) + if (entry != null) { - if (e.X > 0 && e.X < splitContainer.Width) - { - splitContainer.SplitterDistance = e.X; - splitContainer.Refresh(); - } - } - else - { - if (e.Y > 0 && e.Y < splitContainer.Height) - { - splitContainer.SplitterDistance = e.Y; - splitContainer.Refresh(); - } + bgColor = entry.BackgroundColor; } } else { - splitContainer.IsSplitterFixed = false; + if (entry != null) + { + bgColor = entry.BackgroundColor; + } } - } - } - - private void OnFilterSplitContainerMouseDoubleClick (object sender, MouseEventArgs e) - { - AutoResizeFilterBox(); - } - - #region Context Menu - - private void OnDataGridContextMenuStripOpening (object sender, CancelEventArgs e) - { - var lineNum = -1; - if (dataGridView.CurrentRow != null) - { - lineNum = dataGridView.CurrentRow.Index; + + e.CellStyle.BackColor = bgColor; + e.PaintBackground(e.ClipBounds, false); } - if (lineNum == -1) + if (DebugOptions.DisableWordHighlight) { - return; + e.PaintContent(e.CellBounds); } - - var refLineNum = lineNum; - - copyToTabToolStripMenuItem.Enabled = dataGridView.SelectedCells.Count > 0; - scrollAllTabsToTimestampToolStripMenuItem.Enabled = CurrentColumnizer.IsTimeshiftImplemented() - && - GetTimestampForLine(ref refLineNum, false) != - DateTime.MinValue; - - locateLineInOriginalFileToolStripMenuItem.Enabled = IsTempFile && - FilterPipe != null && - FilterPipe.GetOriginalLineNum(lineNum) != -1; - - markEditModeToolStripMenuItem.Enabled = !dataGridView.CurrentCell.ReadOnly; - - // Remove all "old" plugin entries - var index = dataGridContextMenuStrip.Items.IndexOf(pluginSeparator); - - if (index > 0) + else { - for (var i = index + 1; i < dataGridContextMenuStrip.Items.Count;) - { - dataGridContextMenuStrip.Items.RemoveAt(i); - } + PaintCell(e, filterGridView, false, entry); } - // Add plugin entries - var isAdded = false; - if (PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins.Count > 0) + if (e.ColumnIndex == 0) { - IList lines = GetSelectedContent(); - foreach (IContextMenuEntry entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins) + if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) { - LogExpertCallback callback = new(this); - var menuText = entry.GetMenuText(lines.Count, CurrentColumnizer, callback.GetLogLine(lines[0])); + Rectangle r = new(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); + r = e.CellBounds; + r.Inflate(-2, -2); + Brush brush = new SolidBrush(BookmarkColor); + e.Graphics.FillRectangle(brush, r); + brush.Dispose(); + + Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); - if (menuText != null) + if (bookmark.Text.Length > 0) { - var disabled = menuText.StartsWith('_'); - if (disabled) + StringFormat format = new() { - menuText = menuText[1..]; - } - - ToolStripItem item = dataGridContextMenuStrip.Items.Add(menuText, null, OnHandlePluginContextMenu); - item.Tag = new ContextMenuPluginEventArgs(entry, lines, CurrentColumnizer, callback); - item.Enabled = !disabled; - isAdded = true; + LineAlignment = StringAlignment.Center, + Alignment = StringAlignment.Center + }; + + Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); + Font font = new("Verdana", Preferences.fontSize, FontStyle.Bold); + e.Graphics.DrawString("!", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); + font.Dispose(); + brush2.Dispose(); } } } - pluginSeparator.Visible = isAdded; + e.Paint(e.CellBounds, DataGridViewPaintParts.Border); + e.Handled = true; + } + } - // enable/disable Temp Highlight item - tempHighlightsToolStripMenuItem.Enabled = _tempHighlightEntryList.Count > 0; + private void OnFilterGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e) + { + if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) + { + e.Value = ""; + return; + } - markCurrentFilterRangeToolStripMenuItem.Enabled = string.IsNullOrEmpty(filterRangeComboBox.Text) == false; + var lineNum = _filterResultList[e.RowIndex]; + e.Value = GetCellValue(lineNum, e.ColumnIndex); + } - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - IList list = _parentLogTabWin.GetListOfOpenFiles(); - syncTimestampsToToolStripMenuItem.Enabled = true; - syncTimestampsToToolStripMenuItem.DropDownItems.Clear(); - EventHandler ev = OnHandleSyncContextMenu; - Font italicFont = new(syncTimestampsToToolStripMenuItem.Font.FontFamily, syncTimestampsToToolStripMenuItem.Font.Size, FontStyle.Italic); + private void OnFilterGridViewRowHeightInfoNeeded (object sender, DataGridViewRowHeightInfoNeededEventArgs e) + { + e.Height = _lineHeight; + } - foreach (WindowFileEntry fileEntry in list) - { - if (fileEntry.LogWindow != this) - { - var item = syncTimestampsToToolStripMenuItem.DropDownItems.Add(fileEntry.Title, null, ev) as ToolStripMenuItem; - item.Tag = fileEntry; - item.Checked = TimeSyncList != null && TimeSyncList.Contains(fileEntry.LogWindow); - if (fileEntry.LogWindow.TimeSyncList != null && !fileEntry.LogWindow.TimeSyncList.Contains(this)) - { - item.Font = italicFont; - item.ForeColor = Color.Blue; - } + private void OnFilterComboBoxKeyDown (object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + FilterSearch(); + } + } - item.Enabled = fileEntry.LogWindow.CurrentColumnizer.IsTimeshiftImplemented(); - } - } - } - else - { - syncTimestampsToToolStripMenuItem.Enabled = false; - } + private void OnFilterGridViewColumnDividerDoubleClick (object sender, + DataGridViewColumnDividerDoubleClickEventArgs e) + { + e.Handled = true; + AutoResizeColumnsFx fx = AutoResizeColumns; + BeginInvoke(fx, filterGridView); + } - freeThisWindowFromTimeSyncToolStripMenuItem.Enabled = TimeSyncList != null && - TimeSyncList.Count > 1; + private void OnFilterGridViewCellDoubleClick (object sender, DataGridViewCellEventArgs e) + { + if (e.ColumnIndex == 0) + { + ToggleBookmark(); + return; } - private void OnHandlePluginContextMenu (object sender, EventArgs args) + if (filterGridView.CurrentRow != null && e.RowIndex >= 0) { - if (sender is ToolStripItem item) - { - var menuArgs = item.Tag as ContextMenuPluginEventArgs; - var logLines = menuArgs.LogLines; - menuArgs.Entry.MenuSelected(logLines.Count, menuArgs.Columnizer, menuArgs.Callback.GetLogLine(logLines[0])); - } + var lineNum = _filterResultList[filterGridView.CurrentRow.Index]; + SelectAndEnsureVisible(lineNum, true); } + } + + private void OnRangeCheckBoxCheckedChanged (object sender, EventArgs e) + { + filterRangeComboBox.Enabled = rangeCheckBox.Checked; + CheckForFilterDirty(); + } - private void OnHandleSyncContextMenu (object sender, EventArgs args) + private void OnDataGridViewScroll (object sender, ScrollEventArgs e) + { + if (e.ScrollOrientation == ScrollOrientation.VerticalScroll) { - if (sender is ToolStripItem item) + if (dataGridView.DisplayedRowCount(false) + dataGridView.FirstDisplayedScrollingRowIndex >= dataGridView.RowCount) { - var entry = item.Tag as WindowFileEntry; - - if (TimeSyncList != null && TimeSyncList.Contains(entry.LogWindow)) + //this.guiStateArgs.FollowTail = true; + if (!_guiStateArgs.FollowTail) { - FreeSlaveFromTimesync(entry.LogWindow); + FollowTailChanged(true, false); } - else - //AddSlaveToTimesync(entry.LogWindow); + + OnTailFollowed(EventArgs.Empty); + } + else + { + //this.guiStateArgs.FollowTail = false; + if (_guiStateArgs.FollowTail) { - AddOtherWindowToTimesync(entry.LogWindow); + FollowTailChanged(false, false); } } - } - - private void OnCopyToolStripMenuItemClick (object sender, EventArgs e) - { - CopyMarkedLinesToClipboard(); - } - private void OnCopyToTabToolStripMenuItemClick (object sender, EventArgs e) - { - CopyMarkedLinesToTab(); + SendGuiStateUpdate(); } + } - private void OnScrollAllTabsToTimestampToolStripMenuItemClick (object sender, EventArgs e) + private void OnFilterGridViewKeyDown (object sender, KeyEventArgs e) + { + switch (e.KeyCode) { - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - var currentLine = dataGridView.CurrentCellAddress.Y; - if (currentLine > 0 && currentLine < dataGridView.RowCount) + case Keys.Enter: { - var lineNum = currentLine; - DateTime timeStamp = GetTimestampForLine(ref lineNum, false); - if (timeStamp.Equals(DateTime.MinValue)) // means: invalid + if (filterGridView.CurrentCellAddress.Y >= 0 && filterGridView.CurrentCellAddress.Y < _filterResultList.Count) { - return; + var lineNum = _filterResultList[filterGridView.CurrentCellAddress.Y]; + SelectLine(lineNum, false, true); + e.Handled = true; } - _parentLogTabWin.ScrollAllTabsToTimestamp(timeStamp, this); + break; } - } + case Keys.Tab when e.Modifiers == Keys.None: + dataGridView.Focus(); + e.Handled = true; + break; } + } - private void OnLocateLineInOriginalFileToolStripMenuItemClick (object sender, EventArgs e) + private void OnDataGridViewKeyDown (object sender, KeyEventArgs e) + { + switch (e.KeyCode) { - if (dataGridView.CurrentRow != null && FilterPipe != null) - { - var lineNum = FilterPipe.GetOriginalLineNum(dataGridView.CurrentRow.Index); - if (lineNum != -1) + case Keys.Tab when e.Modifiers == Keys.None: { - FilterPipe.LogWindow.SelectLine(lineNum, false, true); - _parentLogTabWin.SelectTab(FilterPipe.LogWindow); + filterGridView.Focus(); + e.Handled = true; + break; } - } } - private void OnToggleBoomarkToolStripMenuItemClick (object sender, EventArgs e) + //switch (e.KeyCode) + //{ + // case Keys.Tab when e.Modifiers == Keys.Control: + // //this.parentLogTabWin.SwitchTab(e.Shift); + // break; + //} + + _shouldCallTimeSync = true; + } + + private void OnDataGridViewPreviewKeyDown (object sender, PreviewKeyDownEventArgs e) + { + if (e.KeyCode == Keys.Tab && e.Control) + { + e.IsInputKey = true; + } + } + + private void OnDataGridViewCellContentDoubleClick (object sender, DataGridViewCellEventArgs e) + { + if (dataGridView.CurrentCell != null) { - ToggleBookmark(); + dataGridView.BeginEdit(false); } + } - private void OnMarkEditModeToolStripMenuItemClick (object sender, EventArgs e) + private void OnSyncFilterCheckBoxCheckedChanged (object sender, EventArgs e) + { + if (syncFilterCheckBox.Checked) { - StartEditMode(); + SyncFilterGridPos(); } + } + + private void OnDataGridViewLeave (object sender, EventArgs e) + { + InvalidateCurrentRow(dataGridView); + } + + private void OnDataGridViewEnter (object sender, EventArgs e) + { + InvalidateCurrentRow(dataGridView); + } + + private void OnFilterGridViewEnter (object sender, EventArgs e) + { + InvalidateCurrentRow(filterGridView); + } + + private void OnFilterGridViewLeave (object sender, EventArgs e) + { + InvalidateCurrentRow(filterGridView); + } - private void OnLogWindowSizeChanged (object sender, EventArgs e) + private void OnDataGridViewResize (object sender, EventArgs e) + { + if (_logFileReader != null && dataGridView.RowCount > 0 && _guiStateArgs.FollowTail) { - //AdjustMinimumGridWith(); - AdjustHighlightSplitterWidth(); + dataGridView.FirstDisplayedScrollingRowIndex = dataGridView.RowCount - 1; } + } - #region BookMarkList + private void OnDataGridViewSelectionChanged (object sender, EventArgs e) + { + UpdateSelectionDisplay(); + } - private void OnColumnRestrictCheckBoxCheckedChanged (object sender, EventArgs e) + private void OnSelectionChangedTriggerSignal (object sender, EventArgs e) + { + var selCount = 0; + try { - columnButton.Enabled = columnRestrictCheckBox.Checked; - if (columnRestrictCheckBox.Checked) // disable when nothing to filter + _logger.Debug("Selection changed trigger"); + selCount = dataGridView.SelectedRows.Count; + if (selCount > 1) { - columnNamesLabel.Visible = true; - _filterParams.ColumnRestrict = true; - columnNamesLabel.Text = CalculateColumnNames(_filterParams); + StatusLineText(selCount + " selected lines"); } else { - columnNamesLabel.Visible = false; + if (IsMultiFile) + { + MethodInvoker invoker = DisplayCurrentFileOnStatusline; + invoker.BeginInvoke(null, null); + } + else + { + StatusLineText(""); + } } - - CheckForFilterDirty(); } + catch (Exception ex) + { + _logger.Error(ex, "Error in selectionChangedTrigger_Signal selcount {0}", selCount); + } + } + + private void OnFilterKnobControlValueChanged (object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + private void OnFilterToTabButtonClick (object sender, EventArgs e) + { + FilterToTab(); + } - private void OnColumnButtonClick (object sender, EventArgs e) + private void OnPipeDisconnected (object sender, EventArgs e) + { + if (sender.GetType() == typeof(FilterPipe)) { - _filterParams.CurrentColumnizer = _currentColumnizer; - FilterColumnChooser chooser = new(_filterParams); - if (chooser.ShowDialog() == DialogResult.OK) + lock (_filterPipeList) { - columnNamesLabel.Text = CalculateColumnNames(_filterParams); - - //CheckForFilterDirty(); //!!!GBro: Indicate to redo the search if search columns were changed - filterSearchButton.Image = _searchButtonImage; - saveFilterButton.Enabled = false; + _filterPipeList.Remove((FilterPipe)sender); + if (_filterPipeList.Count == 0) + // reset naming counter to 0 if no more open filter tabs for this source window + { + _filterPipeNameCounter = 0; + } } } + } + + private void OnAdvancedButtonClick (object sender, EventArgs e) + { + _showAdvanced = !_showAdvanced; + ShowAdvancedFilterPanel(_showAdvanced); + } - #endregion + private void OnFilterSplitContainerMouseDown (object sender, MouseEventArgs e) + { + ((SplitContainer)sender).IsSplitterFixed = true; + } - #region Column Header Context Menu + private void OnFilterSplitContainerMouseUp (object sender, MouseEventArgs e) + { + ((SplitContainer)sender).IsSplitterFixed = false; + } - private void OnDataGridViewCellContextMenuStripNeeded (object sender, DataGridViewCellContextMenuStripNeededEventArgs e) + private void OnFilterSplitContainerMouseMove (object sender, MouseEventArgs e) + { + var splitContainer = (SplitContainer)sender; + if (splitContainer.IsSplitterFixed) { - if (e.RowIndex >= 0 && e.RowIndex < dataGridView.RowCount && !dataGridView.Rows[e.RowIndex].Selected) - { - SelectLine(e.RowIndex, false, true); - } - else if (e.RowIndex < 0) + if (e.Button.Equals(MouseButtons.Left)) { - e.ContextMenuStrip = columnContextMenuStrip; + if (splitContainer.Orientation.Equals(Orientation.Vertical)) + { + if (e.X > 0 && e.X < splitContainer.Width) + { + splitContainer.SplitterDistance = e.X; + splitContainer.Refresh(); + } + } + else + { + if (e.Y > 0 && e.Y < splitContainer.Height) + { + splitContainer.SplitterDistance = e.Y; + splitContainer.Refresh(); + } + } } - - if (e.ContextMenuStrip == columnContextMenuStrip) + else { - _selectedCol = e.ColumnIndex; + splitContainer.IsSplitterFixed = false; } } + } - //private void boomarkDataGridView_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) - //{ - // if (e.RowIndex > 0 && e.RowIndex < this.boomarkDataGridView.RowCount - // && !this.boomarkDataGridView.Rows[e.RowIndex].Selected) - // { - // this.boomarkDataGridView.Rows[e.RowIndex].Selected = true; - // this.boomarkDataGridView.CurrentCell = this.boomarkDataGridView.Rows[e.RowIndex].Cells[0]; - // } - // if (e.ContextMenuStrip == this.columnContextMenuStrip) - // { - // this.selectedCol = e.ColumnIndex; - // } - //} + private void OnFilterSplitContainerMouseDoubleClick (object sender, MouseEventArgs e) + { + AutoResizeFilterBox(); + } - private void OnFilterGridViewCellContextMenuStripNeeded (object sender, DataGridViewCellContextMenuStripNeededEventArgs e) + #region Context Menu + + private void OnDataGridContextMenuStripOpening (object sender, CancelEventArgs e) + { + var lineNum = -1; + if (dataGridView.CurrentRow != null) { - if (e.ContextMenuStrip == columnContextMenuStrip) - { - _selectedCol = e.ColumnIndex; - } + lineNum = dataGridView.CurrentRow.Index; } - private void OnColumnContextMenuStripOpening (object sender, CancelEventArgs e) + if (lineNum == -1) { - Control ctl = columnContextMenuStrip.SourceControl; - var gridView = ctl as BufferedDataGridView; - var frozen = false; - if (_freezeStateMap.TryGetValue(ctl, out var value)) - { - frozen = value; - } + return; + } - freezeLeftColumnsUntilHereToolStripMenuItem.Checked = frozen; + var refLineNum = lineNum; - if (frozen) - { - freezeLeftColumnsUntilHereToolStripMenuItem.Text = "Frozen"; - } - else - { - if (ctl is BufferedDataGridView) - { - freezeLeftColumnsUntilHereToolStripMenuItem.Text = $"Freeze left columns until here ({gridView.Columns[_selectedCol].HeaderText})"; - } - } + copyToTabToolStripMenuItem.Enabled = dataGridView.SelectedCells.Count > 0; + scrollAllTabsToTimestampToolStripMenuItem.Enabled = CurrentColumnizer.IsTimeshiftImplemented() + && + GetTimestampForLine(ref refLineNum, false) != + DateTime.MinValue; + locateLineInOriginalFileToolStripMenuItem.Enabled = IsTempFile && + FilterPipe != null && + FilterPipe.GetOriginalLineNum(lineNum) != -1; - DataGridViewColumn col = gridView.Columns[_selectedCol]; - moveLeftToolStripMenuItem.Enabled = col != null && col.DisplayIndex > 0; - moveRightToolStripMenuItem.Enabled = col != null && col.DisplayIndex < gridView.Columns.Count - 1; + markEditModeToolStripMenuItem.Enabled = !dataGridView.CurrentCell.ReadOnly; - if (gridView.Columns.Count - 1 > _selectedCol) + // Remove all "old" plugin entries + var index = dataGridContextMenuStrip.Items.IndexOf(pluginSeparator); + + if (index > 0) + { + for (var i = index + 1; i < dataGridContextMenuStrip.Items.Count;) { - // DataGridViewColumn colRight = gridView.Columns[this.selectedCol + 1]; - DataGridViewColumn colRight = gridView.Columns.GetNextColumn(col, DataGridViewElementStates.None, DataGridViewElementStates.None); - moveRightToolStripMenuItem.Enabled = colRight != null && colRight.Frozen == col.Frozen; + dataGridContextMenuStrip.Items.RemoveAt(i); } + } - if (_selectedCol > 0) + // Add plugin entries + var isAdded = false; + if (PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins.Count > 0) + { + IList lines = GetSelectedContent(); + foreach (IContextMenuEntry entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins) { - //DataGridViewColumn colLeft = gridView.Columns[this.selectedCol - 1]; - DataGridViewColumn colLeft = gridView.Columns.GetPreviousColumn(col, DataGridViewElementStates.None, DataGridViewElementStates.None); + LogExpertCallback callback = new(this); + var menuText = entry.GetMenuText(lines.Count, CurrentColumnizer, callback.GetLogLine(lines[0])); + + if (menuText != null) + { + var disabled = menuText.StartsWith('_'); + if (disabled) + { + menuText = menuText[1..]; + } - moveLeftToolStripMenuItem.Enabled = colLeft != null && colLeft.Frozen == col.Frozen; + ToolStripItem item = dataGridContextMenuStrip.Items.Add(menuText, null, OnHandlePluginContextMenu); + item.Tag = new ContextMenuPluginEventArgs(entry, lines, CurrentColumnizer, callback); + item.Enabled = !disabled; + isAdded = true; + } } + } - DataGridViewColumn colLast = gridView.Columns[gridView.Columns.Count - 1]; - moveToLastColumnToolStripMenuItem.Enabled = colLast != null && colLast.Frozen == col.Frozen; + pluginSeparator.Visible = isAdded; + + // enable/disable Temp Highlight item + tempHighlightsToolStripMenuItem.Enabled = _tempHighlightEntryList.Count > 0; + + markCurrentFilterRangeToolStripMenuItem.Enabled = string.IsNullOrEmpty(filterRangeComboBox.Text) == false; + + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + IList list = _parentLogTabWin.GetListOfOpenFiles(); + syncTimestampsToToolStripMenuItem.Enabled = true; + syncTimestampsToToolStripMenuItem.DropDownItems.Clear(); + EventHandler ev = OnHandleSyncContextMenu; + Font italicFont = new(syncTimestampsToToolStripMenuItem.Font.FontFamily, syncTimestampsToToolStripMenuItem.Font.Size, FontStyle.Italic); - // Fill context menu with column names - // - EventHandler ev = OnHandleColumnItemContextMenu; - allColumnsToolStripMenuItem.DropDownItems.Clear(); - foreach (DataGridViewColumn column in gridView.Columns) + foreach (WindowFileEntry fileEntry in list) { - if (column.HeaderText.Length > 0) + if (fileEntry.LogWindow != this) { - var item = allColumnsToolStripMenuItem.DropDownItems.Add(column.HeaderText, null, ev) as ToolStripMenuItem; - item.Tag = column; - item.Enabled = !column.Frozen; + var item = syncTimestampsToToolStripMenuItem.DropDownItems.Add(fileEntry.Title, null, ev) as ToolStripMenuItem; + item.Tag = fileEntry; + item.Checked = TimeSyncList != null && TimeSyncList.Contains(fileEntry.LogWindow); + if (fileEntry.LogWindow.TimeSyncList != null && !fileEntry.LogWindow.TimeSyncList.Contains(this)) + { + item.Font = italicFont; + item.ForeColor = Color.Blue; + } + + item.Enabled = fileEntry.LogWindow.CurrentColumnizer.IsTimeshiftImplemented(); } } } + else + { + syncTimestampsToToolStripMenuItem.Enabled = false; + } + + freeThisWindowFromTimeSyncToolStripMenuItem.Enabled = TimeSyncList != null && + TimeSyncList.Count > 1; + } - private void OnHandleColumnItemContextMenu (object sender, EventArgs args) + private void OnHandlePluginContextMenu (object sender, EventArgs args) + { + if (sender is ToolStripItem item) { - if (sender is ToolStripItem item) - { - var column = item.Tag as DataGridViewColumn; - column.Visible = true; - column.DataGridView.FirstDisplayedScrollingColumnIndex = column.Index; - } + var menuArgs = item.Tag as ContextMenuPluginEventArgs; + var logLines = menuArgs.LogLines; + menuArgs.Entry.MenuSelected(logLines.Count, menuArgs.Columnizer, menuArgs.Callback.GetLogLine(logLines[0])); } + } - private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick (object sender, EventArgs e) + private void OnHandleSyncContextMenu (object sender, EventArgs args) + { + if (sender is ToolStripItem item) { - Control ctl = columnContextMenuStrip.SourceControl; - var frozen = false; + var entry = item.Tag as WindowFileEntry; - if (_freezeStateMap.TryGetValue(ctl, out var value)) + if (TimeSyncList != null && TimeSyncList.Contains(entry.LogWindow)) { - frozen = value; + FreeSlaveFromTimesync(entry.LogWindow); } - - frozen = !frozen; - _freezeStateMap[ctl] = frozen; - - if (ctl is BufferedDataGridView gridView) + else + //AddSlaveToTimesync(entry.LogWindow); { - ApplyFrozenState(gridView); + AddOtherWindowToTimesync(entry.LogWindow); } } + } - private void OnMoveToLastColumnToolStripMenuItemClick (object sender, EventArgs e) - { - var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - DataGridViewColumn col = gridView.Columns[_selectedCol]; - if (col != null) - { - col.DisplayIndex = gridView.Columns.Count - 1; - } - } + private void OnCopyToolStripMenuItemClick (object sender, EventArgs e) + { + CopyMarkedLinesToClipboard(); + } + + private void OnCopyToTabToolStripMenuItemClick (object sender, EventArgs e) + { + CopyMarkedLinesToTab(); + } - private void OnMoveLeftToolStripMenuItemClick (object sender, EventArgs e) + private void OnScrollAllTabsToTimestampToolStripMenuItemClick (object sender, EventArgs e) + { + if (CurrentColumnizer.IsTimeshiftImplemented()) { - var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - DataGridViewColumn col = gridView.Columns[_selectedCol]; - if (col != null && col.DisplayIndex > 0) + var currentLine = dataGridView.CurrentCellAddress.Y; + if (currentLine > 0 && currentLine < dataGridView.RowCount) { - col.DisplayIndex -= 1; + var lineNum = currentLine; + DateTime timeStamp = GetTimestampForLine(ref lineNum, false); + if (timeStamp.Equals(DateTime.MinValue)) // means: invalid + { + return; + } + + _parentLogTabWin.ScrollAllTabsToTimestamp(timeStamp, this); } } + } - private void OnMoveRightToolStripMenuItemClick (object sender, EventArgs e) + private void OnLocateLineInOriginalFileToolStripMenuItemClick (object sender, EventArgs e) + { + if (dataGridView.CurrentRow != null && FilterPipe != null) { - var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - DataGridViewColumn col = gridView.Columns[_selectedCol]; - if (col != null && col.DisplayIndex < gridView.Columns.Count - 1) + var lineNum = FilterPipe.GetOriginalLineNum(dataGridView.CurrentRow.Index); + if (lineNum != -1) { - col.DisplayIndex = col.DisplayIndex + 1; + FilterPipe.LogWindow.SelectLine(lineNum, false, true); + _parentLogTabWin.SelectTab(FilterPipe.LogWindow); } } + } - private void OnHideColumnToolStripMenuItemClick (object sender, EventArgs e) - { - var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - DataGridViewColumn col = gridView.Columns[_selectedCol]; - col.Visible = false; - } + private void OnToggleBoomarkToolStripMenuItemClick (object sender, EventArgs e) + { + ToggleBookmark(); + } - private void OnRestoreColumnsToolStripMenuItemClick (object sender, EventArgs e) - { - var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - foreach (DataGridViewColumn col in gridView.Columns) - { - col.Visible = true; - } - } + private void OnMarkEditModeToolStripMenuItemClick (object sender, EventArgs e) + { + StartEditMode(); + } + + private void OnLogWindowSizeChanged (object sender, EventArgs e) + { + //AdjustMinimumGridWith(); + AdjustHighlightSplitterWidth(); + } - private void OnTimeSpreadingControlLineSelected (object sender, SelectLineEventArgs e) + #region BookMarkList + + private void OnColumnRestrictCheckBoxCheckedChanged (object sender, EventArgs e) + { + columnButton.Enabled = columnRestrictCheckBox.Checked; + if (columnRestrictCheckBox.Checked) // disable when nothing to filter { - SelectLine(e.Line, false, true); + columnNamesLabel.Visible = true; + _filterParams.ColumnRestrict = true; + columnNamesLabel.Text = CalculateColumnNames(_filterParams); } - - private void OnBookmarkCommentToolStripMenuItemClick (object sender, EventArgs e) + else { - AddBookmarkAndEditComment(); + columnNamesLabel.Visible = false; } - private void OnHighlightSelectionInLogFileToolStripMenuItemClick (object sender, EventArgs e) + CheckForFilterDirty(); + } + + private void OnColumnButtonClick (object sender, EventArgs e) + { + _filterParams.CurrentColumnizer = _currentColumnizer; + FilterColumnChooser chooser = new(_filterParams); + if (chooser.ShowDialog() == DialogResult.OK) { - if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) - { - var he = new HighlightEntry() - { - SearchText = ctl.SelectedText, - ForegroundColor = Color.Red, - BackgroundColor = Color.Yellow, - IsRegEx = false, - IsCaseSensitive = true, - IsLedSwitch = false, - IsSetBookmark = false, - IsActionEntry = false, - ActionEntry = null, - IsWordMatch = false - }; - - lock (_tempHighlightEntryListLock) - { - _tempHighlightEntryList.Add(he); - } + columnNamesLabel.Text = CalculateColumnNames(_filterParams); - dataGridView.CancelEdit(); - dataGridView.EndEdit(); - RefreshAllGrids(); - } + //CheckForFilterDirty(); //!!!GBro: Indicate to redo the search if search columns were changed + filterSearchButton.Image = _searchButtonImage; + saveFilterButton.Enabled = false; } + } - private void OnHighlightSelectionInLogFilewordModeToolStripMenuItemClick (object sender, EventArgs e) - { - if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) - { - HighlightEntry he = new() - { - SearchText = ctl.SelectedText, - ForegroundColor = Color.Red, - BackgroundColor = Color.Yellow, - IsRegEx = false, - IsCaseSensitive = true, - IsLedSwitch = false, - IsStopTail = false, - IsSetBookmark = false, - IsActionEntry = false, - ActionEntry = null, - IsWordMatch = true - }; - - lock (_tempHighlightEntryListLock) - { - _tempHighlightEntryList.Add(he); - } + #endregion - dataGridView.CancelEdit(); - dataGridView.EndEdit(); - RefreshAllGrids(); - } - } + #region Column Header Context Menu - private void OnEditModeCopyToolStripMenuItemClick (object sender, EventArgs e) + private void OnDataGridViewCellContextMenuStripNeeded (object sender, DataGridViewCellContextMenuStripNeededEventArgs e) + { + if (e.RowIndex >= 0 && e.RowIndex < dataGridView.RowCount && !dataGridView.Rows[e.RowIndex].Selected) { - if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) - { - if (Util.IsNull(ctl.SelectedText) == false) - { - Clipboard.SetText(ctl.SelectedText); - } - } + SelectLine(e.RowIndex, false, true); + } + else if (e.RowIndex < 0) + { + e.ContextMenuStrip = columnContextMenuStrip; } - private void OnRemoveAllToolStripMenuItemClick (object sender, EventArgs e) + if (e.ContextMenuStrip == columnContextMenuStrip) { - RemoveTempHighlights(); + _selectedCol = e.ColumnIndex; } + } - private void OnMakePermanentToolStripMenuItemClick (object sender, EventArgs e) + //private void boomarkDataGridView_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) + //{ + // if (e.RowIndex > 0 && e.RowIndex < this.boomarkDataGridView.RowCount + // && !this.boomarkDataGridView.Rows[e.RowIndex].Selected) + // { + // this.boomarkDataGridView.Rows[e.RowIndex].Selected = true; + // this.boomarkDataGridView.CurrentCell = this.boomarkDataGridView.Rows[e.RowIndex].Cells[0]; + // } + // if (e.ContextMenuStrip == this.columnContextMenuStrip) + // { + // this.selectedCol = e.ColumnIndex; + // } + //} + + private void OnFilterGridViewCellContextMenuStripNeeded (object sender, DataGridViewCellContextMenuStripNeededEventArgs e) + { + if (e.ContextMenuStrip == columnContextMenuStrip) { - lock (_tempHighlightEntryListLock) - { - lock (_currentHighlightGroupLock) - { - _currentHighlightGroup.HighlightEntryList.AddRange(_tempHighlightEntryList); - RemoveTempHighlights(); - OnCurrentHighlightListChanged(); - } - } + _selectedCol = e.ColumnIndex; } + } - private void OnMarkCurrentFilterRangeToolStripMenuItemClick (object sender, EventArgs e) + private void OnColumnContextMenuStripOpening (object sender, CancelEventArgs e) + { + Control ctl = columnContextMenuStrip.SourceControl; + var gridView = ctl as BufferedDataGridView; + var frozen = false; + if (_freezeStateMap.TryGetValue(ctl, out var value)) { - MarkCurrentFilterRange(); + frozen = value; } - private void OnFilterForSelectionToolStripMenuItemClick (object sender, EventArgs e) + freezeLeftColumnsUntilHereToolStripMenuItem.Checked = frozen; + + if (frozen) + { + freezeLeftColumnsUntilHereToolStripMenuItem.Text = "Frozen"; + } + else { - if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) + if (ctl is BufferedDataGridView) { - splitContainerLogWindow.Panel2Collapsed = false; - ResetFilterControls(); - FilterSearch(ctl.SelectedText); + freezeLeftColumnsUntilHereToolStripMenuItem.Text = $"Freeze left columns until here ({gridView.Columns[_selectedCol].HeaderText})"; } } - private void OnSetSelectedTextAsBookmarkCommentToolStripMenuItemClick (object sender, EventArgs e) + + DataGridViewColumn col = gridView.Columns[_selectedCol]; + moveLeftToolStripMenuItem.Enabled = col != null && col.DisplayIndex > 0; + moveRightToolStripMenuItem.Enabled = col != null && col.DisplayIndex < gridView.Columns.Count - 1; + + if (gridView.Columns.Count - 1 > _selectedCol) { - if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) - { - AddBookmarkComment(ctl.SelectedText); - } + // DataGridViewColumn colRight = gridView.Columns[this.selectedCol + 1]; + DataGridViewColumn colRight = gridView.Columns.GetNextColumn(col, DataGridViewElementStates.None, DataGridViewElementStates.None); + moveRightToolStripMenuItem.Enabled = colRight != null && colRight.Frozen == col.Frozen; } - private void OnDataGridViewCellClick (object sender, DataGridViewCellEventArgs e) + if (_selectedCol > 0) { - _shouldCallTimeSync = true; + //DataGridViewColumn colLeft = gridView.Columns[this.selectedCol - 1]; + DataGridViewColumn colLeft = gridView.Columns.GetPreviousColumn(col, DataGridViewElementStates.None, DataGridViewElementStates.None); + + moveLeftToolStripMenuItem.Enabled = colLeft != null && colLeft.Frozen == col.Frozen; } - private void OnDataGridViewCellDoubleClick (object sender, DataGridViewCellEventArgs e) + DataGridViewColumn colLast = gridView.Columns[gridView.Columns.Count - 1]; + moveToLastColumnToolStripMenuItem.Enabled = colLast != null && colLast.Frozen == col.Frozen; + + // Fill context menu with column names + // + EventHandler ev = OnHandleColumnItemContextMenu; + allColumnsToolStripMenuItem.DropDownItems.Clear(); + foreach (DataGridViewColumn column in gridView.Columns) { - if (e.ColumnIndex == 0) + if (column.HeaderText.Length > 0) { - ToggleBookmark(); + var item = allColumnsToolStripMenuItem.DropDownItems.Add(column.HeaderText, null, ev) as ToolStripMenuItem; + item.Tag = column; + item.Enabled = !column.Frozen; } } + } - private void OnDataGridViewOverlayDoubleClicked (object sender, OverlayEventArgs e) + private void OnHandleColumnItemContextMenu (object sender, EventArgs args) + { + if (sender is ToolStripItem item) { - BookmarkComment(e.BookmarkOverlay.Bookmark); + var column = item.Tag as DataGridViewColumn; + column.Visible = true; + column.DataGridView.FirstDisplayedScrollingColumnIndex = column.Index; } + } - private void OnFilterRegexCheckBoxMouseUp (object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Right) - { - RegexHelperDialog dlg = new() - { - ExpressionHistoryList = ConfigManager.Settings.RegexHistory.ExpressionHistoryList, - TesttextHistoryList = ConfigManager.Settings.RegexHistory.TesttextHistoryList, - Owner = this, - CaseSensitive = filterCaseSensitiveCheckBox.Checked, - Pattern = filterComboBox.Text - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - ConfigManager.Settings.RegexHistory.ExpressionHistoryList = dlg.ExpressionHistoryList; - ConfigManager.Settings.RegexHistory.TesttextHistoryList = dlg.TesttextHistoryList; - - filterCaseSensitiveCheckBox.Checked = dlg.CaseSensitive; - filterComboBox.Text = dlg.Pattern; + private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick (object sender, EventArgs e) + { + Control ctl = columnContextMenuStrip.SourceControl; + var frozen = false; - ConfigManager.Save(SettingsFlags.RegexHistory); - } - } + if (_freezeStateMap.TryGetValue(ctl, out var value)) + { + frozen = value; } - #endregion - - #region Filter-Highlight + frozen = !frozen; + _freezeStateMap[ctl] = frozen; - private void OnToggleHighlightPanelButtonClick (object sender, EventArgs e) + if (ctl is BufferedDataGridView gridView) { - ToggleHighlightPanel(highlightSplitContainer.Panel2Collapsed); + ApplyFrozenState(gridView); } + } - private void OnSaveFilterButtonClick (object sender, EventArgs e) + private void OnMoveToLastColumnToolStripMenuItemClick (object sender, EventArgs e) + { + var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + DataGridViewColumn col = gridView.Columns[_selectedCol]; + if (col != null) { - FilterParams newParams = _filterParams.Clone(); - newParams.Color = Color.FromKnownColor(KnownColor.Black); - ConfigManager.Settings.filterList.Add(newParams); - OnFilterListChanged(this); + col.DisplayIndex = gridView.Columns.Count - 1; } + } - private void OnDeleteFilterButtonClick (object sender, EventArgs e) + private void OnMoveLeftToolStripMenuItemClick (object sender, EventArgs e) + { + var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + DataGridViewColumn col = gridView.Columns[_selectedCol]; + if (col != null && col.DisplayIndex > 0) { - var index = filterListBox.SelectedIndex; - if (index >= 0) - { - var filterParams = (FilterParams)filterListBox.Items[index]; - ConfigManager.Settings.filterList.Remove(filterParams); - OnFilterListChanged(this); - if (filterListBox.Items.Count > 0) - { - filterListBox.SelectedIndex = filterListBox.Items.Count - 1; - } - } + col.DisplayIndex -= 1; } + } - private void OnFilterUpButtonClick (object sender, EventArgs e) + private void OnMoveRightToolStripMenuItemClick (object sender, EventArgs e) + { + var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + DataGridViewColumn col = gridView.Columns[_selectedCol]; + if (col != null && col.DisplayIndex < gridView.Columns.Count - 1) { - var i = filterListBox.SelectedIndex; - if (i > 0) - { - var filterParams = (FilterParams)filterListBox.Items[i]; - ConfigManager.Settings.filterList.RemoveAt(i); - i--; - ConfigManager.Settings.filterList.Insert(i, filterParams); - OnFilterListChanged(this); - filterListBox.SelectedIndex = i; - } + col.DisplayIndex = col.DisplayIndex + 1; } + } + + private void OnHideColumnToolStripMenuItemClick (object sender, EventArgs e) + { + var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + DataGridViewColumn col = gridView.Columns[_selectedCol]; + col.Visible = false; + } - private void OnFilterDownButtonClick (object sender, EventArgs e) + private void OnRestoreColumnsToolStripMenuItemClick (object sender, EventArgs e) + { + var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + foreach (DataGridViewColumn col in gridView.Columns) { - var i = filterListBox.SelectedIndex; - if (i < 0) - { - return; - } + col.Visible = true; + } + } + + private void OnTimeSpreadingControlLineSelected (object sender, SelectLineEventArgs e) + { + SelectLine(e.Line, false, true); + } + + private void OnBookmarkCommentToolStripMenuItemClick (object sender, EventArgs e) + { + AddBookmarkAndEditComment(); + } + + private void OnHighlightSelectionInLogFileToolStripMenuItemClick (object sender, EventArgs e) + { + if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) + { + var he = new HighlightEntry() + { + SearchText = ctl.SelectedText, + ForegroundColor = Color.Red, + BackgroundColor = Color.Yellow, + IsRegEx = false, + IsCaseSensitive = true, + IsLedSwitch = false, + IsSetBookmark = false, + IsActionEntry = false, + ActionEntry = null, + IsWordMatch = false + }; - if (i < filterListBox.Items.Count - 1) + lock (_tempHighlightEntryListLock) { - var filterParams = (FilterParams)filterListBox.Items[i]; - ConfigManager.Settings.filterList.RemoveAt(i); - i++; - ConfigManager.Settings.filterList.Insert(i, filterParams); - OnFilterListChanged(this); - filterListBox.SelectedIndex = i; + _tempHighlightEntryList.Add(he); } + + dataGridView.CancelEdit(); + dataGridView.EndEdit(); + RefreshAllGrids(); } + } - private void OnFilterListBoxMouseDoubleClick (object sender, MouseEventArgs e) - { - if (filterListBox.SelectedIndex >= 0) - { - var filterParams = (FilterParams)filterListBox.Items[filterListBox.SelectedIndex]; - FilterParams newParams = filterParams.Clone(); - //newParams.historyList = ConfigManager.Settings.filterHistoryList; - _filterParams = newParams; - ReInitFilterParams(_filterParams); - ApplyFilterParams(); - CheckForAdvancedButtonDirty(); - CheckForFilterDirty(); - filterSearchButton.Image = _searchButtonImage; - saveFilterButton.Enabled = false; - if (hideFilterListOnLoadCheckBox.Checked) - { - ToggleHighlightPanel(false); - } + private void OnHighlightSelectionInLogFilewordModeToolStripMenuItemClick (object sender, EventArgs e) + { + if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) + { + HighlightEntry he = new() + { + SearchText = ctl.SelectedText, + ForegroundColor = Color.Red, + BackgroundColor = Color.Yellow, + IsRegEx = false, + IsCaseSensitive = true, + IsLedSwitch = false, + IsStopTail = false, + IsSetBookmark = false, + IsActionEntry = false, + ActionEntry = null, + IsWordMatch = true + }; - if (filterOnLoadCheckBox.Checked) - { - FilterSearch(); - } + lock (_tempHighlightEntryListLock) + { + _tempHighlightEntryList.Add(he); } + + dataGridView.CancelEdit(); + dataGridView.EndEdit(); + RefreshAllGrids(); } + } - private void OnFilterListBoxDrawItem (object sender, DrawItemEventArgs e) + private void OnEditModeCopyToolStripMenuItemClick (object sender, EventArgs e) + { + if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) { - e.DrawBackground(); - if (e.Index >= 0) + if (Util.IsNull(ctl.SelectedText) == false) { - var filterParams = (FilterParams)filterListBox.Items[e.Index]; - Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); - - Brush brush; - - if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) - { - brush = new SolidBrush(filterListBox.BackColor); - } - else - { - brush = new SolidBrush(filterParams.Color); - } - - e.Graphics.DrawString(filterParams.SearchText, e.Font, brush, - new PointF(rectangle.Left, rectangle.Top)); - e.DrawFocusRectangle(); - brush.Dispose(); + Clipboard.SetText(ctl.SelectedText); } } + } + + private void OnRemoveAllToolStripMenuItemClick (object sender, EventArgs e) + { + RemoveTempHighlights(); + } - // Color for filter list entry - private void OnColorToolStripMenuItemClick (object sender, EventArgs e) + private void OnMakePermanentToolStripMenuItemClick (object sender, EventArgs e) + { + lock (_tempHighlightEntryListLock) { - var i = filterListBox.SelectedIndex; - if (i < filterListBox.Items.Count && i >= 0) + lock (_currentHighlightGroupLock) { - var filterParams = (FilterParams)filterListBox.Items[i]; - ColorDialog dlg = new(); - dlg.CustomColors = new[] { filterParams.Color.ToArgb() }; - dlg.Color = filterParams.Color; - if (dlg.ShowDialog() == DialogResult.OK) - { - filterParams.Color = dlg.Color; - filterListBox.Refresh(); - } + _currentHighlightGroup.HighlightEntryList.AddRange(_tempHighlightEntryList); + RemoveTempHighlights(); + OnCurrentHighlightListChanged(); } } + } - private void OnFilterCaseSensitiveCheckBoxCheckedChanged (object sender, EventArgs e) - { - CheckForFilterDirty(); - } + private void OnMarkCurrentFilterRangeToolStripMenuItemClick (object sender, EventArgs e) + { + MarkCurrentFilterRange(); + } - private void OnFilterRegexCheckBoxCheckedChanged (object sender, EventArgs e) + private void OnFilterForSelectionToolStripMenuItemClick (object sender, EventArgs e) + { + if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) { - fuzzyKnobControl.Enabled = !filterRegexCheckBox.Checked; - fuzzyLabel.Enabled = !filterRegexCheckBox.Checked; - CheckForFilterDirty(); + splitContainerLogWindow.Panel2Collapsed = false; + ResetFilterControls(); + FilterSearch(ctl.SelectedText); } + } - private void OnInvertFilterCheckBoxCheckedChanged (object sender, EventArgs e) + private void OnSetSelectedTextAsBookmarkCommentToolStripMenuItemClick (object sender, EventArgs e) + { + if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) { - CheckForFilterDirty(); + AddBookmarkComment(ctl.SelectedText); } + } - private void OnFilterRangeComboBoxTextChanged (object sender, EventArgs e) - { - CheckForFilterDirty(); - } + private void OnDataGridViewCellClick (object sender, DataGridViewCellEventArgs e) + { + _shouldCallTimeSync = true; + } - private void OnFuzzyKnobControlValueChanged (object sender, EventArgs e) + private void OnDataGridViewCellDoubleClick (object sender, DataGridViewCellEventArgs e) + { + if (e.ColumnIndex == 0) { - CheckForFilterDirty(); + ToggleBookmark(); } + } - private void OnFilterComboBoxTextChanged (object sender, EventArgs e) - { - CheckForFilterDirty(); - } + private void OnDataGridViewOverlayDoubleClicked (object sender, OverlayEventArgs e) + { + BookmarkComment(e.BookmarkOverlay.Bookmark); + } - private void OnSetBookmarksOnSelectedLinesToolStripMenuItemClick (object sender, EventArgs e) + private void OnFilterRegexCheckBoxMouseUp (object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) { - SetBookmarksForSelectedFilterLines(); - } + RegexHelperDialog dlg = new() + { + ExpressionHistoryList = ConfigManager.Settings.RegexHistory.ExpressionHistoryList, + TesttextHistoryList = ConfigManager.Settings.RegexHistory.TesttextHistoryList, + Owner = this, + CaseSensitive = filterCaseSensitiveCheckBox.Checked, + Pattern = filterComboBox.Text + }; - private void OnParentHighlightSettingsChanged (object sender, EventArgs e) - { - var groupName = _guiStateArgs.HighlightGroupName; - SetCurrentHighlightGroup(groupName); - } + if (dlg.ShowDialog() == DialogResult.OK) + { + ConfigManager.Settings.RegexHistory.ExpressionHistoryList = dlg.ExpressionHistoryList; + ConfigManager.Settings.RegexHistory.TesttextHistoryList = dlg.TesttextHistoryList; - private void OnFilterOnLoadCheckBoxMouseClick (object sender, MouseEventArgs e) - { - HandleChangedFilterOnLoadSetting(); - } + filterCaseSensitiveCheckBox.Checked = dlg.CaseSensitive; + filterComboBox.Text = dlg.Pattern; - private void OnFilterOnLoadCheckBoxKeyPress (object sender, KeyPressEventArgs e) - { - HandleChangedFilterOnLoadSetting(); + ConfigManager.Save(SettingsFlags.RegexHistory); + } } + } - private void OnHideFilterListOnLoadCheckBoxMouseClick (object sender, MouseEventArgs e) - { - HandleChangedFilterOnLoadSetting(); - } + #endregion - private void OnFilterToTabToolStripMenuItemClick (object sender, EventArgs e) - { - FilterToTab(); - } + #region Filter-Highlight - private void OnTimeSyncListWindowRemoved (object sender, EventArgs e) + private void OnToggleHighlightPanelButtonClick (object sender, EventArgs e) + { + ToggleHighlightPanel(highlightSplitContainer.Panel2Collapsed); + } + + private void OnSaveFilterButtonClick (object sender, EventArgs e) + { + FilterParams newParams = _filterParams.Clone(); + newParams.Color = Color.FromKnownColor(KnownColor.Black); + ConfigManager.Settings.filterList.Add(newParams); + OnFilterListChanged(this); + } + + private void OnDeleteFilterButtonClick (object sender, EventArgs e) + { + var index = filterListBox.SelectedIndex; + if (index >= 0) { - var syncList = sender as TimeSyncList; - lock (_timeSyncListLock) + var filterParams = (FilterParams)filterListBox.Items[index]; + ConfigManager.Settings.filterList.Remove(filterParams); + OnFilterListChanged(this); + if (filterListBox.Items.Count > 0) { - if (syncList.Count == 0 || syncList.Count == 1 && syncList.Contains(this)) - { - if (syncList == TimeSyncList) - { - TimeSyncList = null; - OnSyncModeChanged(); - } - } + filterListBox.SelectedIndex = filterListBox.Items.Count - 1; } } + } - private void OnFreeThisWindowFromTimeSyncToolStripMenuItemClick (object sender, EventArgs e) + private void OnFilterUpButtonClick (object sender, EventArgs e) + { + var i = filterListBox.SelectedIndex; + if (i > 0) { - FreeFromTimeSync(); + var filterParams = (FilterParams)filterListBox.Items[i]; + ConfigManager.Settings.filterList.RemoveAt(i); + i--; + ConfigManager.Settings.filterList.Insert(i, filterParams); + OnFilterListChanged(this); + filterListBox.SelectedIndex = i; } + } - private void OnSplitContainerSplitterMoved (object sender, SplitterEventArgs e) + private void OnFilterDownButtonClick (object sender, EventArgs e) + { + var i = filterListBox.SelectedIndex; + if (i < 0) { - advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; + return; } - private void OnMarkFilterHitsInLogViewToolStripMenuItemClick (object sender, EventArgs e) + if (i < filterListBox.Items.Count - 1) { - SearchParams p = new(); - p.SearchText = _filterParams.SearchText; - p.IsRegex = _filterParams.IsRegex; - p.IsCaseSensitive = _filterParams.IsCaseSensitive; - AddSearchHitHighlightEntry(p); + var filterParams = (FilterParams)filterListBox.Items[i]; + ConfigManager.Settings.filterList.RemoveAt(i); + i++; + ConfigManager.Settings.filterList.Insert(i, filterParams); + OnFilterListChanged(this); + filterListBox.SelectedIndex = i; } + } - private void OnColumnComboBoxSelectionChangeCommitted (object sender, EventArgs e) - { - SelectColumn(); - } + private void OnFilterListBoxMouseDoubleClick (object sender, MouseEventArgs e) + { + if (filterListBox.SelectedIndex >= 0) + { + var filterParams = (FilterParams)filterListBox.Items[filterListBox.SelectedIndex]; + FilterParams newParams = filterParams.Clone(); + //newParams.historyList = ConfigManager.Settings.filterHistoryList; + _filterParams = newParams; + ReInitFilterParams(_filterParams); + ApplyFilterParams(); + CheckForAdvancedButtonDirty(); + CheckForFilterDirty(); + filterSearchButton.Image = _searchButtonImage; + saveFilterButton.Enabled = false; + if (hideFilterListOnLoadCheckBox.Checked) + { + ToggleHighlightPanel(false); + } - private void OnColumnComboBoxKeyDown (object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) + if (filterOnLoadCheckBox.Checked) { - SelectColumn(); - dataGridView.Focus(); + FilterSearch(); } } + } - private void OnColumnComboBoxPreviewKeyDown (object sender, PreviewKeyDownEventArgs e) + private void OnFilterListBoxDrawItem (object sender, DrawItemEventArgs e) + { + e.DrawBackground(); + if (e.Index >= 0) { - if (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt) + var filterParams = (FilterParams)filterListBox.Items[e.Index]; + Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); + + Brush brush; + + if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { - columnComboBox.DroppedDown = true; + brush = new SolidBrush(filterListBox.BackColor); } - - if (e.KeyCode == Keys.Enter) + else { - e.IsInputKey = true; + brush = new SolidBrush(filterParams.Color); } + + e.Graphics.DrawString(filterParams.SearchText, e.Font, brush, + new PointF(rectangle.Left, rectangle.Top)); + e.DrawFocusRectangle(); + brush.Dispose(); } + } - private void OnBookmarkProviderBookmarkRemoved (object sender, EventArgs e) + // Color for filter list entry + private void OnColorToolStripMenuItemClick (object sender, EventArgs e) + { + var i = filterListBox.SelectedIndex; + if (i < filterListBox.Items.Count && i >= 0) { - if (!_isLoading) + var filterParams = (FilterParams)filterListBox.Items[i]; + ColorDialog dlg = new(); + dlg.CustomColors = [filterParams.Color.ToArgb()]; + dlg.Color = filterParams.Color; + if (dlg.ShowDialog() == DialogResult.OK) { - dataGridView.Refresh(); - filterGridView.Refresh(); + filterParams.Color = dlg.Color; + filterListBox.Refresh(); } } + } + + private void OnFilterCaseSensitiveCheckBoxCheckedChanged (object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + private void OnFilterRegexCheckBoxCheckedChanged (object sender, EventArgs e) + { + fuzzyKnobControl.Enabled = !filterRegexCheckBox.Checked; + fuzzyLabel.Enabled = !filterRegexCheckBox.Checked; + CheckForFilterDirty(); + } + + private void OnInvertFilterCheckBoxCheckedChanged (object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + private void OnFilterRangeComboBoxTextChanged (object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + private void OnFuzzyKnobControlValueChanged (object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + private void OnFilterComboBoxTextChanged (object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + private void OnSetBookmarksOnSelectedLinesToolStripMenuItemClick (object sender, EventArgs e) + { + SetBookmarksForSelectedFilterLines(); + } + + private void OnParentHighlightSettingsChanged (object sender, EventArgs e) + { + var groupName = _guiStateArgs.HighlightGroupName; + SetCurrentHighlightGroup(groupName); + } + + private void OnFilterOnLoadCheckBoxMouseClick (object sender, MouseEventArgs e) + { + HandleChangedFilterOnLoadSetting(); + } + + private void OnFilterOnLoadCheckBoxKeyPress (object sender, KeyPressEventArgs e) + { + HandleChangedFilterOnLoadSetting(); + } + + private void OnHideFilterListOnLoadCheckBoxMouseClick (object sender, MouseEventArgs e) + { + HandleChangedFilterOnLoadSetting(); + } - private void OnBookmarkProviderBookmarkAdded (object sender, EventArgs e) + private void OnFilterToTabToolStripMenuItemClick (object sender, EventArgs e) + { + FilterToTab(); + } + + private void OnTimeSyncListWindowRemoved (object sender, EventArgs e) + { + var syncList = sender as TimeSyncList; + lock (_timeSyncListLock) { - if (!_isLoading) + if (syncList.Count == 0 || syncList.Count == 1 && syncList.Contains(this)) { - dataGridView.Refresh(); - filterGridView.Refresh(); + if (syncList == TimeSyncList) + { + TimeSyncList = null; + OnSyncModeChanged(); + } } } + } + + private void OnFreeThisWindowFromTimeSyncToolStripMenuItemClick (object sender, EventArgs e) + { + FreeFromTimeSync(); + } + + private void OnSplitContainerSplitterMoved (object sender, SplitterEventArgs e) + { + advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; + } + + private void OnMarkFilterHitsInLogViewToolStripMenuItemClick (object sender, EventArgs e) + { + SearchParams p = new(); + p.SearchText = _filterParams.SearchText; + p.IsRegex = _filterParams.IsRegex; + p.IsCaseSensitive = _filterParams.IsCaseSensitive; + AddSearchHitHighlightEntry(p); + } + + private void OnColumnComboBoxSelectionChangeCommitted (object sender, EventArgs e) + { + SelectColumn(); + } + + private void OnColumnComboBoxKeyDown (object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + SelectColumn(); + dataGridView.Focus(); + } + } - private void OnBookmarkProviderAllBookmarksRemoved (object sender, EventArgs e) + private void OnColumnComboBoxPreviewKeyDown (object sender, PreviewKeyDownEventArgs e) + { + if (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt) { - // nothing + columnComboBox.DroppedDown = true; } - private void OnLogWindowLeave (object sender, EventArgs e) + if (e.KeyCode == Keys.Enter) { - InvalidateCurrentRow(); + e.IsInputKey = true; } + } - private void OnLogWindowEnter (object sender, EventArgs e) + private void OnBookmarkProviderBookmarkRemoved (object sender, EventArgs e) + { + if (!_isLoading) { - InvalidateCurrentRow(); + dataGridView.Refresh(); + filterGridView.Refresh(); } + } - private void OnDataGridViewRowUnshared (object sender, DataGridViewRowEventArgs e) + private void OnBookmarkProviderBookmarkAdded (object sender, EventArgs e) + { + if (!_isLoading) { - if (_logger.IsTraceEnabled) - { - _logger.Trace($"Row unshared line {e.Row.Cells[1].Value}"); - } + dataGridView.Refresh(); + filterGridView.Refresh(); } + } - #endregion + private void OnBookmarkProviderAllBookmarksRemoved (object sender, EventArgs e) + { + // nothing + } - #endregion + private void OnLogWindowLeave (object sender, EventArgs e) + { + InvalidateCurrentRow(); + } - #endregion + private void OnLogWindowEnter (object sender, EventArgs e) + { + InvalidateCurrentRow(); + } - private void MeasureItem (object sender, MeasureItemEventArgs e) + private void OnDataGridViewRowUnshared (object sender, DataGridViewRowEventArgs e) + { + if (_logger.IsTraceEnabled) { - e.ItemHeight = filterListBox.Font.Height; + _logger.Trace($"Row unshared line {e.Row.Cells[1].Value}"); } } + + #endregion + + #endregion + + #endregion + + private void MeasureItem (object sender, MeasureItemEventArgs e) + { + e.ItemHeight = filterListBox.Font.Height; + } } diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs index b26368fa..5ea20a31 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs @@ -16,793 +16,842 @@ using LogExpert.Extensions; using LogExpert.UI.Entities; -namespace LogExpert.UI.Controls.LogWindow +namespace LogExpert.UI.Controls.LogWindow; + +partial class LogWindow { - partial class LogWindow + #region Private Methods + + private void RegisterLogFileReaderEvents () { - #region Private Methods + _logFileReader.LoadFile += OnLogFileReaderLoadFile; + _logFileReader.LoadingFinished += OnLogFileReaderFinishedLoading; + _logFileReader.LoadingStarted += OnLogFileReaderLoadingStarted; + _logFileReader.FileNotFound += OnLogFileReaderFileNotFound; + _logFileReader.Respawned += OnLogFileReaderRespawned; + // FileSizeChanged is not registered here because it's registered after loading has finished + } - private void RegisterLogFileReaderEvents () + private void UnRegisterLogFileReaderEvents () + { + if (_logFileReader != null) { - _logFileReader.LoadFile += OnLogFileReaderLoadFile; - _logFileReader.LoadingFinished += OnLogFileReaderFinishedLoading; - _logFileReader.LoadingStarted += OnLogFileReaderLoadingStarted; - _logFileReader.FileNotFound += OnLogFileReaderFileNotFound; - _logFileReader.Respawned += OnLogFileReaderRespawned; - // FileSizeChanged is not registered here because it's registered after loading has finished + _logFileReader.LoadFile -= OnLogFileReaderLoadFile; + _logFileReader.LoadingFinished -= OnLogFileReaderFinishedLoading; + _logFileReader.LoadingStarted -= OnLogFileReaderLoadingStarted; + _logFileReader.FileNotFound -= OnLogFileReaderFileNotFound; + _logFileReader.Respawned -= OnLogFileReaderRespawned; + _logFileReader.FileSizeChanged -= OnFileSizeChanged; } + } + + private void CreateDefaultViewStyle () + { + DataGridViewCellStyle dataGridViewCellStyleMainGrid = new(); + DataGridViewCellStyle dataGridViewCellStyleFilterGrid = new(); + + dataGridViewCellStyleMainGrid.Alignment = DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyleMainGrid.BackColor = SystemColors.Window; + dataGridViewCellStyleMainGrid.Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); + dataGridViewCellStyleMainGrid.ForeColor = SystemColors.ControlText; + dataGridViewCellStyleMainGrid.SelectionBackColor = SystemColors.Highlight; + dataGridViewCellStyleMainGrid.SelectionForeColor = SystemColors.HighlightText; + dataGridViewCellStyleMainGrid.WrapMode = DataGridViewTriState.False; + dataGridView.DefaultCellStyle = dataGridViewCellStyleMainGrid; + + dataGridViewCellStyleFilterGrid.Alignment = DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyleFilterGrid.BackColor = SystemColors.Window; + dataGridViewCellStyleFilterGrid.Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); + dataGridViewCellStyleFilterGrid.ForeColor = SystemColors.ControlText; + dataGridViewCellStyleFilterGrid.SelectionBackColor = SystemColors.Highlight; + dataGridViewCellStyleFilterGrid.SelectionForeColor = SystemColors.HighlightText; + dataGridViewCellStyleFilterGrid.WrapMode = DataGridViewTriState.False; + filterGridView.DefaultCellStyle = dataGridViewCellStyleFilterGrid; + } - private void UnRegisterLogFileReaderEvents () + private bool LoadPersistenceOptions () + { + if (InvokeRequired) { - if (_logFileReader != null) - { - _logFileReader.LoadFile -= OnLogFileReaderLoadFile; - _logFileReader.LoadingFinished -= OnLogFileReaderFinishedLoading; - _logFileReader.LoadingStarted -= OnLogFileReaderLoadingStarted; - _logFileReader.FileNotFound -= OnLogFileReaderFileNotFound; - _logFileReader.Respawned -= OnLogFileReaderRespawned; - _logFileReader.FileSizeChanged -= OnFileSizeChanged; - } + return (bool)Invoke(new BoolReturnDelegate(LoadPersistenceOptions)); } - private void CreateDefaultViewStyle () + if (!Preferences.saveSessions && ForcedPersistenceFileName == null) { - DataGridViewCellStyle dataGridViewCellStyleMainGrid = new(); - DataGridViewCellStyle dataGridViewCellStyleFilterGrid = new(); - - dataGridViewCellStyleMainGrid.Alignment = DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyleMainGrid.BackColor = SystemColors.Window; - dataGridViewCellStyleMainGrid.Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - dataGridViewCellStyleMainGrid.ForeColor = SystemColors.ControlText; - dataGridViewCellStyleMainGrid.SelectionBackColor = SystemColors.Highlight; - dataGridViewCellStyleMainGrid.SelectionForeColor = SystemColors.HighlightText; - dataGridViewCellStyleMainGrid.WrapMode = DataGridViewTriState.False; - dataGridView.DefaultCellStyle = dataGridViewCellStyleMainGrid; - - dataGridViewCellStyleFilterGrid.Alignment = DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyleFilterGrid.BackColor = SystemColors.Window; - dataGridViewCellStyleFilterGrid.Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - dataGridViewCellStyleFilterGrid.ForeColor = SystemColors.ControlText; - dataGridViewCellStyleFilterGrid.SelectionBackColor = SystemColors.Highlight; - dataGridViewCellStyleFilterGrid.SelectionForeColor = SystemColors.HighlightText; - dataGridViewCellStyleFilterGrid.WrapMode = DataGridViewTriState.False; - filterGridView.DefaultCellStyle = dataGridViewCellStyleFilterGrid; + return false; } - private bool LoadPersistenceOptions () + try { - if (InvokeRequired) + PersistenceData persistenceData; + if (ForcedPersistenceFileName == null) + { + persistenceData = Persister.LoadPersistenceDataOptionsOnly(FileName, Preferences); + } + else { - return (bool)Invoke(new BoolReturnDelegate(LoadPersistenceOptions)); + persistenceData = + Persister.LoadPersistenceDataOptionsOnlyFromFixedFile(ForcedPersistenceFileName); } - if (!Preferences.saveSessions && ForcedPersistenceFileName == null) + if (persistenceData == null) { + _logger.Info($"No persistence data for {FileName} found."); return false; } - try + IsMultiFile = persistenceData.multiFile; + _multiFileOptions = new MultiFileOptions(); + _multiFileOptions.FormatPattern = persistenceData.multiFilePattern; + _multiFileOptions.MaxDayTry = persistenceData.multiFileMaxDays; + + if (string.IsNullOrEmpty(_multiFileOptions.FormatPattern)) { - PersistenceData persistenceData; - if (ForcedPersistenceFileName == null) - { - persistenceData = Persister.LoadPersistenceDataOptionsOnly(FileName, Preferences); - } - else - { - persistenceData = - Persister.LoadPersistenceDataOptionsOnlyFromFixedFile(ForcedPersistenceFileName); - } + _multiFileOptions = ObjectClone.Clone(Preferences.multiFileOptions); + } - if (persistenceData == null) - { - _logger.Info($"No persistence data for {FileName} found."); - return false; - } + splitContainerLogWindow.SplitterDistance = persistenceData.filterPosition; + splitContainerLogWindow.Panel2Collapsed = !persistenceData.filterVisible; + ToggleHighlightPanel(persistenceData.filterSaveListVisible); + ShowAdvancedFilterPanel(persistenceData.filterAdvanced); - IsMultiFile = persistenceData.multiFile; - _multiFileOptions = new MultiFileOptions(); - _multiFileOptions.FormatPattern = persistenceData.multiFilePattern; - _multiFileOptions.MaxDayTry = persistenceData.multiFileMaxDays; + if (_reloadMemento == null) + { + PreselectColumnizer(persistenceData.columnizerName); + } - if (string.IsNullOrEmpty(_multiFileOptions.FormatPattern)) - { - _multiFileOptions = ObjectClone.Clone(Preferences.multiFileOptions); - } + FollowTailChanged(persistenceData.followTail, false); + if (persistenceData.tabName != null) + { + Text = persistenceData.tabName; + } - splitContainerLogWindow.SplitterDistance = persistenceData.filterPosition; - splitContainerLogWindow.Panel2Collapsed = !persistenceData.filterVisible; - ToggleHighlightPanel(persistenceData.filterSaveListVisible); - ShowAdvancedFilterPanel(persistenceData.filterAdvanced); + AdjustHighlightSplitterWidth(); + SetCurrentHighlightGroup(persistenceData.highlightGroupName); - if (_reloadMemento == null) - { - PreselectColumnizer(persistenceData.columnizerName); - } + if (persistenceData.multiFileNames.Count > 0) + { + _logger.Info("Detected MultiFile name list in persistence options"); + _fileNames = new string[persistenceData.multiFileNames.Count]; + persistenceData.multiFileNames.CopyTo(_fileNames); + } + else + { + _fileNames = null; + } - FollowTailChanged(persistenceData.followTail, false); - if (persistenceData.tabName != null) - { - Text = persistenceData.tabName; - } + //this.bookmarkWindow.ShowBookmarkCommentColumn = persistenceData.showBookmarkCommentColumn; + SetExplicitEncoding(persistenceData.encoding); + return true; + } + catch (Exception ex) + { + _logger.Error(ex, "Error loading persistence data: "); + return false; + } + } - AdjustHighlightSplitterWidth(); - SetCurrentHighlightGroup(persistenceData.highlightGroupName); + private void SetDefaultsFromPrefs () + { + filterTailCheckBox.Checked = Preferences.filterTail; + syncFilterCheckBox.Checked = Preferences.filterSync; + FollowTailChanged(Preferences.followTail, false); + _multiFileOptions = ObjectClone.Clone(Preferences.multiFileOptions); + } - if (persistenceData.multiFileNames.Count > 0) - { - _logger.Info("Detected MultiFile name list in persistence options"); - _fileNames = new string[persistenceData.multiFileNames.Count]; - persistenceData.multiFileNames.CopyTo(_fileNames); - } - else - { - _fileNames = null; - } + private void LoadPersistenceData () + { + if (InvokeRequired) + { + Invoke(new MethodInvoker(LoadPersistenceData)); + return; + } - //this.bookmarkWindow.ShowBookmarkCommentColumn = persistenceData.showBookmarkCommentColumn; - SetExplicitEncoding(persistenceData.encoding); - return true; - } - catch (Exception ex) - { - _logger.Error(ex, "Error loading persistence data: "); - return false; - } + if (!Preferences.saveSessions && !ForcePersistenceLoading && ForcedPersistenceFileName == null) + { + SetDefaultsFromPrefs(); + return; } - private void SetDefaultsFromPrefs () + if (IsTempFile) { - filterTailCheckBox.Checked = Preferences.filterTail; - syncFilterCheckBox.Checked = Preferences.filterSync; - FollowTailChanged(Preferences.followTail, false); - _multiFileOptions = ObjectClone.Clone(Preferences.multiFileOptions); + SetDefaultsFromPrefs(); + return; } - private void LoadPersistenceData () + ForcePersistenceLoading = false; // force only 1 time (while session load) + + try { - if (InvokeRequired) + PersistenceData persistenceData; + + if (ForcedPersistenceFileName == null) { - Invoke(new MethodInvoker(LoadPersistenceData)); - return; + persistenceData = Persister.LoadPersistenceData(FileName, Preferences); } - - if (!Preferences.saveSessions && !ForcePersistenceLoading && ForcedPersistenceFileName == null) + else { - SetDefaultsFromPrefs(); - return; + persistenceData = Persister.LoadPersistenceDataFromFixedFile(ForcedPersistenceFileName); } - if (IsTempFile) + if (persistenceData.lineCount > _logFileReader.LineCount) { - SetDefaultsFromPrefs(); + // outdated persistence data (logfile rollover) + // MessageBox.Show(this, "Persistence data for " + this.FileName + " is outdated. It was discarded.", "Log Expert"); + _logger.Info($"Persistence data for {FileName} is outdated. It was discarded."); + _ = LoadPersistenceOptions(); return; } - ForcePersistenceLoading = false; // force only 1 time (while session load) - + _bookmarkProvider.SetBookmarks(persistenceData.bookmarkList); + _rowHeightList = persistenceData.rowHeightList; try { - PersistenceData persistenceData; - - if (ForcedPersistenceFileName == null) + if (persistenceData.currentLine >= 0 && persistenceData.currentLine < dataGridView.RowCount) { - persistenceData = Persister.LoadPersistenceData(FileName, Preferences); + SelectLine(persistenceData.currentLine, false, true); } else { - persistenceData = Persister.LoadPersistenceDataFromFixedFile(ForcedPersistenceFileName); - } - - if (persistenceData.lineCount > _logFileReader.LineCount) - { - // outdated persistence data (logfile rollover) - // MessageBox.Show(this, "Persistence data for " + this.FileName + " is outdated. It was discarded.", "Log Expert"); - _logger.Info($"Persistence data for {FileName} is outdated. It was discarded."); - _ = LoadPersistenceOptions(); - return; - } - - _bookmarkProvider.SetBookmarks(persistenceData.bookmarkList); - _rowHeightList = persistenceData.rowHeightList; - try - { - if (persistenceData.currentLine >= 0 && persistenceData.currentLine < dataGridView.RowCount) - { - SelectLine(persistenceData.currentLine, false, true); - } - else - { - if (_logFileReader.LineCount > 0) - { - dataGridView.FirstDisplayedScrollingRowIndex = _logFileReader.LineCount - 1; - SelectLine(_logFileReader.LineCount - 1, false, true); - } - } - - if (persistenceData.firstDisplayedLine >= 0 && - persistenceData.firstDisplayedLine < dataGridView.RowCount) - { - dataGridView.FirstDisplayedScrollingRowIndex = persistenceData.firstDisplayedLine; - } - - if (persistenceData.followTail) + if (_logFileReader.LineCount > 0) { - FollowTailChanged(persistenceData.followTail, false); + dataGridView.FirstDisplayedScrollingRowIndex = _logFileReader.LineCount - 1; + SelectLine(_logFileReader.LineCount - 1, false, true); } } - catch (ArgumentOutOfRangeException) + + if (persistenceData.firstDisplayedLine >= 0 && + persistenceData.firstDisplayedLine < dataGridView.RowCount) { - // FirstDisplayedScrollingRowIndex calculates sometimes the wrong scrolling ranges??? + dataGridView.FirstDisplayedScrollingRowIndex = persistenceData.firstDisplayedLine; } - if (Preferences.saveFilters) + if (persistenceData.followTail) { - RestoreFilters(persistenceData); + FollowTailChanged(persistenceData.followTail, false); } } - catch (IOException ex) - { - SetDefaultsFromPrefs(); - _logger.Error(ex, "Error loading bookmarks: "); - } - } - - private void RestoreFilters (PersistenceData persistenceData) - { - if (persistenceData.filterParamsList.Count > 0) - { - _filterParams = persistenceData.filterParamsList[0]; - ReInitFilterParams(_filterParams); - } - - ApplyFilterParams(); // re-loaded filter settingss - BeginInvoke(new MethodInvoker(FilterSearch)); - try - { - splitContainerLogWindow.SplitterDistance = persistenceData.filterPosition; - splitContainerLogWindow.Panel2Collapsed = !persistenceData.filterVisible; - } - catch (InvalidOperationException e) + catch (ArgumentOutOfRangeException) { - _logger.Error(e, "Error setting splitter distance: "); + // FirstDisplayedScrollingRowIndex calculates sometimes the wrong scrolling ranges??? } - ShowAdvancedFilterPanel(persistenceData.filterAdvanced); - if (_filterPipeList.Count == 0) // don't restore if it's only a reload + if (Preferences.saveFilters) { - RestoreFilterTabs(persistenceData); + RestoreFilters(persistenceData); } } - - private void RestoreFilterTabs (PersistenceData persistenceData) + catch (IOException ex) { - foreach (FilterTabData data in persistenceData.filterTabDataList) - { - FilterParams persistFilterParams = data.FilterParams; - ReInitFilterParams(persistFilterParams); - List filterResultList = []; - //List lastFilterResultList = new List(); - List filterHitList = []; - Filter(persistFilterParams, filterResultList, _lastFilterLinesList, filterHitList); - FilterPipe pipe = new(persistFilterParams.Clone(), this); - WritePipeToTab(pipe, filterResultList, data.PersistenceData.tabName, data.PersistenceData); - } + SetDefaultsFromPrefs(); + _logger.Error(ex, "Error loading bookmarks: "); } + } - private void ReInitFilterParams (FilterParams filterParams) + private void RestoreFilters (PersistenceData persistenceData) + { + if (persistenceData.filterParamsList.Count > 0) { - filterParams.SearchText = filterParams.SearchText; // init "lowerSearchText" - filterParams.RangeSearchText = filterParams.RangeSearchText; // init "lowerRangesearchText" - filterParams.CurrentColumnizer = CurrentColumnizer; - if (filterParams.IsRegex) - { - try - { - filterParams.CreateRegex(); - } - catch (ArgumentException) - { - StatusLineError("Invalid regular expression"); - } - } + _filterParams = persistenceData.filterParamsList[0]; + ReInitFilterParams(_filterParams); } - private void EnterLoadFileStatus () + ApplyFilterParams(); // re-loaded filter settingss + BeginInvoke(new MethodInvoker(FilterSearch)); + try { - _logger.Debug("EnterLoadFileStatus begin"); - - if (InvokeRequired) - { - Invoke(new MethodInvoker(EnterLoadFileStatus)); - return; - } - - _statusEventArgs.StatusText = "Loading file..."; - _statusEventArgs.LineCount = 0; - _statusEventArgs.FileSize = 0; - SendStatusLineUpdate(); + splitContainerLogWindow.SplitterDistance = persistenceData.filterPosition; + splitContainerLogWindow.Panel2Collapsed = !persistenceData.filterVisible; + } + catch (InvalidOperationException e) + { + _logger.Error(e, "Error setting splitter distance: "); + } - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = 0; - _progressEventArgs.Value = 0; - _progressEventArgs.Visible = true; - SendProgressBarUpdate(); + ShowAdvancedFilterPanel(persistenceData.filterAdvanced); + if (_filterPipeList.Count == 0) // don't restore if it's only a reload + { + RestoreFilterTabs(persistenceData); + } + } - _isLoading = true; - _shouldCancel = true; - ClearFilterList(); - ClearBookmarkList(); - dataGridView.ClearSelection(); - dataGridView.RowCount = 0; - _logger.Debug("EnterLoadFileStatus end"); + private void RestoreFilterTabs (PersistenceData persistenceData) + { + foreach (FilterTabData data in persistenceData.filterTabDataList) + { + FilterParams persistFilterParams = data.FilterParams; + ReInitFilterParams(persistFilterParams); + List filterResultList = []; + //List lastFilterResultList = new List(); + List filterHitList = []; + Filter(persistFilterParams, filterResultList, _lastFilterLinesList, filterHitList); + FilterPipe pipe = new(persistFilterParams.Clone(), this); + WritePipeToTab(pipe, filterResultList, data.PersistenceData.tabName, data.PersistenceData); } + } - private void PositionAfterReload (ReloadMemento reloadMemento) + private void ReInitFilterParams (FilterParams filterParams) + { + filterParams.SearchText = filterParams.SearchText; // init "lowerSearchText" + filterParams.RangeSearchText = filterParams.RangeSearchText; // init "lowerRangesearchText" + filterParams.CurrentColumnizer = CurrentColumnizer; + if (filterParams.IsRegex) { - if (_reloadMemento.CurrentLine < dataGridView.RowCount && _reloadMemento.CurrentLine >= 0) + try { - dataGridView.CurrentCell = dataGridView.Rows[_reloadMemento.CurrentLine].Cells[0]; + filterParams.CreateRegex(); } - - if (_reloadMemento.FirstDisplayedLine < dataGridView.RowCount && _reloadMemento.FirstDisplayedLine >= 0) + catch (ArgumentException) { - dataGridView.FirstDisplayedScrollingRowIndex = _reloadMemento.FirstDisplayedLine; + StatusLineError("Invalid regular expression"); } } + } + + private void EnterLoadFileStatus () + { + _logger.Debug("EnterLoadFileStatus begin"); - private void LogfileDead () + if (InvokeRequired) { - _logger.Info("File not found."); - _isDeadFile = true; + Invoke(new MethodInvoker(EnterLoadFileStatus)); + return; + } - //this.logFileReader.FileSizeChanged -= this.FileSizeChangedHandler; - //if (this.logFileReader != null) - // this.logFileReader.stopMonitoring(); + _statusEventArgs.StatusText = "Loading file..."; + _statusEventArgs.LineCount = 0; + _statusEventArgs.FileSize = 0; + SendStatusLineUpdate(); - dataGridView.Enabled = false; - dataGridView.RowCount = 0; - _progressEventArgs.Visible = false; - _progressEventArgs.Value = _progressEventArgs.MaxValue; - SendProgressBarUpdate(); - _statusEventArgs.FileSize = 0; - _statusEventArgs.LineCount = 0; - _statusEventArgs.CurrentLineNum = 0; - SendStatusLineUpdate(); - _shouldCancel = true; - ClearFilterList(); - ClearBookmarkList(); + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = 0; + _progressEventArgs.Value = 0; + _progressEventArgs.Visible = true; + SendProgressBarUpdate(); + + _isLoading = true; + _shouldCancel = true; + ClearFilterList(); + ClearBookmarkList(); + dataGridView.ClearSelection(); + dataGridView.RowCount = 0; + _logger.Debug("EnterLoadFileStatus end"); + } - StatusLineText("File not found"); - OnFileNotFound(EventArgs.Empty); + private void PositionAfterReload (ReloadMemento reloadMemento) + { + if (_reloadMemento.CurrentLine < dataGridView.RowCount && _reloadMemento.CurrentLine >= 0) + { + dataGridView.CurrentCell = dataGridView.Rows[_reloadMemento.CurrentLine].Cells[0]; } - private void LogfileRespawned () + if (_reloadMemento.FirstDisplayedLine < dataGridView.RowCount && _reloadMemento.FirstDisplayedLine >= 0) { - _logger.Info("LogfileDead(): Reloading file because it has been respawned."); - _isDeadFile = false; - dataGridView.Enabled = true; - StatusLineText(""); - OnFileRespawned(EventArgs.Empty); - Reload(); + dataGridView.FirstDisplayedScrollingRowIndex = _reloadMemento.FirstDisplayedLine; } + } + + private void LogfileDead () + { + _logger.Info("File not found."); + _isDeadFile = true; + + //this.logFileReader.FileSizeChanged -= this.FileSizeChangedHandler; + //if (this.logFileReader != null) + // this.logFileReader.stopMonitoring(); + + dataGridView.Enabled = false; + dataGridView.RowCount = 0; + _progressEventArgs.Visible = false; + _progressEventArgs.Value = _progressEventArgs.MaxValue; + SendProgressBarUpdate(); + _statusEventArgs.FileSize = 0; + _statusEventArgs.LineCount = 0; + _statusEventArgs.CurrentLineNum = 0; + SendStatusLineUpdate(); + _shouldCancel = true; + ClearFilterList(); + ClearBookmarkList(); + + StatusLineText("File not found"); + OnFileNotFound(EventArgs.Empty); + } + + private void LogfileRespawned () + { + _logger.Info("LogfileDead(): Reloading file because it has been respawned."); + _isDeadFile = false; + dataGridView.Enabled = true; + StatusLineText(""); + OnFileRespawned(EventArgs.Empty); + Reload(); + } - private void SetGuiAfterLoading () + private void SetGuiAfterLoading () + { + if (Text.Length == 0) { - if (Text.Length == 0) + if (IsTempFile) { - if (IsTempFile) - { - Text = TempTitleName; - } - else - { - Text = Util.GetNameFromPath(FileName); - } + Text = TempTitleName; + } + else + { + Text = Util.GetNameFromPath(FileName); } + } - ShowBookmarkBubbles = Preferences.showBubbles; - //if (this.forcedColumnizer == null) + ShowBookmarkBubbles = Preferences.showBubbles; + //if (this.forcedColumnizer == null) + { + ILogLineColumnizer columnizer; + if (_forcedColumnizerForLoading != null) { - ILogLineColumnizer columnizer; - if (_forcedColumnizerForLoading != null) - { - columnizer = _forcedColumnizerForLoading; - _forcedColumnizerForLoading = null; - } - else + columnizer = _forcedColumnizerForLoading; + _forcedColumnizerForLoading = null; + } + else + { + columnizer = FindColumnizer(); + if (columnizer != null) { - columnizer = FindColumnizer(); - if (columnizer != null) - { - if (_reloadMemento == null) - { - //TODO this needs to be refactored - var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - - columnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); - } - } - else + if (_reloadMemento == null) { //TODO this needs to be refactored var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - // Default Columnizers - columnizer = ColumnizerPicker.CloneColumnizer(ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers), directory); + columnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); } } - - Invoke(new SetColumnizerFx(SetColumnizer), columnizer); - } - dataGridView.Enabled = true; - DisplayCurrentFileOnStatusline(); - //this.guiStateArgs.FollowTail = this.Preferences.followTail; - _guiStateArgs.MultiFileEnabled = !IsTempFile; - _guiStateArgs.MenuEnabled = true; - _guiStateArgs.CurrentEncoding = _logFileReader.CurrentEncoding; - SendGuiStateUpdate(); - //if (this.dataGridView.RowCount > 0) - // SelectLine(this.dataGridView.RowCount - 1); - //if (this.dataGridView.Columns.Count > 1) - //{ - // this.dataGridView.Columns[this.dataGridView.Columns.Count-1].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; - // this.dataGridView.Columns[this.dataGridView.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - // AdjustMinimumGridWith(); - //} - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - if (Preferences.timestampControl) + else { - SetTimestampLimits(); - SyncTimestampDisplay(); - } + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - Settings settings = ConfigManager.Settings; - ShowLineColumn(!settings.hideLineColumn); + // Default Columnizers + columnizer = ColumnizerPicker.CloneColumnizer(ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers), directory); + } } - ShowTimeSpread(Preferences.showTimeSpread && CurrentColumnizer.IsTimeshiftImplemented()); - locateLineInOriginalFileToolStripMenuItem.Enabled = FilterPipe != null; + Invoke(new SetColumnizerFx(SetColumnizer), columnizer); } - - private ILogLineColumnizer FindColumnizer () + dataGridView.Enabled = true; + DisplayCurrentFileOnStatusline(); + //this.guiStateArgs.FollowTail = this.Preferences.followTail; + _guiStateArgs.MultiFileEnabled = !IsTempFile; + _guiStateArgs.MenuEnabled = true; + _guiStateArgs.CurrentEncoding = _logFileReader.CurrentEncoding; + SendGuiStateUpdate(); + //if (this.dataGridView.RowCount > 0) + // SelectLine(this.dataGridView.RowCount - 1); + //if (this.dataGridView.Columns.Count > 1) + //{ + // this.dataGridView.Columns[this.dataGridView.Columns.Count-1].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; + // this.dataGridView.Columns[this.dataGridView.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; + // AdjustMinimumGridWith(); + //} + if (CurrentColumnizer.IsTimeshiftImplemented()) { - ILogLineColumnizer columnizer; - if (Preferences.maskPrio) - { - columnizer = _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)) ?? _parentLogTabWin.GetColumnizerHistoryEntry(FileName); - } - else + if (Preferences.timestampControl) { - columnizer = _parentLogTabWin.GetColumnizerHistoryEntry(FileName) ?? _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)); + SetTimestampLimits(); + SyncTimestampDisplay(); } - return columnizer; + Settings settings = ConfigManager.Settings; + ShowLineColumn(!settings.hideLineColumn); } - private void ReloadNewFile () - { - // prevent "overloads". May occur on very fast rollovers (next rollover before the file is reloaded) - lock (_reloadLock) - { - _reloadOverloadCounter++; - _logger.Info("ReloadNewFile(): counter = {0}", _reloadOverloadCounter); - if (_reloadOverloadCounter <= 1) - { - SavePersistenceData(false); - _loadingFinishedEvent.Reset(); - _externaLoadingFinishedEvent.Reset(); - Thread reloadFinishedThread = new(ReloadFinishedThreadFx); - reloadFinishedThread.IsBackground = true; - reloadFinishedThread.Start(); - LoadFile(FileName, EncodingOptions); - - ClearBookmarkList(); - SavePersistenceData(false); - - //if (this.filterTailCheckBox.Checked) - //{ - // _logger.logDebug("Waiting for loading to be complete."); - // loadingFinishedEvent.WaitOne(); - // _logger.logDebug("Refreshing filter view because of reload."); - // FilterSearch(); - //} - //LoadFilterPipes(); - } - else - { - _logger.Debug("Preventing reload because of recursive calls."); - } + ShowTimeSpread(Preferences.showTimeSpread && CurrentColumnizer.IsTimeshiftImplemented()); + locateLineInOriginalFileToolStripMenuItem.Enabled = FilterPipe != null; + } - _reloadOverloadCounter--; - } + private ILogLineColumnizer FindColumnizer () + { + ILogLineColumnizer columnizer; + if (Preferences.maskPrio) + { + columnizer = _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)) ?? _parentLogTabWin.GetColumnizerHistoryEntry(FileName); } - - private void ReloadFinishedThreadFx () + else { - _logger.Info("Waiting for loading to be complete."); - _loadingFinishedEvent.WaitOne(); - _logger.Info("Refreshing filter view because of reload."); - Invoke(new MethodInvoker(FilterSearch)); - LoadFilterPipes(); + columnizer = _parentLogTabWin.GetColumnizerHistoryEntry(FileName) ?? _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)); } - private void UpdateProgress (LoadFileEventArgs e) + return columnizer; + } + + private void ReloadNewFile () + { + // prevent "overloads". May occur on very fast rollovers (next rollover before the file is reloaded) + lock (_reloadLock) { - try + _reloadOverloadCounter++; + _logger.Info("ReloadNewFile(): counter = {0}", _reloadOverloadCounter); + if (_reloadOverloadCounter <= 1) { - if (e.ReadPos >= e.FileSize) - { - //_logger.Warn("UpdateProgress(): ReadPos (" + e.ReadPos + ") is greater than file size (" + e.FileSize + "). Aborting Update"); - return; - } + SavePersistenceData(false); + _loadingFinishedEvent.Reset(); + _externaLoadingFinishedEvent.Reset(); + Thread reloadFinishedThread = new(ReloadFinishedThreadFx); + reloadFinishedThread.IsBackground = true; + reloadFinishedThread.Start(); + LoadFile(FileName, EncodingOptions); + + ClearBookmarkList(); + SavePersistenceData(false); - _statusEventArgs.FileSize = e.ReadPos; - //this.progressEventArgs.Visible = true; - _progressEventArgs.MaxValue = (int)e.FileSize; - _progressEventArgs.Value = (int)e.ReadPos; - SendProgressBarUpdate(); - SendStatusLineUpdate(); + //if (this.filterTailCheckBox.Checked) + //{ + // _logger.logDebug("Waiting for loading to be complete."); + // loadingFinishedEvent.WaitOne(); + // _logger.logDebug("Refreshing filter view because of reload."); + // FilterSearch(); + //} + //LoadFilterPipes(); } - catch (Exception ex) + else { - _logger.Error(ex, "UpdateProgress(): "); + _logger.Debug("Preventing reload because of recursive calls."); } + + _reloadOverloadCounter--; } + } + + private void ReloadFinishedThreadFx () + { + _logger.Info("Waiting for loading to be complete."); + _loadingFinishedEvent.WaitOne(); + _logger.Info("Refreshing filter view because of reload."); + Invoke(new MethodInvoker(FilterSearch)); + LoadFilterPipes(); + } - private void LoadingStarted (LoadFileEventArgs e) + private void UpdateProgress (LoadFileEventArgs e) + { + try { - try + if (e.ReadPos >= e.FileSize) { - _statusEventArgs.FileSize = e.ReadPos; - _statusEventArgs.StatusText = "Loading " + Util.GetNameFromPath(e.FileName); - _progressEventArgs.Visible = true; - _progressEventArgs.MaxValue = (int)e.FileSize; - _progressEventArgs.Value = (int)e.ReadPos; - SendProgressBarUpdate(); - SendStatusLineUpdate(); - } - catch (Exception ex) - { - _logger.Error(ex, "LoadingStarted(): "); + //_logger.Warn("UpdateProgress(): ReadPos (" + e.ReadPos + ") is greater than file size (" + e.FileSize + "). Aborting Update"); + return; } - } - private void LoadingFinished () - { - _logger.Info("File loading complete."); - - StatusLineText(""); - _logFileReader.FileSizeChanged += OnFileSizeChanged; - _isLoading = false; - _shouldCancel = false; - dataGridView.SuspendLayout(); - dataGridView.RowCount = _logFileReader.LineCount; - dataGridView.CurrentCellChanged += OnDataGridViewCurrentCellChanged; - dataGridView.Enabled = true; - dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - dataGridView.ResumeLayout(); - _progressEventArgs.Visible = false; - _progressEventArgs.Value = _progressEventArgs.MaxValue; + _statusEventArgs.FileSize = e.ReadPos; + //this.progressEventArgs.Visible = true; + _progressEventArgs.MaxValue = (int)e.FileSize; + _progressEventArgs.Value = (int)e.ReadPos; SendProgressBarUpdate(); - //if (this.logFileReader.LineCount > 0) - //{ - // this.dataGridView.FirstDisplayedScrollingRowIndex = this.logFileReader.LineCount - 1; - // SelectLine(this.logFileReader.LineCount - 1); - //} - _guiStateArgs.FollowTail = true; - SendGuiStateUpdate(); - _statusEventArgs.LineCount = _logFileReader.LineCount; - _statusEventArgs.FileSize = _logFileReader.FileSize; SendStatusLineUpdate(); - - PreferencesChanged(_parentLogTabWin.Preferences, true, SettingsFlags.All); - //LoadPersistenceData(); } + catch (Exception ex) + { + _logger.Error(ex, "UpdateProgress(): "); + } + } - private void LogEventWorker () + private void LoadingStarted (LoadFileEventArgs e) + { + try { - Thread.CurrentThread.Name = "LogEventWorker"; - while (true) - { - _logger.Debug("Waiting for signal"); - _logEventArgsEvent.WaitOne(); - _logger.Debug("Wakeup signal received."); - while (true) - { - LogEventArgs e; - var lastLineCount = 0; - lock (_logEventArgsList) - { - _logger.Info("{0} events in queue", _logEventArgsList.Count); - if (_logEventArgsList.Count == 0) - { - _logEventArgsEvent.Reset(); - break; - } + _statusEventArgs.FileSize = e.ReadPos; + _statusEventArgs.StatusText = "Loading " + Util.GetNameFromPath(e.FileName); + _progressEventArgs.Visible = true; + _progressEventArgs.MaxValue = (int)e.FileSize; + _progressEventArgs.Value = (int)e.ReadPos; + SendProgressBarUpdate(); + SendStatusLineUpdate(); + } + catch (Exception ex) + { + _logger.Error(ex, "LoadingStarted(): "); + } + } - e = _logEventArgsList[0]; - _logEventArgsList.RemoveAt(0); - } + private void LoadingFinished () + { + _logger.Info("File loading complete."); + + StatusLineText(""); + _logFileReader.FileSizeChanged += OnFileSizeChanged; + _isLoading = false; + _shouldCancel = false; + dataGridView.SuspendLayout(); + dataGridView.RowCount = _logFileReader.LineCount; + dataGridView.CurrentCellChanged += OnDataGridViewCurrentCellChanged; + dataGridView.Enabled = true; + dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + dataGridView.ResumeLayout(); + _progressEventArgs.Visible = false; + _progressEventArgs.Value = _progressEventArgs.MaxValue; + SendProgressBarUpdate(); + //if (this.logFileReader.LineCount > 0) + //{ + // this.dataGridView.FirstDisplayedScrollingRowIndex = this.logFileReader.LineCount - 1; + // SelectLine(this.logFileReader.LineCount - 1); + //} + _guiStateArgs.FollowTail = true; + SendGuiStateUpdate(); + _statusEventArgs.LineCount = _logFileReader.LineCount; + _statusEventArgs.FileSize = _logFileReader.FileSize; + SendStatusLineUpdate(); + + PreferencesChanged(_parentLogTabWin.Preferences, true, SettingsFlags.All); + //LoadPersistenceData(); + } - if (e.IsRollover) + private void LogEventWorker () + { + Thread.CurrentThread.Name = "LogEventWorker"; + while (true) + { + _logger.Debug("Waiting for signal"); + _logEventArgsEvent.WaitOne(); + _logger.Debug("Wakeup signal received."); + while (true) + { + LogEventArgs e; + var lastLineCount = 0; + lock (_logEventArgsList) + { + _logger.Info("{0} events in queue", _logEventArgsList.Count); + if (_logEventArgsList.Count == 0) { - ShiftBookmarks(e.RolloverOffset); - ShiftRowHeightList(e.RolloverOffset); - ShiftFilterPipes(e.RolloverOffset); - lastLineCount = 0; + _logEventArgsEvent.Reset(); + break; } - else + + e = _logEventArgsList[0]; + _logEventArgsList.RemoveAt(0); + } + + if (e.IsRollover) + { + ShiftBookmarks(e.RolloverOffset); + ShiftRowHeightList(e.RolloverOffset); + ShiftFilterPipes(e.RolloverOffset); + lastLineCount = 0; + } + else + { + if (e.LineCount < lastLineCount) { - if (e.LineCount < lastLineCount) - { - _logger.Error("Line count of event is: {0}, should be greater than last line count: {1}", e.LineCount, lastLineCount); - } + _logger.Error("Line count of event is: {0}, should be greater than last line count: {1}", e.LineCount, lastLineCount); } - - Invoke(UpdateGrid, [e]); - CheckFilterAndHighlight(e); - _timeSpreadCalc.SetLineCount(e.LineCount); } + + Invoke(UpdateGrid, [e]); + CheckFilterAndHighlight(e); + _timeSpreadCalc.SetLineCount(e.LineCount); } } + } - private void StopLogEventWorkerThread () - { - _logEventArgsEvent.Set(); - cts.Cancel(); - //_logEventHandlerThread.Abort(); - //_logEventHandlerThread.Join(); - } + private void StopLogEventWorkerThread () + { + _logEventArgsEvent.Set(); + cts.Cancel(); + //_logEventHandlerThread.Abort(); + //_logEventHandlerThread.Join(); + } - private void OnFileSizeChanged (LogEventArgs e) + private void OnFileSizeChanged (LogEventArgs e) + { + FileSizeChanged?.Invoke(this, e); + } + + private void UpdateGrid (LogEventArgs e) + { + var oldRowCount = dataGridView.RowCount; + var firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex; + + if (dataGridView.CurrentCellAddress.Y >= e.LineCount) { - FileSizeChanged?.Invoke(this, e); + //this.dataGridView.Rows[this.dataGridView.CurrentCellAddress.Y].Selected = false; + //this.dataGridView.CurrentCell = this.dataGridView.Rows[0].Cells[0]; } - private void UpdateGrid (LogEventArgs e) + try { - var oldRowCount = dataGridView.RowCount; - var firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex; - - if (dataGridView.CurrentCellAddress.Y >= e.LineCount) - { - //this.dataGridView.Rows[this.dataGridView.CurrentCellAddress.Y].Selected = false; - //this.dataGridView.CurrentCell = this.dataGridView.Rows[0].Cells[0]; - } - - try + if (dataGridView.RowCount > e.LineCount) { - if (dataGridView.RowCount > e.LineCount) + var currentLineNum = dataGridView.CurrentCellAddress.Y; + dataGridView.RowCount = 0; + dataGridView.RowCount = e.LineCount; + if (_guiStateArgs.FollowTail == false) { - var currentLineNum = dataGridView.CurrentCellAddress.Y; - dataGridView.RowCount = 0; - dataGridView.RowCount = e.LineCount; - if (_guiStateArgs.FollowTail == false) + if (currentLineNum >= dataGridView.RowCount) { - if (currentLineNum >= dataGridView.RowCount) - { - currentLineNum = dataGridView.RowCount - 1; - } - - dataGridView.CurrentCell = dataGridView.Rows[currentLineNum].Cells[0]; + currentLineNum = dataGridView.RowCount - 1; } + + dataGridView.CurrentCell = dataGridView.Rows[currentLineNum].Cells[0]; } - else - { - dataGridView.RowCount = e.LineCount; - } + } + else + { + dataGridView.RowCount = e.LineCount; + } - _logger.Debug("UpdateGrid(): new RowCount={0}", dataGridView.RowCount); + _logger.Debug("UpdateGrid(): new RowCount={0}", dataGridView.RowCount); - if (e.IsRollover) + if (e.IsRollover) + { + // Multifile rollover + // keep selection and view range, if no follow tail mode + if (!_guiStateArgs.FollowTail) { - // Multifile rollover - // keep selection and view range, if no follow tail mode - if (!_guiStateArgs.FollowTail) + var currentLineNum = dataGridView.CurrentCellAddress.Y; + currentLineNum -= e.RolloverOffset; + if (currentLineNum < 0) { - var currentLineNum = dataGridView.CurrentCellAddress.Y; - currentLineNum -= e.RolloverOffset; - if (currentLineNum < 0) - { - currentLineNum = 0; - } - - _logger.Debug("UpdateGrid(): Rollover=true, Rollover offset={0}, currLineNum was {1}, new currLineNum={2}", e.RolloverOffset, dataGridView.CurrentCellAddress.Y, currentLineNum); - firstDisplayedLine -= e.RolloverOffset; - if (firstDisplayedLine < 0) - { - firstDisplayedLine = 0; - } - - dataGridView.FirstDisplayedScrollingRowIndex = firstDisplayedLine; - dataGridView.CurrentCell = dataGridView.Rows[currentLineNum].Cells[0]; - dataGridView.Rows[currentLineNum].Selected = true; + currentLineNum = 0; } - } - _statusEventArgs.LineCount = e.LineCount; - StatusLineFileSize(e.FileSize); - - if (!_isLoading) - { - if (oldRowCount == 0) + _logger.Debug("UpdateGrid(): Rollover=true, Rollover offset={0}, currLineNum was {1}, new currLineNum={2}", e.RolloverOffset, dataGridView.CurrentCellAddress.Y, currentLineNum); + firstDisplayedLine -= e.RolloverOffset; + if (firstDisplayedLine < 0) { - AdjustMinimumGridWith(); + firstDisplayedLine = 0; } - //CheckFilterAndHighlight(e); + dataGridView.FirstDisplayedScrollingRowIndex = firstDisplayedLine; + dataGridView.CurrentCell = dataGridView.Rows[currentLineNum].Cells[0]; + dataGridView.Rows[currentLineNum].Selected = true; } + } - if (_guiStateArgs.FollowTail && dataGridView.RowCount > 0) - { - dataGridView.FirstDisplayedScrollingRowIndex = dataGridView.RowCount - 1; - OnTailFollowed(EventArgs.Empty); - } + _statusEventArgs.LineCount = e.LineCount; + StatusLineFileSize(e.FileSize); - if (Preferences.timestampControl && !_isLoading) + if (!_isLoading) + { + if (oldRowCount == 0) { - SetTimestampLimits(); + AdjustMinimumGridWith(); } + + //CheckFilterAndHighlight(e); } - catch (Exception ex) + + if (_guiStateArgs.FollowTail && dataGridView.RowCount > 0) { - _logger.Error(ex, "Fehler bei UpdateGrid(): "); + dataGridView.FirstDisplayedScrollingRowIndex = dataGridView.RowCount - 1; + OnTailFollowed(EventArgs.Empty); } - //this.dataGridView.Refresh(); - //this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + if (Preferences.timestampControl && !_isLoading) + { + SetTimestampLimits(); + } + } + catch (Exception ex) + { + _logger.Error(ex, "Fehler bei UpdateGrid(): "); } - private void CheckFilterAndHighlight (LogEventArgs e) + //this.dataGridView.Refresh(); + //this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + } + + private void CheckFilterAndHighlight (LogEventArgs e) + { + var noLed = true; + bool suppressLed; + bool setBookmark; + bool stopTail; + string bookmarkComment; + + if (filterTailCheckBox.Checked || _filterPipeList.Count > 0) { - var noLed = true; - bool suppressLed; - bool setBookmark; - bool stopTail; - string bookmarkComment; + var filterStart = e.PrevLineCount; + if (e.IsRollover) + { + ShiftFilterLines(e.RolloverOffset); + filterStart -= e.RolloverOffset; + } - if (filterTailCheckBox.Checked || _filterPipeList.Count > 0) + var firstStopTail = true; + ColumnizerCallback callback = new(this); + var filterLineAdded = false; + for (var i = filterStart; i < e.LineCount; ++i) { - var filterStart = e.PrevLineCount; - if (e.IsRollover) + ILogLine line = _logFileReader.GetLogLine(i); + if (line == null) { - ShiftFilterLines(e.RolloverOffset); - filterStart -= e.RolloverOffset; + return; } - var firstStopTail = true; - ColumnizerCallback callback = new(this); - var filterLineAdded = false; - for (var i = filterStart; i < e.LineCount; ++i) + if (filterTailCheckBox.Checked) { - ILogLine line = _logFileReader.GetLogLine(i); - if (line == null) + callback.SetLineNum(i); + if (Util.TestFilterCondition(_filterParams, line, callback)) { - return; + //AddFilterLineFx addFx = new AddFilterLineFx(AddFilterLine); + //this.Invoke(addFx, new object[] { i, true }); + filterLineAdded = true; + AddFilterLine(i, false, _filterParams, _filterResultList, _lastFilterLinesList, + _filterHitList); } + } + + //ProcessFilterPipeFx pipeFx = new ProcessFilterPipeFx(ProcessFilterPipes); + //pipeFx.BeginInvoke(i, null, null); + ProcessFilterPipes(i); + + IList matchingList = FindMatchingHilightEntries(line); + LaunchHighlightPlugins(matchingList, i); + GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, out bookmarkComment); + if (setBookmark) + { + SetBookmarkFx fx = SetBookmarkFromTrigger; + fx.BeginInvoke(i, bookmarkComment, null, null); + } - if (filterTailCheckBox.Checked) + if (stopTail && _guiStateArgs.FollowTail) + { + var wasFollow = _guiStateArgs.FollowTail; + FollowTailChanged(false, true); + if (firstStopTail && wasFollow) { - callback.SetLineNum(i); - if (Util.TestFilterCondition(_filterParams, line, callback)) - { - //AddFilterLineFx addFx = new AddFilterLineFx(AddFilterLine); - //this.Invoke(addFx, new object[] { i, true }); - filterLineAdded = true; - AddFilterLine(i, false, _filterParams, _filterResultList, _lastFilterLinesList, - _filterHitList); - } + Invoke(new SelectLineFx(SelectAndEnsureVisible), [i, false]); + firstStopTail = false; } + } + + if (!suppressLed) + { + noLed = false; + } + } - //ProcessFilterPipeFx pipeFx = new ProcessFilterPipeFx(ProcessFilterPipes); - //pipeFx.BeginInvoke(i, null, null); - ProcessFilterPipes(i); + if (filterLineAdded) + { + //AddFilterLineGuiUpdateFx addFx = new AddFilterLineGuiUpdateFx(AddFilterLineGuiUpdate); + //this.Invoke(addFx); + TriggerFilterLineGuiUpdate(); + } + } + else + { + var firstStopTail = true; + var startLine = e.PrevLineCount; + if (e.IsRollover) + { + ShiftFilterLines(e.RolloverOffset); + startLine -= e.RolloverOffset; + } + for (var i = startLine; i < e.LineCount; ++i) + { + ILogLine line = _logFileReader.GetLogLine(i); + if (line != null) + { IList matchingList = FindMatchingHilightEntries(line); LaunchHighlightPlugins(matchingList, i); - GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, out bookmarkComment); + GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, + out bookmarkComment); if (setBookmark) { SetBookmarkFx fx = SetBookmarkFromTrigger; @@ -825,1595 +874,1533 @@ private void CheckFilterAndHighlight (LogEventArgs e) noLed = false; } } - - if (filterLineAdded) - { - //AddFilterLineGuiUpdateFx addFx = new AddFilterLineGuiUpdateFx(AddFilterLineGuiUpdate); - //this.Invoke(addFx); - TriggerFilterLineGuiUpdate(); - } - } - else - { - var firstStopTail = true; - var startLine = e.PrevLineCount; - if (e.IsRollover) - { - ShiftFilterLines(e.RolloverOffset); - startLine -= e.RolloverOffset; - } - - for (var i = startLine; i < e.LineCount; ++i) - { - ILogLine line = _logFileReader.GetLogLine(i); - if (line != null) - { - IList matchingList = FindMatchingHilightEntries(line); - LaunchHighlightPlugins(matchingList, i); - GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, - out bookmarkComment); - if (setBookmark) - { - SetBookmarkFx fx = SetBookmarkFromTrigger; - fx.BeginInvoke(i, bookmarkComment, null, null); - } - - if (stopTail && _guiStateArgs.FollowTail) - { - var wasFollow = _guiStateArgs.FollowTail; - FollowTailChanged(false, true); - if (firstStopTail && wasFollow) - { - Invoke(new SelectLineFx(SelectAndEnsureVisible), [i, false]); - firstStopTail = false; - } - } - - if (!suppressLed) - { - noLed = false; - } - } - } } + } - if (!noLed) - { - OnFileSizeChanged(e); - } + if (!noLed) + { + OnFileSizeChanged(e); } + } - private void LaunchHighlightPlugins (IList matchingList, int lineNum) + private void LaunchHighlightPlugins (IList matchingList, int lineNum) + { + LogExpertCallback callback = new(this) { - LogExpertCallback callback = new(this) - { - LineNum = lineNum - }; + LineNum = lineNum + }; - foreach (HighlightEntry entry in matchingList) + foreach (HighlightEntry entry in matchingList) + { + if (entry.IsActionEntry && entry.ActionEntry.PluginName != null) { - if (entry.IsActionEntry && entry.ActionEntry.PluginName != null) + IKeywordAction plugin = PluginRegistry.PluginRegistry.Instance.FindKeywordActionPluginByName(entry.ActionEntry.PluginName); + if (plugin != null) { - IKeywordAction plugin = PluginRegistry.PluginRegistry.Instance.FindKeywordActionPluginByName(entry.ActionEntry.PluginName); - if (plugin != null) - { - ActionPluginExecuteFx fx = plugin.Execute; - fx.BeginInvoke(entry.SearchText, entry.ActionEntry.ActionParam, callback, CurrentColumnizer, null, null); - } + ActionPluginExecuteFx fx = plugin.Execute; + fx.BeginInvoke(entry.SearchText, entry.ActionEntry.ActionParam, callback, CurrentColumnizer, null, null); } } } + } + + private void PreSelectColumnizer (ILogLineColumnizer columnizer) + { + CurrentColumnizer = columnizer != null + ? (_forcedColumnizerForLoading = columnizer) + : (_forcedColumnizerForLoading = ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers)); + } + + private void SetColumnizer (ILogLineColumnizer columnizer) + { + columnizer = ColumnizerPicker.FindReplacementForAutoColumnizer(FileName, _logFileReader, columnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - private void PreSelectColumnizer (ILogLineColumnizer columnizer) + var timeDiff = 0; + if (CurrentColumnizer != null && CurrentColumnizer.IsTimeshiftImplemented()) { - CurrentColumnizer = columnizer != null - ? (_forcedColumnizerForLoading = columnizer) - : (_forcedColumnizerForLoading = ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers)); + timeDiff = CurrentColumnizer.GetTimeOffset(); } - private void SetColumnizer (ILogLineColumnizer columnizer) - { - columnizer = ColumnizerPicker.FindReplacementForAutoColumnizer(FileName, _logFileReader, columnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + SetColumnizerInternal(columnizer); - var timeDiff = 0; - if (CurrentColumnizer != null && CurrentColumnizer.IsTimeshiftImplemented()) - { - timeDiff = CurrentColumnizer.GetTimeOffset(); - } + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + CurrentColumnizer.SetTimeOffset(timeDiff); + } + } - SetColumnizerInternal(columnizer); + private void SetColumnizerInternal (ILogLineColumnizer columnizer) + { + _logger.Info("SetColumnizerInternal(): {0}", columnizer.GetName()); - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - CurrentColumnizer.SetTimeOffset(timeDiff); - } - } + ILogLineColumnizer oldColumnizer = CurrentColumnizer; + var oldColumnizerIsXmlType = CurrentColumnizer is ILogLineXmlColumnizer; + var oldColumnizerIsPreProcess = CurrentColumnizer is IPreProcessColumnizer; + var mustReload = false; - private void SetColumnizerInternal (ILogLineColumnizer columnizer) + // Check if the filtered columns disappeared, if so must refresh the UI + if (_filterParams.ColumnRestrict) { - _logger.Info("SetColumnizerInternal(): {0}", columnizer.GetName()); + var newColumns = columnizer != null ? columnizer.GetColumnNames() : Array.Empty(); + var colChanged = false; - ILogLineColumnizer oldColumnizer = CurrentColumnizer; - var oldColumnizerIsXmlType = CurrentColumnizer is ILogLineXmlColumnizer; - var oldColumnizerIsPreProcess = CurrentColumnizer is IPreProcessColumnizer; - var mustReload = false; - - // Check if the filtered columns disappeared, if so must refresh the UI - if (_filterParams.ColumnRestrict) + if (dataGridView.ColumnCount - 2 == newColumns.Length) // two first columns are 'marker' and 'line number' { - var newColumns = columnizer != null ? columnizer.GetColumnNames() : Array.Empty(); - var colChanged = false; - - if (dataGridView.ColumnCount - 2 == newColumns.Length) // two first columns are 'marker' and 'line number' + for (var i = 0; i < newColumns.Length; i++) { - for (var i = 0; i < newColumns.Length; i++) + if (dataGridView.Columns[i].HeaderText != newColumns[i]) { - if (dataGridView.Columns[i].HeaderText != newColumns[i]) - { - colChanged = true; - break; // one change is sufficient - } + colChanged = true; + break; // one change is sufficient } } - else - { - colChanged = true; - } - - if (colChanged) - { - // Update UI - columnNamesLabel.Text = CalculateColumnNames(_filterParams); - } } - - Type oldColType = _filterParams.CurrentColumnizer?.GetType(); - Type newColType = columnizer?.GetType(); - - if (oldColType != newColType && _filterParams.ColumnRestrict && _filterParams.IsFilterTail) + else { - _filterParams.ColumnList.Clear(); + colChanged = true; } - if (CurrentColumnizer == null || CurrentColumnizer.GetType() != columnizer.GetType()) + if (colChanged) { - CurrentColumnizer = columnizer; - _freezeStateMap.Clear(); - if (_logFileReader != null) - { - if (CurrentColumnizer is IPreProcessColumnizer) - { - _logFileReader.PreProcessColumnizer = (IPreProcessColumnizer)CurrentColumnizer; - } - else - { - _logFileReader.PreProcessColumnizer = null; - } - } + // Update UI + columnNamesLabel.Text = CalculateColumnNames(_filterParams); + } + } - // always reload when choosing XML columnizers - if (_logFileReader != null && CurrentColumnizer is ILogLineXmlColumnizer) - { - //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() - mustReload = true; - } + Type oldColType = _filterParams.CurrentColumnizer?.GetType(); + Type newColType = columnizer?.GetType(); + + if (oldColType != newColType && _filterParams.ColumnRestrict && _filterParams.IsFilterTail) + { + _filterParams.ColumnList.Clear(); + } - // Reload when choosing no XML columnizer but previous columnizer was XML - if (_logFileReader != null && !(CurrentColumnizer is ILogLineXmlColumnizer) && oldColumnizerIsXmlType) + if (CurrentColumnizer == null || CurrentColumnizer.GetType() != columnizer.GetType()) + { + CurrentColumnizer = columnizer; + _freezeStateMap.Clear(); + if (_logFileReader != null) + { + if (CurrentColumnizer is IPreProcessColumnizer) { - _logFileReader.IsXmlMode = false; - //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() - mustReload = true; + _logFileReader.PreProcessColumnizer = (IPreProcessColumnizer)CurrentColumnizer; } - - // Reload when previous columnizer was PreProcess and current is not, and vice versa. - // When the current columnizer is a preProcess columnizer, reload in every case. - if (CurrentColumnizer is IPreProcessColumnizer != oldColumnizerIsPreProcess || - CurrentColumnizer is IPreProcessColumnizer) + else { - //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() - mustReload = true; + _logFileReader.PreProcessColumnizer = null; } } - else - { - CurrentColumnizer = columnizer; - } - - (oldColumnizer as IInitColumnizer)?.DeSelected(new ColumnizerCallback(this)); - - (columnizer as IInitColumnizer)?.Selected(new ColumnizerCallback(this)); - - SetColumnizer(columnizer, dataGridView); - SetColumnizer(columnizer, filterGridView); - _patternWindow?.SetColumnizer(columnizer); - - _guiStateArgs.TimeshiftPossible = columnizer.IsTimeshiftImplemented(); - SendGuiStateUpdate(); - if (_logFileReader != null) + // always reload when choosing XML columnizers + if (_logFileReader != null && CurrentColumnizer is ILogLineXmlColumnizer) { - dataGridView.RowCount = _logFileReader.LineCount; + //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() + mustReload = true; } - if (_filterResultList != null) + // Reload when choosing no XML columnizer but previous columnizer was XML + if (_logFileReader != null && !(CurrentColumnizer is ILogLineXmlColumnizer) && oldColumnizerIsXmlType) { - filterGridView.RowCount = _filterResultList.Count; + _logFileReader.IsXmlMode = false; + //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() + mustReload = true; } - if (mustReload) + // Reload when previous columnizer was PreProcess and current is not, and vice versa. + // When the current columnizer is a preProcess columnizer, reload in every case. + if (CurrentColumnizer is IPreProcessColumnizer != oldColumnizerIsPreProcess || + CurrentColumnizer is IPreProcessColumnizer) { - Reload(); + //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() + mustReload = true; } - else - { - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - SetTimestampLimits(); - SyncTimestampDisplay(); - } + } + else + { + CurrentColumnizer = columnizer; + } - Settings settings = ConfigManager.Settings; - ShowLineColumn(!settings.hideLineColumn); - ShowTimeSpread(Preferences.showTimeSpread && columnizer.IsTimeshiftImplemented()); - } + (oldColumnizer as IInitColumnizer)?.DeSelected(new ColumnizerCallback(this)); - if (!columnizer.IsTimeshiftImplemented() && IsTimeSynced) - { - FreeFromTimeSync(); - } + (columnizer as IInitColumnizer)?.Selected(new ColumnizerCallback(this)); - columnComboBox.Items.Clear(); + SetColumnizer(columnizer, dataGridView); + SetColumnizer(columnizer, filterGridView); + _patternWindow?.SetColumnizer(columnizer); - foreach (var columnName in columnizer.GetColumnNames()) - { - columnComboBox.Items.Add(columnName); - } + _guiStateArgs.TimeshiftPossible = columnizer.IsTimeshiftImplemented(); + SendGuiStateUpdate(); - columnComboBox.SelectedIndex = 0; + if (_logFileReader != null) + { + dataGridView.RowCount = _logFileReader.LineCount; + } - OnColumnizerChanged(CurrentColumnizer); + if (_filterResultList != null) + { + filterGridView.RowCount = _filterResultList.Count; } - private void AutoResizeColumns (BufferedDataGridView gridView) + if (mustReload) { - try - { - gridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - if (gridView.Columns.Count > 1 && Preferences.setLastColumnWidth && - gridView.Columns[gridView.Columns.Count - 1].Width < Preferences.lastColumnWidth - ) - { - // It seems that using 'MinimumWidth' instead of 'Width' prevents the DataGridView's NullReferenceExceptions - //gridView.Columns[gridView.Columns.Count - 1].Width = this.Preferences.lastColumnWidth; - gridView.Columns[gridView.Columns.Count - 1].MinimumWidth = Preferences.lastColumnWidth; - } - } - catch (NullReferenceException e) + Reload(); + } + else + { + if (CurrentColumnizer.IsTimeshiftImplemented()) { - // See https://connect.microsoft.com/VisualStudio/feedback/details/366943/autoresizecolumns-in-datagridview-throws-nullreferenceexception - // possible solution => https://stackoverflow.com/questions/36287553/nullreferenceexception-when-trying-to-set-datagridview-column-width-brings-th - // There are some rare situations with null ref exceptions when resizing columns and on filter finished - // So catch them here. Better than crashing. - _logger.Error(e, "Error while resizing columns: "); + SetTimestampLimits(); + SyncTimestampDisplay(); } + + Settings settings = ConfigManager.Settings; + ShowLineColumn(!settings.hideLineColumn); + ShowTimeSpread(Preferences.showTimeSpread && columnizer.IsTimeshiftImplemented()); } - private void PaintCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, - HighlightEntry groundEntry) + if (!columnizer.IsTimeshiftImplemented() && IsTimeSynced) { - PaintHighlightedCell(e, gridView, noBackgroundFill, groundEntry); + FreeFromTimeSync(); } - private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, - bool noBackgroundFill, - HighlightEntry groundEntry) + columnComboBox.Items.Clear(); + + foreach (var columnName in columnizer.GetColumnNames()) { - var column = e.Value as IColumn; + columnComboBox.Items.Add(columnName); + } + + columnComboBox.SelectedIndex = 0; - column ??= Column.EmptyColumn; + OnColumnizerChanged(CurrentColumnizer); + } - IList matchList = FindHighlightMatches(column); - // too many entries per line seem to cause problems with the GDI - while (matchList.Count > 50) + private void AutoResizeColumns (BufferedDataGridView gridView) + { + try + { + gridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + if (gridView.Columns.Count > 1 && Preferences.setLastColumnWidth && + gridView.Columns[gridView.Columns.Count - 1].Width < Preferences.lastColumnWidth + ) { - matchList.RemoveAt(50); + // It seems that using 'MinimumWidth' instead of 'Width' prevents the DataGridView's NullReferenceExceptions + //gridView.Columns[gridView.Columns.Count - 1].Width = this.Preferences.lastColumnWidth; + gridView.Columns[gridView.Columns.Count - 1].MinimumWidth = Preferences.lastColumnWidth; } + } + catch (NullReferenceException e) + { + // See https://connect.microsoft.com/VisualStudio/feedback/details/366943/autoresizecolumns-in-datagridview-throws-nullreferenceexception + // possible solution => https://stackoverflow.com/questions/36287553/nullreferenceexception-when-trying-to-set-datagridview-column-width-brings-th + // There are some rare situations with null ref exceptions when resizing columns and on filter finished + // So catch them here. Better than crashing. + _logger.Error(e, "Error while resizing columns: "); + } + } - var he = new HighlightEntry - { - SearchText = column.DisplayValue, - ForegroundColor = groundEntry?.ForegroundColor ?? Color.FromKnownColor(KnownColor.Black), - BackgroundColor = groundEntry?.BackgroundColor ?? Color.Empty, - IsWordMatch = true - }; + private void PaintCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, + HighlightEntry groundEntry) + { + PaintHighlightedCell(e, gridView, noBackgroundFill, groundEntry); + } - HilightMatchEntry hme = new() - { - StartPos = 0, - Length = column.DisplayValue.Length, - HilightEntry = he - }; + private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, + bool noBackgroundFill, + HighlightEntry groundEntry) + { + var column = e.Value as IColumn; - if (groundEntry != null) - { - hme.HilightEntry.IsBold = groundEntry.IsBold; - } + column ??= Column.EmptyColumn; - matchList = MergeHighlightMatchEntries(matchList, hme); + IList matchList = FindHighlightMatches(column); + // too many entries per line seem to cause problems with the GDI + while (matchList.Count > 50) + { + matchList.RemoveAt(50); + } - var leftPad = e.CellStyle.Padding.Left; - RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, - e.CellBounds.Height); - Rectangle borderWidths = PaintHelper.BorderWidths(e.AdvancedBorderStyle); - Rectangle valBounds = e.CellBounds; - valBounds.Offset(borderWidths.X, borderWidths.Y); - valBounds.Width -= borderWidths.Right; - valBounds.Height -= borderWidths.Bottom; - if (e.CellStyle.Padding != Padding.Empty) - { - valBounds.Offset(e.CellStyle.Padding.Left, e.CellStyle.Padding.Top); - valBounds.Width -= e.CellStyle.Padding.Horizontal; - valBounds.Height -= e.CellStyle.Padding.Vertical; - } + var he = new HighlightEntry + { + SearchText = column.DisplayValue, + ForegroundColor = groundEntry?.ForegroundColor ?? Color.FromKnownColor(KnownColor.Black), + BackgroundColor = groundEntry?.BackgroundColor ?? Color.Empty, + IsWordMatch = true + }; + + HilightMatchEntry hme = new() + { + StartPos = 0, + Length = column.DisplayValue.Length, + HilightEntry = he + }; - TextFormatFlags flags = - TextFormatFlags.Left - | TextFormatFlags.SingleLine - | TextFormatFlags.NoPrefix - | TextFormatFlags.PreserveGraphicsClipping - | TextFormatFlags.NoPadding - | TextFormatFlags.VerticalCenter - | TextFormatFlags.TextBoxControl - ; + if (groundEntry != null) + { + hme.HilightEntry.IsBold = groundEntry.IsBold; + } - // | TextFormatFlags.VerticalCenter - // | TextFormatFlags.TextBoxControl - // TextFormatFlags.SingleLine + matchList = MergeHighlightMatchEntries(matchList, hme); - //TextRenderer.DrawText(e.Graphics, e.Value as String, e.CellStyle.Font, valBounds, Color.FromKnownColor(KnownColor.Black), flags); + var leftPad = e.CellStyle.Padding.Left; + RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, + e.CellBounds.Height); + Rectangle borderWidths = PaintHelper.BorderWidths(e.AdvancedBorderStyle); + Rectangle valBounds = e.CellBounds; + valBounds.Offset(borderWidths.X, borderWidths.Y); + valBounds.Width -= borderWidths.Right; + valBounds.Height -= borderWidths.Bottom; + if (e.CellStyle.Padding != Padding.Empty) + { + valBounds.Offset(e.CellStyle.Padding.Left, e.CellStyle.Padding.Top); + valBounds.Width -= e.CellStyle.Padding.Horizontal; + valBounds.Height -= e.CellStyle.Padding.Vertical; + } - Point wordPos = valBounds.Location; - Size proposedSize = new(valBounds.Width, valBounds.Height); + TextFormatFlags flags = + TextFormatFlags.Left + | TextFormatFlags.SingleLine + | TextFormatFlags.NoPrefix + | TextFormatFlags.PreserveGraphicsClipping + | TextFormatFlags.NoPadding + | TextFormatFlags.VerticalCenter + | TextFormatFlags.TextBoxControl + ; - Rectangle r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); - e.Graphics.SetClip(e.CellBounds); + // | TextFormatFlags.VerticalCenter + // | TextFormatFlags.TextBoxControl + // TextFormatFlags.SingleLine - foreach (HilightMatchEntry matchEntry in matchList) - { - Font font = matchEntry != null && matchEntry.HilightEntry.IsBold ? BoldFont : NormalFont; - Brush bgBrush = matchEntry.HilightEntry.BackgroundColor != Color.Empty - ? new SolidBrush(matchEntry.HilightEntry.BackgroundColor) - : null; - var matchWord = column.DisplayValue.Substring(matchEntry.StartPos, matchEntry.Length); - Size wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags); - wordSize.Height = e.CellBounds.Height; - Rectangle wordRect = new(wordPos, wordSize); + //TextRenderer.DrawText(e.Graphics, e.Value as String, e.CellStyle.Font, valBounds, Color.FromKnownColor(KnownColor.Black), flags); - Color foreColor = matchEntry.HilightEntry.ForegroundColor; - if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected) - { - if (!noBackgroundFill && bgBrush != null && !matchEntry.HilightEntry.NoBackground) - { - e.Graphics.FillRectangle(bgBrush, wordRect); - } - } + Point wordPos = valBounds.Location; + Size proposedSize = new(valBounds.Width, valBounds.Height); - if (foreColor == Color.Black) + Rectangle r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); + e.Graphics.SetClip(e.CellBounds); + + foreach (HilightMatchEntry matchEntry in matchList) + { + Font font = matchEntry != null && matchEntry.HilightEntry.IsBold ? BoldFont : NormalFont; + Brush bgBrush = matchEntry.HilightEntry.BackgroundColor != Color.Empty + ? new SolidBrush(matchEntry.HilightEntry.BackgroundColor) + : null; + var matchWord = column.DisplayValue.Substring(matchEntry.StartPos, matchEntry.Length); + Size wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags); + wordSize.Height = e.CellBounds.Height; + Rectangle wordRect = new(wordPos, wordSize); + + Color foreColor = matchEntry.HilightEntry.ForegroundColor; + if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected) + { + if (!noBackgroundFill && bgBrush != null && !matchEntry.HilightEntry.NoBackground) { - foreColor = ColorMode.ForeColor; + e.Graphics.FillRectangle(bgBrush, wordRect); } + } - TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, - foreColor, flags); - - wordPos.Offset(wordSize.Width, 0); - bgBrush?.Dispose(); + if (foreColor == Color.Black) + { + foreColor = ColorMode.ForeColor; } + + TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, + foreColor, flags); + + wordPos.Offset(wordSize.Width, 0); + bgBrush?.Dispose(); } + } - /// - /// Builds a list of HilightMatchEntry objects. A HilightMatchEntry spans over a region that is painted with the same foreground and - /// background colors. - /// All regions which don't match a word-mode entry will be painted with the colors of a default entry (groundEntry). This is either the - /// first matching non-word-mode highlight entry or a black-on-white default (if no matching entry was found). - /// - /// List of all highlight matches for the current cell - /// The entry that is used as the default. - /// List of HilightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring. - private IList MergeHighlightMatchEntries (IList matchList, - HilightMatchEntry groundEntry) + /// + /// Builds a list of HilightMatchEntry objects. A HilightMatchEntry spans over a region that is painted with the same foreground and + /// background colors. + /// All regions which don't match a word-mode entry will be painted with the colors of a default entry (groundEntry). This is either the + /// first matching non-word-mode highlight entry or a black-on-white default (if no matching entry was found). + /// + /// List of all highlight matches for the current cell + /// The entry that is used as the default. + /// List of HilightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring. + private IList MergeHighlightMatchEntries (IList matchList, + HilightMatchEntry groundEntry) + { + // Fill an area with lenth of whole text with a default hilight entry + var entryArray = new HighlightEntry[groundEntry.Length]; + for (var i = 0; i < entryArray.Length; ++i) { - // Fill an area with lenth of whole text with a default hilight entry - var entryArray = new HighlightEntry[groundEntry.Length]; - for (var i = 0; i < entryArray.Length; ++i) - { - entryArray[i] = groundEntry.HilightEntry; - } + entryArray[i] = groundEntry.HilightEntry; + } - // "overpaint" with all matching word match enries - // Non-word-mode matches will not overpaint because they use the groundEntry - foreach (HilightMatchEntry me in matchList) + // "overpaint" with all matching word match enries + // Non-word-mode matches will not overpaint because they use the groundEntry + foreach (HilightMatchEntry me in matchList) + { + var endPos = me.StartPos + me.Length; + for (var i = me.StartPos; i < endPos; ++i) { - var endPos = me.StartPos + me.Length; - for (var i = me.StartPos; i < endPos; ++i) + if (me.HilightEntry.IsWordMatch) { - if (me.HilightEntry.IsWordMatch) - { - entryArray[i] = me.HilightEntry; - } - else - { - //entryArray[i].ForegroundColor = me.HilightEntry.ForegroundColor; - } + entryArray[i] = me.HilightEntry; + } + else + { + //entryArray[i].ForegroundColor = me.HilightEntry.ForegroundColor; } } + } - // collect areas with same hilight entry and build new highlight match entries for it - IList mergedList = []; + // collect areas with same hilight entry and build new highlight match entries for it + IList mergedList = []; - if (entryArray.Length > 0) - { - HighlightEntry currentEntry = entryArray[0]; - var lastStartPos = 0; - var pos = 0; + if (entryArray.Length > 0) + { + HighlightEntry currentEntry = entryArray[0]; + var lastStartPos = 0; + var pos = 0; - for (; pos < entryArray.Length; ++pos) + for (; pos < entryArray.Length; ++pos) + { + if (entryArray[pos] != currentEntry) { - if (entryArray[pos] != currentEntry) + HilightMatchEntry me = new() { - HilightMatchEntry me = new() - { - StartPos = lastStartPos, - Length = pos - lastStartPos, - HilightEntry = currentEntry - }; - - mergedList.Add(me); - currentEntry = entryArray[pos]; - lastStartPos = pos; - } - } - - HilightMatchEntry me2 = new() - { - StartPos = lastStartPos, - Length = pos - lastStartPos, - HilightEntry = currentEntry - }; + StartPos = lastStartPos, + Length = pos - lastStartPos, + HilightEntry = currentEntry + }; - mergedList.Add(me2); + mergedList.Add(me); + currentEntry = entryArray[pos]; + lastStartPos = pos; + } } - return mergedList; - } + HilightMatchEntry me2 = new() + { + StartPos = lastStartPos, + Length = pos - lastStartPos, + HilightEntry = currentEntry + }; - /// - /// Returns the first HilightEntry that matches the given line - /// - private HighlightEntry FindHilightEntry (ITextValue line) - { - return FindHighlightEntry(line, false); + mergedList.Add(me2); } - private HighlightEntry FindFirstNoWordMatchHilightEntry (ITextValue line) + return mergedList; + } + + /// + /// Returns the first HilightEntry that matches the given line + /// + private HighlightEntry FindHilightEntry (ITextValue line) + { + return FindHighlightEntry(line, false); + } + + private HighlightEntry FindFirstNoWordMatchHilightEntry (ITextValue line) + { + return FindHighlightEntry(line, true); + } + + private bool CheckHighlightEntryMatch (HighlightEntry entry, ITextValue column) + { + if (entry.IsRegEx) { - return FindHighlightEntry(line, true); + //Regex rex = new Regex(entry.SearchText, entry.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); + if (entry.Regex.IsMatch(column.Text)) + { + return true; + } } - - private bool CheckHighlightEntryMatch (HighlightEntry entry, ITextValue column) + else { - if (entry.IsRegEx) + if (entry.IsCaseSensitive) { - //Regex rex = new Regex(entry.SearchText, entry.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); - if (entry.Regex.IsMatch(column.Text)) + if (column.Text.Contains(entry.SearchText)) { return true; } } else { - if (entry.IsCaseSensitive) - { - if (column.Text.Contains(entry.SearchText)) - { - return true; - } - } - else + if (column.Text.ToLower().Contains(entry.SearchText.ToLower())) { - if (column.Text.ToLower().Contains(entry.SearchText.ToLower())) - { - return true; - } + return true; } } - - return false; } - /// - /// Returns all HilightEntry entries which matches the given line - /// - private IList FindMatchingHilightEntries (ITextValue line) + return false; + } + + /// + /// Returns all HilightEntry entries which matches the given line + /// + private IList FindMatchingHilightEntries (ITextValue line) + { + IList resultList = []; + if (line != null) { - IList resultList = []; - if (line != null) + lock (_currentHighlightGroupLock) { - lock (_currentHighlightGroupLock) + foreach (HighlightEntry entry in _currentHighlightGroup.HighlightEntryList) { - foreach (HighlightEntry entry in _currentHighlightGroup.HighlightEntryList) + if (CheckHighlightEntryMatch(entry, line)) { - if (CheckHighlightEntryMatch(entry, line)) - { - resultList.Add(entry); - } + resultList.Add(entry); } } } - - return resultList; } - private void GetHighlightEntryMatches (ITextValue line, IList hilightEntryList, IList resultList) + return resultList; + } + + private void GetHighlightEntryMatches (ITextValue line, IList hilightEntryList, IList resultList) + { + foreach (HighlightEntry entry in hilightEntryList) { - foreach (HighlightEntry entry in hilightEntryList) + if (entry.IsWordMatch) { - if (entry.IsWordMatch) + MatchCollection matches = entry.Regex.Matches(line.Text); + foreach (Match match in matches) { - MatchCollection matches = entry.Regex.Matches(line.Text); - foreach (Match match in matches) - { - HilightMatchEntry me = new(); - me.HilightEntry = entry; - me.StartPos = match.Index; - me.Length = match.Length; - resultList.Add(me); - } + HilightMatchEntry me = new(); + me.HilightEntry = entry; + me.StartPos = match.Index; + me.Length = match.Length; + resultList.Add(me); } - else + } + else + { + if (CheckHighlightEntryMatch(entry, line)) { - if (CheckHighlightEntryMatch(entry, line)) - { - HilightMatchEntry me = new(); - me.HilightEntry = entry; - me.StartPos = 0; - me.Length = line.Text.Length; - resultList.Add(me); - } + HilightMatchEntry me = new(); + me.HilightEntry = entry; + me.StartPos = 0; + me.Length = line.Text.Length; + resultList.Add(me); } } } + } - private void GetHilightActions (IList matchingList, out bool noLed, out bool stopTail, - out bool setBookmark, out string bookmarkComment) - { - noLed = stopTail = setBookmark = false; - bookmarkComment = string.Empty; + private void GetHilightActions (IList matchingList, out bool noLed, out bool stopTail, + out bool setBookmark, out string bookmarkComment) + { + noLed = stopTail = setBookmark = false; + bookmarkComment = string.Empty; - foreach (HighlightEntry entry in matchingList) + foreach (HighlightEntry entry in matchingList) + { + if (entry.IsLedSwitch) { - if (entry.IsLedSwitch) - { - noLed = true; - } - - if (entry.IsSetBookmark) - { - setBookmark = true; - if (!string.IsNullOrEmpty(entry.BookmarkComment)) - { - bookmarkComment += entry.BookmarkComment + "\r\n"; - } - } + noLed = true; + } - if (entry.IsStopTail) + if (entry.IsSetBookmark) + { + setBookmark = true; + if (!string.IsNullOrEmpty(entry.BookmarkComment)) { - stopTail = true; + bookmarkComment += entry.BookmarkComment + "\r\n"; } } - bookmarkComment = bookmarkComment.TrimEnd(['\r', '\n']); + if (entry.IsStopTail) + { + stopTail = true; + } } - private void StopTimespreadThread () - { - _timeSpreadCalc.Stop(); - } + bookmarkComment = bookmarkComment.TrimEnd(['\r', '\n']); + } - private void StopTimestampSyncThread () - { - _shouldTimestampDisplaySyncingCancel = true; - //_timeShiftSyncWakeupEvent.Set(); - //_timeShiftSyncThread.Abort(); - //_timeShiftSyncThread.Join(); - cts.Cancel(); - } + private void StopTimespreadThread () + { + _timeSpreadCalc.Stop(); + } + + private void StopTimestampSyncThread () + { + _shouldTimestampDisplaySyncingCancel = true; + //_timeShiftSyncWakeupEvent.Set(); + //_timeShiftSyncThread.Abort(); + //_timeShiftSyncThread.Join(); + cts.Cancel(); + } - private void SyncTimestampDisplay () + private void SyncTimestampDisplay () + { + if (CurrentColumnizer.IsTimeshiftImplemented()) { - if (CurrentColumnizer.IsTimeshiftImplemented()) + if (dataGridView.CurrentRow != null) { - if (dataGridView.CurrentRow != null) - { - SyncTimestampDisplay(dataGridView.CurrentRow.Index); - } + SyncTimestampDisplay(dataGridView.CurrentRow.Index); } } + } - private void SyncTimestampDisplay (int lineNum) - { - _timeShiftSyncLine = lineNum; - _timeShiftSyncTimerEvent.Set(); - _timeShiftSyncWakeupEvent.Set(); - } + private void SyncTimestampDisplay (int lineNum) + { + _timeShiftSyncLine = lineNum; + _timeShiftSyncTimerEvent.Set(); + _timeShiftSyncWakeupEvent.Set(); + } + + private void SyncTimestampDisplayWorker () + { + const int WAIT_TIME = 500; + Thread.CurrentThread.Name = "SyncTimestampDisplayWorker"; + _shouldTimestampDisplaySyncingCancel = false; + _isTimestampDisplaySyncing = true; - private void SyncTimestampDisplayWorker () + while (!_shouldTimestampDisplaySyncingCancel) { - const int WAIT_TIME = 500; - Thread.CurrentThread.Name = "SyncTimestampDisplayWorker"; - _shouldTimestampDisplaySyncingCancel = false; - _isTimestampDisplaySyncing = true; + _timeShiftSyncWakeupEvent.WaitOne(); + if (_shouldTimestampDisplaySyncingCancel) + { + return; + } + + _timeShiftSyncWakeupEvent.Reset(); while (!_shouldTimestampDisplaySyncingCancel) { - _timeShiftSyncWakeupEvent.WaitOne(); - if (_shouldTimestampDisplaySyncingCancel) + var signaled = _timeShiftSyncTimerEvent.WaitOne(WAIT_TIME, true); + _timeShiftSyncTimerEvent.Reset(); + if (!signaled) { - return; + break; } + } - _timeShiftSyncWakeupEvent.Reset(); - - while (!_shouldTimestampDisplaySyncingCancel) + // timeout with no new Trigger -> update display + var lineNum = _timeShiftSyncLine; + if (lineNum >= 0 && lineNum < dataGridView.RowCount) + { + var refLine = lineNum; + DateTime timeStamp = GetTimestampForLine(ref refLine, true); + if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel) { - var signaled = _timeShiftSyncTimerEvent.WaitOne(WAIT_TIME, true); - _timeShiftSyncTimerEvent.Reset(); - if (!signaled) + _guiStateArgs.Timestamp = timeStamp; + SendGuiStateUpdate(); + if (_shouldCallTimeSync) { - break; + refLine = lineNum; + DateTime exactTimeStamp = GetTimestampForLine(ref refLine, false); + SyncOtherWindows(exactTimeStamp); + _shouldCallTimeSync = false; } } + } - // timeout with no new Trigger -> update display - var lineNum = _timeShiftSyncLine; - if (lineNum >= 0 && lineNum < dataGridView.RowCount) + // show time difference between 2 selected lines + if (dataGridView.SelectedRows.Count == 2) + { + var row1 = dataGridView.SelectedRows[0].Index; + var row2 = dataGridView.SelectedRows[1].Index; + if (row1 > row2) { - var refLine = lineNum; - DateTime timeStamp = GetTimestampForLine(ref refLine, true); - if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel) - { - _guiStateArgs.Timestamp = timeStamp; - SendGuiStateUpdate(); - if (_shouldCallTimeSync) - { - refLine = lineNum; - DateTime exactTimeStamp = GetTimestampForLine(ref refLine, false); - SyncOtherWindows(exactTimeStamp); - _shouldCallTimeSync = false; - } - } + (row2, row1) = (row1, row2); } - // show time difference between 2 selected lines - if (dataGridView.SelectedRows.Count == 2) + var refLine = row1; + DateTime timeStamp1 = GetTimestampForLine(ref refLine, false); + refLine = row2; + DateTime timeStamp2 = GetTimestampForLine(ref refLine, false); + //TimeSpan span = TimeSpan.FromTicks(timeStamp2.Ticks - timeStamp1.Ticks); + DateTime diff; + if (timeStamp1.Ticks > timeStamp2.Ticks) { - var row1 = dataGridView.SelectedRows[0].Index; - var row2 = dataGridView.SelectedRows[1].Index; - if (row1 > row2) - { - (row2, row1) = (row1, row2); - } - - var refLine = row1; - DateTime timeStamp1 = GetTimestampForLine(ref refLine, false); - refLine = row2; - DateTime timeStamp2 = GetTimestampForLine(ref refLine, false); - //TimeSpan span = TimeSpan.FromTicks(timeStamp2.Ticks - timeStamp1.Ticks); - DateTime diff; - if (timeStamp1.Ticks > timeStamp2.Ticks) - { - diff = new DateTime(timeStamp1.Ticks - timeStamp2.Ticks); - } - else - { - diff = new DateTime(timeStamp2.Ticks - timeStamp1.Ticks); - } - - StatusLineText("Time diff is " + diff.ToString("HH:mm:ss.fff")); + diff = new DateTime(timeStamp1.Ticks - timeStamp2.Ticks); } else { - if (!IsMultiFile && dataGridView.SelectedRows.Count == 1) - { - StatusLineText(string.Empty); - } + diff = new DateTime(timeStamp2.Ticks - timeStamp1.Ticks); + } + + StatusLineText("Time diff is " + diff.ToString("HH:mm:ss.fff")); + } + else + { + if (!IsMultiFile && dataGridView.SelectedRows.Count == 1) + { + StatusLineText(string.Empty); } } } + } - private void SyncFilterGridPos () + private void SyncFilterGridPos () + { + try { - try + if (_filterResultList.Count > 0) { - if (_filterResultList.Count > 0) + var index = _filterResultList.BinarySearch(dataGridView.CurrentRow.Index); + if (index < 0) { - var index = _filterResultList.BinarySearch(dataGridView.CurrentRow.Index); - if (index < 0) + index = ~index; + if (index > 0) { - index = ~index; - if (index > 0) - { - --index; - } + --index; } + } - if (filterGridView.Rows.GetRowCount(DataGridViewElementStates.None) > 0) // exception no rows - { - filterGridView.CurrentCell = filterGridView.Rows[index].Cells[0]; - } - else - { - filterGridView.CurrentCell = null; - } + if (filterGridView.Rows.GetRowCount(DataGridViewElementStates.None) > 0) // exception no rows + { + filterGridView.CurrentCell = filterGridView.Rows[index].Cells[0]; + } + else + { + filterGridView.CurrentCell = null; } - } - catch (Exception e) - { - _logger.Error(e, "SyncFilterGridPos(): "); } } - - private void StatusLineFileSize (long size) + catch (Exception e) { - _statusEventArgs.FileSize = size; - SendStatusLineUpdate(); + _logger.Error(e, "SyncFilterGridPos(): "); } + } + + private void StatusLineFileSize (long size) + { + _statusEventArgs.FileSize = size; + SendStatusLineUpdate(); + } - private int Search (SearchParams searchParams) + private int Search (SearchParams searchParams) + { + if (searchParams.SearchText == null) { - if (searchParams.SearchText == null) - { - return -1; - } + return -1; + } - var lineNum = searchParams.IsFromTop && !searchParams.IsFindNext - ? 0 - : searchParams.CurrentLine; + var lineNum = searchParams.IsFromTop && !searchParams.IsFindNext + ? 0 + : searchParams.CurrentLine; - var lowerSearchText = searchParams.SearchText.ToLower(); - var count = 0; - var hasWrapped = false; + var lowerSearchText = searchParams.SearchText.ToLower(); + var count = 0; + var hasWrapped = false; - while (true) + while (true) + { + if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) { - if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) + if (lineNum >= _logFileReader.LineCount) { - if (lineNum >= _logFileReader.LineCount) + if (hasWrapped) { - if (hasWrapped) - { - StatusLineError("Not found: " + searchParams.SearchText); - return -1; - } - - lineNum = 0; - count = 0; - hasWrapped = true; - StatusLineError("Started from beginning of file"); + StatusLineError("Not found: " + searchParams.SearchText); + return -1; } + + lineNum = 0; + count = 0; + hasWrapped = true; + StatusLineError("Started from beginning of file"); } - else + } + else + { + if (lineNum < 0) { - if (lineNum < 0) + if (hasWrapped) { - if (hasWrapped) - { - StatusLineError("Not found: " + searchParams.SearchText); - return -1; - } - - count = 0; - lineNum = _logFileReader.LineCount - 1; - hasWrapped = true; - StatusLineError("Started from end of file"); + StatusLineError("Not found: " + searchParams.SearchText); + return -1; } + + count = 0; + lineNum = _logFileReader.LineCount - 1; + hasWrapped = true; + StatusLineError("Started from end of file"); } + } - ILogLine line = _logFileReader.GetLogLine(lineNum); - if (line == null) + ILogLine line = _logFileReader.GetLogLine(lineNum); + if (line == null) + { + return -1; + } + + if (searchParams.IsRegex) + { + Regex rex = new(searchParams.SearchText, searchParams.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); + if (rex.IsMatch(line.FullLine)) { - return -1; + return lineNum; } - - if (searchParams.IsRegex) + } + else + { + if (!searchParams.IsCaseSensitive) { - Regex rex = new(searchParams.SearchText, searchParams.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); - if (rex.IsMatch(line.FullLine)) + if (line.FullLine.Contains(lowerSearchText, StringComparison.CurrentCultureIgnoreCase)) { return lineNum; } } else { - if (!searchParams.IsCaseSensitive) - { - if (line.FullLine.Contains(lowerSearchText, StringComparison.CurrentCultureIgnoreCase)) - { - return lineNum; - } - } - else + if (line.FullLine.Contains(searchParams.SearchText)) { - if (line.FullLine.Contains(searchParams.SearchText)) - { - return lineNum; - } + return lineNum; } } + } - if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) - { - lineNum++; - } - else - { - lineNum--; - } + if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) + { + lineNum++; + } + else + { + lineNum--; + } - if (_shouldCancel) - { - return -1; - } + if (_shouldCancel) + { + return -1; + } - if (++count % PROGRESS_BAR_MODULO == 0) + if (++count % PROGRESS_BAR_MODULO == 0) + { + try { - try - { - if (!Disposing) - { - Invoke(UpdateProgressBar, [count]); - } - } - catch (ObjectDisposedException ex) // can occur when closing the app while searching + if (!Disposing) { - _logger.Warn(ex); + Invoke(UpdateProgressBar, [count]); } } + catch (ObjectDisposedException ex) // can occur when closing the app while searching + { + _logger.Warn(ex); + } } } + } - private void ResetProgressBar () - { - _progressEventArgs.Value = _progressEventArgs.MaxValue; - _progressEventArgs.Visible = false; - SendProgressBarUpdate(); - } + private void ResetProgressBar () + { + _progressEventArgs.Value = _progressEventArgs.MaxValue; + _progressEventArgs.Visible = false; + SendProgressBarUpdate(); + } - private void SelectLine (int line, bool triggerSyncCall, bool shouldScroll) + private void SelectLine (int line, bool triggerSyncCall, bool shouldScroll) + { + try { - try - { - _shouldCallTimeSync = triggerSyncCall; - var wasCancelled = _shouldCancel; - _shouldCancel = false; - _isSearching = false; - StatusLineText(""); - _guiStateArgs.MenuEnabled = true; - - if (wasCancelled) - { - return; - } - - if (line == -1) - { - // Hmm... is that experimental code from early days? - MessageBox.Show(this, "Not found:", "Search result"); - return; - } - - // Prevent ArgumentOutOfRangeException - if (line >= dataGridView.Rows.GetRowCount(DataGridViewElementStates.None)) - { - line = dataGridView.Rows.GetRowCount(DataGridViewElementStates.None) - 1; - } + _shouldCallTimeSync = triggerSyncCall; + var wasCancelled = _shouldCancel; + _shouldCancel = false; + _isSearching = false; + StatusLineText(""); + _guiStateArgs.MenuEnabled = true; - dataGridView.Rows[line].Selected = true; + if (wasCancelled) + { + return; + } - if (shouldScroll) - { - dataGridView.CurrentCell = dataGridView.Rows[line].Cells[0]; - dataGridView.Focus(); - } + if (line == -1) + { + // Hmm... is that experimental code from early days? + MessageBox.Show(this, "Not found:", "Search result"); + return; } - catch (ArgumentOutOfRangeException e) + + // Prevent ArgumentOutOfRangeException + if (line >= dataGridView.Rows.GetRowCount(DataGridViewElementStates.None)) { - _logger.Error(e, "Error while selecting line: "); + line = dataGridView.Rows.GetRowCount(DataGridViewElementStates.None) - 1; } - catch (IndexOutOfRangeException e) + + dataGridView.Rows[line].Selected = true; + + if (shouldScroll) { - // Occures sometimes (but cannot reproduce) - _logger.Error(e, "Error while selecting line: "); + dataGridView.CurrentCell = dataGridView.Rows[line].Cells[0]; + dataGridView.Focus(); } } + catch (ArgumentOutOfRangeException e) + { + _logger.Error(e, "Error while selecting line: "); + } + catch (IndexOutOfRangeException e) + { + // Occures sometimes (but cannot reproduce) + _logger.Error(e, "Error while selecting line: "); + } + } - private void StartEditMode () + private void StartEditMode () + { + if (!dataGridView.CurrentCell.ReadOnly) { - if (!dataGridView.CurrentCell.ReadOnly) + dataGridView.BeginEdit(false); + if (dataGridView.EditingControl != null) { - dataGridView.BeginEdit(false); - if (dataGridView.EditingControl != null) + if (dataGridView.EditingControl is LogCellEditingControl editControl) { - if (dataGridView.EditingControl is LogCellEditingControl editControl) - { - editControl.KeyDown += OnEditControlKeyDown; - editControl.KeyPress += OnEditControlKeyPress; - editControl.KeyUp += OnEditControlKeyUp; - editControl.Click += OnEditControlClick; - dataGridView.CellEndEdit += OnDataGridViewCellEndEdit; - editControl.SelectionStart = 0; - } - else - { - _logger.Warn("Edit control in logWindow was null"); - } + editControl.KeyDown += OnEditControlKeyDown; + editControl.KeyPress += OnEditControlKeyPress; + editControl.KeyUp += OnEditControlKeyUp; + editControl.Click += OnEditControlClick; + dataGridView.CellEndEdit += OnDataGridViewCellEndEdit; + editControl.SelectionStart = 0; + } + else + { + _logger.Warn("Edit control in logWindow was null"); } } } + } - private void UpdateEditColumnDisplay (DataGridViewTextBoxEditingControl editControl) + private void UpdateEditColumnDisplay (DataGridViewTextBoxEditingControl editControl) + { + // prevents key events after edit mode has ended + if (dataGridView.EditingControl != null) { - // prevents key events after edit mode has ended - if (dataGridView.EditingControl != null) - { - var pos = editControl.SelectionStart + editControl.SelectionLength; - StatusLineText(" " + pos); - _logger.Debug("SelStart: {0}, SelLen: {1}", editControl.SelectionStart, editControl.SelectionLength); - } + var pos = editControl.SelectionStart + editControl.SelectionLength; + StatusLineText(" " + pos); + _logger.Debug("SelStart: {0}, SelLen: {1}", editControl.SelectionStart, editControl.SelectionLength); } + } - private void SelectPrevHighlightLine () + private void SelectPrevHighlightLine () + { + var lineNum = dataGridView.CurrentCellAddress.Y; + while (lineNum > 0) { - var lineNum = dataGridView.CurrentCellAddress.Y; - while (lineNum > 0) + lineNum--; + ILogLine line = _logFileReader.GetLogLine(lineNum); + if (line != null) { - lineNum--; - ILogLine line = _logFileReader.GetLogLine(lineNum); - if (line != null) + HighlightEntry entry = FindHilightEntry(line); + if (entry != null) { - HighlightEntry entry = FindHilightEntry(line); - if (entry != null) - { - SelectLine(lineNum, false, true); - break; - } + SelectLine(lineNum, false, true); + break; } } } + } - private void SelectNextHighlightLine () + private void SelectNextHighlightLine () + { + var lineNum = dataGridView.CurrentCellAddress.Y; + while (lineNum < _logFileReader.LineCount) { - var lineNum = dataGridView.CurrentCellAddress.Y; - while (lineNum < _logFileReader.LineCount) + lineNum++; + ILogLine line = _logFileReader.GetLogLine(lineNum); + if (line != null) { - lineNum++; - ILogLine line = _logFileReader.GetLogLine(lineNum); - if (line != null) + HighlightEntry entry = FindHilightEntry(line); + if (entry != null) { - HighlightEntry entry = FindHilightEntry(line); - if (entry != null) - { - SelectLine(lineNum, false, true); - break; - } + SelectLine(lineNum, false, true); + break; } } } + } - private int FindNextBookmarkIndex (int lineNum) + private int FindNextBookmarkIndex (int lineNum) + { + if (lineNum >= dataGridView.RowCount) { - if (lineNum >= dataGridView.RowCount) - { - lineNum = 0; - } - else - { - lineNum++; - } - - return _bookmarkProvider.FindNextBookmarkIndex(lineNum); + lineNum = 0; } - - private int FindPrevBookmarkIndex (int lineNum) + else { - if (lineNum <= 0) - { - lineNum = dataGridView.RowCount - 1; - } - else - { - lineNum--; - } - - return _bookmarkProvider.FindPrevBookmarkIndex(lineNum); + lineNum++; } - /** - * Shift bookmarks after a logfile rollover - */ + return _bookmarkProvider.FindNextBookmarkIndex(lineNum); + } - private void ShiftBookmarks (int offset) + private int FindPrevBookmarkIndex (int lineNum) + { + if (lineNum <= 0) + { + lineNum = dataGridView.RowCount - 1; + } + else { - _bookmarkProvider.ShiftBookmarks(offset); - OnBookmarkRemoved(); + lineNum--; } - private void ShiftRowHeightList (int offset) + return _bookmarkProvider.FindPrevBookmarkIndex(lineNum); + } + + /** + * Shift bookmarks after a logfile rollover + */ + + private void ShiftBookmarks (int offset) + { + _bookmarkProvider.ShiftBookmarks(offset); + OnBookmarkRemoved(); + } + + private void ShiftRowHeightList (int offset) + { + SortedList newList = []; + foreach (RowHeightEntry entry in _rowHeightList.Values) { - SortedList newList = []; - foreach (RowHeightEntry entry in _rowHeightList.Values) + var line = entry.LineNum - offset; + if (line >= 0) { - var line = entry.LineNum - offset; - if (line >= 0) - { - entry.LineNum = line; - newList.Add(line, entry); - } + entry.LineNum = line; + newList.Add(line, entry); } - - _rowHeightList = newList; } - private void ShiftFilterPipes (int offset) + _rowHeightList = newList; + } + + private void ShiftFilterPipes (int offset) + { + lock (_filterPipeList) { - lock (_filterPipeList) + foreach (FilterPipe pipe in _filterPipeList) { - foreach (FilterPipe pipe in _filterPipeList) - { - pipe.ShiftLineNums(offset); - } + pipe.ShiftLineNums(offset); } } + } - private void LoadFilterPipes () + private void LoadFilterPipes () + { + lock (_filterPipeList) { - lock (_filterPipeList) + foreach (FilterPipe pipe in _filterPipeList) { - foreach (FilterPipe pipe in _filterPipeList) - { - pipe.RecreateTempFile(); - } + pipe.RecreateTempFile(); } + } - if (_filterPipeList.Count > 0) + if (_filterPipeList.Count > 0) + { + for (var i = 0; i < dataGridView.RowCount; ++i) { - for (var i = 0; i < dataGridView.RowCount; ++i) - { - ProcessFilterPipes(i); - } + ProcessFilterPipes(i); } } + } - private void DisconnectFilterPipes () + private void DisconnectFilterPipes () + { + lock (_filterPipeList) { - lock (_filterPipeList) + foreach (FilterPipe pipe in _filterPipeList) { - foreach (FilterPipe pipe in _filterPipeList) - { - pipe.ClearLineList(); - } + pipe.ClearLineList(); } } + } - private void ApplyFilterParams () - { - filterComboBox.Text = _filterParams.SearchText; - filterCaseSensitiveCheckBox.Checked = _filterParams.IsCaseSensitive; - filterRegexCheckBox.Checked = _filterParams.IsRegex; - filterTailCheckBox.Checked = _filterParams.IsFilterTail; - invertFilterCheckBox.Checked = _filterParams.IsInvert; - filterKnobBackSpread.Value = _filterParams.SpreadBefore; - filterKnobForeSpread.Value = _filterParams.SpreadBehind; - rangeCheckBox.Checked = _filterParams.IsRangeSearch; - columnRestrictCheckBox.Checked = _filterParams.ColumnRestrict; - fuzzyKnobControl.Value = _filterParams.FuzzyValue; - filterRangeComboBox.Text = _filterParams.RangeSearchText; - } + private void ApplyFilterParams () + { + filterComboBox.Text = _filterParams.SearchText; + filterCaseSensitiveCheckBox.Checked = _filterParams.IsCaseSensitive; + filterRegexCheckBox.Checked = _filterParams.IsRegex; + filterTailCheckBox.Checked = _filterParams.IsFilterTail; + invertFilterCheckBox.Checked = _filterParams.IsInvert; + filterKnobBackSpread.Value = _filterParams.SpreadBefore; + filterKnobForeSpread.Value = _filterParams.SpreadBehind; + rangeCheckBox.Checked = _filterParams.IsRangeSearch; + columnRestrictCheckBox.Checked = _filterParams.ColumnRestrict; + fuzzyKnobControl.Value = _filterParams.FuzzyValue; + filterRangeComboBox.Text = _filterParams.RangeSearchText; + } - private void ResetFilterControls () + private void ResetFilterControls () + { + filterComboBox.Text = ""; + filterCaseSensitiveCheckBox.Checked = false; + filterRegexCheckBox.Checked = false; + //this.filterTailCheckBox.Checked = this.Preferences.filterTail; + invertFilterCheckBox.Checked = false; + filterKnobBackSpread.Value = 0; + filterKnobForeSpread.Value = 0; + rangeCheckBox.Checked = false; + columnRestrictCheckBox.Checked = false; + fuzzyKnobControl.Value = 0; + filterRangeComboBox.Text = ""; + } + + private void FilterSearch () + { + if (filterComboBox.Text.Length == 0) { - filterComboBox.Text = ""; - filterCaseSensitiveCheckBox.Checked = false; - filterRegexCheckBox.Checked = false; - //this.filterTailCheckBox.Checked = this.Preferences.filterTail; - invertFilterCheckBox.Checked = false; - filterKnobBackSpread.Value = 0; - filterKnobForeSpread.Value = 0; - rangeCheckBox.Checked = false; - columnRestrictCheckBox.Checked = false; - fuzzyKnobControl.Value = 0; - filterRangeComboBox.Text = ""; + _filterParams.SearchText = ""; + _filterParams.LowerSearchText = ""; + _filterParams.IsRangeSearch = false; + ClearFilterList(); + filterSearchButton.Image = null; + ResetFilterControls(); + saveFilterButton.Enabled = false; + return; } - private void FilterSearch () - { - if (filterComboBox.Text.Length == 0) - { - _filterParams.SearchText = ""; - _filterParams.LowerSearchText = ""; - _filterParams.IsRangeSearch = false; - ClearFilterList(); - filterSearchButton.Image = null; - ResetFilterControls(); - saveFilterButton.Enabled = false; - return; - } + FilterSearch(filterComboBox.Text); + } - FilterSearch(filterComboBox.Text); + private async void FilterSearch (string text) + { + FireCancelHandlers(); // make sure that there's no other filter running (maybe from filter restore) + + _filterParams.SearchText = text; + _filterParams.LowerSearchText = text.ToLower(); + ConfigManager.Settings.filterHistoryList.Remove(text); + ConfigManager.Settings.filterHistoryList.Insert(0, text); + var maxHistory = ConfigManager.Settings.Preferences.maximumFilterEntries; + + if (ConfigManager.Settings.filterHistoryList.Count > maxHistory) + { + ConfigManager.Settings.filterHistoryList.RemoveAt(filterComboBox.Items.Count - 1); } - private async void FilterSearch (string text) + filterComboBox.Items.Clear(); + foreach (var item in ConfigManager.Settings.filterHistoryList) { - FireCancelHandlers(); // make sure that there's no other filter running (maybe from filter restore) + filterComboBox.Items.Add(item); + } - _filterParams.SearchText = text; - _filterParams.LowerSearchText = text.ToLower(); - ConfigManager.Settings.filterHistoryList.Remove(text); - ConfigManager.Settings.filterHistoryList.Insert(0, text); - var maxHistory = ConfigManager.Settings.Preferences.maximumFilterEntries; + filterComboBox.Text = text; - if (ConfigManager.Settings.filterHistoryList.Count > maxHistory) + _filterParams.IsRangeSearch = rangeCheckBox.Checked; + _filterParams.RangeSearchText = filterRangeComboBox.Text; + if (_filterParams.IsRangeSearch) + { + ConfigManager.Settings.filterRangeHistoryList.Remove(filterRangeComboBox.Text); + ConfigManager.Settings.filterRangeHistoryList.Insert(0, filterRangeComboBox.Text); + if (ConfigManager.Settings.filterRangeHistoryList.Count > maxHistory) { - ConfigManager.Settings.filterHistoryList.RemoveAt(filterComboBox.Items.Count - 1); + ConfigManager.Settings.filterRangeHistoryList.RemoveAt(filterRangeComboBox.Items.Count - 1); } - filterComboBox.Items.Clear(); - foreach (var item in ConfigManager.Settings.filterHistoryList) + filterRangeComboBox.Items.Clear(); + foreach (var item in ConfigManager.Settings.filterRangeHistoryList) { - filterComboBox.Items.Add(item); + filterRangeComboBox.Items.Add(item); } + } - filterComboBox.Text = text; + ConfigManager.Save(SettingsFlags.FilterHistory); - _filterParams.IsRangeSearch = rangeCheckBox.Checked; - _filterParams.RangeSearchText = filterRangeComboBox.Text; - if (_filterParams.IsRangeSearch) + _filterParams.IsCaseSensitive = filterCaseSensitiveCheckBox.Checked; + _filterParams.IsRegex = filterRegexCheckBox.Checked; + _filterParams.IsFilterTail = filterTailCheckBox.Checked; + _filterParams.IsInvert = invertFilterCheckBox.Checked; + if (_filterParams.IsRegex) + { + try { - ConfigManager.Settings.filterRangeHistoryList.Remove(filterRangeComboBox.Text); - ConfigManager.Settings.filterRangeHistoryList.Insert(0, filterRangeComboBox.Text); - if (ConfigManager.Settings.filterRangeHistoryList.Count > maxHistory) - { - ConfigManager.Settings.filterRangeHistoryList.RemoveAt(filterRangeComboBox.Items.Count - 1); - } - - filterRangeComboBox.Items.Clear(); - foreach (var item in ConfigManager.Settings.filterRangeHistoryList) - { - filterRangeComboBox.Items.Add(item); - } + _filterParams.CreateRegex(); } - - ConfigManager.Save(SettingsFlags.FilterHistory); - - _filterParams.IsCaseSensitive = filterCaseSensitiveCheckBox.Checked; - _filterParams.IsRegex = filterRegexCheckBox.Checked; - _filterParams.IsFilterTail = filterTailCheckBox.Checked; - _filterParams.IsInvert = invertFilterCheckBox.Checked; - if (_filterParams.IsRegex) + catch (ArgumentException) { - try - { - _filterParams.CreateRegex(); - } - catch (ArgumentException) - { - StatusLineError("Invalid regular expression"); - return; - } + StatusLineError("Invalid regular expression"); + return; } + } - _filterParams.FuzzyValue = fuzzyKnobControl.Value; - _filterParams.SpreadBefore = filterKnobBackSpread.Value; - _filterParams.SpreadBehind = filterKnobForeSpread.Value; - _filterParams.ColumnRestrict = columnRestrictCheckBox.Checked; + _filterParams.FuzzyValue = fuzzyKnobControl.Value; + _filterParams.SpreadBefore = filterKnobBackSpread.Value; + _filterParams.SpreadBehind = filterKnobForeSpread.Value; + _filterParams.ColumnRestrict = columnRestrictCheckBox.Checked; - //ConfigManager.SaveFilterParams(this.filterParams); - ConfigManager.Settings.filterParams = _filterParams; // wozu eigentlich? sinnlos seit MDI? + //ConfigManager.SaveFilterParams(this.filterParams); + ConfigManager.Settings.filterParams = _filterParams; // wozu eigentlich? sinnlos seit MDI? - _shouldCancel = false; - _isSearching = true; - StatusLineText("Filtering... Press ESC to cancel"); - filterSearchButton.Enabled = false; - ClearFilterList(); + _shouldCancel = false; + _isSearching = true; + StatusLineText("Filtering... Press ESC to cancel"); + filterSearchButton.Enabled = false; + ClearFilterList(); - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = dataGridView.RowCount; - _progressEventArgs.Value = 0; - _progressEventArgs.Visible = true; - SendProgressBarUpdate(); + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = dataGridView.RowCount; + _progressEventArgs.Value = 0; + _progressEventArgs.Visible = true; + SendProgressBarUpdate(); - Settings settings = ConfigManager.Settings; + Settings settings = ConfigManager.Settings; - //FilterFx fx = settings.preferences.multiThreadFilter ? MultiThreadedFilter : new FilterFx(Filter); - FilterFxAction = settings.Preferences.multiThreadFilter ? MultiThreadedFilter : Filter; + //FilterFx fx = settings.preferences.multiThreadFilter ? MultiThreadedFilter : new FilterFx(Filter); + FilterFxAction = settings.Preferences.multiThreadFilter ? MultiThreadedFilter : Filter; - //Task.Run(() => fx.Invoke(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList)); - var filterFxActionTask = Task.Run(() => Filter(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList)); + //Task.Run(() => fx.Invoke(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList)); + var filterFxActionTask = Task.Run(() => Filter(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList)); - await filterFxActionTask; - FilterComplete(); + await filterFxActionTask; + FilterComplete(); - //fx.BeginInvoke(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList, FilterComplete, null); - CheckForFilterDirty(); - } + //fx.BeginInvoke(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList, FilterComplete, null); + CheckForFilterDirty(); + } - private void MultiThreadedFilter (FilterParams filterParams, List filterResultLines, - List lastFilterLinesList, List filterHitList) - { - ColumnizerCallback callback = new(this); - FilterStarter fs = new(callback, Environment.ProcessorCount + 2); - fs.FilterHitList = _filterHitList; - fs.FilterResultLines = _filterResultList; - fs.LastFilterLinesList = _lastFilterLinesList; - var cancelHandler = new FilterCancelHandler(fs); - OnRegisterCancelHandler(cancelHandler); - long startTime = Environment.TickCount; + private void MultiThreadedFilter (FilterParams filterParams, List filterResultLines, + List lastFilterLinesList, List filterHitList) + { + ColumnizerCallback callback = new(this); + FilterStarter fs = new(callback, Environment.ProcessorCount + 2); + fs.FilterHitList = _filterHitList; + fs.FilterResultLines = _filterResultList; + fs.LastFilterLinesList = _lastFilterLinesList; + var cancelHandler = new FilterCancelHandler(fs); + OnRegisterCancelHandler(cancelHandler); + long startTime = Environment.TickCount; - fs.DoFilter(filterParams, 0, _logFileReader.LineCount, FilterProgressCallback); + fs.DoFilter(filterParams, 0, _logFileReader.LineCount, FilterProgressCallback); - long endTime = Environment.TickCount; + long endTime = Environment.TickCount; - _logger.Debug("Multi threaded filter duration: {0} ms.", endTime - startTime); + _logger.Debug("Multi threaded filter duration: {0} ms.", endTime - startTime); - OnDeRegisterCancelHandler(cancelHandler); - StatusLineText("Filter duration: " + (endTime - startTime) + " ms."); - } + OnDeRegisterCancelHandler(cancelHandler); + StatusLineText("Filter duration: " + (endTime - startTime) + " ms."); + } - private void FilterProgressCallback (int lineCount) - { - UpdateProgressBar(lineCount); - } + private void FilterProgressCallback (int lineCount) + { + UpdateProgressBar(lineCount); + } - private void Filter (FilterParams filterParams, List filterResultLines, List lastFilterLinesList, - List filterHitList) + private void Filter (FilterParams filterParams, List filterResultLines, List lastFilterLinesList, + List filterHitList) + { + long startTime = Environment.TickCount; + try { - long startTime = Environment.TickCount; - try + filterParams.Reset(); + var lineNum = 0; + //AddFilterLineFx addFx = new AddFilterLineFx(AddFilterLine); + ColumnizerCallback callback = new(this); + while (true) { - filterParams.Reset(); - var lineNum = 0; - //AddFilterLineFx addFx = new AddFilterLineFx(AddFilterLine); - ColumnizerCallback callback = new(this); - while (true) + ILogLine line = _logFileReader.GetLogLine(lineNum); + if (line == null) { - ILogLine line = _logFileReader.GetLogLine(lineNum); - if (line == null) - { - break; - } + break; + } - callback.LineNum = lineNum; - if (Util.TestFilterCondition(filterParams, line, callback)) - { - AddFilterLine(lineNum, false, filterParams, filterResultLines, lastFilterLinesList, - filterHitList); - } + callback.LineNum = lineNum; + if (Util.TestFilterCondition(filterParams, line, callback)) + { + AddFilterLine(lineNum, false, filterParams, filterResultLines, lastFilterLinesList, + filterHitList); + } - lineNum++; - if (lineNum % PROGRESS_BAR_MODULO == 0) - { - UpdateProgressBar(lineNum); - } + lineNum++; + if (lineNum % PROGRESS_BAR_MODULO == 0) + { + UpdateProgressBar(lineNum); + } - if (_shouldCancel) - { - break; - } + if (_shouldCancel) + { + break; } } - catch (Exception ex) - { - _logger.Error(ex, "Exception while filtering. Please report to developer: "); - MessageBox.Show(null, - "Exception while filtering. Please report to developer: \n\n" + ex + "\n\n" + ex.StackTrace, - "LogExpert"); - } - - long endTime = Environment.TickCount; - - _logger.Info("Single threaded filter duration: {0} ms.", endTime - startTime); - - StatusLineText("Filter duration: " + (endTime - startTime) + " ms."); } - - /// - /// Returns a list with 'additional filter results'. This is the given line number - /// and (if back spread and/or fore spread is enabled) some additional lines. - /// This function doesn't check the filter condition! - /// - /// - /// - /// - /// - private IList GetAdditionalFilterResults (FilterParams filterParams, int lineNum, IList checkList) + catch (Exception ex) { - IList resultList = []; - //string textLine = this.logFileReader.GetLogLine(lineNum); - //ColumnizerCallback callback = new ColumnizerCallback(this); - //callback.LineNum = lineNum; + _logger.Error(ex, "Exception while filtering. Please report to developer: "); + MessageBox.Show(null, + "Exception while filtering. Please report to developer: \n\n" + ex + "\n\n" + ex.StackTrace, + "LogExpert"); + } - if (filterParams.SpreadBefore == 0 && filterParams.SpreadBehind == 0) - { - resultList.Add(lineNum); - return resultList; - } + long endTime = Environment.TickCount; - // back spread - for (var i = filterParams.SpreadBefore; i > 0; --i) - { - if (lineNum - i > 0) - { - if (!resultList.Contains(lineNum - i) && !checkList.Contains(lineNum - i)) - { - resultList.Add(lineNum - i); - } - } - } + _logger.Info("Single threaded filter duration: {0} ms.", endTime - startTime); - // direct filter hit - if (!resultList.Contains(lineNum) && !checkList.Contains(lineNum)) - { - resultList.Add(lineNum); - } + StatusLineText("Filter duration: " + (endTime - startTime) + " ms."); + } + + /// + /// Returns a list with 'additional filter results'. This is the given line number + /// and (if back spread and/or fore spread is enabled) some additional lines. + /// This function doesn't check the filter condition! + /// + /// + /// + /// + /// + private IList GetAdditionalFilterResults (FilterParams filterParams, int lineNum, IList checkList) + { + IList resultList = []; + //string textLine = this.logFileReader.GetLogLine(lineNum); + //ColumnizerCallback callback = new ColumnizerCallback(this); + //callback.LineNum = lineNum; + + if (filterParams.SpreadBefore == 0 && filterParams.SpreadBehind == 0) + { + resultList.Add(lineNum); + return resultList; + } - // after spread - for (var i = 1; i <= filterParams.SpreadBehind; ++i) + // back spread + for (var i = filterParams.SpreadBefore; i > 0; --i) + { + if (lineNum - i > 0) { - if (lineNum + i < _logFileReader.LineCount) + if (!resultList.Contains(lineNum - i) && !checkList.Contains(lineNum - i)) { - if (!resultList.Contains(lineNum + i) && !checkList.Contains(lineNum + i)) - { - resultList.Add(lineNum + i); - } + resultList.Add(lineNum - i); } } + } - return resultList; + // direct filter hit + if (!resultList.Contains(lineNum) && !checkList.Contains(lineNum)) + { + resultList.Add(lineNum); } - private void AddFilterLine (int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, - List lastFilterLinesList, List filterHitList) + // after spread + for (var i = 1; i <= filterParams.SpreadBehind; ++i) { - int count; - lock (_filterResultList) + if (lineNum + i < _logFileReader.LineCount) { - filterHitList.Add(lineNum); - IList filterResult = GetAdditionalFilterResults(filterParams, lineNum, lastFilterLinesList); - filterResultLines.AddRange(filterResult); - count = filterResultLines.Count; - lastFilterLinesList.AddRange(filterResult); - if (lastFilterLinesList.Count > SPREAD_MAX * 2) + if (!resultList.Contains(lineNum + i) && !checkList.Contains(lineNum + i)) { - lastFilterLinesList.RemoveRange(0, lastFilterLinesList.Count - SPREAD_MAX * 2); + resultList.Add(lineNum + i); } } + } - if (immediate) - { - TriggerFilterLineGuiUpdate(); - } - else if (lineNum % PROGRESS_BAR_MODULO == 0) + return resultList; + } + + private void AddFilterLine (int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, + List lastFilterLinesList, List filterHitList) + { + int count; + lock (_filterResultList) + { + filterHitList.Add(lineNum); + IList filterResult = GetAdditionalFilterResults(filterParams, lineNum, lastFilterLinesList); + filterResultLines.AddRange(filterResult); + count = filterResultLines.Count; + lastFilterLinesList.AddRange(filterResult); + if (lastFilterLinesList.Count > SPREAD_MAX * 2) { - //FunctionWith1IntParam fx = new FunctionWith1IntParam(UpdateFilterCountLabel); - //this.Invoke(fx, new object[] { count}); + lastFilterLinesList.RemoveRange(0, lastFilterLinesList.Count - SPREAD_MAX * 2); } } - private void TriggerFilterLineGuiUpdate () + if (immediate) { - //lock (this.filterUpdateThread) - //{ - // this.filterEventCount++; - // this.filterUpdateEvent.Set(); - //} - Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); + TriggerFilterLineGuiUpdate(); } + else if (lineNum % PROGRESS_BAR_MODULO == 0) + { + //FunctionWith1IntParam fx = new FunctionWith1IntParam(UpdateFilterCountLabel); + //this.Invoke(fx, new object[] { count}); + } + } - //private void FilterUpdateWorker() - //{ - // Thread.CurrentThread.Name = "FilterUpdateWorker"; - // while (true) - // { - // this.filterUpdateEvent.WaitOne(); - // lock (this.filterUpdateThread) - // { - // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); - // this.filterUpdateEvent.Reset(); - // } - - // //_logger.logDebug("FilterUpdateWorker: Waiting for signal"); - // //bool signaled = this.filterUpdateEvent.WaitOne(1000, false); - - // //if (!signaled) - // //{ - // // lock (this.filterUpdateThread) - // // { - // // if (this.filterEventCount > 0) - // // { - // // this.filterEventCount = 0; - // // _logger.logDebug("FilterUpdateWorker: Invoking GUI update because of wait timeout"); - // // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); - // // } - // // } - // //} - // //else - // //{ - // // _logger.logDebug("FilterUpdateWorker: Wakeup signal received."); - // // lock (this.filterUpdateThread) - // // { - // // _logger.logDebug("FilterUpdateWorker: event count: " + this.filterEventCount); - // // if (this.filterEventCount > 100) - // // { - // // this.filterEventCount = 0; - // // _logger.logDebug("FilterUpdateWorker: Invoking GUI update because of event count"); - // // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); - // // } - // // this.filterUpdateEvent.Reset(); - // // } - // //} - // } - //} - - //private void StopFilterUpdateWorkerThread() + private void TriggerFilterLineGuiUpdate () + { + //lock (this.filterUpdateThread) //{ + // this.filterEventCount++; // this.filterUpdateEvent.Set(); - // this.filterUpdateThread.Abort(); - // this.filterUpdateThread.Join(); //} + Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); + } - private void AddFilterLineGuiUpdate () + //private void FilterUpdateWorker() + //{ + // Thread.CurrentThread.Name = "FilterUpdateWorker"; + // while (true) + // { + // this.filterUpdateEvent.WaitOne(); + // lock (this.filterUpdateThread) + // { + // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); + // this.filterUpdateEvent.Reset(); + // } + + // //_logger.logDebug("FilterUpdateWorker: Waiting for signal"); + // //bool signaled = this.filterUpdateEvent.WaitOne(1000, false); + + // //if (!signaled) + // //{ + // // lock (this.filterUpdateThread) + // // { + // // if (this.filterEventCount > 0) + // // { + // // this.filterEventCount = 0; + // // _logger.logDebug("FilterUpdateWorker: Invoking GUI update because of wait timeout"); + // // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); + // // } + // // } + // //} + // //else + // //{ + // // _logger.logDebug("FilterUpdateWorker: Wakeup signal received."); + // // lock (this.filterUpdateThread) + // // { + // // _logger.logDebug("FilterUpdateWorker: event count: " + this.filterEventCount); + // // if (this.filterEventCount > 100) + // // { + // // this.filterEventCount = 0; + // // _logger.logDebug("FilterUpdateWorker: Invoking GUI update because of event count"); + // // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); + // // } + // // this.filterUpdateEvent.Reset(); + // // } + // //} + // } + //} + + //private void StopFilterUpdateWorkerThread() + //{ + // this.filterUpdateEvent.Set(); + // this.filterUpdateThread.Abort(); + // this.filterUpdateThread.Join(); + //} + + private void AddFilterLineGuiUpdate () + { + try { - try + lock (_filterResultList) { - lock (_filterResultList) + lblFilterCount.Text = "" + _filterResultList.Count; + if (filterGridView.RowCount > _filterResultList.Count) { - lblFilterCount.Text = "" + _filterResultList.Count; - if (filterGridView.RowCount > _filterResultList.Count) - { - filterGridView.RowCount = 0; // helps to prevent hang ? - } + filterGridView.RowCount = 0; // helps to prevent hang ? + } - filterGridView.RowCount = _filterResultList.Count; - if (filterGridView.RowCount > 0) - { - filterGridView.FirstDisplayedScrollingRowIndex = filterGridView.RowCount - 1; - } + filterGridView.RowCount = _filterResultList.Count; + if (filterGridView.RowCount > 0) + { + filterGridView.FirstDisplayedScrollingRowIndex = filterGridView.RowCount - 1; + } - if (filterGridView.RowCount == 1) - { - // after a file reload adjusted column sizes anew when the first line arrives - //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - AutoResizeColumns(filterGridView); - } + if (filterGridView.RowCount == 1) + { + // after a file reload adjusted column sizes anew when the first line arrives + //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + AutoResizeColumns(filterGridView); } } - catch (Exception e) - { - _logger.Error(e, "AddFilterLineGuiUpdate(): "); - } } - - private void UpdateProgressBar (int value) + catch (Exception e) { - _progressEventArgs.Value = value; - if (value > _progressEventArgs.MaxValue) - { - // can occur if new lines will be added while filtering - _progressEventArgs.MaxValue = value; - } - - SendProgressBarUpdate(); + _logger.Error(e, "AddFilterLineGuiUpdate(): "); } + } - private void FilterComplete () + private void UpdateProgressBar (int value) + { + _progressEventArgs.Value = value; + if (value > _progressEventArgs.MaxValue) { - if (!IsDisposed && !_waitingForClose && !Disposing) - { - Invoke(new MethodInvoker(ResetStatusAfterFilter)); - } + // can occur if new lines will be added while filtering + _progressEventArgs.MaxValue = value; } - private void FilterComplete (IAsyncResult result) + SendProgressBarUpdate(); + } + + private void FilterComplete () + { + if (!IsDisposed && !_waitingForClose && !Disposing) { - if (!IsDisposed && !_waitingForClose && !Disposing) - { - Invoke(new MethodInvoker(ResetStatusAfterFilter)); - } + Invoke(new MethodInvoker(ResetStatusAfterFilter)); } + } - private void ResetStatusAfterFilter () + private void FilterComplete (IAsyncResult result) + { + if (!IsDisposed && !_waitingForClose && !Disposing) { - try - { - //StatusLineText(""); - _isSearching = false; - _progressEventArgs.Value = _progressEventArgs.MaxValue; - _progressEventArgs.Visible = false; - SendProgressBarUpdate(); - filterGridView.RowCount = _filterResultList.Count; - //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - AutoResizeColumns(filterGridView); - lblFilterCount.Text = "" + _filterResultList.Count; - if (filterGridView.RowCount > 0) - { - filterGridView.Focus(); - } - - filterSearchButton.Enabled = true; - } - catch (NullReferenceException e) - { - // See https://connect.microsoft.com/VisualStudio/feedback/details/366943/autoresizecolumns-in-datagridview-throws-nullreferenceexception - // There are some rare situations with null ref exceptions when resizing columns and on filter finished - // So catch them here. Better than crashing. - _logger.Error(e, "Error: "); - } + Invoke(new MethodInvoker(ResetStatusAfterFilter)); } + } - private void ClearFilterList () + private void ResetStatusAfterFilter () + { + try { - try + //StatusLineText(""); + _isSearching = false; + _progressEventArgs.Value = _progressEventArgs.MaxValue; + _progressEventArgs.Visible = false; + SendProgressBarUpdate(); + filterGridView.RowCount = _filterResultList.Count; + //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + AutoResizeColumns(filterGridView); + lblFilterCount.Text = "" + _filterResultList.Count; + if (filterGridView.RowCount > 0) { - //this.shouldCancel = true; - lock (_filterResultList) - { - filterGridView.SuspendLayout(); - filterGridView.RowCount = 0; - lblFilterCount.Text = "0"; - _filterResultList = []; - _lastFilterLinesList = []; - _filterHitList = []; - //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - filterGridView.ResumeLayout(); - } + filterGridView.Focus(); } - catch (Exception ex) - { - _logger.Error(ex, "Wieder dieser sporadische Fehler: "); - MessageBox.Show(null, ex.StackTrace, "Wieder dieser sporadische Fehler:"); - } + filterSearchButton.Enabled = true; } - - private void ClearBookmarkList () + catch (NullReferenceException e) { - _bookmarkProvider.ClearAllBookmarks(); + // See https://connect.microsoft.com/VisualStudio/feedback/details/366943/autoresizecolumns-in-datagridview-throws-nullreferenceexception + // There are some rare situations with null ref exceptions when resizing columns and on filter finished + // So catch them here. Better than crashing. + _logger.Error(e, "Error: "); } + } - /** - * Shift filter list line entries after a logfile rollover - */ - - private void ShiftFilterLines (int offset) + private void ClearFilterList () + { + try { - List newFilterList = []; + //this.shouldCancel = true; lock (_filterResultList) { - foreach (var lineNum in _filterResultList) - { - var line = lineNum - offset; - if (line >= 0) - { - newFilterList.Add(line); - } - } - - _filterResultList = newFilterList; + filterGridView.SuspendLayout(); + filterGridView.RowCount = 0; + lblFilterCount.Text = "0"; + _filterResultList = []; + _lastFilterLinesList = []; + _filterHitList = []; + //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + filterGridView.ResumeLayout(); } + } + catch (Exception ex) + { + _logger.Error(ex, "Wieder dieser sporadische Fehler: "); + + MessageBox.Show(null, ex.StackTrace, "Wieder dieser sporadische Fehler:"); + } + } - newFilterList = []; - foreach (var lineNum in _filterHitList) + private void ClearBookmarkList () + { + _bookmarkProvider.ClearAllBookmarks(); + } + + /** + * Shift filter list line entries after a logfile rollover + */ + + private void ShiftFilterLines (int offset) + { + List newFilterList = []; + lock (_filterResultList) + { + foreach (var lineNum in _filterResultList) { var line = lineNum - offset; if (line >= 0) @@ -2422,1318 +2409,1330 @@ private void ShiftFilterLines (int offset) } } - _filterHitList = newFilterList; - - var count = SPREAD_MAX; - if (_filterResultList.Count < SPREAD_MAX) - { - count = _filterResultList.Count; - } - - _lastFilterLinesList = _filterResultList.GetRange(_filterResultList.Count - count, count); - - //this.filterGridView.RowCount = this.filterResultList.Count; - //this.filterCountLabel.Text = "" + this.filterResultList.Count; - //this.BeginInvoke(new MethodInvoker(this.filterGridView.Refresh)); - //this.BeginInvoke(new MethodInvoker(AddFilterLineGuiUpdate)); - TriggerFilterLineGuiUpdate(); + _filterResultList = newFilterList; } - private void CheckForFilterDirty () + newFilterList = []; + foreach (var lineNum in _filterHitList) { - if (IsFilterSearchDirty(_filterParams)) - { - filterSearchButton.Image = _searchButtonImage; - saveFilterButton.Enabled = false; - } - else + var line = lineNum - offset; + if (line >= 0) { - filterSearchButton.Image = null; - saveFilterButton.Enabled = true; + newFilterList.Add(line); } } - private bool IsFilterSearchDirty (FilterParams filterParams) + _filterHitList = newFilterList; + + var count = SPREAD_MAX; + if (_filterResultList.Count < SPREAD_MAX) { - if (!filterParams.SearchText.Equals(filterComboBox.Text)) - { - return true; - } + count = _filterResultList.Count; + } - if (filterParams.IsRangeSearch != rangeCheckBox.Checked) - { - return true; - } + _lastFilterLinesList = _filterResultList.GetRange(_filterResultList.Count - count, count); - if (filterParams.IsRangeSearch && !filterParams.RangeSearchText.Equals(filterRangeComboBox.Text)) - { - return true; - } + //this.filterGridView.RowCount = this.filterResultList.Count; + //this.filterCountLabel.Text = "" + this.filterResultList.Count; + //this.BeginInvoke(new MethodInvoker(this.filterGridView.Refresh)); + //this.BeginInvoke(new MethodInvoker(AddFilterLineGuiUpdate)); + TriggerFilterLineGuiUpdate(); + } - if (filterParams.IsRegex != filterRegexCheckBox.Checked) - { - return true; - } + private void CheckForFilterDirty () + { + if (IsFilterSearchDirty(_filterParams)) + { + filterSearchButton.Image = _searchButtonImage; + saveFilterButton.Enabled = false; + } + else + { + filterSearchButton.Image = null; + saveFilterButton.Enabled = true; + } + } - if (filterParams.IsInvert != invertFilterCheckBox.Checked) - { - return true; - } + private bool IsFilterSearchDirty (FilterParams filterParams) + { + if (!filterParams.SearchText.Equals(filterComboBox.Text)) + { + return true; + } - if (filterParams.SpreadBefore != filterKnobBackSpread.Value) - { - return true; - } + if (filterParams.IsRangeSearch != rangeCheckBox.Checked) + { + return true; + } - if (filterParams.SpreadBehind != filterKnobForeSpread.Value) - { - return true; - } + if (filterParams.IsRangeSearch && !filterParams.RangeSearchText.Equals(filterRangeComboBox.Text)) + { + return true; + } - if (filterParams.FuzzyValue != fuzzyKnobControl.Value) - { - return true; - } + if (filterParams.IsRegex != filterRegexCheckBox.Checked) + { + return true; + } - if (filterParams.ColumnRestrict != columnRestrictCheckBox.Checked) - { - return true; - } + if (filterParams.IsInvert != invertFilterCheckBox.Checked) + { + return true; + } - if (filterParams.IsCaseSensitive != filterCaseSensitiveCheckBox.Checked) - { - return true; - } + if (filterParams.SpreadBefore != filterKnobBackSpread.Value) + { + return true; + } - return false; + if (filterParams.SpreadBehind != filterKnobForeSpread.Value) + { + return true; } - private void AdjustMinimumGridWith () + if (filterParams.FuzzyValue != fuzzyKnobControl.Value) { - if (dataGridView.Columns.Count > 1) - { - //this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - AutoResizeColumns(dataGridView); + return true; + } - var width = dataGridView.Columns.GetColumnsWidth(DataGridViewElementStates.Visible); - var diff = dataGridView.Width - width; - if (diff > 0) - { - diff -= dataGridView.RowHeadersWidth / 2; - dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].Width += diff; - filterGridView.Columns[filterGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].Width += diff; - } - } + if (filterParams.ColumnRestrict != columnRestrictCheckBox.Checked) + { + return true; + } + + if (filterParams.IsCaseSensitive != filterCaseSensitiveCheckBox.Checked) + { + return true; } - private void InvalidateCurrentRow (BufferedDataGridView gridView) + return false; + } + + private void AdjustMinimumGridWith () + { + if (dataGridView.Columns.Count > 1) { - if (gridView.CurrentCellAddress.Y > -1) + //this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + AutoResizeColumns(dataGridView); + + var width = dataGridView.Columns.GetColumnsWidth(DataGridViewElementStates.Visible); + var diff = dataGridView.Width - width; + if (diff > 0) { - gridView.InvalidateRow(gridView.CurrentCellAddress.Y); + diff -= dataGridView.RowHeadersWidth / 2; + dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].Width += diff; + filterGridView.Columns[filterGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].Width += diff; } } + } - private void InvalidateCurrentRow () + private void InvalidateCurrentRow (BufferedDataGridView gridView) + { + if (gridView.CurrentCellAddress.Y > -1) { - InvalidateCurrentRow(dataGridView); - InvalidateCurrentRow(filterGridView); + gridView.InvalidateRow(gridView.CurrentCellAddress.Y); } + } - private void DisplayCurrentFileOnStatusline () + private void InvalidateCurrentRow () + { + InvalidateCurrentRow(dataGridView); + InvalidateCurrentRow(filterGridView); + } + + private void DisplayCurrentFileOnStatusline () + { + if (_logFileReader.IsMultiFile) { - if (_logFileReader.IsMultiFile) + try { - try + if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index > -1) { - if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index > -1) + var fileName = _logFileReader.GetLogFileNameForLine(dataGridView.CurrentRow.Index); + if (fileName != null) { - var fileName = _logFileReader.GetLogFileNameForLine(dataGridView.CurrentRow.Index); - if (fileName != null) - { - StatusLineText(Util.GetNameFromPath(fileName)); - } + StatusLineText(Util.GetNameFromPath(fileName)); } } - catch (Exception) - { - // TODO: handle this concurrent situation better: - // this.dataGridView.CurrentRow may be null even if checked before. - // This can happen when MultiFile shift deselects the current row because there - // are less lines after rollover than before. - // access to dataGridView-Rows should be locked - } } - } - - private void UpdateSelectionDisplay () - { - if (_noSelectionUpdates) + catch (Exception) { - return; + // TODO: handle this concurrent situation better: + // this.dataGridView.CurrentRow may be null even if checked before. + // This can happen when MultiFile shift deselects the current row because there + // are less lines after rollover than before. + // access to dataGridView-Rows should be locked } } + } - private void UpdateFilterHistoryFromSettings () + private void UpdateSelectionDisplay () + { + if (_noSelectionUpdates) { - ConfigManager.Settings.filterHistoryList = ConfigManager.Settings.filterHistoryList; - filterComboBox.Items.Clear(); - foreach (var item in ConfigManager.Settings.filterHistoryList) - { - filterComboBox.Items.Add(item); - } - - filterRangeComboBox.Items.Clear(); - foreach (var item in ConfigManager.Settings.filterRangeHistoryList) - { - filterRangeComboBox.Items.Add(item); - } + return; } + } - private void StatusLineText (string text) + private void UpdateFilterHistoryFromSettings () + { + ConfigManager.Settings.filterHistoryList = ConfigManager.Settings.filterHistoryList; + filterComboBox.Items.Clear(); + foreach (var item in ConfigManager.Settings.filterHistoryList) { - _statusEventArgs.StatusText = text; - SendStatusLineUpdate(); + filterComboBox.Items.Add(item); } - private void StatusLineError (string text) + filterRangeComboBox.Items.Clear(); + foreach (var item in ConfigManager.Settings.filterRangeHistoryList) { - StatusLineText(text); - _isErrorShowing = true; + filterRangeComboBox.Items.Add(item); } + } + + private void StatusLineText (string text) + { + _statusEventArgs.StatusText = text; + SendStatusLineUpdate(); + } + + private void StatusLineError (string text) + { + StatusLineText(text); + _isErrorShowing = true; + } + + private void RemoveStatusLineError () + { + StatusLineText(""); + _isErrorShowing = false; + } + + private void SendGuiStateUpdate () + { + OnGuiState(_guiStateArgs); + } - private void RemoveStatusLineError () + private void SendProgressBarUpdate () + { + OnProgressBarUpdate(_progressEventArgs); + } + + private void SendStatusLineUpdate () + { + OnStatusLine(_statusEventArgs); + } + + private void ShowAdvancedFilterPanel (bool show) + { + if (show) { - StatusLineText(""); - _isErrorShowing = false; + advancedButton.Text = "Hide advanced..."; + advancedButton.Image = null; } - - private void SendGuiStateUpdate () + else { - OnGuiState(_guiStateArgs); + advancedButton.Text = "Show advanced..."; + CheckForAdvancedButtonDirty(); } - private void SendProgressBarUpdate () + advancedFilterSplitContainer.Panel1Collapsed = !show; + advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; + _showAdvanced = show; + } + + private void CheckForAdvancedButtonDirty () + { + if (IsAdvancedOptionActive() && !_showAdvanced) { - OnProgressBarUpdate(_progressEventArgs); + advancedButton.Image = _advancedButtonImage; } - - private void SendStatusLineUpdate () + else { - OnStatusLine(_statusEventArgs); + advancedButton.Image = null; } + } + + private void FilterToTab () + { + filterSearchButton.Enabled = false; + Task.Run(() => WriteFilterToTab()); + } - private void ShowAdvancedFilterPanel (bool show) + private void WriteFilterToTab () + { + FilterPipe pipe = new(_filterParams.Clone(), this); + lock (_filterResultList) { - if (show) + var namePrefix = "->F"; + string title; + if (IsTempFile) { - advancedButton.Text = "Hide advanced..."; - advancedButton.Image = null; + title = TempTitleName + namePrefix + ++_filterPipeNameCounter; } else { - advancedButton.Text = "Show advanced..."; - CheckForAdvancedButtonDirty(); + title = Util.GetNameFromPath(FileName) + namePrefix + ++_filterPipeNameCounter; } - advancedFilterSplitContainer.Panel1Collapsed = !show; - advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; - _showAdvanced = show; + WritePipeToTab(pipe, _filterResultList, title, null); } + } - private void CheckForAdvancedButtonDirty () - { - if (IsAdvancedOptionActive() && !_showAdvanced) - { - advancedButton.Image = _advancedButtonImage; - } - else - { - advancedButton.Image = null; - } - } + private void WritePipeToTab (FilterPipe pipe, IList lineNumberList, string name, PersistenceData persistenceData) + { + _logger.Info("WritePipeToTab(): {0} lines.", lineNumberList.Count); + StatusLineText("Writing to temp file... Press ESC to cancel."); + _guiStateArgs.MenuEnabled = false; + SendGuiStateUpdate(); + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = lineNumberList.Count; + _progressEventArgs.Value = 0; + _progressEventArgs.Visible = true; + Invoke(new MethodInvoker(SendProgressBarUpdate)); + _isSearching = true; + _shouldCancel = false; - private void FilterToTab () + lock (_filterPipeList) { - filterSearchButton.Enabled = false; - Task.Run(() => WriteFilterToTab()); + _filterPipeList.Add(pipe); } - private void WriteFilterToTab () + pipe.Closed += OnPipeDisconnected; + var count = 0; + pipe.OpenFile(); + LogExpertCallback callback = new(this); + foreach (var i in lineNumberList) { - FilterPipe pipe = new(_filterParams.Clone(), this); - lock (_filterResultList) + if (_shouldCancel) { - var namePrefix = "->F"; - string title; - if (IsTempFile) - { - title = TempTitleName + namePrefix + ++_filterPipeNameCounter; - } - else - { - title = Util.GetNameFromPath(FileName) + namePrefix + ++_filterPipeNameCounter; - } - - WritePipeToTab(pipe, _filterResultList, title, null); + break; } - } - - private void WritePipeToTab (FilterPipe pipe, IList lineNumberList, string name, PersistenceData persistenceData) - { - _logger.Info("WritePipeToTab(): {0} lines.", lineNumberList.Count); - StatusLineText("Writing to temp file... Press ESC to cancel."); - _guiStateArgs.MenuEnabled = false; - SendGuiStateUpdate(); - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = lineNumberList.Count; - _progressEventArgs.Value = 0; - _progressEventArgs.Visible = true; - Invoke(new MethodInvoker(SendProgressBarUpdate)); - _isSearching = true; - _shouldCancel = false; - lock (_filterPipeList) + ILogLine line = _logFileReader.GetLogLine(i); + if (CurrentColumnizer is ILogLineXmlColumnizer) { - _filterPipeList.Add(pipe); + callback.LineNum = i; + line = (CurrentColumnizer as ILogLineXmlColumnizer).GetLineTextForClipboard(line, callback); } - pipe.Closed += OnPipeDisconnected; - var count = 0; - pipe.OpenFile(); - LogExpertCallback callback = new(this); - foreach (var i in lineNumberList) + pipe.WriteToPipe(line, i); + if (++count % PROGRESS_BAR_MODULO == 0) { - if (_shouldCancel) - { - break; - } - - ILogLine line = _logFileReader.GetLogLine(i); - if (CurrentColumnizer is ILogLineXmlColumnizer) - { - callback.LineNum = i; - line = (CurrentColumnizer as ILogLineXmlColumnizer).GetLineTextForClipboard(line, callback); - } - - pipe.WriteToPipe(line, i); - if (++count % PROGRESS_BAR_MODULO == 0) - { - _progressEventArgs.Value = count; - Invoke(new MethodInvoker(SendProgressBarUpdate)); - } + _progressEventArgs.Value = count; + Invoke(new MethodInvoker(SendProgressBarUpdate)); } - - pipe.CloseFile(); - _logger.Info("WritePipeToTab(): finished"); - Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), pipe, name, persistenceData); } - private void WriteFilterToTabFinished (FilterPipe pipe, string name, PersistenceData persistenceData) + pipe.CloseFile(); + _logger.Info("WritePipeToTab(): finished"); + Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), pipe, name, persistenceData); + } + + private void WriteFilterToTabFinished (FilterPipe pipe, string name, PersistenceData persistenceData) + { + _isSearching = false; + if (!_shouldCancel) { - _isSearching = false; - if (!_shouldCancel) + var title = name; + ILogLineColumnizer preProcessColumnizer = null; + if (CurrentColumnizer is not ILogLineXmlColumnizer) { - var title = name; - ILogLineColumnizer preProcessColumnizer = null; - if (CurrentColumnizer is not ILogLineXmlColumnizer) - { - preProcessColumnizer = CurrentColumnizer; - } - - LogWindow newWin = _parentLogTabWin.AddFilterTab(pipe, title, preProcessColumnizer); - newWin.FilterPipe = pipe; - pipe.OwnLogWindow = newWin; - if (persistenceData != null) - { - Task.Run(() => FilterRestore(newWin, persistenceData)); - } + preProcessColumnizer = CurrentColumnizer; } - _progressEventArgs.Value = _progressEventArgs.MaxValue; - _progressEventArgs.Visible = false; - SendProgressBarUpdate(); - _guiStateArgs.MenuEnabled = true; - SendGuiStateUpdate(); - StatusLineText(""); - filterSearchButton.Enabled = true; - } - - /// - /// Used to create a new tab and pipe the given content into it. - /// - /// - /// - internal void WritePipeTab (IList lineEntryList, string title) - { - FilterPipe pipe = new(new FilterParams(), this); - pipe.IsStopped = true; - pipe.Closed += OnPipeDisconnected; - pipe.OpenFile(); - foreach (LineEntry entry in lineEntryList) + LogWindow newWin = _parentLogTabWin.AddFilterTab(pipe, title, preProcessColumnizer); + newWin.FilterPipe = pipe; + pipe.OwnLogWindow = newWin; + if (persistenceData != null) { - pipe.WriteToPipe(entry.logLine, entry.lineNum); + Task.Run(() => FilterRestore(newWin, persistenceData)); } - - pipe.CloseFile(); - Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), [pipe, title, null]); } - private void FilterRestore (LogWindow newWin, PersistenceData persistenceData) + _progressEventArgs.Value = _progressEventArgs.MaxValue; + _progressEventArgs.Visible = false; + SendProgressBarUpdate(); + _guiStateArgs.MenuEnabled = true; + SendGuiStateUpdate(); + StatusLineText(""); + filterSearchButton.Enabled = true; + } + + /// + /// Used to create a new tab and pipe the given content into it. + /// + /// + /// + internal void WritePipeTab (IList lineEntryList, string title) + { + FilterPipe pipe = new(new FilterParams(), this); + pipe.IsStopped = true; + pipe.Closed += OnPipeDisconnected; + pipe.OpenFile(); + foreach (LineEntry entry in lineEntryList) { - newWin.WaitForLoadingFinished(); - ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(persistenceData.columnizerName, - PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - if (columnizer != null) - { - SetColumnizerFx fx = newWin.ForceColumnizer; - newWin.Invoke(fx, [columnizer]); - } - else - { - _logger.Warn("FilterRestore(): Columnizer {0} not found", persistenceData.columnizerName); - } + pipe.WriteToPipe(entry.logLine, entry.lineNum); + } + + pipe.CloseFile(); + Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), [pipe, title, null]); + } - newWin.BeginInvoke(new RestoreFiltersFx(newWin.RestoreFilters), [persistenceData]); + private void FilterRestore (LogWindow newWin, PersistenceData persistenceData) + { + newWin.WaitForLoadingFinished(); + ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(persistenceData.columnizerName, + PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + if (columnizer != null) + { + SetColumnizerFx fx = newWin.ForceColumnizer; + newWin.Invoke(fx, [columnizer]); + } + else + { + _logger.Warn("FilterRestore(): Columnizer {0} not found", persistenceData.columnizerName); } - private void ProcessFilterPipes (int lineNum) + newWin.BeginInvoke(new RestoreFiltersFx(newWin.RestoreFilters), [persistenceData]); + } + + private void ProcessFilterPipes (int lineNum) + { + ILogLine searchLine = _logFileReader.GetLogLine(lineNum); + if (searchLine == null) { - ILogLine searchLine = _logFileReader.GetLogLine(lineNum); - if (searchLine == null) - { - return; - } + return; + } - ColumnizerCallback callback = new(this); - callback.LineNum = lineNum; - IList deleteList = []; - lock (_filterPipeList) + ColumnizerCallback callback = new(this); + callback.LineNum = lineNum; + IList deleteList = []; + lock (_filterPipeList) + { + foreach (FilterPipe pipe in _filterPipeList) { - foreach (FilterPipe pipe in _filterPipeList) + if (pipe.IsStopped) { - if (pipe.IsStopped) - { - continue; - } + continue; + } - long startTime = Environment.TickCount; - if (Util.TestFilterCondition(pipe.FilterParams, searchLine, callback)) + long startTime = Environment.TickCount; + if (Util.TestFilterCondition(pipe.FilterParams, searchLine, callback)) + { + IList filterResult = + GetAdditionalFilterResults(pipe.FilterParams, lineNum, pipe.LastLinesHistoryList); + pipe.OpenFile(); + foreach (var line in filterResult) { - IList filterResult = - GetAdditionalFilterResults(pipe.FilterParams, lineNum, pipe.LastLinesHistoryList); - pipe.OpenFile(); - foreach (var line in filterResult) + pipe.LastLinesHistoryList.Add(line); + if (pipe.LastLinesHistoryList.Count > SPREAD_MAX * 2) { - pipe.LastLinesHistoryList.Add(line); - if (pipe.LastLinesHistoryList.Count > SPREAD_MAX * 2) - { - pipe.LastLinesHistoryList.RemoveAt(0); - } - - ILogLine textLine = _logFileReader.GetLogLine(line); - var fileOk = pipe.WriteToPipe(textLine, line); - if (!fileOk) - { - deleteList.Add(pipe); - } + pipe.LastLinesHistoryList.RemoveAt(0); } - pipe.CloseFile(); + ILogLine textLine = _logFileReader.GetLogLine(line); + var fileOk = pipe.WriteToPipe(textLine, line); + if (!fileOk) + { + deleteList.Add(pipe); + } } - long endTime = Environment.TickCount; - //_logger.logDebug("ProcessFilterPipes(" + lineNum + ") duration: " + ((endTime - startTime))); + pipe.CloseFile(); } - } - foreach (FilterPipe pipe in deleteList) - { - _filterPipeList.Remove(pipe); + long endTime = Environment.TickCount; + //_logger.logDebug("ProcessFilterPipes(" + lineNum + ") duration: " + ((endTime - startTime))); } } - private void CopyMarkedLinesToClipboard () + foreach (FilterPipe pipe in deleteList) { - if (_guiStateArgs.CellSelectMode) - { - DataObject data = dataGridView.GetClipboardContent(); - Clipboard.SetDataObject(data); - } - else + _filterPipeList.Remove(pipe); + } + } + + private void CopyMarkedLinesToClipboard () + { + if (_guiStateArgs.CellSelectMode) + { + DataObject data = dataGridView.GetClipboardContent(); + Clipboard.SetDataObject(data); + } + else + { + List lineNumList = []; + foreach (DataGridViewRow row in dataGridView.SelectedRows) { - List lineNumList = []; - foreach (DataGridViewRow row in dataGridView.SelectedRows) + if (row.Index != -1) { - if (row.Index != -1) - { - lineNumList.Add(row.Index); - } + lineNumList.Add(row.Index); } + } - lineNumList.Sort(); - StringBuilder clipText = new(); - LogExpertCallback callback = new(this); + lineNumList.Sort(); + StringBuilder clipText = new(); + LogExpertCallback callback = new(this); - var xmlColumnizer = _currentColumnizer as ILogLineXmlColumnizer; + var xmlColumnizer = _currentColumnizer as ILogLineXmlColumnizer; - foreach (var lineNum in lineNumList) + foreach (var lineNum in lineNumList) + { + ILogLine line = _logFileReader.GetLogLine(lineNum); + if (xmlColumnizer != null) { - ILogLine line = _logFileReader.GetLogLine(lineNum); - if (xmlColumnizer != null) - { - callback.LineNum = lineNum; - line = xmlColumnizer.GetLineTextForClipboard(line, callback); - } - - clipText.AppendLine(line.ToClipBoardText()); + callback.LineNum = lineNum; + line = xmlColumnizer.GetLineTextForClipboard(line, callback); } - Clipboard.SetText(clipText.ToString()); + clipText.AppendLine(line.ToClipBoardText()); } - } - /// - /// Set an Encoding which shall be used when loading a file. Used before a file is loaded. - /// - /// - private void SetExplicitEncoding (Encoding encoding) - { - EncodingOptions.Encoding = encoding; + Clipboard.SetText(clipText.ToString()); } + } + + /// + /// Set an Encoding which shall be used when loading a file. Used before a file is loaded. + /// + /// + private void SetExplicitEncoding (Encoding encoding) + { + EncodingOptions.Encoding = encoding; + } - private void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, Preferences prefs) + private void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, Preferences prefs) + { + if (dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) > 1) { - if (dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) > 1) + if (prefs.setLastColumnWidth) { - if (prefs.setLastColumnWidth) - { - dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].MinimumWidth = prefs.lastColumnWidth; - } - else - { - // Workaround for a .NET bug which brings the DataGridView into an unstable state (causing lots of NullReferenceExceptions). - dataGridView.FirstDisplayedScrollingColumnIndex = 0; - - dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].MinimumWidth = 5; // default - } + dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].MinimumWidth = prefs.lastColumnWidth; } - - if (dataGridView.RowCount > 0) + else { - dataGridView.UpdateRowHeightInfo(0, true); + // Workaround for a .NET bug which brings the DataGridView into an unstable state (causing lots of NullReferenceExceptions). + dataGridView.FirstDisplayedScrollingColumnIndex = 0; + + dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].MinimumWidth = 5; // default } + } - dataGridView.Invalidate(); - dataGridView.Refresh(); - AutoResizeColumns(dataGridView); + if (dataGridView.RowCount > 0) + { + dataGridView.UpdateRowHeightInfo(0, true); } - private IList GetSelectedContent () + dataGridView.Invalidate(); + dataGridView.Refresh(); + AutoResizeColumns(dataGridView); + } + + private IList GetSelectedContent () + { + if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) { - if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) - { - List lineNumList = []; + List lineNumList = []; - foreach (DataGridViewRow row in dataGridView.SelectedRows) + foreach (DataGridViewRow row in dataGridView.SelectedRows) + { + if (row.Index != -1) { - if (row.Index != -1) - { - lineNumList.Add(row.Index); - } + lineNumList.Add(row.Index); } - - lineNumList.Sort(); - return lineNumList; } - return []; + lineNumList.Sort(); + return lineNumList; } - /* ======================================================================== - * Timestamp stuff - * =======================================================================*/ - - private void SetTimestampLimits () - { - if (!CurrentColumnizer.IsTimeshiftImplemented()) - { - return; - } + return []; + } - var line = 0; - _guiStateArgs.MinTimestamp = GetTimestampForLineForward(ref line, true); - line = dataGridView.RowCount - 1; - _guiStateArgs.MaxTimestamp = GetTimestampForLine(ref line, true); - SendGuiStateUpdate(); - } + /* ======================================================================== + * Timestamp stuff + * =======================================================================*/ - private void AdjustHighlightSplitterWidth () + private void SetTimestampLimits () + { + if (!CurrentColumnizer.IsTimeshiftImplemented()) { - //int size = this.editHighlightsSplitContainer.Panel2Collapsed ? 600 : 660; - //int distance = this.highlightSplitContainer.Width - size; - //if (distance < 10) - // distance = 10; - //this.highlightSplitContainer.SplitterDistance = distance; + return; } - private void BookmarkComment (Bookmark bookmark) + var line = 0; + _guiStateArgs.MinTimestamp = GetTimestampForLineForward(ref line, true); + line = dataGridView.RowCount - 1; + _guiStateArgs.MaxTimestamp = GetTimestampForLine(ref line, true); + SendGuiStateUpdate(); + } + + private void AdjustHighlightSplitterWidth () + { + //int size = this.editHighlightsSplitContainer.Panel2Collapsed ? 600 : 660; + //int distance = this.highlightSplitContainer.Width - size; + //if (distance < 10) + // distance = 10; + //this.highlightSplitContainer.SplitterDistance = distance; + } + + private void BookmarkComment (Bookmark bookmark) + { + BookmarkCommentDlg dlg = new(); + dlg.Comment = bookmark.Text; + if (dlg.ShowDialog() == DialogResult.OK) { - BookmarkCommentDlg dlg = new(); - dlg.Comment = bookmark.Text; - if (dlg.ShowDialog() == DialogResult.OK) - { - bookmark.Text = dlg.Comment; - dataGridView.Refresh(); - OnBookmarkTextChanged(bookmark); - } + bookmark.Text = dlg.Comment; + dataGridView.Refresh(); + OnBookmarkTextChanged(bookmark); } + } - /// - /// Indicates which columns we are filtering on - /// - /// - /// - private string CalculateColumnNames (FilterParams filter) - { - var names = string.Empty; + /// + /// Indicates which columns we are filtering on + /// + /// + /// + private string CalculateColumnNames (FilterParams filter) + { + var names = string.Empty; - if (filter.ColumnRestrict) + if (filter.ColumnRestrict) + { + foreach (var colIndex in filter.ColumnList) { - foreach (var colIndex in filter.ColumnList) + if (colIndex < dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 2) { - if (colIndex < dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 2) + if (names.Length > 0) { - if (names.Length > 0) - { - names += ", "; - } - - names += dataGridView.Columns[2 + colIndex] - .HeaderText; // skip first two columns: marker + line number + names += ", "; } + + names += dataGridView.Columns[2 + colIndex] + .HeaderText; // skip first two columns: marker + line number } } - - return names; } - private void ApplyFrozenState (BufferedDataGridView gridView) - { - SortedDictionary dict = []; - foreach (DataGridViewColumn col in gridView.Columns) - { - dict.Add(col.DisplayIndex, col); - } + return names; + } - foreach (DataGridViewColumn col in dict.Values) - { - col.Frozen = _freezeStateMap.ContainsKey(gridView) && _freezeStateMap[gridView]; - var sel = col.HeaderCell.Selected; - if (col.Index == _selectedCol) - { - break; - } - } + private void ApplyFrozenState (BufferedDataGridView gridView) + { + SortedDictionary dict = []; + foreach (DataGridViewColumn col in gridView.Columns) + { + dict.Add(col.DisplayIndex, col); } - private void ShowTimeSpread (bool show) + foreach (DataGridViewColumn col in dict.Values) { - if (show) - { - tableLayoutPanel1.ColumnStyles[1].Width = 16; - } - else + col.Frozen = _freezeStateMap.ContainsKey(gridView) && _freezeStateMap[gridView]; + var sel = col.HeaderCell.Selected; + if (col.Index == _selectedCol) { - tableLayoutPanel1.ColumnStyles[1].Width = 0; + break; } - - _timeSpreadCalc.Enabled = show; } + } - protected internal void AddTempFileTab (string fileName, string title) + private void ShowTimeSpread (bool show) + { + if (show) { - _parentLogTabWin.AddTempFileTab(fileName, title); + tableLayoutPanel1.ColumnStyles[1].Width = 16; } - - private void InitPatternWindow () + else { - //PatternStatistic(this.patternArgs); - _patternWindow = new PatternWindow(this); - _patternWindow.SetColumnizer(CurrentColumnizer); - //this.patternWindow.SetBlockList(blockList); - _patternWindow.SetFont(Preferences.fontName, Preferences.fontSize); - _patternWindow.Fuzzy = _patternArgs.Fuzzy; - _patternWindow.MaxDiff = _patternArgs.MaxDiffInBlock; - _patternWindow.MaxMisses = _patternArgs.MaxMisses; - _patternWindow.Weight = _patternArgs.MinWeight; - //this.patternWindow.Show(); + tableLayoutPanel1.ColumnStyles[1].Width = 0; } - private void TestStatistic (PatternArgs patternArgs) - { - var beginLine = patternArgs.StartLine; - _logger.Info("TestStatistics() called with start line {0}", beginLine); + _timeSpreadCalc.Enabled = show; + } - _patternArgs = patternArgs; + protected internal void AddTempFileTab (string fileName, string title) + { + _parentLogTabWin.AddTempFileTab(fileName, title); + } - var num = beginLine + 1; //this.dataGridView.RowCount; + private void InitPatternWindow () + { + //PatternStatistic(this.patternArgs); + _patternWindow = new PatternWindow(this); + _patternWindow.SetColumnizer(CurrentColumnizer); + //this.patternWindow.SetBlockList(blockList); + _patternWindow.SetFont(Preferences.fontName, Preferences.fontSize); + _patternWindow.Fuzzy = _patternArgs.Fuzzy; + _patternWindow.MaxDiff = _patternArgs.MaxDiffInBlock; + _patternWindow.MaxMisses = _patternArgs.MaxMisses; + _patternWindow.Weight = _patternArgs.MinWeight; + //this.patternWindow.Show(); + } - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = dataGridView.RowCount; - _progressEventArgs.Value = beginLine; - _progressEventArgs.Visible = true; - SendProgressBarUpdate(); + private void TestStatistic (PatternArgs patternArgs) + { + var beginLine = patternArgs.StartLine; + _logger.Info("TestStatistics() called with start line {0}", beginLine); - PrepareDict(); - ResetCache(num); + _patternArgs = patternArgs; - Dictionary processedLinesDict = []; - List blockList = []; - var blockId = 0; - _isSearching = true; - _shouldCancel = false; - var searchLine = -1; - for (var i = beginLine; i < num && !_shouldCancel; ++i) + var num = beginLine + 1; //this.dataGridView.RowCount; + + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = dataGridView.RowCount; + _progressEventArgs.Value = beginLine; + _progressEventArgs.Visible = true; + SendProgressBarUpdate(); + + PrepareDict(); + ResetCache(num); + + Dictionary processedLinesDict = []; + List blockList = []; + var blockId = 0; + _isSearching = true; + _shouldCancel = false; + var searchLine = -1; + for (var i = beginLine; i < num && !_shouldCancel; ++i) + { + if (processedLinesDict.ContainsKey(i)) { - if (processedLinesDict.ContainsKey(i)) - { - continue; - } + continue; + } - PatternBlock block; - var maxBlockLen = patternArgs.EndLine - patternArgs.StartLine; - //int searchLine = i + 1; - _logger.Debug("TestStatistic(): i={0} searchLine={1}", i, searchLine); - //bool firstBlock = true; - searchLine++; - UpdateProgressBar(searchLine); - while (!_shouldCancel && - (block = - DetectBlock(i, searchLine, maxBlockLen, _patternArgs.MaxDiffInBlock, - _patternArgs.MaxMisses, - processedLinesDict)) != null) - { - _logger.Debug("Found block: {0}", block); - if (block.weigth >= _patternArgs.MinWeight) - { - //PatternBlock existingBlock = FindExistingBlock(block, blockList); - //if (existingBlock != null) - //{ - // if (block.weigth > existingBlock.weigth) - // { - // blockList.Remove(existingBlock); - // blockList.Add(block); - // } - //} - //else - { - blockList.Add(block); - addBlockTargetLinesToDict(processedLinesDict, block); - } - block.blockId = blockId; - //if (firstBlock) - //{ - // addBlockSrcLinesToDict(processedLinesDict, block); - //} - searchLine = block.targetEnd + 1; - } - else + PatternBlock block; + var maxBlockLen = patternArgs.EndLine - patternArgs.StartLine; + //int searchLine = i + 1; + _logger.Debug("TestStatistic(): i={0} searchLine={1}", i, searchLine); + //bool firstBlock = true; + searchLine++; + UpdateProgressBar(searchLine); + while (!_shouldCancel && + (block = + DetectBlock(i, searchLine, maxBlockLen, _patternArgs.MaxDiffInBlock, + _patternArgs.MaxMisses, + processedLinesDict)) != null) + { + _logger.Debug("Found block: {0}", block); + if (block.weigth >= _patternArgs.MinWeight) + { + //PatternBlock existingBlock = FindExistingBlock(block, blockList); + //if (existingBlock != null) + //{ + // if (block.weigth > existingBlock.weigth) + // { + // blockList.Remove(existingBlock); + // blockList.Add(block); + // } + //} + //else { - searchLine = block.targetStart + 1; + blockList.Add(block); + addBlockTargetLinesToDict(processedLinesDict, block); } - - UpdateProgressBar(searchLine); + block.blockId = blockId; + //if (firstBlock) + //{ + // addBlockSrcLinesToDict(processedLinesDict, block); + //} + searchLine = block.targetEnd + 1; + } + else + { + searchLine = block.targetStart + 1; } - blockId++; - } - - _isSearching = false; - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = 0; - _progressEventArgs.Value = 0; - _progressEventArgs.Visible = false; - SendProgressBarUpdate(); - //if (this.patternWindow.IsDisposed) - //{ - // this.Invoke(new MethodInvoker(CreatePatternWindow)); - //} - _patternWindow.SetBlockList(blockList, _patternArgs); - _logger.Info("TestStatistics() ended"); + UpdateProgressBar(searchLine); + } + + blockId++; } - private void addBlockTargetLinesToDict (Dictionary dict, PatternBlock block) + _isSearching = false; + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = 0; + _progressEventArgs.Value = 0; + _progressEventArgs.Visible = false; + SendProgressBarUpdate(); + //if (this.patternWindow.IsDisposed) + //{ + // this.Invoke(new MethodInvoker(CreatePatternWindow)); + //} + _patternWindow.SetBlockList(blockList, _patternArgs); + _logger.Info("TestStatistics() ended"); + } + + private void addBlockTargetLinesToDict (Dictionary dict, PatternBlock block) + { + foreach (var lineNum in block.targetLines.Keys) { - foreach (var lineNum in block.targetLines.Keys) + if (!dict.ContainsKey(lineNum)) { - if (!dict.ContainsKey(lineNum)) - { - dict.Add(lineNum, lineNum); - } + dict.Add(lineNum, lineNum); } } + } - //Well keep this for the moment because there is some other commented code which calls this one - private PatternBlock FindExistingBlock (PatternBlock block, List blockList) + //Well keep this for the moment because there is some other commented code which calls this one + private PatternBlock FindExistingBlock (PatternBlock block, List blockList) + { + foreach (PatternBlock searchBlock in blockList) { - foreach (PatternBlock searchBlock in blockList) + if ((block.startLine > searchBlock.startLine && + block.startLine < searchBlock.endLine + || + block.endLine > searchBlock.startLine && + block.endLine < searchBlock.endLine) && block.startLine != searchBlock.startLine && + block.endLine != searchBlock.endLine + ) { - if ((block.startLine > searchBlock.startLine && - block.startLine < searchBlock.endLine - || - block.endLine > searchBlock.startLine && - block.endLine < searchBlock.endLine) && block.startLine != searchBlock.startLine && - block.endLine != searchBlock.endLine - ) - { - return searchBlock; - } + return searchBlock; } + } + + return null; + } + private PatternBlock DetectBlock (int startNum, int startLineToSearch, int maxBlockLen, int maxDiffInBlock, + int maxMisses, Dictionary processedLinesDict) + { + var targetLine = FindSimilarLine(startNum, startLineToSearch, processedLinesDict); + if (targetLine == -1) + { return null; } - private PatternBlock DetectBlock (int startNum, int startLineToSearch, int maxBlockLen, int maxDiffInBlock, - int maxMisses, Dictionary processedLinesDict) + PatternBlock block = new(); + block.startLine = startNum; + var srcLine = block.startLine; + block.targetStart = targetLine; + var srcMisses = 0; + block.srcLines.Add(srcLine, srcLine); + //block.targetLines.Add(targetLine, targetLine); + var len = 0; + QualityInfo qi = new(); + qi.quality = block.weigth; + block.qualityInfoList[targetLine] = qi; + + while (!_shouldCancel) { - var targetLine = FindSimilarLine(startNum, startLineToSearch, processedLinesDict); - if (targetLine == -1) + srcLine++; + len++; + //if (srcLine >= block.targetStart) + // break; // prevent to search in the own block + if (maxBlockLen > 0 && len > maxBlockLen) { - return null; + break; } - PatternBlock block = new(); - block.startLine = startNum; - var srcLine = block.startLine; - block.targetStart = targetLine; - var srcMisses = 0; - block.srcLines.Add(srcLine, srcLine); - //block.targetLines.Add(targetLine, targetLine); - var len = 0; - QualityInfo qi = new(); - qi.quality = block.weigth; - block.qualityInfoList[targetLine] = qi; - - while (!_shouldCancel) + var nextTargetLine = FindSimilarLine(srcLine, targetLine + 1, processedLinesDict); + if (nextTargetLine > -1 && nextTargetLine - targetLine - 1 <= maxDiffInBlock) { - srcLine++; - len++; - //if (srcLine >= block.targetStart) - // break; // prevent to search in the own block - if (maxBlockLen > 0 && len > maxBlockLen) - { - break; - } - - var nextTargetLine = FindSimilarLine(srcLine, targetLine + 1, processedLinesDict); - if (nextTargetLine > -1 && nextTargetLine - targetLine - 1 <= maxDiffInBlock) - { - block.weigth += maxDiffInBlock - (nextTargetLine - targetLine - 1) + 1; - block.endLine = srcLine; - //block.targetLines.Add(nextTargetLine, nextTargetLine); - block.srcLines.Add(srcLine, srcLine); - if (nextTargetLine - targetLine > 1) - { - var tempWeight = block.weigth; - for (var tl = targetLine + 1; tl < nextTargetLine; ++tl) - { - qi = new QualityInfo(); - qi.quality = --tempWeight; - block.qualityInfoList[tl] = qi; - } - } - - targetLine = nextTargetLine; - qi = new QualityInfo(); - qi.quality = block.weigth; - block.qualityInfoList[targetLine] = qi; - } - else + block.weigth += maxDiffInBlock - (nextTargetLine - targetLine - 1) + 1; + block.endLine = srcLine; + //block.targetLines.Add(nextTargetLine, nextTargetLine); + block.srcLines.Add(srcLine, srcLine); + if (nextTargetLine - targetLine > 1) { - srcMisses++; - block.weigth--; - targetLine++; - qi = new QualityInfo(); - qi.quality = block.weigth; - block.qualityInfoList[targetLine] = qi; - if (srcMisses > maxMisses) + var tempWeight = block.weigth; + for (var tl = targetLine + 1; tl < nextTargetLine; ++tl) { - break; + qi = new QualityInfo(); + qi.quality = --tempWeight; + block.qualityInfoList[tl] = qi; } } - } - block.targetEnd = targetLine; - qi = new QualityInfo(); - qi.quality = block.weigth; - block.qualityInfoList[targetLine] = qi; - for (var k = block.targetStart; k <= block.targetEnd; ++k) + targetLine = nextTargetLine; + qi = new QualityInfo(); + qi.quality = block.weigth; + block.qualityInfoList[targetLine] = qi; + } + else { - block.targetLines.Add(k, k); + srcMisses++; + block.weigth--; + targetLine++; + qi = new QualityInfo(); + qi.quality = block.weigth; + block.qualityInfoList[targetLine] = qi; + if (srcMisses > maxMisses) + { + break; + } } - - return block; } - private void PrepareDict () + block.targetEnd = targetLine; + qi = new QualityInfo(); + qi.quality = block.weigth; + block.qualityInfoList[targetLine] = qi; + for (var k = block.targetStart; k <= block.targetEnd; ++k) { - _lineHashList.Clear(); - Regex regex = new("\\d"); - Regex regex2 = new("\\S"); + block.targetLines.Add(k, k); + } - var num = _logFileReader.LineCount; - for (var i = 0; i < num; ++i) - { - var msg = GetMsgForLine(i); - if (msg != null) - { - msg = msg.ToLower(); - msg = regex.Replace(msg, "0"); - msg = regex2.Replace(msg, " "); - var chars = msg.ToCharArray(); - var value = 0; - var numOfE = 0; - var numOfA = 0; - var numOfI = 0; - foreach (var t in chars) - { - value += t; - switch (t) - { - case 'e': - numOfE++; - break; - case 'a': - numOfA++; - break; - case 'i': - numOfI++; - break; - } - } + return block; + } - value += numOfE * 30; - value += numOfA * 20; - value += numOfI * 10; - _lineHashList.Add(value); + private void PrepareDict () + { + _lineHashList.Clear(); + Regex regex = new("\\d"); + Regex regex2 = new("\\S"); + + var num = _logFileReader.LineCount; + for (var i = 0; i < num; ++i) + { + var msg = GetMsgForLine(i); + if (msg != null) + { + msg = msg.ToLower(); + msg = regex.Replace(msg, "0"); + msg = regex2.Replace(msg, " "); + var chars = msg.ToCharArray(); + var value = 0; + var numOfE = 0; + var numOfA = 0; + var numOfI = 0; + foreach (var t in chars) + { + value += t; + switch (t) + { + case 'e': + numOfE++; + break; + case 'a': + numOfA++; + break; + case 'i': + numOfI++; + break; + } } + + value += numOfE * 30; + value += numOfA * 20; + value += numOfI * 10; + _lineHashList.Add(value); } } + } - private int _FindSimilarLine (int srcLine, int startLine) - { - var value = _lineHashList[srcLine]; + private int _FindSimilarLine (int srcLine, int startLine) + { + var value = _lineHashList[srcLine]; - var num = _lineHashList.Count; - for (var i = startLine; i < num; ++i) + var num = _lineHashList.Count; + for (var i = startLine; i < num; ++i) + { + if (Math.Abs(_lineHashList[i] - value) < 3) { - if (Math.Abs(_lineHashList[i] - value) < 3) - { - return i; - } + return i; } - - return -1; } - // int[,] similarCache; + return -1; + } + + // int[,] similarCache; + + private void ResetCache (int num) + { + //this.similarCache = new int[num, num]; + //for (int i = 0; i < num; ++i) + //{ + // for (int j = 0; j < num; j++) + // { + // this.similarCache[i, j] = -1; + // } + //} + } + + private int FindSimilarLine (int srcLine, int startLine, Dictionary processedLinesDict) + { + var threshold = _patternArgs.Fuzzy; + + var prepared = false; + Regex regex = null; + Regex regex2 = null; + string msgToFind = null; + CultureInfo culture = CultureInfo.CurrentCulture; - private void ResetCache (int num) + var num = _logFileReader.LineCount; + for (var i = startLine; i < num; ++i) { - //this.similarCache = new int[num, num]; - //for (int i = 0; i < num; ++i) + if (processedLinesDict.ContainsKey(i)) + { + continue; + } + + //if (this.similarCache[srcLine, i] != -1) //{ - // for (int j = 0; j < num; j++) + // if (this.similarCache[srcLine, i] < threshold) // { - // this.similarCache[i, j] = -1; + // return i; // } //} - } - - private int FindSimilarLine (int srcLine, int startLine, Dictionary processedLinesDict) - { - var threshold = _patternArgs.Fuzzy; - - var prepared = false; - Regex regex = null; - Regex regex2 = null; - string msgToFind = null; - CultureInfo culture = CultureInfo.CurrentCulture; - - var num = _logFileReader.LineCount; - for (var i = startLine; i < num; ++i) + //else { - if (processedLinesDict.ContainsKey(i)) + if (!prepared) { - continue; + msgToFind = GetMsgForLine(srcLine); + regex = new Regex("\\d"); + regex2 = new Regex("\\W"); + msgToFind = msgToFind.ToLower(culture); + msgToFind = regex.Replace(msgToFind, "0"); + msgToFind = regex2.Replace(msgToFind, " "); + prepared = true; } - //if (this.similarCache[srcLine, i] != -1) - //{ - // if (this.similarCache[srcLine, i] < threshold) - // { - // return i; - // } - //} - //else + var msg = GetMsgForLine(i); + if (msg != null) { - if (!prepared) + msg = regex.Replace(msg, "0"); + msg = regex2.Replace(msg, " "); + var lenDiff = Math.Abs(msg.Length - msgToFind.Length); + if (lenDiff > threshold) { - msgToFind = GetMsgForLine(srcLine); - regex = new Regex("\\d"); - regex2 = new Regex("\\W"); - msgToFind = msgToFind.ToLower(culture); - msgToFind = regex.Replace(msgToFind, "0"); - msgToFind = regex2.Replace(msgToFind, " "); - prepared = true; + //this.similarCache[srcLine, i] = lenDiff; + continue; } - var msg = GetMsgForLine(i); - if (msg != null) + msg = msg.ToLower(culture); + var distance = Util.YetiLevenshtein(msgToFind, msg); + //this.similarCache[srcLine, i] = distance; + if (distance < threshold) { - msg = regex.Replace(msg, "0"); - msg = regex2.Replace(msg, " "); - var lenDiff = Math.Abs(msg.Length - msgToFind.Length); - if (lenDiff > threshold) - { - //this.similarCache[srcLine, i] = lenDiff; - continue; - } - - msg = msg.ToLower(culture); - var distance = Util.YetiLevenshtein(msgToFind, msg); - //this.similarCache[srcLine, i] = distance; - if (distance < threshold) - { - return i; - } + return i; } } } - - return -1; } - private string GetMsgForLine (int i) + return -1; + } + + private string GetMsgForLine (int i) + { + ILogLine line = _logFileReader.GetLogLine(i); + ILogLineColumnizer columnizer = CurrentColumnizer; + ColumnizerCallback callback = new(this); + IColumnizedLogLine cols = columnizer.SplitLine(callback, line); + return cols.ColumnValues.Last().FullValue; + } + + private void ChangeRowHeight (bool decrease) + { + var rowNum = dataGridView.CurrentCellAddress.Y; + if (rowNum < 0 || rowNum >= dataGridView.RowCount) { - ILogLine line = _logFileReader.GetLogLine(i); - ILogLineColumnizer columnizer = CurrentColumnizer; - ColumnizerCallback callback = new(this); - IColumnizedLogLine cols = columnizer.SplitLine(callback, line); - return cols.ColumnValues.Last().FullValue; + return; } - private void ChangeRowHeight (bool decrease) + if (decrease) { - var rowNum = dataGridView.CurrentCellAddress.Y; - if (rowNum < 0 || rowNum >= dataGridView.RowCount) + if (!_rowHeightList.ContainsKey(rowNum)) { return; } - - if (decrease) - { - if (!_rowHeightList.ContainsKey(rowNum)) - { - return; - } - else - { - RowHeightEntry entry = _rowHeightList[rowNum]; - entry.Height -= _lineHeight; - if (entry.Height <= _lineHeight) - { - _rowHeightList.Remove(rowNum); - } - } - } else { - RowHeightEntry entry; - if (!_rowHeightList.ContainsKey(rowNum)) - { - entry = new RowHeightEntry(); - entry.LineNum = rowNum; - entry.Height = _lineHeight; - _rowHeightList[rowNum] = entry; - } - else + RowHeightEntry entry = _rowHeightList[rowNum]; + entry.Height -= _lineHeight; + if (entry.Height <= _lineHeight) { - entry = _rowHeightList[rowNum]; + _rowHeightList.Remove(rowNum); } - - entry.Height += _lineHeight; - } - - dataGridView.UpdateRowHeightInfo(rowNum, false); - if (rowNum == dataGridView.RowCount - 1 && _guiStateArgs.FollowTail) - { - dataGridView.FirstDisplayedScrollingRowIndex = rowNum; } - - dataGridView.Refresh(); } - - private int GetRowHeight (int rowNum) + else { - if (_rowHeightList.ContainsKey(rowNum)) + RowHeightEntry entry; + if (!_rowHeightList.ContainsKey(rowNum)) { - return _rowHeightList[rowNum].Height; + entry = new RowHeightEntry(); + entry.LineNum = rowNum; + entry.Height = _lineHeight; + _rowHeightList[rowNum] = entry; } else { - return _lineHeight; + entry = _rowHeightList[rowNum]; } + + entry.Height += _lineHeight; } - private void AddBookmarkAtLineSilently (int lineNum) + dataGridView.UpdateRowHeightInfo(rowNum, false); + if (rowNum == dataGridView.RowCount - 1 && _guiStateArgs.FollowTail) { - if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - _bookmarkProvider.AddBookmark(new Bookmark(lineNum)); - } + dataGridView.FirstDisplayedScrollingRowIndex = rowNum; } - private void AddBookmarkAndEditComment () - { - var lineNum = dataGridView.CurrentCellAddress.Y; - if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - ToggleBookmark(); - } + dataGridView.Refresh(); + } - BookmarkComment(_bookmarkProvider.GetBookmarkForLine(lineNum)); + private int GetRowHeight (int rowNum) + { + if (_rowHeightList.ContainsKey(rowNum)) + { + return _rowHeightList[rowNum].Height; } - - private void AddBookmarkComment (string text) + else { - var lineNum = dataGridView.CurrentCellAddress.Y; - Bookmark bookmark; - if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - _bookmarkProvider.AddBookmark(bookmark = new Bookmark(lineNum)); - } - else - { - bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); - } + return _lineHeight; + } + } - bookmark.Text += text; - dataGridView.Refresh(); - filterGridView.Refresh(); - OnBookmarkTextChanged(bookmark); + private void AddBookmarkAtLineSilently (int lineNum) + { + if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) + { + _bookmarkProvider.AddBookmark(new Bookmark(lineNum)); } + } - private void MarkCurrentFilterRange () + private void AddBookmarkAndEditComment () + { + var lineNum = dataGridView.CurrentCellAddress.Y; + if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) { - _filterParams.RangeSearchText = filterRangeComboBox.Text; - ColumnizerCallback callback = new(this); - RangeFinder rangeFinder = new(_filterParams, callback); - Core.Entities.Range range = rangeFinder.FindRange(dataGridView.CurrentCellAddress.Y); - if (range != null) - { - SetCellSelectionMode(false); - _noSelectionUpdates = true; - for (var i = range.StartLine; i <= range.EndLine; ++i) - { - dataGridView.Rows[i].Selected = true; - } + ToggleBookmark(); + } - _noSelectionUpdates = false; - UpdateSelectionDisplay(); - } + BookmarkComment(_bookmarkProvider.GetBookmarkForLine(lineNum)); + } + + private void AddBookmarkComment (string text) + { + var lineNum = dataGridView.CurrentCellAddress.Y; + Bookmark bookmark; + if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) + { + _bookmarkProvider.AddBookmark(bookmark = new Bookmark(lineNum)); } + else + { + bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); + } + + bookmark.Text += text; + dataGridView.Refresh(); + filterGridView.Refresh(); + OnBookmarkTextChanged(bookmark); + } - private void RemoveTempHighlights () + private void MarkCurrentFilterRange () + { + _filterParams.RangeSearchText = filterRangeComboBox.Text; + ColumnizerCallback callback = new(this); + RangeFinder rangeFinder = new(_filterParams, callback); + Core.Entities.Range range = rangeFinder.FindRange(dataGridView.CurrentCellAddress.Y); + if (range != null) { - lock (_tempHighlightEntryListLock) + SetCellSelectionMode(false); + _noSelectionUpdates = true; + for (var i = range.StartLine; i <= range.EndLine; ++i) { - _tempHighlightEntryList.Clear(); + dataGridView.Rows[i].Selected = true; } - RefreshAllGrids(); + _noSelectionUpdates = false; + UpdateSelectionDisplay(); } + } - private void ToggleHighlightPanel (bool open) + private void RemoveTempHighlights () + { + lock (_tempHighlightEntryListLock) { - highlightSplitContainer.Panel2Collapsed = !open; - btnToggleHighlightPanel.Image = open - ? new Bitmap(_panelCloseButtonImage, new Size(btnToggleHighlightPanel.Size.Height, btnToggleHighlightPanel.Size.Height)) - : new Bitmap(_panelOpenButtonImage, new Size(btnToggleHighlightPanel.Size.Height, btnToggleHighlightPanel.Size.Height)); + _tempHighlightEntryList.Clear(); } - private void SetBookmarksForSelectedFilterLines () - { - lock (_filterResultList) - { - foreach (DataGridViewRow row in filterGridView.SelectedRows) - { - var lineNum = _filterResultList[row.Index]; - AddBookmarkAtLineSilently(lineNum); - } - } + RefreshAllGrids(); + } - dataGridView.Refresh(); - filterGridView.Refresh(); - OnBookmarkAdded(); - } + private void ToggleHighlightPanel (bool open) + { + highlightSplitContainer.Panel2Collapsed = !open; + btnToggleHighlightPanel.Image = open + ? new Bitmap(_panelCloseButtonImage, new Size(btnToggleHighlightPanel.Size.Height, btnToggleHighlightPanel.Size.Height)) + : new Bitmap(_panelOpenButtonImage, new Size(btnToggleHighlightPanel.Size.Height, btnToggleHighlightPanel.Size.Height)); + } - private void SetDefaultHighlightGroup () + private void SetBookmarksForSelectedFilterLines () + { + lock (_filterResultList) { - HighlightGroup group = _parentLogTabWin.FindHighlightGroupByFileMask(FileName); - if (group != null) - { - SetCurrentHighlightGroup(group.GroupName); - } - else + foreach (DataGridViewRow row in filterGridView.SelectedRows) { - SetCurrentHighlightGroup("[Default]"); + var lineNum = _filterResultList[row.Index]; + AddBookmarkAtLineSilently(lineNum); } } - private void HandleChangedFilterOnLoadSetting () + dataGridView.Refresh(); + filterGridView.Refresh(); + OnBookmarkAdded(); + } + + private void SetDefaultHighlightGroup () + { + HighlightGroup group = _parentLogTabWin.FindHighlightGroupByFileMask(FileName); + if (group != null) + { + SetCurrentHighlightGroup(group.GroupName); + } + else { - _parentLogTabWin.Preferences.isFilterOnLoad = filterOnLoadCheckBox.Checked; - _parentLogTabWin.Preferences.isAutoHideFilterList = hideFilterListOnLoadCheckBox.Checked; - OnFilterListChanged(this); + SetCurrentHighlightGroup("[Default]"); } + } - private void FireCancelHandlers () + private void HandleChangedFilterOnLoadSetting () + { + _parentLogTabWin.Preferences.isFilterOnLoad = filterOnLoadCheckBox.Checked; + _parentLogTabWin.Preferences.isAutoHideFilterList = hideFilterListOnLoadCheckBox.Checked; + OnFilterListChanged(this); + } + + private void FireCancelHandlers () + { + lock (_cancelHandlerList) { - lock (_cancelHandlerList) + foreach (var handler in _cancelHandlerList) { - foreach (var handler in _cancelHandlerList) - { - handler.EscapePressed(); - } + handler.EscapePressed(); } } + } - private void SyncOtherWindows (DateTime timestamp) + private void SyncOtherWindows (DateTime timestamp) + { + lock (_timeSyncListLock) { - lock (_timeSyncListLock) - { - TimeSyncList?.NavigateToTimestamp(timestamp, this); - } + TimeSyncList?.NavigateToTimestamp(timestamp, this); } + } - private void AddSlaveToTimesync (LogWindow slave) + private void AddSlaveToTimesync (LogWindow slave) + { + lock (_timeSyncListLock) { - lock (_timeSyncListLock) + if (TimeSyncList == null) { - if (TimeSyncList == null) + if (slave.TimeSyncList == null) { - if (slave.TimeSyncList == null) - { - TimeSyncList = new TimeSyncList(); - TimeSyncList.AddWindow(this); - } - else - { - TimeSyncList = slave.TimeSyncList; - } - - var currentLineNum = dataGridView.CurrentCellAddress.Y; - var refLine = currentLineNum; - DateTime timeStamp = GetTimestampForLine(ref refLine, true); - if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel) - { - TimeSyncList.CurrentTimestamp = timeStamp; - } + TimeSyncList = new TimeSyncList(); + TimeSyncList.AddWindow(this); + } + else + { + TimeSyncList = slave.TimeSyncList; + } - TimeSyncList.WindowRemoved += OnTimeSyncListWindowRemoved; + var currentLineNum = dataGridView.CurrentCellAddress.Y; + var refLine = currentLineNum; + DateTime timeStamp = GetTimestampForLine(ref refLine, true); + if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel) + { + TimeSyncList.CurrentTimestamp = timeStamp; } - } - slave.AddToTimeSync(this); - OnSyncModeChanged(); + TimeSyncList.WindowRemoved += OnTimeSyncListWindowRemoved; + } } - private void FreeSlaveFromTimesync (LogWindow slave) - { - slave.FreeFromTimeSync(); - } + slave.AddToTimeSync(this); + OnSyncModeChanged(); + } - private void OnSyncModeChanged () - { - SyncModeChanged?.Invoke(this, new SyncModeEventArgs(IsTimeSynced)); - } + private void FreeSlaveFromTimesync (LogWindow slave) + { + slave.FreeFromTimeSync(); + } - private void AddSearchHitHighlightEntry (SearchParams para) - { - HighlightEntry he = new() - { - SearchText = para.SearchText, - ForegroundColor = Color.Red, - BackgroundColor = Color.Yellow, - IsRegEx = para.IsRegex, - IsCaseSensitive = para.IsCaseSensitive, - IsLedSwitch = false, - IsStopTail = false, - IsSetBookmark = false, - IsActionEntry = false, - ActionEntry = null, - IsWordMatch = true, - IsSearchHit = true - }; + private void OnSyncModeChanged () + { + SyncModeChanged?.Invoke(this, new SyncModeEventArgs(IsTimeSynced)); + } - lock (_tempHighlightEntryListLock) - { - _tempHighlightEntryList.Add(he); - } + private void AddSearchHitHighlightEntry (SearchParams para) + { + HighlightEntry he = new() + { + SearchText = para.SearchText, + ForegroundColor = Color.Red, + BackgroundColor = Color.Yellow, + IsRegEx = para.IsRegex, + IsCaseSensitive = para.IsCaseSensitive, + IsLedSwitch = false, + IsStopTail = false, + IsSetBookmark = false, + IsActionEntry = false, + ActionEntry = null, + IsWordMatch = true, + IsSearchHit = true + }; - RefreshAllGrids(); + lock (_tempHighlightEntryListLock) + { + _tempHighlightEntryList.Add(he); } - private void RemoveAllSearchHighlightEntries () + RefreshAllGrids(); + } + + private void RemoveAllSearchHighlightEntries () + { + lock (_tempHighlightEntryListLock) { - lock (_tempHighlightEntryListLock) + List newList = []; + foreach (HighlightEntry he in _tempHighlightEntryList) { - List newList = []; - foreach (HighlightEntry he in _tempHighlightEntryList) + if (!he.IsSearchHit) { - if (!he.IsSearchHit) - { - newList.Add(he); - } + newList.Add(he); } - - _tempHighlightEntryList = newList; } - RefreshAllGrids(); + _tempHighlightEntryList = newList; } - private DataGridViewColumn GetColumnByName (BufferedDataGridView dataGridView, string name) + RefreshAllGrids(); + } + + private DataGridViewColumn GetColumnByName (BufferedDataGridView dataGridView, string name) + { + foreach (DataGridViewColumn col in dataGridView.Columns) { - foreach (DataGridViewColumn col in dataGridView.Columns) + if (col.HeaderText.Equals(name)) { - if (col.HeaderText.Equals(name)) - { - return col; - } + return col; } - - return null; } - private void SelectColumn () + return null; + } + + private void SelectColumn () + { + var colName = columnComboBox.SelectedItem as string; + DataGridViewColumn col = GetColumnByName(dataGridView, colName); + if (col != null && !col.Frozen) { - var colName = columnComboBox.SelectedItem as string; - DataGridViewColumn col = GetColumnByName(dataGridView, colName); - if (col != null && !col.Frozen) + dataGridView.FirstDisplayedScrollingColumnIndex = col.Index; + var currentLine = dataGridView.CurrentCellAddress.Y; + if (currentLine >= 0) { - dataGridView.FirstDisplayedScrollingColumnIndex = col.Index; - var currentLine = dataGridView.CurrentCellAddress.Y; - if (currentLine >= 0) - { - dataGridView.CurrentCell = dataGridView.Rows[dataGridView.CurrentCellAddress.Y].Cells[col.Index]; - } + dataGridView.CurrentCell = dataGridView.Rows[dataGridView.CurrentCellAddress.Y].Cells[col.Index]; } } + } - #endregion + #endregion - } } \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs index 458839c4..20e1451e 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs @@ -1,4 +1,6 @@ -using LogExpert.Classes.Filter; +using System.Text; + +using LogExpert.Classes.Filter; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Bookmark; using LogExpert.Core.Classes.Columnizer; @@ -10,1833 +12,1831 @@ using LogExpert.Core.EventArguments; using LogExpert.Dialogs; using LogExpert.UI.Entities; -using System.Text; -namespace LogExpert.UI.Controls.LogWindow +namespace LogExpert.UI.Controls.LogWindow; + +partial class LogWindow { - partial class LogWindow + #region Public methods + + public void LoadFile (string fileName, EncodingOptions encodingOptions) { - #region Public methods + EnterLoadFileStatus(); - public void LoadFile(string fileName, EncodingOptions encodingOptions) + if (fileName != null) { - EnterLoadFileStatus(); + FileName = fileName; + EncodingOptions = encodingOptions; - if (fileName != null) + if (_logFileReader != null) { - FileName = fileName; - EncodingOptions = encodingOptions; - - if (_logFileReader != null) - { - _logFileReader.StopMonitoringAsync(); - UnRegisterLogFileReaderEvents(); - } + _logFileReader.StopMonitoringAsync(); + UnRegisterLogFileReaderEvents(); + } - // - // isUsingDefaultColumnizer is to enable automatically find the best columnizer. - // When a new log file is opened, and no Columnizer can be chose by file mask, - // this flag will enable find a columnizer automatically. - // Current solution is not elegant. - // Since the refactory will involving a lot of work, we can plan it in the future. - // One possible solution is, using raw file stream to read the sample lines to help - // the ColumnizerPicker to determine the priority. - // - var isUsingDefaultColumnizer = false; - if (!LoadPersistenceOptions()) + // + // isUsingDefaultColumnizer is to enable automatically find the best columnizer. + // When a new log file is opened, and no Columnizer can be chose by file mask, + // this flag will enable find a columnizer automatically. + // Current solution is not elegant. + // Since the refactory will involving a lot of work, we can plan it in the future. + // One possible solution is, using raw file stream to read the sample lines to help + // the ColumnizerPicker to determine the priority. + // + var isUsingDefaultColumnizer = false; + if (!LoadPersistenceOptions()) + { + if (!IsTempFile) { - if (!IsTempFile) + ILogLineColumnizer columnizer = FindColumnizer(); + if (columnizer != null) { - ILogLineColumnizer columnizer = FindColumnizer(); - if (columnizer != null) + if (_reloadMemento == null) { - if (_reloadMemento == null) - { - //TODO this needs to be refactored - var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - columnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); - } - } - else - { - isUsingDefaultColumnizer = true; + columnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); } - PreSelectColumnizer(columnizer); } - SetDefaultHighlightGroup(); + else + { + isUsingDefaultColumnizer = true; + } + PreSelectColumnizer(columnizer); } + SetDefaultHighlightGroup(); + } - // this may be set after loading persistence data - if (_fileNames != null && IsMultiFile) - { - LoadFilesAsMulti(_fileNames, EncodingOptions); - return; - } + // this may be set after loading persistence data + if (_fileNames != null && IsMultiFile) + { + LoadFilesAsMulti(_fileNames, EncodingOptions); + return; + } - _columnCache = new ColumnCache(); + _columnCache = new ColumnCache(); - try - { - _logFileReader = new(fileName, EncodingOptions, IsMultiFile, Preferences.bufferCount, Preferences.linesPerBuffer, _multiFileOptions, PluginRegistry.PluginRegistry.Instance) - { - UseNewReader = !Preferences.useLegacyReader - }; - } - catch (LogFileException lfe) + try + { + _logFileReader = new(fileName, EncodingOptions, IsMultiFile, Preferences.bufferCount, Preferences.linesPerBuffer, _multiFileOptions, PluginRegistry.PluginRegistry.Instance) { - _logger.Error(lfe); - MessageBox.Show("Cannot load file\n" + lfe.Message, "LogExpert"); - _ = BeginInvoke(new FunctionWith1BoolParam(Close), true); - _isLoadError = true; - return; - } + UseNewReader = !Preferences.useLegacyReader + }; + } + catch (LogFileException lfe) + { + _logger.Error(lfe); + MessageBox.Show("Cannot load file\n" + lfe.Message, "LogExpert"); + _ = BeginInvoke(new FunctionWith1BoolParam(Close), true); + _isLoadError = true; + return; + } - if (CurrentColumnizer is ILogLineXmlColumnizer xmlColumnizer) - { - _logFileReader.IsXmlMode = true; - _logFileReader.XmlLogConfig = xmlColumnizer.GetXmlLogConfiguration(); - } + if (CurrentColumnizer is ILogLineXmlColumnizer xmlColumnizer) + { + _logFileReader.IsXmlMode = true; + _logFileReader.XmlLogConfig = xmlColumnizer.GetXmlLogConfiguration(); + } - if (_forcedColumnizerForLoading != null) - { - CurrentColumnizer = _forcedColumnizerForLoading; - } + if (_forcedColumnizerForLoading != null) + { + CurrentColumnizer = _forcedColumnizerForLoading; + } - if (CurrentColumnizer is IPreProcessColumnizer processColumnizer) - { - _logFileReader.PreProcessColumnizer = processColumnizer; - } - else - { - _logFileReader.PreProcessColumnizer = null; - } + if (CurrentColumnizer is IPreProcessColumnizer processColumnizer) + { + _logFileReader.PreProcessColumnizer = processColumnizer; + } + else + { + _logFileReader.PreProcessColumnizer = null; + } - RegisterLogFileReaderEvents(); - _logger.Info($"Loading logfile: {fileName}"); - _logFileReader.StartMonitoring(); + RegisterLogFileReaderEvents(); + _logger.Info($"Loading logfile: {fileName}"); + _logFileReader.StartMonitoring(); - if (isUsingDefaultColumnizer) + if (isUsingDefaultColumnizer) + { + if (Preferences.autoPick) { - if (Preferences.autoPick) - { - ILogLineColumnizer newColumnizer = ColumnizerPicker.FindBetterColumnizer(FileName, _logFileReader, CurrentColumnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + ILogLineColumnizer newColumnizer = ColumnizerPicker.FindBetterColumnizer(FileName, _logFileReader, CurrentColumnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - if (newColumnizer != null) - { - _logger.Debug($"Picked new columnizer '{newColumnizer}'"); + if (newColumnizer != null) + { + _logger.Debug($"Picked new columnizer '{newColumnizer}'"); - PreSelectColumnizer(newColumnizer); - } + PreSelectColumnizer(newColumnizer); } } } } + } - public void LoadFilesAsMulti(string[] fileNames, EncodingOptions encodingOptions) - { - _logger.Info("Loading given files as MultiFile:"); + public void LoadFilesAsMulti (string[] fileNames, EncodingOptions encodingOptions) + { + _logger.Info("Loading given files as MultiFile:"); - EnterLoadFileStatus(); + EnterLoadFileStatus(); - foreach (var name in fileNames) - { - _logger.Info("File: {0}", name); - } + foreach (var name in fileNames) + { + _logger.Info("File: {0}", name); + } - if (_logFileReader != null) - { - _logFileReader.StopMonitoring(); - UnRegisterLogFileReaderEvents(); - } + if (_logFileReader != null) + { + _logFileReader.StopMonitoring(); + UnRegisterLogFileReaderEvents(); + } - EncodingOptions = encodingOptions; - _columnCache = new ColumnCache(); + EncodingOptions = encodingOptions; + _columnCache = new ColumnCache(); - _logFileReader = new(fileNames, EncodingOptions, Preferences.bufferCount, Preferences.linesPerBuffer, _multiFileOptions, PluginRegistry.PluginRegistry.Instance) - { - UseNewReader = !Preferences.useLegacyReader - }; + _logFileReader = new(fileNames, EncodingOptions, Preferences.bufferCount, Preferences.linesPerBuffer, _multiFileOptions, PluginRegistry.PluginRegistry.Instance) + { + UseNewReader = !Preferences.useLegacyReader + }; - RegisterLogFileReaderEvents(); - _logFileReader.StartMonitoring(); - FileName = fileNames[^1]; - _fileNames = fileNames; - IsMultiFile = true; - //if (this.isTempFile) - // this.Text = this.tempTitleName; - //else - // this.Text = Util.GetNameFromPath(this.FileName); - } + RegisterLogFileReaderEvents(); + _logFileReader.StartMonitoring(); + FileName = fileNames[^1]; + _fileNames = fileNames; + IsMultiFile = true; + //if (this.isTempFile) + // this.Text = this.tempTitleName; + //else + // this.Text = Util.GetNameFromPath(this.FileName); + } - public string SavePersistenceData(bool force) + public string SavePersistenceData (bool force) + { + if (!force) { - if (!force) - { - if (!Preferences.saveSessions) - { - return null; - } - } - - if (IsTempFile || _isLoadError) + if (!Preferences.saveSessions) { return null; } + } - try - { - PersistenceData persistenceData = GetPersistenceData(); + if (IsTempFile || _isLoadError) + { + return null; + } - if (ForcedPersistenceFileName == null) - { - return Persister.SavePersistenceData(FileName, persistenceData, Preferences); - } + try + { + PersistenceData persistenceData = GetPersistenceData(); - return Persister.SavePersistenceDataWithFixedName(ForcedPersistenceFileName, persistenceData); - } - catch (IOException ex) - { - _logger.Error(ex, "Error saving persistence: "); - } - catch (Exception e) + if (ForcedPersistenceFileName == null) { - MessageBox.Show($"Unexpected error while saving persistence: {e.Message}"); + return Persister.SavePersistenceData(FileName, persistenceData, Preferences); } - return null; + return Persister.SavePersistenceDataWithFixedName(ForcedPersistenceFileName, persistenceData); + } + catch (IOException ex) + { + _logger.Error(ex, "Error saving persistence: "); + } + catch (Exception e) + { + MessageBox.Show($"Unexpected error while saving persistence: {e.Message}"); } - public PersistenceData GetPersistenceData() - { - PersistenceData persistenceData = new() - { - bookmarkList = _bookmarkProvider.BookmarkList, - rowHeightList = _rowHeightList, - multiFile = IsMultiFile, - multiFilePattern = _multiFileOptions.FormatPattern, - multiFileMaxDays = _multiFileOptions.MaxDayTry, - currentLine = dataGridView.CurrentCellAddress.Y, - firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex, - filterVisible = !splitContainerLogWindow.Panel2Collapsed, - filterAdvanced = !advancedFilterSplitContainer.Panel1Collapsed, - filterPosition = splitContainerLogWindow.SplitterDistance, - followTail = _guiStateArgs.FollowTail, - fileName = FileName, - tabName = Text, - sessionFileName = SessionFileName, - columnizerName = CurrentColumnizer.GetName(), - lineCount = _logFileReader.LineCount - }; + return null; + } - _filterParams.IsFilterTail = filterTailCheckBox.Checked; // this option doesnt need a press on 'search' + public PersistenceData GetPersistenceData () + { + PersistenceData persistenceData = new() + { + bookmarkList = _bookmarkProvider.BookmarkList, + rowHeightList = _rowHeightList, + multiFile = IsMultiFile, + multiFilePattern = _multiFileOptions.FormatPattern, + multiFileMaxDays = _multiFileOptions.MaxDayTry, + currentLine = dataGridView.CurrentCellAddress.Y, + firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex, + filterVisible = !splitContainerLogWindow.Panel2Collapsed, + filterAdvanced = !advancedFilterSplitContainer.Panel1Collapsed, + filterPosition = splitContainerLogWindow.SplitterDistance, + followTail = _guiStateArgs.FollowTail, + fileName = FileName, + tabName = Text, + sessionFileName = SessionFileName, + columnizerName = CurrentColumnizer.GetName(), + lineCount = _logFileReader.LineCount + }; + + _filterParams.IsFilterTail = filterTailCheckBox.Checked; // this option doesnt need a press on 'search' + + if (Preferences.saveFilters) + { + List filterList = [_filterParams]; + persistenceData.filterParamsList = filterList; + + foreach (FilterPipe filterPipe in _filterPipeList) + { + FilterTabData data = new() + { + PersistenceData = filterPipe.OwnLogWindow.GetPersistenceData(), + FilterParams = filterPipe.FilterParams + }; + persistenceData.filterTabDataList.Add(data); + } + } - if (Preferences.saveFilters) - { - List filterList = [_filterParams]; - persistenceData.filterParamsList = filterList; + if (_currentHighlightGroup != null) + { + persistenceData.highlightGroupName = _currentHighlightGroup.GroupName; + } - foreach (FilterPipe filterPipe in _filterPipeList) - { - FilterTabData data = new() - { - PersistenceData = filterPipe.OwnLogWindow.GetPersistenceData(), - FilterParams = filterPipe.FilterParams - }; - persistenceData.filterTabDataList.Add(data); - } - } + if (_fileNames != null && IsMultiFile) + { + persistenceData.multiFileNames.AddRange(_fileNames); + } - if (_currentHighlightGroup != null) - { - persistenceData.highlightGroupName = _currentHighlightGroup.GroupName; - } + //persistenceData.showBookmarkCommentColumn = this.bookmarkWindow.ShowBookmarkCommentColumn; + persistenceData.filterSaveListVisible = !highlightSplitContainer.Panel2Collapsed; + persistenceData.encoding = _logFileReader.CurrentEncoding; - if (_fileNames != null && IsMultiFile) - { - persistenceData.multiFileNames.AddRange(_fileNames); - } + return persistenceData; + } + + public void Close (bool dontAsk) + { + Preferences.askForClose = !dontAsk; + Close(); + } - //persistenceData.showBookmarkCommentColumn = this.bookmarkWindow.ShowBookmarkCommentColumn; - persistenceData.filterSaveListVisible = !highlightSplitContainer.Panel2Collapsed; - persistenceData.encoding = _logFileReader.CurrentEncoding; + public void CloseLogWindow () + { + StopTimespreadThread(); + StopTimestampSyncThread(); + StopLogEventWorkerThread(); + _shouldCancel = true; - return persistenceData; + if (_logFileReader != null) + { + UnRegisterLogFileReaderEvents(); + _logFileReader.StopMonitoringAsync(); + //this.logFileReader.DeleteAllContent(); } - public void Close(bool dontAsk) + if (_isLoading) { - Preferences.askForClose = !dontAsk; - Close(); + _waitingForClose = true; } - public void CloseLogWindow() + if (IsTempFile) { - StopTimespreadThread(); - StopTimestampSyncThread(); - StopLogEventWorkerThread(); - _shouldCancel = true; + _logger.Info("Deleting temp file {0}", FileName); - if (_logFileReader != null) + try { - UnRegisterLogFileReaderEvents(); - _logFileReader.StopMonitoringAsync(); - //this.logFileReader.DeleteAllContent(); + File.Delete(FileName); } - - if (_isLoading) + catch (IOException e) { - _waitingForClose = true; + _logger.Error(e, "Error while deleting temp file {0}: {1}", FileName, e); } + } - if (IsTempFile) - { - _logger.Info("Deleting temp file {0}", FileName); + FilterPipe?.CloseAndDisconnect(); + DisconnectFilterPipes(); + } - try - { - File.Delete(FileName); - } - catch (IOException e) - { - _logger.Error(e, "Error while deleting temp file {0}: {1}", FileName, e); - } - } + public void WaitForLoadingFinished () + { + _externaLoadingFinishedEvent.WaitOne(); + } - FilterPipe?.CloseAndDisconnect(); - DisconnectFilterPipes(); - } + public void ForceColumnizer (ILogLineColumnizer columnizer) + { + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - public void WaitForLoadingFinished() - { - _externaLoadingFinishedEvent.WaitOne(); - } + _forcedColumnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); + SetColumnizer(_forcedColumnizer); + } - public void ForceColumnizer(ILogLineColumnizer columnizer) - { - //TODO this needs to be refactored - var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + public void ForceColumnizerForLoading (ILogLineColumnizer columnizer) + { + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - _forcedColumnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); - SetColumnizer(_forcedColumnizer); - } + _forcedColumnizerForLoading = ColumnizerPicker.CloneColumnizer(columnizer, directory); + } - public void ForceColumnizerForLoading(ILogLineColumnizer columnizer) - { - //TODO this needs to be refactored - var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + public void PreselectColumnizer (string columnizerName) + { + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - _forcedColumnizerForLoading = ColumnizerPicker.CloneColumnizer(columnizer, directory); - } + ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + PreSelectColumnizer(ColumnizerPicker.CloneColumnizer(columnizer, directory)); + } - public void PreselectColumnizer(string columnizerName) - { - //TODO this needs to be refactored - var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + public void ColumnizerConfigChanged () + { + SetColumnizerInternal(CurrentColumnizer); + } - ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - PreSelectColumnizer(ColumnizerPicker.CloneColumnizer(columnizer, directory)); - } + public void SetColumnizer (ILogLineColumnizer columnizer, BufferedDataGridView gridView) + { + PaintHelper.SetColumnizer(columnizer, gridView); + + gridView.Refresh(); + AutoResizeColumns(gridView); + ApplyFrozenState(gridView); + } - public void ColumnizerConfigChanged() + public IColumn GetCellValue (int rowIndex, int columnIndex) + { + if (columnIndex == 1) { - SetColumnizerInternal(CurrentColumnizer); + return new Column + { + FullValue = (rowIndex + 1).ToString() // line number + }; } - public void SetColumnizer(ILogLineColumnizer columnizer, BufferedDataGridView gridView) + if (columnIndex == 0) // marker column { - PaintHelper.SetColumnizer(columnizer, gridView); - - gridView.Refresh(); - AutoResizeColumns(gridView); - ApplyFrozenState(gridView); + return Column.EmptyColumn; } - public IColumn GetCellValue(int rowIndex, int columnIndex) + try { - if (columnIndex == 1) + IColumnizedLogLine cols = GetColumnsForLine(rowIndex); + if (cols != null && cols.ColumnValues != null) { - return new Column + if (columnIndex <= cols.ColumnValues.Length + 1) { - FullValue = (rowIndex + 1).ToString() // line number - }; - } - - if (columnIndex == 0) // marker column - { - return Column.EmptyColumn; - } + IColumn value = cols.ColumnValues[columnIndex - 2]; - try - { - IColumnizedLogLine cols = GetColumnsForLine(rowIndex); - if (cols != null && cols.ColumnValues != null) - { - if (columnIndex <= cols.ColumnValues.Length + 1) + if (value != null && value.DisplayValue != null) { - IColumn value = cols.ColumnValues[columnIndex - 2]; - - if (value != null && value.DisplayValue != null) - { - return value; - } return value; } + return value; + } - if (columnIndex == 2) - { - return cols.ColumnValues[^1]; - } - - return Column.EmptyColumn; + if (columnIndex == 2) + { + return cols.ColumnValues[^1]; } - } - catch - { + return Column.EmptyColumn; } - + } + catch + { return Column.EmptyColumn; } - public void CellPainting(BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) + return Column.EmptyColumn; + } + + public void CellPainting (BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) + { + if (rowIndex < 0 || e.ColumnIndex < 0) { - if (rowIndex < 0 || e.ColumnIndex < 0) - { - e.Handled = false; - return; - } + e.Handled = false; + return; + } - ILogLine line = _logFileReader.GetLogLineWithWait(rowIndex).Result; + ILogLine line = _logFileReader.GetLogLineWithWait(rowIndex).Result; - if (line != null) + if (line != null) + { + HighlightEntry entry = FindFirstNoWordMatchHilightEntry(line); + e.Graphics.SetClip(e.CellBounds); + + if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) { - HighlightEntry entry = FindFirstNoWordMatchHilightEntry(line); - e.Graphics.SetClip(e.CellBounds); + Color backColor = ColorMode.BackgroundColor; - if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) + Brush brush; + + if (gridView.Focused) + { + brush = new SolidBrush(e.CellStyle.SelectionBackColor); + } + else { - Color backColor = ColorMode.BackgroundColor; + Color color = backColor; + brush = new SolidBrush(color); + } - Brush brush; + e.Graphics.FillRectangle(brush, e.CellBounds); + brush.Dispose(); + } + else + { + Color bgColor = ColorMode.DockBackgroundColor; - if (gridView.Focused) - { - brush = new SolidBrush(e.CellStyle.SelectionBackColor); - } - else + if (!DebugOptions.DisableWordHighlight) + { + if (entry != null) { - Color color = backColor; - brush = new SolidBrush(color); + bgColor = entry.BackgroundColor; } - - e.Graphics.FillRectangle(brush, e.CellBounds); - brush.Dispose(); } else { - Color bgColor = ColorMode.DockBackgroundColor; - - if (!DebugOptions.DisableWordHighlight) - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - else + if (entry != null) { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } + bgColor = entry.BackgroundColor; } + } - e.CellStyle.BackColor = bgColor; + e.CellStyle.BackColor = bgColor; - e.PaintBackground(e.ClipBounds, false); - } + e.PaintBackground(e.ClipBounds, false); + } - if (DebugOptions.DisableWordHighlight) - { - e.PaintContent(e.CellBounds); - } - else - { - PaintCell(e, gridView, false, entry); - } + if (DebugOptions.DisableWordHighlight) + { + e.PaintContent(e.CellBounds); + } + else + { + PaintCell(e, gridView, false, entry); + } - if (e.ColumnIndex == 0) + if (e.ColumnIndex == 0) + { + if (_bookmarkProvider.IsBookmarkAtLine(rowIndex)) { - if (_bookmarkProvider.IsBookmarkAtLine(rowIndex)) + Rectangle r; // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); + r = e.CellBounds; + r.Inflate(-2, -2); + Brush brush = new SolidBrush(BookmarkColor); + e.Graphics.FillRectangle(brush, r); + brush.Dispose(); + Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(rowIndex); + + if (bookmark.Text.Length > 0) { - Rectangle r; // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); - r = e.CellBounds; - r.Inflate(-2, -2); - Brush brush = new SolidBrush(BookmarkColor); - e.Graphics.FillRectangle(brush, r); - brush.Dispose(); - Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(rowIndex); - - if (bookmark.Text.Length > 0) + StringFormat format = new() { - StringFormat format = new() - { - LineAlignment = StringAlignment.Center, - Alignment = StringAlignment.Center - }; - Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); - Font font = new("Courier New", Preferences.fontSize, FontStyle.Bold); - e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), - format); - font.Dispose(); - brush2.Dispose(); - } + LineAlignment = StringAlignment.Center, + Alignment = StringAlignment.Center + }; + Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); + Font font = new("Courier New", Preferences.fontSize, FontStyle.Bold); + e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), + format); + font.Dispose(); + brush2.Dispose(); } } - - e.Paint(e.CellBounds, DataGridViewPaintParts.Border); - e.Handled = true; } - } - public void OnDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) - { - var gridView = (BufferedDataGridView)sender; - CellPainting(gridView, e.RowIndex, e); + e.Paint(e.CellBounds, DataGridViewPaintParts.Border); + e.Handled = true; } + } - /// - /// Returns the first HilightEntry that matches the given line - /// - /// - /// - /// - public HighlightEntry FindHighlightEntry(ITextValue line, bool noWordMatches) - { - // first check the temp entries - lock (_tempHighlightEntryListLock) + public void OnDataGridView_CellPainting (object sender, DataGridViewCellPaintingEventArgs e) + { + var gridView = (BufferedDataGridView)sender; + CellPainting(gridView, e.RowIndex, e); + } + + /// + /// Returns the first HilightEntry that matches the given line + /// + /// + /// + /// + public HighlightEntry FindHighlightEntry (ITextValue line, bool noWordMatches) + { + // first check the temp entries + lock (_tempHighlightEntryListLock) + { + foreach (HighlightEntry entry in _tempHighlightEntryList) { - foreach (HighlightEntry entry in _tempHighlightEntryList) + if (noWordMatches && entry.IsWordMatch) { - if (noWordMatches && entry.IsWordMatch) - { - continue; - } - if (CheckHighlightEntryMatch(entry, line)) - { - return entry; - } + continue; } - } - - lock (_currentHighlightGroupLock) - { - foreach (HighlightEntry entry in _currentHighlightGroup.HighlightEntryList) + if (CheckHighlightEntryMatch(entry, line)) { - if (noWordMatches && entry.IsWordMatch) - { - continue; - } - if (CheckHighlightEntryMatch(entry, line)) - { - return entry; - } + return entry; } - return null; } } - public IList FindHighlightMatches(ITextValue column) + lock (_currentHighlightGroupLock) { - IList resultList = new List(); - if (column != null) + foreach (HighlightEntry entry in _currentHighlightGroup.HighlightEntryList) { - lock (_currentHighlightGroupLock) + if (noWordMatches && entry.IsWordMatch) { - GetHighlightEntryMatches(column, _currentHighlightGroup.HighlightEntryList, resultList); + continue; } - lock (_tempHighlightEntryList) + if (CheckHighlightEntryMatch(entry, line)) { - GetHighlightEntryMatches(column, _tempHighlightEntryList, resultList); + return entry; } } - return resultList; + return null; } + } - public void FollowTailChanged(bool isChecked, bool byTrigger) + public IList FindHighlightMatches (ITextValue column) + { + IList resultList = new List(); + if (column != null) { - _guiStateArgs.FollowTail = isChecked; - - if (_guiStateArgs.FollowTail && _logFileReader != null) + lock (_currentHighlightGroupLock) { - if (dataGridView.RowCount >= _logFileReader.LineCount && _logFileReader.LineCount > 0) - { - dataGridView.FirstDisplayedScrollingRowIndex = _logFileReader.LineCount - 1; - } + GetHighlightEntryMatches(column, _currentHighlightGroup.HighlightEntryList, resultList); + } + lock (_tempHighlightEntryList) + { + GetHighlightEntryMatches(column, _tempHighlightEntryList, resultList); } - BeginInvoke(new MethodInvoker(dataGridView.Refresh)); - //this.dataGridView.Refresh(); - _parentLogTabWin.FollowTailChanged(this, isChecked, byTrigger); - SendGuiStateUpdate(); } + return resultList; + } - public void GotoLine(int line) + public void FollowTailChanged (bool isChecked, bool byTrigger) + { + _guiStateArgs.FollowTail = isChecked; + + if (_guiStateArgs.FollowTail && _logFileReader != null) { - if (line >= 0) + if (dataGridView.RowCount >= _logFileReader.LineCount && _logFileReader.LineCount > 0) { - if (line < dataGridView.RowCount) - { - SelectLine(line, false, true); - } - else - { - SelectLine(dataGridView.RowCount - 1, false, true); - } - dataGridView.Focus(); + dataGridView.FirstDisplayedScrollingRowIndex = _logFileReader.LineCount - 1; } } + BeginInvoke(new MethodInvoker(dataGridView.Refresh)); + //this.dataGridView.Refresh(); + _parentLogTabWin.FollowTailChanged(this, isChecked, byTrigger); + SendGuiStateUpdate(); + } - public void StartSearch() + public void GotoLine (int line) + { + if (line >= 0) { - _guiStateArgs.MenuEnabled = false; - GuiStateUpdate(this, _guiStateArgs); - SearchParams searchParams = _parentLogTabWin.SearchParams; - - if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) + if (line < dataGridView.RowCount) { - searchParams.CurrentLine = dataGridView.CurrentCellAddress.Y + 1; + SelectLine(line, false, true); } else { - searchParams.CurrentLine = dataGridView.CurrentCellAddress.Y - 1; + SelectLine(dataGridView.RowCount - 1, false, true); } + dataGridView.Focus(); + } + } + + public void StartSearch () + { + _guiStateArgs.MenuEnabled = false; + GuiStateUpdate(this, _guiStateArgs); + SearchParams searchParams = _parentLogTabWin.SearchParams; - _currentSearchParams = searchParams; // remember for async "not found" messages + if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) + { + searchParams.CurrentLine = dataGridView.CurrentCellAddress.Y + 1; + } + else + { + searchParams.CurrentLine = dataGridView.CurrentCellAddress.Y - 1; + } + + _currentSearchParams = searchParams; // remember for async "not found" messages - _isSearching = true; - _shouldCancel = false; - StatusLineText("Searching... Press ESC to cancel."); + _isSearching = true; + _shouldCancel = false; + StatusLineText("Searching... Press ESC to cancel."); - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = dataGridView.RowCount; - _progressEventArgs.Value = 0; - _progressEventArgs.Visible = true; - SendProgressBarUpdate(); + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = dataGridView.RowCount; + _progressEventArgs.Value = 0; + _progressEventArgs.Visible = true; + SendProgressBarUpdate(); - Task.Run(() => Search(searchParams)).ContinueWith(SearchComplete); + Task.Run(() => Search(searchParams)).ContinueWith(SearchComplete); - RemoveAllSearchHighlightEntries(); - AddSearchHitHighlightEntry(searchParams); + RemoveAllSearchHighlightEntries(); + AddSearchHitHighlightEntry(searchParams); + } + + private void SearchComplete (Task task) + { + if (Disposing) + { + return; } - private void SearchComplete(Task task) + try { - if (Disposing) + Invoke(new MethodInvoker(ResetProgressBar)); + var line = task.Result; + _guiStateArgs.MenuEnabled = true; + GuiStateUpdate(this, _guiStateArgs); + if (line == -1) { return; } - try + dataGridView.Invoke(new SelectLineFx((line1, triggerSyncCall) => SelectLine(line1, triggerSyncCall, true)), line, true); + } + catch (Exception ex) // in the case the windows is already destroyed + { + _logger.Warn(ex); + } + } + + public void SelectLogLine (int line) + { + Invoke(new SelectLineFx((line1, triggerSyncCall) => SelectLine(line1, triggerSyncCall, true)), line, true); + } + + public void SelectAndEnsureVisible (int line, bool triggerSyncCall) + { + try + { + SelectLine(line, triggerSyncCall, false); + + //if (!this.dataGridView.CurrentRow.Displayed) + if (line < dataGridView.FirstDisplayedScrollingRowIndex || line > dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false)) { - Invoke(new MethodInvoker(ResetProgressBar)); - var line = task.Result; - _guiStateArgs.MenuEnabled = true; - GuiStateUpdate(this, _guiStateArgs); - if (line == -1) + dataGridView.FirstDisplayedScrollingRowIndex = line; + for (var i = 0; i < 8 && dataGridView.FirstDisplayedScrollingRowIndex > 0 && line < dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false); ++i) { - return; + dataGridView.FirstDisplayedScrollingRowIndex -= 1; } - dataGridView.Invoke(new SelectLineFx((line1, triggerSyncCall) => SelectLine(line1, triggerSyncCall, true)), line, true); - } - catch (Exception ex) // in the case the windows is already destroyed - { - _logger.Warn(ex); + if (line >= dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false)) + { + dataGridView.FirstDisplayedScrollingRowIndex += 1; + } } + dataGridView.CurrentCell = dataGridView.Rows[line].Cells[0]; } - - public void SelectLogLine(int line) + catch (Exception e) { - Invoke(new SelectLineFx((line1, triggerSyncCall) => SelectLine(line1, triggerSyncCall, true)), line, true); + // In rare situations there seems to be an invalid argument exceptions (or something like this). Concrete location isn't visible in stack + // trace because use of Invoke(). So catch it, and log (better than crashing the app). + _logger.Error(e); } + } - public void SelectAndEnsureVisible(int line, bool triggerSyncCall) + public void OnLogWindowKeyDown (object sender, KeyEventArgs e) + { + if (_isErrorShowing) { - try - { - SelectLine(line, triggerSyncCall, false); + RemoveStatusLineError(); + } - //if (!this.dataGridView.CurrentRow.Displayed) - if (line < dataGridView.FirstDisplayedScrollingRowIndex || line > dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false)) + switch (e.KeyCode) + { + case Keys.F3 when _parentLogTabWin.SearchParams?.SearchText == null || _parentLogTabWin.SearchParams.SearchText.Length == 0: { - dataGridView.FirstDisplayedScrollingRowIndex = line; - for (var i = 0; i < 8 && dataGridView.FirstDisplayedScrollingRowIndex > 0 && line < dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false); ++i) + return; + } + case Keys.F3: + { + _parentLogTabWin.SearchParams.IsFindNext = true; + _parentLogTabWin.SearchParams.IsShiftF3Pressed = (e.Modifiers & Keys.Shift) == Keys.Shift; + StartSearch(); + break; + } + case Keys.Escape: + { + if (_isSearching) { - dataGridView.FirstDisplayedScrollingRowIndex -= 1; + _shouldCancel = true; } - if (line >= dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false)) - { - dataGridView.FirstDisplayedScrollingRowIndex += 1; - } + FireCancelHandlers(); + RemoveAllSearchHighlightEntries(); + break; } - dataGridView.CurrentCell = dataGridView.Rows[line].Cells[0]; - } - catch (Exception e) - { - // In rare situations there seems to be an invalid argument exceptions (or something like this). Concrete location isn't visible in stack - // trace because use of Invoke(). So catch it, and log (better than crashing the app). - _logger.Error(e); - } - } - - public void OnLogWindowKeyDown(object sender, KeyEventArgs e) - { - if (_isErrorShowing) - { - RemoveStatusLineError(); - } + case Keys.E when (e.Modifiers & Keys.Control) == Keys.Control: + { + StartEditMode(); - switch (e.KeyCode) - { - case Keys.F3 when _parentLogTabWin.SearchParams?.SearchText == null || _parentLogTabWin.SearchParams.SearchText.Length == 0: - { - return; - } - case Keys.F3: - { - _parentLogTabWin.SearchParams.IsFindNext = true; - _parentLogTabWin.SearchParams.IsShiftF3Pressed = (e.Modifiers & Keys.Shift) == Keys.Shift; - StartSearch(); - break; - } - case Keys.Escape: - { - if (_isSearching) - { - _shouldCancel = true; - } + break; + } + case Keys.Down when e.Modifiers == Keys.Alt: + { + var newLine = _logFileReader.GetNextMultiFileLine(dataGridView.CurrentCellAddress.Y); - FireCancelHandlers(); - RemoveAllSearchHighlightEntries(); - break; - } - case Keys.E when (e.Modifiers & Keys.Control) == Keys.Control: + if (newLine != -1) { - StartEditMode(); - - break; + SelectLine(newLine, false, true); } - case Keys.Down when e.Modifiers == Keys.Alt: - { - var newLine = _logFileReader.GetNextMultiFileLine(dataGridView.CurrentCellAddress.Y); - if (newLine != -1) - { - SelectLine(newLine, false, true); - } + e.Handled = true; - e.Handled = true; + break; + } + case Keys.Up when e.Modifiers == Keys.Alt: + { + var newLine = _logFileReader.GetPrevMultiFileLine(dataGridView.CurrentCellAddress.Y); - break; - } - case Keys.Up when e.Modifiers == Keys.Alt: + if (newLine != -1) { - var newLine = _logFileReader.GetPrevMultiFileLine(dataGridView.CurrentCellAddress.Y); + SelectLine(newLine - 1, false, true); + } - if (newLine != -1) - { - SelectLine(newLine - 1, false, true); - } + e.Handled = true; - e.Handled = true; + break; + } + case Keys.Enter when dataGridView.Focused: + { + ChangeRowHeight(e.Shift); + e.Handled = true; - break; - } - case Keys.Enter when dataGridView.Focused: - { - ChangeRowHeight(e.Shift); - e.Handled = true; + break; + } + case Keys.Back when dataGridView.Focused: + { + ChangeRowHeight(true); + e.Handled = true; - break; - } - case Keys.Back when dataGridView.Focused: - { - ChangeRowHeight(true); - e.Handled = true; + break; + } + case Keys.PageUp when e.Modifiers == Keys.Alt: + { + SelectPrevHighlightLine(); + e.Handled = true; - break; - } - case Keys.PageUp when e.Modifiers == Keys.Alt: - { - SelectPrevHighlightLine(); - e.Handled = true; + break; + } + case Keys.PageDown when e.Modifiers == Keys.Alt: + { + SelectNextHighlightLine(); + e.Handled = true; - break; - } - case Keys.PageDown when e.Modifiers == Keys.Alt: - { - SelectNextHighlightLine(); - e.Handled = true; + break; + } + case Keys.T when (e.Modifiers & Keys.Control) == Keys.Control && (e.Modifiers & Keys.Shift) == Keys.Shift: + { + FilterToTab(); + break; + } + } + } - break; - } - case Keys.T when (e.Modifiers & Keys.Control) == Keys.Control && (e.Modifiers & Keys.Shift) == Keys.Shift: - { - FilterToTab(); - break; - } - } + public void AddBookmarkOverlays () + { + const int OVERSCAN = 20; + + var firstLine = dataGridView.FirstDisplayedScrollingRowIndex; + if (firstLine < 0) + { + return; } - public void AddBookmarkOverlays() + firstLine -= OVERSCAN; + if (firstLine < 0) { - const int OVERSCAN = 20; + firstLine = 0; + } - var firstLine = dataGridView.FirstDisplayedScrollingRowIndex; - if (firstLine < 0) - { - return; - } + var oversizeCount = OVERSCAN; - firstLine -= OVERSCAN; - if (firstLine < 0) + for (var i = firstLine; i < dataGridView.RowCount; ++i) + { + if (!dataGridView.Rows[i].Displayed && i > dataGridView.FirstDisplayedScrollingRowIndex) { - firstLine = 0; + if (oversizeCount-- < 0) + { + break; + } } - - var oversizeCount = OVERSCAN; - - for (var i = firstLine; i < dataGridView.RowCount; ++i) + if (_bookmarkProvider.IsBookmarkAtLine(i)) { - if (!dataGridView.Rows[i].Displayed && i > dataGridView.FirstDisplayedScrollingRowIndex) + Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(i); + if (bookmark.Text.Length > 0) { - if (oversizeCount-- < 0) + //BookmarkOverlay overlay = new BookmarkOverlay(); + BookmarkOverlay overlay = bookmark.Overlay; + overlay.Bookmark = bookmark; + + Rectangle r; + if (dataGridView.Rows[i].Displayed) { - break; + r = dataGridView.GetCellDisplayRectangle(0, i, false); } - } - if (_bookmarkProvider.IsBookmarkAtLine(i)) - { - Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(i); - if (bookmark.Text.Length > 0) + else { - //BookmarkOverlay overlay = new BookmarkOverlay(); - BookmarkOverlay overlay = bookmark.Overlay; - overlay.Bookmark = bookmark; - - Rectangle r; - if (dataGridView.Rows[i].Displayed) + r = dataGridView.GetCellDisplayRectangle(0, dataGridView.FirstDisplayedScrollingRowIndex, false); + //int count = i - this.dataGridView.FirstDisplayedScrollingRowIndex; + var heightSum = 0; + if (dataGridView.FirstDisplayedScrollingRowIndex < i) { - r = dataGridView.GetCellDisplayRectangle(0, i, false); + for (var rn = dataGridView.FirstDisplayedScrollingRowIndex + 1; rn < i; ++rn) + { + //Rectangle rr = this.dataGridView.GetCellDisplayRectangle(0, rn, false); + //heightSum += rr.Height; + heightSum += GetRowHeight(rn); + } + r.Offset(0, r.Height + heightSum); } else { - r = dataGridView.GetCellDisplayRectangle(0, dataGridView.FirstDisplayedScrollingRowIndex, false); - //int count = i - this.dataGridView.FirstDisplayedScrollingRowIndex; - var heightSum = 0; - if (dataGridView.FirstDisplayedScrollingRowIndex < i) - { - for (var rn = dataGridView.FirstDisplayedScrollingRowIndex + 1; rn < i; ++rn) - { - //Rectangle rr = this.dataGridView.GetCellDisplayRectangle(0, rn, false); - //heightSum += rr.Height; - heightSum += GetRowHeight(rn); - } - r.Offset(0, r.Height + heightSum); - } - else + for (var rn = dataGridView.FirstDisplayedScrollingRowIndex + 1; rn > i; --rn) { - for (var rn = dataGridView.FirstDisplayedScrollingRowIndex + 1; rn > i; --rn) - { - //Rectangle rr = this.dataGridView.GetCellDisplayRectangle(0, rn, false); - //heightSum += rr.Height; - heightSum += GetRowHeight(rn); - } - r.Offset(0, -(r.Height + heightSum)); + //Rectangle rr = this.dataGridView.GetCellDisplayRectangle(0, rn, false); + //heightSum += rr.Height; + heightSum += GetRowHeight(rn); } - //r.Offset(0, this.dataGridView.DisplayRectangle.Height); - } - if (_logger.IsDebugEnabled) - { - _logger.Debug("AddBookmarkOverlay() r.Location={0}, width={1}, scroll_offset={2}", r.Location.X, r.Width, dataGridView.HorizontalScrollingOffset); + r.Offset(0, -(r.Height + heightSum)); } - overlay.Position = r.Location - new Size(dataGridView.HorizontalScrollingOffset, 0); - overlay.Position += new Size(10, r.Height / 2); - dataGridView.AddOverlay(overlay); + //r.Offset(0, this.dataGridView.DisplayRectangle.Height); } + if (_logger.IsDebugEnabled) + { + _logger.Debug("AddBookmarkOverlay() r.Location={0}, width={1}, scroll_offset={2}", r.Location.X, r.Width, dataGridView.HorizontalScrollingOffset); + } + overlay.Position = r.Location - new Size(dataGridView.HorizontalScrollingOffset, 0); + overlay.Position += new Size(10, r.Height / 2); + dataGridView.AddOverlay(overlay); } } } + } - public void ToggleBookmark() - { - BufferedDataGridView gridView; - int lineNum; + public void ToggleBookmark () + { + BufferedDataGridView gridView; + int lineNum; - if (filterGridView.Focused) + if (filterGridView.Focused) + { + gridView = filterGridView; + if (gridView.CurrentCellAddress.Y == -1) { - gridView = filterGridView; - if (gridView.CurrentCellAddress.Y == -1) - { - return; - } + return; + } - lineNum = _filterResultList[gridView.CurrentCellAddress.Y]; + lineNum = _filterResultList[gridView.CurrentCellAddress.Y]; + } + else + { + gridView = dataGridView; + if (gridView.CurrentCellAddress.Y == -1) + { + return; } - else + lineNum = dataGridView.CurrentCellAddress.Y; + } + + ToggleBookmark(lineNum); + } + + public void ToggleBookmark (int lineNum) + { + if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) + { + Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); + + if (string.IsNullOrEmpty(bookmark.Text) == false) { - gridView = dataGridView; - if (gridView.CurrentCellAddress.Y == -1) + if (DialogResult.No == MessageBox.Show("There's a comment attached to the bookmark. Really remove the bookmark?", "LogExpert", MessageBoxButtons.YesNo)) { return; } - lineNum = dataGridView.CurrentCellAddress.Y; } - - ToggleBookmark(lineNum); + _bookmarkProvider.RemoveBookmarkForLine(lineNum); } + else + { + _bookmarkProvider.AddBookmark(new Bookmark(lineNum)); + } + dataGridView.Refresh(); + filterGridView.Refresh(); + OnBookmarkAdded(); + } - public void ToggleBookmark(int lineNum) + public void SetBookmarkFromTrigger (int lineNum, string comment) + { + lock (_bookmarkLock) { - if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) + ILogLine line = _logFileReader.GetLogLine(lineNum); + if (line == null) { - Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); - - if (string.IsNullOrEmpty(bookmark.Text) == false) - { - if (DialogResult.No == MessageBox.Show("There's a comment attached to the bookmark. Really remove the bookmark?", "LogExpert", MessageBoxButtons.YesNo)) - { - return; - } - } - _bookmarkProvider.RemoveBookmarkForLine(lineNum); + return; } - else + var paramParser = new ParamParser(comment); + try { - _bookmarkProvider.AddBookmark(new Bookmark(lineNum)); + comment = paramParser.ReplaceParams(line, lineNum, FileName); } - dataGridView.Refresh(); - filterGridView.Refresh(); - OnBookmarkAdded(); - } - - public void SetBookmarkFromTrigger(int lineNum, string comment) - { - lock (_bookmarkLock) + catch (ArgumentException) { - ILogLine line = _logFileReader.GetLogLine(lineNum); - if (line == null) - { - return; - } - var paramParser = new ParamParser(comment); - try - { - comment = paramParser.ReplaceParams(line, lineNum, FileName); - } - catch (ArgumentException) - { - // occurs on invalid regex - } - if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - _bookmarkProvider.RemoveBookmarkForLine(lineNum); - } - _bookmarkProvider.AddBookmark(new Bookmark(lineNum, comment)); - OnBookmarkAdded(); + // occurs on invalid regex } + if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) + { + _bookmarkProvider.RemoveBookmarkForLine(lineNum); + } + _bookmarkProvider.AddBookmark(new Bookmark(lineNum, comment)); + OnBookmarkAdded(); } + } - public void JumpNextBookmark() + public void JumpNextBookmark () + { + if (_bookmarkProvider.Bookmarks.Count > 0) { - if (_bookmarkProvider.Bookmarks.Count > 0) + if (filterGridView.Focused) { - if (filterGridView.Focused) + var index = FindNextBookmarkIndex(_filterResultList[filterGridView.CurrentCellAddress.Y]); + var startIndex = index; + var wrapped = false; + while (true) { - var index = FindNextBookmarkIndex(_filterResultList[filterGridView.CurrentCellAddress.Y]); - var startIndex = index; - var wrapped = false; - while (true) + var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; + if (_filterResultList.Contains(lineNum)) { - var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; - if (_filterResultList.Contains(lineNum)) - { - var filterLine = _filterResultList.IndexOf(lineNum); - filterGridView.Rows[filterLine].Selected = true; - filterGridView.CurrentCell = filterGridView.Rows[filterLine].Cells[0]; - break; - } - index++; - if (index > _bookmarkProvider.Bookmarks.Count - 1) - { - index = 0; - wrapped = true; - } - if (index >= startIndex && wrapped) - { - break; - } + var filterLine = _filterResultList.IndexOf(lineNum); + filterGridView.Rows[filterLine].Selected = true; + filterGridView.CurrentCell = filterGridView.Rows[filterLine].Cells[0]; + break; } - } - else - { - var index = FindNextBookmarkIndex(dataGridView.CurrentCellAddress.Y); + index++; if (index > _bookmarkProvider.Bookmarks.Count - 1) { index = 0; + wrapped = true; + } + if (index >= startIndex && wrapped) + { + break; } - - var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; - SelectLine(lineNum, true, true); } } + else + { + var index = FindNextBookmarkIndex(dataGridView.CurrentCellAddress.Y); + if (index > _bookmarkProvider.Bookmarks.Count - 1) + { + index = 0; + } + + var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; + SelectLine(lineNum, true, true); + } } + } - public void JumpPrevBookmark() + public void JumpPrevBookmark () + { + if (_bookmarkProvider.Bookmarks.Count > 0) { - if (_bookmarkProvider.Bookmarks.Count > 0) + if (filterGridView.Focused) { - if (filterGridView.Focused) + //int index = this.bookmarkList.BinarySearch(this.filterResultList[this.filterGridView.CurrentCellAddress.Y]); + //if (index < 0) + // index = ~index; + //index--; + var index = FindPrevBookmarkIndex(_filterResultList[filterGridView.CurrentCellAddress.Y]); + if (index < 0) { - //int index = this.bookmarkList.BinarySearch(this.filterResultList[this.filterGridView.CurrentCellAddress.Y]); - //if (index < 0) - // index = ~index; - //index--; - var index = FindPrevBookmarkIndex(_filterResultList[filterGridView.CurrentCellAddress.Y]); + index = _bookmarkProvider.Bookmarks.Count - 1; + } + var startIndex = index; + var wrapped = false; + while (true) + { + var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; + if (_filterResultList.Contains(lineNum)) + { + var filterLine = _filterResultList.IndexOf(lineNum); + filterGridView.Rows[filterLine].Selected = true; + filterGridView.CurrentCell = filterGridView.Rows[filterLine].Cells[0]; + break; + } + index--; if (index < 0) { index = _bookmarkProvider.Bookmarks.Count - 1; + wrapped = true; } - var startIndex = index; - var wrapped = false; - while (true) + if (index <= startIndex && wrapped) { - var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; - if (_filterResultList.Contains(lineNum)) - { - var filterLine = _filterResultList.IndexOf(lineNum); - filterGridView.Rows[filterLine].Selected = true; - filterGridView.CurrentCell = filterGridView.Rows[filterLine].Cells[0]; - break; - } - index--; - if (index < 0) - { - index = _bookmarkProvider.Bookmarks.Count - 1; - wrapped = true; - } - if (index <= startIndex && wrapped) - { - break; - } + break; } } - else + } + else + { + var index = FindPrevBookmarkIndex(dataGridView.CurrentCellAddress.Y); + if (index < 0) { - var index = FindPrevBookmarkIndex(dataGridView.CurrentCellAddress.Y); - if (index < 0) - { - index = _bookmarkProvider.Bookmarks.Count - 1; - } - - var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; - SelectLine(lineNum, false, true); + index = _bookmarkProvider.Bookmarks.Count - 1; } + + var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; + SelectLine(lineNum, false, true); } } + } - public void DeleteBookmarks(List lineNumList) + public void DeleteBookmarks (List lineNumList) + { + var bookmarksPresent = false; + foreach (var lineNum in lineNumList) { - var bookmarksPresent = false; - foreach (var lineNum in lineNumList) + if (lineNum != -1) { - if (lineNum != -1) + if (_bookmarkProvider.IsBookmarkAtLine(lineNum) && + _bookmarkProvider.GetBookmarkForLine(lineNum).Text.Length > 0) { - if (_bookmarkProvider.IsBookmarkAtLine(lineNum) && - _bookmarkProvider.GetBookmarkForLine(lineNum).Text.Length > 0) - { - bookmarksPresent = true; - } + bookmarksPresent = true; } } - if (bookmarksPresent) + } + if (bookmarksPresent) + { + if ( + MessageBox.Show("There are some comments in the bookmarks. Really remove bookmarks?", "LogExpert", + MessageBoxButtons.YesNo) == DialogResult.No) { - if ( - MessageBox.Show("There are some comments in the bookmarks. Really remove bookmarks?", "LogExpert", - MessageBoxButtons.YesNo) == DialogResult.No) - { - return; - } + return; } - _bookmarkProvider.RemoveBookmarksForLines(lineNumList); - OnBookmarkRemoved(); } + _bookmarkProvider.RemoveBookmarksForLines(lineNumList); + OnBookmarkRemoved(); + } - public void SetTimeshiftValue(string value) + public void SetTimeshiftValue (string value) + { + _guiStateArgs.TimeshiftText = value; + if (CurrentColumnizer.IsTimeshiftImplemented()) { - _guiStateArgs.TimeshiftText = value; - if (CurrentColumnizer.IsTimeshiftImplemented()) + try { - try + if (_guiStateArgs.TimeshiftEnabled) { - if (_guiStateArgs.TimeshiftEnabled) + try { - try - { - var text = _guiStateArgs.TimeshiftText; - if (text.StartsWith("+")) - { - text = text.Substring(1); - } - var timeSpan = TimeSpan.Parse(text); - var diff = (int)(timeSpan.Ticks / TimeSpan.TicksPerMillisecond); - CurrentColumnizer.SetTimeOffset(diff); - } - catch (Exception) + var text = _guiStateArgs.TimeshiftText; + if (text.StartsWith("+")) { - CurrentColumnizer.SetTimeOffset(0); + text = text.Substring(1); } + var timeSpan = TimeSpan.Parse(text); + var diff = (int)(timeSpan.Ticks / TimeSpan.TicksPerMillisecond); + CurrentColumnizer.SetTimeOffset(diff); } - else + catch (Exception) { CurrentColumnizer.SetTimeOffset(0); } - dataGridView.Refresh(); - filterGridView.Refresh(); - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - SetTimestampLimits(); - SyncTimestampDisplay(); - } } - catch (FormatException ex) + else { - _logger.Error(ex); + CurrentColumnizer.SetTimeOffset(0); + } + dataGridView.Refresh(); + filterGridView.Refresh(); + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + SetTimestampLimits(); + SyncTimestampDisplay(); } } - } - - public void ToggleFilterPanel() - { - splitContainerLogWindow.Panel2Collapsed = !splitContainerLogWindow.Panel2Collapsed; - if (!splitContainerLogWindow.Panel2Collapsed) - { - filterComboBox.Focus(); - } - else + catch (FormatException ex) { - dataGridView.Focus(); + _logger.Error(ex); } } + } - public void LogWindowActivated() + public void ToggleFilterPanel () + { + splitContainerLogWindow.Panel2Collapsed = !splitContainerLogWindow.Panel2Collapsed; + if (!splitContainerLogWindow.Panel2Collapsed) + { + filterComboBox.Focus(); + } + else { - if (_guiStateArgs.FollowTail && !_isDeadFile) - { - OnTailFollowed(EventArgs.Empty); - } - if (Preferences.timestampControl) - { - SetTimestampLimits(); - SyncTimestampDisplay(); - } dataGridView.Focus(); - - SendGuiStateUpdate(); - SendStatusLineUpdate(); - SendProgressBarUpdate(); } + } - public void SetCellSelectionMode(bool isCellMode) + public void LogWindowActivated () + { + if (_guiStateArgs.FollowTail && !_isDeadFile) { - if (isCellMode) - { - //possible performance issue, see => https://docs.microsoft.com/en-us/dotnet/desktop/winforms/controls/best-practices-for-scaling-the-windows-forms-datagridview-control?view=netframeworkdesktop-4.8#using-the-selected-cells-rows-and-columns-collections-efficiently - dataGridView.SelectionMode = DataGridViewSelectionMode.CellSelect; - } - else - { - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - } - - _guiStateArgs.CellSelectMode = isCellMode; + OnTailFollowed(EventArgs.Empty); } - - public void TimeshiftEnabled(bool isEnabled, string shiftValue) + if (Preferences.timestampControl) { - _guiStateArgs.TimeshiftEnabled = isEnabled; SetTimestampLimits(); - SetTimeshiftValue(shiftValue); + SyncTimestampDisplay(); } + dataGridView.Focus(); + + SendGuiStateUpdate(); + SendStatusLineUpdate(); + SendProgressBarUpdate(); + } - public void CopyMarkedLinesToTab() + public void SetCellSelectionMode (bool isCellMode) + { + if (isCellMode) + { + //possible performance issue, see => https://docs.microsoft.com/en-us/dotnet/desktop/winforms/controls/best-practices-for-scaling-the-windows-forms-datagridview-control?view=netframeworkdesktop-4.8#using-the-selected-cells-rows-and-columns-collections-efficiently + dataGridView.SelectionMode = DataGridViewSelectionMode.CellSelect; + } + else { - if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + } + + _guiStateArgs.CellSelectMode = isCellMode; + } + + public void TimeshiftEnabled (bool isEnabled, string shiftValue) + { + _guiStateArgs.TimeshiftEnabled = isEnabled; + SetTimestampLimits(); + SetTimeshiftValue(shiftValue); + } + + public void CopyMarkedLinesToTab () + { + if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) + { + var lineNumList = new List(); + foreach (DataGridViewRow row in dataGridView.SelectedRows) { - var lineNumList = new List(); - foreach (DataGridViewRow row in dataGridView.SelectedRows) + if (row.Index != -1) { - if (row.Index != -1) - { - lineNumList.Add(row.Index); - } + lineNumList.Add(row.Index); } - lineNumList.Sort(); - // create dummy FilterPipe for connecting line numbers to original window - // setting IsStopped to true prevents further filter processing - var pipe = new FilterPipe(new FilterParams(), this) - { - IsStopped = true - }; - WritePipeToTab(pipe, lineNumList, Text + "->C", null); } - else + lineNumList.Sort(); + // create dummy FilterPipe for connecting line numbers to original window + // setting IsStopped to true prevents further filter processing + var pipe = new FilterPipe(new FilterParams(), this) { - var fileName = Path.GetTempFileName(); - var fStream = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.Read); - var writer = new StreamWriter(fStream, Encoding.Unicode); + IsStopped = true + }; + WritePipeToTab(pipe, lineNumList, Text + "->C", null); + } + else + { + var fileName = Path.GetTempFileName(); + var fStream = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.Read); + var writer = new StreamWriter(fStream, Encoding.Unicode); - DataObject data = dataGridView.GetClipboardContent(); - var text = data.GetText(TextDataFormat.Text); - writer.Write(text); + DataObject data = dataGridView.GetClipboardContent(); + var text = data.GetText(TextDataFormat.Text); + writer.Write(text); - writer.Close(); - var title = Util.GetNameFromPath(FileName) + "->Clip"; - _parentLogTabWin.AddTempFileTab(fileName, title); - } + writer.Close(); + var title = Util.GetNameFromPath(FileName) + "->Clip"; + _parentLogTabWin.AddTempFileTab(fileName, title); } + } - /// - /// Change the file encoding. May force a reload if byte count ot preamble lenght differs from previous used encoding. - /// - /// - public void ChangeEncoding(Encoding encoding) + /// + /// Change the file encoding. May force a reload if byte count ot preamble lenght differs from previous used encoding. + /// + /// + public void ChangeEncoding (Encoding encoding) + { + _logFileReader.ChangeEncoding(encoding); + EncodingOptions.Encoding = encoding; + if (_guiStateArgs.CurrentEncoding.IsSingleByte != encoding.IsSingleByte || + _guiStateArgs.CurrentEncoding.GetPreamble().Length != encoding.GetPreamble().Length) { - _logFileReader.ChangeEncoding(encoding); - EncodingOptions.Encoding = encoding; - if (_guiStateArgs.CurrentEncoding.IsSingleByte != encoding.IsSingleByte || - _guiStateArgs.CurrentEncoding.GetPreamble().Length != encoding.GetPreamble().Length) - { - Reload(); - } - else - { - dataGridView.Refresh(); - SendGuiStateUpdate(); - } - _guiStateArgs.CurrentEncoding = _logFileReader.CurrentEncoding; + Reload(); } - - public void Reload() + else { - SavePersistenceData(false); + dataGridView.Refresh(); + SendGuiStateUpdate(); + } + _guiStateArgs.CurrentEncoding = _logFileReader.CurrentEncoding; + } - _reloadMemento = new ReloadMemento - { - CurrentLine = dataGridView.CurrentCellAddress.Y, - FirstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex - }; - _forcedColumnizerForLoading = CurrentColumnizer; + public void Reload () + { + SavePersistenceData(false); - if (_fileNames == null || !IsMultiFile) - { - LoadFile(FileName, EncodingOptions); - } - else - { - LoadFilesAsMulti(_fileNames, EncodingOptions); - } - //if (currentLine < this.dataGridView.RowCount && currentLine >= 0) - // this.dataGridView.CurrentCell = this.dataGridView.Rows[currentLine].Cells[0]; - //if (firstDisplayedLine < this.dataGridView.RowCount && firstDisplayedLine >= 0) - // this.dataGridView.FirstDisplayedScrollingRowIndex = firstDisplayedLine; + _reloadMemento = new ReloadMemento + { + CurrentLine = dataGridView.CurrentCellAddress.Y, + FirstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex + }; + _forcedColumnizerForLoading = CurrentColumnizer; - //if (this.filterTailCheckBox.Checked) - //{ - // _logger.logInfo("Refreshing filter view because of reload."); - // FilterSearch(); - //} + if (_fileNames == null || !IsMultiFile) + { + LoadFile(FileName, EncodingOptions); } - - public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags) + else { - if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors) - { - NormalFont = new Font(new FontFamily(newPreferences.fontName), newPreferences.fontSize); - BoldFont = new Font(NormalFont, FontStyle.Bold); - MonospacedFont = new Font("Courier New", Preferences.fontSize, FontStyle.Bold); - - var lineSpacing = NormalFont.FontFamily.GetLineSpacing(FontStyle.Regular); - var lineSpacingPixel = NormalFont.Size * lineSpacing / NormalFont.FontFamily.GetEmHeight(FontStyle.Regular); + LoadFilesAsMulti(_fileNames, EncodingOptions); + } + //if (currentLine < this.dataGridView.RowCount && currentLine >= 0) + // this.dataGridView.CurrentCell = this.dataGridView.Rows[currentLine].Cells[0]; + //if (firstDisplayedLine < this.dataGridView.RowCount && firstDisplayedLine >= 0) + // this.dataGridView.FirstDisplayedScrollingRowIndex = firstDisplayedLine; - dataGridView.DefaultCellStyle.Font = NormalFont; - filterGridView.DefaultCellStyle.Font = NormalFont; - _lineHeight = NormalFont.Height + 4; - dataGridView.RowTemplate.Height = NormalFont.Height + 4; + //if (this.filterTailCheckBox.Checked) + //{ + // _logger.logInfo("Refreshing filter view because of reload."); + // FilterSearch(); + //} + } - ShowBookmarkBubbles = Preferences.showBubbles; + public void PreferencesChanged (Preferences newPreferences, bool isLoadTime, SettingsFlags flags) + { + if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors) + { + NormalFont = new Font(new FontFamily(newPreferences.fontName), newPreferences.fontSize); + BoldFont = new Font(NormalFont, FontStyle.Bold); + MonospacedFont = new Font("Courier New", Preferences.fontSize, FontStyle.Bold); - ApplyDataGridViewPrefs(dataGridView, newPreferences); - ApplyDataGridViewPrefs(filterGridView, newPreferences); + var lineSpacing = NormalFont.FontFamily.GetLineSpacing(FontStyle.Regular); + var lineSpacingPixel = NormalFont.Size * lineSpacing / NormalFont.FontFamily.GetEmHeight(FontStyle.Regular); - if (Preferences.timestampControl) - { - SetTimestampLimits(); - SyncTimestampDisplay(); - } - if (isLoadTime) - { - filterTailCheckBox.Checked = Preferences.filterTail; - syncFilterCheckBox.Checked = Preferences.filterSync; - //this.FollowTailChanged(this.Preferences.followTail, false); - } + dataGridView.DefaultCellStyle.Font = NormalFont; + filterGridView.DefaultCellStyle.Font = NormalFont; + _lineHeight = NormalFont.Height + 4; + dataGridView.RowTemplate.Height = NormalFont.Height + 4; - _timeSpreadCalc.TimeMode = Preferences.timeSpreadTimeMode; - timeSpreadingControl.ForeColor = Preferences.timeSpreadColor; - timeSpreadingControl.ReverseAlpha = Preferences.reverseAlpha; - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - timeSpreadingControl.Invoke(new MethodInvoker(timeSpreadingControl.Refresh)); - ShowTimeSpread(Preferences.showTimeSpread); - } - ToggleColumnFinder(Preferences.showColumnFinder, false); - } + ShowBookmarkBubbles = Preferences.showBubbles; - if ((flags & SettingsFlags.FilterList) == SettingsFlags.FilterList) + ApplyDataGridViewPrefs(dataGridView, newPreferences); + ApplyDataGridViewPrefs(filterGridView, newPreferences); + + if (Preferences.timestampControl) + { + SetTimestampLimits(); + SyncTimestampDisplay(); + } + if (isLoadTime) { - HandleChangedFilterList(); + filterTailCheckBox.Checked = Preferences.filterTail; + syncFilterCheckBox.Checked = Preferences.filterSync; + //this.FollowTailChanged(this.Preferences.followTail, false); } - if ((flags & SettingsFlags.FilterHistory) == SettingsFlags.FilterHistory) + _timeSpreadCalc.TimeMode = Preferences.timeSpreadTimeMode; + timeSpreadingControl.ForeColor = Preferences.timeSpreadColor; + timeSpreadingControl.ReverseAlpha = Preferences.reverseAlpha; + if (CurrentColumnizer.IsTimeshiftImplemented()) { - UpdateFilterHistoryFromSettings(); - - if (isLoadTime) - { - AutoResizeFilterBox(); - } + timeSpreadingControl.Invoke(new MethodInvoker(timeSpreadingControl.Refresh)); + ShowTimeSpread(Preferences.showTimeSpread); } + ToggleColumnFinder(Preferences.showColumnFinder, false); + } + + if ((flags & SettingsFlags.FilterList) == SettingsFlags.FilterList) + { + HandleChangedFilterList(); } - public bool ScrollToTimestamp(DateTime timestamp, bool roundToSeconds, bool triggerSyncCall) + if ((flags & SettingsFlags.FilterHistory) == SettingsFlags.FilterHistory) { - if (InvokeRequired) + UpdateFilterHistoryFromSettings(); + + if (isLoadTime) { - BeginInvoke(new ScrollToTimestampFx(ScrollToTimestampWorker), timestamp, roundToSeconds, triggerSyncCall); - return true; + AutoResizeFilterBox(); } + } + } + + public bool ScrollToTimestamp (DateTime timestamp, bool roundToSeconds, bool triggerSyncCall) + { + if (InvokeRequired) + { + BeginInvoke(new ScrollToTimestampFx(ScrollToTimestampWorker), timestamp, roundToSeconds, triggerSyncCall); + return true; + } - return ScrollToTimestampWorker(timestamp, roundToSeconds, triggerSyncCall); + return ScrollToTimestampWorker(timestamp, roundToSeconds, triggerSyncCall); + } + + public bool ScrollToTimestampWorker (DateTime timestamp, bool roundToSeconds, bool triggerSyncCall) + { + var hasScrolled = false; + if (!CurrentColumnizer.IsTimeshiftImplemented() || dataGridView.RowCount == 0) + { + return false; } - public bool ScrollToTimestampWorker(DateTime timestamp, bool roundToSeconds, bool triggerSyncCall) + //this.Cursor = Cursors.WaitCursor; + var currentLine = dataGridView.CurrentCellAddress.Y; + if (currentLine < 0 || currentLine >= dataGridView.RowCount) { - var hasScrolled = false; - if (!CurrentColumnizer.IsTimeshiftImplemented() || dataGridView.RowCount == 0) - { - return false; - } + currentLine = 0; + } + var foundLine = FindTimestampLine(currentLine, timestamp, roundToSeconds); + if (foundLine >= 0) + { + SelectAndEnsureVisible(foundLine, triggerSyncCall); + hasScrolled = true; + } + //this.Cursor = Cursors.Default; + return hasScrolled; + } - //this.Cursor = Cursors.WaitCursor; - var currentLine = dataGridView.CurrentCellAddress.Y; - if (currentLine < 0 || currentLine >= dataGridView.RowCount) + public int FindTimestampLine (int lineNum, DateTime timestamp, bool roundToSeconds) + { + var foundLine = + FindTimestampLine_Internal(lineNum, 0, dataGridView.RowCount - 1, timestamp, roundToSeconds); + if (foundLine >= 0) + { + // go backwards to the first occurence of the hit + DateTime foundTimestamp = GetTimestampForLine(ref foundLine, roundToSeconds); + while (foundTimestamp.CompareTo(timestamp) == 0 && foundLine >= 0) { - currentLine = 0; + foundLine--; + foundTimestamp = GetTimestampForLine(ref foundLine, roundToSeconds); } - var foundLine = FindTimestampLine(currentLine, timestamp, roundToSeconds); - if (foundLine >= 0) + if (foundLine < 0) { - SelectAndEnsureVisible(foundLine, triggerSyncCall); - hasScrolled = true; + return 0; } - //this.Cursor = Cursors.Default; - return hasScrolled; + + foundLine++; + GetTimestampForLineForward(ref foundLine, roundToSeconds); // fwd to next valid timestamp + return foundLine; } + return -foundLine; + } - public int FindTimestampLine(int lineNum, DateTime timestamp, bool roundToSeconds) + public int FindTimestampLine_Internal (int lineNum, int rangeStart, int rangeEnd, DateTime timestamp, + bool roundToSeconds) + { + _logger.Debug("FindTimestampLine_Internal(): timestamp={0}, lineNum={1}, rangeStart={2}, rangeEnd={3}", timestamp, lineNum, rangeStart, rangeEnd); + var refLine = lineNum; + DateTime currentTimestamp = GetTimestampForLine(ref refLine, roundToSeconds); + if (currentTimestamp.CompareTo(timestamp) == 0) { - var foundLine = - FindTimestampLine_Internal(lineNum, 0, dataGridView.RowCount - 1, timestamp, roundToSeconds); - if (foundLine >= 0) - { - // go backwards to the first occurence of the hit - DateTime foundTimestamp = GetTimestampForLine(ref foundLine, roundToSeconds); - while (foundTimestamp.CompareTo(timestamp) == 0 && foundLine >= 0) - { - foundLine--; - foundTimestamp = GetTimestampForLine(ref foundLine, roundToSeconds); - } - if (foundLine < 0) - { - return 0; - } + return lineNum; + } + if (timestamp < currentTimestamp) + { + //rangeStart = rangeStart; + rangeEnd = lineNum; + } + else + { + rangeStart = lineNum; + //rangeEnd = rangeEnd; + } - foundLine++; - GetTimestampForLineForward(ref foundLine, roundToSeconds); // fwd to next valid timestamp - return foundLine; - } - return -foundLine; + if (rangeEnd - rangeStart <= 0) + { + return -lineNum; } - public int FindTimestampLine_Internal(int lineNum, int rangeStart, int rangeEnd, DateTime timestamp, - bool roundToSeconds) + lineNum = (rangeEnd - rangeStart) / 2 + rangeStart; + // prevent endless loop + if (rangeEnd - rangeStart < 2) { - _logger.Debug("FindTimestampLine_Internal(): timestamp={0}, lineNum={1}, rangeStart={2}, rangeEnd={3}", timestamp, lineNum, rangeStart, rangeEnd); - var refLine = lineNum; - DateTime currentTimestamp = GetTimestampForLine(ref refLine, roundToSeconds); + currentTimestamp = GetTimestampForLine(ref rangeStart, roundToSeconds); if (currentTimestamp.CompareTo(timestamp) == 0) { - return lineNum; - } - if (timestamp < currentTimestamp) - { - //rangeStart = rangeStart; - rangeEnd = lineNum; - } - else - { - rangeStart = lineNum; - //rangeEnd = rangeEnd; + return rangeStart; } - - if (rangeEnd - rangeStart <= 0) - { - return -lineNum; - } - - lineNum = (rangeEnd - rangeStart) / 2 + rangeStart; - // prevent endless loop - if (rangeEnd - rangeStart < 2) + currentTimestamp = GetTimestampForLine(ref rangeEnd, roundToSeconds); + if (currentTimestamp.CompareTo(timestamp) == 0) { - currentTimestamp = GetTimestampForLine(ref rangeStart, roundToSeconds); - if (currentTimestamp.CompareTo(timestamp) == 0) - { - return rangeStart; - } - currentTimestamp = GetTimestampForLine(ref rangeEnd, roundToSeconds); - if (currentTimestamp.CompareTo(timestamp) == 0) - { - return rangeEnd; - } - return -lineNum; + return rangeEnd; } - - return FindTimestampLine_Internal(lineNum, rangeStart, rangeEnd, timestamp, roundToSeconds); + return -lineNum; } - /** - * Get the timestamp for the given line number. If the line - * has no timestamp, the previous line will be checked until a - * timestamp is found. - */ + return FindTimestampLine_Internal(lineNum, rangeStart, rangeEnd, timestamp, roundToSeconds); + } + + /** + * Get the timestamp for the given line number. If the line + * has no timestamp, the previous line will be checked until a + * timestamp is found. + */ - public DateTime GetTimestampForLine(ref int lineNum, bool roundToSeconds) + public DateTime GetTimestampForLine (ref int lineNum, bool roundToSeconds) + { + lock (_currentColumnizerLock) { - lock (_currentColumnizerLock) + if (!CurrentColumnizer.IsTimeshiftImplemented()) { - if (!CurrentColumnizer.IsTimeshiftImplemented()) - { - return DateTime.MinValue; - } - _logger.Debug("GetTimestampForLine({0}) enter", lineNum); - DateTime timeStamp = DateTime.MinValue; - var lookBack = false; - if (lineNum >= 0 && lineNum < dataGridView.RowCount) + return DateTime.MinValue; + } + _logger.Debug("GetTimestampForLine({0}) enter", lineNum); + DateTime timeStamp = DateTime.MinValue; + var lookBack = false; + if (lineNum >= 0 && lineNum < dataGridView.RowCount) + { + while (timeStamp.CompareTo(DateTime.MinValue) == 0 && lineNum >= 0) { - while (timeStamp.CompareTo(DateTime.MinValue) == 0 && lineNum >= 0) + if (_isTimestampDisplaySyncing && _shouldTimestampDisplaySyncingCancel) { - if (_isTimestampDisplaySyncing && _shouldTimestampDisplaySyncingCancel) - { - return DateTime.MinValue; - } - lookBack = true; - ILogLine logLine = _logFileReader.GetLogLine(lineNum); - if (logLine == null) - { - return DateTime.MinValue; - } - ColumnizerCallbackObject.LineNum = lineNum; - timeStamp = CurrentColumnizer.GetTimestamp(ColumnizerCallbackObject, logLine); - if (roundToSeconds) - { - timeStamp = timeStamp.Subtract(TimeSpan.FromMilliseconds(timeStamp.Millisecond)); - } - lineNum--; + return DateTime.MinValue; } + lookBack = true; + ILogLine logLine = _logFileReader.GetLogLine(lineNum); + if (logLine == null) + { + return DateTime.MinValue; + } + ColumnizerCallbackObject.LineNum = lineNum; + timeStamp = CurrentColumnizer.GetTimestamp(ColumnizerCallbackObject, logLine); + if (roundToSeconds) + { + timeStamp = timeStamp.Subtract(TimeSpan.FromMilliseconds(timeStamp.Millisecond)); + } + lineNum--; } - if (lookBack) - { - lineNum++; - } - _logger.Debug("GetTimestampForLine() leave with lineNum={0}", lineNum); - return timeStamp; } + if (lookBack) + { + lineNum++; + } + _logger.Debug("GetTimestampForLine() leave with lineNum={0}", lineNum); + return timeStamp; } + } - /** - * Get the timestamp for the given line number. If the line - * has no timestamp, the next line will be checked until a - * timestamp is found. - */ + /** + * Get the timestamp for the given line number. If the line + * has no timestamp, the next line will be checked until a + * timestamp is found. + */ - public DateTime GetTimestampForLineForward(ref int lineNum, bool roundToSeconds) + public DateTime GetTimestampForLineForward (ref int lineNum, bool roundToSeconds) + { + lock (_currentColumnizerLock) { - lock (_currentColumnizerLock) + if (!CurrentColumnizer.IsTimeshiftImplemented()) { - if (!CurrentColumnizer.IsTimeshiftImplemented()) - { - return DateTime.MinValue; - } + return DateTime.MinValue; + } - DateTime timeStamp = DateTime.MinValue; - var lookFwd = false; - if (lineNum >= 0 && lineNum < dataGridView.RowCount) + DateTime timeStamp = DateTime.MinValue; + var lookFwd = false; + if (lineNum >= 0 && lineNum < dataGridView.RowCount) + { + while (timeStamp.CompareTo(DateTime.MinValue) == 0 && lineNum < dataGridView.RowCount) { - while (timeStamp.CompareTo(DateTime.MinValue) == 0 && lineNum < dataGridView.RowCount) + lookFwd = true; + ILogLine logLine = _logFileReader.GetLogLine(lineNum); + if (logLine == null) { - lookFwd = true; - ILogLine logLine = _logFileReader.GetLogLine(lineNum); - if (logLine == null) - { - timeStamp = DateTime.MinValue; - break; - } - timeStamp = CurrentColumnizer.GetTimestamp(ColumnizerCallbackObject, logLine); - if (roundToSeconds) - { - timeStamp = timeStamp.Subtract(TimeSpan.FromMilliseconds(timeStamp.Millisecond)); - } - lineNum++; + timeStamp = DateTime.MinValue; + break; } + timeStamp = CurrentColumnizer.GetTimestamp(ColumnizerCallbackObject, logLine); + if (roundToSeconds) + { + timeStamp = timeStamp.Subtract(TimeSpan.FromMilliseconds(timeStamp.Millisecond)); + } + lineNum++; } - if (lookFwd) - { - lineNum--; - } - return timeStamp; } + if (lookFwd) + { + lineNum--; + } + return timeStamp; } + } - public void AppFocusLost() - { - InvalidateCurrentRow(dataGridView); - } + public void AppFocusLost () + { + InvalidateCurrentRow(dataGridView); + } - public void AppFocusGained() - { - InvalidateCurrentRow(dataGridView); - } + public void AppFocusGained () + { + InvalidateCurrentRow(dataGridView); + } - public ILogLine GetCurrentLine() + public ILogLine GetCurrentLine () + { + if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index != -1) { - if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index != -1) - { - return _logFileReader.GetLogLine(dataGridView.CurrentRow.Index); - } - return null; + return _logFileReader.GetLogLine(dataGridView.CurrentRow.Index); } + return null; + } - public ILogLine GetLine(int lineNum) + public ILogLine GetLine (int lineNum) + { + if (lineNum < 0 || _logFileReader == null || lineNum >= _logFileReader.LineCount) { - if (lineNum < 0 || _logFileReader == null || lineNum >= _logFileReader.LineCount) - { - return null; - } - return _logFileReader.GetLogLine(lineNum); + return null; } + return _logFileReader.GetLogLine(lineNum); + } - public int GetCurrentLineNum() + public int GetCurrentLineNum () + { + if (dataGridView.CurrentRow == null) { - if (dataGridView.CurrentRow == null) - { - return -1; - } - return dataGridView.CurrentRow.Index; + return -1; } + return dataGridView.CurrentRow.Index; + } - public int GetRealLineNum() + public int GetRealLineNum () + { + var lineNum = GetCurrentLineNum(); + if (lineNum == -1) { - var lineNum = GetCurrentLineNum(); - if (lineNum == -1) - { - return -1; - } - return _logFileReader.GetRealLineNumForVirtualLineNum(lineNum); + return -1; } + return _logFileReader.GetRealLineNumForVirtualLineNum(lineNum); + } - public ILogFileInfo GetCurrentFileInfo() + public ILogFileInfo GetCurrentFileInfo () + { + if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index != -1) { - if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index != -1) - { - return _logFileReader.GetLogFileInfoForLine(dataGridView.CurrentRow.Index); - } - return null; + return _logFileReader.GetLogFileInfoForLine(dataGridView.CurrentRow.Index); } + return null; + } - /// - /// zero-based - /// - /// - /// - public string GetCurrentFileName(int lineNum) - { - return _logFileReader.GetLogFileNameForLine(lineNum); - } + /// + /// zero-based + /// + /// + /// + public string GetCurrentFileName (int lineNum) + { + return _logFileReader.GetLogFileNameForLine(lineNum); + } - // =============== end of bookmark stuff =================================== + // =============== end of bookmark stuff =================================== - public void ShowLineColumn(bool show) - { - dataGridView.Columns[1].Visible = show; - filterGridView.Columns[1].Visible = show; - } + public void ShowLineColumn (bool show) + { + dataGridView.Columns[1].Visible = show; + filterGridView.Columns[1].Visible = show; + } - // ================================================================= - // Pattern statistics - // ================================================================= + // ================================================================= + // Pattern statistics + // ================================================================= - public void PatternStatistic() - { - InitPatternWindow(); - } + public void PatternStatistic () + { + InitPatternWindow(); + } - public void PatternStatisticSelectRange(PatternArgs patternArgs) + public void PatternStatisticSelectRange (PatternArgs patternArgs) + { + if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) { - if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) + List lineNumList = []; + foreach (DataGridViewRow row in dataGridView.SelectedRows) { - List lineNumList = []; - foreach (DataGridViewRow row in dataGridView.SelectedRows) + if (row.Index != -1) { - if (row.Index != -1) - { - lineNumList.Add(row.Index); - } + lineNumList.Add(row.Index); } - lineNumList.Sort(); - patternArgs.StartLine = lineNumList[0]; - patternArgs.EndLine = lineNumList[^1]; + } + lineNumList.Sort(); + patternArgs.StartLine = lineNumList[0]; + patternArgs.EndLine = lineNumList[^1]; + } + else + { + if (dataGridView.CurrentCellAddress.Y != -1) + { + patternArgs.StartLine = dataGridView.CurrentCellAddress.Y; } else { - if (dataGridView.CurrentCellAddress.Y != -1) - { - patternArgs.StartLine = dataGridView.CurrentCellAddress.Y; - } - else - { - patternArgs.StartLine = 0; - } - patternArgs.EndLine = dataGridView.RowCount - 1; + patternArgs.StartLine = 0; } + patternArgs.EndLine = dataGridView.RowCount - 1; } + } + + public void PatternStatistic (PatternArgs patternArgs) + { + var fx = new PatternStatisticFx(TestStatistic); + fx.BeginInvoke(patternArgs, null, null); + } - public void PatternStatistic(PatternArgs patternArgs) + public void ExportBookmarkList () + { + SaveFileDialog dlg = new() { - var fx = new PatternStatisticFx(TestStatistic); - fx.BeginInvoke(patternArgs, null, null); - } + Title = "Choose a file to save bookmarks into", + AddExtension = true, + DefaultExt = "csv", + Filter = "CSV file (*.csv)|*.csv|Bookmark file (*.bmk)|*.bmk", + FilterIndex = 1, + FileName = Path.GetFileNameWithoutExtension(FileName) + }; - public void ExportBookmarkList() + if (dlg.ShowDialog() == DialogResult.OK) { - SaveFileDialog dlg = new() + try { - Title = "Choose a file to save bookmarks into", - AddExtension = true, - DefaultExt = "csv", - Filter = "CSV file (*.csv)|*.csv|Bookmark file (*.bmk)|*.bmk", - FilterIndex = 1, - FileName = Path.GetFileNameWithoutExtension(FileName) - }; - - if (dlg.ShowDialog() == DialogResult.OK) + BookmarkExporter.ExportBookmarkList(_bookmarkProvider.BookmarkList, FileName, + dlg.FileName); + } + catch (IOException e) { - try - { - BookmarkExporter.ExportBookmarkList(_bookmarkProvider.BookmarkList, FileName, - dlg.FileName); - } - catch (IOException e) - { - _logger.Error(e); - MessageBox.Show("Error while exporting bookmark list: " + e.Message, "LogExpert"); - } + _logger.Error(e); + MessageBox.Show("Error while exporting bookmark list: " + e.Message, "LogExpert"); } } + } - public void ImportBookmarkList() + public void ImportBookmarkList () + { + OpenFileDialog dlg = new() { - OpenFileDialog dlg = new() - { - Title = "Choose a file to load bookmarks from", - AddExtension = true, - DefaultExt = "csv", - Filter = "CSV file (*.csv)|*.csv|Bookmark file (*.bmk)|*.bmk", - FilterIndex = 1, - FileName = Path.GetFileNameWithoutExtension(FileName) - }; + Title = "Choose a file to load bookmarks from", + AddExtension = true, + DefaultExt = "csv", + Filter = "CSV file (*.csv)|*.csv|Bookmark file (*.bmk)|*.bmk", + FilterIndex = 1, + FileName = Path.GetFileNameWithoutExtension(FileName) + }; - if (dlg.ShowDialog() == DialogResult.OK) + if (dlg.ShowDialog() == DialogResult.OK) + { + try { - try - { - // add to the existing bookmarks - SortedList newBookmarks = []; - BookmarkExporter.ImportBookmarkList(FileName, dlg.FileName, newBookmarks); + // add to the existing bookmarks + SortedList newBookmarks = []; + BookmarkExporter.ImportBookmarkList(FileName, dlg.FileName, newBookmarks); - // Add (or replace) to existing bookmark list - var bookmarkAdded = false; - foreach (Bookmark b in newBookmarks.Values) + // Add (or replace) to existing bookmark list + var bookmarkAdded = false; + foreach (Bookmark b in newBookmarks.Values) + { + if (!_bookmarkProvider.BookmarkList.ContainsKey(b.LineNum)) { - if (!_bookmarkProvider.BookmarkList.ContainsKey(b.LineNum)) - { - _bookmarkProvider.BookmarkList.Add(b.LineNum, b); - bookmarkAdded = true; // refresh the list only once at the end - } - else - { - Bookmark existingBookmark = _bookmarkProvider.BookmarkList[b.LineNum]; - existingBookmark.Text = - b.Text; // replace existing bookmark for that line, preserving the overlay - OnBookmarkTextChanged(b); - } + _bookmarkProvider.BookmarkList.Add(b.LineNum, b); + bookmarkAdded = true; // refresh the list only once at the end } - - // Refresh the lists - if (bookmarkAdded) + else { - OnBookmarkAdded(); + Bookmark existingBookmark = _bookmarkProvider.BookmarkList[b.LineNum]; + existingBookmark.Text = + b.Text; // replace existing bookmark for that line, preserving the overlay + OnBookmarkTextChanged(b); } - dataGridView.Refresh(); - filterGridView.Refresh(); } - catch (IOException e) + + // Refresh the lists + if (bookmarkAdded) { - _logger.Error(e); - MessageBox.Show($"Error while importing bookmark list: {e.Message}", "LogExpert"); + OnBookmarkAdded(); } + dataGridView.Refresh(); + filterGridView.Refresh(); + } + catch (IOException e) + { + _logger.Error(e); + MessageBox.Show($"Error while importing bookmark list: {e.Message}", "LogExpert"); } } + } - public bool IsAdvancedOptionActive() - { - return rangeCheckBox.Checked || - fuzzyKnobControl.Value > 0 || - filterKnobBackSpread.Value > 0 || - filterKnobForeSpread.Value > 0 || - invertFilterCheckBox.Checked || - columnRestrictCheckBox.Checked; - } + public bool IsAdvancedOptionActive () + { + return rangeCheckBox.Checked || + fuzzyKnobControl.Value > 0 || + filterKnobBackSpread.Value > 0 || + filterKnobForeSpread.Value > 0 || + invertFilterCheckBox.Checked || + columnRestrictCheckBox.Checked; + } + + public void HandleChangedFilterList () + { + Invoke(new MethodInvoker(HandleChangedFilterListWorker)); + } - public void HandleChangedFilterList() + public void HandleChangedFilterListWorker () + { + var index = filterListBox.SelectedIndex; + filterListBox.Items.Clear(); + foreach (FilterParams filterParam in ConfigManager.Settings.filterList) { - Invoke(new MethodInvoker(HandleChangedFilterListWorker)); + filterListBox.Items.Add(filterParam); } - - public void HandleChangedFilterListWorker() + filterListBox.Refresh(); + if (index >= 0 && index < filterListBox.Items.Count) { - var index = filterListBox.SelectedIndex; - filterListBox.Items.Clear(); - foreach (FilterParams filterParam in ConfigManager.Settings.filterList) - { - filterListBox.Items.Add(filterParam); - } - filterListBox.Refresh(); - if (index >= 0 && index < filterListBox.Items.Count) - { - filterListBox.SelectedIndex = index; - } - filterOnLoadCheckBox.Checked = Preferences.isFilterOnLoad; - hideFilterListOnLoadCheckBox.Checked = Preferences.isAutoHideFilterList; + filterListBox.SelectedIndex = index; } + filterOnLoadCheckBox.Checked = Preferences.isFilterOnLoad; + hideFilterListOnLoadCheckBox.Checked = Preferences.isAutoHideFilterList; + } - public void SetCurrentHighlightGroup(string groupName) + public void SetCurrentHighlightGroup (string groupName) + { + _guiStateArgs.HighlightGroupName = groupName; + lock (_currentHighlightGroupLock) { - _guiStateArgs.HighlightGroupName = groupName; - lock (_currentHighlightGroupLock) + _currentHighlightGroup = _parentLogTabWin.FindHighlightGroup(groupName); + if (_currentHighlightGroup == null) { - _currentHighlightGroup = _parentLogTabWin.FindHighlightGroup(groupName); - if (_currentHighlightGroup == null) + if (_parentLogTabWin.HighlightGroupList.Count > 0) { - if (_parentLogTabWin.HighlightGroupList.Count > 0) - { - _currentHighlightGroup = _parentLogTabWin.HighlightGroupList[0]; - } - else - { - _currentHighlightGroup = new HighlightGroup(); - } + _currentHighlightGroup = _parentLogTabWin.HighlightGroupList[0]; + } + else + { + _currentHighlightGroup = new HighlightGroup(); } - _guiStateArgs.HighlightGroupName = _currentHighlightGroup.GroupName; } - SendGuiStateUpdate(); - BeginInvoke(new MethodInvoker(RefreshAllGrids)); + _guiStateArgs.HighlightGroupName = _currentHighlightGroup.GroupName; } + SendGuiStateUpdate(); + BeginInvoke(new MethodInvoker(RefreshAllGrids)); + } - public void SwitchMultiFile(bool enabled) - { - IsMultiFile = enabled; - Reload(); - } + public void SwitchMultiFile (bool enabled) + { + IsMultiFile = enabled; + Reload(); + } - public void AddOtherWindowToTimesync(LogWindow other) + public void AddOtherWindowToTimesync (LogWindow other) + { + if (other.IsTimeSynced) { - if (other.IsTimeSynced) + if (IsTimeSynced) { - if (IsTimeSynced) - { - other.FreeFromTimeSync(); - AddSlaveToTimesync(other); - } - else - { - AddToTimeSync(other); - } + other.FreeFromTimeSync(); + AddSlaveToTimesync(other); } else { - AddSlaveToTimesync(other); + AddToTimeSync(other); } } - - public void AddToTimeSync(LogWindow master) + else { - _logger.Info("Syncing window for {0} to {1}", Util.GetNameFromPath(FileName), Util.GetNameFromPath(master.FileName)); - lock (_timeSyncListLock) - { - if (IsTimeSynced && master.TimeSyncList != TimeSyncList) - // already synced but master has different sync list - { - FreeFromTimeSync(); - } - TimeSyncList = master.TimeSyncList; - TimeSyncList.AddWindow(this); - ScrollToTimestamp(TimeSyncList.CurrentTimestamp, false, false); - } - OnSyncModeChanged(); + AddSlaveToTimesync(other); } + } - public void FreeFromTimeSync() + public void AddToTimeSync (LogWindow master) + { + _logger.Info("Syncing window for {0} to {1}", Util.GetNameFromPath(FileName), Util.GetNameFromPath(master.FileName)); + lock (_timeSyncListLock) { - lock (_timeSyncListLock) + if (IsTimeSynced && master.TimeSyncList != TimeSyncList) + // already synced but master has different sync list { - if (TimeSyncList != null) - { - _logger.Info("De-Syncing window for {0}", Util.GetNameFromPath(FileName)); - TimeSyncList.WindowRemoved -= OnTimeSyncListWindowRemoved; - TimeSyncList.RemoveWindow(this); - TimeSyncList = null; - } + FreeFromTimeSync(); } - OnSyncModeChanged(); + TimeSyncList = master.TimeSyncList; + TimeSyncList.AddWindow(this); + ScrollToTimestamp(TimeSyncList.CurrentTimestamp, false, false); } + OnSyncModeChanged(); + } - public void RefreshLogView() + public void FreeFromTimeSync () + { + lock (_timeSyncListLock) { - RefreshAllGrids(); + if (TimeSyncList != null) + { + _logger.Info("De-Syncing window for {0}", Util.GetNameFromPath(FileName)); + TimeSyncList.WindowRemoved -= OnTimeSyncListWindowRemoved; + TimeSyncList.RemoveWindow(this); + TimeSyncList = null; + } } + OnSyncModeChanged(); + } - #endregion + public void RefreshLogView () + { + RefreshAllGrids(); } + + #endregion } diff --git a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs index 8c961e4e..d7d9ae3b 100644 --- a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs @@ -6,355 +6,354 @@ using System.Drawing; using System.Windows.Forms; -namespace LogExpert.UI.Controls.LogWindow +namespace LogExpert.UI.Controls.LogWindow; + +internal partial class PatternWindow : Form //TODO: Can this be changed to UserControl? { - internal partial class PatternWindow : Form //TODO: Can this be changed to UserControl? + #region Fields + + private readonly List> blockList = []; + private PatternBlock currentBlock; + private List currentList; + + private readonly LogWindow logWindow; + private PatternArgs patternArgs = new(); + + #endregion + + #region cTor + + public PatternWindow() { - #region Fields + InitializeComponent(); + } - private readonly List> blockList = []; - private PatternBlock currentBlock; - private List currentList; + public PatternWindow(LogWindow logWindow) + { + this.logWindow = logWindow; + InitializeComponent(); + recalcButton.Enabled = false; + } - private readonly LogWindow logWindow; - private PatternArgs patternArgs = new(); + #endregion - #endregion + #region Properties - #region cTor + public int Fuzzy + { + set => fuzzyKnobControl.Value = value; + get => fuzzyKnobControl.Value; + } - public PatternWindow() - { - InitializeComponent(); - } + public int MaxDiff + { + set => maxDiffKnobControl.Value = value; + get => maxDiffKnobControl.Value; + } - public PatternWindow(LogWindow logWindow) - { - this.logWindow = logWindow; - InitializeComponent(); - recalcButton.Enabled = false; - } + public int MaxMisses + { + set => maxMissesKnobControl.Value = value; + get => maxMissesKnobControl.Value; + } - #endregion + public int Weight + { + set => weigthKnobControl.Value = value; + get => weigthKnobControl.Value; + } - #region Properties + #endregion - public int Fuzzy - { - set => fuzzyKnobControl.Value = value; - get => fuzzyKnobControl.Value; - } + #region Public methods - public int MaxDiff + public void SetBlockList(List flatBlockList, PatternArgs patternArgs) + { + this.patternArgs = patternArgs; + blockList.Clear(); + List singeList = []; + //int blockId = -1; + for (var i = 0; i < flatBlockList.Count; ++i) { - set => maxDiffKnobControl.Value = value; - get => maxDiffKnobControl.Value; + PatternBlock block = flatBlockList[i]; + singeList.Add(block); + //if (block.blockId != blockId) + //{ + // singeList = new List(); + // PatternBlock selfRefBlock = new PatternBlock(); + // selfRefBlock.targetStart = block.startLine; + // selfRefBlock.targetEnd = block.endLine; + // selfRefBlock.blockId = block.blockId; + // singeList.Add(selfRefBlock); + // singeList.Add(block); + // this.blockList.Add(singeList); + // blockId = block.blockId; + //} + //else + //{ + // singeList.Add(block); + //} } + blockList.Add(singeList); + Invoke(new MethodInvoker(SetBlockListGuiStuff)); + } - public int MaxMisses - { - set => maxMissesKnobControl.Value = value; - get => maxMissesKnobControl.Value; - } - public int Weight - { - set => weigthKnobControl.Value = value; - get => weigthKnobControl.Value; - } + public void SetColumnizer(ILogLineColumnizer columnizer) + { + logWindow.SetColumnizer(columnizer, patternHitsDataGridView); + logWindow.SetColumnizer(columnizer, contentDataGridView); + patternHitsDataGridView.Columns[0].Width = 20; + contentDataGridView.Columns[0].Width = 20; + + DataGridViewTextBoxColumn blockInfoColumn = new(); + blockInfoColumn.HeaderText = "Weight"; + blockInfoColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; + blockInfoColumn.Resizable = DataGridViewTriState.False; + blockInfoColumn.DividerWidth = 1; + blockInfoColumn.ReadOnly = true; + blockInfoColumn.Width = 50; + + DataGridViewTextBoxColumn contentInfoColumn = new(); + contentInfoColumn.HeaderText = "Diff"; + contentInfoColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; + contentInfoColumn.Resizable = DataGridViewTriState.False; + contentInfoColumn.DividerWidth = 1; + contentInfoColumn.ReadOnly = true; + contentInfoColumn.Width = 50; + + patternHitsDataGridView.Columns.Insert(1, blockInfoColumn); + contentDataGridView.Columns.Insert(1, contentInfoColumn); + } - #endregion + public void SetFont(string fontName, float fontSize) + { + Font font = new(new FontFamily(fontName), fontSize); + var lineSpacing = font.FontFamily.GetLineSpacing(FontStyle.Regular); + var lineSpacingPixel = font.Size * lineSpacing / font.FontFamily.GetEmHeight(FontStyle.Regular); + + patternHitsDataGridView.DefaultCellStyle.Font = font; + contentDataGridView.DefaultCellStyle.Font = font; + //this.lineHeight = font.Height + 4; + patternHitsDataGridView.RowTemplate.Height = font.Height + 4; + contentDataGridView.RowTemplate.Height = font.Height + 4; + } + + #endregion - #region Public methods + #region Private Methods - public void SetBlockList(List flatBlockList, PatternArgs patternArgs) + private void SetBlockListGuiStuff() + { + patternHitsDataGridView.RowCount = 0; + blockCountLabel.Text = "0"; + contentDataGridView.RowCount = 0; + blockLinesLabel.Text = "0"; + recalcButton.Enabled = true; + setRangeButton.Enabled = true; + if (blockList.Count > 0) { - this.patternArgs = patternArgs; - blockList.Clear(); - List singeList = []; - //int blockId = -1; - for (var i = 0; i < flatBlockList.Count; ++i) - { - PatternBlock block = flatBlockList[i]; - singeList.Add(block); - //if (block.blockId != blockId) - //{ - // singeList = new List(); - // PatternBlock selfRefBlock = new PatternBlock(); - // selfRefBlock.targetStart = block.startLine; - // selfRefBlock.targetEnd = block.endLine; - // selfRefBlock.blockId = block.blockId; - // singeList.Add(selfRefBlock); - // singeList.Add(block); - // this.blockList.Add(singeList); - // blockId = block.blockId; - //} - //else - //{ - // singeList.Add(block); - //} - } - blockList.Add(singeList); - Invoke(new MethodInvoker(SetBlockListGuiStuff)); + SetCurrentList(blockList[0]); } + } + private void SetCurrentList(List patternList) + { + patternHitsDataGridView.RowCount = 0; + currentList = patternList; + patternHitsDataGridView.RowCount = currentList.Count; + patternHitsDataGridView.Refresh(); + blockCountLabel.Text = "" + currentList.Count; + } - public void SetColumnizer(ILogLineColumnizer columnizer) - { - logWindow.SetColumnizer(columnizer, patternHitsDataGridView); - logWindow.SetColumnizer(columnizer, contentDataGridView); - patternHitsDataGridView.Columns[0].Width = 20; - contentDataGridView.Columns[0].Width = 20; - - DataGridViewTextBoxColumn blockInfoColumn = new(); - blockInfoColumn.HeaderText = "Weight"; - blockInfoColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - blockInfoColumn.Resizable = DataGridViewTriState.False; - blockInfoColumn.DividerWidth = 1; - blockInfoColumn.ReadOnly = true; - blockInfoColumn.Width = 50; - - DataGridViewTextBoxColumn contentInfoColumn = new(); - contentInfoColumn.HeaderText = "Diff"; - contentInfoColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - contentInfoColumn.Resizable = DataGridViewTriState.False; - contentInfoColumn.DividerWidth = 1; - contentInfoColumn.ReadOnly = true; - contentInfoColumn.Width = 50; - - patternHitsDataGridView.Columns.Insert(1, blockInfoColumn); - contentDataGridView.Columns.Insert(1, contentInfoColumn); - } + private int GetLineForHitGrid(int rowIndex) + { + int line; + line = currentList[rowIndex].targetStart; + return line; + } - public void SetFont(string fontName, float fontSize) - { - Font font = new(new FontFamily(fontName), fontSize); - var lineSpacing = font.FontFamily.GetLineSpacing(FontStyle.Regular); - var lineSpacingPixel = font.Size * lineSpacing / font.FontFamily.GetEmHeight(FontStyle.Regular); - - patternHitsDataGridView.DefaultCellStyle.Font = font; - contentDataGridView.DefaultCellStyle.Font = font; - //this.lineHeight = font.Height + 4; - patternHitsDataGridView.RowTemplate.Height = font.Height + 4; - contentDataGridView.RowTemplate.Height = font.Height + 4; - } + private int GetLineForContentGrid(int rowIndex) + { + int line; + line = currentBlock.targetStart + rowIndex; + return line; + } - #endregion + #endregion - #region Private Methods + #region Events handler - private void SetBlockListGuiStuff() + private void patternHitsDataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) + { + if (currentList == null || e.RowIndex < 0) { - patternHitsDataGridView.RowCount = 0; - blockCountLabel.Text = "0"; - contentDataGridView.RowCount = 0; - blockLinesLabel.Text = "0"; - recalcButton.Enabled = true; - setRangeButton.Enabled = true; - if (blockList.Count > 0) - { - SetCurrentList(blockList[0]); - } + return; } - - private void SetCurrentList(List patternList) + var rowIndex = GetLineForHitGrid(e.RowIndex); + var colIndex = e.ColumnIndex; + if (colIndex == 1) { - patternHitsDataGridView.RowCount = 0; - currentList = patternList; - patternHitsDataGridView.RowCount = currentList.Count; - patternHitsDataGridView.Refresh(); - blockCountLabel.Text = "" + currentList.Count; + e.Value = currentList[e.RowIndex].weigth; } - - private int GetLineForHitGrid(int rowIndex) + else { - int line; - line = currentList[rowIndex].targetStart; - return line; + if (colIndex > 1) + { + colIndex--; // correct the additional inserted col + } + e.Value = logWindow.GetCellValue(rowIndex, colIndex); } + } - private int GetLineForContentGrid(int rowIndex) + private void patternHitsDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) + { + if (currentList == null || e.RowIndex < 0) { - int line; - line = currentBlock.targetStart + rowIndex; - return line; + return; } - - #endregion - - #region Events handler - - private void patternHitsDataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) + if (e.ColumnIndex == 1) { - if (currentList == null || e.RowIndex < 0) + e.PaintBackground(e.CellBounds, false); + var selCount = patternArgs.EndLine - patternArgs.StartLine; + var maxWeight = patternArgs.MaxDiffInBlock * selCount + selCount; + if (maxWeight > 0) { - return; + var width = (int)((int)e.Value / (double)maxWeight * e.CellBounds.Width); + Rectangle rect = new(e.CellBounds.X, e.CellBounds.Y, width, e.CellBounds.Height); + var alpha = 90 + (int)((int)e.Value / (double)maxWeight * 165); + var color = Color.FromArgb(alpha, 170, 180, 150); + Brush brush = new SolidBrush(color); + rect.Inflate(-2, -1); + e.Graphics.FillRectangle(brush, rect); + brush.Dispose(); } + e.PaintContent(e.CellBounds); + e.Handled = true; + } + else + { + var gridView = (BufferedDataGridView)sender; var rowIndex = GetLineForHitGrid(e.RowIndex); - var colIndex = e.ColumnIndex; - if (colIndex == 1) - { - e.Value = currentList[e.RowIndex].weigth; - } - else - { - if (colIndex > 1) - { - colIndex--; // correct the additional inserted col - } - e.Value = logWindow.GetCellValue(rowIndex, colIndex); - } + logWindow.CellPainting(gridView, rowIndex, e); } + } - private void patternHitsDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) + private void patternHitsDataGridView_MouseDoubleClick(object sender, MouseEventArgs e) + { + //if (this.currentList == null || patternHitsDataGridView.CurrentRow == null) + // return; + //int rowIndex = GetLineForHitGrid(patternHitsDataGridView.CurrentRow.Index); + + //this.logWindow.SelectLogLine(rowIndex); + } + + private void patternHitsDataGridView_CurrentCellChanged(object sender, EventArgs e) + { + if (currentList == null || patternHitsDataGridView.CurrentRow == null) { - if (currentList == null || e.RowIndex < 0) - { - return; - } - if (e.ColumnIndex == 1) - { - e.PaintBackground(e.CellBounds, false); - var selCount = patternArgs.EndLine - patternArgs.StartLine; - var maxWeight = patternArgs.MaxDiffInBlock * selCount + selCount; - if (maxWeight > 0) - { - var width = (int)((int)e.Value / (double)maxWeight * e.CellBounds.Width); - Rectangle rect = new(e.CellBounds.X, e.CellBounds.Y, width, e.CellBounds.Height); - var alpha = 90 + (int)((int)e.Value / (double)maxWeight * 165); - var color = Color.FromArgb(alpha, 170, 180, 150); - Brush brush = new SolidBrush(color); - rect.Inflate(-2, -1); - e.Graphics.FillRectangle(brush, rect); - brush.Dispose(); - } - e.PaintContent(e.CellBounds); - e.Handled = true; - } - else - { - var gridView = (BufferedDataGridView)sender; - var rowIndex = GetLineForHitGrid(e.RowIndex); - logWindow.CellPainting(gridView, rowIndex, e); - } + return; } - - private void patternHitsDataGridView_MouseDoubleClick(object sender, MouseEventArgs e) + if (patternHitsDataGridView.CurrentRow.Index > currentList.Count - 1) { - //if (this.currentList == null || patternHitsDataGridView.CurrentRow == null) - // return; - //int rowIndex = GetLineForHitGrid(patternHitsDataGridView.CurrentRow.Index); - - //this.logWindow.SelectLogLine(rowIndex); + return; } + contentDataGridView.RowCount = 0; + currentBlock = currentList[patternHitsDataGridView.CurrentRow.Index]; + contentDataGridView.RowCount = currentBlock.targetEnd - currentBlock.targetStart + 1; + contentDataGridView.Refresh(); + contentDataGridView.CurrentCell = contentDataGridView.Rows[0].Cells[0]; + blockLinesLabel.Text = "" + contentDataGridView.RowCount; + } - private void patternHitsDataGridView_CurrentCellChanged(object sender, EventArgs e) + private void contentDataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) + { + if (currentBlock == null || e.RowIndex < 0) { - if (currentList == null || patternHitsDataGridView.CurrentRow == null) - { - return; - } - if (patternHitsDataGridView.CurrentRow.Index > currentList.Count - 1) - { - return; - } - contentDataGridView.RowCount = 0; - currentBlock = currentList[patternHitsDataGridView.CurrentRow.Index]; - contentDataGridView.RowCount = currentBlock.targetEnd - currentBlock.targetStart + 1; - contentDataGridView.Refresh(); - contentDataGridView.CurrentCell = contentDataGridView.Rows[0].Cells[0]; - blockLinesLabel.Text = "" + contentDataGridView.RowCount; + return; } - - private void contentDataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) + var rowIndex = GetLineForContentGrid(e.RowIndex); + var colIndex = e.ColumnIndex; + if (colIndex == 1) { - if (currentBlock == null || e.RowIndex < 0) - { - return; - } - var rowIndex = GetLineForContentGrid(e.RowIndex); - var colIndex = e.ColumnIndex; - if (colIndex == 1) + QualityInfo qi; + if (currentBlock.qualityInfoList.TryGetValue(rowIndex, out qi)) { - QualityInfo qi; - if (currentBlock.qualityInfoList.TryGetValue(rowIndex, out qi)) - { - e.Value = qi.quality; - } - else - { - e.Value = ""; - } + e.Value = qi.quality; } else { - if (colIndex != 0) - { - colIndex--; // adjust the inserted column - } - e.Value = logWindow.GetCellValue(rowIndex, colIndex); + e.Value = ""; } } - - private void contentDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) + else { - if (currentBlock == null || e.RowIndex < 0) + if (colIndex != 0) { - return; + colIndex--; // adjust the inserted column } - var gridView = (BufferedDataGridView)sender; - var rowIndex = GetLineForContentGrid(e.RowIndex); - logWindow.CellPainting(gridView, rowIndex, e); + e.Value = logWindow.GetCellValue(rowIndex, colIndex); } + } - private void contentDataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) + private void contentDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) + { + if (currentBlock == null || e.RowIndex < 0) { - if (currentBlock == null || contentDataGridView.CurrentRow == null) - { - return; - } - var rowIndex = GetLineForContentGrid(contentDataGridView.CurrentRow.Index); - - logWindow.SelectLogLine(rowIndex); + return; } + var gridView = (BufferedDataGridView)sender; + var rowIndex = GetLineForContentGrid(e.RowIndex); + logWindow.CellPainting(gridView, rowIndex, e); + } - private void recalcButton_Click(object sender, EventArgs e) + private void contentDataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) + { + if (currentBlock == null || contentDataGridView.CurrentRow == null) { - patternArgs.Fuzzy = fuzzyKnobControl.Value; - patternArgs.MaxDiffInBlock = maxDiffKnobControl.Value; - patternArgs.MaxMisses = maxMissesKnobControl.Value; - patternArgs.MinWeight = weigthKnobControl.Value; - logWindow.PatternStatistic(patternArgs); - recalcButton.Enabled = false; - setRangeButton.Enabled = false; + return; } + var rowIndex = GetLineForContentGrid(contentDataGridView.CurrentRow.Index); - private void closeButton_Click(object sender, EventArgs e) - { - Close(); - } + logWindow.SelectLogLine(rowIndex); + } - private void contentDataGridView_ColumnDividerDoubleClick(object sender, - DataGridViewColumnDividerDoubleClickEventArgs e) - { - e.Handled = true; - contentDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - } + private void recalcButton_Click(object sender, EventArgs e) + { + patternArgs.Fuzzy = fuzzyKnobControl.Value; + patternArgs.MaxDiffInBlock = maxDiffKnobControl.Value; + patternArgs.MaxMisses = maxMissesKnobControl.Value; + patternArgs.MinWeight = weigthKnobControl.Value; + logWindow.PatternStatistic(patternArgs); + recalcButton.Enabled = false; + setRangeButton.Enabled = false; + } - private void patternHitsDataGridView_ColumnDividerDoubleClick(object sender, - DataGridViewColumnDividerDoubleClickEventArgs e) - { - e.Handled = true; - patternHitsDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - } + private void closeButton_Click(object sender, EventArgs e) + { + Close(); + } - private void setRangeButton_Click(object sender, EventArgs e) - { - logWindow.PatternStatisticSelectRange(patternArgs); - recalcButton.Enabled = true; - rangeLabel.Text = "Start: " + patternArgs.StartLine + "\r\nEnd: " + patternArgs.EndLine; - } + private void contentDataGridView_ColumnDividerDoubleClick(object sender, + DataGridViewColumnDividerDoubleClickEventArgs e) + { + e.Handled = true; + contentDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + } - #endregion + private void patternHitsDataGridView_ColumnDividerDoubleClick(object sender, + DataGridViewColumnDividerDoubleClickEventArgs e) + { + e.Handled = true; + patternHitsDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); } + + private void setRangeButton_Click(object sender, EventArgs e) + { + logWindow.PatternStatisticSelectRange(patternArgs); + recalcButton.Enabled = true; + rangeLabel.Text = "Start: " + patternArgs.StartLine + "\r\nEnd: " + patternArgs.EndLine; + } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs b/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs index 726c072c..8fe836d7 100644 --- a/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs +++ b/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs @@ -7,100 +7,99 @@ using Range = LogExpert.Core.Entities.Range; -namespace LogExpert.UI.Controls.LogWindow +namespace LogExpert.UI.Controls.LogWindow; + +/// +/// Delivers the range (from..to) that matches the current range filter settings starting from a given line. +/// +public class RangeFinder(FilterParams filterParams, ColumnizerCallback callback) { - /// - /// Delivers the range (from..to) that matches the current range filter settings starting from a given line. - /// - public class RangeFinder(FilterParams filterParams, ColumnizerCallback callback) - { - #region Fields + #region Fields - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - private readonly FilterParams _filterParams = filterParams.CloneWithCurrentColumnizer(); + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private readonly FilterParams _filterParams = filterParams.CloneWithCurrentColumnizer(); - #endregion + #endregion - #region Public methods + #region Public methods + + public Range FindRange(int startLine) + { + _logger.Info($"Starting range search for {_filterParams.SearchText} ... {_filterParams.RangeSearchText}"); - public Range FindRange(int startLine) + if (_filterParams.RangeSearchText == null || _filterParams.RangeSearchText.Trim().Length == 0) { - _logger.Info($"Starting range search for {_filterParams.SearchText} ... {_filterParams.RangeSearchText}"); + _logger.Info("Range search text not set. Cancelling range search."); + return null; + } + if (_filterParams.SearchText == null || _filterParams.SearchText.Trim().Length == 0) + { + _logger.Info("Search text not set. Cancelling range search."); + return null; + } - if (_filterParams.RangeSearchText == null || _filterParams.RangeSearchText.Trim().Length == 0) - { - _logger.Info("Range search text not set. Cancelling range search."); - return null; - } - if (_filterParams.SearchText == null || _filterParams.SearchText.Trim().Length == 0) - { - _logger.Info("Search text not set. Cancelling range search."); - return null; - } + _filterParams.IsRangeSearch = false; + _filterParams.IsInRange = false; - _filterParams.IsRangeSearch = false; - _filterParams.IsInRange = false; + var lineCount = callback.GetLineCount(); + var lineNum = startLine; + var foundStartLine = false; - var lineCount = callback.GetLineCount(); - var lineNum = startLine; - var foundStartLine = false; + Range range = new(); + FilterParams tmpParam = _filterParams.CloneWithCurrentColumnizer(); - Range range = new(); - FilterParams tmpParam = _filterParams.CloneWithCurrentColumnizer(); + tmpParam.SearchText = _filterParams.RangeSearchText; - tmpParam.SearchText = _filterParams.RangeSearchText; + // search backward for starting keyword + var line = callback.GetLogLine(lineNum); - // search backward for starting keyword - var line = callback.GetLogLine(lineNum); + while (lineNum >= 0) + { + callback.LineNum = lineNum; - while (lineNum >= 0) + if (Util.TestFilterCondition(_filterParams, line, callback)) { - callback.LineNum = lineNum; - - if (Util.TestFilterCondition(_filterParams, line, callback)) - { - foundStartLine = true; - break; - } - lineNum--; - line = callback.GetLogLine(lineNum); - - if (lineNum < 0 || Util.TestFilterCondition(tmpParam, line, callback)) // do not crash on Ctrl+R when there is not start line found - { - // lower range bound found --> we are not in between a valid range - break; - } + foundStartLine = true; + break; } + lineNum--; + line = callback.GetLogLine(lineNum); - if (!foundStartLine) + if (lineNum < 0 || Util.TestFilterCondition(tmpParam, line, callback)) // do not crash on Ctrl+R when there is not start line found { - _logger.Info("Range start not found"); - return null; + // lower range bound found --> we are not in between a valid range + break; } + } - range.StartLine = lineNum; - _filterParams.IsRangeSearch = true; - _filterParams.IsInRange = true; - lineNum++; + if (!foundStartLine) + { + _logger.Info("Range start not found"); + return null; + } + + range.StartLine = lineNum; + _filterParams.IsRangeSearch = true; + _filterParams.IsInRange = true; + lineNum++; - while (lineNum < lineCount) + while (lineNum < lineCount) + { + line = callback.GetLogLine(lineNum); + callback.LineNum = lineNum; + if (!Util.TestFilterCondition(_filterParams, line, callback)) { - line = callback.GetLogLine(lineNum); - callback.LineNum = lineNum; - if (!Util.TestFilterCondition(_filterParams, line, callback)) - { - break; - } - lineNum++; + break; } - lineNum--; - range.EndLine = lineNum; - - _logger.Info($"Range search finished. Found {range.EndLine - range.StartLine} lines"); - - return range; + lineNum++; } + lineNum--; + range.EndLine = lineNum; + + _logger.Info($"Range search finished. Found {range.EndLine - range.StartLine} lines"); - #endregion + return range; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs index 93ae8c72..58c71e58 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs @@ -9,446 +9,445 @@ using System.Threading; using System.Threading.Tasks; -namespace LogExpert.UI.Controls.LogWindow +namespace LogExpert.UI.Controls.LogWindow; + +internal class TimeSpreadCalculator { - internal class TimeSpreadCalculator - { - #region Fields + #region Fields - private const int INACTIVITY_TIME = 2000; + private const int INACTIVITY_TIME = 2000; - private const int MAX_CONTRAST = 1300; - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private const int MAX_CONTRAST = 1300; + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - private readonly EventWaitHandle _calcEvent = new ManualResetEvent(false); - private readonly ColumnizerCallback _callback; + private readonly EventWaitHandle _calcEvent = new ManualResetEvent(false); + private readonly ColumnizerCallback _callback; - private readonly object _diffListLock = new(); - private readonly EventWaitHandle _lineCountEvent = new ManualResetEvent(false); + private readonly object _diffListLock = new(); + private readonly EventWaitHandle _lineCountEvent = new ManualResetEvent(false); - //TODO Refactor that it does not need LogWindow - private readonly ILogWindow _logWindow; + //TODO Refactor that it does not need LogWindow + private readonly ILogWindow _logWindow; - // for DoCalc_via_Time - private double _average; + // for DoCalc_via_Time + private double _average; - private int _contrast = 400; - private int _displayHeight; - private bool _enabled; - private DateTime _endTimestamp; - private int _lineCount; - private int _maxDiff; - private TimeSpan _maxSpan; - private bool _shouldStop; - private CancellationTokenSource cts = new(); + private int _contrast = 400; + private int _displayHeight; + private bool _enabled; + private DateTime _endTimestamp; + private int _lineCount; + private int _maxDiff; + private TimeSpan _maxSpan; + private bool _shouldStop; + private CancellationTokenSource cts = new(); - private DateTime _startTimestamp; + private DateTime _startTimestamp; - private bool _timeMode = true; + private bool _timeMode = true; - // for DoCalc - private int _timePerLine; + // for DoCalc + private int _timePerLine; - #endregion + #endregion - #region cTor + #region cTor - public TimeSpreadCalculator(ILogWindow logWindow) - { - _logWindow = logWindow; - _callback = new ColumnizerCallback(_logWindow); + public TimeSpreadCalculator(ILogWindow logWindow) + { + _logWindow = logWindow; + _callback = new ColumnizerCallback(_logWindow); - Task.Run(WorkerFx, cts.Token); - } + Task.Run(WorkerFx, cts.Token); + } - #endregion + #endregion - #region Delegates + #region Delegates - public delegate void CalcDoneEventHandler(object sender, EventArgs e); + public delegate void CalcDoneEventHandler(object sender, EventArgs e); - public delegate void StartCalcEventHandler(object sender, EventArgs e); + public delegate void StartCalcEventHandler(object sender, EventArgs e); - #endregion + #endregion - #region Events + #region Events - public event CalcDoneEventHandler CalcDone; - public event StartCalcEventHandler StartCalc; + public event CalcDoneEventHandler CalcDone; + public event StartCalcEventHandler StartCalc; - #endregion + #endregion - #region Properties + #region Properties - public bool Enabled + public bool Enabled + { + get => _enabled; + set { - get => _enabled; - set + _enabled = value; + if (_enabled) { - _enabled = value; - if (_enabled) - { - _calcEvent.Set(); - _lineCountEvent.Set(); - } + _calcEvent.Set(); + _lineCountEvent.Set(); } } + } - public bool TimeMode + public bool TimeMode + { + get => _timeMode; + set { - get => _timeMode; - set + _timeMode = value; + if (_enabled) { - _timeMode = value; - if (_enabled) - { - _calcEvent.Set(); - _lineCountEvent.Set(); - } + _calcEvent.Set(); + _lineCountEvent.Set(); } } + } - public int Contrast + public int Contrast + { + set { - set + _contrast = value; + if (_contrast < 0) { - _contrast = value; - if (_contrast < 0) - { - _contrast = 0; - } - else if (_contrast > MAX_CONTRAST) - { - _contrast = MAX_CONTRAST; - } - - if (TimeMode) - { - CalcValuesViaTime(_maxDiff, _average); - } - else - { - CalcValuesViaLines(_timePerLine, _maxSpan); - } - OnCalcDone(EventArgs.Empty); + _contrast = 0; + } + else if (_contrast > MAX_CONTRAST) + { + _contrast = MAX_CONTRAST; } - get => _contrast; + if (TimeMode) + { + CalcValuesViaTime(_maxDiff, _average); + } + else + { + CalcValuesViaLines(_timePerLine, _maxSpan); + } + OnCalcDone(EventArgs.Empty); } - public List DiffList { get; set; } = []; + get => _contrast; + } + + public List DiffList { get; set; } = []; + + #endregion - #endregion + #region Public methods - #region Public methods + public void Stop() + { + _shouldStop = true; + _lineCountEvent.Set(); + cts.Cancel(); + } - public void Stop() + public void SetLineCount(int count) + { + _lineCount = count; + if (Enabled) { - _shouldStop = true; + _calcEvent.Set(); _lineCountEvent.Set(); - cts.Cancel(); } + } - public void SetLineCount(int count) + public void SetDisplayHeight(int height) + { + _displayHeight = height; + if (Enabled) { - _lineCount = count; - if (Enabled) - { - _calcEvent.Set(); - _lineCountEvent.Set(); - } + _calcEvent.Set(); + _lineCountEvent.Set(); } + } - public void SetDisplayHeight(int height) - { - _displayHeight = height; - if (Enabled) - { - _calcEvent.Set(); - _lineCountEvent.Set(); - } - } + #endregion - #endregion + #region Private Methods - #region Private Methods + private void WorkerFx() + { + //Thread.CurrentThread.Name = "TimeSpreadCalculator Worker"; + //Thread.CurrentThread.Priority = ThreadPriority.BelowNormal; - private void WorkerFx() + while (!_shouldStop) { - //Thread.CurrentThread.Name = "TimeSpreadCalculator Worker"; - //Thread.CurrentThread.Priority = ThreadPriority.BelowNormal; + // wait for wakeup + _lineCountEvent.WaitOne(); while (!_shouldStop) { - // wait for wakeup - _lineCountEvent.WaitOne(); - - while (!_shouldStop) + // wait for unbusy moments + _logger.Debug("TimeSpreadCalculator: wait for unbusy moments"); + var signaled = _calcEvent.WaitOne(INACTIVITY_TIME, false); + if (signaled == false) { - // wait for unbusy moments - _logger.Debug("TimeSpreadCalculator: wait for unbusy moments"); - var signaled = _calcEvent.WaitOne(INACTIVITY_TIME, false); - if (signaled == false) + _logger.Debug("TimeSpreadCalculator: unbusy. starting calc."); + if (TimeMode) { - _logger.Debug("TimeSpreadCalculator: unbusy. starting calc."); - if (TimeMode) - { - DoCalc_via_Time(); - } - else - { - DoCalc(); - } - break; + DoCalc_via_Time(); } - - _logger.Debug("TimeSpreadCalculator: signalled. no calc."); - _calcEvent.Reset(); + else + { + DoCalc(); + } + break; } - _lineCountEvent.Reset(); + + _logger.Debug("TimeSpreadCalculator: signalled. no calc."); + _calcEvent.Reset(); } + _lineCountEvent.Reset(); } + } - private void DoCalc() + private void DoCalc() + { + OnStartCalc(EventArgs.Empty); + _logger.Debug("TimeSpreadCalculator.DoCalc() begin"); + + if (_callback.GetLineCount() < 1) { - OnStartCalc(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc() begin"); + OnCalcDone(EventArgs.Empty); + _logger.Debug("TimeSpreadCalculator.DoCalc() end because of line count < 1"); + return; + } - if (_callback.GetLineCount() < 1) - { - OnCalcDone(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc() end because of line count < 1"); - return; - } + var lineNum = 0; + var lastLineNum = _callback.GetLineCount() - 1; + _startTimestamp = _logWindow.GetTimestampForLineForward(ref lineNum, false); + _endTimestamp = _logWindow.GetTimestampForLine(ref lastLineNum, false); - var lineNum = 0; - var lastLineNum = _callback.GetLineCount() - 1; - _startTimestamp = _logWindow.GetTimestampForLineForward(ref lineNum, false); - _endTimestamp = _logWindow.GetTimestampForLine(ref lastLineNum, false); + var timePerLineSum = 0; - var timePerLineSum = 0; + if (_startTimestamp != DateTime.MinValue && _endTimestamp != DateTime.MinValue) + { + TimeSpan overallSpan = _endTimestamp - _startTimestamp; + var overallSpanMillis = (int)(overallSpan.Ticks / TimeSpan.TicksPerMillisecond); + _timePerLine = (int)Math.Round(overallSpanMillis / (double)_lineCount); + DateTime oldTime = _logWindow.GetTimestampForLineForward(ref lineNum, false); + int step; - if (_startTimestamp != DateTime.MinValue && _endTimestamp != DateTime.MinValue) + if (_lineCount > _displayHeight) { - TimeSpan overallSpan = _endTimestamp - _startTimestamp; - var overallSpanMillis = (int)(overallSpan.Ticks / TimeSpan.TicksPerMillisecond); - _timePerLine = (int)Math.Round(overallSpanMillis / (double)_lineCount); - DateTime oldTime = _logWindow.GetTimestampForLineForward(ref lineNum, false); - int step; - - if (_lineCount > _displayHeight) - { - step = (int)Math.Round(_lineCount / (double)_displayHeight); - } - else - { - step = 1; - } - - _logger.Debug("TimeSpreadCalculator.DoCalc() collecting data for {0} lines with step size {1}", lastLineNum, step); - - List newDiffList = []; - List maxList = []; - lineNum++; + step = (int)Math.Round(_lineCount / (double)_displayHeight); + } + else + { + step = 1; + } - for (var i = lineNum; i < lastLineNum; i += step) - { - var currLineNum = i; - DateTime time = _logWindow.GetTimestampForLineForward(ref currLineNum, false); - if (time != DateTime.MinValue) - { - TimeSpan span = time - oldTime; - maxList.Add(span); - timePerLineSum += (int)(span.Ticks / TimeSpan.TicksPerMillisecond); - newDiffList.Add(new SpreadEntry(i, 0, time)); - oldTime = time; - _logger.Debug("TimeSpreadCalculator.DoCalc() time diff {0}", span); - } - } + _logger.Debug("TimeSpreadCalculator.DoCalc() collecting data for {0} lines with step size {1}", lastLineNum, step); - if (maxList.Count > 3) - { - maxList.Sort(); - _maxSpan = maxList[^3]; - } + List newDiffList = []; + List maxList = []; + lineNum++; - lock (_diffListLock) + for (var i = lineNum; i < lastLineNum; i += step) + { + var currLineNum = i; + DateTime time = _logWindow.GetTimestampForLineForward(ref currLineNum, false); + if (time != DateTime.MinValue) { - DiffList = newDiffList; - _timePerLine = (int)Math.Round(timePerLineSum / ((double)(lastLineNum + 1) / step)); - CalcValuesViaLines(_timePerLine, _maxSpan); - OnCalcDone(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc() end"); + TimeSpan span = time - oldTime; + maxList.Add(span); + timePerLineSum += (int)(span.Ticks / TimeSpan.TicksPerMillisecond); + newDiffList.Add(new SpreadEntry(i, 0, time)); + oldTime = time; + _logger.Debug("TimeSpreadCalculator.DoCalc() time diff {0}", span); } } - } - - //TODO Refactor this method - private void DoCalc_via_Time() - { - OnStartCalc(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() begin"); - if (_callback.GetLineCount() < 1) + if (maxList.Count > 3) { - OnCalcDone(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc() end because of line count < 1"); - return; + maxList.Sort(); + _maxSpan = maxList[^3]; } - var lineNum = 0; - var lastLineNum = _callback.GetLineCount() - 1; - _startTimestamp = _logWindow.GetTimestampForLineForward(ref lineNum, false); - _endTimestamp = _logWindow.GetTimestampForLine(ref lastLineNum, false); - - if (_startTimestamp != DateTime.MinValue && _endTimestamp != DateTime.MinValue) + lock (_diffListLock) { - TimeSpan overallSpan = _endTimestamp - _startTimestamp; - var overallSpanMillis = overallSpan.Ticks / TimeSpan.TicksPerMillisecond; - //int timePerLine = (int)Math.Round((double)overallSpanMillis / (double)this.lineCount); + DiffList = newDiffList; + _timePerLine = (int)Math.Round(timePerLineSum / ((double)(lastLineNum + 1) / step)); + CalcValuesViaLines(_timePerLine, _maxSpan); + OnCalcDone(EventArgs.Empty); + _logger.Debug("TimeSpreadCalculator.DoCalc() end"); + } + } + } - long step; + //TODO Refactor this method + private void DoCalc_via_Time() + { + OnStartCalc(EventArgs.Empty); + _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() begin"); - if (overallSpanMillis > _displayHeight) - { - step = (long)Math.Round(overallSpanMillis / (double)_displayHeight); - } - else - { - step = 1; - } + if (_callback.GetLineCount() < 1) + { + OnCalcDone(EventArgs.Empty); + _logger.Debug("TimeSpreadCalculator.DoCalc() end because of line count < 1"); + return; + } - _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() time range is {0} ms", overallSpanMillis); + var lineNum = 0; + var lastLineNum = _callback.GetLineCount() - 1; + _startTimestamp = _logWindow.GetTimestampForLineForward(ref lineNum, false); + _endTimestamp = _logWindow.GetTimestampForLine(ref lastLineNum, false); - lineNum = 0; - DateTime searchTimeStamp = _startTimestamp; - var oldLineNum = lineNum; - var loopCount = 0; - var lineDiffSum = 0; - var minDiff = int.MaxValue; - _maxDiff = 0; - List maxList = []; - List newDiffList = []; + if (_startTimestamp != DateTime.MinValue && _endTimestamp != DateTime.MinValue) + { + TimeSpan overallSpan = _endTimestamp - _startTimestamp; + var overallSpanMillis = overallSpan.Ticks / TimeSpan.TicksPerMillisecond; + //int timePerLine = (int)Math.Round((double)overallSpanMillis / (double)this.lineCount); - while (searchTimeStamp.CompareTo(_endTimestamp) <= 0) - { - lineNum = _logWindow.FindTimestampLine_Internal(lineNum, lineNum, lastLineNum, searchTimeStamp, false); - if (lineNum < 0) - { - lineNum = -lineNum; - } - var lineDiff = lineNum - oldLineNum; + long step; - _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() test time {0:HH:mm:ss.fff} line diff={1}", searchTimeStamp, lineDiff); + if (overallSpanMillis > _displayHeight) + { + step = (long)Math.Round(overallSpanMillis / (double)_displayHeight); + } + else + { + step = 1; + } - if (lineDiff >= 0) - { - lineDiffSum += lineDiff; - newDiffList.Add(new SpreadEntry(lineNum, lineDiff, searchTimeStamp)); - - if (lineDiff < minDiff) - { - minDiff = lineDiff; - } - - if (lineDiff > _maxDiff) - { - _maxDiff = lineDiff; - } - maxList.Add(lineDiff); - loopCount++; - } + _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() time range is {0} ms", overallSpanMillis); - searchTimeStamp = searchTimeStamp.AddMilliseconds(step); - oldLineNum = lineNum; - //lineNum++; - } + lineNum = 0; + DateTime searchTimeStamp = _startTimestamp; + var oldLineNum = lineNum; + var loopCount = 0; + var lineDiffSum = 0; + var minDiff = int.MaxValue; + _maxDiff = 0; + List maxList = []; + List newDiffList = []; - if (maxList.Count > 3) + while (searchTimeStamp.CompareTo(_endTimestamp) <= 0) + { + lineNum = _logWindow.FindTimestampLine_Internal(lineNum, lineNum, lastLineNum, searchTimeStamp, false); + if (lineNum < 0) { - maxList.Sort(); - _maxDiff = maxList[^3]; + lineNum = -lineNum; } + var lineDiff = lineNum - oldLineNum; - _average = lineDiffSum / (double)loopCount; - //double average = maxList[maxList.Count / 2]; - _logger.Debug("Average diff={0} minDiff={1} maxDiff={2}", _average, minDiff, _maxDiff); + _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() test time {0:HH:mm:ss.fff} line diff={1}", searchTimeStamp, lineDiff); - lock (_diffListLock) + if (lineDiff >= 0) { - if (newDiffList.Count > 0) + lineDiffSum += lineDiff; + newDiffList.Add(new SpreadEntry(lineNum, lineDiff, searchTimeStamp)); + + if (lineDiff < minDiff) { - newDiffList.RemoveAt(0); + minDiff = lineDiff; } - if (newDiffList.Count > 0) + if (lineDiff > _maxDiff) { - newDiffList.RemoveAt(0); + _maxDiff = lineDiff; } - - DiffList = newDiffList; - CalcValuesViaTime(_maxDiff, _average); - OnCalcDone(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() end"); + maxList.Add(lineDiff); + loopCount++; } - } - } - private DateTime CalcValuesViaLines(int timePerLine, TimeSpan maxSpan) - { - DateTime oldTime = DateTime.MinValue; + searchTimeStamp = searchTimeStamp.AddMilliseconds(step); + oldLineNum = lineNum; + //lineNum++; + } - if (DiffList.Count > 0) + if (maxList.Count > 3) { - oldTime = DiffList[0].Timestamp; + maxList.Sort(); + _maxDiff = maxList[^3]; + } - foreach (SpreadEntry entry in DiffList) - { - TimeSpan span = entry.Timestamp - oldTime; - double diffFromAverage = (int)(span.Ticks / TimeSpan.TicksPerMillisecond) - timePerLine; + _average = lineDiffSum / (double)loopCount; + //double average = maxList[maxList.Count / 2]; + _logger.Debug("Average diff={0} minDiff={1} maxDiff={2}", _average, minDiff, _maxDiff); - if (diffFromAverage < 0) - { - diffFromAverage = 0; - } + lock (_diffListLock) + { + if (newDiffList.Count > 0) + { + newDiffList.RemoveAt(0); + } - var value = (int)(diffFromAverage / (timePerLine / TimeSpan.TicksPerMillisecond) * _contrast); - entry.Value = 255 - value; - oldTime = entry.Timestamp; + if (newDiffList.Count > 0) + { + newDiffList.RemoveAt(0); } - } - return oldTime; + DiffList = newDiffList; + CalcValuesViaTime(_maxDiff, _average); + OnCalcDone(EventArgs.Empty); + _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() end"); + } } + } - private void CalcValuesViaTime(int maxDiff, double average) + private DateTime CalcValuesViaLines(int timePerLine, TimeSpan maxSpan) + { + DateTime oldTime = DateTime.MinValue; + + if (DiffList.Count > 0) { + oldTime = DiffList[0].Timestamp; + foreach (SpreadEntry entry in DiffList) { - var lineDiff = entry.Diff; - var diffFromAverage = entry.Diff - average; + TimeSpan span = entry.Timestamp - oldTime; + double diffFromAverage = (int)(span.Ticks / TimeSpan.TicksPerMillisecond) - timePerLine; if (diffFromAverage < 0) { diffFromAverage = 0; } - var value = (int)(diffFromAverage / maxDiff * _contrast); - entry.Value = 255 - value; - _logger.Debug("TimeSpreadCalculator.DoCalc() test time {0:HH:mm:ss.fff} line diff={1} value={2}", entry.Timestamp, lineDiff, value); + var value = (int)(diffFromAverage / (timePerLine / TimeSpan.TicksPerMillisecond) * _contrast); + entry.Value = 255 - value; + oldTime = entry.Timestamp; } } - private void OnCalcDone(EventArgs e) - { - CalcDone?.Invoke(this, e); - } + return oldTime; + } - private void OnStartCalc(EventArgs e) + private void CalcValuesViaTime(int maxDiff, double average) + { + foreach (SpreadEntry entry in DiffList) { - StartCalc?.Invoke(this, e); + var lineDiff = entry.Diff; + var diffFromAverage = entry.Diff - average; + + if (diffFromAverage < 0) + { + diffFromAverage = 0; + } + var value = (int)(diffFromAverage / maxDiff * _contrast); + entry.Value = 255 - value; + + _logger.Debug("TimeSpreadCalculator.DoCalc() test time {0:HH:mm:ss.fff} line diff={1} value={2}", entry.Timestamp, lineDiff, value); } + } - #endregion + private void OnCalcDone(EventArgs e) + { + CalcDone?.Invoke(this, e); } + + private void OnStartCalc(EventArgs e) + { + StartCalc?.Invoke(this, e); + } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs index 4f4eaaed..952136e7 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs @@ -3,304 +3,303 @@ using LogExpert.UI.Extensions; using NLog; -namespace LogExpert.UI.Controls.LogWindow +namespace LogExpert.UI.Controls.LogWindow; + +internal partial class TimeSpreadingControl : UserControl { - internal partial class TimeSpreadingControl : UserControl - { - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - #region Fields + #region Fields - private Bitmap _bitmap = new(1, 1); - private int _displayHeight = 1; - private readonly int _edgeOffset = (int)Win32.GetSystemMetricsForDpi(Win32.SM_CYVSCROLL); - private int _lastMouseY; - private readonly object _monitor = new(); - private int _rectHeight = 1; + private Bitmap _bitmap = new(1, 1); + private int _displayHeight = 1; + private readonly int _edgeOffset = (int)Win32.GetSystemMetricsForDpi(Win32.SM_CYVSCROLL); + private int _lastMouseY; + private readonly object _monitor = new(); + private int _rectHeight = 1; - private TimeSpreadCalculator _timeSpreadCalc; - private readonly ToolTip _toolTip; + private TimeSpreadCalculator _timeSpreadCalc; + private readonly ToolTip _toolTip; - #endregion + #endregion - #region cTor + #region cTor - public TimeSpreadingControl() - { - InitializeComponent(); - _toolTip = new ToolTip(); - Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - _toolTip.InitialDelay = 0; - _toolTip.ReshowDelay = 0; - _toolTip.ShowAlways = true; - DoubleBuffered = false; - } + public TimeSpreadingControl() + { + InitializeComponent(); + _toolTip = new ToolTip(); + Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); + _toolTip.InitialDelay = 0; + _toolTip.ReshowDelay = 0; + _toolTip.ShowAlways = true; + DoubleBuffered = false; + } - #endregion + #endregion - #region Delegates + #region Delegates - public delegate void LineSelectedEventHandler(object sender, SelectLineEventArgs e); + public delegate void LineSelectedEventHandler(object sender, SelectLineEventArgs e); - #endregion + #endregion - #region Events + #region Events - public event LineSelectedEventHandler LineSelected; + public event LineSelectedEventHandler LineSelected; - #endregion + #endregion - #region Properties + #region Properties - public bool ReverseAlpha { get; set; } + public bool ReverseAlpha { get; set; } - internal TimeSpreadCalculator TimeSpreadCalc + internal TimeSpreadCalculator TimeSpreadCalc + { + get => _timeSpreadCalc; + set { - get => _timeSpreadCalc; - set - { - //timeSpreadCalc.CalcDone -= timeSpreadCalc_CalcDone; - _timeSpreadCalc = value; - _timeSpreadCalc.CalcDone += TimeSpreadCalc_CalcDone; - _timeSpreadCalc.StartCalc += TimeSpreadCalc_StartCalc; - } + //timeSpreadCalc.CalcDone -= timeSpreadCalc_CalcDone; + _timeSpreadCalc = value; + _timeSpreadCalc.CalcDone += TimeSpreadCalc_CalcDone; + _timeSpreadCalc.StartCalc += TimeSpreadCalc_StartCalc; } + } - #endregion + #endregion - #region Overrides + #region Overrides - protected override void OnPaint(PaintEventArgs e) + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + lock (_monitor) { - base.OnPaint(e); - lock (_monitor) + if (DesignMode) { - if (DesignMode) - { - Brush bgBrush = new SolidBrush(Color.FromKnownColor(KnownColor.LightSkyBlue)); - Rectangle rect = ClientRectangle; - rect.Inflate(0, -_edgeOffset); - e.Graphics.FillRectangle(bgBrush, rect); - bgBrush.Dispose(); - } - else - { - e.Graphics.DrawImage(_bitmap, 0, _edgeOffset); - } + Brush bgBrush = new SolidBrush(Color.FromKnownColor(KnownColor.LightSkyBlue)); + Rectangle rect = ClientRectangle; + rect.Inflate(0, -_edgeOffset); + e.Graphics.FillRectangle(bgBrush, rect); + bgBrush.Dispose(); + } + else + { + e.Graphics.DrawImage(_bitmap, 0, _edgeOffset); } } + } - #endregion + #endregion - #region Private Methods + #region Private Methods - private SpreadEntry GetEntryForMouse(MouseEventArgs e) + private SpreadEntry GetEntryForMouse(MouseEventArgs e) + { + List list = TimeSpreadCalc.DiffList; + var y = e.Y - _edgeOffset; + if (y < 0) { - List list = TimeSpreadCalc.DiffList; - var y = e.Y - _edgeOffset; - if (y < 0) - { - y = 0; - } - else if (y >= ClientRectangle.Height - _edgeOffset * 3) - { - y = list.Count - 1; - } - else - { - y /= _rectHeight; - } - - lock (_monitor) - { - if (y >= list.Count || y < 0) - { - return null; - } - return list[y]; - } + y = 0; + } + else if (y >= ClientRectangle.Height - _edgeOffset * 3) + { + y = list.Count - 1; + } + else + { + y /= _rectHeight; } - private void DragContrast(MouseEventArgs e) + lock (_monitor) { - if (_lastMouseY == 0) + if (y >= list.Count || y < 0) { - _lastMouseY = _lastMouseY = e.Y; - return; + return null; } - _timeSpreadCalc.Contrast += (_lastMouseY - e.Y) * 5; - _lastMouseY = e.Y; + return list[y]; } + } - private void OnLineSelected(SelectLineEventArgs e) + private void DragContrast(MouseEventArgs e) + { + if (_lastMouseY == 0) { - LineSelected?.Invoke(this, e); + _lastMouseY = _lastMouseY = e.Y; + return; } + _timeSpreadCalc.Contrast += (_lastMouseY - e.Y) * 5; + _lastMouseY = e.Y; + } + + private void OnLineSelected(SelectLineEventArgs e) + { + LineSelected?.Invoke(this, e); + } - #endregion + #endregion - #region Events handler + #region Events handler - private void TimeSpreadCalc_CalcDone(object sender, EventArgs e) + private void TimeSpreadCalc_CalcDone(object sender, EventArgs e) + { + _logger.Debug("timeSpreadCalc_CalcDone()"); + + lock (_monitor) { - _logger.Debug("timeSpreadCalc_CalcDone()"); + Invalidate(); + Rectangle rect = ClientRectangle; + rect.Size = new Size(rect.Width, rect.Height - _edgeOffset * 3); - lock (_monitor) + if (rect.Height < 1) { - Invalidate(); - Rectangle rect = ClientRectangle; - rect.Size = new Size(rect.Width, rect.Height - _edgeOffset * 3); + return; + } - if (rect.Height < 1) - { - return; - } + _bitmap = new Bitmap(rect.Width, rect.Height); + var gfx = Graphics.FromImage(_bitmap); + Brush bgBrush = new SolidBrush(BackColor); + gfx.FillRectangle(bgBrush, rect); + bgBrush.Dispose(); - _bitmap = new Bitmap(rect.Width, rect.Height); - var gfx = Graphics.FromImage(_bitmap); - Brush bgBrush = new SolidBrush(BackColor); - gfx.FillRectangle(bgBrush, rect); - bgBrush.Dispose(); + List list = TimeSpreadCalc.DiffList; + int step; - List list = TimeSpreadCalc.DiffList; - int step; + if (list.Count >= _displayHeight) + { + step = (int)Math.Round(list.Count / (double)_displayHeight); + _rectHeight = 1; + } + else + { + step = 1; + _rectHeight = (int)Math.Round(_displayHeight / (double)list.Count); + } - if (list.Count >= _displayHeight) - { - step = (int)Math.Round(list.Count / (double)_displayHeight); - _rectHeight = 1; - } - else + Rectangle fillRect = new(0, 0, rect.Width, _rectHeight); + + lock (list) + { + for (var i = 0; i < list.Count; i += step) { - step = 1; - _rectHeight = (int)Math.Round(_displayHeight / (double)list.Count); - } + SpreadEntry entry = list[i]; + var color = ReverseAlpha ? entry.Value : 255 - entry.Value; - Rectangle fillRect = new(0, 0, rect.Width, _rectHeight); + if (color > 255) + { + color = 255; + } - lock (list) - { - for (var i = 0; i < list.Count; i += step) + if (color < 0) { - SpreadEntry entry = list[i]; - var color = ReverseAlpha ? entry.Value : 255 - entry.Value; - - if (color > 255) - { - color = 255; - } - - if (color < 0) - { - color = 0; - } - - Brush brush = new SolidBrush(Color.FromArgb(color, ForeColor)); - //Brush brush = new SolidBrush(Color.FromArgb(color, color, color, color)); - gfx.FillRectangle(brush, fillRect); - brush.Dispose(); - fillRect.Offset(0, _rectHeight); + color = 0; } + + Brush brush = new SolidBrush(Color.FromArgb(color, ForeColor)); + //Brush brush = new SolidBrush(Color.FromArgb(color, color, color, color)); + gfx.FillRectangle(brush, fillRect); + brush.Dispose(); + fillRect.Offset(0, _rectHeight); } } - BeginInvoke(new MethodInvoker(Refresh)); } + BeginInvoke(new MethodInvoker(Refresh)); + } - private void TimeSpreadCalc_StartCalc(object sender, EventArgs e) + private void TimeSpreadCalc_StartCalc(object sender, EventArgs e) + { + lock (_monitor) { - lock (_monitor) - { - Invalidate(); - Rectangle rect = ClientRectangle; - rect.Size = new Size(rect.Width, rect.Height - _edgeOffset * 3); + Invalidate(); + Rectangle rect = ClientRectangle; + rect.Size = new Size(rect.Width, rect.Height - _edgeOffset * 3); - if (rect.Height < 1) - { - return; - } - - //this.bmp = new Bitmap(rect.Width, rect.Height); - var gfx = Graphics.FromImage(_bitmap); + if (rect.Height < 1) + { + return; + } - Brush bgBrush = new SolidBrush(BackColor); - Brush fgBrush = new SolidBrush(ForeColor); - //gfx.FillRectangle(bgBrush, rect); + //this.bmp = new Bitmap(rect.Width, rect.Height); + var gfx = Graphics.FromImage(_bitmap); - StringFormat format = new(StringFormatFlags.DirectionVertical | StringFormatFlags.NoWrap); - format.LineAlignment = StringAlignment.Center; - format.Alignment = StringAlignment.Center; + Brush bgBrush = new SolidBrush(BackColor); + Brush fgBrush = new SolidBrush(ForeColor); + //gfx.FillRectangle(bgBrush, rect); - RectangleF rectf = new(rect.Left, rect.Top, rect.Width, rect.Height); + StringFormat format = new(StringFormatFlags.DirectionVertical | StringFormatFlags.NoWrap); + format.LineAlignment = StringAlignment.Center; + format.Alignment = StringAlignment.Center; - gfx.DrawString("Calculating time spread view...", Font, fgBrush, rectf, format); + RectangleF rectf = new(rect.Left, rect.Top, rect.Width, rect.Height); - bgBrush.Dispose(); - fgBrush.Dispose(); - } + gfx.DrawString("Calculating time spread view...", Font, fgBrush, rectf, format); - BeginInvoke(new MethodInvoker(Refresh)); + bgBrush.Dispose(); + fgBrush.Dispose(); } - private void TimeSpreadingControl_SizeChanged(object sender, EventArgs e) - { - if (TimeSpreadCalc != null) - { - _displayHeight = ClientRectangle.Height - _edgeOffset * 3; - TimeSpreadCalc.SetDisplayHeight(_displayHeight); - } - } + BeginInvoke(new MethodInvoker(Refresh)); + } - private void TimeSpreadingControl_MouseDown(object sender, MouseEventArgs e) + private void TimeSpreadingControl_SizeChanged(object sender, EventArgs e) + { + if (TimeSpreadCalc != null) { + _displayHeight = ClientRectangle.Height - _edgeOffset * 3; + TimeSpreadCalc.SetDisplayHeight(_displayHeight); } + } - private void TimeSpreadingControl_MouseUp(object sender, MouseEventArgs e) + private void TimeSpreadingControl_MouseDown(object sender, MouseEventArgs e) + { + } + + private void TimeSpreadingControl_MouseUp(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) { - if (e.Button == MouseButtons.Left) + SpreadEntry entry = GetEntryForMouse(e); + if (entry == null) { - SpreadEntry entry = GetEntryForMouse(e); - if (entry == null) - { - return; - } - OnLineSelected(new SelectLineEventArgs(entry.LineNum)); + return; } + OnLineSelected(new SelectLineEventArgs(entry.LineNum)); } + } - private void TimeSpreadingControl_MouseEnter(object sender, EventArgs e) - { - _toolTip.Active = true; - } + private void TimeSpreadingControl_MouseEnter(object sender, EventArgs e) + { + _toolTip.Active = true; + } - private void TimeSpreadingControl_MouseLeave(object sender, EventArgs e) + private void TimeSpreadingControl_MouseLeave(object sender, EventArgs e) + { + _toolTip.Active = false; + } + + private void TimeSpreadingControl_MouseMove(object sender, MouseEventArgs e) + { + if (e.Y == _lastMouseY) { - _toolTip.Active = false; + return; } - private void TimeSpreadingControl_MouseMove(object sender, MouseEventArgs e) + if (e.Button == MouseButtons.Right) { - if (e.Y == _lastMouseY) - { - return; - } - - if (e.Button == MouseButtons.Right) - { - DragContrast(e); - return; - } + DragContrast(e); + return; + } - SpreadEntry entry = GetEntryForMouse(e); + SpreadEntry entry = GetEntryForMouse(e); - if (entry == null) - { - return; - } - _lastMouseY = e.Y; - var dts = entry.Timestamp.ToString("dd.MM.yyyy HH:mm:ss"); - _toolTip.SetToolTip(this, "Line " + (entry.LineNum + 1) + "\n" + dts); + if (entry == null) + { + return; } - - #endregion + _lastMouseY = e.Y; + var dts = entry.Timestamp.ToString("dd.MM.yyyy HH:mm:ss"); + _toolTip.SetToolTip(this, "Line " + (entry.LineNum + 1) + "\n" + dts); } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs b/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs index a772597b..16698f1b 100644 --- a/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs +++ b/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs @@ -10,295 +10,294 @@ //TODO: This whole Eminus folder is not in use. Can be deleted? What is it? //[assembly: SupportedOSPlatform("windows")] -namespace LogExpert +namespace LogExpert; + +internal class Eminus : IContextMenuEntry, ILogExpertPluginConfigurator { - internal class Eminus : IContextMenuEntry, ILogExpertPluginConfigurator - { - #region Fields + #region Fields - private const string CFG_FILE_NAME = "eminus.json"; - private const string DOT = "."; - private const string DOUBLE_DOT = ":"; - private const string DISABLED = "_"; + private const string CFG_FILE_NAME = "eminus.json"; + private const string DOT = "."; + private const string DOUBLE_DOT = ":"; + private const string DISABLED = "_"; - private EminusConfig _config = new(); - private EminusConfigDlg dlg; - private EminusConfig tmpConfig = new(); + private EminusConfig _config = new(); + private EminusConfigDlg dlg; + private EminusConfig tmpConfig = new(); - #endregion + #endregion - #region Properties + #region Properties - public static string Text => "eminus"; + public static string Text => "eminus"; - #endregion + #endregion - #region Private Methods + #region Private Methods - private XmlDocument BuildParam(ILogLine line) + private XmlDocument BuildParam(ILogLine line) + { + var fullLogLine = line.FullLine; + // no Java stacktrace but some special logging of our applications at work: + if (fullLogLine.Contains("Exception of type", StringComparison.CurrentCulture) || + fullLogLine.Contains("Nested:", StringComparison.CurrentCulture)) { - var fullLogLine = line.FullLine; - // no Java stacktrace but some special logging of our applications at work: - if (fullLogLine.Contains("Exception of type", StringComparison.CurrentCulture) || - fullLogLine.Contains("Nested:", StringComparison.CurrentCulture)) + var pos = fullLogLine.IndexOf("created in "); + + if (pos == -1) { - var pos = fullLogLine.IndexOf("created in "); + return null; + } - if (pos == -1) + pos += "created in ".Length; + var endPos = fullLogLine.IndexOf(DOT, pos); + + if (endPos == -1) + { + return null; + } + + var className = fullLogLine[pos..endPos]; + pos = fullLogLine.IndexOf(DOUBLE_DOT, pos); + + if (pos == -1) + { + return null; + } + + var lineNum = fullLogLine[(pos + 1)..]; + XmlDocument doc = BuildXmlDocument(className, lineNum); + return doc; + } + + if (fullLogLine.Contains("at ", StringComparison.CurrentCulture)) + { + var str = fullLogLine.Trim(); + string className = null; + string lineNum = null; + var pos = str.IndexOf("at ") + 3; + str = str[pos..]; // remove 'at ' + var idx = str.IndexOfAny(['(', '$', '<']); + + if (idx != -1) + { + if (str[idx] == '$') { - return null; + className = str[..idx]; + } + else + { + pos = str.LastIndexOf(DOT, idx); + if (pos == -1) + { + return null; + } + className = str[..pos]; } - pos += "created in ".Length; - var endPos = fullLogLine.IndexOf(DOT, pos); + idx = str.LastIndexOf(DOUBLE_DOT); - if (endPos == -1) + if (idx == -1) { return null; } - var className = fullLogLine[pos..endPos]; - pos = fullLogLine.IndexOf(DOUBLE_DOT, pos); + pos = str.IndexOf(')', idx); if (pos == -1) { return null; } - var lineNum = fullLogLine[(pos + 1)..]; - XmlDocument doc = BuildXmlDocument(className, lineNum); - return doc; + lineNum = str.Substring(idx + 1, pos - idx - 1); } + /* + * + + + + + + + */ + + XmlDocument doc = BuildXmlDocument(className, lineNum); + return doc; + } + return null; + } - if (fullLogLine.Contains("at ", StringComparison.CurrentCulture)) - { - var str = fullLogLine.Trim(); - string className = null; - string lineNum = null; - var pos = str.IndexOf("at ") + 3; - str = str[pos..]; // remove 'at ' - var idx = str.IndexOfAny(['(', '$', '<']); - - if (idx != -1) - { - if (str[idx] == '$') - { - className = str[..idx]; - } - else - { - pos = str.LastIndexOf(DOT, idx); - if (pos == -1) - { - return null; - } - className = str[..pos]; - } - - idx = str.LastIndexOf(DOUBLE_DOT); + private XmlDocument BuildXmlDocument(string className, string lineNum) + { + XmlDocument xmlDoc = new(); + xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); + XmlElement rootElement = xmlDoc.CreateElement("eminus"); + xmlDoc.AppendChild(rootElement); + rootElement.SetAttribute("authKey", _config.password); + + XmlElement loadElement = xmlDoc.CreateElement("loadclass"); + loadElement.SetAttribute("mode", "dialog"); + rootElement.AppendChild(loadElement); + + XmlElement elemClassName = xmlDoc.CreateElement("classname"); + XmlElement elemLineNum = xmlDoc.CreateElement("linenumber"); + elemClassName.InnerText = className; + elemLineNum.InnerText = lineNum; + loadElement.AppendChild(elemClassName); + loadElement.AppendChild(elemLineNum); + return xmlDoc; + } - if (idx == -1) - { - return null; - } + #endregion - pos = str.IndexOf(')', idx); + #region IContextMenuEntry Member - if (pos == -1) - { - return null; - } + public string GetMenuText(IList logLines, ILogLineColumnizer columnizer, ILogExpertCallback callback) + { + //not used + return string.Empty; + } - lineNum = str.Substring(idx + 1, pos - idx - 1); - } - /* - * - - - - - - - */ - - XmlDocument doc = BuildXmlDocument(className, lineNum); - return doc; - } - return null; + public string GetMenuText(int logLinesCount, ILogLineColumnizer columnizer, ILogLine logline) + { + if (logLinesCount == 1 && BuildParam(logline) != null) + { + return "Load class in Eclipse"; } - - private XmlDocument BuildXmlDocument(string className, string lineNum) + else { - XmlDocument xmlDoc = new(); - xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); - XmlElement rootElement = xmlDoc.CreateElement("eminus"); - xmlDoc.AppendChild(rootElement); - rootElement.SetAttribute("authKey", _config.password); - - XmlElement loadElement = xmlDoc.CreateElement("loadclass"); - loadElement.SetAttribute("mode", "dialog"); - rootElement.AppendChild(loadElement); - - XmlElement elemClassName = xmlDoc.CreateElement("classname"); - XmlElement elemLineNum = xmlDoc.CreateElement("linenumber"); - elemClassName.InnerText = className; - elemLineNum.InnerText = lineNum; - loadElement.AppendChild(elemClassName); - loadElement.AppendChild(elemLineNum); - return xmlDoc; + return $"{DISABLED}Load class in Eclipse"; } + } - #endregion - - #region IContextMenuEntry Member + public void MenuSelected(IList logLines, ILogLineColumnizer columnizer, ILogExpertCallback callback) + { + //Not used + } - public string GetMenuText(IList logLines, ILogLineColumnizer columnizer, ILogExpertCallback callback) + public void MenuSelected(int logLinesCount, ILogLineColumnizer columnizer, ILogLine logline) + { + if (logLinesCount != 1) { - //not used - return string.Empty; + return; } - public string GetMenuText(int logLinesCount, ILogLineColumnizer columnizer, ILogLine logline) - { - if (logLinesCount == 1 && BuildParam(logline) != null) - { - return "Load class in Eclipse"; - } - else - { - return $"{DISABLED}Load class in Eclipse"; - } - } + XmlDocument doc = BuildParam(logline); - public void MenuSelected(IList logLines, ILogLineColumnizer columnizer, ILogExpertCallback callback) + if (doc == null) { - //Not used + MessageBox.Show("Cannot parse Java stack trace line", "LogExpert"); } - - public void MenuSelected(int logLinesCount, ILogLineColumnizer columnizer, ILogLine logline) + else { - if (logLinesCount != 1) + try { - return; + TcpClient client = new(_config.host, _config.port); + NetworkStream stream = client.GetStream(); + StreamWriter writer = new(stream); + doc.Save(writer); + writer.Flush(); + stream.Flush(); + writer.Close(); + stream.Close(500); + client.Close(); } - - XmlDocument doc = BuildParam(logline); - - if (doc == null) - { - MessageBox.Show("Cannot parse Java stack trace line", "LogExpert"); - } - else + catch (Exception e) { - try - { - TcpClient client = new(_config.host, _config.port); - NetworkStream stream = client.GetStream(); - StreamWriter writer = new(stream); - doc.Save(writer); - writer.Flush(); - stream.Flush(); - writer.Close(); - stream.Close(500); - client.Close(); - } - catch (Exception e) - { - MessageBox.Show(e.Message, "LogExpert"); - } + MessageBox.Show(e.Message, "LogExpert"); } } + } - #endregion + #endregion - #region ILogExpertPluginConfigurator Member + #region ILogExpertPluginConfigurator Member - public void LoadConfig(string configDir) - { - var configPath = configDir + CFG_FILE_NAME; + public void LoadConfig(string configDir) + { + var configPath = configDir + CFG_FILE_NAME; - FileInfo fileInfo = new(configDir + Path.DirectorySeparatorChar + CFG_FILE_NAME); + FileInfo fileInfo = new(configDir + Path.DirectorySeparatorChar + CFG_FILE_NAME); - if (!File.Exists(configPath)) + if (!File.Exists(configPath)) + { + _config = new EminusConfig(); + } + else + { + try { - _config = new EminusConfig(); + _config = JsonConvert.DeserializeObject(File.ReadAllText($"{fileInfo.FullName}")); } - else + catch (SerializationException e) { - try - { - _config = JsonConvert.DeserializeObject(File.ReadAllText($"{fileInfo.FullName}")); - } - catch (SerializationException e) - { - MessageBox.Show(e.Message, "Deserialize"); - _config = new EminusConfig(); - } + MessageBox.Show(e.Message, "Deserialize"); + _config = new EminusConfig(); } } + } - public void SaveConfig(string configDir) - { - FileInfo fileInfo = new(configDir + Path.DirectorySeparatorChar + CFG_FILE_NAME); + public void SaveConfig(string configDir) + { + FileInfo fileInfo = new(configDir + Path.DirectorySeparatorChar + CFG_FILE_NAME); - dlg?.ApplyChanges(); + dlg?.ApplyChanges(); - _config = tmpConfig.Clone(); + _config = tmpConfig.Clone(); - using StreamWriter sw = new(fileInfo.Create()); - JsonSerializer serializer = new(); - serializer.Serialize(sw, _config); - } + using StreamWriter sw = new(fileInfo.Create()); + JsonSerializer serializer = new(); + serializer.Serialize(sw, _config); + } - public bool HasEmbeddedForm() - { - return true; - } + public bool HasEmbeddedForm() + { + return true; + } - public void ShowConfigForm(object panel) + public void ShowConfigForm(object panel) + { + dlg = new EminusConfigDlg(tmpConfig) { - dlg = new EminusConfigDlg(tmpConfig) - { - Parent = (Panel)panel - }; - dlg.Show(); - } + Parent = (Panel)panel + }; + dlg.Show(); + } - /// - /// Implemented only for demonstration purposes. This function is called when the config button - /// is pressed (HasEmbeddedForm() must return false for this). - /// - /// - public void ShowConfigDialog(object owner) + /// + /// Implemented only for demonstration purposes. This function is called when the config button + /// is pressed (HasEmbeddedForm() must return false for this). + /// + /// + public void ShowConfigDialog(object owner) + { + dlg = new EminusConfigDlg(tmpConfig) { - dlg = new EminusConfigDlg(tmpConfig) - { - TopLevel = true, - Owner = (Form)owner - }; + TopLevel = true, + Owner = (Form)owner + }; - dlg.ShowDialog(); - dlg.ApplyChanges(); - } + dlg.ShowDialog(); + dlg.ApplyChanges(); + } - public void HideConfigForm() - { - if (dlg != null) - { - dlg.ApplyChanges(); - dlg.Hide(); - dlg.Dispose(); - dlg = null; - } - } - - public void StartConfig() + public void HideConfigForm() + { + if (dlg != null) { - tmpConfig = _config.Clone(); + dlg.ApplyChanges(); + dlg.Hide(); + dlg.Dispose(); + dlg = null; } + } - #endregion + public void StartConfig() + { + tmpConfig = _config.Clone(); } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Dialogs/Eminus/EminusConfig.cs b/src/LogExpert.UI/Dialogs/Eminus/EminusConfig.cs index 28586414..444e9dd8 100644 --- a/src/LogExpert.UI/Dialogs/Eminus/EminusConfig.cs +++ b/src/LogExpert.UI/Dialogs/Eminus/EminusConfig.cs @@ -1,31 +1,30 @@ using System; -namespace LogExpert +namespace LogExpert; + +[Serializable] +internal class EminusConfig { - [Serializable] - internal class EminusConfig - { - #region Fields + #region Fields - public string host = "127.0.0.1"; - public string password = ""; - public int port = 12345; + public string host = "127.0.0.1"; + public string password = ""; + public int port = 12345; - #endregion + #endregion - #region Public methods + #region Public methods - public EminusConfig Clone() + public EminusConfig Clone() + { + EminusConfig config = new() { - EminusConfig config = new() - { - host = host, - port = port, - password = password - }; - return config; - } - - #endregion + host = host, + port = port, + password = password + }; + return config; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.cs b/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.cs index 7568e0b1..8b43c982 100644 --- a/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.cs +++ b/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.cs @@ -2,59 +2,58 @@ using System.Drawing; using System.Windows.Forms; -namespace LogExpert +namespace LogExpert; + +internal partial class EminusConfigDlg : Form { - internal partial class EminusConfigDlg : Form - { - #region Fields + #region Fields - #endregion + #endregion - #region cTor + #region cTor - public EminusConfigDlg(EminusConfig config) - { - SuspendLayout(); + public EminusConfigDlg(EminusConfig config) + { + SuspendLayout(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; - InitializeComponent(); + InitializeComponent(); - TopLevel = false; - Config = config; + TopLevel = false; + Config = config; - hostTextBox.Text = config.host; - portTextBox.Text = string.Empty + config.port; - passwordTextBox.Text = config.password; + hostTextBox.Text = config.host; + portTextBox.Text = string.Empty + config.port; + passwordTextBox.Text = config.password; - ResumeLayout(); - } + ResumeLayout(); + } - #endregion + #endregion - #region Properties + #region Properties - public EminusConfig Config { get; set; } + public EminusConfig Config { get; set; } - #endregion + #endregion - #region Public methods + #region Public methods - public void ApplyChanges() + public void ApplyChanges() + { + Config.host = hostTextBox.Text; + try { - Config.host = hostTextBox.Text; - try - { - Config.port = short.Parse(portTextBox.Text); - } - catch (FormatException) - { - Config.port = 0; - } - Config.password = passwordTextBox.Text; + Config.port = short.Parse(portTextBox.Text); } - - #endregion + catch (FormatException) + { + Config.port = 0; + } + Config.password = passwordTextBox.Text; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs index 885879cd..034172db 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs @@ -764,8 +764,8 @@ private void OnSaveProjectToolStripMenuItemClick (object sender, EventArgs e) } ProjectData projectData = new(); - projectData.memberList = fileNames; - projectData.tabLayoutXml = SaveLayout(); + projectData.MemberList = fileNames; + projectData.TabLayoutXml = SaveLayout(); ProjectPersister.SaveProjectData(fileName, projectData); } } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs index d6b6c722..173763fd 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs @@ -1176,7 +1176,7 @@ private void SetTabColor (LogWindow.LogWindow logWindow, Color color) private void LoadProject (string projectFileName, bool restoreLayout) { ProjectData projectData = ProjectPersister.LoadProjectData(projectFileName); - var hasLayoutData = projectData.tabLayoutXml != null; + var hasLayoutData = projectData.TabLayoutXml != null; if (hasLayoutData && restoreLayout && _logWindowList.Count > 0) { @@ -1200,7 +1200,7 @@ private void LoadProject (string projectFileName, bool restoreLayout) if (projectData != null) { - foreach (var fileName in projectData.memberList) + foreach (var fileName in projectData.MemberList) { if (hasLayoutData) { @@ -1217,7 +1217,7 @@ private void LoadProject (string projectFileName, bool restoreLayout) // Re-creating tool (non-document) windows is needed because the DockPanel control would throw strange errors DestroyToolWindows(); InitToolWindows(); - RestoreLayout(projectData.tabLayoutXml); + RestoreLayout(projectData.TabLayoutXml); } } } @@ -1233,10 +1233,10 @@ private void ApplySelectedHighlightGroup () private void FillToolLauncherBar () { char[] labels = - { + [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' - }; + ]; toolsToolStripMenuItem.DropDownItems.Clear(); toolsToolStripMenuItem.DropDownItems.Add(configureToolStripMenuItem); toolsToolStripMenuItem.DropDownItems.Add(configureToolStripSeparator); diff --git a/src/LogExpert.UI/Entities/ArgParser.cs b/src/LogExpert.UI/Entities/ArgParser.cs index 91b7b20c..215a1981 100644 --- a/src/LogExpert.UI/Entities/ArgParser.cs +++ b/src/LogExpert.UI/Entities/ArgParser.cs @@ -1,155 +1,154 @@ -using System; -using System.Text; +using System.Text; using System.Text.RegularExpressions; -using System.Windows.Forms; using LogExpert.Core.Classes; using LogExpert.Dialogs; -namespace LogExpert.Classes +namespace LogExpert.Classes; + +internal class ArgParser { - internal class ArgParser - { - #region Fields + #region Fields - private readonly string argLine; + private readonly string argLine; - #endregion + #endregion - #region cTor + #region cTor - public ArgParser(string argTemplate) - { - argLine = argTemplate; - } + public ArgParser (string argTemplate) + { + argLine = argTemplate; + } - #endregion + #endregion - #region Public methods + #region Public methods - public string BuildArgs(ILogLine logLine, int lineNum, ILogFileInfo logFileInfo, Form parent) + public string BuildArgs (ILogLine logLine, int lineNum, ILogFileInfo logFileInfo, Form parent) + { + StringBuilder builder = new(argLine); + builder.Replace("%L", "" + lineNum); + builder.Replace("%P", logFileInfo.DirectoryName); + builder.Replace("%N", logFileInfo.FileName); + builder.Replace("%F", logFileInfo.FullName); + builder.Replace("%E", Util.GetExtension(logFileInfo.FileName)); + var stripped = Util.StripExtension(logFileInfo.FileName); + builder.Replace("%M", stripped); + + builder.Replace("%URI", logFileInfo.Uri.AbsoluteUri); + var user = logFileInfo.Uri.UserInfo; + if (user.Contains(":")) + { + user = user.Substring(0, user.IndexOf(':')); + } + builder.Replace("%S", user); + builder.Replace("%R", logFileInfo.Uri.PathAndQuery); + builder.Replace("%H", logFileInfo.Uri.Host); + builder.Replace("%T", logFileInfo.Uri.Port.ToString()); + + var sPos = 0; + string reg; + string replace; + do { - StringBuilder builder = new(argLine); - builder.Replace("%L", "" + lineNum); - builder.Replace("%P", logFileInfo.DirectoryName); - builder.Replace("%N", logFileInfo.FileName); - builder.Replace("%F", logFileInfo.FullName); - builder.Replace("%E", Util.GetExtension(logFileInfo.FileName)); - var stripped = Util.StripExtension(logFileInfo.FileName); - builder.Replace("%M", stripped); - - builder.Replace("%URI", logFileInfo.Uri.AbsoluteUri); - var user = logFileInfo.Uri.UserInfo; - if (user.Contains(":")) + reg = GetNextGroup(builder, ref sPos); + replace = GetNextGroup(builder, ref sPos); + if (reg != null && replace != null) { - user = user.Substring(0, user.IndexOf(':')); + var result = Regex.Replace(logLine.FullLine, reg, replace); + builder.Insert(sPos, result); } - builder.Replace("%S", user); - builder.Replace("%R", logFileInfo.Uri.PathAndQuery); - builder.Replace("%H", logFileInfo.Uri.Host); - builder.Replace("%T", logFileInfo.Uri.Port.ToString()); - - var sPos = 0; - string reg; - string replace; - do - { - reg = GetNextGroup(builder, ref sPos); - replace = GetNextGroup(builder, ref sPos); - if (reg != null && replace != null) - { - var result = Regex.Replace(logLine.FullLine, reg, replace); - builder.Insert(sPos, result); - } - } while (replace != null); + } while (replace != null); - var i = 0; - while (i < builder.Length) + var i = 0; + while (i < builder.Length) + { + // ?"Pinpad-type?"(thales,dione) + if (builder[i] == '?') { - // ?"Pinpad-type?"(thales,dione) - if (builder[i] == '?') + var end = i; + var ask = "Parameter"; + if (builder[i + 1] == '"') { - var end = i; - var ask = "Parameter"; - if (builder[i + 1] == '"') + end = builder.ToString().IndexOf('"', i + 2); + if (end == -1) { - end = builder.ToString().IndexOf('"', i + 2); - if (end == -1) - { - end = builder.Length - 1; - } - ask = builder.ToString().Substring(i + 2, end - i - 2); + end = builder.Length - 1; } - string[] values = null; - if (builder[end + 1] == '(') + ask = builder.ToString().Substring(i + 2, end - i - 2); + } + string[] values = null; + if (builder[end + 1] == '(') + { + var end2 = builder.ToString().IndexOf(')'); + if (end2 == -1) { - var end2 = builder.ToString().IndexOf(')'); - if (end2 == -1) - { - end2 = builder.Length - 1; - } - var valueStr = builder.ToString().Substring(end + 2, end2 - end - 2); - values = valueStr.Split(new char[] { ',' }, StringSplitOptions.None); - end = end2; + end2 = builder.Length - 1; } + var valueStr = builder.ToString().Substring(end + 2, end2 - end - 2); + values = valueStr.Split([','], StringSplitOptions.None); + end = end2; + } - ParamRequesterDialog dlg = new(); - dlg.ParamName = ask; - dlg.Values = values; - DialogResult res = dlg.ShowDialog(parent); - if (res == DialogResult.OK) - { - builder.Remove(i, end - i + 1); - builder.Insert(i, dlg.ParamValue); - } - else if (res == DialogResult.Cancel || res == DialogResult.Abort) - { - return null; - } + ParamRequesterDialog dlg = new(); + dlg.ParamName = ask; + dlg.Values = values; + DialogResult res = dlg.ShowDialog(parent); + + if (res == DialogResult.OK) + { + builder.Remove(i, end - i + 1); + builder.Insert(i, dlg.ParamValue); + } + else if (res == DialogResult.Cancel || res == DialogResult.Abort) + { + return null; } - ++i; } - return builder.ToString(); + ++i; } - #endregion + return builder.ToString(); + } + + #endregion - #region Private Methods + #region Private Methods - private string GetNextGroup(StringBuilder builder, ref int sPos) + private string GetNextGroup (StringBuilder builder, ref int sPos) + { + int ePos; + while (sPos < builder.Length) { - int ePos; - while (sPos < builder.Length) + if (builder[sPos] == '{') { - if (builder[sPos] == '{') + ePos = sPos + 1; + var count = 1; + while (ePos < builder.Length) { - ePos = sPos + 1; - var count = 1; - while (ePos < builder.Length) + if (builder[ePos] == '{') + { + count++; + } + if (builder[ePos] == '}') { - if (builder[ePos] == '{') - { - count++; - } - if (builder[ePos] == '}') - { - count--; - } - if (count == 0) - { - var reg = builder.ToString(sPos + 1, ePos - sPos - 1); - builder.Remove(sPos, ePos - sPos + 1); - return reg; - } - ePos++; + count--; } + if (count == 0) + { + var reg = builder.ToString(sPos + 1, ePos - sPos - 1); + builder.Remove(sPos, ePos - sPos + 1); + return reg; + } + ePos++; } - sPos++; } - return null; + sPos++; } - - #endregion + return null; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index 064edb6b..6c795af4 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -7,483 +7,482 @@ using LogExpert.UI.Interface; using NLog; -namespace LogExpert.UI.Entities +namespace LogExpert.UI.Entities; + +//TOOD: This whole class should be refactored and rethought +//TODO: This class should not knoow ConfigManager? +internal static class PaintHelper { - //TOOD: This whole class should be refactored and rethought - //TODO: This class should not knoow ConfigManager? - internal static class PaintHelper - { - #region Fields + #region Fields - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - //TODO Make configurable - private static Color _bookmarkColor = Color.FromArgb(165, 200, 225); + //TODO Make configurable + private static Color _bookmarkColor = Color.FromArgb(165, 200, 225); - #endregion + #endregion - #region Properties - public static IConfigManager ConfigManager { get; set; } - private static Preferences Preferences => ConfigManager.Settings.Preferences; + #region Properties + public static IConfigManager ConfigManager { get; set; } + private static Preferences Preferences => ConfigManager.Settings.Preferences; - #endregion + #endregion - #region Public methods + #region Public methods - public static void CellPainting(ILogPaintContextUI logPaintCtx, BufferedDataGridView gridView, int rowIndex, - DataGridViewCellPaintingEventArgs e) + public static void CellPainting(ILogPaintContextUI logPaintCtx, BufferedDataGridView gridView, int rowIndex, + DataGridViewCellPaintingEventArgs e) + { + if (rowIndex < 0 || e.ColumnIndex < 0) + { + e.Handled = false; + return; + } + ILogLine line = logPaintCtx.GetLogLine(rowIndex); + if (line != null) { - if (rowIndex < 0 || e.ColumnIndex < 0) + HighlightEntry entry = logPaintCtx.FindHighlightEntry(line, true); + e.Graphics.SetClip(e.CellBounds); + if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) { - e.Handled = false; - return; + Color backColor = e.CellStyle.SelectionBackColor; + Brush brush; + if (gridView.Focused) + { + brush = new SolidBrush(e.CellStyle.SelectionBackColor); + } + else + { + var color = Color.FromArgb(255, 170, 170, 170); + brush = new SolidBrush(color); + } + e.Graphics.FillRectangle(brush, e.CellBounds); + brush.Dispose(); } - ILogLine line = logPaintCtx.GetLogLine(rowIndex); - if (line != null) + else { - HighlightEntry entry = logPaintCtx.FindHighlightEntry(line, true); - e.Graphics.SetClip(e.CellBounds); - if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) + Color bgColor = ColorMode.DockBackgroundColor; + if (!DebugOptions.DisableWordHighlight) { - Color backColor = e.CellStyle.SelectionBackColor; - Brush brush; - if (gridView.Focused) - { - brush = new SolidBrush(e.CellStyle.SelectionBackColor); - } - else + if (entry != null) { - var color = Color.FromArgb(255, 170, 170, 170); - brush = new SolidBrush(color); + bgColor = entry.BackgroundColor; } - e.Graphics.FillRectangle(brush, e.CellBounds); - brush.Dispose(); } else { - Color bgColor = ColorMode.DockBackgroundColor; - if (!DebugOptions.DisableWordHighlight) + if (entry != null) { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } + bgColor = entry.BackgroundColor; } - else - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - e.CellStyle.BackColor = bgColor; - e.PaintBackground(e.ClipBounds, false); } + e.CellStyle.BackColor = bgColor; + e.PaintBackground(e.ClipBounds, false); + } - if (DebugOptions.DisableWordHighlight) - { - e.PaintContent(e.CellBounds); - } - else - { - PaintCell(logPaintCtx, e, gridView, false, entry); - } + if (DebugOptions.DisableWordHighlight) + { + e.PaintContent(e.CellBounds); + } + else + { + PaintCell(logPaintCtx, e, gridView, false, entry); + } - if (e.ColumnIndex == 0) + if (e.ColumnIndex == 0) + { + Bookmark bookmark = logPaintCtx.GetBookmarkForLine(rowIndex); + if (bookmark != null) { - Bookmark bookmark = logPaintCtx.GetBookmarkForLine(rowIndex); - if (bookmark != null) + Rectangle r; // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); + r = e.CellBounds; + r.Inflate(-2, -2); + Brush brush = new SolidBrush(logPaintCtx.BookmarkColor); + e.Graphics.FillRectangle(brush, r); + brush.Dispose(); + if (bookmark.Text.Length > 0) { - Rectangle r; // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); - r = e.CellBounds; - r.Inflate(-2, -2); - Brush brush = new SolidBrush(logPaintCtx.BookmarkColor); - e.Graphics.FillRectangle(brush, r); - brush.Dispose(); - if (bookmark.Text.Length > 0) - { - StringFormat format = new(); - format.LineAlignment = StringAlignment.Center; - format.Alignment = StringAlignment.Center; - Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); - Font font = logPaintCtx.MonospacedFont; - e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), - format); - brush2.Dispose(); - } + StringFormat format = new(); + format.LineAlignment = StringAlignment.Center; + format.Alignment = StringAlignment.Center; + Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); + Font font = logPaintCtx.MonospacedFont; + e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), + format); + brush2.Dispose(); } } - - e.Paint(e.CellBounds, DataGridViewPaintParts.Border); - e.Handled = true; } - } - public static DataGridViewTextBoxColumn CreateMarkerColumn() - { - DataGridViewTextBoxColumn markerColumn = new(); - markerColumn.HeaderText = ""; - markerColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - markerColumn.Resizable = DataGridViewTriState.False; - markerColumn.DividerWidth = 1; - markerColumn.ReadOnly = true; - markerColumn.SortMode = DataGridViewColumnSortMode.NotSortable; - - return markerColumn; + e.Paint(e.CellBounds, DataGridViewPaintParts.Border); + e.Handled = true; } + } - public static DataGridViewTextBoxColumn CreateLineNumberColumn() + public static DataGridViewTextBoxColumn CreateMarkerColumn() + { + DataGridViewTextBoxColumn markerColumn = new(); + markerColumn.HeaderText = ""; + markerColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; + markerColumn.Resizable = DataGridViewTriState.False; + markerColumn.DividerWidth = 1; + markerColumn.ReadOnly = true; + markerColumn.SortMode = DataGridViewColumnSortMode.NotSortable; + + return markerColumn; + } + + public static DataGridViewTextBoxColumn CreateLineNumberColumn() + { + DataGridViewTextBoxColumn lineNumberColumn = new(); + lineNumberColumn.HeaderText = "Line"; + lineNumberColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; + lineNumberColumn.Resizable = DataGridViewTriState.NotSet; + lineNumberColumn.DividerWidth = 1; + lineNumberColumn.ReadOnly = true; + lineNumberColumn.SortMode = DataGridViewColumnSortMode.NotSortable; + + return lineNumberColumn; + } + + public static DataGridViewColumn CreateTitleColumn(string colName) + { + DataGridViewColumn titleColumn = new LogTextColumn(); + titleColumn.HeaderText = colName; + titleColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; + titleColumn.Resizable = DataGridViewTriState.NotSet; + titleColumn.DividerWidth = 1; + titleColumn.SortMode = DataGridViewColumnSortMode.NotSortable; + + return titleColumn; + } + + public static void SetColumnizer(ILogLineColumnizer columnizer, BufferedDataGridView gridView) + { + var rowCount = gridView.RowCount; + var currLine = gridView.CurrentCellAddress.Y; + var currFirstLine = gridView.FirstDisplayedScrollingRowIndex; + + try { - DataGridViewTextBoxColumn lineNumberColumn = new(); - lineNumberColumn.HeaderText = "Line"; - lineNumberColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - lineNumberColumn.Resizable = DataGridViewTriState.NotSet; - lineNumberColumn.DividerWidth = 1; - lineNumberColumn.ReadOnly = true; - lineNumberColumn.SortMode = DataGridViewColumnSortMode.NotSortable; - - return lineNumberColumn; + gridView.Columns.Clear(); } - - public static DataGridViewColumn CreateTitleColumn(string colName) + catch (ArgumentOutOfRangeException ae) { - DataGridViewColumn titleColumn = new LogTextColumn(); - titleColumn.HeaderText = colName; - titleColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - titleColumn.Resizable = DataGridViewTriState.NotSet; - titleColumn.DividerWidth = 1; - titleColumn.SortMode = DataGridViewColumnSortMode.NotSortable; - - return titleColumn; + // Occures sometimes on empty gridViews (no lines) if bookmark window was closed and re-opened in floating mode. + // Don't know why. + _logger.Error(ae); } - public static void SetColumnizer(ILogLineColumnizer columnizer, BufferedDataGridView gridView) - { - var rowCount = gridView.RowCount; - var currLine = gridView.CurrentCellAddress.Y; - var currFirstLine = gridView.FirstDisplayedScrollingRowIndex; + gridView.Columns.Add(CreateMarkerColumn()); - try - { - gridView.Columns.Clear(); - } - catch (ArgumentOutOfRangeException ae) - { - // Occures sometimes on empty gridViews (no lines) if bookmark window was closed and re-opened in floating mode. - // Don't know why. - _logger.Error(ae); - } + gridView.Columns.Add(CreateLineNumberColumn()); - gridView.Columns.Add(CreateMarkerColumn()); + foreach (var colName in columnizer.GetColumnNames()) + { + gridView.Columns.Add(CreateTitleColumn(colName)); + } - gridView.Columns.Add(CreateLineNumberColumn()); + gridView.RowCount = rowCount; + if (currLine != -1) + { + gridView.CurrentCell = gridView.Rows[currLine].Cells[0]; + } + if (currFirstLine != -1) + { + gridView.FirstDisplayedScrollingRowIndex = currFirstLine; + } + //gridView.Refresh(); + //AutoResizeColumns(gridView); + } - foreach (var colName in columnizer.GetColumnNames()) + //TODO: Original name is AutoResizeColumn. Where is this used? + //TODO: Rename ConfigManager to configManager + private static void AutoResizeColumns(BufferedDataGridView gridView, IConfigManager CnofigManager) + { + try + { + gridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + if (gridView.Columns.Count > 1 && Preferences.setLastColumnWidth && + gridView.Columns[gridView.Columns.Count - 1].Width < Preferences.lastColumnWidth + ) { - gridView.Columns.Add(CreateTitleColumn(colName)); + // It seems that using 'MinimumWidth' instead of 'Width' prevents the DataGridView's NullReferenceExceptions + //gridView.Columns[gridView.Columns.Count - 1].Width = this.Preferences.lastColumnWidth; + gridView.Columns[gridView.Columns.Count - 1].MinimumWidth = Preferences.lastColumnWidth; } + } + catch (NullReferenceException e) + { + // See https://connect.microsoft.com/VisualStudio/feedback/details/366943/autoresizecolumns-in-datagridview-throws-nullreferenceexception + // possible solution => https://stackoverflow.com/questions/36287553/nullreferenceexception-when-trying-to-set-datagridview-column-width-brings-th + // There are some rare situations with null ref exceptions when resizing columns and on filter finished + // So catch them here. Better than crashing. + _logger.Error(e, "Error while resizing columns: "); + } + } - gridView.RowCount = rowCount; - if (currLine != -1) - { - gridView.CurrentCell = gridView.Rows[currLine].Cells[0]; - } - if (currFirstLine != -1) - { - gridView.FirstDisplayedScrollingRowIndex = currFirstLine; - } - //gridView.Refresh(); - //AutoResizeColumns(gridView); + public static void ApplyDataGridViewPrefs(BufferedDataGridView dataGridView, Preferences prefs, IConfigManager configManager) + { + //TODO: This is a very bad solution and should be solved ASAP + if (ConfigManager == null) { + ConfigManager = configManager; } - //TODO: Original name is AutoResizeColumn. Where is this used? - //TODO: Rename ConfigManager to configManager - private static void AutoResizeColumns(BufferedDataGridView gridView, IConfigManager CnofigManager) + if (dataGridView.Columns.Count > 1) { - try + if (prefs.setLastColumnWidth) { - gridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - if (gridView.Columns.Count > 1 && Preferences.setLastColumnWidth && - gridView.Columns[gridView.Columns.Count - 1].Width < Preferences.lastColumnWidth - ) - { - // It seems that using 'MinimumWidth' instead of 'Width' prevents the DataGridView's NullReferenceExceptions - //gridView.Columns[gridView.Columns.Count - 1].Width = this.Preferences.lastColumnWidth; - gridView.Columns[gridView.Columns.Count - 1].MinimumWidth = Preferences.lastColumnWidth; - } + dataGridView.Columns[dataGridView.Columns.Count - 1].MinimumWidth = prefs.lastColumnWidth; } - catch (NullReferenceException e) + else { - // See https://connect.microsoft.com/VisualStudio/feedback/details/366943/autoresizecolumns-in-datagridview-throws-nullreferenceexception - // possible solution => https://stackoverflow.com/questions/36287553/nullreferenceexception-when-trying-to-set-datagridview-column-width-brings-th - // There are some rare situations with null ref exceptions when resizing columns and on filter finished - // So catch them here. Better than crashing. - _logger.Error(e, "Error while resizing columns: "); + // Workaround for a .NET bug which brings the DataGridView into an unstable state (causing lots of NullReferenceExceptions). + dataGridView.FirstDisplayedScrollingColumnIndex = 0; + + dataGridView.Columns[dataGridView.Columns.Count - 1].MinimumWidth = 5; // default } } - - public static void ApplyDataGridViewPrefs(BufferedDataGridView dataGridView, Preferences prefs, IConfigManager configManager) + if (dataGridView.RowCount > 0) { - //TODO: This is a very bad solution and should be solved ASAP - if (ConfigManager == null) { - ConfigManager = configManager; - } + dataGridView.UpdateRowHeightInfo(0, true); + } + dataGridView.Invalidate(); + dataGridView.Refresh(); + AutoResizeColumns(dataGridView, ConfigManager); + } - if (dataGridView.Columns.Count > 1) - { - if (prefs.setLastColumnWidth) - { - dataGridView.Columns[dataGridView.Columns.Count - 1].MinimumWidth = prefs.lastColumnWidth; - } - else - { - // Workaround for a .NET bug which brings the DataGridView into an unstable state (causing lots of NullReferenceExceptions). - dataGridView.FirstDisplayedScrollingColumnIndex = 0; + public static Rectangle BorderWidths(DataGridViewAdvancedBorderStyle advancedBorderStyle) + { + Rectangle rect = new(); - dataGridView.Columns[dataGridView.Columns.Count - 1].MinimumWidth = 5; // default - } - } - if (dataGridView.RowCount > 0) - { - dataGridView.UpdateRowHeightInfo(0, true); - } - dataGridView.Invalidate(); - dataGridView.Refresh(); - AutoResizeColumns(dataGridView, ConfigManager); + rect.X = advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; + if (advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.OutsetDouble || + advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.InsetDouble) + { + rect.X++; } - public static Rectangle BorderWidths(DataGridViewAdvancedBorderStyle advancedBorderStyle) + rect.Y = advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; + if (advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.OutsetDouble || + advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.InsetDouble) { - Rectangle rect = new(); + rect.Y++; + } - rect.X = advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; - if (advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.OutsetDouble || - advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.InsetDouble) - { - rect.X++; - } + rect.Width = advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; + if (advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.OutsetDouble || + advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.InsetDouble) + { + rect.Width++; + } - rect.Y = advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; - if (advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.OutsetDouble || - advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.InsetDouble) - { - rect.Y++; - } + rect.Height = advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; + if (advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.OutsetDouble || + advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.InsetDouble) + { + rect.Height++; + } - rect.Width = advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; - if (advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.OutsetDouble || - advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.InsetDouble) - { - rect.Width++; - } + //rect.Width += this.owningColumn.DividerWidth; + //rect.Height += this.owningRow.DividerHeight; - rect.Height = advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; - if (advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.OutsetDouble || - advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.InsetDouble) - { - rect.Height++; - } + return rect; + } - //rect.Width += this.owningColumn.DividerWidth; - //rect.Height += this.owningRow.DividerHeight; + #endregion - return rect; - } + #region Private Methods - #endregion + private static void PaintCell(ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) + { + PaintHighlightedCell(logPaintCtx, e, gridView, noBackgroundFill, groundEntry); + } - #region Private Methods + private static void PaintHighlightedCell(ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) + { + var value = e.Value ?? string.Empty; - private static void PaintCell(ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) + IList matchList = logPaintCtx.FindHighlightMatches(value as ILogLine); + // too many entries per line seem to cause problems with the GDI + while (matchList.Count > 50) { - PaintHighlightedCell(logPaintCtx, e, gridView, noBackgroundFill, groundEntry); + matchList.RemoveAt(50); } - private static void PaintHighlightedCell(ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) + if (value is Column column) { - var value = e.Value ?? string.Empty; - - IList matchList = logPaintCtx.FindHighlightMatches(value as ILogLine); - // too many entries per line seem to cause problems with the GDI - while (matchList.Count > 50) + if (string.IsNullOrEmpty(column.FullValue) == false) { - matchList.RemoveAt(50); - } + HilightMatchEntry hme = new(); + hme.StartPos = 0; + hme.Length = column.FullValue.Length; - if (value is Column column) - { - if (string.IsNullOrEmpty(column.FullValue) == false) + var he = new HighlightEntry { - HilightMatchEntry hme = new(); - hme.StartPos = 0; - hme.Length = column.FullValue.Length; - - var he = new HighlightEntry - { - SearchText = column.FullValue, - ForegroundColor = groundEntry?.ForegroundColor ?? ColorMode.ForeColor, - BackgroundColor = groundEntry?.BackgroundColor ?? Color.Empty, - IsRegEx = false, - IsCaseSensitive = false, - IsLedSwitch = false, - IsStopTail = false, - IsSetBookmark = false, - IsActionEntry = false, - IsWordMatch = false - }; - - hme.HilightEntry = he; - - matchList = MergeHighlightMatchEntries(matchList, hme); - } + SearchText = column.FullValue, + ForegroundColor = groundEntry?.ForegroundColor ?? ColorMode.ForeColor, + BackgroundColor = groundEntry?.BackgroundColor ?? Color.Empty, + IsRegEx = false, + IsCaseSensitive = false, + IsLedSwitch = false, + IsStopTail = false, + IsSetBookmark = false, + IsActionEntry = false, + IsWordMatch = false + }; + + hme.HilightEntry = he; + + matchList = MergeHighlightMatchEntries(matchList, hme); } + } - var leftPad = e.CellStyle.Padding.Left; - RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, e.CellBounds.Height); - Rectangle borderWidths = BorderWidths(e.AdvancedBorderStyle); - Rectangle valBounds = e.CellBounds; - valBounds.Offset(borderWidths.X, borderWidths.Y); - valBounds.Width -= borderWidths.Right; - valBounds.Height -= borderWidths.Bottom; - if (e.CellStyle.Padding != Padding.Empty) - { - valBounds.Offset(e.CellStyle.Padding.Left, e.CellStyle.Padding.Top); - valBounds.Width -= e.CellStyle.Padding.Horizontal; - valBounds.Height -= e.CellStyle.Padding.Vertical; - } + var leftPad = e.CellStyle.Padding.Left; + RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, e.CellBounds.Height); + Rectangle borderWidths = BorderWidths(e.AdvancedBorderStyle); + Rectangle valBounds = e.CellBounds; + valBounds.Offset(borderWidths.X, borderWidths.Y); + valBounds.Width -= borderWidths.Right; + valBounds.Height -= borderWidths.Bottom; + if (e.CellStyle.Padding != Padding.Empty) + { + valBounds.Offset(e.CellStyle.Padding.Left, e.CellStyle.Padding.Top); + valBounds.Width -= e.CellStyle.Padding.Horizontal; + valBounds.Height -= e.CellStyle.Padding.Vertical; + } - TextFormatFlags flags = - TextFormatFlags.Left - | TextFormatFlags.SingleLine - | TextFormatFlags.NoPrefix - | TextFormatFlags.PreserveGraphicsClipping - | TextFormatFlags.NoPadding - | TextFormatFlags.VerticalCenter - | TextFormatFlags.TextBoxControl; + TextFormatFlags flags = + TextFormatFlags.Left + | TextFormatFlags.SingleLine + | TextFormatFlags.NoPrefix + | TextFormatFlags.PreserveGraphicsClipping + | TextFormatFlags.NoPadding + | TextFormatFlags.VerticalCenter + | TextFormatFlags.TextBoxControl; - // | TextFormatFlags.VerticalCenter - // | TextFormatFlags.TextBoxControl - // TextFormatFlags.SingleLine - //TextRenderer.DrawText(e.Graphics, e.Value as String, e.CellStyle.Font, valBounds, Color.FromKnownColor(KnownColor.Black), flags); + // | TextFormatFlags.VerticalCenter + // | TextFormatFlags.TextBoxControl + // TextFormatFlags.SingleLine + //TextRenderer.DrawText(e.Graphics, e.Value as String, e.CellStyle.Font, valBounds, Color.FromKnownColor(KnownColor.Black), flags); - Point wordPos = valBounds.Location; - Size proposedSize = new(valBounds.Width, valBounds.Height); + Point wordPos = valBounds.Location; + Size proposedSize = new(valBounds.Width, valBounds.Height); - Rectangle r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); - e.Graphics.SetClip(e.CellBounds); + Rectangle r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); + e.Graphics.SetClip(e.CellBounds); - foreach (HilightMatchEntry matchEntry in matchList) - { - Font font = matchEntry != null && matchEntry.HilightEntry.IsBold - ? logPaintCtx.BoldFont - : logPaintCtx.NormalFont; + foreach (HilightMatchEntry matchEntry in matchList) + { + Font font = matchEntry != null && matchEntry.HilightEntry.IsBold + ? logPaintCtx.BoldFont + : logPaintCtx.NormalFont; - Brush bgBrush = matchEntry.HilightEntry.BackgroundColor != Color.Empty - ? new SolidBrush(matchEntry.HilightEntry.BackgroundColor) - : null; + Brush bgBrush = matchEntry.HilightEntry.BackgroundColor != Color.Empty + ? new SolidBrush(matchEntry.HilightEntry.BackgroundColor) + : null; - var matchWord = string.Empty; - if (value is Column again) + var matchWord = string.Empty; + if (value is Column again) + { + if (string.IsNullOrEmpty(again.FullValue) == false) { - if (string.IsNullOrEmpty(again.FullValue) == false) - { - matchWord = again.FullValue.Substring(matchEntry.StartPos, matchEntry.Length); - } + matchWord = again.FullValue.Substring(matchEntry.StartPos, matchEntry.Length); } + } - Size wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags); - wordSize.Height = e.CellBounds.Height; - Rectangle wordRect = new(wordPos, wordSize); + Size wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags); + wordSize.Height = e.CellBounds.Height; + Rectangle wordRect = new(wordPos, wordSize); - Color foreColor = matchEntry.HilightEntry.ForegroundColor; - if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected) + Color foreColor = matchEntry.HilightEntry.ForegroundColor; + if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected) + { + if (!noBackgroundFill && bgBrush != null && !matchEntry.HilightEntry.NoBackground) { - if (!noBackgroundFill && bgBrush != null && !matchEntry.HilightEntry.NoBackground) - { - e.Graphics.FillRectangle(bgBrush, wordRect); - } + e.Graphics.FillRectangle(bgBrush, wordRect); } - else + } + else + { + if (foreColor.Equals(Color.Black)) { - if (foreColor.Equals(Color.Black)) - { - foreColor = Color.White; - } + foreColor = Color.White; } - TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, foreColor, flags); - - wordPos.Offset(wordSize.Width, 0); - bgBrush?.Dispose(); } + TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, foreColor, flags); + + wordPos.Offset(wordSize.Width, 0); + bgBrush?.Dispose(); } + } - /// - /// Builds a list of HilightMatchEntry objects. A HilightMatchEntry spans over a region that is painted with the same foreground and - /// background colors. - /// All regions which don't match a word-mode entry will be painted with the colors of a default entry (groundEntry). This is either the - /// first matching non-word-mode highlight entry or a black-on-white default (if no matching entry was found). - /// - /// List of all highlight matches for the current cell - /// The entry that is used as the default. - /// List of HilightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring. - private static IList MergeHighlightMatchEntries(IList matchList, HilightMatchEntry groundEntry) + /// + /// Builds a list of HilightMatchEntry objects. A HilightMatchEntry spans over a region that is painted with the same foreground and + /// background colors. + /// All regions which don't match a word-mode entry will be painted with the colors of a default entry (groundEntry). This is either the + /// first matching non-word-mode highlight entry or a black-on-white default (if no matching entry was found). + /// + /// List of all highlight matches for the current cell + /// The entry that is used as the default. + /// List of HilightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring. + private static IList MergeHighlightMatchEntries(IList matchList, HilightMatchEntry groundEntry) + { + // Fill an area with lenth of whole text with a default hilight entry + var entryArray = new HighlightEntry[groundEntry.Length]; + for (var i = 0; i < entryArray.Length; ++i) { - // Fill an area with lenth of whole text with a default hilight entry - var entryArray = new HighlightEntry[groundEntry.Length]; - for (var i = 0; i < entryArray.Length; ++i) - { - entryArray[i] = groundEntry.HilightEntry; - } + entryArray[i] = groundEntry.HilightEntry; + } - // "overpaint" with all matching word match enries - // Non-word-mode matches will not overpaint because they use the groundEntry - foreach (HilightMatchEntry me in matchList) + // "overpaint" with all matching word match enries + // Non-word-mode matches will not overpaint because they use the groundEntry + foreach (HilightMatchEntry me in matchList) + { + var endPos = me.StartPos + me.Length; + for (var i = me.StartPos; i < endPos; ++i) { - var endPos = me.StartPos + me.Length; - for (var i = me.StartPos; i < endPos; ++i) + if (me.HilightEntry.IsWordMatch) { - if (me.HilightEntry.IsWordMatch) - { - entryArray[i] = me.HilightEntry; - } - //else - //{ - // //entryArray[i].ForegroundColor = me.HilightEntry.ForegroundColor; - //} + entryArray[i] = me.HilightEntry; } + //else + //{ + // //entryArray[i].ForegroundColor = me.HilightEntry.ForegroundColor; + //} } + } - // collect areas with same hilight entry and build new highlight match entries for it - IList mergedList = new List(); - if (entryArray.Length > 0) + // collect areas with same hilight entry and build new highlight match entries for it + IList mergedList = new List(); + if (entryArray.Length > 0) + { + HighlightEntry currentEntry = entryArray[0]; + var lastStartPos = 0; + var pos = 0; + for (; pos < entryArray.Length; ++pos) { - HighlightEntry currentEntry = entryArray[0]; - var lastStartPos = 0; - var pos = 0; - for (; pos < entryArray.Length; ++pos) + if (entryArray[pos] != currentEntry) { - if (entryArray[pos] != currentEntry) - { - HilightMatchEntry me = new(); - me.StartPos = lastStartPos; - me.Length = pos - lastStartPos; - me.HilightEntry = currentEntry; - mergedList.Add(me); - currentEntry = entryArray[pos]; - lastStartPos = pos; - } + HilightMatchEntry me = new(); + me.StartPos = lastStartPos; + me.Length = pos - lastStartPos; + me.HilightEntry = currentEntry; + mergedList.Add(me); + currentEntry = entryArray[pos]; + lastStartPos = pos; } - HilightMatchEntry me2 = new(); - me2.StartPos = lastStartPos; - me2.Length = pos - lastStartPos; - me2.HilightEntry = currentEntry; - mergedList.Add(me2); } - return mergedList; + HilightMatchEntry me2 = new(); + me2.StartPos = lastStartPos; + me2.Length = pos - lastStartPos; + me2.HilightEntry = currentEntry; + mergedList.Add(me2); } - - #endregion + return mergedList; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Extensions/Utils.cs b/src/LogExpert.UI/Extensions/Utils.cs index 9e3507d1..6b2c2d67 100644 --- a/src/LogExpert.UI/Extensions/Utils.cs +++ b/src/LogExpert.UI/Extensions/Utils.cs @@ -1,57 +1,56 @@ -namespace LogExpert.UI.Extensions +namespace LogExpert.UI.Extensions; + +internal static class Utils { - internal static class Utils + public static string GetWordFromPos(int xPos, string text, Graphics g, Font font) { - public static string GetWordFromPos(int xPos, string text, Graphics g, Font font) - { - var words = text.Split([' ', '.', ':', ';']); + var words = text.Split([' ', '.', ':', ';']); - var index = 0; + var index = 0; - List crList = []; + List crList = []; - for (var i = 0; i < words.Length; ++i) - { - crList.Add(new CharacterRange(index, words[i].Length)); - index += words[i].Length; - } + for (var i = 0; i < words.Length; ++i) + { + crList.Add(new CharacterRange(index, words[i].Length)); + index += words[i].Length; + } - CharacterRange[] crArray = [.. crList]; + CharacterRange[] crArray = [.. crList]; - StringFormat stringFormat = new(StringFormat.GenericTypographic) - { - Trimming = StringTrimming.None, - FormatFlags = StringFormatFlags.NoClip - }; + StringFormat stringFormat = new(StringFormat.GenericTypographic) + { + Trimming = StringTrimming.None, + FormatFlags = StringFormatFlags.NoClip + }; - stringFormat.SetMeasurableCharacterRanges(crArray); + stringFormat.SetMeasurableCharacterRanges(crArray); - RectangleF rect = new(0, 0, 3000, 20); - Region[] stringRegions = g.MeasureCharacterRanges(text, font, rect, stringFormat); + RectangleF rect = new(0, 0, 3000, 20); + Region[] stringRegions = g.MeasureCharacterRanges(text, font, rect, stringFormat); - var found = false; + var found = false; - var y = 0; + var y = 0; - foreach (Region regio in stringRegions) + foreach (Region regio in stringRegions) + { + if (regio.IsVisible(xPos, 3, g)) { - if (regio.IsVisible(xPos, 3, g)) - { - found = true; - break; - } - - y++; + found = true; + break; } - if (found) - { - return words[y]; - } - else - { - return null; - } + y++; + } + + if (found) + { + return words[y]; + } + else + { + return null; } } } diff --git a/src/LogExpert.UI/Extensions/Win32.cs b/src/LogExpert.UI/Extensions/Win32.cs index 3fef2b52..a039e711 100644 --- a/src/LogExpert.UI/Extensions/Win32.cs +++ b/src/LogExpert.UI/Extensions/Win32.cs @@ -2,150 +2,149 @@ using System.Runtime.InteropServices; using System.Runtime.Versioning; -namespace LogExpert.UI.Extensions +namespace LogExpert.UI.Extensions; + +[SupportedOSPlatform("windows")] +internal static partial class Win32 //NativeMethods { - [SupportedOSPlatform("windows")] - internal static partial class Win32 //NativeMethods + #region Fields + + public const long SM_CYVSCROLL = 20; + public const long SM_CXHSCROLL = 21; + public const long SM_CXVSCROLL = 2; + public const long SM_CYHSCROLL = 3; + private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19; + private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20; + + #endregion + + #region Library Imports + [LibraryImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool DestroyIcon(nint hIcon); + + [LibraryImport("User32.dll")] + public static partial int SetForegroundWindow(nint hWnd); + + [LibraryImport("user32.dll")] + public static partial long GetSystemMetricsForDpi(long index); + + [LibraryImport("user32.dll")] + public static partial long GetSystemMetrics(long index); + + [LibraryImport("user32.dll")] + public static partial short GetKeyState(int vKey); + + /* + UINT ExtractIconEx( + LPCTSTR lpszFile, + int nIconIndex, + HICON *phiconLarge, + HICON *phiconSmall, + UINT nIcons + ); + * */ + [LibraryImport("shell32.dll", StringMarshalling = StringMarshalling.Utf16)] + public static partial uint ExtractIconEx( + string fileName, + int iconIndex, + ref nint iconsLarge, + ref nint iconsSmall, + uint numIcons + ); + + #region TitleBarDarkMode + [LibraryImport("dwmapi.dll")] + public static partial int DwmSetWindowAttribute(nint hwnd, int attr, ref int attrValue, int attrSize); + #endregion + #endregion + + #region Public methods + + public static Icon LoadIconFromExe(string fileName, int index) + { + //IntPtr[] smallIcons = new IntPtr[1]; + //IntPtr[] largeIcons = new IntPtr[1]; + nint smallIcons = new(); + nint largeIcons = new(); + var num = (int)ExtractIconEx(fileName, index, ref largeIcons, ref smallIcons, 1); + if (num > 0 && smallIcons != nint.Zero) + { + var icon = (Icon)Icon.FromHandle(smallIcons).Clone(); + DestroyIcon(smallIcons); + return icon; + } + if (num > 0 && largeIcons != nint.Zero) + { + var icon = (Icon)Icon.FromHandle(largeIcons).Clone(); + DestroyIcon(largeIcons); + return icon; + } + return null; + } + + public static Icon[,] ExtractIcons(string fileName) { - #region Fields - - public const long SM_CYVSCROLL = 20; - public const long SM_CXHSCROLL = 21; - public const long SM_CXVSCROLL = 2; - public const long SM_CYHSCROLL = 3; - private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19; - private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20; - - #endregion - - #region Library Imports - [LibraryImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static partial bool DestroyIcon(nint hIcon); - - [LibraryImport("User32.dll")] - public static partial int SetForegroundWindow(nint hWnd); - - [LibraryImport("user32.dll")] - public static partial long GetSystemMetricsForDpi(long index); - - [LibraryImport("user32.dll")] - public static partial long GetSystemMetrics(long index); - - [LibraryImport("user32.dll")] - public static partial short GetKeyState(int vKey); - - /* - UINT ExtractIconEx( - LPCTSTR lpszFile, - int nIconIndex, - HICON *phiconLarge, - HICON *phiconSmall, - UINT nIcons - ); - * */ - [LibraryImport("shell32.dll", StringMarshalling = StringMarshalling.Utf16)] - public static partial uint ExtractIconEx( - string fileName, - int iconIndex, - ref nint iconsLarge, - ref nint iconsSmall, - uint numIcons - ); - - #region TitleBarDarkMode - [LibraryImport("dwmapi.dll")] - public static partial int DwmSetWindowAttribute(nint hwnd, int attr, ref int attrValue, int attrSize); - #endregion - #endregion - - #region Public methods - - public static Icon LoadIconFromExe(string fileName, int index) + var smallIcon = nint.Zero; + var largeIcon = nint.Zero; + var iconCount = (int)ExtractIconEx(fileName, -1, ref largeIcon, ref smallIcon, 0); + if (iconCount <= 0) { - //IntPtr[] smallIcons = new IntPtr[1]; - //IntPtr[] largeIcons = new IntPtr[1]; - nint smallIcons = new(); - nint largeIcons = new(); - var num = (int)ExtractIconEx(fileName, index, ref largeIcons, ref smallIcons, 1); - if (num > 0 && smallIcons != nint.Zero) + return null; + } + + nint smallIcons = new(); + nint largeIcons = new(); + var result = new Icon[2, iconCount]; + + for (var i = 0; i < iconCount; ++i) + { + var num = (int)ExtractIconEx(fileName, i, ref largeIcons, ref smallIcons, 1); + if (smallIcons != nint.Zero) { - var icon = (Icon)Icon.FromHandle(smallIcons).Clone(); + result[0, i] = (Icon)Icon.FromHandle(smallIcons).Clone(); DestroyIcon(smallIcons); - return icon; } - if (num > 0 && largeIcons != nint.Zero) + else { - var icon = (Icon)Icon.FromHandle(largeIcons).Clone(); - DestroyIcon(largeIcons); - return icon; + result[0, i] = null; } - return null; - } - - public static Icon[,] ExtractIcons(string fileName) - { - var smallIcon = nint.Zero; - var largeIcon = nint.Zero; - var iconCount = (int)ExtractIconEx(fileName, -1, ref largeIcon, ref smallIcon, 0); - if (iconCount <= 0) + if (num > 0 && largeIcons != nint.Zero) { - return null; + result[1, i] = (Icon)Icon.FromHandle(largeIcons).Clone(); + DestroyIcon(largeIcons); } - - nint smallIcons = new(); - nint largeIcons = new(); - var result = new Icon[2, iconCount]; - - for (var i = 0; i < iconCount; ++i) + else { - var num = (int)ExtractIconEx(fileName, i, ref largeIcons, ref smallIcons, 1); - if (smallIcons != nint.Zero) - { - result[0, i] = (Icon)Icon.FromHandle(smallIcons).Clone(); - DestroyIcon(smallIcons); - } - else - { - result[0, i] = null; - } - if (num > 0 && largeIcons != nint.Zero) - { - result[1, i] = (Icon)Icon.FromHandle(largeIcons).Clone(); - DestroyIcon(largeIcons); - } - else - { - result[1, i] = null; - } + result[1, i] = null; } - return result; } + return result; + } - #endregion - - #region Private Methods - - public static bool UseImmersiveDarkMode(nint handle, bool enabled) - { - - var attribute = DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1; - if (IsWindows10OrGreater(18985)) - { - attribute = DWMWA_USE_IMMERSIVE_DARK_MODE; - } + #endregion - var useImmersiveDarkMode = enabled ? 1 : 0; - return DwmSetWindowAttribute(handle, attribute, ref useImmersiveDarkMode, sizeof(int)) == 0; + #region Private Methods - } + public static bool UseImmersiveDarkMode(nint handle, bool enabled) + { - private static bool IsWindows10OrGreater(int build = -1) + var attribute = DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1; + if (IsWindows10OrGreater(18985)) { - return Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= build; + attribute = DWMWA_USE_IMMERSIVE_DARK_MODE; } - #endregion TitleBarDarkMode + var useImmersiveDarkMode = enabled ? 1 : 0; + return DwmSetWindowAttribute(handle, attribute, ref useImmersiveDarkMode, sizeof(int)) == 0; } + + private static bool IsWindows10OrGreater(int build = -1) + { + return Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= build; + } + + #endregion TitleBarDarkMode + } \ No newline at end of file diff --git a/src/LogExpert.UI/Interface/ILogPaintContextUI.cs b/src/LogExpert.UI/Interface/ILogPaintContextUI.cs index dcd8ae41..39557972 100644 --- a/src/LogExpert.UI/Interface/ILogPaintContextUI.cs +++ b/src/LogExpert.UI/Interface/ILogPaintContextUI.cs @@ -2,34 +2,33 @@ using LogExpert.Core.Entities; using LogExpert.Core.Interface; -namespace LogExpert.UI.Interface +namespace LogExpert.UI.Interface; + +/// +/// Declares methods that are needed for drawing log lines. Used by PaintHelper. +/// +public interface ILogPaintContextUI : ILogPaintContext { - /// - /// Declares methods that are needed for drawing log lines. Used by PaintHelper. - /// - public interface ILogPaintContextUI : ILogPaintContext - { - #region Properties + #region Properties - Font MonospacedFont { get; } // Font font = new Font("Courier New", this.Preferences.fontSize, FontStyle.Bold); - Font NormalFont { get; } - Font BoldFont { get; } - Color BookmarkColor { get; } + Font MonospacedFont { get; } // Font font = new Font("Courier New", this.Preferences.fontSize, FontStyle.Bold); + Font NormalFont { get; } + Font BoldFont { get; } + Color BookmarkColor { get; } - #endregion + #endregion - #region Public methods + #region Public methods - ILogLine GetLogLine(int lineNum); + ILogLine GetLogLine(int lineNum); - IColumn GetCellValue(int rowIndex, int columnIndex); + IColumn GetCellValue(int rowIndex, int columnIndex); - Bookmark GetBookmarkForLine(int lineNum); + Bookmark GetBookmarkForLine(int lineNum); - HighlightEntry FindHighlightEntry(ITextValue line, bool noWordMatches); + HighlightEntry FindHighlightEntry(ITextValue line, bool noWordMatches); - IList FindHighlightMatches(ITextValue line); + IList FindHighlightMatches(ITextValue line); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/LogExpert/Classes/CommandLine/CmdLine.cs b/src/LogExpert/Classes/CommandLine/CmdLine.cs index 878c1e66..07155cb5 100644 --- a/src/LogExpert/Classes/CommandLine/CmdLine.cs +++ b/src/LogExpert/Classes/CommandLine/CmdLine.cs @@ -5,185 +5,184 @@ //TODO: Replace with https://github.com/commandlineparser/commandline //TODO: or with this https://github.com/natemcmaster/CommandLineUtils -namespace LogExpert.Classes.CommandLine +namespace LogExpert.Classes.CommandLine; + +/// +/// Represents an string command line parameter. +/// +public class CmdLineString(string name, bool required, string helpMessage) : CmdLineParameter(name, required, helpMessage) { - /// - /// Represents an string command line parameter. - /// - public class CmdLineString(string name, bool required, string helpMessage) : CmdLineParameter(name, required, helpMessage) - { - #region Public methods + #region Public methods - public static implicit operator string(CmdLineString s) - { - return s.Value; - } - - #endregion + public static implicit operator string(CmdLineString s) + { + return s.Value; } - /// - /// Provides a simple strongly typed interface to work with command line parameters. - /// - public class CmdLine - { - #region Fields + #endregion +} - // A private dictonary containing the parameters. - private readonly Dictionary parameters = []; +/// +/// Provides a simple strongly typed interface to work with command line parameters. +/// +public class CmdLine +{ + #region Fields - #endregion + // A private dictonary containing the parameters. + private readonly Dictionary parameters = []; - #region cTor + #endregion - /// - /// Creats a new empty command line object. - /// - public CmdLine() - { - } + #region cTor + + /// + /// Creats a new empty command line object. + /// + public CmdLine() + { + } - #endregion + #endregion - #region Properties + #region Properties - /// - /// Returns a command line parameter by the name. - /// - /// The name of the parameter (the word after the initial hyphen (-). - /// A reference to the named comman line object. - public CmdLineParameter this[string name] + /// + /// Returns a command line parameter by the name. + /// + /// The name of the parameter (the word after the initial hyphen (-). + /// A reference to the named comman line object. + public CmdLineParameter this[string name] + { + get { - get + if (parameters.TryGetValue(name, out CmdLineParameter value) == false) { - if (parameters.TryGetValue(name, out CmdLineParameter value) == false) - { - throw new CmdLineException(name, "Not a registered parameter."); - } - return value; + throw new CmdLineException(name, "Not a registered parameter."); } + return value; } + } - #endregion + #endregion - #region Public methods + #region Public methods - /// - /// Registers a parameter to be used and adds it to the help screen. - /// - /// The parameter to add. - public void RegisterParameter(CmdLineParameter parameter) + /// + /// Registers a parameter to be used and adds it to the help screen. + /// + /// The parameter to add. + public void RegisterParameter(CmdLineParameter parameter) + { + if (parameters.ContainsKey(parameter.Name)) { - if (parameters.ContainsKey(parameter.Name)) - { - throw new CmdLineException(parameter.Name, "Parameter is already registered."); - } - parameters.Add(parameter.Name, parameter); + throw new CmdLineException(parameter.Name, "Parameter is already registered."); } + parameters.Add(parameter.Name, parameter); + } - /// - /// Registers parameters to be used and adds hem to the help screen. - /// - /// The parameter to add. - public void RegisterParameter(CmdLineParameter[] parameters) + /// + /// Registers parameters to be used and adds hem to the help screen. + /// + /// The parameter to add. + public void RegisterParameter(CmdLineParameter[] parameters) + { + foreach (CmdLineParameter p in parameters) { - foreach (CmdLineParameter p in parameters) - { - RegisterParameter(p); - } + RegisterParameter(p); } + } - /// - /// Parses the command line and sets the value of each registered parmaters. - /// - /// The arguments array sent to main() - /// Any reminding strings after arguments has been processed. - public string[] Parse(string[] args) - { - var i = 0; + /// + /// Parses the command line and sets the value of each registered parmaters. + /// + /// The arguments array sent to main() + /// Any reminding strings after arguments has been processed. + public string[] Parse(string[] args) + { + var i = 0; - List new_args = []; + List new_args = []; - while (i < args.Length) + while (i < args.Length) + { + if (args[i].Length > 1 && args[i][0] == '-') { - if (args[i].Length > 1 && args[i][0] == '-') + // The current string is a parameter name + var key = args[i][1..].ToLower(); + var argsValue = string.Empty; + i++; + if (i < args.Length) { - // The current string is a parameter name - var key = args[i][1..].ToLower(); - var argsValue = string.Empty; - i++; - if (i < args.Length) + if (args[i].Length > 0 && args[i][0] == '-') { - if (args[i].Length > 0 && args[i][0] == '-') - { - // The next string is a new parameter, do not nothing - } - else - { - // The next string is a value, read the value and move forward - argsValue = args[i]; - i++; - } + // The next string is a new parameter, do not nothing } - if (parameters.TryGetValue(key, out CmdLineParameter cmdLineParameter) == false) + else { - throw new CmdLineException(key, "Parameter is not allowed."); + // The next string is a value, read the value and move forward + argsValue = args[i]; + i++; } - - if (cmdLineParameter.Exists) - { - throw new CmdLineException(key, "Parameter is specified more than once."); - } - - cmdLineParameter.SetValue(argsValue); } - else + if (parameters.TryGetValue(key, out CmdLineParameter cmdLineParameter) == false) { - new_args.Add(args[i]); - i++; + throw new CmdLineException(key, "Parameter is not allowed."); } - } - - // Check that required parameters are present in the command line. - foreach (var key in parameters.Keys) - { - if (parameters[key].Required && parameters[key].Exists == false) + if (cmdLineParameter.Exists) { - throw new CmdLineException(key, "Required parameter is not found."); + throw new CmdLineException(key, "Parameter is specified more than once."); } - } - return new_args.ToArray(); + cmdLineParameter.SetValue(argsValue); + } + else + { + new_args.Add(args[i]); + i++; + } } - /// - /// Generates the help screen. - /// - public string HelpScreen() + + // Check that required parameters are present in the command line. + foreach (var key in parameters.Keys) { - var len = 0; - foreach (var key in parameters.Keys) + if (parameters[key].Required && parameters[key].Exists == false) { - len = Math.Max(len, key.Length); + throw new CmdLineException(key, "Required parameter is not found."); } + } - var help = "\nParameters:\n\n"; - foreach (var key in parameters.Keys) + return new_args.ToArray(); + } + + /// + /// Generates the help screen. + /// + public string HelpScreen() + { + var len = 0; + foreach (var key in parameters.Keys) + { + len = Math.Max(len, key.Length); + } + + var help = "\nParameters:\n\n"; + foreach (var key in parameters.Keys) + { + var s = "-" + parameters[key].Name; + while (s.Length < len + 3) { - var s = "-" + parameters[key].Name; - while (s.Length < len + 3) - { - s += " "; - } - s += parameters[key].Help + "\n"; - help += s; + s += " "; } - return help; + s += parameters[key].Help + "\n"; + help += s; } - - #endregion + return help; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert/Classes/CommandLine/CmdLineException.cs b/src/LogExpert/Classes/CommandLine/CmdLineException.cs index a89bc570..01e67c7d 100644 --- a/src/LogExpert/Classes/CommandLine/CmdLineException.cs +++ b/src/LogExpert/Classes/CommandLine/CmdLineException.cs @@ -5,27 +5,30 @@ //TODO: Replace with https://github.com/commandlineparser/commandline //TODO: or with this https://github.com/natemcmaster/CommandLineUtils -namespace LogExpert.Classes.CommandLine +namespace LogExpert.Classes.CommandLine; + +/// +/// Represents an error occuring during command line parsing. +/// +public class CmdLineException : Exception { - /// - /// Represents an error occuring during command line parsing. - /// - public class CmdLineException : Exception + #region cTor + + public CmdLineException (string parameter, string message) : base($"Syntax error of parameter -{parameter}: {message}") { - #region cTor + } - public CmdLineException(string parameter, string message) - : - base(string.Format("Syntax error of parameter -{0}: {1}", parameter, message)) - { - } + public CmdLineException (string message) : base(message) + { + } - public CmdLineException(string message) - : - base(message) - { - } + public CmdLineException () + { + } - #endregion + public CmdLineException (string message, Exception innerException) : base(message, innerException) + { } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert/Classes/CommandLine/CmdLineInt.cs b/src/LogExpert/Classes/CommandLine/CmdLineInt.cs index 949e6cd6..c67dd9ad 100644 --- a/src/LogExpert/Classes/CommandLine/CmdLineInt.cs +++ b/src/LogExpert/Classes/CommandLine/CmdLineInt.cs @@ -5,98 +5,97 @@ //TODO: Replace with https://github.com/commandlineparser/commandline //TODO: or with this https://github.com/natemcmaster/CommandLineUtils -namespace LogExpert.Classes.CommandLine +namespace LogExpert.Classes.CommandLine; + +/// +/// Represents an integer command line parameter. +/// +public class CmdLineInt : CmdLineParameter { - /// - /// Represents an integer command line parameter. - /// - public class CmdLineInt : CmdLineParameter - { - #region Fields + #region Fields - private readonly int _max = int.MaxValue; - private readonly int _min = int.MinValue; + private readonly int _max = int.MaxValue; + private readonly int _min = int.MinValue; - #endregion + #endregion - #region cTor + #region cTor - /// - /// Creates a new instance of this class. - /// - /// Name of parameter. - /// Require that the parameter is present in the command line. - /// The explanation of the parameter to add to the help screen. - public CmdLineInt(string name, bool required, string helpMessage) - : base(name, required, helpMessage) - { - } + /// + /// Creates a new instance of this class. + /// + /// Name of parameter. + /// Require that the parameter is present in the command line. + /// The explanation of the parameter to add to the help screen. + public CmdLineInt(string name, bool required, string helpMessage) + : base(name, required, helpMessage) + { + } - /// - /// Creates a new instance of this class. - /// - /// Name of parameter. - /// Require that the parameter is present in the command line. - /// The explanation of the parameter to add to the help screen. - /// The minimum value of the parameter. - /// The maximum valie of the parameter. - public CmdLineInt(string name, bool required, string helpMessage, int min, int max) - : base(name, required, helpMessage) - { - _min = min; - _max = max; - } + /// + /// Creates a new instance of this class. + /// + /// Name of parameter. + /// Require that the parameter is present in the command line. + /// The explanation of the parameter to add to the help screen. + /// The minimum value of the parameter. + /// The maximum valie of the parameter. + public CmdLineInt(string name, bool required, string helpMessage, int min, int max) + : base(name, required, helpMessage) + { + _min = min; + _max = max; + } - #endregion + #endregion - #region Properties + #region Properties - /// - /// Returns the current value of the parameter. - /// - new public int Value { get; private set; } + /// + /// Returns the current value of the parameter. + /// + new public int Value { get; private set; } - #endregion + #endregion - #region Public methods + #region Public methods - /// - /// Sets the value of the parameter. - /// - /// A string containing a integer expression. - public override void SetValue(string value) + /// + /// Sets the value of the parameter. + /// + /// A string containing a integer expression. + public override void SetValue(string value) + { + base.SetValue(value); + int i; + try { - base.SetValue(value); - int i; - try - { - i = Convert.ToInt32(value); - } - catch (Exception) - { - throw new CmdLineException(Name, "Value is not an integer."); - } - if (i < _min) - { - throw new CmdLineException(Name, string.Format("Value must be greather or equal to {0}.", _min)); - } - if (i > _max) - { - throw new CmdLineException(Name, string.Format("Value must be less or equal to {0}.", _max)); - } - Value = i; + i = Convert.ToInt32(value); } - - /// - /// A implicit converion to a int data type. - /// - /// - /// - public static implicit operator int(CmdLineInt s) + catch (Exception) + { + throw new CmdLineException(Name, "Value is not an integer."); + } + if (i < _min) { - return s.Value; + throw new CmdLineException(Name, string.Format("Value must be greather or equal to {0}.", _min)); } + if (i > _max) + { + throw new CmdLineException(Name, string.Format("Value must be less or equal to {0}.", _max)); + } + Value = i; + } - #endregion + /// + /// A implicit converion to a int data type. + /// + /// + /// + public static implicit operator int(CmdLineInt s) + { + return s.Value; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert/Classes/CommandLine/CmdLineParameter.cs b/src/LogExpert/Classes/CommandLine/CmdLineParameter.cs index 12d1d48a..5143ead3 100644 --- a/src/LogExpert/Classes/CommandLine/CmdLineParameter.cs +++ b/src/LogExpert/Classes/CommandLine/CmdLineParameter.cs @@ -5,62 +5,61 @@ //TODO: Replace with https://github.com/commandlineparser/commandline //TODO: or with this https://github.com/natemcmaster/CommandLineUtils -namespace LogExpert.Classes.CommandLine +namespace LogExpert.Classes.CommandLine; + +/// +/// Represents a command line parameter. +/// Parameters are words in the command line beginning with a hyphen (-). +/// The value of the parameter is the next word in +/// +/// +/// Creates a new instance of this class. +/// +/// Name of parameter. +/// Require that the parameter is present in the command line. +/// The explanation of the parameter to add to the help screen. +public class CmdLineParameter(string name, bool required, string helpMessage) { + #region Properties + /// - /// Represents a command line parameter. - /// Parameters are words in the command line beginning with a hyphen (-). - /// The value of the parameter is the next word in + /// Returns the value of the parameter. /// - /// - /// Creates a new instance of this class. - /// - /// Name of parameter. - /// Require that the parameter is present in the command line. - /// The explanation of the parameter to add to the help screen. - public class CmdLineParameter(string name, bool required, string helpMessage) - { - #region Properties - - /// - /// Returns the value of the parameter. - /// - public string Value { get; private set; } = ""; - - /// - /// Returns the help message associated with the parameter. - /// - public string Help { get; } = helpMessage; + public string Value { get; private set; } = ""; - /// - /// Returns true if the parameter was found in the command line. - /// - public bool Exists { get; private set; } + /// + /// Returns the help message associated with the parameter. + /// + public string Help { get; } = helpMessage; - /// - /// Returns true if the parameter is required in the command line. - /// - public bool Required { get; } = required; + /// + /// Returns true if the parameter was found in the command line. + /// + public bool Exists { get; private set; } - /// - /// Returns the name of the parameter. - /// - public string Name { get; } = name; + /// + /// Returns true if the parameter is required in the command line. + /// + public bool Required { get; } = required; - #endregion + /// + /// Returns the name of the parameter. + /// + public string Name { get; } = name; - #region Public methods + #endregion - /// - /// Sets the value of the parameter. - /// - /// A string containing a integer expression. - public virtual void SetValue(string value) - { - Value = value; - Exists = true; - } + #region Public methods - #endregion + /// + /// Sets the value of the parameter. + /// + /// A string containing a integer expression. + public virtual void SetValue(string value) + { + Value = value; + Exists = true; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert/Classes/CommandLine/ConsoleCmdLine.cs b/src/LogExpert/Classes/CommandLine/ConsoleCmdLine.cs index 0d93f533..408831e5 100644 --- a/src/LogExpert/Classes/CommandLine/ConsoleCmdLine.cs +++ b/src/LogExpert/Classes/CommandLine/ConsoleCmdLine.cs @@ -5,57 +5,56 @@ //TODO: Replace with https://github.com/commandlineparser/commandline //TODO: or with this https://github.com/natemcmaster/CommandLineUtils -namespace LogExpert.Classes.CommandLine +namespace LogExpert.Classes.CommandLine; + +/// +/// Represents a CmdLine object to use with console applications. +/// The -help parameter will be registered automatically. +/// Any errors will be written to the console instead of generating exceptions. +/// +public class ConsoleCmdLine : CmdLine { - /// - /// Represents a CmdLine object to use with console applications. - /// The -help parameter will be registered automatically. - /// Any errors will be written to the console instead of generating exceptions. - /// - public class ConsoleCmdLine : CmdLine + #region cTor + + public ConsoleCmdLine() { - #region cTor + RegisterParameter(new CmdLineString("help", false, "Prints the help screen.")); + } + + #endregion + + #region Public methods + + public new string[] Parse(string[] args) + { + string[] ret = []; + + var error = string.Empty; - public ConsoleCmdLine() + try { - RegisterParameter(new CmdLineString("help", false, "Prints the help screen.")); + ret = base.Parse(args); + } + catch (CmdLineException ex) + { + error = ex.Message; } - #endregion - - #region Public methods + if (this["help"].Exists) + { + Console.WriteLine(HelpScreen()); + Environment.Exit(0); + } - public new string[] Parse(string[] args) + if (error != string.Empty) { - string[] ret = []; - - var error = string.Empty; - - try - { - ret = base.Parse(args); - } - catch (CmdLineException ex) - { - error = ex.Message; - } - - if (this["help"].Exists) - { - Console.WriteLine(HelpScreen()); - Environment.Exit(0); - } - - if (error != string.Empty) - { - Console.WriteLine(error); - Console.WriteLine("Use -help for more information."); - Environment.Exit(1); - } - - return ret; + Console.WriteLine(error); + Console.WriteLine("Use -help for more information."); + Environment.Exit(1); } - #endregion + return ret; } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert/Classes/LogExpertApplicationContext.cs b/src/LogExpert/Classes/LogExpertApplicationContext.cs index 1dfc04e1..a078f898 100644 --- a/src/LogExpert/Classes/LogExpertApplicationContext.cs +++ b/src/LogExpert/Classes/LogExpertApplicationContext.cs @@ -2,35 +2,34 @@ using System; using System.Windows.Forms; -namespace LogExpert.Classes -{ - internal class LogExpertApplicationContext : ApplicationContext - { - #region Fields +namespace LogExpert.Classes; - private readonly LogExpertProxy _proxy; +internal class LogExpertApplicationContext : ApplicationContext +{ + #region Fields - #endregion + private readonly LogExpertProxy _proxy; - #region cTor + #endregion - public LogExpertApplicationContext(LogExpertProxy proxy, ILogTabWindow firstLogWin) - { - _proxy = proxy; - _proxy.LastWindowClosed += new LogExpertProxy.LastWindowClosedEventHandler(OnProxyLastWindowClosed); - firstLogWin.Show(); - } + #region cTor - #endregion + public LogExpertApplicationContext(LogExpertProxy proxy, ILogTabWindow firstLogWin) + { + _proxy = proxy; + _proxy.LastWindowClosed += new LogExpertProxy.LastWindowClosedEventHandler(OnProxyLastWindowClosed); + firstLogWin.Show(); + } - #region Events handler + #endregion - private void OnProxyLastWindowClosed(object sender, EventArgs e) - { - ExitThread(); - Application.Exit(); - } + #region Events handler - #endregion + private void OnProxyLastWindowClosed(object sender, EventArgs e) + { + ExitThread(); + Application.Exit(); } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert/Classes/LogExpertProxy.cs b/src/LogExpert/Classes/LogExpertProxy.cs index 25f514f1..6823f7da 100644 --- a/src/LogExpert/Classes/LogExpertProxy.cs +++ b/src/LogExpert/Classes/LogExpertProxy.cs @@ -8,172 +8,171 @@ using System.Collections.Generic; using System.Windows.Forms; -namespace LogExpert.Classes +namespace LogExpert.Classes; + +internal class LogExpertProxy : ILogExpertProxy { - internal class LogExpertProxy : ILogExpertProxy - { - #region Fields + #region Fields - private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); - [NonSerialized] private readonly List _windowList = []; + [NonSerialized] private readonly List _windowList = []; - [NonSerialized] private ILogTabWindow _firstLogTabWindow; + [NonSerialized] private ILogTabWindow _firstLogTabWindow; - [NonSerialized] private int _logWindowIndex = 1; + [NonSerialized] private int _logWindowIndex = 1; - #endregion + #endregion - #region cTor + #region cTor - public LogExpertProxy(ILogTabWindow logTabWindow) - { - AddWindow(logTabWindow); - logTabWindow.LogExpertProxy = this; - _firstLogTabWindow = logTabWindow; - } + public LogExpertProxy(ILogTabWindow logTabWindow) + { + AddWindow(logTabWindow); + logTabWindow.LogExpertProxy = this; + _firstLogTabWindow = logTabWindow; + } - #endregion + #endregion - #region Delegates + #region Delegates - //public void BroadcastSettingsChanged(Object cookie) - //{ - // lock (this.windowList) - // { - // foreach (LogTabWindow logTabWindow in this.windowList) - // { - // logTabWindow.NotifySettingsChanged(cookie); - // } - // } - //} + //public void BroadcastSettingsChanged(Object cookie) + //{ + // lock (this.windowList) + // { + // foreach (LogTabWindow logTabWindow in this.windowList) + // { + // logTabWindow.NotifySettingsChanged(cookie); + // } + // } + //} - public delegate void LastWindowClosedEventHandler(object sender, EventArgs e); + public delegate void LastWindowClosedEventHandler(object sender, EventArgs e); - #endregion + #endregion - #region Events + #region Events - public event LastWindowClosedEventHandler LastWindowClosed; + public event LastWindowClosedEventHandler LastWindowClosed; - #endregion + #endregion - #region Public methods + #region Public methods - public void LoadFiles(string[] fileNames) - { - _logger.Info("Loading files into existing LogTabWindow"); - ILogTabWindow logWin = _windowList[^1]; - _ = logWin.Invoke(new MethodInvoker(logWin.SetForeground)); - logWin.LoadFiles(fileNames); - } + public void LoadFiles(string[] fileNames) + { + _logger.Info("Loading files into existing LogTabWindow"); + ILogTabWindow logWin = _windowList[^1]; + _ = logWin.Invoke(new MethodInvoker(logWin.SetForeground)); + logWin.LoadFiles(fileNames); + } - public void NewWindow(string[] fileNames) + public void NewWindow(string[] fileNames) + { + if (_firstLogTabWindow.IsDisposed) { - if (_firstLogTabWindow.IsDisposed) + _logger.Warn("first GUI thread window is disposed. Setting a new one."); + // may occur if a window is closed because of unhandled exception. + // Determine a new 'firstWindow'. If no window is left, start a new one. + RemoveWindow(_firstLogTabWindow); + if (_windowList.Count == 0) { - _logger.Warn("first GUI thread window is disposed. Setting a new one."); - // may occur if a window is closed because of unhandled exception. - // Determine a new 'firstWindow'. If no window is left, start a new one. - RemoveWindow(_firstLogTabWindow); - if (_windowList.Count == 0) - { - _logger.Info("No windows left. New created window will be the new 'first' GUI window"); - LoadFiles(fileNames); - } - else - { - _firstLogTabWindow = _windowList[^1]; - NewWindow(fileNames); - } + _logger.Info("No windows left. New created window will be the new 'first' GUI window"); + LoadFiles(fileNames); } else { - _ = _firstLogTabWindow.Invoke(new NewWindowFx(NewWindowWorker), new object[] { fileNames }); + _firstLogTabWindow = _windowList[^1]; + NewWindow(fileNames); } } + else + { + _ = _firstLogTabWindow.Invoke(new NewWindowFx(NewWindowWorker), [fileNames]); + } + } - public void NewWindowOrLockedWindow(string[] fileNames) + public void NewWindowOrLockedWindow(string[] fileNames) + { + foreach (var logWin in _windowList) { - foreach (var logWin in _windowList) + if (AbstractLogTabWindow.StaticData.CurrentLockedMainWindow == logWin) { - if (AbstractLogTabWindow.StaticData.CurrentLockedMainWindow == logWin) - { - _ = logWin.Invoke(new MethodInvoker(logWin.SetForeground)); - logWin.LoadFiles(fileNames); - return; - } + _ = logWin.Invoke(new MethodInvoker(logWin.SetForeground)); + logWin.LoadFiles(fileNames); + return; } - // No locked window was found --> create a new one - NewWindow(fileNames); } + // No locked window was found --> create a new one + NewWindow(fileNames); + } - public void NewWindowWorker(string[] fileNames) - { - _logger.Info("Creating new LogTabWindow"); - IConfigManager configManager = ConfigManager.Instance; - ILogTabWindow logWin = AbstractLogTabWindow.Create(fileNames.Length > 0 ? fileNames : null, _logWindowIndex++, true, configManager); - logWin.LogExpertProxy = this; - AddWindow(logWin); - logWin.Show(); - logWin.Activate(); - } + public void NewWindowWorker(string[] fileNames) + { + _logger.Info("Creating new LogTabWindow"); + IConfigManager configManager = ConfigManager.Instance; + ILogTabWindow logWin = AbstractLogTabWindow.Create(fileNames.Length > 0 ? fileNames : null, _logWindowIndex++, true, configManager); + logWin.LogExpertProxy = this; + AddWindow(logWin); + logWin.Show(); + logWin.Activate(); + } - public void WindowClosed(ILogTabWindow logWin) + public void WindowClosed(ILogTabWindow logWin) + { + RemoveWindow(logWin); + if (_windowList.Count == 0) { - RemoveWindow(logWin); - if (_windowList.Count == 0) - { - _logger.Info("Last LogTabWindow was closed"); - PluginRegistry.PluginRegistry.Instance.CleanupPlugins(); - OnLastWindowClosed(); - } - else + _logger.Info("Last LogTabWindow was closed"); + PluginRegistry.PluginRegistry.Instance.CleanupPlugins(); + OnLastWindowClosed(); + } + else + { + if (_firstLogTabWindow == logWin) { - if (_firstLogTabWindow == logWin) - { - // valid firstLogTabWindow is needed for the Invoke()-Calls in NewWindow() - _firstLogTabWindow = _windowList[^1]; - } + // valid firstLogTabWindow is needed for the Invoke()-Calls in NewWindow() + _firstLogTabWindow = _windowList[^1]; } } + } - public int GetLogWindowCount() - { - return _windowList.Count; - } + public int GetLogWindowCount() + { + return _windowList.Count; + } - //public override object InitializeLifetimeService() - //{ - // return null; - //} + //public override object InitializeLifetimeService() + //{ + // return null; + //} - #endregion + #endregion - #region Private Methods + #region Private Methods - private void AddWindow(ILogTabWindow window) - { - _logger.Info("Adding window to list"); - _windowList.Add(window); - } - - private void RemoveWindow(ILogTabWindow window) - { - _logger.Info("Removing window from list"); - _ = _windowList.Remove(window); - } + private void AddWindow(ILogTabWindow window) + { + _logger.Info("Adding window to list"); + _windowList.Add(window); + } - #endregion + private void RemoveWindow(ILogTabWindow window) + { + _logger.Info("Removing window from list"); + _ = _windowList.Remove(window); + } - protected void OnLastWindowClosed() - { - LastWindowClosed?.Invoke(this, new EventArgs()); - } + #endregion - private delegate void NewWindowFx(string[] fileNames); + protected void OnLastWindowClosed() + { + LastWindowClosed?.Invoke(this, new EventArgs()); } + + private delegate void NewWindowFx(string[] fileNames); } \ No newline at end of file diff --git a/src/LogExpert/Config/ConfigManager.cs b/src/LogExpert/Config/ConfigManager.cs index 175caef9..939860b4 100644 --- a/src/LogExpert/Config/ConfigManager.cs +++ b/src/LogExpert/Config/ConfigManager.cs @@ -1,3 +1,8 @@ +using System.Drawing; +using System.Reflection; +using System.Text; +using System.Windows.Forms; + using LogExpert.Core.Classes; using LogExpert.Core.Classes.Filter; using LogExpert.Core.Config; @@ -5,430 +10,421 @@ using LogExpert.Core.EventArguments; using LogExpert.Core.EventHandlers; using LogExpert.Core.Interface; + using Newtonsoft.Json; using NLog; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Windows.Forms; +namespace LogExpert.Config; -namespace LogExpert.Config +public class ConfigManager : IConfigManager { - public class ConfigManager : IConfigManager - { - #region Fields + #region Fields - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - private static readonly object _monitor = new(); - private static ConfigManager _instance; - private readonly object _loadSaveLock = new(); - private Settings _settings; + private static readonly object _monitor = new(); + private static ConfigManager _instance; + private readonly object _loadSaveLock = new(); + private Settings _settings; - #endregion + #endregion - #region cTor + #region cTor - private ConfigManager() - { - _settings = Load(); - } + private ConfigManager () + { + _settings = Load(); + } - #endregion + #endregion - #region Events + #region Events - public event ConfigChangedEventHandler ConfigChanged; + public event ConfigChangedEventHandler ConfigChanged; - #endregion + #endregion - #region Properties + #region Properties - public static ConfigManager Instance + public static ConfigManager Instance + { + get { - get + lock (_monitor) { - lock (_monitor) - { - _instance ??= new ConfigManager(); - } - return _instance; + _instance ??= new ConfigManager(); } + return _instance; } + } + + public string ConfigDir => Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + Path.DirectorySeparatorChar + "LogExpert"; //TODO: change to Path.Combine + + /// + /// Application.StartupPath + portable + /// + public string PortableModeDir => Application.StartupPath + Path.DirectorySeparatorChar + "portable"; + + /// + /// portableMode.json + /// + public string PortableModeSettingsFileName => "portableMode.json"; + + public Settings Settings => Instance._settings; - public string ConfigDir => Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + Path.DirectorySeparatorChar + "LogExpert"; //TODO: change to Path.Combine + IConfigManager IConfigManager.Instance => Instance; - /// - /// Application.StartupPath + portable - /// - public string PortableModeDir => Application.StartupPath + Path.DirectorySeparatorChar + "portable"; + // Action IConfigManager.ConfigChanged { get => ((IConfigManager)_instance).ConfigChanged; set => ((IConfigManager)_instance).ConfigChanged = value; } - /// - /// portableMode.json - /// - public string PortableModeSettingsFileName => "portableMode.json"; + //public string PortableModeSettingsFileName => ((IConfigManager)_instance).PortableModeSettingsFileName; - public Settings Settings => Instance._settings; + #endregion - IConfigManager IConfigManager.Instance => Instance; + #region Public methods -// Action IConfigManager.ConfigChanged { get => ((IConfigManager)_instance).ConfigChanged; set => ((IConfigManager)_instance).ConfigChanged = value; } + public void Save (SettingsFlags flags) + { + Instance.Save(Settings, flags); + } + + public void Export (FileInfo fileInfo) + { + Instance.Save(fileInfo, Settings); + } + + public void Export (FileInfo fileInfo, SettingsFlags flags) + { + Instance.Save(fileInfo, Settings, flags); + } - //public string PortableModeSettingsFileName => ((IConfigManager)_instance).PortableModeSettingsFileName; + public void Import (FileInfo fileInfo, ExportImportFlags flags) + { + Instance._settings = Instance.Import(Instance._settings, fileInfo, flags); + Save(SettingsFlags.All); + } - #endregion + public void ImportHighlightSettings (FileInfo fileInfo, ExportImportFlags flags) + { + Instance._settings.Preferences.HighlightGroupList = Instance.Import(Instance._settings.Preferences.HighlightGroupList, fileInfo, flags); + Save(SettingsFlags.All); + } - #region Public methods + #endregion - public void Save(SettingsFlags flags) + #region Private Methods + + private Settings Load () + { + _logger.Info("Loading settings"); + + string dir; + + if (File.Exists(PortableModeDir + Path.DirectorySeparatorChar + PortableModeSettingsFileName) == false) { - Instance.Save(Settings, flags); + _logger.Info("Load settings standard mode"); + dir = ConfigDir; } - - public void Export(FileInfo fileInfo) + else { - Instance.Save(fileInfo, Settings); + _logger.Info("Load settings portable mode"); + dir = Application.StartupPath; } - public void Export(FileInfo fileInfo, SettingsFlags flags) + if (!Directory.Exists(dir)) { - Instance.Save(fileInfo, Settings, flags); + Directory.CreateDirectory(dir); } - public void Import(FileInfo fileInfo, ExportImportFlags flags) + if (!File.Exists(dir + Path.DirectorySeparatorChar + "settings.json")) { - Instance._settings = Instance.Import(Instance._settings, fileInfo, flags); - Save(SettingsFlags.All); + return LoadOrCreateNew(null); } - public void ImportHighlightSettings(FileInfo fileInfo, ExportImportFlags flags) + try { - Instance._settings.Preferences.HighlightGroupList = Instance.Import(Instance._settings.Preferences.HighlightGroupList, fileInfo, flags); - Save(SettingsFlags.All); + FileInfo fileInfo = new(dir + Path.DirectorySeparatorChar + "settings.json"); + return LoadOrCreateNew(fileInfo); + } + catch (Exception e) + { + _logger.Error($"Error loading settings: {e}"); + return LoadOrCreateNew(null); } - #endregion - - #region Private Methods + } - private Settings Load() + /// + /// Loads Settings of a given file or creates new settings if the file does not exist + /// + /// file that has settings saved + /// loaded or created settings + private Settings LoadOrCreateNew (FileInfo fileInfo) + { + lock (_loadSaveLock) { - _logger.Info("Loading settings"); - - string dir; + Settings settings; - if (File.Exists(PortableModeDir + Path.DirectorySeparatorChar + PortableModeSettingsFileName) == false) + if (fileInfo == null || fileInfo.Exists == false) { - _logger.Info("Load settings standard mode"); - dir = ConfigDir; + settings = new Settings(); } else { - _logger.Info("Load settings portable mode"); - dir = Application.StartupPath; + try + { + settings = JsonConvert.DeserializeObject(File.ReadAllText($"{fileInfo.FullName}")); + } + catch (Exception e) + { + _logger.Error($"Error while deserializing config data: {e}"); + settings = new Settings(); + } } - if (!Directory.Exists(dir)) - { - Directory.CreateDirectory(dir); - } + settings.Preferences ??= new Preferences(); + + settings.Preferences.toolEntries ??= []; + + settings.Preferences.columnizerMaskList ??= []; + + settings.fileHistoryList ??= []; + + settings.lastOpenFilesList ??= []; + + settings.fileColors ??= []; - if (!File.Exists(dir + Path.DirectorySeparatorChar + "settings.json")) + if (settings.Preferences.showTailColor == Color.Empty) { - return LoadOrCreateNew(null); + settings.Preferences.showTailColor = Color.FromKnownColor(KnownColor.Blue); } - try + if (settings.Preferences.timeSpreadColor == Color.Empty) { - FileInfo fileInfo = new(dir + Path.DirectorySeparatorChar + "settings.json"); - return LoadOrCreateNew(fileInfo); + settings.Preferences.timeSpreadColor = Color.Gray; } - catch (Exception e) + + if (settings.Preferences.bufferCount < 10) { - _logger.Error($"Error loading settings: {e}"); - return LoadOrCreateNew(null); + settings.Preferences.bufferCount = 100; } - } - - /// - /// Loads Settings of a given file or creates new settings if the file does not exist - /// - /// file that has settings saved - /// loaded or created settings - private Settings LoadOrCreateNew(FileInfo fileInfo) - { - lock (_loadSaveLock) + if (settings.Preferences.linesPerBuffer < 1) { - Settings settings; + settings.Preferences.linesPerBuffer = 500; + } - if (fileInfo == null || fileInfo.Exists == false) - { - settings = new Settings(); - } - else - { - try - { - settings = JsonConvert.DeserializeObject(File.ReadAllText($"{fileInfo.FullName}")); - } - catch (Exception e) - { - _logger.Error($"Error while deserializing config data: {e}"); - settings = new Settings(); - } - } + settings.filterList ??= []; - settings.Preferences ??= new Preferences(); + settings.searchHistoryList ??= []; - settings.Preferences.toolEntries ??= []; + settings.filterHistoryList ??= []; - settings.Preferences.columnizerMaskList ??= []; + settings.filterRangeHistoryList ??= []; - settings.fileHistoryList ??= []; + foreach (FilterParams filterParams in settings.filterList) + { + filterParams.Init(); + } - settings.lastOpenFilesList ??= []; + if (settings.Preferences.HighlightGroupList == null) + { + settings.Preferences.HighlightGroupList = []; + } - settings.fileColors ??= []; + settings.Preferences.highlightMaskList ??= []; - if (settings.Preferences.showTailColor == Color.Empty) - { - settings.Preferences.showTailColor = Color.FromKnownColor(KnownColor.Blue); - } + if (settings.Preferences.pollingInterval < 20) + { + settings.Preferences.pollingInterval = 250; + } - if (settings.Preferences.timeSpreadColor == Color.Empty) - { - settings.Preferences.timeSpreadColor = Color.Gray; - } + settings.Preferences.multiFileOptions ??= new MultiFileOptions(); - if (settings.Preferences.bufferCount < 10) - { - settings.Preferences.bufferCount = 100; - } + settings.Preferences.defaultEncoding ??= Encoding.Default.HeaderName; - if (settings.Preferences.linesPerBuffer < 1) - { - settings.Preferences.linesPerBuffer = 500; - } + if (settings.Preferences.maximumFilterEntriesDisplayed == 0) + { + settings.Preferences.maximumFilterEntriesDisplayed = 20; + } - settings.filterList ??= []; + if (settings.Preferences.maximumFilterEntries == 0) + { + settings.Preferences.maximumFilterEntries = 30; + } - settings.searchHistoryList ??= []; + SetBoundsWithinVirtualScreen(settings); - settings.filterHistoryList ??= []; + return settings; + } + } - settings.filterRangeHistoryList ??= []; + /// + /// Saves the Settings to file, fires OnConfigChanged Event so LogTabWindow is updated + /// + /// Settings to be saved + /// Settings that "changed" + private void Save (Settings settings, SettingsFlags flags) + { + lock (_loadSaveLock) + { + _logger.Info("Saving settings"); + lock (this) + { + var dir = Settings.Preferences.PortableMode ? Application.StartupPath : ConfigDir; - foreach (FilterParams filterParams in settings.filterList) + if (!Directory.Exists(dir)) { - filterParams.Init(); + Directory.CreateDirectory(dir); } - if (settings.Preferences.HighlightGroupList == null) - { - settings.Preferences.HighlightGroupList = []; - } + FileInfo fileInfo = new(dir + Path.DirectorySeparatorChar + "settings.json"); + Save(fileInfo, settings); + } - settings.Preferences.highlightMaskList ??= []; + OnConfigChanged(flags); + } + } - if (settings.Preferences.pollingInterval < 20) - { - settings.Preferences.pollingInterval = 250; - } + /// + /// Saves the file in any defined format + /// + /// FileInfo for creating the file (if exists will be overwritten) + /// Current Settings + private void Save (FileInfo fileInfo, Settings settings) + { + //Currently only fileFormat, maybe add some other formats later (YAML or XML?) + SaveAsJSON(fileInfo, settings); + } - settings.Preferences.multiFileOptions ??= new MultiFileOptions(); + private void Save (FileInfo fileInfo, Settings settings, SettingsFlags flags) + { + switch (flags) + { + case SettingsFlags.HighlightSettings: + SaveHighlightgroupsAsJSON(fileInfo, settings.Preferences.HighlightGroupList); + break; + } - settings.Preferences.defaultEncoding ??= Encoding.Default.HeaderName; + OnConfigChanged(flags); + } - if (settings.Preferences.maximumFilterEntriesDisplayed == 0) - { - settings.Preferences.maximumFilterEntriesDisplayed = 20; - } + private static void SaveAsJSON (FileInfo fileInfo, Settings settings) + { + settings.versionBuild = Assembly.GetExecutingAssembly().GetName().Version.Build; - if (settings.Preferences.maximumFilterEntries == 0) - { - settings.Preferences.maximumFilterEntries = 30; - } + using StreamWriter sw = new(fileInfo.Create()); + JsonSerializer serializer = new(); + serializer.Serialize(sw, settings); + } + + private static void SaveHighlightgroupsAsJSON (FileInfo fileInfo, List groups) + { + using StreamWriter sw = new(fileInfo.Create()); + JsonSerializer serializer = new(); + serializer.Serialize(sw, groups); + } - SetBoundsWithinVirtualScreen(settings); + private List Import (List currentGroups, FileInfo fileInfo, ExportImportFlags flags) + { + List newGroups; - return settings; - } + try + { + newGroups = JsonConvert.DeserializeObject>(File.ReadAllText($"{fileInfo.FullName}")); } - - /// - /// Saves the Settings to file, fires OnConfigChanged Event so LogTabWindow is updated - /// - /// Settings to be saved - /// Settings that "changed" - private void Save(Settings settings, SettingsFlags flags) + catch (Exception e) { - lock (_loadSaveLock) - { - _logger.Info("Saving settings"); - lock (this) - { - var dir = Settings.Preferences.PortableMode ? Application.StartupPath : ConfigDir; - - if (!Directory.Exists(dir)) - { - Directory.CreateDirectory(dir); - } - - FileInfo fileInfo = new(dir + Path.DirectorySeparatorChar + "settings.json"); - Save(fileInfo, settings); - } - - OnConfigChanged(flags); - } + _logger.Error($"Error while deserializing config data: {e}"); + newGroups = []; } - /// - /// Saves the file in any defined format - /// - /// FileInfo for creating the file (if exists will be overwritten) - /// Current Settings - private void Save(FileInfo fileInfo, Settings settings) + if (flags.HasFlag(ExportImportFlags.KeepExisting)) { - //Currently only fileFormat, maybe add some other formats later (YAML or XML?) - SaveAsJSON(fileInfo, settings); + currentGroups.AddRange(newGroups); } - - private void Save(FileInfo fileInfo, Settings settings, SettingsFlags flags) + else { - switch (flags) - { - case SettingsFlags.HighlightSettings: - SaveHighlightgroupsAsJSON(fileInfo, settings.Preferences.HighlightGroupList); - break; - } - - OnConfigChanged(flags); + currentGroups.Clear(); + currentGroups.AddRange(newGroups); } - private static void SaveAsJSON(FileInfo fileInfo, Settings settings) - { - settings.versionBuild = Assembly.GetExecutingAssembly().GetName().Version.Build; + return currentGroups; + } - using StreamWriter sw = new(fileInfo.Create()); - JsonSerializer serializer = new(); - serializer.Serialize(sw, settings); - } + /// + /// Imports all or some of the settings/prefs stored in the input stream. + /// This will overwrite appropriate parts of the current (own) settings with the imported ones. + /// + /// + /// + /// Flags to indicate which parts shall be imported + private Settings Import (Settings currentSettings, FileInfo fileInfo, ExportImportFlags flags) + { + Settings importSettings = LoadOrCreateNew(fileInfo); + Settings ownSettings = ObjectClone.Clone(currentSettings); + Settings newSettings; - private static void SaveHighlightgroupsAsJSON(FileInfo fileInfo, List groups) + // at first check for 'Other' as this are the most options. + if ((flags & ExportImportFlags.Other) == ExportImportFlags.Other) { - using StreamWriter sw = new(fileInfo.Create()); - JsonSerializer serializer = new(); - serializer.Serialize(sw, groups); + newSettings = ownSettings; + newSettings.Preferences = ObjectClone.Clone(importSettings.Preferences); + newSettings.Preferences.columnizerMaskList = ownSettings.Preferences.columnizerMaskList; + newSettings.Preferences.highlightMaskList = ownSettings.Preferences.highlightMaskList; + newSettings.Preferences.HighlightGroupList = ownSettings.Preferences.HighlightGroupList; + newSettings.Preferences.toolEntries = ownSettings.Preferences.toolEntries; } - - private List Import(List currentGroups, FileInfo fileInfo, ExportImportFlags flags) + else { - List newGroups; - - try - { - newGroups = JsonConvert.DeserializeObject>(File.ReadAllText($"{fileInfo.FullName}")); - } - catch (Exception e) - { - _logger.Error($"Error while deserializing config data: {e}"); - newGroups = []; - } - - if (flags.HasFlag(ExportImportFlags.KeepExisting)) - { - currentGroups.AddRange(newGroups); - } - else - { - currentGroups.Clear(); - currentGroups.AddRange(newGroups); - } - - return currentGroups; + newSettings = ownSettings; } - /// - /// Imports all or some of the settings/prefs stored in the input stream. - /// This will overwrite appropriate parts of the current (own) settings with the imported ones. - /// - /// - /// - /// Flags to indicate which parts shall be imported - private Settings Import(Settings currentSettings, FileInfo fileInfo, ExportImportFlags flags) + if ((flags & ExportImportFlags.ColumnizerMasks) == ExportImportFlags.ColumnizerMasks) { - Settings importSettings = LoadOrCreateNew(fileInfo); - Settings ownSettings = ObjectClone.Clone(currentSettings); - Settings newSettings; - - // at first check for 'Other' as this are the most options. - if ((flags & ExportImportFlags.Other) == ExportImportFlags.Other) - { - newSettings = ownSettings; - newSettings.Preferences = ObjectClone.Clone(importSettings.Preferences); - newSettings.Preferences.columnizerMaskList = ownSettings.Preferences.columnizerMaskList; - newSettings.Preferences.highlightMaskList = ownSettings.Preferences.highlightMaskList; - newSettings.Preferences.HighlightGroupList = ownSettings.Preferences.HighlightGroupList; - newSettings.Preferences.toolEntries = ownSettings.Preferences.toolEntries; - } - else - { - newSettings = ownSettings; - } - - if ((flags & ExportImportFlags.ColumnizerMasks) == ExportImportFlags.ColumnizerMasks) - { - newSettings.Preferences.columnizerMaskList = ReplaceOrKeepExisting(flags, ownSettings.Preferences.columnizerMaskList, importSettings.Preferences.columnizerMaskList); - } - if ((flags & ExportImportFlags.HighlightMasks) == ExportImportFlags.HighlightMasks) - { - newSettings.Preferences.highlightMaskList = ReplaceOrKeepExisting(flags, ownSettings.Preferences.highlightMaskList, importSettings.Preferences.highlightMaskList); - } - if ((flags & ExportImportFlags.HighlightSettings) == ExportImportFlags.HighlightSettings) - { - newSettings.Preferences.HighlightGroupList = ReplaceOrKeepExisting(flags, ownSettings.Preferences.HighlightGroupList, importSettings.Preferences.HighlightGroupList); - } - if ((flags & ExportImportFlags.ToolEntries) == ExportImportFlags.ToolEntries) - { - newSettings.Preferences.toolEntries = ReplaceOrKeepExisting(flags, ownSettings.Preferences.toolEntries, importSettings.Preferences.toolEntries); - } - - return newSettings; + newSettings.Preferences.columnizerMaskList = ReplaceOrKeepExisting(flags, ownSettings.Preferences.columnizerMaskList, importSettings.Preferences.columnizerMaskList); } - - private static List ReplaceOrKeepExisting(ExportImportFlags flags, List existingList, List newList) + if ((flags & ExportImportFlags.HighlightMasks) == ExportImportFlags.HighlightMasks) { - if ((flags & ExportImportFlags.KeepExisting) == ExportImportFlags.KeepExisting) - { - return existingList.Union(newList).ToList(); - } - - return newList; + newSettings.Preferences.highlightMaskList = ReplaceOrKeepExisting(flags, ownSettings.Preferences.highlightMaskList, importSettings.Preferences.highlightMaskList); + } + if ((flags & ExportImportFlags.HighlightSettings) == ExportImportFlags.HighlightSettings) + { + newSettings.Preferences.HighlightGroupList = ReplaceOrKeepExisting(flags, ownSettings.Preferences.HighlightGroupList, importSettings.Preferences.HighlightGroupList); + } + if ((flags & ExportImportFlags.ToolEntries) == ExportImportFlags.ToolEntries) + { + newSettings.Preferences.toolEntries = ReplaceOrKeepExisting(flags, ownSettings.Preferences.toolEntries, importSettings.Preferences.toolEntries); } - // Checking if the appBounds values are outside the current virtual screen. - // If so, the appBounds values are set to 0. - private void SetBoundsWithinVirtualScreen(Settings settings) + return newSettings; + } + + private static List ReplaceOrKeepExisting (ExportImportFlags flags, List existingList, List newList) + { + if ((flags & ExportImportFlags.KeepExisting) == ExportImportFlags.KeepExisting) { - var vs = SystemInformation.VirtualScreen; - if (vs.X + vs.Width < settings.appBounds.X + settings.appBounds.Width || - vs.Y + vs.Height < settings.appBounds.Y + settings.appBounds.Height) - { - settings.appBounds = new Rectangle(); - } + return existingList.Union(newList).ToList(); } - #endregion - protected void OnConfigChanged(SettingsFlags flags) + return newList; + } + + // Checking if the appBounds values are outside the current virtual screen. + // If so, the appBounds values are set to 0. + private void SetBoundsWithinVirtualScreen (Settings settings) + { + var vs = SystemInformation.VirtualScreen; + if (vs.X + vs.Width < settings.appBounds.X + settings.appBounds.Width || + vs.Y + vs.Height < settings.appBounds.Y + settings.appBounds.Height) { - ConfigChanged?.Invoke(this, new ConfigChangedEventArgs(flags)); + settings.appBounds = new Rectangle(); } } + #endregion + + protected void OnConfigChanged (SettingsFlags flags) + { + ConfigChanged?.Invoke(this, new ConfigChangedEventArgs(flags)); + } } \ No newline at end of file diff --git a/src/LogExpert/Program.cs b/src/LogExpert/Program.cs index a46932b4..17226642 100644 --- a/src/LogExpert/Program.cs +++ b/src/LogExpert/Program.cs @@ -21,344 +21,343 @@ using System.Text; using System.Windows.Forms; -namespace LogExpert +namespace LogExpert; + +internal static class Program { - internal static class Program - { - #region Fields + #region Fields - private static readonly Logger _logger = LogManager.GetLogger("Program"); - private const string PIPE_SERVER_NAME = "LogExpert_IPC"; - private const int PIPE_CONNECTION_TIMEOUT_IN_MS = 5000; + private static readonly Logger _logger = LogManager.GetLogger("Program"); + private const string PIPE_SERVER_NAME = "LogExpert_IPC"; + private const int PIPE_CONNECTION_TIMEOUT_IN_MS = 5000; - #endregion + #endregion - #region Private Methods + #region Private Methods - /// - /// The main entry point for the application. - /// - [STAThread] - private static void Main(string[] args) - { - AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; - Application.ThreadException += Application_ThreadException; + /// + /// The main entry point for the application. + /// + [STAThread] + private static void Main(string[] args) + { + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; + Application.ThreadException += Application_ThreadException; - ApplicationConfiguration.Initialize(); + ApplicationConfiguration.Initialize(); - Application.EnableVisualStyles(); - Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); + Application.EnableVisualStyles(); + Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); - _logger.Info("\r\n============================================================================\r\nLogExpert {0} started.\r\n============================================================================", Assembly.GetExecutingAssembly().GetName().Version.ToString(3)); + _logger.Info("\r\n============================================================================\r\nLogExpert {0} started.\r\n============================================================================", Assembly.GetExecutingAssembly().GetName().Version.ToString(3)); - CancellationTokenSource cts = new(); - try + CancellationTokenSource cts = new(); + try + { + CmdLineString configFile = new("config", false, "A configuration (settings) file"); + CmdLine cmdLine = new(); + cmdLine.RegisterParameter(configFile); + if (configFile.Exists) { - CmdLineString configFile = new("config", false, "A configuration (settings) file"); - CmdLine cmdLine = new(); - cmdLine.RegisterParameter(configFile); - if (configFile.Exists) + FileInfo cfgFileInfo = new(configFile.Value); + //TODO: The config file import and the try catch for the primary instance and secondary instance should be separated functions + if (cfgFileInfo.Exists) { - FileInfo cfgFileInfo = new(configFile.Value); - //TODO: The config file import and the try catch for the primary instance and secondary instance should be separated functions - if (cfgFileInfo.Exists) - { - ConfigManager.Instance.Import(cfgFileInfo, ExportImportFlags.All); - } - else - { - MessageBox.Show(@"Config file not found", @"LogExpert"); - } + ConfigManager.Instance.Import(cfgFileInfo, ExportImportFlags.All); + } + else + { + MessageBox.Show(@"Config file not found", @"LogExpert"); } - PluginRegistry.PluginRegistry.Instance.Create(ConfigManager.Instance.ConfigDir, ConfigManager.Instance.Settings.Preferences.pollingInterval); + } + PluginRegistry.PluginRegistry.Instance.Create(ConfigManager.Instance.ConfigDir, ConfigManager.Instance.Settings.Preferences.pollingInterval); + + var pId = Process.GetCurrentProcess().SessionId; - var pId = Process.GetCurrentProcess().SessionId; + try + { + Mutex mutex = new(false, "Local\\LogExpertInstanceMutex" + pId, out var isCreated); + var remainingArgs = cmdLine.Parse(args); + var absoluteFilePaths = GenerateAbsoluteFilePaths(remainingArgs); - try + if (isCreated) { - Mutex mutex = new(false, "Local\\LogExpertInstanceMutex" + pId, out var isCreated); - var remainingArgs = cmdLine.Parse(args); - var absoluteFilePaths = GenerateAbsoluteFilePaths(remainingArgs); + // first application instance + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + ILogTabWindow logWin = AbstractLogTabWindow.Create(absoluteFilePaths.Length > 0 ? absoluteFilePaths : null, 1, false, ConfigManager.Instance); - if (isCreated) - { - // first application instance - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - ILogTabWindow logWin = AbstractLogTabWindow.Create(absoluteFilePaths.Length > 0 ? absoluteFilePaths : null, 1, false, ConfigManager.Instance); + // first instance + var wi = WindowsIdentity.GetCurrent(); + LogExpertProxy proxy = new(logWin); + LogExpertApplicationContext context = new(proxy, logWin); - // first instance - var wi = WindowsIdentity.GetCurrent(); - LogExpertProxy proxy = new(logWin); - LogExpertApplicationContext context = new(proxy, logWin); + Task.Run(() => RunServerLoopAsync(SendMessageToProxy, proxy, cts.Token)); - Task.Run(() => RunServerLoopAsync(SendMessageToProxy, proxy, cts.Token)); + Application.Run(context); + } + else + { + var counter = 3; + Exception errMsg = null; - Application.Run(context); - } - else + Settings settings = ConfigManager.Instance.Settings; + while (counter > 0) { - var counter = 3; - Exception errMsg = null; - - Settings settings = ConfigManager.Instance.Settings; - while (counter > 0) + try { - try - { - var wi = WindowsIdentity.GetCurrent(); - var command = SerializeCommandIntoNonFormattedJSON(absoluteFilePaths, settings.Preferences.allowOnlyOneInstance); - SendCommandToServer(command); - break; - } - catch (Exception e) - { - _logger.Warn(e, "IpcClientChannel error: "); - errMsg = e; - counter--; - Thread.Sleep(500); - } + var wi = WindowsIdentity.GetCurrent(); + var command = SerializeCommandIntoNonFormattedJSON(absoluteFilePaths, settings.Preferences.allowOnlyOneInstance); + SendCommandToServer(command); + break; } - - if (counter == 0) + catch (Exception e) { - _logger.Error(errMsg, "IpcClientChannel error, giving up: "); - MessageBox.Show($"Cannot open connection to first instance ({errMsg})", "LogExpert"); + _logger.Warn(e, "IpcClientChannel error: "); + errMsg = e; + counter--; + Thread.Sleep(500); } + } + + if (counter == 0) + { + _logger.Error(errMsg, "IpcClientChannel error, giving up: "); + MessageBox.Show($"Cannot open connection to first instance ({errMsg})", "LogExpert"); + } - if (settings.Preferences.allowOnlyOneInstance && settings.Preferences.ShowErrorMessageAllowOnlyOneInstances) + if (settings.Preferences.allowOnlyOneInstance && settings.Preferences.ShowErrorMessageAllowOnlyOneInstances) + { + AllowOnlyOneInstanceErrorDialog a = new(); + if (a.ShowDialog() == DialogResult.OK) { - AllowOnlyOneInstanceErrorDialog a = new(); - if (a.ShowDialog() == DialogResult.OK) - { - settings.Preferences.ShowErrorMessageAllowOnlyOneInstances = !a.DoNotShowThisMessageAgain; - ConfigManager.Instance.Save(SettingsFlags.All); - } + settings.Preferences.ShowErrorMessageAllowOnlyOneInstances = !a.DoNotShowThisMessageAgain; + ConfigManager.Instance.Save(SettingsFlags.All); } } - - mutex.Close(); - cts.Cancel(); - } - catch (Exception ex) - { - _logger.Error(ex, "Mutex error, giving up: "); - cts.Cancel(); - MessageBox.Show($"Cannot open connection to first instance ({ex.Message})", "LogExpert"); } + + mutex.Close(); + cts.Cancel(); } - catch (SecurityException se) + catch (Exception ex) { - MessageBox.Show("Insufficient system rights for LogExpert. Maybe you have started it from a network drive. Please start LogExpert from a local drive.\n(" + se.Message + ")", "LogExpert Error"); + _logger.Error(ex, "Mutex error, giving up: "); cts.Cancel(); + MessageBox.Show($"Cannot open connection to first instance ({ex.Message})", "LogExpert"); } } - - private static string SerializeCommandIntoNonFormattedJSON(string[] fileNames, bool allowOnlyOneInstance) + catch (SecurityException se) { - var message = new IpcMessage() - { - Type = allowOnlyOneInstance ? IpcMessageType.NewWindowOrLockedWindow : IpcMessageType.NewWindow, - Payload = JObject.FromObject(new LoadPayload { Files = [.. fileNames] }) - }; - - return JsonConvert.SerializeObject(message, Formatting.None); + MessageBox.Show("Insufficient system rights for LogExpert. Maybe you have started it from a network drive. Please start LogExpert from a local drive.\n(" + se.Message + ")", "LogExpert Error"); + cts.Cancel(); } + } - // This loop tries to convert relative file names into absolute file names (assuming that platform file names are given). - // It tolerates errors, to give file system plugins (e.g. sftp) a change later. - // TODO: possibly should be moved to LocalFileSystem plugin - private static string[] GenerateAbsoluteFilePaths(string[] remainingArgs) + private static string SerializeCommandIntoNonFormattedJSON(string[] fileNames, bool allowOnlyOneInstance) + { + var message = new IpcMessage() { - List argsList = []; + Type = allowOnlyOneInstance ? IpcMessageType.NewWindowOrLockedWindow : IpcMessageType.NewWindow, + Payload = JObject.FromObject(new LoadPayload { Files = [.. fileNames] }) + }; + + return JsonConvert.SerializeObject(message, Formatting.None); + } + + // This loop tries to convert relative file names into absolute file names (assuming that platform file names are given). + // It tolerates errors, to give file system plugins (e.g. sftp) a change later. + // TODO: possibly should be moved to LocalFileSystem plugin + private static string[] GenerateAbsoluteFilePaths(string[] remainingArgs) + { + List argsList = []; - foreach (var fileArg in remainingArgs) + foreach (var fileArg in remainingArgs) + { + try { - try - { - FileInfo info = new(fileArg); - argsList.Add(info.Exists ? info.FullName : fileArg); - } - catch (Exception) - { - argsList.Add(fileArg); - } + FileInfo info = new(fileArg); + argsList.Add(info.Exists ? info.FullName : fileArg); + } + catch (Exception) + { + argsList.Add(fileArg); } - - return [.. argsList]; } - private static void SendMessageToProxy(IpcMessage message, LogExpertProxy proxy) + return [.. argsList]; + } + + private static void SendMessageToProxy(IpcMessage message, LogExpertProxy proxy) + { + switch (message.Type) { - switch (message.Type) - { - case IpcMessageType.Load: - { - var payLoad = message.Payload.ToObject(); + case IpcMessageType.Load: + { + var payLoad = message.Payload.ToObject(); - if (CheckPayload(payLoad)) - { - proxy.LoadFiles([.. payLoad.Files]); - } + if (CheckPayload(payLoad)) + { + proxy.LoadFiles([.. payLoad.Files]); } - break; - case IpcMessageType.NewWindow: + } + break; + case IpcMessageType.NewWindow: + { + var payLoad = message.Payload.ToObject(); + if (CheckPayload(payLoad)) { - var payLoad = message.Payload.ToObject(); - if (CheckPayload(payLoad)) - { - proxy.NewWindow([.. payLoad.Files]); - } + proxy.NewWindow([.. payLoad.Files]); } - break; - case IpcMessageType.NewWindowOrLockedWindow: + } + break; + case IpcMessageType.NewWindowOrLockedWindow: + { + var payLoad = message.Payload.ToObject(); + if (CheckPayload(payLoad)) { - var payLoad = message.Payload.ToObject(); - if (CheckPayload(payLoad)) - { - proxy.NewWindowOrLockedWindow([.. payLoad.Files]); - } + proxy.NewWindowOrLockedWindow([.. payLoad.Files]); } - break; - default: - _logger.Error($"Unknown IPC Message Type {message.Type}"); - break; - } + } + break; + default: + _logger.Error($"Unknown IPC Message Type {message.Type}"); + break; } + } - private static bool CheckPayload(LoadPayload payLoad) + private static bool CheckPayload(LoadPayload payLoad) + { + if (payLoad == null) { - if (payLoad == null) - { - _logger.Error("Invalid payload for NewWindow command"); - return false; - } + _logger.Error("Invalid payload for NewWindow command"); + return false; + } + + return true; + } - return true; + private static void SendCommandToServer(string command) + { + using var client = new NamedPipeClientStream(".", PIPE_SERVER_NAME, PipeDirection.Out); + + try + { + client.Connect(PIPE_CONNECTION_TIMEOUT_IN_MS); + } + catch (TimeoutException) + { + _logger.Error("Timeout connecting to pipe server"); + return; + } + catch (IOException ex) + { + _logger.Warn(ex, "An I/O error occurred while connecting to the pipe server."); + return; + } + catch (UnauthorizedAccessException ex) + { + _logger.Warn(ex, "Unauthorized access while connecting to the pipe server."); + return; } - private static void SendCommandToServer(string command) + using var writer = new StreamWriter(client, Encoding.UTF8) { AutoFlush = true }; + writer.WriteLine(command); + } + + private static async Task RunServerLoopAsync(Action onCommand, LogExpertProxy proxy, CancellationToken cancellationToken) + { + while (cancellationToken.IsCancellationRequested == false) { - using var client = new NamedPipeClientStream(".", PIPE_SERVER_NAME, PipeDirection.Out); + using var server = new NamedPipeServerStream( + PIPE_SERVER_NAME, + PipeDirection.In, + 1, + PipeTransmissionMode.Message, + PipeOptions.Asynchronous); try { - client.Connect(PIPE_CONNECTION_TIMEOUT_IN_MS); - } - catch (TimeoutException) - { - _logger.Error("Timeout connecting to pipe server"); - return; + await server.WaitForConnectionAsync(cancellationToken); + using var reader = new StreamReader(server, Encoding.UTF8); + var line = await reader.ReadLineAsync(cancellationToken); + + if (line != null) + { + var message = JsonConvert.DeserializeObject(line); + onCommand(message, proxy); + } } - catch (IOException ex) + catch (OperationCanceledException) { - _logger.Warn(ex, "An I/O error occurred while connecting to the pipe server."); - return; + break; } - catch (UnauthorizedAccessException ex) + catch (Exception ex) { - _logger.Warn(ex, "Unauthorized access while connecting to the pipe server."); - return; + _logger.Warn(ex, "Pipe server error"); } - - using var writer = new StreamWriter(client, Encoding.UTF8) { AutoFlush = true }; - writer.WriteLine(command); } + } - private static async Task RunServerLoopAsync(Action onCommand, LogExpertProxy proxy, CancellationToken cancellationToken) - { - while (cancellationToken.IsCancellationRequested == false) - { - using var server = new NamedPipeServerStream( - PIPE_SERVER_NAME, - PipeDirection.In, - 1, - PipeTransmissionMode.Message, - PipeOptions.Asynchronous); - - try - { - await server.WaitForConnectionAsync(cancellationToken); - using var reader = new StreamReader(server, Encoding.UTF8); - var line = await reader.ReadLineAsync(cancellationToken); + [STAThread] + private static void ShowUnhandledException(object exceptionObject) + { + var errorText = string.Empty; + string stackTrace; - if (line != null) - { - var message = JsonConvert.DeserializeObject(line); - onCommand(message, proxy); - } - } - catch (OperationCanceledException) - { - break; - } - catch (Exception ex) - { - _logger.Warn(ex, "Pipe server error"); - } - } + if (exceptionObject is Exception exception) + { + errorText = exception.Message; + stackTrace = $"\r\n{exception.GetType().Name}\r\n{exception.StackTrace}"; } - - [STAThread] - private static void ShowUnhandledException(object exceptionObject) + else { - var errorText = string.Empty; - string stackTrace; + stackTrace = exceptionObject.ToString(); + var lines = stackTrace.Split('\n'); - if (exceptionObject is Exception exception) - { - errorText = exception.Message; - stackTrace = $"\r\n{exception.GetType().Name}\r\n{exception.StackTrace}"; - } - else + if (lines != null && lines.Length > 0) { - stackTrace = exceptionObject.ToString(); - var lines = stackTrace.Split('\n'); - - if (lines != null && lines.Length > 0) - { - errorText = lines[0]; - } + errorText = lines[0]; } - - ExceptionWindow win = new(errorText, stackTrace); - _ = win.ShowDialog(); } - #endregion - - #region Events handler + ExceptionWindow win = new(errorText, stackTrace); + _ = win.ShowDialog(); + } - private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) - { - _logger.Fatal(e); + #endregion - Thread thread = new(ShowUnhandledException) - { - IsBackground = true - }; + #region Events handler - thread.SetApartmentState(ApartmentState.STA); - thread.Start(e.Exception); - thread.Join(); - } + private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) + { + _logger.Fatal(e); - private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + Thread thread = new(ShowUnhandledException) { - _logger.Fatal(e); + IsBackground = true + }; - var exceptionObject = e.ExceptionObject; + thread.SetApartmentState(ApartmentState.STA); + thread.Start(e.Exception); + thread.Join(); + } - Thread thread = new(ShowUnhandledException) - { - IsBackground = true - }; + private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + _logger.Fatal(e); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(exceptionObject); - thread.Join(); - } + var exceptionObject = e.ExceptionObject; + + Thread thread = new(ShowUnhandledException) + { + IsBackground = true + }; - #endregion + thread.SetApartmentState(ApartmentState.STA); + thread.Start(exceptionObject); + thread.Join(); } + + #endregion } diff --git a/src/Logexpert.Core/Classes/Persister/PersistenceData.cs b/src/Logexpert.Core/Classes/Persister/PersistenceData.cs new file mode 100644 index 00000000..bd358a72 --- /dev/null +++ b/src/Logexpert.Core/Classes/Persister/PersistenceData.cs @@ -0,0 +1,42 @@ +using System.Text; + +using LogExpert.Core.Classes.Filter; +using LogExpert.Core.Entities; + +namespace LogExpert.Core.Classes.Persister; + +public class PersistenceData +{ + #region Fields + + public SortedList bookmarkList = []; + public int bookmarkListPosition = 300; + public bool bookmarkListVisible; + public string columnizerName; + public int currentLine = -1; + public Encoding encoding; + public string fileName; + public bool filterAdvanced; + public List filterParamsList = []; + public int filterPosition = 222; + public bool filterSaveListVisible; + public List filterTabDataList = []; + public bool filterVisible; + public int firstDisplayedLine = -1; + public bool followTail = true; + public string highlightGroupName; + public int lineCount; + + public bool multiFile; + public int multiFileMaxDays; + public List multiFileNames = []; + public string multiFilePattern; + public SortedList rowHeightList = []; + public string sessionFileName; + public bool showBookmarkCommentColumn; + public string tabName; + + public string settingsSaveLoadLocation; + + #endregion +} diff --git a/src/PluginRegistry/FileSystem/LocalFileSystem.cs b/src/PluginRegistry/FileSystem/LocalFileSystem.cs index aafb3eaf..289b1ed3 100644 --- a/src/PluginRegistry/FileSystem/LocalFileSystem.cs +++ b/src/PluginRegistry/FileSystem/LocalFileSystem.cs @@ -1,40 +1,39 @@ -namespace LogExpert.PluginRegistry.FileSystem +namespace LogExpert.PluginRegistry.FileSystem; + +public class LocalFileSystem : IFileSystemPlugin { - public class LocalFileSystem : IFileSystemPlugin - { - #region IFileSystemPlugin Member + #region IFileSystemPlugin Member - public bool CanHandleUri(string uriString) + public bool CanHandleUri(string uriString) + { + try { - try - { - Uri uri = new(uriString); - return uri.IsFile; - } - catch (Exception) - { - return false; - } + Uri uri = new(uriString); + return uri.IsFile; } + catch (Exception) + { + return false; + } + } - public ILogFileInfo GetLogfileInfo(string uriString) + public ILogFileInfo GetLogfileInfo(string uriString) + { + Uri uri = new(uriString); + if (uri.IsFile) { - Uri uri = new(uriString); - if (uri.IsFile) - { - ILogFileInfo logFileInfo = new LogFileInfo(uri); - return logFileInfo; - } - else - { - throw new UriFormatException("Uri " + uriString + " is no file Uri"); - } + ILogFileInfo logFileInfo = new LogFileInfo(uri); + return logFileInfo; + } + else + { + throw new UriFormatException("Uri " + uriString + " is no file Uri"); } + } - public string Text => "Local file system"; + public string Text => "Local file system"; - public string Description => "Access files from normal file system."; + public string Description => "Access files from normal file system."; - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/PluginRegistry/FileSystem/LogFileInfo.cs b/src/PluginRegistry/FileSystem/LogFileInfo.cs index 6b0d96a7..31920565 100644 --- a/src/PluginRegistry/FileSystem/LogFileInfo.cs +++ b/src/PluginRegistry/FileSystem/LogFileInfo.cs @@ -1,172 +1,171 @@ using NLog; -namespace LogExpert.PluginRegistry.FileSystem +namespace LogExpert.PluginRegistry.FileSystem; + +public class LogFileInfo : ILogFileInfo { - public class LogFileInfo : ILogFileInfo - { - #region Fields + #region Fields - private const int RETRY_COUNT = 5; - private const int RETRY_SLEEP = 250; - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private const int RETRY_COUNT = 5; + private const int RETRY_SLEEP = 250; + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - //FileStream fStream; - private readonly FileInfo fInfo; + //FileStream fStream; + private readonly FileInfo fInfo; - private long lastLength; + private long lastLength; - #endregion + #endregion - #region cTor + #region cTor - public LogFileInfo(Uri fileUri) - { - fInfo = new FileInfo(fileUri.LocalPath); - Uri = fileUri; - OriginalLength = lastLength = LengthWithoutRetry; - //this.oldLength = 0; - } + public LogFileInfo(Uri fileUri) + { + fInfo = new FileInfo(fileUri.LocalPath); + Uri = fileUri; + OriginalLength = lastLength = LengthWithoutRetry; + //this.oldLength = 0; + } - #endregion + #endregion - #region Properties + #region Properties - public string FullName => fInfo.FullName; + public string FullName => fInfo.FullName; - public string FileName => fInfo.Name; + public string FileName => fInfo.Name; - public string DirectoryName => fInfo.DirectoryName; + public string DirectoryName => fInfo.DirectoryName; - public char DirectorySeparatorChar => Path.DirectorySeparatorChar; + public char DirectorySeparatorChar => Path.DirectorySeparatorChar; - public Uri Uri { get; } + public Uri Uri { get; } - public long Length + public long Length + { + get { - get + if (fInfo == null) { - if (fInfo == null) - { - return -1; - } + return -1; + } - var retry = RETRY_COUNT; + var retry = RETRY_COUNT; - while (retry > 0) + while (retry > 0) + { + try { - try - { - fInfo.Refresh(); - return fInfo.Length; - } - catch (IOException e) + fInfo.Refresh(); + return fInfo.Length; + } + catch (IOException e) + { + if (--retry <= 0) { - if (--retry <= 0) - { - _logger.Warn(e, "LogFileInfo.Length"); - return -1; - } - Thread.Sleep(RETRY_SLEEP); + _logger.Warn(e, "LogFileInfo.Length"); + return -1; } + Thread.Sleep(RETRY_SLEEP); } - - return -1; } + + return -1; } + } - public long OriginalLength { get; } + public long OriginalLength { get; } - public bool FileExists + public bool FileExists + { + get { - get - { - fInfo.Refresh(); - return fInfo.Exists; - } + fInfo.Refresh(); + return fInfo.Exists; } + } - //TODO this should be set from outside once - public int PollInterval => PluginRegistry.PollingInterval; + //TODO this should be set from outside once + public int PollInterval => PluginRegistry.PollingInterval; - public long LengthWithoutRetry + public long LengthWithoutRetry + { + get { - get + if (fInfo == null) { - if (fInfo == null) - { - return -1; - } - try - { - fInfo.Refresh(); - return fInfo.Length; - } - catch (IOException) - { - return -1; - } + return -1; + } + try + { + fInfo.Refresh(); + return fInfo.Length; + } + catch (IOException) + { + return -1; } } + } - #endregion + #endregion - #region Public methods + #region Public methods - /// - /// Creates a new FileStream for the file. The caller is responsible for closing. - /// If file opening fails it will be tried RETRY_COUNT times. This may be needed sometimes - /// if the file is locked for a short amount of time or temporarly unaccessible because of - /// rollover situations. - /// - /// - public Stream OpenStream() - { - var retry = RETRY_COUNT; + /// + /// Creates a new FileStream for the file. The caller is responsible for closing. + /// If file opening fails it will be tried RETRY_COUNT times. This may be needed sometimes + /// if the file is locked for a short amount of time or temporarly unaccessible because of + /// rollover situations. + /// + /// + public Stream OpenStream() + { + var retry = RETRY_COUNT; - while (true) + while (true) + { + try { - try - { - return new FileStream(fInfo.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); - } - catch (IOException fe) - { - _logger.Debug(fe, "LogFileInfo.OpenFile(): \r\nRetry counter {0}", retry); - if (--retry <= 0) - { - throw; - } - Thread.Sleep(RETRY_SLEEP); - } - catch (UnauthorizedAccessException uae) + return new FileStream(fInfo.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); + } + catch (IOException fe) + { + _logger.Debug(fe, "LogFileInfo.OpenFile(): \r\nRetry counter {0}", retry); + if (--retry <= 0) { - _logger.Debug(uae, "LogFileInfo.OpenFile(): \r\nRetry counter: {0}", retry); - if (--retry <= 0) - { - throw new IOException("Error opening file", uae); - } - Thread.Sleep(RETRY_SLEEP); + throw; } + Thread.Sleep(RETRY_SLEEP); } - } - - //TODO Replace with Event from FileSystemWatcher - public bool FileHasChanged() - { - if (LengthWithoutRetry != lastLength) + catch (UnauthorizedAccessException uae) { - lastLength = LengthWithoutRetry; - return true; + _logger.Debug(uae, "LogFileInfo.OpenFile(): \r\nRetry counter: {0}", retry); + if (--retry <= 0) + { + throw new IOException("Error opening file", uae); + } + Thread.Sleep(RETRY_SLEEP); } - return false; } + } - public override string ToString() + //TODO Replace with Event from FileSystemWatcher + public bool FileHasChanged() + { + if (LengthWithoutRetry != lastLength) { - return fInfo.FullName + ", OldLen: " + OriginalLength + ", Len: " + Length; + lastLength = LengthWithoutRetry; + return true; } + return false; + } - #endregion + public override string ToString() + { + return fInfo.FullName + ", OldLen: " + OriginalLength + ", Len: " + Length; } + + #endregion } \ No newline at end of file diff --git a/src/PluginRegistry/PluginRegistry.cs b/src/PluginRegistry/PluginRegistry.cs index 6a282f21..24547ff6 100644 --- a/src/PluginRegistry/PluginRegistry.cs +++ b/src/PluginRegistry/PluginRegistry.cs @@ -1,386 +1,386 @@ -using LogExpert.Core.Classes; +using System.Reflection; + +using LogExpert.Core.Classes; using LogExpert.Core.Classes.Columnizer; using LogExpert.Core.Entities; using LogExpert.Core.Interface; using LogExpert.PluginRegistry.FileSystem; + using NLog; -using System.Reflection; -namespace LogExpert.PluginRegistry +namespace LogExpert.PluginRegistry; + +/// +/// Holds all registered plugins. +/// +/// +/// It all has started with Columnizers only. So the different types of plugins have no common super interface. I didn't change it +/// to keep existing plugin API stable. In a future version this may change. +/// +public class PluginRegistry : IPluginRegistry { - /// - /// Holds all registered plugins. - /// - /// - /// It all has started with Columnizers only. So the different types of plugins have no common super interface. I didn't change it - /// to keep existing plugin API stable. In a future version this may change. - /// - public class PluginRegistry : IPluginRegistry - { - #region Fields + #region Fields + + private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static PluginRegistry? _instance; + private static readonly object _lock = new(); - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - private static PluginRegistry? _instance; - private static readonly object _lock = new(); + private readonly IFileSystemCallback _fileSystemCallback = new FileSystemCallback(); + private readonly IList _pluginList = []; + private readonly IDictionary _registeredKeywordsDict = new Dictionary(); - private readonly IFileSystemCallback _fileSystemCallback = new FileSystemCallback(); - private readonly IList _pluginList = []; - private readonly IDictionary _registeredKeywordsDict = new Dictionary(); + #endregion - #endregion + private static string _applicationConfigurationFolder = string.Empty; + private static int _pollingInterval = 250; - private static string _applicationConfigurationFolder = string.Empty; - private static int _pollingInterval = 250; + #region cTor + // Private constructor to prevent instantiation + private PluginRegistry (string applicationConfigurationFolder, int pollingInterval) + { + _applicationConfigurationFolder = applicationConfigurationFolder; + _pollingInterval = pollingInterval; + } - #region cTor - // Private constructor to prevent instantiation - private PluginRegistry(string applicationConfigurationFolder, int pollingInterval) + public PluginRegistry Create (string applicationConfigurationFolder, int pollingInterval) + { + if (_instance != null) { - _applicationConfigurationFolder = applicationConfigurationFolder; - _pollingInterval = pollingInterval; + return _instance; } - public PluginRegistry Create(string applicationConfigurationFolder, int pollingInterval) + lock (_lock) { - if (_instance != null) - { - return _instance; - } + _instance = new PluginRegistry(applicationConfigurationFolder, pollingInterval); + } - lock (_lock) - { - _instance ??= new PluginRegistry(applicationConfigurationFolder, pollingInterval); - } + _applicationConfigurationFolder = applicationConfigurationFolder; + _pollingInterval = pollingInterval; - _applicationConfigurationFolder = applicationConfigurationFolder; - _pollingInterval = pollingInterval; + _instance.LoadPlugins(); + return Instance; + } - _instance.LoadPlugins(); - return Instance; - } + #endregion - #endregion + #region Properties - #region Properties + public static PluginRegistry Instance => _instance ?? new PluginRegistry(_applicationConfigurationFolder, _pollingInterval); - public static PluginRegistry Instance => _instance ?? new PluginRegistry(_applicationConfigurationFolder, _pollingInterval); + public IList RegisteredColumnizers { get; private set; } - public IList RegisteredColumnizers { get; private set; } + public IList RegisteredContextMenuPlugins { get; } = []; - public IList RegisteredContextMenuPlugins { get; } = []; + public IList RegisteredKeywordActions { get; } = []; - public IList RegisteredKeywordActions { get; } = []; + public IList RegisteredFileSystemPlugins { get; } = []; - public IList RegisteredFileSystemPlugins { get; } = []; + #endregion - #endregion + #region Public methods - #region Public methods + public static int PollingInterval => _pollingInterval; - public static int PollingInterval => _pollingInterval; + #endregion - #endregion + #region Internals - #region Internals + internal void LoadPlugins () + { + _logger.Info("Loading plugins..."); + + RegisteredColumnizers = + [ + //TODO: Remove these plugins and load them as any other plugin + new DefaultLogfileColumnizer(), + new TimestampColumnizer(), + new SquareBracketColumnizer(), + new ClfColumnizer(), + ]; + RegisteredFileSystemPlugins.Add(new LocalFileSystem()); + + var pluginDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins"); + //TODO: FIXME: This is a hack for the tests to pass. Need to find a better approach + if (!Directory.Exists(pluginDir)) + { + pluginDir = "."; + } + + AppDomain.CurrentDomain.AssemblyResolve += ColumnizerResolveEventHandler; - internal void LoadPlugins() + var interfaceName = typeof(ILogLineColumnizer).FullName + ?? throw new NotImplementedException("The interface name is null. How did this happen? Let's fix this."); + + foreach (var dllName in Directory.EnumerateFiles(pluginDir, "*.dll")) { - _logger.Info("Loading plugins..."); - - RegisteredColumnizers = - [ - //TODO: Remove these plugins and load them as any other plugin - new DefaultLogfileColumnizer(), - new TimestampColumnizer(), - new SquareBracketColumnizer(), - new ClfColumnizer(), - ]; - RegisteredFileSystemPlugins.Add(new LocalFileSystem()); - - var pluginDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins"); - //TODO: FIXME: This is a hack for the tests to pass. Need to find a better approach - if (!Directory.Exists(pluginDir)) + try { - pluginDir = "."; + LoadPluginAssembly(dllName, interfaceName); } - - AppDomain.CurrentDomain.AssemblyResolve += ColumnizerResolveEventHandler; - - var interfaceName = typeof(ILogLineColumnizer).FullName; - if (interfaceName == null) { - throw new NotImplementedException("The interface name is null. How did this happen? Let's fix this."); + catch (Exception ex) when (ex is BadImageFormatException or FileLoadException) + { + // Can happen when a 32bit-only DLL is loaded on a 64bit system (or vice versa) + // or could be a not columnizer DLL (e.g. A DLL that is needed by a plugin). + _logger.Error(ex, dllName); } - foreach (var dllName in Directory.EnumerateFiles(pluginDir, "*.dll")) + catch (ReflectionTypeLoadException ex) { - try + // can happen when a dll dependency is missing + if (ex.LoaderExceptions != null && ex.LoaderExceptions.Length != 0) { - LoadPluginAssembly(dllName, interfaceName); - } - catch (Exception ex) when (ex is BadImageFormatException or FileLoadException) - { - // Can happen when a 32bit-only DLL is loaded on a 64bit system (or vice versa) - // or could be a not columnizer DLL (e.g. A DLL that is needed by a plugin). - _logger.Error(ex, dllName); - } - catch (ReflectionTypeLoadException ex) - { - // can happen when a dll dependency is missing - if (ex.LoaderExceptions != null && ex.LoaderExceptions.Length != 0) + foreach (Exception loaderException in ex.LoaderExceptions) { - foreach (Exception loaderException in ex.LoaderExceptions) - { - _logger.Error(loaderException, "Plugin load failed with '{0}'", dllName); - } + _logger.Error(loaderException, "Plugin load failed with '{0}'", dllName); } - _logger.Error(ex, "Loader exception during load of dll '{0}'", dllName); - throw; - } - catch (Exception ex) - { - _logger.Error(ex, $"General Exception for the file {dllName}, of type: {ex.GetType()}, with the message: {ex.Message}"); - throw; } + _logger.Error(ex, "Loader exception during load of dll '{0}'", dllName); + throw; + } + catch (Exception ex) + { + _logger.Error(ex, $"General Exception for the file {dllName}, of type: {ex.GetType()}, with the message: {ex.Message}"); + throw; } - - _logger.Info("Plugin loading complete."); } - private void LoadPluginAssembly(string dllName, string interfaceName) + _logger.Info("Plugin loading complete."); + } + + private void LoadPluginAssembly (string dllName, string interfaceName) + { + var assembly = Assembly.LoadFrom(dllName); + Type[] types = assembly.GetTypes(); + + foreach (Type type in types) { - var assembly = Assembly.LoadFrom(dllName); - var types = assembly.GetTypes(); + _logger.Info($"Type {type.FullName} in assembly {assembly.FullName} implements {interfaceName}"); - foreach (var type in types) + if (type.GetInterfaces().Any(i => i.FullName == interfaceName)) { - _logger.Info($"Type {type.FullName} in assembly {assembly.FullName} implements {interfaceName}"); - - if (type.GetInterfaces().Any(i => i.FullName == interfaceName)) + ConstructorInfo cti = type.GetConstructor(Type.EmptyTypes); + if (cti != null) { - ConstructorInfo cti = type.GetConstructor(Type.EmptyTypes); - if (cti != null) - { - var instance = cti.Invoke([]); - RegisteredColumnizers.Add((ILogLineColumnizer)instance); - - if (instance is IColumnizerConfigurator configurator) - { - configurator.LoadConfig(_applicationConfigurationFolder); - } + var instance = cti.Invoke([]); + RegisteredColumnizers.Add((ILogLineColumnizer)instance); - if (instance is ILogExpertPlugin plugin) - { - _pluginList.Add(plugin); - plugin.PluginLoaded(); - } - - _logger.Info("Added columnizer {0}", type.Name); - } - } - else - { - if (TryAsContextMenu(type)) + if (instance is IColumnizerConfigurator configurator) { - continue; + configurator.LoadConfig(_applicationConfigurationFolder); } - if (TryAsKeywordAction(type)) + if (instance is ILogExpertPlugin plugin) { - continue; + _pluginList.Add(plugin); + plugin.PluginLoaded(); } - if (TryAsFileSystem(type)) - { - continue; - } + _logger.Info($"Added columnizer {type.Name}"); + } + } + else + { + if (TryAsContextMenu(type)) + { + continue; + } + + if (TryAsKeywordAction(type)) + { + continue; + } + + if (TryAsFileSystem(type)) + { + continue; } } } + } + + public IKeywordAction FindKeywordActionPluginByName (string name) + { + _registeredKeywordsDict.TryGetValue(name, out IKeywordAction action); + return action; + } - public IKeywordAction FindKeywordActionPluginByName(string name) + public void CleanupPlugins () + { + foreach (ILogExpertPlugin plugin in _pluginList) { - _registeredKeywordsDict.TryGetValue(name, out IKeywordAction action); - return action; + plugin.AppExiting(); } + } - public void CleanupPlugins() + public IFileSystemPlugin FindFileSystemForUri (string uriString) + { + if (_logger.IsDebugEnabled) { - foreach (ILogExpertPlugin plugin in _pluginList) - { - plugin.AppExiting(); - } + _logger.Debug("Trying to find file system plugin for uri {0}", uriString); } - public IFileSystemPlugin FindFileSystemForUri(string uriString) + foreach (IFileSystemPlugin fs in RegisteredFileSystemPlugins) { if (_logger.IsDebugEnabled) { - _logger.Debug("Trying to find file system plugin for uri {0}", uriString); + _logger.Debug("Checking {0}", fs.Text); } - foreach (IFileSystemPlugin fs in RegisteredFileSystemPlugins) + if (fs.CanHandleUri(uriString)) { if (_logger.IsDebugEnabled) { - _logger.Debug("Checking {0}", fs.Text); + _logger.Debug("Found match {0}", fs.Text); } - if (fs.CanHandleUri(uriString)) - { - if (_logger.IsDebugEnabled) - { - _logger.Debug("Found match {0}", fs.Text); - } - - return fs; - } + return fs; } - - _logger.Error("No file system plugin found for uri {0}", uriString); - return null; } - #endregion + _logger.Error("No file system plugin found for uri {0}", uriString); + return null; + } - #region Private Methods - //TODO: Can this be delted? - private bool TryAsContextMenu(Type type) - { - IContextMenuEntry me = TryInstantiate(type); + #endregion - if (me != null) - { - RegisteredContextMenuPlugins.Add(me); - if (me is ILogExpertPluginConfigurator configurator) - { - configurator.LoadConfig(_applicationConfigurationFolder); - } + #region Private Methods + //TODO: Can this be deleted? + private bool TryAsContextMenu (Type type) + { + IContextMenuEntry me = TryInstantiate(type); - if (me is ILogExpertPlugin plugin) - { - _pluginList.Add(plugin); - plugin.PluginLoaded(); - } + if (me != null) + { + RegisteredContextMenuPlugins.Add(me); + if (me is ILogExpertPluginConfigurator configurator) + { + configurator.LoadConfig(_applicationConfigurationFolder); + } - _logger.Info("Added context menu plugin {0}", type); - return true; + if (me is ILogExpertPlugin plugin) + { + _pluginList.Add(plugin); + plugin.PluginLoaded(); } - return false; + _logger.Info("Added context menu plugin {0}", type); + return true; } - //TODO: Can this be delted? - private bool TryAsKeywordAction(Type type) + return false; + } + + //TODO: Can this be delted? + private bool TryAsKeywordAction (Type type) + { + IKeywordAction ka = TryInstantiate(type); + if (ka != null) { - IKeywordAction ka = TryInstantiate(type); - if (ka != null) + RegisteredKeywordActions.Add(ka); + _registeredKeywordsDict.Add(ka.GetName(), ka); + if (ka is ILogExpertPluginConfigurator configurator) { - RegisteredKeywordActions.Add(ka); - _registeredKeywordsDict.Add(ka.GetName(), ka); - if (ka is ILogExpertPluginConfigurator configurator) - { - configurator.LoadConfig(_applicationConfigurationFolder); - } - - if (ka is ILogExpertPlugin plugin) - { - _pluginList.Add(plugin); - plugin.PluginLoaded(); - } + configurator.LoadConfig(_applicationConfigurationFolder); + } - _logger.Info("Added keyword plugin {0}", type); - return true; + if (ka is ILogExpertPlugin plugin) + { + _pluginList.Add(plugin); + plugin.PluginLoaded(); } - return false; + _logger.Info("Added keyword plugin {0}", type); + return true; } - //TODO: Can this be delted? - private bool TryAsFileSystem(Type type) - { - // file system plugins can have optional constructor with IFileSystemCallback argument - IFileSystemPlugin fs = TryInstantiate(type, _fileSystemCallback); - fs ??= TryInstantiate(type); + return false; + } - if (fs != null) - { - RegisteredFileSystemPlugins.Add(fs); - if (fs is ILogExpertPluginConfigurator configurator) - { - //TODO Refactor, this should be set from outside once and not loaded all the time - configurator.LoadConfig(_applicationConfigurationFolder); - } + //TODO: Can this be delted? + private bool TryAsFileSystem (Type type) + { + // file system plugins can have optional constructor with IFileSystemCallback argument + IFileSystemPlugin fs = TryInstantiate(type, _fileSystemCallback); + fs ??= TryInstantiate(type); - if (fs is ILogExpertPlugin plugin) - { - _pluginList.Add(plugin); - plugin.PluginLoaded(); - } + if (fs != null) + { + RegisteredFileSystemPlugins.Add(fs); + if (fs is ILogExpertPluginConfigurator configurator) + { + //TODO Refactor, this should be set from outside once and not loaded all the time + configurator.LoadConfig(_applicationConfigurationFolder); + } - _logger.Info("Added file system plugin {0}", type); - return true; + if (fs is ILogExpertPlugin plugin) + { + _pluginList.Add(plugin); + plugin.PluginLoaded(); } - return false; + _logger.Info("Added file system plugin {0}", type); + return true; } - private static T TryInstantiate(Type loadedType) where T : class + return false; + } + + private static T TryInstantiate (Type loadedType) where T : class + { + Type t = typeof(T); + Type inter = loadedType.GetInterface(t.Name); + if (inter != null) { - Type t = typeof(T); - Type inter = loadedType.GetInterface(t.Name); - if (inter != null) + ConstructorInfo cti = loadedType.GetConstructor(Type.EmptyTypes); + if (cti != null) { - ConstructorInfo cti = loadedType.GetConstructor(Type.EmptyTypes); - if (cti != null) - { - var o = cti.Invoke([]); - return o as T; - } + var o = cti.Invoke([]); + return o as T; } - - return default; } - private static T TryInstantiate(Type loadedType, IFileSystemCallback fsCallback) where T : class + return default; + } + + private static T TryInstantiate (Type loadedType, IFileSystemCallback fsCallback) where T : class + { + Type t = typeof(T); + Type inter = loadedType.GetInterface(t.Name); + if (inter != null) { - Type t = typeof(T); - Type inter = loadedType.GetInterface(t.Name); - if (inter != null) + ConstructorInfo cti = loadedType.GetConstructor([typeof(IFileSystemCallback)]); + if (cti != null) { - ConstructorInfo cti = loadedType.GetConstructor([typeof(IFileSystemCallback)]); - if (cti != null) - { - var o = cti.Invoke([fsCallback]); - return o as T; - } + var o = cti.Invoke([fsCallback]); + return o as T; } - - return default; } - #endregion + return default; + } - #region Events handler + #endregion - private static Assembly ColumnizerResolveEventHandler(object? sender, ResolveEventArgs args) - { - var fileName = new AssemblyName(args.Name).Name + ".dll"; + #region Events handler - var mainDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - var pluginDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins", fileName); + private static Assembly ColumnizerResolveEventHandler (object? sender, ResolveEventArgs args) + { + var fileName = new AssemblyName(args.Name).Name + ".dll"; - if (File.Exists(mainDir)) - { - return Assembly.LoadFrom(mainDir); - } + var mainDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); + var pluginDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins", fileName); - if (File.Exists(pluginDir)) - { - return Assembly.LoadFrom(pluginDir); - } + if (File.Exists(mainDir)) + { + return Assembly.LoadFrom(mainDir); + } - return null; + if (File.Exists(pluginDir)) + { + return Assembly.LoadFrom(pluginDir); } - #endregion + return null; } + + #endregion } \ No newline at end of file diff --git a/src/RegexColumnizer.UnitTests/RegexColumnizerTests.cs b/src/RegexColumnizer.UnitTests/RegexColumnizerTests.cs index 6728420d..54312b0e 100644 --- a/src/RegexColumnizer.UnitTests/RegexColumnizerTests.cs +++ b/src/RegexColumnizer.UnitTests/RegexColumnizerTests.cs @@ -4,69 +4,66 @@ using System.Runtime.Versioning; [assembly: SupportedOSPlatform("windows")] -namespace RegexColumnizer.UnitTests +namespace RegexColumnizer.UnitTests; + +[TestFixture] +public class RegexColumnizerTests { - [TestFixture] - public class RegexColumnizerTests + // The same amount of columns should be returned whether the line matches the regex or not. + [TestCase("5 test message", @"^(?'time'[\d]+)\s+(?'Message'.+)$", 2)] + [TestCase("Error in com.example.core", @"^(?'time'[\d]+)\s+(?'Message'.+)$", 2)] + public void SplitLine_ColumnCountMatches(string lineToParse, string regex, int expectedNumberOfColumns) { - // The same amount of columns should be returned whether the line matches the regex or not. - [TestCase("5 test message", @"^(?'time'[\d]+)\s+(?'Message'.+)$", 2)] - [TestCase("Error in com.example.core", @"^(?'time'[\d]+)\s+(?'Message'.+)$", 2)] - public void SplitLine_ColumnCountMatches(string lineToParse, string regex, int expectedNumberOfColumns) - { - Regex1Columnizer columnizer = CreateInitializedColumnizer(regex); + Regex1Columnizer columnizer = CreateInitializedColumnizer(regex); - TestLogLine testLogLine = new(4, lineToParse); - IColumnizedLogLine parsedLogLine = columnizer.SplitLine(Mock.Of(), testLogLine); + TestLogLine testLogLine = new(4, lineToParse); + IColumnizedLogLine parsedLogLine = columnizer.SplitLine(Mock.Of(), testLogLine); - Assert.That(expectedNumberOfColumns, Is.EqualTo(parsedLogLine.ColumnValues.Length)); - } + Assert.That(expectedNumberOfColumns, Is.EqualTo(parsedLogLine.ColumnValues.Length)); + } - //Using "" for empty string since string.Empty can't be passed to the TestCase attribute. - [TestCase("5 test message", @"^(?'time'[\d]+)\s+(?'Message'.+)$", 0, "5")] - [TestCase("5 test message", @"^(?'time'[\d]+)\s+(?'Message'.+)$", 1, "test message")] - [TestCase("Error in com.example.core", @"^(?'time'[\d]+)\s+(?'Message'.+)$", 0, "")] // doesn't match regex so should be empty - [TestCase("Error in com.example.core", @"^(?'time'[\d]+)\s+(?'Message'.+)$", 1, "Error in com.example.core")] - public void SplitLine_ColumnValues(string lineToParse, string regex, int columnIndexToTest, - string expectedColumnValue) - { - Regex1Columnizer columnizer = CreateInitializedColumnizer(regex); + //Using "" for empty string since string.Empty can't be passed to the TestCase attribute. + [TestCase("5 test message", @"^(?'time'[\d]+)\s+(?'Message'.+)$", 0, "5")] + [TestCase("5 test message", @"^(?'time'[\d]+)\s+(?'Message'.+)$", 1, "test message")] + [TestCase("Error in com.example.core", @"^(?'time'[\d]+)\s+(?'Message'.+)$", 0, "")] // doesn't match regex so should be empty + [TestCase("Error in com.example.core", @"^(?'time'[\d]+)\s+(?'Message'.+)$", 1, "Error in com.example.core")] + public void SplitLine_ColumnValues(string lineToParse, string regex, int columnIndexToTest, + string expectedColumnValue) + { + Regex1Columnizer columnizer = CreateInitializedColumnizer(regex); - TestLogLine testLogLine = new(3, lineToParse); - IColumnizedLogLine parsedLogLine = columnizer.SplitLine(Mock.Of(), testLogLine); + TestLogLine testLogLine = new(3, lineToParse); + IColumnizedLogLine parsedLogLine = columnizer.SplitLine(Mock.Of(), testLogLine); - Assert.That(expectedColumnValue, Is.EqualTo(parsedLogLine.ColumnValues[columnIndexToTest].Text)); - } + Assert.That(expectedColumnValue, Is.EqualTo(parsedLogLine.ColumnValues[columnIndexToTest].Text)); + } - private Regex1Columnizer CreateInitializedColumnizer(string regex) + private Regex1Columnizer CreateInitializedColumnizer(string regex) + { + RegexColumnizerConfig columnizerConfig = new() { - RegexColumnizerConfig columnizerConfig = new() - { - Expression = regex, - Name = "Test regex" - }; + Expression = regex, + Name = "Test regex" + }; - Regex1Columnizer columnizer = new(); - //TODO this should be an internal function - columnizer.Init(columnizerConfig); - return columnizer; - } + Regex1Columnizer columnizer = new(); + //TODO this should be an internal function + columnizer.Init(columnizerConfig); + return columnizer; + } - private class TestLogLine : ILogLine + private class TestLogLine : ILogLine + { + public TestLogLine(int lineNumber, string fullLine) { - public TestLogLine(int lineNumber, string fullLine) - { - LineNumber = lineNumber; - FullLine = fullLine; - } + LineNumber = lineNumber; + FullLine = fullLine; + } - public string FullLine { get; set; } + public string FullLine { get; set; } - public int LineNumber { get; set; } + public int LineNumber { get; set; } - public string Text { get; set; } - } + public string Text { get; set; } } - - } diff --git a/src/RegexColumnizer/RegexColumnizer.cs b/src/RegexColumnizer/RegexColumnizer.cs index dbc3ecc0..bc66b146 100644 --- a/src/RegexColumnizer/RegexColumnizer.cs +++ b/src/RegexColumnizer/RegexColumnizer.cs @@ -8,241 +8,240 @@ using System.Xml.Serialization; [assembly: SupportedOSPlatform("windows")] -namespace RegexColumnizer +namespace RegexColumnizer; + +public abstract class BaseRegexColumnizer : ILogLineColumnizer, IColumnizerConfigurator { - public abstract class BaseRegexColumnizer : ILogLineColumnizer, IColumnizerConfigurator - { - #region Fields + #region Fields - private readonly XmlSerializer xml = new XmlSerializer(typeof(RegexColumnizerConfig)); - private string[] columns; + private readonly XmlSerializer xml = new XmlSerializer(typeof(RegexColumnizerConfig)); + private string[] columns; - #endregion + #endregion - #region Properties + #region Properties - public RegexColumnizerConfig Config { get; private set; } - - public Regex Regex { get; private set; } + public RegexColumnizerConfig Config { get; private set; } + + public Regex Regex { get; private set; } - #endregion + #endregion - #region Public methods + #region Public methods - public string GetName() + public string GetName() + { + if (Config == null || string.IsNullOrWhiteSpace(Config.Name)) { - if (Config == null || string.IsNullOrWhiteSpace(Config.Name)) - { - return GetNameInternal(); - } - - return Config.Name; + return GetNameInternal(); } - public string GetDescription() => "Columns are filled by regular expression named capture groups"; - - public int GetColumnCount() => columns.Length; - public string[] GetColumnNames() => columns; + return Config.Name; + } + public string GetDescription() => "Columns are filled by regular expression named capture groups"; + + public int GetColumnCount() => columns.Length; - public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) + public string[] GetColumnNames() => columns; + + public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) + { + var logLine = new ColumnizedLogLine(); + + logLine.ColumnValues = new IColumn[columns.Length]; + if (Regex != null) { - var logLine = new ColumnizedLogLine(); + var m = Regex.Match(line.FullLine); - logLine.ColumnValues = new IColumn[columns.Length]; - if (Regex != null) + if (m.Success) { - var m = Regex.Match(line.FullLine); - - if (m.Success) - { - for (var i = m.Groups.Count - 1; i > 0; i--) - { - logLine.ColumnValues[i - 1] = new Column - { - Parent = logLine, - FullValue = m.Groups[i].Value - }; - } - } - else + for (var i = m.Groups.Count - 1; i > 0; i--) { - //Move non matching lines in the last column - logLine.ColumnValues[columns.Length - 1] = new Column + logLine.ColumnValues[i - 1] = new Column { Parent = logLine, - FullValue = line.FullLine + FullValue = m.Groups[i].Value }; - - - //Fill other columns with empty string to avoid null pointer exceptions in unexpected places - for (var i = 0; i < columns.Length - 1; i++) - { - logLine.ColumnValues[i] = new Column - { - Parent = logLine, - FullValue = string.Empty - }; - } } } else { - IColumn colVal = new Column + //Move non matching lines in the last column + logLine.ColumnValues[columns.Length - 1] = new Column { Parent = logLine, FullValue = line.FullLine }; - logLine.ColumnValues[0] = colVal; + + //Fill other columns with empty string to avoid null pointer exceptions in unexpected places + for (var i = 0; i < columns.Length - 1; i++) + { + logLine.ColumnValues[i] = new Column + { + Parent = logLine, + FullValue = string.Empty + }; + } } - - logLine.LogLine = line; - return logLine; } - - public bool IsTimeshiftImplemented() => false; - - public void SetTimeOffset(int msecOffset) + else { - throw new NotImplementedException(); - } + IColumn colVal = new Column + { + Parent = logLine, + FullValue = line.FullLine + }; - public int GetTimeOffset() - { - throw new NotImplementedException(); + logLine.ColumnValues[0] = colVal; } - public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) - { - throw new NotImplementedException(); - } + logLine.LogLine = line; + return logLine; + } - public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) - { - throw new NotImplementedException(); - } + public bool IsTimeshiftImplemented() => false; - public void Configure(ILogLineColumnizerCallback callback, string configDir) - { - var dialog = new RegexColumnizerConfigDialog {Config = Config}; - if (dialog.ShowDialog() == DialogResult.OK) - { - var configFile = GetConfigFile(configDir); - using (var w = new FileStream(configFile, FileMode.Create)) - { - xml.Serialize(w, dialog.Config); - } + public void SetTimeOffset(int msecOffset) + { + throw new NotImplementedException(); + } - Init(dialog.Config); - } - } + public int GetTimeOffset() + { + throw new NotImplementedException(); + } + + public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) + { + throw new NotImplementedException(); + } - public void LoadConfig(string configDir) + public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) + { + throw new NotImplementedException(); + } + + public void Configure(ILogLineColumnizerCallback callback, string configDir) + { + var dialog = new RegexColumnizerConfigDialog {Config = Config}; + if (dialog.ShowDialog() == DialogResult.OK) { var configFile = GetConfigFile(configDir); - RegexColumnizerConfig config; - if (!File.Exists(configFile)) - { - config = new RegexColumnizerConfig - { - Name = GetName() - }; - } - else + using (var w = new FileStream(configFile, FileMode.Create)) { - using (var reader = new StreamReader(configFile)) - { - config = xml.Deserialize(reader) as RegexColumnizerConfig; - } + xml.Serialize(w, dialog.Config); } - Init(config); + Init(dialog.Config); } + } - public string GetConfigFile(string configDir) - { - var name = GetType().Name; - var configPath = Path.Combine(configDir, name); - configPath = Path.ChangeExtension(configPath, "xml"); //todo change to json - return configPath; - } - - #endregion - - /// - /// ToString, this is displayed in the columnizer picker combobox only in the FilterSelectionDialog - /// - /// - public override string ToString() + public void LoadConfig(string configDir) + { + var configFile = GetConfigFile(configDir); + RegexColumnizerConfig config; + if (!File.Exists(configFile)) { - return GetName(); + config = new RegexColumnizerConfig + { + Name = GetName() + }; } - - #region Private Methods - - protected abstract string GetNameInternal(); - - public void Init(RegexColumnizerConfig config) + else { - Config = config; - - try + using (var reader = new StreamReader(configFile)) { - Regex = new Regex(Config.Expression, RegexOptions.Compiled); - var skip = Regex.GetGroupNames().Length == 1 ? 0 : 1; - columns = Regex.GetGroupNames().Skip(skip).ToArray(); - } - catch - { - Regex = null; + config = xml.Deserialize(reader) as RegexColumnizerConfig; } } - #endregion + Init(config); } - public class Regex1Columnizer : BaseRegexColumnizer + public string GetConfigFile(string configDir) { - protected override string GetNameInternal() => "Regex1"; + var name = GetType().Name; + var configPath = Path.Combine(configDir, name); + configPath = Path.ChangeExtension(configPath, "xml"); //todo change to json + return configPath; } - public class Regex2Columnizer : BaseRegexColumnizer - { - protected override string GetNameInternal() => "Regex2"; - } + #endregion - public class Regex3Columnizer : BaseRegexColumnizer + /// + /// ToString, this is displayed in the columnizer picker combobox only in the FilterSelectionDialog + /// + /// + public override string ToString() { - protected override string GetNameInternal() => "Regex3"; + return GetName(); } - public class Regex4Columnizer : BaseRegexColumnizer - { - protected override string GetNameInternal() => "Regex4"; - } + #region Private Methods - public class Regex5Columnizer : BaseRegexColumnizer - { - protected override string GetNameInternal() => "Regex5"; - } + protected abstract string GetNameInternal(); - public class Regex6Columnizer : BaseRegexColumnizer + public void Init(RegexColumnizerConfig config) { - protected override string GetNameInternal() => "Regex6"; - } + Config = config; - public class Regex7Columnizer : BaseRegexColumnizer - { - protected override string GetNameInternal() => "Regex7"; + try + { + Regex = new Regex(Config.Expression, RegexOptions.Compiled); + var skip = Regex.GetGroupNames().Length == 1 ? 0 : 1; + columns = Regex.GetGroupNames().Skip(skip).ToArray(); + } + catch + { + Regex = null; + } } - public class Regex8Columnizer : BaseRegexColumnizer - { - protected override string GetNameInternal() => "Regex8"; - } + #endregion +} - public class Regex9Columnizer : BaseRegexColumnizer - { - protected override string GetNameInternal() => "Regex9"; - } +public class Regex1Columnizer : BaseRegexColumnizer +{ + protected override string GetNameInternal() => "Regex1"; +} + +public class Regex2Columnizer : BaseRegexColumnizer +{ + protected override string GetNameInternal() => "Regex2"; +} + +public class Regex3Columnizer : BaseRegexColumnizer +{ + protected override string GetNameInternal() => "Regex3"; +} + +public class Regex4Columnizer : BaseRegexColumnizer +{ + protected override string GetNameInternal() => "Regex4"; +} + +public class Regex5Columnizer : BaseRegexColumnizer +{ + protected override string GetNameInternal() => "Regex5"; +} + +public class Regex6Columnizer : BaseRegexColumnizer +{ + protected override string GetNameInternal() => "Regex6"; +} + +public class Regex7Columnizer : BaseRegexColumnizer +{ + protected override string GetNameInternal() => "Regex7"; +} + +public class Regex8Columnizer : BaseRegexColumnizer +{ + protected override string GetNameInternal() => "Regex8"; +} + +public class Regex9Columnizer : BaseRegexColumnizer +{ + protected override string GetNameInternal() => "Regex9"; } \ No newline at end of file diff --git a/src/RegexColumnizer/RegexColumnizerConfig.cs b/src/RegexColumnizer/RegexColumnizerConfig.cs index f9b3897b..a8547403 100644 --- a/src/RegexColumnizer/RegexColumnizerConfig.cs +++ b/src/RegexColumnizer/RegexColumnizerConfig.cs @@ -1,13 +1,12 @@ -namespace RegexColumnizer +namespace RegexColumnizer; + +public class RegexColumnizerConfig { - public class RegexColumnizerConfig - { - #region Properties + #region Properties - public string Expression { get; set; } = "(?.*)"; + public string Expression { get; set; } = "(?.*)"; - public string Name { get; set; } + public string Name { get; set; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/RegexColumnizer/RegexColumnizerConfigDialog.cs b/src/RegexColumnizer/RegexColumnizerConfigDialog.cs index 5e388d5c..a355aa38 100644 --- a/src/RegexColumnizer/RegexColumnizerConfigDialog.cs +++ b/src/RegexColumnizer/RegexColumnizerConfigDialog.cs @@ -5,78 +5,77 @@ using System.Text.RegularExpressions; using System.Windows.Forms; -namespace RegexColumnizer +namespace RegexColumnizer; + +public partial class RegexColumnizerConfigDialog : Form { - public partial class RegexColumnizerConfigDialog : Form + public RegexColumnizerConfigDialog() { - public RegexColumnizerConfigDialog() - { - SuspendLayout(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - - InitializeComponent(); - ResumeLayout(); - } + SuspendLayout(); + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; - public RegexColumnizerConfig Config { get; set; } - - private void OnBtnOkClick(object sender, EventArgs e) - { - if (Check()) - { - Config.Expression = tbExpression.Text; - Config.Name = tbName.Text; - } + InitializeComponent(); + ResumeLayout(); + } - } + public RegexColumnizerConfig Config { get; set; } - private void RegexColumnizerConfigDialog_Load(object sender, EventArgs e) + private void OnBtnOkClick(object sender, EventArgs e) + { + if (Check()) { - tbExpression.Text = Config.Expression; - tbName.Text = Config.Name; + Config.Expression = tbExpression.Text; + Config.Name = tbName.Text; } - private void OnButtonCheckClick(object sender, EventArgs e) - { - Check(); - } + } - private bool Check() - { - DataTable table = new(); + private void RegexColumnizerConfigDialog_Load(object sender, EventArgs e) + { + tbExpression.Text = Config.Expression; + tbName.Text = Config.Name; + } - try - { - Regex regex = new(tbExpression.Text); - var groupNames = regex.GetGroupNames(); - var offset = groupNames.Length > 1 ? 1 : 0; + private void OnButtonCheckClick(object sender, EventArgs e) + { + Check(); + } - for (var i = offset; i < groupNames.Length; i++) - { - table.Columns.Add(groupNames[i]); - } + private bool Check() + { + DataTable table = new(); - if (!string.IsNullOrEmpty(tbTestLine.Text)) - { - Match match = regex.Match(tbTestLine.Text); - var row = table.NewRow(); - var values = match.Groups.OfType().Skip(offset).Select(group => group.Value).Cast().ToArray(); - row.ItemArray = values; - table.Rows.Add(row); - } + try + { + Regex regex = new(tbExpression.Text); + var groupNames = regex.GetGroupNames(); + var offset = groupNames.Length > 1 ? 1 : 0; - return true; - } - catch (Exception ex) + for (var i = offset; i < groupNames.Length; i++) { - MessageBox.Show($@"Invalid Regex !{Environment.NewLine}{ex.Message}", @"Regex Columnizer Configuration", MessageBoxButtons.OK, MessageBoxIcon.Error); - return false; + table.Columns.Add(groupNames[i]); } - finally + + if (!string.IsNullOrEmpty(tbTestLine.Text)) { - dataGridView1.DataSource = table; + Match match = regex.Match(tbTestLine.Text); + var row = table.NewRow(); + var values = match.Groups.OfType().Skip(offset).Select(group => group.Value).Cast().ToArray(); + row.ItemArray = values; + table.Rows.Add(row); } + + return true; + } + catch (Exception ex) + { + MessageBox.Show($@"Invalid Regex !{Environment.NewLine}{ex.Message}", @"Regex Columnizer Configuration", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + finally + { + dataGridView1.DataSource = table; } } } diff --git a/src/SftpFileSystemx64/ConfigData.cs b/src/SftpFileSystemx64/ConfigData.cs index 800005ce..02b58e21 100644 --- a/src/SftpFileSystemx64/ConfigData.cs +++ b/src/SftpFileSystemx64/ConfigData.cs @@ -1,15 +1,14 @@ -namespace SftpFileSystem +namespace SftpFileSystem; + +public class ConfigData { - public class ConfigData - { - #region Properties + #region Properties - public string KeyFile { get; set; } + public string KeyFile { get; set; } - public bool UseKeyfile { get; set; } + public bool UseKeyfile { get; set; } - public KeyType KeyType { get; set; } + public KeyType KeyType { get; set; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/SftpFileSystemx64/ConfigDialog.cs b/src/SftpFileSystemx64/ConfigDialog.cs index f7f963db..c3515d9d 100644 --- a/src/SftpFileSystemx64/ConfigDialog.cs +++ b/src/SftpFileSystemx64/ConfigDialog.cs @@ -4,68 +4,67 @@ using System.Windows.Forms; [assembly: SupportedOSPlatform("windows")] -namespace SftpFileSystem -{ - public partial class ConfigDialog : Form - { - #region Ctor +namespace SftpFileSystem; - public ConfigDialog(ConfigData configData) - { - SuspendLayout(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - InitializeComponent(); - TopLevel = false; - ConfigData = configData; - chkBoxPK.Checked = ConfigData.UseKeyfile; - radioBtnPuttyKey.Checked = ConfigData.KeyType == KeyType.Putty; - radioBtnSSHKey.Checked = ConfigData.KeyType == KeyType.Ssh; - lblFile.Text = ConfigData.KeyFile; - ResumeLayout(); - } +public partial class ConfigDialog : Form +{ + #region Ctor - #endregion + public ConfigDialog(ConfigData configData) + { + SuspendLayout(); + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + InitializeComponent(); + TopLevel = false; + ConfigData = configData; + chkBoxPK.Checked = ConfigData.UseKeyfile; + radioBtnPuttyKey.Checked = ConfigData.KeyType == KeyType.Putty; + radioBtnSSHKey.Checked = ConfigData.KeyType == KeyType.Ssh; + lblFile.Text = ConfigData.KeyFile; + ResumeLayout(); + } - #region Properties / Indexers + #endregion - public ConfigData ConfigData { get; } + #region Properties / Indexers - #endregion + public ConfigData ConfigData { get; } - #region Event handling Methods + #endregion - private void OnBtnKeyFileClick(object sender, EventArgs e) - { - FileDialog dlg = new OpenFileDialog(); - if (DialogResult.OK == dlg.ShowDialog()) - { - ConfigData.KeyFile = dlg.FileName; - lblFile.Text = ConfigData.KeyFile; - } - } + #region Event handling Methods - private void OnChkBoxPKCheckedChanged(object sender, EventArgs e) + private void OnBtnKeyFileClick(object sender, EventArgs e) + { + FileDialog dlg = new OpenFileDialog(); + if (DialogResult.OK == dlg.ShowDialog()) { - ConfigData.UseKeyfile = chkBoxPK.Checked; + ConfigData.KeyFile = dlg.FileName; + lblFile.Text = ConfigData.KeyFile; } + } - private void OnChkBoxPKCheckStateChanged(object sender, EventArgs e) - { - keyFileButton.Enabled = chkBoxPK.Checked; - keyTypeGroupBox.Enabled = chkBoxPK.Checked; - } + private void OnChkBoxPKCheckedChanged(object sender, EventArgs e) + { + ConfigData.UseKeyfile = chkBoxPK.Checked; + } - private void OnRadioButtonPuttyKeyCheckedChanged(object sender, EventArgs e) - { - ConfigData.KeyType = KeyType.Putty; - } + private void OnChkBoxPKCheckStateChanged(object sender, EventArgs e) + { + keyFileButton.Enabled = chkBoxPK.Checked; + keyTypeGroupBox.Enabled = chkBoxPK.Checked; + } - private void OnRadioButtonSSHKeyCheckedChanged(object sender, EventArgs e) - { - ConfigData.KeyType = KeyType.Ssh; - } + private void OnRadioButtonPuttyKeyCheckedChanged(object sender, EventArgs e) + { + ConfigData.KeyType = KeyType.Putty; + } - #endregion + private void OnRadioButtonSSHKeyCheckedChanged(object sender, EventArgs e) + { + ConfigData.KeyType = KeyType.Ssh; } + + #endregion } diff --git a/src/SftpFileSystemx64/CredentialCache.cs b/src/SftpFileSystemx64/CredentialCache.cs index 5838be12..93571c2b 100644 --- a/src/SftpFileSystemx64/CredentialCache.cs +++ b/src/SftpFileSystemx64/CredentialCache.cs @@ -1,60 +1,59 @@ using System.Collections.Generic; -namespace SftpFileSystem +namespace SftpFileSystem; + +internal class CredentialCache { - internal class CredentialCache - { - #region Private Fields + #region Private Fields - private readonly IList _credList = []; + private readonly IList _credList = []; - #endregion + #endregion - #region Private Methods + #region Private Methods - private void RemoveCredentials(string host, string user) + private void RemoveCredentials(string host, string user) + { + Credentials credentials = GetCredentials(host, user); + if (credentials != null) { - Credentials credentials = GetCredentials(host, user); - if (credentials != null) - { - _credList.Remove(credentials); - } + _credList.Remove(credentials); } + } - #endregion + #endregion - internal IList GetUsersForHost(string host) - { - IList result = []; + internal IList GetUsersForHost(string host) + { + IList result = []; - foreach (Credentials cred in _credList) + foreach (Credentials cred in _credList) + { + if (cred.Host.Equals(host)) { - if (cred.Host.Equals(host)) - { - result.Add(cred.UserName); - } + result.Add(cred.UserName); } - - return result; } - internal Credentials GetCredentials(string host, string user) + return result; + } + + internal Credentials GetCredentials(string host, string user) + { + foreach (Credentials cred in _credList) { - foreach (Credentials cred in _credList) + if (cred.Host.Equals(host) && cred.UserName.Equals(user)) { - if (cred.Host.Equals(host) && cred.UserName.Equals(user)) - { - return cred; - } + return cred; } - - return null; } - internal void Add(Credentials cred) - { - RemoveCredentials(cred.Host, cred.UserName); - _credList.Add(cred); - } + return null; + } + + internal void Add(Credentials cred) + { + RemoveCredentials(cred.Host, cred.UserName); + _credList.Add(cred); } } diff --git a/src/SftpFileSystemx64/Credentials.cs b/src/SftpFileSystemx64/Credentials.cs index 8bdcdf5d..fbd7cecf 100644 --- a/src/SftpFileSystemx64/Credentials.cs +++ b/src/SftpFileSystemx64/Credentials.cs @@ -1,26 +1,25 @@ -namespace SftpFileSystem +namespace SftpFileSystem; + +internal class Credentials { - internal class Credentials - { - #region Ctor + #region Ctor - internal Credentials(string host, string userName, string password) - { - Host = host; - UserName = userName; - Password = password; - } + internal Credentials(string host, string userName, string password) + { + Host = host; + UserName = userName; + Password = password; + } - #endregion + #endregion - #region Properties / Indexers + #region Properties / Indexers - public string Host { get; } + public string Host { get; } - public string Password { get; } + public string Password { get; } - public string UserName { get; } + public string UserName { get; } - #endregion - } + #endregion } diff --git a/src/SftpFileSystemx64/FailedKeyDialog.cs b/src/SftpFileSystemx64/FailedKeyDialog.cs index 6a728c3e..6084c33d 100644 --- a/src/SftpFileSystemx64/FailedKeyDialog.cs +++ b/src/SftpFileSystemx64/FailedKeyDialog.cs @@ -2,43 +2,42 @@ using System.Drawing; using System.Windows.Forms; -namespace SftpFileSystem +namespace SftpFileSystem; + +public partial class FailedKeyDialog : Form { - public partial class FailedKeyDialog : Form + #region Ctor + + public FailedKeyDialog() + { + SuspendLayout(); + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + InitializeComponent(); + ResumeLayout(); + } + + #endregion + + #region Event handling Methods + + private void OnBtnCancelClick(object sender, EventArgs e) { - #region Ctor - - public FailedKeyDialog() - { - SuspendLayout(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - InitializeComponent(); - ResumeLayout(); - } - - #endregion - - #region Event handling Methods - - private void OnBtnCancelClick(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - Close(); - } - - private void OnBtnRetryClick(object sender, EventArgs e) - { - DialogResult = DialogResult.Retry; - Close(); - } - - private void OnBtnUsePasswordAuthenticationClick(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - Close(); - } - - #endregion + DialogResult = DialogResult.Cancel; + Close(); } + + private void OnBtnRetryClick(object sender, EventArgs e) + { + DialogResult = DialogResult.Retry; + Close(); + } + + private void OnBtnUsePasswordAuthenticationClick(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + Close(); + } + + #endregion } diff --git a/src/SftpFileSystemx64/KeyType.cs b/src/SftpFileSystemx64/KeyType.cs index 8d989f34..a6a737c4 100644 --- a/src/SftpFileSystemx64/KeyType.cs +++ b/src/SftpFileSystemx64/KeyType.cs @@ -1,8 +1,7 @@ -namespace SftpFileSystem +namespace SftpFileSystem; + +public enum KeyType { - public enum KeyType - { - Putty, - Ssh - } + Putty, + Ssh } diff --git a/src/SftpFileSystemx64/LoginDialog.cs b/src/SftpFileSystemx64/LoginDialog.cs index a458cd35..7f9581a7 100644 --- a/src/SftpFileSystemx64/LoginDialog.cs +++ b/src/SftpFileSystemx64/LoginDialog.cs @@ -3,80 +3,79 @@ using System.Drawing; using System.Windows.Forms; -namespace SftpFileSystem +namespace SftpFileSystem; + +public partial class LoginDialog : Form { - public partial class LoginDialog : Form - { - #region Private Fields + #region Private Fields - private string _username; + private string _username; - #endregion + #endregion - #region Ctor + #region Ctor - public LoginDialog(string host, IList userNames, bool hidePasswordField) - { - SuspendLayout(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; + public LoginDialog(string host, IList userNames, bool hidePasswordField) + { + SuspendLayout(); + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; - InitializeComponent(); - serverNameLabel.Text = host; - if (userNames != null) + InitializeComponent(); + serverNameLabel.Text = host; + if (userNames != null) + { + foreach (var name in userNames) { - foreach (var name in userNames) + if (name != null) { - if (name != null) - { - cmbUsername.Items.Add(name); - } + cmbUsername.Items.Add(name); } } + } - if (hidePasswordField) - { - txtBoxPassword.Enabled = false; - lblPassword.Enabled = false; - } - - ResumeLayout(); + if (hidePasswordField) + { + txtBoxPassword.Enabled = false; + lblPassword.Enabled = false; } - #endregion + ResumeLayout(); + } + + #endregion - #region Properties / Indexers + #region Properties / Indexers - public string Password { get; private set; } + public string Password { get; private set; } - public string Username + public string Username + { + get => _username; + set { - get => _username; - set - { - _username = value ?? string.Empty; - cmbUsername.Text = value; - } + _username = value ?? string.Empty; + cmbUsername.Text = value; } + } - #endregion + #endregion - #region Event handling Methods + #region Event handling Methods - private void OnBtnOKClick(object sender, EventArgs e) - { - Password = txtBoxPassword.Text; - _username = cmbUsername.Text; - } + private void OnBtnOKClick(object sender, EventArgs e) + { + Password = txtBoxPassword.Text; + _username = cmbUsername.Text; + } - private void OnLoginDialogLoad(object sender, EventArgs e) + private void OnLoginDialogLoad(object sender, EventArgs e) + { + if (cmbUsername.Text.Length > 0) { - if (cmbUsername.Text.Length > 0) - { - txtBoxPassword.Focus(); - } + txtBoxPassword.Focus(); } - - #endregion } + + #endregion } diff --git a/src/SftpFileSystemx64/PrivateKeyPasswordDialog.cs b/src/SftpFileSystemx64/PrivateKeyPasswordDialog.cs index 6184f6ab..21c2c269 100644 --- a/src/SftpFileSystemx64/PrivateKeyPasswordDialog.cs +++ b/src/SftpFileSystemx64/PrivateKeyPasswordDialog.cs @@ -2,41 +2,40 @@ using System.Drawing; using System.Windows.Forms; -namespace SftpFileSystem -{ - public partial class PrivateKeyPasswordDialog : Form - { - #region Ctor +namespace SftpFileSystem; - public PrivateKeyPasswordDialog() - { - SuspendLayout(); - AutoScaleDimensions = new SizeF(96F, 96F); - AutoScaleMode = AutoScaleMode.Dpi; - InitializeComponent(); - ResumeLayout(); - } +public partial class PrivateKeyPasswordDialog : Form +{ + #region Ctor - #endregion + public PrivateKeyPasswordDialog() + { + SuspendLayout(); + AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleMode = AutoScaleMode.Dpi; + InitializeComponent(); + ResumeLayout(); + } - #region Properties / Indexers + #endregion - public string Password { get; private set; } + #region Properties / Indexers - #endregion + public string Password { get; private set; } - #region Event handling Methods + #endregion - private void OnLoginDialogLoad(object sender, EventArgs e) - { - passwordTextBox.Focus(); - } + #region Event handling Methods - private void OnBtnOkClick(object sender, EventArgs e) - { - Password = passwordTextBox.Text; - } + private void OnLoginDialogLoad(object sender, EventArgs e) + { + passwordTextBox.Focus(); + } - #endregion + private void OnBtnOkClick(object sender, EventArgs e) + { + Password = passwordTextBox.Text; } + + #endregion } diff --git a/src/SftpFileSystemx64/SftpFileSystem.cs b/src/SftpFileSystemx64/SftpFileSystem.cs index 41355951..d899b430 100644 --- a/src/SftpFileSystemx64/SftpFileSystem.cs +++ b/src/SftpFileSystemx64/SftpFileSystem.cs @@ -8,230 +8,229 @@ using System.Windows.Forms; using System.Xml.Serialization; -namespace SftpFileSystem +namespace SftpFileSystem; + +public class SftpFileSystem : IFileSystemPlugin, ILogExpertPluginConfigurator { - public class SftpFileSystem : IFileSystemPlugin, ILogExpertPluginConfigurator - { - #region Private Fields + #region Private Fields - private readonly ILogExpertLogger _logger; + private readonly ILogExpertLogger _logger; - private ConfigDialog _configDialog; - private volatile PrivateKeyFile _privateKeyFile; + private ConfigDialog _configDialog; + private volatile PrivateKeyFile _privateKeyFile; - #endregion + #endregion - #region Ctor + #region Ctor - public SftpFileSystem(IFileSystemCallback callback) - { - _logger = callback.GetLogger(); - CredentialsCache = new CredentialCache(); - } + public SftpFileSystem(IFileSystemCallback callback) + { + _logger = callback.GetLogger(); + CredentialsCache = new CredentialCache(); + } - #endregion + #endregion - #region Interface IFileSystemPlugin + #region Interface IFileSystemPlugin - public string Description => "Can read log files directly from SFTP server."; + public string Description => "Can read log files directly from SFTP server."; - public string Text => "SFTP plugin"; + public string Text => "SFTP plugin"; - public bool CanHandleUri(string uriString) + public bool CanHandleUri(string uriString) + { + try { - try - { - Uri uri = new(uriString); - return uri.Scheme.Equals("sftp", StringComparison.InvariantCultureIgnoreCase); - } - catch (Exception e) - { - _logger.LogError(e.Message); - return false; - } + Uri uri = new(uriString); + return uri.Scheme.Equals("sftp", StringComparison.InvariantCultureIgnoreCase); } - - public ILogFileInfo GetLogfileInfo(string uriString) + catch (Exception e) { - try - { - Uri uri = new(uriString.Replace('\\', '/')); - return new SftpLogFileInfo(this, uri, _logger); - } - catch (Exception e) - { - _logger.LogError(e.Message); - return null; - } + _logger.LogError(e.Message); + return false; } + } - #endregion - - #region Interface ILogExpertPluginConfigurator - - public bool HasEmbeddedForm() + public ILogFileInfo GetLogfileInfo(string uriString) + { + try { - return true; + Uri uri = new(uriString.Replace('\\', '/')); + return new SftpLogFileInfo(this, uri, _logger); } - - public void HideConfigForm() + catch (Exception e) { - ConfigData = _configDialog.ConfigData; - _configDialog.Hide(); - _configDialog.Dispose(); + _logger.LogError(e.Message); + return null; } + } - public void LoadConfig(string configDir) - { - XmlSerializer xml = new(ConfigData.GetType()); + #endregion - FileInfo configFile = new(configDir + "\\" + "sftpfilesystem.cfg"); + #region Interface ILogExpertPluginConfigurator - if (!configFile.Exists) - { - return; - } + public bool HasEmbeddedForm() + { + return true; + } - FileStream fs = null; + public void HideConfigForm() + { + ConfigData = _configDialog.ConfigData; + _configDialog.Hide(); + _configDialog.Dispose(); + } - try - { - fs = configFile.OpenRead(); + public void LoadConfig(string configDir) + { + XmlSerializer xml = new(ConfigData.GetType()); - ConfigData = (ConfigData)xml.Deserialize(fs); - } - catch (IOException e) - { - _logger.LogError(e.Message); - } - finally - { - fs?.Flush(); - fs?.Close(); - fs?.Dispose(); - } - } + FileInfo configFile = new(configDir + "\\" + "sftpfilesystem.cfg"); - public void SaveConfig(string configDir) + if (!configFile.Exists) { - _logger.Info("Saving SFTP config"); - XmlSerializer xml = new(ConfigData.GetType()); + return; + } - FileStream fs = null; + FileStream fs = null; - try - { - fs = new FileStream(configDir + "\\" + "sftpfilesystem.cfg", FileMode.Create); - xml.Serialize(fs, ConfigData); - fs.Close(); - } - catch (IOException e) - { - _logger.LogError(e.Message); - } - finally - { - fs?.Flush(); - fs?.Close(); - fs?.Dispose(); - } - } + try + { + fs = configFile.OpenRead(); - public void ShowConfigDialog(object owner) + ConfigData = (ConfigData)xml.Deserialize(fs); + } + catch (IOException e) { - throw new NotImplementedException(); + _logger.LogError(e.Message); } - - public void ShowConfigForm(object parentPanel) + finally { - _configDialog = new ConfigDialog(ConfigData) - { - Parent = (Panel)parentPanel - }; - - _configDialog.Show(); + fs?.Flush(); + fs?.Close(); + fs?.Dispose(); } + } + + public void SaveConfig(string configDir) + { + _logger.Info("Saving SFTP config"); + XmlSerializer xml = new(ConfigData.GetType()); - public void StartConfig() + FileStream fs = null; + + try + { + fs = new FileStream(configDir + "\\" + "sftpfilesystem.cfg", FileMode.Create); + xml.Serialize(fs, ConfigData); + fs.Close(); + } + catch (IOException e) + { + _logger.LogError(e.Message); + } + finally { + fs?.Flush(); + fs?.Close(); + fs?.Dispose(); } + } - #endregion + public void ShowConfigDialog(object owner) + { + throw new NotImplementedException(); + } - #region Properties / Indexers + public void ShowConfigForm(object parentPanel) + { + _configDialog = new ConfigDialog(ConfigData) + { + Parent = (Panel)parentPanel + }; - public ConfigData ConfigData { get; private set; } = new ConfigData(); + _configDialog.Show(); + } - public PrivateKeyFile PrivateKeyFile - { - get => _privateKeyFile; - set => _privateKeyFile = value; - } + public void StartConfig() + { + } + + #endregion - private CredentialCache CredentialsCache { get; } + #region Properties / Indexers - #endregion + public ConfigData ConfigData { get; private set; } = new ConfigData(); + + public PrivateKeyFile PrivateKeyFile + { + get => _privateKeyFile; + set => _privateKeyFile = value; + } - internal Credentials GetCredentials(Uri uri, bool cacheAllowed, bool hidePasswordField) + private CredentialCache CredentialsCache { get; } + + #endregion + + internal Credentials GetCredentials(Uri uri, bool cacheAllowed, bool hidePasswordField) + { + // Synchronized access to the GetCredentials() method prevents multiple login dialogs when loading multiple files at once + // (e.g. on startup). So the user only needs to enter credentials once for the same host. + lock (this) { - // Synchronized access to the GetCredentials() method prevents multiple login dialogs when loading multiple files at once - // (e.g. on startup). So the user only needs to enter credentials once for the same host. - lock (this) + string userName = null; + string password = null; + if (uri.UserInfo != null && uri.UserInfo.Length > 0) { - string userName = null; - string password = null; - if (uri.UserInfo != null && uri.UserInfo.Length > 0) + var split = uri.UserInfo.Split(':'); + if (split.Length > 0) { - var split = uri.UserInfo.Split(':'); - if (split.Length > 0) - { - userName = split[0]; - } - - if (split.Length > 1) - { - password = split[1]; - } + userName = split[0]; } - IList usersForHost = CredentialsCache.GetUsersForHost(uri.Host); - if (userName == null && cacheAllowed) + if (split.Length > 1) { - if (usersForHost.Count == 1) - { - userName = usersForHost[0]; - } + password = split[1]; } + } - if (userName != null && password == null && cacheAllowed) + IList usersForHost = CredentialsCache.GetUsersForHost(uri.Host); + if (userName == null && cacheAllowed) + { + if (usersForHost.Count == 1) { - Credentials cred = CredentialsCache.GetCredentials(uri.Host, userName); - if (cred != null) - { - return cred; - } + userName = usersForHost[0]; } + } + + if (userName != null && password == null && cacheAllowed) + { + Credentials cred = CredentialsCache.GetCredentials(uri.Host, userName); + if (cred != null) + { + return cred; + } + } - if (userName == null || password == null) + if (userName == null || password == null) + { + LoginDialog dlg = new(uri.Host, usersForHost, hidePasswordField) { - LoginDialog dlg = new(uri.Host, usersForHost, hidePasswordField) - { - Username = userName - }; - - if (DialogResult.OK == dlg.ShowDialog()) - { - password = dlg.Password; - userName = dlg.Username; - } - - dlg.Dispose(); + Username = userName + }; + + if (DialogResult.OK == dlg.ShowDialog()) + { + password = dlg.Password; + userName = dlg.Username; } - Credentials credentials = new(uri.Host, userName, password); - CredentialsCache.Add(credentials); - return credentials; + dlg.Dispose(); } + + Credentials credentials = new(uri.Host, userName, password); + CredentialsCache.Add(credentials); + return credentials; } } } diff --git a/src/SftpFileSystemx64/SftpLogFileInfo.cs b/src/SftpFileSystemx64/SftpLogFileInfo.cs index 83c3e4ce..5784dc9c 100644 --- a/src/SftpFileSystemx64/SftpLogFileInfo.cs +++ b/src/SftpFileSystemx64/SftpLogFileInfo.cs @@ -1,263 +1,264 @@ -using System; +using System; using System.IO; using System.Threading; using System.Windows.Forms; + using LogExpert; + using Renci.SshNet; using Renci.SshNet.Sftp; -namespace SftpFileSystem +namespace SftpFileSystem; + +internal class SftpLogFileInfo : ILogFileInfo { - internal class SftpLogFileInfo : ILogFileInfo - { - #region Static/Constants - //TODO Add to Options - private const int RETRY_COUNT = 20; - private const int RETRY_SLEEP = 250; + #region Static/Constants + //TODO Add to Options + private const int RETRY_COUNT = 20; + private const int RETRY_SLEEP = 250; - #endregion + #endregion - #region Private Fields + #region Private Fields - private readonly ILogExpertLogger _logger; - private readonly string _remoteFileName; + private readonly ILogExpertLogger _logger; + private readonly string _remoteFileName; - private readonly SftpClient _sftp; - private readonly object _sshKeyMonitor = new(); - private DateTime _lastChange = DateTime.Now; - private long _lastLength; + private readonly SftpClient _sftp; + private readonly object _sshKeyMonitor = new(); + private DateTime _lastChange = DateTime.Now; + private long _lastLength; - #endregion + #endregion - #region Ctor + #region Ctor - internal SftpLogFileInfo(SftpFileSystem sftpFileSystem, Uri fileUri, ILogExpertLogger logger) - { - _logger = logger; - SftpFileSystem sftFileSystem = sftpFileSystem; - Uri = fileUri; - _remoteFileName = Uri.PathAndQuery; + internal SftpLogFileInfo (SftpFileSystem sftpFileSystem, Uri fileUri, ILogExpertLogger logger) + { + _logger = logger; + SftpFileSystem sftFileSystem = sftpFileSystem; + Uri = fileUri; + _remoteFileName = Uri.PathAndQuery; - var port = Uri.Port != -1 ? Uri.Port : 22; + var port = Uri.Port != -1 ? Uri.Port : 22; - var success = false; - var cancelled = false; - if (sftFileSystem.ConfigData.UseKeyfile) + var success = false; + var cancelled = false; + if (sftFileSystem.ConfigData.UseKeyfile) + { + lock (_sshKeyMonitor) // prevent multiple password dialogs when opening multiple files at once { - lock (_sshKeyMonitor) // prevent multiple password dialogs when opening multiple files at once + while (sftFileSystem.PrivateKeyFile == null) { - while (sftFileSystem.PrivateKeyFile == null) + PrivateKeyPasswordDialog dlg = new(); + DialogResult dialogResult = dlg.ShowDialog(); + if (dialogResult == DialogResult.Cancel) { - PrivateKeyPasswordDialog dlg = new(); - DialogResult dialogResult = dlg.ShowDialog(); - if (dialogResult == DialogResult.Cancel) - { - cancelled = true; - break; - } + cancelled = true; + break; + } - PrivateKeyFile privateKeyFile = new(sftFileSystem.ConfigData.KeyFile, dlg.Password); + PrivateKeyFile privateKeyFile = new(sftFileSystem.ConfigData.KeyFile, dlg.Password); - if (privateKeyFile != null) - { - sftFileSystem.PrivateKeyFile = privateKeyFile; - } - else - { - MessageBox.Show("Loading key file failed"); - } + if (privateKeyFile != null) + { + sftFileSystem.PrivateKeyFile = privateKeyFile; + } + else + { + MessageBox.Show("Loading key file failed"); } } + } - if (cancelled == false) + if (cancelled == false) + { + success = false; + Credentials credentials = sftFileSystem.GetCredentials(Uri, true, true); + while (success == false) { - success = false; - Credentials credentials = sftFileSystem.GetCredentials(Uri, true, true); - while (success == false) + //Add ConnectionInfo object + _sftp = new SftpClient(Uri.Host, credentials.UserName, sftFileSystem.PrivateKeyFile); + + if (_sftp != null) { - //Add ConnectionInfo object - _sftp = new SftpClient(Uri.Host, credentials.UserName, sftFileSystem.PrivateKeyFile); + _sftp.Connect(); + success = true; + } - if (_sftp != null) + if (success == false) + { + FailedKeyDialog dlg = new(); + DialogResult res = dlg.ShowDialog(); + dlg.Dispose(); + if (res == DialogResult.Cancel) { - _sftp.Connect(); - success = true; + return; } - if (success == false) + if (res == DialogResult.OK) { - FailedKeyDialog dlg = new(); - DialogResult res = dlg.ShowDialog(); - dlg.Dispose(); - if (res == DialogResult.Cancel) - { - return; - } - - if (res == DialogResult.OK) - { - break; // go to user/pw auth - } - - // retries with disabled cache - credentials = sftFileSystem.GetCredentials(Uri, false, true); + break; // go to user/pw auth } + + // retries with disabled cache + credentials = sftFileSystem.GetCredentials(Uri, false, true); } } } + } + + if (success == false) + { + // username/password auth + Credentials credentials = sftFileSystem.GetCredentials(Uri, true, false); + _sftp = new SftpClient(Uri.Host, port, credentials.UserName, credentials.Password); - if (success == false) + if (_sftp == null) { - // username/password auth - Credentials credentials = sftFileSystem.GetCredentials(Uri, true, false); + // first fail -> try again with disabled cache + credentials = sftFileSystem.GetCredentials(Uri, false, false); _sftp = new SftpClient(Uri.Host, port, credentials.UserName, credentials.Password); if (_sftp == null) { - // first fail -> try again with disabled cache - credentials = sftFileSystem.GetCredentials(Uri, false, false); - _sftp = new SftpClient(Uri.Host, port, credentials.UserName, credentials.Password); - - if (_sftp == null) - { - // 2nd fail -> abort - MessageBox.Show("Authentication failed!"); - //MessageBox.Show(sftp.LastErrorText); - return; - } - } - else - { - _sftp.Connect(); + // 2nd fail -> abort + MessageBox.Show("Authentication failed!"); + //MessageBox.Show(sftp.LastErrorText); + return; } } - - if (_sftp.IsConnected == false) + else { - MessageBox.Show("Sftp is not connected"); - return; + _sftp.Connect(); } + } - OriginalLength = _lastLength = Length; + if (_sftp.IsConnected == false) + { + MessageBox.Show("Sftp is not connected"); + return; } - #endregion + OriginalLength = _lastLength = Length; + } + + #endregion - #region Interface ILogFileInfo + #region Interface ILogFileInfo - public string DirectoryName + public string DirectoryName + { + get { - get + var full = FullName; + var i = full.LastIndexOf(DirectorySeparatorChar); + if (i != -1) { - var full = FullName; - var i = full.LastIndexOf(DirectorySeparatorChar); - if (i != -1) - { - return full.Substring(0, i); - } - - return "."; + return full.Substring(0, i); } + + return "."; } + } - public char DirectorySeparatorChar => '/'; + public char DirectorySeparatorChar => '/'; - public bool FileExists + public bool FileExists + { + get { - get + try { - try - { - var file = (SftpFile) _sftp.Get(_remoteFileName); - var len = file.Attributes.Size; - return len != -1; - } - catch (Exception e) - { - _logger.LogError(e.Message); - return false; - } + var file = (SftpFile)_sftp.Get(_remoteFileName); + var len = file.Attributes.Size; + return len != -1; + } + catch (Exception e) + { + _logger.LogError(e.Message); + return false; } } + } - public string FileName + public string FileName + { + get { - get - { - var full = FullName; - var i = full.LastIndexOf(DirectorySeparatorChar); - return full.Substring(i + 1); - } + var full = FullName; + var i = full.LastIndexOf(DirectorySeparatorChar); + return full.Substring(i + 1); } + } - public string FullName => Uri.ToString(); + public string FullName => Uri.ToString(); - public long Length + public long Length + { + get { - get - { - var file = (SftpFile)_sftp.Get(_remoteFileName); - return file.Attributes.Size; - } + var file = (SftpFile)_sftp.Get(_remoteFileName); + return file.Attributes.Size; } + } - public long OriginalLength { get; } + public long OriginalLength { get; } - public int PollInterval + public int PollInterval + { + get { - get + TimeSpan diff = DateTime.Now - _lastChange; + if (diff.TotalSeconds < 4) { - TimeSpan diff = DateTime.Now - _lastChange; - if (diff.TotalSeconds < 4) - { - return 400; - } - - if (diff.TotalSeconds < 30) - { - return (int)diff.TotalSeconds * 100; - } + return 400; + } - return 5000; + if (diff.TotalSeconds < 30) + { + return (int)diff.TotalSeconds * 100; } + + return 5000; } + } - public Uri Uri { get; } + public Uri Uri { get; } - public bool FileHasChanged() + public bool FileHasChanged () + { + if (Length != _lastLength) { - if (Length != _lastLength) - { - _lastLength = Length; - _lastChange = DateTime.Now; - return true; - } - - return false; + _lastLength = Length; + _lastChange = DateTime.Now; + return true; } - public Stream OpenStream() + return false; + } + + public Stream OpenStream () + { + var retry = RETRY_COUNT; + while (true) { - var retry = RETRY_COUNT; - while (true) + try { - try + return _sftp.OpenRead(_remoteFileName); + } + catch (IOException) + { + //First remove a try then check if its less or 0 + if (--retry <= 0) { - return _sftp.OpenRead(_remoteFileName); + throw; } - catch (IOException) - { - //First remove a try then check if its less or 0 - if (--retry <= 0) - { - throw; - } - Thread.Sleep(RETRY_SLEEP); - } + Thread.Sleep(RETRY_SLEEP); } } - - #endregion } + + #endregion } From 55e527bf75f792487ff3c47f5f88e3f627797bd0 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sun, 1 Jun 2025 16:35:12 +0300 Subject: [PATCH 056/142] Add new rules to editorconfig and removed them from the .csproj files --- src/.editorconfig | 17 ++++++++++++++++- src/ColumnizerLib/ColumnizerLib.csproj | 3 +-- src/LogExpert.Core/LogExpert.Core.csproj | 1 - src/LogExpert.UI/LogExpert.UI.csproj | 1 - src/LogExpert/LogExpert.csproj | 1 - .../LogExpert.PluginRegistry.csproj | 1 - 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/.editorconfig b/src/.editorconfig index 7225b5c0..aa92b5d8 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -245,6 +245,21 @@ dotnet_naming_style.begins_with_i.required_suffix = dotnet_naming_style.begins_with_i.word_separator = dotnet_naming_style.begins_with_i.capitalization = pascal_case +#### The Nullable Knights #### + +dotnet_diagnostic.CS8625.severity = none +dotnet_diagnostic.CS8603.severity = none +dotnet_diagnostic.CS8618.severity = none +dotnet_diagnostic.CS8600.severity = none +dotnet_diagnostic.CS8602.severity = none +dotnet_diagnostic.CS8604.severity = none +dotnet_diagnostic.CS8622.severity = none +dotnet_diagnostic.CS8601.severity = none +dotnet_diagnostic.CS8605.severity = none +dotnet_diagnostic.CS0649.severity = none +dotnet_diagnostic.CS0169.severity = none +dotnet_diagnostic.CS1591.severity = none + #### Analyzers Rules #### ## Microsoft.CodeAnalysis.CSharp.CodeStyle @@ -4849,4 +4864,4 @@ dotnet_diagnostic.xUnit2019.severity = none dotnet_diagnostic.xUnit3000.severity = warning # xUnit3001: Classes that implement Xunit.Abstractions.IXunitSerializable must have a public parameterless constructor -dotnet_diagnostic.xUnit3001.severity = warning \ No newline at end of file +dotnet_diagnostic.xUnit3001.severity = warning diff --git a/src/ColumnizerLib/ColumnizerLib.csproj b/src/ColumnizerLib/ColumnizerLib.csproj index ec4cc262..c341d269 100644 --- a/src/ColumnizerLib/ColumnizerLib.csproj +++ b/src/ColumnizerLib/ColumnizerLib.csproj @@ -6,10 +6,9 @@ LogExpert false $(SolutionDir)..\bin\Docs\ColumnizerLib.xml - false + false false $(SolutionDir)..\bin\$(Configuration) - CS1591; False diff --git a/src/LogExpert.Core/LogExpert.Core.csproj b/src/LogExpert.Core/LogExpert.Core.csproj index 0062fbbf..87c6a9bc 100644 --- a/src/LogExpert.Core/LogExpert.Core.csproj +++ b/src/LogExpert.Core/LogExpert.Core.csproj @@ -9,7 +9,6 @@ True ..\Solution Items\Key.snk false - CS8625;CS8603;CS8618;CS8600;CS8603;CS8602;CS8604;CS8622;CS8601; diff --git a/src/LogExpert.UI/LogExpert.UI.csproj b/src/LogExpert.UI/LogExpert.UI.csproj index 94a3d5c1..145fbbc4 100644 --- a/src/LogExpert.UI/LogExpert.UI.csproj +++ b/src/LogExpert.UI/LogExpert.UI.csproj @@ -7,7 +7,6 @@ true false enable - CS8625;CS8603;CS8618;CS8600;CS8603;CS8602;CS8604;CS8622;CS8601;CS8605; enable false True diff --git a/src/LogExpert/LogExpert.csproj b/src/LogExpert/LogExpert.csproj index a145ea46..d8c317de 100644 --- a/src/LogExpert/LogExpert.csproj +++ b/src/LogExpert/LogExpert.csproj @@ -13,7 +13,6 @@ Auto enable False - CS1591; $(SolutionDir)..\bin\$(Configuration) WinExe True diff --git a/src/PluginRegistry/LogExpert.PluginRegistry.csproj b/src/PluginRegistry/LogExpert.PluginRegistry.csproj index 4190d432..63c4fbbe 100644 --- a/src/PluginRegistry/LogExpert.PluginRegistry.csproj +++ b/src/PluginRegistry/LogExpert.PluginRegistry.csproj @@ -7,7 +7,6 @@ enable True ..\Solution Items\Key.snk - CS8600;CS8603;CS8618; From a43a5cf524122fbe46a3909903826c63adbffc78 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Tue, 3 Jun 2025 08:49:34 +0200 Subject: [PATCH 057/142] wrong file structure, added the files to the correct one --- .../Classes/Persister/PersistenceData.cs | 0 src/{Logexpert.Core => LogExpert.Core}/Interface/IBookmarkView.cs | 0 .../Controls/LogWindow}/AbstractLogTabWindow.cs | 0 .../Controls/LogWindow}/StaticLogTabWindowData.cs | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/{Logexpert.Core => LogExpert.Core}/Classes/Persister/PersistenceData.cs (100%) rename src/{Logexpert.Core => LogExpert.Core}/Interface/IBookmarkView.cs (100%) rename src/{Logexpert.UI/Dialogs/LogTabWindow => LogExpert.UI/Controls/LogWindow}/AbstractLogTabWindow.cs (100%) rename src/{Logexpert.UI/Dialogs/LogTabWindow => LogExpert.UI/Controls/LogWindow}/StaticLogTabWindowData.cs (100%) diff --git a/src/Logexpert.Core/Classes/Persister/PersistenceData.cs b/src/LogExpert.Core/Classes/Persister/PersistenceData.cs similarity index 100% rename from src/Logexpert.Core/Classes/Persister/PersistenceData.cs rename to src/LogExpert.Core/Classes/Persister/PersistenceData.cs diff --git a/src/Logexpert.Core/Interface/IBookmarkView.cs b/src/LogExpert.Core/Interface/IBookmarkView.cs similarity index 100% rename from src/Logexpert.Core/Interface/IBookmarkView.cs rename to src/LogExpert.Core/Interface/IBookmarkView.cs diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/AbstractLogTabWindow.cs b/src/LogExpert.UI/Controls/LogWindow/AbstractLogTabWindow.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/LogTabWindow/AbstractLogTabWindow.cs rename to src/LogExpert.UI/Controls/LogWindow/AbstractLogTabWindow.cs diff --git a/src/Logexpert.UI/Dialogs/LogTabWindow/StaticLogTabWindowData.cs b/src/LogExpert.UI/Controls/LogWindow/StaticLogTabWindowData.cs similarity index 100% rename from src/Logexpert.UI/Dialogs/LogTabWindow/StaticLogTabWindowData.cs rename to src/LogExpert.UI/Controls/LogWindow/StaticLogTabWindowData.cs From f5bc73609655d120d65f4b06d716a82ac59df1cb Mon Sep 17 00:00:00 2001 From: Hirogen Date: Tue, 3 Jun 2025 10:58:25 +0200 Subject: [PATCH 058/142] first iteration --- src/ColumnizerLib/Column.cs | 39 +- src/ColumnizerLib/LineEntry.cs | 4 +- src/DefaultPlugins/ProcessLauncher.cs | 13 +- src/JsonColumnizer/JsonColumnizer.cs | 77 ++-- src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs | 68 ++-- .../Log4jXmlColumnizerConfig.cs | 27 +- .../Log4jXmlColumnizerConfigDlg.cs | 12 +- .../Classes/Columnizer/ClfColumnizer.cs | 66 ++-- .../Classes/Columnizer/ColumnizerPicker.cs | 20 +- .../Columnizer/SquareBracketColumnizer.cs | 38 +- .../Columnizer/TimeFormatDeterminer.cs | 75 ++-- .../Classes/Filter/FilterParams.cs | 18 +- .../Classes/Filter/FilterStarter.cs | 2 +- .../Classes/Log/LogfileReader.cs | 24 +- .../Log/PositionAwareStreamReaderBase.cs | 36 +- .../Classes/Log/RolloverFilenameBuilder.cs | 58 +-- src/LogExpert.Core/Classes/ParamParser.cs | 64 ++-- src/LogExpert.Core/Classes/PatternBlock.cs | 37 +- .../Classes/Persister/PersistenceData.cs | 18 +- .../Classes/Persister/Persister.cs | 52 +-- src/LogExpert.Core/Classes/QualityInfo.cs | 6 + src/LogExpert.Core/Classes/Util.cs | 14 +- src/LogExpert.Tests/BufferShiftTest.cs | 6 +- .../Controls/DateTimeDragControl.cs | 66 ++-- .../Controls/LogWindow/LogWindow.cs | 10 + .../LogWindow/LogWindowEventHandlers.cs | 47 ++- .../Controls/LogWindow/LogWindowPrivate.cs | 354 +++++++++++------- .../Controls/LogWindow/LogWindowPublic.cs | 6 +- .../Controls/LogWindow/PatternWindow.cs | 64 ++-- .../Controls/LogWindow/TimeSpreadigControl.cs | 43 ++- .../Dialogs/LogTabWindow/HighlightDialog.cs | 103 +++-- .../Dialogs/LogTabWindow/LogTabWindow.cs | 49 ++- .../LogTabWindow/LogTabWindowEventHandlers.cs | 40 +- .../LogTabWindow/LogTabWindowPrivate.cs | 24 +- .../LogTabWindow/LogTabWindowPublic.cs | 32 +- .../Dialogs/LogTabWindow/SettingsDialog.cs | 119 +++--- src/LogExpert.UI/Dialogs/ToolArgsDialog.cs | 4 +- src/LogExpert.UI/Entities/ArgParser.cs | 79 ++-- src/SftpFileSystemx64/CredentialCache.cs | 14 +- src/SftpFileSystemx64/SftpFileSystem.cs | 50 ++- 40 files changed, 1022 insertions(+), 856 deletions(-) create mode 100644 src/LogExpert.Core/Classes/QualityInfo.cs diff --git a/src/ColumnizerLib/Column.cs b/src/ColumnizerLib/Column.cs index 03fb37b6..e344464b 100644 --- a/src/ColumnizerLib/Column.cs +++ b/src/ColumnizerLib/Column.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; namespace LogExpert; @@ -18,42 +18,35 @@ public class Column : IColumn #region cTor - static Column() + static Column () { var replacements = new List>( - new Func[] - { + [ //replace tab with 3 spaces, from old coding. Needed??? - input => input.Replace("\t", " "), + input => input.Replace("\t", " ", StringComparison.Ordinal), //shorten string if it exceeds maxLength - input => - { - if (input.Length > _maxLength) - { - return input.Substring(0, _maxLength) + _replacement; - } - - return input; - } - }); + input => input.Length > _maxLength + ? string.Concat(input.AsSpan(0, _maxLength), _replacement) + : input + ]); if (Environment.Version >= Version.Parse("6.2")) { //Win8 or newer support full UTF8 chars with the preinstalled fonts. - //Replace null char with UTF8 Symbol U+2400 (␀) - replacements.Add(input => input.Replace("\0", "␀")); + //Replace null char with UTF8 Symbol U+2400 (␀) + replacements.Add(input => input.Replace("\0", "␀", StringComparison.Ordinal)); } else { //Everything below Win8 the installed fonts seems to not to support reliabel //Replace null char with space - replacements.Add(input => input.Replace("\0", " ")); + replacements.Add(input => input.Replace("\0", " ", StringComparison.Ordinal)); } _replacements = replacements; - EmptyColumn = new Column {FullValue = string.Empty}; + EmptyColumn = new Column { FullValue = string.Empty }; } #endregion @@ -90,24 +83,24 @@ public string FullValue #region Public methods - public static Column[] CreateColumns(int count, IColumnizedLogLine parent) + public static Column[] CreateColumns (int count, IColumnizedLogLine parent) { return CreateColumns(count, parent, string.Empty); } - public static Column[] CreateColumns(int count, IColumnizedLogLine parent, string defaultValue) + public static Column[] CreateColumns (int count, IColumnizedLogLine parent, string defaultValue) { var output = new Column[count]; for (var i = 0; i < count; i++) { - output[i] = new Column {FullValue = defaultValue, Parent = parent}; + output[i] = new Column { FullValue = defaultValue, Parent = parent }; } return output; } - public override string ToString() + public override string ToString () { return DisplayValue ?? string.Empty; } diff --git a/src/ColumnizerLib/LineEntry.cs b/src/ColumnizerLib/LineEntry.cs index bcbb4699..3869767c 100644 --- a/src/ColumnizerLib/LineEntry.cs +++ b/src/ColumnizerLib/LineEntry.cs @@ -10,10 +10,10 @@ public struct LineEntry /// /// The content of the line. /// - public ILogLine logLine; + public ILogLine LogLine { get; set; } /// /// The line number. See for an explanation of the line number. /// - public int lineNum; + public int LineNum { get; set; } } \ No newline at end of file diff --git a/src/DefaultPlugins/ProcessLauncher.cs b/src/DefaultPlugins/ProcessLauncher.cs index 8e381867..de439ddf 100644 --- a/src/DefaultPlugins/ProcessLauncher.cs +++ b/src/DefaultPlugins/ProcessLauncher.cs @@ -1,3 +1,4 @@ +using System; using System.Diagnostics; namespace LogExpert; @@ -26,7 +27,7 @@ public void Execute (string keyword, string param, ILogExpertCallback callback, } else { - end = param.IndexOf(' '); + end = param.IndexOf(' ', StringComparison.Ordinal); } if (end == -1) @@ -39,14 +40,14 @@ public void Execute (string keyword, string param, ILogExpertCallback callback, lock (_callbackLock) { var parameters = param[end..].Trim(); - parameters = parameters.Replace("%F", callback.GetFileName()); - parameters = parameters.Replace("%K", keyword); + parameters = parameters.Replace("%F", callback.GetFileName(), StringComparison.Ordinal); + parameters = parameters.Replace("%K", keyword, StringComparison.Ordinal); var lineNumber = callback.GetLineNum(); //Line Numbers start at 0, but are displayed (+1) var logline = callback.GetLogLine(lineNumber).FullLine; - parameters = parameters.Replace("%L", string.Empty + lineNumber); - parameters = parameters.Replace("%T", callback.GetTabTitle()); - parameters = parameters.Replace("%C", logline); + parameters = parameters.Replace("%L", string.Empty + lineNumber, System.StringComparison.Ordinal); + parameters = parameters.Replace("%T", callback.GetTabTitle(), StringComparison.Ordinal); + parameters = parameters.Replace("%C", logline, StringComparison.Ordinal); Process explorer = new(); explorer.StartInfo.FileName = procName; diff --git a/src/JsonColumnizer/JsonColumnizer.cs b/src/JsonColumnizer/JsonColumnizer.cs index 04c6f071..48dacfea 100644 --- a/src/JsonColumnizer/JsonColumnizer.cs +++ b/src/JsonColumnizer/JsonColumnizer.cs @@ -1,12 +1,12 @@ -using LogExpert; - -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - using System; using System.Collections.Generic; using System.Linq; +using LogExpert; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + namespace JsonColumnizer; /// @@ -14,36 +14,28 @@ namespace JsonColumnizer; /// public class JsonColumnizer : ILogLineColumnizer, IInitColumnizer, IColumnizerPriority { - #region Fields - - private static readonly JsonColumn _initialColumn = new JsonColumn("Text"); - - private readonly IList _columnList = new List([InitialColumn]); - - #endregion - #region Properties public HashSet ColumnSet { get; set; } = []; - protected IList ColumnList => _columnList; + protected IList ColumnList { get; } = new List([InitialColumn]); - protected static JsonColumn InitialColumn => _initialColumn; + protected static JsonColumn InitialColumn { get; } = new JsonColumn("Text"); #endregion #region Public methods - public virtual void Selected(ILogLineColumnizerCallback callback) + public virtual void Selected (ILogLineColumnizerCallback callback) { ColumnList.Clear(); ColumnSet.Clear(); - var line = callback.GetLogLine(0); + ILogLine line = callback.GetLogLine(0); if (line != null) { - var json = ParseJson(line); + JObject json = ParseJson(line); if (json != null) { var fieldCount = json.Properties().Count(); @@ -51,52 +43,51 @@ public virtual void Selected(ILogLineColumnizerCallback callback) for (var i = 0; i < fieldCount; ++i) { var columeName = json.Properties().ToArray()[i].Name; - if (!ColumnSet.Contains(columeName)) + if (ColumnSet.Add(columeName)) { - ColumnSet.Add(columeName); ColumnList.Add(new JsonColumn(columeName)); } } } else { - ColumnSet.Add("Text"); + _ = ColumnSet.Add("Text"); ColumnList.Add(InitialColumn); } } - if (ColumnList.Count() == 0) + if (ColumnList.Count == 0) { - ColumnSet.Add("Text"); + _ = ColumnSet.Add("Text"); ColumnList.Add(InitialColumn); } } - public virtual void DeSelected(ILogLineColumnizerCallback callback) + public virtual void DeSelected (ILogLineColumnizerCallback callback) { // nothing to do } - public virtual string GetName() + public virtual string GetName () { return "JSON Columnizer"; } - public virtual string GetDescription() + public virtual string GetDescription () { return "Splits JSON files into columns.\r\n\r\nCredits:\r\nThis Columnizer uses the Newtonsoft json package.\r\n\r\nFirst line must be valid or else only one column will be displayed and the other values dropped!"; } - public virtual int GetColumnCount() + public virtual int GetColumnCount () { return ColumnList.Count; } - public virtual string[] GetColumnNames() + public virtual string[] GetColumnNames () { var names = new string[GetColumnCount()]; var i = 0; - foreach (var column in ColumnList) + foreach (JsonColumn column in ColumnList) { names[i++] = column.Name; } @@ -104,7 +95,7 @@ public virtual string[] GetColumnNames() return names; } - public virtual IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) + public virtual IColumnizedLogLine SplitLine (ILogLineColumnizerCallback callback, ILogLine line) { JObject json = ParseJson(line); @@ -115,7 +106,7 @@ public virtual IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, var cLogLine = new ColumnizedLogLine { LogLine = line }; - var columns = Column.CreateColumns(ColumnList.Count, cLogLine); + Column[] columns = Column.CreateColumns(ColumnList.Count, cLogLine); columns.Last().FullValue = line.FullLine; @@ -124,32 +115,32 @@ public virtual IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, return cLogLine; } - public virtual bool IsTimeshiftImplemented() + public virtual bool IsTimeshiftImplemented () { return false; } - public virtual void SetTimeOffset(int msecOffset) + public virtual void SetTimeOffset (int msecOffset) { throw new NotImplementedException(); } - public virtual int GetTimeOffset() + public virtual int GetTimeOffset () { throw new NotImplementedException(); } - public virtual DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) + public virtual DateTime GetTimestamp (ILogLineColumnizerCallback callback, ILogLine line) { throw new NotImplementedException(); } - public virtual void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) + public virtual void PushValue (ILogLineColumnizerCallback callback, int column, string value, string oldValue) { throw new NotImplementedException(); } - public virtual Priority GetPriority(string fileName, IEnumerable samples) + public virtual Priority GetPriority (string fileName, IEnumerable samples) { Priority result = Priority.NotSupport; if (fileName.EndsWith("json", StringComparison.OrdinalIgnoreCase)) @@ -164,7 +155,7 @@ public virtual Priority GetPriority(string fileName, IEnumerable sampl #region Private Methods - protected static JObject ParseJson(ILogLine line) + protected static JObject ParseJson (ILogLine line) { return JsonConvert.DeserializeObject(line.FullLine, new JsonSerializerSettings() { @@ -182,13 +173,13 @@ public class ColumnWithName : Column // {"time":"2019-02-13T02:55:35.5186240Z","message":"Hosting starting"} // {"time":"2019-02-13T02:55:35.5186240Z","level":"warning", "message":"invalid host."} // - protected virtual IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) + protected virtual IColumnizedLogLine SplitJsonLine (ILogLine line, JObject json) { var cLogLine = new ColumnizedLogLine { LogLine = line }; var columns = json.Properties().Select(property => new ColumnWithName { FullValue = property.Value.ToString(), ColumnName = property.Name.ToString(), Parent = cLogLine }).ToList(); - foreach (var jsonColumn in columns) + foreach (ColumnWithName jsonColumn in columns) { // When find new column in a log line, add a new column in the end of the list. if (!ColumnSet.Contains(jsonColumn.ColumnName)) @@ -198,7 +189,7 @@ protected virtual IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) ColumnList.Clear(); } - ColumnSet.Add(jsonColumn.ColumnName); + _ = ColumnSet.Add(jsonColumn.ColumnName); ColumnList.Add(new JsonColumn(jsonColumn.ColumnName)); } } @@ -208,9 +199,9 @@ protected virtual IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) // This will make sure the log line displayed correct even the order of json fields changed. // List returnColumns = []; - foreach (var column in ColumnList) + foreach (JsonColumn column in ColumnList) { - var existingColumn = columns.Find(x => x.ColumnName == column.Name); + ColumnWithName existingColumn = columns.Find(x => x.ColumnName == column.Name); if (existingColumn != null) { returnColumns.Add(new Column() { FullValue = existingColumn.FullValue, Parent = cLogLine }); diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs index 012bd06b..e02464fd 100644 --- a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs @@ -1,7 +1,3 @@ -using LogExpert; - -using Newtonsoft.Json; - using System; using System.Collections.Generic; using System.Globalization; @@ -11,6 +7,10 @@ using System.Runtime.Versioning; using System.Windows.Forms; +using LogExpert; + +using Newtonsoft.Json; + [assembly: SupportedOSPlatform("windows")] namespace Log4jXmlColumnizer; @@ -25,14 +25,14 @@ public class Log4jXmlColumnizer : ILogLineXmlColumnizer, IColumnizerConfigurator private readonly char separatorChar = '\xFFFD'; private readonly char[] trimChars = ['\xFFFD']; private Log4jXmlColumnizerConfig _config; - protected CultureInfo cultureInfo = new("de-DE"); - protected int timeOffset; + private readonly CultureInfo _cultureInfo = new("de-DE"); + private int _timeOffset; #endregion #region cTor - public Log4jXmlColumnizer() + public Log4jXmlColumnizer () { _config = new Log4jXmlColumnizerConfig(GetAllColumnNames()); } @@ -41,12 +41,12 @@ public Log4jXmlColumnizer() #region Public methods - public IXmlLogConfiguration GetXmlLogConfiguration() + public IXmlLogConfiguration GetXmlLogConfiguration () { return xmlConfig; } - public ILogLine GetLineTextForClipboard(ILogLine logLine, ILogLineColumnizerCallback callback) + public ILogLine GetLineTextForClipboard (ILogLine logLine, ILogLineColumnizerCallback callback) { Log4JLogLine line = new() { @@ -57,27 +57,27 @@ public ILogLine GetLineTextForClipboard(ILogLine logLine, ILogLineColumnizerCall return line; } - public string GetName() + public string GetName () { return "Log4j XML"; } - public string GetDescription() + public string GetDescription () { return "Reads and formats XML log files written with log4j."; } - public int GetColumnCount() + public int GetColumnCount () { return _config.ActiveColumnCount; } - public string[] GetColumnNames() + public string[] GetColumnNames () { return _config.ActiveColumnNames; } - public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) + public IColumnizedLogLine SplitLine (ILogLineColumnizerCallback callback, ILogLine line) { ColumnizedLogLine clogLine = new(); clogLine.LogLine = line; @@ -146,22 +146,22 @@ public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLin } - public bool IsTimeshiftImplemented() + public bool IsTimeshiftImplemented () { return true; } - public void SetTimeOffset(int msecOffset) + public void SetTimeOffset (int msecOffset) { - timeOffset = msecOffset; + _timeOffset = msecOffset; } - public int GetTimeOffset() + public int GetTimeOffset () { - return timeOffset; + return _timeOffset; } - public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) + public DateTime GetTimestamp (ILogLineColumnizerCallback callback, ILogLine line) { if (line.FullLine.Length < 15) { @@ -185,11 +185,11 @@ public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) DateTime dateTime = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); dateTime = dateTime.AddMilliseconds(timestamp); - if (_config.localTimestamps) + if (_config.LocalTimestamps) { dateTime = dateTime.ToLocalTime(); } - return dateTime.AddMilliseconds(timeOffset); + return dateTime.AddMilliseconds(_timeOffset); } else { @@ -202,17 +202,17 @@ public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) } } - public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) + public void PushValue (ILogLineColumnizerCallback callback, int column, string value, string oldValue) { if (column == 0) { try { - var newDateTime = DateTime.ParseExact(value, DATETIME_FORMAT, cultureInfo); - var oldDateTime = DateTime.ParseExact(oldValue, DATETIME_FORMAT, cultureInfo); + var newDateTime = DateTime.ParseExact(value, DATETIME_FORMAT, _cultureInfo); + var oldDateTime = DateTime.ParseExact(oldValue, DATETIME_FORMAT, _cultureInfo); var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; - timeOffset = (int)(mSecsNew - mSecsOld); + _timeOffset = (int)(mSecsNew - mSecsOld); } catch (FormatException) { @@ -220,7 +220,7 @@ public void PushValue(ILogLineColumnizerCallback callback, int column, string va } } - public void Configure(ILogLineColumnizerCallback callback, string configDir) + public void Configure (ILogLineColumnizerCallback callback, string configDir) { FileInfo fileInfo = new(configDir + Path.DirectorySeparatorChar + "log4jxmlcolumnizer.json"); @@ -234,7 +234,7 @@ public void Configure(ILogLineColumnizerCallback callback, string configDir) } } - public void LoadConfig(string configDir) + public void LoadConfig (string configDir) { var configPath = configDir + Path.DirectorySeparatorChar + "log4jxmlcolumnizer.json"; @@ -249,7 +249,7 @@ public void LoadConfig(string configDir) try { _config = JsonConvert.DeserializeObject(File.ReadAllText($"{fileInfo.FullName}")); - if (_config.columnList.Count < COLUMN_COUNT) + if (_config.ColumnList.Count < COLUMN_COUNT) { _config = new Log4jXmlColumnizerConfig(GetAllColumnNames()); } @@ -262,7 +262,7 @@ public void LoadConfig(string configDir) } } - public Priority GetPriority(string fileName, IEnumerable samples) + public Priority GetPriority (string fileName, IEnumerable samples) { Priority result = Priority.NotSupport; if (fileName.EndsWith("xml", StringComparison.OrdinalIgnoreCase)) @@ -276,18 +276,18 @@ public Priority GetPriority(string fileName, IEnumerable samples) #region Private Methods - private string[] GetAllColumnNames() => ["Timestamp", "Level", "Logger", "Thread", "Class", "Method", "File", "Line", "Message"]; + private string[] GetAllColumnNames () => ["Timestamp", "Level", "Logger", "Thread", "Class", "Method", "File", "Line", "Message"]; /// /// Returns only the columns which are "active". The order of the columns depends on the column order in the config /// /// /// - private Column[] MapColumns(Column[] cols) + private Column[] MapColumns (Column[] cols) { List output = []; var index = 0; - foreach (Log4jColumnEntry entry in _config.columnList) + foreach (Log4jColumnEntry entry in _config.ColumnList) { if (entry.Visible) { @@ -296,7 +296,7 @@ private Column[] MapColumns(Column[] cols) if (entry.MaxLen > 0 && column.FullValue.Length > entry.MaxLen) { - column.FullValue = column.FullValue.Substring(column.FullValue.Length - entry.MaxLen); + column.FullValue = column.FullValue[^entry.MaxLen..]; } } index++; diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfig.cs b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfig.cs index 186a7cfd..3d070108 100644 --- a/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfig.cs +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfig.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; namespace Log4jXmlColumnizer; @@ -6,16 +6,9 @@ namespace Log4jXmlColumnizer; [Serializable] public class Log4jXmlColumnizerConfig { - #region Fields - - public List columnList = []; - public bool localTimestamps = true; - - #endregion - #region cTor - public Log4jXmlColumnizerConfig(string[] columnNames) + public Log4jXmlColumnizerConfig (string[] columnNames) { FillDefaults(columnNames); } @@ -33,13 +26,14 @@ public int ActiveColumnCount get { var count = 0; - foreach (Log4jColumnEntry entry in columnList) + foreach (Log4jColumnEntry entry in ColumnList) { if (entry.Visible) { count++; } } + return count; } } @@ -53,27 +47,32 @@ public string[] ActiveColumnNames { var names = new string[ActiveColumnCount]; var index = 0; - foreach (Log4jColumnEntry entry in columnList) + foreach (Log4jColumnEntry entry in ColumnList) { if (entry.Visible) { names[index++] = entry.ColumnName; } } + return names; } } + public List ColumnList { get; set; } = []; + + public bool LocalTimestamps { get; set; } = true; + #endregion #region Public methods - public void FillDefaults(string[] columnNames) + public void FillDefaults (string[] columnNames) { - columnList.Clear(); + ColumnList.Clear(); for (var i = 0; i < columnNames.Length; ++i) { - columnList.Add(new Log4jColumnEntry(columnNames[i], i, 0)); + ColumnList.Add(new Log4jColumnEntry(columnNames[i], i, 0)); } } diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs index a07ff9b3..00fc2a71 100644 --- a/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs @@ -25,7 +25,7 @@ public Log4jXmlColumnizerConfigDlg(Log4jXmlColumnizerConfig config) _config = config; InitializeComponent(); FillListBox(); - localTimeCheckBox.Checked = _config.localTimestamps; + localTimeCheckBox.Checked = _config.LocalTimestamps; ResumeLayout(); } @@ -39,7 +39,7 @@ private void FillListBox() var nameColumn = (DataGridViewTextBoxColumn)columnGridView.Columns[1]; var lenColumn = (DataGridViewTextBoxColumn)columnGridView.Columns[2]; - foreach (Log4jColumnEntry entry in _config.columnList) + foreach (Log4jColumnEntry entry in _config.ColumnList) { DataGridViewRow row = new(); row.Cells.Add(new DataGridViewCheckBoxCell()); @@ -64,19 +64,19 @@ private void OkButton_Click(object sender, EventArgs e) // } for (var i = 0; i < columnGridView.Rows.Count; ++i) { - _config.columnList[i].Visible = (bool)columnGridView.Rows[i].Cells[0].Value; + _config.ColumnList[i].Visible = (bool)columnGridView.Rows[i].Cells[0].Value; var sLen = (string)columnGridView.Rows[i].Cells[2].Value; if (int.TryParse(sLen, out var len)) { - _config.columnList[i].MaxLen = len; + _config.ColumnList[i].MaxLen = len; } else { - _config.columnList[i].MaxLen = 0; + _config.ColumnList[i].MaxLen = 0; } } - _config.localTimestamps = localTimeCheckBox.Checked; + _config.LocalTimestamps = localTimeCheckBox.Checked; } #endregion diff --git a/src/LogExpert.Core/Classes/Columnizer/ClfColumnizer.cs b/src/LogExpert.Core/Classes/Columnizer/ClfColumnizer.cs index d5cf9614..433eda96 100644 --- a/src/LogExpert.Core/Classes/Columnizer/ClfColumnizer.cs +++ b/src/LogExpert.Core/Classes/Columnizer/ClfColumnizer.cs @@ -1,26 +1,25 @@ -using System; using System.Globalization; -using System.Linq; using System.Text.RegularExpressions; namespace LogExpert.Core.Classes.Columnizer; public class ClfColumnizer : ILogLineColumnizer { + private const string DateTimeFormat = "dd/MMM/yyyy:HH:mm:ss zzz"; #region Fields - private readonly Regex lineRegex = new("(.*) (-) (.*) (\\[.*\\]) (\".*\") (.*) (.*) (\".*\") (\".*\")"); + private readonly Regex _lineRegex = new("(.*) (-) (.*) (\\[.*\\]) (\".*\") (.*) (.*) (\".*\") (\".*\")"); - protected CultureInfo cultureInfo = new("de-DE"); - protected int timeOffset; + private readonly CultureInfo _cultureInfo = new("en-US"); + private int _timeOffset; #endregion #region cTor - // anon-212-34-174-126.suchen.de - - [08/Mar/2008:00:41:10 +0100] "GET /wiki/index.php?title=Bild:Poster_small.jpg&printable=yes&printable=yes HTTP/1.1" 304 0 "http://www.captain-kloppi.de/wiki/index.php?title=Bild:Poster_small.jpg&printable=yes" "gonzo1[P] +http://www.suchen.de/faq.html" + // anon-212-34-174-126.suchen.de - - [08/Mar/2008:00:41:10 +0100] "GET /wiki/index.php?title=Bild:Poster_small.jpg&printable=yes&printable=yes HTTP/1.1" 304 0 "http://www.captain-kloppi.de/wiki/index.php?title=Bild:Poster_small.jpg&printable=yes" "gonzo1[P] +http://www.suchen.de/faq.html" - public ClfColumnizer() + public ClfColumnizer () { } @@ -28,22 +27,22 @@ public ClfColumnizer() #region Public methods - public bool IsTimeshiftImplemented() + public bool IsTimeshiftImplemented () { return true; } - public void SetTimeOffset(int msecOffset) + public void SetTimeOffset (int msecOffset) { - timeOffset = msecOffset; + _timeOffset = msecOffset; } - public int GetTimeOffset() + public int GetTimeOffset () { - return timeOffset; + return _timeOffset; } - public DateTime GetTimestamp(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + public DateTime GetTimestamp (ILogLineColumnizerCallback callback, ILogLine line) { IColumnizedLogLine cols = SplitLine(callback, line); if (cols == null || cols.ColumnValues.Length < 8) @@ -58,8 +57,7 @@ public DateTime GetTimestamp(LogExpert.ILogLineColumnizerCallback callback, ILog try { - var dateTime = DateTime.ParseExact(cols.ColumnValues[2].FullValue, "dd/MMM/yyyy:HH:mm:ss zzz", - new CultureInfo("en-US")); + var dateTime = DateTime.ParseExact(cols.ColumnValues[2].FullValue, DateTimeFormat, _cultureInfo); return dateTime; } catch (Exception) @@ -68,19 +66,19 @@ public DateTime GetTimestamp(LogExpert.ILogLineColumnizerCallback callback, ILog } } - public void PushValue(LogExpert.ILogLineColumnizerCallback callback, int column, string value, string oldValue) + public void PushValue (ILogLineColumnizerCallback callback, int column, string value, string oldValue) { if (column == 2) { try { var newDateTime = - DateTime.ParseExact(value, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US")); + DateTime.ParseExact(value, DateTimeFormat, _cultureInfo); var oldDateTime = - DateTime.ParseExact(oldValue, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US")); + DateTime.ParseExact(oldValue, DateTimeFormat, _cultureInfo); var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; - timeOffset = (int)(mSecsNew - mSecsOld); + _timeOffset = (int)(mSecsNew - mSecsOld); } catch (FormatException) { @@ -88,27 +86,27 @@ public void PushValue(LogExpert.ILogLineColumnizerCallback callback, int column, } } - public string GetName() + public string GetName () { return "Webserver CLF Columnizer"; } - public string GetDescription() + public string GetDescription () { return "Common Logfile Format used by webservers."; } - public int GetColumnCount() + public int GetColumnCount () { return 8; } - public string[] GetColumnNames() + public string[] GetColumnNames () { return ["IP", "User", "Date/Time", "Request", "Status", "Bytes", "Referrer", "User agent"]; } - public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + public IColumnizedLogLine SplitLine (ILogLineColumnizerCallback callback, ILogLine line) { ColumnizedLogLine cLogLine = new() { @@ -132,17 +130,17 @@ public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callbac var temp = line.FullLine; if (temp.Length > 1024) { - // spam - temp = temp.Substring(0, 1024); + // spam + temp = temp[..1024]; columns[3].FullValue = temp; return cLogLine; } // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 - // anon-212-34-174-126.suchen.de - - [08/Mar/2008:00:41:10 +0100] "GET /wiki/index.php?title=Bild:Poster_small.jpg&printable=yes&printable=yes HTTP/1.1" 304 0 "http://www.captain-kloppi.de/wiki/index.php?title=Bild:Poster_small.jpg&printable=yes" "gonzo1[P] +http://www.suchen.de/faq.html" + // anon-212-34-174-126.suchen.de - - [08/Mar/2008:00:41:10 +0100] "GET /wiki/index.php?title=Bild:Poster_small.jpg&printable=yes&printable=yes HTTP/1.1" 304 0 "http://www.captain-kloppi.de/wiki/index.php?title=Bild:Poster_small.jpg&printable=yes" "gonzo1[P] +http://www.suchen.de/faq.html" - if (lineRegex.IsMatch(temp)) + if (_lineRegex.IsMatch(temp)) { - Match match = lineRegex.Match(temp); + Match match = _lineRegex.Match(temp); GroupCollection groups = match.Groups; if (groups.Count == 10) { @@ -159,15 +157,13 @@ public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callbac // dirty probing of date/time format (much faster than DateTime.ParseExact() if (dateTimeStr[2] == '/' && dateTimeStr[6] == '/' && dateTimeStr[11] == ':') { - if (timeOffset != 0) + if (_timeOffset != 0) { try { - var dateTime = DateTime.ParseExact(dateTimeStr, "dd/MMM/yyyy:HH:mm:ss zzz", - new CultureInfo("en-US")); - dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); - var newDate = dateTime.ToString("dd/MMM/yyyy:HH:mm:ss zzz", - new CultureInfo("en-US")); + var dateTime = DateTime.ParseExact(dateTimeStr, DateTimeFormat, _cultureInfo); + dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, _timeOffset)); + var newDate = dateTime.ToString(DateTimeFormat, _cultureInfo); columns[2].FullValue = newDate; } catch (Exception) diff --git a/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs b/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs index 33cf2ac8..227fe06e 100644 --- a/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs +++ b/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs @@ -1,16 +1,16 @@ -using LogExpert.Core.Entities; - using System.Reflection; +using LogExpert.Core.Entities; + namespace LogExpert.Core.Classes.Columnizer; public class ColumnizerPicker { - public static ILogLineColumnizer FindColumnizerByName(string name, IList list) + public static ILogLineColumnizer FindColumnizerByName (string name, IList list) { foreach (ILogLineColumnizer columnizer in list) { - if (columnizer.GetName().Equals(name)) + if (columnizer.GetName().Equals(name, StringComparison.Ordinal)) { return columnizer; } @@ -18,11 +18,11 @@ public static ILogLineColumnizer FindColumnizerByName(string name, IList list) + public static ILogLineColumnizer DecideColumnizerByName (string name, IList list) { foreach (ILogLineColumnizer columnizer in list) { - if (columnizer.GetName().Equals(name)) + if (columnizer.GetName().Equals(name, StringComparison.Ordinal)) { return columnizer; } @@ -31,7 +31,7 @@ public static ILogLineColumnizer DecideColumnizerByName(string name, IList /// /// - public static ILogLineColumnizer FindReplacementForAutoColumnizer(string fileName, + public static ILogLineColumnizer FindReplacementForAutoColumnizer (string fileName, IAutoLogLineColumnizerCallback logFileReader, ILogLineColumnizer logLineColumnizer, IList list) @@ -72,7 +72,7 @@ public static ILogLineColumnizer FindReplacementForAutoColumnizer(string fileNam return logLineColumnizer; } - public static ILogLineColumnizer FindBetterColumnizer(string fileName, + public static ILogLineColumnizer FindBetterColumnizer (string fileName, IAutoLogLineColumnizerCallback logFileReader, ILogLineColumnizer logLineColumnizer, IList list) @@ -93,7 +93,7 @@ public static ILogLineColumnizer FindBetterColumnizer(string fileName, /// /// /// - public static ILogLineColumnizer FindColumnizer(string fileName, IAutoLogLineColumnizerCallback logFileReader, IList list) + public static ILogLineColumnizer FindColumnizer (string fileName, IAutoLogLineColumnizerCallback logFileReader, IList list) { if (string.IsNullOrEmpty(fileName)) { diff --git a/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs b/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs index 769cf4c4..36c733ca 100644 --- a/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs +++ b/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs @@ -8,8 +8,8 @@ public class SquareBracketColumnizer : ILogLineColumnizer, IColumnizerPriority { #region ILogLineColumnizer implementation - protected int timeOffset; - private TimeFormatDeterminer _timeFormatDeterminer = new(); + private int _timeOffset; + private readonly TimeFormatDeterminer _timeFormatDeterminer = new(); // TODO: need preparing this columnizer with sample log lines before use it. private int _columnCount = 5; @@ -38,15 +38,15 @@ public bool IsTimeshiftImplemented () public void SetTimeOffset (int msecOffset) { - timeOffset = msecOffset; + _timeOffset = msecOffset; } public int GetTimeOffset () { - return timeOffset; + return _timeOffset; } - public DateTime GetTimestamp (LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + public DateTime GetTimestamp (ILogLineColumnizerCallback callback, ILogLine line) { IColumnizedLogLine cols = SplitLine(callback, line); if (cols == null || cols.ColumnValues == null || cols.ColumnValues.Length < 2) @@ -78,7 +78,7 @@ public DateTime GetTimestamp (LogExpert.ILogLineColumnizerCallback callback, ILo } } - public void PushValue (LogExpert.ILogLineColumnizerCallback callback, int column, string value, string oldValue) + public void PushValue (ILogLineColumnizerCallback callback, int column, string value, string oldValue) { if (column == 1) { @@ -94,7 +94,7 @@ public void PushValue (LogExpert.ILogLineColumnizerCallback callback, int column var oldDateTime = DateTime.ParseExact(oldValue, formatInfo.TimeFormat, formatInfo.CultureInfo); var mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond; var mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond; - timeOffset = (int)(mSecsNew - mSecsOld); + _timeOffset = (int)(mSecsNew - mSecsOld); } catch (FormatException) { @@ -187,11 +187,11 @@ public IColumnizedLogLine SplitLine (LogExpert.ILogLineColumnizerCallback callba var dateLen = formatInfo.DateFormat.Length; try { - if (timeOffset != 0) + if (_timeOffset != 0) { - var dateTime = DateTime.ParseExact(temp.Substring(0, endPos), formatInfo.DateTimeFormat, + var dateTime = DateTime.ParseExact(temp[..endPos], formatInfo.DateTimeFormat, formatInfo.CultureInfo); - dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, timeOffset)); + dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, _timeOffset)); var newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo); SquareSplit(ref columns, newDate, dateLen, timeLen, endPos, clogLine); @@ -220,7 +220,7 @@ void SquareSplit (ref Column[] columns, string line, int dateLen, int timeLen, i var restColumn = _columnCount; if (_isTimeExists) { - columnList.Add(new Column { FullValue = line.Substring(0, dateLen), Parent = clogLine }); + columnList.Add(new Column { FullValue = line[..dateLen], Parent = clogLine }); columnList.Add(new Column { FullValue = line.Substring(dateLen + 1, timeLen), Parent = clogLine }); restColumn -= 2; } @@ -231,17 +231,17 @@ void SquareSplit (ref Column[] columns, string line, int dateLen, int timeLen, i for (var i = 0; i < restColumn; i++) { - rest = rest.Substring(nextPos); + rest = rest[nextPos..]; //var fullValue = rest.Substring(0, rest.IndexOf(']')).TrimStart(new char[] {' '}).TrimEnd(new char[] { ' ' }); var trimmed = rest.TrimStart([' ']); - if (string.IsNullOrEmpty(trimmed) || trimmed[0] != '[' || rest.IndexOf(']') < 0 || i == restColumn - 1) + if (string.IsNullOrEmpty(trimmed) || trimmed[0] != '[' || rest.IndexOf(']', StringComparison.Ordinal) < 0 || i == restColumn - 1) { columnList.Add(new Column { FullValue = rest, Parent = clogLine }); break; } - nextPos = rest.IndexOf(']') + 1; - var fullValue = rest.Substring(0, nextPos); + nextPos = rest.IndexOf(']', StringComparison.Ordinal) + 1; + var fullValue = rest[..nextPos]; columnList.Add(new Column { FullValue = fullValue, Parent = clogLine }); } @@ -261,7 +261,7 @@ public Priority GetPriority (string fileName, IEnumerable samples) var bracketsExistsCount = 0; var maxBracketNumbers = 1; - foreach (var logline in samples) + foreach (ILogLine logline in samples) { var line = logline?.FullLine; if (string.IsNullOrEmpty(line)) @@ -279,9 +279,9 @@ public Priority GetPriority (string fileName, IEnumerable samples) timeStampExistsCount--; } - var noSpaceLine = line.Replace(" ", string.Empty); - if (noSpaceLine.IndexOf('[') >= 0 && noSpaceLine.IndexOf(']') >= 0 - && noSpaceLine.IndexOf('[') < noSpaceLine.IndexOf(']')) + var noSpaceLine = line.Replace(" ", string.Empty, StringComparison.Ordinal); + if (noSpaceLine.Contains('[', StringComparison.Ordinal) && noSpaceLine.Contains(']', StringComparison.Ordinal) + && noSpaceLine.IndexOf('[', StringComparison.Ordinal) < noSpaceLine.IndexOf(']', StringComparison.Ordinal)) { bracketNumbers += Regex.Matches(noSpaceLine, @"\]\[").Count; bracketsExistsCount++; diff --git a/src/LogExpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs b/src/LogExpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs index cf438dc1..a0a21f38 100644 --- a/src/LogExpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs +++ b/src/LogExpert.Core/Classes/Columnizer/TimeFormatDeterminer.cs @@ -1,4 +1,4 @@ -using System.Globalization; +using System.Globalization; namespace LogExpert.Core.Classes.Columnizer; @@ -6,26 +6,16 @@ internal class TimeFormatDeterminer { #region FormatInfo helper class - public class FormatInfo + public class FormatInfo (string dateFormat, string timeFormat, CultureInfo cultureInfo) { - #region cTor - - public FormatInfo(string dateFormat, string timeFormat, CultureInfo cultureInfo) - { - DateFormat = dateFormat; - TimeFormat = timeFormat; - CultureInfo = cultureInfo; - } - - #endregion #region Properties - public string DateFormat { get; } + public string DateFormat { get; } = dateFormat; - public string TimeFormat { get; } + public string TimeFormat { get; } = timeFormat; - public CultureInfo CultureInfo { get; } + public CultureInfo CultureInfo { get; } = cultureInfo; public string DateTimeFormat => DateFormat + " " + TimeFormat; @@ -36,30 +26,30 @@ public FormatInfo(string dateFormat, string timeFormat, CultureInfo cultureInfo) #endregion - protected FormatInfo formatInfo1 = new("dd.MM.yyyy", "HH:mm:ss.fff", new CultureInfo("de-DE")); - protected FormatInfo formatInfo2 = new("dd.MM.yyyy", "HH:mm:ss", new CultureInfo("de-DE")); - protected FormatInfo formatInfo3 = new("yyyy/MM/dd", "HH:mm:ss.fff", new CultureInfo("en-US")); - protected FormatInfo formatInfo4 = new("yyyy/MM/dd", "HH:mm:ss", new CultureInfo("en-US")); - protected FormatInfo formatInfo5 = new("yyyy.MM.dd", "HH:mm:ss.fff", new CultureInfo("de-DE")); - protected FormatInfo formatInfo6 = new("yyyy.MM.dd", "HH:mm:ss", new CultureInfo("de-DE")); - protected FormatInfo formatInfo7 = new("dd.MM.yyyy", "HH:mm:ss,fff", new CultureInfo("de-DE")); - protected FormatInfo formatInfo8 = new("yyyy/MM/dd", "HH:mm:ss,fff", new CultureInfo("en-US")); - protected FormatInfo formatInfo9 = new("yyyy.MM.dd", "HH:mm:ss,fff", new CultureInfo("de-DE")); - protected FormatInfo formatInfo10 = new("yyyy-MM-dd", "HH:mm:ss.fff", new CultureInfo("en-US")); - protected FormatInfo formatInfo11 = new("yyyy-MM-dd", "HH:mm:ss,fff", new CultureInfo("en-US")); - protected FormatInfo formatInfo12 = new("yyyy-MM-dd", "HH:mm:ss", new CultureInfo("en-US")); - protected FormatInfo formatInfo13 = new("dd MMM yyyy", "HH:mm:ss,fff", new CultureInfo("de-DE")); - protected FormatInfo formatInfo14 = new("dd MMM yyyy", "HH:mm:ss.fff", new CultureInfo("de-DE")); - protected FormatInfo formatInfo15 = new("dd MMM yyyy", "HH:mm:ss", new CultureInfo("de-DE")); - protected FormatInfo formatInfo16 = new("dd.MM.yy", "HH:mm:ss.fff", new CultureInfo("de-DE")); - protected FormatInfo formatInfo17 = new("yyyy-MM-dd", "HH:mm:ss:ffff", new CultureInfo("en-US")); - protected FormatInfo formatInfo18 = new("dd/MM/yyyy", "HH:mm:ss.fff", new CultureInfo("en-US")); - protected FormatInfo formatInfo19 = new("dd/MM/yyyy", "HH:mm:ss:fff", new CultureInfo("en-US")); - protected FormatInfo formatInfo20 = new("yyyy-MM-dd", "HH:mm:ss.ffff", new CultureInfo("en-US")); - protected FormatInfo formatInfo21 = new("yyyy-MM-dd", "HH:mm:ss,ffff", new CultureInfo("en-US")); - - - public FormatInfo DetermineDateTimeFormatInfo(string line) + private readonly FormatInfo formatInfo1 = new("dd.MM.yyyy", "HH:mm:ss.fff", new CultureInfo("de-DE")); + private readonly FormatInfo formatInfo2 = new("dd.MM.yyyy", "HH:mm:ss", new CultureInfo("de-DE")); + private readonly FormatInfo formatInfo3 = new("yyyy/MM/dd", "HH:mm:ss.fff", new CultureInfo("en-US")); + private readonly FormatInfo formatInfo4 = new("yyyy/MM/dd", "HH:mm:ss", new CultureInfo("en-US")); + private readonly FormatInfo formatInfo5 = new("yyyy.MM.dd", "HH:mm:ss.fff", new CultureInfo("de-DE")); + private readonly FormatInfo formatInfo6 = new("yyyy.MM.dd", "HH:mm:ss", new CultureInfo("de-DE")); + private readonly FormatInfo formatInfo7 = new("dd.MM.yyyy", "HH:mm:ss,fff", new CultureInfo("de-DE")); + private readonly FormatInfo formatInfo8 = new("yyyy/MM/dd", "HH:mm:ss,fff", new CultureInfo("en-US")); + private readonly FormatInfo formatInfo9 = new("yyyy.MM.dd", "HH:mm:ss,fff", new CultureInfo("de-DE")); + private readonly FormatInfo formatInfo10 = new("yyyy-MM-dd", "HH:mm:ss.fff", new CultureInfo("en-US")); + private readonly FormatInfo formatInfo11 = new("yyyy-MM-dd", "HH:mm:ss,fff", new CultureInfo("en-US")); + private readonly FormatInfo formatInfo12 = new("yyyy-MM-dd", "HH:mm:ss", new CultureInfo("en-US")); + private readonly FormatInfo formatInfo13 = new("dd MMM yyyy", "HH:mm:ss,fff", new CultureInfo("de-DE")); + private readonly FormatInfo formatInfo14 = new("dd MMM yyyy", "HH:mm:ss.fff", new CultureInfo("de-DE")); + private readonly FormatInfo formatInfo15 = new("dd MMM yyyy", "HH:mm:ss", new CultureInfo("de-DE")); + private readonly FormatInfo formatInfo16 = new("dd.MM.yy", "HH:mm:ss.fff", new CultureInfo("de-DE")); + private readonly FormatInfo formatInfo17 = new("yyyy-MM-dd", "HH:mm:ss:ffff", new CultureInfo("en-US")); + private readonly FormatInfo formatInfo18 = new("dd/MM/yyyy", "HH:mm:ss.fff", new CultureInfo("en-US")); + private readonly FormatInfo formatInfo19 = new("dd/MM/yyyy", "HH:mm:ss:fff", new CultureInfo("en-US")); + private readonly FormatInfo formatInfo20 = new("yyyy-MM-dd", "HH:mm:ss.ffff", new CultureInfo("en-US")); + private readonly FormatInfo formatInfo21 = new("yyyy-MM-dd", "HH:mm:ss,ffff", new CultureInfo("en-US")); + + + public FormatInfo DetermineDateTimeFormatInfo (string line) { if (line.Length < 21) { @@ -70,9 +60,9 @@ public FormatInfo DetermineDateTimeFormatInfo(string line) var ignoreFirst = false; // determine if string starts with bracket and remove it - if (temp[0] == '[' || temp[0] == '(' || temp[0] == '{') + if (temp[0] is '[' or '(' or '{') { - temp = temp.Substring(1); + temp = temp[1..]; ignoreFirst = true; } @@ -212,7 +202,7 @@ public FormatInfo DetermineDateTimeFormatInfo(string line) return null; } - public FormatInfo DetermineTimeFormatInfo(string field) + public FormatInfo DetermineTimeFormatInfo (string field) { // dirty hardcoded probing of time format (much faster than DateTime.ParseExact() if (field[2] == ':' && field[5] == ':') @@ -233,6 +223,7 @@ public FormatInfo DetermineTimeFormatInfo(string field) return formatInfo2; } } + return null; } } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Filter/FilterParams.cs b/src/LogExpert.Core/Classes/Filter/FilterParams.cs index 57ff7ec2..4daf42c5 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterParams.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterParams.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System.Collections; using System.Drawing; using System.Text.Json.Serialization; using System.Text.RegularExpressions; @@ -111,7 +111,7 @@ public string RangeSearchText /// Returns a new FilterParams object with the current columnizer set to the one used in this object. /// /// - public FilterParams CloneWithCurrentColumnizer() + public FilterParams CloneWithCurrentColumnizer () { FilterParams newParams = Clone(); newParams.Init(); @@ -122,22 +122,22 @@ public FilterParams CloneWithCurrentColumnizer() } // call after deserialization! - public void Init() + public void Init () { LastNonEmptyCols = []; - LowerRangeSearchText = RangeSearchText.ToLower(); - LowerSearchText = SearchText.ToLower(); + LowerRangeSearchText = RangeSearchText.ToLowerInvariant(); + LowerSearchText = SearchText.ToLowerInvariant(); LastLine = string.Empty; } // Reset before a new search - public void Reset() + public void Reset () { LastNonEmptyCols.Clear(); IsInRange = false; } - public void CreateRegex() + public void CreateRegex () { if (SearchText != null) { @@ -153,7 +153,7 @@ public void CreateRegex() /// Shallow Copy /// /// - public FilterParams Clone() + public FilterParams Clone () { return (FilterParams)MemberwiseClone(); } @@ -162,7 +162,7 @@ public FilterParams Clone() /// Shallow Copy /// /// - object ICloneable.Clone() + object ICloneable.Clone () { return Clone(); } diff --git a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs index 7a2ba26a..efa6a886 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs @@ -160,7 +160,7 @@ private Filter DoWork (FilterParams filterParams, int startLine, int maxCount, P } _ = filter.DoFilter(threadFilterParams, startLine, maxCount, progressCallback); - _logger.Info("Filter worker [{0}] for line {1} has completed.", Thread.CurrentThread.ManagedThreadId, startLine); + _logger.Info("Filter worker [{0}] for line {1} has completed.", Environment.CurrentManagedThreadId, startLine); lock (_filterReadyList) { diff --git a/src/LogExpert.Core/Classes/Log/LogfileReader.cs b/src/LogExpert.Core/Classes/Log/LogfileReader.cs index 87be8741..f895c283 100644 --- a/src/LogExpert.Core/Classes/Log/LogfileReader.cs +++ b/src/LogExpert.Core/Classes/Log/LogfileReader.cs @@ -853,7 +853,7 @@ private void ReplaceBufferInfos (ILogFileInfo oldLogFileInfo, ILogFileInfo newLo { if (buffer.FileInfo == oldLogFileInfo) { - _logger.Debug("Buffer with startLine={0}, lineCount={1}, filePos={2}, size={3} gets new filename {4}", buffer.StartLine, buffer.LineCount, buffer.StartPos, buffer.Size, newLogFileInfo.FullName); + _logger.Debug($"Buffer with startLine={buffer.StartLine}, lineCount={buffer.LineCount}, filePos={buffer.StartPos}, size={buffer.Size} gets new filename {newLogFileInfo.FullName}"); buffer.FileInfo = newLogFileInfo; } } @@ -863,7 +863,7 @@ private void ReplaceBufferInfos (ILogFileInfo oldLogFileInfo, ILogFileInfo newLo private LogBuffer DeleteBuffersForInfo (ILogFileInfo ILogFileInfo, bool matchNamesOnly) { - _logger.Info("Deleting buffers for file {0}", ILogFileInfo.FullName); + _logger.Info($"Deleting buffers for file {ILogFileInfo.FullName}"); LogBuffer lastRemovedBuffer = null; IList deleteList = []; AcquireBufferListWriterLock(); @@ -872,7 +872,7 @@ private LogBuffer DeleteBuffersForInfo (ILogFileInfo ILogFileInfo, bool matchNam { foreach (LogBuffer buffer in _bufferList) { - if (buffer.FileInfo.FullName.ToLower().Equals(ILogFileInfo.FullName.ToLower())) + if (buffer.FileInfo.FullName.Equals(ILogFileInfo.FullName, StringComparison.Ordinal)) { lastRemovedBuffer = buffer; deleteList.Add(buffer); @@ -938,9 +938,11 @@ private void ReadToBufferList (ILogFileInfo logFileInfo, long filePos, int start AcquireBufferListReaderLock(); if (_bufferList.Count == 0) { - logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER); - logBuffer.StartLine = startLine; - logBuffer.StartPos = filePos; + logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER) + { + StartLine = startLine, + StartPos = filePos + }; LockCookie cookie = UpgradeBufferListLockToWriter(); AddBufferToList(logBuffer); DowngradeBufferListLockFromWriter(ref cookie); @@ -949,11 +951,13 @@ private void ReadToBufferList (ILogFileInfo logFileInfo, long filePos, int start { logBuffer = _bufferList[_bufferList.Count - 1]; - if (!logBuffer.FileInfo.FullName.Equals(logFileInfo.FullName)) + if (!logBuffer.FileInfo.FullName.Equals(logFileInfo.FullName, StringComparison.Ordinal)) { - logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER); - logBuffer.StartLine = startLine; - logBuffer.StartPos = filePos; + logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER) + { + StartLine = startLine, + StartPos = filePos + }; LockCookie cookie = UpgradeBufferListLockToWriter(); AddBufferToList(logBuffer); DowngradeBufferListLockFromWriter(ref cookie); diff --git a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs index dd142b44..00a130d0 100644 --- a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs +++ b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs @@ -1,7 +1,7 @@ -using LogExpert.Core.Entities; - using System.Text; +using LogExpert.Core.Entities; + namespace LogExpert.Core.Classes.Log; public abstract class PositionAwareStreamReaderBase : LogStreamReaderBase @@ -24,7 +24,7 @@ public abstract class PositionAwareStreamReaderBase : LogStreamReaderBase #region cTor - protected PositionAwareStreamReaderBase(Stream stream, EncodingOptions encodingOptions) + protected PositionAwareStreamReaderBase (Stream stream, EncodingOptions encodingOptions) { _stream = new BufferedStream(stream); @@ -82,7 +82,7 @@ public sealed override long Position /// Destroy and release the current stream reader. /// /// Specifies whether or not the managed objects should be released. - protected override void Dispose(bool disposing) + protected override void Dispose (bool disposing) { if (disposing) { @@ -92,13 +92,9 @@ protected override void Dispose(bool disposing) } //TODO This is unsafe and should be refactored - public override unsafe int ReadChar() + public override unsafe int ReadChar () { - //ObjectDisposedException.ThrowIf - if (IsDisposed) - { - throw new ObjectDisposedException(ToString()); - } + ObjectDisposedException.ThrowIf(true, ToString()); try { @@ -123,17 +119,19 @@ public override unsafe int ReadChar() } } - protected virtual void ResetReader() + protected virtual void ResetReader () { _reader.DiscardBufferedData(); } - protected StreamReader GetStreamReader() + protected StreamReader GetStreamReader () { - return IsDisposed ? throw new ObjectDisposedException(ToString()) : _reader; + return IsDisposed + ? throw new ObjectDisposedException(ToString()) + : _reader; } - protected void MovePosition(int offset) + protected void MovePosition (int offset) { _position += offset; } @@ -146,7 +144,7 @@ protected void MovePosition(int offset) /// Determines the actual number of preamble bytes in the file. /// /// Number of preamble bytes in the file - private int DetectPreambleLengthAndEncoding(out Encoding detectedEncoding) + private int DetectPreambleLengthAndEncoding (out Encoding detectedEncoding) { /* UTF-8: EF BB BF @@ -189,7 +187,7 @@ private int DetectPreambleLengthAndEncoding(out Encoding detectedEncoding) return 0; } - private Encoding GetUsedEncoding(EncodingOptions encodingOptions, Encoding detectedEncoding) + private Encoding GetUsedEncoding (EncodingOptions encodingOptions, Encoding detectedEncoding) { if (encodingOptions.Encoding != null) { @@ -203,15 +201,15 @@ private Encoding GetUsedEncoding(EncodingOptions encodingOptions, Encoding detec return encodingOptions.DefaultEncoding ?? Encoding.Default; } - private int GetPosIncPrecomputed(Encoding usedEncoding) + private int GetPosIncPrecomputed (Encoding usedEncoding) { switch (usedEncoding) { - case UTF8Encoding _: + case UTF8Encoding: { return 0; } - case UnicodeEncoding _: + case UnicodeEncoding: { return 2; } diff --git a/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs b/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs index e9327051..c6eab62c 100644 --- a/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs +++ b/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs @@ -1,4 +1,4 @@ -using System.Globalization; +using System.Globalization; using System.Text; using System.Text.RegularExpressions; @@ -47,7 +47,7 @@ public class RolloverFilenameBuilder #region cTor - public RolloverFilenameBuilder(string formatString) + public RolloverFilenameBuilder (string formatString) { ParseFormatString(formatString); } @@ -66,7 +66,7 @@ public RolloverFilenameBuilder(string formatString) #region Public methods - public void SetFileName(string fileName) + public void SetFileName (string fileName) { _currentFileName = fileName; Match match = _regex.Match(fileName); @@ -91,18 +91,18 @@ public void SetFileName(string fileName) } } - public void IncrementDate() + public void IncrementDate () { _dateTime = _dateTime.AddDays(1); } - public void DecrementDate() + public void DecrementDate () { _dateTime = _dateTime.AddDays(-1); } - public string BuildFileName() + public string BuildFileName () { var fileName = _currentFileName; if (_dateGroup != null && _dateGroup.Success) @@ -136,10 +136,10 @@ public string BuildFileName() #region Private Methods - private void ParseFormatString(string formatString) + private void ParseFormatString (string formatString) { var fmt = EscapeNonvarRegions(formatString); - var datePos = formatString.IndexOf("$D("); + var datePos = formatString.IndexOf("$D(", StringComparison.Ordinal); if (datePos != -1) { var endPos = formatString.IndexOf(')', datePos); @@ -151,9 +151,9 @@ private void ParseFormatString(string formatString) var dtf = _dateTimeFormat; dtf = dtf.ToUpper(); - dtf = dtf.Replace("D", "\\d"); - dtf = dtf.Replace("Y", "\\d"); - dtf = dtf.Replace("M", "\\d"); + dtf = dtf.Replace("D", "\\d", StringComparison.Ordinal); + dtf = dtf.Replace("Y", "\\d", StringComparison.Ordinal); + dtf = dtf.Replace("M", "\\d", StringComparison.Ordinal); fmt = fmt.Remove(datePos, 2); // remove $D fmt = fmt.Remove(datePos + 1, _dateTimeFormat.Length); // replace with regex version of format fmt = fmt.Insert(datePos + 1, dtf); @@ -161,7 +161,7 @@ private void ParseFormatString(string formatString) } } - var condPos = fmt.IndexOf("$J("); + var condPos = fmt.IndexOf("$J(", StringComparison.Ordinal); if (condPos != -1) { var endPos = fmt.IndexOf(')', condPos); @@ -172,20 +172,22 @@ private void ParseFormatString(string formatString) } } - fmt = fmt.Replace("*", ".*"); - _hideZeroIndex = fmt.Contains("$J"); - fmt = fmt.Replace("$I", "(?'index'[\\d]+)"); - fmt = fmt.Replace("$J", "(?'index'[\\d]*)"); + fmt = fmt.Replace("*", ".*", StringComparison.Ordinal); + _hideZeroIndex = fmt.Contains("$J", StringComparison.Ordinal); + fmt = fmt.Replace("$I", "(?'index'[\\d]+)", StringComparison.Ordinal); + fmt = fmt.Replace("$J", "(?'index'[\\d]*)", StringComparison.Ordinal); _regex = new Regex(fmt); } - private string EscapeNonvarRegions(string formatString) + private string EscapeNonvarRegions (string formatString) { var fmt = formatString.Replace('*', '\xFFFD'); - StringBuilder result = new(); var state = 0; + + StringBuilder result = new(); StringBuilder segment = new(); + for (var i = 0; i < fmt.Length; ++i) { switch (state) @@ -193,41 +195,45 @@ private string EscapeNonvarRegions(string formatString) case 0: // looking for $ if (fmt[i] == '$') { - result.Append(Regex.Escape(segment.ToString())); + _ = result.Append(Regex.Escape(segment.ToString())); segment = new StringBuilder(); state = 1; } - segment.Append(fmt[i]); + + _ = segment.Append(fmt[i]); break; case 1: // the char behind $ - segment.Append(fmt[i]); - result.Append(segment.ToString()); + _ = segment.Append(fmt[i]); + _ = result.Append(segment); segment = new StringBuilder(); state = 2; break; case 2: // checking if ( or other char if (fmt[i] == '(') { - segment.Append(fmt[i]); + _ = segment.Append(fmt[i]); state = 3; } else { - segment.Append(fmt[i]); + _ = segment.Append(fmt[i]); state = 0; } + break; case 3: // looking for ) - segment.Append(fmt[i]); + _ = segment.Append(fmt[i]); if (fmt[i] == ')') { - result.Append(segment.ToString()); + _ = result.Append(segment); segment = new StringBuilder(); state = 0; } + break; } } + fmt = result.ToString().Replace('\xFFFD', '*'); return fmt; } diff --git a/src/LogExpert.Core/Classes/ParamParser.cs b/src/LogExpert.Core/Classes/ParamParser.cs index 42fbee75..6ca9731f 100644 --- a/src/LogExpert.Core/Classes/ParamParser.cs +++ b/src/LogExpert.Core/Classes/ParamParser.cs @@ -1,41 +1,34 @@ -using System.Text; +using System.Text; using System.Text.RegularExpressions; namespace LogExpert.Core.Classes; -public class ParamParser +public class ParamParser (string argTemplate) { - #region Fields - - private readonly string argLine; - - #endregion - - #region cTor - - public ParamParser(string argTemplate) - { - argLine = argTemplate; - } - - #endregion - #region Public methods - public string ReplaceParams(ILogLine logLine, int lineNum, string fileName) + public string ReplaceParams (ILogLine logLine, int lineNum, string fileName) { FileInfo fileInfo = new(fileName); - StringBuilder builder = new(argLine); - builder.Replace("%L", "" + lineNum); - builder.Replace("%P", - fileInfo.DirectoryName.Contains(" ") ? "\"" + fileInfo.DirectoryName + "\"" : fileInfo.DirectoryName); - builder.Replace("%N", fileInfo.Name.Contains(" ") ? "\"" + fileInfo.Name + "\"" : fileInfo.Name); - builder.Replace("%F", - fileInfo.FullName.Contains(" ") ? "\"" + fileInfo.FullName + "\"" : fileInfo.FullName); - builder.Replace("%E", - fileInfo.Extension.Contains(" ") ? "\"" + fileInfo.Extension + "\"" : fileInfo.Extension); + StringBuilder builder = new(argTemplate); + _ = builder.Replace("%L", "" + lineNum); + _ = builder.Replace("%P", fileInfo.DirectoryName.Contains(' ', StringComparison.Ordinal) + ? "\"" + fileInfo.DirectoryName + "\"" + : fileInfo.DirectoryName); + _ = builder.Replace("%N", fileInfo.Name.Contains(' ', StringComparison.Ordinal) + ? "\"" + fileInfo.Name + "\"" + : fileInfo.Name); + _ = builder.Replace("%F", + fileInfo.FullName.Contains(' ', StringComparison.Ordinal) + ? "\"" + fileInfo.FullName + "\"" + : fileInfo.FullName); + _ = builder.Replace("%E", fileInfo.Extension.Contains(' ', StringComparison.Ordinal) + ? "\"" + fileInfo.Extension + "\"" + : fileInfo.Extension); var stripped = StripExtension(fileInfo.Name); - builder.Replace("%M", stripped.Contains(" ") ? "\"" + stripped + "\"" : stripped); + _ = builder.Replace("%M", stripped.Contains(' ', StringComparison.Ordinal) + ? "\"" + stripped + "\"" + : stripped); var sPos = 0; string reg; string replace; @@ -52,21 +45,23 @@ public string ReplaceParams(ILogLine logLine, int lineNum, string fileName) return builder.ToString(); } - public static string StripExtension(string fileName) + public static string StripExtension (string fileName) { var i = fileName.LastIndexOf('.'); + if (i < 0) { i = fileName.Length - 1; } - return fileName.Substring(0, i); + + return fileName[..i]; } #endregion #region Private Methods - private string GetNextGroup(StringBuilder builder, ref int sPos) + private string GetNextGroup (StringBuilder builder, ref int sPos) { int ePos; while (sPos < builder.Length) @@ -81,21 +76,26 @@ private string GetNextGroup(StringBuilder builder, ref int sPos) { count++; } + if (builder[ePos] == '}') { count--; } + if (count == 0) { var reg = builder.ToString(sPos + 1, ePos - sPos - 1); - builder.Remove(sPos, ePos - sPos + 1); + _ = builder.Remove(sPos, ePos - sPos + 1); return reg; } + ePos++; } } + sPos++; } + return null; } diff --git a/src/LogExpert.Core/Classes/PatternBlock.cs b/src/LogExpert.Core/Classes/PatternBlock.cs index 2fc6b6ba..41d23bc1 100644 --- a/src/LogExpert.Core/Classes/PatternBlock.cs +++ b/src/LogExpert.Core/Classes/PatternBlock.cs @@ -1,42 +1,31 @@ -using System.Collections.Generic; - namespace LogExpert.Core.Classes; -public class QualityInfo +public class PatternBlock { - #region Fields + public int BlockId { get; set; } - public int quality; + public int EndLine { get; set; } - #endregion -} + // key: line num + public Dictionary QualityInfoList { get; set; } = []; -public class PatternBlock -{ - #region Fields + public SortedDictionary SrcLines { get; set; } = []; - public int blockId; + public int StartLine { get; set; } - public int endLine; + public int TargetEnd { get; set; } - // key: line num - public Dictionary qualityInfoList = []; + public SortedDictionary TargetLines { get; set; } = []; - public SortedDictionary srcLines = []; - public int startLine; - public int targetEnd; - public SortedDictionary targetLines = []; - public int targetStart; - public int weigth; + public int TargetStart { get; set; } - #endregion + public int Weigth { get; set; } #region Public methods - public override string ToString() + public override string ToString () { - return "srcStart=" + startLine + ", srcEnd=" + endLine + ", targetStart=" + targetStart + - ", targetEnd=" + targetEnd + ", weight=" + weigth; + return $"srcStart={StartLine}, srcEnd={EndLine}, targetStart={TargetStart}, targetEnd={TargetEnd}, weight={Weigth}"; } #endregion diff --git a/src/LogExpert.Core/Classes/Persister/PersistenceData.cs b/src/LogExpert.Core/Classes/Persister/PersistenceData.cs index bd358a72..36610342 100644 --- a/src/LogExpert.Core/Classes/Persister/PersistenceData.cs +++ b/src/LogExpert.Core/Classes/Persister/PersistenceData.cs @@ -1,4 +1,4 @@ -using System.Text; +using System.Text; using LogExpert.Core.Classes.Filter; using LogExpert.Core.Entities; @@ -9,11 +9,11 @@ public class PersistenceData { #region Fields - public SortedList bookmarkList = []; - public int bookmarkListPosition = 300; - public bool bookmarkListVisible; - public string columnizerName; - public int currentLine = -1; + private SortedList bookmarkList = []; + private int bookmarkListPosition = 300; + private bool bookmarkListVisible; + private string columnizerName; + private int currentLine = -1; public Encoding encoding; public string fileName; public bool filterAdvanced; @@ -38,5 +38,11 @@ public class PersistenceData public string settingsSaveLoadLocation; + public SortedList BookmarkList { get => bookmarkList; set => bookmarkList = value; } + public int BookmarkListPosition { get => bookmarkListPosition; set => bookmarkListPosition = value; } + public bool BookmarkListVisible { get => bookmarkListVisible; set => bookmarkListVisible = value; } + public string ColumnizerName { get => columnizerName; set => columnizerName = value; } + public int CurrentLine { get => currentLine; set => currentLine = value; } + #endregion } diff --git a/src/LogExpert.Core/Classes/Persister/Persister.cs b/src/LogExpert.Core/Classes/Persister/Persister.cs index c1bf9ce4..63a727af 100644 --- a/src/LogExpert.Core/Classes/Persister/Persister.cs +++ b/src/LogExpert.Core/Classes/Persister/Persister.cs @@ -174,7 +174,7 @@ private static void Save (string fileName, PersistenceData persistenceData) rootElement.AppendChild(fileElement); fileElement.SetAttribute("fileName", persistenceData.fileName); fileElement.SetAttribute("lineCount", "" + persistenceData.lineCount); - WriteBookmarks(xmlDoc, fileElement, persistenceData.bookmarkList); + WriteBookmarks(xmlDoc, fileElement, persistenceData.BookmarkList); WriteRowHeightList(xmlDoc, fileElement, persistenceData.rowHeightList); WriteOptions(xmlDoc, fileElement, persistenceData); WriteFilter(xmlDoc, fileElement, persistenceData.filterParamsList); @@ -207,7 +207,7 @@ private static void WriteFilterTabs (XmlDocument xmlDoc, XmlElement rootElement, PersistenceData persistenceData = data.PersistenceData; XmlElement filterTabElement = xmlDoc.CreateElement("filterTab"); filterTabsElement.AppendChild(filterTabElement); - WriteBookmarks(xmlDoc, filterTabElement, persistenceData.bookmarkList); + WriteBookmarks(xmlDoc, filterTabElement, persistenceData.BookmarkList); WriteRowHeightList(xmlDoc, filterTabElement, persistenceData.rowHeightList); WriteOptions(xmlDoc, filterTabElement, persistenceData); WriteFilter(xmlDoc, filterTabElement, persistenceData.filterParamsList); @@ -280,7 +280,7 @@ private static List ReadFilter (XmlElement startNode) { foreach (XmlNode subNode in node.ChildNodes) { - if (subNode.Name.Equals("params")) + if (subNode.Name.Equals("params", StringComparison.OrdinalIgnoreCase)) { var base64Text = subNode.InnerText; var data = Convert.FromBase64String(base64Text); @@ -344,7 +344,7 @@ private static PersistenceData ReadPersistenceDataFromNode (XmlNode node) { PersistenceData persistenceData = new(); var fileElement = node as XmlElement; - persistenceData.bookmarkList = ReadBookmarks(fileElement); + persistenceData.BookmarkList = ReadBookmarks(fileElement); persistenceData.rowHeightList = ReadRowHeightList(fileElement); ReadOptions(fileElement, persistenceData); persistenceData.fileName = fileElement.GetAttribute("fileName"); @@ -401,29 +401,29 @@ private static Encoding ReadEncoding (XmlElement fileElement) foreach (XmlAttribute attr in node.Attributes) { - if (attr.Name.Equals("line")) + if (attr.Name.Equals("line", StringComparison.OrdinalIgnoreCase)) { line = attr.InnerText; } } foreach (XmlNode subNode in node.ChildNodes) { - if (subNode.Name.Equals("text")) + if (subNode.Name.Equals("text", StringComparison.OrdinalIgnoreCase)) { text = subNode.InnerText; } - else if (subNode.Name.Equals("posX")) + else if (subNode.Name.Equals("posX", StringComparison.OrdinalIgnoreCase)) { posX = subNode.InnerText; } - else if (subNode.Name.Equals("posY")) + else if (subNode.Name.Equals("posY", StringComparison.OrdinalIgnoreCase)) { posY = subNode.InnerText; } } if (line == null || posX == null || posY == null) { - _logger.Error("Invalid XML format for bookmark: {0}", node.InnerText); + _logger.Error($"Invalid XML format for bookmark: {node.InnerText}"); continue; } var lineNum = int.Parse(line); @@ -469,11 +469,11 @@ private static SortedList ReadRowHeightList (XmlElement sta string line = null; foreach (XmlAttribute attr in node.Attributes) { - if (attr.Name.Equals("line")) + if (attr.Name.Equals("line", StringComparison.OrdinalIgnoreCase)) { line = attr.InnerText; } - else if (attr.Name.Equals("height")) + else if (attr.Name.Equals("height", StringComparison.OrdinalIgnoreCase)) { height = attr.InnerText; } @@ -505,7 +505,7 @@ private static void WriteOptions (XmlDocument xmlDoc, XmlElement rootElement, Pe optionsElement.AppendChild(element); element = xmlDoc.CreateElement("currentline"); - element.SetAttribute("line", "" + persistenceData.currentLine); + element.SetAttribute("line", "" + persistenceData.CurrentLine); optionsElement.AppendChild(element); element = xmlDoc.CreateElement("firstDisplayedLine"); @@ -519,8 +519,8 @@ private static void WriteOptions (XmlDocument xmlDoc, XmlElement rootElement, Pe optionsElement.AppendChild(element); element = xmlDoc.CreateElement("bookmarklist"); - element.SetAttribute("visible", persistenceData.bookmarkListVisible ? "1" : "0"); - element.SetAttribute("position", "" + persistenceData.bookmarkListPosition); + element.SetAttribute("visible", persistenceData.BookmarkListVisible ? "1" : "0"); + element.SetAttribute("position", "" + persistenceData.BookmarkListPosition); optionsElement.AppendChild(element); element = xmlDoc.CreateElement("followTail"); @@ -532,7 +532,7 @@ private static void WriteOptions (XmlDocument xmlDoc, XmlElement rootElement, Pe rootElement.AppendChild(element); element = xmlDoc.CreateElement("columnizer"); - element.SetAttribute("name", persistenceData.columnizerName); + element.SetAttribute("name", persistenceData.ColumnizerName); rootElement.AppendChild(element); element = xmlDoc.CreateElement("highlightGroup"); @@ -553,7 +553,7 @@ private static void ReadOptions (XmlElement startNode, PersistenceData persisten { XmlNode optionsNode = startNode.SelectSingleNode("options"); var value = GetOptionsAttribute(optionsNode, "multifile", "enabled"); - persistenceData.multiFile = value != null && value.Equals("1"); + persistenceData.multiFile = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); persistenceData.multiFilePattern = GetOptionsAttribute(optionsNode, "multifile", "pattern"); value = GetOptionsAttribute(optionsNode, "multifile", "maxDays"); try @@ -574,7 +574,7 @@ private static void ReadOptions (XmlElement startNode, PersistenceData persisten string fileName = null; foreach (XmlAttribute attr in node.Attributes) { - if (attr.Name.Equals("fileName")) + if (attr.Name.Equals("fileName", StringComparison.OrdinalIgnoreCase)) { fileName = attr.InnerText; } @@ -586,7 +586,7 @@ private static void ReadOptions (XmlElement startNode, PersistenceData persisten value = GetOptionsAttribute(optionsNode, "currentline", "line"); if (value != null) { - persistenceData.currentLine = int.Parse(value); + persistenceData.CurrentLine = int.Parse(value); } value = GetOptionsAttribute(optionsNode, "firstDisplayedLine", "line"); if (value != null) @@ -595,9 +595,9 @@ private static void ReadOptions (XmlElement startNode, PersistenceData persisten } value = GetOptionsAttribute(optionsNode, "filter", "visible"); - persistenceData.filterVisible = value != null && value.Equals("1"); + persistenceData.filterVisible = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); value = GetOptionsAttribute(optionsNode, "filter", "advanced"); - persistenceData.filterAdvanced = value != null && value.Equals("1"); + persistenceData.filterAdvanced = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); value = GetOptionsAttribute(optionsNode, "filter", "position"); if (value != null) { @@ -605,21 +605,21 @@ private static void ReadOptions (XmlElement startNode, PersistenceData persisten } value = GetOptionsAttribute(optionsNode, "bookmarklist", "visible"); - persistenceData.bookmarkListVisible = value != null && value.Equals("1"); + persistenceData.BookmarkListVisible = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); value = GetOptionsAttribute(optionsNode, "bookmarklist", "position"); if (value != null) { - persistenceData.bookmarkListPosition = int.Parse(value); + persistenceData.BookmarkListPosition = int.Parse(value); } value = GetOptionsAttribute(optionsNode, "followTail", "enabled"); - persistenceData.followTail = value != null && value.Equals("1"); + persistenceData.followTail = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); value = GetOptionsAttribute(optionsNode, "bookmarkCommentColumn", "visible"); - persistenceData.showBookmarkCommentColumn = value != null && value.Equals("1"); + persistenceData.showBookmarkCommentColumn = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); value = GetOptionsAttribute(optionsNode, "filterSaveList", "visible"); - persistenceData.filterSaveListVisible = value != null && value.Equals("1"); + persistenceData.filterSaveListVisible = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); XmlNode tabNode = startNode.SelectSingleNode("tab"); if (tabNode != null) @@ -629,7 +629,7 @@ private static void ReadOptions (XmlElement startNode, PersistenceData persisten XmlNode columnizerNode = startNode.SelectSingleNode("columnizer"); if (columnizerNode != null) { - persistenceData.columnizerName = (columnizerNode as XmlElement).GetAttribute("name"); + persistenceData.ColumnizerName = (columnizerNode as XmlElement).GetAttribute("name"); } XmlNode highlightGroupNode = startNode.SelectSingleNode("highlightGroup"); if (highlightGroupNode != null) diff --git a/src/LogExpert.Core/Classes/QualityInfo.cs b/src/LogExpert.Core/Classes/QualityInfo.cs new file mode 100644 index 00000000..7e150c3d --- /dev/null +++ b/src/LogExpert.Core/Classes/QualityInfo.cs @@ -0,0 +1,6 @@ +namespace LogExpert.Core.Classes; + +public class QualityInfo +{ + public int Quality { get; set; } +} diff --git a/src/LogExpert.Core/Classes/Util.cs b/src/LogExpert.Core/Classes/Util.cs index b8b7c904..14523f5b 100644 --- a/src/LogExpert.Core/Classes/Util.cs +++ b/src/LogExpert.Core/Classes/Util.cs @@ -63,7 +63,7 @@ public static string GetFileSizeAsText (long size) public static bool TestFilterCondition (FilterParams filterParams, ILogLine line, ILogLineColumnizerCallback columnizerCallback) { - if (filterParams.LastLine.Equals(line.FullLine)) + if (filterParams.LastLine.Equals(line.FullLine, StringComparison.OrdinalIgnoreCase)) { return filterParams.LastResult; } @@ -550,14 +550,14 @@ private static bool TestMatchSub (FilterParams filterParams, string line, string { if (exactMatch) { - if (line.ToLower().Trim().Equals(lowerSearchText)) + if (line.ToLowerInvariant().Trim().Equals(lowerSearchText, StringComparison.Ordinal)) { return true; } } else { - if (line.Contains(lowerSearchText, StringComparison.CurrentCultureIgnoreCase)) + if (line.Contains(lowerSearchText, StringComparison.OrdinalIgnoreCase)) { return true; } @@ -567,14 +567,14 @@ private static bool TestMatchSub (FilterParams filterParams, string line, string { if (exactMatch) { - if (line.Equals(searchText)) + if (line.Equals(searchText, StringComparison.Ordinal)) { return true; } } else { - if (line.Contains(searchText)) + if (line.Contains(searchText, StringComparison.OrdinalIgnoreCase)) { return true; } @@ -592,7 +592,7 @@ private static bool TestMatchSub (FilterParams filterParams, string line, string if (!filterParams.IsCaseSensitive) { - src = src.ToLower(); + src = src.ToLowerInvariant(); } var dist = DamerauLevenshteinDistance(src, searchText); @@ -603,9 +603,11 @@ private static bool TestMatchSub (FilterParams filterParams, string line, string } } } + return false; } } + return false; } diff --git a/src/LogExpert.Tests/BufferShiftTest.cs b/src/LogExpert.Tests/BufferShiftTest.cs index bbbefee5..8783bd68 100644 --- a/src/LogExpert.Tests/BufferShiftTest.cs +++ b/src/LogExpert.Tests/BufferShiftTest.cs @@ -110,7 +110,7 @@ public void TestShiftBuffers1 () { LogBuffer logBuffer = logBuffers[i]; ILogLine line = logBuffer.GetLineOfBlock(0); - Assert.That(line.FullLine.Contains(enumerator.Current)); + Assert.That(line.FullLine.Contains(enumerator.Current, System.StringComparison.Ordinal)); enumerator.MoveNext(); } enumerator.MoveNext(); @@ -119,7 +119,7 @@ public void TestShiftBuffers1 () { LogBuffer logBuffer = logBuffers[i]; ILogLine line = logBuffer.GetLineOfBlock(0); - Assert.That(line.FullLine.Contains(enumerator.Current)); + Assert.That(line.FullLine.Contains(enumerator.Current, System.StringComparison.Ordinal)); } oldCount = lil.Count; @@ -142,6 +142,6 @@ public void TestShiftBuffers1 () ILogLine firstLine = reader.GetLogLine(0); var names = new string[files.Count]; files.CopyTo(names, 0); - Assert.That(firstLine.FullLine.Contains(names[2])); + Assert.That(firstLine.FullLine.Contains(names[2], System.StringComparison.Ordinal)); } } \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/DateTimeDragControl.cs b/src/LogExpert.UI/Controls/DateTimeDragControl.cs index 8ae0e23f..e7b96a98 100644 --- a/src/LogExpert.UI/Controls/DateTimeDragControl.cs +++ b/src/LogExpert.UI/Controls/DateTimeDragControl.cs @@ -1,14 +1,10 @@ -using LogExpert.Core.Classes.DateTimeParser; -using LogExpert.Core.Enums; - -using System; -using System.Collections.Generic; using System.ComponentModel; using System.Data; -using System.Drawing; using System.Globalization; -using System.Linq; -using System.Windows.Forms; +using System.Runtime.Versioning; + +using LogExpert.Core.Classes.DateTimeParser; +using LogExpert.Core.Enums; namespace LogExpert.Dialogs; @@ -51,7 +47,7 @@ public partial class DateTimeDragControl : UserControl /// /// Default Constructor /// - public DateTimeDragControl() + public DateTimeDragControl () { InitializeComponent(); @@ -70,9 +66,9 @@ public DateTimeDragControl() #region Delegates - public delegate void ValueChangedEventHandler(object sender, EventArgs e); + public delegate void ValueChangedEventHandler (object sender, EventArgs e); - public delegate void ValueDraggedEventHandler(object sender, EventArgs e); + public delegate void ValueDraggedEventHandler (object sender, EventArgs e); #endregion @@ -124,7 +120,7 @@ public DateTime DateTime #region Private Methods // Returns the index of the rectangle (digitRects) under the mouse cursor - private int DetermineDraggedDigit(MouseEventArgs e) + private int DetermineDraggedDigit (MouseEventArgs e) { for (var i = 0; i < _digitRects.Count; ++i) { @@ -138,7 +134,7 @@ private int DetermineDraggedDigit(MouseEventArgs e) } // Return the value corresponding to current dragged digit - private int GetDraggedValue() + private int GetDraggedValue () { var datePart = _dateParts[_draggedDigit]; @@ -170,7 +166,7 @@ private int GetDraggedValue() return datePart.StartsWith("s", StringComparison.OrdinalIgnoreCase) ? _dateTime.Second : NO_DIGIT_DRAGGED; } - private bool SetDraggedValue(int delta) + private bool SetDraggedValue (int delta) { if (_draggedDigit == NO_DIGIT_DRAGGED) { @@ -226,7 +222,7 @@ private bool SetDraggedValue(int delta) return changed; } - private void InitCustomRects(Section dateSection) + private void InitCustomRects (Section dateSection) { _dateParts = dateSection .GeneralTextDateDurationParts @@ -248,7 +244,7 @@ private void InitCustomRects(Section dateSection) } - private void InitDigitRects() + private void InitDigitRects () { CultureInfo culture = System.Threading.Thread.CurrentThread.CurrentCulture; @@ -270,7 +266,7 @@ private void InitDigitRects() #region Events handler - private void DateTimeDragControl_Load(object sender, EventArgs e) + private void DateTimeDragControl_Load (object sender, EventArgs e) { InitDigitRects(); @@ -279,19 +275,20 @@ private void DateTimeDragControl_Load(object sender, EventArgs e) #endregion - protected void OnValueChanged(EventArgs e) + protected void OnValueChanged (EventArgs e) { ValueChanged?.Invoke(this, e); } - protected void OnValueDragged(EventArgs e) + protected void OnValueDragged (EventArgs e) { ValueDragged?.Invoke(this, e); } #region Contextual Menu - private void BuildContextualMenu() + [SupportedOSPlatform("windows")] + private void BuildContextualMenu () { ContextMenuStrip = new ContextMenuStrip(); ContextMenuStrip.Name = "Timestamp selector"; @@ -313,14 +310,16 @@ private void BuildContextualMenu() UpdateContextMenu(); } - private void UpdateContextMenu() + [SupportedOSPlatform("windows")] + private void UpdateContextMenu () { toolStripItemHorizontalDrag.Enabled = DragOrientation != DragOrientationsEnum.Horizontal; toolStripItemVerticalDrag.Enabled = DragOrientation != DragOrientationsEnum.Vertical; toolStripItemVerticalInvertedDrag.Enabled = DragOrientation != DragOrientationsEnum.InvertedVertical; } - private void OnContextMenuStripOpening(object sender, CancelEventArgs e) + [SupportedOSPlatform("windows")] + private void OnContextMenuStripOpening (object sender, CancelEventArgs e) { if (Capture) { @@ -328,7 +327,7 @@ private void OnContextMenuStripOpening(object sender, CancelEventArgs e) } } - private void OnToolStripItemHorizontalDragClick(object sender, EventArgs e) + private void OnToolStripItemHorizontalDragClick (object sender, EventArgs e) { DragOrientation = DragOrientationsEnum.Horizontal; toolStripItemHorizontalDrag.Enabled = false; @@ -336,7 +335,7 @@ private void OnToolStripItemHorizontalDragClick(object sender, EventArgs e) toolStripItemVerticalInvertedDrag.Enabled = true; } - private void OnToolStripItemVerticalDragClick(object sender, EventArgs e) + private void OnToolStripItemVerticalDragClick (object sender, EventArgs e) { DragOrientation = DragOrientationsEnum.Vertical; toolStripItemHorizontalDrag.Enabled = true; @@ -344,7 +343,7 @@ private void OnToolStripItemVerticalDragClick(object sender, EventArgs e) toolStripItemVerticalInvertedDrag.Enabled = true; } - private void OnToolStripItemVerticalInvertedDragClick(object sender, EventArgs e) + private void OnToolStripItemVerticalInvertedDragClick (object sender, EventArgs e) { DragOrientation = DragOrientationsEnum.InvertedVertical; toolStripItemHorizontalDrag.Enabled = true; @@ -356,7 +355,7 @@ private void OnToolStripItemVerticalInvertedDragClick(object sender, EventArgs e #region Rendering - protected override void OnPaint(PaintEventArgs e) + protected override void OnPaint (PaintEventArgs e) { base.OnPaint(e); @@ -400,7 +399,7 @@ protected override void OnPaint(PaintEventArgs e) } } - private void DateTimeDragControl_Resize(object sender, EventArgs e) + private void DateTimeDragControl_Resize (object sender, EventArgs e) { InitDigitRects(); } @@ -409,7 +408,8 @@ private void DateTimeDragControl_Resize(object sender, EventArgs e) #region Mouse callbacks - protected override void OnMouseDown(MouseEventArgs e) + [SupportedOSPlatform("windows")] + protected override void OnMouseDown (MouseEventArgs e) { base.OnMouseDown(e); @@ -420,6 +420,7 @@ protected override void OnMouseDown(MouseEventArgs e) { return; } + Capture = true; _startMouseY = e.Y; _startMouseX = e.X; @@ -434,7 +435,8 @@ protected override void OnMouseDown(MouseEventArgs e) Invalidate(); // repaint with the selected item (or none) } - protected override void OnMouseUp(MouseEventArgs e) + [SupportedOSPlatform("windows")] + protected override void OnMouseUp (MouseEventArgs e) { if (!Capture) { @@ -450,7 +452,8 @@ protected override void OnMouseUp(MouseEventArgs e) OnValueChanged(EventArgs.Empty); } - protected override void OnMouseMove(MouseEventArgs e) + [SupportedOSPlatform("windows")] + protected override void OnMouseMove (MouseEventArgs e) { base.OnMouseMove(e); @@ -496,7 +499,8 @@ protected override void OnMouseMove(MouseEventArgs e) OnValueDragged(EventArgs.Empty); } - private void DateTimeDragControl_MouseLeave(object sender, EventArgs e) + [SupportedOSPlatform("windows")] + private void DateTimeDragControl_MouseLeave (object sender, EventArgs e) { if (Capture) { diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index dec9982f..f95b02f7 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -1,3 +1,5 @@ +using System.Runtime.Versioning; + using LogExpert.Classes.Filter; using LogExpert.Core.Callback; using LogExpert.Core.Classes.Bookmark; @@ -134,6 +136,7 @@ public partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILog #region cTor + [SupportedOSPlatform("windows")] public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTempFile, bool forcePersistenceLoading, IConfigManager configManager) { SuspendLayout(); @@ -267,6 +270,8 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp #endregion #region ColorTheme + + [SupportedOSPlatform("windows")] public void ChangeTheme (Control.ControlCollection container) { #region ApplyColorToAllControls @@ -448,6 +453,7 @@ private set } } + [SupportedOSPlatform("windows")] public bool ShowBookmarkBubbles { get => _guiStateArgs.ShowBookmarkBubbles; @@ -563,12 +569,14 @@ internal IColumnizedLogLine GetColumnsForLine (int lineNumber) //} } + [SupportedOSPlatform("windows")] internal void RefreshAllGrids () { dataGridView.Refresh(); filterGridView.Refresh(); } + [SupportedOSPlatform("windows")] internal void ChangeMultifileMask () { MultiFileMaskDialog dlg = new(this, FileName) @@ -589,6 +597,7 @@ internal void ChangeMultifileMask () } } + [SupportedOSPlatform("windows")] internal void ToggleColumnFinder (bool show, bool setFocus) { _guiStateArgs.ColumnFinderVisible = show; @@ -621,6 +630,7 @@ protected override string GetPersistString () #endregion + [SupportedOSPlatform("windows")] private void OnButtonSizeChanged (object sender, EventArgs e) { if (sender is Button button && button.Image != null) diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs index d18bf035..848927a2 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs @@ -1,4 +1,5 @@ using System.ComponentModel; +using System.Runtime.Versioning; using LogExpert.Classes.Filter; using LogExpert.Core.Classes; @@ -751,6 +752,7 @@ private void OnFilterSplitContainerMouseDoubleClick (object sender, MouseEventAr #region Context Menu + [SupportedOSPlatform("windows")] private void OnDataGridContextMenuStripOpening (object sender, CancelEventArgs e) { var lineNum = -1; @@ -856,6 +858,7 @@ private void OnDataGridContextMenuStripOpening (object sender, CancelEventArgs e TimeSyncList.Count > 1; } + [SupportedOSPlatform("windows")] private void OnHandlePluginContextMenu (object sender, EventArgs args) { if (sender is ToolStripItem item) @@ -866,6 +869,7 @@ private void OnHandlePluginContextMenu (object sender, EventArgs args) } } + [SupportedOSPlatform("windows")] private void OnHandleSyncContextMenu (object sender, EventArgs args) { if (sender is ToolStripItem item) @@ -979,6 +983,7 @@ private void OnColumnButtonClick (object sender, EventArgs e) #region Column Header Context Menu + [SupportedOSPlatform("windows")] private void OnDataGridViewCellContextMenuStripNeeded (object sender, DataGridViewCellContextMenuStripNeededEventArgs e) { if (e.RowIndex >= 0 && e.RowIndex < dataGridView.RowCount && !dataGridView.Rows[e.RowIndex].Selected) @@ -1010,6 +1015,7 @@ private void OnDataGridViewCellContextMenuStripNeeded (object sender, DataGridVi // } //} + [SupportedOSPlatform("windows")] private void OnFilterGridViewCellContextMenuStripNeeded (object sender, DataGridViewCellContextMenuStripNeededEventArgs e) { if (e.ContextMenuStrip == columnContextMenuStrip) @@ -1018,6 +1024,7 @@ private void OnFilterGridViewCellContextMenuStripNeeded (object sender, DataGrid } } + [SupportedOSPlatform("windows")] private void OnColumnContextMenuStripOpening (object sender, CancelEventArgs e) { Control ctl = columnContextMenuStrip.SourceControl; @@ -1080,6 +1087,7 @@ private void OnColumnContextMenuStripOpening (object sender, CancelEventArgs e) } } + [SupportedOSPlatform("windows")] private void OnHandleColumnItemContextMenu (object sender, EventArgs args) { if (sender is ToolStripItem item) @@ -1090,6 +1098,7 @@ private void OnHandleColumnItemContextMenu (object sender, EventArgs args) } } + [SupportedOSPlatform("windows")] private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick (object sender, EventArgs e) { Control ctl = columnContextMenuStrip.SourceControl; @@ -1109,6 +1118,7 @@ private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick (object sender, } } + [SupportedOSPlatform("windows")] private void OnMoveToLastColumnToolStripMenuItemClick (object sender, EventArgs e) { var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; @@ -1119,6 +1129,7 @@ private void OnMoveToLastColumnToolStripMenuItemClick (object sender, EventArgs } } + [SupportedOSPlatform("windows")] private void OnMoveLeftToolStripMenuItemClick (object sender, EventArgs e) { var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; @@ -1129,6 +1140,7 @@ private void OnMoveLeftToolStripMenuItemClick (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnMoveRightToolStripMenuItemClick (object sender, EventArgs e) { var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; @@ -1139,6 +1151,7 @@ private void OnMoveRightToolStripMenuItemClick (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnHideColumnToolStripMenuItemClick (object sender, EventArgs e) { var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; @@ -1146,6 +1159,7 @@ private void OnHideColumnToolStripMenuItemClick (object sender, EventArgs e) col.Visible = false; } + [SupportedOSPlatform("windows")] private void OnRestoreColumnsToolStripMenuItemClick (object sender, EventArgs e) { var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; @@ -1165,6 +1179,7 @@ private void OnBookmarkCommentToolStripMenuItemClick (object sender, EventArgs e AddBookmarkAndEditComment(); } + [SupportedOSPlatform("windows")] private void OnHighlightSelectionInLogFileToolStripMenuItemClick (object sender, EventArgs e) { if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) @@ -1194,6 +1209,7 @@ private void OnHighlightSelectionInLogFileToolStripMenuItemClick (object sender, } } + [SupportedOSPlatform("windows")] private void OnHighlightSelectionInLogFilewordModeToolStripMenuItemClick (object sender, EventArgs e) { if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) @@ -1224,6 +1240,7 @@ private void OnHighlightSelectionInLogFilewordModeToolStripMenuItemClick (object } } + [SupportedOSPlatform("windows")] private void OnEditModeCopyToolStripMenuItemClick (object sender, EventArgs e) { if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) @@ -1258,6 +1275,7 @@ private void OnMarkCurrentFilterRangeToolStripMenuItemClick (object sender, Even MarkCurrentFilterRange(); } + [SupportedOSPlatform("windows")] private void OnFilterForSelectionToolStripMenuItemClick (object sender, EventArgs e) { if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) @@ -1268,6 +1286,7 @@ private void OnFilterForSelectionToolStripMenuItemClick (object sender, EventArg } } + [SupportedOSPlatform("windows")] private void OnSetSelectedTextAsBookmarkCommentToolStripMenuItemClick (object sender, EventArgs e) { if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) @@ -1281,6 +1300,7 @@ private void OnDataGridViewCellClick (object sender, DataGridViewCellEventArgs e _shouldCallTimeSync = true; } + [SupportedOSPlatform("windows")] private void OnDataGridViewCellDoubleClick (object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) @@ -1294,6 +1314,7 @@ private void OnDataGridViewOverlayDoubleClicked (object sender, OverlayEventArgs BookmarkComment(e.BookmarkOverlay.Bookmark); } + [SupportedOSPlatform("windows")] private void OnFilterRegexCheckBoxMouseUp (object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) @@ -1324,6 +1345,7 @@ private void OnFilterRegexCheckBoxMouseUp (object sender, MouseEventArgs e) #region Filter-Highlight + [SupportedOSPlatform("windows")] private void OnToggleHighlightPanelButtonClick (object sender, EventArgs e) { ToggleHighlightPanel(highlightSplitContainer.Panel2Collapsed); @@ -1337,6 +1359,7 @@ private void OnSaveFilterButtonClick (object sender, EventArgs e) OnFilterListChanged(this); } + [SupportedOSPlatform("windows")] private void OnDeleteFilterButtonClick (object sender, EventArgs e) { var index = filterListBox.SelectedIndex; @@ -1352,6 +1375,7 @@ private void OnDeleteFilterButtonClick (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnFilterUpButtonClick (object sender, EventArgs e) { var i = filterListBox.SelectedIndex; @@ -1366,6 +1390,7 @@ private void OnFilterUpButtonClick (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnFilterDownButtonClick (object sender, EventArgs e) { var i = filterListBox.SelectedIndex; @@ -1385,6 +1410,7 @@ private void OnFilterDownButtonClick (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnFilterListBoxMouseDoubleClick (object sender, MouseEventArgs e) { if (filterListBox.SelectedIndex >= 0) @@ -1411,6 +1437,7 @@ private void OnFilterListBoxMouseDoubleClick (object sender, MouseEventArgs e) } } + [SupportedOSPlatform("windows")] private void OnFilterListBoxDrawItem (object sender, DrawItemEventArgs e) { e.DrawBackground(); @@ -1437,6 +1464,7 @@ private void OnFilterListBoxDrawItem (object sender, DrawItemEventArgs e) } } + [SupportedOSPlatform("windows")] // Color for filter list entry private void OnColorToolStripMenuItemClick (object sender, EventArgs e) { @@ -1460,6 +1488,7 @@ private void OnFilterCaseSensitiveCheckBoxCheckedChanged (object sender, EventAr CheckForFilterDirty(); } + [SupportedOSPlatform("windows")] private void OnFilterRegexCheckBoxCheckedChanged (object sender, EventArgs e) { fuzzyKnobControl.Enabled = !filterRegexCheckBox.Checked; @@ -1539,6 +1568,7 @@ private void OnFreeThisWindowFromTimeSyncToolStripMenuItemClick (object sender, FreeFromTimeSync(); } + [SupportedOSPlatform("windows")] private void OnSplitContainerSplitterMoved (object sender, SplitterEventArgs e) { advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; @@ -1546,10 +1576,13 @@ private void OnSplitContainerSplitterMoved (object sender, SplitterEventArgs e) private void OnMarkFilterHitsInLogViewToolStripMenuItemClick (object sender, EventArgs e) { - SearchParams p = new(); - p.SearchText = _filterParams.SearchText; - p.IsRegex = _filterParams.IsRegex; - p.IsCaseSensitive = _filterParams.IsCaseSensitive; + SearchParams p = new() + { + SearchText = _filterParams.SearchText, + IsRegex = _filterParams.IsRegex, + IsCaseSensitive = _filterParams.IsCaseSensitive + }; + AddSearchHitHighlightEntry(p); } @@ -1558,6 +1591,7 @@ private void OnColumnComboBoxSelectionChangeCommitted (object sender, EventArgs SelectColumn(); } + [SupportedOSPlatform("windows")] private void OnColumnComboBoxKeyDown (object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) @@ -1567,6 +1601,7 @@ private void OnColumnComboBoxKeyDown (object sender, KeyEventArgs e) } } + [SupportedOSPlatform("windows")] private void OnColumnComboBoxPreviewKeyDown (object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt) @@ -1580,6 +1615,7 @@ private void OnColumnComboBoxPreviewKeyDown (object sender, PreviewKeyDownEventA } } + [SupportedOSPlatform("windows")] private void OnBookmarkProviderBookmarkRemoved (object sender, EventArgs e) { if (!_isLoading) @@ -1589,6 +1625,7 @@ private void OnBookmarkProviderBookmarkRemoved (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnBookmarkProviderBookmarkAdded (object sender, EventArgs e) { if (!_isLoading) @@ -1613,6 +1650,7 @@ private void OnLogWindowEnter (object sender, EventArgs e) InvalidateCurrentRow(); } + [SupportedOSPlatform("windows")] private void OnDataGridViewRowUnshared (object sender, DataGridViewRowEventArgs e) { if (_logger.IsTraceEnabled) @@ -1627,6 +1665,7 @@ private void OnDataGridViewRowUnshared (object sender, DataGridViewRowEventArgs #endregion + [SupportedOSPlatform("windows")] private void MeasureItem (object sender, MeasureItemEventArgs e) { e.ItemHeight = filterListBox.Font.Height; diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs index 5ea20a31..2c0cd564 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs @@ -1,4 +1,5 @@ using System.Globalization; +using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; @@ -101,9 +102,11 @@ private bool LoadPersistenceOptions () } IsMultiFile = persistenceData.multiFile; - _multiFileOptions = new MultiFileOptions(); - _multiFileOptions.FormatPattern = persistenceData.multiFilePattern; - _multiFileOptions.MaxDayTry = persistenceData.multiFileMaxDays; + _multiFileOptions = new MultiFileOptions + { + FormatPattern = persistenceData.multiFilePattern, + MaxDayTry = persistenceData.multiFileMaxDays + }; if (string.IsNullOrEmpty(_multiFileOptions.FormatPattern)) { @@ -117,7 +120,7 @@ private bool LoadPersistenceOptions () if (_reloadMemento == null) { - PreselectColumnizer(persistenceData.columnizerName); + PreselectColumnizer(persistenceData.ColumnizerName); } FollowTailChanged(persistenceData.followTail, false); @@ -203,13 +206,13 @@ private void LoadPersistenceData () return; } - _bookmarkProvider.SetBookmarks(persistenceData.bookmarkList); + _bookmarkProvider.SetBookmarks(persistenceData.BookmarkList); _rowHeightList = persistenceData.rowHeightList; try { - if (persistenceData.currentLine >= 0 && persistenceData.currentLine < dataGridView.RowCount) + if (persistenceData.CurrentLine >= 0 && persistenceData.CurrentLine < dataGridView.RowCount) { - SelectLine(persistenceData.currentLine, false, true); + SelectLine(persistenceData.CurrentLine, false, true); } else { @@ -493,8 +496,10 @@ private void ReloadNewFile () SavePersistenceData(false); _loadingFinishedEvent.Reset(); _externaLoadingFinishedEvent.Reset(); - Thread reloadFinishedThread = new(ReloadFinishedThreadFx); - reloadFinishedThread.IsBackground = true; + Thread reloadFinishedThread = new(ReloadFinishedThreadFx) + { + IsBackground = true + }; reloadFinishedThread.Start(); LoadFile(FileName, EncodingOptions); @@ -1315,14 +1320,14 @@ private bool CheckHighlightEntryMatch (HighlightEntry entry, ITextValue column) { if (entry.IsCaseSensitive) { - if (column.Text.Contains(entry.SearchText)) + if (column.Text.Contains(entry.SearchText, StringComparison.Ordinal)) { return true; } } else { - if (column.Text.ToLower().Contains(entry.SearchText.ToLower())) + if (column.Text.ToUpperInvariant().Contains(entry.SearchText.ToUpperInvariant(), StringComparison.OrdinalIgnoreCase)) { return true; } @@ -1364,10 +1369,13 @@ private void GetHighlightEntryMatches (ITextValue line, IList hi MatchCollection matches = entry.Regex.Matches(line.Text); foreach (Match match in matches) { - HilightMatchEntry me = new(); - me.HilightEntry = entry; - me.StartPos = match.Index; - me.Length = match.Length; + HilightMatchEntry me = new() + { + HilightEntry = entry, + StartPos = match.Index, + Length = match.Length + }; + resultList.Add(me); } } @@ -1375,18 +1383,20 @@ private void GetHighlightEntryMatches (ITextValue line, IList hi { if (CheckHighlightEntryMatch(entry, line)) { - HilightMatchEntry me = new(); - me.HilightEntry = entry; - me.StartPos = 0; - me.Length = line.Text.Length; + HilightMatchEntry me = new() + { + HilightEntry = entry, + StartPos = 0, + Length = line.Text.Length + }; + resultList.Add(me); } } } } - private void GetHilightActions (IList matchingList, out bool noLed, out bool stopTail, - out bool setBookmark, out string bookmarkComment) + private void GetHilightActions (IList matchingList, out bool noLed, out bool stopTail, out bool setBookmark, out string bookmarkComment) { noLed = stopTail = setBookmark = false; bookmarkComment = string.Empty; @@ -1430,6 +1440,7 @@ private void StopTimestampSyncThread () cts.Cancel(); } + [SupportedOSPlatform("windows")] private void SyncTimestampDisplay () { if (CurrentColumnizer.IsTimeshiftImplemented()) @@ -1441,6 +1452,7 @@ private void SyncTimestampDisplay () } } + [SupportedOSPlatform("windows")] private void SyncTimestampDisplay (int lineNum) { _timeShiftSyncLine = lineNum; @@ -1448,6 +1460,7 @@ private void SyncTimestampDisplay (int lineNum) _timeShiftSyncWakeupEvent.Set(); } + [SupportedOSPlatform("windows")] private void SyncTimestampDisplayWorker () { const int WAIT_TIME = 500; @@ -1532,6 +1545,7 @@ private void SyncTimestampDisplayWorker () } } + [SupportedOSPlatform("windows")] private void SyncFilterGridPos () { try @@ -1570,6 +1584,7 @@ private void StatusLineFileSize (long size) SendStatusLineUpdate(); } + [SupportedOSPlatform("windows")] private int Search (SearchParams searchParams) { if (searchParams.SearchText == null) @@ -1581,7 +1596,7 @@ private int Search (SearchParams searchParams) ? 0 : searchParams.CurrentLine; - var lowerSearchText = searchParams.SearchText.ToLower(); + var lowerSearchText = searchParams.SearchText.ToLowerInvariant(); var count = 0; var hasWrapped = false; @@ -1636,16 +1651,16 @@ private int Search (SearchParams searchParams) } else { - if (!searchParams.IsCaseSensitive) + if (searchParams.IsCaseSensitive) { - if (line.FullLine.Contains(lowerSearchText, StringComparison.CurrentCultureIgnoreCase)) + if (line.FullLine.Contains(searchParams.SearchText, StringComparison.Ordinal)) { return lineNum; } } else { - if (line.FullLine.Contains(searchParams.SearchText)) + if (line.FullLine.Contains(lowerSearchText, StringComparison.OrdinalIgnoreCase)) { return lineNum; } @@ -1690,6 +1705,7 @@ private void ResetProgressBar () SendProgressBarUpdate(); } + [SupportedOSPlatform("windows")] private void SelectLine (int line, bool triggerSyncCall, bool shouldScroll) { try @@ -1738,6 +1754,7 @@ private void SelectLine (int line, bool triggerSyncCall, bool shouldScroll) } } + [SupportedOSPlatform("windows")] private void StartEditMode () { if (!dataGridView.CurrentCell.ReadOnly) @@ -1762,6 +1779,7 @@ private void StartEditMode () } } + [SupportedOSPlatform("windows")] private void UpdateEditColumnDisplay (DataGridViewTextBoxEditingControl editControl) { // prevents key events after edit mode has ended @@ -1773,6 +1791,7 @@ private void UpdateEditColumnDisplay (DataGridViewTextBoxEditingControl editCont } } + [SupportedOSPlatform("windows")] private void SelectPrevHighlightLine () { var lineNum = dataGridView.CurrentCellAddress.Y; @@ -1792,6 +1811,7 @@ private void SelectPrevHighlightLine () } } + [SupportedOSPlatform("windows")] private void SelectNextHighlightLine () { var lineNum = dataGridView.CurrentCellAddress.Y; @@ -1811,6 +1831,7 @@ private void SelectNextHighlightLine () } } + [SupportedOSPlatform("windows")] private int FindNextBookmarkIndex (int lineNum) { if (lineNum >= dataGridView.RowCount) @@ -1825,6 +1846,7 @@ private int FindNextBookmarkIndex (int lineNum) return _bookmarkProvider.FindNextBookmarkIndex(lineNum); } + [SupportedOSPlatform("windows")] private int FindPrevBookmarkIndex (int lineNum) { if (lineNum <= 0) @@ -1876,6 +1898,7 @@ private void ShiftFilterPipes (int offset) } } + [SupportedOSPlatform("windows")] private void LoadFilterPipes () { lock (_filterPipeList) @@ -1906,6 +1929,7 @@ private void DisconnectFilterPipes () } } + [SupportedOSPlatform("windows")] private void ApplyFilterParams () { filterComboBox.Text = _filterParams.SearchText; @@ -1921,6 +1945,7 @@ private void ApplyFilterParams () filterRangeComboBox.Text = _filterParams.RangeSearchText; } + [SupportedOSPlatform("windows")] private void ResetFilterControls () { filterComboBox.Text = ""; @@ -1936,12 +1961,13 @@ private void ResetFilterControls () filterRangeComboBox.Text = ""; } + [SupportedOSPlatform("windows")] private void FilterSearch () { if (filterComboBox.Text.Length == 0) { - _filterParams.SearchText = ""; - _filterParams.LowerSearchText = ""; + _filterParams.SearchText = string.Empty; + _filterParams.LowerSearchText = string.Empty; _filterParams.IsRangeSearch = false; ClearFilterList(); filterSearchButton.Image = null; @@ -1953,12 +1979,13 @@ private void FilterSearch () FilterSearch(filterComboBox.Text); } + [SupportedOSPlatform("windows")] private async void FilterSearch (string text) { FireCancelHandlers(); // make sure that there's no other filter running (maybe from filter restore) _filterParams.SearchText = text; - _filterParams.LowerSearchText = text.ToLower(); + _filterParams.LowerSearchText = text.ToLowerInvariant(); ConfigManager.Settings.filterHistoryList.Remove(text); ConfigManager.Settings.filterHistoryList.Insert(0, text); var maxHistory = ConfigManager.Settings.Preferences.maximumFilterEntries; @@ -2048,14 +2075,17 @@ private async void FilterSearch (string text) CheckForFilterDirty(); } - private void MultiThreadedFilter (FilterParams filterParams, List filterResultLines, - List lastFilterLinesList, List filterHitList) + private void MultiThreadedFilter (FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) { ColumnizerCallback callback = new(this); - FilterStarter fs = new(callback, Environment.ProcessorCount + 2); - fs.FilterHitList = _filterHitList; - fs.FilterResultLines = _filterResultList; - fs.LastFilterLinesList = _lastFilterLinesList; + + FilterStarter fs = new(callback, Environment.ProcessorCount + 2) + { + FilterHitList = _filterHitList, + FilterResultLines = _filterResultList, + LastFilterLinesList = _lastFilterLinesList + }; + var cancelHandler = new FilterCancelHandler(fs); OnRegisterCancelHandler(cancelHandler); long startTime = Environment.TickCount; @@ -2064,7 +2094,7 @@ private void MultiThreadedFilter (FilterParams filterParams, List filterRes long endTime = Environment.TickCount; - _logger.Debug("Multi threaded filter duration: {0} ms.", endTime - startTime); + _logger.Debug($"Multi threaded filter duration: {endTime - startTime} ms."); OnDeRegisterCancelHandler(cancelHandler); StatusLineText("Filter duration: " + (endTime - startTime) + " ms."); @@ -2075,8 +2105,8 @@ private void FilterProgressCallback (int lineCount) UpdateProgressBar(lineCount); } - private void Filter (FilterParams filterParams, List filterResultLines, List lastFilterLinesList, - List filterHitList) + [SupportedOSPlatform("windows")] + private void Filter (FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) { long startTime = Environment.TickCount; try @@ -2115,14 +2145,12 @@ private void Filter (FilterParams filterParams, List filterResultLines, Lis catch (Exception ex) { _logger.Error(ex, "Exception while filtering. Please report to developer: "); - MessageBox.Show(null, - "Exception while filtering. Please report to developer: \n\n" + ex + "\n\n" + ex.StackTrace, - "LogExpert"); + MessageBox.Show(null, $"Exception while filtering. Please report to developer: \n\n{ex}\n\n{ex.StackTrace}", "LogExpert"); } long endTime = Environment.TickCount; - _logger.Info("Single threaded filter duration: {0} ms.", endTime - startTime); + _logger.Info($"Single threaded filter duration: {endTime - startTime} ms."); StatusLineText("Filter duration: " + (endTime - startTime) + " ms."); } @@ -2182,8 +2210,8 @@ private IList GetAdditionalFilterResults (FilterParams filterParams, int li return resultList; } - private void AddFilterLine (int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, - List lastFilterLinesList, List filterHitList) + [SupportedOSPlatform("windows")] + private void AddFilterLine (int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) { int count; lock (_filterResultList) @@ -2210,6 +2238,7 @@ private void AddFilterLine (int lineNum, bool immediate, FilterParams filterPara } } + [SupportedOSPlatform("windows")] private void TriggerFilterLineGuiUpdate () { //lock (this.filterUpdateThread) @@ -2272,6 +2301,7 @@ private void TriggerFilterLineGuiUpdate () // this.filterUpdateThread.Join(); //} + [SupportedOSPlatform("windows")] private void AddFilterLineGuiUpdate () { try @@ -2316,6 +2346,7 @@ private void UpdateProgressBar (int value) SendProgressBarUpdate(); } + [SupportedOSPlatform("windows")] private void FilterComplete () { if (!IsDisposed && !_waitingForClose && !Disposing) @@ -2324,6 +2355,7 @@ private void FilterComplete () } } + [SupportedOSPlatform("windows")] private void FilterComplete (IAsyncResult result) { if (!IsDisposed && !_waitingForClose && !Disposing) @@ -2332,6 +2364,7 @@ private void FilterComplete (IAsyncResult result) } } + [SupportedOSPlatform("windows")] private void ResetStatusAfterFilter () { try @@ -2361,6 +2394,7 @@ private void ResetStatusAfterFilter () } } + [SupportedOSPlatform("windows")] private void ClearFilterList () { try @@ -2394,7 +2428,7 @@ private void ClearBookmarkList () /** * Shift filter list line entries after a logfile rollover */ - + [SupportedOSPlatform("windows")] private void ShiftFilterLines (int offset) { List newFilterList = []; @@ -2439,6 +2473,7 @@ private void ShiftFilterLines (int offset) TriggerFilterLineGuiUpdate(); } + [SupportedOSPlatform("windows")] private void CheckForFilterDirty () { if (IsFilterSearchDirty(_filterParams)) @@ -2453,9 +2488,10 @@ private void CheckForFilterDirty () } } + [SupportedOSPlatform("windows")] private bool IsFilterSearchDirty (FilterParams filterParams) { - if (!filterParams.SearchText.Equals(filterComboBox.Text)) + if (!filterParams.SearchText.Equals(filterComboBox.Text, StringComparison.Ordinal)) { return true; } @@ -2465,7 +2501,7 @@ private bool IsFilterSearchDirty (FilterParams filterParams) return true; } - if (filterParams.IsRangeSearch && !filterParams.RangeSearchText.Equals(filterRangeComboBox.Text)) + if (filterParams.IsRangeSearch && !filterParams.RangeSearchText.Equals(filterRangeComboBox.Text, StringComparison.Ordinal)) { return true; } @@ -2508,6 +2544,7 @@ private bool IsFilterSearchDirty (FilterParams filterParams) return false; } + [SupportedOSPlatform("windows")] private void AdjustMinimumGridWith () { if (dataGridView.Columns.Count > 1) @@ -2526,6 +2563,7 @@ private void AdjustMinimumGridWith () } } + [SupportedOSPlatform("windows")] private void InvalidateCurrentRow (BufferedDataGridView gridView) { if (gridView.CurrentCellAddress.Y > -1) @@ -2540,6 +2578,7 @@ private void InvalidateCurrentRow () InvalidateCurrentRow(filterGridView); } + [SupportedOSPlatform("windows")] private void DisplayCurrentFileOnStatusline () { if (_logFileReader.IsMultiFile) @@ -2574,6 +2613,7 @@ private void UpdateSelectionDisplay () } } + [SupportedOSPlatform("windows")] private void UpdateFilterHistoryFromSettings () { ConfigManager.Settings.filterHistoryList = ConfigManager.Settings.filterHistoryList; @@ -2623,6 +2663,7 @@ private void SendStatusLineUpdate () OnStatusLine(_statusEventArgs); } + [SupportedOSPlatform("windows")] private void ShowAdvancedFilterPanel (bool show) { if (show) @@ -2641,44 +2682,37 @@ private void ShowAdvancedFilterPanel (bool show) _showAdvanced = show; } + [SupportedOSPlatform("windows")] private void CheckForAdvancedButtonDirty () { - if (IsAdvancedOptionActive() && !_showAdvanced) - { - advancedButton.Image = _advancedButtonImage; - } - else - { - advancedButton.Image = null; - } + advancedButton.Image = IsAdvancedOptionActive() && !_showAdvanced + ? _advancedButtonImage + : null; } + [SupportedOSPlatform("windows")] private void FilterToTab () { filterSearchButton.Enabled = false; Task.Run(() => WriteFilterToTab()); } + [SupportedOSPlatform("windows")] private void WriteFilterToTab () { FilterPipe pipe = new(_filterParams.Clone(), this); lock (_filterResultList) { var namePrefix = "->F"; - string title; - if (IsTempFile) - { - title = TempTitleName + namePrefix + ++_filterPipeNameCounter; - } - else - { - title = Util.GetNameFromPath(FileName) + namePrefix + ++_filterPipeNameCounter; - } + var title = IsTempFile + ? TempTitleName + namePrefix + ++_filterPipeNameCounter + : Util.GetNameFromPath(FileName) + namePrefix + ++_filterPipeNameCounter; WritePipeToTab(pipe, _filterResultList, title, null); } } + [SupportedOSPlatform("windows")] private void WritePipeToTab (FilterPipe pipe, IList lineNumberList, string name, PersistenceData persistenceData) { _logger.Info("WritePipeToTab(): {0} lines.", lineNumberList.Count); @@ -2729,6 +2763,7 @@ private void WritePipeToTab (FilterPipe pipe, IList lineNumberList, string Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), pipe, name, persistenceData); } + [SupportedOSPlatform("windows")] private void WriteFilterToTabFinished (FilterPipe pipe, string name, PersistenceData persistenceData) { _isSearching = false; @@ -2764,25 +2799,29 @@ private void WriteFilterToTabFinished (FilterPipe pipe, string name, Persistence /// /// /// + [SupportedOSPlatform("windows")] internal void WritePipeTab (IList lineEntryList, string title) { - FilterPipe pipe = new(new FilterParams(), this); - pipe.IsStopped = true; + FilterPipe pipe = new(new FilterParams(), this) + { + IsStopped = true + }; pipe.Closed += OnPipeDisconnected; pipe.OpenFile(); foreach (LineEntry entry in lineEntryList) { - pipe.WriteToPipe(entry.logLine, entry.lineNum); + pipe.WriteToPipe(entry.LogLine, entry.LineNum); } pipe.CloseFile(); Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), [pipe, title, null]); } + [SupportedOSPlatform("windows")] private void FilterRestore (LogWindow newWin, PersistenceData persistenceData) { newWin.WaitForLoadingFinished(); - ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(persistenceData.columnizerName, + ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(persistenceData.ColumnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); if (columnizer != null) { @@ -2791,12 +2830,13 @@ private void FilterRestore (LogWindow newWin, PersistenceData persistenceData) } else { - _logger.Warn("FilterRestore(): Columnizer {0} not found", persistenceData.columnizerName); + _logger.Warn($"FilterRestore(): Columnizer {persistenceData.ColumnizerName} not found"); } newWin.BeginInvoke(new RestoreFiltersFx(newWin.RestoreFilters), [persistenceData]); } + [SupportedOSPlatform("windows")] private void ProcessFilterPipes (int lineNum) { ILogLine searchLine = _logFileReader.GetLogLine(lineNum); @@ -2805,8 +2845,10 @@ private void ProcessFilterPipes (int lineNum) return; } - ColumnizerCallback callback = new(this); - callback.LineNum = lineNum; + ColumnizerCallback callback = new(this) + { + LineNum = lineNum + }; IList deleteList = []; lock (_filterPipeList) { @@ -2817,7 +2859,7 @@ private void ProcessFilterPipes (int lineNum) continue; } - long startTime = Environment.TickCount; + //long startTime = Environment.TickCount; if (Util.TestFilterCondition(pipe.FilterParams, searchLine, callback)) { IList filterResult = @@ -2842,7 +2884,7 @@ private void ProcessFilterPipes (int lineNum) pipe.CloseFile(); } - long endTime = Environment.TickCount; + //long endTime = Environment.TickCount; //_logger.logDebug("ProcessFilterPipes(" + lineNum + ") duration: " + ((endTime - startTime))); } } @@ -2853,6 +2895,7 @@ private void ProcessFilterPipes (int lineNum) } } + [SupportedOSPlatform("windows")] private void CopyMarkedLinesToClipboard () { if (_guiStateArgs.CellSelectMode) @@ -2902,6 +2945,7 @@ private void SetExplicitEncoding (Encoding encoding) EncodingOptions.Encoding = encoding; } + [SupportedOSPlatform("windows")] private void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, Preferences prefs) { if (dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) > 1) @@ -2929,6 +2973,7 @@ private void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, Preferen AutoResizeColumns(dataGridView); } + [SupportedOSPlatform("windows")] private IList GetSelectedContent () { if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) @@ -2954,6 +2999,7 @@ private IList GetSelectedContent () * Timestamp stuff * =======================================================================*/ + [SupportedOSPlatform("windows")] private void SetTimestampLimits () { if (!CurrentColumnizer.IsTimeshiftImplemented()) @@ -2977,10 +3023,13 @@ private void AdjustHighlightSplitterWidth () //this.highlightSplitContainer.SplitterDistance = distance; } + [SupportedOSPlatform("windows")] private void BookmarkComment (Bookmark bookmark) { - BookmarkCommentDlg dlg = new(); - dlg.Comment = bookmark.Text; + BookmarkCommentDlg dlg = new() + { + Comment = bookmark.Text + }; if (dlg.ShowDialog() == DialogResult.OK) { bookmark.Text = dlg.Comment; @@ -2994,6 +3043,7 @@ private void BookmarkComment (Bookmark bookmark) /// /// /// + [SupportedOSPlatform("windows")] private string CalculateColumnNames (FilterParams filter) { var names = string.Empty; @@ -3018,6 +3068,7 @@ private string CalculateColumnNames (FilterParams filter) return names; } + [SupportedOSPlatform("windows")] private void ApplyFrozenState (BufferedDataGridView gridView) { SortedDictionary dict = []; @@ -3037,6 +3088,7 @@ private void ApplyFrozenState (BufferedDataGridView gridView) } } + [SupportedOSPlatform("windows")] private void ShowTimeSpread (bool show) { if (show) @@ -3051,6 +3103,7 @@ private void ShowTimeSpread (bool show) _timeSpreadCalc.Enabled = show; } + [SupportedOSPlatform("windows")] protected internal void AddTempFileTab (string fileName, string title) { _parentLogTabWin.AddTempFileTab(fileName, title); @@ -3070,10 +3123,11 @@ private void InitPatternWindow () //this.patternWindow.Show(); } + [SupportedOSPlatform("windows")] private void TestStatistic (PatternArgs patternArgs) { var beginLine = patternArgs.StartLine; - _logger.Info("TestStatistics() called with start line {0}", beginLine); + _logger.Info($"TestStatistics() called with start line {beginLine}"); _patternArgs = patternArgs; @@ -3115,7 +3169,7 @@ private void TestStatistic (PatternArgs patternArgs) processedLinesDict)) != null) { _logger.Debug("Found block: {0}", block); - if (block.weigth >= _patternArgs.MinWeight) + if (block.Weigth >= _patternArgs.MinWeight) { //PatternBlock existingBlock = FindExistingBlock(block, blockList); //if (existingBlock != null) @@ -3129,18 +3183,18 @@ private void TestStatistic (PatternArgs patternArgs) //else { blockList.Add(block); - addBlockTargetLinesToDict(processedLinesDict, block); + AddBlockTargetLinesToDict(processedLinesDict, block); } - block.blockId = blockId; + block.BlockId = blockId; //if (firstBlock) //{ // addBlockSrcLinesToDict(processedLinesDict, block); //} - searchLine = block.targetEnd + 1; + searchLine = block.TargetEnd + 1; } else { - searchLine = block.targetStart + 1; + searchLine = block.TargetStart + 1; } UpdateProgressBar(searchLine); @@ -3163,14 +3217,11 @@ private void TestStatistic (PatternArgs patternArgs) _logger.Info("TestStatistics() ended"); } - private void addBlockTargetLinesToDict (Dictionary dict, PatternBlock block) + private void AddBlockTargetLinesToDict (Dictionary dict, PatternBlock block) { - foreach (var lineNum in block.targetLines.Keys) + foreach (var lineNum in block.TargetLines.Keys) { - if (!dict.ContainsKey(lineNum)) - { - dict.Add(lineNum, lineNum); - } + _ = dict.TryAdd(lineNum, lineNum); } } @@ -3179,12 +3230,10 @@ private PatternBlock FindExistingBlock (PatternBlock block, List b { foreach (PatternBlock searchBlock in blockList) { - if ((block.startLine > searchBlock.startLine && - block.startLine < searchBlock.endLine - || - block.endLine > searchBlock.startLine && - block.endLine < searchBlock.endLine) && block.startLine != searchBlock.startLine && - block.endLine != searchBlock.endLine + if (((block.StartLine > searchBlock.StartLine && block.StartLine < searchBlock.EndLine) || + (block.EndLine > searchBlock.StartLine && block.EndLine < searchBlock.EndLine)) && + block.StartLine != searchBlock.StartLine && + block.EndLine != searchBlock.EndLine ) { return searchBlock; @@ -3194,8 +3243,7 @@ private PatternBlock FindExistingBlock (PatternBlock block, List b return null; } - private PatternBlock DetectBlock (int startNum, int startLineToSearch, int maxBlockLen, int maxDiffInBlock, - int maxMisses, Dictionary processedLinesDict) + private PatternBlock DetectBlock (int startNum, int startLineToSearch, int maxBlockLen, int maxDiffInBlock, int maxMisses, Dictionary processedLinesDict) { var targetLine = FindSimilarLine(startNum, startLineToSearch, processedLinesDict); if (targetLine == -1) @@ -3203,17 +3251,21 @@ private PatternBlock DetectBlock (int startNum, int startLineToSearch, int maxBl return null; } - PatternBlock block = new(); - block.startLine = startNum; - var srcLine = block.startLine; - block.targetStart = targetLine; + PatternBlock block = new() + { + StartLine = startNum + }; + var srcLine = block.StartLine; + block.TargetStart = targetLine; var srcMisses = 0; - block.srcLines.Add(srcLine, srcLine); + block.SrcLines.Add(srcLine, srcLine); //block.targetLines.Add(targetLine, targetLine); var len = 0; - QualityInfo qi = new(); - qi.quality = block.weigth; - block.qualityInfoList[targetLine] = qi; + QualityInfo qi = new() + { + Quality = block.Weigth + }; + block.QualityInfoList[targetLine] = qi; while (!_shouldCancel) { @@ -3229,34 +3281,40 @@ private PatternBlock DetectBlock (int startNum, int startLineToSearch, int maxBl var nextTargetLine = FindSimilarLine(srcLine, targetLine + 1, processedLinesDict); if (nextTargetLine > -1 && nextTargetLine - targetLine - 1 <= maxDiffInBlock) { - block.weigth += maxDiffInBlock - (nextTargetLine - targetLine - 1) + 1; - block.endLine = srcLine; + block.Weigth += maxDiffInBlock - (nextTargetLine - targetLine - 1) + 1; + block.EndLine = srcLine; //block.targetLines.Add(nextTargetLine, nextTargetLine); - block.srcLines.Add(srcLine, srcLine); + block.SrcLines.Add(srcLine, srcLine); if (nextTargetLine - targetLine > 1) { - var tempWeight = block.weigth; + var tempWeight = block.Weigth; for (var tl = targetLine + 1; tl < nextTargetLine; ++tl) { - qi = new QualityInfo(); - qi.quality = --tempWeight; - block.qualityInfoList[tl] = qi; + qi = new QualityInfo + { + Quality = --tempWeight + }; + block.QualityInfoList[tl] = qi; } } targetLine = nextTargetLine; - qi = new QualityInfo(); - qi.quality = block.weigth; - block.qualityInfoList[targetLine] = qi; + qi = new QualityInfo + { + Quality = block.Weigth + }; + block.QualityInfoList[targetLine] = qi; } else { srcMisses++; - block.weigth--; + block.Weigth--; targetLine++; - qi = new QualityInfo(); - qi.quality = block.weigth; - block.qualityInfoList[targetLine] = qi; + qi = new QualityInfo + { + Quality = block.Weigth + }; + block.QualityInfoList[targetLine] = qi; if (srcMisses > maxMisses) { break; @@ -3264,13 +3322,17 @@ private PatternBlock DetectBlock (int startNum, int startLineToSearch, int maxBl } } - block.targetEnd = targetLine; - qi = new QualityInfo(); - qi.quality = block.weigth; - block.qualityInfoList[targetLine] = qi; - for (var k = block.targetStart; k <= block.targetEnd; ++k) + block.TargetEnd = targetLine; + qi = new QualityInfo + { + Quality = block.Weigth + }; + + block.QualityInfoList[targetLine] = qi; + + for (var k = block.TargetStart; k <= block.TargetEnd; ++k) { - block.targetLines.Add(k, k); + block.TargetLines.Add(k, k); } return block; @@ -3288,7 +3350,7 @@ private void PrepareDict () var msg = GetMsgForLine(i); if (msg != null) { - msg = msg.ToLower(); + msg = msg.ToLowerInvariant(); msg = regex.Replace(msg, "0"); msg = regex2.Replace(msg, " "); var chars = msg.ToCharArray(); @@ -3321,7 +3383,7 @@ private void PrepareDict () } } - private int _FindSimilarLine (int srcLine, int startLine) + private int FindSimilarLine (int srcLine, int startLine) { var value = _lineHashList[srcLine]; @@ -3424,6 +3486,7 @@ private string GetMsgForLine (int i) return cols.ColumnValues.Last().FullValue; } + [SupportedOSPlatform("windows")] private void ChangeRowHeight (bool decrease) { var rowNum = dataGridView.CurrentCellAddress.Y; @@ -3434,13 +3497,12 @@ private void ChangeRowHeight (bool decrease) if (decrease) { - if (!_rowHeightList.ContainsKey(rowNum)) + if (!_rowHeightList.TryGetValue(rowNum, out RowHeightEntry? entry)) { return; } else { - RowHeightEntry entry = _rowHeightList[rowNum]; entry.Height -= _lineHeight; if (entry.Height <= _lineHeight) { @@ -3451,16 +3513,19 @@ private void ChangeRowHeight (bool decrease) else { RowHeightEntry entry; - if (!_rowHeightList.ContainsKey(rowNum)) + if (!_rowHeightList.TryGetValue(rowNum, out RowHeightEntry? value)) { - entry = new RowHeightEntry(); - entry.LineNum = rowNum; - entry.Height = _lineHeight; + entry = new RowHeightEntry + { + LineNum = rowNum, + Height = _lineHeight + }; + _rowHeightList[rowNum] = entry; } else { - entry = _rowHeightList[rowNum]; + entry = value; } entry.Height += _lineHeight; @@ -3477,14 +3542,9 @@ private void ChangeRowHeight (bool decrease) private int GetRowHeight (int rowNum) { - if (_rowHeightList.ContainsKey(rowNum)) - { - return _rowHeightList[rowNum].Height; - } - else - { - return _lineHeight; - } + return _rowHeightList.TryGetValue(rowNum, out RowHeightEntry? value) + ? value.Height + : _lineHeight; } private void AddBookmarkAtLineSilently (int lineNum) @@ -3495,6 +3555,7 @@ private void AddBookmarkAtLineSilently (int lineNum) } } + [SupportedOSPlatform("windows")] private void AddBookmarkAndEditComment () { var lineNum = dataGridView.CurrentCellAddress.Y; @@ -3506,6 +3567,7 @@ private void AddBookmarkAndEditComment () BookmarkComment(_bookmarkProvider.GetBookmarkForLine(lineNum)); } + [SupportedOSPlatform("windows")] private void AddBookmarkComment (string text) { var lineNum = dataGridView.CurrentCellAddress.Y; @@ -3525,6 +3587,7 @@ private void AddBookmarkComment (string text) OnBookmarkTextChanged(bookmark); } + [SupportedOSPlatform("windows")] private void MarkCurrentFilterRange () { _filterParams.RangeSearchText = filterRangeComboBox.Text; @@ -3545,6 +3608,7 @@ private void MarkCurrentFilterRange () } } + [SupportedOSPlatform("windows")] private void RemoveTempHighlights () { lock (_tempHighlightEntryListLock) @@ -3555,6 +3619,7 @@ private void RemoveTempHighlights () RefreshAllGrids(); } + [SupportedOSPlatform("windows")] private void ToggleHighlightPanel (bool open) { highlightSplitContainer.Panel2Collapsed = !open; @@ -3563,6 +3628,7 @@ private void ToggleHighlightPanel (bool open) : new Bitmap(_panelOpenButtonImage, new Size(btnToggleHighlightPanel.Size.Height, btnToggleHighlightPanel.Size.Height)); } + [SupportedOSPlatform("windows")] private void SetBookmarksForSelectedFilterLines () { lock (_filterResultList) @@ -3592,6 +3658,7 @@ private void SetDefaultHighlightGroup () } } + [SupportedOSPlatform("windows")] private void HandleChangedFilterOnLoadSetting () { _parentLogTabWin.Preferences.isFilterOnLoad = filterOnLoadCheckBox.Checked; @@ -3603,7 +3670,7 @@ private void FireCancelHandlers () { lock (_cancelHandlerList) { - foreach (var handler in _cancelHandlerList) + foreach (Core.Interface.IBackgroundProcessCancelHandler handler in _cancelHandlerList) { handler.EscapePressed(); } @@ -3618,6 +3685,7 @@ private void SyncOtherWindows (DateTime timestamp) } } + [SupportedOSPlatform("windows")] private void AddSlaveToTimesync (LogWindow slave) { lock (_timeSyncListLock) @@ -3660,6 +3728,7 @@ private void OnSyncModeChanged () SyncModeChanged?.Invoke(this, new SyncModeEventArgs(IsTimeSynced)); } + [SupportedOSPlatform("windows")] private void AddSearchHitHighlightEntry (SearchParams para) { HighlightEntry he = new() @@ -3686,6 +3755,7 @@ private void AddSearchHitHighlightEntry (SearchParams para) RefreshAllGrids(); } + [SupportedOSPlatform("windows")] private void RemoveAllSearchHighlightEntries () { lock (_tempHighlightEntryListLock) @@ -3705,11 +3775,12 @@ private void RemoveAllSearchHighlightEntries () RefreshAllGrids(); } + [SupportedOSPlatform("windows")] private DataGridViewColumn GetColumnByName (BufferedDataGridView dataGridView, string name) { foreach (DataGridViewColumn col in dataGridView.Columns) { - if (col.HeaderText.Equals(name)) + if (col.HeaderText.Equals(name, StringComparison.Ordinal)) { return col; } @@ -3718,6 +3789,7 @@ private DataGridViewColumn GetColumnByName (BufferedDataGridView dataGridView, s return null; } + [SupportedOSPlatform("windows")] private void SelectColumn () { var colName = columnComboBox.SelectedItem as string; diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs index 20e1451e..6a4c227e 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs @@ -212,12 +212,12 @@ public PersistenceData GetPersistenceData () { PersistenceData persistenceData = new() { - bookmarkList = _bookmarkProvider.BookmarkList, + BookmarkList = _bookmarkProvider.BookmarkList, rowHeightList = _rowHeightList, multiFile = IsMultiFile, multiFilePattern = _multiFileOptions.FormatPattern, multiFileMaxDays = _multiFileOptions.MaxDayTry, - currentLine = dataGridView.CurrentCellAddress.Y, + CurrentLine = dataGridView.CurrentCellAddress.Y, firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex, filterVisible = !splitContainerLogWindow.Panel2Collapsed, filterAdvanced = !advancedFilterSplitContainer.Panel1Collapsed, @@ -226,7 +226,7 @@ public PersistenceData GetPersistenceData () fileName = FileName, tabName = Text, sessionFileName = SessionFileName, - columnizerName = CurrentColumnizer.GetName(), + ColumnizerName = CurrentColumnizer.GetName(), lineCount = _logFileReader.LineCount }; diff --git a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs index d7d9ae3b..f0c6cb84 100644 --- a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs @@ -1,10 +1,6 @@ -using LogExpert.Core.Classes; +using LogExpert.Core.Classes; using LogExpert.Core.EventArguments; using LogExpert.Dialogs; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Windows.Forms; namespace LogExpert.UI.Controls.LogWindow; @@ -23,12 +19,12 @@ internal partial class PatternWindow : Form //TODO: Can this be changed to UserC #region cTor - public PatternWindow() + public PatternWindow () { InitializeComponent(); } - public PatternWindow(LogWindow logWindow) + public PatternWindow (LogWindow logWindow) { this.logWindow = logWindow; InitializeComponent(); @@ -67,7 +63,7 @@ public int Weight #region Public methods - public void SetBlockList(List flatBlockList, PatternArgs patternArgs) + public void SetBlockList (List flatBlockList, PatternArgs patternArgs) { this.patternArgs = patternArgs; blockList.Clear(); @@ -99,7 +95,7 @@ public void SetBlockList(List flatBlockList, PatternArgs patternAr } - public void SetColumnizer(ILogLineColumnizer columnizer) + public void SetColumnizer (ILogLineColumnizer columnizer) { logWindow.SetColumnizer(columnizer, patternHitsDataGridView); logWindow.SetColumnizer(columnizer, contentDataGridView); @@ -126,7 +122,7 @@ public void SetColumnizer(ILogLineColumnizer columnizer) contentDataGridView.Columns.Insert(1, contentInfoColumn); } - public void SetFont(string fontName, float fontSize) + public void SetFont (string fontName, float fontSize) { Font font = new(new FontFamily(fontName), fontSize); var lineSpacing = font.FontFamily.GetLineSpacing(FontStyle.Regular); @@ -143,7 +139,7 @@ public void SetFont(string fontName, float fontSize) #region Private Methods - private void SetBlockListGuiStuff() + private void SetBlockListGuiStuff () { patternHitsDataGridView.RowCount = 0; blockCountLabel.Text = "0"; @@ -157,7 +153,7 @@ private void SetBlockListGuiStuff() } } - private void SetCurrentList(List patternList) + private void SetCurrentList (List patternList) { patternHitsDataGridView.RowCount = 0; currentList = patternList; @@ -166,17 +162,17 @@ private void SetCurrentList(List patternList) blockCountLabel.Text = "" + currentList.Count; } - private int GetLineForHitGrid(int rowIndex) + private int GetLineForHitGrid (int rowIndex) { int line; - line = currentList[rowIndex].targetStart; + line = currentList[rowIndex].TargetStart; return line; } - private int GetLineForContentGrid(int rowIndex) + private int GetLineForContentGrid (int rowIndex) { int line; - line = currentBlock.targetStart + rowIndex; + line = currentBlock.TargetStart + rowIndex; return line; } @@ -184,7 +180,7 @@ private int GetLineForContentGrid(int rowIndex) #region Events handler - private void patternHitsDataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) + private void patternHitsDataGridView_CellValueNeeded (object sender, DataGridViewCellValueEventArgs e) { if (currentList == null || e.RowIndex < 0) { @@ -194,7 +190,7 @@ private void patternHitsDataGridView_CellValueNeeded(object sender, DataGridView var colIndex = e.ColumnIndex; if (colIndex == 1) { - e.Value = currentList[e.RowIndex].weigth; + e.Value = currentList[e.RowIndex].Weigth; } else { @@ -202,16 +198,18 @@ private void patternHitsDataGridView_CellValueNeeded(object sender, DataGridView { colIndex--; // correct the additional inserted col } + e.Value = logWindow.GetCellValue(rowIndex, colIndex); } } - private void patternHitsDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) + private void patternHitsDataGridView_CellPainting (object sender, DataGridViewCellPaintingEventArgs e) { if (currentList == null || e.RowIndex < 0) { return; } + if (e.ColumnIndex == 1) { e.PaintBackground(e.CellBounds, false); @@ -239,7 +237,7 @@ private void patternHitsDataGridView_CellPainting(object sender, DataGridViewCel } } - private void patternHitsDataGridView_MouseDoubleClick(object sender, MouseEventArgs e) + private void patternHitsDataGridView_MouseDoubleClick (object sender, MouseEventArgs e) { //if (this.currentList == null || patternHitsDataGridView.CurrentRow == null) // return; @@ -248,25 +246,27 @@ private void patternHitsDataGridView_MouseDoubleClick(object sender, MouseEventA //this.logWindow.SelectLogLine(rowIndex); } - private void patternHitsDataGridView_CurrentCellChanged(object sender, EventArgs e) + private void patternHitsDataGridView_CurrentCellChanged (object sender, EventArgs e) { if (currentList == null || patternHitsDataGridView.CurrentRow == null) { return; } + if (patternHitsDataGridView.CurrentRow.Index > currentList.Count - 1) { return; } + contentDataGridView.RowCount = 0; currentBlock = currentList[patternHitsDataGridView.CurrentRow.Index]; - contentDataGridView.RowCount = currentBlock.targetEnd - currentBlock.targetStart + 1; + contentDataGridView.RowCount = currentBlock.TargetEnd - currentBlock.TargetStart + 1; contentDataGridView.Refresh(); contentDataGridView.CurrentCell = contentDataGridView.Rows[0].Cells[0]; blockLinesLabel.Text = "" + contentDataGridView.RowCount; } - private void contentDataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) + private void contentDataGridView_CellValueNeeded (object sender, DataGridViewCellValueEventArgs e) { if (currentBlock == null || e.RowIndex < 0) { @@ -277,9 +277,9 @@ private void contentDataGridView_CellValueNeeded(object sender, DataGridViewCell if (colIndex == 1) { QualityInfo qi; - if (currentBlock.qualityInfoList.TryGetValue(rowIndex, out qi)) + if (currentBlock.QualityInfoList.TryGetValue(rowIndex, out qi)) { - e.Value = qi.quality; + e.Value = qi.Quality; } else { @@ -296,7 +296,7 @@ private void contentDataGridView_CellValueNeeded(object sender, DataGridViewCell } } - private void contentDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) + private void contentDataGridView_CellPainting (object sender, DataGridViewCellPaintingEventArgs e) { if (currentBlock == null || e.RowIndex < 0) { @@ -307,7 +307,7 @@ private void contentDataGridView_CellPainting(object sender, DataGridViewCellPai logWindow.CellPainting(gridView, rowIndex, e); } - private void contentDataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) + private void contentDataGridView_CellMouseDoubleClick (object sender, DataGridViewCellMouseEventArgs e) { if (currentBlock == null || contentDataGridView.CurrentRow == null) { @@ -318,7 +318,7 @@ private void contentDataGridView_CellMouseDoubleClick(object sender, DataGridVie logWindow.SelectLogLine(rowIndex); } - private void recalcButton_Click(object sender, EventArgs e) + private void recalcButton_Click (object sender, EventArgs e) { patternArgs.Fuzzy = fuzzyKnobControl.Value; patternArgs.MaxDiffInBlock = maxDiffKnobControl.Value; @@ -329,26 +329,26 @@ private void recalcButton_Click(object sender, EventArgs e) setRangeButton.Enabled = false; } - private void closeButton_Click(object sender, EventArgs e) + private void closeButton_Click (object sender, EventArgs e) { Close(); } - private void contentDataGridView_ColumnDividerDoubleClick(object sender, + private void contentDataGridView_ColumnDividerDoubleClick (object sender, DataGridViewColumnDividerDoubleClickEventArgs e) { e.Handled = true; contentDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); } - private void patternHitsDataGridView_ColumnDividerDoubleClick(object sender, + private void patternHitsDataGridView_ColumnDividerDoubleClick (object sender, DataGridViewColumnDividerDoubleClickEventArgs e) { e.Handled = true; patternHitsDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); } - private void setRangeButton_Click(object sender, EventArgs e) + private void setRangeButton_Click (object sender, EventArgs e) { logWindow.PatternStatisticSelectRange(patternArgs); recalcButton.Enabled = true; diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs index 952136e7..0d7d3e04 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs @@ -1,6 +1,9 @@ -using LogExpert.Core.Classes; +using System.Runtime.Versioning; + +using LogExpert.Core.Classes; using LogExpert.Core.EventArguments; using LogExpert.UI.Extensions; + using NLog; namespace LogExpert.UI.Controls.LogWindow; @@ -25,7 +28,8 @@ internal partial class TimeSpreadingControl : UserControl #region cTor - public TimeSpreadingControl() + [SupportedOSPlatform("windows")] + public TimeSpreadingControl () { InitializeComponent(); _toolTip = new ToolTip(); @@ -40,7 +44,7 @@ public TimeSpreadingControl() #region Delegates - public delegate void LineSelectedEventHandler(object sender, SelectLineEventArgs e); + public delegate void LineSelectedEventHandler (object sender, SelectLineEventArgs e); #endregion @@ -70,7 +74,7 @@ internal TimeSpreadCalculator TimeSpreadCalc #region Overrides - protected override void OnPaint(PaintEventArgs e) + protected override void OnPaint (PaintEventArgs e) { base.OnPaint(e); lock (_monitor) @@ -94,7 +98,7 @@ protected override void OnPaint(PaintEventArgs e) #region Private Methods - private SpreadEntry GetEntryForMouse(MouseEventArgs e) + private SpreadEntry GetEntryForMouse (MouseEventArgs e) { List list = TimeSpreadCalc.DiffList; var y = e.Y - _edgeOffset; @@ -121,7 +125,7 @@ private SpreadEntry GetEntryForMouse(MouseEventArgs e) } } - private void DragContrast(MouseEventArgs e) + private void DragContrast (MouseEventArgs e) { if (_lastMouseY == 0) { @@ -132,7 +136,7 @@ private void DragContrast(MouseEventArgs e) _lastMouseY = e.Y; } - private void OnLineSelected(SelectLineEventArgs e) + private void OnLineSelected (SelectLineEventArgs e) { LineSelected?.Invoke(this, e); } @@ -141,7 +145,8 @@ private void OnLineSelected(SelectLineEventArgs e) #region Events handler - private void TimeSpreadCalc_CalcDone(object sender, EventArgs e) + [SupportedOSPlatform("windows")] + private void TimeSpreadCalc_CalcDone (object sender, EventArgs e) { _logger.Debug("timeSpreadCalc_CalcDone()"); @@ -203,10 +208,12 @@ private void TimeSpreadCalc_CalcDone(object sender, EventArgs e) } } } + BeginInvoke(new MethodInvoker(Refresh)); } - private void TimeSpreadCalc_StartCalc(object sender, EventArgs e) + [SupportedOSPlatform("windows")] + private void TimeSpreadCalc_StartCalc (object sender, EventArgs e) { lock (_monitor) { @@ -241,7 +248,8 @@ private void TimeSpreadCalc_StartCalc(object sender, EventArgs e) BeginInvoke(new MethodInvoker(Refresh)); } - private void TimeSpreadingControl_SizeChanged(object sender, EventArgs e) + [SupportedOSPlatform("windows")] + private void TimeSpreadingControl_SizeChanged (object sender, EventArgs e) { if (TimeSpreadCalc != null) { @@ -250,11 +258,12 @@ private void TimeSpreadingControl_SizeChanged(object sender, EventArgs e) } } - private void TimeSpreadingControl_MouseDown(object sender, MouseEventArgs e) + private void TimeSpreadingControl_MouseDown (object sender, MouseEventArgs e) { } - private void TimeSpreadingControl_MouseUp(object sender, MouseEventArgs e) + [SupportedOSPlatform("windows")] + private void TimeSpreadingControl_MouseUp (object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { @@ -267,17 +276,20 @@ private void TimeSpreadingControl_MouseUp(object sender, MouseEventArgs e) } } - private void TimeSpreadingControl_MouseEnter(object sender, EventArgs e) + [SupportedOSPlatform("windows")] + private void TimeSpreadingControl_MouseEnter (object sender, EventArgs e) { _toolTip.Active = true; } - private void TimeSpreadingControl_MouseLeave(object sender, EventArgs e) + [SupportedOSPlatform("windows")] + private void TimeSpreadingControl_MouseLeave (object sender, EventArgs e) { _toolTip.Active = false; } - private void TimeSpreadingControl_MouseMove(object sender, MouseEventArgs e) + [SupportedOSPlatform("windows")] + private void TimeSpreadingControl_MouseMove (object sender, MouseEventArgs e) { if (e.Y == _lastMouseY) { @@ -296,6 +308,7 @@ private void TimeSpreadingControl_MouseMove(object sender, MouseEventArgs e) { return; } + _lastMouseY = e.Y; var dts = entry.Timestamp.ToString("dd.MM.yyyy HH:mm:ss"); _toolTip.SetToolTip(this, "Line " + (entry.LineNum + 1) + "\n" + dts); diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs index 1b7a06a0..7c46803b 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs @@ -1,4 +1,6 @@ -using LogExpert.Core.Classes.Highlight; +using System.Text.RegularExpressions; + +using LogExpert.Core.Classes.Highlight; using LogExpert.Core.Entities; using LogExpert.Core.Interface; using LogExpert.UI.Controls; @@ -6,14 +8,6 @@ using NLog; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Text.RegularExpressions; -using System.Windows.Forms; - namespace LogExpert.Dialogs; public partial class HighlightDialog : Form @@ -32,7 +26,7 @@ public partial class HighlightDialog : Form #region Ctor - public HighlightDialog(IConfigManager configManager) + public HighlightDialog (IConfigManager configManager) { InitializeComponent(); @@ -75,18 +69,18 @@ public List HighlightGroupList #region Event handling Methods - private void OnAddButtonClick(object sender, EventArgs e) + private void OnAddButtonClick (object sender, EventArgs e) { AddNewEntry(); Dirty(); } - private void OnBtnApplyClick(object sender, EventArgs e) + private void OnBtnApplyClick (object sender, EventArgs e) { SaveEntry(); } - private void OnBtnBookmarkCommentClick(object sender, EventArgs e) + private void OnBtnBookmarkCommentClick (object sender, EventArgs e) { BookmarkCommentDlg dlg = new(); dlg.Comment = _bookmarkComment; @@ -97,7 +91,7 @@ private void OnBtnBookmarkCommentClick(object sender, EventArgs e) } } - private void OnBtnCopyGroupClick(object sender, EventArgs e) + private void OnBtnCopyGroupClick (object sender, EventArgs e) { if (comboBoxGroups.SelectedIndex >= 0 && comboBoxGroups.SelectedIndex < HighlightGroupList.Count) { @@ -110,19 +104,19 @@ private void OnBtnCopyGroupClick(object sender, EventArgs e) } } - private void OnBtnCustomBackColorClick(object sender, EventArgs e) + private void OnBtnCustomBackColorClick (object sender, EventArgs e) { ChooseColor(colorBoxBackground); Dirty(); } - private void OnBtnCustomForeColorClick(object sender, EventArgs e) + private void OnBtnCustomForeColorClick (object sender, EventArgs e) { ChooseColor(colorBoxForeground); Dirty(); } - private void OnBtnDelGroupClick(object sender, EventArgs e) + private void OnBtnDelGroupClick (object sender, EventArgs e) { // the last group cannot be deleted if (HighlightGroupList.Count == 1) @@ -147,7 +141,7 @@ private void OnBtnDelGroupClick(object sender, EventArgs e) } //TODO: This class should not knoow ConfigManager? - private void OnBtnExportGroupClick(object sender, EventArgs e) + private void OnBtnExportGroupClick (object sender, EventArgs e) { SaveFileDialog dlg = new() { @@ -164,7 +158,7 @@ private void OnBtnExportGroupClick(object sender, EventArgs e) } } - private void OnBtnGroupDownClick(object sender, EventArgs e) + private void OnBtnGroupDownClick (object sender, EventArgs e) { var index = comboBoxGroups.SelectedIndex; if (index > -1 && index < _highlightGroupList.Count - 1) @@ -176,7 +170,7 @@ private void OnBtnGroupDownClick(object sender, EventArgs e) } } - private void OnBtnGroupUpClick(object sender, EventArgs e) + private void OnBtnGroupUpClick (object sender, EventArgs e) { var index = comboBoxGroups.SelectedIndex; if (index > 0) @@ -188,7 +182,7 @@ private void OnBtnGroupUpClick(object sender, EventArgs e) } } - private void OnBtnImportGroupClick(object sender, EventArgs e) + private void OnBtnImportGroupClick (object sender, EventArgs e) { ImportSettingsDialog dlg = new(Core.Config.ExportImportFlags.HighlightSettings); @@ -238,7 +232,7 @@ private void OnBtnImportGroupClick(object sender, EventArgs e) MessageBox.Show(this, @"Settings imported", @"LogExpert"); } - private void OnBtnMoveDownClick(object sender, EventArgs e) + private void OnBtnMoveDownClick (object sender, EventArgs e) { var index = listBoxHighlight.SelectedIndex; @@ -252,7 +246,7 @@ private void OnBtnMoveDownClick(object sender, EventArgs e) } } - private void OnBtnMoveUpClick(object sender, EventArgs e) + private void OnBtnMoveUpClick (object sender, EventArgs e) { var index = listBoxHighlight.SelectedIndex; if (index > 0) @@ -265,7 +259,7 @@ private void OnBtnMoveUpClick(object sender, EventArgs e) } } - private void OnBtnNewGroupClick(object sender, EventArgs e) + private void OnBtnNewGroupClick (object sender, EventArgs e) { // Propose a unique name const string baseName = "New group"; @@ -274,7 +268,8 @@ private void OnBtnNewGroupClick(object sender, EventArgs e) var i = 1; while (!uniqueName) { - uniqueName = HighlightGroupList.FindIndex(delegate (HighlightGroup g) { return g.GroupName == name; }) < 0; + uniqueName = HighlightGroupList.FindIndex(delegate (HighlightGroup g) + { return g.GroupName == name; }) < 0; if (!uniqueName) { @@ -288,7 +283,7 @@ private void OnBtnNewGroupClick(object sender, EventArgs e) SelectGroup(HighlightGroupList.Count - 1); } - private void OnBtnOkClick(object sender, EventArgs e) + private void OnBtnOkClick (object sender, EventArgs e) { // Apply pending changes if closing the form. if (IsDirty) @@ -298,25 +293,25 @@ private void OnBtnOkClick(object sender, EventArgs e) } } - private void OnChkBoxBoldCheckedChanged(object sender, EventArgs e) + private void OnChkBoxBoldCheckedChanged (object sender, EventArgs e) { Dirty(); } - private void OnChkBoxNoBackgroundCheckedChanged(object sender, EventArgs e) + private void OnChkBoxNoBackgroundCheckedChanged (object sender, EventArgs e) { colorBoxBackground.Enabled = !checkBoxNoBackground.Checked; btnCustomBackColor.Enabled = !checkBoxNoBackground.Checked; Dirty(); } - private void OnChkBoxPluginCheckedChanged(object sender, EventArgs e) + private void OnChkBoxPluginCheckedChanged (object sender, EventArgs e) { Dirty(); btnSelectPlugin.Enabled = checkBoxPlugin.Checked; } - private void OnChkBoxRegexMouseUp(object sender, MouseEventArgs e) + private void OnChkBoxRegexMouseUp (object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { @@ -335,13 +330,13 @@ private void OnChkBoxRegexMouseUp(object sender, MouseEventArgs e) } } - private void OnChkBoxWordMatchCheckedChanged(object sender, EventArgs e) + private void OnChkBoxWordMatchCheckedChanged (object sender, EventArgs e) { Dirty(); checkBoxNoBackground.Enabled = checkBoxWordMatch.Checked; } - private void OnCmbBoxGroupDrawItem(object sender, DrawItemEventArgs e) + private void OnCmbBoxGroupDrawItem (object sender, DrawItemEventArgs e) { e.DrawBackground(); if (e.Index >= 0) @@ -356,17 +351,17 @@ private void OnCmbBoxGroupDrawItem(object sender, DrawItemEventArgs e) } } - private void OnCmbBoxGroupSelectionChangeCommitted(object sender, EventArgs e) + private void OnCmbBoxGroupSelectionChangeCommitted (object sender, EventArgs e) { SelectGroup(comboBoxGroups.SelectedIndex); } - private void OnCmbBoxGroupTextUpdate(object sender, EventArgs e) + private void OnCmbBoxGroupTextUpdate (object sender, EventArgs e) { _currentGroup.GroupName = comboBoxGroups.Text; } - private void OnDeleteButtonClick(object sender, EventArgs e) + private void OnDeleteButtonClick (object sender, EventArgs e) { if (listBoxHighlight.SelectedIndex >= 0) { @@ -390,7 +385,7 @@ private void OnDeleteButtonClick(object sender, EventArgs e) } } - private void OnHighlightDialogLoad(object sender, EventArgs e) + private void OnHighlightDialogLoad (object sender, EventArgs e) { colorBoxForeground.SelectedIndex = 1; colorBoxBackground.SelectedIndex = 2; @@ -402,12 +397,12 @@ private void OnHighlightDialogLoad(object sender, EventArgs e) ReEvaluateHighlightButtonStates(); } - private void OnHighlightDialogShown(object sender, EventArgs e) + private void OnHighlightDialogShown (object sender, EventArgs e) { InitData(); } - private void OnHighlightListBoxDrawItem(object sender, DrawItemEventArgs e) + private void OnHighlightListBoxDrawItem (object sender, DrawItemEventArgs e) { e.DrawBackground(); if (e.Index >= 0) @@ -427,12 +422,12 @@ private void OnHighlightListBoxDrawItem(object sender, DrawItemEventArgs e) } } - private void OnListBoxHighlightSelectedIndexChanged(object sender, EventArgs e) + private void OnListBoxHighlightSelectedIndexChanged (object sender, EventArgs e) { StartEditEntry(); } - private void OnPluginButtonClick(object sender, EventArgs e) + private void OnPluginButtonClick (object sender, EventArgs e) { KeywordActionDlg dlg = new(_currentActionEntry, KeywordActionList); @@ -447,7 +442,7 @@ private void OnPluginButtonClick(object sender, EventArgs e) #region Private Methods - private void AddNewEntry() + private void AddNewEntry () { { try @@ -485,12 +480,12 @@ private void AddNewEntry() } } - private void ChangeToDirty(object sender, EventArgs e) + private void ChangeToDirty (object sender, EventArgs e) { Dirty(); } - private void CheckRegex() + private void CheckRegex () { if (checkBoxRegex.Checked) { @@ -504,7 +499,7 @@ private void CheckRegex() } } - private void ChooseColor(ColorComboBox comboBox) + private void ChooseColor (ColorComboBox comboBox) { ColorDialog colorDialog = new(); colorDialog.AllowFullOpen = true; @@ -517,7 +512,7 @@ private void ChooseColor(ColorComboBox comboBox) } } - private void Dirty() + private void Dirty () { var index = listBoxHighlight.SelectedIndex; if (index > -1) @@ -529,7 +524,7 @@ private void Dirty() btnAdd.Enabled = textBoxSearchString.Text.Length > 0; } - private void FillGroupComboBox() + private void FillGroupComboBox () { SelectGroup(-1); @@ -543,7 +538,7 @@ private void FillGroupComboBox() ReEvaluateGroupButtonStates(); } - private void FillHighlightListBox() + private void FillHighlightListBox () { listBoxHighlight.Items.Clear(); if (_currentGroup != null) @@ -555,7 +550,7 @@ private void FillHighlightListBox() } } - private void InitData() + private void InitData () { const string def = "[Default]"; HighlightGroupList ??= []; @@ -582,7 +577,7 @@ private void InitData() foreach (HighlightGroup group in HighlightGroupList) { - if (group.GroupName.Equals(groupToSelect)) + if (group.GroupName.Equals(groupToSelect, StringComparison.Ordinal)) { _currentGroup = group; comboBoxGroups.SelectedValue = group; @@ -596,7 +591,7 @@ private void InitData() FillHighlightListBox(); } - private void ReEvaluateGroupButtonStates() + private void ReEvaluateGroupButtonStates () { // Refresh button states based on the selection in the combobox var atLeastOneSelected = comboBoxGroups.SelectedItem != null; @@ -610,7 +605,7 @@ private void ReEvaluateGroupButtonStates() btnMoveGroupDown.Enabled = atLeastOneSelected && moreThanOne && !lastSelected; } - private void ReEvaluateHighlightButtonStates() + private void ReEvaluateHighlightButtonStates () { // Refresh button states based on the selection in the combobox var atLeastOneSelected = listBoxHighlight.SelectedItem != null; @@ -623,7 +618,7 @@ private void ReEvaluateHighlightButtonStates() btnMoveDown.Enabled = atLeastOneSelected && moreThanOne && !lastSelected; } - private void SaveEntry() + private void SaveEntry () { try { @@ -656,7 +651,7 @@ private void SaveEntry() } } - private void SelectGroup(int index) + private void SelectGroup (int index) { if (index >= 0 && index < HighlightGroupList.Count) { @@ -677,7 +672,7 @@ private void SelectGroup(int index) ReEvaluateGroupButtonStates(); } - private void StartEditEntry() + private void StartEditEntry () { var entry = (HighlightEntry)listBoxHighlight.SelectedItem; diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs index 55e54962..fe6b126c 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs @@ -1,4 +1,5 @@ using System.Reflection; +using System.Runtime.Versioning; using System.Text; using LogExpert.Core.Config; @@ -22,7 +23,7 @@ public partial class LogTabWindow : Form, ILogTabWindow private const int MAX_COLOR_HISTORY = 40; private const int DIFF_MAX = 100; private const int MAX_FILE_HISTORY = 10; - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); private readonly Icon _deadIcon; private readonly Color _defaultTabColor = Color.FromArgb(255, 192, 192, 192); @@ -34,7 +35,7 @@ public partial class LogTabWindow : Form, ILogTabWindow private readonly Rectangle[] _leds = new Rectangle[5]; - private readonly IList _logWindowList = new List(); + private readonly IList _logWindowList = []; private readonly Brush _offLedBrush; private readonly bool _showInstanceNumbers; @@ -43,7 +44,10 @@ public partial class LogTabWindow : Form, ILogTabWindow private readonly EventWaitHandle _statusLineEventHandle = new AutoResetEvent(false); private readonly EventWaitHandle _statusLineEventWakeupHandle = new ManualResetEvent(false); private readonly Brush _syncLedBrush; + + [SupportedOSPlatform("windows")] private readonly StringFormat _tabStringFormat = new(); + private readonly Brush[] _tailLedBrush = new Brush[3]; private BookmarkWindow _bookmarkWindow; @@ -64,6 +68,8 @@ public partial class LogTabWindow : Form, ILogTabWindow #endregion #region cTor + + [SupportedOSPlatform("windows")] public LogTabWindow (string[] fileNames, int instanceNumber, bool showInstanceNumbers, IConfigManager configManager) { AutoScaleDimensions = new SizeF(96F, 96F); @@ -158,6 +164,8 @@ public LogTabWindow (string[] fileNames, int instanceNumber, bool showInstanceNu #endregion #region ColorTheme + + [SupportedOSPlatform("windows")] public void ChangeTheme (Control.ControlCollection container) { ColorMode.LoadColorMode(ConfigManager.Settings.Preferences.darkMode); @@ -189,7 +197,7 @@ public void ChangeTheme (Control.ControlCollection container) { for (var x = 0; x < item.DropDownItems.Count; x++) { - var children = item.DropDownItems[x]; + ToolStripItem children = item.DropDownItems[x]; children.ForeColor = ColorMode.ForeColor; children.BackColor = ColorMode.MenuBackgroundColor; @@ -197,7 +205,7 @@ public void ChangeTheme (Control.ControlCollection container) { for (var y = 0; y < toolstripDropDownItem.DropDownItems.Count; y++) { - var subChildren = toolstripDropDownItem.DropDownItems[y]; + ToolStripItem subChildren = toolstripDropDownItem.DropDownItems[y]; subChildren.ForeColor = ColorMode.ForeColor; subChildren.BackColor = ColorMode.MenuBackgroundColor; } @@ -228,7 +236,7 @@ public void ChangeTheme (Control.ControlCollection container) // Tabs menu for (var y = 0; y < tabContextMenuStrip.Items.Count; y++) { - var item = tabContextMenuStrip.Items[y]; + ToolStripItem item = tabContextMenuStrip.Items[y]; item.ForeColor = ColorMode.ForeColor; item.BackColor = ColorMode.MenuBackgroundColor; } @@ -284,6 +292,7 @@ public void ChangeTheme (Control.ControlCollection container) #region Properties + [SupportedOSPlatform("windows")] public LogWindow.LogWindow CurrentLogWindow { get => _currentLogWindow; @@ -314,11 +323,12 @@ internal HighlightGroup FindHighlightGroup (string groupName) { foreach (HighlightGroup group in HighlightGroupList) { - if (group.GroupName.Equals(groupName)) + if (group.GroupName.Equals(groupName, StringComparison.Ordinal)) { return group; } } + return null; } } @@ -330,13 +340,28 @@ private class LogWindowData #region Fields // public MdiTabControl.TabPage tabPage; - public Color color = Color.FromKnownColor(KnownColor.Gray); - public int diffSum; - public bool dirty; - public int syncMode; // 0 = off, 1 = timeSynced - public int tailState; // tailState: 0,1,2 = on/off/off by Trigger - public ToolTip toolTip; + public Color Color { get; set; } = Color.FromKnownColor(KnownColor.Gray); + + public int DiffSum { get; set; } + + public bool Dirty { get; set; } + + // tailState: + /// + /// 0 = on

    + /// 1 = off

    + /// 2 = off by Trigger

    + ///
    + public int TailState { get; set; } + + public ToolTip ToolTip { get; set; } + + /// + /// 0 = off

    + /// 1 = timeSynced + ///
    + public int SyncMode { get; set; } #endregion } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs index 034172db..e5b91364 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs @@ -1,5 +1,6 @@ using System.ComponentModel; using System.Diagnostics; +using System.Runtime.Versioning; using System.Text; using LogExpert.Core.Classes; @@ -294,6 +295,7 @@ private void OnLogWindowDragDrop (object sender, DragEventArgs e) } } + [SupportedOSPlatform("windows")] private void OnTimeShiftToolStripMenuItemCheckStateChanged (object sender, EventArgs e) { if (!_skipEvents && CurrentLogWindow != null) @@ -305,6 +307,7 @@ private void OnTimeShiftToolStripMenuItemCheckStateChanged (object sender, Event } } + [SupportedOSPlatform("windows")] private void OnAboutToolStripMenuItemClick (object sender, EventArgs e) { AboutBox aboutBox = new(); @@ -317,12 +320,14 @@ private void OnFilterToolStripMenuItemClick (object sender, EventArgs e) CurrentLogWindow?.ToggleFilterPanel(); } + [SupportedOSPlatform("windows")] private void OnMultiFileToolStripMenuItemClick (object sender, EventArgs e) { ToggleMultiFile(); fileToolStripMenuItem.HideDropDown(); } + [SupportedOSPlatform("windows")] private void OnGuiStateUpdate (object sender, GuiStateArgs e) { BeginInvoke(GuiStateUpdateWorker, e); @@ -384,6 +389,7 @@ private void OnCloseFileToolStripMenuItemClick (object sender, EventArgs e) CurrentLogWindow?.Close(); } + [SupportedOSPlatform("windows")] private void OnCellSelectModeToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.SetCellSelectionMode(cellSelectModeToolStripMenuItem.Checked); @@ -408,6 +414,7 @@ private void OnTimeShiftMenuTextBoxKeyDown (object sender, KeyEventArgs e) } } + [SupportedOSPlatform("windows")] private void OnAlwaysOnTopToolStripMenuItemClick (object sender, EventArgs e) { TopMost = alwaysOnTopToolStripMenuItem.Checked; @@ -427,19 +434,19 @@ private void OnFileSizeChanged (object sender, LogEventArgs e) { lock (data) { - data.diffSum += diff; - if (data.diffSum > DIFF_MAX) + data.DiffSum += diff; + if (data.DiffSum > DIFF_MAX) { - data.diffSum = DIFF_MAX; + data.DiffSum = DIFF_MAX; } } //if (this.dockPanel.ActiveContent != null && // this.dockPanel.ActiveContent != sender || data.tailState != 0) if (CurrentLogWindow != null && - CurrentLogWindow != sender || data.tailState != 0) + CurrentLogWindow != sender || data.TailState != 0) { - data.dirty = true; + data.Dirty = true; } Icon icon = GetIcon(diff, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); @@ -490,8 +497,8 @@ private void OnTailFollowed (object sender, EventArgs e) if (dockPanel.ActiveContent == sender) { var data = ((LogWindow.LogWindow)sender).Tag as LogWindowData; - data.dirty = false; - Icon icon = GetIcon(data.diffSum, data); + data.Dirty = false; + Icon icon = GetIcon(data.DiffSum, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); } } @@ -502,8 +509,8 @@ private void OnLogWindowSyncModeChanged (object sender, SyncModeEventArgs e) if (!Disposing) { var data = ((LogWindow.LogWindow)sender).Tag as LogWindowData; - data.syncMode = e.IsTimeSynced ? 1 : 0; - Icon icon = GetIcon(data.diffSum, data); + data.SyncMode = e.IsTimeSynced ? 1 : 0; + Icon icon = GetIcon(data.DiffSum, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); } else @@ -703,17 +710,17 @@ private void OnTabColorToolStripMenuItemClick (object sender, EventArgs e) } ColorDialog dlg = new(); - dlg.Color = data.color; + dlg.Color = data.Color; if (dlg.ShowDialog() == DialogResult.OK) { - data.color = dlg.Color; - SetTabColor(logWindow, data.color); + data.Color = dlg.Color; + SetTabColor(logWindow, data.Color); } List delList = []; foreach (ColorEntry entry in ConfigManager.Settings.fileColors) { - if (entry.FileName.ToLower().Equals(logWindow.FileName.ToLower())) + if (entry.FileName.Equals(logWindow.FileName, StringComparison.Ordinal)) { delList.Add(entry); } @@ -926,6 +933,7 @@ private void OnLogLevelToolStripMenuItemDropDownOpening (object sender, EventArg //debugToolStripMenuItem1.Checked = _logger.Get_logger().LogLevel == _logger.Level.DEBUG; } + [SupportedOSPlatform("windows")] private void OnDisableWordHighlightModeToolStripMenuItemClick (object sender, EventArgs e) { DebugOptions.DisableWordHighlight = disableWordHighlightModeToolStripMenuItem.Checked; @@ -937,6 +945,7 @@ private void OnMultiFileMaskToolStripMenuItemClick (object sender, EventArgs e) CurrentLogWindow?.ChangeMultifileMask(); } + [SupportedOSPlatform("windows")] private void OnMultiFileEnabledStripMenuItemClick (object sender, EventArgs e) { ToggleMultiFile(); @@ -947,22 +956,26 @@ private void OnLockInstanceToolStripMenuItemClick (object sender, EventArgs e) AbstractLogTabWindow.StaticData.CurrentLockedMainWindow = lockInstanceToolStripMenuItem.Checked ? null : this; } + [SupportedOSPlatform("windows")] private void OnOptionToolStripMenuItemDropDownOpening (object sender, EventArgs e) { lockInstanceToolStripMenuItem.Enabled = !ConfigManager.Settings.Preferences.allowOnlyOneInstance; lockInstanceToolStripMenuItem.Checked = AbstractLogTabWindow.StaticData.CurrentLockedMainWindow == this; } + [SupportedOSPlatform("windows")] private void OnFileToolStripMenuItemDropDownOpening (object sender, EventArgs e) { newFromClipboardToolStripMenuItem.Enabled = Clipboard.ContainsText(); } + [SupportedOSPlatform("windows")] private void OnNewFromClipboardToolStripMenuItemClick (object sender, EventArgs e) { PasteFromClipboard(); } + [SupportedOSPlatform("windows")] private void OnOpenURIToolStripMenuItemClick (object sender, EventArgs e) { OpenUriDialog dlg = new() @@ -981,6 +994,7 @@ private void OnOpenURIToolStripMenuItemClick (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnColumnFinderToolStripMenuItemClick (object sender, EventArgs e) { if (CurrentLogWindow != null && !_skipEvents) diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs index 173763fd..761608c2 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs @@ -4,7 +4,6 @@ using System.Security; using System.Text; -using LogExpert.Classes; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Columnizer; using LogExpert.Core.Classes.Persister; @@ -15,6 +14,7 @@ using LogExpert.Dialogs; using LogExpert.PluginRegistry.FileSystem; using LogExpert.UI.Dialogs; +using LogExpert.UI.Entities; using LogExpert.UI.Extensions; using WeifenLuo.WinFormsUI.Docking; @@ -175,7 +175,7 @@ private void AddLogWindow (LogWindow.LogWindow logWindow, string title, bool doN LogWindowData data = new() { - diffSum = 0 + DiffSum = 0 }; logWindow.Tag = data; @@ -819,10 +819,10 @@ private void ShowLedPeak (LogWindow.LogWindow logWin) var data = logWin.Tag as LogWindowData; lock (data) { - data.diffSum = DIFF_MAX; + data.DiffSum = DIFF_MAX; } - Icon icon = GetIcon(data.diffSum, data); + Icon icon = GetIcon(data.DiffSum, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, icon); } @@ -866,15 +866,15 @@ private void LedThreadProc () foreach (LogWindow.LogWindow logWindow in _logWindowList) { var data = logWindow.Tag as LogWindowData; - if (data.diffSum > 0) + if (data.DiffSum > 0) { - data.diffSum -= 10; - if (data.diffSum < 0) + data.DiffSum -= 10; + if (data.DiffSum < 0) { - data.diffSum = 0; + data.DiffSum = 0; } - Icon icon = GetIcon(data.diffSum, data); + Icon icon = GetIcon(data.DiffSum, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); } } @@ -896,8 +896,8 @@ private Icon GetIcon (int diff, LogWindowData data) { Icon icon = _ledIcons[ - GetLevelFromDiff(diff), data.dirty ? 1 : 0, Preferences.showTailState ? data.tailState : 3, - data.syncMode + GetLevelFromDiff(diff), data.Dirty ? 1 : 0, Preferences.showTailState ? data.TailState : 3, + data.SyncMode ]; return icon; } @@ -1018,7 +1018,7 @@ private void SetTabIcons (Preferences preferences) foreach (LogWindow.LogWindow logWindow in _logWindowList) { var data = logWindow.Tag as LogWindowData; - Icon icon = GetIcon(data.diffSum, data); + Icon icon = GetIcon(data.DiffSum, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); } } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs index a324dec3..6d5e93e6 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs @@ -1,3 +1,4 @@ +using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; @@ -18,36 +19,42 @@ public partial class LogTabWindow { #region Public methods + [SupportedOSPlatform("windows")] public LogWindow.LogWindow AddTempFileTab (string fileName, string title) { return AddFileTab(fileName, true, title, false, null); } + [SupportedOSPlatform("windows")] public LogWindow.LogWindow AddFilterTab (FilterPipe pipe, string title, ILogLineColumnizer preProcessColumnizer) { LogWindow.LogWindow logWin = AddFileTab(pipe.FileName, true, title, false, preProcessColumnizer); if (pipe.FilterParams.SearchText.Length > 0) { ToolTip tip = new(components); + tip.SetToolTip(logWin, "Filter: \"" + pipe.FilterParams.SearchText + "\"" + (pipe.FilterParams.IsInvert ? " (Invert match)" : "") + (pipe.FilterParams.ColumnRestrict ? "\nColumn restrict" : "") ); + tip.AutomaticDelay = 10; tip.AutoPopDelay = 5000; var data = logWin.Tag as LogWindowData; - data.toolTip = tip; + data.ToolTip = tip; } return logWin; } + [SupportedOSPlatform("windows")] public LogWindow.LogWindow AddFileTabDeferred (string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer) { return AddFileTab(givenFileName, isTempFile, title, forcePersistenceLoading, preProcessColumnizer, true); } + [SupportedOSPlatform("windows")] public LogWindow.LogWindow AddFileTab (string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer, bool doNotAddToDockPanel = false) { var logFileName = FindFilenameForSettings(givenFileName); @@ -87,16 +94,16 @@ public LogWindow.LogWindow AddFileTab (string givenFileName, bool isTempFile, st } var data = logWindow.Tag as LogWindowData; - data.color = _defaultTabColor; + data.Color = _defaultTabColor; SetTabColor(logWindow, _defaultTabColor); //data.tabPage.BorderColor = this.defaultTabBorderColor; if (!isTempFile) { foreach (ColorEntry colorEntry in ConfigManager.Settings.fileColors) { - if (colorEntry.FileName.ToLower().Equals(logFileName.ToLower())) + if (colorEntry.FileName.ToUpperInvariant().Equals(logFileName.ToUpperInvariant(), StringComparison.Ordinal)) { - data.color = colorEntry.Color; + data.Color = colorEntry.Color; SetTabColor(logWindow, colorEntry.Color); break; } @@ -108,7 +115,7 @@ public LogWindow.LogWindow AddFileTab (string givenFileName, bool isTempFile, st SetTooltipText(logWindow, logFileName); } - if (givenFileName.EndsWith(".lxp")) + if (givenFileName.EndsWith(".lxp", StringComparison.Ordinal)) { logWindow.ForcedPersistenceFileName = givenFileName; } @@ -118,6 +125,7 @@ public LogWindow.LogWindow AddFileTab (string givenFileName, bool isTempFile, st return logWindow; } + [SupportedOSPlatform("windows")] public LogWindow.LogWindow AddMultiFileTab (string[] fileNames) { if (fileNames.Length < 1) @@ -125,8 +133,8 @@ public LogWindow.LogWindow AddMultiFileTab (string[] fileNames) return null; } - LogWindow.LogWindow logWindow = new(this, fileNames[fileNames.Length - 1], false, false, ConfigManager); - AddLogWindow(logWindow, fileNames[fileNames.Length - 1], false); + LogWindow.LogWindow logWindow = new(this, fileNames[^1], false, false, ConfigManager); + AddLogWindow(logWindow, fileNames[^1], false); multiFileToolStripMenuItem.Checked = true; multiFileEnabledStripMenuItem.Checked = true; EncodingOptions encodingOptions = new(); @@ -136,11 +144,13 @@ public LogWindow.LogWindow AddMultiFileTab (string[] fileNames) return logWindow; } + [SupportedOSPlatform("windows")] public void LoadFiles (string[] fileNames) { Invoke(new AddFileTabsDelegate(AddFileTabs), [fileNames]); } + [SupportedOSPlatform("windows")] public void OpenSearchDialog () { if (CurrentLogWindow == null) @@ -169,7 +179,7 @@ public ILogLineColumnizer GetColumnizerHistoryEntry (string fileName) { foreach (ILogLineColumnizer columnizer in PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers) { - if (columnizer.GetName().Equals(entry.ColumnizerName)) + if (columnizer.GetName().Equals(entry.ColumnizerName, StringComparison.Ordinal)) { return columnizer; } @@ -311,16 +321,16 @@ public void FollowTailChanged (LogWindow.LogWindow logWindow, bool isEnabled, bo if (isEnabled) { - data.tailState = 0; + data.TailState = 0; } else { - data.tailState = offByTrigger ? 2 : 1; + data.TailState = offByTrigger ? 2 : 1; } if (Preferences.showTailState) { - Icon icon = GetIcon(data.diffSum, data); + Icon icon = GetIcon(data.DiffSum, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); } } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs index 0d5308c7..4c097add 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs @@ -1,3 +1,6 @@ +using System.Runtime.Versioning; +using System.Text; + using LogExpert.Core.Classes; using LogExpert.Core.Classes.Columnizer; using LogExpert.Core.Config; @@ -7,12 +10,11 @@ using LogExpert.UI.Controls.LogTabWindow; using LogExpert.UI.Dialogs; using LogExpert.UI.Extensions; -using System.Runtime.InteropServices; -using System.Text; namespace LogExpert.Dialogs; //TODO: This class should not knoow ConfigManager? +[SupportedOSPlatform("windows")] internal partial class SettingsDialog : Form { #region Fields @@ -27,7 +29,7 @@ internal partial class SettingsDialog : Form #region cTor - private SettingsDialog(Preferences prefs, LogTabWindow logTabWin) + private SettingsDialog (Preferences prefs, LogTabWindow logTabWin) { Preferences = prefs; _logTabWin = logTabWin; //TODO: uses only HighlightGroupList. Can we pass IList instead? @@ -38,7 +40,7 @@ private SettingsDialog(Preferences prefs, LogTabWindow logTabWin) Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); } - public SettingsDialog(Preferences prefs, LogTabWindow logTabWin, int tabToOpen, IConfigManager configManager) : this(prefs, logTabWin) + public SettingsDialog (Preferences prefs, LogTabWindow logTabWin, int tabToOpen, IConfigManager configManager) : this(prefs, logTabWin) { tabControlSettings.SelectedIndex = tabToOpen; ConfigManager = configManager; @@ -56,7 +58,7 @@ public SettingsDialog(Preferences prefs, LogTabWindow logTabWin, int tabToOpen, #region Private Methods - private void FillDialog() + private void FillDialog () { Preferences ??= new Preferences(); @@ -174,18 +176,18 @@ private void FillDialog() checkBoxShowErrorMessageOnlyOneInstance.Checked = Preferences.ShowErrorMessageAllowOnlyOneInstances; } - private void FillPortableMode() + private void FillPortableMode () { checkBoxPortableMode.CheckState = Preferences.PortableMode ? CheckState.Checked : CheckState.Unchecked; } - private void DisplayFontName() + private void DisplayFontName () { labelFont.Text = Preferences.fontName + @" " + (int)Preferences.fontSize; labelFont.Font = new Font(new FontFamily(Preferences.fontName), Preferences.fontSize); } - private void SaveMultifileData() + private void SaveMultifileData () { if (radioButtonLoadEveryFileIntoSeperatedTab.Checked) { @@ -206,7 +208,7 @@ private void SaveMultifileData() Preferences.multiFileOptions.MaxDayTry = (int)upDownMultifileDays.Value; } - private void OnBtnToolClickInternal(TextBox textBox) + private void OnBtnToolClickInternal (TextBox textBox) { OpenFileDialog dlg = new(); dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); @@ -227,7 +229,7 @@ private void OnBtnToolClickInternal(TextBox textBox) } //TODO: what is the purpose of this method? - private void OnBtnArgsClickInternal(TextBox textBox) + private void OnBtnArgsClickInternal (TextBox textBox) { ToolArgsDialog dlg = new(_logTabWin, this) { @@ -240,7 +242,7 @@ private void OnBtnArgsClickInternal(TextBox textBox) } } - private void OnBtnWorkingDirClick(TextBox textBox) + private void OnBtnWorkingDirClick (TextBox textBox) { FolderBrowserDialog dlg = new() { @@ -263,7 +265,7 @@ private void OnBtnWorkingDirClick(TextBox textBox) } } - private void FillColumnizerForToolsList() + private void FillColumnizerForToolsList () { if (_selectedTool != null) { @@ -271,7 +273,7 @@ private void FillColumnizerForToolsList() } } - private void FillColumnizerForToolsList(ComboBox comboBox, string columnizerName) + private void FillColumnizerForToolsList (ComboBox comboBox, string columnizerName) { var selIndex = 0; comboBox.Items.Clear(); @@ -280,7 +282,7 @@ private void FillColumnizerForToolsList(ComboBox comboBox, string columnizerName foreach (ILogLineColumnizer columnizer in columnizers) { var index = comboBox.Items.Add(columnizer.GetName()); - if (columnizer.GetName().Equals(columnizerName)) + if (columnizer.GetName().Equals(columnizerName, StringComparison.Ordinal)) { selIndex = index; } @@ -292,7 +294,7 @@ private void FillColumnizerForToolsList(ComboBox comboBox, string columnizerName comboBox.SelectedIndex = selIndex; } - private void FillColumnizerList() + private void FillColumnizerList () { dataGridViewColumnizer.Rows.Clear(); @@ -339,7 +341,7 @@ private void FillColumnizerList() } } - private void FillHighlightMaskList() + private void FillHighlightMaskList () { dataGridViewHighlightMask.Rows.Clear(); @@ -386,7 +388,7 @@ private void FillHighlightMaskList() } } - private void SaveColumnizerList() + private void SaveColumnizerList () { Preferences.columnizerMaskList.Clear(); @@ -402,7 +404,7 @@ private void SaveColumnizerList() } } - private void SaveHighlightMaskList() + private void SaveHighlightMaskList () { Preferences.highlightMaskList.Clear(); @@ -418,7 +420,7 @@ private void SaveHighlightMaskList() } } - private void FillPluginList() + private void FillPluginList () { listBoxPlugin.Items.Clear(); @@ -452,7 +454,7 @@ private void FillPluginList() buttonConfigPlugin.Enabled = false; } - private void SavePluginSettings() + private void SavePluginSettings () { _selectedPlugin?.HideConfigForm(); @@ -473,7 +475,7 @@ private void SavePluginSettings() } } - private void FillToolListbox() + private void FillToolListbox () { listBoxTools.Items.Clear(); @@ -488,7 +490,7 @@ private void FillToolListbox() } } - private void FillMultifileSettings() + private void FillMultifileSettings () { switch (Preferences.multiFileOption) { @@ -513,7 +515,7 @@ private void FillMultifileSettings() upDownMultifileDays.Value = Preferences.multiFileOptions.MaxDayTry; } - private void GetToolListBoxData() + private void GetToolListBoxData () { GetCurrentToolValues(); Preferences.toolEntries.Clear(); @@ -525,7 +527,7 @@ private void GetToolListBoxData() } } - private void GetCurrentToolValues() + private void GetCurrentToolValues () { if (_selectedTool != null) { @@ -538,7 +540,7 @@ private void GetCurrentToolValues() } } - private void ShowCurrentToolValues() + private void ShowCurrentToolValues () { if (_selectedTool != null) { @@ -552,7 +554,7 @@ private void ShowCurrentToolValues() } } - private void DisplayCurrentIcon() + private void DisplayCurrentIcon () { if (_selectedTool != null) { @@ -571,7 +573,7 @@ private void DisplayCurrentIcon() } } - private void FillEncodingList() + private void FillEncodingList () { comboBoxEncoding.Items.Clear(); @@ -589,12 +591,12 @@ private void FillEncodingList() #region Events handler - private void OnSettingsDialogLoad(object sender, EventArgs e) + private void OnSettingsDialogLoad (object sender, EventArgs e) { FillDialog(); } - private void OnBtnChangeFontClick(object sender, EventArgs e) + private void OnBtnChangeFontClick (object sender, EventArgs e) { FontDialog dlg = new() { @@ -613,7 +615,7 @@ private void OnBtnChangeFontClick(object sender, EventArgs e) DisplayFontName(); } - private void OnBtnOkClick(object sender, EventArgs e) + private void OnBtnOkClick (object sender, EventArgs e) { Preferences.timestampControl = checkBoxTimestamp.Checked; Preferences.filterSync = checkBoxSyncFilter.Checked; @@ -687,19 +689,19 @@ private void OnBtnOkClick(object sender, EventArgs e) SaveMultifileData(); } - private void OnBtnToolClick(object sender, EventArgs e) + private void OnBtnToolClick (object sender, EventArgs e) { OnBtnToolClickInternal(textBoxTool); } //TODO: what is the purpose of this click? - private void OnBtnArgClick(object sender, EventArgs e) + private void OnBtnArgClick (object sender, EventArgs e) { OnBtnArgsClickInternal(textBoxArguments); } //TODO Remove or refactor this function - private void OnDataGridViewColumnizerRowsAdded(object sender, DataGridViewRowsAddedEventArgs e) + private void OnDataGridViewColumnizerRowsAdded (object sender, DataGridViewRowsAddedEventArgs e) { var comboCell = (DataGridViewComboBoxCell)dataGridViewColumnizer.Rows[e.RowIndex].Cells[1]; if (comboCell.Items.Count > 0) @@ -708,7 +710,7 @@ private void OnDataGridViewColumnizerRowsAdded(object sender, DataGridViewRowsAd } } - private void OnBtnDeleteClick(object sender, EventArgs e) + private void OnBtnDeleteClick (object sender, EventArgs e) { if (dataGridViewColumnizer.CurrentRow != null && !dataGridViewColumnizer.CurrentRow.IsNewRow) { @@ -718,17 +720,17 @@ private void OnBtnDeleteClick(object sender, EventArgs e) } } - private void OnDataGridViewColumnizerDataError(object sender, DataGridViewDataErrorEventArgs e) + private void OnDataGridViewColumnizerDataError (object sender, DataGridViewDataErrorEventArgs e) { e.Cancel = true; } - private void OnChkBoxSysoutCheckedChanged(object sender, EventArgs e) + private void OnChkBoxSysoutCheckedChanged (object sender, EventArgs e) { comboBoxColumnizer.Enabled = checkBoxSysout.Checked; } - private void OnBtnTailColorClick(object sender, EventArgs e) + private void OnBtnTailColorClick (object sender, EventArgs e) { ColorDialog dlg = new() { @@ -741,12 +743,12 @@ private void OnBtnTailColorClick(object sender, EventArgs e) } } - private void OnChkBoxColumnSizeCheckedChanged(object sender, EventArgs e) + private void OnChkBoxColumnSizeCheckedChanged (object sender, EventArgs e) { cpDownColumnWidth.Enabled = checkBoxColumnSize.Checked; } - private void OnBtnTimespreadColorClick(object sender, EventArgs e) + private void OnBtnTimespreadColorClick (object sender, EventArgs e) { ColorDialog dlg = new() { @@ -759,7 +761,7 @@ private void OnBtnTimespreadColorClick(object sender, EventArgs e) } } - private void OnListBoxPluginSelectedIndexChanged(object sender, EventArgs e) + private void OnListBoxPluginSelectedIndexChanged (object sender, EventArgs e) { _selectedPlugin?.HideConfigForm(); @@ -791,7 +793,7 @@ private void OnListBoxPluginSelectedIndexChanged(object sender, EventArgs e) } } - private void OnBtnSessionSaveDirClick(object sender, EventArgs e) + private void OnBtnSessionSaveDirClick (object sender, EventArgs e) { FolderBrowserDialog dlg = new(); @@ -809,7 +811,7 @@ private void OnBtnSessionSaveDirClick(object sender, EventArgs e) } } - private void OnPortableModeCheckedChanged(object sender, EventArgs e) + private void OnPortableModeCheckedChanged (object sender, EventArgs e) { try { @@ -858,7 +860,7 @@ private void OnPortableModeCheckedChanged(object sender, EventArgs e) } - private void OnBtnConfigPluginClick(object sender, EventArgs e) + private void OnBtnConfigPluginClick (object sender, EventArgs e) { if (!_selectedPlugin.HasEmbeddedForm()) { @@ -866,12 +868,12 @@ private void OnBtnConfigPluginClick(object sender, EventArgs e) } } - private void OnNumericUpDown1ValueChanged(object sender, EventArgs e) + private void OnNumericUpDown1ValueChanged (object sender, EventArgs e) { //TODO implement } - private void OnListBoxToolSelectedIndexChanged(object sender, EventArgs e) + private void OnListBoxToolSelectedIndexChanged (object sender, EventArgs e) { GetCurrentToolValues(); _selectedTool = listBoxTools.SelectedItem as ToolEntry; @@ -881,7 +883,7 @@ private void OnListBoxToolSelectedIndexChanged(object sender, EventArgs e) DisplayCurrentIcon(); } - private void OnBtnToolUpClick(object sender, EventArgs e) + private void OnBtnToolUpClick (object sender, EventArgs e) { var i = listBoxTools.SelectedIndex; @@ -897,7 +899,7 @@ private void OnBtnToolUpClick(object sender, EventArgs e) } } - private void OnBtnToolDownClick(object sender, EventArgs e) + private void OnBtnToolDownClick (object sender, EventArgs e) { var i = listBoxTools.SelectedIndex; @@ -913,13 +915,15 @@ private void OnBtnToolDownClick(object sender, EventArgs e) } } - private void OnBtnToolAddClick(object sender, EventArgs e) + [SupportedOSPlatform("windows")] + private void OnBtnToolAddClick (object sender, EventArgs e) { listBoxTools.Items.Add(new ToolEntry()); listBoxTools.SelectedIndex = listBoxTools.Items.Count - 1; } - private void OnToolDeleteButtonClick(object sender, EventArgs e) + [SupportedOSPlatform("windows")] + private void OnToolDeleteButtonClick (object sender, EventArgs e) { var i = listBoxTools.SelectedIndex; @@ -940,7 +944,8 @@ private void OnToolDeleteButtonClick(object sender, EventArgs e) } } - private void OnBtnIconClick(object sender, EventArgs e) + [SupportedOSPlatform("windows")] + private void OnBtnIconClick (object sender, EventArgs e) { if (_selectedTool != null) { @@ -962,23 +967,25 @@ private void OnBtnIconClick(object sender, EventArgs e) } } - private void OnBtnCancelClick(object sender, EventArgs e) + private void OnBtnCancelClick (object sender, EventArgs e) { _selectedPlugin?.HideConfigForm(); } - private void OnBtnWorkingDirClick(object sender, EventArgs e) + private void OnBtnWorkingDirClick (object sender, EventArgs e) { OnBtnWorkingDirClick(textBoxWorkingDir); } - private void OnMultiFilePatternTextChanged(object sender, EventArgs e) + [SupportedOSPlatform("windows")] + private void OnMultiFilePatternTextChanged (object sender, EventArgs e) { var pattern = textBoxMultifilePattern.Text; - upDownMultifileDays.Enabled = pattern.Contains("$D"); + upDownMultifileDays.Enabled = pattern.Contains("$D", System.StringComparison.Ordinal); } - private void OnBtnExportClick(object sender, EventArgs e) + [SupportedOSPlatform("windows")] + private void OnBtnExportClick (object sender, EventArgs e) { SaveFileDialog dlg = new() { @@ -1002,7 +1009,7 @@ private void OnBtnExportClick(object sender, EventArgs e) /// /// /// - private void OnBtnImportClick(object sender, EventArgs e) + private void OnBtnImportClick (object sender, EventArgs e) { ImportSettingsDialog dlg = new(ExportImportFlags.All); diff --git a/src/LogExpert.UI/Dialogs/ToolArgsDialog.cs b/src/LogExpert.UI/Dialogs/ToolArgsDialog.cs index 60271fdf..4a734f9d 100644 --- a/src/LogExpert.UI/Dialogs/ToolArgsDialog.cs +++ b/src/LogExpert.UI/Dialogs/ToolArgsDialog.cs @@ -1,6 +1,6 @@ -using LogExpert.Classes; -using LogExpert.UI.Controls.LogTabWindow; +using LogExpert.UI.Controls.LogTabWindow; using LogExpert.UI.Dialogs; +using LogExpert.UI.Entities; using System; using System.Drawing; diff --git a/src/LogExpert.UI/Entities/ArgParser.cs b/src/LogExpert.UI/Entities/ArgParser.cs index 215a1981..e481a877 100644 --- a/src/LogExpert.UI/Entities/ArgParser.cs +++ b/src/LogExpert.UI/Entities/ArgParser.cs @@ -1,51 +1,43 @@ -using System.Text; +using System.Text; using System.Text.RegularExpressions; using LogExpert.Core.Classes; using LogExpert.Dialogs; -namespace LogExpert.Classes; +namespace LogExpert.UI.Entities; -internal class ArgParser +internal class ArgParser (string argTemplate) { - #region Fields - - private readonly string argLine; - - #endregion #region cTor - public ArgParser (string argTemplate) - { - argLine = argTemplate; - } - #endregion #region Public methods public string BuildArgs (ILogLine logLine, int lineNum, ILogFileInfo logFileInfo, Form parent) { - StringBuilder builder = new(argLine); - builder.Replace("%L", "" + lineNum); - builder.Replace("%P", logFileInfo.DirectoryName); - builder.Replace("%N", logFileInfo.FileName); - builder.Replace("%F", logFileInfo.FullName); - builder.Replace("%E", Util.GetExtension(logFileInfo.FileName)); - var stripped = Util.StripExtension(logFileInfo.FileName); - builder.Replace("%M", stripped); + StringBuilder builder = new(argTemplate); - builder.Replace("%URI", logFileInfo.Uri.AbsoluteUri); + _ = builder.Replace("%L", "" + lineNum); + _ = builder.Replace("%P", logFileInfo.DirectoryName); + _ = builder.Replace("%N", logFileInfo.FileName); + _ = builder.Replace("%F", logFileInfo.FullName); + _ = builder.Replace("%E", Util.GetExtension(logFileInfo.FileName)); + var stripped = Util.StripExtension(logFileInfo.FileName); + _ = builder.Replace("%M", stripped); + _ = builder.Replace("%URI", logFileInfo.Uri.AbsoluteUri); var user = logFileInfo.Uri.UserInfo; - if (user.Contains(":")) + + if (user.Contains(':', StringComparison.Ordinal)) { - user = user.Substring(0, user.IndexOf(':')); + user = user[..user.IndexOf(':', StringComparison.Ordinal)]; } - builder.Replace("%S", user); - builder.Replace("%R", logFileInfo.Uri.PathAndQuery); - builder.Replace("%H", logFileInfo.Uri.Host); - builder.Replace("%T", logFileInfo.Uri.Port.ToString()); + + _ = builder.Replace("%S", user); + _ = builder.Replace("%R", logFileInfo.Uri.PathAndQuery); + _ = builder.Replace("%H", logFileInfo.Uri.Host); + _ = builder.Replace("%T", logFileInfo.Uri.Port.ToString()); var sPos = 0; string reg; @@ -57,7 +49,7 @@ public string BuildArgs (ILogLine logLine, int lineNum, ILogFileInfo logFileInfo if (reg != null && replace != null) { var result = Regex.Replace(logLine.FullLine, reg, replace); - builder.Insert(sPos, result); + _ = builder.Insert(sPos, result); } } while (replace != null); @@ -78,10 +70,12 @@ public string BuildArgs (ILogLine logLine, int lineNum, ILogFileInfo logFileInfo } ask = builder.ToString().Substring(i + 2, end - i - 2); } + string[] values = null; + if (builder[end + 1] == '(') { - var end2 = builder.ToString().IndexOf(')'); + var end2 = builder.ToString().IndexOf(')', StringComparison.Ordinal); if (end2 == -1) { end2 = builder.Length - 1; @@ -91,17 +85,20 @@ public string BuildArgs (ILogLine logLine, int lineNum, ILogFileInfo logFileInfo end = end2; } - ParamRequesterDialog dlg = new(); - dlg.ParamName = ask; - dlg.Values = values; + ParamRequesterDialog dlg = new() + { + ParamName = ask, + Values = values + }; + DialogResult res = dlg.ShowDialog(parent); - if (res == DialogResult.OK) + if (res is DialogResult.OK) { - builder.Remove(i, end - i + 1); - builder.Insert(i, dlg.ParamValue); + _ = builder.Remove(i, end - i + 1); + _ = builder.Insert(i, dlg.ParamValue); } - else if (res == DialogResult.Cancel || res == DialogResult.Abort) + else if (res is DialogResult.Cancel or DialogResult.Abort) { return null; } @@ -126,27 +123,33 @@ private string GetNextGroup (StringBuilder builder, ref int sPos) { ePos = sPos + 1; var count = 1; + while (ePos < builder.Length) { if (builder[ePos] == '{') { count++; } + if (builder[ePos] == '}') { count--; } + if (count == 0) { var reg = builder.ToString(sPos + 1, ePos - sPos - 1); - builder.Remove(sPos, ePos - sPos + 1); + _ = builder.Remove(sPos, ePos - sPos + 1); return reg; } + ePos++; } } + sPos++; } + return null; } diff --git a/src/SftpFileSystemx64/CredentialCache.cs b/src/SftpFileSystemx64/CredentialCache.cs index 93571c2b..dc48ff33 100644 --- a/src/SftpFileSystemx64/CredentialCache.cs +++ b/src/SftpFileSystemx64/CredentialCache.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace SftpFileSystem; @@ -12,7 +12,7 @@ internal class CredentialCache #region Private Methods - private void RemoveCredentials(string host, string user) + private void RemoveCredentials (string host, string user) { Credentials credentials = GetCredentials(host, user); if (credentials != null) @@ -23,13 +23,13 @@ private void RemoveCredentials(string host, string user) #endregion - internal IList GetUsersForHost(string host) + internal IList GetUsersForHost (string host) { IList result = []; foreach (Credentials cred in _credList) { - if (cred.Host.Equals(host)) + if (cred.Host.Equals(host, System.StringComparison.Ordinal)) { result.Add(cred.UserName); } @@ -38,11 +38,11 @@ internal IList GetUsersForHost(string host) return result; } - internal Credentials GetCredentials(string host, string user) + internal Credentials GetCredentials (string host, string user) { foreach (Credentials cred in _credList) { - if (cred.Host.Equals(host) && cred.UserName.Equals(user)) + if (cred.Host.Equals(host, System.StringComparison.Ordinal) && cred.UserName.Equals(user, System.StringComparison.Ordinal)) { return cred; } @@ -51,7 +51,7 @@ internal Credentials GetCredentials(string host, string user) return null; } - internal void Add(Credentials cred) + internal void Add (Credentials cred) { RemoveCredentials(cred.Host, cred.UserName); _credList.Add(cred); diff --git a/src/SftpFileSystemx64/SftpFileSystem.cs b/src/SftpFileSystemx64/SftpFileSystem.cs index d899b430..bdc86465 100644 --- a/src/SftpFileSystemx64/SftpFileSystem.cs +++ b/src/SftpFileSystemx64/SftpFileSystem.cs @@ -1,33 +1,24 @@ -using LogExpert; - -using Renci.SshNet; - using System; using System.Collections.Generic; using System.IO; using System.Windows.Forms; using System.Xml.Serialization; +using LogExpert; + +using Renci.SshNet; + namespace SftpFileSystem; -public class SftpFileSystem : IFileSystemPlugin, ILogExpertPluginConfigurator +public class SftpFileSystem (IFileSystemCallback callback) : IFileSystemPlugin, ILogExpertPluginConfigurator { #region Private Fields - private readonly ILogExpertLogger _logger; + private readonly ILogExpertLogger _logger = callback.GetLogger(); private ConfigDialog _configDialog; private volatile PrivateKeyFile _privateKeyFile; - - #endregion - - #region Ctor - - public SftpFileSystem(IFileSystemCallback callback) - { - _logger = callback.GetLogger(); - CredentialsCache = new CredentialCache(); - } + private object _lock = new object(); #endregion @@ -37,12 +28,12 @@ public SftpFileSystem(IFileSystemCallback callback) public string Text => "SFTP plugin"; - public bool CanHandleUri(string uriString) + public bool CanHandleUri (string uriString) { try { Uri uri = new(uriString); - return uri.Scheme.Equals("sftp", StringComparison.InvariantCultureIgnoreCase); + return uri.Scheme.Equals("sftp", StringComparison.OrdinalIgnoreCase); } catch (Exception e) { @@ -51,7 +42,7 @@ public bool CanHandleUri(string uriString) } } - public ILogFileInfo GetLogfileInfo(string uriString) + public ILogFileInfo GetLogfileInfo (string uriString) { try { @@ -69,19 +60,20 @@ public ILogFileInfo GetLogfileInfo(string uriString) #region Interface ILogExpertPluginConfigurator - public bool HasEmbeddedForm() + public bool HasEmbeddedForm () { return true; } - public void HideConfigForm() + public void HideConfigForm () { ConfigData = _configDialog.ConfigData; _configDialog.Hide(); _configDialog.Dispose(); } - public void LoadConfig(string configDir) + //TODO JSON config should be used + public void LoadConfig (string configDir) { XmlSerializer xml = new(ConfigData.GetType()); @@ -112,7 +104,7 @@ public void LoadConfig(string configDir) } } - public void SaveConfig(string configDir) + public void SaveConfig (string configDir) { _logger.Info("Saving SFTP config"); XmlSerializer xml = new(ConfigData.GetType()); @@ -137,12 +129,12 @@ public void SaveConfig(string configDir) } } - public void ShowConfigDialog(object owner) + public void ShowConfigDialog (object owner) { throw new NotImplementedException(); } - public void ShowConfigForm(object parentPanel) + public void ShowConfigForm (object parentPanel) { _configDialog = new ConfigDialog(ConfigData) { @@ -152,7 +144,7 @@ public void ShowConfigForm(object parentPanel) _configDialog.Show(); } - public void StartConfig() + public void StartConfig () { } @@ -168,15 +160,15 @@ public PrivateKeyFile PrivateKeyFile set => _privateKeyFile = value; } - private CredentialCache CredentialsCache { get; } + private CredentialCache CredentialsCache { get; } = new CredentialCache(); #endregion - internal Credentials GetCredentials(Uri uri, bool cacheAllowed, bool hidePasswordField) + internal Credentials GetCredentials (Uri uri, bool cacheAllowed, bool hidePasswordField) { // Synchronized access to the GetCredentials() method prevents multiple login dialogs when loading multiple files at once // (e.g. on startup). So the user only needs to enter credentials once for the same host. - lock (this) + lock (_lock) { string userName = null; string password = null; From 0d81ea23bb13c6f35fef59c09a943f92229fa7ab Mon Sep 17 00:00:00 2001 From: Hirogen Date: Tue, 3 Jun 2025 11:21:15 +0200 Subject: [PATCH 059/142] removed more warnings --- .../JsonCompactColumnizer.cs | 28 +++--- .../Classes/Filter/FilterPipe.cs | 63 ++++++------- .../Classes/Persister/PersistenceData.cs | 91 ++++++++++-------- .../Classes/Persister/Persister.cs | 94 +++++++++---------- .../Config/ColumnizerMaskEntry.cs | 9 +- .../Config/HighlightMaskEntry.cs | 9 +- src/LogExpert.Core/Config/ToolEntry.cs | 58 ++++++------ .../RolloverHandlerTestBase.cs | 49 +++++----- .../Controls/LogWindow/LogWindow.cs | 1 - .../LogWindow/LogWindowEventHandlers.cs | 1 - .../Controls/LogWindow/LogWindowPrivate.cs | 58 ++++++------ .../Controls/LogWindow/LogWindowPublic.cs | 39 ++++---- src/LogExpert.UI/Dialogs/Eminus/Eminus.cs | 9 +- .../Dialogs/Eminus/EminusConfig.cs | 20 ++-- .../Dialogs/Eminus/EminusConfigDlg.cs | 16 ++-- .../LogTabWindow/LogTabWindowPrivate.cs | 32 +++---- .../LogTabWindow/LogTabWindowPublic.cs | 14 +-- .../Dialogs/LogTabWindow/SettingsDialog.cs | 56 +++++------ src/LogExpert/Config/ConfigManager.cs | 18 ++-- 19 files changed, 332 insertions(+), 333 deletions(-) diff --git a/src/JsonCompactColumnizer/JsonCompactColumnizer.cs b/src/JsonCompactColumnizer/JsonCompactColumnizer.cs index d286ac88..5cc3b33d 100644 --- a/src/JsonCompactColumnizer/JsonCompactColumnizer.cs +++ b/src/JsonCompactColumnizer/JsonCompactColumnizer.cs @@ -1,11 +1,11 @@ -using LogExpert; - -using Newtonsoft.Json.Linq; - using System; using System.Collections.Generic; using System.Linq; +using LogExpert; + +using Newtonsoft.Json.Linq; + namespace JsonColumnizer; /// @@ -15,28 +15,28 @@ public class JsonCompactColumnizer : JsonColumnizer, IColumnizerPriority { #region Public methods - public override string GetName() + public override string GetName () { return "JSON Compact Columnizer"; } - public override string GetDescription() + public override string GetDescription () { return "A JSON columnier for Serilog.Formatting.Compact format."; } - public override void Selected(ILogLineColumnizerCallback callback) + public override void Selected (ILogLineColumnizerCallback callback) { ColumnList.Clear(); // Create column header with cached column list. - foreach (var col in _tagDict.Keys) + foreach (var col in TagDict.Keys) { - ColumnList.Add(new JsonColumn(_tagDict[col])); + ColumnList.Add(new JsonColumn(TagDict[col])); } } - public override Priority GetPriority(string fileName, IEnumerable samples) + public override Priority GetPriority (string fileName, IEnumerable samples) { Priority result = Priority.NotSupport; if (fileName.EndsWith("json", StringComparison.OrdinalIgnoreCase)) @@ -72,7 +72,7 @@ public override Priority GetPriority(string fileName, IEnumerable samp #region Private Methods - protected Dictionary _tagDict = new() + protected Dictionary TagDict { get; set; } = new() { {"@t", "Timestamp"}, {"@l", "Level"}, @@ -83,7 +83,7 @@ public override Priority GetPriority(string fileName, IEnumerable samp {"@mt", "Message Template"}, }; - protected override IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) + protected override IColumnizedLogLine SplitJsonLine (ILogLine line, JObject json) { List returnColumns = []; var cLogLine = new ColumnizedLogLine { LogLine = line }; @@ -94,11 +94,11 @@ protected override IColumnizedLogLine SplitJsonLine(ILogLine line, JObject json) // Always rearrage the order of all json fields within a line to follow the sequence of columnNameList. // This will make sure the log line displayed correct even the order of json fields changed. // - foreach (var column in _tagDict.Keys) + foreach (var column in TagDict.Keys) { if (column.StartsWith('@')) { - var existingColumn = columns.Find(x => x.ColumnName == column); + ColumnWithName existingColumn = columns.Find(x => x.ColumnName == column); if (existingColumn != null) { diff --git a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs index e99ce716..1b847c4b 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs @@ -1,42 +1,40 @@ -using LogExpert.Core.Classes.Filter; +using System.Text; + using LogExpert.Core.Interface; -using NLog; -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; +using NLog; -namespace LogExpert.Classes.Filter; +namespace LogExpert.Core.Classes.Filter; public class FilterPipe { #region Fields - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); - private IList _lineMappingList = new List(); + private IList _lineMappingList = []; private StreamWriter _writer; + private readonly object _fileNameLock = new(); #endregion #region cTor - public FilterPipe(FilterParams filterParams, ILogWindow logWindow) + public FilterPipe (FilterParams filterParams, ILogWindow logWindow) { FilterParams = filterParams; LogWindow = logWindow; IsStopped = false; FileName = Path.GetTempFileName(); - _logger.Info("Created temp file: {0}", FileName); + _logger.Info($"Created temp file: {FileName}"); } #endregion #region Delegates - public delegate void ClosedEventHandler(object sender, EventArgs e); + public delegate void ClosedEventHandler (object sender, EventArgs e); #endregion @@ -54,7 +52,7 @@ public FilterPipe(FilterParams filterParams, ILogWindow logWindow) public FilterParams FilterParams { get; } - public IList LastLinesHistoryList { get; } = new List(); + public IList LastLinesHistoryList { get; } = []; public ILogWindow LogWindow { get; } @@ -64,13 +62,13 @@ public FilterPipe(FilterParams filterParams, ILogWindow logWindow) #region Public methods - public void OpenFile() + public void OpenFile () { FileStream fStream = new(FileName, FileMode.Append, FileAccess.Write, FileShare.Read); _writer = new StreamWriter(fStream, new UnicodeEncoding(false, false)); } - public void CloseFile() + public void CloseFile () { if (_writer != null) { @@ -79,11 +77,11 @@ public void CloseFile() } } - public bool WriteToPipe(ILogLine textLine, int orgLineNum) + public bool WriteToPipe (ILogLine textLine, int orgLineNum) { try { - lock (FileName) + lock (_fileNameLock) { lock (_lineMappingList) { @@ -108,22 +106,19 @@ public bool WriteToPipe(ILogLine textLine, int orgLineNum) } } - public int GetOriginalLineNum(int lineNum) + public int GetOriginalLineNum (int lineNum) { lock (_lineMappingList) { - if (_lineMappingList.Count > lineNum) - { - return _lineMappingList[lineNum]; - } - - return -1; + return _lineMappingList.Count > lineNum + ? _lineMappingList[lineNum] + : -1; } } - public void ShiftLineNums(int offset) + public void ShiftLineNums (int offset) { - _logger.Debug("FilterPipe.ShiftLineNums() offset={0}", offset); + _logger.Debug($"FilterPipe.ShiftLineNums() offset={offset}"); List newList = []; lock (_lineMappingList) { @@ -139,11 +134,12 @@ public void ShiftLineNums(int offset) newList.Add(-1); } } + _lineMappingList = newList; } } - public void ClearLineNums() + public void ClearLineNums () { _logger.Debug("FilterPipe.ClearLineNums()"); lock (_lineMappingList) @@ -155,7 +151,7 @@ public void ClearLineNums() } } - public void ClearLineList() + public void ClearLineList () { lock (_lineMappingList) { @@ -163,13 +159,14 @@ public void ClearLineList() } } - public void RecreateTempFile() + public void RecreateTempFile () { lock (_lineMappingList) { - _lineMappingList = new List(); + _lineMappingList = []; } - lock (FileName) + + lock (_fileNameLock) { CloseFile(); // trunc file @@ -179,7 +176,7 @@ public void RecreateTempFile() } } - public void CloseAndDisconnect() + public void CloseAndDisconnect () { ClearLineList(); OnClosed(); @@ -189,7 +186,7 @@ public void CloseAndDisconnect() #region Private Methods - private void OnClosed() + private void OnClosed () { Closed?.Invoke(this, EventArgs.Empty); } diff --git a/src/LogExpert.Core/Classes/Persister/PersistenceData.cs b/src/LogExpert.Core/Classes/Persister/PersistenceData.cs index 36610342..eefe1a34 100644 --- a/src/LogExpert.Core/Classes/Persister/PersistenceData.cs +++ b/src/LogExpert.Core/Classes/Persister/PersistenceData.cs @@ -7,42 +7,55 @@ namespace LogExpert.Core.Classes.Persister; public class PersistenceData { - #region Fields - - private SortedList bookmarkList = []; - private int bookmarkListPosition = 300; - private bool bookmarkListVisible; - private string columnizerName; - private int currentLine = -1; - public Encoding encoding; - public string fileName; - public bool filterAdvanced; - public List filterParamsList = []; - public int filterPosition = 222; - public bool filterSaveListVisible; - public List filterTabDataList = []; - public bool filterVisible; - public int firstDisplayedLine = -1; - public bool followTail = true; - public string highlightGroupName; - public int lineCount; - - public bool multiFile; - public int multiFileMaxDays; - public List multiFileNames = []; - public string multiFilePattern; - public SortedList rowHeightList = []; - public string sessionFileName; - public bool showBookmarkCommentColumn; - public string tabName; - - public string settingsSaveLoadLocation; - - public SortedList BookmarkList { get => bookmarkList; set => bookmarkList = value; } - public int BookmarkListPosition { get => bookmarkListPosition; set => bookmarkListPosition = value; } - public bool BookmarkListVisible { get => bookmarkListVisible; set => bookmarkListVisible = value; } - public string ColumnizerName { get => columnizerName; set => columnizerName = value; } - public int CurrentLine { get => currentLine; set => currentLine = value; } - - #endregion -} + public SortedList BookmarkList { get; set; } = []; + + public int BookmarkListPosition { get; set; } = 300; + + public bool BookmarkListVisible { get; set; } + + public string ColumnizerName { get; set; } + + public int CurrentLine { get; set; } = -1; + + public Encoding Encoding { get; set; } + + public string FileName { get; set; } + + public bool FilterAdvanced { get; set; } + + public List FilterParamsList { get; set; } = []; + + public int FilterPosition { get; set; } = 222; + + public bool FilterSaveListVisible { get; set; } + + public List FilterTabDataList { get; set; } = []; + + public int FirstDisplayedLine { get; set; } = -1; + + public bool FollowTail { get; set; } = true; + + public string HighlightGroupName { get; set; } + + public bool FilterVisible { get; set; } + + public int LineCount { get; set; } + + public bool MultiFile { get; set; } + + public int MultiFileMaxDays { get; set; } + + public List MultiFileNames { get; set; } = []; + + public string MultiFilePattern { get; set; } + + public SortedList RowHeightList { get; set; } = []; + + public string SessionFileName { get; set; } + + public bool ShowBookmarkCommentColumn { get; set; } + + public string TabName { get; set; } + + public string SettingsSaveLoadLocation { get; set; } +} \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Persister/Persister.cs b/src/LogExpert.Core/Classes/Persister/Persister.cs index 63a727af..6e6835b2 100644 --- a/src/LogExpert.Core/Classes/Persister/Persister.cs +++ b/src/LogExpert.Core/Classes/Persister/Persister.cs @@ -24,13 +24,13 @@ public class Persister public static string SavePersistenceData (string logFileName, PersistenceData persistenceData, Preferences preferences) { - var fileName = persistenceData.sessionFileName ?? BuildPersisterFileName(logFileName, preferences); + var fileName = persistenceData.SessionFileName ?? BuildPersisterFileName(logFileName, preferences); if (preferences.saveLocation == SessionSaveLocation.SameDir) { // make to log file in .lxp file relative - var filePart = Path.GetFileName(persistenceData.fileName); - persistenceData.fileName = filePart; + var filePart = Path.GetFileName(persistenceData.FileName); + persistenceData.FileName = filePart; } Save(fileName, persistenceData); @@ -91,8 +91,8 @@ public static PersistenceData LoadOptionsOnly (string fileName) { var fileElement = fileNode as XmlElement; ReadOptions(fileElement, persistenceData); - persistenceData.fileName = fileElement.GetAttribute("fileName"); - persistenceData.encoding = ReadEncoding(fileElement); + persistenceData.FileName = fileElement.GetAttribute("fileName"); + persistenceData.Encoding = ReadEncoding(fileElement); } return persistenceData; } @@ -172,14 +172,14 @@ private static void Save (string fileName, PersistenceData persistenceData) xmlDoc.AppendChild(rootElement); XmlElement fileElement = xmlDoc.CreateElement("file"); rootElement.AppendChild(fileElement); - fileElement.SetAttribute("fileName", persistenceData.fileName); - fileElement.SetAttribute("lineCount", "" + persistenceData.lineCount); + fileElement.SetAttribute("fileName", persistenceData.FileName); + fileElement.SetAttribute("lineCount", "" + persistenceData.LineCount); WriteBookmarks(xmlDoc, fileElement, persistenceData.BookmarkList); - WriteRowHeightList(xmlDoc, fileElement, persistenceData.rowHeightList); + WriteRowHeightList(xmlDoc, fileElement, persistenceData.RowHeightList); WriteOptions(xmlDoc, fileElement, persistenceData); - WriteFilter(xmlDoc, fileElement, persistenceData.filterParamsList); - WriteFilterTabs(xmlDoc, fileElement, persistenceData.filterTabDataList); - WriteEncoding(xmlDoc, fileElement, persistenceData.encoding); + WriteFilter(xmlDoc, fileElement, persistenceData.FilterParamsList); + WriteFilterTabs(xmlDoc, fileElement, persistenceData.FilterTabDataList); + WriteEncoding(xmlDoc, fileElement, persistenceData.Encoding); if (xmlDoc.HasChildNodes) { xmlDoc.Save(fileName); @@ -208,10 +208,10 @@ private static void WriteFilterTabs (XmlDocument xmlDoc, XmlElement rootElement, XmlElement filterTabElement = xmlDoc.CreateElement("filterTab"); filterTabsElement.AppendChild(filterTabElement); WriteBookmarks(xmlDoc, filterTabElement, persistenceData.BookmarkList); - WriteRowHeightList(xmlDoc, filterTabElement, persistenceData.rowHeightList); + WriteRowHeightList(xmlDoc, filterTabElement, persistenceData.RowHeightList); WriteOptions(xmlDoc, filterTabElement, persistenceData); - WriteFilter(xmlDoc, filterTabElement, persistenceData.filterParamsList); - WriteFilterTabs(xmlDoc, filterTabElement, persistenceData.filterTabDataList); + WriteFilter(xmlDoc, filterTabElement, persistenceData.FilterParamsList); + WriteFilterTabs(xmlDoc, filterTabElement, persistenceData.FilterTabDataList); XmlElement filterElement = xmlDoc.CreateElement("tabFilter"); filterTabElement.AppendChild(filterElement); List filterList = [data.FilterParams]; @@ -345,17 +345,17 @@ private static PersistenceData ReadPersistenceDataFromNode (XmlNode node) PersistenceData persistenceData = new(); var fileElement = node as XmlElement; persistenceData.BookmarkList = ReadBookmarks(fileElement); - persistenceData.rowHeightList = ReadRowHeightList(fileElement); + persistenceData.RowHeightList = ReadRowHeightList(fileElement); ReadOptions(fileElement, persistenceData); - persistenceData.fileName = fileElement.GetAttribute("fileName"); + persistenceData.FileName = fileElement.GetAttribute("fileName"); var sLineCount = fileElement.GetAttribute("lineCount"); if (sLineCount != null && sLineCount.Length > 0) { - persistenceData.lineCount = int.Parse(sLineCount); + persistenceData.LineCount = int.Parse(sLineCount); } - persistenceData.filterParamsList = ReadFilter(fileElement); - persistenceData.filterTabDataList = ReadFilterTabs(fileElement); - persistenceData.encoding = ReadEncoding(fileElement); + persistenceData.FilterParamsList = ReadFilter(fileElement); + persistenceData.FilterTabDataList = ReadFilterTabs(fileElement); + persistenceData.Encoding = ReadEncoding(fileElement); return persistenceData; } @@ -493,10 +493,10 @@ private static void WriteOptions (XmlDocument xmlDoc, XmlElement rootElement, Pe rootElement.AppendChild(optionsElement); XmlElement element = xmlDoc.CreateElement("multifile"); - element.SetAttribute("enabled", persistenceData.multiFile ? "1" : "0"); - element.SetAttribute("pattern", persistenceData.multiFilePattern); - element.SetAttribute("maxDays", "" + persistenceData.multiFileMaxDays); - foreach (var fileName in persistenceData.multiFileNames) + element.SetAttribute("enabled", persistenceData.MultiFile ? "1" : "0"); + element.SetAttribute("pattern", persistenceData.MultiFilePattern); + element.SetAttribute("maxDays", "" + persistenceData.MultiFileMaxDays); + foreach (var fileName in persistenceData.MultiFileNames) { XmlElement entryElement = xmlDoc.CreateElement("fileEntry"); entryElement.SetAttribute("fileName", "" + fileName); @@ -509,13 +509,13 @@ private static void WriteOptions (XmlDocument xmlDoc, XmlElement rootElement, Pe optionsElement.AppendChild(element); element = xmlDoc.CreateElement("firstDisplayedLine"); - element.SetAttribute("line", "" + persistenceData.firstDisplayedLine); + element.SetAttribute("line", "" + persistenceData.FirstDisplayedLine); optionsElement.AppendChild(element); element = xmlDoc.CreateElement("filter"); - element.SetAttribute("visible", persistenceData.filterVisible ? "1" : "0"); - element.SetAttribute("advanced", persistenceData.filterAdvanced ? "1" : "0"); - element.SetAttribute("position", "" + persistenceData.filterPosition); + element.SetAttribute("visible", persistenceData.FilterVisible ? "1" : "0"); + element.SetAttribute("advanced", persistenceData.FilterAdvanced ? "1" : "0"); + element.SetAttribute("position", "" + persistenceData.FilterPosition); optionsElement.AppendChild(element); element = xmlDoc.CreateElement("bookmarklist"); @@ -524,11 +524,11 @@ private static void WriteOptions (XmlDocument xmlDoc, XmlElement rootElement, Pe optionsElement.AppendChild(element); element = xmlDoc.CreateElement("followTail"); - element.SetAttribute("enabled", persistenceData.followTail ? "1" : "0"); + element.SetAttribute("enabled", persistenceData.FollowTail ? "1" : "0"); optionsElement.AppendChild(element); element = xmlDoc.CreateElement("tab"); - element.SetAttribute("name", persistenceData.tabName); + element.SetAttribute("name", persistenceData.TabName); rootElement.AppendChild(element); element = xmlDoc.CreateElement("columnizer"); @@ -536,15 +536,15 @@ private static void WriteOptions (XmlDocument xmlDoc, XmlElement rootElement, Pe rootElement.AppendChild(element); element = xmlDoc.CreateElement("highlightGroup"); - element.SetAttribute("name", persistenceData.highlightGroupName); + element.SetAttribute("name", persistenceData.HighlightGroupName); rootElement.AppendChild(element); element = xmlDoc.CreateElement("bookmarkCommentColumn"); - element.SetAttribute("visible", persistenceData.showBookmarkCommentColumn ? "1" : "0"); + element.SetAttribute("visible", persistenceData.ShowBookmarkCommentColumn ? "1" : "0"); optionsElement.AppendChild(element); element = xmlDoc.CreateElement("filterSaveList"); - element.SetAttribute("visible", persistenceData.filterSaveListVisible ? "1" : "0"); + element.SetAttribute("visible", persistenceData.FilterSaveListVisible ? "1" : "0"); optionsElement.AppendChild(element); } @@ -553,16 +553,16 @@ private static void ReadOptions (XmlElement startNode, PersistenceData persisten { XmlNode optionsNode = startNode.SelectSingleNode("options"); var value = GetOptionsAttribute(optionsNode, "multifile", "enabled"); - persistenceData.multiFile = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); - persistenceData.multiFilePattern = GetOptionsAttribute(optionsNode, "multifile", "pattern"); + persistenceData.MultiFile = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); + persistenceData.MultiFilePattern = GetOptionsAttribute(optionsNode, "multifile", "pattern"); value = GetOptionsAttribute(optionsNode, "multifile", "maxDays"); try { - persistenceData.multiFileMaxDays = value != null ? short.Parse(value) : 0; + persistenceData.MultiFileMaxDays = value != null ? short.Parse(value) : 0; } catch (Exception) { - persistenceData.multiFileMaxDays = 0; + persistenceData.MultiFileMaxDays = 0; } XmlNode multiFileNode = optionsNode.SelectSingleNode("multifile"); @@ -579,7 +579,7 @@ private static void ReadOptions (XmlElement startNode, PersistenceData persisten fileName = attr.InnerText; } } - persistenceData.multiFileNames.Add(fileName); + persistenceData.MultiFileNames.Add(fileName); } } @@ -591,17 +591,17 @@ private static void ReadOptions (XmlElement startNode, PersistenceData persisten value = GetOptionsAttribute(optionsNode, "firstDisplayedLine", "line"); if (value != null) { - persistenceData.firstDisplayedLine = int.Parse(value); + persistenceData.FirstDisplayedLine = int.Parse(value); } value = GetOptionsAttribute(optionsNode, "filter", "visible"); - persistenceData.filterVisible = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); + persistenceData.FilterVisible = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); value = GetOptionsAttribute(optionsNode, "filter", "advanced"); - persistenceData.filterAdvanced = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); + persistenceData.FilterAdvanced = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); value = GetOptionsAttribute(optionsNode, "filter", "position"); if (value != null) { - persistenceData.filterPosition = int.Parse(value); + persistenceData.FilterPosition = int.Parse(value); } value = GetOptionsAttribute(optionsNode, "bookmarklist", "visible"); @@ -613,18 +613,18 @@ private static void ReadOptions (XmlElement startNode, PersistenceData persisten } value = GetOptionsAttribute(optionsNode, "followTail", "enabled"); - persistenceData.followTail = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); + persistenceData.FollowTail = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); value = GetOptionsAttribute(optionsNode, "bookmarkCommentColumn", "visible"); - persistenceData.showBookmarkCommentColumn = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); + persistenceData.ShowBookmarkCommentColumn = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); value = GetOptionsAttribute(optionsNode, "filterSaveList", "visible"); - persistenceData.filterSaveListVisible = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); + persistenceData.FilterSaveListVisible = value != null && value.Equals("1", StringComparison.OrdinalIgnoreCase); XmlNode tabNode = startNode.SelectSingleNode("tab"); if (tabNode != null) { - persistenceData.tabName = (tabNode as XmlElement).GetAttribute("name"); + persistenceData.TabName = (tabNode as XmlElement).GetAttribute("name"); } XmlNode columnizerNode = startNode.SelectSingleNode("columnizer"); if (columnizerNode != null) @@ -634,7 +634,7 @@ private static void ReadOptions (XmlElement startNode, PersistenceData persisten XmlNode highlightGroupNode = startNode.SelectSingleNode("highlightGroup"); if (highlightGroupNode != null) { - persistenceData.highlightGroupName = (highlightGroupNode as XmlElement).GetAttribute("name"); + persistenceData.HighlightGroupName = (highlightGroupNode as XmlElement).GetAttribute("name"); } } diff --git a/src/LogExpert.Core/Config/ColumnizerMaskEntry.cs b/src/LogExpert.Core/Config/ColumnizerMaskEntry.cs index 37586ec5..9e11b1de 100644 --- a/src/LogExpert.Core/Config/ColumnizerMaskEntry.cs +++ b/src/LogExpert.Core/Config/ColumnizerMaskEntry.cs @@ -1,14 +1,9 @@ -using System; - namespace LogExpert.Core.Config; [Serializable] public class ColumnizerMaskEntry { - #region Fields - - public string columnizerName; - public string mask; + public string ColumnizerName { get; set; } - #endregion + public string Mask { get; set; } } \ No newline at end of file diff --git a/src/LogExpert.Core/Config/HighlightMaskEntry.cs b/src/LogExpert.Core/Config/HighlightMaskEntry.cs index cf1f40d2..8f5fb108 100644 --- a/src/LogExpert.Core/Config/HighlightMaskEntry.cs +++ b/src/LogExpert.Core/Config/HighlightMaskEntry.cs @@ -1,14 +1,9 @@ -using System; - namespace LogExpert.Core.Config; [Serializable] public class HighlightMaskEntry { - #region Fields - - public string highlightGroupName; - public string mask; + public string HighlightGroupName { get; set; } - #endregion + public string Mask { get; set; } } \ No newline at end of file diff --git a/src/LogExpert.Core/Config/ToolEntry.cs b/src/LogExpert.Core/Config/ToolEntry.cs index bb5d4d1e..107ed1d3 100644 --- a/src/LogExpert.Core/Config/ToolEntry.cs +++ b/src/LogExpert.Core/Config/ToolEntry.cs @@ -1,5 +1,3 @@ -using System; - using LogExpert.Core.Classes; namespace LogExpert.Core.Config; @@ -7,39 +5,45 @@ namespace LogExpert.Core.Config; [Serializable] public class ToolEntry { - #region Fields - - public string args = ""; - public string cmd = ""; - public string columnizerName = ""; - public string iconFile; - public int iconIndex; - public bool isFavourite; - public string name; - public bool sysout; - public string workingDir = ""; + public string Args { get; set; } = string.Empty; - #endregion + public string Cmd { get; set; } = string.Empty; + + public string ColumnizerName { get; set; } = string.Empty; + + public string IconFile { get; set; } + + public int IconIndex { get; set; } + + public bool IsFavourite { get; set; } + + public string Name { get; set; } + + public bool Sysout { get; set; } + + public string WorkingDir { get; set; } = string.Empty; #region Public methods - public override string ToString() + public override string ToString () { - return Util.IsNull(name) ? cmd : name; + return Util.IsNull(Name) ? Cmd : Name; } - public ToolEntry Clone() + public ToolEntry Clone () { - ToolEntry clone = new(); - clone.cmd = cmd; - clone.args = args; - clone.name = name; - clone.sysout = sysout; - clone.columnizerName = columnizerName; - clone.isFavourite = isFavourite; - clone.iconFile = iconFile; - clone.iconIndex = iconIndex; - clone.workingDir = workingDir; + ToolEntry clone = new() + { + Cmd = Cmd, + Args = Args, + Name = Name, + Sysout = Sysout, + ColumnizerName = ColumnizerName, + IsFavourite = IsFavourite, + IconFile = IconFile, + IconIndex = IconIndex, + WorkingDir = WorkingDir + }; return clone; } diff --git a/src/LogExpert.Tests/RolloverHandlerTestBase.cs b/src/LogExpert.Tests/RolloverHandlerTestBase.cs index ea84c2cd..abc3d47c 100644 --- a/src/LogExpert.Tests/RolloverHandlerTestBase.cs +++ b/src/LogExpert.Tests/RolloverHandlerTestBase.cs @@ -1,9 +1,9 @@ -using LogExpert.Core.Classes.Log; - using System; using System.Collections.Generic; using System.IO; +using LogExpert.Core.Classes.Log; + namespace LogExpert.Tests; internal class RolloverHandlerTestBase @@ -11,43 +11,40 @@ internal class RolloverHandlerTestBase #region Fields public const string TEST_DIR_NAME = "test"; - public DirectoryInfo testDirectory; #endregion - protected LinkedList CreateTestFilesWithDate() + protected LinkedList CreateTestFilesWithDate () { LinkedList createdFiles = new(); DirectoryInfo dInfo = Directory.CreateDirectory(TEST_DIR_NAME); - testDirectory = dInfo; - createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-08_1.log")); - createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-08_0.log")); - createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-10_0.log")); - createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-11_1.log")); - createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-11_0.log")); - createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-12_2.log")); - createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-12_1.log")); - createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-12_0.log")); + _ = createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-08_1.log")); + _ = createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-08_0.log")); + _ = createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-10_0.log")); + _ = createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-11_1.log")); + _ = createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-11_0.log")); + _ = createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-12_2.log")); + _ = createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-12_1.log")); + _ = createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-12_0.log")); return createdFiles; } - protected LinkedList CreateTestFilesWithoutDate() + protected LinkedList CreateTestFilesWithoutDate () { LinkedList createdFiles = new(); DirectoryInfo dInfo = Directory.CreateDirectory(TEST_DIR_NAME); - testDirectory = dInfo; - createdFiles.AddLast(CreateFile(dInfo, "engine.log.6")); - createdFiles.AddLast(CreateFile(dInfo, "engine.log.5")); - createdFiles.AddLast(CreateFile(dInfo, "engine.log.4")); - createdFiles.AddLast(CreateFile(dInfo, "engine.log.3")); - createdFiles.AddLast(CreateFile(dInfo, "engine.log.2")); - createdFiles.AddLast(CreateFile(dInfo, "engine.log.1")); - createdFiles.AddLast(CreateFile(dInfo, "engine.log")); + _ = createdFiles.AddLast(CreateFile(dInfo, "engine.log.6")); + _ = createdFiles.AddLast(CreateFile(dInfo, "engine.log.5")); + _ = createdFiles.AddLast(CreateFile(dInfo, "engine.log.4")); + _ = createdFiles.AddLast(CreateFile(dInfo, "engine.log.3")); + _ = createdFiles.AddLast(CreateFile(dInfo, "engine.log.2")); + _ = createdFiles.AddLast(CreateFile(dInfo, "engine.log.1")); + _ = createdFiles.AddLast(CreateFile(dInfo, "engine.log")); return createdFiles; } - protected LinkedList RolloverSimulation(LinkedList files, string formatPattern, + protected LinkedList RolloverSimulation (LinkedList files, string formatPattern, bool deleteLatestFile) { LinkedList fileList = files; @@ -65,6 +62,7 @@ protected LinkedList RolloverSimulation(LinkedList files, string File.Move(nextEnumerator.Current, enumerator.Current); enumerator.MoveNext(); } + CreateFile(null, nextEnumerator.Current); if (deleteLatestFile) @@ -72,11 +70,12 @@ protected LinkedList RolloverSimulation(LinkedList files, string File.Delete(fileList.First.Value); fileList.RemoveFirst(); } + return fileList; } - protected void Cleanup() + protected void Cleanup () { try { @@ -87,7 +86,7 @@ protected void Cleanup() } } - protected string CreateFile(DirectoryInfo dInfo, string fileName) + protected string CreateFile (DirectoryInfo dInfo, string fileName) { var lineCount = 10; var fullName = dInfo == null ? fileName : dInfo.FullName + Path.DirectorySeparatorChar + fileName; diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index f95b02f7..ee81f630 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -1,6 +1,5 @@ using System.Runtime.Versioning; -using LogExpert.Classes.Filter; using LogExpert.Core.Callback; using LogExpert.Core.Classes.Bookmark; using LogExpert.Core.Classes.Filter; diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs index 848927a2..e2a49dec 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs @@ -1,7 +1,6 @@ using System.ComponentModel; using System.Runtime.Versioning; -using LogExpert.Classes.Filter; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Filter; using LogExpert.Core.Classes.Highlight; diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs index 2c0cd564..6e35ae4f 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs @@ -101,11 +101,11 @@ private bool LoadPersistenceOptions () return false; } - IsMultiFile = persistenceData.multiFile; + IsMultiFile = persistenceData.MultiFile; _multiFileOptions = new MultiFileOptions { - FormatPattern = persistenceData.multiFilePattern, - MaxDayTry = persistenceData.multiFileMaxDays + FormatPattern = persistenceData.MultiFilePattern, + MaxDayTry = persistenceData.MultiFileMaxDays }; if (string.IsNullOrEmpty(_multiFileOptions.FormatPattern)) @@ -113,30 +113,30 @@ private bool LoadPersistenceOptions () _multiFileOptions = ObjectClone.Clone(Preferences.multiFileOptions); } - splitContainerLogWindow.SplitterDistance = persistenceData.filterPosition; - splitContainerLogWindow.Panel2Collapsed = !persistenceData.filterVisible; - ToggleHighlightPanel(persistenceData.filterSaveListVisible); - ShowAdvancedFilterPanel(persistenceData.filterAdvanced); + splitContainerLogWindow.SplitterDistance = persistenceData.FilterPosition; + splitContainerLogWindow.Panel2Collapsed = !persistenceData.FilterVisible; + ToggleHighlightPanel(persistenceData.FilterSaveListVisible); + ShowAdvancedFilterPanel(persistenceData.FilterAdvanced); if (_reloadMemento == null) { PreselectColumnizer(persistenceData.ColumnizerName); } - FollowTailChanged(persistenceData.followTail, false); - if (persistenceData.tabName != null) + FollowTailChanged(persistenceData.FollowTail, false); + if (persistenceData.TabName != null) { - Text = persistenceData.tabName; + Text = persistenceData.TabName; } AdjustHighlightSplitterWidth(); - SetCurrentHighlightGroup(persistenceData.highlightGroupName); + SetCurrentHighlightGroup(persistenceData.HighlightGroupName); - if (persistenceData.multiFileNames.Count > 0) + if (persistenceData.MultiFileNames.Count > 0) { _logger.Info("Detected MultiFile name list in persistence options"); - _fileNames = new string[persistenceData.multiFileNames.Count]; - persistenceData.multiFileNames.CopyTo(_fileNames); + _fileNames = new string[persistenceData.MultiFileNames.Count]; + persistenceData.MultiFileNames.CopyTo(_fileNames); } else { @@ -144,7 +144,7 @@ private bool LoadPersistenceOptions () } //this.bookmarkWindow.ShowBookmarkCommentColumn = persistenceData.showBookmarkCommentColumn; - SetExplicitEncoding(persistenceData.encoding); + SetExplicitEncoding(persistenceData.Encoding); return true; } catch (Exception ex) @@ -197,7 +197,7 @@ private void LoadPersistenceData () persistenceData = Persister.LoadPersistenceDataFromFixedFile(ForcedPersistenceFileName); } - if (persistenceData.lineCount > _logFileReader.LineCount) + if (persistenceData.LineCount > _logFileReader.LineCount) { // outdated persistence data (logfile rollover) // MessageBox.Show(this, "Persistence data for " + this.FileName + " is outdated. It was discarded.", "Log Expert"); @@ -207,7 +207,7 @@ private void LoadPersistenceData () } _bookmarkProvider.SetBookmarks(persistenceData.BookmarkList); - _rowHeightList = persistenceData.rowHeightList; + _rowHeightList = persistenceData.RowHeightList; try { if (persistenceData.CurrentLine >= 0 && persistenceData.CurrentLine < dataGridView.RowCount) @@ -223,15 +223,15 @@ private void LoadPersistenceData () } } - if (persistenceData.firstDisplayedLine >= 0 && - persistenceData.firstDisplayedLine < dataGridView.RowCount) + if (persistenceData.FirstDisplayedLine >= 0 && + persistenceData.FirstDisplayedLine < dataGridView.RowCount) { - dataGridView.FirstDisplayedScrollingRowIndex = persistenceData.firstDisplayedLine; + dataGridView.FirstDisplayedScrollingRowIndex = persistenceData.FirstDisplayedLine; } - if (persistenceData.followTail) + if (persistenceData.FollowTail) { - FollowTailChanged(persistenceData.followTail, false); + FollowTailChanged(persistenceData.FollowTail, false); } } catch (ArgumentOutOfRangeException) @@ -253,9 +253,9 @@ private void LoadPersistenceData () private void RestoreFilters (PersistenceData persistenceData) { - if (persistenceData.filterParamsList.Count > 0) + if (persistenceData.FilterParamsList.Count > 0) { - _filterParams = persistenceData.filterParamsList[0]; + _filterParams = persistenceData.FilterParamsList[0]; ReInitFilterParams(_filterParams); } @@ -263,15 +263,15 @@ private void RestoreFilters (PersistenceData persistenceData) BeginInvoke(new MethodInvoker(FilterSearch)); try { - splitContainerLogWindow.SplitterDistance = persistenceData.filterPosition; - splitContainerLogWindow.Panel2Collapsed = !persistenceData.filterVisible; + splitContainerLogWindow.SplitterDistance = persistenceData.FilterPosition; + splitContainerLogWindow.Panel2Collapsed = !persistenceData.FilterVisible; } catch (InvalidOperationException e) { _logger.Error(e, "Error setting splitter distance: "); } - ShowAdvancedFilterPanel(persistenceData.filterAdvanced); + ShowAdvancedFilterPanel(persistenceData.FilterAdvanced); if (_filterPipeList.Count == 0) // don't restore if it's only a reload { RestoreFilterTabs(persistenceData); @@ -280,7 +280,7 @@ private void RestoreFilters (PersistenceData persistenceData) private void RestoreFilterTabs (PersistenceData persistenceData) { - foreach (FilterTabData data in persistenceData.filterTabDataList) + foreach (FilterTabData data in persistenceData.FilterTabDataList) { FilterParams persistFilterParams = data.FilterParams; ReInitFilterParams(persistFilterParams); @@ -289,7 +289,7 @@ private void RestoreFilterTabs (PersistenceData persistenceData) List filterHitList = []; Filter(persistFilterParams, filterResultList, _lastFilterLinesList, filterHitList); FilterPipe pipe = new(persistFilterParams.Clone(), this); - WritePipeToTab(pipe, filterResultList, data.PersistenceData.tabName, data.PersistenceData); + WritePipeToTab(pipe, filterResultList, data.PersistenceData.TabName, data.PersistenceData); } } diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs index 6a4c227e..b221c1ba 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs @@ -1,6 +1,5 @@ using System.Text; -using LogExpert.Classes.Filter; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Bookmark; using LogExpert.Core.Classes.Columnizer; @@ -213,21 +212,21 @@ public PersistenceData GetPersistenceData () PersistenceData persistenceData = new() { BookmarkList = _bookmarkProvider.BookmarkList, - rowHeightList = _rowHeightList, - multiFile = IsMultiFile, - multiFilePattern = _multiFileOptions.FormatPattern, - multiFileMaxDays = _multiFileOptions.MaxDayTry, + RowHeightList = _rowHeightList, + MultiFile = IsMultiFile, + MultiFilePattern = _multiFileOptions.FormatPattern, + MultiFileMaxDays = _multiFileOptions.MaxDayTry, CurrentLine = dataGridView.CurrentCellAddress.Y, - firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex, - filterVisible = !splitContainerLogWindow.Panel2Collapsed, - filterAdvanced = !advancedFilterSplitContainer.Panel1Collapsed, - filterPosition = splitContainerLogWindow.SplitterDistance, - followTail = _guiStateArgs.FollowTail, - fileName = FileName, - tabName = Text, - sessionFileName = SessionFileName, + FirstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex, + FilterVisible = !splitContainerLogWindow.Panel2Collapsed, + FilterAdvanced = !advancedFilterSplitContainer.Panel1Collapsed, + FilterPosition = splitContainerLogWindow.SplitterDistance, + FollowTail = _guiStateArgs.FollowTail, + FileName = FileName, + TabName = Text, + SessionFileName = SessionFileName, ColumnizerName = CurrentColumnizer.GetName(), - lineCount = _logFileReader.LineCount + LineCount = _logFileReader.LineCount }; _filterParams.IsFilterTail = filterTailCheckBox.Checked; // this option doesnt need a press on 'search' @@ -235,7 +234,7 @@ public PersistenceData GetPersistenceData () if (Preferences.saveFilters) { List filterList = [_filterParams]; - persistenceData.filterParamsList = filterList; + persistenceData.FilterParamsList = filterList; foreach (FilterPipe filterPipe in _filterPipeList) { @@ -244,23 +243,23 @@ public PersistenceData GetPersistenceData () PersistenceData = filterPipe.OwnLogWindow.GetPersistenceData(), FilterParams = filterPipe.FilterParams }; - persistenceData.filterTabDataList.Add(data); + persistenceData.FilterTabDataList.Add(data); } } if (_currentHighlightGroup != null) { - persistenceData.highlightGroupName = _currentHighlightGroup.GroupName; + persistenceData.HighlightGroupName = _currentHighlightGroup.GroupName; } if (_fileNames != null && IsMultiFile) { - persistenceData.multiFileNames.AddRange(_fileNames); + persistenceData.MultiFileNames.AddRange(_fileNames); } //persistenceData.showBookmarkCommentColumn = this.bookmarkWindow.ShowBookmarkCommentColumn; - persistenceData.filterSaveListVisible = !highlightSplitContainer.Panel2Collapsed; - persistenceData.encoding = _logFileReader.CurrentEncoding; + persistenceData.FilterSaveListVisible = !highlightSplitContainer.Panel2Collapsed; + persistenceData.Encoding = _logFileReader.CurrentEncoding; return persistenceData; } diff --git a/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs b/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs index 16698f1b..d9d19f30 100644 --- a/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs +++ b/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs @@ -1,4 +1,7 @@ -using Newtonsoft.Json; +using LogExpert.UI.Dialogs.Eminus; + +using Newtonsoft.Json; + using System; using System.Collections.Generic; using System.IO; @@ -133,7 +136,7 @@ private XmlDocument BuildXmlDocument(string className, string lineNum) xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); XmlElement rootElement = xmlDoc.CreateElement("eminus"); xmlDoc.AppendChild(rootElement); - rootElement.SetAttribute("authKey", _config.password); + rootElement.SetAttribute("authKey", _config.Password); XmlElement loadElement = xmlDoc.CreateElement("loadclass"); loadElement.SetAttribute("mode", "dialog"); @@ -192,7 +195,7 @@ public void MenuSelected(int logLinesCount, ILogLineColumnizer columnizer, ILogL { try { - TcpClient client = new(_config.host, _config.port); + TcpClient client = new(_config.Host, _config.Port); NetworkStream stream = client.GetStream(); StreamWriter writer = new(stream); doc.Save(writer); diff --git a/src/LogExpert.UI/Dialogs/Eminus/EminusConfig.cs b/src/LogExpert.UI/Dialogs/Eminus/EminusConfig.cs index 444e9dd8..12bda818 100644 --- a/src/LogExpert.UI/Dialogs/Eminus/EminusConfig.cs +++ b/src/LogExpert.UI/Dialogs/Eminus/EminusConfig.cs @@ -1,27 +1,23 @@ -using System; - -namespace LogExpert; +namespace LogExpert.UI.Dialogs.Eminus; [Serializable] internal class EminusConfig { - #region Fields + public string Host { get; set; } = "127.0.0.1"; - public string host = "127.0.0.1"; - public string password = ""; - public int port = 12345; + public string Password { get; set; } = string.Empty; - #endregion + public int Port { get; set; } = 12345; #region Public methods - public EminusConfig Clone() + public EminusConfig Clone () { EminusConfig config = new() { - host = host, - port = port, - password = password + Host = Host, + Port = Port, + Password = Password }; return config; } diff --git a/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.cs b/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.cs index 8b43c982..8fc6673f 100644 --- a/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.cs +++ b/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.cs @@ -2,6 +2,8 @@ using System.Drawing; using System.Windows.Forms; +using LogExpert.UI.Dialogs.Eminus; + namespace LogExpert; internal partial class EminusConfigDlg : Form @@ -24,9 +26,9 @@ public EminusConfigDlg(EminusConfig config) TopLevel = false; Config = config; - hostTextBox.Text = config.host; - portTextBox.Text = string.Empty + config.port; - passwordTextBox.Text = config.password; + hostTextBox.Text = config.Host; + portTextBox.Text = string.Empty + config.Port; + passwordTextBox.Text = config.Password; ResumeLayout(); } @@ -43,16 +45,16 @@ public EminusConfigDlg(EminusConfig config) public void ApplyChanges() { - Config.host = hostTextBox.Text; + Config.Host = hostTextBox.Text; try { - Config.port = short.Parse(portTextBox.Text); + Config.Port = short.Parse(portTextBox.Text); } catch (FormatException) { - Config.port = 0; + Config.Port = 0; } - Config.password = passwordTextBox.Text; + Config.Password = passwordTextBox.Text; } #endregion diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs index 761608c2..5ec04039 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs @@ -272,24 +272,24 @@ private string FindFilenameForSettings (string fileName) return fileName; } - if (!string.IsNullOrEmpty(persistenceData.fileName)) + if (!string.IsNullOrEmpty(persistenceData.FileName)) { - IFileSystemPlugin fs = PluginRegistry.PluginRegistry.Instance.FindFileSystemForUri(persistenceData.fileName); + IFileSystemPlugin fs = PluginRegistry.PluginRegistry.Instance.FindFileSystemForUri(persistenceData.FileName); if (fs != null && !fs.GetType().Equals(typeof(LocalFileSystem))) { - return persistenceData.fileName; + return persistenceData.FileName; } // On relative paths the URI check (and therefore the file system plugin check) will fail. // So fs == null and fs == LocalFileSystem are handled here like normal files. - if (Path.IsPathRooted(persistenceData.fileName)) + if (Path.IsPathRooted(persistenceData.FileName)) { - return persistenceData.fileName; + return persistenceData.FileName; } // handle relative paths in .lxp files var dir = Path.GetDirectoryName(fileName); - return Path.Combine(dir, persistenceData.fileName); + return Path.Combine(dir, persistenceData.FileName); } } @@ -1027,7 +1027,7 @@ private void SetTabIcons (Preferences preferences) [SupportedOSPlatform("windows")] private void SetToolIcon (ToolEntry entry, ToolStripItem item) { - Icon icon = Win32.LoadIconFromExe(entry.iconFile, entry.iconIndex); + Icon icon = Win32.LoadIconFromExe(entry.IconFile, entry.IconIndex); if (icon != null) { item.Image = icon.ToBitmap(); @@ -1044,15 +1044,15 @@ private void SetToolIcon (ToolEntry entry, ToolStripItem item) icon.Dispose(); } - if (!string.IsNullOrEmpty(entry.cmd)) + if (!string.IsNullOrEmpty(entry.Cmd)) { - item.ToolTipText = entry.name; + item.ToolTipText = entry.Name; } } private void ToolButtonClick (ToolEntry toolEntry) { - if (string.IsNullOrEmpty(toolEntry.cmd)) + if (string.IsNullOrEmpty(toolEntry.Cmd)) { //TODO TabIndex => To Enum OpenSettings(2); @@ -1065,12 +1065,12 @@ private void ToolButtonClick (ToolEntry toolEntry) ILogFileInfo info = CurrentLogWindow.GetCurrentFileInfo(); if (line != null && info != null) { - ArgParser parser = new(toolEntry.args); + ArgParser parser = new(toolEntry.Args); var argLine = parser.BuildArgs(line, CurrentLogWindow.GetRealLineNum() + 1, info, this); if (argLine != null) { - StartTool(toolEntry.cmd, argLine, toolEntry.sysout, toolEntry.columnizerName, - toolEntry.workingDir); + StartTool(toolEntry.Cmd, argLine, toolEntry.Sysout, toolEntry.ColumnizerName, + toolEntry.WorkingDir); } } } @@ -1245,7 +1245,7 @@ private void FillToolLauncherBar () externalToolsToolStrip.SuspendLayout(); foreach (ToolEntry tool in Preferences.toolEntries) { - if (tool.isFavourite) + if (tool.IsFavourite) { ToolStripButton button = new("" + labels[num % 26]) { @@ -1258,7 +1258,7 @@ private void FillToolLauncherBar () } num++; - ToolStripMenuItem menuItem = new(tool.name) + ToolStripMenuItem menuItem = new(tool.Name) { Tag = tool }; @@ -1335,7 +1335,7 @@ private IDockContent DeserializeDockContent (string persistString) if (persistString.StartsWith(WindowTypes.LogWindow.ToString())) { - var fileName = persistString.Substring(WindowTypes.LogWindow.ToString().Length + 1); + var fileName = persistString[(WindowTypes.LogWindow.ToString().Length + 1)..]; LogWindow.LogWindow win = FindWindowForFile(fileName); if (win != null) { diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs index 6d5e93e6..006eedf9 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs @@ -2,8 +2,8 @@ using System.Text; using System.Text.RegularExpressions; -using LogExpert.Classes.Filter; using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Classes.Filter; using LogExpert.Core.Config; using LogExpert.Core.Entities; using LogExpert.Core.Interface; @@ -243,13 +243,13 @@ public ILogLineColumnizer FindColumnizerByFileMask (string fileName) { foreach (ColumnizerMaskEntry entry in ConfigManager.Settings.Preferences.columnizerMaskList) { - if (entry.mask != null) + if (entry.Mask != null) { try { - if (Regex.IsMatch(fileName, entry.mask)) + if (Regex.IsMatch(fileName, entry.Mask)) { - ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(entry.columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(entry.ColumnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); return columnizer; } } @@ -268,13 +268,13 @@ public HighlightGroup FindHighlightGroupByFileMask (string fileName) { foreach (HighlightMaskEntry entry in ConfigManager.Settings.Preferences.highlightMaskList) { - if (entry.mask != null) + if (entry.Mask != null) { try { - if (Regex.IsMatch(fileName, entry.mask)) + if (Regex.IsMatch(fileName, entry.Mask)) { - HighlightGroup group = FindHighlightGroup(entry.highlightGroupName); + HighlightGroup group = FindHighlightGroup(entry.HighlightGroupName); return group; } } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs index 4c097add..c32ab66d 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs @@ -269,7 +269,7 @@ private void FillColumnizerForToolsList () { if (_selectedTool != null) { - FillColumnizerForToolsList(comboBoxColumnizer, _selectedTool.columnizerName); + FillColumnizerForToolsList(comboBoxColumnizer, _selectedTool.ColumnizerName); } } @@ -324,8 +324,8 @@ private void FillColumnizerList () } row.Cells.Add(cell); - row.Cells[0].Value = maskEntry.mask; - ILogLineColumnizer columnizer = ColumnizerPicker.DecideColumnizerByName(maskEntry.columnizerName, + row.Cells[0].Value = maskEntry.Mask; + ILogLineColumnizer columnizer = ColumnizerPicker.DecideColumnizerByName(maskEntry.ColumnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); row.Cells[1].Value = columnizer.GetName(); @@ -368,9 +368,9 @@ private void FillHighlightMaskList () } row.Cells.Add(cell); - row.Cells[0].Value = maskEntry.mask; + row.Cells[0].Value = maskEntry.Mask; - HighlightGroup currentGroup = _logTabWin.FindHighlightGroup(maskEntry.highlightGroupName); + HighlightGroup currentGroup = _logTabWin.FindHighlightGroup(maskEntry.HighlightGroupName); var highlightGroupList = _logTabWin.HighlightGroupList; currentGroup ??= highlightGroupList.Count > 0 ? highlightGroupList[0] : new HighlightGroup(); @@ -397,8 +397,8 @@ private void SaveColumnizerList () if (!row.IsNewRow) { ColumnizerMaskEntry entry = new(); - entry.mask = (string)row.Cells[0].Value; - entry.columnizerName = (string)row.Cells[1].Value; + entry.Mask = (string)row.Cells[0].Value; + entry.ColumnizerName = (string)row.Cells[1].Value; Preferences.columnizerMaskList.Add(entry); } } @@ -413,8 +413,8 @@ private void SaveHighlightMaskList () if (!row.IsNewRow) { HighlightMaskEntry entry = new(); - entry.mask = (string)row.Cells[0].Value; - entry.highlightGroupName = (string)row.Cells[1].Value; + entry.Mask = (string)row.Cells[0].Value; + entry.HighlightGroupName = (string)row.Cells[1].Value; Preferences.highlightMaskList.Add(entry); } } @@ -481,7 +481,7 @@ private void FillToolListbox () foreach (ToolEntry tool in Preferences.toolEntries) { - listBoxTools.Items.Add(tool.Clone(), tool.isFavourite); + listBoxTools.Items.Add(tool.Clone(), tool.IsFavourite); } if (listBoxTools.Items.Count > 0) @@ -523,7 +523,7 @@ private void GetToolListBoxData () for (var i = 0; i < listBoxTools.Items.Count; ++i) { Preferences.toolEntries.Add(listBoxTools.Items[i] as ToolEntry); - (listBoxTools.Items[i] as ToolEntry).isFavourite = listBoxTools.GetItemChecked(i); + (listBoxTools.Items[i] as ToolEntry).IsFavourite = listBoxTools.GetItemChecked(i); } } @@ -531,12 +531,12 @@ private void GetCurrentToolValues () { if (_selectedTool != null) { - _selectedTool.name = Util.IsNullOrSpaces(textBoxToolName.Text) ? textBoxTool.Text : textBoxToolName.Text; - _selectedTool.cmd = textBoxTool.Text; - _selectedTool.args = textBoxArguments.Text; - _selectedTool.columnizerName = comboBoxColumnizer.Text; - _selectedTool.sysout = checkBoxSysout.Checked; - _selectedTool.workingDir = textBoxWorkingDir.Text; + _selectedTool.Name = Util.IsNullOrSpaces(textBoxToolName.Text) ? textBoxTool.Text : textBoxToolName.Text; + _selectedTool.Cmd = textBoxTool.Text; + _selectedTool.Args = textBoxArguments.Text; + _selectedTool.ColumnizerName = comboBoxColumnizer.Text; + _selectedTool.Sysout = checkBoxSysout.Checked; + _selectedTool.WorkingDir = textBoxWorkingDir.Text; } } @@ -544,13 +544,13 @@ private void ShowCurrentToolValues () { if (_selectedTool != null) { - textBoxToolName.Text = _selectedTool.name; - textBoxTool.Text = _selectedTool.cmd; - textBoxArguments.Text = _selectedTool.args; - comboBoxColumnizer.Text = _selectedTool.columnizerName; - checkBoxSysout.Checked = _selectedTool.sysout; - comboBoxColumnizer.Enabled = _selectedTool.sysout; - textBoxWorkingDir.Text = _selectedTool.workingDir; + textBoxToolName.Text = _selectedTool.Name; + textBoxTool.Text = _selectedTool.Cmd; + textBoxArguments.Text = _selectedTool.Args; + comboBoxColumnizer.Text = _selectedTool.ColumnizerName; + checkBoxSysout.Checked = _selectedTool.Sysout; + comboBoxColumnizer.Enabled = _selectedTool.Sysout; + textBoxWorkingDir.Text = _selectedTool.WorkingDir; } } @@ -558,7 +558,7 @@ private void DisplayCurrentIcon () { if (_selectedTool != null) { - Icon icon = Win32.LoadIconFromExe(_selectedTool.iconFile, _selectedTool.iconIndex); + Icon icon = Win32.LoadIconFromExe(_selectedTool.IconFile, _selectedTool.IconIndex); if (icon != null) { Image image = icon.ToBitmap(); @@ -949,7 +949,7 @@ private void OnBtnIconClick (object sender, EventArgs e) { if (_selectedTool != null) { - var iconFile = _selectedTool.iconFile; + var iconFile = _selectedTool.IconFile; if (Util.IsNullOrSpaces(iconFile)) { @@ -960,8 +960,8 @@ private void OnBtnIconClick (object sender, EventArgs e) if (dlg.ShowDialog() == DialogResult.OK) { - _selectedTool.iconFile = dlg.FileName; - _selectedTool.iconIndex = dlg.IconIndex; + _selectedTool.IconFile = dlg.FileName; + _selectedTool.IconIndex = dlg.IconIndex; DisplayCurrentIcon(); } } diff --git a/src/LogExpert/Config/ConfigManager.cs b/src/LogExpert/Config/ConfigManager.cs index 939860b4..9a201cc5 100644 --- a/src/LogExpert/Config/ConfigManager.cs +++ b/src/LogExpert/Config/ConfigManager.cs @@ -26,6 +26,7 @@ public class ConfigManager : IConfigManager private static readonly object _monitor = new(); private static ConfigManager _instance; private readonly object _loadSaveLock = new(); + private readonly object _saveSaveLock = new(); private Settings _settings; #endregion @@ -269,19 +270,16 @@ private void Save (Settings settings, SettingsFlags flags) lock (_loadSaveLock) { _logger.Info("Saving settings"); - lock (this) - { - var dir = Settings.Preferences.PortableMode ? Application.StartupPath : ConfigDir; - - if (!Directory.Exists(dir)) - { - Directory.CreateDirectory(dir); - } + var dir = Settings.Preferences.PortableMode ? Application.StartupPath : ConfigDir; - FileInfo fileInfo = new(dir + Path.DirectorySeparatorChar + "settings.json"); - Save(fileInfo, settings); + if (!Directory.Exists(dir)) + { + Directory.CreateDirectory(dir); } + FileInfo fileInfo = new(dir + Path.DirectorySeparatorChar + "settings.json"); + Save(fileInfo, settings); + OnConfigChanged(flags); } } From aca8c640b1b1f4e13964c07a9402af6584fd4d05 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Tue, 3 Jun 2025 12:27:21 +0200 Subject: [PATCH 060/142] more warnings removed --- src/ColumnizerLib/Column.cs | 8 +- src/CsvColumnizer/CsvColumnizer.cs | 54 ++--- src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs | 2 +- .../Classes/Log/LogfileReader.cs | 28 +-- .../Classes/Persister/Persister.cs | 6 +- src/LogExpert.Core/Config/Preferences.cs | 110 +++++---- .../Config/SessionSaveLocation.cs | 2 +- src/LogExpert.Core/Config/Settings.cs | 44 ++-- src/LogExpert.Tests/BufferShiftTest.cs | 2 +- src/LogExpert.Tests/JSONSaveTest.cs | 8 +- .../RolloverHandlerTestBase.cs | 3 + .../Controls/BufferedDataGridView.cs | 2 + .../Controls/DateTimeDragControl.cs | 92 ++++---- src/LogExpert.UI/Controls/LogTextColumn.cs | 5 +- .../LogWindow/AbstractLogTabWindow.cs | 8 +- .../Controls/LogWindow/LogWindow.cs | 13 +- .../LogWindow/LogWindowEventHandlers.cs | 101 ++++++-- .../Controls/LogWindow/LogWindowPrivate.cs | 142 ++++++------ .../Controls/LogWindow/LogWindowPublic.cs | 50 ++-- .../Controls/LogWindow/PatternWindow.cs | 89 +++---- .../Controls/LogWindow/TimeSpreadigControl.cs | 19 +- .../Controls/LogWindow/TimeSyncList.cs | 11 +- .../AllowOnlyOneInstanceErrorDialog.cs | 9 +- src/LogExpert.UI/Dialogs/BookmarkWindow.cs | 9 +- src/LogExpert.UI/Dialogs/Eminus/Eminus.cs | 60 +++-- .../Dialogs/Eminus/EminusConfigDlg.cs | 10 +- src/LogExpert.UI/Dialogs/ExceptionWindow.cs | 14 +- .../LogTabWindow/FilterSelectorForm.cs | 17 +- .../Dialogs/LogTabWindow/HighlightDialog.cs | 2 + .../Dialogs/LogTabWindow/LogTabWindow.cs | 3 +- .../LogTabWindow/LogTabWindowEventHandlers.cs | 94 ++++++-- .../LogTabWindow/LogTabWindowPrivate.cs | 76 +++--- .../LogTabWindow/LogTabWindowPublic.cs | 20 +- .../Dialogs/LogTabWindow/SettingsDialog.cs | 218 +++++++++--------- .../Dialogs/ParamRequesterDialog.Designer.cs | 2 +- .../Dialogs/ParamRequesterDialog.cs | 16 +- src/LogExpert.UI/Dialogs/RegexHelperDialog.cs | 22 +- src/LogExpert.UI/Dialogs/SearchDialog.cs | 18 +- src/LogExpert.UI/Dialogs/ToolArgsDialog.cs | 20 +- src/LogExpert.UI/Entities/ArgParser.cs | 8 +- src/LogExpert.UI/Entities/PaintHelper.cs | 152 +++++++----- src/LogExpert.UI/Entities/WindowFileEntry.cs | 1 + src/LogExpert.UI/Extensions/Utils.cs | 19 +- .../Classes/CommandLine/CmdLineInt.cs | 28 +-- src/LogExpert/Classes/LogExpertProxy.cs | 2 +- src/LogExpert/Config/ConfigManager.cs | 74 +++--- src/LogExpert/Program.cs | 8 +- 47 files changed, 931 insertions(+), 770 deletions(-) diff --git a/src/ColumnizerLib/Column.cs b/src/ColumnizerLib/Column.cs index e344464b..7cabf065 100644 --- a/src/ColumnizerLib/Column.cs +++ b/src/ColumnizerLib/Column.cs @@ -7,8 +7,8 @@ public class Column : IColumn { #region Fields - private static readonly int _maxLength = 4678 - 3; - private static readonly string _replacement = "..."; + private const int MAXLENGTH = 4678 - 3; + private const string REPLACEMENT = "..."; private static readonly IEnumerable> _replacements; @@ -26,8 +26,8 @@ static Column () input => input.Replace("\t", " ", StringComparison.Ordinal), //shorten string if it exceeds maxLength - input => input.Length > _maxLength - ? string.Concat(input.AsSpan(0, _maxLength), _replacement) + input => input.Length > MAXLENGTH + ? string.Concat(input.AsSpan(0, MAXLENGTH), REPLACEMENT) : input ]); diff --git a/src/CsvColumnizer/CsvColumnizer.cs b/src/CsvColumnizer/CsvColumnizer.cs index 8d6bffe5..9254c4ca 100644 --- a/src/CsvColumnizer/CsvColumnizer.cs +++ b/src/CsvColumnizer/CsvColumnizer.cs @@ -1,9 +1,3 @@ -using CsvHelper; - -using LogExpert; - -using Newtonsoft.Json; - using System; using System.Collections.Generic; using System.IO; @@ -12,6 +6,12 @@ using System.Runtime.Versioning; using System.Windows.Forms; +using CsvHelper; + +using LogExpert; + +using Newtonsoft.Json; + [assembly: SupportedOSPlatform("windows")] namespace CsvColumnizer; @@ -24,7 +24,7 @@ public class CsvColumnizer : ILogLineColumnizer, IInitColumnizer, IColumnizerCon { #region Fields - private static readonly string _configFileName = "csvcolumnizer.json"; + private const string CONFIGFILENAME = "csvcolumnizer.json"; private readonly IList _columnList = []; private CsvColumnizerConfig _config; @@ -38,7 +38,7 @@ public class CsvColumnizer : ILogLineColumnizer, IInitColumnizer, IColumnizerCon #region Public methods - public string PreProcessLine(string logLine, int lineNum, int realLineNum) + public string PreProcessLine (string logLine, int lineNum, int realLineNum) { if (realLineNum == 0) { @@ -72,22 +72,22 @@ public string PreProcessLine(string logLine, int lineNum, int realLineNum) return logLine; } - public string GetName() + public string GetName () { return "CSV Columnizer"; } - public string GetDescription() + public string GetDescription () { return "Splits CSV files into columns.\r\n\r\nCredits:\r\nThis Columnizer uses the CsvHelper. https://github.com/JoshClose/CsvHelper. \r\n"; } - public int GetColumnCount() + public int GetColumnCount () { return _isValidCsv ? _columnList.Count : 1; } - public string[] GetColumnNames() + public string[] GetColumnNames () { var names = new string[GetColumnCount()]; if (_isValidCsv) @@ -106,7 +106,7 @@ public string[] GetColumnNames() return names; } - public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) + public IColumnizedLogLine SplitLine (ILogLineColumnizerCallback callback, ILogLine line) { if (_isValidCsv) { @@ -116,7 +116,7 @@ public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLin return CreateColumnizedLogLine(line); } - private static ColumnizedLogLine CreateColumnizedLogLine(ILogLine line) + private static ColumnizedLogLine CreateColumnizedLogLine (ILogLine line) { ColumnizedLogLine cLogLine = new() { @@ -126,32 +126,32 @@ private static ColumnizedLogLine CreateColumnizedLogLine(ILogLine line) return cLogLine; } - public bool IsTimeshiftImplemented() + public bool IsTimeshiftImplemented () { return false; } - public void SetTimeOffset(int msecOffset) + public void SetTimeOffset (int msecOffset) { throw new NotImplementedException(); } - public int GetTimeOffset() + public int GetTimeOffset () { throw new NotImplementedException(); } - public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) + public DateTime GetTimestamp (ILogLineColumnizerCallback callback, ILogLine line) { throw new NotImplementedException(); } - public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) + public void PushValue (ILogLineColumnizerCallback callback, int column, string value, string oldValue) { throw new NotImplementedException(); } - public void Selected(ILogLineColumnizerCallback callback) + public void Selected (ILogLineColumnizerCallback callback) { if (_isValidCsv) // see PreProcessLine() { @@ -186,14 +186,14 @@ public void Selected(ILogLineColumnizerCallback callback) } } - public void DeSelected(ILogLineColumnizerCallback callback) + public void DeSelected (ILogLineColumnizerCallback callback) { // nothing to do } - public void Configure(ILogLineColumnizerCallback callback, string configDir) + public void Configure (ILogLineColumnizerCallback callback, string configDir) { - var configPath = configDir + "\\" + _configFileName; + var configPath = configDir + "\\" + CONFIGFILENAME; FileInfo fileInfo = new(configPath); CsvColumnizerConfigDlg dlg = new(_config); @@ -214,9 +214,9 @@ public void Configure(ILogLineColumnizerCallback callback, string configDir) } } - public void LoadConfig(string configDir) + public void LoadConfig (string configDir) { - var configPath = Path.Combine(configDir, _configFileName); + var configPath = Path.Combine(configDir, CONFIGFILENAME); if (!File.Exists(configPath)) { @@ -239,7 +239,7 @@ public void LoadConfig(string configDir) } } - public Priority GetPriority(string fileName, IEnumerable samples) + public Priority GetPriority (string fileName, IEnumerable samples) { Priority result = Priority.NotSupport; @@ -255,7 +255,7 @@ public Priority GetPriority(string fileName, IEnumerable samples) #region Private Methods - private IColumnizedLogLine SplitCsvLine(ILogLine line) + private IColumnizedLogLine SplitCsvLine (ILogLine line) { ColumnizedLogLine cLogLine = new() { diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs index e02464fd..0d8833a3 100644 --- a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs @@ -22,7 +22,7 @@ public class Log4jXmlColumnizer : ILogLineXmlColumnizer, IColumnizerConfigurator protected const string DATETIME_FORMAT = "dd.MM.yyyy HH:mm:ss.fff"; private static readonly XmlConfig xmlConfig = new(); - private readonly char separatorChar = '\xFFFD'; + private const char separatorChar = '\xFFFD'; private readonly char[] trimChars = ['\xFFFD']; private Log4jXmlColumnizerConfig _config; private readonly CultureInfo _cultureInfo = new("de-DE"); diff --git a/src/LogExpert.Core/Classes/Log/LogfileReader.cs b/src/LogExpert.Core/Classes/Log/LogfileReader.cs index f895c283..279b9668 100644 --- a/src/LogExpert.Core/Classes/Log/LogfileReader.cs +++ b/src/LogExpert.Core/Classes/Log/LogfileReader.cs @@ -19,8 +19,8 @@ public class LogfileReader : IAutoLogLineColumnizerCallback private readonly GetLogLineFx _logLineFx; private readonly string _fileName; - private readonly int _MAX_BUFFERS = 10; - private readonly int _MAX_LINES_PER_BUFFER = 100; + private readonly int _max_buffers; + private readonly int _maxLinesPerBuffer; private readonly object _monitor = new(); private readonly MultiFileOptions _multiFileOptions; @@ -64,8 +64,8 @@ public LogfileReader (string fileName, EncodingOptions encodingOptions, bool mul _fileName = fileName; EncodingOptions = encodingOptions; IsMultiFile = multiFile; - _MAX_BUFFERS = bufferCount; - _MAX_LINES_PER_BUFFER = linesPerBuffer; + _max_buffers = bufferCount; + _maxLinesPerBuffer = linesPerBuffer; _multiFileOptions = multiFileOptions; _pluginRegistry = pluginRegistry; _logLineFx = GetLogLineInternal; @@ -102,8 +102,8 @@ public LogfileReader (string[] fileNames, EncodingOptions encodingOptions, int b EncodingOptions = encodingOptions; IsMultiFile = true; - _MAX_BUFFERS = bufferCount; - _MAX_LINES_PER_BUFFER = linesPerBuffer; + _max_buffers = bufferCount; + _maxLinesPerBuffer = linesPerBuffer; _multiFileOptions = multiFileOptions; _pluginRegistry = pluginRegistry; _logLineFx = GetLogLineInternal; @@ -799,9 +799,9 @@ private Task GetLogLineInternal (int lineNum) private void InitLruBuffers () { _bufferList = []; - _bufferLru = new List(_MAX_BUFFERS + 1); + _bufferLru = new List(_max_buffers + 1); //this.lruDict = new Dictionary(this.MAX_BUFFERS + 1); // key=startline, value = index in bufferLru - _lruCacheDict = new Dictionary(_MAX_BUFFERS + 1); + _lruCacheDict = new Dictionary(_max_buffers + 1); _lruCacheDictLock = new ReaderWriterLock(); _bufferListLock = new ReaderWriterLock(); _disposeLock = new ReaderWriterLock(); @@ -938,7 +938,7 @@ private void ReadToBufferList (ILogFileInfo logFileInfo, long filePos, int start AcquireBufferListReaderLock(); if (_bufferList.Count == 0) { - logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER) + logBuffer = new LogBuffer(logFileInfo, _maxLinesPerBuffer) { StartLine = startLine, StartPos = filePos @@ -953,7 +953,7 @@ private void ReadToBufferList (ILogFileInfo logFileInfo, long filePos, int start if (!logBuffer.FileInfo.FullName.Equals(logFileInfo.FullName, StringComparison.Ordinal)) { - logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER) + logBuffer = new LogBuffer(logFileInfo, _maxLinesPerBuffer) { StartLine = startLine, StartPos = filePos @@ -997,12 +997,12 @@ private void ReadToBufferList (ILogFileInfo logFileInfo, long filePos, int start } lineCount++; - if (lineCount > _MAX_LINES_PER_BUFFER && reader.IsBufferComplete) + if (lineCount > _maxLinesPerBuffer && reader.IsBufferComplete) { OnLoadFile(new LoadFileEventArgs(logFileInfo.FullName, filePos, false, logFileInfo.Length, false)); Monitor.Exit(logBuffer); - logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER); + logBuffer = new LogBuffer(logFileInfo, _maxLinesPerBuffer); Monitor.Enter(logBuffer); logBuffer.StartLine = lineNum; logBuffer.StartPos = filePos; @@ -1136,9 +1136,9 @@ private void GarbageCollectLruCache () var threshold = 10; _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); var diff = 0; - if (_lruCacheDict.Count - (_MAX_BUFFERS + threshold) > 0) + if (_lruCacheDict.Count - (_max_buffers + threshold) > 0) { - diff = _lruCacheDict.Count - _MAX_BUFFERS; + diff = _lruCacheDict.Count - _max_buffers; #if DEBUG if (diff > 0) { diff --git a/src/LogExpert.Core/Classes/Persister/Persister.cs b/src/LogExpert.Core/Classes/Persister/Persister.cs index 6e6835b2..d055db08 100644 --- a/src/LogExpert.Core/Classes/Persister/Persister.cs +++ b/src/LogExpert.Core/Classes/Persister/Persister.cs @@ -26,7 +26,7 @@ public static string SavePersistenceData (string logFileName, PersistenceData pe { var fileName = persistenceData.SessionFileName ?? BuildPersisterFileName(logFileName, preferences); - if (preferences.saveLocation == SessionSaveLocation.SameDir) + if (preferences.SaveLocation == SessionSaveLocation.SameDir) { // make to log file in .lxp file relative var filePart = Path.GetFileName(persistenceData.FileName); @@ -106,7 +106,7 @@ private static string BuildPersisterFileName (string logFileName, Preferences pr string dir; string file; - switch (preferences.saveLocation) + switch (preferences.SaveLocation) { case SessionSaveLocation.SameDir: default: @@ -126,7 +126,7 @@ private static string BuildPersisterFileName (string logFileName, Preferences pr } case SessionSaveLocation.OwnDir: { - dir = preferences.sessionSaveDirectory; + dir = preferences.SessionSaveDirectory; file = dir + Path.DirectorySeparatorChar + BuildSessionFileNameFromPath(logFileName); break; } diff --git a/src/LogExpert.Core/Config/Preferences.cs b/src/LogExpert.Core/Config/Preferences.cs index 333465ec..779e6fb8 100644 --- a/src/LogExpert.Core/Config/Preferences.cs +++ b/src/LogExpert.Core/Config/Preferences.cs @@ -1,111 +1,107 @@ +using System.Drawing; + using LogExpert.Core.Entities; using LogExpert.Core.Enums; -using System.Drawing; - namespace LogExpert.Core.Config; [Serializable] public class Preferences { - #region Fields - - public bool allowOnlyOneInstance; - - public bool askForClose; + public List HighlightGroupList { get; set; } = []; - public bool darkMode; + public bool PortableMode { get; set; } - public int bufferCount = 100; + public bool ShowErrorMessageAllowOnlyOneInstances { get; set; } - public List columnizerMaskList = []; + public int MaxLineLength { get; set; } = 20000; - public string defaultEncoding; + public bool AllowOnlyOneInstance { get; set; } - public bool filterSync = true; + public bool AskForClose { get; set; } - public bool filterTail = true; + public bool DarkMode { get; set; } - public bool followTail = true; + public bool UseLegacyReader { get; set; } - public string fontName = "Courier New"; + public List ToolEntries { get; set; } = []; - public float fontSize = 9; + public DragOrientationsEnum TimestampControlDragOrientation { get; set; } = DragOrientationsEnum.Horizontal; - public List highlightMaskList = []; + public bool TimestampControl { get; set; } - public List HighlightGroupList { get; set; } = []; + public bool TimeSpreadTimeMode { get; set; } - public bool isAutoHideFilterList; + /// + /// Save Directory of the last logfile + /// + public string SessionSaveDirectory { get; set; } - public bool isFilterOnLoad; + public bool SaveFilters { get; set; } = true; - public int lastColumnWidth = 2000; + public SessionSaveLocation SaveLocation { get; set; } = SessionSaveLocation.DocumentsDir; - public int linesPerBuffer = 500; + public bool SaveSessions { get; set; } = true; - public int maximumFilterEntries = 30; + public bool SetLastColumnWidth { get; set; } - public int maximumFilterEntriesDisplayed = 20; + public bool ShowBubbles { get; set; } = true; - public bool maskPrio; + public bool ShowColumnFinder { get; set; } - public bool autoPick; + public Color ShowTailColor { get; set; } = Color.FromKnownColor(KnownColor.Blue); - //Refactor Enum - public MultiFileOption multiFileOption; + public bool ShowTailState { get; set; } = true; - //Refactor class? - public MultiFileOptions multiFileOptions; + public bool ShowTimeSpread { get; set; } - public bool multiThreadFilter = true; + public Color TimeSpreadColor { get; set; } = Color.FromKnownColor(KnownColor.Gray); - public bool openLastFiles = true; + public bool IsAutoHideFilterList { get; set; } - public int pollingInterval = 250; + public bool IsFilterOnLoad { get; set; } - public bool reverseAlpha; + public int LastColumnWidth { get; set; } = 2000; - public bool PortableMode { get; set; } + public int LinesPerBuffer { get; set; } = 500; - /// - /// Save Directory of the last logfile - /// - public string sessionSaveDirectory; + public int MaximumFilterEntries { get; set; } = 30; - public bool saveFilters = true; + public int MaximumFilterEntriesDisplayed { get; set; } = 20; - public SessionSaveLocation saveLocation = SessionSaveLocation.DocumentsDir; + public bool MaskPrio { get; set; } - public bool saveSessions = true; + public bool AutoPick { get; set; } - public bool setLastColumnWidth; + //TODO Refactor Enum + public MultiFileOption MultiFileOption { get; set; } - public bool showBubbles = true; + //TODO Refactor Class + public MultiFileOptions MultiFileOptions { get; set; } - public bool showColumnFinder; + public bool MultiThreadFilter { get; set; } = true; - public Color showTailColor = Color.FromKnownColor(KnownColor.Blue); + public bool OpenLastFiles { get; set; } = true; - public bool showTailState = true; + public int PollingInterval { get; set; } = 250; - public bool showTimeSpread; + public bool ReverseAlpha { get; set; } - public Color timeSpreadColor = Color.FromKnownColor(KnownColor.Gray); + public int BufferCount { get; set; } = 100; - public bool timeSpreadTimeMode; + public List ColumnizerMaskList { get; set; } = []; - public bool timestampControl = true; + public string DefaultEncoding { get; set; } - public DragOrientationsEnum timestampControlDragOrientation = DragOrientationsEnum.Horizontal; + public bool FilterSync { get; set; } = true; - public List toolEntries = []; + public bool FilterTail { get; set; } = true; - public bool useLegacyReader; + public bool FollowTail { get; set; } = true; - public bool ShowErrorMessageAllowOnlyOneInstances { get; set; } + public string FontName { get; set; } = "Courier New"; - public int MaxLineLength { get; set; } = 20000; + public float FontSize { get; set; } = 9; - #endregion + public List HighlightMaskList { get; set; } = []; } \ No newline at end of file diff --git a/src/LogExpert.Core/Config/SessionSaveLocation.cs b/src/LogExpert.Core/Config/SessionSaveLocation.cs index 7e559d6c..2759cb19 100644 --- a/src/LogExpert.Core/Config/SessionSaveLocation.cs +++ b/src/LogExpert.Core/Config/SessionSaveLocation.cs @@ -14,7 +14,7 @@ public enum SessionSaveLocation SameDir, //uses configured folder to save the session files /// - /// + /// /// OwnDir, /// diff --git a/src/LogExpert.Core/Config/Settings.cs b/src/LogExpert.Core/Config/Settings.cs index 461ec6d9..51375e41 100644 --- a/src/LogExpert.Core/Config/Settings.cs +++ b/src/LogExpert.Core/Config/Settings.cs @@ -8,47 +8,43 @@ namespace LogExpert.Core.Config; [Serializable] public class Settings { - #region Fields - - public bool alwaysOnTop; - - public Rectangle appBounds; + public Preferences Preferences { get; set; } = new(); - public Rectangle appBoundsFullscreen; + public RegexHistory RegexHistory { get; set; } = new(); - public IList columnizerHistoryList = []; + public bool AlwaysOnTop { get; set; } - public List fileColors = []; + public Rectangle AppBounds { get; set; } - public List fileHistoryList = []; + public Rectangle AppBoundsFullscreen { get; set; } - public List filterHistoryList = []; + public IList ColumnizerHistoryList { get; set; } = []; - public List filterList = []; + public List FileColors { get; set; } = []; - public FilterParams filterParams = new(); + public List FileHistoryList { get; set; } = []; - public List filterRangeHistoryList = []; + public List FilterHistoryList { get; set; } = []; - public bool hideLineColumn; + public List FilterList { get; set; } = []; - public bool isMaximized; + public FilterParams FilterParams { get; set; } = new(); - public string lastDirectory; + public List FilterRangeHistoryList { get; set; } = []; - public List lastOpenFilesList = []; + public bool HideLineColumn { get; set; } - public Preferences Preferences { get; set; } = new(); + public bool IsMaximized { get; set; } - public RegexHistory RegexHistory { get; set; } = new(); + public string LastDirectory { get; set; } - public List searchHistoryList = []; + public List LastOpenFilesList { get; set; } = []; - public SearchParams searchParams = new(); + public List SearchHistoryList { get; set; } = []; - public IList uriHistoryList = []; + public SearchParams SearchParams { get; set; } = new(); - public int versionBuild; + public IList UriHistoryList { get; set; } = []; - #endregion + public int VersionBuild { get; set; } } \ No newline at end of file diff --git a/src/LogExpert.Tests/BufferShiftTest.cs b/src/LogExpert.Tests/BufferShiftTest.cs index 8783bd68..985f3a5d 100644 --- a/src/LogExpert.Tests/BufferShiftTest.cs +++ b/src/LogExpert.Tests/BufferShiftTest.cs @@ -41,7 +41,7 @@ public void TestShiftBuffers1 () Encoding = Encoding.Default }; - PluginRegistry.PluginRegistry.Instance.Create(testDirectory.FullName, 500); + PluginRegistry.PluginRegistry.Instance.Create(TestDirectory.FullName, 500); LogfileReader reader = new(files.Last.Value, encodingOptions, true, 40, 50, options, PluginRegistry.PluginRegistry.Instance); reader.ReadFiles(); diff --git a/src/LogExpert.Tests/JSONSaveTest.cs b/src/LogExpert.Tests/JSONSaveTest.cs index e4193294..01f542a3 100644 --- a/src/LogExpert.Tests/JSONSaveTest.cs +++ b/src/LogExpert.Tests/JSONSaveTest.cs @@ -15,7 +15,7 @@ public class JSONSaveTest [Test(Author = "Hirogen", Description = "Save Options as JSON and Check if the written file can be cast again into the settings object")] public void SaveOptionsAsJSON() { - ConfigManager.Instance.Settings.alwaysOnTop = true; + ConfigManager.Instance.Settings.AlwaysOnTop = true; ConfigManager.Instance.Save(SettingsFlags.All); var configDir = ConfigManager.Instance.ConfigDir; var settingsFile = configDir + "\\settings.json"; @@ -24,16 +24,16 @@ public void SaveOptionsAsJSON() Assert.DoesNotThrow(CastSettings); Assert.That(settings, Is.Not.Null); - Assert.That(settings.alwaysOnTop, Is.True); + Assert.That(settings.AlwaysOnTop, Is.True); - ConfigManager.Instance.Settings.alwaysOnTop = false; + ConfigManager.Instance.Settings.AlwaysOnTop = false; ConfigManager.Instance.Save(SettingsFlags.All); settings = null; Assert.DoesNotThrow(CastSettings); Assert.That(settings, !Is.Null); - Assert.That(settings.alwaysOnTop, Is.False); + Assert.That(settings.AlwaysOnTop, Is.False); void CastSettings() diff --git a/src/LogExpert.Tests/RolloverHandlerTestBase.cs b/src/LogExpert.Tests/RolloverHandlerTestBase.cs index abc3d47c..445a1579 100644 --- a/src/LogExpert.Tests/RolloverHandlerTestBase.cs +++ b/src/LogExpert.Tests/RolloverHandlerTestBase.cs @@ -14,11 +14,13 @@ internal class RolloverHandlerTestBase #endregion + public DirectoryInfo TestDirectory { get; set; } protected LinkedList CreateTestFilesWithDate () { LinkedList createdFiles = new(); DirectoryInfo dInfo = Directory.CreateDirectory(TEST_DIR_NAME); + TestDirectory = dInfo; _ = createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-08_1.log")); _ = createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-08_0.log")); _ = createdFiles.AddLast(CreateFile(dInfo, "engine_2010-06-10_0.log")); @@ -34,6 +36,7 @@ protected LinkedList CreateTestFilesWithoutDate () { LinkedList createdFiles = new(); DirectoryInfo dInfo = Directory.CreateDirectory(TEST_DIR_NAME); + TestDirectory = dInfo; _ = createdFiles.AddLast(CreateFile(dInfo, "engine.log.6")); _ = createdFiles.AddLast(CreateFile(dInfo, "engine.log.5")); _ = createdFiles.AddLast(CreateFile(dInfo, "engine.log.4")); diff --git a/src/LogExpert.UI/Controls/BufferedDataGridView.cs b/src/LogExpert.UI/Controls/BufferedDataGridView.cs index e279178f..c52e73bc 100644 --- a/src/LogExpert.UI/Controls/BufferedDataGridView.cs +++ b/src/LogExpert.UI/Controls/BufferedDataGridView.cs @@ -1,4 +1,5 @@ using System.Drawing.Drawing2D; +using System.Runtime.Versioning; using LogExpert.Core.Entities; using LogExpert.Core.EventArguments; @@ -8,6 +9,7 @@ namespace LogExpert.Dialogs; +[SupportedOSPlatform("windows")] public partial class BufferedDataGridView : DataGridView { #region Fields diff --git a/src/LogExpert.UI/Controls/DateTimeDragControl.cs b/src/LogExpert.UI/Controls/DateTimeDragControl.cs index e7b96a98..676e9f86 100644 --- a/src/LogExpert.UI/Controls/DateTimeDragControl.cs +++ b/src/LogExpert.UI/Controls/DateTimeDragControl.cs @@ -14,6 +14,7 @@ namespace LogExpert.Dialogs; /// We currently support only three: US (mm/dd/yyyy), French (yyyy-mm-dd) and German (dd.mm.yyyy). /// The control raises events (ValueChanged, ValueDragged) when the date/time changes so that owner can react accordingly. /// +[SupportedOSPlatform("windows")] public partial class DateTimeDragControl : UserControl { #region Fields @@ -23,11 +24,12 @@ public partial class DateTimeDragControl : UserControl private DateTime _dateTime; - private readonly IList _digitRects = new List(); + private readonly IList _digitRects = []; + private readonly StringFormat _digitsFormat = new(); private int _draggedDigit; - public DragOrientationsEnum dragOrientation = DragOrientationsEnum.Vertical; + private DragOrientationsEnum _dragOrientation = DragOrientationsEnum.Vertical; private readonly ToolStripItem toolStripItemHorizontalDrag = new ToolStripMenuItem(); private readonly ToolStripItem toolStripItemVerticalDrag = new ToolStripMenuItem(); @@ -87,10 +89,10 @@ public DateTimeDragControl () public DragOrientationsEnum DragOrientation { - get => dragOrientation; + get => _dragOrientation; set { - dragOrientation = value; + _dragOrientation = value; UpdateContextMenu(); } } @@ -138,32 +140,34 @@ private int GetDraggedValue () { var datePart = _dateParts[_draggedDigit]; - if (datePart.StartsWith("y", StringComparison.OrdinalIgnoreCase)) + if (datePart.StartsWith('y')) { return _dateTime.Year; } - if (datePart.StartsWith("M")) + if (datePart.StartsWith('M')) { return _dateTime.Month; } - if (datePart.StartsWith("d", StringComparison.OrdinalIgnoreCase)) + if (datePart.StartsWith('d')) { return _dateTime.Day; } - if (datePart.StartsWith("h", StringComparison.OrdinalIgnoreCase)) + if (datePart.StartsWith('h')) { return _dateTime.Hour; } - if (datePart.StartsWith("m")) + if (datePart.StartsWith('m')) { return _dateTime.Minute; } - return datePart.StartsWith("s", StringComparison.OrdinalIgnoreCase) ? _dateTime.Second : NO_DIGIT_DRAGGED; + return datePart.StartsWith('s') + ? _dateTime.Second + : NO_DIGIT_DRAGGED; } private bool SetDraggedValue (int delta) @@ -178,27 +182,27 @@ private bool SetDraggedValue (int delta) { var datePart = _dateParts[_draggedDigit]; - if (datePart.StartsWith("y", StringComparison.OrdinalIgnoreCase)) + if (datePart.StartsWith('y')) { _dateTime = _dateTime.AddYears(delta); } - else if (datePart.StartsWith("M")) + else if (datePart.StartsWith('M')) { _dateTime = _dateTime.AddMonths(delta); } - else if (datePart.StartsWith("d", StringComparison.OrdinalIgnoreCase)) + else if (datePart.StartsWith('d')) { _dateTime = _dateTime.AddDays(delta); } - else if (datePart.StartsWith("h", StringComparison.OrdinalIgnoreCase)) + else if (datePart.StartsWith('h')) { _dateTime = _dateTime.AddHours(delta); } - else if (datePart.StartsWith("m")) + else if (datePart.StartsWith('m')) { _dateTime = _dateTime.AddMinutes(delta); } - else if (datePart.StartsWith("s", StringComparison.OrdinalIgnoreCase)) + else if (datePart.StartsWith('s')) { _dateTime = _dateTime.AddSeconds(delta); } @@ -213,6 +217,7 @@ private bool SetDraggedValue (int delta) _dateTime = MaxDateTime; changed = false; } + if (_dateTime < MinDateTime) { _dateTime = MinDateTime; @@ -246,7 +251,7 @@ private void InitCustomRects (Section dateSection) private void InitDigitRects () { - CultureInfo culture = System.Threading.Thread.CurrentThread.CurrentCulture; + CultureInfo culture = CultureInfo.CurrentCulture; var datePattern = string.Concat(culture.DateTimeFormat.ShortDatePattern, " ", culture.DateTimeFormat.LongTimePattern); @@ -287,11 +292,13 @@ protected void OnValueDragged (EventArgs e) #region Contextual Menu - [SupportedOSPlatform("windows")] private void BuildContextualMenu () { - ContextMenuStrip = new ContextMenuStrip(); - ContextMenuStrip.Name = "Timestamp selector"; + ContextMenuStrip = new ContextMenuStrip + { + Name = "Timestamp selector" + }; + ContextMenuStrip.Items.Add(toolStripItemHorizontalDrag); ContextMenuStrip.Items.Add(toolStripItemVerticalDrag); ContextMenuStrip.Items.Add(toolStripItemVerticalInvertedDrag); @@ -310,7 +317,6 @@ private void BuildContextualMenu () UpdateContextMenu(); } - [SupportedOSPlatform("windows")] private void UpdateContextMenu () { toolStripItemHorizontalDrag.Enabled = DragOrientation != DragOrientationsEnum.Horizontal; @@ -318,7 +324,6 @@ private void UpdateContextMenu () toolStripItemVerticalInvertedDrag.Enabled = DragOrientation != DragOrientationsEnum.InvertedVertical; } - [SupportedOSPlatform("windows")] private void OnContextMenuStripOpening (object sender, CancelEventArgs e) { if (Capture) @@ -369,33 +374,31 @@ protected override void OnPaint (PaintEventArgs e) } // Display current value with user-defined date format and fixed time format ("HH:mm:ss") - using (Brush brush = new SolidBrush(Color.Black)) + using Brush brush = new SolidBrush(Color.Black); + for (var i = 0; i < _dateParts.Length; i++) { - for (var i = 0; i < _dateParts.Length; i++) - { - var datePart = _dateParts[i]; - Rectangle rect = _digitRects[i]; - string value; + var datePart = _dateParts[i]; + Rectangle rect = _digitRects[i]; + string value; - if (Token.IsDatePart(datePart)) + if (Token.IsDatePart(datePart)) + { + try { - try - { - value = _dateTime.ToString("-" + datePart + "-"); - value = value.Substring(1, value.Length - 2); - } - catch - { - value = datePart; - } + value = _dateTime.ToString("-" + datePart + "-"); + value = value[1..^1]; } - else + catch { value = datePart; } - - e.Graphics.DrawString(value, Font, brush, rect, _digitsFormat); } + else + { + value = datePart; + } + + e.Graphics.DrawString(value, Font, brush, rect, _digitsFormat); } } @@ -408,7 +411,6 @@ private void DateTimeDragControl_Resize (object sender, EventArgs e) #region Mouse callbacks - [SupportedOSPlatform("windows")] protected override void OnMouseDown (MouseEventArgs e) { base.OnMouseDown(e); @@ -432,10 +434,10 @@ protected override void OnMouseDown (MouseEventArgs e) Capture = false; SetDraggedValue(0); //undo } + Invalidate(); // repaint with the selected item (or none) } - [SupportedOSPlatform("windows")] protected override void OnMouseUp (MouseEventArgs e) { if (!Capture) @@ -452,7 +454,6 @@ protected override void OnMouseUp (MouseEventArgs e) OnValueChanged(EventArgs.Empty); } - [SupportedOSPlatform("windows")] protected override void OnMouseMove (MouseEventArgs e) { base.OnMouseMove(e); @@ -482,7 +483,7 @@ protected override void OnMouseMove (MouseEventArgs e) } } - var delta = diff / 5 - _addedValue; // one unit per 5 pixels move + var delta = (diff / 5) - _addedValue; // one unit per 5 pixels move if (delta == 0) { @@ -499,7 +500,6 @@ protected override void OnMouseMove (MouseEventArgs e) OnValueDragged(EventArgs.Empty); } - [SupportedOSPlatform("windows")] private void DateTimeDragControl_MouseLeave (object sender, EventArgs e) { if (Capture) diff --git a/src/LogExpert.UI/Controls/LogTextColumn.cs b/src/LogExpert.UI/Controls/LogTextColumn.cs index 2bca5e54..3f2e44b7 100644 --- a/src/LogExpert.UI/Controls/LogTextColumn.cs +++ b/src/LogExpert.UI/Controls/LogTextColumn.cs @@ -1,4 +1,4 @@ -using System.Windows.Forms; +using System.Runtime.Versioning; namespace LogExpert.UI.Controls; @@ -6,7 +6,8 @@ public class LogTextColumn : DataGridViewColumn { #region cTor - public LogTextColumn() : base(new LogGridCell()) + [SupportedOSPlatform("windows")] + public LogTextColumn () : base(new LogGridCell()) { } diff --git a/src/LogExpert.UI/Controls/LogWindow/AbstractLogTabWindow.cs b/src/LogExpert.UI/Controls/LogWindow/AbstractLogTabWindow.cs index 7336d535..2a7caae9 100644 --- a/src/LogExpert.UI/Controls/LogWindow/AbstractLogTabWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/AbstractLogTabWindow.cs @@ -1,13 +1,17 @@ +using System.Runtime.Versioning; + using LogExpert.Core.Interface; +using LogExpert.UI.Dialogs.LogTabWindow; -namespace LogExpert.UI.Dialogs.LogTabWindow; +namespace LogExpert.UI.Controls.LogWindow; public abstract class AbstractLogTabWindow () { public static StaticLogTabWindowData StaticData { get; set; } = new StaticLogTabWindowData(); + [SupportedOSPlatform("windows")] public static ILogTabWindow Create (string[] fileNames, int instanceNumber, bool showInstanceNumbers, IConfigManager configManager) { - return new Controls.LogTabWindow.LogTabWindow(fileNames, instanceNumber, showInstanceNumbers, configManager); + return new LogTabWindow.LogTabWindow(fileNames, instanceNumber, showInstanceNumbers, configManager); } } \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index ee81f630..34e04cc6 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -24,6 +24,7 @@ namespace LogExpert.UI.Controls.LogWindow; //TODO: Implemented 4 interfaces explicitly. Find them by searching: ILogWindow. +[SupportedOSPlatform("windows")] public partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILogWindow { #region Fields @@ -192,12 +193,12 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp //this.toolwinTabControl.TabPages.Add(this.bookmarkWindow); _filterParams = new FilterParams(); - foreach (var item in configManager.Settings.filterHistoryList) + foreach (var item in configManager.Settings.FilterHistoryList) { filterComboBox.Items.Add(item); } - filterComboBox.DropDownHeight = filterComboBox.ItemHeight * configManager.Settings.Preferences.maximumFilterEntriesDisplayed; + filterComboBox.DropDownHeight = filterComboBox.ItemHeight * configManager.Settings.Preferences.MaximumFilterEntriesDisplayed; AutoResizeFilterBox(); filterRegexCheckBox.Checked = _filterParams.IsRegex; @@ -234,9 +235,9 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp Settings settings = configManager.Settings; - if (settings.appBounds.Right > 0) + if (settings.AppBounds.Right > 0) { - Bounds = settings.appBounds; + Bounds = settings.AppBounds; } _waitingForClose = false; @@ -669,6 +670,7 @@ private void OnButtonSizeChanged (object sender, EventArgs e) // =================== ILogLineColumnizerCallback ============================ #if DEBUG + [SupportedOSPlatform("windows")] internal void DumpBufferInfo () { var currentLineNum = dataGridView.CurrentCellAddress.Y; @@ -680,16 +682,19 @@ internal void DumpBufferDiagnostic () _logFileReader.LogBufferDiagnostic(); } + [SupportedOSPlatform("windows")] void ILogWindow.SelectLine (int lineNum, bool v1, bool v2) { SelectLine(lineNum, v1, v2); } + [SupportedOSPlatform("windows")] void ILogWindow.AddTempFileTab (string fileName, string title) { AddTempFileTab(fileName, title); } + [SupportedOSPlatform("windows")] void ILogWindow.WritePipeTab (IList lineEntryList, string title) { WritePipeTab(lineEntryList, title); diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs index e2a49dec..40d1647c 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs @@ -17,6 +17,7 @@ namespace LogExpert.UI.Controls.LogWindow; partial class LogWindow { + [SupportedOSPlatform("windows")] private void AutoResizeFilterBox () { filterSplitContainer.SplitterDistance = filterComboBox.Left + filterComboBox.GetMaxTextWidth(); @@ -100,11 +101,13 @@ protected void OnDeRegisterCancelHandler (IBackgroundProcessCancelHandler handle } } + [SupportedOSPlatform("windows")] private void OnLogWindowLoad (object sender, EventArgs e) { PreferencesChanged(_parentLogTabWin.Preferences, true, SettingsFlags.GuiOrColors); } + [SupportedOSPlatform("windows")] private void OnLogWindowDisposed (object sender, EventArgs e) { _waitingForClose = true; @@ -114,11 +117,13 @@ private void OnLogWindowDisposed (object sender, EventArgs e) FreeFromTimeSync(); } + [SupportedOSPlatform("windows")] private void OnLogFileReaderLoadingStarted (object sender, LoadFileEventArgs e) { Invoke(LoadingStarted, e); } + [SupportedOSPlatform("windows")] private void OnLogFileReaderFinishedLoading (object sender, EventArgs e) { //Thread.CurrentThread.Name = "FinishedLoading event thread"; @@ -151,6 +156,7 @@ private void OnLogFileReaderFinishedLoading (object sender, EventArgs e) _reloadMemento = null; } + [SupportedOSPlatform("windows")] private void OnLogFileReaderFileNotFound (object sender, EventArgs e) { if (!IsDisposed && !Disposing) @@ -161,14 +167,16 @@ private void OnLogFileReaderFileNotFound (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnLogFileReaderRespawned (object sender, EventArgs e) { BeginInvoke(new MethodInvoker(LogfileRespawned)); } + [SupportedOSPlatform("windows")] private void OnLogWindowClosing (object sender, CancelEventArgs e) { - if (Preferences.askForClose) + if (Preferences.AskForClose) { if (MessageBox.Show("Sure to close?", "LogExpert", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { @@ -181,6 +189,7 @@ private void OnLogWindowClosing (object sender, CancelEventArgs e) CloseLogWindow(); } + [SupportedOSPlatform("windows")] private void OnDataGridViewColumnDividerDoubleClick (object sender, DataGridViewColumnDividerDoubleClickEventArgs e) { e.Handled = true; @@ -190,6 +199,7 @@ private void OnDataGridViewColumnDividerDoubleClick (object sender, DataGridView /** * Event handler for the Load event from LogfileReader */ + [SupportedOSPlatform("windows")] private void OnLogFileReaderLoadFile (object sender, LoadFileEventArgs e) { if (e.NewFile) @@ -233,6 +243,7 @@ private void OnFileSizeChanged (object sender, LogEventArgs e) } } + [SupportedOSPlatform("windows")] private void OnDataGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e) { var startCount = CurrentColumnizer?.GetColumnCount() ?? 0; @@ -252,6 +263,7 @@ private void OnDataGridViewCellValueNeeded (object sender, DataGridViewCellValue } } + [SupportedOSPlatform("windows")] private void OnDataGridViewCellValuePushed (object sender, DataGridViewCellValueEventArgs e) { if (!CurrentColumnizer.IsTimeshiftImplemented()) @@ -287,11 +299,13 @@ private void OnDataGridViewCellValuePushed (object sender, DataGridViewCellValue SendGuiStateUpdate(); } + [SupportedOSPlatform("windows")] private void OnDataGridViewRowHeightInfoNeeded (object sender, DataGridViewRowHeightInfoNeededEventArgs e) { e.Height = GetRowHeight(e.RowIndex); } + [SupportedOSPlatform("windows")] private void OnDataGridViewCurrentCellChanged (object sender, EventArgs e) { if (dataGridView.CurrentRow != null) @@ -303,7 +317,7 @@ private void OnDataGridViewCurrentCellChanged (object sender, EventArgs e) SyncFilterGridPos(); } - if (CurrentColumnizer.IsTimeshiftImplemented() && Preferences.timestampControl) + if (CurrentColumnizer.IsTimeshiftImplemented() && Preferences.TimestampControl) { SyncTimestampDisplay(); } @@ -318,26 +332,31 @@ private void OnDataGridViewCellEndEdit (object sender, DataGridViewCellEventArgs StatusLineText(string.Empty); } + [SupportedOSPlatform("windows")] private void OnEditControlKeyUp (object sender, KeyEventArgs e) { UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); } + [SupportedOSPlatform("windows")] private void OnEditControlKeyPress (object sender, KeyPressEventArgs e) { UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); } + [SupportedOSPlatform("windows")] private void OnEditControlClick (object sender, EventArgs e) { UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); } + [SupportedOSPlatform("windows")] private void OnEditControlKeyDown (object sender, KeyEventArgs e) { UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); } + [SupportedOSPlatform("windows")] private void OnDataGridViewPaint (object sender, PaintEventArgs e) { if (ShowBookmarkBubbles) @@ -350,11 +369,13 @@ private void OnDataGridViewPaint (object sender, PaintEventArgs e) // Filter Grid stuff // ====================================================================================== + [SupportedOSPlatform("windows")] private void OnFilterSearchButtonClick (object sender, EventArgs e) { FilterSearch(); } + [SupportedOSPlatform("windows")] private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPaintingEventArgs e) { var gridView = (BufferedDataGridView)sender; @@ -446,7 +467,7 @@ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPainti }; Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); - Font font = new("Verdana", Preferences.fontSize, FontStyle.Bold); + Font font = new("Verdana", Preferences.FontSize, FontStyle.Bold); e.Graphics.DrawString("!", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); font.Dispose(); brush2.Dispose(); @@ -459,6 +480,7 @@ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPainti } } + [SupportedOSPlatform("windows")] private void OnFilterGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e) { if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) @@ -471,11 +493,13 @@ private void OnFilterGridViewCellValueNeeded (object sender, DataGridViewCellVal e.Value = GetCellValue(lineNum, e.ColumnIndex); } + [SupportedOSPlatform("windows")] private void OnFilterGridViewRowHeightInfoNeeded (object sender, DataGridViewRowHeightInfoNeededEventArgs e) { e.Height = _lineHeight; } + [SupportedOSPlatform("windows")] private void OnFilterComboBoxKeyDown (object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) @@ -484,6 +508,7 @@ private void OnFilterComboBoxKeyDown (object sender, KeyEventArgs e) } } + [SupportedOSPlatform("windows")] private void OnFilterGridViewColumnDividerDoubleClick (object sender, DataGridViewColumnDividerDoubleClickEventArgs e) { @@ -492,6 +517,7 @@ private void OnFilterGridViewColumnDividerDoubleClick (object sender, BeginInvoke(fx, filterGridView); } + [SupportedOSPlatform("windows")] private void OnFilterGridViewCellDoubleClick (object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) @@ -507,12 +533,14 @@ private void OnFilterGridViewCellDoubleClick (object sender, DataGridViewCellEve } } + [SupportedOSPlatform("windows")] private void OnRangeCheckBoxCheckedChanged (object sender, EventArgs e) { filterRangeComboBox.Enabled = rangeCheckBox.Checked; CheckForFilterDirty(); } + [SupportedOSPlatform("windows")] private void OnDataGridViewScroll (object sender, ScrollEventArgs e) { if (e.ScrollOrientation == ScrollOrientation.VerticalScroll) @@ -540,6 +568,7 @@ private void OnDataGridViewScroll (object sender, ScrollEventArgs e) } } + [SupportedOSPlatform("windows")] private void OnFilterGridViewKeyDown (object sender, KeyEventArgs e) { switch (e.KeyCode) @@ -562,6 +591,7 @@ private void OnFilterGridViewKeyDown (object sender, KeyEventArgs e) } } + [SupportedOSPlatform("windows")] private void OnDataGridViewKeyDown (object sender, KeyEventArgs e) { switch (e.KeyCode) @@ -584,6 +614,7 @@ private void OnDataGridViewKeyDown (object sender, KeyEventArgs e) _shouldCallTimeSync = true; } + [SupportedOSPlatform("windows")] private void OnDataGridViewPreviewKeyDown (object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Tab && e.Control) @@ -592,6 +623,7 @@ private void OnDataGridViewPreviewKeyDown (object sender, PreviewKeyDownEventArg } } + [SupportedOSPlatform("windows")] private void OnDataGridViewCellContentDoubleClick (object sender, DataGridViewCellEventArgs e) { if (dataGridView.CurrentCell != null) @@ -600,6 +632,7 @@ private void OnDataGridViewCellContentDoubleClick (object sender, DataGridViewCe } } + [SupportedOSPlatform("windows")] private void OnSyncFilterCheckBoxCheckedChanged (object sender, EventArgs e) { if (syncFilterCheckBox.Checked) @@ -608,26 +641,31 @@ private void OnSyncFilterCheckBoxCheckedChanged (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnDataGridViewLeave (object sender, EventArgs e) { InvalidateCurrentRow(dataGridView); } + [SupportedOSPlatform("windows")] private void OnDataGridViewEnter (object sender, EventArgs e) { InvalidateCurrentRow(dataGridView); } + [SupportedOSPlatform("windows")] private void OnFilterGridViewEnter (object sender, EventArgs e) { InvalidateCurrentRow(filterGridView); } + [SupportedOSPlatform("windows")] private void OnFilterGridViewLeave (object sender, EventArgs e) { InvalidateCurrentRow(filterGridView); } + [SupportedOSPlatform("windows")] private void OnDataGridViewResize (object sender, EventArgs e) { if (_logFileReader != null && dataGridView.RowCount > 0 && _guiStateArgs.FollowTail) @@ -641,6 +679,7 @@ private void OnDataGridViewSelectionChanged (object sender, EventArgs e) UpdateSelectionDisplay(); } + [SupportedOSPlatform("windows")] private void OnSelectionChangedTriggerSignal (object sender, EventArgs e) { var selCount = 0; @@ -671,11 +710,13 @@ private void OnSelectionChangedTriggerSignal (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnFilterKnobControlValueChanged (object sender, EventArgs e) { CheckForFilterDirty(); } + [SupportedOSPlatform("windows")] private void OnFilterToTabButtonClick (object sender, EventArgs e) { FilterToTab(); @@ -697,22 +738,26 @@ private void OnPipeDisconnected (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnAdvancedButtonClick (object sender, EventArgs e) { _showAdvanced = !_showAdvanced; ShowAdvancedFilterPanel(_showAdvanced); } + [SupportedOSPlatform("windows")] private void OnFilterSplitContainerMouseDown (object sender, MouseEventArgs e) { ((SplitContainer)sender).IsSplitterFixed = true; } + [SupportedOSPlatform("windows")] private void OnFilterSplitContainerMouseUp (object sender, MouseEventArgs e) { ((SplitContainer)sender).IsSplitterFixed = false; } + [SupportedOSPlatform("windows")] private void OnFilterSplitContainerMouseMove (object sender, MouseEventArgs e) { var splitContainer = (SplitContainer)sender; @@ -744,6 +789,7 @@ private void OnFilterSplitContainerMouseMove (object sender, MouseEventArgs e) } } + [SupportedOSPlatform("windows")] private void OnFilterSplitContainerMouseDoubleClick (object sender, MouseEventArgs e) { AutoResizeFilterBox(); @@ -863,7 +909,7 @@ private void OnHandlePluginContextMenu (object sender, EventArgs args) if (sender is ToolStripItem item) { var menuArgs = item.Tag as ContextMenuPluginEventArgs; - var logLines = menuArgs.LogLines; + IList logLines = menuArgs.LogLines; menuArgs.Entry.MenuSelected(logLines.Count, menuArgs.Columnizer, menuArgs.Callback.GetLogLine(logLines[0])); } } @@ -887,6 +933,7 @@ private void OnHandleSyncContextMenu (object sender, EventArgs args) } } + [SupportedOSPlatform("windows")] private void OnCopyToolStripMenuItemClick (object sender, EventArgs e) { CopyMarkedLinesToClipboard(); @@ -897,6 +944,7 @@ private void OnCopyToTabToolStripMenuItemClick (object sender, EventArgs e) CopyMarkedLinesToTab(); } + [SupportedOSPlatform("windows")] private void OnScrollAllTabsToTimestampToolStripMenuItemClick (object sender, EventArgs e) { if (CurrentColumnizer.IsTimeshiftImplemented()) @@ -916,6 +964,7 @@ private void OnScrollAllTabsToTimestampToolStripMenuItemClick (object sender, Ev } } + [SupportedOSPlatform("windows")] private void OnLocateLineInOriginalFileToolStripMenuItemClick (object sender, EventArgs e) { if (dataGridView.CurrentRow != null && FilterPipe != null) @@ -934,6 +983,7 @@ private void OnToggleBoomarkToolStripMenuItemClick (object sender, EventArgs e) ToggleBookmark(); } + [SupportedOSPlatform("windows")] private void OnMarkEditModeToolStripMenuItemClick (object sender, EventArgs e) { StartEditMode(); @@ -947,6 +997,7 @@ private void OnLogWindowSizeChanged (object sender, EventArgs e) #region BookMarkList + [SupportedOSPlatform("windows")] private void OnColumnRestrictCheckBoxCheckedChanged (object sender, EventArgs e) { columnButton.Enabled = columnRestrictCheckBox.Checked; @@ -964,6 +1015,7 @@ private void OnColumnRestrictCheckBoxCheckedChanged (object sender, EventArgs e) CheckForFilterDirty(); } + [SupportedOSPlatform("windows")] private void OnColumnButtonClick (object sender, EventArgs e) { _filterParams.CurrentColumnizer = _currentColumnizer; @@ -1168,11 +1220,13 @@ private void OnRestoreColumnsToolStripMenuItemClick (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnTimeSpreadingControlLineSelected (object sender, SelectLineEventArgs e) { SelectLine(e.Line, false, true); } + [SupportedOSPlatform("windows")] private void OnBookmarkCommentToolStripMenuItemClick (object sender, EventArgs e) { AddBookmarkAndEditComment(); @@ -1251,11 +1305,13 @@ private void OnEditModeCopyToolStripMenuItemClick (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnRemoveAllToolStripMenuItemClick (object sender, EventArgs e) { RemoveTempHighlights(); } + [SupportedOSPlatform("windows")] private void OnMakePermanentToolStripMenuItemClick (object sender, EventArgs e) { lock (_tempHighlightEntryListLock) @@ -1269,6 +1325,7 @@ private void OnMakePermanentToolStripMenuItemClick (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnMarkCurrentFilterRangeToolStripMenuItemClick (object sender, EventArgs e) { MarkCurrentFilterRange(); @@ -1308,6 +1365,7 @@ private void OnDataGridViewCellDoubleClick (object sender, DataGridViewCellEvent } } + [SupportedOSPlatform("windows")] private void OnDataGridViewOverlayDoubleClicked (object sender, OverlayEventArgs e) { BookmarkComment(e.BookmarkOverlay.Bookmark); @@ -1354,7 +1412,7 @@ private void OnSaveFilterButtonClick (object sender, EventArgs e) { FilterParams newParams = _filterParams.Clone(); newParams.Color = Color.FromKnownColor(KnownColor.Black); - ConfigManager.Settings.filterList.Add(newParams); + ConfigManager.Settings.FilterList.Add(newParams); OnFilterListChanged(this); } @@ -1365,7 +1423,7 @@ private void OnDeleteFilterButtonClick (object sender, EventArgs e) if (index >= 0) { var filterParams = (FilterParams)filterListBox.Items[index]; - ConfigManager.Settings.filterList.Remove(filterParams); + ConfigManager.Settings.FilterList.Remove(filterParams); OnFilterListChanged(this); if (filterListBox.Items.Count > 0) { @@ -1381,9 +1439,9 @@ private void OnFilterUpButtonClick (object sender, EventArgs e) if (i > 0) { var filterParams = (FilterParams)filterListBox.Items[i]; - ConfigManager.Settings.filterList.RemoveAt(i); + ConfigManager.Settings.FilterList.RemoveAt(i); i--; - ConfigManager.Settings.filterList.Insert(i, filterParams); + ConfigManager.Settings.FilterList.Insert(i, filterParams); OnFilterListChanged(this); filterListBox.SelectedIndex = i; } @@ -1401,9 +1459,9 @@ private void OnFilterDownButtonClick (object sender, EventArgs e) if (i < filterListBox.Items.Count - 1) { var filterParams = (FilterParams)filterListBox.Items[i]; - ConfigManager.Settings.filterList.RemoveAt(i); + ConfigManager.Settings.FilterList.RemoveAt(i); i++; - ConfigManager.Settings.filterList.Insert(i, filterParams); + ConfigManager.Settings.FilterList.Insert(i, filterParams); OnFilterListChanged(this); filterListBox.SelectedIndex = i; } @@ -1471,9 +1529,12 @@ private void OnColorToolStripMenuItemClick (object sender, EventArgs e) if (i < filterListBox.Items.Count && i >= 0) { var filterParams = (FilterParams)filterListBox.Items[i]; - ColorDialog dlg = new(); - dlg.CustomColors = [filterParams.Color.ToArgb()]; - dlg.Color = filterParams.Color; + ColorDialog dlg = new() + { + CustomColors = [filterParams.Color.ToArgb()], + Color = filterParams.Color + }; + if (dlg.ShowDialog() == DialogResult.OK) { filterParams.Color = dlg.Color; @@ -1482,6 +1543,7 @@ private void OnColorToolStripMenuItemClick (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnFilterCaseSensitiveCheckBoxCheckedChanged (object sender, EventArgs e) { CheckForFilterDirty(); @@ -1495,26 +1557,31 @@ private void OnFilterRegexCheckBoxCheckedChanged (object sender, EventArgs e) CheckForFilterDirty(); } + [SupportedOSPlatform("windows")] private void OnInvertFilterCheckBoxCheckedChanged (object sender, EventArgs e) { CheckForFilterDirty(); } + [SupportedOSPlatform("windows")] private void OnFilterRangeComboBoxTextChanged (object sender, EventArgs e) { CheckForFilterDirty(); } + [SupportedOSPlatform("windows")] private void OnFuzzyKnobControlValueChanged (object sender, EventArgs e) { CheckForFilterDirty(); } + [SupportedOSPlatform("windows")] private void OnFilterComboBoxTextChanged (object sender, EventArgs e) { CheckForFilterDirty(); } + [SupportedOSPlatform("windows")] private void OnSetBookmarksOnSelectedLinesToolStripMenuItemClick (object sender, EventArgs e) { SetBookmarksForSelectedFilterLines(); @@ -1526,21 +1593,25 @@ private void OnParentHighlightSettingsChanged (object sender, EventArgs e) SetCurrentHighlightGroup(groupName); } + [SupportedOSPlatform("windows")] private void OnFilterOnLoadCheckBoxMouseClick (object sender, MouseEventArgs e) { HandleChangedFilterOnLoadSetting(); } + [SupportedOSPlatform("windows")] private void OnFilterOnLoadCheckBoxKeyPress (object sender, KeyPressEventArgs e) { HandleChangedFilterOnLoadSetting(); } + [SupportedOSPlatform("windows")] private void OnHideFilterListOnLoadCheckBoxMouseClick (object sender, MouseEventArgs e) { HandleChangedFilterOnLoadSetting(); } + [SupportedOSPlatform("windows")] private void OnFilterToTabToolStripMenuItemClick (object sender, EventArgs e) { FilterToTab(); @@ -1551,7 +1622,7 @@ private void OnTimeSyncListWindowRemoved (object sender, EventArgs e) var syncList = sender as TimeSyncList; lock (_timeSyncListLock) { - if (syncList.Count == 0 || syncList.Count == 1 && syncList.Contains(this)) + if (syncList.Count == 0 || (syncList.Count == 1 && syncList.Contains(this))) { if (syncList == TimeSyncList) { @@ -1573,6 +1644,7 @@ private void OnSplitContainerSplitterMoved (object sender, SplitterEventArgs e) advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; } + [SupportedOSPlatform("windows")] private void OnMarkFilterHitsInLogViewToolStripMenuItemClick (object sender, EventArgs e) { SearchParams p = new() @@ -1585,6 +1657,7 @@ private void OnMarkFilterHitsInLogViewToolStripMenuItemClick (object sender, Eve AddSearchHitHighlightEntry(p); } + [SupportedOSPlatform("windows")] private void OnColumnComboBoxSelectionChangeCommitted (object sender, EventArgs e) { SelectColumn(); diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs index 6e35ae4f..49b9f505 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs @@ -23,6 +23,7 @@ partial class LogWindow { #region Private Methods + [SupportedOSPlatform("windows")] private void RegisterLogFileReaderEvents () { _logFileReader.LoadFile += OnLogFileReaderLoadFile; @@ -33,6 +34,7 @@ private void RegisterLogFileReaderEvents () // FileSizeChanged is not registered here because it's registered after loading has finished } + [SupportedOSPlatform("windows")] private void UnRegisterLogFileReaderEvents () { if (_logFileReader != null) @@ -46,6 +48,7 @@ private void UnRegisterLogFileReaderEvents () } } + [SupportedOSPlatform("windows")] private void CreateDefaultViewStyle () { DataGridViewCellStyle dataGridViewCellStyleMainGrid = new(); @@ -70,6 +73,7 @@ private void CreateDefaultViewStyle () filterGridView.DefaultCellStyle = dataGridViewCellStyleFilterGrid; } + [SupportedOSPlatform("windows")] private bool LoadPersistenceOptions () { if (InvokeRequired) @@ -77,23 +81,16 @@ private bool LoadPersistenceOptions () return (bool)Invoke(new BoolReturnDelegate(LoadPersistenceOptions)); } - if (!Preferences.saveSessions && ForcedPersistenceFileName == null) + if (!Preferences.SaveSessions && ForcedPersistenceFileName == null) { return false; } try { - PersistenceData persistenceData; - if (ForcedPersistenceFileName == null) - { - persistenceData = Persister.LoadPersistenceDataOptionsOnly(FileName, Preferences); - } - else - { - persistenceData = - Persister.LoadPersistenceDataOptionsOnlyFromFixedFile(ForcedPersistenceFileName); - } + PersistenceData persistenceData = ForcedPersistenceFileName == null + ? Persister.LoadPersistenceDataOptionsOnly(FileName, Preferences) + : Persister.LoadPersistenceDataOptionsOnlyFromFixedFile(ForcedPersistenceFileName); if (persistenceData == null) { @@ -110,7 +107,7 @@ private bool LoadPersistenceOptions () if (string.IsNullOrEmpty(_multiFileOptions.FormatPattern)) { - _multiFileOptions = ObjectClone.Clone(Preferences.multiFileOptions); + _multiFileOptions = ObjectClone.Clone(Preferences.MultiFileOptions); } splitContainerLogWindow.SplitterDistance = persistenceData.FilterPosition; @@ -154,14 +151,16 @@ private bool LoadPersistenceOptions () } } + [SupportedOSPlatform("windows")] private void SetDefaultsFromPrefs () { - filterTailCheckBox.Checked = Preferences.filterTail; - syncFilterCheckBox.Checked = Preferences.filterSync; - FollowTailChanged(Preferences.followTail, false); - _multiFileOptions = ObjectClone.Clone(Preferences.multiFileOptions); + filterTailCheckBox.Checked = Preferences.FilterTail; + syncFilterCheckBox.Checked = Preferences.FilterSync; + FollowTailChanged(Preferences.FollowTail, false); + _multiFileOptions = ObjectClone.Clone(Preferences.MultiFileOptions); } + [SupportedOSPlatform("windows")] private void LoadPersistenceData () { if (InvokeRequired) @@ -170,7 +169,7 @@ private void LoadPersistenceData () return; } - if (!Preferences.saveSessions && !ForcePersistenceLoading && ForcedPersistenceFileName == null) + if (!Preferences.SaveSessions && !ForcePersistenceLoading && ForcedPersistenceFileName == null) { SetDefaultsFromPrefs(); return; @@ -186,16 +185,9 @@ private void LoadPersistenceData () try { - PersistenceData persistenceData; - - if (ForcedPersistenceFileName == null) - { - persistenceData = Persister.LoadPersistenceData(FileName, Preferences); - } - else - { - persistenceData = Persister.LoadPersistenceDataFromFixedFile(ForcedPersistenceFileName); - } + PersistenceData persistenceData = ForcedPersistenceFileName == null + ? Persister.LoadPersistenceData(FileName, Preferences) + : Persister.LoadPersistenceDataFromFixedFile(ForcedPersistenceFileName); if (persistenceData.LineCount > _logFileReader.LineCount) { @@ -239,7 +231,7 @@ private void LoadPersistenceData () // FirstDisplayedScrollingRowIndex calculates sometimes the wrong scrolling ranges??? } - if (Preferences.saveFilters) + if (Preferences.SaveFilters) { RestoreFilters(persistenceData); } @@ -251,6 +243,7 @@ private void LoadPersistenceData () } } + [SupportedOSPlatform("windows")] private void RestoreFilters (PersistenceData persistenceData) { if (persistenceData.FilterParamsList.Count > 0) @@ -341,6 +334,7 @@ private void EnterLoadFileStatus () _logger.Debug("EnterLoadFileStatus end"); } + [SupportedOSPlatform("windows")] private void PositionAfterReload (ReloadMemento reloadMemento) { if (_reloadMemento.CurrentLine < dataGridView.RowCount && _reloadMemento.CurrentLine >= 0) @@ -354,6 +348,7 @@ private void PositionAfterReload (ReloadMemento reloadMemento) } } + [SupportedOSPlatform("windows")] private void LogfileDead () { _logger.Info("File not found."); @@ -380,6 +375,7 @@ private void LogfileDead () OnFileNotFound(EventArgs.Empty); } + [SupportedOSPlatform("windows")] private void LogfileRespawned () { _logger.Info("LogfileDead(): Reloading file because it has been respawned."); @@ -390,21 +386,17 @@ private void LogfileRespawned () Reload(); } + [SupportedOSPlatform("windows")] private void SetGuiAfterLoading () { if (Text.Length == 0) { - if (IsTempFile) - { - Text = TempTitleName; - } - else - { - Text = Util.GetNameFromPath(FileName); - } + Text = IsTempFile + ? TempTitleName + : Util.GetNameFromPath(FileName); } - ShowBookmarkBubbles = Preferences.showBubbles; + ShowBookmarkBubbles = Preferences.ShowBubbles; //if (this.forcedColumnizer == null) { ILogLineColumnizer columnizer; @@ -438,6 +430,7 @@ private void SetGuiAfterLoading () Invoke(new SetColumnizerFx(SetColumnizer), columnizer); } + dataGridView.Enabled = true; DisplayCurrentFileOnStatusline(); //this.guiStateArgs.FollowTail = this.Preferences.followTail; @@ -455,31 +448,25 @@ private void SetGuiAfterLoading () //} if (CurrentColumnizer.IsTimeshiftImplemented()) { - if (Preferences.timestampControl) + if (Preferences.TimestampControl) { SetTimestampLimits(); SyncTimestampDisplay(); } Settings settings = ConfigManager.Settings; - ShowLineColumn(!settings.hideLineColumn); + ShowLineColumn(!settings.HideLineColumn); } - ShowTimeSpread(Preferences.showTimeSpread && CurrentColumnizer.IsTimeshiftImplemented()); + ShowTimeSpread(Preferences.ShowTimeSpread && CurrentColumnizer.IsTimeshiftImplemented()); locateLineInOriginalFileToolStripMenuItem.Enabled = FilterPipe != null; } private ILogLineColumnizer FindColumnizer () { - ILogLineColumnizer columnizer; - if (Preferences.maskPrio) - { - columnizer = _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)) ?? _parentLogTabWin.GetColumnizerHistoryEntry(FileName); - } - else - { - columnizer = _parentLogTabWin.GetColumnizerHistoryEntry(FileName) ?? _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)); - } + ILogLineColumnizer columnizer = Preferences.MaskPrio + ? _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)) ?? _parentLogTabWin.GetColumnizerHistoryEntry(FileName) + : _parentLogTabWin.GetColumnizerHistoryEntry(FileName) ?? _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)); return columnizer; } @@ -490,7 +477,7 @@ private void ReloadNewFile () lock (_reloadLock) { _reloadOverloadCounter++; - _logger.Info("ReloadNewFile(): counter = {0}", _reloadOverloadCounter); + _logger.Info($"ReloadNewFile(): counter = {_reloadOverloadCounter}"); if (_reloadOverloadCounter <= 1) { SavePersistenceData(false); @@ -524,6 +511,7 @@ private void ReloadNewFile () } } + [SupportedOSPlatform("windows")] private void ReloadFinishedThreadFx () { _logger.Info("Waiting for loading to be complete."); @@ -746,7 +734,7 @@ private void UpdateGrid (LogEventArgs e) OnTailFollowed(EventArgs.Empty); } - if (Preferences.timestampControl && !_isLoading) + if (Preferences.TimestampControl && !_isLoading) { SetTimestampLimits(); } @@ -1059,8 +1047,8 @@ private void SetColumnizerInternal (ILogLineColumnizer columnizer) } Settings settings = ConfigManager.Settings; - ShowLineColumn(!settings.hideLineColumn); - ShowTimeSpread(Preferences.showTimeSpread && columnizer.IsTimeshiftImplemented()); + ShowLineColumn(!settings.HideLineColumn); + ShowTimeSpread(Preferences.ShowTimeSpread && columnizer.IsTimeshiftImplemented()); } if (!columnizer.IsTimeshiftImplemented() && IsTimeSynced) @@ -1085,13 +1073,13 @@ private void AutoResizeColumns (BufferedDataGridView gridView) try { gridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - if (gridView.Columns.Count > 1 && Preferences.setLastColumnWidth && - gridView.Columns[gridView.Columns.Count - 1].Width < Preferences.lastColumnWidth + if (gridView.Columns.Count > 1 && Preferences.SetLastColumnWidth && + gridView.Columns[gridView.Columns.Count - 1].Width < Preferences.LastColumnWidth ) { // It seems that using 'MinimumWidth' instead of 'Width' prevents the DataGridView's NullReferenceExceptions //gridView.Columns[gridView.Columns.Count - 1].Width = this.Preferences.lastColumnWidth; - gridView.Columns[gridView.Columns.Count - 1].MinimumWidth = Preferences.lastColumnWidth; + gridView.Columns[gridView.Columns.Count - 1].MinimumWidth = Preferences.LastColumnWidth; } } catch (NullReferenceException e) @@ -1986,17 +1974,17 @@ private async void FilterSearch (string text) _filterParams.SearchText = text; _filterParams.LowerSearchText = text.ToLowerInvariant(); - ConfigManager.Settings.filterHistoryList.Remove(text); - ConfigManager.Settings.filterHistoryList.Insert(0, text); - var maxHistory = ConfigManager.Settings.Preferences.maximumFilterEntries; + ConfigManager.Settings.FilterHistoryList.Remove(text); + ConfigManager.Settings.FilterHistoryList.Insert(0, text); + var maxHistory = ConfigManager.Settings.Preferences.MaximumFilterEntries; - if (ConfigManager.Settings.filterHistoryList.Count > maxHistory) + if (ConfigManager.Settings.FilterHistoryList.Count > maxHistory) { - ConfigManager.Settings.filterHistoryList.RemoveAt(filterComboBox.Items.Count - 1); + ConfigManager.Settings.FilterHistoryList.RemoveAt(filterComboBox.Items.Count - 1); } filterComboBox.Items.Clear(); - foreach (var item in ConfigManager.Settings.filterHistoryList) + foreach (var item in ConfigManager.Settings.FilterHistoryList) { filterComboBox.Items.Add(item); } @@ -2007,15 +1995,15 @@ private async void FilterSearch (string text) _filterParams.RangeSearchText = filterRangeComboBox.Text; if (_filterParams.IsRangeSearch) { - ConfigManager.Settings.filterRangeHistoryList.Remove(filterRangeComboBox.Text); - ConfigManager.Settings.filterRangeHistoryList.Insert(0, filterRangeComboBox.Text); - if (ConfigManager.Settings.filterRangeHistoryList.Count > maxHistory) + ConfigManager.Settings.FilterRangeHistoryList.Remove(filterRangeComboBox.Text); + ConfigManager.Settings.FilterRangeHistoryList.Insert(0, filterRangeComboBox.Text); + if (ConfigManager.Settings.FilterRangeHistoryList.Count > maxHistory) { - ConfigManager.Settings.filterRangeHistoryList.RemoveAt(filterRangeComboBox.Items.Count - 1); + ConfigManager.Settings.FilterRangeHistoryList.RemoveAt(filterRangeComboBox.Items.Count - 1); } filterRangeComboBox.Items.Clear(); - foreach (var item in ConfigManager.Settings.filterRangeHistoryList) + foreach (var item in ConfigManager.Settings.FilterRangeHistoryList) { filterRangeComboBox.Items.Add(item); } @@ -2046,7 +2034,7 @@ private async void FilterSearch (string text) _filterParams.ColumnRestrict = columnRestrictCheckBox.Checked; //ConfigManager.SaveFilterParams(this.filterParams); - ConfigManager.Settings.filterParams = _filterParams; // wozu eigentlich? sinnlos seit MDI? + ConfigManager.Settings.FilterParams = _filterParams; // wozu eigentlich? sinnlos seit MDI? _shouldCancel = false; _isSearching = true; @@ -2063,7 +2051,7 @@ private async void FilterSearch (string text) Settings settings = ConfigManager.Settings; //FilterFx fx = settings.preferences.multiThreadFilter ? MultiThreadedFilter : new FilterFx(Filter); - FilterFxAction = settings.Preferences.multiThreadFilter ? MultiThreadedFilter : Filter; + FilterFxAction = settings.Preferences.MultiThreadFilter ? MultiThreadedFilter : Filter; //Task.Run(() => fx.Invoke(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList)); var filterFxActionTask = Task.Run(() => Filter(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList)); @@ -2616,15 +2604,15 @@ private void UpdateSelectionDisplay () [SupportedOSPlatform("windows")] private void UpdateFilterHistoryFromSettings () { - ConfigManager.Settings.filterHistoryList = ConfigManager.Settings.filterHistoryList; + ConfigManager.Settings.FilterHistoryList = ConfigManager.Settings.FilterHistoryList; filterComboBox.Items.Clear(); - foreach (var item in ConfigManager.Settings.filterHistoryList) + foreach (var item in ConfigManager.Settings.FilterHistoryList) { filterComboBox.Items.Add(item); } filterRangeComboBox.Items.Clear(); - foreach (var item in ConfigManager.Settings.filterRangeHistoryList) + foreach (var item in ConfigManager.Settings.FilterRangeHistoryList) { filterRangeComboBox.Items.Add(item); } @@ -2950,9 +2938,9 @@ private void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, Preferen { if (dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) > 1) { - if (prefs.setLastColumnWidth) + if (prefs.SetLastColumnWidth) { - dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].MinimumWidth = prefs.lastColumnWidth; + dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].MinimumWidth = prefs.LastColumnWidth; } else { @@ -3115,7 +3103,7 @@ private void InitPatternWindow () _patternWindow = new PatternWindow(this); _patternWindow.SetColumnizer(CurrentColumnizer); //this.patternWindow.SetBlockList(blockList); - _patternWindow.SetFont(Preferences.fontName, Preferences.fontSize); + _patternWindow.SetFont(Preferences.FontName, Preferences.FontSize); _patternWindow.Fuzzy = _patternArgs.Fuzzy; _patternWindow.MaxDiff = _patternArgs.MaxDiffInBlock; _patternWindow.MaxMisses = _patternArgs.MaxMisses; @@ -3661,8 +3649,8 @@ private void SetDefaultHighlightGroup () [SupportedOSPlatform("windows")] private void HandleChangedFilterOnLoadSetting () { - _parentLogTabWin.Preferences.isFilterOnLoad = filterOnLoadCheckBox.Checked; - _parentLogTabWin.Preferences.isAutoHideFilterList = hideFilterListOnLoadCheckBox.Checked; + _parentLogTabWin.Preferences.IsFilterOnLoad = filterOnLoadCheckBox.Checked; + _parentLogTabWin.Preferences.IsAutoHideFilterList = hideFilterListOnLoadCheckBox.Checked; OnFilterListChanged(this); } diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs index b221c1ba..7b3ae108 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs @@ -1,4 +1,4 @@ -using System.Text; +using System.Text; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Bookmark; @@ -78,9 +78,9 @@ public void LoadFile (string fileName, EncodingOptions encodingOptions) try { - _logFileReader = new(fileName, EncodingOptions, IsMultiFile, Preferences.bufferCount, Preferences.linesPerBuffer, _multiFileOptions, PluginRegistry.PluginRegistry.Instance) + _logFileReader = new(fileName, EncodingOptions, IsMultiFile, Preferences.BufferCount, Preferences.LinesPerBuffer, _multiFileOptions, PluginRegistry.PluginRegistry.Instance) { - UseNewReader = !Preferences.useLegacyReader + UseNewReader = !Preferences.UseLegacyReader }; } catch (LogFileException lfe) @@ -118,7 +118,7 @@ public void LoadFile (string fileName, EncodingOptions encodingOptions) if (isUsingDefaultColumnizer) { - if (Preferences.autoPick) + if (Preferences.AutoPick) { ILogLineColumnizer newColumnizer = ColumnizerPicker.FindBetterColumnizer(FileName, _logFileReader, CurrentColumnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); @@ -153,9 +153,9 @@ public void LoadFilesAsMulti (string[] fileNames, EncodingOptions encodingOption EncodingOptions = encodingOptions; _columnCache = new ColumnCache(); - _logFileReader = new(fileNames, EncodingOptions, Preferences.bufferCount, Preferences.linesPerBuffer, _multiFileOptions, PluginRegistry.PluginRegistry.Instance) + _logFileReader = new(fileNames, EncodingOptions, Preferences.BufferCount, Preferences.LinesPerBuffer, _multiFileOptions, PluginRegistry.PluginRegistry.Instance) { - UseNewReader = !Preferences.useLegacyReader + UseNewReader = !Preferences.UseLegacyReader }; RegisterLogFileReaderEvents(); @@ -173,7 +173,7 @@ public string SavePersistenceData (bool force) { if (!force) { - if (!Preferences.saveSessions) + if (!Preferences.SaveSessions) { return null; } @@ -231,7 +231,7 @@ public PersistenceData GetPersistenceData () _filterParams.IsFilterTail = filterTailCheckBox.Checked; // this option doesnt need a press on 'search' - if (Preferences.saveFilters) + if (Preferences.SaveFilters) { List filterList = [_filterParams]; persistenceData.FilterParamsList = filterList; @@ -266,7 +266,7 @@ public PersistenceData GetPersistenceData () public void Close (bool dontAsk) { - Preferences.askForClose = !dontAsk; + Preferences.AskForClose = !dontAsk; Close(); } @@ -486,7 +486,7 @@ public void CellPainting (BufferedDataGridView gridView, int rowIndex, DataGridV Alignment = StringAlignment.Center }; Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); - Font font = new("Courier New", Preferences.fontSize, FontStyle.Bold); + Font font = new("Courier New", Preferences.FontSize, FontStyle.Bold); e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); font.Dispose(); @@ -1137,7 +1137,7 @@ public void LogWindowActivated () { OnTailFollowed(EventArgs.Empty); } - if (Preferences.timestampControl) + if (Preferences.TimestampControl) { SetTimestampLimits(); SyncTimestampDisplay(); @@ -1264,9 +1264,9 @@ public void PreferencesChanged (Preferences newPreferences, bool isLoadTime, Set { if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors) { - NormalFont = new Font(new FontFamily(newPreferences.fontName), newPreferences.fontSize); + NormalFont = new Font(new FontFamily(newPreferences.FontName), newPreferences.FontSize); BoldFont = new Font(NormalFont, FontStyle.Bold); - MonospacedFont = new Font("Courier New", Preferences.fontSize, FontStyle.Bold); + MonospacedFont = new Font("Courier New", Preferences.FontSize, FontStyle.Bold); var lineSpacing = NormalFont.FontFamily.GetLineSpacing(FontStyle.Regular); var lineSpacingPixel = NormalFont.Size * lineSpacing / NormalFont.FontFamily.GetEmHeight(FontStyle.Regular); @@ -1276,32 +1276,32 @@ public void PreferencesChanged (Preferences newPreferences, bool isLoadTime, Set _lineHeight = NormalFont.Height + 4; dataGridView.RowTemplate.Height = NormalFont.Height + 4; - ShowBookmarkBubbles = Preferences.showBubbles; + ShowBookmarkBubbles = Preferences.ShowBubbles; ApplyDataGridViewPrefs(dataGridView, newPreferences); ApplyDataGridViewPrefs(filterGridView, newPreferences); - if (Preferences.timestampControl) + if (Preferences.TimestampControl) { SetTimestampLimits(); SyncTimestampDisplay(); } if (isLoadTime) { - filterTailCheckBox.Checked = Preferences.filterTail; - syncFilterCheckBox.Checked = Preferences.filterSync; + filterTailCheckBox.Checked = Preferences.FilterTail; + syncFilterCheckBox.Checked = Preferences.FilterSync; //this.FollowTailChanged(this.Preferences.followTail, false); } - _timeSpreadCalc.TimeMode = Preferences.timeSpreadTimeMode; - timeSpreadingControl.ForeColor = Preferences.timeSpreadColor; - timeSpreadingControl.ReverseAlpha = Preferences.reverseAlpha; + _timeSpreadCalc.TimeMode = Preferences.TimeSpreadTimeMode; + timeSpreadingControl.ForeColor = Preferences.TimeSpreadColor; + timeSpreadingControl.ReverseAlpha = Preferences.ReverseAlpha; if (CurrentColumnizer.IsTimeshiftImplemented()) { timeSpreadingControl.Invoke(new MethodInvoker(timeSpreadingControl.Refresh)); - ShowTimeSpread(Preferences.showTimeSpread); + ShowTimeSpread(Preferences.ShowTimeSpread); } - ToggleColumnFinder(Preferences.showColumnFinder, false); + ToggleColumnFinder(Preferences.ShowColumnFinder, false); } if ((flags & SettingsFlags.FilterList) == SettingsFlags.FilterList) @@ -1738,7 +1738,7 @@ public void HandleChangedFilterListWorker () { var index = filterListBox.SelectedIndex; filterListBox.Items.Clear(); - foreach (FilterParams filterParam in ConfigManager.Settings.filterList) + foreach (FilterParams filterParam in ConfigManager.Settings.FilterList) { filterListBox.Items.Add(filterParam); } @@ -1747,8 +1747,8 @@ public void HandleChangedFilterListWorker () { filterListBox.SelectedIndex = index; } - filterOnLoadCheckBox.Checked = Preferences.isFilterOnLoad; - hideFilterListOnLoadCheckBox.Checked = Preferences.isAutoHideFilterList; + filterOnLoadCheckBox.Checked = Preferences.IsFilterOnLoad; + hideFilterListOnLoadCheckBox.Checked = Preferences.IsAutoHideFilterList; } public void SetCurrentHighlightGroup (string groupName) diff --git a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs index f0c6cb84..84614aef 100644 --- a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs @@ -1,19 +1,22 @@ +using System.Runtime.Versioning; + using LogExpert.Core.Classes; using LogExpert.Core.EventArguments; using LogExpert.Dialogs; namespace LogExpert.UI.Controls.LogWindow; +[SupportedOSPlatform("windows")] internal partial class PatternWindow : Form //TODO: Can this be changed to UserControl? { #region Fields - private readonly List> blockList = []; - private PatternBlock currentBlock; - private List currentList; + private readonly List> _blockList = []; + private PatternBlock _currentBlock; + private List _currentList; - private readonly LogWindow logWindow; - private PatternArgs patternArgs = new(); + private readonly LogWindow _logWindow; + private PatternArgs _patternArgs = new(); #endregion @@ -26,7 +29,7 @@ public PatternWindow () public PatternWindow (LogWindow logWindow) { - this.logWindow = logWindow; + this._logWindow = logWindow; InitializeComponent(); recalcButton.Enabled = false; } @@ -65,8 +68,8 @@ public int Weight public void SetBlockList (List flatBlockList, PatternArgs patternArgs) { - this.patternArgs = patternArgs; - blockList.Clear(); + this._patternArgs = patternArgs; + _blockList.Clear(); List singeList = []; //int blockId = -1; for (var i = 0; i < flatBlockList.Count; ++i) @@ -90,15 +93,15 @@ public void SetBlockList (List flatBlockList, PatternArgs patternA // singeList.Add(block); //} } - blockList.Add(singeList); + _blockList.Add(singeList); Invoke(new MethodInvoker(SetBlockListGuiStuff)); } public void SetColumnizer (ILogLineColumnizer columnizer) { - logWindow.SetColumnizer(columnizer, patternHitsDataGridView); - logWindow.SetColumnizer(columnizer, contentDataGridView); + _logWindow.SetColumnizer(columnizer, patternHitsDataGridView); + _logWindow.SetColumnizer(columnizer, contentDataGridView); patternHitsDataGridView.Columns[0].Width = 20; contentDataGridView.Columns[0].Width = 20; @@ -147,32 +150,32 @@ private void SetBlockListGuiStuff () blockLinesLabel.Text = "0"; recalcButton.Enabled = true; setRangeButton.Enabled = true; - if (blockList.Count > 0) + if (_blockList.Count > 0) { - SetCurrentList(blockList[0]); + SetCurrentList(_blockList[0]); } } private void SetCurrentList (List patternList) { patternHitsDataGridView.RowCount = 0; - currentList = patternList; - patternHitsDataGridView.RowCount = currentList.Count; + _currentList = patternList; + patternHitsDataGridView.RowCount = _currentList.Count; patternHitsDataGridView.Refresh(); - blockCountLabel.Text = "" + currentList.Count; + blockCountLabel.Text = "" + _currentList.Count; } private int GetLineForHitGrid (int rowIndex) { int line; - line = currentList[rowIndex].TargetStart; + line = _currentList[rowIndex].TargetStart; return line; } private int GetLineForContentGrid (int rowIndex) { int line; - line = currentBlock.TargetStart + rowIndex; + line = _currentBlock.TargetStart + rowIndex; return line; } @@ -182,7 +185,7 @@ private int GetLineForContentGrid (int rowIndex) private void patternHitsDataGridView_CellValueNeeded (object sender, DataGridViewCellValueEventArgs e) { - if (currentList == null || e.RowIndex < 0) + if (_currentList == null || e.RowIndex < 0) { return; } @@ -190,7 +193,7 @@ private void patternHitsDataGridView_CellValueNeeded (object sender, DataGridVie var colIndex = e.ColumnIndex; if (colIndex == 1) { - e.Value = currentList[e.RowIndex].Weigth; + e.Value = _currentList[e.RowIndex].Weigth; } else { @@ -199,13 +202,13 @@ private void patternHitsDataGridView_CellValueNeeded (object sender, DataGridVie colIndex--; // correct the additional inserted col } - e.Value = logWindow.GetCellValue(rowIndex, colIndex); + e.Value = _logWindow.GetCellValue(rowIndex, colIndex); } } private void patternHitsDataGridView_CellPainting (object sender, DataGridViewCellPaintingEventArgs e) { - if (currentList == null || e.RowIndex < 0) + if (_currentList == null || e.RowIndex < 0) { return; } @@ -213,8 +216,8 @@ private void patternHitsDataGridView_CellPainting (object sender, DataGridViewCe if (e.ColumnIndex == 1) { e.PaintBackground(e.CellBounds, false); - var selCount = patternArgs.EndLine - patternArgs.StartLine; - var maxWeight = patternArgs.MaxDiffInBlock * selCount + selCount; + var selCount = _patternArgs.EndLine - _patternArgs.StartLine; + var maxWeight = _patternArgs.MaxDiffInBlock * selCount + selCount; if (maxWeight > 0) { var width = (int)((int)e.Value / (double)maxWeight * e.CellBounds.Width); @@ -233,7 +236,7 @@ private void patternHitsDataGridView_CellPainting (object sender, DataGridViewCe { var gridView = (BufferedDataGridView)sender; var rowIndex = GetLineForHitGrid(e.RowIndex); - logWindow.CellPainting(gridView, rowIndex, e); + _logWindow.CellPainting(gridView, rowIndex, e); } } @@ -248,19 +251,19 @@ private void patternHitsDataGridView_MouseDoubleClick (object sender, MouseEvent private void patternHitsDataGridView_CurrentCellChanged (object sender, EventArgs e) { - if (currentList == null || patternHitsDataGridView.CurrentRow == null) + if (_currentList == null || patternHitsDataGridView.CurrentRow == null) { return; } - if (patternHitsDataGridView.CurrentRow.Index > currentList.Count - 1) + if (patternHitsDataGridView.CurrentRow.Index > _currentList.Count - 1) { return; } contentDataGridView.RowCount = 0; - currentBlock = currentList[patternHitsDataGridView.CurrentRow.Index]; - contentDataGridView.RowCount = currentBlock.TargetEnd - currentBlock.TargetStart + 1; + _currentBlock = _currentList[patternHitsDataGridView.CurrentRow.Index]; + contentDataGridView.RowCount = _currentBlock.TargetEnd - _currentBlock.TargetStart + 1; contentDataGridView.Refresh(); contentDataGridView.CurrentCell = contentDataGridView.Rows[0].Cells[0]; blockLinesLabel.Text = "" + contentDataGridView.RowCount; @@ -268,7 +271,7 @@ private void patternHitsDataGridView_CurrentCellChanged (object sender, EventArg private void contentDataGridView_CellValueNeeded (object sender, DataGridViewCellValueEventArgs e) { - if (currentBlock == null || e.RowIndex < 0) + if (_currentBlock == null || e.RowIndex < 0) { return; } @@ -277,7 +280,7 @@ private void contentDataGridView_CellValueNeeded (object sender, DataGridViewCel if (colIndex == 1) { QualityInfo qi; - if (currentBlock.QualityInfoList.TryGetValue(rowIndex, out qi)) + if (_currentBlock.QualityInfoList.TryGetValue(rowIndex, out qi)) { e.Value = qi.Quality; } @@ -292,39 +295,39 @@ private void contentDataGridView_CellValueNeeded (object sender, DataGridViewCel { colIndex--; // adjust the inserted column } - e.Value = logWindow.GetCellValue(rowIndex, colIndex); + e.Value = _logWindow.GetCellValue(rowIndex, colIndex); } } private void contentDataGridView_CellPainting (object sender, DataGridViewCellPaintingEventArgs e) { - if (currentBlock == null || e.RowIndex < 0) + if (_currentBlock == null || e.RowIndex < 0) { return; } var gridView = (BufferedDataGridView)sender; var rowIndex = GetLineForContentGrid(e.RowIndex); - logWindow.CellPainting(gridView, rowIndex, e); + _logWindow.CellPainting(gridView, rowIndex, e); } private void contentDataGridView_CellMouseDoubleClick (object sender, DataGridViewCellMouseEventArgs e) { - if (currentBlock == null || contentDataGridView.CurrentRow == null) + if (_currentBlock == null || contentDataGridView.CurrentRow == null) { return; } var rowIndex = GetLineForContentGrid(contentDataGridView.CurrentRow.Index); - logWindow.SelectLogLine(rowIndex); + _logWindow.SelectLogLine(rowIndex); } private void recalcButton_Click (object sender, EventArgs e) { - patternArgs.Fuzzy = fuzzyKnobControl.Value; - patternArgs.MaxDiffInBlock = maxDiffKnobControl.Value; - patternArgs.MaxMisses = maxMissesKnobControl.Value; - patternArgs.MinWeight = weigthKnobControl.Value; - logWindow.PatternStatistic(patternArgs); + _patternArgs.Fuzzy = fuzzyKnobControl.Value; + _patternArgs.MaxDiffInBlock = maxDiffKnobControl.Value; + _patternArgs.MaxMisses = maxMissesKnobControl.Value; + _patternArgs.MinWeight = weigthKnobControl.Value; + _logWindow.PatternStatistic(_patternArgs); recalcButton.Enabled = false; setRangeButton.Enabled = false; } @@ -350,9 +353,9 @@ private void patternHitsDataGridView_ColumnDividerDoubleClick (object sender, private void setRangeButton_Click (object sender, EventArgs e) { - logWindow.PatternStatisticSelectRange(patternArgs); + _logWindow.PatternStatisticSelectRange(_patternArgs); recalcButton.Enabled = true; - rangeLabel.Text = "Start: " + patternArgs.StartLine + "\r\nEnd: " + patternArgs.EndLine; + rangeLabel.Text = "Start: " + _patternArgs.StartLine + "\r\nEnd: " + _patternArgs.EndLine; } #endregion diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs index 0d7d3e04..c65bc9a9 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs @@ -8,6 +8,7 @@ namespace LogExpert.UI.Controls.LogWindow; +[SupportedOSPlatform("windows")] internal partial class TimeSpreadingControl : UserControl { private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); @@ -28,7 +29,6 @@ internal partial class TimeSpreadingControl : UserControl #region cTor - [SupportedOSPlatform("windows")] public TimeSpreadingControl () { InitializeComponent(); @@ -117,11 +117,9 @@ private SpreadEntry GetEntryForMouse (MouseEventArgs e) lock (_monitor) { - if (y >= list.Count || y < 0) - { - return null; - } - return list[y]; + return y >= list.Count || y < 0 + ? null + : list[y]; } } @@ -132,6 +130,7 @@ private void DragContrast (MouseEventArgs e) _lastMouseY = _lastMouseY = e.Y; return; } + _timeSpreadCalc.Contrast += (_lastMouseY - e.Y) * 5; _lastMouseY = e.Y; } @@ -145,7 +144,6 @@ private void OnLineSelected (SelectLineEventArgs e) #region Events handler - [SupportedOSPlatform("windows")] private void TimeSpreadCalc_CalcDone (object sender, EventArgs e) { _logger.Debug("timeSpreadCalc_CalcDone()"); @@ -212,7 +210,6 @@ private void TimeSpreadCalc_CalcDone (object sender, EventArgs e) BeginInvoke(new MethodInvoker(Refresh)); } - [SupportedOSPlatform("windows")] private void TimeSpreadCalc_StartCalc (object sender, EventArgs e) { lock (_monitor) @@ -248,7 +245,6 @@ private void TimeSpreadCalc_StartCalc (object sender, EventArgs e) BeginInvoke(new MethodInvoker(Refresh)); } - [SupportedOSPlatform("windows")] private void TimeSpreadingControl_SizeChanged (object sender, EventArgs e) { if (TimeSpreadCalc != null) @@ -262,7 +258,6 @@ private void TimeSpreadingControl_MouseDown (object sender, MouseEventArgs e) { } - [SupportedOSPlatform("windows")] private void TimeSpreadingControl_MouseUp (object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) @@ -272,23 +267,21 @@ private void TimeSpreadingControl_MouseUp (object sender, MouseEventArgs e) { return; } + OnLineSelected(new SelectLineEventArgs(entry.LineNum)); } } - [SupportedOSPlatform("windows")] private void TimeSpreadingControl_MouseEnter (object sender, EventArgs e) { _toolTip.Active = true; } - [SupportedOSPlatform("windows")] private void TimeSpreadingControl_MouseLeave (object sender, EventArgs e) { _toolTip.Active = false; } - [SupportedOSPlatform("windows")] private void TimeSpreadingControl_MouseMove (object sender, MouseEventArgs e) { if (e.Y == _lastMouseY) diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs index bb5ac3c1..5cf5a90c 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs @@ -1,3 +1,5 @@ +using System.Runtime.Versioning; + namespace LogExpert.UI.Controls.LogWindow; /// @@ -7,7 +9,7 @@ public class TimeSyncList { #region Fields - private readonly IList logWindowList = new List(); + private readonly IList logWindowList = []; #endregion @@ -27,12 +29,14 @@ public class TimeSyncList public DateTime CurrentTimestamp { get; set; } + [SupportedOSPlatform("windows")] public int Count => logWindowList.Count; #endregion #region Public methods + [SupportedOSPlatform("windows")] public void AddWindow (LogWindow logWindow) { lock (logWindowList) @@ -44,7 +48,7 @@ public void AddWindow (LogWindow logWindow) } } - + [SupportedOSPlatform("windows")] public void RemoveWindow (LogWindow logWindow) { lock (logWindowList) @@ -61,6 +65,7 @@ public void RemoveWindow (LogWindow logWindow) /// /// /// + [SupportedOSPlatform("windows")] public void NavigateToTimestamp (DateTime timestamp, LogWindow sender) { CurrentTimestamp = timestamp; @@ -76,7 +81,7 @@ public void NavigateToTimestamp (DateTime timestamp, LogWindow sender) } } - + [SupportedOSPlatform("windows")] public bool Contains (LogWindow logWindow) { return logWindowList.Contains(logWindow); diff --git a/src/LogExpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.cs b/src/LogExpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.cs index 717d3e00..3c046848 100644 --- a/src/LogExpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.cs +++ b/src/LogExpert.UI/Dialogs/AllowOnlyOneInstanceErrorDialog.cs @@ -1,23 +1,24 @@ -using System.Windows.Forms; +using System.Runtime.Versioning; namespace LogExpert.Dialogs; +[SupportedOSPlatform("windows")] public partial class AllowOnlyOneInstanceErrorDialog : Form { public bool DoNotShowThisMessageAgain { get; private set; } - public AllowOnlyOneInstanceErrorDialog() + public AllowOnlyOneInstanceErrorDialog () { InitializeComponent(); SetText(); } - private void SetText() + private void SetText () { labelErrorText.Text = @"Only one instance allowed, uncheck ""View Settings => Allow only 1 Instances"" to start multiple instances!"; } - private void OnButtonOkClick(object sender, System.EventArgs e) + private void OnButtonOkClick (object sender, System.EventArgs e) { DoNotShowThisMessageAgain = checkBoxIgnoreMessage.Checked; } diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs index 6853a51e..0ee8d848 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs @@ -1,3 +1,5 @@ +using System.Runtime.Versioning; + using LogExpert.Core.Config; using LogExpert.Core.Entities; using LogExpert.Core.Enums; @@ -13,6 +15,7 @@ namespace LogExpert.Dialogs; //TODO can be moved to Logexpert.UI if the PaintHelper has been refactored +[SupportedOSPlatform("windows")] public partial class BookmarkWindow : DockContent, ISharedToolWindow, IBookmarkView { #region Fields @@ -198,11 +201,11 @@ public void PreferencesChanged (Preferences newPreferences, bool isLoadTime, Set { if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors) { - SetFont(newPreferences.fontName, newPreferences.fontSize); - if (bookmarkDataGridView.Columns.Count > 1 && newPreferences.setLastColumnWidth) + SetFont(newPreferences.FontName, newPreferences.FontSize); + if (bookmarkDataGridView.Columns.Count > 1 && newPreferences.SetLastColumnWidth) { bookmarkDataGridView.Columns[bookmarkDataGridView.Columns.Count - 1].MinimumWidth = - newPreferences.lastColumnWidth; + newPreferences.LastColumnWidth; } PaintHelper.ApplyDataGridViewPrefs(bookmarkDataGridView, newPreferences, configManager); diff --git a/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs b/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs index d9d19f30..da5350c8 100644 --- a/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs +++ b/src/LogExpert.UI/Dialogs/Eminus/Eminus.cs @@ -1,19 +1,15 @@ -using LogExpert.UI.Dialogs.Eminus; - -using Newtonsoft.Json; - -using System; -using System.Collections.Generic; -using System.IO; using System.Net.Sockets; using System.Runtime.Serialization; using System.Runtime.Versioning; + //using System.Windows.Forms; using System.Xml; +using Newtonsoft.Json; + //TODO: This whole Eminus folder is not in use. Can be deleted? What is it? //[assembly: SupportedOSPlatform("windows")] -namespace LogExpert; +namespace LogExpert.UI.Dialogs.Eminus; internal class Eminus : IContextMenuEntry, ILogExpertPluginConfigurator { @@ -38,7 +34,8 @@ internal class Eminus : IContextMenuEntry, ILogExpertPluginConfigurator #region Private Methods - private XmlDocument BuildParam(ILogLine line) + [SupportedOSPlatform("windows")] + private XmlDocument BuildParam (ILogLine line) { var fullLogLine = line.FullLine; // no Java stacktrace but some special logging of our applications at work: @@ -130,7 +127,8 @@ private XmlDocument BuildParam(ILogLine line) return null; } - private XmlDocument BuildXmlDocument(string className, string lineNum) + [SupportedOSPlatform("windows")] + private XmlDocument BuildXmlDocument (string className, string lineNum) { XmlDocument xmlDoc = new(); xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); @@ -155,30 +153,27 @@ private XmlDocument BuildXmlDocument(string className, string lineNum) #region IContextMenuEntry Member - public string GetMenuText(IList logLines, ILogLineColumnizer columnizer, ILogExpertCallback callback) + public string GetMenuText (IList logLines, ILogLineColumnizer columnizer, ILogExpertCallback callback) { //not used return string.Empty; } - public string GetMenuText(int logLinesCount, ILogLineColumnizer columnizer, ILogLine logline) + [SupportedOSPlatform("windows")] + public string GetMenuText (int logLinesCount, ILogLineColumnizer columnizer, ILogLine logline) { - if (logLinesCount == 1 && BuildParam(logline) != null) - { - return "Load class in Eclipse"; - } - else - { - return $"{DISABLED}Load class in Eclipse"; - } + return logLinesCount == 1 && BuildParam(logline) != null + ? "Load class in Eclipse" + : $"{DISABLED}Load class in Eclipse"; } - public void MenuSelected(IList logLines, ILogLineColumnizer columnizer, ILogExpertCallback callback) + public void MenuSelected (IList logLines, ILogLineColumnizer columnizer, ILogExpertCallback callback) { //Not used } - public void MenuSelected(int logLinesCount, ILogLineColumnizer columnizer, ILogLine logline) + [SupportedOSPlatform("windows")] + public void MenuSelected (int logLinesCount, ILogLineColumnizer columnizer, ILogLine logline) { if (logLinesCount != 1) { @@ -216,7 +211,8 @@ public void MenuSelected(int logLinesCount, ILogLineColumnizer columnizer, ILogL #region ILogExpertPluginConfigurator Member - public void LoadConfig(string configDir) + [SupportedOSPlatform("windows")] + public void LoadConfig (string configDir) { var configPath = configDir + CFG_FILE_NAME; @@ -240,8 +236,8 @@ public void LoadConfig(string configDir) } } - - public void SaveConfig(string configDir) + [SupportedOSPlatform("windows")] + public void SaveConfig (string configDir) { FileInfo fileInfo = new(configDir + Path.DirectorySeparatorChar + CFG_FILE_NAME); @@ -254,12 +250,13 @@ public void SaveConfig(string configDir) serializer.Serialize(sw, _config); } - public bool HasEmbeddedForm() + public bool HasEmbeddedForm () { return true; } - public void ShowConfigForm(object panel) + [SupportedOSPlatform("windows")] + public void ShowConfigForm (object panel) { dlg = new EminusConfigDlg(tmpConfig) { @@ -273,7 +270,8 @@ public void ShowConfigForm(object panel) /// is pressed (HasEmbeddedForm() must return false for this). /// /// - public void ShowConfigDialog(object owner) + [SupportedOSPlatform("windows")] + public void ShowConfigDialog (object owner) { dlg = new EminusConfigDlg(tmpConfig) { @@ -285,8 +283,8 @@ public void ShowConfigDialog(object owner) dlg.ApplyChanges(); } - - public void HideConfigForm() + [SupportedOSPlatform("windows")] + public void HideConfigForm () { if (dlg != null) { @@ -297,7 +295,7 @@ public void HideConfigForm() } } - public void StartConfig() + public void StartConfig () { tmpConfig = _config.Clone(); } diff --git a/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.cs b/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.cs index 8fc6673f..841a340a 100644 --- a/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.cs +++ b/src/LogExpert.UI/Dialogs/Eminus/EminusConfigDlg.cs @@ -1,11 +1,10 @@ -using System; -using System.Drawing; -using System.Windows.Forms; +using System.Runtime.Versioning; using LogExpert.UI.Dialogs.Eminus; namespace LogExpert; +[SupportedOSPlatform("windows")] internal partial class EminusConfigDlg : Form { #region Fields @@ -14,7 +13,7 @@ internal partial class EminusConfigDlg : Form #region cTor - public EminusConfigDlg(EminusConfig config) + public EminusConfigDlg (EminusConfig config) { SuspendLayout(); @@ -43,7 +42,7 @@ public EminusConfigDlg(EminusConfig config) #region Public methods - public void ApplyChanges() + public void ApplyChanges () { Config.Host = hostTextBox.Text; try @@ -54,6 +53,7 @@ public void ApplyChanges() { Config.Port = 0; } + Config.Password = passwordTextBox.Text; } diff --git a/src/LogExpert.UI/Dialogs/ExceptionWindow.cs b/src/LogExpert.UI/Dialogs/ExceptionWindow.cs index 2ab0adb5..486f68b0 100644 --- a/src/LogExpert.UI/Dialogs/ExceptionWindow.cs +++ b/src/LogExpert.UI/Dialogs/ExceptionWindow.cs @@ -1,5 +1,8 @@ -namespace LogExpert.UI.Dialogs; +using System.Runtime.Versioning; +namespace LogExpert.UI.Dialogs; + +[SupportedOSPlatform("windows")] public partial class ExceptionWindow : Form { #region Fields @@ -12,9 +15,9 @@ public partial class ExceptionWindow : Form #region cTor - //TODO: for HighDPI SuspendLayout() before InitializeComponent() and then ResumeLayout() as last command in the CTOR can help in complex forms to reduce flickering and miscalculations. Also, it is a good practice. - public ExceptionWindow(string errorText, string stackTrace) + public ExceptionWindow (string errorText, string stackTrace) { + SuspendLayout(); InitializeComponent(); AutoScaleDimensions = new SizeF(96F, 96F); @@ -25,13 +28,14 @@ public ExceptionWindow(string errorText, string stackTrace) stackTraceTextBox.Text = _errorText + @"\n\n" + _stackTrace; stackTraceTextBox.Select(0, 0); + ResumeLayout(); } #endregion #region Private Methods - private void CopyToClipboard() + private void CopyToClipboard () { Clipboard.SetText(_errorText + @"\n\n" + _stackTrace); } @@ -40,7 +44,7 @@ private void CopyToClipboard() #region Events handler - private void copyButton_Click(object sender, EventArgs e) + private void copyButton_Click (object sender, EventArgs e) { CopyToClipboard(); } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.cs index a23c253a..7fc01ba0 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/FilterSelectorForm.cs @@ -1,11 +1,10 @@ -using LogExpert.Core.Interface; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Windows.Forms; +using System.Runtime.Versioning; + +using LogExpert.Core.Interface; namespace LogExpert.Dialogs; +[SupportedOSPlatform("windows")] internal partial class FilterSelectorForm : Form //TODO: Can this be changed to UserControl? { #region Fields @@ -17,7 +16,7 @@ internal partial class FilterSelectorForm : Form //TODO: Can this be changed to #region cTor - public FilterSelectorForm(IList existingColumnizerList, ILogLineColumnizer currentColumnizer, ILogLineColumnizerCallback callback, IConfigManager configManager) + public FilterSelectorForm (IList existingColumnizerList, ILogLineColumnizer currentColumnizer, ILogLineColumnizerCallback callback, IConfigManager configManager) { SelectedColumnizer = currentColumnizer; _callback = callback; @@ -34,7 +33,7 @@ public FilterSelectorForm(IList existingColumnizerList, ILog // columnizer registry. This ensures that changes made in columnizer config dialogs // will apply to the current instance _columnizerList = new List(); - + foreach (ILogLineColumnizer col in existingColumnizerList) { _columnizerList.Add(col.GetType() == SelectedColumnizer.GetType() ? SelectedColumnizer : col); @@ -70,7 +69,7 @@ public FilterSelectorForm(IList existingColumnizerList, ILog #region Events handler - private void OnFilterComboBoxSelectedIndexChanged(object sender, EventArgs e) + private void OnFilterComboBoxSelectedIndexChanged (object sender, EventArgs e) { ILogLineColumnizer col = _columnizerList[filterComboBox.SelectedIndex]; SelectedColumnizer = col; @@ -82,7 +81,7 @@ private void OnFilterComboBoxSelectedIndexChanged(object sender, EventArgs e) //TODO: Check if this logic can be remoed from this class and remove all the config manager instances from here. - private void OnConfigButtonClick(object sender, EventArgs e) + private void OnConfigButtonClick (object sender, EventArgs e) { if (SelectedColumnizer is IColumnizerConfigurator configurator) { diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs index 7c46803b..8a150e27 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs @@ -1,3 +1,4 @@ +using System.Runtime.Versioning; using System.Text.RegularExpressions; using LogExpert.Core.Classes.Highlight; @@ -10,6 +11,7 @@ namespace LogExpert.Dialogs; +[SupportedOSPlatform("windows")] public partial class HighlightDialog : Form { private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs index fe6b126c..254707aa 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs @@ -15,6 +15,7 @@ namespace LogExpert.UI.Controls.LogTabWindow; // Data shared over all LogTabWindow instances //TODO: Can we get rid of this class? +[SupportedOSPlatform("windows")] public partial class LogTabWindow : Form, ILogTabWindow { #region Fields @@ -168,7 +169,7 @@ public LogTabWindow (string[] fileNames, int instanceNumber, bool showInstanceNu [SupportedOSPlatform("windows")] public void ChangeTheme (Control.ControlCollection container) { - ColorMode.LoadColorMode(ConfigManager.Settings.Preferences.darkMode); + ColorMode.LoadColorMode(ConfigManager.Settings.Preferences.DarkMode); Win32.UseImmersiveDarkMode(Handle, ColorMode.DarkModeEnabled); #region ApplyColorToAllControls diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs index e5b91364..3cb32910 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs @@ -9,8 +9,8 @@ using LogExpert.Core.Entities; using LogExpert.Core.EventArguments; using LogExpert.Dialogs; +using LogExpert.UI.Controls.LogWindow; using LogExpert.UI.Dialogs; -using LogExpert.UI.Dialogs.LogTabWindow; using WeifenLuo.WinFormsUI.Docking; @@ -28,23 +28,23 @@ private void OnBookmarkWindowVisibleChanged (object sender, EventArgs e) private void OnLogTabWindowLoad (object sender, EventArgs e) { ApplySettings(ConfigManager.Settings, SettingsFlags.All); - if (ConfigManager.Settings.isMaximized) + if (ConfigManager.Settings.IsMaximized) { - Bounds = ConfigManager.Settings.appBoundsFullscreen; + Bounds = ConfigManager.Settings.AppBoundsFullscreen; WindowState = FormWindowState.Maximized; - Bounds = ConfigManager.Settings.appBounds; + Bounds = ConfigManager.Settings.AppBounds; } else { - if (ConfigManager.Settings.appBounds.Right > 0) + if (ConfigManager.Settings.AppBounds.Right > 0) { - Bounds = ConfigManager.Settings.appBounds; + Bounds = ConfigManager.Settings.AppBounds; } } - if (ConfigManager.Settings.Preferences.openLastFiles && _startupFileNames == null) + if (ConfigManager.Settings.Preferences.OpenLastFiles && _startupFileNames == null) { - List tmpList = ObjectClone.Clone(ConfigManager.Settings.lastOpenFilesList); + List tmpList = ObjectClone.Clone(ConfigManager.Settings.LastOpenFilesList); foreach (var name in tmpList) { @@ -79,7 +79,7 @@ private void OnLogTabWindowClosing (object sender, CancelEventArgs e) _ledThread.Join(); IList deleteLogWindowList = new List(); - ConfigManager.Settings.alwaysOnTop = TopMost && ConfigManager.Settings.Preferences.allowOnlyOneInstance; + ConfigManager.Settings.AlwaysOnTop = TopMost && ConfigManager.Settings.Preferences.AllowOnlyOneInstance; SaveLastOpenFilesList(); foreach (LogWindow.LogWindow logWindow in _logWindowList) @@ -504,6 +504,7 @@ private void OnTailFollowed (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnLogWindowSyncModeChanged (object sender, SyncModeEventArgs e) { if (!Disposing) @@ -519,46 +520,55 @@ private void OnLogWindowSyncModeChanged (object sender, SyncModeEventArgs e) } } + [SupportedOSPlatform("windows")] private void OnToggleBookmarkToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ToggleBookmark(); } + [SupportedOSPlatform("windows")] private void OnJumpToNextToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.JumpNextBookmark(); } + [SupportedOSPlatform("windows")] private void OnJumpToPrevToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.JumpPrevBookmark(); } + [SupportedOSPlatform("windows")] private void OnASCIIToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ChangeEncoding(Encoding.ASCII); } + [SupportedOSPlatform("windows")] private void OnANSIToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ChangeEncoding(Encoding.Default); } + [SupportedOSPlatform("windows")] private void OnUTF8ToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ChangeEncoding(new UTF8Encoding(false)); } + [SupportedOSPlatform("windows")] private void OnUTF16ToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ChangeEncoding(Encoding.Unicode); } + [SupportedOSPlatform("windows")] private void OnISO88591ToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ChangeEncoding(Encoding.GetEncoding("iso-8859-1")); } + [SupportedOSPlatform("windows")] private void OnReloadToolStripMenuItemClick (object sender, EventArgs e) { if (CurrentLogWindow != null) @@ -570,11 +580,13 @@ private void OnReloadToolStripMenuItemClick (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnSettingsToolStripMenuItemClick (object sender, EventArgs e) { OpenSettings(0); } + [SupportedOSPlatform("windows")] private void OnDateTimeDragControlValueDragged (object sender, EventArgs e) { if (CurrentLogWindow != null) @@ -583,21 +595,25 @@ private void OnDateTimeDragControlValueDragged (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnDateTimeDragControlValueChanged (object sender, EventArgs e) { CurrentLogWindow?.ScrollToTimestamp(dragControlDateTime.DateTime, true, true); } + [SupportedOSPlatform("windows")] private void OnLogTabWindowDeactivate (object sender, EventArgs e) { CurrentLogWindow?.AppFocusLost(); } + [SupportedOSPlatform("windows")] private void OnLogTabWindowActivated (object sender, EventArgs e) { CurrentLogWindow?.AppFocusGained(); } + [SupportedOSPlatform("windows")] private void OnShowBookmarkListToolStripMenuItemClick (object sender, EventArgs e) { if (_bookmarkWindow.Visible) @@ -617,36 +633,43 @@ private void OnShowBookmarkListToolStripMenuItemClick (object sender, EventArgs } } + [SupportedOSPlatform("windows")] private void OnToolStripButtonOpenClick (object sender, EventArgs e) { OpenFileDialog(); } + [SupportedOSPlatform("windows")] private void OnToolStripButtonSearchClick (object sender, EventArgs e) { OpenSearchDialog(); } + [SupportedOSPlatform("windows")] private void OnToolStripButtonFilterClick (object sender, EventArgs e) { CurrentLogWindow?.ToggleFilterPanel(); } + [SupportedOSPlatform("windows")] private void OnToolStripButtonBookmarkClick (object sender, EventArgs e) { CurrentLogWindow?.ToggleBookmark(); } + [SupportedOSPlatform("windows")] private void OnToolStripButtonUpClick (object sender, EventArgs e) { CurrentLogWindow?.JumpPrevBookmark(); } + [SupportedOSPlatform("windows")] private void OnToolStripButtonDownClick (object sender, EventArgs e) { CurrentLogWindow?.JumpNextBookmark(); } + [SupportedOSPlatform("windows")] private void OnShowHelpToolStripMenuItemClick (object sender, EventArgs e) { Help.ShowHelp(this, "LogExpert.chm"); @@ -654,29 +677,31 @@ private void OnShowHelpToolStripMenuItemClick (object sender, EventArgs e) private void OnHideLineColumnToolStripMenuItemClick (object sender, EventArgs e) { - ConfigManager.Settings.hideLineColumn = hideLineColumnToolStripMenuItem.Checked; + ConfigManager.Settings.HideLineColumn = hideLineColumnToolStripMenuItem.Checked; lock (_logWindowList) { foreach (LogWindow.LogWindow logWin in _logWindowList) { - logWin.ShowLineColumn(!ConfigManager.Settings.hideLineColumn); + logWin.ShowLineColumn(!ConfigManager.Settings.HideLineColumn); } } - _bookmarkWindow.LineColumnVisible = ConfigManager.Settings.hideLineColumn; + _bookmarkWindow.LineColumnVisible = ConfigManager.Settings.HideLineColumn; } // ================================================================== // Tab context menu stuff // ================================================================== + [SupportedOSPlatform("windows")] private void OnCloseThisTabToolStripMenuItemClick (object sender, EventArgs e) { (dockPanel.ActiveContent as LogWindow.LogWindow).Close(); } + [SupportedOSPlatform("windows")] private void OnCloseOtherTabsToolStripMenuItemClick (object sender, EventArgs e) { - IList closeList = new List(); + IList closeList = []; lock (_logWindowList) { foreach (DockContent content in dockPanel.Contents) @@ -693,11 +718,13 @@ private void OnCloseOtherTabsToolStripMenuItemClick (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnCloseAllTabsToolStripMenuItemClick (object sender, EventArgs e) { CloseAllTabs(); } + [SupportedOSPlatform("windows")] private void OnTabColorToolStripMenuItemClick (object sender, EventArgs e) { var logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; @@ -718,7 +745,7 @@ private void OnTabColorToolStripMenuItemClick (object sender, EventArgs e) } List delList = []; - foreach (ColorEntry entry in ConfigManager.Settings.fileColors) + foreach (ColorEntry entry in ConfigManager.Settings.FileColors) { if (entry.FileName.Equals(logWindow.FileName, StringComparison.Ordinal)) { @@ -728,16 +755,17 @@ private void OnTabColorToolStripMenuItemClick (object sender, EventArgs e) foreach (ColorEntry entry in delList) { - ConfigManager.Settings.fileColors.Remove(entry); + ConfigManager.Settings.FileColors.Remove(entry); } - ConfigManager.Settings.fileColors.Add(new ColorEntry(logWindow.FileName, dlg.Color)); + ConfigManager.Settings.FileColors.Add(new ColorEntry(logWindow.FileName, dlg.Color)); - while (ConfigManager.Settings.fileColors.Count > MAX_COLOR_HISTORY) + while (ConfigManager.Settings.FileColors.Count > MAX_COLOR_HISTORY) { - ConfigManager.Settings.fileColors.RemoveAt(0); + ConfigManager.Settings.FileColors.RemoveAt(0); } } + [SupportedOSPlatform("windows")] private void OnLogTabWindowSizeChanged (object sender, EventArgs e) { if (WindowState != FormWindowState.Minimized) @@ -746,6 +774,7 @@ private void OnLogTabWindowSizeChanged (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnSaveProjectToolStripMenuItemClick (object sender, EventArgs e) { SaveFileDialog dlg = new(); @@ -777,6 +806,7 @@ private void OnSaveProjectToolStripMenuItemClick (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnLoadProjectToolStripMenuItemClick (object sender, EventArgs e) { OpenFileDialog dlg = new(); @@ -790,6 +820,7 @@ private void OnLoadProjectToolStripMenuItemClick (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnToolStripButtonBubblesClick (object sender, EventArgs e) { if (CurrentLogWindow != null) @@ -798,6 +829,7 @@ private void OnToolStripButtonBubblesClick (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnCopyPathToClipboardToolStripMenuItemClick (object sender, EventArgs e) { var logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; @@ -815,21 +847,25 @@ private void OnFindInExplorerToolStripMenuItemClick (object sender, EventArgs e) explorer.Start(); } + [SupportedOSPlatform("windows")] private void OnExportBookmarksToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ExportBookmarkList(); } + [SupportedOSPlatform("windows")] private void OnHighlightGroupsComboBoxDropDownClosed (object sender, EventArgs e) { ApplySelectedHighlightGroup(); } + [SupportedOSPlatform("windows")] private void OnHighlightGroupsComboBoxSelectedIndexChanged (object sender, EventArgs e) { ApplySelectedHighlightGroup(); } + [SupportedOSPlatform("windows")] private void OnHighlightGroupsComboBoxMouseUp (object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) @@ -847,6 +883,7 @@ private void OnConfigChanged (object sender, ConfigChangedEventArgs e) } } + [SupportedOSPlatform("windows")] private void OnDumpLogBufferInfoToolStripMenuItemClick (object sender, EventArgs e) { #if DEBUG @@ -854,6 +891,7 @@ private void OnDumpLogBufferInfoToolStripMenuItemClick (object sender, EventArgs #endif } + [SupportedOSPlatform("windows")] private void OnDumpBufferDiagnosticToolStripMenuItemClick (object sender, EventArgs e) { #if DEBUG @@ -871,6 +909,7 @@ private void OnGCInfoToolStripMenuItemClick (object sender, EventArgs e) DumpGCInfo(); } + [SupportedOSPlatform("windows")] private void OnToolsToolStripMenuItemDropDownItemClicked (object sender, ToolStripItemClickedEventArgs e) { if (e.ClickedItem.Tag is ToolEntry tag) @@ -879,11 +918,13 @@ private void OnToolsToolStripMenuItemDropDownItemClicked (object sender, ToolStr } } + [SupportedOSPlatform("windows")] private void OnExternalToolsToolStripItemClicked (object sender, ToolStripItemClickedEventArgs e) { ToolButtonClick(e.ClickedItem.Tag as ToolEntry); } + [SupportedOSPlatform("windows")] private void OnConfigureToolStripMenuItemClick (object sender, EventArgs e) { OpenSettings(2); @@ -902,8 +943,11 @@ private void OnThrowExceptionBackgroundThToolStripMenuItemClick (object sender, private void OnThrowExceptionBackgroundThreadToolStripMenuItemClick (object sender, EventArgs e) { - Thread thread = new(ThrowExceptionThreadFx); - thread.IsBackground = true; + Thread thread = new(ThrowExceptionThreadFx) + { + IsBackground = true + }; + thread.Start(); } @@ -940,6 +984,7 @@ private void OnDisableWordHighlightModeToolStripMenuItemClick (object sender, Ev CurrentLogWindow?.RefreshAllGrids(); } + [SupportedOSPlatform("windows")] private void OnMultiFileMaskToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ChangeMultifileMask(); @@ -951,6 +996,7 @@ private void OnMultiFileEnabledStripMenuItemClick (object sender, EventArgs e) ToggleMultiFile(); } + [SupportedOSPlatform("windows")] private void OnLockInstanceToolStripMenuItemClick (object sender, EventArgs e) { AbstractLogTabWindow.StaticData.CurrentLockedMainWindow = lockInstanceToolStripMenuItem.Checked ? null : this; @@ -959,7 +1005,7 @@ private void OnLockInstanceToolStripMenuItemClick (object sender, EventArgs e) [SupportedOSPlatform("windows")] private void OnOptionToolStripMenuItemDropDownOpening (object sender, EventArgs e) { - lockInstanceToolStripMenuItem.Enabled = !ConfigManager.Settings.Preferences.allowOnlyOneInstance; + lockInstanceToolStripMenuItem.Enabled = !ConfigManager.Settings.Preferences.AllowOnlyOneInstance; lockInstanceToolStripMenuItem.Checked = AbstractLogTabWindow.StaticData.CurrentLockedMainWindow == this; } @@ -980,14 +1026,14 @@ private void OnOpenURIToolStripMenuItemClick (object sender, EventArgs e) { OpenUriDialog dlg = new() { - UriHistory = ConfigManager.Settings.uriHistoryList + UriHistory = ConfigManager.Settings.UriHistoryList }; if (DialogResult.OK == dlg.ShowDialog()) { if (dlg.Uri.Trim().Length > 0) { - ConfigManager.Settings.uriHistoryList = dlg.UriHistory; + ConfigManager.Settings.UriHistoryList = dlg.UriHistory; ConfigManager.Save(SettingsFlags.FileHistory); LoadFiles([dlg.Uri], false); } @@ -1003,6 +1049,7 @@ private void OnColumnFinderToolStripMenuItemClick (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnDockPanelActiveContentChanged (object sender, EventArgs e) { if (dockPanel.ActiveContent is LogWindow.LogWindow window) @@ -1013,6 +1060,7 @@ private void OnDockPanelActiveContentChanged (object sender, EventArgs e) } } + [SupportedOSPlatform("windows")] private void OnTabRenameToolStripMenuItemClick (object sender, EventArgs e) { if (CurrentLogWindow != null) diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs index 5ec04039..ec93bd35 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs @@ -52,11 +52,13 @@ private void PasteFromClipboard () } } + [SupportedOSPlatform("windows")] private void InitToolWindows () { InitBookmarkWindow(); } + [SupportedOSPlatform("windows")] private void DestroyToolWindows () { DestroyBookmarkWindow(); @@ -85,14 +87,14 @@ private void DestroyBookmarkWindow () private void SaveLastOpenFilesList () { - ConfigManager.Settings.lastOpenFilesList.Clear(); + ConfigManager.Settings.LastOpenFilesList.Clear(); foreach (DockContent content in dockPanel.Contents) { if (content is LogWindow.LogWindow logWin) { if (!logWin.IsTempFile) { - ConfigManager.Settings.lastOpenFilesList.Add(logWin.GivenFileName); + ConfigManager.Settings.LastOpenFilesList.Add(logWin.GivenFileName); } } } @@ -104,15 +106,15 @@ private void SaveWindowPosition () SuspendLayout(); if (WindowState == FormWindowState.Normal) { - ConfigManager.Settings.appBounds = Bounds; - ConfigManager.Settings.isMaximized = false; + ConfigManager.Settings.AppBounds = Bounds; + ConfigManager.Settings.IsMaximized = false; } else { - ConfigManager.Settings.appBoundsFullscreen = Bounds; - ConfigManager.Settings.isMaximized = true; + ConfigManager.Settings.AppBoundsFullscreen = Bounds; + ConfigManager.Settings.IsMaximized = true; WindowState = FormWindowState.Normal; - ConfigManager.Settings.appBounds = Bounds; + ConfigManager.Settings.AppBounds = Bounds; } ResumeLayout(); @@ -125,15 +127,15 @@ private void SetTooltipText (LogWindow.LogWindow logWindow, string logFileName) private void FillDefaultEncodingFromSettings (EncodingOptions encodingOptions) { - if (ConfigManager.Settings.Preferences.defaultEncoding != null) + if (ConfigManager.Settings.Preferences.DefaultEncoding != null) { try { - encodingOptions.DefaultEncoding = Encoding.GetEncoding(ConfigManager.Settings.Preferences.defaultEncoding); + encodingOptions.DefaultEncoding = Encoding.GetEncoding(ConfigManager.Settings.Preferences.DefaultEncoding); } catch (ArgumentException) { - _logger.Warn("Encoding " + ConfigManager.Settings.Preferences.defaultEncoding + " is not a valid encoding"); + _logger.Warn("Encoding " + ConfigManager.Settings.Preferences.DefaultEncoding + " is not a valid encoding"); encodingOptions.DefaultEncoding = null; } } @@ -216,22 +218,23 @@ private void DisconnectEventHandlers (LogWindow.LogWindow logWindow) //data.tabPage = null; } + [SupportedOSPlatform("windows")] private void AddToFileHistory (string fileName) { bool FindName (string s) => s.ToUpperInvariant().Equals(fileName.ToUpperInvariant(), StringComparison.Ordinal); - var index = ConfigManager.Settings.fileHistoryList.FindIndex(FindName); + var index = ConfigManager.Settings.FileHistoryList.FindIndex(FindName); if (index != -1) { - ConfigManager.Settings.fileHistoryList.RemoveAt(index); + ConfigManager.Settings.FileHistoryList.RemoveAt(index); } - ConfigManager.Settings.fileHistoryList.Insert(0, fileName); + ConfigManager.Settings.FileHistoryList.Insert(0, fileName); - while (ConfigManager.Settings.fileHistoryList.Count > MAX_FILE_HISTORY) + while (ConfigManager.Settings.FileHistoryList.Count > MAX_FILE_HISTORY) { - ConfigManager.Settings.fileHistoryList.RemoveAt(ConfigManager.Settings.fileHistoryList.Count - 1); + ConfigManager.Settings.FileHistoryList.RemoveAt(ConfigManager.Settings.FileHistoryList.Count - 1); } ConfigManager.Save(SettingsFlags.FileHistory); @@ -301,7 +304,7 @@ private void FillHistoryMenu () { ToolStripDropDown strip = new ToolStripDropDownMenu(); - foreach (var file in ConfigManager.Settings.fileHistoryList) + foreach (var file in ConfigManager.Settings.FileHistoryList) { ToolStripItem item = new ToolStripMenuItem(file); strip.Items.Add(item); @@ -390,9 +393,9 @@ private void OpenFileDialog () } else { - if (!string.IsNullOrEmpty(ConfigManager.Settings.lastDirectory)) + if (!string.IsNullOrEmpty(ConfigManager.Settings.LastDirectory)) { - openFileDialog.InitialDirectory = ConfigManager.Settings.lastDirectory; + openFileDialog.InitialDirectory = ConfigManager.Settings.LastDirectory; } else { @@ -415,7 +418,7 @@ private void OpenFileDialog () FileInfo info = new(openFileDialog.FileName); if (info.Directory.Exists) { - ConfigManager.Settings.lastDirectory = info.DirectoryName; + ConfigManager.Settings.LastDirectory = info.DirectoryName; ConfigManager.Save(SettingsFlags.FileHistory); } @@ -443,7 +446,7 @@ private void LoadFiles (string[] names, bool invertLogic) return; } - MultiFileOption option = ConfigManager.Settings.Preferences.multiFileOption; + MultiFileOption option = ConfigManager.Settings.Preferences.MultiFileOption; if (option == MultiFileOption.Ask) { MultiLoadRequestDialog dlg = new(); @@ -487,21 +490,21 @@ private void SetColumnizerHistoryEntry (string fileName, ILogLineColumnizer colu ColumnizerHistoryEntry entry = FindColumnizerHistoryEntry(fileName); if (entry != null) { - _ = ConfigManager.Settings.columnizerHistoryList.Remove(entry); + _ = ConfigManager.Settings.ColumnizerHistoryList.Remove(entry); } - ConfigManager.Settings.columnizerHistoryList.Add(new ColumnizerHistoryEntry(fileName, columnizer.GetName())); + ConfigManager.Settings.ColumnizerHistoryList.Add(new ColumnizerHistoryEntry(fileName, columnizer.GetName())); - if (ConfigManager.Settings.columnizerHistoryList.Count > MAX_COLUMNIZER_HISTORY) + if (ConfigManager.Settings.ColumnizerHistoryList.Count > MAX_COLUMNIZER_HISTORY) { - ConfigManager.Settings.columnizerHistoryList.RemoveAt(0); + ConfigManager.Settings.ColumnizerHistoryList.RemoveAt(0); } } private ColumnizerHistoryEntry FindColumnizerHistoryEntry (string fileName) { - foreach (ColumnizerHistoryEntry entry in ConfigManager.Settings.columnizerHistoryList) + foreach (ColumnizerHistoryEntry entry in ConfigManager.Settings.ColumnizerHistoryList) { if (entry.FileName.Equals(fileName, StringComparison.Ordinal)) { @@ -633,7 +636,7 @@ private void GuiStateUpdateWorker (GuiStateArgs e) cellSelectModeToolStripMenuItem.Checked = e.CellSelectMode; RefreshEncodingMenuBar(e.CurrentEncoding); - if (e.TimeshiftPossible && ConfigManager.Settings.Preferences.timestampControl) + if (e.TimeshiftPossible && ConfigManager.Settings.Preferences.TimestampControl) { dragControlDateTime.MinDateTime = e.MinTimestamp; dragControlDateTime.MaxDateTime = e.MaxTimestamp; @@ -778,6 +781,7 @@ private Icon CreateLedIcon (int level, bool dirty, int tailState, int syncMode) return icon; } + [SupportedOSPlatform("windows")] private void CreateIcons () { for (var syncMode = 0; syncMode <= 1; syncMode++) // LED indicating time synced tabs @@ -896,7 +900,7 @@ private Icon GetIcon (int diff, LogWindowData data) { Icon icon = _ledIcons[ - GetLevelFromDiff(diff), data.Dirty ? 1 : 0, Preferences.showTailState ? data.TailState : 3, + GetLevelFromDiff(diff), data.Dirty ? 1 : 0, Preferences.ShowTailState ? data.TailState : 3, data.SyncMode ]; return icon; @@ -940,6 +944,7 @@ private void RefreshEncodingMenuBar (Encoding encoding) toolStripEncodingANSIItem.Text = Encoding.Default.HeaderName; } + [SupportedOSPlatform("windows")] private void OpenSettings (int tabToOpen) { SettingsDialog dlg = new(ConfigManager.Settings.Preferences, this, tabToOpen, ConfigManager) @@ -955,6 +960,7 @@ private void OpenSettings (int tabToOpen) } } + [SupportedOSPlatform("windows")] private void NotifyWindowsForChangedPrefs (SettingsFlags flags) { _logger.Info("The preferences have changed"); @@ -982,9 +988,9 @@ private void ApplySettings (Settings settings, SettingsFlags flags) { if ((flags & SettingsFlags.WindowPosition) == SettingsFlags.WindowPosition) { - TopMost = alwaysOnTopToolStripMenuItem.Checked = settings.alwaysOnTop; - dragControlDateTime.DragOrientation = settings.Preferences.timestampControlDragOrientation; - hideLineColumnToolStripMenuItem.Checked = settings.hideLineColumn; + TopMost = alwaysOnTopToolStripMenuItem.Checked = settings.AlwaysOnTop; + dragControlDateTime.DragOrientation = settings.Preferences.TimestampControlDragOrientation; + hideLineColumnToolStripMenuItem.Checked = settings.HideLineColumn; } if ((flags & SettingsFlags.FileHistory) == SettingsFlags.FileHistory) @@ -1011,7 +1017,7 @@ private void ApplySettings (Settings settings, SettingsFlags flags) [SupportedOSPlatform("windows")] private void SetTabIcons (Preferences preferences) { - _tailLedBrush[0] = new SolidBrush(preferences.showTailColor); + _tailLedBrush[0] = new SolidBrush(preferences.ShowTailColor); CreateIcons(); lock (_logWindowList) { @@ -1050,6 +1056,7 @@ private void SetToolIcon (ToolEntry entry, ToolStripItem item) } } + [SupportedOSPlatform("windows")] private void ToolButtonClick (ToolEntry toolEntry) { if (string.IsNullOrEmpty(toolEntry.Cmd)) @@ -1069,8 +1076,7 @@ private void ToolButtonClick (ToolEntry toolEntry) var argLine = parser.BuildArgs(line, CurrentLogWindow.GetRealLineNum() + 1, info, this); if (argLine != null) { - StartTool(toolEntry.Cmd, argLine, toolEntry.Sysout, toolEntry.ColumnizerName, - toolEntry.WorkingDir); + StartTool(toolEntry.Cmd, argLine, toolEntry.Sysout, toolEntry.ColumnizerName, toolEntry.WorkingDir); } } } @@ -1243,7 +1249,7 @@ private void FillToolLauncherBar () externalToolsToolStrip.Items.Clear(); var num = 0; externalToolsToolStrip.SuspendLayout(); - foreach (ToolEntry tool in Preferences.toolEntries) + foreach (ToolEntry tool in Preferences.ToolEntries) { if (tool.IsFavourite) { @@ -1314,6 +1320,7 @@ private string SaveLayout () return resultXml; } + [SupportedOSPlatform("windows")] private void RestoreLayout (string layoutXml) { using MemoryStream memStream = new(2000); @@ -1326,6 +1333,7 @@ private void RestoreLayout (string layoutXml) dockPanel.LoadFromXml(memStream, DeserializeDockContent, true); } + [SupportedOSPlatform("windows")] private IDockContent DeserializeDockContent (string persistString) { if (persistString.Equals(WindowTypes.BookmarkWindow.ToString(), StringComparison.Ordinal)) diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs index 006eedf9..4058efe4 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs @@ -99,7 +99,7 @@ public LogWindow.LogWindow AddFileTab (string givenFileName, bool isTempFile, st //data.tabPage.BorderColor = this.defaultTabBorderColor; if (!isTempFile) { - foreach (ColorEntry colorEntry in ConfigManager.Settings.fileColors) + foreach (ColorEntry colorEntry in ConfigManager.Settings.FileColors) { if (colorEntry.FileName.ToUpperInvariant().Equals(logFileName.ToUpperInvariant(), StringComparison.Ordinal)) { @@ -161,7 +161,7 @@ public void OpenSearchDialog () SearchDialog dlg = new(); AddOwnedForm(dlg); dlg.TopMost = TopMost; - SearchParams.HistoryList = ConfigManager.Settings.searchHistoryList; + SearchParams.HistoryList = ConfigManager.Settings.SearchHistoryList; dlg.SearchParams = SearchParams; DialogResult res = dlg.ShowDialog(); if (res == DialogResult.OK && dlg.SearchParams != null && !string.IsNullOrWhiteSpace(dlg.SearchParams.SearchText)) @@ -185,7 +185,7 @@ public ILogLineColumnizer GetColumnizerHistoryEntry (string fileName) } } - ConfigManager.Settings.columnizerHistoryList.Remove(entry); // no valid name -> remove entry + ConfigManager.Settings.ColumnizerHistoryList.Remove(entry); // no valid name -> remove entry } return null; @@ -241,7 +241,7 @@ public void ScrollAllTabsToTimestamp (DateTime timestamp, LogWindow.LogWindow se public ILogLineColumnizer FindColumnizerByFileMask (string fileName) { - foreach (ColumnizerMaskEntry entry in ConfigManager.Settings.Preferences.columnizerMaskList) + foreach (ColumnizerMaskEntry entry in ConfigManager.Settings.Preferences.ColumnizerMaskList) { if (entry.Mask != null) { @@ -266,7 +266,7 @@ public ILogLineColumnizer FindColumnizerByFileMask (string fileName) public HighlightGroup FindHighlightGroupByFileMask (string fileName) { - foreach (HighlightMaskEntry entry in ConfigManager.Settings.Preferences.highlightMaskList) + foreach (HighlightMaskEntry entry in ConfigManager.Settings.Preferences.HighlightMaskList) { if (entry.Mask != null) { @@ -294,6 +294,7 @@ public void SelectTab (ILogWindow logWindow) logWindow.Activate(); } + [SupportedOSPlatform("windows")] public void SetForeground () { Win32.SetForegroundWindow(Handle); @@ -311,10 +312,10 @@ public void SetForeground () } // called from LogWindow when follow tail was changed + [SupportedOSPlatform("windows")] public void FollowTailChanged (LogWindow.LogWindow logWindow, bool isEnabled, bool offByTrigger) { - var data = logWindow.Tag as LogWindowData; - if (data == null) + if (logWindow.Tag is not LogWindowData data) { return; } @@ -328,13 +329,14 @@ public void FollowTailChanged (LogWindow.LogWindow logWindow, bool isEnabled, bo data.TailState = offByTrigger ? 2 : 1; } - if (Preferences.showTailState) + if (Preferences.ShowTailState) { Icon icon = GetIcon(data.DiffSum, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); } } + [SupportedOSPlatform("windows")] public void NotifySettingsChanged (object sender, SettingsFlags flags) { if (sender != this) @@ -345,7 +347,7 @@ public void NotifySettingsChanged (object sender, SettingsFlags flags) public IList GetListOfOpenFiles () { - IList list = new List(); + IList list = []; lock (_logWindowList) { foreach (LogWindow.LogWindow logWindow in _logWindowList) diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs index c32ab66d..d6b20a7d 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs @@ -62,58 +62,58 @@ private void FillDialog () { Preferences ??= new Preferences(); - if (Preferences.fontName == null) + if (Preferences.FontName == null) { - Preferences.fontName = "Courier New"; + Preferences.FontName = "Courier New"; } - if (Math.Abs(Preferences.fontSize) < 0.1) + if (Math.Abs(Preferences.FontSize) < 0.1) { - Preferences.fontSize = 9.0f; + Preferences.FontSize = 9.0f; } FillPortableMode(); - checkBoxDarkMode.Checked = Preferences.darkMode; - checkBoxTimestamp.Checked = Preferences.timestampControl; - checkBoxSyncFilter.Checked = Preferences.filterSync; - checkBoxFilterTail.Checked = Preferences.filterTail; - checkBoxFollowTail.Checked = Preferences.followTail; + checkBoxDarkMode.Checked = Preferences.DarkMode; + checkBoxTimestamp.Checked = Preferences.TimestampControl; + checkBoxSyncFilter.Checked = Preferences.FilterSync; + checkBoxFilterTail.Checked = Preferences.FilterTail; + checkBoxFollowTail.Checked = Preferences.FollowTail; - radioButtonHorizMouseDrag.Checked = Preferences.timestampControlDragOrientation == DragOrientationsEnum.Horizontal; - radioButtonVerticalMouseDrag.Checked = Preferences.timestampControlDragOrientation == DragOrientationsEnum.Vertical; - radioButtonVerticalMouseDragInverted.Checked = Preferences.timestampControlDragOrientation == DragOrientationsEnum.InvertedVertical; + radioButtonHorizMouseDrag.Checked = Preferences.TimestampControlDragOrientation == DragOrientationsEnum.Horizontal; + radioButtonVerticalMouseDrag.Checked = Preferences.TimestampControlDragOrientation == DragOrientationsEnum.Vertical; + radioButtonVerticalMouseDragInverted.Checked = Preferences.TimestampControlDragOrientation == DragOrientationsEnum.InvertedVertical; - checkBoxSingleInstance.Checked = Preferences.allowOnlyOneInstance; - checkBoxOpenLastFiles.Checked = Preferences.openLastFiles; - checkBoxTailState.Checked = Preferences.showTailState; - checkBoxColumnSize.Checked = Preferences.setLastColumnWidth; - cpDownColumnWidth.Enabled = Preferences.setLastColumnWidth; + checkBoxSingleInstance.Checked = Preferences.AllowOnlyOneInstance; + checkBoxOpenLastFiles.Checked = Preferences.OpenLastFiles; + checkBoxTailState.Checked = Preferences.ShowTailState; + checkBoxColumnSize.Checked = Preferences.SetLastColumnWidth; + cpDownColumnWidth.Enabled = Preferences.SetLastColumnWidth; - if (Preferences.lastColumnWidth != 0) + if (Preferences.LastColumnWidth != 0) { - if (Preferences.lastColumnWidth < cpDownColumnWidth.Minimum) + if (Preferences.LastColumnWidth < cpDownColumnWidth.Minimum) { - Preferences.lastColumnWidth = (int)cpDownColumnWidth.Minimum; + Preferences.LastColumnWidth = (int)cpDownColumnWidth.Minimum; } - if (Preferences.lastColumnWidth > cpDownColumnWidth.Maximum) + if (Preferences.LastColumnWidth > cpDownColumnWidth.Maximum) { - Preferences.lastColumnWidth = (int)cpDownColumnWidth.Maximum; + Preferences.LastColumnWidth = (int)cpDownColumnWidth.Maximum; } - cpDownColumnWidth.Value = Preferences.lastColumnWidth; + cpDownColumnWidth.Value = Preferences.LastColumnWidth; } - checkBoxTimeSpread.Checked = Preferences.showTimeSpread; - checkBoxReverseAlpha.Checked = Preferences.reverseAlpha; + checkBoxTimeSpread.Checked = Preferences.ShowTimeSpread; + checkBoxReverseAlpha.Checked = Preferences.ReverseAlpha; - radioButtonTimeView.Checked = Preferences.timeSpreadTimeMode; - radioButtonLineView.Checked = !Preferences.timeSpreadTimeMode; + radioButtonTimeView.Checked = Preferences.TimeSpreadTimeMode; + radioButtonLineView.Checked = !Preferences.TimeSpreadTimeMode; - checkBoxSaveSessions.Checked = Preferences.saveSessions; + checkBoxSaveSessions.Checked = Preferences.SaveSessions; - switch (Preferences.saveLocation) + switch (Preferences.SaveLocation) { case SessionSaveLocation.OwnDir: { @@ -145,15 +145,15 @@ private void FillDialog () upDownMaximumLineLength.Value = Preferences.MaxLineLength; - upDownMaximumFilterEntriesDisplayed.Value = Preferences.maximumFilterEntriesDisplayed; - upDownMaximumFilterEntries.Value = Preferences.maximumFilterEntries; + upDownMaximumFilterEntriesDisplayed.Value = Preferences.MaximumFilterEntriesDisplayed; + upDownMaximumFilterEntries.Value = Preferences.MaximumFilterEntries; - labelSessionSaveOwnDir.Text = Preferences.sessionSaveDirectory ?? string.Empty; - checkBoxSaveFilter.Checked = Preferences.saveFilters; - upDownBlockCount.Value = Preferences.bufferCount; - upDownLinesPerBlock.Value = Preferences.linesPerBuffer; - upDownPollingInterval.Value = Preferences.pollingInterval; - checkBoxMultiThread.Checked = Preferences.multiThreadFilter; + labelSessionSaveOwnDir.Text = Preferences.SessionSaveDirectory ?? string.Empty; + checkBoxSaveFilter.Checked = Preferences.SaveFilters; + upDownBlockCount.Value = Preferences.BufferCount; + upDownLinesPerBlock.Value = Preferences.LinesPerBuffer; + upDownPollingInterval.Value = Preferences.PollingInterval; + checkBoxMultiThread.Checked = Preferences.MultiThreadFilter; dataGridViewColumnizer.DataError += OnDataGridViewColumnizerDataError; @@ -165,14 +165,14 @@ private void FillDialog () FillMultifileSettings(); FillEncodingList(); - var temp = Encoding.GetEncoding(Preferences.defaultEncoding); + var temp = Encoding.GetEncoding(Preferences.DefaultEncoding); - comboBoxEncoding.SelectedItem = Encoding.GetEncoding(Preferences.defaultEncoding); - checkBoxMaskPrio.Checked = Preferences.maskPrio; - checkBoxAutoPick.Checked = Preferences.autoPick; - checkBoxAskCloseTabs.Checked = Preferences.askForClose; - checkBoxColumnFinder.Checked = Preferences.showColumnFinder; - checkBoxLegacyReader.Checked = Preferences.useLegacyReader; + comboBoxEncoding.SelectedItem = Encoding.GetEncoding(Preferences.DefaultEncoding); + checkBoxMaskPrio.Checked = Preferences.MaskPrio; + checkBoxAutoPick.Checked = Preferences.AutoPick; + checkBoxAskCloseTabs.Checked = Preferences.AskForClose; + checkBoxColumnFinder.Checked = Preferences.ShowColumnFinder; + checkBoxLegacyReader.Checked = Preferences.UseLegacyReader; checkBoxShowErrorMessageOnlyOneInstance.Checked = Preferences.ShowErrorMessageAllowOnlyOneInstances; } @@ -183,29 +183,29 @@ private void FillPortableMode () private void DisplayFontName () { - labelFont.Text = Preferences.fontName + @" " + (int)Preferences.fontSize; - labelFont.Font = new Font(new FontFamily(Preferences.fontName), Preferences.fontSize); + labelFont.Text = Preferences.FontName + @" " + (int)Preferences.FontSize; + labelFont.Font = new Font(new FontFamily(Preferences.FontName), Preferences.FontSize); } private void SaveMultifileData () { if (radioButtonLoadEveryFileIntoSeperatedTab.Checked) { - Preferences.multiFileOption = MultiFileOption.SingleFiles; + Preferences.MultiFileOption = MultiFileOption.SingleFiles; } if (radioButtonTreatAllFilesAsOneMultifile.Checked) { - Preferences.multiFileOption = MultiFileOption.MultiFile; + Preferences.MultiFileOption = MultiFileOption.MultiFile; } if (radioButtonAskWhatToDo.Checked) { - Preferences.multiFileOption = MultiFileOption.Ask; + Preferences.MultiFileOption = MultiFileOption.Ask; } - Preferences.multiFileOptions.FormatPattern = textBoxMultifilePattern.Text; - Preferences.multiFileOptions.MaxDayTry = (int)upDownMultifileDays.Value; + Preferences.MultiFileOptions.FormatPattern = textBoxMultifilePattern.Text; + Preferences.MultiFileOptions.MaxDayTry = (int)upDownMultifileDays.Value; } private void OnBtnToolClickInternal (TextBox textBox) @@ -312,7 +312,7 @@ private void FillColumnizerList () //comboColumn.DisplayMember = "Name"; //comboColumn.ValueMember = "Columnizer"; - foreach (ColumnizerMaskEntry maskEntry in Preferences.columnizerMaskList) + foreach (ColumnizerMaskEntry maskEntry in Preferences.ColumnizerMaskList) { DataGridViewRow row = new(); row.Cells.Add(new DataGridViewTextBoxCell()); @@ -356,7 +356,7 @@ private void FillHighlightMaskList () comboColumn.Items.Add(group.GroupName); } - foreach (HighlightMaskEntry maskEntry in Preferences.highlightMaskList) + foreach (HighlightMaskEntry maskEntry in Preferences.HighlightMaskList) { DataGridViewRow row = new(); row.Cells.Add(new DataGridViewTextBoxCell()); @@ -390,7 +390,7 @@ private void FillHighlightMaskList () private void SaveColumnizerList () { - Preferences.columnizerMaskList.Clear(); + Preferences.ColumnizerMaskList.Clear(); foreach (DataGridViewRow row in dataGridViewColumnizer.Rows) { @@ -399,14 +399,14 @@ private void SaveColumnizerList () ColumnizerMaskEntry entry = new(); entry.Mask = (string)row.Cells[0].Value; entry.ColumnizerName = (string)row.Cells[1].Value; - Preferences.columnizerMaskList.Add(entry); + Preferences.ColumnizerMaskList.Add(entry); } } } private void SaveHighlightMaskList () { - Preferences.highlightMaskList.Clear(); + Preferences.HighlightMaskList.Clear(); foreach (DataGridViewRow row in dataGridViewHighlightMask.Rows) { @@ -415,7 +415,7 @@ private void SaveHighlightMaskList () HighlightMaskEntry entry = new(); entry.Mask = (string)row.Cells[0].Value; entry.HighlightGroupName = (string)row.Cells[1].Value; - Preferences.highlightMaskList.Add(entry); + Preferences.HighlightMaskList.Add(entry); } } } @@ -479,7 +479,7 @@ private void FillToolListbox () { listBoxTools.Items.Clear(); - foreach (ToolEntry tool in Preferences.toolEntries) + foreach (ToolEntry tool in Preferences.ToolEntries) { listBoxTools.Items.Add(tool.Clone(), tool.IsFavourite); } @@ -492,7 +492,7 @@ private void FillToolListbox () private void FillMultifileSettings () { - switch (Preferences.multiFileOption) + switch (Preferences.MultiFileOption) { case MultiFileOption.SingleFiles: { @@ -511,18 +511,18 @@ private void FillMultifileSettings () } } - textBoxMultifilePattern.Text = Preferences.multiFileOptions.FormatPattern; //TODO: Impport settings file throws an exception. Fix or I caused it? - upDownMultifileDays.Value = Preferences.multiFileOptions.MaxDayTry; + textBoxMultifilePattern.Text = Preferences.MultiFileOptions.FormatPattern; //TODO: Impport settings file throws an exception. Fix or I caused it? + upDownMultifileDays.Value = Preferences.MultiFileOptions.MaxDayTry; } private void GetToolListBoxData () { GetCurrentToolValues(); - Preferences.toolEntries.Clear(); + Preferences.ToolEntries.Clear(); for (var i = 0; i < listBoxTools.Items.Count; ++i) { - Preferences.toolEntries.Add(listBoxTools.Items[i] as ToolEntry); + Preferences.ToolEntries.Add(listBoxTools.Items[i] as ToolEntry); (listBoxTools.Items[i] as ToolEntry).IsFavourite = listBoxTools.GetItemChecked(i); } } @@ -603,13 +603,13 @@ private void OnBtnChangeFontClick (object sender, EventArgs e) ShowEffects = false, AllowVerticalFonts = false, AllowScriptChange = false, - Font = new Font(new FontFamily(Preferences.fontName), Preferences.fontSize) + Font = new Font(new FontFamily(Preferences.FontName), Preferences.FontSize) }; if (dlg.ShowDialog() == DialogResult.OK) { - Preferences.fontSize = dlg.Font.Size; - Preferences.fontName = dlg.Font.FontFamily.Name; + Preferences.FontSize = dlg.Font.Size; + Preferences.FontName = dlg.Font.FontFamily.Name; } DisplayFontName(); @@ -617,71 +617,71 @@ private void OnBtnChangeFontClick (object sender, EventArgs e) private void OnBtnOkClick (object sender, EventArgs e) { - Preferences.timestampControl = checkBoxTimestamp.Checked; - Preferences.filterSync = checkBoxSyncFilter.Checked; - Preferences.filterTail = checkBoxFilterTail.Checked; - Preferences.followTail = checkBoxFollowTail.Checked; + Preferences.TimestampControl = checkBoxTimestamp.Checked; + Preferences.FilterSync = checkBoxSyncFilter.Checked; + Preferences.FilterTail = checkBoxFilterTail.Checked; + Preferences.FollowTail = checkBoxFollowTail.Checked; if (radioButtonVerticalMouseDrag.Checked) { - Preferences.timestampControlDragOrientation = DragOrientationsEnum.Vertical; + Preferences.TimestampControlDragOrientation = DragOrientationsEnum.Vertical; } else if (radioButtonVerticalMouseDragInverted.Checked) { - Preferences.timestampControlDragOrientation = DragOrientationsEnum.InvertedVertical; + Preferences.TimestampControlDragOrientation = DragOrientationsEnum.InvertedVertical; } else { - Preferences.timestampControlDragOrientation = DragOrientationsEnum.Horizontal; + Preferences.TimestampControlDragOrientation = DragOrientationsEnum.Horizontal; } SaveColumnizerList(); - Preferences.maskPrio = checkBoxMaskPrio.Checked; - Preferences.autoPick = checkBoxAutoPick.Checked; - Preferences.askForClose = checkBoxAskCloseTabs.Checked; - Preferences.allowOnlyOneInstance = checkBoxSingleInstance.Checked; - Preferences.openLastFiles = checkBoxOpenLastFiles.Checked; - Preferences.showTailState = checkBoxTailState.Checked; - Preferences.setLastColumnWidth = checkBoxColumnSize.Checked; - Preferences.lastColumnWidth = (int)cpDownColumnWidth.Value; - Preferences.showTimeSpread = checkBoxTimeSpread.Checked; - Preferences.reverseAlpha = checkBoxReverseAlpha.Checked; - Preferences.timeSpreadTimeMode = radioButtonTimeView.Checked; - - Preferences.saveSessions = checkBoxSaveSessions.Checked; - Preferences.sessionSaveDirectory = labelSessionSaveOwnDir.Text; + Preferences.MaskPrio = checkBoxMaskPrio.Checked; + Preferences.AutoPick = checkBoxAutoPick.Checked; + Preferences.AskForClose = checkBoxAskCloseTabs.Checked; + Preferences.AllowOnlyOneInstance = checkBoxSingleInstance.Checked; + Preferences.OpenLastFiles = checkBoxOpenLastFiles.Checked; + Preferences.ShowTailState = checkBoxTailState.Checked; + Preferences.SetLastColumnWidth = checkBoxColumnSize.Checked; + Preferences.LastColumnWidth = (int)cpDownColumnWidth.Value; + Preferences.ShowTimeSpread = checkBoxTimeSpread.Checked; + Preferences.ReverseAlpha = checkBoxReverseAlpha.Checked; + Preferences.TimeSpreadTimeMode = radioButtonTimeView.Checked; + + Preferences.SaveSessions = checkBoxSaveSessions.Checked; + Preferences.SessionSaveDirectory = labelSessionSaveOwnDir.Text; if (radioButtonsessionSaveDocuments.Checked) { - Preferences.saveLocation = SessionSaveLocation.DocumentsDir; + Preferences.SaveLocation = SessionSaveLocation.DocumentsDir; } else if (radioButtonSessionSaveOwn.Checked) { - Preferences.saveLocation = SessionSaveLocation.OwnDir; + Preferences.SaveLocation = SessionSaveLocation.OwnDir; } else if (radioButtonSessionApplicationStartupDir.Checked) { - Preferences.saveLocation = SessionSaveLocation.ApplicationStartupDir; + Preferences.SaveLocation = SessionSaveLocation.ApplicationStartupDir; } else { - Preferences.saveLocation = SessionSaveLocation.SameDir; + Preferences.SaveLocation = SessionSaveLocation.SameDir; } - Preferences.saveFilters = checkBoxSaveFilter.Checked; - Preferences.bufferCount = (int)upDownBlockCount.Value; - Preferences.linesPerBuffer = (int)upDownLinesPerBlock.Value; - Preferences.pollingInterval = (int)upDownPollingInterval.Value; - Preferences.multiThreadFilter = checkBoxMultiThread.Checked; - Preferences.defaultEncoding = comboBoxEncoding.SelectedItem != null ? (comboBoxEncoding.SelectedItem as Encoding).HeaderName : Encoding.Default.HeaderName; - Preferences.showColumnFinder = checkBoxColumnFinder.Checked; - Preferences.useLegacyReader = checkBoxLegacyReader.Checked; - - Preferences.maximumFilterEntries = (int)upDownMaximumFilterEntries.Value; - Preferences.maximumFilterEntriesDisplayed = (int)upDownMaximumFilterEntriesDisplayed.Value; + Preferences.SaveFilters = checkBoxSaveFilter.Checked; + Preferences.BufferCount = (int)upDownBlockCount.Value; + Preferences.LinesPerBuffer = (int)upDownLinesPerBlock.Value; + Preferences.PollingInterval = (int)upDownPollingInterval.Value; + Preferences.MultiThreadFilter = checkBoxMultiThread.Checked; + Preferences.DefaultEncoding = comboBoxEncoding.SelectedItem != null ? (comboBoxEncoding.SelectedItem as Encoding).HeaderName : Encoding.Default.HeaderName; + Preferences.ShowColumnFinder = checkBoxColumnFinder.Checked; + Preferences.UseLegacyReader = checkBoxLegacyReader.Checked; + + Preferences.MaximumFilterEntries = (int)upDownMaximumFilterEntries.Value; + Preferences.MaximumFilterEntriesDisplayed = (int)upDownMaximumFilterEntriesDisplayed.Value; Preferences.ShowErrorMessageAllowOnlyOneInstances = checkBoxShowErrorMessageOnlyOneInstance.Checked; - Preferences.darkMode = checkBoxDarkMode.Checked; + Preferences.DarkMode = checkBoxDarkMode.Checked; SavePluginSettings(); SaveHighlightMaskList(); @@ -734,12 +734,12 @@ private void OnBtnTailColorClick (object sender, EventArgs e) { ColorDialog dlg = new() { - Color = Preferences.showTailColor + Color = Preferences.ShowTailColor }; if (dlg.ShowDialog() == DialogResult.OK) { - Preferences.showTailColor = dlg.Color; + Preferences.ShowTailColor = dlg.Color; } } @@ -752,12 +752,12 @@ private void OnBtnTimespreadColorClick (object sender, EventArgs e) { ColorDialog dlg = new() { - Color = Preferences.timeSpreadColor + Color = Preferences.TimeSpreadColor }; if (dlg.ShowDialog() == DialogResult.OK) { - Preferences.timeSpreadColor = dlg.Color; + Preferences.TimeSpreadColor = dlg.Color; } } @@ -797,9 +797,9 @@ private void OnBtnSessionSaveDirClick (object sender, EventArgs e) { FolderBrowserDialog dlg = new(); - if (Preferences.sessionSaveDirectory != null) + if (Preferences.SessionSaveDirectory != null) { - dlg.SelectedPath = Preferences.sessionSaveDirectory; + dlg.SelectedPath = Preferences.SessionSaveDirectory; } dlg.ShowNewFolderButton = true; diff --git a/src/LogExpert.UI/Dialogs/ParamRequesterDialog.Designer.cs b/src/LogExpert.UI/Dialogs/ParamRequesterDialog.Designer.cs index bddf7808..a42f5b83 100644 --- a/src/LogExpert.UI/Dialogs/ParamRequesterDialog.Designer.cs +++ b/src/LogExpert.UI/Dialogs/ParamRequesterDialog.Designer.cs @@ -62,7 +62,7 @@ private void InitializeComponent() this.buttonOk.TabIndex = 2; this.buttonOk.Text = "OK"; this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.okButton_Click); + this.buttonOk.Click += new System.EventHandler(this.OnButtonOkClick); // // comboBoxValue // diff --git a/src/LogExpert.UI/Dialogs/ParamRequesterDialog.cs b/src/LogExpert.UI/Dialogs/ParamRequesterDialog.cs index 26d38846..ef272593 100644 --- a/src/LogExpert.UI/Dialogs/ParamRequesterDialog.cs +++ b/src/LogExpert.UI/Dialogs/ParamRequesterDialog.cs @@ -1,13 +1,8 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; +using System.Runtime.Versioning; namespace LogExpert.Dialogs; +[SupportedOSPlatform("windows")] public partial class ParamRequesterDialog : Form { #region Fields @@ -16,7 +11,7 @@ public partial class ParamRequesterDialog : Form #region cTor - public ParamRequesterDialog() + public ParamRequesterDialog () { InitializeComponent(); @@ -38,7 +33,7 @@ public ParamRequesterDialog() #region Events handler - private void ParamRequesterDialog_Shown(object sender, EventArgs e) + private void ParamRequesterDialog_Shown (object sender, EventArgs e) { labelValueForParameter.Text = ParamName; @@ -48,11 +43,12 @@ private void ParamRequesterDialog_Shown(object sender, EventArgs e) { comboBoxValue.Items.Add(value); } + comboBoxValue.SelectedIndex = 0; } } - private void okButton_Click(object sender, EventArgs e) + private void OnButtonOkClick (object sender, EventArgs e) { ParamValue = comboBoxValue.Text; } diff --git a/src/LogExpert.UI/Dialogs/RegexHelperDialog.cs b/src/LogExpert.UI/Dialogs/RegexHelperDialog.cs index d564884b..64c99a9f 100644 --- a/src/LogExpert.UI/Dialogs/RegexHelperDialog.cs +++ b/src/LogExpert.UI/Dialogs/RegexHelperDialog.cs @@ -1,4 +1,4 @@ -using System.Runtime.Versioning; +using System.Runtime.Versioning; using System.Text.RegularExpressions; namespace LogExpert.UI.Dialogs; @@ -8,7 +8,7 @@ public partial class RegexHelperDialog : Form { #region Fields - private static readonly int MAX_HISTORY = 30; + private const int MAX_HISTORY = 30; private bool _caseSensitive; private List _expressionHistoryList = []; private List _testtextHistoryList = []; @@ -17,7 +17,7 @@ public partial class RegexHelperDialog : Form #region cTor - public RegexHelperDialog() + public RegexHelperDialog () { InitializeComponent(); @@ -63,7 +63,7 @@ public List TesttextHistoryList #region Private Methods - private void UpdateMatches() + private void UpdateMatches () { textBoxMatches.Text = ""; try @@ -82,7 +82,7 @@ private void UpdateMatches() } } - private void LoadHistory() + private void LoadHistory () { comboBoxRegex.Items.Clear(); comboBoxRegex.DataSource = _expressionHistoryList; @@ -95,18 +95,18 @@ private void LoadHistory() #region Events handler - private void OnRegexHelperDialogLoad(object? sender, EventArgs e) + private void OnRegexHelperDialogLoad (object? sender, EventArgs e) { LoadHistory(); } - private void OnCaseSensitiveCheckBoxCheckedChanged(object sender, EventArgs e) + private void OnCaseSensitiveCheckBoxCheckedChanged (object sender, EventArgs e) { _caseSensitive = checkBoxCaseSensitive.Checked; UpdateMatches(); } - private void OnButtonOkClick(object sender, EventArgs e) + private void OnButtonOkClick (object sender, EventArgs e) { var text = comboBoxRegex.Text; comboBoxRegex.Items.Remove(text); @@ -127,17 +127,17 @@ private void OnButtonOkClick(object sender, EventArgs e) } } - private void OnComboBoxRegexTextChanged(object sender, EventArgs e) + private void OnComboBoxRegexTextChanged (object sender, EventArgs e) { UpdateMatches(); } - private void OnComboBoxTestTextTextChanged(object sender, EventArgs e) + private void OnComboBoxTestTextTextChanged (object sender, EventArgs e) { UpdateMatches(); } - private void OnButtonHelpClick(object sender, EventArgs e) + private void OnButtonHelpClick (object sender, EventArgs e) { Help.ShowHelp(this, "LogExpert.chm", HelpNavigator.Topic, "RegEx.htm"); } diff --git a/src/LogExpert.UI/Dialogs/SearchDialog.cs b/src/LogExpert.UI/Dialogs/SearchDialog.cs index e4542dc5..f1e09da9 100644 --- a/src/LogExpert.UI/Dialogs/SearchDialog.cs +++ b/src/LogExpert.UI/Dialogs/SearchDialog.cs @@ -1,9 +1,9 @@ -using LogExpert.Core.Entities; -using LogExpert.UI.Dialogs; - using System.Runtime.Versioning; using System.Text.RegularExpressions; +using LogExpert.Core.Entities; +using LogExpert.UI.Dialogs; + namespace LogExpert.Dialogs; [SupportedOSPlatform("windows")] @@ -11,13 +11,13 @@ public partial class SearchDialog : Form { #region Fields - private static readonly int MAX_HISTORY = 30; + private const int MAX_HISTORY = 30; #endregion #region cTor - public SearchDialog() + public SearchDialog () { InitializeComponent(); @@ -37,7 +37,7 @@ public SearchDialog() #region Events handler - private void OnSearchDialogLoad(object? sender, EventArgs e) + private void OnSearchDialogLoad (object? sender, EventArgs e) { if (SearchParams != null) { @@ -79,7 +79,7 @@ private void OnSearchDialogLoad(object? sender, EventArgs e) } } - private void OnButtonRegexClick(object sender, EventArgs e) + private void OnButtonRegexClick (object sender, EventArgs e) { RegexHelperDialog dlg = new() { @@ -95,7 +95,7 @@ private void OnButtonRegexClick(object sender, EventArgs e) } } - private void OnButtonOkClick(object sender, EventArgs e) + private void OnButtonOkClick (object sender, EventArgs e) { try { @@ -130,7 +130,7 @@ private void OnButtonOkClick(object sender, EventArgs e) #endregion - private void OnButtonCancelClick(object sender, EventArgs e) + private void OnButtonCancelClick (object sender, EventArgs e) { Close(); } diff --git a/src/LogExpert.UI/Dialogs/ToolArgsDialog.cs b/src/LogExpert.UI/Dialogs/ToolArgsDialog.cs index 4a734f9d..a1a68d1f 100644 --- a/src/LogExpert.UI/Dialogs/ToolArgsDialog.cs +++ b/src/LogExpert.UI/Dialogs/ToolArgsDialog.cs @@ -1,14 +1,12 @@ -using LogExpert.UI.Controls.LogTabWindow; +using System.Runtime.Versioning; + +using LogExpert.UI.Controls.LogTabWindow; using LogExpert.UI.Dialogs; using LogExpert.UI.Entities; -using System; -using System.Drawing; -using System.Windows.Forms; - - namespace LogExpert.Dialogs; +[SupportedOSPlatform("windows")] internal partial class ToolArgsDialog : Form { #region Fields @@ -19,7 +17,7 @@ internal partial class ToolArgsDialog : Form #region cTor - public ToolArgsDialog(LogTabWindow logTabWin, Form parent) + public ToolArgsDialog (LogTabWindow logTabWin, Form parent) { this.logTabWin = logTabWin; parent.AddOwnedForm(this); @@ -40,7 +38,7 @@ public ToolArgsDialog(LogTabWindow logTabWin, Form parent) #region Events handler - private void OnToolArgsDialogLoad(object sender, EventArgs e) + private void OnToolArgsDialogLoad (object sender, EventArgs e) { labelHelp.Text = "" + "%L = Current line number\n" + @@ -62,7 +60,7 @@ private void OnToolArgsDialogLoad(object sender, EventArgs e) textBoxArguments.Text = Arg; } - private void OnButtonRegexHelpClick(object sender, EventArgs e) + private void OnButtonRegexHelpClick (object sender, EventArgs e) { RegexHelperDialog regexDlg = new(); if (regexDlg.ShowDialog() == DialogResult.OK) @@ -72,7 +70,7 @@ private void OnButtonRegexHelpClick(object sender, EventArgs e) } //TODO: what is the purpose of this in the settings? Can we just send the line and info instead of the object? - private void OnButtonTestClick(object sender, EventArgs e) + private void OnButtonTestClick (object sender, EventArgs e) { if (logTabWin.CurrentLogWindow != null) { @@ -87,7 +85,7 @@ private void OnButtonTestClick(object sender, EventArgs e) } } - private void OnButtonOkClick(object sender, EventArgs e) + private void OnButtonOkClick (object sender, EventArgs e) { Arg = textBoxArguments.Text; } diff --git a/src/LogExpert.UI/Entities/ArgParser.cs b/src/LogExpert.UI/Entities/ArgParser.cs index e481a877..8aa65cfd 100644 --- a/src/LogExpert.UI/Entities/ArgParser.cs +++ b/src/LogExpert.UI/Entities/ArgParser.cs @@ -1,3 +1,4 @@ +using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; @@ -8,13 +9,9 @@ namespace LogExpert.UI.Entities; internal class ArgParser (string argTemplate) { - - #region cTor - - #endregion - #region Public methods + [SupportedOSPlatform("windows")] public string BuildArgs (ILogLine logLine, int lineNum, ILogFileInfo logFileInfo, Form parent) { StringBuilder builder = new(argTemplate); @@ -68,6 +65,7 @@ public string BuildArgs (ILogLine logLine, int lineNum, ILogFileInfo logFileInfo { end = builder.Length - 1; } + ask = builder.ToString().Substring(i + 2, end - i - 2); } diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index 6c795af4..4d760cde 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -1,10 +1,13 @@ -using LogExpert.Core.Classes.Highlight; +using System.Runtime.Versioning; + +using LogExpert.Core.Classes.Highlight; using LogExpert.Core.Config; using LogExpert.Core.Entities; using LogExpert.Core.Interface; using LogExpert.Dialogs; using LogExpert.UI.Controls; using LogExpert.UI.Interface; + using NLog; namespace LogExpert.UI.Entities; @@ -24,13 +27,15 @@ internal static class PaintHelper #region Properties public static IConfigManager ConfigManager { get; set; } + private static Preferences Preferences => ConfigManager.Settings.Preferences; #endregion #region Public methods - public static void CellPainting(ILogPaintContextUI logPaintCtx, BufferedDataGridView gridView, int rowIndex, + [SupportedOSPlatform("windows")] + public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) { if (rowIndex < 0 || e.ColumnIndex < 0) @@ -102,9 +107,11 @@ public static void CellPainting(ILogPaintContextUI logPaintCtx, BufferedDataGrid brush.Dispose(); if (bookmark.Text.Length > 0) { - StringFormat format = new(); - format.LineAlignment = StringAlignment.Center; - format.Alignment = StringAlignment.Center; + StringFormat format = new() + { + LineAlignment = StringAlignment.Center, + Alignment = StringAlignment.Center + }; Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); Font font = logPaintCtx.MonospacedFont; e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), @@ -119,45 +126,55 @@ public static void CellPainting(ILogPaintContextUI logPaintCtx, BufferedDataGrid } } - public static DataGridViewTextBoxColumn CreateMarkerColumn() + [SupportedOSPlatform("windows")] + public static DataGridViewTextBoxColumn CreateMarkerColumn () { - DataGridViewTextBoxColumn markerColumn = new(); - markerColumn.HeaderText = ""; - markerColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - markerColumn.Resizable = DataGridViewTriState.False; - markerColumn.DividerWidth = 1; - markerColumn.ReadOnly = true; - markerColumn.SortMode = DataGridViewColumnSortMode.NotSortable; + DataGridViewTextBoxColumn markerColumn = new() + { + HeaderText = "", + AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet, + Resizable = DataGridViewTriState.False, + DividerWidth = 1, + ReadOnly = true, + SortMode = DataGridViewColumnSortMode.NotSortable + }; return markerColumn; } - public static DataGridViewTextBoxColumn CreateLineNumberColumn() + [SupportedOSPlatform("windows")] + public static DataGridViewTextBoxColumn CreateLineNumberColumn () { - DataGridViewTextBoxColumn lineNumberColumn = new(); - lineNumberColumn.HeaderText = "Line"; - lineNumberColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - lineNumberColumn.Resizable = DataGridViewTriState.NotSet; - lineNumberColumn.DividerWidth = 1; - lineNumberColumn.ReadOnly = true; - lineNumberColumn.SortMode = DataGridViewColumnSortMode.NotSortable; + DataGridViewTextBoxColumn lineNumberColumn = new() + { + HeaderText = "Line", + AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet, + Resizable = DataGridViewTriState.NotSet, + DividerWidth = 1, + ReadOnly = true, + SortMode = DataGridViewColumnSortMode.NotSortable + }; return lineNumberColumn; } - public static DataGridViewColumn CreateTitleColumn(string colName) + [SupportedOSPlatform("windows")] + public static DataGridViewColumn CreateTitleColumn (string colName) { - DataGridViewColumn titleColumn = new LogTextColumn(); - titleColumn.HeaderText = colName; - titleColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - titleColumn.Resizable = DataGridViewTriState.NotSet; - titleColumn.DividerWidth = 1; - titleColumn.SortMode = DataGridViewColumnSortMode.NotSortable; + DataGridViewColumn titleColumn = new LogTextColumn + { + HeaderText = colName, + AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet, + Resizable = DataGridViewTriState.NotSet, + DividerWidth = 1, + SortMode = DataGridViewColumnSortMode.NotSortable + }; return titleColumn; } - public static void SetColumnizer(ILogLineColumnizer columnizer, BufferedDataGridView gridView) + [SupportedOSPlatform("windows")] + public static void SetColumnizer (ILogLineColumnizer columnizer, BufferedDataGridView gridView) { var rowCount = gridView.RowCount; var currLine = gridView.CurrentCellAddress.Y; @@ -188,6 +205,7 @@ public static void SetColumnizer(ILogLineColumnizer columnizer, BufferedDataGrid { gridView.CurrentCell = gridView.Rows[currLine].Cells[0]; } + if (currFirstLine != -1) { gridView.FirstDisplayedScrollingRowIndex = currFirstLine; @@ -198,18 +216,19 @@ public static void SetColumnizer(ILogLineColumnizer columnizer, BufferedDataGrid //TODO: Original name is AutoResizeColumn. Where is this used? //TODO: Rename ConfigManager to configManager - private static void AutoResizeColumns(BufferedDataGridView gridView, IConfigManager CnofigManager) + [SupportedOSPlatform("windows")] + private static void AutoResizeColumns (BufferedDataGridView gridView, IConfigManager configManager) { try { gridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - if (gridView.Columns.Count > 1 && Preferences.setLastColumnWidth && - gridView.Columns[gridView.Columns.Count - 1].Width < Preferences.lastColumnWidth + if (gridView.Columns.Count > 1 && Preferences.SetLastColumnWidth && + gridView.Columns[gridView.Columns.Count - 1].Width < Preferences.LastColumnWidth ) { // It seems that using 'MinimumWidth' instead of 'Width' prevents the DataGridView's NullReferenceExceptions //gridView.Columns[gridView.Columns.Count - 1].Width = this.Preferences.lastColumnWidth; - gridView.Columns[gridView.Columns.Count - 1].MinimumWidth = Preferences.lastColumnWidth; + gridView.Columns[gridView.Columns.Count - 1].MinimumWidth = Preferences.LastColumnWidth; } } catch (NullReferenceException e) @@ -222,18 +241,17 @@ private static void AutoResizeColumns(BufferedDataGridView gridView, IConfigMana } } - public static void ApplyDataGridViewPrefs(BufferedDataGridView dataGridView, Preferences prefs, IConfigManager configManager) + [SupportedOSPlatform("windows")] + public static void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, Preferences prefs, IConfigManager configManager) { //TODO: This is a very bad solution and should be solved ASAP - if (ConfigManager == null) { - ConfigManager = configManager; - } + ConfigManager ??= configManager; if (dataGridView.Columns.Count > 1) { - if (prefs.setLastColumnWidth) + if (prefs.SetLastColumnWidth) { - dataGridView.Columns[dataGridView.Columns.Count - 1].MinimumWidth = prefs.lastColumnWidth; + dataGridView.Columns[dataGridView.Columns.Count - 1].MinimumWidth = prefs.LastColumnWidth; } else { @@ -243,20 +261,24 @@ public static void ApplyDataGridViewPrefs(BufferedDataGridView dataGridView, Pre dataGridView.Columns[dataGridView.Columns.Count - 1].MinimumWidth = 5; // default } } + if (dataGridView.RowCount > 0) { dataGridView.UpdateRowHeightInfo(0, true); } + dataGridView.Invalidate(); dataGridView.Refresh(); AutoResizeColumns(dataGridView, ConfigManager); } - public static Rectangle BorderWidths(DataGridViewAdvancedBorderStyle advancedBorderStyle) + [SupportedOSPlatform("windows")] + public static Rectangle BorderWidths (DataGridViewAdvancedBorderStyle advancedBorderStyle) { - Rectangle rect = new(); - - rect.X = advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; + Rectangle rect = new() + { + X = advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1 + }; if (advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.OutsetDouble || advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.InsetDouble) { @@ -294,12 +316,14 @@ public static Rectangle BorderWidths(DataGridViewAdvancedBorderStyle advancedBor #region Private Methods - private static void PaintCell(ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) + [SupportedOSPlatform("windows")] + private static void PaintCell (ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) { PaintHighlightedCell(logPaintCtx, e, gridView, noBackgroundFill, groundEntry); } - private static void PaintHighlightedCell(ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) + [SupportedOSPlatform("windows")] + private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) { var value = e.Value ?? string.Empty; @@ -312,11 +336,13 @@ private static void PaintHighlightedCell(ILogPaintContextUI logPaintCtx, DataGri if (value is Column column) { - if (string.IsNullOrEmpty(column.FullValue) == false) + if (!string.IsNullOrEmpty(column.FullValue)) { - HilightMatchEntry hme = new(); - hme.StartPos = 0; - hme.Length = column.FullValue.Length; + HilightMatchEntry hme = new() + { + StartPos = 0, + Length = column.FullValue.Length + }; var he = new HighlightEntry { @@ -386,7 +412,7 @@ private static void PaintHighlightedCell(ILogPaintContextUI logPaintCtx, DataGri var matchWord = string.Empty; if (value is Column again) { - if (string.IsNullOrEmpty(again.FullValue) == false) + if (!string.IsNullOrEmpty(again.FullValue)) { matchWord = again.FullValue.Substring(matchEntry.StartPos, matchEntry.Length); } @@ -411,6 +437,7 @@ private static void PaintHighlightedCell(ILogPaintContextUI logPaintCtx, DataGri foreColor = Color.White; } } + TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, foreColor, flags); wordPos.Offset(wordSize.Width, 0); @@ -428,7 +455,7 @@ private static void PaintHighlightedCell(ILogPaintContextUI logPaintCtx, DataGri /// List of all highlight matches for the current cell /// The entry that is used as the default. /// List of HilightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring. - private static IList MergeHighlightMatchEntries(IList matchList, HilightMatchEntry groundEntry) + private static IList MergeHighlightMatchEntries (IList matchList, HilightMatchEntry groundEntry) { // Fill an area with lenth of whole text with a default hilight entry var entryArray = new HighlightEntry[groundEntry.Length]; @@ -456,7 +483,7 @@ private static IList MergeHighlightMatchEntries(IList mergedList = new List(); + IList mergedList = []; if (entryArray.Length > 0) { HighlightEntry currentEntry = entryArray[0]; @@ -466,21 +493,26 @@ private static IList MergeHighlightMatchEntries(IList LogWindow.FileName; public LogWindow LogWindow { get; } = logWindow; diff --git a/src/LogExpert.UI/Extensions/Utils.cs b/src/LogExpert.UI/Extensions/Utils.cs index 6b2c2d67..27d000b0 100644 --- a/src/LogExpert.UI/Extensions/Utils.cs +++ b/src/LogExpert.UI/Extensions/Utils.cs @@ -1,8 +1,12 @@ -namespace LogExpert.UI.Extensions; +using System.Runtime.Versioning; + +namespace LogExpert.UI.Extensions; + internal static class Utils { - public static string GetWordFromPos(int xPos, string text, Graphics g, Font font) + [SupportedOSPlatform("windows")] + public static string GetWordFromPos (int xPos, string text, Graphics g, Font font) { var words = text.Split([' ', '.', ':', ';']); @@ -44,13 +48,8 @@ public static string GetWordFromPos(int xPos, string text, Graphics g, Font font y++; } - if (found) - { - return words[y]; - } - else - { - return null; - } + return found + ? words[y] + : null; } } diff --git a/src/LogExpert/Classes/CommandLine/CmdLineInt.cs b/src/LogExpert/Classes/CommandLine/CmdLineInt.cs index c67dd9ad..c9bfead4 100644 --- a/src/LogExpert/Classes/CommandLine/CmdLineInt.cs +++ b/src/LogExpert/Classes/CommandLine/CmdLineInt.cs @@ -14,8 +14,8 @@ public class CmdLineInt : CmdLineParameter { #region Fields - private readonly int _max = int.MaxValue; - private readonly int _min = int.MinValue; + private readonly int _max; + private readonly int _min; #endregion @@ -27,9 +27,11 @@ public class CmdLineInt : CmdLineParameter /// Name of parameter. /// Require that the parameter is present in the command line. /// The explanation of the parameter to add to the help screen. - public CmdLineInt(string name, bool required, string helpMessage) + public CmdLineInt (string name, bool required, string helpMessage) : base(name, required, helpMessage) { + _max = int.MaxValue; + _min = int.MinValue; } /// @@ -40,10 +42,10 @@ public CmdLineInt(string name, bool required, string helpMessage) /// The explanation of the parameter to add to the help screen. /// The minimum value of the parameter. /// The maximum valie of the parameter. - public CmdLineInt(string name, bool required, string helpMessage, int min, int max) + public CmdLineInt (string name, bool required, string helpMessage, int min, int max) : base(name, required, helpMessage) { - _min = min; + _max = min; _max = max; } @@ -54,7 +56,7 @@ public CmdLineInt(string name, bool required, string helpMessage, int min, int m /// /// Returns the current value of the parameter. /// - new public int Value { get; private set; } + public new int Value { get; private set; } #endregion @@ -64,7 +66,7 @@ public CmdLineInt(string name, bool required, string helpMessage, int min, int m /// Sets the value of the parameter. /// /// A string containing a integer expression. - public override void SetValue(string value) + public override void SetValue (string value) { base.SetValue(value); int i; @@ -76,14 +78,17 @@ public override void SetValue(string value) { throw new CmdLineException(Name, "Value is not an integer."); } + if (i < _min) { - throw new CmdLineException(Name, string.Format("Value must be greather or equal to {0}.", _min)); + throw new CmdLineException(Name, $"Value must be greather or equal to {_min}."); } + if (i > _max) { - throw new CmdLineException(Name, string.Format("Value must be less or equal to {0}.", _max)); + throw new CmdLineException(Name, $"Value must be less or equal to {_max}."); } + Value = i; } @@ -92,10 +97,7 @@ public override void SetValue(string value) /// /// /// - public static implicit operator int(CmdLineInt s) - { - return s.Value; - } + public static implicit operator int (CmdLineInt s) => s.Value; #endregion } \ No newline at end of file diff --git a/src/LogExpert/Classes/LogExpertProxy.cs b/src/LogExpert/Classes/LogExpertProxy.cs index 6823f7da..bf122209 100644 --- a/src/LogExpert/Classes/LogExpertProxy.cs +++ b/src/LogExpert/Classes/LogExpertProxy.cs @@ -1,6 +1,6 @@ using LogExpert.Config; using LogExpert.Core.Interface; -using LogExpert.UI.Dialogs.LogTabWindow; +using LogExpert.UI.Controls.LogWindow; using NLog; diff --git a/src/LogExpert/Config/ConfigManager.cs b/src/LogExpert/Config/ConfigManager.cs index 9a201cc5..cae55ba6 100644 --- a/src/LogExpert/Config/ConfigManager.cs +++ b/src/LogExpert/Config/ConfigManager.cs @@ -185,45 +185,45 @@ private Settings LoadOrCreateNew (FileInfo fileInfo) settings.Preferences ??= new Preferences(); - settings.Preferences.toolEntries ??= []; + settings.Preferences.ToolEntries ??= []; - settings.Preferences.columnizerMaskList ??= []; + settings.Preferences.ColumnizerMaskList ??= []; - settings.fileHistoryList ??= []; + settings.FileHistoryList ??= []; - settings.lastOpenFilesList ??= []; + settings.LastOpenFilesList ??= []; - settings.fileColors ??= []; + settings.FileColors ??= []; - if (settings.Preferences.showTailColor == Color.Empty) + if (settings.Preferences.ShowTailColor == Color.Empty) { - settings.Preferences.showTailColor = Color.FromKnownColor(KnownColor.Blue); + settings.Preferences.ShowTailColor = Color.FromKnownColor(KnownColor.Blue); } - if (settings.Preferences.timeSpreadColor == Color.Empty) + if (settings.Preferences.TimeSpreadColor == Color.Empty) { - settings.Preferences.timeSpreadColor = Color.Gray; + settings.Preferences.TimeSpreadColor = Color.Gray; } - if (settings.Preferences.bufferCount < 10) + if (settings.Preferences.BufferCount < 10) { - settings.Preferences.bufferCount = 100; + settings.Preferences.BufferCount = 100; } - if (settings.Preferences.linesPerBuffer < 1) + if (settings.Preferences.LinesPerBuffer < 1) { - settings.Preferences.linesPerBuffer = 500; + settings.Preferences.LinesPerBuffer = 500; } - settings.filterList ??= []; + settings.FilterList ??= []; - settings.searchHistoryList ??= []; + settings.SearchHistoryList ??= []; - settings.filterHistoryList ??= []; + settings.FilterHistoryList ??= []; - settings.filterRangeHistoryList ??= []; + settings.FilterRangeHistoryList ??= []; - foreach (FilterParams filterParams in settings.filterList) + foreach (FilterParams filterParams in settings.FilterList) { filterParams.Init(); } @@ -233,25 +233,25 @@ private Settings LoadOrCreateNew (FileInfo fileInfo) settings.Preferences.HighlightGroupList = []; } - settings.Preferences.highlightMaskList ??= []; + settings.Preferences.HighlightMaskList ??= []; - if (settings.Preferences.pollingInterval < 20) + if (settings.Preferences.PollingInterval < 20) { - settings.Preferences.pollingInterval = 250; + settings.Preferences.PollingInterval = 250; } - settings.Preferences.multiFileOptions ??= new MultiFileOptions(); + settings.Preferences.MultiFileOptions ??= new MultiFileOptions(); - settings.Preferences.defaultEncoding ??= Encoding.Default.HeaderName; + settings.Preferences.DefaultEncoding ??= Encoding.Default.HeaderName; - if (settings.Preferences.maximumFilterEntriesDisplayed == 0) + if (settings.Preferences.MaximumFilterEntriesDisplayed == 0) { - settings.Preferences.maximumFilterEntriesDisplayed = 20; + settings.Preferences.MaximumFilterEntriesDisplayed = 20; } - if (settings.Preferences.maximumFilterEntries == 0) + if (settings.Preferences.MaximumFilterEntries == 0) { - settings.Preferences.maximumFilterEntries = 30; + settings.Preferences.MaximumFilterEntries = 30; } SetBoundsWithinVirtualScreen(settings); @@ -309,7 +309,7 @@ private void Save (FileInfo fileInfo, Settings settings, SettingsFlags flags) private static void SaveAsJSON (FileInfo fileInfo, Settings settings) { - settings.versionBuild = Assembly.GetExecutingAssembly().GetName().Version.Build; + settings.VersionBuild = Assembly.GetExecutingAssembly().GetName().Version.Build; using StreamWriter sw = new(fileInfo.Create()); JsonSerializer serializer = new(); @@ -368,10 +368,10 @@ private Settings Import (Settings currentSettings, FileInfo fileInfo, ExportImpo { newSettings = ownSettings; newSettings.Preferences = ObjectClone.Clone(importSettings.Preferences); - newSettings.Preferences.columnizerMaskList = ownSettings.Preferences.columnizerMaskList; - newSettings.Preferences.highlightMaskList = ownSettings.Preferences.highlightMaskList; + newSettings.Preferences.ColumnizerMaskList = ownSettings.Preferences.ColumnizerMaskList; + newSettings.Preferences.HighlightMaskList = ownSettings.Preferences.HighlightMaskList; newSettings.Preferences.HighlightGroupList = ownSettings.Preferences.HighlightGroupList; - newSettings.Preferences.toolEntries = ownSettings.Preferences.toolEntries; + newSettings.Preferences.ToolEntries = ownSettings.Preferences.ToolEntries; } else { @@ -380,11 +380,11 @@ private Settings Import (Settings currentSettings, FileInfo fileInfo, ExportImpo if ((flags & ExportImportFlags.ColumnizerMasks) == ExportImportFlags.ColumnizerMasks) { - newSettings.Preferences.columnizerMaskList = ReplaceOrKeepExisting(flags, ownSettings.Preferences.columnizerMaskList, importSettings.Preferences.columnizerMaskList); + newSettings.Preferences.ColumnizerMaskList = ReplaceOrKeepExisting(flags, ownSettings.Preferences.ColumnizerMaskList, importSettings.Preferences.ColumnizerMaskList); } if ((flags & ExportImportFlags.HighlightMasks) == ExportImportFlags.HighlightMasks) { - newSettings.Preferences.highlightMaskList = ReplaceOrKeepExisting(flags, ownSettings.Preferences.highlightMaskList, importSettings.Preferences.highlightMaskList); + newSettings.Preferences.HighlightMaskList = ReplaceOrKeepExisting(flags, ownSettings.Preferences.HighlightMaskList, importSettings.Preferences.HighlightMaskList); } if ((flags & ExportImportFlags.HighlightSettings) == ExportImportFlags.HighlightSettings) { @@ -392,7 +392,7 @@ private Settings Import (Settings currentSettings, FileInfo fileInfo, ExportImpo } if ((flags & ExportImportFlags.ToolEntries) == ExportImportFlags.ToolEntries) { - newSettings.Preferences.toolEntries = ReplaceOrKeepExisting(flags, ownSettings.Preferences.toolEntries, importSettings.Preferences.toolEntries); + newSettings.Preferences.ToolEntries = ReplaceOrKeepExisting(flags, ownSettings.Preferences.ToolEntries, importSettings.Preferences.ToolEntries); } return newSettings; @@ -413,10 +413,10 @@ private static List ReplaceOrKeepExisting (ExportImportFlags flags, List Date: Tue, 3 Jun 2025 12:29:48 +0200 Subject: [PATCH 061/142] static because everything is static in this class --- src/LogExpert.Core/Classes/Persister/Persister.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LogExpert.Core/Classes/Persister/Persister.cs b/src/LogExpert.Core/Classes/Persister/Persister.cs index d055db08..8ae747b9 100644 --- a/src/LogExpert.Core/Classes/Persister/Persister.cs +++ b/src/LogExpert.Core/Classes/Persister/Persister.cs @@ -12,7 +12,7 @@ namespace LogExpert.Core.Classes.Persister; //TODO Rewrite as json Persister, xml is outdated and difficult to parse and write -public class Persister +public static class Persister { #region Fields From ccf2a769125b94010031eaec7b387167befbcd4d Mon Sep 17 00:00:00 2001 From: Hirogen Date: Tue, 3 Jun 2025 13:18:16 +0200 Subject: [PATCH 062/142] ObjectDisposedException.ThrowIf wrongly used --- .../Classes/Log/PositionAwareStreamReaderBase.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs index 00a130d0..0cd74d6d 100644 --- a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs +++ b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs @@ -94,7 +94,7 @@ protected override void Dispose (bool disposing) //TODO This is unsafe and should be refactored public override unsafe int ReadChar () { - ObjectDisposedException.ThrowIf(true, ToString()); + ObjectDisposedException.ThrowIf(IsDisposed, GetType().ToString()); try { @@ -126,9 +126,8 @@ protected virtual void ResetReader () protected StreamReader GetStreamReader () { - return IsDisposed - ? throw new ObjectDisposedException(ToString()) - : _reader; + ObjectDisposedException.ThrowIf(IsDisposed, GetType().ToString()); + return _reader; } protected void MovePosition (int offset) From 1cbe8bf435fa9051dcad04d36bab4c3b6c6b3772 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sun, 1 Jun 2025 18:50:34 +0300 Subject: [PATCH 063/142] Added truncate file option to context menu - .net8 version Changed Win32 to NativeMethods to take care of some warnings. Based on: https://github.com/LogExperts/LogExpert/pull/146 --- .../Controls/LogWindow/LogWindowPublic.cs | 23 ++ .../Controls/LogWindow/TimeSpreadigControl.cs | 2 +- src/LogExpert.UI/Dialogs/ChooseIconDlg.cs | 4 +- .../Dialogs/LogTabWindow/LogTabWindow.cs | 2 +- .../LogTabWindow/LogTabWindow.designer.cs | 12 +- .../LogTabWindow/LogTabWindowEventHandlers.cs | 6 +- .../LogTabWindow/LogTabWindowPrivate.cs | 6 +- .../LogTabWindow/LogTabWindowPublic.cs | 2 +- .../Dialogs/LogTabWindow/SettingsDialog.cs | 4 +- src/LogExpert.UI/Extensions/LockFinder.cs | 129 ++++++++++ src/LogExpert.UI/Extensions/NativeMethods.cs | 228 ++++++++++++++++++ src/LogExpert.UI/Extensions/Win32.cs | 150 ------------ 12 files changed, 406 insertions(+), 162 deletions(-) create mode 100644 src/LogExpert.UI/Extensions/LockFinder.cs create mode 100644 src/LogExpert.UI/Extensions/NativeMethods.cs delete mode 100644 src/LogExpert.UI/Extensions/Win32.cs diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs index 7b3ae108..9fce6a8c 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs @@ -11,6 +11,7 @@ using LogExpert.Core.EventArguments; using LogExpert.Dialogs; using LogExpert.UI.Entities; +using LogExpert.UI.Extensions; namespace LogExpert.UI.Controls.LogWindow; @@ -581,6 +582,28 @@ public void FollowTailChanged (bool isChecked, bool byTrigger) SendGuiStateUpdate(); } + public void TryToTruncate () + { + try + { + if (LockFinder.CheckIfFileIsLocked(Title)) + { + var name = LockFinder.FindLockedProcessName(Title); + StatusLineText($"Truncate failed: file is locked by {name}"); + } + else + { + File.WriteAllText(Title, ""); + } + } + catch (Exception ex) + { + _logger.Warn($"Unexpected issue truncating file: {ex.Message}"); + StatusLineText("Unexpected issue truncating file"); + throw; + } + } + public void GotoLine (int line) { if (line >= 0) diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs index c65bc9a9..7aea14ed 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs @@ -17,7 +17,7 @@ internal partial class TimeSpreadingControl : UserControl private Bitmap _bitmap = new(1, 1); private int _displayHeight = 1; - private readonly int _edgeOffset = (int)Win32.GetSystemMetricsForDpi(Win32.SM_CYVSCROLL); + private readonly int _edgeOffset = (int)NativeMethods.GetSystemMetricsForDpi(NativeMethods.SM_CYVSCROLL); private int _lastMouseY; private readonly object _monitor = new(); private int _rectHeight = 1; diff --git a/src/LogExpert.UI/Dialogs/ChooseIconDlg.cs b/src/LogExpert.UI/Dialogs/ChooseIconDlg.cs index ddce747d..bee7a594 100644 --- a/src/LogExpert.UI/Dialogs/ChooseIconDlg.cs +++ b/src/LogExpert.UI/Dialogs/ChooseIconDlg.cs @@ -1,4 +1,4 @@ -using LogExpert.UI.Extensions; +using LogExpert.UI.Extensions; using System.Runtime.Versioning; namespace LogExpert.UI.Dialogs; @@ -38,7 +38,7 @@ private void FillIconList() { iconListView.Items.Clear(); - Icon[,] icons = Win32.ExtractIcons(FileName); + Icon[,] icons = NativeMethods.ExtractIcons(FileName); if (icons == null) { diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs index 254707aa..43742412 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs @@ -170,7 +170,7 @@ public LogTabWindow (string[] fileNames, int instanceNumber, bool showInstanceNu public void ChangeTheme (Control.ControlCollection container) { ColorMode.LoadColorMode(ConfigManager.Settings.Preferences.DarkMode); - Win32.UseImmersiveDarkMode(Handle, ColorMode.DarkModeEnabled); + NativeMethods.UseImmersiveDarkMode(Handle, ColorMode.DarkModeEnabled); #region ApplyColorToAllControls foreach (Control component in container) diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs index 4030f93d..3821a872 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs @@ -155,6 +155,7 @@ private void InitializeComponent() tabRenameToolStripMenuItem = new ToolStripMenuItem(); copyPathToClipboardToolStripMenuItem = new ToolStripMenuItem(); findInExplorerToolStripMenuItem = new ToolStripMenuItem(); + truncateFileToolStripMenuItem = new ToolStripMenuItem(); dragControlDateTime = new DateTimeDragControl(); statusStrip.SuspendLayout(); mainMenuStrip.SuspendLayout(); @@ -1053,7 +1054,7 @@ private void InitializeComponent() // tabContextMenuStrip.ForeColor = System.Drawing.SystemColors.ControlText; tabContextMenuStrip.ImageScalingSize = new System.Drawing.Size(24, 24); - tabContextMenuStrip.Items.AddRange(new ToolStripItem[] { closeThisTabToolStripMenuItem, closeOtherTabsToolStripMenuItem, closeAllTabsToolStripMenuItem, tabColorToolStripMenuItem, tabRenameToolStripMenuItem, copyPathToClipboardToolStripMenuItem, findInExplorerToolStripMenuItem }); + tabContextMenuStrip.Items.AddRange(new ToolStripItem[] { closeThisTabToolStripMenuItem, closeOtherTabsToolStripMenuItem, closeAllTabsToolStripMenuItem, tabColorToolStripMenuItem, tabRenameToolStripMenuItem, copyPathToClipboardToolStripMenuItem, findInExplorerToolStripMenuItem, truncateFileToolStripMenuItem }); tabContextMenuStrip.Name = "tabContextMenuStrip"; tabContextMenuStrip.Size = new System.Drawing.Size(197, 158); // @@ -1114,6 +1115,14 @@ private void InitializeComponent() findInExplorerToolStripMenuItem.ToolTipText = "Opens an Explorer window and selects the log file"; findInExplorerToolStripMenuItem.Click += OnFindInExplorerToolStripMenuItemClick; // + // truncateFileToolStripMenuItem + // + this.truncateFileToolStripMenuItem.Name = "truncateFileToolStripMenuItem"; + this.truncateFileToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + this.truncateFileToolStripMenuItem.Text = "Truncate File"; + this.truncateFileToolStripMenuItem.ToolTipText = "Try to truncate the file opened in tab"; + this.truncateFileToolStripMenuItem.Click += new System.EventHandler(this.TruncateFileToolStripMenuItem_Click); + // // dragControlDateTime // dragControlDateTime.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; @@ -1236,6 +1245,7 @@ private void InitializeComponent() private ToolStripButton toolStripButtonBubbles; private ToolStripMenuItem copyPathToClipboardToolStripMenuItem; private ToolStripMenuItem findInExplorerToolStripMenuItem; + private ToolStripMenuItem truncateFileToolStripMenuItem; private ToolStripMenuItem exportBookmarksToolStripMenuItem; private ToolStripComboBox groupsComboBoxHighlightGroups; private ToolStripMenuItem debugToolStripMenuItem; diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs index 3cb32910..3b0dc376 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs @@ -847,7 +847,11 @@ private void OnFindInExplorerToolStripMenuItemClick (object sender, EventArgs e) explorer.Start(); } - [SupportedOSPlatform("windows")] + private void TruncateFileToolStripMenuItem_Click (object sender, EventArgs e) + { + CurrentLogWindow?.TryToTruncate(); + } + private void OnExportBookmarksToolStripMenuItemClick (object sender, EventArgs e) { CurrentLogWindow?.ExportBookmarkList(); diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs index ec93bd35..68fcff65 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs @@ -774,7 +774,7 @@ private Icon CreateLedIcon (int level, bool dirty, int tailState, int syncMode) // a managed copy of icon. then the unmanaged win32 handle is destroyed var iconHandle = bmp.GetHicon(); var icon = Icon.FromHandle(iconHandle).Clone() as Icon; - Win32.DestroyIcon(iconHandle); + NativeMethods.DestroyIcon(iconHandle); gfx.Dispose(); bmp.Dispose(); @@ -1033,7 +1033,7 @@ private void SetTabIcons (Preferences preferences) [SupportedOSPlatform("windows")] private void SetToolIcon (ToolEntry entry, ToolStripItem item) { - Icon icon = Win32.LoadIconFromExe(entry.IconFile, entry.IconIndex); + Icon icon = NativeMethods.LoadIconFromExe(entry.IconFile, entry.IconIndex); if (icon != null) { item.Image = icon.ToBitmap(); @@ -1046,7 +1046,7 @@ private void SetToolIcon (ToolEntry entry, ToolStripItem item) item.DisplayStyle = ToolStripItemDisplayStyle.Image; } - Win32.DestroyIcon(icon.Handle); + NativeMethods.DestroyIcon(icon.Handle); icon.Dispose(); } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs index 4058efe4..eb4745ac 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs @@ -297,7 +297,7 @@ public void SelectTab (ILogWindow logWindow) [SupportedOSPlatform("windows")] public void SetForeground () { - Win32.SetForegroundWindow(Handle); + NativeMethods.SetForegroundWindow(Handle); if (WindowState == FormWindowState.Minimized) { if (_wasMaximized) diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs index d6b20a7d..bdf5df26 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs @@ -558,12 +558,12 @@ private void DisplayCurrentIcon () { if (_selectedTool != null) { - Icon icon = Win32.LoadIconFromExe(_selectedTool.IconFile, _selectedTool.IconIndex); + Icon icon = NativeMethods.LoadIconFromExe(_selectedTool.IconFile, _selectedTool.IconIndex); if (icon != null) { Image image = icon.ToBitmap(); buttonIcon.Image = image; - Win32.DestroyIcon(icon.Handle); + NativeMethods.DestroyIcon(icon.Handle); icon.Dispose(); } else diff --git a/src/LogExpert.UI/Extensions/LockFinder.cs b/src/LogExpert.UI/Extensions/LockFinder.cs new file mode 100644 index 00000000..ad4c74c7 --- /dev/null +++ b/src/LogExpert.UI/Extensions/LockFinder.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.InteropServices; + +// Expanded with some helpers from: https://code.msdn.microsoft.com/windowsapps/How-to-know-the-process-704839f4/ +// Uses Windows Restart Manager. +// A more involved and cross platform solution to this problem is here: https://github.com/cklutz/LockCheck + + +namespace LogExpert.UI.Extensions; + +internal class LockFinder +{ + + /// + /// Method FindLockedProcessName Retrieve the first process name + /// that is locking the file at the specified path + /// + /// The path of a file with a write lock held by a + /// process + /// The name of the first process found with a lock + /// + /// Thrown when the file path is not locked + /// + static public string FindLockedProcessName (string path) + { + var list = FindLockProcesses(path); + if (list.Count == 0) + { + throw new Exception( + "No processes are locking the path specified"); + } + return list[0].ProcessName; + } + + /// + /// Method CheckIfFileIsLocked Check if the file specified has a + /// write lock held by a process + /// + /// The path of a file being checked if a write lock + /// held by a process + /// true when one or more processes with lock + static public bool CheckIfFileIsLocked (string path) + { + var list = FindLockProcesses(path); + if (list.Count > 0) + { return true; } + return false; + } + + /// + /// Used to find processes holding a lock on the file. This would cause + /// other usage, such as file truncation or write opretions to throw + /// IOException if an exclusive lock is attempted. + /// + /// Path being checked + /// List of processes holding file lock to path + /// + static public List FindLockProcesses (string path) + { + var key = Guid.NewGuid().ToString(); + var processes = new List(); + + var res = NativeMethods.RmStartSession(out var handle, 0, key); + if (res != 0) + { + throw new Exception("Could not begin restart session. " + + "Unable to determine file locker."); + } + + try + { + uint pnProcInfo = 0; + uint lpdwRebootReasons = NativeMethods.RmRebootReasonNone; + string[] resources = [path]; + + res = NativeMethods.RmRegisterResources(handle, (uint)resources.Length, + resources, 0, null, 0, null); + if (res != 0) + { + throw new Exception("Could not register resource."); + } + res = NativeMethods.RmGetList(handle, out var pnProcInfoNeeded, ref pnProcInfo, null, + ref lpdwRebootReasons); + const int ERROR_MORE_DATA = 234; + if (res == ERROR_MORE_DATA) + { + var processInfo = + new NativeMethods.RM_PROCESS_INFO[pnProcInfoNeeded]; + pnProcInfo = pnProcInfoNeeded; + // Get the list. + res = NativeMethods.RmGetList(handle, out pnProcInfoNeeded, ref pnProcInfo, processInfo, ref lpdwRebootReasons); + if (res == 0) + { + processes = new List((int)pnProcInfo); + for (var i = 0; i < pnProcInfo; i++) + { + try + { + processes.Add(Process.GetProcessById(processInfo[i]. + Process.dwProcessId)); + } + catch (ArgumentException) { } + } + } + else + { + throw new Exception("Could not list processes locking resource"); + } + } + else if (res != 0) + { + throw new Exception("Could not list processes locking resource." + + "Failed to get size of result."); + } + } + catch (Exception exception) + { + Trace.WriteLine(exception.Message); + } + finally + { + Trace.WriteLine($"RmEndSession: {NativeMethods.RmEndSession(handle)}"); + } + + return processes; + } +} diff --git a/src/LogExpert.UI/Extensions/NativeMethods.cs b/src/LogExpert.UI/Extensions/NativeMethods.cs new file mode 100644 index 00000000..41d97fa1 --- /dev/null +++ b/src/LogExpert.UI/Extensions/NativeMethods.cs @@ -0,0 +1,228 @@ +using System.Runtime.InteropServices; +using System.Runtime.Versioning; + +namespace LogExpert.UI.Extensions; + +[SupportedOSPlatform("windows")] +internal static partial class NativeMethods +{ + #region Fields + + public const long SM_CYVSCROLL = 20; + public const long SM_CXHSCROLL = 21; + public const long SM_CXVSCROLL = 2; + public const long SM_CYHSCROLL = 3; + private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19; + private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20; + public const int RmRebootReasonNone = 0; + private const int CCH_RM_MAX_APP_NAME = 255; + private const int CCH_RM_MAX_SVC_NAME = 63; + + #endregion + + #region Structs + + [StructLayout(LayoutKind.Sequential)] + public struct RM_UNIQUE_PROCESS + { + public int dwProcessId; + public System.Runtime.InteropServices. + ComTypes.FILETIME ProcessStartTime; + } + + [StructLayout(LayoutKind.Sequential, + CharSet = CharSet.Auto)] + public struct RM_PROCESS_INFO + { + public RM_UNIQUE_PROCESS Process; + [MarshalAs(UnmanagedType.ByValTStr, + SizeConst = CCH_RM_MAX_APP_NAME + 1)] + public string strAppName; + [MarshalAs(UnmanagedType.ByValTStr, + SizeConst = CCH_RM_MAX_SVC_NAME + 1)] + public string strServiceShortName; + public RM_APP_TYPE ApplicationType; + public uint AppStatus; + public uint TSSessionId; + [MarshalAs(UnmanagedType.Bool)] + public bool bRestartable; + } + #endregion Structs + + #region Enums + public enum RM_APP_TYPE + { + RmUnknownApp = 0, + RmMainWindow = 1, + RmOtherWindow = 2, + RmService = 3, + RmExplorer = 4, + RmConsole = 5, + RmCritical = 1000 + } + + #endregion Enums + + #region Library Imports + + #region user32.dll Imports + [LibraryImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + public static partial bool DestroyIcon (nint hIcon); + + [LibraryImport("User32.dll")] + public static partial int SetForegroundWindow (nint hWnd); + + [LibraryImport("user32.dll")] + public static partial long GetSystemMetricsForDpi (long index); + + [LibraryImport("user32.dll")] + public static partial long GetSystemMetrics (long index); + + [LibraryImport("user32.dll")] + public static partial short GetKeyState (int vKey); + + #endregion user32.dll Imports + + #region shell32.dll Imports + /* + UINT ExtractIconEx( + LPCTSTR lpszFile, + int nIconIndex, + HICON *phiconLarge, + HICON *phiconSmall, + UINT nIcons + ); + * */ + [LibraryImport("shell32.dll", StringMarshalling = StringMarshalling.Utf16)] + public static partial uint ExtractIconEx ( + string fileName, + int iconIndex, + out nint iconsLarge, + out nint iconsSmall, + uint numIcons + ); + + #endregion shell32.dll Imports + + #region dwmapi.dll Imports + + #region TitleBarDarkMode + [LibraryImport("dwmapi.dll")] + public static partial int DwmSetWindowAttribute (nint hwnd, int attr, ref int attrValue, int attrSize); + #endregion TitleBarDarkMode + + #endregion shell32.dll Imports + + #region rstrtmgr.dll Imports + + [DllImport("rstrtmgr.dll", CharSet = CharSet.Auto, SetLastError = true)] + public static extern int RmGetList ( + uint dwSessionHandle, + out uint pnProcInfoNeeded, + ref uint pnProcInfo, + [In, Out] RM_PROCESS_INFO[] rgAffectedApps, + ref uint lpdwRebootReasons); + + [DllImport("rstrtmgr.dll", CharSet = CharSet.Auto, SetLastError = true)] + public static extern int RmRegisterResources ( + uint pSessionHandle, + uint nFiles, + string[] rgsFilenames, + uint nApplications, + [In] RM_UNIQUE_PROCESS[] rgApplications, + uint nServices, + string[] rgsServiceNames); + + [LibraryImport("rstrtmgr.dll", StringMarshalling = StringMarshalling.Utf16)] + public static partial int RmStartSession ( + out uint pSessionHandle, + int dwSessionFlags, + string strSessionKey); + + [LibraryImport("rstrtmgr.dll", StringMarshalling = StringMarshalling.Utf16)] + public static partial int RmEndSession (uint pSessionHandle); + + #endregion rstrtmgr.dll Imports + + #endregion Library Imports + + #region Helper methods + + public static Icon LoadIconFromExe (string fileName, int index) + { + nint smallIcons = new(); + nint largeIcons = new(); + int num = (int)ExtractIconEx(fileName, index, out largeIcons, out smallIcons, 1); + if (num > 0 && smallIcons != nint.Zero) + { + var icon = (Icon)Icon.FromHandle(smallIcons).Clone(); + DestroyIcon(smallIcons); + return icon; + } + if (num > 0 && largeIcons != nint.Zero) + { + var icon = (Icon)Icon.FromHandle(largeIcons).Clone(); + DestroyIcon(largeIcons); + return icon; + } + return null; + } + + public static Icon[,] ExtractIcons (string fileName) + { + var iconCount = ExtractIconEx(fileName, -1, out var largeIcon, out var smallIcon, 0); + if (iconCount <= 0) + { + return null; + } + + var result = new Icon[2, iconCount]; + + for (var i = 0; i < iconCount; ++i) + { + var num = ExtractIconEx(fileName, i, out var largeIcons, out var smallIcons, 1); + if (smallIcons != nint.Zero) + { + result[0, i] = (Icon)Icon.FromHandle(smallIcons).Clone(); + DestroyIcon(smallIcons); + } + else + { + result[0, i] = null; + } + + if (num > 0 && largeIcons != nint.Zero) + { + result[1, i] = (Icon)Icon.FromHandle(largeIcons).Clone(); + DestroyIcon(largeIcons); + } + else + { + result[1, i] = null; + } + } + + return result; + } + + public static bool UseImmersiveDarkMode (nint handle, bool enabled) + { + var attribute = DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1; + if (IsWindows10OrGreater(18985)) + { + attribute = DWMWA_USE_IMMERSIVE_DARK_MODE; + } + + var useImmersiveDarkMode = enabled ? 1 : 0; + return DwmSetWindowAttribute(handle, attribute, ref useImmersiveDarkMode, sizeof(int)) == 0; + + } + + private static bool IsWindows10OrGreater (int build = -1) + { + return Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= build; + } + + #endregion Helper methods +} \ No newline at end of file diff --git a/src/LogExpert.UI/Extensions/Win32.cs b/src/LogExpert.UI/Extensions/Win32.cs deleted file mode 100644 index a039e711..00000000 --- a/src/LogExpert.UI/Extensions/Win32.cs +++ /dev/null @@ -1,150 +0,0 @@ -using System.Drawing; -using System.Runtime.InteropServices; -using System.Runtime.Versioning; - -namespace LogExpert.UI.Extensions; - -[SupportedOSPlatform("windows")] -internal static partial class Win32 //NativeMethods -{ - #region Fields - - public const long SM_CYVSCROLL = 20; - public const long SM_CXHSCROLL = 21; - public const long SM_CXVSCROLL = 2; - public const long SM_CYHSCROLL = 3; - private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19; - private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20; - - #endregion - - #region Library Imports - [LibraryImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static partial bool DestroyIcon(nint hIcon); - - [LibraryImport("User32.dll")] - public static partial int SetForegroundWindow(nint hWnd); - - [LibraryImport("user32.dll")] - public static partial long GetSystemMetricsForDpi(long index); - - [LibraryImport("user32.dll")] - public static partial long GetSystemMetrics(long index); - - [LibraryImport("user32.dll")] - public static partial short GetKeyState(int vKey); - - /* - UINT ExtractIconEx( - LPCTSTR lpszFile, - int nIconIndex, - HICON *phiconLarge, - HICON *phiconSmall, - UINT nIcons - ); - * */ - [LibraryImport("shell32.dll", StringMarshalling = StringMarshalling.Utf16)] - public static partial uint ExtractIconEx( - string fileName, - int iconIndex, - ref nint iconsLarge, - ref nint iconsSmall, - uint numIcons - ); - - #region TitleBarDarkMode - [LibraryImport("dwmapi.dll")] - public static partial int DwmSetWindowAttribute(nint hwnd, int attr, ref int attrValue, int attrSize); - #endregion - #endregion - - #region Public methods - - public static Icon LoadIconFromExe(string fileName, int index) - { - //IntPtr[] smallIcons = new IntPtr[1]; - //IntPtr[] largeIcons = new IntPtr[1]; - nint smallIcons = new(); - nint largeIcons = new(); - var num = (int)ExtractIconEx(fileName, index, ref largeIcons, ref smallIcons, 1); - if (num > 0 && smallIcons != nint.Zero) - { - var icon = (Icon)Icon.FromHandle(smallIcons).Clone(); - DestroyIcon(smallIcons); - return icon; - } - if (num > 0 && largeIcons != nint.Zero) - { - var icon = (Icon)Icon.FromHandle(largeIcons).Clone(); - DestroyIcon(largeIcons); - return icon; - } - return null; - } - - public static Icon[,] ExtractIcons(string fileName) - { - var smallIcon = nint.Zero; - var largeIcon = nint.Zero; - var iconCount = (int)ExtractIconEx(fileName, -1, ref largeIcon, ref smallIcon, 0); - if (iconCount <= 0) - { - return null; - } - - nint smallIcons = new(); - nint largeIcons = new(); - var result = new Icon[2, iconCount]; - - for (var i = 0; i < iconCount; ++i) - { - var num = (int)ExtractIconEx(fileName, i, ref largeIcons, ref smallIcons, 1); - if (smallIcons != nint.Zero) - { - result[0, i] = (Icon)Icon.FromHandle(smallIcons).Clone(); - DestroyIcon(smallIcons); - } - else - { - result[0, i] = null; - } - if (num > 0 && largeIcons != nint.Zero) - { - result[1, i] = (Icon)Icon.FromHandle(largeIcons).Clone(); - DestroyIcon(largeIcons); - } - else - { - result[1, i] = null; - } - } - return result; - } - - #endregion - - #region Private Methods - - public static bool UseImmersiveDarkMode(nint handle, bool enabled) - { - - var attribute = DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1; - if (IsWindows10OrGreater(18985)) - { - attribute = DWMWA_USE_IMMERSIVE_DARK_MODE; - } - - var useImmersiveDarkMode = enabled ? 1 : 0; - return DwmSetWindowAttribute(handle, attribute, ref useImmersiveDarkMode, sizeof(int)) == 0; - - } - - private static bool IsWindows10OrGreater(int build = -1) - { - return Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= build; - } - - #endregion TitleBarDarkMode - -} \ No newline at end of file From 4fd3b7499e92552078b2bcf10833493ac62433cf Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Wed, 11 Jun 2025 23:12:32 +0300 Subject: [PATCH 064/142] Got rid of a few warnings --- .../ILogLineColumnizerCallback.cs | 2 ++ .../Classes/Bookmark/BookmarkDataProvider.cs | 22 +++++------- .../Classes/Bookmark/BookmarkExporter.cs | 1 + .../Classes/Columnizer/ColumnizerPicker.cs | 6 ++-- .../Columnizer/SquareBracketColumnizer.cs | 5 +-- .../Classes/Filter/FilterPipe.cs | 34 ++++++++++++++++--- src/LogExpert.Core/Interface/IBookmarkData.cs | 1 + 7 files changed, 47 insertions(+), 24 deletions(-) diff --git a/src/ColumnizerLib/ILogLineColumnizerCallback.cs b/src/ColumnizerLib/ILogLineColumnizerCallback.cs index 2c5f5811..77e417c1 100644 --- a/src/ColumnizerLib/ILogLineColumnizerCallback.cs +++ b/src/ColumnizerLib/ILogLineColumnizerCallback.cs @@ -1,3 +1,5 @@ +#pragma warning disable IDE0040 + namespace LogExpert; /// diff --git a/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs b/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs index bf098ffc..cb003c79 100644 --- a/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs +++ b/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs @@ -27,21 +27,11 @@ public BookmarkDataProvider (SortedList bookmarkList) #endregion - #region Delegates - - public delegate void AllBookmarksRemovedEventHandler (object sender, EventArgs e); - - public delegate void BookmarkAddedEventHandler (object sender, EventArgs e); - - public delegate void BookmarkRemovedEventHandler (object sender, EventArgs e); - - #endregion - #region Events - public event BookmarkAddedEventHandler BookmarkAdded; - public event BookmarkRemovedEventHandler BookmarkRemoved; - public event AllBookmarksRemovedEventHandler AllBookmarksRemoved; + public event EventHandler BookmarkAdded; + public event EventHandler BookmarkRemoved; + public event EventHandler AllBookmarksRemoved; #endregion @@ -141,8 +131,10 @@ public void RemoveBookmarkForLine (int lineNum) OnBookmarkRemoved(); } - public void RemoveBookmarksForLines (List lineNumList) + public void RemoveBookmarksForLines (IEnumerable lineNumList) { + ArgumentNullException.ThrowIfNull(lineNumList); + foreach (var lineNum in lineNumList) { _ = BookmarkList.Remove(lineNum); @@ -155,6 +147,8 @@ public void RemoveBookmarksForLines (List lineNumList) public void AddBookmark (Entities.Bookmark bookmark) { + ArgumentNullException.ThrowIfNull(bookmark); + BookmarkList.Add(bookmark.LineNum, bookmark); OnBookmarkAdded(); } diff --git a/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs b/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs index 2100f803..078082f8 100644 --- a/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs +++ b/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs @@ -13,6 +13,7 @@ public static class BookmarkExporter public static void ExportBookmarkList (SortedList bookmarkList, string logfileName, string fileName) { + ArgumentNullException.ThrowIfNull(bookmarkList); FileStream fs = new(fileName, FileMode.Create, FileAccess.Write); StreamWriter writer = new(fs); writer.WriteLine("Log file name;Line number;Comment"); diff --git a/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs b/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs index 227fe06e..15b9fac9 100644 --- a/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs +++ b/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs @@ -93,13 +93,15 @@ public static ILogLineColumnizer FindBetterColumnizer (string fileName, /// /// /// - public static ILogLineColumnizer FindColumnizer (string fileName, IAutoLogLineColumnizerCallback logFileReader, IList list) + public static ILogLineColumnizer FindColumnizer (string fileName, IAutoLogLineColumnizerCallback logFileReader, IList registeredColumnizer) { if (string.IsNullOrEmpty(fileName)) { return new DefaultLogfileColumnizer(); } + ArgumentNullException.ThrowIfNull(registeredColumnizer); + List loglines = []; if (logFileReader != null) @@ -120,8 +122,6 @@ public static ILogLineColumnizer FindColumnizer (string fileName, IAutoLogLineCo ]; } - var registeredColumnizer = list; - List> priorityListOfColumnizers = []; foreach (ILogLineColumnizer logLineColumnizer in registeredColumnizer) diff --git a/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs b/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs index 36c733ca..d770f865 100644 --- a/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs +++ b/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs @@ -1,3 +1,4 @@ +using System.Globalization; using System.Text.RegularExpressions; using static LogExpert.Core.Classes.Columnizer.TimeFormatDeterminer; @@ -142,13 +143,13 @@ public string[] GetColumnNames () var i = 1; while (columnNames.Count < GetColumnCount()) { - columnNames.Insert(columnNames.Count - 1, "Source" + i++.ToString()); + columnNames.Insert(columnNames.Count - 1, $"Source{i++.ToString(CultureInfo.InvariantCulture)}"); } return columnNames.ToArray(); } - public IColumnizedLogLine SplitLine (LogExpert.ILogLineColumnizerCallback callback, ILogLine line) + public IColumnizedLogLine SplitLine (ILogLineColumnizerCallback callback, ILogLine line) { // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 diff --git a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs index 1b847c4b..af33b7e3 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs @@ -1,31 +1,31 @@ using System.Text; - using LogExpert.Core.Interface; - using NLog; namespace LogExpert.Core.Classes.Filter; -public class FilterPipe +public class FilterPipe : IDisposable { #region Fields private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); - private IList _lineMappingList = []; + private List _lineMappingList = []; private StreamWriter _writer; private readonly object _fileNameLock = new(); + private bool _disposed; #endregion #region cTor - public FilterPipe (FilterParams filterParams, ILogWindow logWindow) + public FilterPipe(FilterParams filterParams, ILogWindow logWindow) { FilterParams = filterParams; LogWindow = logWindow; IsStopped = false; FileName = Path.GetTempFileName(); + _disposed = false; _logger.Info($"Created temp file: {FileName}"); } @@ -191,5 +191,29 @@ private void OnClosed () Closed?.Invoke(this, EventArgs.Empty); } + public void Dispose () + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose (bool disposing) + { + if (!_disposed) + { + if (disposing) + { + _writer?.Dispose(); + } + _disposed = true; + } + } + + ~FilterPipe () + { + Dispose(false); + } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Interface/IBookmarkData.cs b/src/LogExpert.Core/Interface/IBookmarkData.cs index 7abcedb7..9afe7562 100644 --- a/src/LogExpert.Core/Interface/IBookmarkData.cs +++ b/src/LogExpert.Core/Interface/IBookmarkData.cs @@ -2,6 +2,7 @@ namespace LogExpert.Core.Interface; +#pragma warning disable IDE0040 public interface IBookmarkData { #region Properties From 6a05a1cd112322b33600a6171c0e50ec2a4bbe16 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Thu, 12 Jun 2025 00:14:02 +0300 Subject: [PATCH 065/142] Changed rules: 1. Space before brackets in method names 2. Allow to use List in private fields --- src/.editorconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/.editorconfig b/src/.editorconfig index 1de2ba37..c9040640 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -415,7 +415,7 @@ dotnet_diagnostic.IDE0053.severity = suggestion dotnet_diagnostic.IDE0054.severity = warning # IDE0055: Fix formatting -dotnet_diagnostic.IDE0055.severity = warning +dotnet_diagnostic.IDE0055.severity = none # IDE0056: Use index operator dotnet_diagnostic.IDE0056.severity = warning @@ -571,7 +571,7 @@ dotnet_code_quality.CA1001.excluded_type_names_with_derived_types = # CA1002: Do not expose generic lists dotnet_diagnostic.CA1002.severity = suggestion -dotnet_code_quality.CA1002.api_surface = all +dotnet_code_quality.CA1002.api_surface = public, internal # CA1003: Use generic event handler instances dotnet_diagnostic.CA1003.severity = warning From ca02f3b1e475e15c6572c6cd071a136aa545093d Mon Sep 17 00:00:00 2001 From: Hirogen Date: Thu, 12 Jun 2025 16:27:27 +0200 Subject: [PATCH 066/142] removed ConfigManager and Preferences from PaintHelper --- .../Classes/Highlight/HighlightMatchEntry.cs | 26 +++++ .../Classes/Highlight/HilightMatchEntry.cs | 26 ----- src/LogExpert.Core/Config/ColorMode.cs | 15 ++- .../Interface/ISharedToolWindow.cs | 10 +- .../Controls/LogWindow/LogWindow.cs | 36 ++---- .../LogWindow/LogWindowEventHandlers.cs | 7 +- .../Controls/LogWindow/LogWindowPrivate.cs | 84 +++++++------- .../Controls/LogWindow/LogWindowPublic.cs | 27 +++-- src/LogExpert.UI/Dialogs/BookmarkWindow.cs | 33 +++--- .../LogTabWindow/LogTabWindowPrivate.cs | 16 ++- src/LogExpert.UI/Entities/PaintHelper.cs | 104 ++++++++---------- .../Interface/ILogPaintContextUI.cs | 2 +- src/LogExpert/Program.cs | 50 +++++---- 13 files changed, 221 insertions(+), 215 deletions(-) create mode 100644 src/LogExpert.Core/Classes/Highlight/HighlightMatchEntry.cs delete mode 100644 src/LogExpert.Core/Classes/Highlight/HilightMatchEntry.cs diff --git a/src/LogExpert.Core/Classes/Highlight/HighlightMatchEntry.cs b/src/LogExpert.Core/Classes/Highlight/HighlightMatchEntry.cs new file mode 100644 index 00000000..91c38160 --- /dev/null +++ b/src/LogExpert.Core/Classes/Highlight/HighlightMatchEntry.cs @@ -0,0 +1,26 @@ +namespace LogExpert.Core.Classes.Highlight; + +/// +/// Class for storing word-wise highlight matches. Used for colouring different matches on one line. +/// +public class HighlightMatchEntry +{ + #region Properties + + public HighlightEntry HighlightEntry { get; set; } + + public int StartPos { get; set; } + + public int Length { get; set; } + + #endregion + + #region Public methods + + public override string ToString () + { + return $"{HighlightEntry.SearchText}/{StartPos}/{Length}"; + } + + #endregion +} \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Highlight/HilightMatchEntry.cs b/src/LogExpert.Core/Classes/Highlight/HilightMatchEntry.cs deleted file mode 100644 index 1052ac4b..00000000 --- a/src/LogExpert.Core/Classes/Highlight/HilightMatchEntry.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace LogExpert.Core.Classes.Highlight; - -/// -/// Class for storing word-wise hilight matches. Used for colouring different matches on one line. -/// -public class HilightMatchEntry -{ - #region Properties - - public HighlightEntry HilightEntry { get; set; } - - public int StartPos { get; set; } - - public int Length { get; set; } - - #endregion - - #region Public methods - - public override string ToString() - { - return $"{HilightEntry.SearchText}/{StartPos}/{Length}"; - } - - #endregion -} \ No newline at end of file diff --git a/src/LogExpert.Core/Config/ColorMode.cs b/src/LogExpert.Core/Config/ColorMode.cs index b8297b95..02a0c876 100644 --- a/src/LogExpert.Core/Config/ColorMode.cs +++ b/src/LogExpert.Core/Config/ColorMode.cs @@ -1,5 +1,4 @@ -using System.Drawing; -using System.Runtime.InteropServices; +using System.Drawing; namespace LogExpert.Core.Config; @@ -10,8 +9,8 @@ public static class ColorMode private static readonly Color BrightBookmarkDefaultSystemColor = SystemColors.Control; // Important: only supports SystemColors private static readonly Color LessBrightBackgroundColor = Color.FromArgb(208, 205, 206); private static readonly Color BrightBackgroundColor = Color.FromArgb(221, 221, 221); - private static readonly Color BrighterBackgroundColor = Color.FromArgb(253, 253, 253); - private static readonly Color BrightForeColor = Color.FromArgb(0, 0, 0); + private static readonly Color BrighterBackgroundColor = Color.White; + private static readonly Color BrightForeColor = Color.Black; // Dark Theme // https://paletton.com/#uid=15-0u0k005U0670008J003Y003Y @@ -20,7 +19,7 @@ public static class ColorMode private static readonly Color LessDarkBackgroundColor = Color.FromArgb(67, 67, 67); private static readonly Color DarkBackgroundColor = Color.FromArgb(45, 45, 45); private static readonly Color DarkerBackgroundColor = Color.FromArgb(30, 30, 30); - private static readonly Color DarkForeColor = Color.FromArgb(255, 255, 255); + private static readonly Color DarkForeColor = Color.White; // Default public static Color BackgroundColor = BrightBackgroundColor; @@ -35,7 +34,7 @@ public static class ColorMode public static bool DarkModeEnabled; - public static void LoadColorMode(bool darkMode) + public static void LoadColorMode (bool darkMode) { if (darkMode) { @@ -47,7 +46,7 @@ public static void LoadColorMode(bool darkMode) } } - private static void SetDarkMode() + private static void SetDarkMode () { BackgroundColor = DarkBackgroundColor; ForeColor = DarkForeColor; @@ -61,7 +60,7 @@ private static void SetDarkMode() DarkModeEnabled = true; } - private static void SetBrightMode() + private static void SetBrightMode () { BackgroundColor = BrightBackgroundColor; ForeColor = BrightForeColor; diff --git a/src/LogExpert.Core/Interface/ISharedToolWindow.cs b/src/LogExpert.Core/Interface/ISharedToolWindow.cs index 1d2a80e8..6c091cae 100644 --- a/src/LogExpert.Core/Interface/ISharedToolWindow.cs +++ b/src/LogExpert.Core/Interface/ISharedToolWindow.cs @@ -1,4 +1,4 @@ -using LogExpert.Core.Config; +using LogExpert.Core.Config; namespace LogExpert.Core.Interface; @@ -15,16 +15,16 @@ public interface ISharedToolWindow /// Called when a file becomes the active file (e.g. when user selects a tab). /// /// - void SetCurrentFile(IFileViewContext ctx); + void SetCurrentFile (IFileViewContext ctx); /// /// Called whenever the current file has been changed. /// - void FileChanged(); + void FileChanged (); - void SetColumnizer(ILogLineColumnizer columnizer); + void SetColumnizer (ILogLineColumnizer columnizer); - void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags); + void PreferencesChanged (string fontName, float fontSize, bool setLastColumnWidth, int lastColumnWidth, SettingsFlags flags); #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index 34e04cc6..1cb86faf 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -32,14 +32,14 @@ public partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILog private const int SPREAD_MAX = 99; private const int PROGRESS_BAR_MODULO = 1000; private const int FILTER_ADVANCED_SPLITTER_DISTANCE = 150; - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); private readonly Image _advancedButtonImage; private readonly object _bookmarkLock = new(); private readonly BookmarkDataProvider _bookmarkProvider = new(); - private readonly IList _cancelHandlerList = new List(); + private readonly IList _cancelHandlerList = []; private readonly object _currentColumnizerLock = new(); @@ -47,7 +47,7 @@ public partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILog private readonly EventWaitHandle _externaLoadingFinishedEvent = new ManualResetEvent(false); - private readonly IList _filterPipeList = new List(); + private readonly IList _filterPipeList = []; private readonly Dictionary _freezeStateMap = []; private readonly GuiStateArgs _guiStateArgs = new(); @@ -141,10 +141,11 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp { SuspendLayout(); + //HighDPI Functionality must be called before all UI Elements are initialized, to make sure they work as intended AutoScaleDimensions = new SizeF(96F, 96F); AutoScaleMode = AutoScaleMode.Dpi; - InitializeComponent(); //TODO: Move this to be the first line of the constructor? + InitializeComponent(); CreateDefaultViewStyle(); @@ -210,15 +211,9 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp _timeShiftSyncTask = new Task(SyncTimestampDisplayWorker, cts.Token); _timeShiftSyncTask.Start(); - //_timeShiftSyncThread = new Thread(SyncTimestampDisplayWorker); - //_timeShiftSyncThread.IsBackground = true; - //_timeShiftSyncThread.Start(); _logEventHandlerTask = new Task(LogEventWorker, cts.Token); _logEventHandlerTask.Start(); - //_logEventHandlerThread = new Thread(LogEventWorker); - //_logEventHandlerThread.IsBackground = true; - //_logEventHandlerThread.Start(); //this.filterUpdateThread = new Thread(new ThreadStart(this.FilterUpdateWorker)); //this.filterUpdateThread.Start(); @@ -355,7 +350,7 @@ public void ChangeTheme (Control.ControlCollection container) for (var y = 0; y < filterContextMenuStrip.Items.Count; y++) { - var item = filterContextMenuStrip.Items[y]; + ToolStripItem item = filterContextMenuStrip.Items[y]; item.ForeColor = ColorMode.ForeColor; item.BackColor = ColorMode.MenuBackgroundColor; } @@ -482,18 +477,9 @@ public bool IsMultiFile internal FilterPipe FilterPipe { get; set; } - public string Title - { - get - { - if (IsTempFile) - { - return TempTitleName; - } - - return FileName; - } - } + public string Title => IsTempFile + ? TempTitleName + : FileName; public ColumnizerCallback ColumnizerCallbackObject { get; } @@ -501,7 +487,7 @@ public string Title public string ForcedPersistenceFileName { get; set; } - public Preferences Preferences => ConfigManager.Settings.Preferences; + public Preferences Preferences => _parentLogTabWin.Preferences; public string GivenFileName { get; set; } @@ -601,11 +587,13 @@ internal void ChangeMultifileMask () internal void ToggleColumnFinder (bool show, bool setFocus) { _guiStateArgs.ColumnFinderVisible = show; + if (show) { columnComboBox.AutoCompleteMode = AutoCompleteMode.Suggest; columnComboBox.AutoCompleteSource = AutoCompleteSource.CustomSource; columnComboBox.AutoCompleteCustomSource = [.. CurrentColumnizer.GetColumnNames()]; + if (setFocus) { columnComboBox.Focus(); diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs index 40d1647c..2b8e367a 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs @@ -104,7 +104,12 @@ protected void OnDeRegisterCancelHandler (IBackgroundProcessCancelHandler handle [SupportedOSPlatform("windows")] private void OnLogWindowLoad (object sender, EventArgs e) { - PreferencesChanged(_parentLogTabWin.Preferences, true, SettingsFlags.GuiOrColors); + var setLastColumnWidth = _parentLogTabWin.Preferences.SetLastColumnWidth; + var lastColumnWidth = _parentLogTabWin.Preferences.LastColumnWidth; + var fontName = _parentLogTabWin.Preferences.FontName; + var fontSize = _parentLogTabWin.Preferences.FontSize; + + PreferencesChanged(fontName, fontSize, setLastColumnWidth, lastColumnWidth, true, SettingsFlags.GuiOrColors); } [SupportedOSPlatform("windows")] diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs index 49b9f505..26c441e8 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs @@ -590,7 +590,12 @@ private void LoadingFinished () _statusEventArgs.FileSize = _logFileReader.FileSize; SendStatusLineUpdate(); - PreferencesChanged(_parentLogTabWin.Preferences, true, SettingsFlags.All); + var setLastColumnWidth = _parentLogTabWin.Preferences.SetLastColumnWidth; + var lastColumnWidth = _parentLogTabWin.Preferences.LastColumnWidth; + var fontName = _parentLogTabWin.Preferences.FontName; + var fontSize = _parentLogTabWin.Preferences.FontSize; + + PreferencesChanged(fontName, fontSize, setLastColumnWidth, lastColumnWidth, true, SettingsFlags.All); //LoadPersistenceData(); } @@ -1092,21 +1097,18 @@ private void AutoResizeColumns (BufferedDataGridView gridView) } } - private void PaintCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, - HighlightEntry groundEntry) + private void PaintCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) { PaintHighlightedCell(e, gridView, noBackgroundFill, groundEntry); } - private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, - bool noBackgroundFill, - HighlightEntry groundEntry) + private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) { var column = e.Value as IColumn; column ??= Column.EmptyColumn; - IList matchList = FindHighlightMatches(column); + IList matchList = FindHighlightMatches(column); // too many entries per line seem to cause problems with the GDI while (matchList.Count > 50) { @@ -1121,23 +1123,23 @@ private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, Buffered IsWordMatch = true }; - HilightMatchEntry hme = new() + HighlightMatchEntry hme = new() { StartPos = 0, Length = column.DisplayValue.Length, - HilightEntry = he + HighlightEntry = he }; if (groundEntry != null) { - hme.HilightEntry.IsBold = groundEntry.IsBold; + hme.HighlightEntry.IsBold = groundEntry.IsBold; } matchList = MergeHighlightMatchEntries(matchList, hme); - var leftPad = e.CellStyle.Padding.Left; - RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, - e.CellBounds.Height); + //var leftPad = e.CellStyle.Padding.Left; + //RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, e.CellBounds.Height); + Rectangle borderWidths = PaintHelper.BorderWidths(e.AdvancedBorderStyle); Rectangle valBounds = e.CellBounds; valBounds.Offset(borderWidths.X, borderWidths.Y); @@ -1172,21 +1174,23 @@ private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, Buffered Rectangle r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); e.Graphics.SetClip(e.CellBounds); - foreach (HilightMatchEntry matchEntry in matchList) + foreach (HighlightMatchEntry matchEntry in matchList) { - Font font = matchEntry != null && matchEntry.HilightEntry.IsBold ? BoldFont : NormalFont; - Brush bgBrush = matchEntry.HilightEntry.BackgroundColor != Color.Empty - ? new SolidBrush(matchEntry.HilightEntry.BackgroundColor) + Font font = matchEntry != null && matchEntry.HighlightEntry.IsBold ? BoldFont : NormalFont; + + Brush bgBrush = matchEntry.HighlightEntry.BackgroundColor != Color.Empty + ? new SolidBrush(matchEntry.HighlightEntry.BackgroundColor) : null; + var matchWord = column.DisplayValue.Substring(matchEntry.StartPos, matchEntry.Length); Size wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags); wordSize.Height = e.CellBounds.Height; Rectangle wordRect = new(wordPos, wordSize); - Color foreColor = matchEntry.HilightEntry.ForegroundColor; + Color foreColor = matchEntry.HighlightEntry.ForegroundColor; if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected) { - if (!noBackgroundFill && bgBrush != null && !matchEntry.HilightEntry.NoBackground) + if (!noBackgroundFill && bgBrush != null && !matchEntry.HighlightEntry.NoBackground) { e.Graphics.FillRectangle(bgBrush, wordRect); } @@ -1197,8 +1201,7 @@ private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, Buffered foreColor = ColorMode.ForeColor; } - TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, - foreColor, flags); + TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, foreColor, flags); wordPos.Offset(wordSize.Width, 0); bgBrush?.Dispose(); @@ -1214,26 +1217,25 @@ private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, Buffered /// List of all highlight matches for the current cell /// The entry that is used as the default. /// List of HilightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring. - private IList MergeHighlightMatchEntries (IList matchList, - HilightMatchEntry groundEntry) + private IList MergeHighlightMatchEntries (IList matchList, HighlightMatchEntry groundEntry) { // Fill an area with lenth of whole text with a default hilight entry var entryArray = new HighlightEntry[groundEntry.Length]; for (var i = 0; i < entryArray.Length; ++i) { - entryArray[i] = groundEntry.HilightEntry; + entryArray[i] = groundEntry.HighlightEntry; } // "overpaint" with all matching word match enries // Non-word-mode matches will not overpaint because they use the groundEntry - foreach (HilightMatchEntry me in matchList) + foreach (HighlightMatchEntry me in matchList) { var endPos = me.StartPos + me.Length; for (var i = me.StartPos; i < endPos; ++i) { - if (me.HilightEntry.IsWordMatch) + if (me.HighlightEntry.IsWordMatch) { - entryArray[i] = me.HilightEntry; + entryArray[i] = me.HighlightEntry; } else { @@ -1243,7 +1245,7 @@ private IList MergeHighlightMatchEntries (IList mergedList = []; + IList mergedList = []; if (entryArray.Length > 0) { @@ -1255,11 +1257,11 @@ private IList MergeHighlightMatchEntries (IList MergeHighlightMatchEntries (IList FindMatchingHilightEntries (ITextValue line) return resultList; } - private void GetHighlightEntryMatches (ITextValue line, IList hilightEntryList, IList resultList) + private void GetHighlightEntryMatches (ITextValue line, IList hilightEntryList, IList resultList) { foreach (HighlightEntry entry in hilightEntryList) { @@ -1357,9 +1359,9 @@ private void GetHighlightEntryMatches (ITextValue line, IList hi MatchCollection matches = entry.Regex.Matches(line.Text); foreach (Match match in matches) { - HilightMatchEntry me = new() + HighlightMatchEntry me = new() { - HilightEntry = entry, + HighlightEntry = entry, StartPos = match.Index, Length = match.Length }; @@ -1371,9 +1373,9 @@ private void GetHighlightEntryMatches (ITextValue line, IList hi { if (CheckHighlightEntryMatch(entry, line)) { - HilightMatchEntry me = new() + HighlightMatchEntry me = new() { - HilightEntry = entry, + HighlightEntry = entry, StartPos = 0, Length = line.Text.Length }; @@ -1702,7 +1704,7 @@ private void SelectLine (int line, bool triggerSyncCall, bool shouldScroll) var wasCancelled = _shouldCancel; _shouldCancel = false; _isSearching = false; - StatusLineText(""); + StatusLineText(string.Empty); _guiStateArgs.MenuEnabled = true; if (wasCancelled) @@ -2934,13 +2936,13 @@ private void SetExplicitEncoding (Encoding encoding) } [SupportedOSPlatform("windows")] - private void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, Preferences prefs) + private void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, bool setLastColumnWidth, int lastColumnWidth) { if (dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) > 1) { - if (prefs.SetLastColumnWidth) + if (setLastColumnWidth) { - dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].MinimumWidth = prefs.LastColumnWidth; + dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].MinimumWidth = lastColumnWidth; } else { diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs index 7b3ae108..7e20d28e 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs @@ -523,6 +523,7 @@ public HighlightEntry FindHighlightEntry (ITextValue line, bool noWordMatches) { continue; } + if (CheckHighlightEntryMatch(entry, line)) { return entry; @@ -547,9 +548,10 @@ public HighlightEntry FindHighlightEntry (ITextValue line, bool noWordMatches) } } - public IList FindHighlightMatches (ITextValue column) + public IList FindHighlightMatches (ITextValue column) { - IList resultList = new List(); + IList resultList = []; + if (column != null) { lock (_currentHighlightGroupLock) @@ -681,6 +683,7 @@ public void SelectAndEnsureVisible (int line, bool triggerSyncCall) dataGridView.FirstDisplayedScrollingRowIndex += 1; } } + dataGridView.CurrentCell = dataGridView.Rows[line].Cells[0]; } catch (Exception e) @@ -817,6 +820,7 @@ public void AddBookmarkOverlays () break; } } + if (_bookmarkProvider.IsBookmarkAtLine(i)) { Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(i); @@ -844,6 +848,7 @@ public void AddBookmarkOverlays () //heightSum += rr.Height; heightSum += GetRowHeight(rn); } + r.Offset(0, r.Height + heightSum); } else @@ -854,14 +859,17 @@ public void AddBookmarkOverlays () //heightSum += rr.Height; heightSum += GetRowHeight(rn); } + r.Offset(0, -(r.Height + heightSum)); } //r.Offset(0, this.dataGridView.DisplayRectangle.Height); } + if (_logger.IsDebugEnabled) { - _logger.Debug("AddBookmarkOverlay() r.Location={0}, width={1}, scroll_offset={2}", r.Location.X, r.Width, dataGridView.HorizontalScrollingOffset); + _logger.Debug($"AddBookmarkOverlay() r.Location={r.Location.X}, width={r.Width}, scroll_offset={dataGridView.HorizontalScrollingOffset}"); } + overlay.Position = r.Location - new Size(dataGridView.HorizontalScrollingOffset, 0); overlay.Position += new Size(10, r.Height / 2); dataGridView.AddOverlay(overlay); @@ -1137,11 +1145,13 @@ public void LogWindowActivated () { OnTailFollowed(EventArgs.Empty); } + if (Preferences.TimestampControl) { SetTimestampLimits(); SyncTimestampDisplay(); } + dataGridView.Focus(); SendGuiStateUpdate(); @@ -1260,11 +1270,11 @@ public void Reload () //} } - public void PreferencesChanged (Preferences newPreferences, bool isLoadTime, SettingsFlags flags) + public void PreferencesChanged (string fontName, float fontSize, bool setLastColumnWidth, int lastColumnWidth, bool isLoadTime, SettingsFlags flags) { if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors) { - NormalFont = new Font(new FontFamily(newPreferences.FontName), newPreferences.FontSize); + NormalFont = new Font(new FontFamily(fontName), fontSize); BoldFont = new Font(NormalFont, FontStyle.Bold); MonospacedFont = new Font("Courier New", Preferences.FontSize, FontStyle.Bold); @@ -1278,14 +1288,15 @@ public void PreferencesChanged (Preferences newPreferences, bool isLoadTime, Set ShowBookmarkBubbles = Preferences.ShowBubbles; - ApplyDataGridViewPrefs(dataGridView, newPreferences); - ApplyDataGridViewPrefs(filterGridView, newPreferences); + ApplyDataGridViewPrefs(dataGridView, setLastColumnWidth, lastColumnWidth); + ApplyDataGridViewPrefs(filterGridView, setLastColumnWidth, lastColumnWidth); if (Preferences.TimestampControl) { SetTimestampLimits(); SyncTimestampDisplay(); } + if (isLoadTime) { filterTailCheckBox.Checked = Preferences.FilterTail; @@ -1296,11 +1307,13 @@ public void PreferencesChanged (Preferences newPreferences, bool isLoadTime, Set _timeSpreadCalc.TimeMode = Preferences.TimeSpreadTimeMode; timeSpreadingControl.ForeColor = Preferences.TimeSpreadColor; timeSpreadingControl.ReverseAlpha = Preferences.ReverseAlpha; + if (CurrentColumnizer.IsTimeshiftImplemented()) { timeSpreadingControl.Invoke(new MethodInvoker(timeSpreadingControl.Refresh)); ShowTimeSpread(Preferences.ShowTimeSpread); } + ToggleColumnFinder(Preferences.ShowColumnFinder, false); } diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs index 0ee8d848..7b958d41 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs @@ -38,7 +38,7 @@ public BookmarkWindow () AutoScaleMode = AutoScaleMode.Dpi; bookmarkDataGridView.CellValueNeeded += OnBoomarkDataGridViewCellValueNeeded; - bookmarkDataGridView.CellPainting += boomarkDataGridView_CellPainting; + bookmarkDataGridView.CellPainting += OnBoomarkDataGridViewCellPainting; ChangeTheme(Controls); } @@ -196,28 +196,20 @@ public void SetBookmarkData (IBookmarkData bookmarkData) HideIfNeeded(); } - //TODO: BAD DESIGN! FIX!!! - public void PreferencesChanged (Preferences newPreferences, bool isLoadTime, SettingsFlags flags, IConfigManager configManager) + public void PreferencesChanged (string fontName, float fontSize, bool setLastColumnWidth, int lastColumnWidth, SettingsFlags flags) { if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors) { - SetFont(newPreferences.FontName, newPreferences.FontSize); - if (bookmarkDataGridView.Columns.Count > 1 && newPreferences.SetLastColumnWidth) + SetFont(fontName, fontSize); + if (bookmarkDataGridView.Columns.Count > 1 && setLastColumnWidth) { - bookmarkDataGridView.Columns[bookmarkDataGridView.Columns.Count - 1].MinimumWidth = - newPreferences.LastColumnWidth; + bookmarkDataGridView.Columns[bookmarkDataGridView.Columns.Count - 1].MinimumWidth = lastColumnWidth; } - PaintHelper.ApplyDataGridViewPrefs(bookmarkDataGridView, newPreferences, configManager); + PaintHelper.ApplyDataGridViewPrefs(bookmarkDataGridView, setLastColumnWidth, lastColumnWidth); } } - //TODO: BAD DESIGN! FIX!!! - public void PreferencesChanged (Preferences newPreferences, bool isLoadTime, SettingsFlags flags) - { - PreferencesChanged(newPreferences, isLoadTime, flags, null); - } - public void SetCurrentFile (IFileViewContext ctx) { if (ctx != null) @@ -260,10 +252,13 @@ protected override void OnPaint (PaintEventArgs e) { Rectangle r = ClientRectangle; e.Graphics.FillRectangle(SystemBrushes.FromSystemColor(ColorMode.BookmarksDefaultBackgroundColor), r); - RectangleF rect = r; - StringFormat sf = new(); - sf.Alignment = StringAlignment.Center; - sf.LineAlignment = StringAlignment.Center; + + StringFormat sf = new() + { + Alignment = StringAlignment.Center, + LineAlignment = StringAlignment.Center + }; + e.Graphics.DrawString("No bookmarks in current file", SystemFonts.DialogFont, SystemBrushes.WindowText, r, sf); } else @@ -369,7 +364,7 @@ private void HideIfNeeded () #region Events handler - private void boomarkDataGridView_CellPainting (object sender, DataGridViewCellPaintingEventArgs e) + private void OnBoomarkDataGridViewCellPainting (object sender, DataGridViewCellPaintingEventArgs e) { if (bookmarkData == null) { diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs index ec93bd35..da96280d 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs @@ -73,7 +73,12 @@ private void InitBookmarkWindow () ShowHint = DockState.DockBottom }; - _bookmarkWindow.PreferencesChanged(ConfigManager.Settings.Preferences, false, SettingsFlags.All, ConfigManager.Instance); + var setLastColumnWidth = ConfigManager.Settings.Preferences.SetLastColumnWidth; + var lastColumnWidth = ConfigManager.Settings.Preferences.LastColumnWidth; + var fontName = ConfigManager.Settings.Preferences.FontName; + var fontSize = ConfigManager.Settings.Preferences.FontSize; + + _bookmarkWindow.PreferencesChanged(fontName, fontSize, setLastColumnWidth, lastColumnWidth, SettingsFlags.All); _bookmarkWindow.VisibleChanged += OnBookmarkWindowVisibleChanged; _firstBookmarkWindowShow = true; } @@ -966,15 +971,20 @@ private void NotifyWindowsForChangedPrefs (SettingsFlags flags) _logger.Info("The preferences have changed"); ApplySettings(ConfigManager.Settings, flags); + var setLastColumnWidth = ConfigManager.Settings.Preferences.SetLastColumnWidth; + var lastColumnWidth = ConfigManager.Settings.Preferences.LastColumnWidth; + var fontName = ConfigManager.Settings.Preferences.FontName; + var fontSize = ConfigManager.Settings.Preferences.FontSize; + lock (_logWindowList) { foreach (LogWindow.LogWindow logWindow in _logWindowList) { - logWindow.PreferencesChanged(ConfigManager.Settings.Preferences, false, flags); + logWindow.PreferencesChanged(fontName, fontSize, setLastColumnWidth, lastColumnWidth, false, flags); } } - _bookmarkWindow.PreferencesChanged(ConfigManager.Settings.Preferences, false, flags); + _bookmarkWindow.PreferencesChanged(fontName, fontSize, setLastColumnWidth, lastColumnWidth, flags); HighlightGroupList = ConfigManager.Settings.Preferences.HighlightGroupList; if ((flags & SettingsFlags.HighlightSettings) == SettingsFlags.HighlightSettings) diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index 4d760cde..c1f9c9e5 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -3,7 +3,6 @@ using LogExpert.Core.Classes.Highlight; using LogExpert.Core.Config; using LogExpert.Core.Entities; -using LogExpert.Core.Interface; using LogExpert.Dialogs; using LogExpert.UI.Controls; using LogExpert.UI.Interface; @@ -18,49 +17,46 @@ internal static class PaintHelper { #region Fields - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); //TODO Make configurable private static Color _bookmarkColor = Color.FromArgb(165, 200, 225); #endregion - #region Properties - public static IConfigManager ConfigManager { get; set; } - - private static Preferences Preferences => ConfigManager.Settings.Preferences; - - #endregion - #region Public methods [SupportedOSPlatform("windows")] - public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGridView gridView, int rowIndex, - DataGridViewCellPaintingEventArgs e) + public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) { if (rowIndex < 0 || e.ColumnIndex < 0) { e.Handled = false; return; } + ILogLine line = logPaintCtx.GetLogLine(rowIndex); + if (line != null) { HighlightEntry entry = logPaintCtx.FindHighlightEntry(line, true); e.Graphics.SetClip(e.CellBounds); + if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) { Color backColor = e.CellStyle.SelectionBackColor; Brush brush; + if (gridView.Focused) { - brush = new SolidBrush(e.CellStyle.SelectionBackColor); + brush = new SolidBrush(backColor); } else { var color = Color.FromArgb(255, 170, 170, 170); brush = new SolidBrush(color); } + e.Graphics.FillRectangle(brush, e.CellBounds); brush.Dispose(); } @@ -81,6 +77,7 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri bgColor = entry.BackgroundColor; } } + e.CellStyle.BackColor = bgColor; e.PaintBackground(e.ClipBounds, false); } @@ -112,10 +109,10 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }; + Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); Font font = logPaintCtx.MonospacedFont; - e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), - format); + e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); brush2.Dispose(); } } @@ -191,16 +188,17 @@ public static void SetColumnizer (ILogLineColumnizer columnizer, BufferedDataGri _logger.Error(ae); } - gridView.Columns.Add(CreateMarkerColumn()); + _ = gridView.Columns.Add(CreateMarkerColumn()); - gridView.Columns.Add(CreateLineNumberColumn()); + _ = gridView.Columns.Add(CreateLineNumberColumn()); foreach (var colName in columnizer.GetColumnNames()) { - gridView.Columns.Add(CreateTitleColumn(colName)); + _ = gridView.Columns.Add(CreateTitleColumn(colName)); } gridView.RowCount = rowCount; + if (currLine != -1) { gridView.CurrentCell = gridView.Rows[currLine].Cells[0]; @@ -210,25 +208,23 @@ public static void SetColumnizer (ILogLineColumnizer columnizer, BufferedDataGri { gridView.FirstDisplayedScrollingRowIndex = currFirstLine; } + //gridView.Refresh(); //AutoResizeColumns(gridView); } - //TODO: Original name is AutoResizeColumn. Where is this used? - //TODO: Rename ConfigManager to configManager [SupportedOSPlatform("windows")] - private static void AutoResizeColumns (BufferedDataGridView gridView, IConfigManager configManager) + private static void AutoResizeColumns (BufferedDataGridView gridView, bool setLastColumnWidth, int lastColumnWidth) { try { gridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - if (gridView.Columns.Count > 1 && Preferences.SetLastColumnWidth && - gridView.Columns[gridView.Columns.Count - 1].Width < Preferences.LastColumnWidth + if (gridView.Columns.Count > 1 && setLastColumnWidth && gridView.Columns[gridView.Columns.Count - 1].Width < lastColumnWidth ) { // It seems that using 'MinimumWidth' instead of 'Width' prevents the DataGridView's NullReferenceExceptions //gridView.Columns[gridView.Columns.Count - 1].Width = this.Preferences.lastColumnWidth; - gridView.Columns[gridView.Columns.Count - 1].MinimumWidth = Preferences.LastColumnWidth; + gridView.Columns[gridView.Columns.Count - 1].MinimumWidth = lastColumnWidth; } } catch (NullReferenceException e) @@ -242,16 +238,13 @@ private static void AutoResizeColumns (BufferedDataGridView gridView, IConfigMan } [SupportedOSPlatform("windows")] - public static void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, Preferences prefs, IConfigManager configManager) + public static void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, bool setLastColumnWidht, int lastColumnWidth) { - //TODO: This is a very bad solution and should be solved ASAP - ConfigManager ??= configManager; - if (dataGridView.Columns.Count > 1) { - if (prefs.SetLastColumnWidth) + if (setLastColumnWidht) { - dataGridView.Columns[dataGridView.Columns.Count - 1].MinimumWidth = prefs.LastColumnWidth; + dataGridView.Columns[dataGridView.Columns.Count - 1].MinimumWidth = lastColumnWidth; } else { @@ -269,7 +262,7 @@ public static void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, Pr dataGridView.Invalidate(); dataGridView.Refresh(); - AutoResizeColumns(dataGridView, ConfigManager); + AutoResizeColumns(dataGridView, setLastColumnWidht, lastColumnWidth); } [SupportedOSPlatform("windows")] @@ -279,29 +272,26 @@ public static Rectangle BorderWidths (DataGridViewAdvancedBorderStyle advancedBo { X = advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1 }; - if (advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.OutsetDouble || - advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.InsetDouble) + if (advancedBorderStyle.Left is DataGridViewAdvancedCellBorderStyle.OutsetDouble or DataGridViewAdvancedCellBorderStyle.InsetDouble) { rect.X++; } rect.Y = advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; - if (advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.OutsetDouble || - advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.InsetDouble) + if (advancedBorderStyle.Top is DataGridViewAdvancedCellBorderStyle.OutsetDouble or DataGridViewAdvancedCellBorderStyle.InsetDouble) { rect.Y++; } rect.Width = advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; - if (advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.OutsetDouble || - advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.InsetDouble) + if (advancedBorderStyle.Right is DataGridViewAdvancedCellBorderStyle.OutsetDouble or DataGridViewAdvancedCellBorderStyle.InsetDouble) { rect.Width++; } rect.Height = advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; - if (advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.OutsetDouble || - advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.InsetDouble) + if (advancedBorderStyle.Bottom is DataGridViewAdvancedCellBorderStyle.OutsetDouble or + DataGridViewAdvancedCellBorderStyle.InsetDouble) { rect.Height++; } @@ -327,7 +317,7 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr { var value = e.Value ?? string.Empty; - IList matchList = logPaintCtx.FindHighlightMatches(value as ILogLine); + IList matchList = logPaintCtx.FindHighlightMatches(value as ILogLine); // too many entries per line seem to cause problems with the GDI while (matchList.Count > 50) { @@ -338,7 +328,7 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr { if (!string.IsNullOrEmpty(column.FullValue)) { - HilightMatchEntry hme = new() + HighlightMatchEntry hme = new() { StartPos = 0, Length = column.FullValue.Length @@ -358,7 +348,7 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr IsWordMatch = false }; - hme.HilightEntry = he; + hme.HighlightEntry = he; matchList = MergeHighlightMatchEntries(matchList, hme); } @@ -399,14 +389,14 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr Rectangle r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); e.Graphics.SetClip(e.CellBounds); - foreach (HilightMatchEntry matchEntry in matchList) + foreach (HighlightMatchEntry matchEntry in matchList) { - Font font = matchEntry != null && matchEntry.HilightEntry.IsBold + Font font = matchEntry != null && matchEntry.HighlightEntry.IsBold ? logPaintCtx.BoldFont : logPaintCtx.NormalFont; - Brush bgBrush = matchEntry.HilightEntry.BackgroundColor != Color.Empty - ? new SolidBrush(matchEntry.HilightEntry.BackgroundColor) + Brush bgBrush = matchEntry.HighlightEntry.BackgroundColor != Color.Empty + ? new SolidBrush(matchEntry.HighlightEntry.BackgroundColor) : null; var matchWord = string.Empty; @@ -422,10 +412,10 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr wordSize.Height = e.CellBounds.Height; Rectangle wordRect = new(wordPos, wordSize); - Color foreColor = matchEntry.HilightEntry.ForegroundColor; + Color foreColor = matchEntry.HighlightEntry.ForegroundColor; if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected) { - if (!noBackgroundFill && bgBrush != null && !matchEntry.HilightEntry.NoBackground) + if (!noBackgroundFill && bgBrush != null && !matchEntry.HighlightEntry.NoBackground) { e.Graphics.FillRectangle(bgBrush, wordRect); } @@ -455,25 +445,25 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr /// List of all highlight matches for the current cell /// The entry that is used as the default. /// List of HilightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring. - private static IList MergeHighlightMatchEntries (IList matchList, HilightMatchEntry groundEntry) + private static IList MergeHighlightMatchEntries (IList matchList, HighlightMatchEntry groundEntry) { // Fill an area with lenth of whole text with a default hilight entry var entryArray = new HighlightEntry[groundEntry.Length]; for (var i = 0; i < entryArray.Length; ++i) { - entryArray[i] = groundEntry.HilightEntry; + entryArray[i] = groundEntry.HighlightEntry; } // "overpaint" with all matching word match enries // Non-word-mode matches will not overpaint because they use the groundEntry - foreach (HilightMatchEntry me in matchList) + foreach (HighlightMatchEntry me in matchList) { var endPos = me.StartPos + me.Length; for (var i = me.StartPos; i < endPos; ++i) { - if (me.HilightEntry.IsWordMatch) + if (me.HighlightEntry.IsWordMatch) { - entryArray[i] = me.HilightEntry; + entryArray[i] = me.HighlightEntry; } //else //{ @@ -483,7 +473,7 @@ private static IList MergeHighlightMatchEntries (IList mergedList = []; + IList mergedList = []; if (entryArray.Length > 0) { HighlightEntry currentEntry = entryArray[0]; @@ -493,22 +483,22 @@ private static IList MergeHighlightMatchEntries (IList FindHighlightMatches(ITextValue line); + IList FindHighlightMatches(ITextValue line); #endregion } \ No newline at end of file diff --git a/src/LogExpert/Program.cs b/src/LogExpert/Program.cs index 95fa7dfe..971e3660 100644 --- a/src/LogExpert/Program.cs +++ b/src/LogExpert/Program.cs @@ -1,4 +1,12 @@ -using LogExpert.Classes; +using System.Diagnostics; +using System.IO.Pipes; +using System.Reflection; +using System.Security; +using System.Security.Principal; +using System.Text; +using System.Windows.Forms; + +using LogExpert.Classes; using LogExpert.Classes.CommandLine; using LogExpert.Config; using LogExpert.Core.Classes.IPC; @@ -13,14 +21,6 @@ using NLog; -using System.Diagnostics; -using System.IO.Pipes; -using System.Reflection; -using System.Security; -using System.Security.Principal; -using System.Text; -using System.Windows.Forms; - namespace LogExpert; internal static class Program @@ -39,7 +39,7 @@ internal static class Program /// The main entry point for the application. /// [STAThread] - private static void Main(string[] args) + private static void Main (string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.ThreadException += Application_ThreadException; @@ -49,7 +49,7 @@ private static void Main(string[] args) Application.EnableVisualStyles(); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); - _logger.Info("\r\n============================================================================\r\nLogExpert {0} started.\r\n============================================================================", Assembly.GetExecutingAssembly().GetName().Version.ToString(3)); + _logger.Info($"\r\n============================================================================\r\nLogExpert {Assembly.GetExecutingAssembly().GetName().Version.ToString(3)} started.\r\n============================================================================"); CancellationTokenSource cts = new(); try @@ -70,6 +70,7 @@ private static void Main(string[] args) MessageBox.Show(@"Config file not found", @"LogExpert"); } } + PluginRegistry.PluginRegistry.Instance.Create(ConfigManager.Instance.ConfigDir, ConfigManager.Instance.Settings.Preferences.PollingInterval); var pId = Process.GetCurrentProcess().SessionId; @@ -154,7 +155,7 @@ private static void Main(string[] args) } } - private static string SerializeCommandIntoNonFormattedJSON(string[] fileNames, bool allowOnlyOneInstance) + private static string SerializeCommandIntoNonFormattedJSON (string[] fileNames, bool allowOnlyOneInstance) { var message = new IpcMessage() { @@ -168,7 +169,7 @@ private static string SerializeCommandIntoNonFormattedJSON(string[] fileNames, b // This loop tries to convert relative file names into absolute file names (assuming that platform file names are given). // It tolerates errors, to give file system plugins (e.g. sftp) a change later. // TODO: possibly should be moved to LocalFileSystem plugin - private static string[] GenerateAbsoluteFilePaths(string[] remainingArgs) + private static string[] GenerateAbsoluteFilePaths (string[] remainingArgs) { List argsList = []; @@ -188,37 +189,40 @@ private static string[] GenerateAbsoluteFilePaths(string[] remainingArgs) return [.. argsList]; } - private static void SendMessageToProxy(IpcMessage message, LogExpertProxy proxy) + private static void SendMessageToProxy (IpcMessage message, LogExpertProxy proxy) { switch (message.Type) { case IpcMessageType.Load: { - var payLoad = message.Payload.ToObject(); + LoadPayload payLoad = message.Payload.ToObject(); if (CheckPayload(payLoad)) { proxy.LoadFiles([.. payLoad.Files]); } } + break; case IpcMessageType.NewWindow: { - var payLoad = message.Payload.ToObject(); + LoadPayload payLoad = message.Payload.ToObject(); if (CheckPayload(payLoad)) { proxy.NewWindow([.. payLoad.Files]); } } + break; case IpcMessageType.NewWindowOrLockedWindow: { - var payLoad = message.Payload.ToObject(); + LoadPayload payLoad = message.Payload.ToObject(); if (CheckPayload(payLoad)) { proxy.NewWindowOrLockedWindow([.. payLoad.Files]); } } + break; default: _logger.Error($"Unknown IPC Message Type {message.Type}"); @@ -226,7 +230,7 @@ private static void SendMessageToProxy(IpcMessage message, LogExpertProxy proxy) } } - private static bool CheckPayload(LoadPayload payLoad) + private static bool CheckPayload (LoadPayload payLoad) { if (payLoad == null) { @@ -237,7 +241,7 @@ private static bool CheckPayload(LoadPayload payLoad) return true; } - private static void SendCommandToServer(string command) + private static void SendCommandToServer (string command) { using var client = new NamedPipeClientStream(".", PIPE_SERVER_NAME, PipeDirection.Out); @@ -265,7 +269,7 @@ private static void SendCommandToServer(string command) writer.WriteLine(command); } - private static async Task RunServerLoopAsync(Action onCommand, LogExpertProxy proxy, CancellationToken cancellationToken) + private static async Task RunServerLoopAsync (Action onCommand, LogExpertProxy proxy, CancellationToken cancellationToken) { while (cancellationToken.IsCancellationRequested == false) { @@ -300,7 +304,7 @@ private static async Task RunServerLoopAsync(Action } [STAThread] - private static void ShowUnhandledException(object exceptionObject) + private static void ShowUnhandledException (object exceptionObject) { var errorText = string.Empty; string stackTrace; @@ -329,7 +333,7 @@ private static void ShowUnhandledException(object exceptionObject) #region Events handler - private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) + private static void Application_ThreadException (object sender, ThreadExceptionEventArgs e) { _logger.Fatal(e); @@ -343,7 +347,7 @@ private static void Application_ThreadException(object sender, ThreadExceptionEv thread.Join(); } - private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + private static void CurrentDomain_UnhandledException (object sender, UnhandledExceptionEventArgs e) { _logger.Fatal(e); From f8e884ee9199df4222edd0b81fafa8ed488ced18 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Thu, 12 Jun 2025 19:28:15 +0200 Subject: [PATCH 067/142] small optimizations --- .../Controls/BufferedDataGridView.Designer.cs | 56 +++++++++---------- .../Controls/BufferedDataGridView.cs | 17 +++--- .../Controls/LogWindow/LogWindow.designer.cs | 2 +- .../Controls/LogWindow/LogWindowPrivate.cs | 30 ++++++++-- .../Controls/LogWindow/LogWindowPublic.cs | 27 ++++++--- src/LogExpert.UI/Dialogs/BookmarkWindow.cs | 2 + .../LogTabWindow/LogTabWindowPublic.cs | 7 ++- .../Forms/LineToolStripSeparatorExtension.cs | 8 +-- src/LogExpert.UI/Extensions/Win32.cs | 23 ++++---- 9 files changed, 102 insertions(+), 70 deletions(-) diff --git a/src/LogExpert.UI/Controls/BufferedDataGridView.Designer.cs b/src/LogExpert.UI/Controls/BufferedDataGridView.Designer.cs index 694fce0a..f4908a0f 100644 --- a/src/LogExpert.UI/Controls/BufferedDataGridView.Designer.cs +++ b/src/LogExpert.UI/Controls/BufferedDataGridView.Designer.cs @@ -1,35 +1,35 @@ -namespace LogExpert.Dialogs; +namespace LogExpert.Dialogs; partial class BufferedDataGridView { -/// -/// Required designer variable. -/// -private System.ComponentModel.IContainer components = null; + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; -/// -/// Clean up any resources being used. -/// -/// true if managed resources should be disposed; otherwise, false. -protected override void Dispose(bool disposing) -{ - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); -} + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } -#region Component Designer generated code + #region Component Designer generated code -/// -/// Required method for Designer support - do not modify -/// the contents of this method with the code editor. -/// -private void InitializeComponent() -{ - components = new System.ComponentModel.Container(); -} + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } -#endregion -} + #endregion +} \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/BufferedDataGridView.cs b/src/LogExpert.UI/Controls/BufferedDataGridView.cs index c52e73bc..3f160823 100644 --- a/src/LogExpert.UI/Controls/BufferedDataGridView.cs +++ b/src/LogExpert.UI/Controls/BufferedDataGridView.cs @@ -14,10 +14,10 @@ public partial class BufferedDataGridView : DataGridView { #region Fields - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); private readonly Brush _brush; - private readonly Color _bubbleColor = Color.FromArgb(160, 250, 250, 00); + private readonly Color _bubbleColor = Color.FromArgb(160, 250, 250, 0); private readonly Font _font = new("Arial", 10); private readonly SortedList _overlayList = []; @@ -230,9 +230,11 @@ private void PaintOverlays (PaintEventArgs e) base.OnPaint(args); - StringFormat format = new(); - format.LineAlignment = StringAlignment.Center; - format.Alignment = StringAlignment.Near; + StringFormat format = new() + { + LineAlignment = StringAlignment.Center, + Alignment = StringAlignment.Near + }; myBuffer.Graphics.SetClip(DisplayRectangle, CombineMode.Intersect); @@ -247,8 +249,7 @@ private void PaintOverlays (PaintEventArgs e) foreach (BookmarkOverlay overlay in _overlayList.Values) { SizeF textSize = myBuffer.Graphics.MeasureString(overlay.Bookmark.Text, _font, 300); - Rectangle rectBubble = new(overlay.Position, - new Size((int)textSize.Width, (int)textSize.Height)); + Rectangle rectBubble = new(overlay.Position, new Size((int)textSize.Width, (int)textSize.Height)); rectBubble.Offset(60, -(rectBubble.Height + 40)); rectBubble.Inflate(3, 3); rectBubble.Location += overlay.Bookmark.OverlayOffset; @@ -264,7 +265,7 @@ private void PaintOverlays (PaintEventArgs e) if (_logger.IsDebugEnabled) { - _logger.Debug("ClipRgn: {0},{1},{2},{3}", myBuffer.Graphics.ClipBounds.Left, myBuffer.Graphics.ClipBounds.Top, myBuffer.Graphics.ClipBounds.Width, myBuffer.Graphics.ClipBounds.Height); + _logger.Debug($"ClipRgn: {myBuffer.Graphics.ClipBounds.Left},{myBuffer.Graphics.ClipBounds.Top},{myBuffer.Graphics.ClipBounds.Width},{myBuffer.Graphics.ClipBounds.Height}"); } } } diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs index 82822995..27d15a90 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs @@ -1,4 +1,4 @@ -using LogExpert.Dialogs; +using LogExpert.Dialogs; using LogExpert.UI.Extensions.Forms; using System; using System.Drawing; diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs index 26c441e8..e484a366 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs @@ -60,6 +60,21 @@ private void CreateDefaultViewStyle () dataGridViewCellStyleMainGrid.ForeColor = SystemColors.ControlText; dataGridViewCellStyleMainGrid.SelectionBackColor = SystemColors.Highlight; dataGridViewCellStyleMainGrid.SelectionForeColor = SystemColors.HighlightText; + + Color highlightColor = SystemColors.Highlight; + //Color is smaller than 128, means its darker + var isDark = (highlightColor.R * 0.2126) + (highlightColor.G * 0.7152) + (highlightColor.B * 0.0722) < 255 / 2; + + if (isDark) + { + dataGridViewCellStyleMainGrid.SelectionForeColor = Color.White; + } + else + { + dataGridViewCellStyleMainGrid.SelectionForeColor = Color.Black; + + } + dataGridViewCellStyleMainGrid.WrapMode = DataGridViewTriState.False; dataGridView.DefaultCellStyle = dataGridViewCellStyleMainGrid; @@ -69,6 +84,16 @@ private void CreateDefaultViewStyle () dataGridViewCellStyleFilterGrid.ForeColor = SystemColors.ControlText; dataGridViewCellStyleFilterGrid.SelectionBackColor = SystemColors.Highlight; dataGridViewCellStyleFilterGrid.SelectionForeColor = SystemColors.HighlightText; + + if (isDark) + { + dataGridViewCellStyleFilterGrid.SelectionForeColor = Color.White; + } + else + { + dataGridViewCellStyleFilterGrid.SelectionForeColor = Color.Black; + } + dataGridViewCellStyleFilterGrid.WrapMode = DataGridViewTriState.False; filterGridView.DefaultCellStyle = dataGridViewCellStyleFilterGrid; } @@ -1196,11 +1221,6 @@ private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, Buffered } } - if (foreColor == Color.Black) - { - foreColor = ColorMode.ForeColor; - } - TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, foreColor, flags); wordPos.Offset(wordSize.Width, 0); diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs index 7e20d28e..6dbcdabc 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs @@ -558,11 +558,13 @@ public IList FindHighlightMatches (ITextValue column) { GetHighlightEntryMatches(column, _currentHighlightGroup.HighlightEntryList, resultList); } + lock (_tempHighlightEntryList) { GetHighlightEntryMatches(column, _tempHighlightEntryList, resultList); } } + return resultList; } @@ -1193,6 +1195,7 @@ public void CopyMarkedLinesToTab () lineNumList.Add(row.Index); } } + lineNumList.Sort(); // create dummy FilterPipe for connecting line numbers to original window // setting IsStopped to true prevents further filter processing @@ -1390,6 +1393,7 @@ public int FindTimestampLine (int lineNum, DateTime timestamp, bool roundToSecon GetTimestampForLineForward(ref foundLine, roundToSeconds); // fwd to next valid timestamp return foundLine; } + return -foundLine; } @@ -1403,6 +1407,7 @@ public int FindTimestampLine_Internal (int lineNum, int rangeStart, int rangeEnd { return lineNum; } + if (timestamp < currentTimestamp) { //rangeStart = rangeStart; @@ -1419,7 +1424,7 @@ public int FindTimestampLine_Internal (int lineNum, int rangeStart, int rangeEnd return -lineNum; } - lineNum = (rangeEnd - rangeStart) / 2 + rangeStart; + lineNum = ((rangeEnd - rangeStart) / 2) + rangeStart; // prevent endless loop if (rangeEnd - rangeStart < 2) { @@ -1428,12 +1433,12 @@ public int FindTimestampLine_Internal (int lineNum, int rangeStart, int rangeEnd { return rangeStart; } + currentTimestamp = GetTimestampForLine(ref rangeEnd, roundToSeconds); - if (currentTimestamp.CompareTo(timestamp) == 0) - { - return rangeEnd; - } - return -lineNum; + + return currentTimestamp.CompareTo(timestamp) == 0 + ? rangeEnd + : -lineNum; } return FindTimestampLine_Internal(lineNum, rangeStart, rangeEnd, timestamp, roundToSeconds); @@ -1444,7 +1449,6 @@ public int FindTimestampLine_Internal (int lineNum, int rangeStart, int rangeEnd * has no timestamp, the previous line will be checked until a * timestamp is found. */ - public DateTime GetTimestampForLine (ref int lineNum, bool roundToSeconds) { lock (_currentColumnizerLock) @@ -1453,7 +1457,8 @@ public DateTime GetTimestampForLine (ref int lineNum, bool roundToSeconds) { return DateTime.MinValue; } - _logger.Debug("GetTimestampForLine({0}) enter", lineNum); + + _logger.Debug($"GetTimestampForLine({lineNum}) enter"); DateTime timeStamp = DateTime.MinValue; var lookBack = false; if (lineNum >= 0 && lineNum < dataGridView.RowCount) @@ -1464,25 +1469,30 @@ public DateTime GetTimestampForLine (ref int lineNum, bool roundToSeconds) { return DateTime.MinValue; } + lookBack = true; ILogLine logLine = _logFileReader.GetLogLine(lineNum); if (logLine == null) { return DateTime.MinValue; } + ColumnizerCallbackObject.LineNum = lineNum; timeStamp = CurrentColumnizer.GetTimestamp(ColumnizerCallbackObject, logLine); if (roundToSeconds) { timeStamp = timeStamp.Subtract(TimeSpan.FromMilliseconds(timeStamp.Millisecond)); } + lineNum--; } } + if (lookBack) { lineNum++; } + _logger.Debug("GetTimestampForLine() leave with lineNum={0}", lineNum); return timeStamp; } @@ -1493,7 +1503,6 @@ public DateTime GetTimestampForLine (ref int lineNum, bool roundToSeconds) * has no timestamp, the next line will be checked until a * timestamp is found. */ - public DateTime GetTimestampForLineForward (ref int lineNum, bool roundToSeconds) { lock (_currentColumnizerLock) diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs index 7b958d41..cdea0c23 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs @@ -50,6 +50,7 @@ public BookmarkWindow () public void ChangeTheme (Control.ControlCollection container) { #region ApplyColorToAllControls + foreach (Control component in container) { if (component.Controls != null && component.Controls.Count > 0) @@ -65,6 +66,7 @@ public void ChangeTheme (Control.ControlCollection container) } } + #endregion #region DataGridView diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs index 4058efe4..0ab5bb16 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs @@ -72,9 +72,10 @@ public LogWindow.LogWindow AddFileTab (string givenFileName, bool isTempFile, st EncodingOptions encodingOptions = new(); FillDefaultEncodingFromSettings(encodingOptions); - LogWindow.LogWindow logWindow = new(this, logFileName, isTempFile, forcePersistenceLoading, ConfigManager); - - logWindow.GivenFileName = givenFileName; + LogWindow.LogWindow logWindow = new(this, logFileName, isTempFile, forcePersistenceLoading, ConfigManager) + { + GivenFileName = givenFileName + }; if (preProcessColumnizer != null) { diff --git a/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs b/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs index 4c30c9a4..73f8e32b 100644 --- a/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs +++ b/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs @@ -1,18 +1,18 @@ -using LogExpert.Core.Config; - using System.Runtime.Versioning; +using LogExpert.Core.Config; + namespace LogExpert.UI.Extensions.Forms; [SupportedOSPlatform("windows")] public class LineToolStripSeparatorExtension : ToolStripSeparator { - public LineToolStripSeparatorExtension() + public LineToolStripSeparatorExtension () { Paint += OnExtendedToolStripSeparatorPaint; } - private void OnExtendedToolStripSeparatorPaint(object sender, PaintEventArgs e) + private void OnExtendedToolStripSeparatorPaint (object sender, PaintEventArgs e) { // Get the separator's width and height. var toolStripSeparator = (ToolStripSeparator)sender; diff --git a/src/LogExpert.UI/Extensions/Win32.cs b/src/LogExpert.UI/Extensions/Win32.cs index a039e711..97b6cd62 100644 --- a/src/LogExpert.UI/Extensions/Win32.cs +++ b/src/LogExpert.UI/Extensions/Win32.cs @@ -1,4 +1,3 @@ -using System.Drawing; using System.Runtime.InteropServices; using System.Runtime.Versioning; @@ -21,19 +20,19 @@ internal static partial class Win32 //NativeMethods #region Library Imports [LibraryImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] - public static partial bool DestroyIcon(nint hIcon); + public static partial bool DestroyIcon (nint hIcon); [LibraryImport("User32.dll")] - public static partial int SetForegroundWindow(nint hWnd); + public static partial int SetForegroundWindow (nint hWnd); [LibraryImport("user32.dll")] - public static partial long GetSystemMetricsForDpi(long index); + public static partial long GetSystemMetricsForDpi (long index); [LibraryImport("user32.dll")] - public static partial long GetSystemMetrics(long index); + public static partial long GetSystemMetrics (long index); [LibraryImport("user32.dll")] - public static partial short GetKeyState(int vKey); + public static partial short GetKeyState (int vKey); /* UINT ExtractIconEx( @@ -45,7 +44,7 @@ UINT nIcons ); * */ [LibraryImport("shell32.dll", StringMarshalling = StringMarshalling.Utf16)] - public static partial uint ExtractIconEx( + public static partial uint ExtractIconEx ( string fileName, int iconIndex, ref nint iconsLarge, @@ -55,13 +54,13 @@ uint numIcons #region TitleBarDarkMode [LibraryImport("dwmapi.dll")] - public static partial int DwmSetWindowAttribute(nint hwnd, int attr, ref int attrValue, int attrSize); + public static partial int DwmSetWindowAttribute (nint hwnd, int attr, ref int attrValue, int attrSize); #endregion #endregion #region Public methods - public static Icon LoadIconFromExe(string fileName, int index) + public static Icon LoadIconFromExe (string fileName, int index) { //IntPtr[] smallIcons = new IntPtr[1]; //IntPtr[] largeIcons = new IntPtr[1]; @@ -83,7 +82,7 @@ public static Icon LoadIconFromExe(string fileName, int index) return null; } - public static Icon[,] ExtractIcons(string fileName) + public static Icon[,] ExtractIcons (string fileName) { var smallIcon = nint.Zero; var largeIcon = nint.Zero; @@ -126,7 +125,7 @@ public static Icon LoadIconFromExe(string fileName, int index) #region Private Methods - public static bool UseImmersiveDarkMode(nint handle, bool enabled) + public static bool UseImmersiveDarkMode (nint handle, bool enabled) { var attribute = DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1; @@ -140,7 +139,7 @@ public static bool UseImmersiveDarkMode(nint handle, bool enabled) } - private static bool IsWindows10OrGreater(int build = -1) + private static bool IsWindows10OrGreater (int build = -1) { return Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= build; } From 4c4e2a80054f2019d48e811af4699e0301fffe70 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Thu, 12 Jun 2025 23:57:36 +0300 Subject: [PATCH 068/142] Fixed a few warnings --- src/.editorconfig | 2 +- src/ColumnizerLib/ILogLineColumnizerCallback.cs | 2 -- .../Classes/Bookmark/BookmarkDataProvider.cs | 3 ++- .../Classes/Bookmark/BookmarkExporter.cs | 4 ++-- .../Classes/Columnizer/ColumnizerPicker.cs | 7 ++++--- .../Classes/Columnizer/SquareBracketColumnizer.cs | 2 +- src/LogExpert.Core/Classes/Filter/FilterPipe.cs | 7 +------ src/LogExpert.Core/Interface/IBookmarkData.cs | 1 - src/LogExpert/Classes/CommandLine/CmdLine.cs | 10 ++++++++-- src/LogExpert/Classes/LogExpertApplicationContext.cs | 4 ++-- src/LogExpert/Classes/LogExpertProxy.cs | 7 ++----- src/LogExpert/Config/ConfigManager.cs | 7 ++++--- 12 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/.editorconfig b/src/.editorconfig index 1de2ba37..71f425c5 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -50,7 +50,7 @@ dotnet_style_parentheses_in_other_operators = never_if_unnecessary:warning dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning # Modifier preferences -dotnet_style_require_accessibility_modifiers = always:warning +dotnet_style_require_accessibility_modifiers = for_non_interface_members # Expression-level preferences dotnet_prefer_system_hash_code = true diff --git a/src/ColumnizerLib/ILogLineColumnizerCallback.cs b/src/ColumnizerLib/ILogLineColumnizerCallback.cs index 77e417c1..2c5f5811 100644 --- a/src/ColumnizerLib/ILogLineColumnizerCallback.cs +++ b/src/ColumnizerLib/ILogLineColumnizerCallback.cs @@ -1,5 +1,3 @@ -#pragma warning disable IDE0040 - namespace LogExpert; /// diff --git a/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs b/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs index cb003c79..6b905d9d 100644 --- a/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs +++ b/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs @@ -131,6 +131,7 @@ public void RemoveBookmarkForLine (int lineNum) OnBookmarkRemoved(); } + //TOOD: check if the callers are checking for null before calling public void RemoveBookmarksForLines (IEnumerable lineNumList) { ArgumentNullException.ThrowIfNull(lineNumList); @@ -144,7 +145,7 @@ public void RemoveBookmarksForLines (IEnumerable lineNumList) OnBookmarkRemoved(); } - + //TOOD: check if the callers are checking for null before calling public void AddBookmark (Entities.Bookmark bookmark) { ArgumentNullException.ThrowIfNull(bookmark); diff --git a/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs b/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs index 078082f8..2d15a433 100644 --- a/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs +++ b/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs @@ -10,8 +10,8 @@ public static class BookmarkExporter #region Public methods - public static void ExportBookmarkList (SortedList bookmarkList, string logfileName, - string fileName) + //TOOD: check if the callers are checking for null before calling + public static void ExportBookmarkList (SortedList bookmarkList, string logfileName, string fileName) { ArgumentNullException.ThrowIfNull(bookmarkList); FileStream fs = new(fileName, FileMode.Create, FileAccess.Write); diff --git a/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs b/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs index 15b9fac9..785c3a82 100644 --- a/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs +++ b/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs @@ -86,6 +86,7 @@ public static ILogLineColumnizer FindBetterColumnizer (string fileName, return newColumnizer; } + //TOOD: check if the callers are checking for null before calling /// /// This method will search all registered columnizer and return one according to the priority that returned /// by the each columnizer. @@ -122,7 +123,7 @@ public static ILogLineColumnizer FindColumnizer (string fileName, IAutoLogLineCo ]; } - List> priorityListOfColumnizers = []; + List<(Priority priority, ILogLineColumnizer columnizer)> priorityListOfColumnizers = []; foreach (ILogLineColumnizer logLineColumnizer in registeredColumnizer) { @@ -132,10 +133,10 @@ public static ILogLineColumnizer FindColumnizer (string fileName, IAutoLogLineCo priority = columnizerPriority.GetPriority(fileName, loglines); } - priorityListOfColumnizers.Add(new Tuple(priority, logLineColumnizer)); + priorityListOfColumnizers.Add((priority, logLineColumnizer)); } - ILogLineColumnizer lineColumnizer = priorityListOfColumnizers.OrderByDescending(a => a.Item1).Select(a => a.Item2).First(); + ILogLineColumnizer lineColumnizer = priorityListOfColumnizers.OrderByDescending(item => item.priority).Select(item => item.columnizer).First(); return lineColumnizer; } diff --git a/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs b/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs index d770f865..123db94b 100644 --- a/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs +++ b/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs @@ -143,7 +143,7 @@ public string[] GetColumnNames () var i = 1; while (columnNames.Count < GetColumnCount()) { - columnNames.Insert(columnNames.Count - 1, $"Source{i++.ToString(CultureInfo.InvariantCulture)}"); + columnNames.Insert(columnNames.Count - 1, $"Source{i++}"); } return columnNames.ToArray(); diff --git a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs index af33b7e3..ebc49471 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs @@ -205,15 +205,10 @@ protected virtual void Dispose (bool disposing) { _writer?.Dispose(); } + _disposed = true; } } - ~FilterPipe () - { - Dispose(false); - } - - #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Interface/IBookmarkData.cs b/src/LogExpert.Core/Interface/IBookmarkData.cs index 9afe7562..7abcedb7 100644 --- a/src/LogExpert.Core/Interface/IBookmarkData.cs +++ b/src/LogExpert.Core/Interface/IBookmarkData.cs @@ -2,7 +2,6 @@ namespace LogExpert.Core.Interface; -#pragma warning disable IDE0040 public interface IBookmarkData { #region Properties diff --git a/src/LogExpert/Classes/CommandLine/CmdLine.cs b/src/LogExpert/Classes/CommandLine/CmdLine.cs index 07155cb5..9c4d2799 100644 --- a/src/LogExpert/Classes/CommandLine/CmdLine.cs +++ b/src/LogExpert/Classes/CommandLine/CmdLine.cs @@ -10,16 +10,22 @@ namespace LogExpert.Classes.CommandLine; /// /// Represents an string command line parameter. /// -public class CmdLineString(string name, bool required, string helpMessage) : CmdLineParameter(name, required, helpMessage) +public class CmdLineString (string name, bool required, string helpMessage) : CmdLineParameter(name, required, helpMessage) { #region Public methods - public static implicit operator string(CmdLineString s) + public static implicit operator string (CmdLineString s) { + ArgumentNullException.ThrowIfNull(s); return s.Value; } + public override string ToString () + { + return Value; + } + #endregion } diff --git a/src/LogExpert/Classes/LogExpertApplicationContext.cs b/src/LogExpert/Classes/LogExpertApplicationContext.cs index a078f898..1b3940bb 100644 --- a/src/LogExpert/Classes/LogExpertApplicationContext.cs +++ b/src/LogExpert/Classes/LogExpertApplicationContext.cs @@ -1,4 +1,4 @@ -using LogExpert.Core.Interface; +using LogExpert.Core.Interface; using System; using System.Windows.Forms; @@ -17,7 +17,7 @@ internal class LogExpertApplicationContext : ApplicationContext public LogExpertApplicationContext(LogExpertProxy proxy, ILogTabWindow firstLogWin) { _proxy = proxy; - _proxy.LastWindowClosed += new LogExpertProxy.LastWindowClosedEventHandler(OnProxyLastWindowClosed); + _proxy.LastWindowClosed += OnProxyLastWindowClosed; firstLogWin.Show(); } diff --git a/src/LogExpert/Classes/LogExpertProxy.cs b/src/LogExpert/Classes/LogExpertProxy.cs index bf122209..5573d286 100644 --- a/src/LogExpert/Classes/LogExpertProxy.cs +++ b/src/LogExpert/Classes/LogExpertProxy.cs @@ -1,4 +1,4 @@ -using LogExpert.Config; +using LogExpert.Config; using LogExpert.Core.Interface; using LogExpert.UI.Controls.LogWindow; @@ -48,14 +48,11 @@ public LogExpertProxy(ILogTabWindow logTabWindow) // } //} - - public delegate void LastWindowClosedEventHandler(object sender, EventArgs e); - #endregion #region Events - public event LastWindowClosedEventHandler LastWindowClosed; + public event EventHandler LastWindowClosed; #endregion diff --git a/src/LogExpert/Config/ConfigManager.cs b/src/LogExpert/Config/ConfigManager.cs index cae55ba6..f11719fd 100644 --- a/src/LogExpert/Config/ConfigManager.cs +++ b/src/LogExpert/Config/ConfigManager.cs @@ -48,6 +48,7 @@ private ConfigManager () #region Properties + //TODO: Change to init public static ConfigManager Instance { get @@ -120,8 +121,8 @@ private Settings Load () _logger.Info("Loading settings"); string dir; - - if (File.Exists(PortableModeDir + Path.DirectorySeparatorChar + PortableModeSettingsFileName) == false) + + if (!File.Exists(Path.Combine(PortableModeDir, PortableModeSettingsFileName))) { _logger.Info("Load settings standard mode"); dir = ConfigDir; @@ -137,7 +138,7 @@ private Settings Load () Directory.CreateDirectory(dir); } - if (!File.Exists(dir + Path.DirectorySeparatorChar + "settings.json")) + if (!File.Exists(Path.Combine(dir, "settings.json"))) { return LoadOrCreateNew(null); } From 354d24c41f8e5d76fe352740c197dcf7020eb676 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Fri, 13 Jun 2025 02:14:19 +0300 Subject: [PATCH 069/142] Fixed a few more warnings --- src/.editorconfig | 4 +-- src/ColumnizerLib/Column.cs | 29 ++++++++----------- .../Extensions/LogLineExtensions.cs | 6 ++-- src/ColumnizerLib/IXmlLogConfiguration.cs | 2 +- src/ColumnizerLib/LineEntry.cs | 22 +++++++++++++- src/GlassfishColumnizer/XmlConfig.cs | 4 +-- src/Log4jXmlColumnizer/XmlConfig.cs | 4 +-- .../Classes/DateTimeParser/Token.cs | 4 ++- .../Classes/xml/XmlBlockSplitter.cs | 5 ++-- 9 files changed, 50 insertions(+), 30 deletions(-) diff --git a/src/.editorconfig b/src/.editorconfig index 71f425c5..4dc74b5f 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -89,7 +89,7 @@ dotnet_style_allow_statement_immediately_after_block_experimental = false:warnin #### C# Coding Conventions #### # var preferences -csharp_style_var_elsewhere = false:suggestion +csharp_style_var_elsewhere = true:suggestion csharp_style_var_for_built_in_types = true:warning csharp_style_var_when_type_is_apparent = true:warning @@ -277,7 +277,7 @@ dotnet_diagnostic.IDE0003.severity = warning dotnet_diagnostic.IDE0004.severity = warning # IDE0005: Remove unnecessary import -dotnet_diagnostic.IDE0005.severity = warning +dotnet_diagnostic.IDE0005.severity = none # IDE0005_gen: Remove unnecessary import (NotConfigurable) #dotnet_diagnostic.IDE0005_gen.severity = silent diff --git a/src/ColumnizerLib/Column.cs b/src/ColumnizerLib/Column.cs index 7cabf065..87bfdd69 100644 --- a/src/ColumnizerLib/Column.cs +++ b/src/ColumnizerLib/Column.cs @@ -10,7 +10,15 @@ public class Column : IColumn private const int MAXLENGTH = 4678 - 3; private const string REPLACEMENT = "..."; - private static readonly IEnumerable> _replacements; + private static readonly List> _replacements = [ + //replace tab with 3 spaces, from old coding. Needed??? + input => input.Replace("\t", " ", StringComparison.Ordinal), + + //shorten string if it exceeds maxLength + input => input.Length > MAXLENGTH + ? string.Concat(input.AsSpan(0, MAXLENGTH), REPLACEMENT) + : input + ]; private string _fullValue; @@ -20,32 +28,19 @@ public class Column : IColumn static Column () { - var replacements = new List>( - [ - //replace tab with 3 spaces, from old coding. Needed??? - input => input.Replace("\t", " ", StringComparison.Ordinal), - - //shorten string if it exceeds maxLength - input => input.Length > MAXLENGTH - ? string.Concat(input.AsSpan(0, MAXLENGTH), REPLACEMENT) - : input - ]); - if (Environment.Version >= Version.Parse("6.2")) { //Win8 or newer support full UTF8 chars with the preinstalled fonts. //Replace null char with UTF8 Symbol U+2400 (␀) - replacements.Add(input => input.Replace("\0", "␀", StringComparison.Ordinal)); + _replacements.Add(input => input.Replace("\0", "␀", StringComparison.Ordinal)); } else { //Everything below Win8 the installed fonts seems to not to support reliabel //Replace null char with space - replacements.Add(input => input.Replace("\0", " ", StringComparison.Ordinal)); + _replacements.Add(input => input.Replace("\0", " ", StringComparison.Ordinal)); } - _replacements = replacements; - EmptyColumn = new Column { FullValue = string.Empty }; } @@ -77,7 +72,7 @@ public string FullValue public string DisplayValue { get; private set; } - string ITextValue.Text => DisplayValue; + public string Text => DisplayValue; #endregion diff --git a/src/ColumnizerLib/Extensions/LogLineExtensions.cs b/src/ColumnizerLib/Extensions/LogLineExtensions.cs index 659ff75e..de081a34 100644 --- a/src/ColumnizerLib/Extensions/LogLineExtensions.cs +++ b/src/ColumnizerLib/Extensions/LogLineExtensions.cs @@ -1,9 +1,11 @@ namespace LogExpert.Extensions; +//TODO: Move this to LogExpert.UI, change to internal and fix tests public static class LogLineExtensions { - public static string ToClipBoardText(this ILogLine logLine) + //TOOD: check if the callers are checking for null before calling + public static string ToClipBoardText (this ILogLine logLine) { - return "\t" + (logLine.LineNumber + 1).ToString() + "\t" + logLine.FullLine; + return logLine == null ? string.Empty : $"\t{logLine.LineNumber + 1}\t{logLine.FullLine}"; } } \ No newline at end of file diff --git a/src/ColumnizerLib/IXmlLogConfiguration.cs b/src/ColumnizerLib/IXmlLogConfiguration.cs index c48d7535..b65422ed 100644 --- a/src/ColumnizerLib/IXmlLogConfiguration.cs +++ b/src/ColumnizerLib/IXmlLogConfiguration.cs @@ -30,7 +30,7 @@ public interface IXmlLogConfiguration /// Example: {"log4j", "http://jakarta.apache.org/log4j"} /// /// - string[] Namespace { get; } + string[] GetNamespaceDeclaration (); #endregion } \ No newline at end of file diff --git a/src/ColumnizerLib/LineEntry.cs b/src/ColumnizerLib/LineEntry.cs index 3869767c..e59c1791 100644 --- a/src/ColumnizerLib/LineEntry.cs +++ b/src/ColumnizerLib/LineEntry.cs @@ -1,3 +1,5 @@ +using System; + namespace LogExpert; /// @@ -5,7 +7,7 @@ namespace LogExpert; /// This struct is used by . /// /// -public struct LineEntry +public struct LineEntry : IEquatable { /// /// The content of the line. @@ -16,4 +18,22 @@ public struct LineEntry /// The line number. See for an explanation of the line number. /// public int LineNum { get; set; } + + public override bool Equals(object obj) + { + return obj is LineEntry other && Equals(other); + } + + public readonly bool Equals(LineEntry other) + { + return LineNum == other.LineNum && Equals(LogLine, other.LogLine); + } + + public override readonly int GetHashCode() + { + return HashCode.Combine(LineNum, LogLine); + } + + public static bool operator == (LineEntry left, LineEntry right) => left.Equals(right); + public static bool operator != (LineEntry left, LineEntry right) => !left.Equals(right); } \ No newline at end of file diff --git a/src/GlassfishColumnizer/XmlConfig.cs b/src/GlassfishColumnizer/XmlConfig.cs index 0d81e05a..925be273 100644 --- a/src/GlassfishColumnizer/XmlConfig.cs +++ b/src/GlassfishColumnizer/XmlConfig.cs @@ -1,4 +1,4 @@ -using LogExpert; +using LogExpert; namespace GlassfishColumnizer; @@ -12,7 +12,7 @@ internal class XmlConfig : IXmlLogConfiguration public string Stylesheet { get; } - public string[] Namespace => null; + public string[] GetNamespaceDeclaration () => null; #endregion } \ No newline at end of file diff --git a/src/Log4jXmlColumnizer/XmlConfig.cs b/src/Log4jXmlColumnizer/XmlConfig.cs index 24620b82..ed852699 100644 --- a/src/Log4jXmlColumnizer/XmlConfig.cs +++ b/src/Log4jXmlColumnizer/XmlConfig.cs @@ -1,4 +1,4 @@ -using LogExpert; +using LogExpert; namespace Log4jXmlColumnizer; @@ -26,7 +26,7 @@ internal class XmlConfig : IXmlLogConfiguration "" + ""; - public string[] Namespace => ["log4j", "http://jakarta.apache.org/log4j"]; + public string[] GetNamespaceDeclaration () => ["log4j", "http://jakarta.apache.org/log4j"]; #endregion } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/DateTimeParser/Token.cs b/src/LogExpert.Core/Classes/DateTimeParser/Token.cs index a9869b55..4e3d47d2 100644 --- a/src/LogExpert.Core/Classes/DateTimeParser/Token.cs +++ b/src/LogExpert.Core/Classes/DateTimeParser/Token.cs @@ -4,14 +4,16 @@ namespace LogExpert.Core.Classes.DateTimeParser; public static class Token { + //TOOD: check if the callers are checking for null before calling public static bool IsDatePart(string token) { + ArgumentNullException.ThrowIfNull(token); return token.StartsWith("y", StringComparison.OrdinalIgnoreCase) || token.StartsWith("m", StringComparison.OrdinalIgnoreCase) || token.StartsWith("d", StringComparison.OrdinalIgnoreCase) || token.StartsWith("s", StringComparison.OrdinalIgnoreCase) || token.StartsWith("h", StringComparison.OrdinalIgnoreCase) || - string.Compare(token, "tt", StringComparison.OrdinalIgnoreCase) == 0; + token.Equals("tt", StringComparison.OrdinalIgnoreCase); } } \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs b/src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs index 469f5ab2..3fb1b5b0 100644 --- a/src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs +++ b/src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs @@ -39,9 +39,10 @@ public XmlBlockSplitter(XmlLogReader reader, IXmlLogConfiguration xmlLogConfig) // Create the XmlNamespaceManager. NameTable nt = new(); XmlNamespaceManager nsmgr = new(nt); - if (xmlLogConfig.Namespace != null) + var namespaceDeclaration = xmlLogConfig.GetNamespaceDeclaration(); + if (namespaceDeclaration != null) { - nsmgr.AddNamespace(xmlLogConfig.Namespace[0], xmlLogConfig.Namespace[1]); + nsmgr.AddNamespace(namespaceDeclaration[0], namespaceDeclaration[1]); } // Create the XmlParserContext. _context = new XmlParserContext(nt, nsmgr, null, XmlSpace.None); From a83bf101fe6c3658aa91dc1fd8409ccfd726fc62 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Fri, 13 Jun 2025 14:51:31 +0300 Subject: [PATCH 070/142] Added IDisposable to classed that have disposable fields --- .../Classes/Filter/FilterPipe.cs | 8 +-- .../Classes/Log/LogfileReader.cs | 56 +++++++++++++------ src/LogExpert.Core/Classes/SysoutPipe.cs | 43 ++++++++++---- 3 files changed, 73 insertions(+), 34 deletions(-) diff --git a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs index ebc49471..afa671da 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs @@ -32,15 +32,9 @@ public FilterPipe(FilterParams filterParams, ILogWindow logWindow) #endregion - #region Delegates - - public delegate void ClosedEventHandler (object sender, EventArgs e); - - #endregion - #region Events - public event ClosedEventHandler Closed; + public event EventHandler Closed; #endregion diff --git a/src/LogExpert.Core/Classes/Log/LogfileReader.cs b/src/LogExpert.Core/Classes/Log/LogfileReader.cs index 279b9668..1970f9b7 100644 --- a/src/LogExpert.Core/Classes/Log/LogfileReader.cs +++ b/src/LogExpert.Core/Classes/Log/LogfileReader.cs @@ -10,7 +10,7 @@ namespace LogExpert.Core.Classes.Log; -public class LogfileReader : IAutoLogLineColumnizerCallback +public class LogfileReader : IAutoLogLineColumnizerCallback, IDisposable { #region Fields @@ -27,7 +27,6 @@ public class LogfileReader : IAutoLogLineColumnizerCallback private readonly IPluginRegistry _pluginRegistry; private IList _bufferList; private ReaderWriterLock _bufferListLock; - private IList _bufferLru; private bool _contentDeleted; private int _currLineCount; private ReaderWriterLock _disposeLock; @@ -36,7 +35,7 @@ public class LogfileReader : IAutoLogLineColumnizerCallback private Task _garbageCollectorTask; private Task _monitorTask; - private readonly CancellationTokenSource cts = new(); + private readonly CancellationTokenSource _cts = new(); private bool _isDeleted; private bool _isFailModeCheckCallPending; @@ -48,6 +47,7 @@ public class LogfileReader : IAutoLogLineColumnizerCallback private ReaderWriterLock _lruCacheDictLock; private bool _shouldStop; + private bool _disposed; private ILogFileInfo _watchedILogFileInfo; #endregion @@ -69,13 +69,15 @@ public LogfileReader (string fileName, EncodingOptions encodingOptions, bool mul _multiFileOptions = multiFileOptions; _pluginRegistry = pluginRegistry; _logLineFx = GetLogLineInternal; + _disposed = false; + InitLruBuffers(); if (multiFile) { - ILogFileInfo info = GetLogFileInfo(fileName); + var info = GetLogFileInfo(fileName); RolloverFilenameHandler rolloverHandler = new(info, _multiFileOptions); - LinkedList nameList = rolloverHandler.GetNameList(_pluginRegistry); + var nameList = rolloverHandler.GetNameList(_pluginRegistry); ILogFileInfo fileInfo = null; foreach (var name in nameList) @@ -107,6 +109,7 @@ public LogfileReader (string[] fileNames, EncodingOptions encodingOptions, int b _multiFileOptions = multiFileOptions; _pluginRegistry = pluginRegistry; _logLineFx = GetLogLineInternal; + _disposed = false; InitLruBuffers(); @@ -564,7 +567,7 @@ public int GetRealLineNumForVirtualLineNum (int lineNum) public void StartMonitoring () { _logger.Info("startMonitoring()"); - _monitorTask = Task.Run(MonitorThreadProc, cts.Token); + _monitorTask = Task.Run(MonitorThreadProc, _cts.Token); _shouldStop = false; } @@ -579,7 +582,7 @@ public void StopMonitoring () { if (_monitorTask.Status == TaskStatus.Running) // if thread has not finished, abort it { - cts.Cancel(); + _cts.Cancel(); } } @@ -587,7 +590,7 @@ public void StopMonitoring () { if (_garbageCollectorTask.Status == TaskStatus.Running) // if thread has not finished, abort it { - cts.Cancel(); + _cts.Cancel(); } } @@ -799,7 +802,7 @@ private Task GetLogLineInternal (int lineNum) private void InitLruBuffers () { _bufferList = []; - _bufferLru = new List(_max_buffers + 1); + //_bufferLru = new List(_max_buffers + 1); //this.lruDict = new Dictionary(this.MAX_BUFFERS + 1); // key=startline, value = index in bufferLru _lruCacheDict = new Dictionary(_max_buffers + 1); _lruCacheDictLock = new ReaderWriterLock(); @@ -809,7 +812,7 @@ private void InitLruBuffers () private void StartGCThread () { - _garbageCollectorTask = Task.Run(GarbageCollectorThreadProc, cts.Token); + _garbageCollectorTask = Task.Run(GarbageCollectorThreadProc, _cts.Token); //_garbageCollectorThread = new Thread(new ThreadStart(GarbageCollectorThreadProc)); //_garbageCollectorThread.IsBackground = true; //_garbageCollectorThread.Start(); @@ -911,13 +914,13 @@ private LogBuffer DeleteBuffersForInfo (ILogFileInfo ILogFileInfo, bool matchNam } /// - /// The caller must have writer locks for lruCache and buffer list! + /// The caller must have _writer locks for lruCache and buffer list! /// /// private void RemoveFromBufferList (LogBuffer buffer) { - Util.AssertTrue(_lruCacheDictLock.IsWriterLockHeld, "No writer lock for lru cache"); - Util.AssertTrue(_bufferListLock.IsWriterLockHeld, "No writer lock for buffer list"); + Util.AssertTrue(_lruCacheDictLock.IsWriterLockHeld, "No _writer lock for lru cache"); + Util.AssertTrue(_bufferListLock.IsWriterLockHeld, "No _writer lock for buffer list"); _lruCacheDict.Remove(buffer.StartLine); _bufferList.Remove(buffer); } @@ -1068,7 +1071,7 @@ private void UpdateLruCache (LogBuffer logBuffer) { LockCookie cookie = _lruCacheDictLock.UpgradeToWriterLock(Timeout.Infinite); if (!_lruCacheDict.TryGetValue(logBuffer.StartLine, out cacheEntry) - ) // #536: re-test, because multiple threads may have been waiting for writer lock + ) // #536: re-test, because multiple threads may have been waiting for _writer lock { cacheEntry = new LogBufferCacheEntry(); cacheEntry.LogBuffer = logBuffer; @@ -1112,7 +1115,7 @@ private void UpdateLruCache (LogBuffer logBuffer) /// private void SetNewStartLineForBuffer (LogBuffer logBuffer, int newLineNum) { - Util.AssertTrue(_lruCacheDictLock.IsWriterLockHeld, "No writer lock for lru cache"); + Util.AssertTrue(_lruCacheDictLock.IsWriterLockHeld, "No _writer lock for lru cache"); if (_lruCacheDict.ContainsKey(logBuffer.StartLine)) { _lruCacheDict.Remove(logBuffer.StartLine); @@ -1787,9 +1790,30 @@ private void DumpBufferInfos (LogBuffer buffer) #endregion + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); // Suppress finalization (not needed but best practice) + } + + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + DeleteAllContent(); + _cts.Dispose(); // Dispose managed resources + } + + _disposed = true; + } + } + + //TODO: Seems that this can be deleted. Need to verify. ~LogfileReader () { - DeleteAllContent(); + Dispose (false); } protected virtual void OnFileSizeChanged (LogEventArgs e) diff --git a/src/LogExpert.Core/Classes/SysoutPipe.cs b/src/LogExpert.Core/Classes/SysoutPipe.cs index 86460221..89f89927 100644 --- a/src/LogExpert.Core/Classes/SysoutPipe.cs +++ b/src/LogExpert.Core/Classes/SysoutPipe.cs @@ -5,14 +5,15 @@ namespace LogExpert.Core.Classes; -public class SysoutPipe +public class SysoutPipe : IDisposable { #region Fields - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); - private readonly StreamReader sysout; - private StreamWriter writer; + private readonly StreamReader _sysout; + private StreamWriter _writer; + private bool _disposed; #endregion @@ -20,12 +21,13 @@ public class SysoutPipe public SysoutPipe(StreamReader sysout) { - this.sysout = sysout; + _disposed = false; + this._sysout = sysout; FileName = Path.GetTempFileName(); _logger.Info("sysoutPipe created temp file: {0}", FileName); FileStream fStream = new(FileName, FileMode.Append, FileAccess.Write, FileShare.Read); - writer = new StreamWriter(fStream, Encoding.Unicode); + _writer = new StreamWriter(fStream, Encoding.Unicode); Thread thread = new(new ThreadStart(ReaderThread)) { @@ -46,14 +48,14 @@ public SysoutPipe(StreamReader sysout) public void ClosePipe() { - writer.Close(); - writer = null; + _writer.Close(); + _writer = null; } public void DataReceivedEventHandler(object sender, DataReceivedEventArgs e) { - writer.WriteLine(e.Data); + _writer.WriteLine(e.Data); } public void ProcessExitedEventHandler(object sender, System.EventArgs e) @@ -76,12 +78,12 @@ protected void ReaderThread() { try { - var read = sysout.Read(buff, 0, 256); + var read = _sysout.Read(buff, 0, 256); if (read == 0) { break; } - writer.Write(buff, 0, read); + _writer.Write(buff, 0, read); } catch (IOException e) { @@ -92,4 +94,23 @@ protected void ReaderThread() ClosePipe(); } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); // Suppress finalization (not needed but best practice) + } + + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + _writer.Dispose(); // Dispose managed resources + } + + _disposed = true; + } + } } \ No newline at end of file From b0c27921cbb1a9438dea2de59a10e0dd5dac9fe8 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Fri, 13 Jun 2025 14:57:23 +0300 Subject: [PATCH 071/142] Solved CA1003 --- .../Classes/Log/LogfileReader.cs | 18 ++++++------------ .../EventHandlers/EventHandlers.cs | 7 ------- src/LogExpert.Core/Interface/IConfigManager.cs | 3 +-- src/LogExpert.Core/Interface/ILogWindow.cs | 5 ++--- 4 files changed, 9 insertions(+), 24 deletions(-) delete mode 100644 src/LogExpert.Core/EventHandlers/EventHandlers.cs diff --git a/src/LogExpert.Core/Classes/Log/LogfileReader.cs b/src/LogExpert.Core/Classes/Log/LogfileReader.cs index 1970f9b7..ba8da223 100644 --- a/src/LogExpert.Core/Classes/Log/LogfileReader.cs +++ b/src/LogExpert.Core/Classes/Log/LogfileReader.cs @@ -3,7 +3,6 @@ using LogExpert.Core.Classes.xml; using LogExpert.Core.Entities; using LogExpert.Core.EventArguments; -using LogExpert.Core.EventHandlers; using LogExpert.Core.Interface; using NLog; @@ -129,23 +128,18 @@ public LogfileReader (string[] fileNames, EncodingOptions encodingOptions, int b #region Delegates - public delegate void BlockLoadedEventHandler (object sender, LoadFileEventArgs e); - public delegate void FileNotFoundEventHandler (object sender, EventArgs e); - public delegate void FileRespawnedEventHandler (object sender, EventArgs e); - public delegate void FinishedLoadingEventHandler (object sender, EventArgs e); private delegate Task GetLogLineFx (int lineNum); - public delegate void LoadingStartedEventHandler (object sender, LoadFileEventArgs e); #endregion #region Events - public event FileSizeChangedEventHandler FileSizeChanged; - public event BlockLoadedEventHandler LoadFile; - public event LoadingStartedEventHandler LoadingStarted; - public event FinishedLoadingEventHandler LoadingFinished; - public event FileNotFoundEventHandler FileNotFound; - public event FileRespawnedEventHandler Respawned; + public event EventHandler FileSizeChanged; + public event EventHandler LoadFile; + public event EventHandler LoadingStarted; + public event EventHandler LoadingFinished; + public event EventHandler FileNotFound; + public event EventHandler Respawned; #endregion diff --git a/src/LogExpert.Core/EventHandlers/EventHandlers.cs b/src/LogExpert.Core/EventHandlers/EventHandlers.cs deleted file mode 100644 index 63f44923..00000000 --- a/src/LogExpert.Core/EventHandlers/EventHandlers.cs +++ /dev/null @@ -1,7 +0,0 @@ -using LogExpert.Core.Entities; -using LogExpert.Core.EventArguments; - -namespace LogExpert.Core.EventHandlers; - -public delegate void ConfigChangedEventHandler(object sender, ConfigChangedEventArgs e); -public delegate void FileSizeChangedEventHandler(object sender, LogEventArgs e); diff --git a/src/LogExpert.Core/Interface/IConfigManager.cs b/src/LogExpert.Core/Interface/IConfigManager.cs index 57638394..d921e9b4 100644 --- a/src/LogExpert.Core/Interface/IConfigManager.cs +++ b/src/LogExpert.Core/Interface/IConfigManager.cs @@ -1,6 +1,5 @@ using LogExpert.Core.Config; using LogExpert.Core.EventArguments; -using LogExpert.Core.EventHandlers; namespace LogExpert.Core.Interface; @@ -16,6 +15,6 @@ public interface IConfigManager void Export(FileInfo fileInfo); void Import(FileInfo fileInfo, ExportImportFlags importFlags); void ImportHighlightSettings(FileInfo fileInfo, ExportImportFlags importFlags); - event ConfigChangedEventHandler ConfigChanged; //TODO: All handlers that are public shoulld be in Core + event EventHandler ConfigChanged; //TODO: All handlers that are public shoulld be in Core void Save(SettingsFlags flags); } \ No newline at end of file diff --git a/src/LogExpert.Core/Interface/ILogWindow.cs b/src/LogExpert.Core/Interface/ILogWindow.cs index 9072cdcb..b327f2fc 100644 --- a/src/LogExpert.Core/Interface/ILogWindow.cs +++ b/src/LogExpert.Core/Interface/ILogWindow.cs @@ -1,7 +1,6 @@ - using LogExpert.Core.Classes.Log; using LogExpert.Core.Classes.Persister; -using LogExpert.Core.EventHandlers; +using LogExpert.Core.Entities; namespace LogExpert.Core.Interface; @@ -36,7 +35,7 @@ public interface ILogWindow string FileName { get; } - event FileSizeChangedEventHandler FileSizeChanged; //TODO: All handlers should be moved to Core + event EventHandler FileSizeChanged; //TODO: All handlers should be moved to Core event EventHandler TailFollowed; //LogExpert.UI.Controls.LogTabWindow.LogTabWindow.LogWindowData Tag { get; } From 15e4671fa02e988a57d39b0069a92207763bf6b2 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Fri, 13 Jun 2025 15:35:52 +0300 Subject: [PATCH 072/142] Solved CA1052 --- src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs | 2 +- src/LogExpert.Core/Entities/DebugOptions.cs | 2 +- src/LogExpert.Core/Interface/IBookmarkView.cs | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs b/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs index 785c3a82..daea8f9f 100644 --- a/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs +++ b/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs @@ -4,7 +4,7 @@ namespace LogExpert.Core.Classes.Columnizer; -public class ColumnizerPicker +public static class ColumnizerPicker { public static ILogLineColumnizer FindColumnizerByName (string name, IList list) { diff --git a/src/LogExpert.Core/Entities/DebugOptions.cs b/src/LogExpert.Core/Entities/DebugOptions.cs index f6e1fcfd..fbd4b084 100644 --- a/src/LogExpert.Core/Entities/DebugOptions.cs +++ b/src/LogExpert.Core/Entities/DebugOptions.cs @@ -1,6 +1,6 @@ namespace LogExpert.Core.Entities; -public class DebugOptions +public static class DebugOptions { public static bool DisableWordHighlight { get; set; } } \ No newline at end of file diff --git a/src/LogExpert.Core/Interface/IBookmarkView.cs b/src/LogExpert.Core/Interface/IBookmarkView.cs index d22a7791..963c7c41 100644 --- a/src/LogExpert.Core/Interface/IBookmarkView.cs +++ b/src/LogExpert.Core/Interface/IBookmarkView.cs @@ -9,6 +9,7 @@ public interface IBookmarkView { #region Properties + //TODO: After all refactoring is done, take care of this warning. bool LineColumnVisible { set; } #endregion From fde54f697d2cdd8102a3e7a62463ba361d19a076 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Fri, 13 Jun 2025 15:56:25 +0300 Subject: [PATCH 073/142] Change from ToString to GetType in order to avoid the following problems: - ToString() may be overridden in a class, returning a custom string instead of the type name. - Not guaranteed to return the type name, which is what ObjectDisposedException expects. - Returns the runtime type of the instance, ensuring accuracy. - Works even in derived classes, reflecting the actual type rather than the base type. - Recommended by Microsoft for ObjectDisposedException. --- src/LogExpert.Core/Classes/Log/LogfileReader.cs | 2 +- .../Classes/Log/PositionAwareStreamReaderBase.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/LogExpert.Core/Classes/Log/LogfileReader.cs b/src/LogExpert.Core/Classes/Log/LogfileReader.cs index ba8da223..6fcfcb38 100644 --- a/src/LogExpert.Core/Classes/Log/LogfileReader.cs +++ b/src/LogExpert.Core/Classes/Log/LogfileReader.cs @@ -846,7 +846,7 @@ private void ReplaceBufferInfos (ILogFileInfo oldLogFileInfo, ILogFileInfo newLo { _logger.Debug("ReplaceBufferInfos() " + oldLogFileInfo.FullName + " -> " + newLogFileInfo.FullName); AcquireBufferListReaderLock(); - foreach (LogBuffer buffer in _bufferList) + foreach (var buffer in _bufferList) { if (buffer.FileInfo == oldLogFileInfo) { diff --git a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs index 0cd74d6d..74f66e94 100644 --- a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs +++ b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs @@ -94,7 +94,7 @@ protected override void Dispose (bool disposing) //TODO This is unsafe and should be refactored public override unsafe int ReadChar () { - ObjectDisposedException.ThrowIf(IsDisposed, GetType().ToString()); + ObjectDisposedException.ThrowIf(IsDisposed, GetType()); try { @@ -126,7 +126,7 @@ protected virtual void ResetReader () protected StreamReader GetStreamReader () { - ObjectDisposedException.ThrowIf(IsDisposed, GetType().ToString()); + ObjectDisposedException.ThrowIf(IsDisposed, GetType()); return _reader; } From 92af0858c0a9525fb2238dcb0bdc52fdfc0c3a7c Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Fri, 13 Jun 2025 16:12:13 +0300 Subject: [PATCH 074/142] Solved CA1063 --- .../Classes/Log/LogStreamReaderBase.cs | 13 +++---------- .../Classes/Log/PositionAwareStreamReaderBase.cs | 3 ++- .../Classes/Log/PositionAwareStreamReaderLegacy.cs | 2 ++ .../Classes/Log/PositionAwareStreamReaderSystem.cs | 2 ++ src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs | 3 +++ src/LogExpert.Core/Classes/xml/XmlLogReader.cs | 2 ++ 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/LogExpert.Core/Classes/Log/LogStreamReaderBase.cs b/src/LogExpert.Core/Classes/Log/LogStreamReaderBase.cs index d5800faf..58b0b0bf 100644 --- a/src/LogExpert.Core/Classes/Log/LogStreamReaderBase.cs +++ b/src/LogExpert.Core/Classes/Log/LogStreamReaderBase.cs @@ -35,7 +35,7 @@ protected LogStreamReaderBase() /// /// Indicates whether or not the stream reader has already been disposed. /// - public bool IsDisposed { get; private set; } + public abstract bool IsDisposed { get; protected set; } #endregion @@ -46,15 +46,8 @@ protected LogStreamReaderBase() /// public void Dispose() { - try - { - Dispose(true); - GC.SuppressFinalize(this); - } - finally - { - IsDisposed = true; - } + Dispose(true); + GC.SuppressFinalize(this); } /// /// Destroy and release the current stream reader. diff --git a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs index 74f66e94..5f072c27 100644 --- a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs +++ b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderBase.cs @@ -88,7 +88,8 @@ protected override void Dispose (bool disposing) { _stream.Dispose(); _reader.Dispose(); - } + IsDisposed = true; +} } //TODO This is unsafe and should be refactored diff --git a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs index 8b8f7c9d..a47eaa0d 100644 --- a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs +++ b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderLegacy.cs @@ -11,6 +11,8 @@ public class PositionAwareStreamReaderLegacy : PositionAwareStreamReaderBase private int _charBufferPos; private bool _crDetect; + public override bool IsDisposed { get; protected set; } + #endregion #region cTor diff --git a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs index 354703a0..a4f8b4a0 100644 --- a/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs +++ b/src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderSystem.cs @@ -17,6 +17,8 @@ public class PositionAwareStreamReaderSystem : PositionAwareStreamReaderBase private int _newLineSequenceLength; + public override bool IsDisposed { get; protected set; } + #endregion #region cTor diff --git a/src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs b/src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs index 3fb1b5b0..1188c203 100644 --- a/src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs +++ b/src/LogExpert.Core/Classes/xml/XmlBlockSplitter.cs @@ -24,6 +24,8 @@ public class XmlBlockSplitter : LogStreamReaderBase private string _stylesheet; private XslCompiledTransform _xslt; + public override bool IsDisposed { get; protected set; } + #endregion #region cTor @@ -136,6 +138,7 @@ protected override void Dispose(bool disposing) if (disposing) { _reader.Dispose(); + IsDisposed = true; } } diff --git a/src/LogExpert.Core/Classes/xml/XmlLogReader.cs b/src/LogExpert.Core/Classes/xml/XmlLogReader.cs index 9334cbbd..43c4e2c7 100644 --- a/src/LogExpert.Core/Classes/xml/XmlLogReader.cs +++ b/src/LogExpert.Core/Classes/xml/XmlLogReader.cs @@ -10,6 +10,7 @@ public class XmlLogReader : LogStreamReaderBase #region Fields private readonly ILogStreamReader reader; + public override bool IsDisposed { get; protected set; } #endregion @@ -47,6 +48,7 @@ protected override void Dispose(bool disposing) if (disposing) { reader.Dispose(); + IsDisposed = true; } } From e33f3234c1499869f60d1973dd0e52ad8a29e27b Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Fri, 13 Jun 2025 16:37:19 +0300 Subject: [PATCH 075/142] Add second parameter for better message when throwing ArgumentNullException --- .../Classes/Bookmark/BookmarkDataProvider.cs | 4 ++-- src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs | 2 +- src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs | 2 +- .../Classes/DateTimeParser/DateFormatPartAdjuster.cs | 3 +++ src/LogExpert.Core/Classes/DateTimeParser/Token.cs | 2 +- src/LogExpert.UI/Controls/DateTimeDragControl.cs | 7 +++---- src/LogExpert/Classes/CommandLine/CmdLine.cs | 2 +- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs b/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs index 6b905d9d..23abd312 100644 --- a/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs +++ b/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs @@ -134,7 +134,7 @@ public void RemoveBookmarkForLine (int lineNum) //TOOD: check if the callers are checking for null before calling public void RemoveBookmarksForLines (IEnumerable lineNumList) { - ArgumentNullException.ThrowIfNull(lineNumList); + ArgumentNullException.ThrowIfNull(lineNumList, nameof(lineNumList)); foreach (var lineNum in lineNumList) { @@ -148,7 +148,7 @@ public void RemoveBookmarksForLines (IEnumerable lineNumList) //TOOD: check if the callers are checking for null before calling public void AddBookmark (Entities.Bookmark bookmark) { - ArgumentNullException.ThrowIfNull(bookmark); + ArgumentNullException.ThrowIfNull(bookmark, nameof(bookmark)); BookmarkList.Add(bookmark.LineNum, bookmark); OnBookmarkAdded(); diff --git a/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs b/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs index 2d15a433..c24bafdf 100644 --- a/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs +++ b/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs @@ -13,7 +13,7 @@ public static class BookmarkExporter //TOOD: check if the callers are checking for null before calling public static void ExportBookmarkList (SortedList bookmarkList, string logfileName, string fileName) { - ArgumentNullException.ThrowIfNull(bookmarkList); + ArgumentNullException.ThrowIfNull(bookmarkList, nameof(bookmarkList)); FileStream fs = new(fileName, FileMode.Create, FileAccess.Write); StreamWriter writer = new(fs); writer.WriteLine("Log file name;Line number;Comment"); diff --git a/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs b/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs index daea8f9f..22c859dc 100644 --- a/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs +++ b/src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs @@ -101,7 +101,7 @@ public static ILogLineColumnizer FindColumnizer (string fileName, IAutoLogLineCo return new DefaultLogfileColumnizer(); } - ArgumentNullException.ThrowIfNull(registeredColumnizer); + ArgumentNullException.ThrowIfNull(registeredColumnizer, nameof(registeredColumnizer)); List loglines = []; diff --git a/src/LogExpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs b/src/LogExpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs index b0277ee5..9c85f936 100644 --- a/src/LogExpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs +++ b/src/LogExpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs @@ -3,6 +3,7 @@ namespace LogExpert.Core.Classes.DateTimeParser; +//TODO: This should be moved into LogExpert.UI and changed to internal // Ensures we have constant width (number of characters) date formats public static class DateFormatPartAdjuster { @@ -18,6 +19,8 @@ public static class DateFormatPartAdjuster public static string AdjustDateTimeFormatPart(string part) { + ArgumentNullException.ThrowIfNull(part, nameof(part)); + if (!_dateTimePartReplacements.TryGetValue(part, out var adjustedPart)) { return part; diff --git a/src/LogExpert.Core/Classes/DateTimeParser/Token.cs b/src/LogExpert.Core/Classes/DateTimeParser/Token.cs index 4e3d47d2..3db40686 100644 --- a/src/LogExpert.Core/Classes/DateTimeParser/Token.cs +++ b/src/LogExpert.Core/Classes/DateTimeParser/Token.cs @@ -7,7 +7,7 @@ public static class Token //TOOD: check if the callers are checking for null before calling public static bool IsDatePart(string token) { - ArgumentNullException.ThrowIfNull(token); + ArgumentNullException.ThrowIfNull(token, nameof(token)); return token.StartsWith("y", StringComparison.OrdinalIgnoreCase) || token.StartsWith("m", StringComparison.OrdinalIgnoreCase) || diff --git a/src/LogExpert.UI/Controls/DateTimeDragControl.cs b/src/LogExpert.UI/Controls/DateTimeDragControl.cs index 676e9f86..52c89d08 100644 --- a/src/LogExpert.UI/Controls/DateTimeDragControl.cs +++ b/src/LogExpert.UI/Controls/DateTimeDragControl.cs @@ -234,16 +234,15 @@ private void InitCustomRects (Section dateSection) .Select(DateFormatPartAdjuster.AdjustDateTimeFormatPart) .ToArray(); - Rectangle rect = ClientRectangle; - var oneCharWidth = rect.Width / _dateParts.Sum(s => s.Length); - var left = rect.Left; + var oneCharWidth = ClientRectangle.Width / _dateParts.Sum(s => s.Length); + var left = ClientRectangle.Left; _digitRects.Clear(); foreach (var datePart in _dateParts) { var s = datePart.Length * oneCharWidth; - _digitRects.Add(new Rectangle(left, rect.Top, s, rect.Height)); + _digitRects.Add(new Rectangle(left, ClientRectangle.Top, s, ClientRectangle.Height)); left += s; } diff --git a/src/LogExpert/Classes/CommandLine/CmdLine.cs b/src/LogExpert/Classes/CommandLine/CmdLine.cs index 9c4d2799..a269f214 100644 --- a/src/LogExpert/Classes/CommandLine/CmdLine.cs +++ b/src/LogExpert/Classes/CommandLine/CmdLine.cs @@ -17,7 +17,7 @@ public class CmdLineString (string name, bool required, string helpMessage) : Cm public static implicit operator string (CmdLineString s) { - ArgumentNullException.ThrowIfNull(s); + ArgumentNullException.ThrowIfNull(s, nameof(s)); return s.Value; } From 4679b792c1bb59503042deb10010454024fa8fb6 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Fri, 13 Jun 2025 16:49:18 +0300 Subject: [PATCH 076/142] Finished changing the EventHandlers --- src/LogExpert.Core/Interface/ILogWindow.cs | 4 +-- .../Controls/LogWindow/LogWindow.cs | 25 +++++++++---------- src/LogExpert/Config/ConfigManager.cs | 3 +-- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/LogExpert.Core/Interface/ILogWindow.cs b/src/LogExpert.Core/Interface/ILogWindow.cs index b327f2fc..a0181219 100644 --- a/src/LogExpert.Core/Interface/ILogWindow.cs +++ b/src/LogExpert.Core/Interface/ILogWindow.cs @@ -35,8 +35,8 @@ public interface ILogWindow string FileName { get; } - event EventHandler FileSizeChanged; //TODO: All handlers should be moved to Core + //event EventHandler FileSizeChanged; //TODO: All handlers should be moved to Core - event EventHandler TailFollowed; + //event EventHandler TailFollowed; //LogExpert.UI.Controls.LogTabWindow.LogTabWindow.LogWindowData Tag { get; } } \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index 34e04cc6..165b7c8e 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -9,7 +9,6 @@ using LogExpert.Core.Config; using LogExpert.Core.Entities; using LogExpert.Core.EventArguments; -using LogExpert.Core.EventHandlers; using LogExpert.Core.Interface; using LogExpert.Dialogs; using LogExpert.UI.Dialogs; @@ -406,7 +405,7 @@ public void ChangeTheme (Control.ControlCollection container) #region Events - public event FileSizeChangedEventHandler FileSizeChanged; + public event EventHandler FileSizeChanged; public event ProgressBarEventHandler ProgressBarUpdate; @@ -521,17 +520,17 @@ public string Title LogfileReader ILogWindow.LogFileReader => _logFileReader; - event FileSizeChangedEventHandler ILogWindow.FileSizeChanged - { - add => FileSizeChanged += new FileSizeChangedEventHandler(value); - remove => FileSizeChanged -= new FileSizeChangedEventHandler(value); - } - - event EventHandler ILogWindow.TailFollowed - { - add => TailFollowed += new TailFollowedEventHandler(value); - remove => TailFollowed -= new TailFollowedEventHandler(value); - } + //public event EventHandler ILogWindow.FileSizeChanged + //{ + // add => FileSizeChanged += new EventHandler(value); + // remove => FileSizeChanged -= new EventHandler(value); + //} + + //event EventHandler ILogWindow.TailFollowed + //{ + // add => TailFollowed += new TailFollowedEventHandler(value); + // remove => TailFollowed -= new TailFollowedEventHandler(value); + //} #endregion diff --git a/src/LogExpert/Config/ConfigManager.cs b/src/LogExpert/Config/ConfigManager.cs index f11719fd..c512ec51 100644 --- a/src/LogExpert/Config/ConfigManager.cs +++ b/src/LogExpert/Config/ConfigManager.cs @@ -8,7 +8,6 @@ using LogExpert.Core.Config; using LogExpert.Core.Entities; using LogExpert.Core.EventArguments; -using LogExpert.Core.EventHandlers; using LogExpert.Core.Interface; using Newtonsoft.Json; @@ -42,7 +41,7 @@ private ConfigManager () #region Events - public event ConfigChangedEventHandler ConfigChanged; + public event EventHandler ConfigChanged; #endregion From 120e1f623e30ae9b644ca8051096ddd04ba20ad0 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Fri, 13 Jun 2025 18:22:45 +0300 Subject: [PATCH 077/142] Solved CA1823 --- src/LogExpert.UI/Controls/LogWindow/LogWindow.cs | 2 -- src/LogExpert.UI/Entities/PaintHelper.cs | 5 +---- src/LogExpert/Config/ConfigManager.cs | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index 165b7c8e..16af3385 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -97,8 +97,6 @@ public partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILog private int _filterPipeNameCounter; private List _filterResultList = []; - private EventWaitHandle _filterUpdateEvent = new ManualResetEvent(false); - private ILogLineColumnizer _forcedColumnizer; private ILogLineColumnizer _forcedColumnizerForLoading; private bool _isDeadFile; diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index 4d760cde..6ae49a44 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -13,16 +13,13 @@ namespace LogExpert.UI.Entities; //TOOD: This whole class should be refactored and rethought -//TODO: This class should not knoow ConfigManager? +//TODO: This class should not know ConfigManager? internal static class PaintHelper { #region Fields private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); - //TODO Make configurable - private static Color _bookmarkColor = Color.FromArgb(165, 200, 225); - #endregion #region Properties diff --git a/src/LogExpert/Config/ConfigManager.cs b/src/LogExpert/Config/ConfigManager.cs index c512ec51..d806ce35 100644 --- a/src/LogExpert/Config/ConfigManager.cs +++ b/src/LogExpert/Config/ConfigManager.cs @@ -25,7 +25,6 @@ public class ConfigManager : IConfigManager private static readonly object _monitor = new(); private static ConfigManager _instance; private readonly object _loadSaveLock = new(); - private readonly object _saveSaveLock = new(); private Settings _settings; #endregion From 76bea221f663997db8d20adfa25dfe36a8e4d057 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sun, 15 Jun 2025 00:01:14 +0300 Subject: [PATCH 078/142] Solved CA1304 Solved IDE0035 --- .../Classes/DateTimeParser/Tokenizer.cs | 57 ++++++++----------- .../Classes/Filter/FilterStarter.cs | 6 +- .../Classes/Log/RolloverFilenameBuilder.cs | 28 ++++----- 3 files changed, 43 insertions(+), 48 deletions(-) diff --git a/src/LogExpert.Core/Classes/DateTimeParser/Tokenizer.cs b/src/LogExpert.Core/Classes/DateTimeParser/Tokenizer.cs index ae68743c..864b96f3 100644 --- a/src/LogExpert.Core/Classes/DateTimeParser/Tokenizer.cs +++ b/src/LogExpert.Core/Classes/DateTimeParser/Tokenizer.cs @@ -1,37 +1,37 @@ -using System; +using System; +using System.Globalization; namespace LogExpert.Core.Classes.DateTimeParser; internal class Tokenizer { - private string formatString; - private int formatStringPosition; + private readonly string formatString; - public Tokenizer(string fmt) + public Tokenizer (string fmt) { formatString = fmt; } - public int Position => formatStringPosition; + public int Position { get; private set; } public int Length => formatString.Length; - public string Substring(int startIndex, int length) + public string Substring (int startIndex, int length) { return formatString.Substring(startIndex, length); } - public int Peek(int offset = 0) + public int Peek (int offset = 0) { - if (formatStringPosition + offset >= formatString.Length) + if (Position + offset >= formatString.Length) { return -1; } - return formatString[formatStringPosition + offset]; + return formatString[Position + offset]; } - public int PeekUntil(int startOffset, int until) + public int PeekUntil (int startOffset, int until) { var offset = startOffset; while (true) @@ -50,7 +50,7 @@ public int PeekUntil(int startOffset, int until) return 0; } - public bool PeekOneOf(int offset, string s) + public bool PeekOneOf (int offset, string s) { foreach (var c in s) { @@ -62,12 +62,12 @@ public bool PeekOneOf(int offset, string s) return false; } - public void Advance(int characters = 1) + public void Advance (int characters = 1) { - formatStringPosition = Math.Min(formatStringPosition + characters, formatString.Length); + Position = Math.Min(Position + characters, formatString.Length); } - public bool ReadOneOrMore(int c) + public bool ReadOneOrMore (int c) { if (Peek() != c) { @@ -82,7 +82,7 @@ public bool ReadOneOrMore(int c) return true; } - public bool ReadOneOf(string s) + public bool ReadOneOf (string s) { if (PeekOneOf(0, s)) { @@ -92,38 +92,29 @@ public bool ReadOneOf(string s) return false; } - public bool ReadString(string s, bool ignoreCase = false) + public bool ReadString (string str, bool ignoreCase = false) { - if (formatStringPosition + s.Length > formatString.Length) + if (Position + str.Length > formatString.Length) { return false; } - for (var i = 0; i < s.Length; i++) + for (var i = 0; i < str.Length; i++) { - var c1 = s[i]; + var c1 = str[i]; var c2 = (char)Peek(i); - if (ignoreCase) - { - if (char.ToLower(c1) != char.ToLower(c2)) - { - return false; - } - } - else + + if ((ignoreCase && char.ToUpperInvariant(c1) != char.ToUpperInvariant(c2)) || (!ignoreCase && c1 != c2)) { - if (c1 != c2) - { - return false; - } + return false; } } - Advance(s.Length); + Advance(str.Length); return true; } - public bool ReadEnclosed(char open, char close) + public bool ReadEnclosed (char open, char close) { if (Peek() == open) { diff --git a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs index efa6a886..c7626a81 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs @@ -1,3 +1,5 @@ +using System.Globalization; + using LogExpert.Core.Callback; using LogExpert.Core.Classes.Filter; @@ -122,8 +124,8 @@ public void CancelFilter () _shouldStop = true; lock (_filterWorkerList) { - _logger.Info("Filter cancel requested. Stopping all {0} threads.", _filterWorkerList.Count); - foreach (Filter filter in _filterWorkerList) + _logger.Info(CultureInfo.InvariantCulture, "Filter cancel requested. Stopping all {0} threads.", _filterWorkerList.Count); + foreach (var filter in _filterWorkerList) { filter.ShouldCancel = true; } diff --git a/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs b/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs index c6eab62c..912201d4 100644 --- a/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs +++ b/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs @@ -140,24 +140,26 @@ private void ParseFormatString (string formatString) { var fmt = EscapeNonvarRegions(formatString); var datePos = formatString.IndexOf("$D(", StringComparison.Ordinal); + if (datePos != -1) { var endPos = formatString.IndexOf(')', datePos); if (endPos != -1) { - _dateTimeFormat = formatString.Substring(datePos + 3, endPos - datePos - 3); - _dateTimeFormat = _dateTimeFormat.ToUpper(); - _dateTimeFormat = _dateTimeFormat.Replace('D', 'd').Replace('Y', 'y'); - - var dtf = _dateTimeFormat; - dtf = dtf.ToUpper(); - dtf = dtf.Replace("D", "\\d", StringComparison.Ordinal); - dtf = dtf.Replace("Y", "\\d", StringComparison.Ordinal); - dtf = dtf.Replace("M", "\\d", StringComparison.Ordinal); - fmt = fmt.Remove(datePos, 2); // remove $D - fmt = fmt.Remove(datePos + 1, _dateTimeFormat.Length); // replace with regex version of format - fmt = fmt.Insert(datePos + 1, dtf); - fmt = fmt.Insert(datePos + 1, "?'date'"); // name the regex group + _dateTimeFormat = formatString.Substring(datePos + 3, endPos - datePos - 3) + .ToUpper(CultureInfo.InvariantCulture) + .Replace('D', 'd') + .Replace('Y', 'y'); + + var dtf = _dateTimeFormat.ToUpper(CultureInfo.InvariantCulture) + .Replace("D", "\\d", StringComparison.Ordinal) + .Replace("Y", "\\d", StringComparison.Ordinal) + .Replace("M", "\\d", StringComparison.Ordinal); + + fmt = fmt.Remove(datePos, 2) // remove $D + .Remove(datePos + 1, _dateTimeFormat.Length) // replace with regex version of format + .Insert(datePos + 1, dtf) + .Insert(datePos + 1, "?'date'"); // name the regex group } } From 6e7dd3dea3e620c8183de4b6c760d64485b10743 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sun, 15 Jun 2025 00:49:08 +0300 Subject: [PATCH 079/142] Solved CA1305 Solved IDE0058 --- .../Classes/Bookmark/BookmarkDataProvider.cs | 4 +- .../Classes/Filter/FilterCancelHandler.cs | 6 +- .../Classes/Filter/FilterPipe.cs | 3 +- .../Classes/Filter/FilterStarter.cs | 10 +- .../Classes/Log/LogfileReader.cs | 119 +++++++++--------- src/LogExpert.Core/Classes/SysoutPipe.cs | 5 +- .../Controls/BufferedDataGridView.cs | 5 +- src/LogExpert.UI/Controls/KnobControl.cs | 3 +- .../LogWindow/LogWindowEventHandlers.cs | 15 +-- .../Controls/LogWindow/LogWindowPrivate.cs | 46 +++---- .../Controls/LogWindow/LogWindowPublic.cs | 19 +-- .../Controls/LogWindow/RangeFinder.cs | 10 +- .../LogWindow/TimeSpreadCalculator.cs | 33 ++--- .../Controls/LogWindow/TimeSpreadigControl.cs | 3 +- .../LogTabWindow/LogTabWindowEventHandlers.cs | 3 +- .../LogTabWindow/LogTabWindowPrivate.cs | 11 +- src/LogExpert/Classes/LogExpertProxy.cs | 15 +-- src/LogExpert/Config/ConfigManager.cs | 9 +- src/LogExpert/Program.cs | 5 +- src/PluginRegistry/PluginRegistry.cs | 17 +-- src/SftpFileSystemx64/SftpFileSystem.cs | 2 +- 21 files changed, 182 insertions(+), 161 deletions(-) diff --git a/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs b/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs index 23abd312..e8b7373c 100644 --- a/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs +++ b/src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs @@ -1,3 +1,5 @@ +using System.Globalization; + using LogExpert.Core.Entities; using LogExpert.Core.Interface; @@ -156,7 +158,7 @@ public void AddBookmark (Entities.Bookmark bookmark) public void ClearAllBookmarks () { - _logger.Debug("Removing all bookmarks"); + _logger.Debug(CultureInfo.InvariantCulture, "Removing all bookmarks"); BookmarkList.Clear(); OnAllBookmarksRemoved(); } diff --git a/src/LogExpert.Core/Classes/Filter/FilterCancelHandler.cs b/src/LogExpert.Core/Classes/Filter/FilterCancelHandler.cs index 18b7dd50..8fd32c11 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterCancelHandler.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterCancelHandler.cs @@ -1,4 +1,6 @@ -using LogExpert.Core.Interface; +using System.Globalization; + +using LogExpert.Core.Interface; using NLog; @@ -26,7 +28,7 @@ public FilterCancelHandler(FilterStarter filterStarter) public void EscapePressed() { - _logger.Info("FilterCancelHandler called."); + _logger.Info(CultureInfo.InvariantCulture, "FilterCancelHandler called."); _filterStarter.CancelFilter(); } diff --git a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs index afa671da..fa3a5b52 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs @@ -1,3 +1,4 @@ +using System.Globalization; using System.Text; using LogExpert.Core.Interface; using NLog; @@ -135,7 +136,7 @@ public void ShiftLineNums (int offset) public void ClearLineNums () { - _logger.Debug("FilterPipe.ClearLineNums()"); + _logger.Debug(CultureInfo.InvariantCulture, "FilterPipe.ClearLineNums()"); lock (_lineMappingList) { for (var i = 0; i < _lineMappingList.Count; ++i) diff --git a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs index c7626a81..90d8dbce 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs @@ -99,7 +99,7 @@ public async void DoFilter (FilterParams filterParams, int startLine, int maxCou break; } } - _logger.Info("FilterStarter starts worker for line {0}, lineCount {1}", workStartLine, interval); + _logger.Info(CultureInfo.InvariantCulture, "FilterStarter starts worker for line {0}, lineCount {1}", workStartLine, interval); await Task.Run(() => DoWork(filterParams, workStartLine, interval, ThreadProgressCallback)).ContinueWith(FilterDoneCallback); workStartLine += interval; @@ -144,7 +144,7 @@ private void ThreadProgressCallback (int lineCount) private Filter DoWork (FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback) { - _logger.Info("Started Filter worker [{0}] for line {1}", Environment.CurrentManagedThreadId, startLine); + _logger.Info(CultureInfo.InvariantCulture, "Started Filter worker [{0}] for line {1}", Environment.CurrentManagedThreadId, startLine); // Give every thread own copies of ColumnizerCallback and FilterParams, because the state of the objects changes while filtering FilterParams threadFilterParams = filterParams.CloneWithCurrentColumnizer(); @@ -162,7 +162,7 @@ private Filter DoWork (FilterParams filterParams, int startLine, int maxCount, P } _ = filter.DoFilter(threadFilterParams, startLine, maxCount, progressCallback); - _logger.Info("Filter worker [{0}] for line {1} has completed.", Environment.CurrentManagedThreadId, startLine); + _logger.Info(CultureInfo.InvariantCulture, "Filter worker [{0}] for line {1} has completed.", Environment.CurrentManagedThreadId, startLine); lock (_filterReadyList) { @@ -187,7 +187,7 @@ private void FilterDoneCallback (Task filterTask) private void MergeResults () { - _logger.Info("Merging filter results."); + _logger.Info(CultureInfo.InvariantCulture, "Merging filter results."); foreach (Filter filter in _filterReadyList) { foreach (var lineNum in filter.FilterHitList) @@ -215,7 +215,7 @@ private void MergeResults () FilterHitList.AddRange(_filterHitDict.Keys); FilterResultLines.AddRange(_filterResultDict.Keys); LastFilterLinesList.AddRange(_lastFilterLinesDict.Keys); - _logger.Info("Merging done."); + _logger.Info(CultureInfo.InvariantCulture, "Merging done."); } #endregion diff --git a/src/LogExpert.Core/Classes/Log/LogfileReader.cs b/src/LogExpert.Core/Classes/Log/LogfileReader.cs index 6fcfcb38..445ffd1e 100644 --- a/src/LogExpert.Core/Classes/Log/LogfileReader.cs +++ b/src/LogExpert.Core/Classes/Log/LogfileReader.cs @@ -1,3 +1,4 @@ +using System.Globalization; using System.Text; using LogExpert.Core.Classes.xml; @@ -255,7 +256,7 @@ public void ReadFiles () /// public int ShiftBuffers () { - _logger.Info("ShiftBuffers() begin for {0}{1}", _fileName, IsMultiFile ? " (MultiFile)" : ""); + _logger.Info(CultureInfo.InvariantCulture, "ShiftBuffers() begin for {0}{1}", _fileName, IsMultiFile ? " (MultiFile)" : ""); AcquireBufferListWriterLock(); var offset = 0; _isLineCountDirty = true; @@ -273,11 +274,11 @@ public int ShiftBuffers () { ILogFileInfo logFileInfo = enumerator.Current; var fileName = logFileInfo.FullName; - _logger.Debug("Testing file {0}", fileName); + _logger.Debug(CultureInfo.InvariantCulture, "Testing file {0}", fileName); LinkedListNode node = fileNameList.Find(fileName); if (node == null) { - _logger.Warn("File {0} not found", fileName); + _logger.Warn(CultureInfo.InvariantCulture, "File {0} not found", fileName); continue; } @@ -285,7 +286,7 @@ public int ShiftBuffers () { fileName = node.Previous.Value; ILogFileInfo newILogFileInfo = GetLogFileInfo(fileName); - _logger.Debug("{0} exists\r\nOld size={1}, new size={2}", fileName, logFileInfo.OriginalLength, newILogFileInfo.Length); + _logger.Debug(CultureInfo.InvariantCulture, "{0} exists\r\nOld size={1}, new size={2}", fileName, logFileInfo.OriginalLength, newILogFileInfo.Length); // is the new file the same as the old buffer info? if (newILogFileInfo.Length == logFileInfo.OriginalLength) { @@ -294,7 +295,7 @@ public int ShiftBuffers () } else { - _logger.Debug("Buffer for {0} must be re-read.", fileName); + _logger.Debug(CultureInfo.InvariantCulture, "Buffer for {0} must be re-read.", fileName); // not the same. so must read the rest of the list anew from the files readNewILogFileInfoList.Add(newILogFileInfo); while (enumerator.MoveNext()) @@ -303,26 +304,26 @@ public int ShiftBuffers () node = fileNameList.Find(fileName); if (node == null) { - _logger.Warn("File {0} not found", fileName); + _logger.Warn(CultureInfo.InvariantCulture, "File {0} not found", fileName); continue; } if (node.Previous != null) { fileName = node.Previous.Value; - _logger.Debug("New name is {0}", fileName); + _logger.Debug(CultureInfo.InvariantCulture, "New name is {0}", fileName); readNewILogFileInfoList.Add(GetLogFileInfo(fileName)); } else { - _logger.Warn("No previous file for {0} found", fileName); + _logger.Warn(CultureInfo.InvariantCulture, "No previous file for {0} found", fileName); } } } } else { - _logger.Info("{0} does not exist", fileName); + _logger.Info(CultureInfo.InvariantCulture, "{0} does not exist", fileName); lostILogFileInfoList.Add(logFileInfo); #if DEBUG // for better overview in logfile: //ILogFileInfo newILogFileInfo = new ILogFileInfo(fileName); @@ -333,7 +334,7 @@ public int ShiftBuffers () if (lostILogFileInfoList.Count > 0) { - _logger.Info("Deleting buffers for lost files"); + _logger.Info(CultureInfo.InvariantCulture, "Deleting buffers for lost files"); foreach (ILogFileInfo ILogFileInfo in lostILogFileInfoList) { //this.ILogFileInfoList.Remove(ILogFileInfo); @@ -345,7 +346,7 @@ public int ShiftBuffers () } _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); - _logger.Info("Adjusting StartLine values in {0} buffers by offset {1}", _bufferList.Count, offset); + _logger.Info(CultureInfo.InvariantCulture, "Adjusting StartLine values in {0} buffers by offset {1}", _bufferList.Count, offset); foreach (LogBuffer buffer in _bufferList) { SetNewStartLineForBuffer(buffer, buffer.StartLine - offset); @@ -355,23 +356,23 @@ public int ShiftBuffers () #if DEBUG if (_bufferList.Count > 0) { - _logger.Debug("First buffer now has StartLine {0}", _bufferList[0].StartLine); + _logger.Debug(CultureInfo.InvariantCulture, "First buffer now has StartLine {0}", _bufferList[0].StartLine); } #endif } // Read anew all buffers following a buffer info that couldn't be matched with the corresponding existing file - _logger.Info("Deleting buffers for files that must be re-read"); + _logger.Info(CultureInfo.InvariantCulture, "Deleting buffers for files that must be re-read"); foreach (ILogFileInfo ILogFileInfo in readNewILogFileInfoList) { DeleteBuffersForInfo(ILogFileInfo, true); //this.ILogFileInfoList.Remove(ILogFileInfo); } - _logger.Info("Deleting buffers for the watched file"); + _logger.Info(CultureInfo.InvariantCulture, "Deleting buffers for the watched file"); DeleteBuffersForInfo(_watchedILogFileInfo, true); var startLine = LineCount - 1; - _logger.Info("Re-Reading files"); + _logger.Info(CultureInfo.InvariantCulture, "Re-Reading files"); foreach (ILogFileInfo ILogFileInfo in readNewILogFileInfoList) { //ILogFileInfo.OpenFile(); @@ -384,11 +385,11 @@ public int ShiftBuffers () _logFileInfoList = newFileInfoList; _watchedILogFileInfo = GetLogFileInfo(_watchedILogFileInfo.FullName); _logFileInfoList.Add(_watchedILogFileInfo); - _logger.Info("Reading watched file"); + _logger.Info(CultureInfo.InvariantCulture, "Reading watched file"); ReadToBufferList(_watchedILogFileInfo, 0, LineCount); } - _logger.Info("ShiftBuffers() end. offset={0}", offset); + _logger.Info(CultureInfo.InvariantCulture, "ShiftBuffers() end. offset={0}", offset); ReleaseBufferListWriterLock(); return offset; } @@ -430,12 +431,12 @@ public async Task GetLogLineWithWait (int lineNum) else { _isFastFailOnGetLogLine = true; - _logger.Debug("No result after {0}ms. Returning .", WAIT_TIME); + _logger.Debug(CultureInfo.InvariantCulture, "No result after {0}ms. Returning .", WAIT_TIME); } } else { - _logger.Debug("Fast failing GetLogLine()"); + _logger.Debug(CultureInfo.InvariantCulture, "Fast failing GetLogLine()"); if (!_isFailModeCheckCallPending) { _isFailModeCheckCallPending = true; @@ -560,14 +561,14 @@ public int GetRealLineNumForVirtualLineNum (int lineNum) public void StartMonitoring () { - _logger.Info("startMonitoring()"); + _logger.Info(CultureInfo.InvariantCulture, "startMonitoring()"); _monitorTask = Task.Run(MonitorThreadProc, _cts.Token); _shouldStop = false; } public void StopMonitoring () { - _logger.Info("stopMonitoring()"); + _logger.Info(CultureInfo.InvariantCulture, "stopMonitoring()"); _shouldStop = true; Thread.Sleep(_watchedILogFileInfo.PollInterval); // leave time for the threads to stop by themselves @@ -617,11 +618,11 @@ public void DeleteAllContent () { if (_contentDeleted) { - _logger.Debug("Buffers for {0} already deleted.", Util.GetNameFromPath(_fileName)); + _logger.Debug(CultureInfo.InvariantCulture, "Buffers for {0} already deleted.", Util.GetNameFromPath(_fileName)); return; } - _logger.Info("Deleting all log buffers for {0}. Used mem: {1:N0}", Util.GetNameFromPath(_fileName), GC.GetTotalMemory(true)); //TODO [Z] uh GC collect calls creepy + _logger.Info(CultureInfo.InvariantCulture, "Deleting all log buffers for {0}. Used mem: {1:N0}", Util.GetNameFromPath(_fileName), GC.GetTotalMemory(true)); //TODO [Z] uh GC collect calls creepy AcquireBufferListWriterLock(); _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); _disposeLock.AcquireWriterLock(Timeout.Infinite); @@ -642,7 +643,7 @@ public void DeleteAllContent () ReleaseBufferListWriterLock(); GC.Collect(); _contentDeleted = true; - _logger.Info("Deleting complete. Used mem: {0:N0}", GC.GetTotalMemory(true)); //TODO [Z] uh GC collect calls creepy + _logger.Info(CultureInfo.InvariantCulture, "Deleting complete. Used mem: {0:N0}", GC.GetTotalMemory(true)); //TODO [Z] uh GC collect calls creepy } /// @@ -692,13 +693,13 @@ public void LogBufferInfoForLine (int lineNum) return; } - _logger.Info("-----------------------------------"); + _logger.Info(CultureInfo.InvariantCulture, "-----------------------------------"); _disposeLock.AcquireReaderLock(Timeout.Infinite); - _logger.Info("Buffer info for line {0}", lineNum); + _logger.Info(CultureInfo.InvariantCulture, "Buffer info for line {0}", lineNum); DumpBufferInfos(buffer); - _logger.Info("File pos for current line: {0}", buffer.GetFilePosForLineOfBlock(lineNum - buffer.StartLine)); + _logger.Info(CultureInfo.InvariantCulture, "File pos for current line: {0}", buffer.GetFilePosForLineOfBlock(lineNum - buffer.StartLine)); _disposeLock.ReleaseReaderLock(); - _logger.Info("-----------------------------------"); + _logger.Info(CultureInfo.InvariantCulture, "-----------------------------------"); ReleaseBufferListReaderLock(); } #endif @@ -706,14 +707,14 @@ public void LogBufferInfoForLine (int lineNum) #if DEBUG public void LogBufferDiagnostic () { - _logger.Info("-------- Buffer diagnostics -------"); + _logger.Info(CultureInfo.InvariantCulture, "-------- Buffer diagnostics -------"); _lruCacheDictLock.AcquireReaderLock(Timeout.Infinite); var cacheCount = _lruCacheDict.Count; - _logger.Info("LRU entries: {0}", cacheCount); + _logger.Info(CultureInfo.InvariantCulture, "LRU entries: {0}", cacheCount); _lruCacheDictLock.ReleaseReaderLock(); AcquireBufferListReaderLock(); - _logger.Info("File: {0}\r\nBuffer count: {1}\r\nDisposed buffers: {2}", _fileName, _bufferList.Count, _bufferList.Count - cacheCount); + _logger.Info(CultureInfo.InvariantCulture, "File: {0}\r\nBuffer count: {1}\r\nDisposed buffers: {2}", _fileName, _bufferList.Count, _bufferList.Count - cacheCount); var lineNum = 0; long disposeSum = 0; long maxDispose = 0; @@ -725,7 +726,7 @@ public void LogBufferDiagnostic () if (buffer.StartLine != lineNum) { _logger.Error("Start line of buffer is: {0}, expected: {1}", buffer.StartLine, lineNum); - _logger.Info("Info of buffer follows:"); + _logger.Info(CultureInfo.InvariantCulture, "Info of buffer follows:"); DumpBufferInfos(buffer); } @@ -737,7 +738,7 @@ public void LogBufferDiagnostic () } ReleaseBufferListReaderLock(); - _logger.Info("Dispose count sum is: {0}\r\nMin dispose count is: {1}\r\nMax dispose count is: {2}\r\n-----------------------------------", disposeSum, minDispose, maxDispose); + _logger.Info(CultureInfo.InvariantCulture, "Dispose count sum is: {0}\r\nMin dispose count is: {1}\r\nMax dispose count is: {2}\r\n-----------------------------------", disposeSum, minDispose, maxDispose); } #endif @@ -748,7 +749,7 @@ public void LogBufferDiagnostic () private ILogFileInfo AddFile (string fileName) { - _logger.Info("Adding file to ILogFileInfoList: " + fileName); + _logger.Info(CultureInfo.InvariantCulture, "Adding file to ILogFileInfoList: " + fileName); ILogFileInfo info = GetLogFileInfo(fileName); _logFileInfoList.Add(info); return info; @@ -758,7 +759,7 @@ private Task GetLogLineInternal (int lineNum) { if (_isDeleted) { - _logger.Debug("Returning null for line {0} because file is deleted.", lineNum); + _logger.Debug(CultureInfo.InvariantCulture, "Returning null for line {0} because file is deleted.", lineNum); // fast fail if dead file was detected. Prevents repeated lags in GUI thread caused by callbacks from control (e.g. repaint) return null; @@ -844,7 +845,7 @@ private ILogFileInfo GetLogFileInfo (string fileNameOrUri) //TODO: I changed to private void ReplaceBufferInfos (ILogFileInfo oldLogFileInfo, ILogFileInfo newLogFileInfo) { - _logger.Debug("ReplaceBufferInfos() " + oldLogFileInfo.FullName + " -> " + newLogFileInfo.FullName); + _logger.Debug(CultureInfo.InvariantCulture, "ReplaceBufferInfos() " + oldLogFileInfo.FullName + " -> " + newLogFileInfo.FullName); AcquireBufferListReaderLock(); foreach (var buffer in _bufferList) { @@ -897,11 +898,11 @@ private LogBuffer DeleteBuffersForInfo (ILogFileInfo ILogFileInfo, bool matchNam ReleaseBufferListWriterLock(); if (lastRemovedBuffer == null) { - _logger.Info("lastRemovedBuffer is null"); + _logger.Info(CultureInfo.InvariantCulture, "lastRemovedBuffer is null"); } else { - _logger.Info("lastRemovedBuffer: startLine={0}", lastRemovedBuffer.StartLine); + _logger.Info(CultureInfo.InvariantCulture, "lastRemovedBuffer: startLine={0}", lastRemovedBuffer.StartLine); } return lastRemovedBuffer; @@ -1047,7 +1048,7 @@ private void ReadToBufferList (ILogFileInfo logFileInfo, long filePos, int start private void AddBufferToList (LogBuffer logBuffer) { #if DEBUG - _logger.Debug("AddBufferToList(): {0}/{1}/{2}", logBuffer.StartLine, logBuffer.LineCount, logBuffer.FileInfo.FullName); + _logger.Debug(CultureInfo.InvariantCulture, "AddBufferToList(): {0}/{1}/{2}", logBuffer.StartLine, logBuffer.LineCount, logBuffer.FileInfo.FullName); #endif _bufferList.Add(logBuffer); //UpdateLru(logBuffer); @@ -1078,16 +1079,16 @@ private void UpdateLruCache (LogBuffer logBuffer) _logger.Error(e, "Error in LRU cache: " + e.Message); #if DEBUG // there seems to be a bug with double added key - _logger.Info("Added buffer:"); + _logger.Info(CultureInfo.InvariantCulture, "Added buffer:"); DumpBufferInfos(logBuffer); if (_lruCacheDict.TryGetValue(logBuffer.StartLine, out LogBufferCacheEntry existingEntry)) { - _logger.Info("Existing buffer: "); + _logger.Info(CultureInfo.InvariantCulture, "Existing buffer: "); DumpBufferInfos(existingEntry.LogBuffer); } else { - _logger.Warn("Ooops? Cannot find the already existing entry in LRU."); + _logger.Warn(CultureInfo.InvariantCulture, "Ooops? Cannot find the already existing entry in LRU."); } #endif _lruCacheDictLock.ReleaseLock(); @@ -1129,7 +1130,7 @@ private void GarbageCollectLruCache () #if DEBUG long startTime = Environment.TickCount; #endif - _logger.Debug("Starting garbage collection"); + _logger.Debug(CultureInfo.InvariantCulture, "Starting garbage collection"); var threshold = 10; _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); var diff = 0; @@ -1139,7 +1140,7 @@ private void GarbageCollectLruCache () #if DEBUG if (diff > 0) { - _logger.Info("Removing {0} entries from LRU cache for {1}", diff, Util.GetNameFromPath(_fileName)); + _logger.Info(CultureInfo.InvariantCulture, "Removing {0} entries from LRU cache for {1}", diff, Util.GetNameFromPath(_fileName)); } #endif SortedList useSorterList = []; @@ -1175,7 +1176,7 @@ private void GarbageCollectLruCache () if (diff > 0) { long endTime = Environment.TickCount; - _logger.Info("Garbage collector time: " + (endTime - startTime) + " ms."); + _logger.Info(CultureInfo.InvariantCulture, "Garbage collector time: " + (endTime - startTime) + " ms."); } #endif } @@ -1283,7 +1284,7 @@ private void ClearLru () // this.bufferLru.Clear(); // this.lruDict.Clear(); //} - _logger.Info("Clearing LRU cache."); + _logger.Info(CultureInfo.InvariantCulture, "Clearing LRU cache."); _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); _disposeLock.AcquireWriterLock(Timeout.Infinite); foreach (LogBufferCacheEntry entry in _lruCacheDict.Values) @@ -1294,13 +1295,13 @@ private void ClearLru () _lruCacheDict.Clear(); _disposeLock.ReleaseWriterLock(); _lruCacheDictLock.ReleaseWriterLock(); - _logger.Info("Clearing done."); + _logger.Info(CultureInfo.InvariantCulture, "Clearing done."); } private void ReReadBuffer (LogBuffer logBuffer) { #if DEBUG - _logger.Info("re-reading buffer: {0}/{1}/{2}", logBuffer.StartLine, logBuffer.LineCount, logBuffer.FileInfo.FullName); + _logger.Info(CultureInfo.InvariantCulture, "re-reading buffer: {0}/{1}/{2}", logBuffer.StartLine, logBuffer.LineCount, logBuffer.FileInfo.FullName); #endif try { @@ -1353,12 +1354,12 @@ private void ReReadBuffer (LogBuffer logBuffer) if (maxLinesCount != logBuffer.LineCount) { - _logger.Warn("LineCount in buffer differs after re-reading. old={0}, new={1}", maxLinesCount, logBuffer.LineCount); + _logger.Warn(CultureInfo.InvariantCulture, "LineCount in buffer differs after re-reading. old={0}, new={1}", maxLinesCount, logBuffer.LineCount); } if (dropCount - logBuffer.PrevBuffersDroppedLinesSum != logBuffer.DroppedLinesCount) { - _logger.Warn("DroppedLinesCount in buffer differs after re-reading. old={0}, new={1}", logBuffer.DroppedLinesCount, dropCount); + _logger.Warn(CultureInfo.InvariantCulture, "DroppedLinesCount in buffer differs after re-reading. old={0}, new={1}", logBuffer.DroppedLinesCount, dropCount); logBuffer.DroppedLinesCount = dropCount - logBuffer.PrevBuffersDroppedLinesSum; } @@ -1422,11 +1423,11 @@ private void GetLineFinishedCallback (ILogLine line) _isFailModeCheckCallPending = false; if (line != null) { - _logger.Debug("'isFastFailOnGetLogLine' flag was reset"); + _logger.Debug(CultureInfo.InvariantCulture, "'isFastFailOnGetLogLine' flag was reset"); _isFastFailOnGetLogLine = false; } - _logger.Debug("'isLogLineCallPending' flag was reset."); + _logger.Debug(CultureInfo.InvariantCulture, "'isLogLineCallPending' flag was reset."); } private LogBuffer GetFirstBufferForFileByLogBuffer (LogBuffer logBuffer) @@ -1460,7 +1461,7 @@ private void MonitorThreadProc () { Thread.CurrentThread.Name = "MonitorThread"; //IFileSystemPlugin fs = PluginRegistry.GetInstance().FindFileSystemForUri(this.watchedILogFileInfo.FullName); - _logger.Info("MonitorThreadProc() for file {0}", _watchedILogFileInfo.FullName); + _logger.Info(CultureInfo.InvariantCulture, "MonitorThreadProc() for file {0}", _watchedILogFileInfo.FullName); long oldSize; try @@ -1529,7 +1530,7 @@ private void MonitoredFileNotFound () long oldSize; if (!_isDeleted) { - _logger.Debug("File not FileNotFoundException catched. Switching to 'deleted' mode."); + _logger.Debug(CultureInfo.InvariantCulture, "File not FileNotFoundException catched. Switching to 'deleted' mode."); _isDeleted = true; oldSize = _fileLength = -1; FileSize = 0; @@ -1538,7 +1539,7 @@ private void MonitoredFileNotFound () #if DEBUG else { - _logger.Debug("File not FileNotFoundException catched. Already in deleted mode."); + _logger.Debug(CultureInfo.InvariantCulture, "File not FileNotFoundException catched. Already in deleted mode."); } #endif } @@ -1555,7 +1556,7 @@ private void FileChanged () var newSize = _fileLength; //if (this.currFileSize != newSize) { - _logger.Info("file size changed. new size={0}, file: {1}", newSize, _fileName); + _logger.Info(CultureInfo.InvariantCulture, "file size changed. new size={0}, file: {1}", newSize, _fileName); FireChangeEvent(); } } @@ -1568,7 +1569,7 @@ private void FireChangeEvent () var newSize = _fileLength; if (newSize < FileSize || _isDeleted) { - _logger.Info("File was created anew: new size={0}, oldSize={1}", newSize, FileSize); + _logger.Info(CultureInfo.InvariantCulture, "File was created anew: new size={0}, oldSize={1}", newSize, FileSize); // Fire "New File" event FileSize = 0; LineCount = 0; @@ -1769,7 +1770,7 @@ private void DumpBufferInfos (LogBuffer buffer) { if (_logger.IsTraceEnabled) { - _logger.Trace("StartLine: {0}\r\nLineCount: {1}\r\nStartPos: {2}\r\nSize: {3}\r\nDisposed: {4}\r\nDisposeCount: {5}\r\nFile: {6}", + _logger.Trace(CultureInfo.InvariantCulture, "StartLine: {0}\r\nLineCount: {1}\r\nStartPos: {2}\r\nSize: {3}\r\nDisposed: {4}\r\nDisposeCount: {5}\r\nFile: {6}", buffer.StartLine, buffer.LineCount, buffer.StartPos, @@ -1837,7 +1838,7 @@ protected virtual void OnFileNotFound () protected virtual void OnRespawned () { - _logger.Info("OnRespawned()"); + _logger.Info(CultureInfo.InvariantCulture, "OnRespawned()"); Respawned?.Invoke(this, EventArgs.Empty); } diff --git a/src/LogExpert.Core/Classes/SysoutPipe.cs b/src/LogExpert.Core/Classes/SysoutPipe.cs index 89f89927..4068cf1c 100644 --- a/src/LogExpert.Core/Classes/SysoutPipe.cs +++ b/src/LogExpert.Core/Classes/SysoutPipe.cs @@ -1,6 +1,7 @@ -using NLog; +using NLog; using System.Diagnostics; +using System.Globalization; using System.Text; namespace LogExpert.Core.Classes; @@ -24,7 +25,7 @@ public SysoutPipe(StreamReader sysout) _disposed = false; this._sysout = sysout; FileName = Path.GetTempFileName(); - _logger.Info("sysoutPipe created temp file: {0}", FileName); + _logger.Info(CultureInfo.InvariantCulture, "sysoutPipe created temp file: {0}", FileName); FileStream fStream = new(FileName, FileMode.Append, FileAccess.Write, FileShare.Read); _writer = new StreamWriter(fStream, Encoding.Unicode); diff --git a/src/LogExpert.UI/Controls/BufferedDataGridView.cs b/src/LogExpert.UI/Controls/BufferedDataGridView.cs index c52e73bc..278857a6 100644 --- a/src/LogExpert.UI/Controls/BufferedDataGridView.cs +++ b/src/LogExpert.UI/Controls/BufferedDataGridView.cs @@ -1,4 +1,5 @@ using System.Drawing.Drawing2D; +using System.Globalization; using System.Runtime.Versioning; using LogExpert.Core.Entities; @@ -264,7 +265,7 @@ private void PaintOverlays (PaintEventArgs e) if (_logger.IsDebugEnabled) { - _logger.Debug("ClipRgn: {0},{1},{2},{3}", myBuffer.Graphics.ClipBounds.Left, myBuffer.Graphics.ClipBounds.Top, myBuffer.Graphics.ClipBounds.Width, myBuffer.Graphics.ClipBounds.Height); + _logger.Debug(CultureInfo.InvariantCulture, "ClipRgn: {0},{1},{2},{3}", myBuffer.Graphics.ClipBounds.Left, myBuffer.Graphics.ClipBounds.Top, myBuffer.Graphics.ClipBounds.Width, myBuffer.Graphics.ClipBounds.Height); } } } @@ -325,7 +326,7 @@ private void OnControlKeyDown (object sender, KeyEventArgs e) } else { - _logger.Warn("Edit control was null, to be checked"); + _logger.Warn(CultureInfo.InvariantCulture, "Edit control was null, to be checked"); } } } diff --git a/src/LogExpert.UI/Controls/KnobControl.cs b/src/LogExpert.UI/Controls/KnobControl.cs index b63eb5c4..693b6f2a 100644 --- a/src/LogExpert.UI/Controls/KnobControl.cs +++ b/src/LogExpert.UI/Controls/KnobControl.cs @@ -1,5 +1,6 @@ using NLog; +using System.Globalization; using System.Runtime.Versioning; namespace LogExpert.UI.Controls; @@ -147,7 +148,7 @@ protected override void OnMouseMove(MouseEventArgs e) var sense = _isShiftPressed ? DragSensitivity * 2 : DragSensitivity; var diff = _startMouseY - e.Y; - _logger.Debug("KnobDiff: {0}", diff); + _logger.Debug(CultureInfo.InvariantCulture, "KnobDiff: {0}", diff); var range = MaxValue - MinValue; _value = _oldValue + diff / sense; diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs index 40d1647c..8c90d136 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs @@ -1,4 +1,5 @@ using System.ComponentModel; +using System.Globalization; using System.Runtime.Versioning; using LogExpert.Core.Classes; @@ -127,7 +128,7 @@ private void OnLogFileReaderLoadingStarted (object sender, LoadFileEventArgs e) private void OnLogFileReaderFinishedLoading (object sender, EventArgs e) { //Thread.CurrentThread.Name = "FinishedLoading event thread"; - _logger.Info("Finished loading."); + _logger.Info(CultureInfo.InvariantCulture, "Finished loading."); _isLoading = false; _isDeadFile = false; if (!_waitingForClose) @@ -146,7 +147,7 @@ private void OnLogFileReaderFinishedLoading (object sender, EventArgs e) if (filterTailCheckBox.Checked) { - _logger.Info("Refreshing filter view because of reload."); + _logger.Info(CultureInfo.InvariantCulture, "Refreshing filter view because of reload."); Invoke(new MethodInvoker(FilterSearch)); // call on proper thread } @@ -161,7 +162,7 @@ private void OnLogFileReaderFileNotFound (object sender, EventArgs e) { if (!IsDisposed && !Disposing) { - _logger.Info("Handling file not found event."); + _logger.Info(CultureInfo.InvariantCulture, "Handling file not found event."); _isDeadFile = true; BeginInvoke(new MethodInvoker(LogfileDead)); } @@ -204,7 +205,7 @@ private void OnLogFileReaderLoadFile (object sender, LoadFileEventArgs e) { if (e.NewFile) { - _logger.Info("File created anew."); + _logger.Info(CultureInfo.InvariantCulture, "File created anew."); // File was new created (e.g. rollover) _isDeadFile = false; @@ -214,7 +215,7 @@ private void OnLogFileReaderLoadFile (object sender, LoadFileEventArgs e) BeginInvoke(invoker); //Thread loadThread = new Thread(new ThreadStart(ReloadNewFile)); //loadThread.Start(); - _logger.Debug("Reloading invoked."); + _logger.Debug(CultureInfo.InvariantCulture, "Reloading invoked."); } else if (_isLoading) { @@ -225,7 +226,7 @@ private void OnLogFileReaderLoadFile (object sender, LoadFileEventArgs e) private void OnFileSizeChanged (object sender, LogEventArgs e) { //OnFileSizeChanged(e); // now done in UpdateGrid() - _logger.Info("Got FileSizeChanged event. prevLines:{0}, curr lines: {1}", e.PrevLineCount, e.LineCount); + _logger.Info(CultureInfo.InvariantCulture, "Got FileSizeChanged event. prevLines:{0}, curr lines: {1}", e.PrevLineCount, e.LineCount); // - now done in the thread that works on the event args list //if (e.IsRollover) @@ -685,7 +686,7 @@ private void OnSelectionChangedTriggerSignal (object sender, EventArgs e) var selCount = 0; try { - _logger.Debug("Selection changed trigger"); + _logger.Debug(CultureInfo.InvariantCulture, "Selection changed trigger"); selCount = dataGridView.SelectedRows.Count; if (selCount > 1) { diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs index 49b9f505..d7844929 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs @@ -131,7 +131,7 @@ private bool LoadPersistenceOptions () if (persistenceData.MultiFileNames.Count > 0) { - _logger.Info("Detected MultiFile name list in persistence options"); + _logger.Info(CultureInfo.InvariantCulture, "Detected MultiFile name list in persistence options"); _fileNames = new string[persistenceData.MultiFileNames.Count]; persistenceData.MultiFileNames.CopyTo(_fileNames); } @@ -306,7 +306,7 @@ private void ReInitFilterParams (FilterParams filterParams) private void EnterLoadFileStatus () { - _logger.Debug("EnterLoadFileStatus begin"); + _logger.Debug(CultureInfo.InvariantCulture, "EnterLoadFileStatus begin"); if (InvokeRequired) { @@ -331,7 +331,7 @@ private void EnterLoadFileStatus () ClearBookmarkList(); dataGridView.ClearSelection(); dataGridView.RowCount = 0; - _logger.Debug("EnterLoadFileStatus end"); + _logger.Debug(CultureInfo.InvariantCulture, "EnterLoadFileStatus end"); } [SupportedOSPlatform("windows")] @@ -351,7 +351,7 @@ private void PositionAfterReload (ReloadMemento reloadMemento) [SupportedOSPlatform("windows")] private void LogfileDead () { - _logger.Info("File not found."); + _logger.Info(CultureInfo.InvariantCulture, "File not found."); _isDeadFile = true; //this.logFileReader.FileSizeChanged -= this.FileSizeChangedHandler; @@ -378,7 +378,7 @@ private void LogfileDead () [SupportedOSPlatform("windows")] private void LogfileRespawned () { - _logger.Info("LogfileDead(): Reloading file because it has been respawned."); + _logger.Info(CultureInfo.InvariantCulture, "LogfileDead(): Reloading file because it has been respawned."); _isDeadFile = false; dataGridView.Enabled = true; StatusLineText(""); @@ -504,7 +504,7 @@ private void ReloadNewFile () } else { - _logger.Debug("Preventing reload because of recursive calls."); + _logger.Debug(CultureInfo.InvariantCulture, "Preventing reload because of recursive calls."); } _reloadOverloadCounter--; @@ -514,9 +514,9 @@ private void ReloadNewFile () [SupportedOSPlatform("windows")] private void ReloadFinishedThreadFx () { - _logger.Info("Waiting for loading to be complete."); + _logger.Info(CultureInfo.InvariantCulture, "Waiting for loading to be complete."); _loadingFinishedEvent.WaitOne(); - _logger.Info("Refreshing filter view because of reload."); + _logger.Info(CultureInfo.InvariantCulture, "Refreshing filter view because of reload."); Invoke(new MethodInvoker(FilterSearch)); LoadFilterPipes(); } @@ -527,7 +527,7 @@ private void UpdateProgress (LoadFileEventArgs e) { if (e.ReadPos >= e.FileSize) { - //_logger.Warn("UpdateProgress(): ReadPos (" + e.ReadPos + ") is greater than file size (" + e.FileSize + "). Aborting Update"); + //_logger.Warn(CultureInfo.InvariantCulture, "UpdateProgress(): ReadPos (" + e.ReadPos + ") is greater than file size (" + e.FileSize + "). Aborting Update"); return; } @@ -564,7 +564,7 @@ private void LoadingStarted (LoadFileEventArgs e) private void LoadingFinished () { - _logger.Info("File loading complete."); + _logger.Info(CultureInfo.InvariantCulture, "File loading complete."); StatusLineText(""); _logFileReader.FileSizeChanged += OnFileSizeChanged; @@ -599,16 +599,16 @@ private void LogEventWorker () Thread.CurrentThread.Name = "LogEventWorker"; while (true) { - _logger.Debug("Waiting for signal"); + _logger.Debug(CultureInfo.InvariantCulture, "Waiting for signal"); _logEventArgsEvent.WaitOne(); - _logger.Debug("Wakeup signal received."); + _logger.Debug(CultureInfo.InvariantCulture, "Wakeup signal received."); while (true) { LogEventArgs e; var lastLineCount = 0; lock (_logEventArgsList) { - _logger.Info("{0} events in queue", _logEventArgsList.Count); + _logger.Info(CultureInfo.InvariantCulture, "{0} events in queue", _logEventArgsList.Count); if (_logEventArgsList.Count == 0) { _logEventArgsEvent.Reset(); @@ -687,7 +687,7 @@ private void UpdateGrid (LogEventArgs e) dataGridView.RowCount = e.LineCount; } - _logger.Debug("UpdateGrid(): new RowCount={0}", dataGridView.RowCount); + _logger.Debug(CultureInfo.InvariantCulture, "UpdateGrid(): new RowCount={0}", dataGridView.RowCount); if (e.IsRollover) { @@ -702,7 +702,7 @@ private void UpdateGrid (LogEventArgs e) currentLineNum = 0; } - _logger.Debug("UpdateGrid(): Rollover=true, Rollover offset={0}, currLineNum was {1}, new currLineNum={2}", e.RolloverOffset, dataGridView.CurrentCellAddress.Y, currentLineNum); + _logger.Debug(CultureInfo.InvariantCulture, "UpdateGrid(): Rollover=true, Rollover offset={0}, currLineNum was {1}, new currLineNum={2}", e.RolloverOffset, dataGridView.CurrentCellAddress.Y, currentLineNum); firstDisplayedLine -= e.RolloverOffset; if (firstDisplayedLine < 0) { @@ -924,7 +924,7 @@ private void SetColumnizer (ILogLineColumnizer columnizer) private void SetColumnizerInternal (ILogLineColumnizer columnizer) { - _logger.Info("SetColumnizerInternal(): {0}", columnizer.GetName()); + _logger.Info(CultureInfo.InvariantCulture, "SetColumnizerInternal(): {0}", columnizer.GetName()); ILogLineColumnizer oldColumnizer = CurrentColumnizer; var oldColumnizerIsXmlType = CurrentColumnizer is ILogLineXmlColumnizer; @@ -1761,7 +1761,7 @@ private void StartEditMode () } else { - _logger.Warn("Edit control in logWindow was null"); + _logger.Warn(CultureInfo.InvariantCulture, "Edit control in logWindow was null"); } } } @@ -1775,7 +1775,7 @@ private void UpdateEditColumnDisplay (DataGridViewTextBoxEditingControl editCont { var pos = editControl.SelectionStart + editControl.SelectionLength; StatusLineText(" " + pos); - _logger.Debug("SelStart: {0}, SelLen: {1}", editControl.SelectionStart, editControl.SelectionLength); + _logger.Debug(CultureInfo.InvariantCulture, "SelStart: {0}, SelLen: {1}", editControl.SelectionStart, editControl.SelectionLength); } } @@ -2703,7 +2703,7 @@ private void WriteFilterToTab () [SupportedOSPlatform("windows")] private void WritePipeToTab (FilterPipe pipe, IList lineNumberList, string name, PersistenceData persistenceData) { - _logger.Info("WritePipeToTab(): {0} lines.", lineNumberList.Count); + _logger.Info(CultureInfo.InvariantCulture, "WritePipeToTab(): {0} lines.", lineNumberList.Count); StatusLineText("Writing to temp file... Press ESC to cancel."); _guiStateArgs.MenuEnabled = false; SendGuiStateUpdate(); @@ -2747,7 +2747,7 @@ private void WritePipeToTab (FilterPipe pipe, IList lineNumberList, string } pipe.CloseFile(); - _logger.Info("WritePipeToTab(): finished"); + _logger.Info(CultureInfo.InvariantCulture, "WritePipeToTab(): finished"); Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), pipe, name, persistenceData); } @@ -3146,7 +3146,7 @@ private void TestStatistic (PatternArgs patternArgs) PatternBlock block; var maxBlockLen = patternArgs.EndLine - patternArgs.StartLine; //int searchLine = i + 1; - _logger.Debug("TestStatistic(): i={0} searchLine={1}", i, searchLine); + _logger.Debug(CultureInfo.InvariantCulture, "TestStatistic(): i={0} searchLine={1}", i, searchLine); //bool firstBlock = true; searchLine++; UpdateProgressBar(searchLine); @@ -3156,7 +3156,7 @@ private void TestStatistic (PatternArgs patternArgs) _patternArgs.MaxMisses, processedLinesDict)) != null) { - _logger.Debug("Found block: {0}", block); + _logger.Debug(CultureInfo.InvariantCulture, "Found block: {0}", block); if (block.Weigth >= _patternArgs.MinWeight) { //PatternBlock existingBlock = FindExistingBlock(block, blockList); @@ -3202,7 +3202,7 @@ private void TestStatistic (PatternArgs patternArgs) // this.Invoke(new MethodInvoker(CreatePatternWindow)); //} _patternWindow.SetBlockList(blockList, _patternArgs); - _logger.Info("TestStatistics() ended"); + _logger.Info(CultureInfo.InvariantCulture, "TestStatistics() ended"); } private void AddBlockTargetLinesToDict (Dictionary dict, PatternBlock block) diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs index 9fce6a8c..a00a8c24 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs @@ -1,3 +1,4 @@ +using System.Globalization; using System.Text; using LogExpert.Core.Classes; @@ -136,13 +137,13 @@ public void LoadFile (string fileName, EncodingOptions encodingOptions) public void LoadFilesAsMulti (string[] fileNames, EncodingOptions encodingOptions) { - _logger.Info("Loading given files as MultiFile:"); + _logger.Info(CultureInfo.InvariantCulture, "Loading given files as MultiFile:"); EnterLoadFileStatus(); foreach (var name in fileNames) { - _logger.Info("File: {0}", name); + _logger.Info(CultureInfo.InvariantCulture, "File: {0}", name); } if (_logFileReader != null) @@ -292,7 +293,7 @@ public void CloseLogWindow () if (IsTempFile) { - _logger.Info("Deleting temp file {0}", FileName); + _logger.Info(CultureInfo.InvariantCulture, "Deleting temp file {0}", FileName); try { @@ -883,7 +884,7 @@ public void AddBookmarkOverlays () } if (_logger.IsDebugEnabled) { - _logger.Debug("AddBookmarkOverlay() r.Location={0}, width={1}, scroll_offset={2}", r.Location.X, r.Width, dataGridView.HorizontalScrollingOffset); + _logger.Debug(CultureInfo.InvariantCulture, "AddBookmarkOverlay() r.Location={0}, width={1}, scroll_offset={2}", r.Location.X, r.Width, dataGridView.HorizontalScrollingOffset); } overlay.Position = r.Location - new Size(dataGridView.HorizontalScrollingOffset, 0); overlay.Position += new Size(10, r.Height / 2); @@ -1406,7 +1407,7 @@ public int FindTimestampLine (int lineNum, DateTime timestamp, bool roundToSecon public int FindTimestampLine_Internal (int lineNum, int rangeStart, int rangeEnd, DateTime timestamp, bool roundToSeconds) { - _logger.Debug("FindTimestampLine_Internal(): timestamp={0}, lineNum={1}, rangeStart={2}, rangeEnd={3}", timestamp, lineNum, rangeStart, rangeEnd); + _logger.Debug(CultureInfo.InvariantCulture, "FindTimestampLine_Internal(): timestamp={0}, lineNum={1}, rangeStart={2}, rangeEnd={3}", timestamp, lineNum, rangeStart, rangeEnd); var refLine = lineNum; DateTime currentTimestamp = GetTimestampForLine(ref refLine, roundToSeconds); if (currentTimestamp.CompareTo(timestamp) == 0) @@ -1463,7 +1464,7 @@ public DateTime GetTimestampForLine (ref int lineNum, bool roundToSeconds) { return DateTime.MinValue; } - _logger.Debug("GetTimestampForLine({0}) enter", lineNum); + _logger.Debug(CultureInfo.InvariantCulture, "GetTimestampForLine({0}) enter", lineNum); DateTime timeStamp = DateTime.MinValue; var lookBack = false; if (lineNum >= 0 && lineNum < dataGridView.RowCount) @@ -1493,7 +1494,7 @@ public DateTime GetTimestampForLine (ref int lineNum, bool roundToSeconds) { lineNum++; } - _logger.Debug("GetTimestampForLine() leave with lineNum={0}", lineNum); + _logger.Debug(CultureInfo.InvariantCulture, "GetTimestampForLine() leave with lineNum={0}", lineNum); return timeStamp; } } @@ -1825,7 +1826,7 @@ public void AddOtherWindowToTimesync (LogWindow other) public void AddToTimeSync (LogWindow master) { - _logger.Info("Syncing window for {0} to {1}", Util.GetNameFromPath(FileName), Util.GetNameFromPath(master.FileName)); + _logger.Info(CultureInfo.InvariantCulture, "Syncing window for {0} to {1}", Util.GetNameFromPath(FileName), Util.GetNameFromPath(master.FileName)); lock (_timeSyncListLock) { if (IsTimeSynced && master.TimeSyncList != TimeSyncList) @@ -1846,7 +1847,7 @@ public void FreeFromTimeSync () { if (TimeSyncList != null) { - _logger.Info("De-Syncing window for {0}", Util.GetNameFromPath(FileName)); + _logger.Info(CultureInfo.InvariantCulture, "De-Syncing window for {0}", Util.GetNameFromPath(FileName)); TimeSyncList.WindowRemoved -= OnTimeSyncListWindowRemoved; TimeSyncList.RemoveWindow(this); TimeSyncList = null; diff --git a/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs b/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs index 8fe836d7..fdd89358 100644 --- a/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs +++ b/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs @@ -1,4 +1,6 @@ -using LogExpert.Core.Callback; +using System.Globalization; + +using LogExpert.Core.Callback; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Filter; using LogExpert.Core.Entities; @@ -29,12 +31,12 @@ public Range FindRange(int startLine) if (_filterParams.RangeSearchText == null || _filterParams.RangeSearchText.Trim().Length == 0) { - _logger.Info("Range search text not set. Cancelling range search."); + _logger.Info(CultureInfo.InvariantCulture, "Range search text not set. Cancelling range search."); return null; } if (_filterParams.SearchText == null || _filterParams.SearchText.Trim().Length == 0) { - _logger.Info("Search text not set. Cancelling range search."); + _logger.Info(CultureInfo.InvariantCulture, "Search text not set. Cancelling range search."); return null; } @@ -74,7 +76,7 @@ public Range FindRange(int startLine) if (!foundStartLine) { - _logger.Info("Range start not found"); + _logger.Info(CultureInfo.InvariantCulture, "Range start not found"); return null; } diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs index 58c71e58..791e6797 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs @@ -1,4 +1,4 @@ -using LogExpert.Core.Callback; +using LogExpert.Core.Callback; using LogExpert.Core.Classes; using LogExpert.Core.Interface; @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Threading; using System.Threading.Tasks; @@ -186,11 +187,11 @@ private void WorkerFx() while (!_shouldStop) { // wait for unbusy moments - _logger.Debug("TimeSpreadCalculator: wait for unbusy moments"); + _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator: wait for unbusy moments"); var signaled = _calcEvent.WaitOne(INACTIVITY_TIME, false); if (signaled == false) { - _logger.Debug("TimeSpreadCalculator: unbusy. starting calc."); + _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator: unbusy. starting calc."); if (TimeMode) { DoCalc_via_Time(); @@ -202,7 +203,7 @@ private void WorkerFx() break; } - _logger.Debug("TimeSpreadCalculator: signalled. no calc."); + _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator: signalled. no calc."); _calcEvent.Reset(); } _lineCountEvent.Reset(); @@ -212,12 +213,12 @@ private void WorkerFx() private void DoCalc() { OnStartCalc(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc() begin"); + _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator.DoCalc() begin"); if (_callback.GetLineCount() < 1) { OnCalcDone(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc() end because of line count < 1"); + _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator.DoCalc() end because of line count < 1"); return; } @@ -245,7 +246,7 @@ private void DoCalc() step = 1; } - _logger.Debug("TimeSpreadCalculator.DoCalc() collecting data for {0} lines with step size {1}", lastLineNum, step); + _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator.DoCalc() collecting data for {0} lines with step size {1}", lastLineNum, step); List newDiffList = []; List maxList = []; @@ -262,7 +263,7 @@ private void DoCalc() timePerLineSum += (int)(span.Ticks / TimeSpan.TicksPerMillisecond); newDiffList.Add(new SpreadEntry(i, 0, time)); oldTime = time; - _logger.Debug("TimeSpreadCalculator.DoCalc() time diff {0}", span); + _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator.DoCalc() time diff {0}", span); } } @@ -278,7 +279,7 @@ private void DoCalc() _timePerLine = (int)Math.Round(timePerLineSum / ((double)(lastLineNum + 1) / step)); CalcValuesViaLines(_timePerLine, _maxSpan); OnCalcDone(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc() end"); + _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator.DoCalc() end"); } } } @@ -287,12 +288,12 @@ private void DoCalc() private void DoCalc_via_Time() { OnStartCalc(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() begin"); + _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator.DoCalc_via_Time() begin"); if (_callback.GetLineCount() < 1) { OnCalcDone(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc() end because of line count < 1"); + _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator.DoCalc() end because of line count < 1"); return; } @@ -318,7 +319,7 @@ private void DoCalc_via_Time() step = 1; } - _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() time range is {0} ms", overallSpanMillis); + _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator.DoCalc_via_Time() time range is {0} ms", overallSpanMillis); lineNum = 0; DateTime searchTimeStamp = _startTimestamp; @@ -339,7 +340,7 @@ private void DoCalc_via_Time() } var lineDiff = lineNum - oldLineNum; - _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() test time {0:HH:mm:ss.fff} line diff={1}", searchTimeStamp, lineDiff); + _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator.DoCalc_via_Time() test time {0:HH:mm:ss.fff} line diff={1}", searchTimeStamp, lineDiff); if (lineDiff >= 0) { @@ -372,7 +373,7 @@ private void DoCalc_via_Time() _average = lineDiffSum / (double)loopCount; //double average = maxList[maxList.Count / 2]; - _logger.Debug("Average diff={0} minDiff={1} maxDiff={2}", _average, minDiff, _maxDiff); + _logger.Debug(CultureInfo.InvariantCulture, "Average diff={0} minDiff={1} maxDiff={2}", _average, minDiff, _maxDiff); lock (_diffListLock) { @@ -389,7 +390,7 @@ private void DoCalc_via_Time() DiffList = newDiffList; CalcValuesViaTime(_maxDiff, _average); OnCalcDone(EventArgs.Empty); - _logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() end"); + _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator.DoCalc_via_Time() end"); } } } @@ -435,7 +436,7 @@ private void CalcValuesViaTime(int maxDiff, double average) var value = (int)(diffFromAverage / maxDiff * _contrast); entry.Value = 255 - value; - _logger.Debug("TimeSpreadCalculator.DoCalc() test time {0:HH:mm:ss.fff} line diff={1} value={2}", entry.Timestamp, lineDiff, value); + _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator.DoCalc() test time {0:HH:mm:ss.fff} line diff={1} value={2}", entry.Timestamp, lineDiff, value); } } diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs index 7aea14ed..d3c97f17 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs @@ -1,3 +1,4 @@ +using System.Globalization; using System.Runtime.Versioning; using LogExpert.Core.Classes; @@ -146,7 +147,7 @@ private void OnLineSelected (SelectLineEventArgs e) private void TimeSpreadCalc_CalcDone (object sender, EventArgs e) { - _logger.Debug("timeSpreadCalc_CalcDone()"); + _logger.Debug(CultureInfo.InvariantCulture, "timeSpreadCalc_CalcDone()"); lock (_monitor) { diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs index 3b0dc376..b7d09f99 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs @@ -1,5 +1,6 @@ using System.ComponentModel; using System.Diagnostics; +using System.Globalization; using System.Runtime.Versioning; using System.Text; @@ -516,7 +517,7 @@ private void OnLogWindowSyncModeChanged (object sender, SyncModeEventArgs e) } else { - _logger.Warn("Received SyncModeChanged event while disposing. Event ignored."); + _logger.Warn(CultureInfo.InvariantCulture, "Received SyncModeChanged event while disposing. Event ignored."); } } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs index 68fcff65..d47ad17e 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs @@ -1,5 +1,6 @@ using System.ComponentModel; using System.Diagnostics; +using System.Globalization; using System.Runtime.Versioning; using System.Security; using System.Text; @@ -135,7 +136,7 @@ private void FillDefaultEncodingFromSettings (EncodingOptions encodingOptions) } catch (ArgumentException) { - _logger.Warn("Encoding " + ConfigManager.Settings.Preferences.DefaultEncoding + " is not a valid encoding"); + _logger.Warn(CultureInfo.InvariantCulture, "Encoding " + ConfigManager.Settings.Preferences.DefaultEncoding + " is not a valid encoding"); encodingOptions.DefaultEncoding = null; } } @@ -963,7 +964,7 @@ private void OpenSettings (int tabToOpen) [SupportedOSPlatform("windows")] private void NotifyWindowsForChangedPrefs (SettingsFlags flags) { - _logger.Info("The preferences have changed"); + _logger.Info(CultureInfo.InvariantCulture, "The preferences have changed"); ApplySettings(ConfigManager.Settings, flags); lock (_logWindowList) @@ -1104,7 +1105,7 @@ private void StartTool (string cmd, string args, bool sysoutPipe, string columni { ILogLineColumnizer columnizer = ColumnizerPicker.DecideColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - _logger.Info("Starting external tool with sysout redirection: {0} {1}", cmd, args); + _logger.Info(CultureInfo.InvariantCulture, "Starting external tool with sysout redirection: {0} {1}", cmd, args); startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; //process.OutputDataReceived += pipe.DataReceivedEventHandler; @@ -1132,7 +1133,7 @@ private void StartTool (string cmd, string args, bool sysoutPipe, string columni } else { - _logger.Info("Starting external tool: {0} {1}", cmd, args); + _logger.Info(CultureInfo.InvariantCulture, "Starting external tool: {0} {1}", cmd, args); try { @@ -1293,7 +1294,7 @@ private void DumpGCInfo () _logger.Info($"Generation {i} collect count: {GC.CollectionCount(i)}"); } - _logger.Info("----------------------------"); + _logger.Info(CultureInfo.InvariantCulture, "----------------------------"); } private void ThrowExceptionFx () diff --git a/src/LogExpert/Classes/LogExpertProxy.cs b/src/LogExpert/Classes/LogExpertProxy.cs index 5573d286..af9b5e14 100644 --- a/src/LogExpert/Classes/LogExpertProxy.cs +++ b/src/LogExpert/Classes/LogExpertProxy.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Windows.Forms; namespace LogExpert.Classes; @@ -60,7 +61,7 @@ public LogExpertProxy(ILogTabWindow logTabWindow) public void LoadFiles(string[] fileNames) { - _logger.Info("Loading files into existing LogTabWindow"); + _logger.Info(CultureInfo.InvariantCulture, "Loading files into existing LogTabWindow"); ILogTabWindow logWin = _windowList[^1]; _ = logWin.Invoke(new MethodInvoker(logWin.SetForeground)); logWin.LoadFiles(fileNames); @@ -70,13 +71,13 @@ public void NewWindow(string[] fileNames) { if (_firstLogTabWindow.IsDisposed) { - _logger.Warn("first GUI thread window is disposed. Setting a new one."); + _logger.Warn(CultureInfo.InvariantCulture, "first GUI thread window is disposed. Setting a new one."); // may occur if a window is closed because of unhandled exception. // Determine a new 'firstWindow'. If no window is left, start a new one. RemoveWindow(_firstLogTabWindow); if (_windowList.Count == 0) { - _logger.Info("No windows left. New created window will be the new 'first' GUI window"); + _logger.Info(CultureInfo.InvariantCulture, "No windows left. New created window will be the new 'first' GUI window"); LoadFiles(fileNames); } else @@ -109,7 +110,7 @@ public void NewWindowOrLockedWindow(string[] fileNames) public void NewWindowWorker(string[] fileNames) { - _logger.Info("Creating new LogTabWindow"); + _logger.Info(CultureInfo.InvariantCulture, "Creating new LogTabWindow"); IConfigManager configManager = ConfigManager.Instance; ILogTabWindow logWin = AbstractLogTabWindow.Create(fileNames.Length > 0 ? fileNames : null, _logWindowIndex++, true, configManager); logWin.LogExpertProxy = this; @@ -124,7 +125,7 @@ public void WindowClosed(ILogTabWindow logWin) RemoveWindow(logWin); if (_windowList.Count == 0) { - _logger.Info("Last LogTabWindow was closed"); + _logger.Info(CultureInfo.InvariantCulture, "Last LogTabWindow was closed"); PluginRegistry.PluginRegistry.Instance.CleanupPlugins(); OnLastWindowClosed(); } @@ -154,13 +155,13 @@ public int GetLogWindowCount() private void AddWindow(ILogTabWindow window) { - _logger.Info("Adding window to list"); + _logger.Info(CultureInfo.InvariantCulture, "Adding window to list"); _windowList.Add(window); } private void RemoveWindow(ILogTabWindow window) { - _logger.Info("Removing window from list"); + _logger.Info(CultureInfo.InvariantCulture, "Removing window from list"); _ = _windowList.Remove(window); } diff --git a/src/LogExpert/Config/ConfigManager.cs b/src/LogExpert/Config/ConfigManager.cs index d806ce35..8ad8018e 100644 --- a/src/LogExpert/Config/ConfigManager.cs +++ b/src/LogExpert/Config/ConfigManager.cs @@ -1,4 +1,5 @@ using System.Drawing; +using System.Globalization; using System.Reflection; using System.Text; using System.Windows.Forms; @@ -116,13 +117,13 @@ public void ImportHighlightSettings (FileInfo fileInfo, ExportImportFlags flags) private Settings Load () { - _logger.Info("Loading settings"); + _logger.Info(CultureInfo.InvariantCulture, "Loading settings"); string dir; if (!File.Exists(Path.Combine(PortableModeDir, PortableModeSettingsFileName))) { - _logger.Info("Load settings standard mode"); + _logger.Info(CultureInfo.InvariantCulture, "Load settings standard mode"); dir = ConfigDir; } else @@ -133,7 +134,7 @@ private Settings Load () if (!Directory.Exists(dir)) { - Directory.CreateDirectory(dir); + _ = Directory.CreateDirectory(dir); } if (!File.Exists(Path.Combine(dir, "settings.json"))) @@ -268,7 +269,7 @@ private void Save (Settings settings, SettingsFlags flags) { lock (_loadSaveLock) { - _logger.Info("Saving settings"); + _logger.Info(CultureInfo.InvariantCulture, "Saving settings"); var dir = Settings.Preferences.PortableMode ? Application.StartupPath : ConfigDir; if (!Directory.Exists(dir)) diff --git a/src/LogExpert/Program.cs b/src/LogExpert/Program.cs index 95fa7dfe..0bad3736 100644 --- a/src/LogExpert/Program.cs +++ b/src/LogExpert/Program.cs @@ -1,4 +1,4 @@ -using LogExpert.Classes; +using LogExpert.Classes; using LogExpert.Classes.CommandLine; using LogExpert.Config; using LogExpert.Core.Classes.IPC; @@ -14,6 +14,7 @@ using NLog; using System.Diagnostics; +using System.Globalization; using System.IO.Pipes; using System.Reflection; using System.Security; @@ -49,7 +50,7 @@ private static void Main(string[] args) Application.EnableVisualStyles(); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); - _logger.Info("\r\n============================================================================\r\nLogExpert {0} started.\r\n============================================================================", Assembly.GetExecutingAssembly().GetName().Version.ToString(3)); + _logger.Info(CultureInfo.InvariantCulture, "\r\n============================================================================\r\nLogExpert {0} started.\r\n============================================================================", Assembly.GetExecutingAssembly().GetName().Version.ToString(3)); CancellationTokenSource cts = new(); try diff --git a/src/PluginRegistry/PluginRegistry.cs b/src/PluginRegistry/PluginRegistry.cs index 24547ff6..0b7a339b 100644 --- a/src/PluginRegistry/PluginRegistry.cs +++ b/src/PluginRegistry/PluginRegistry.cs @@ -1,3 +1,4 @@ +using System.Globalization; using System.Reflection; using LogExpert.Core.Classes; @@ -87,7 +88,7 @@ public PluginRegistry Create (string applicationConfigurationFolder, int polling internal void LoadPlugins () { - _logger.Info("Loading plugins..."); + _logger.Info(CultureInfo.InvariantCulture, "Loading plugins..."); RegisteredColumnizers = [ @@ -143,7 +144,7 @@ internal void LoadPlugins () } } - _logger.Info("Plugin loading complete."); + _logger.Info(CultureInfo.InvariantCulture, "Plugin loading complete."); } private void LoadPluginAssembly (string dllName, string interfaceName) @@ -215,21 +216,21 @@ public IFileSystemPlugin FindFileSystemForUri (string uriString) { if (_logger.IsDebugEnabled) { - _logger.Debug("Trying to find file system plugin for uri {0}", uriString); + _logger.Debug(CultureInfo.InvariantCulture, "Trying to find file system plugin for uri {0}", uriString); } foreach (IFileSystemPlugin fs in RegisteredFileSystemPlugins) { if (_logger.IsDebugEnabled) { - _logger.Debug("Checking {0}", fs.Text); + _logger.Debug(CultureInfo.InvariantCulture, "Checking {0}", fs.Text); } if (fs.CanHandleUri(uriString)) { if (_logger.IsDebugEnabled) { - _logger.Debug("Found match {0}", fs.Text); + _logger.Debug(CultureInfo.InvariantCulture, "Found match {0}", fs.Text); } return fs; @@ -262,7 +263,7 @@ private bool TryAsContextMenu (Type type) plugin.PluginLoaded(); } - _logger.Info("Added context menu plugin {0}", type); + _logger.Info(CultureInfo.InvariantCulture, "Added context menu plugin {0}", type); return true; } @@ -288,7 +289,7 @@ private bool TryAsKeywordAction (Type type) plugin.PluginLoaded(); } - _logger.Info("Added keyword plugin {0}", type); + _logger.Info(CultureInfo.InvariantCulture, "Added keyword plugin {0}", type); return true; } @@ -317,7 +318,7 @@ private bool TryAsFileSystem (Type type) plugin.PluginLoaded(); } - _logger.Info("Added file system plugin {0}", type); + _logger.Info(CultureInfo.InvariantCulture, "Added file system plugin {0}", type); return true; } diff --git a/src/SftpFileSystemx64/SftpFileSystem.cs b/src/SftpFileSystemx64/SftpFileSystem.cs index bdc86465..cac7d1f1 100644 --- a/src/SftpFileSystemx64/SftpFileSystem.cs +++ b/src/SftpFileSystemx64/SftpFileSystem.cs @@ -106,7 +106,7 @@ public void LoadConfig (string configDir) public void SaveConfig (string configDir) { - _logger.Info("Saving SFTP config"); + _logger.Info(CultureInfo.InvariantCulture, "Saving SFTP config"); XmlSerializer xml = new(ConfigData.GetType()); FileStream fs = null; From 6ef0adf64058def99aa4e67d9a4f276bd9fb0075 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sun, 15 Jun 2025 01:09:00 +0300 Subject: [PATCH 080/142] Solved a few more warnings --- src/LogExpert/Config/ConfigManager.cs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/LogExpert/Config/ConfigManager.cs b/src/LogExpert/Config/ConfigManager.cs index 8ad8018e..23213246 100644 --- a/src/LogExpert/Config/ConfigManager.cs +++ b/src/LogExpert/Config/ConfigManager.cs @@ -144,15 +144,24 @@ private Settings Load () try { - FileInfo fileInfo = new(dir + Path.DirectorySeparatorChar + "settings.json"); + FileInfo fileInfo = new(Path.Combine(dir, "settings.json")); return LoadOrCreateNew(fileInfo); } - catch (Exception e) + catch (IOException ex) { - _logger.Error($"Error loading settings: {e}"); - return LoadOrCreateNew(null); + _logger.Error($"File system error: {ex.Message}"); + } + catch (UnauthorizedAccessException ex) + { + _logger.Error($"Access denied: {ex.Message}"); + } + catch (Exception ex) when (ex is not OperationCanceledException) + { + _logger.Error($"Unexpected error: {ex.Message}"); } + return LoadOrCreateNew(null); + } /// @@ -359,8 +368,8 @@ private List Import (List currentGroups, FileInf /// Flags to indicate which parts shall be imported private Settings Import (Settings currentSettings, FileInfo fileInfo, ExportImportFlags flags) { - Settings importSettings = LoadOrCreateNew(fileInfo); - Settings ownSettings = ObjectClone.Clone(currentSettings); + var importSettings = LoadOrCreateNew(fileInfo); + var ownSettings = ObjectClone.Clone(currentSettings); Settings newSettings; // at first check for 'Other' as this are the most options. From ac9348aa9c08110699d895eb1c51a83788c49e6d Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sun, 15 Jun 2025 01:22:18 +0300 Subject: [PATCH 081/142] Added another log overload to the interface --- src/ColumnizerLib/ILogExpertLogger.cs | 4 +++- src/LogExpert.Core/Classes/FileSystemCallback.cs | 9 ++++++++- src/SftpFileSystemx64/SftpFileSystem.cs | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ColumnizerLib/ILogExpertLogger.cs b/src/ColumnizerLib/ILogExpertLogger.cs index cb9405d2..cfbbd884 100644 --- a/src/ColumnizerLib/ILogExpertLogger.cs +++ b/src/ColumnizerLib/ILogExpertLogger.cs @@ -1,5 +1,6 @@ -using System; +using System; using System.Collections.Generic; +using System.Globalization; using System.Text; namespace LogExpert; @@ -17,6 +18,7 @@ public interface ILogExpertLogger /// /// A message to be logged. void Info(string msg); + void Info (IFormatProvider formatProvider, string msg); /// /// Logs a message on DEBUG level to LogExpert#s log file. The logfile is only active in debug builds. diff --git a/src/LogExpert.Core/Classes/FileSystemCallback.cs b/src/LogExpert.Core/Classes/FileSystemCallback.cs index 008f2b29..ca8d6688 100644 --- a/src/LogExpert.Core/Classes/FileSystemCallback.cs +++ b/src/LogExpert.Core/Classes/FileSystemCallback.cs @@ -1,4 +1,6 @@ -using NLog; +using System.Globalization; + +using NLog; namespace LogExpert.Core.Classes; @@ -28,6 +30,11 @@ public void Info(string msg) _logger.Info(msg); } + public void Info (IFormatProvider formatProvider, string msg) + { + _logger.Info(formatProvider, msg); + } + public void Debug(string msg) { _logger.Debug(msg); diff --git a/src/SftpFileSystemx64/SftpFileSystem.cs b/src/SftpFileSystemx64/SftpFileSystem.cs index cac7d1f1..4d43af87 100644 --- a/src/SftpFileSystemx64/SftpFileSystem.cs +++ b/src/SftpFileSystemx64/SftpFileSystem.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Windows.Forms; using System.Xml.Serialization; From 1a3a435aeb25b78c4dbffe1e7604a0ba7a87b503 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sun, 15 Jun 2025 01:37:14 +0300 Subject: [PATCH 082/142] Fixed some warnings and improved the tests Fixed warnings --- src/ColumnizerLib.UnitTests/ColumnTests.cs | 46 +++++++------------ .../Classes/Bookmark/BookmarkExporter.cs | 3 +- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/src/ColumnizerLib.UnitTests/ColumnTests.cs b/src/ColumnizerLib.UnitTests/ColumnTests.cs index 649b132a..98830505 100644 --- a/src/ColumnizerLib.UnitTests/ColumnTests.cs +++ b/src/ColumnizerLib.UnitTests/ColumnTests.cs @@ -1,5 +1,7 @@ -using LogExpert; +using LogExpert; + using NUnit.Framework; + using System; using System.Text; @@ -9,44 +11,30 @@ namespace ColumnizerLib.UnitTests; public class ColumnTests { [Test] - public void Column_LineCutOf() + public void Column_LineCutOff () { - Column column = new(); - - StringBuilder builder = new(); + var expectedFullValue = new StringBuilder().Append('6', 4675).Append("1234").ToString(); + var expectedDisplayValue = expectedFullValue[..4675] + "..."; // Using substring shorthand - for (var i = 0; i < 4675; i++) + Column column = new() { - builder.Append("6"); - } - - var expected = builder + "..."; - builder.Append("1234"); - - column.FullValue = builder.ToString(); + FullValue = expectedFullValue + }; - Assert.That(column.DisplayValue, Is.EqualTo(expected)); - Assert.That(column.FullValue, Is.EqualTo(builder.ToString())); + Assert.That(column.DisplayValue, Is.EqualTo(expectedDisplayValue)); + Assert.That(column.FullValue, Is.EqualTo(expectedFullValue)); } [Test] - public void Column_NoLineCutOf() + public void Column_NoLineCutOff () { - Column column = new(); - - StringBuilder builder = new(); - - for (var i = 0; i < 4675; i++) + var expected = new StringBuilder().Append('6', 4675).ToString(); + Column column = new() { - builder.Append("6"); - } - - var expected = builder.ToString(); - - column.FullValue = expected; + FullValue = expected + }; - Assert.That(column.DisplayValue, Is.EqualTo(expected)); - Assert.That(column.FullValue, Is.EqualTo(expected)); + Assert.That(column.DisplayValue, Is.EqualTo(column.FullValue)); } [Test] diff --git a/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs b/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs index c24bafdf..a20c21e9 100644 --- a/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs +++ b/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs @@ -17,11 +17,12 @@ public static void ExportBookmarkList (SortedList bookma FileStream fs = new(fileName, FileMode.Create, FileAccess.Write); StreamWriter writer = new(fs); writer.WriteLine("Log file name;Line number;Comment"); - foreach (Entities.Bookmark bookmark in bookmarkList.Values) + foreach (var bookmark in bookmarkList.Values) { var line = $"{logfileName};{bookmark.LineNum};{bookmark.Text.Replace(replacementForNewLine, @"\" + replacementForNewLine, StringComparison.OrdinalIgnoreCase).Replace("\r\n", replacementForNewLine, StringComparison.OrdinalIgnoreCase)}"; writer.WriteLine(line); } + writer.Close(); fs.Close(); } From 87b86e2a7c9bd40ee2d686c8abf019195848fe97 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sun, 15 Jun 2025 01:49:38 +0300 Subject: [PATCH 083/142] Added and changed rules --- src/.editorconfig | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/.editorconfig b/src/.editorconfig index c9040640..5f2d7b13 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -50,7 +50,7 @@ dotnet_style_parentheses_in_other_operators = never_if_unnecessary:warning dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning # Modifier preferences -dotnet_style_require_accessibility_modifiers = always:warning +dotnet_style_require_accessibility_modifiers = for_non_interface_members # Expression-level preferences dotnet_prefer_system_hash_code = true @@ -89,7 +89,7 @@ dotnet_style_allow_statement_immediately_after_block_experimental = false:warnin #### C# Coding Conventions #### # var preferences -csharp_style_var_elsewhere = false:suggestion +csharp_style_var_elsewhere = true:suggestion csharp_style_var_for_built_in_types = true:warning csharp_style_var_when_type_is_apparent = true:warning @@ -219,8 +219,14 @@ dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = warning dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.no_single_letter_names.severity = error +dotnet_naming_rule.no_single_letter_names.symbols = parameters_and_variables +dotnet_naming_rule.no_single_letter_names.style = descriptive_names + # Symbol specifications +dotnet_naming_symbols.parameters_and_variables.applicable_kinds = parameter, local + dotnet_naming_symbols.interface.applicable_kinds = interface dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected dotnet_naming_symbols.interface.required_modifiers = @@ -235,6 +241,9 @@ dotnet_naming_symbols.non_field_members.required_modifiers = # Naming styles +dotnet_naming_style.descriptive_names.capitalization = camel_case +dotnet_naming_style.descriptive_names.minimum_word_length = 2 + dotnet_naming_style.pascal_case.required_prefix = dotnet_naming_style.pascal_case.required_suffix = dotnet_naming_style.pascal_case.word_separator = @@ -277,7 +286,7 @@ dotnet_diagnostic.IDE0003.severity = warning dotnet_diagnostic.IDE0004.severity = warning # IDE0005: Remove unnecessary import -dotnet_diagnostic.IDE0005.severity = warning +dotnet_diagnostic.IDE0005.severity = none # IDE0005_gen: Remove unnecessary import (NotConfigurable) #dotnet_diagnostic.IDE0005_gen.severity = silent @@ -388,7 +397,7 @@ dotnet_diagnostic.IDE0044.severity = warning dotnet_diagnostic.IDE0045.severity = warning # IDE0046: Use conditional expression for return -dotnet_diagnostic.IDE0046.severity = warning +dotnet_diagnostic.IDE0046.severity = suggestion # IDE0047: Remove unnecessary parentheses dotnet_diagnostic.IDE0047.severity = warning @@ -4865,3 +4874,4 @@ dotnet_diagnostic.xUnit3000.severity = warning # xUnit3001: Classes that implement Xunit.Abstractions.IXunitSerializable must have a public parameterless constructor dotnet_diagnostic.xUnit3001.severity = warning + From 6722febb0b8b8a5ab6c3a78e033a760d7d21b7b6 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sun, 15 Jun 2025 01:56:06 +0300 Subject: [PATCH 084/142] Moved a file from Core to UI and changed to internal --- .../Controls/LogWindow/LogWindowPublic.cs | 1 - .../Extensions}/BookmarkExporter.cs | 14 ++++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) rename src/{LogExpert.Core/Classes/Bookmark => LogExpert.UI/Extensions}/BookmarkExporter.cs (84%) diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs index 9fce6a8c..03c37a77 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs @@ -1,7 +1,6 @@ using System.Text; using LogExpert.Core.Classes; -using LogExpert.Core.Classes.Bookmark; using LogExpert.Core.Classes.Columnizer; using LogExpert.Core.Classes.Filter; using LogExpert.Core.Classes.Highlight; diff --git a/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs b/src/LogExpert.UI/Extensions/BookmarkExporter.cs similarity index 84% rename from src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs rename to src/LogExpert.UI/Extensions/BookmarkExporter.cs index 2100f803..fbf2f660 100644 --- a/src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs +++ b/src/LogExpert.UI/Extensions/BookmarkExporter.cs @@ -1,6 +1,8 @@ -namespace LogExpert.Core.Classes.Bookmark; +using LogExpert.Core.Entities; -public static class BookmarkExporter +namespace LogExpert.UI.Extensions; + +internal static class BookmarkExporter { #region Fields @@ -10,13 +12,13 @@ public static class BookmarkExporter #region Public methods - public static void ExportBookmarkList (SortedList bookmarkList, string logfileName, + public static void ExportBookmarkList (SortedList bookmarkList, string logfileName, string fileName) { FileStream fs = new(fileName, FileMode.Create, FileAccess.Write); StreamWriter writer = new(fs); writer.WriteLine("Log file name;Line number;Comment"); - foreach (Entities.Bookmark bookmark in bookmarkList.Values) + foreach (var bookmark in bookmarkList.Values) { var line = $"{logfileName};{bookmark.LineNum};{bookmark.Text.Replace(replacementForNewLine, @"\" + replacementForNewLine, StringComparison.OrdinalIgnoreCase).Replace("\r\n", replacementForNewLine, StringComparison.OrdinalIgnoreCase)}"; writer.WriteLine(line); @@ -25,7 +27,7 @@ public static void ExportBookmarkList (SortedList bookma fs.Close(); } - public static void ImportBookmarkList (string logfileName, string fileName, SortedList bookmarkList) + public static void ImportBookmarkList (string logfileName, string fileName, SortedList bookmarkList) { using FileStream fs = new(fileName, FileMode.Open, FileAccess.Read); using StreamReader reader = new(fs); @@ -51,7 +53,7 @@ public static void ImportBookmarkList (string logfileName, string fileName, Sort if (int.TryParse(lineStr, out var lineNum)) { - Entities.Bookmark bookmark = new(lineNum, comment); + Bookmark bookmark = new(lineNum, comment); bookmarkList.Add(lineNum, bookmark); } else From 45b38e8751cb0cb09c93ae2b3f7b5863042a56e9 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Sun, 15 Jun 2025 12:30:38 +0300 Subject: [PATCH 085/142] Changed from public to internal on all possible classes in UI Moved non UI components to a different folder. --- .../Controls/BufferedDataGridView.cs | 2 +- src/LogExpert.UI/Controls/ColorComboBox.cs | 2 +- .../Controls/DateTimeDragControl.cs | 2 +- src/LogExpert.UI/Controls/KnobControl.cs | 2 +- .../Controls/LogCellEditingControl.cs | 2 +- src/LogExpert.UI/Controls/LogGridCell.cs | 2 +- src/LogExpert.UI/Controls/LogTextColumn.cs | 2 +- .../Controls/LogWindow/LogWindow.cs | 2 +- .../Controls/LogWindow/RangeFinder.cs | 2 +- .../Controls/LogWindow/TimeSyncList.cs | 2 +- src/LogExpert.UI/Dialogs/AboutBox.cs | 4 ++-- .../Dialogs/BookmarkCommentDlg.cs | 4 ++-- src/LogExpert.UI/Dialogs/BookmarkWindow.cs | 2 +- src/LogExpert.UI/Dialogs/ChooseIconDlg.cs | 2 +- .../Dialogs/FilterColumnChooser.cs | 4 ++-- src/LogExpert.UI/Dialogs/GotoLineDialog.cs | 4 ++-- .../Dialogs/ImportSettingsDialog.cs | 4 ++-- src/LogExpert.UI/Dialogs/KeywordActionDlg.cs | 4 ++-- .../Dialogs/LogTabWindow/HighlightDialog.cs | 2 +- .../Dialogs/LogTabWindow/LogTabWindow.cs | 8 +++---- .../LogTabWindow/LogTabWindowEventHandlers.cs | 4 ++-- .../LogTabWindow/LogTabWindowPrivate.cs | 2 +- .../LogTabWindow/LogTabWindowPublic.cs | 2 +- .../Dialogs/MultiFileMaskDialog.cs | 4 ++-- .../Dialogs/MultiLoadRequestDialog.cs | 4 ++-- src/LogExpert.UI/Dialogs/OpenUriDialog.cs | 4 ++-- .../Dialogs/ParamRequesterDialog.cs | 2 +- src/LogExpert.UI/Dialogs/ProjectLoadDlg.cs | 4 ++-- src/LogExpert.UI/Dialogs/RegexHelperDialog.cs | 2 +- src/LogExpert.UI/Dialogs/SearchDialog.cs | 2 +- .../Dialogs/SearchProgressDialog.cs | 4 ++-- src/LogExpert.UI/Dialogs/TabRenameDialog.cs | 4 ++-- src/LogExpert.UI/Entities/WindowFileEntry.cs | 2 +- .../Extensions/ComboBoxExtensions.cs | 4 ++-- .../Forms/LineToolStripSeparatorExtension.cs | 4 ++-- .../Extensions/Forms/MenuSelectedColors.cs | 4 ++-- .../Extensions/Forms/MenuStripExtension.cs | 4 ++-- .../Forms/MenuToolStripSeparatorExtension.cs | 4 ++-- .../Forms/ToolStripRendererExtension.cs | 4 ++-- .../LogWindow/AbstractLogTabWindow.cs | 6 +++--- .../LogWindow/StaticLogTabWindowData.cs | 2 +- .../Interface/ILogPaintContextUI.cs | 4 ++-- src/LogExpert/Classes/LogExpertProxy.cs | 10 ++++----- src/LogExpert/Program.cs | 21 ++++++++++--------- 44 files changed, 82 insertions(+), 83 deletions(-) rename src/LogExpert.UI/{Controls => Extensions}/LogWindow/AbstractLogTabWindow.cs (67%) rename src/LogExpert.UI/{Controls => Extensions}/LogWindow/StaticLogTabWindowData.cs (79%) diff --git a/src/LogExpert.UI/Controls/BufferedDataGridView.cs b/src/LogExpert.UI/Controls/BufferedDataGridView.cs index c52e73bc..83dd2575 100644 --- a/src/LogExpert.UI/Controls/BufferedDataGridView.cs +++ b/src/LogExpert.UI/Controls/BufferedDataGridView.cs @@ -10,7 +10,7 @@ namespace LogExpert.Dialogs; [SupportedOSPlatform("windows")] -public partial class BufferedDataGridView : DataGridView +internal partial class BufferedDataGridView : DataGridView { #region Fields diff --git a/src/LogExpert.UI/Controls/ColorComboBox.cs b/src/LogExpert.UI/Controls/ColorComboBox.cs index 2cc8dcd1..71feb634 100644 --- a/src/LogExpert.UI/Controls/ColorComboBox.cs +++ b/src/LogExpert.UI/Controls/ColorComboBox.cs @@ -4,7 +4,7 @@ namespace LogExpert.UI.Controls; [SupportedOSPlatform("windows")] -public class ColorComboBox : ComboBox +internal class ColorComboBox : ComboBox { #region Fields diff --git a/src/LogExpert.UI/Controls/DateTimeDragControl.cs b/src/LogExpert.UI/Controls/DateTimeDragControl.cs index 676e9f86..0d4dd777 100644 --- a/src/LogExpert.UI/Controls/DateTimeDragControl.cs +++ b/src/LogExpert.UI/Controls/DateTimeDragControl.cs @@ -15,7 +15,7 @@ namespace LogExpert.Dialogs; /// The control raises events (ValueChanged, ValueDragged) when the date/time changes so that owner can react accordingly. /// [SupportedOSPlatform("windows")] -public partial class DateTimeDragControl : UserControl +internal partial class DateTimeDragControl : UserControl { #region Fields diff --git a/src/LogExpert.UI/Controls/KnobControl.cs b/src/LogExpert.UI/Controls/KnobControl.cs index b63eb5c4..f0893f18 100644 --- a/src/LogExpert.UI/Controls/KnobControl.cs +++ b/src/LogExpert.UI/Controls/KnobControl.cs @@ -5,7 +5,7 @@ namespace LogExpert.UI.Controls; [SupportedOSPlatform("windows")] -public partial class KnobControl : UserControl +internal partial class KnobControl : UserControl { #region Fields diff --git a/src/LogExpert.UI/Controls/LogCellEditingControl.cs b/src/LogExpert.UI/Controls/LogCellEditingControl.cs index 316ed197..024bd30c 100644 --- a/src/LogExpert.UI/Controls/LogCellEditingControl.cs +++ b/src/LogExpert.UI/Controls/LogCellEditingControl.cs @@ -3,7 +3,7 @@ namespace LogExpert.UI.Controls; [SupportedOSPlatform("windows")] -public class LogCellEditingControl : DataGridViewTextBoxEditingControl +internal class LogCellEditingControl : DataGridViewTextBoxEditingControl { #region Public methods diff --git a/src/LogExpert.UI/Controls/LogGridCell.cs b/src/LogExpert.UI/Controls/LogGridCell.cs index fe870e1b..e9954a17 100644 --- a/src/LogExpert.UI/Controls/LogGridCell.cs +++ b/src/LogExpert.UI/Controls/LogGridCell.cs @@ -3,7 +3,7 @@ namespace LogExpert.UI.Controls; -public class LogGridCell : DataGridViewTextBoxCell +internal class LogGridCell : DataGridViewTextBoxCell { #region Properties diff --git a/src/LogExpert.UI/Controls/LogTextColumn.cs b/src/LogExpert.UI/Controls/LogTextColumn.cs index 3f2e44b7..c0054b30 100644 --- a/src/LogExpert.UI/Controls/LogTextColumn.cs +++ b/src/LogExpert.UI/Controls/LogTextColumn.cs @@ -2,7 +2,7 @@ namespace LogExpert.UI.Controls; -public class LogTextColumn : DataGridViewColumn +internal class LogTextColumn : DataGridViewColumn { #region cTor diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index 34e04cc6..b1d52dbb 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -25,7 +25,7 @@ namespace LogExpert.UI.Controls.LogWindow; //TODO: Implemented 4 interfaces explicitly. Find them by searching: ILogWindow. [SupportedOSPlatform("windows")] -public partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILogWindow +internal partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILogWindow { #region Fields diff --git a/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs b/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs index 8fe836d7..4a46be2a 100644 --- a/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs +++ b/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs @@ -12,7 +12,7 @@ namespace LogExpert.UI.Controls.LogWindow; /// /// Delivers the range (from..to) that matches the current range filter settings starting from a given line. /// -public class RangeFinder(FilterParams filterParams, ColumnizerCallback callback) +internal class RangeFinder(FilterParams filterParams, ColumnizerCallback callback) { #region Fields diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs index 5cf5a90c..fe51937b 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs @@ -5,7 +5,7 @@ namespace LogExpert.UI.Controls.LogWindow; /// /// Holds all windows which are in sync via timestamp /// -public class TimeSyncList +internal class TimeSyncList { #region Fields diff --git a/src/LogExpert.UI/Dialogs/AboutBox.cs b/src/LogExpert.UI/Dialogs/AboutBox.cs index 632dd07c..471d836f 100644 --- a/src/LogExpert.UI/Dialogs/AboutBox.cs +++ b/src/LogExpert.UI/Dialogs/AboutBox.cs @@ -1,4 +1,4 @@ -using LogExpert.Core.Classes; +using LogExpert.Core.Classes; using Newtonsoft.Json; @@ -9,7 +9,7 @@ namespace LogExpert.UI.Dialogs; [SupportedOSPlatform("windows")] -public partial class AboutBox : Form +internal partial class AboutBox : Form { #region Fields diff --git a/src/LogExpert.UI/Dialogs/BookmarkCommentDlg.cs b/src/LogExpert.UI/Dialogs/BookmarkCommentDlg.cs index ece0c852..7949c604 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkCommentDlg.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkCommentDlg.cs @@ -1,9 +1,9 @@ -using System.Runtime.Versioning; +using System.Runtime.Versioning; namespace LogExpert.Dialogs; [SupportedOSPlatform("windows")] -public partial class BookmarkCommentDlg : Form +internal partial class BookmarkCommentDlg : Form { #region cTor diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs index 0ee8d848..c347a4c6 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs @@ -16,7 +16,7 @@ namespace LogExpert.Dialogs; //TODO can be moved to Logexpert.UI if the PaintHelper has been refactored [SupportedOSPlatform("windows")] -public partial class BookmarkWindow : DockContent, ISharedToolWindow, IBookmarkView +internal partial class BookmarkWindow : DockContent, ISharedToolWindow, IBookmarkView { #region Fields diff --git a/src/LogExpert.UI/Dialogs/ChooseIconDlg.cs b/src/LogExpert.UI/Dialogs/ChooseIconDlg.cs index bee7a594..229f18e8 100644 --- a/src/LogExpert.UI/Dialogs/ChooseIconDlg.cs +++ b/src/LogExpert.UI/Dialogs/ChooseIconDlg.cs @@ -4,7 +4,7 @@ namespace LogExpert.UI.Dialogs; [SupportedOSPlatform("windows")] -public partial class ChooseIconDlg : Form +internal partial class ChooseIconDlg : Form { #region Fields diff --git a/src/LogExpert.UI/Dialogs/FilterColumnChooser.cs b/src/LogExpert.UI/Dialogs/FilterColumnChooser.cs index 4a62edb8..1aea2b15 100644 --- a/src/LogExpert.UI/Dialogs/FilterColumnChooser.cs +++ b/src/LogExpert.UI/Dialogs/FilterColumnChooser.cs @@ -1,11 +1,11 @@ -using LogExpert.Core.Classes.Filter; +using LogExpert.Core.Classes.Filter; using System.Runtime.Versioning; namespace LogExpert.UI.Dialogs; [SupportedOSPlatform("windows")] -public partial class FilterColumnChooser : Form +internal partial class FilterColumnChooser : Form { #region Fields diff --git a/src/LogExpert.UI/Dialogs/GotoLineDialog.cs b/src/LogExpert.UI/Dialogs/GotoLineDialog.cs index 123b1ca1..8b7d0b36 100644 --- a/src/LogExpert.UI/Dialogs/GotoLineDialog.cs +++ b/src/LogExpert.UI/Dialogs/GotoLineDialog.cs @@ -1,9 +1,9 @@ -using System.Runtime.Versioning; +using System.Runtime.Versioning; namespace LogExpert.UI.Dialogs; [SupportedOSPlatform("windows")] -public partial class GotoLineDialog : Form +internal partial class GotoLineDialog : Form { #region Fields diff --git a/src/LogExpert.UI/Dialogs/ImportSettingsDialog.cs b/src/LogExpert.UI/Dialogs/ImportSettingsDialog.cs index 5d66a75b..e7200fb4 100644 --- a/src/LogExpert.UI/Dialogs/ImportSettingsDialog.cs +++ b/src/LogExpert.UI/Dialogs/ImportSettingsDialog.cs @@ -1,11 +1,11 @@ -using LogExpert.Core.Config; +using LogExpert.Core.Config; using System.Runtime.Versioning; namespace LogExpert.UI.Dialogs; [SupportedOSPlatform("windows")] -public partial class ImportSettingsDialog : Form +internal partial class ImportSettingsDialog : Form { #region cTor diff --git a/src/LogExpert.UI/Dialogs/KeywordActionDlg.cs b/src/LogExpert.UI/Dialogs/KeywordActionDlg.cs index b34dca5b..dbc508f0 100644 --- a/src/LogExpert.UI/Dialogs/KeywordActionDlg.cs +++ b/src/LogExpert.UI/Dialogs/KeywordActionDlg.cs @@ -1,11 +1,11 @@ -using LogExpert.Core.Classes.Highlight; +using LogExpert.Core.Classes.Highlight; using System.Runtime.Versioning; namespace LogExpert.UI.Dialogs; [SupportedOSPlatform("windows")] -public partial class KeywordActionDlg : Form +internal partial class KeywordActionDlg : Form { #region Fields diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs index 8a150e27..fa1e3b01 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs @@ -12,7 +12,7 @@ namespace LogExpert.Dialogs; [SupportedOSPlatform("windows")] -public partial class HighlightDialog : Form +internal partial class HighlightDialog : Form { private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs index 43742412..6ae4d6e3 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs @@ -16,7 +16,7 @@ namespace LogExpert.UI.Controls.LogTabWindow; // Data shared over all LogTabWindow instances //TODO: Can we get rid of this class? [SupportedOSPlatform("windows")] -public partial class LogTabWindow : Form, ILogTabWindow +internal partial class LogTabWindow : Form, ILogTabWindow { #region Fields @@ -198,7 +198,7 @@ public void ChangeTheme (Control.ControlCollection container) { for (var x = 0; x < item.DropDownItems.Count; x++) { - ToolStripItem children = item.DropDownItems[x]; + var children = item.DropDownItems[x]; children.ForeColor = ColorMode.ForeColor; children.BackColor = ColorMode.MenuBackgroundColor; @@ -206,7 +206,7 @@ public void ChangeTheme (Control.ControlCollection container) { for (var y = 0; y < toolstripDropDownItem.DropDownItems.Count; y++) { - ToolStripItem subChildren = toolstripDropDownItem.DropDownItems[y]; + var subChildren = toolstripDropDownItem.DropDownItems[y]; subChildren.ForeColor = ColorMode.ForeColor; subChildren.BackColor = ColorMode.MenuBackgroundColor; } @@ -237,7 +237,7 @@ public void ChangeTheme (Control.ControlCollection container) // Tabs menu for (var y = 0; y < tabContextMenuStrip.Items.Count; y++) { - ToolStripItem item = tabContextMenuStrip.Items[y]; + var item = tabContextMenuStrip.Items[y]; item.ForeColor = ColorMode.ForeColor; item.BackColor = ColorMode.MenuBackgroundColor; } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs index 3b0dc376..16e7ed7e 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs @@ -9,14 +9,14 @@ using LogExpert.Core.Entities; using LogExpert.Core.EventArguments; using LogExpert.Dialogs; -using LogExpert.UI.Controls.LogWindow; using LogExpert.UI.Dialogs; +using LogExpert.UI.Extensions.LogWindow; using WeifenLuo.WinFormsUI.Docking; namespace LogExpert.UI.Controls.LogTabWindow; -public partial class LogTabWindow +internal partial class LogTabWindow { #region Events handler diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs index 68fcff65..8ad87e27 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs @@ -21,7 +21,7 @@ namespace LogExpert.UI.Controls.LogTabWindow; -public partial class LogTabWindow +internal partial class LogTabWindow { #region Private Methods diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs index eb4745ac..25000414 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs @@ -15,7 +15,7 @@ namespace LogExpert.UI.Controls.LogTabWindow; -public partial class LogTabWindow +internal partial class LogTabWindow { #region Public methods diff --git a/src/LogExpert.UI/Dialogs/MultiFileMaskDialog.cs b/src/LogExpert.UI/Dialogs/MultiFileMaskDialog.cs index 8b2203cf..6bbf4b12 100644 --- a/src/LogExpert.UI/Dialogs/MultiFileMaskDialog.cs +++ b/src/LogExpert.UI/Dialogs/MultiFileMaskDialog.cs @@ -1,9 +1,9 @@ -using System.Runtime.Versioning; +using System.Runtime.Versioning; namespace LogExpert.UI.Dialogs; [SupportedOSPlatform("windows")] -public partial class MultiFileMaskDialog : Form +internal partial class MultiFileMaskDialog : Form { #region Fields diff --git a/src/LogExpert.UI/Dialogs/MultiLoadRequestDialog.cs b/src/LogExpert.UI/Dialogs/MultiLoadRequestDialog.cs index b53360fd..0e311a0e 100644 --- a/src/LogExpert.UI/Dialogs/MultiLoadRequestDialog.cs +++ b/src/LogExpert.UI/Dialogs/MultiLoadRequestDialog.cs @@ -1,9 +1,9 @@ -using System.Runtime.Versioning; +using System.Runtime.Versioning; namespace LogExpert.UI.Dialogs; [SupportedOSPlatform("windows")] -public partial class MultiLoadRequestDialog : Form +internal partial class MultiLoadRequestDialog : Form { #region cTor diff --git a/src/LogExpert.UI/Dialogs/OpenUriDialog.cs b/src/LogExpert.UI/Dialogs/OpenUriDialog.cs index 290a2471..0b9f8cd7 100644 --- a/src/LogExpert.UI/Dialogs/OpenUriDialog.cs +++ b/src/LogExpert.UI/Dialogs/OpenUriDialog.cs @@ -1,9 +1,9 @@ -using System.Runtime.Versioning; +using System.Runtime.Versioning; namespace LogExpert.UI.Dialogs; [SupportedOSPlatform("windows")] -public partial class OpenUriDialog : Form +internal partial class OpenUriDialog : Form { #region Fields diff --git a/src/LogExpert.UI/Dialogs/ParamRequesterDialog.cs b/src/LogExpert.UI/Dialogs/ParamRequesterDialog.cs index ef272593..263a8a71 100644 --- a/src/LogExpert.UI/Dialogs/ParamRequesterDialog.cs +++ b/src/LogExpert.UI/Dialogs/ParamRequesterDialog.cs @@ -3,7 +3,7 @@ namespace LogExpert.Dialogs; [SupportedOSPlatform("windows")] -public partial class ParamRequesterDialog : Form +internal partial class ParamRequesterDialog : Form { #region Fields diff --git a/src/LogExpert.UI/Dialogs/ProjectLoadDlg.cs b/src/LogExpert.UI/Dialogs/ProjectLoadDlg.cs index 95ca661d..5d268884 100644 --- a/src/LogExpert.UI/Dialogs/ProjectLoadDlg.cs +++ b/src/LogExpert.UI/Dialogs/ProjectLoadDlg.cs @@ -1,11 +1,11 @@ -using LogExpert.Core.Enums; +using LogExpert.Core.Enums; using System.Runtime.Versioning; namespace LogExpert.Dialogs; [SupportedOSPlatform("windows")] -public partial class ProjectLoadDlg : Form +internal partial class ProjectLoadDlg : Form { #region Fields diff --git a/src/LogExpert.UI/Dialogs/RegexHelperDialog.cs b/src/LogExpert.UI/Dialogs/RegexHelperDialog.cs index 64c99a9f..ac7df7c5 100644 --- a/src/LogExpert.UI/Dialogs/RegexHelperDialog.cs +++ b/src/LogExpert.UI/Dialogs/RegexHelperDialog.cs @@ -4,7 +4,7 @@ namespace LogExpert.UI.Dialogs; [SupportedOSPlatform("windows")] -public partial class RegexHelperDialog : Form +internal partial class RegexHelperDialog : Form { #region Fields diff --git a/src/LogExpert.UI/Dialogs/SearchDialog.cs b/src/LogExpert.UI/Dialogs/SearchDialog.cs index f1e09da9..9ae87f17 100644 --- a/src/LogExpert.UI/Dialogs/SearchDialog.cs +++ b/src/LogExpert.UI/Dialogs/SearchDialog.cs @@ -7,7 +7,7 @@ namespace LogExpert.Dialogs; [SupportedOSPlatform("windows")] -public partial class SearchDialog : Form +internal partial class SearchDialog : Form { #region Fields diff --git a/src/LogExpert.UI/Dialogs/SearchProgressDialog.cs b/src/LogExpert.UI/Dialogs/SearchProgressDialog.cs index 5fd7a6be..5d1f8deb 100644 --- a/src/LogExpert.UI/Dialogs/SearchProgressDialog.cs +++ b/src/LogExpert.UI/Dialogs/SearchProgressDialog.cs @@ -1,9 +1,9 @@ -using System.Runtime.Versioning; +using System.Runtime.Versioning; namespace LogExpert.UI.Dialogs; [SupportedOSPlatform("windows")] -public partial class SearchProgressDialog : Form +internal partial class SearchProgressDialog : Form { #region Fields diff --git a/src/LogExpert.UI/Dialogs/TabRenameDialog.cs b/src/LogExpert.UI/Dialogs/TabRenameDialog.cs index 3a7a5391..2f2455db 100644 --- a/src/LogExpert.UI/Dialogs/TabRenameDialog.cs +++ b/src/LogExpert.UI/Dialogs/TabRenameDialog.cs @@ -1,9 +1,9 @@ -using System.Runtime.Versioning; +using System.Runtime.Versioning; namespace LogExpert.UI.Dialogs; [SupportedOSPlatform("windows")] -public partial class TabRenameDialog : Form +internal partial class TabRenameDialog : Form { #region cTor diff --git a/src/LogExpert.UI/Entities/WindowFileEntry.cs b/src/LogExpert.UI/Entities/WindowFileEntry.cs index 761c5c40..842dfd41 100644 --- a/src/LogExpert.UI/Entities/WindowFileEntry.cs +++ b/src/LogExpert.UI/Entities/WindowFileEntry.cs @@ -7,7 +7,7 @@ namespace LogExpert.UI.Entities; /// /// Represents a log file and its window. Used as a kind of handle for menus or list of open files. /// -public class WindowFileEntry (LogWindow logWindow) +internal class WindowFileEntry (LogWindow logWindow) { #region Fields diff --git a/src/LogExpert.UI/Extensions/ComboBoxExtensions.cs b/src/LogExpert.UI/Extensions/ComboBoxExtensions.cs index 90d7d31e..9cd24a7a 100644 --- a/src/LogExpert.UI/Extensions/ComboBoxExtensions.cs +++ b/src/LogExpert.UI/Extensions/ComboBoxExtensions.cs @@ -1,9 +1,9 @@ -using System.Runtime.Versioning; +using System.Runtime.Versioning; namespace LogExpert.UI.Extensions; [SupportedOSPlatform("windows")] -public static class ComboBoxExtensions +internal static class ComboBoxExtensions { /// public static int GetMaxTextWidth(this ComboBox comboBox) diff --git a/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs b/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs index 4c30c9a4..69fb69c6 100644 --- a/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs +++ b/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs @@ -1,11 +1,11 @@ -using LogExpert.Core.Config; +using LogExpert.Core.Config; using System.Runtime.Versioning; namespace LogExpert.UI.Extensions.Forms; [SupportedOSPlatform("windows")] -public class LineToolStripSeparatorExtension : ToolStripSeparator +internal class LineToolStripSeparatorExtension : ToolStripSeparator { public LineToolStripSeparatorExtension() { diff --git a/src/LogExpert.UI/Extensions/Forms/MenuSelectedColors.cs b/src/LogExpert.UI/Extensions/Forms/MenuSelectedColors.cs index 5e6a81bd..bc3544e5 100644 --- a/src/LogExpert.UI/Extensions/Forms/MenuSelectedColors.cs +++ b/src/LogExpert.UI/Extensions/Forms/MenuSelectedColors.cs @@ -1,11 +1,11 @@ -using LogExpert.Core.Config; +using LogExpert.Core.Config; using System.Runtime.Versioning; namespace LogExpert.UI.Extensions.Forms; [SupportedOSPlatform("windows")] -public class MenuSelectedColors : ProfessionalColorTable +internal class MenuSelectedColors : ProfessionalColorTable { public override Color ImageMarginGradientBegin => ColorMode.MenuBackgroundColor; diff --git a/src/LogExpert.UI/Extensions/Forms/MenuStripExtension.cs b/src/LogExpert.UI/Extensions/Forms/MenuStripExtension.cs index 1d4d16ca..e54a1796 100644 --- a/src/LogExpert.UI/Extensions/Forms/MenuStripExtension.cs +++ b/src/LogExpert.UI/Extensions/Forms/MenuStripExtension.cs @@ -1,9 +1,9 @@ -using System.Runtime.Versioning; +using System.Runtime.Versioning; namespace LogExpert.UI.Extensions.Forms; [SupportedOSPlatform("windows")] -public class ExtendedMenuStripRenderer : ToolStripProfessionalRenderer +internal class ExtendedMenuStripRenderer : ToolStripProfessionalRenderer { public ExtendedMenuStripRenderer() : base(new MenuSelectedColors()) { } } diff --git a/src/LogExpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs b/src/LogExpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs index 82e44e39..3f5f26f1 100644 --- a/src/LogExpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs +++ b/src/LogExpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs @@ -1,11 +1,11 @@ -using LogExpert.Core.Config; +using LogExpert.Core.Config; using System.Runtime.Versioning; namespace LogExpert.UI.Extensions.Forms; [SupportedOSPlatform("windows")] -public class MenuToolStripSeparatorExtension : ToolStripSeparator +internal class MenuToolStripSeparatorExtension : ToolStripSeparator { public MenuToolStripSeparatorExtension() { diff --git a/src/LogExpert.UI/Extensions/Forms/ToolStripRendererExtension.cs b/src/LogExpert.UI/Extensions/Forms/ToolStripRendererExtension.cs index 5b85f845..191d5988 100644 --- a/src/LogExpert.UI/Extensions/Forms/ToolStripRendererExtension.cs +++ b/src/LogExpert.UI/Extensions/Forms/ToolStripRendererExtension.cs @@ -1,9 +1,9 @@ -using System.Runtime.Versioning; +using System.Runtime.Versioning; namespace LogExpert.UI.Extensions.Forms; [SupportedOSPlatform("windows")] -public class ToolStripRendererExtension : ToolStripSystemRenderer +internal class ToolStripRendererExtension : ToolStripSystemRenderer { public ToolStripRendererExtension() { } diff --git a/src/LogExpert.UI/Controls/LogWindow/AbstractLogTabWindow.cs b/src/LogExpert.UI/Extensions/LogWindow/AbstractLogTabWindow.cs similarity index 67% rename from src/LogExpert.UI/Controls/LogWindow/AbstractLogTabWindow.cs rename to src/LogExpert.UI/Extensions/LogWindow/AbstractLogTabWindow.cs index 2a7caae9..664f4279 100644 --- a/src/LogExpert.UI/Controls/LogWindow/AbstractLogTabWindow.cs +++ b/src/LogExpert.UI/Extensions/LogWindow/AbstractLogTabWindow.cs @@ -1,9 +1,9 @@ using System.Runtime.Versioning; using LogExpert.Core.Interface; -using LogExpert.UI.Dialogs.LogTabWindow; +using LogExpert.UI.Controls.LogTabWindow; -namespace LogExpert.UI.Controls.LogWindow; +namespace LogExpert.UI.Extensions.LogWindow; public abstract class AbstractLogTabWindow () { @@ -12,6 +12,6 @@ public abstract class AbstractLogTabWindow () [SupportedOSPlatform("windows")] public static ILogTabWindow Create (string[] fileNames, int instanceNumber, bool showInstanceNumbers, IConfigManager configManager) { - return new LogTabWindow.LogTabWindow(fileNames, instanceNumber, showInstanceNumbers, configManager); + return new LogTabWindow(fileNames, instanceNumber, showInstanceNumbers, configManager); } } \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/StaticLogTabWindowData.cs b/src/LogExpert.UI/Extensions/LogWindow/StaticLogTabWindowData.cs similarity index 79% rename from src/LogExpert.UI/Controls/LogWindow/StaticLogTabWindowData.cs rename to src/LogExpert.UI/Extensions/LogWindow/StaticLogTabWindowData.cs index 88e8e1bf..cc356eb6 100644 --- a/src/LogExpert.UI/Controls/LogWindow/StaticLogTabWindowData.cs +++ b/src/LogExpert.UI/Extensions/LogWindow/StaticLogTabWindowData.cs @@ -1,6 +1,6 @@ using LogExpert.Core.Interface; -namespace LogExpert.UI.Dialogs.LogTabWindow; +namespace LogExpert.UI.Extensions.LogWindow; public class StaticLogTabWindowData { diff --git a/src/LogExpert.UI/Interface/ILogPaintContextUI.cs b/src/LogExpert.UI/Interface/ILogPaintContextUI.cs index 39557972..e4465748 100644 --- a/src/LogExpert.UI/Interface/ILogPaintContextUI.cs +++ b/src/LogExpert.UI/Interface/ILogPaintContextUI.cs @@ -1,4 +1,4 @@ -using LogExpert.Core.Classes.Highlight; +using LogExpert.Core.Classes.Highlight; using LogExpert.Core.Entities; using LogExpert.Core.Interface; @@ -7,7 +7,7 @@ namespace LogExpert.UI.Interface; /// /// Declares methods that are needed for drawing log lines. Used by PaintHelper. /// -public interface ILogPaintContextUI : ILogPaintContext +internal interface ILogPaintContextUI : ILogPaintContext { #region Properties diff --git a/src/LogExpert/Classes/LogExpertProxy.cs b/src/LogExpert/Classes/LogExpertProxy.cs index bf122209..d85448fb 100644 --- a/src/LogExpert/Classes/LogExpertProxy.cs +++ b/src/LogExpert/Classes/LogExpertProxy.cs @@ -1,13 +1,11 @@ -using LogExpert.Config; +using System.Windows.Forms; + +using LogExpert.Config; using LogExpert.Core.Interface; -using LogExpert.UI.Controls.LogWindow; +using LogExpert.UI.Extensions.LogWindow; using NLog; -using System; -using System.Collections.Generic; -using System.Windows.Forms; - namespace LogExpert.Classes; internal class LogExpertProxy : ILogExpertProxy diff --git a/src/LogExpert/Program.cs b/src/LogExpert/Program.cs index 95fa7dfe..0bd88b9b 100644 --- a/src/LogExpert/Program.cs +++ b/src/LogExpert/Program.cs @@ -1,26 +1,26 @@ -using LogExpert.Classes; +using System.Diagnostics; +using System.IO.Pipes; +using System.Reflection; +using System.Security; +using System.Security.Principal; +using System.Text; +using System.Windows.Forms; + +using LogExpert.Classes; using LogExpert.Classes.CommandLine; using LogExpert.Config; using LogExpert.Core.Classes.IPC; using LogExpert.Core.Config; using LogExpert.Core.Interface; using LogExpert.Dialogs; -using LogExpert.UI.Controls.LogWindow; using LogExpert.UI.Dialogs; +using LogExpert.UI.Extensions.LogWindow; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using NLog; -using System.Diagnostics; -using System.IO.Pipes; -using System.Reflection; -using System.Security; -using System.Security.Principal; -using System.Text; -using System.Windows.Forms; - namespace LogExpert; internal static class Program @@ -126,6 +126,7 @@ private static void Main(string[] args) MessageBox.Show($"Cannot open connection to first instance ({errMsg})", "LogExpert"); } + //TODO: Remove this from here? Why is it called from the Main project and not from the main window? if (settings.Preferences.AllowOnlyOneInstance && settings.Preferences.ShowErrorMessageAllowOnlyOneInstances) { AllowOnlyOneInstanceErrorDialog a = new(); From dcdd47d60c87f47755cded492e255bd13fe97f31 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Mon, 16 Jun 2025 08:54:46 +0200 Subject: [PATCH 086/142] removing DarkMode in preparation for .net 10 --- src/LogExpert.Core/Config/ColorMode.cs | 76 ------------- .../Controls/LogWindow/LogWindow.cs | 103 +----------------- .../Controls/LogWindow/LogWindowPublic.cs | 65 ++++++----- src/LogExpert.UI/Dialogs/BookmarkWindow.cs | 52 --------- .../Dialogs/LogTabWindow/LogTabWindow.cs | 103 ------------------ src/LogExpert.UI/Entities/PaintHelper.cs | 41 ++++--- 6 files changed, 53 insertions(+), 387 deletions(-) delete mode 100644 src/LogExpert.Core/Config/ColorMode.cs diff --git a/src/LogExpert.Core/Config/ColorMode.cs b/src/LogExpert.Core/Config/ColorMode.cs deleted file mode 100644 index 02a0c876..00000000 --- a/src/LogExpert.Core/Config/ColorMode.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System.Drawing; - -namespace LogExpert.Core.Config; - -public static class ColorMode -{ - // Bright Theme - // https://paletton.com/#uid=15-0u0k00sH00kJ0pq+00RL00RL - private static readonly Color BrightBookmarkDefaultSystemColor = SystemColors.Control; // Important: only supports SystemColors - private static readonly Color LessBrightBackgroundColor = Color.FromArgb(208, 205, 206); - private static readonly Color BrightBackgroundColor = Color.FromArgb(221, 221, 221); - private static readonly Color BrighterBackgroundColor = Color.White; - private static readonly Color BrightForeColor = Color.Black; - - // Dark Theme - // https://paletton.com/#uid=15-0u0k005U0670008J003Y003Y - private static readonly Color DarkBookmarkDefaultSystemColor = SystemColors.ControlDarkDark; // Important: only supports SystemColors - private static readonly Color LessLessDarkBackgroundColor = Color.FromArgb(90, 90, 90); - private static readonly Color LessDarkBackgroundColor = Color.FromArgb(67, 67, 67); - private static readonly Color DarkBackgroundColor = Color.FromArgb(45, 45, 45); - private static readonly Color DarkerBackgroundColor = Color.FromArgb(30, 30, 30); - private static readonly Color DarkForeColor = Color.White; - - // Default - public static Color BackgroundColor = BrightBackgroundColor; - public static Color DockBackgroundColor = BrighterBackgroundColor; - public static Color BookmarksDefaultBackgroundColor = BrightBookmarkDefaultSystemColor; - public static Color ForeColor = BrightForeColor; - public static Color MenuBackgroundColor = BrighterBackgroundColor; - public static Color HoverMenuBackgroundColor = LessBrightBackgroundColor; - public static Color ActiveTabColor = BrighterBackgroundColor; - public static Color InactiveTabColor = LessBrightBackgroundColor; - public static Color TabsBackgroundStripColor = LessBrightBackgroundColor; - - public static bool DarkModeEnabled; - - public static void LoadColorMode (bool darkMode) - { - if (darkMode) - { - SetDarkMode(); - } - else - { - SetBrightMode(); - } - } - - private static void SetDarkMode () - { - BackgroundColor = DarkBackgroundColor; - ForeColor = DarkForeColor; - MenuBackgroundColor = DarkerBackgroundColor; - DockBackgroundColor = LessDarkBackgroundColor; - HoverMenuBackgroundColor = LessDarkBackgroundColor; - BookmarksDefaultBackgroundColor = DarkBookmarkDefaultSystemColor; - TabsBackgroundStripColor = LessDarkBackgroundColor; - ActiveTabColor = LessLessDarkBackgroundColor; - InactiveTabColor = LessDarkBackgroundColor; - DarkModeEnabled = true; - } - - private static void SetBrightMode () - { - BackgroundColor = BrightBackgroundColor; - ForeColor = BrightForeColor; - MenuBackgroundColor = BrighterBackgroundColor; - DockBackgroundColor = BrighterBackgroundColor; - BookmarksDefaultBackgroundColor = BrightBookmarkDefaultSystemColor; - HoverMenuBackgroundColor = LessBrightBackgroundColor; - TabsBackgroundStripColor = BrighterBackgroundColor; - ActiveTabColor = BrighterBackgroundColor; - InactiveTabColor = LessBrightBackgroundColor; - DarkModeEnabled = false; - } -} diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index c593387e..f755c20e 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -13,7 +13,6 @@ using LogExpert.Core.Interface; using LogExpert.Dialogs; using LogExpert.UI.Dialogs; -using LogExpert.UI.Extensions.Forms; using LogExpert.UI.Interface; using NLog; @@ -228,7 +227,7 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp _panelOpenButtonImage = Resources.Resources.Arrow_menu_open; _panelCloseButtonImage = Resources.Resources.Arrow_menu_close; - Settings settings = configManager.Settings; + var settings = configManager.Settings; if (settings.AppBounds.Right > 0) { @@ -256,110 +255,10 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp _bookmarkProvider.AllBookmarksRemoved += OnBookmarkProviderAllBookmarksRemoved; ResumeLayout(); - - ChangeTheme(Controls); } - #endregion - - #region ColorTheme - - [SupportedOSPlatform("windows")] - public void ChangeTheme (Control.ControlCollection container) - { - #region ApplyColorToAllControls - foreach (Control component in container) - { - if (component.Controls != null && component.Controls.Count > 0) - { - ChangeTheme(component.Controls); - component.BackColor = ColorMode.BackgroundColor; - component.ForeColor = ColorMode.ForeColor; - } - else - { - component.BackColor = ColorMode.BackgroundColor; - component.ForeColor = ColorMode.ForeColor; - } - - } - #endregion - - #region DataGridView - - // Main DataGridView - dataGridView.BackgroundColor = ColorMode.DockBackgroundColor; - dataGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor; - dataGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor; - dataGridView.EnableHeadersVisualStyles = false; - - // Filter dataGridView - filterGridView.BackgroundColor = ColorMode.DockBackgroundColor; - filterGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor; - filterGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor; - filterGridView.EnableHeadersVisualStyles = false; - - // Colors for menu - dataGridContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - bookmarkContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - columnContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - editModeContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - filterContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - filterListContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - - foreach (ToolStripItem item in dataGridContextMenuStrip.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - foreach (ToolStripItem item in bookmarkContextMenuStrip.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - foreach (ToolStripItem item in columnContextMenuStrip.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - foreach (ToolStripItem item in editModeContextMenuStrip.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - foreach (ToolStripItem item in filterContextMenuStrip.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - foreach (ToolStripItem item in filterListContextMenuStrip.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - // Colors for menu - filterContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - - for (var y = 0; y < filterContextMenuStrip.Items.Count; y++) - { - ToolStripItem item = filterContextMenuStrip.Items[y]; - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - #endregion DataGridView - - filterComboBox.BackColor = ColorMode.DockBackgroundColor; - } - #endregion #region Delegates diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs index 601f3064..cd01695c 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs @@ -47,7 +47,7 @@ public void LoadFile (string fileName, EncodingOptions encodingOptions) { if (!IsTempFile) { - ILogLineColumnizer columnizer = FindColumnizer(); + var columnizer = FindColumnizer(); if (columnizer != null) { if (_reloadMemento == null) @@ -120,7 +120,7 @@ public void LoadFile (string fileName, EncodingOptions encodingOptions) { if (Preferences.AutoPick) { - ILogLineColumnizer newColumnizer = ColumnizerPicker.FindBetterColumnizer(FileName, _logFileReader, CurrentColumnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + var newColumnizer = ColumnizerPicker.FindBetterColumnizer(FileName, _logFileReader, CurrentColumnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); if (newColumnizer != null) { @@ -186,7 +186,7 @@ public string SavePersistenceData (bool force) try { - PersistenceData persistenceData = GetPersistenceData(); + var persistenceData = GetPersistenceData(); if (ForcedPersistenceFileName == null) { @@ -236,7 +236,7 @@ public PersistenceData GetPersistenceData () List filterList = [_filterParams]; persistenceData.FilterParamsList = filterList; - foreach (FilterPipe filterPipe in _filterPipeList) + foreach (var filterPipe in _filterPipeList) { FilterTabData data = new() { @@ -334,7 +334,7 @@ public void PreselectColumnizer (string columnizerName) //TODO this needs to be refactored var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + var columnizer = ColumnizerPicker.FindColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); PreSelectColumnizer(ColumnizerPicker.CloneColumnizer(columnizer, directory)); } @@ -369,12 +369,12 @@ public IColumn GetCellValue (int rowIndex, int columnIndex) try { - IColumnizedLogLine cols = GetColumnsForLine(rowIndex); + var cols = GetColumnsForLine(rowIndex); if (cols != null && cols.ColumnValues != null) { if (columnIndex <= cols.ColumnValues.Length + 1) { - IColumn value = cols.ColumnValues[columnIndex - 2]; + var value = cols.ColumnValues[columnIndex - 2]; if (value != null && value.DisplayValue != null) { @@ -407,27 +407,26 @@ public void CellPainting (BufferedDataGridView gridView, int rowIndex, DataGridV return; } - ILogLine line = _logFileReader.GetLogLineWithWait(rowIndex).Result; + var line = _logFileReader.GetLogLineWithWait(rowIndex).Result; if (line != null) { - HighlightEntry entry = FindFirstNoWordMatchHilightEntry(line); + var entry = FindFirstNoWordMatchHilightEntry(line); e.Graphics.SetClip(e.CellBounds); if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) { - Color backColor = ColorMode.BackgroundColor; + var backColor = e.CellStyle.SelectionBackColor; Brush brush; if (gridView.Focused) { - brush = new SolidBrush(e.CellStyle.SelectionBackColor); + brush = new SolidBrush(backColor); } else { - Color color = backColor; - brush = new SolidBrush(color); + brush = new SolidBrush(Color.FromArgb(255, 170, 170, 170)); //gray } e.Graphics.FillRectangle(brush, e.CellBounds); @@ -435,7 +434,7 @@ public void CellPainting (BufferedDataGridView gridView, int rowIndex, DataGridV } else { - Color bgColor = ColorMode.DockBackgroundColor; + var bgColor = Color.White; if (!DebugOptions.DisableWordHighlight) { @@ -476,7 +475,7 @@ public void CellPainting (BufferedDataGridView gridView, int rowIndex, DataGridV Brush brush = new SolidBrush(BookmarkColor); e.Graphics.FillRectangle(brush, r); brush.Dispose(); - Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(rowIndex); + var bookmark = _bookmarkProvider.GetBookmarkForLine(rowIndex); if (bookmark.Text.Length > 0) { @@ -485,7 +484,7 @@ public void CellPainting (BufferedDataGridView gridView, int rowIndex, DataGridV LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }; - Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); + Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); //dark orange Font font = new("Courier New", Preferences.FontSize, FontStyle.Bold); e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); @@ -517,7 +516,7 @@ public HighlightEntry FindHighlightEntry (ITextValue line, bool noWordMatches) // first check the temp entries lock (_tempHighlightEntryListLock) { - foreach (HighlightEntry entry in _tempHighlightEntryList) + foreach (var entry in _tempHighlightEntryList) { if (noWordMatches && entry.IsWordMatch) { @@ -533,7 +532,7 @@ public HighlightEntry FindHighlightEntry (ITextValue line, bool noWordMatches) lock (_currentHighlightGroupLock) { - foreach (HighlightEntry entry in _currentHighlightGroup.HighlightEntryList) + foreach (var entry in _currentHighlightGroup.HighlightEntryList) { if (noWordMatches && entry.IsWordMatch) { @@ -627,7 +626,7 @@ public void StartSearch () { _guiStateArgs.MenuEnabled = false; GuiStateUpdate(this, _guiStateArgs); - SearchParams searchParams = _parentLogTabWin.SearchParams; + var searchParams = _parentLogTabWin.SearchParams; if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) { @@ -847,11 +846,11 @@ public void AddBookmarkOverlays () if (_bookmarkProvider.IsBookmarkAtLine(i)) { - Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(i); + var bookmark = _bookmarkProvider.GetBookmarkForLine(i); if (bookmark.Text.Length > 0) { //BookmarkOverlay overlay = new BookmarkOverlay(); - BookmarkOverlay overlay = bookmark.Overlay; + var overlay = bookmark.Overlay; overlay.Bookmark = bookmark; Rectangle r; @@ -934,7 +933,7 @@ public void ToggleBookmark (int lineNum) { if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) { - Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); + var bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); if (string.IsNullOrEmpty(bookmark.Text) == false) { @@ -958,7 +957,7 @@ public void SetBookmarkFromTrigger (int lineNum, string comment) { lock (_bookmarkLock) { - ILogLine line = _logFileReader.GetLogLine(lineNum); + var line = _logFileReader.GetLogLine(lineNum); if (line == null) { return; @@ -1233,7 +1232,7 @@ public void CopyMarkedLinesToTab () var fStream = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.Read); var writer = new StreamWriter(fStream, Encoding.Unicode); - DataObject data = dataGridView.GetClipboardContent(); + var data = dataGridView.GetClipboardContent(); var text = data.GetText(TextDataFormat.Text); writer.Write(text); @@ -1400,7 +1399,7 @@ public int FindTimestampLine (int lineNum, DateTime timestamp, bool roundToSecon if (foundLine >= 0) { // go backwards to the first occurence of the hit - DateTime foundTimestamp = GetTimestampForLine(ref foundLine, roundToSeconds); + var foundTimestamp = GetTimestampForLine(ref foundLine, roundToSeconds); while (foundTimestamp.CompareTo(timestamp) == 0 && foundLine >= 0) { foundLine--; @@ -1424,7 +1423,7 @@ public int FindTimestampLine_Internal (int lineNum, int rangeStart, int rangeEnd { _logger.Debug("FindTimestampLine_Internal(): timestamp={0}, lineNum={1}, rangeStart={2}, rangeEnd={3}", timestamp, lineNum, rangeStart, rangeEnd); var refLine = lineNum; - DateTime currentTimestamp = GetTimestampForLine(ref refLine, roundToSeconds); + var currentTimestamp = GetTimestampForLine(ref refLine, roundToSeconds); if (currentTimestamp.CompareTo(timestamp) == 0) { return lineNum; @@ -1481,7 +1480,7 @@ public DateTime GetTimestampForLine (ref int lineNum, bool roundToSeconds) } _logger.Debug($"GetTimestampForLine({lineNum}) enter"); - DateTime timeStamp = DateTime.MinValue; + var timeStamp = DateTime.MinValue; var lookBack = false; if (lineNum >= 0 && lineNum < dataGridView.RowCount) { @@ -1493,7 +1492,7 @@ public DateTime GetTimestampForLine (ref int lineNum, bool roundToSeconds) } lookBack = true; - ILogLine logLine = _logFileReader.GetLogLine(lineNum); + var logLine = _logFileReader.GetLogLine(lineNum); if (logLine == null) { return DateTime.MinValue; @@ -1534,14 +1533,14 @@ public DateTime GetTimestampForLineForward (ref int lineNum, bool roundToSeconds return DateTime.MinValue; } - DateTime timeStamp = DateTime.MinValue; + var timeStamp = DateTime.MinValue; var lookFwd = false; if (lineNum >= 0 && lineNum < dataGridView.RowCount) { while (timeStamp.CompareTo(DateTime.MinValue) == 0 && lineNum < dataGridView.RowCount) { lookFwd = true; - ILogLine logLine = _logFileReader.GetLogLine(lineNum); + var logLine = _logFileReader.GetLogLine(lineNum); if (logLine == null) { timeStamp = DateTime.MinValue; @@ -1731,7 +1730,7 @@ public void ImportBookmarkList () // Add (or replace) to existing bookmark list var bookmarkAdded = false; - foreach (Bookmark b in newBookmarks.Values) + foreach (var b in newBookmarks.Values) { if (!_bookmarkProvider.BookmarkList.ContainsKey(b.LineNum)) { @@ -1740,7 +1739,7 @@ public void ImportBookmarkList () } else { - Bookmark existingBookmark = _bookmarkProvider.BookmarkList[b.LineNum]; + var existingBookmark = _bookmarkProvider.BookmarkList[b.LineNum]; existingBookmark.Text = b.Text; // replace existing bookmark for that line, preserving the overlay OnBookmarkTextChanged(b); @@ -1782,7 +1781,7 @@ public void HandleChangedFilterListWorker () { var index = filterListBox.SelectedIndex; filterListBox.Items.Clear(); - foreach (FilterParams filterParam in ConfigManager.Settings.FilterList) + foreach (var filterParam in ConfigManager.Settings.FilterList) { filterListBox.Items.Add(filterParam); } diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs index d471c587..8653c766 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs @@ -5,7 +5,6 @@ using LogExpert.Core.Enums; using LogExpert.Core.Interface; using LogExpert.UI.Entities; -using LogExpert.UI.Extensions.Forms; using LogExpert.UI.Interface; using NLog; @@ -39,57 +38,6 @@ public BookmarkWindow () bookmarkDataGridView.CellValueNeeded += OnBoomarkDataGridViewCellValueNeeded; bookmarkDataGridView.CellPainting += OnBoomarkDataGridViewCellPainting; - - ChangeTheme(Controls); - } - - #endregion - - #region ColorTheme - - public void ChangeTheme (Control.ControlCollection container) - { - #region ApplyColorToAllControls - - foreach (Control component in container) - { - if (component.Controls != null && component.Controls.Count > 0) - { - ChangeTheme(component.Controls); - component.BackColor = ColorMode.BackgroundColor; - component.ForeColor = ColorMode.ForeColor; - } - else - { - component.BackColor = ColorMode.BackgroundColor; - component.ForeColor = ColorMode.ForeColor; - } - - } - - #endregion - - #region DataGridView - - BackColor = ColorMode.DockBackgroundColor; - - // Main DataGridView - bookmarkDataGridView.BackgroundColor = ColorMode.DockBackgroundColor; - bookmarkDataGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor; - bookmarkDataGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor; - bookmarkDataGridView.EnableHeadersVisualStyles = false; - - // Colors for menu - contextMenuStrip1.Renderer = new ExtendedMenuStripRenderer(); - - for (var y = 0; y < contextMenuStrip1.Items.Count; y++) - { - var item = contextMenuStrip1.Items[y]; - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - #endregion DataGridView } #endregion diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs index 6ae4d6e3..e1ac9cfa 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs @@ -6,8 +6,6 @@ using LogExpert.Core.Entities; using LogExpert.Core.Interface; using LogExpert.Dialogs; -using LogExpert.UI.Extensions; -using LogExpert.UI.Extensions.Forms; using NLog; @@ -164,107 +162,6 @@ public LogTabWindow (string[] fileNames, int instanceNumber, bool showInstanceNu #endregion - #region ColorTheme - - [SupportedOSPlatform("windows")] - public void ChangeTheme (Control.ControlCollection container) - { - ColorMode.LoadColorMode(ConfigManager.Settings.Preferences.DarkMode); - NativeMethods.UseImmersiveDarkMode(Handle, ColorMode.DarkModeEnabled); - - #region ApplyColorToAllControls - foreach (Control component in container) - { - if (component.Controls != null && component.Controls.Count > 0) - { - ChangeTheme(component.Controls); - component.BackColor = ColorMode.BackgroundColor; - component.ForeColor = ColorMode.ForeColor; - } - else - { - component.BackColor = ColorMode.BackgroundColor; - component.ForeColor = ColorMode.ForeColor; - } - - if (component is MenuStrip menu) - { - foreach (ToolStripMenuItem item in menu.Items) - { - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.BackgroundColor; - - try - { - for (var x = 0; x < item.DropDownItems.Count; x++) - { - var children = item.DropDownItems[x]; - children.ForeColor = ColorMode.ForeColor; - children.BackColor = ColorMode.MenuBackgroundColor; - - if (children is ToolStripDropDownItem toolstripDropDownItem) - { - for (var y = 0; y < toolstripDropDownItem.DropDownItems.Count; y++) - { - var subChildren = toolstripDropDownItem.DropDownItems[y]; - subChildren.ForeColor = ColorMode.ForeColor; - subChildren.BackColor = ColorMode.MenuBackgroundColor; - } - } - } - } - catch (Exception ex) - { - _logger.Error(ex, "An error occured while applying style dynamically to all Controls under LogTabWindow:"); - } - } - } - } - #endregion - - // Colors for selected menus - mainMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - - // Dock special color - dockPanel.DockBackColor = ColorMode.DockBackgroundColor; - - // Remove toolstrip bottom border - buttonToolStrip.Renderer = new ToolStripRendererExtension(); - - #region Tabs - tabContextMenuStrip.Renderer = new ExtendedMenuStripRenderer(); - - // Tabs menu - for (var y = 0; y < tabContextMenuStrip.Items.Count; y++) - { - var item = tabContextMenuStrip.Items[y]; - item.ForeColor = ColorMode.ForeColor; - item.BackColor = ColorMode.MenuBackgroundColor; - } - - // Tabs line - dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient.StartColor = ColorMode.TabsBackgroundStripColor; - dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient.EndColor = ColorMode.TabsBackgroundStripColor; - - dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.DockStripGradient.StartColor = ColorMode.TabsBackgroundStripColor; - dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.DockStripGradient.EndColor = ColorMode.TabsBackgroundStripColor; - - // Tabs - dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.StartColor = ColorMode.ActiveTabColor; - dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.EndColor = ColorMode.ActiveTabColor; - dockPanel.Theme.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.TextColor = ColorMode.ForeColor; - - dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.StartColor = ColorMode.ActiveTabColor; - dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.EndColor = ColorMode.ActiveTabColor; - dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.TextColor = ColorMode.ForeColor; - - dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.StartColor = ColorMode.InactiveTabColor; - dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.EndColor = ColorMode.InactiveTabColor; - dockPanel.Theme.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.TextColor = ColorMode.ForeColor; - #endregion Tabs - } - #endregion - #region Delegates private delegate void AddFileTabsDelegate (string[] fileNames); diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index c1f9c9e5..b0e783d6 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -1,7 +1,6 @@ using System.Runtime.Versioning; using LogExpert.Core.Classes.Highlight; -using LogExpert.Core.Config; using LogExpert.Core.Entities; using LogExpert.Dialogs; using LogExpert.UI.Controls; @@ -35,16 +34,16 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri return; } - ILogLine line = logPaintCtx.GetLogLine(rowIndex); + var line = logPaintCtx.GetLogLine(rowIndex); if (line != null) { - HighlightEntry entry = logPaintCtx.FindHighlightEntry(line, true); + var entry = logPaintCtx.FindHighlightEntry(line, true); e.Graphics.SetClip(e.CellBounds); if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) { - Color backColor = e.CellStyle.SelectionBackColor; + var backColor = e.CellStyle.SelectionBackColor; Brush brush; if (gridView.Focused) @@ -53,8 +52,7 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri } else { - var color = Color.FromArgb(255, 170, 170, 170); - brush = new SolidBrush(color); + brush = new SolidBrush(Color.FromArgb(255, 170, 170, 170)); //gray } e.Graphics.FillRectangle(brush, e.CellBounds); @@ -62,7 +60,8 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri } else { - Color bgColor = ColorMode.DockBackgroundColor; + var bgColor = Color.White; + if (!DebugOptions.DisableWordHighlight) { if (entry != null) @@ -93,7 +92,7 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri if (e.ColumnIndex == 0) { - Bookmark bookmark = logPaintCtx.GetBookmarkForLine(rowIndex); + var bookmark = logPaintCtx.GetBookmarkForLine(rowIndex); if (bookmark != null) { Rectangle r; // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); @@ -111,7 +110,7 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri }; Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); - Font font = logPaintCtx.MonospacedFont; + var font = logPaintCtx.MonospacedFont; e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); brush2.Dispose(); } @@ -317,7 +316,7 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr { var value = e.Value ?? string.Empty; - IList matchList = logPaintCtx.FindHighlightMatches(value as ILogLine); + var matchList = logPaintCtx.FindHighlightMatches(value as ILogLine); // too many entries per line seem to cause problems with the GDI while (matchList.Count > 50) { @@ -356,8 +355,8 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr var leftPad = e.CellStyle.Padding.Left; RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, e.CellBounds.Height); - Rectangle borderWidths = BorderWidths(e.AdvancedBorderStyle); - Rectangle valBounds = e.CellBounds; + var borderWidths = BorderWidths(e.AdvancedBorderStyle); + var valBounds = e.CellBounds; valBounds.Offset(borderWidths.X, borderWidths.Y); valBounds.Width -= borderWidths.Right; valBounds.Height -= borderWidths.Bottom; @@ -369,7 +368,7 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr } - TextFormatFlags flags = + var flags = TextFormatFlags.Left | TextFormatFlags.SingleLine | TextFormatFlags.NoPrefix @@ -383,15 +382,15 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr // TextFormatFlags.SingleLine //TextRenderer.DrawText(e.Graphics, e.Value as String, e.CellStyle.Font, valBounds, Color.FromKnownColor(KnownColor.Black), flags); - Point wordPos = valBounds.Location; + var wordPos = valBounds.Location; Size proposedSize = new(valBounds.Width, valBounds.Height); - Rectangle r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); + var r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); e.Graphics.SetClip(e.CellBounds); - foreach (HighlightMatchEntry matchEntry in matchList) + foreach (var matchEntry in matchList) { - Font font = matchEntry != null && matchEntry.HighlightEntry.IsBold + var font = matchEntry != null && matchEntry.HighlightEntry.IsBold ? logPaintCtx.BoldFont : logPaintCtx.NormalFont; @@ -408,11 +407,11 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr } } - Size wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags); + var wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags); wordSize.Height = e.CellBounds.Height; Rectangle wordRect = new(wordPos, wordSize); - Color foreColor = matchEntry.HighlightEntry.ForegroundColor; + var foreColor = matchEntry.HighlightEntry.ForegroundColor; if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected) { if (!noBackgroundFill && bgBrush != null && !matchEntry.HighlightEntry.NoBackground) @@ -456,7 +455,7 @@ private static IList MergeHighlightMatchEntries (IList MergeHighlightMatchEntries (IList mergedList = []; if (entryArray.Length > 0) { - HighlightEntry currentEntry = entryArray[0]; + var currentEntry = entryArray[0]; var lastStartPos = 0; var pos = 0; for (; pos < entryArray.Length; ++pos) From d9512cb548b99287f74dee3e4791e27983b01289 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Mon, 16 Jun 2025 09:02:46 +0200 Subject: [PATCH 087/142] more colors --- src/LogExpert.UI/Dialogs/BookmarkWindow.cs | 19 +++++++++---------- .../Dialogs/LogTabWindow/LogTabWindow.cs | 2 -- src/LogExpert.UI/Entities/PaintHelper.cs | 3 ++- .../Forms/LineToolStripSeparatorExtension.cs | 9 ++++----- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs index 8653c766..2c5096e1 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs @@ -200,7 +200,7 @@ protected override void OnPaint (PaintEventArgs e) { if (!splitContainer1.Visible) { - Rectangle r = ClientRectangle; + var r = ClientRectangle; e.Graphics.FillRectangle(SystemBrushes.FromSystemColor(ColorMode.BookmarksDefaultBackgroundColor), r); StringFormat sf = new() @@ -229,9 +229,9 @@ private void SetFont (string fontName, float fontSize) bookmarkDataGridView.Refresh(); } - private void CommentPainting (BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) + private void CommentPainting (BufferedDataGridView gridView, DataGridViewCellPaintingEventArgs e) { - Color backColor = ColorMode.DockBackgroundColor; + var backColor = e.CellStyle.SelectionBackColor; if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) { @@ -244,8 +244,7 @@ private void CommentPainting (BufferedDataGridView gridView, int rowIndex, DataG else { // _logger.logDebug("CellPaint No Focus"); - var color = Color.FromArgb(255, 170, 170, 170); - brush = new SolidBrush(color); + brush = new SolidBrush(Color.FromArgb(255, 170, 170, 170)); //gray } e.Graphics.FillRectangle(brush, e.CellBounds); @@ -253,7 +252,7 @@ private void CommentPainting (BufferedDataGridView gridView, int rowIndex, DataG } else { - e.CellStyle.BackColor = backColor; + e.CellStyle.BackColor = Color.White; e.PaintBackground(e.CellBounds, false); } @@ -294,7 +293,7 @@ private void CurrentRowChanged (int rowIndex) } else { - Bookmark bookmark = bookmarkData.Bookmarks[rowIndex]; + var bookmark = bookmarkData.Bookmarks[rowIndex]; bookmarkTextBox.Text = bookmark.Text; bookmarkTextBox.Enabled = true; } @@ -362,7 +361,7 @@ private void OnBoomarkDataGridViewCellValueNeeded (object sender, DataGridViewCe return; } - Bookmark bookmarkForLine = bookmarkData.Bookmarks[e.RowIndex]; + var bookmarkForLine = bookmarkData.Bookmarks[e.RowIndex]; var lineNum = bookmarkForLine.LineNum; if (e.ColumnIndex == 1) { @@ -454,7 +453,7 @@ private void bookmarkTextBox_TextChanged (object sender, EventArgs e) return; } - Bookmark bookmark = bookmarkData.Bookmarks[rowIndex]; + var bookmark = bookmarkData.Bookmarks[rowIndex]; bookmark.Text = bookmarkTextBox.Text; logView?.RefreshLogView(); } @@ -488,7 +487,7 @@ private void bookmarkDataGridView_CellToolTipTextNeeded (object sender, return; } - Bookmark bookmark = bookmarkData.Bookmarks[e.RowIndex]; + var bookmark = bookmarkData.Bookmarks[e.RowIndex]; if (!string.IsNullOrEmpty(bookmark.Text)) { e.ToolTipText = bookmark.Text; diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs index e1ac9cfa..88889378 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs @@ -82,8 +82,6 @@ public LogTabWindow (string[] fileNames, int instanceNumber, bool showInstanceNu mainMenuStrip.Location = new Point(0, 0); externalToolsToolStrip.Location = new Point(0, 54); - ChangeTheme(Controls); - _startupFileNames = fileNames; _instanceNumber = instanceNumber; _showInstanceNumbers = showInstanceNumbers; diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index b0e783d6..b438a93a 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -336,7 +336,8 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr var he = new HighlightEntry { SearchText = column.FullValue, - ForegroundColor = groundEntry?.ForegroundColor ?? ColorMode.ForeColor, + //TODO change to white if the background color is darker + ForegroundColor = groundEntry?.ForegroundColor ?? Color.FromKnownColor(KnownColor.Black), BackgroundColor = groundEntry?.BackgroundColor ?? Color.Empty, IsRegEx = false, IsCaseSensitive = false, diff --git a/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs b/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs index 4e7d5752..134f8843 100644 --- a/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs +++ b/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs @@ -1,13 +1,11 @@ -using System.Runtime.Versioning; - -using LogExpert.Core.Config; +using System.Runtime.Versioning; namespace LogExpert.UI.Extensions.Forms; [SupportedOSPlatform("windows")] internal class LineToolStripSeparatorExtension : ToolStripSeparator { - public LineToolStripSeparatorExtension() + public LineToolStripSeparatorExtension () { Paint += OnExtendedToolStripSeparatorPaint; } @@ -21,7 +19,8 @@ private void OnExtendedToolStripSeparatorPaint (object sender, PaintEventArgs e) // Choose the colors for drawing. // I've used Color.White as the foreColor. - Color foreColor = ColorMode.ForeColor; + //TODO change to white if the background color is darker; + Color foreColor = Color.FromKnownColor(KnownColor.Black); // Color.Teal as the backColor. Color backColor = ColorMode.BackgroundColor; From 6b3d97d2f56cfaf8f5f069c1304ecee562e306fe Mon Sep 17 00:00:00 2001 From: Hirogen Date: Mon, 16 Jun 2025 09:10:18 +0200 Subject: [PATCH 088/142] removing more darkmode stuff --- .../Controls/LogWindow/LogWindow.designer.cs | 29 ++-- .../LogTabWindow/LogTabWindow.designer.cs | 135 +++++++++--------- .../Forms/LineToolStripSeparatorExtension.cs | 35 ----- .../Extensions/Forms/MenuSelectedColors.cs | 31 ---- .../Extensions/Forms/MenuStripExtension.cs | 9 -- .../Forms/MenuToolStripSeparatorExtension.cs | 39 ----- .../Forms/ToolStripRendererExtension.cs | 15 -- 7 files changed, 81 insertions(+), 212 deletions(-) delete mode 100644 src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs delete mode 100644 src/LogExpert.UI/Extensions/Forms/MenuSelectedColors.cs delete mode 100644 src/LogExpert.UI/Extensions/Forms/MenuStripExtension.cs delete mode 100644 src/LogExpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs delete mode 100644 src/LogExpert.UI/Extensions/Forms/ToolStripRendererExtension.cs diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs index 27d15a90..c49e42bf 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs @@ -1,5 +1,4 @@ using LogExpert.Dialogs; -using LogExpert.UI.Extensions.Forms; using System; using System.Drawing; using System.IO; @@ -46,21 +45,21 @@ private void InitializeComponent() dataGridContextMenuStrip = new ContextMenuStrip(components); copyToolStripMenuItem = new ToolStripMenuItem(); copyToTabToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparator1 = new MenuToolStripSeparatorExtension(); + menuToolStripSeparator1 = new ToolStripSeparator(); scrollAllTabsToTimestampToolStripMenuItem = new ToolStripMenuItem(); syncTimestampsToToolStripMenuItem = new ToolStripMenuItem(); freeThisWindowFromTimeSyncToolStripMenuItem = new ToolStripMenuItem(); locateLineInOriginalFileToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparator2 = new MenuToolStripSeparatorExtension(); + menuToolStripSeparator2 = new ToolStripSeparator(); toggleBoomarkToolStripMenuItem = new ToolStripMenuItem(); bookmarkCommentToolStripMenuItem = new ToolStripMenuItem(); markEditModeToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparator3 = new MenuToolStripSeparatorExtension(); + menuToolStripSeparator3 = new ToolStripSeparator(); tempHighlightsToolStripMenuItem = new ToolStripMenuItem(); removeAllToolStripMenuItem = new ToolStripMenuItem(); makePermanentToolStripMenuItem = new ToolStripMenuItem(); markCurrentFilterRangeToolStripMenuItem = new ToolStripMenuItem(); - pluginSeparator = new MenuToolStripSeparatorExtension(); + pluginSeparator = new ToolStripSeparator(); timeSpreadingControl = new TimeSpreadingControl(); advancedBackPanel = new Panel(); advancedFilterSplitContainer = new SplitContainer(); @@ -112,14 +111,14 @@ private void InitializeComponent() deleteBookmarksToolStripMenuItem = new ToolStripMenuItem(); columnContextMenuStrip = new ContextMenuStrip(components); freezeLeftColumnsUntilHereToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparator4 = new MenuToolStripSeparatorExtension(); + menuToolStripSeparator4 = new ToolStripSeparator(); moveToLastColumnToolStripMenuItem = new ToolStripMenuItem(); moveLeftToolStripMenuItem = new ToolStripMenuItem(); moveRightToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparator5 = new MenuToolStripSeparatorExtension(); + menuToolStripSeparator5 = new ToolStripSeparator(); hideColumnToolStripMenuItem = new ToolStripMenuItem(); restoreColumnsToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparator6 = new MenuToolStripSeparatorExtension(); + menuToolStripSeparator6 = new ToolStripSeparator(); allColumnsToolStripMenuItem = new ToolStripMenuItem(); editModeContextMenuStrip = new ContextMenuStrip(components); editModecopyToolStripMenuItem = new ToolStripMenuItem(); @@ -1294,12 +1293,12 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox filterCaseSensitiveCheckBox; private System.Windows.Forms.Button filterSearchButton; private System.Windows.Forms.Panel panelBackgroundAdvancedFilterSplitContainer; - private MenuToolStripSeparatorExtension pluginSeparator; - private MenuToolStripSeparatorExtension menuToolStripSeparator1; - private MenuToolStripSeparatorExtension menuToolStripSeparator2; - private MenuToolStripSeparatorExtension menuToolStripSeparator3; - private MenuToolStripSeparatorExtension menuToolStripSeparator4; - private MenuToolStripSeparatorExtension menuToolStripSeparator5; - private MenuToolStripSeparatorExtension menuToolStripSeparator6; + private ToolStripSeparator pluginSeparator; + private ToolStripSeparator menuToolStripSeparator1; + private ToolStripSeparator menuToolStripSeparator2; + private ToolStripSeparator menuToolStripSeparator3; + private ToolStripSeparator menuToolStripSeparator4; + private ToolStripSeparator menuToolStripSeparator5; + private ToolStripSeparator menuToolStripSeparator6; } } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs index 3821a872..88684eb7 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs @@ -1,7 +1,6 @@ -using System.Windows.Forms; +using System.Windows.Forms; using LogExpert.Core.Enums; using LogExpert.Dialogs; -using LogExpert.UI.Extensions.Forms; using WeifenLuo.WinFormsUI.Docking; namespace LogExpert.UI.Controls.LogTabWindow @@ -63,15 +62,15 @@ private void InitializeComponent() closeFileToolStripMenuItem = new ToolStripMenuItem(); reloadToolStripMenuItem = new ToolStripMenuItem(); newFromClipboardToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparatorExtension1 = new MenuToolStripSeparatorExtension(); + ToolStripSeparator1 = new ToolStripSeparator(); multiFileToolStripMenuItem = new ToolStripMenuItem(); multiFileEnabledStripMenuItem = new ToolStripMenuItem(); multifileMaskToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparatorExtension2 = new MenuToolStripSeparatorExtension(); + ToolStripSeparator2 = new ToolStripSeparator(); loadProjectToolStripMenuItem = new ToolStripMenuItem(); saveProjectToolStripMenuItem = new ToolStripMenuItem(); exportBookmarksToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparatorExtension3 = new MenuToolStripSeparatorExtension(); + ToolStripSeparator3 = new ToolStripSeparator(); lastUsedToolStripMenuItem = new ToolStripMenuItem(); exitToolStripMenuItem = new ToolStripMenuItem(); viewNavigateToolStripMenuItem = new ToolStripMenuItem(); @@ -84,35 +83,35 @@ private void InitializeComponent() jumpToPrevToolStripMenuItem = new ToolStripMenuItem(); showBookmarkListToolStripMenuItem = new ToolStripMenuItem(); columnFinderToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparatorExtension5 = new MenuToolStripSeparatorExtension(); + ToolStripSeparator5 = new ToolStripSeparator(); toolStripEncodingMenuItem = new ToolStripMenuItem(); toolStripEncodingASCIIItem = new ToolStripMenuItem(); toolStripEncodingANSIItem = new ToolStripMenuItem(); toolStripEncodingISO88591Item = new ToolStripMenuItem(); toolStripEncodingUTF8Item = new ToolStripMenuItem(); toolStripEncodingUTF16Item = new ToolStripMenuItem(); - menuToolStripSeparatorExtension6 = new MenuToolStripSeparatorExtension(); + ToolStripSeparator6 = new ToolStripSeparator(); timeshiftToolStripMenuItem = new ToolStripMenuItem(); timeshiftMenuTextBox = new ToolStripTextBox(); - menuToolStripSeparatorExtension4 = new MenuToolStripSeparatorExtension(); + ToolStripSeparator4 = new ToolStripSeparator(); copyMarkedLinesIntoNewTabToolStripMenuItem = new ToolStripMenuItem(); optionToolStripMenuItem = new ToolStripMenuItem(); columnizerToolStripMenuItem = new ToolStripMenuItem(); hilightingToolStripMenuItem1 = new ToolStripMenuItem(); - menuToolStripSeparatorExtension7 = new MenuToolStripSeparatorExtension(); + ToolStripSeparator7 = new ToolStripSeparator(); settingsToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparatorExtension9 = new MenuToolStripSeparatorExtension(); + ToolStripSeparator9 = new ToolStripSeparator(); cellSelectModeToolStripMenuItem = new ToolStripMenuItem(); alwaysOnTopToolStripMenuItem = new ToolStripMenuItem(); hideLineColumnToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparatorExtension8 = new MenuToolStripSeparatorExtension(); + ToolStripSeparator8 = new ToolStripSeparator(); lockInstanceToolStripMenuItem = new ToolStripMenuItem(); toolsToolStripMenuItem = new ToolStripMenuItem(); configureToolStripMenuItem = new ToolStripMenuItem(); - configureToolStripSeparator = new MenuToolStripSeparatorExtension(); + configureToolStripSeparator = new ToolStripSeparator(); helpToolStripMenuItem = new ToolStripMenuItem(); showHelpToolStripMenuItem = new ToolStripMenuItem(); - menuToolStripSeparatorExtension11 = new MenuToolStripSeparatorExtension(); + ToolStripSeparator11 = new ToolStripSeparator(); aboutToolStripMenuItem = new ToolStripMenuItem(); debugToolStripMenuItem = new ToolStripMenuItem(); dumpLogBufferInfoToolStripMenuItem = new ToolStripMenuItem(); @@ -133,18 +132,18 @@ private void InitializeComponent() externalToolsToolStrip = new ToolStrip(); buttonToolStrip = new ToolStrip(); toolStripButtonOpen = new ToolStripButton(); - lineToolStripSeparatorExtension1 = new LineToolStripSeparatorExtension(); + lineToolStripSeparatorExtension1 = new ToolStripSeparator(); toolStripButtonSearch = new ToolStripButton(); toolStripButtonFilter = new ToolStripButton(); - lineToolStripSeparatorExtension2 = new LineToolStripSeparatorExtension(); + lineToolStripSeparatorExtension2 = new ToolStripSeparator(); toolStripButtonBookmark = new ToolStripButton(); toolStripButtonUp = new ToolStripButton(); toolStripButtonDown = new ToolStripButton(); - lineToolStripSeparatorExtension3 = new LineToolStripSeparatorExtension(); + lineToolStripSeparatorExtension3 = new ToolStripSeparator(); toolStripButtonBubbles = new ToolStripButton(); - lineToolStripSeparatorExtension4 = new LineToolStripSeparatorExtension(); + lineToolStripSeparatorExtension4 = new ToolStripSeparator(); toolStripButtonTail = new ToolStripButton(); - lineToolStripSeparatorExtension5 = new LineToolStripSeparatorExtension(); + lineToolStripSeparatorExtension5 = new ToolStripSeparator(); groupsComboBoxHighlightGroups = new ToolStripComboBox(); checkBoxFollowTail = new CheckBox(); tabContextMenuStrip = new ContextMenuStrip(components); @@ -232,7 +231,7 @@ private void InitializeComponent() // // fileToolStripMenuItem // - fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { openToolStripMenuItem, openURIToolStripMenuItem, closeFileToolStripMenuItem, reloadToolStripMenuItem, newFromClipboardToolStripMenuItem, menuToolStripSeparatorExtension1, multiFileToolStripMenuItem, menuToolStripSeparatorExtension2, loadProjectToolStripMenuItem, saveProjectToolStripMenuItem, exportBookmarksToolStripMenuItem, menuToolStripSeparatorExtension3, lastUsedToolStripMenuItem, exitToolStripMenuItem }); + fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { openToolStripMenuItem, openURIToolStripMenuItem, closeFileToolStripMenuItem, reloadToolStripMenuItem, newFromClipboardToolStripMenuItem, ToolStripSeparator1, multiFileToolStripMenuItem, ToolStripSeparator2, loadProjectToolStripMenuItem, saveProjectToolStripMenuItem, exportBookmarksToolStripMenuItem, ToolStripSeparator3, lastUsedToolStripMenuItem, exitToolStripMenuItem }); fileToolStripMenuItem.Name = "fileToolStripMenuItem"; fileToolStripMenuItem.Size = new System.Drawing.Size(37, 19); fileToolStripMenuItem.Text = "File"; @@ -284,10 +283,10 @@ private void InitializeComponent() newFromClipboardToolStripMenuItem.ToolTipText = "Creates a new tab with content from clipboard"; newFromClipboardToolStripMenuItem.Click += OnNewFromClipboardToolStripMenuItemClick; // - // menuToolStripSeparatorExtension1 + // ToolStripSeparator1 // - menuToolStripSeparatorExtension1.Name = "menuToolStripSeparatorExtension1"; - menuToolStripSeparatorExtension1.Size = new System.Drawing.Size(250, 6); + ToolStripSeparator1.Name = "ToolStripSeparator1"; + ToolStripSeparator1.Size = new System.Drawing.Size(250, 6); // // multiFileToolStripMenuItem // @@ -318,10 +317,10 @@ private void InitializeComponent() multifileMaskToolStripMenuItem.Text = "File name mask..."; multifileMaskToolStripMenuItem.Click += OnMultiFileMaskToolStripMenuItemClick; // - // menuToolStripSeparatorExtension2 + // ToolStripSeparator2 // - menuToolStripSeparatorExtension2.Name = "menuToolStripSeparatorExtension2"; - menuToolStripSeparatorExtension2.Size = new System.Drawing.Size(250, 6); + ToolStripSeparator2.Name = "ToolStripSeparator2"; + ToolStripSeparator2.Size = new System.Drawing.Size(250, 6); // // loadProjectToolStripMenuItem // @@ -347,10 +346,10 @@ private void InitializeComponent() exportBookmarksToolStripMenuItem.ToolTipText = "Write a list of bookmarks and their comments to a CSV file"; exportBookmarksToolStripMenuItem.Click += OnExportBookmarksToolStripMenuItemClick; // - // menuToolStripSeparatorExtension3 + // ToolStripSeparator3 // - menuToolStripSeparatorExtension3.Name = "menuToolStripSeparatorExtension3"; - menuToolStripSeparatorExtension3.Size = new System.Drawing.Size(250, 6); + ToolStripSeparator3.Name = "ToolStripSeparator3"; + ToolStripSeparator3.Size = new System.Drawing.Size(250, 6); // // lastUsedToolStripMenuItem // @@ -369,7 +368,7 @@ private void InitializeComponent() // // viewNavigateToolStripMenuItem // - viewNavigateToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { goToLineToolStripMenuItem, searchToolStripMenuItem, filterToolStripMenuItem, bookmarksToolStripMenuItem, columnFinderToolStripMenuItem, menuToolStripSeparatorExtension5, toolStripEncodingMenuItem, menuToolStripSeparatorExtension6, timeshiftToolStripMenuItem, timeshiftMenuTextBox, menuToolStripSeparatorExtension4, copyMarkedLinesIntoNewTabToolStripMenuItem }); + viewNavigateToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { goToLineToolStripMenuItem, searchToolStripMenuItem, filterToolStripMenuItem, bookmarksToolStripMenuItem, columnFinderToolStripMenuItem, ToolStripSeparator5, toolStripEncodingMenuItem, ToolStripSeparator6, timeshiftToolStripMenuItem, timeshiftMenuTextBox, ToolStripSeparator4, copyMarkedLinesIntoNewTabToolStripMenuItem }); viewNavigateToolStripMenuItem.Name = "viewNavigateToolStripMenuItem"; viewNavigateToolStripMenuItem.Size = new System.Drawing.Size(96, 19); viewNavigateToolStripMenuItem.Text = "View/Navigate"; @@ -458,10 +457,10 @@ private void InitializeComponent() columnFinderToolStripMenuItem.Text = "Column finder"; columnFinderToolStripMenuItem.Click += OnColumnFinderToolStripMenuItemClick; // - // menuToolStripSeparatorExtension5 + // ToolStripSeparator5 // - menuToolStripSeparatorExtension5.Name = "menuToolStripSeparatorExtension5"; - menuToolStripSeparatorExtension5.Size = new System.Drawing.Size(186, 6); + ToolStripSeparator5.Name = "ToolStripSeparator5"; + ToolStripSeparator5.Size = new System.Drawing.Size(186, 6); // // toolStripEncodingMenuItem // @@ -517,10 +516,10 @@ private void InitializeComponent() toolStripEncodingUTF16Item.Text = "Unicode"; toolStripEncodingUTF16Item.Click += OnUTF16ToolStripMenuItemClick; // - // menuToolStripSeparatorExtension6 + // ToolStripSeparator6 // - menuToolStripSeparatorExtension6.Name = "menuToolStripSeparatorExtension6"; - menuToolStripSeparatorExtension6.Size = new System.Drawing.Size(186, 6); + ToolStripSeparator6.Name = "ToolStripSeparator6"; + ToolStripSeparator6.Size = new System.Drawing.Size(186, 6); // // timeshiftToolStripMenuItem // @@ -542,10 +541,10 @@ private void InitializeComponent() timeshiftMenuTextBox.ToolTipText = "Time offset (hh:mm:ss.fff)"; timeshiftMenuTextBox.KeyDown += OnTimeShiftMenuTextBoxKeyDown; // - // menuToolStripSeparatorExtension4 + // ToolStripSeparator4 // - menuToolStripSeparatorExtension4.Name = "menuToolStripSeparatorExtension4"; - menuToolStripSeparatorExtension4.Size = new System.Drawing.Size(186, 6); + ToolStripSeparator4.Name = "ToolStripSeparator4"; + ToolStripSeparator4.Size = new System.Drawing.Size(186, 6); // // copyMarkedLinesIntoNewTabToolStripMenuItem // @@ -558,7 +557,7 @@ private void InitializeComponent() // // optionToolStripMenuItem // - optionToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { columnizerToolStripMenuItem, hilightingToolStripMenuItem1, menuToolStripSeparatorExtension7, settingsToolStripMenuItem, menuToolStripSeparatorExtension9, cellSelectModeToolStripMenuItem, alwaysOnTopToolStripMenuItem, hideLineColumnToolStripMenuItem, menuToolStripSeparatorExtension8, lockInstanceToolStripMenuItem }); + optionToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { columnizerToolStripMenuItem, hilightingToolStripMenuItem1, ToolStripSeparator7, settingsToolStripMenuItem, ToolStripSeparator9, cellSelectModeToolStripMenuItem, alwaysOnTopToolStripMenuItem, hideLineColumnToolStripMenuItem, ToolStripSeparator8, lockInstanceToolStripMenuItem }); optionToolStripMenuItem.Name = "optionToolStripMenuItem"; optionToolStripMenuItem.Size = new System.Drawing.Size(61, 19); optionToolStripMenuItem.Text = "Options"; @@ -579,10 +578,10 @@ private void InitializeComponent() hilightingToolStripMenuItem1.Text = "Highlighting and triggers..."; hilightingToolStripMenuItem1.Click += OnHighlightingToolStripMenuItemClick; // - // menuToolStripSeparatorExtension7 + // ToolStripSeparator7 // - menuToolStripSeparatorExtension7.Name = "menuToolStripSeparatorExtension7"; - menuToolStripSeparatorExtension7.Size = new System.Drawing.Size(221, 6); + ToolStripSeparator7.Name = "ToolStripSeparator7"; + ToolStripSeparator7.Size = new System.Drawing.Size(221, 6); // // settingsToolStripMenuItem // @@ -592,10 +591,10 @@ private void InitializeComponent() settingsToolStripMenuItem.Text = "Settings..."; settingsToolStripMenuItem.Click += OnSettingsToolStripMenuItemClick; // - // menuToolStripSeparatorExtension9 + // ToolStripSeparator9 // - menuToolStripSeparatorExtension9.Name = "menuToolStripSeparatorExtension9"; - menuToolStripSeparatorExtension9.Size = new System.Drawing.Size(221, 6); + ToolStripSeparator9.Name = "ToolStripSeparator9"; + ToolStripSeparator9.Size = new System.Drawing.Size(221, 6); // // cellSelectModeToolStripMenuItem // @@ -622,10 +621,10 @@ private void InitializeComponent() hideLineColumnToolStripMenuItem.Text = "Hide line column"; hideLineColumnToolStripMenuItem.Click += OnHideLineColumnToolStripMenuItemClick; // - // menuToolStripSeparatorExtension8 + // ToolStripSeparator8 // - menuToolStripSeparatorExtension8.Name = "menuToolStripSeparatorExtension8"; - menuToolStripSeparatorExtension8.Size = new System.Drawing.Size(221, 6); + ToolStripSeparator8.Name = "ToolStripSeparator8"; + ToolStripSeparator8.Size = new System.Drawing.Size(221, 6); // // lockInstanceToolStripMenuItem // @@ -658,7 +657,7 @@ private void InitializeComponent() // // helpToolStripMenuItem // - helpToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { showHelpToolStripMenuItem, menuToolStripSeparatorExtension11, aboutToolStripMenuItem }); + helpToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { showHelpToolStripMenuItem, ToolStripSeparator11, aboutToolStripMenuItem }); helpToolStripMenuItem.Name = "helpToolStripMenuItem"; helpToolStripMenuItem.Size = new System.Drawing.Size(44, 19); helpToolStripMenuItem.Text = "Help"; @@ -671,10 +670,10 @@ private void InitializeComponent() showHelpToolStripMenuItem.Text = "Show help"; showHelpToolStripMenuItem.Click += OnShowHelpToolStripMenuItemClick; // - // menuToolStripSeparatorExtension11 + // ToolStripSeparator11 // - menuToolStripSeparatorExtension11.Name = "menuToolStripSeparatorExtension11"; - menuToolStripSeparatorExtension11.Size = new System.Drawing.Size(145, 6); + ToolStripSeparator11.Name = "ToolStripSeparator11"; + ToolStripSeparator11.Size = new System.Drawing.Size(145, 6); // // aboutToolStripMenuItem // @@ -1273,22 +1272,22 @@ private void InitializeComponent() private ToolStripMenuItem columnFinderToolStripMenuItem; private DockPanel dockPanel; private ToolStripMenuItem tabRenameToolStripMenuItem; - private LineToolStripSeparatorExtension lineToolStripSeparatorExtension1; - private LineToolStripSeparatorExtension lineToolStripSeparatorExtension2; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension1; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension2; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension3; - private LineToolStripSeparatorExtension lineToolStripSeparatorExtension3; - private LineToolStripSeparatorExtension lineToolStripSeparatorExtension4; - private LineToolStripSeparatorExtension lineToolStripSeparatorExtension5; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension5; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension6; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension4; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension7; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension9; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension8; - private MenuToolStripSeparatorExtension configureToolStripSeparator; - private MenuToolStripSeparatorExtension menuToolStripSeparatorExtension11; + private ToolStripSeparator lineToolStripSeparatorExtension1; + private ToolStripSeparator lineToolStripSeparatorExtension2; + private ToolStripSeparator ToolStripSeparator1; + private ToolStripSeparator ToolStripSeparator2; + private ToolStripSeparator ToolStripSeparator3; + private ToolStripSeparator lineToolStripSeparatorExtension3; + private ToolStripSeparator lineToolStripSeparatorExtension4; + private ToolStripSeparator lineToolStripSeparatorExtension5; + private ToolStripSeparator ToolStripSeparator5; + private ToolStripSeparator ToolStripSeparator6; + private ToolStripSeparator ToolStripSeparator4; + private ToolStripSeparator ToolStripSeparator7; + private ToolStripSeparator ToolStripSeparator9; + private ToolStripSeparator ToolStripSeparator8; + private ToolStripSeparator configureToolStripSeparator; + private ToolStripSeparator ToolStripSeparator11; } } diff --git a/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs b/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs deleted file mode 100644 index 134f8843..00000000 --- a/src/LogExpert.UI/Extensions/Forms/LineToolStripSeparatorExtension.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Runtime.Versioning; - -namespace LogExpert.UI.Extensions.Forms; - -[SupportedOSPlatform("windows")] -internal class LineToolStripSeparatorExtension : ToolStripSeparator -{ - public LineToolStripSeparatorExtension () - { - Paint += OnExtendedToolStripSeparatorPaint; - } - - private void OnExtendedToolStripSeparatorPaint (object sender, PaintEventArgs e) - { - // Get the separator's width and height. - var toolStripSeparator = (ToolStripSeparator)sender; - var width = toolStripSeparator.Width; - var height = toolStripSeparator.Height; - - // Choose the colors for drawing. - // I've used Color.White as the foreColor. - //TODO change to white if the background color is darker; - Color foreColor = Color.FromKnownColor(KnownColor.Black); - // Color.Teal as the backColor. - Color backColor = ColorMode.BackgroundColor; - - // Fill the background. - using SolidBrush backbrush = new(backColor); - e.Graphics.FillRectangle(backbrush, 0, 0, width, height); - - // Draw the line. - using Pen pen = new(foreColor); - e.Graphics.DrawLine(pen, width / 2, 4, width / 2, height - 4); - } -} diff --git a/src/LogExpert.UI/Extensions/Forms/MenuSelectedColors.cs b/src/LogExpert.UI/Extensions/Forms/MenuSelectedColors.cs deleted file mode 100644 index bc3544e5..00000000 --- a/src/LogExpert.UI/Extensions/Forms/MenuSelectedColors.cs +++ /dev/null @@ -1,31 +0,0 @@ -using LogExpert.Core.Config; - -using System.Runtime.Versioning; - -namespace LogExpert.UI.Extensions.Forms; - -[SupportedOSPlatform("windows")] -internal class MenuSelectedColors : ProfessionalColorTable -{ - public override Color ImageMarginGradientBegin => ColorMode.MenuBackgroundColor; - - public override Color ImageMarginGradientMiddle => ColorMode.MenuBackgroundColor; - - public override Color ImageMarginGradientEnd => ColorMode.MenuBackgroundColor; - - public override Color ToolStripDropDownBackground => ColorMode.MenuBackgroundColor; - - public override Color MenuBorder => ColorMode.MenuBackgroundColor; - - public override Color MenuItemBorder => ColorMode.MenuBackgroundColor; - - public override Color MenuItemSelected => ColorMode.HoverMenuBackgroundColor; - - public override Color MenuItemSelectedGradientBegin => ColorMode.HoverMenuBackgroundColor; - - public override Color MenuItemSelectedGradientEnd => ColorMode.HoverMenuBackgroundColor; - - public override Color MenuItemPressedGradientBegin => ColorMode.MenuBackgroundColor; - - public override Color MenuItemPressedGradientEnd => ColorMode.MenuBackgroundColor; -} \ No newline at end of file diff --git a/src/LogExpert.UI/Extensions/Forms/MenuStripExtension.cs b/src/LogExpert.UI/Extensions/Forms/MenuStripExtension.cs deleted file mode 100644 index e54a1796..00000000 --- a/src/LogExpert.UI/Extensions/Forms/MenuStripExtension.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Runtime.Versioning; - -namespace LogExpert.UI.Extensions.Forms; - -[SupportedOSPlatform("windows")] -internal class ExtendedMenuStripRenderer : ToolStripProfessionalRenderer -{ - public ExtendedMenuStripRenderer() : base(new MenuSelectedColors()) { } -} diff --git a/src/LogExpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs b/src/LogExpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs deleted file mode 100644 index 3f5f26f1..00000000 --- a/src/LogExpert.UI/Extensions/Forms/MenuToolStripSeparatorExtension.cs +++ /dev/null @@ -1,39 +0,0 @@ -using LogExpert.Core.Config; - -using System.Runtime.Versioning; - -namespace LogExpert.UI.Extensions.Forms; - -[SupportedOSPlatform("windows")] -internal class MenuToolStripSeparatorExtension : ToolStripSeparator -{ - public MenuToolStripSeparatorExtension() - { - Paint += OnExtendedToolStripSeparatorPaint; - } - - private void OnExtendedToolStripSeparatorPaint(object? sender, PaintEventArgs e) - { - if (sender == null) - { - return; - } - - // Get the separator's width and height. - var toolStripSeparator = sender as ToolStripSeparator; - var width = toolStripSeparator.Width; - var height = toolStripSeparator.Height; - - // Choose the colors for drawing. - // I've used Color.White as the foreColor. - Color foreColor = ColorMode.ForeColor; - // Color.Teal as the backColor. - Color backColor = ColorMode.MenuBackgroundColor; - - // Fill the background. - e.Graphics.FillRectangle(new SolidBrush(backColor), 0, 0, width, height); - - // Draw the line. - e.Graphics.DrawLine(new Pen(foreColor), 4, height / 2, width - 4, height / 2); - } -} diff --git a/src/LogExpert.UI/Extensions/Forms/ToolStripRendererExtension.cs b/src/LogExpert.UI/Extensions/Forms/ToolStripRendererExtension.cs deleted file mode 100644 index 191d5988..00000000 --- a/src/LogExpert.UI/Extensions/Forms/ToolStripRendererExtension.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Runtime.Versioning; - -namespace LogExpert.UI.Extensions.Forms; - -[SupportedOSPlatform("windows")] -internal class ToolStripRendererExtension : ToolStripSystemRenderer -{ - public ToolStripRendererExtension() { } - - protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) - { - // Commented on purpose to avoid drawing the border that appears visible in Dark Mode (not visible in Bright mode) - //base.OnRenderToolStripBorder(e); - } -} From a00f7ef4a7b7fa04f603d484e00330e33b3967b6 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Mon, 16 Jun 2025 09:15:10 +0200 Subject: [PATCH 089/142] completed removing dark mode --- src/LogExpert.UI/Dialogs/BookmarkWindow.cs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs index 2c5096e1..54e0f11e 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs @@ -72,14 +72,17 @@ public void SetColumnizer (ILogLineColumnizer columnizer) bookmarkDataGridView.Columns[0].Width = 20; } - DataGridViewTextBoxColumn commentColumn = new(); - commentColumn.HeaderText = "Bookmark Comment"; - commentColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; - commentColumn.Resizable = DataGridViewTriState.NotSet; - commentColumn.DividerWidth = 1; - commentColumn.ReadOnly = true; - commentColumn.Width = 250; - commentColumn.MinimumWidth = 130; + DataGridViewTextBoxColumn commentColumn = new() + { + HeaderText = "Bookmark Comment", + AutoSizeMode = DataGridViewAutoSizeColumnMode.None, + Resizable = DataGridViewTriState.NotSet, + DividerWidth = 1, + ReadOnly = true, + Width = 250, + MinimumWidth = 130 + }; + bookmarkDataGridView.Columns.Insert(1, commentColumn); ShowCommentColumn(commentColumnCheckBox.Checked); ResizeColumns(); @@ -111,6 +114,7 @@ public void UpdateView () public void BookmarkTextChanged (Bookmark bookmark) { var rowIndex = bookmarkDataGridView.CurrentCellAddress.Y; + if (rowIndex == -1) { return; @@ -201,7 +205,7 @@ protected override void OnPaint (PaintEventArgs e) if (!splitContainer1.Visible) { var r = ClientRectangle; - e.Graphics.FillRectangle(SystemBrushes.FromSystemColor(ColorMode.BookmarksDefaultBackgroundColor), r); + e.Graphics.FillRectangle(SystemBrushes.ControlLight, r); StringFormat sf = new() { From f768551c2abe5780a62c1db0236fb37d0264ea3c Mon Sep 17 00:00:00 2001 From: Hirogen Date: Mon, 16 Jun 2025 10:16:18 +0200 Subject: [PATCH 090/142] optimizations --- src/LogExpert.Core/Config/ColorEntry.cs | 16 +- .../Controls/BufferedDataGridView.cs | 36 ++--- src/LogExpert.UI/Controls/ColorComboBox.cs | 42 ++--- .../Controls/LogWindow/LogWindow.cs | 2 +- .../LogWindow/LogWindowEventHandlers.cs | 53 +++--- .../Controls/LogWindow/LogWindowPrivate.cs | 152 +++++++++--------- .../Controls/LogWindow/LogWindowPublic.cs | 2 +- .../LogWindow/PatternWindow.Designer.cs | 22 +-- .../Controls/LogWindow/PatternWindow.cs | 97 +++++------ .../LogWindow/TimeSpreadigControl.Designer.cs | 12 +- .../Controls/LogWindow/TimeSpreadigControl.cs | 46 +++--- .../Dialogs/BookmarkWindow.Designer.cs | 32 ++-- src/LogExpert.UI/Dialogs/BookmarkWindow.cs | 34 ++-- .../LogTabWindow/LogTabWindowPrivate.cs | 78 +++++---- src/LogExpert.UI/Entities/PaintHelper.cs | 1 - 15 files changed, 306 insertions(+), 319 deletions(-) diff --git a/src/LogExpert.Core/Config/ColorEntry.cs b/src/LogExpert.Core/Config/ColorEntry.cs index ceeaf244..521f2ae7 100644 --- a/src/LogExpert.Core/Config/ColorEntry.cs +++ b/src/LogExpert.Core/Config/ColorEntry.cs @@ -7,21 +7,11 @@ namespace LogExpert.Core.Config; [Serializable] -public class ColorEntry +public class ColorEntry (string fileName, Color color) { - #region cTor + public Color Color { get; } = color; - public ColorEntry(string fileName, Color color) - { - FileName = fileName; - Color = color; - } - - #endregion - - public Color Color { get; } - - public string FileName { get; } + public string FileName { get; } = fileName; #region Fields diff --git a/src/LogExpert.UI/Controls/BufferedDataGridView.cs b/src/LogExpert.UI/Controls/BufferedDataGridView.cs index cc249ece..41f6da11 100644 --- a/src/LogExpert.UI/Controls/BufferedDataGridView.cs +++ b/src/LogExpert.UI/Controls/BufferedDataGridView.cs @@ -17,13 +17,13 @@ internal partial class BufferedDataGridView : DataGridView private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); private readonly Brush _brush; - private readonly Color _bubbleColor = Color.FromArgb(160, 250, 250, 0); + private readonly Color _bubbleColor = Color.FromArgb(160, 250, 250, 0); //yellow private readonly Font _font = new("Arial", 10); private readonly SortedList _overlayList = []; private readonly Pen _pen; - private readonly Brush _textBrush = new SolidBrush(Color.FromArgb(200, 0, 0, 90)); + private readonly Brush _textBrush = new SolidBrush(Color.FromArgb(200, 0, 0, 90)); //dark blue private BookmarkOverlay _draggedOverlay; private Point _dragStartPoint; @@ -46,15 +46,9 @@ public BufferedDataGridView () #endregion - #region Delegates - - public delegate void OverlayDoubleClickedEventHandler (object sender, OverlayEventArgs e); - - #endregion - #region Events - public event OverlayDoubleClickedEventHandler OverlayDoubleClicked; + public event EventHandler OverlayDoubleClicked; #endregion @@ -112,15 +106,15 @@ protected override void OnEditingControlShowing (DataGridViewEditingControlShowi e.Control.KeyDown -= OnControlKeyDown; e.Control.KeyDown += OnControlKeyDown; var editControl = (DataGridViewTextBoxEditingControl)e.Control; - e.Control.PreviewKeyDown -= Control_PreviewKeyDown; - e.Control.PreviewKeyDown += Control_PreviewKeyDown; + e.Control.PreviewKeyDown -= OnControlPreviewKeyDown; + e.Control.PreviewKeyDown += OnControlPreviewKeyDown; editControl.ContextMenuStrip = EditModeMenuStrip; } protected override void OnMouseDown (MouseEventArgs e) { - BookmarkOverlay overlay = GetOverlayForPosition(e.Location); + var overlay = GetOverlayForPosition(e.Location); if (overlay != null) { if (e.Button == MouseButtons.Right) @@ -171,7 +165,7 @@ protected override void OnMouseMove (MouseEventArgs e) } else { - BookmarkOverlay overlay = GetOverlayForPosition(e.Location); + var overlay = GetOverlayForPosition(e.Location); Cursor = overlay != null ? Cursors.Hand : Cursors.Default; base.OnMouseMove(e); } @@ -179,7 +173,7 @@ protected override void OnMouseMove (MouseEventArgs e) protected override void OnMouseDoubleClick (MouseEventArgs e) { - BookmarkOverlay overlay = GetOverlayForPosition(e.Location); + var overlay = GetOverlayForPosition(e.Location); if (overlay != null) { if (e.Button == MouseButtons.Left) @@ -201,7 +195,7 @@ private BookmarkOverlay GetOverlayForPosition (Point pos) { lock (_overlayList) { - foreach (BookmarkOverlay overlay in _overlayList.Values) + foreach (var overlay in _overlayList.Values) { if (overlay.BubbleRect.Contains(pos)) { @@ -215,9 +209,9 @@ private BookmarkOverlay GetOverlayForPosition (Point pos) private void PaintOverlays (PaintEventArgs e) { - BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current; + var currentContext = BufferedGraphicsManager.Current; - using BufferedGraphics myBuffer = currentContext.Allocate(CreateGraphics(), ClientRectangle); + using var myBuffer = currentContext.Allocate(CreateGraphics(), ClientRectangle); lock (_overlayList) { _overlayList.Clear(); @@ -246,9 +240,9 @@ private void PaintOverlays (PaintEventArgs e) lock (_overlayList) { - foreach (BookmarkOverlay overlay in _overlayList.Values) + foreach (var overlay in _overlayList.Values) { - SizeF textSize = myBuffer.Graphics.MeasureString(overlay.Bookmark.Text, _font, 300); + var textSize = myBuffer.Graphics.MeasureString(overlay.Bookmark.Text, _font, 300); Rectangle rectBubble = new(overlay.Position, new Size((int)textSize.Width, (int)textSize.Height)); rectBubble.Offset(60, -(rectBubble.Height + 40)); rectBubble.Inflate(3, 3); @@ -277,7 +271,7 @@ private void PaintOverlays (PaintEventArgs e) #region Events handler - private void Control_PreviewKeyDown (object sender, PreviewKeyDownEventArgs e) + private void OnControlPreviewKeyDown (object sender, PreviewKeyDownEventArgs e) { if ((e.KeyCode == Keys.C || e.KeyCode == Keys.Insert) && e.Control) { @@ -290,7 +284,7 @@ private void Control_PreviewKeyDown (object sender, PreviewKeyDownEventArgs e) private void OnControlKeyDown (object sender, KeyEventArgs e) { - if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down) + if (e.KeyCode is Keys.Up or Keys.Down) { if (EditingControl != null) { diff --git a/src/LogExpert.UI/Controls/ColorComboBox.cs b/src/LogExpert.UI/Controls/ColorComboBox.cs index 71feb634..40ea6d4d 100644 --- a/src/LogExpert.UI/Controls/ColorComboBox.cs +++ b/src/LogExpert.UI/Controls/ColorComboBox.cs @@ -1,4 +1,4 @@ -using System.Drawing.Drawing2D; +using System.Drawing.Drawing2D; using System.Runtime.Versioning; namespace LogExpert.UI.Controls; @@ -14,31 +14,31 @@ internal class ColorComboBox : ComboBox #region cTor - public ColorComboBox() + public ColorComboBox () { DrawMode = DrawMode.OwnerDrawFixed; DrawItem += OnColorComboBoxDrawItem; // add color presets if (!DesignMode) { - Items.Add(_customColor); - Items.Add(Color.Black); - Items.Add(Color.White); - Items.Add(Color.Gray); - Items.Add(Color.DarkGray); - Items.Add(Color.Blue); - Items.Add(Color.LightBlue); - Items.Add(Color.DarkBlue); - Items.Add(Color.Green); - Items.Add(Color.LightGreen); - Items.Add(Color.DarkGreen); - Items.Add(Color.Olive); - Items.Add(Color.Red); - Items.Add(Color.Pink); - Items.Add(Color.Purple); - Items.Add(Color.IndianRed); - Items.Add(Color.DarkCyan); - Items.Add(Color.Yellow); + _ = Items.Add(_customColor); + _ = Items.Add(Color.Black); + _ = Items.Add(Color.White); + _ = Items.Add(Color.Gray); + _ = Items.Add(Color.DarkGray); + _ = Items.Add(Color.Blue); + _ = Items.Add(Color.LightBlue); + _ = Items.Add(Color.DarkBlue); + _ = Items.Add(Color.Green); + _ = Items.Add(Color.LightGreen); + _ = Items.Add(Color.DarkGreen); + _ = Items.Add(Color.Olive); + _ = Items.Add(Color.Red); + _ = Items.Add(Color.Pink); + _ = Items.Add(Color.Purple); + _ = Items.Add(Color.IndianRed); + _ = Items.Add(Color.DarkCyan); + _ = Items.Add(Color.Yellow); } } @@ -63,7 +63,7 @@ public Color CustomColor #region Events handler - private void OnColorComboBoxDrawItem(object sender, DrawItemEventArgs e) + private void OnColorComboBoxDrawItem (object sender, DrawItemEventArgs e) { e.DrawBackground(); if (e.Index >= 0) diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index f755c20e..eb2c9b96 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -160,7 +160,7 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp ForcePersistenceLoading = forcePersistenceLoading; dataGridView.CellValueNeeded += OnDataGridViewCellValueNeeded; - dataGridView.CellPainting += OnDataGridView_CellPainting; + dataGridView.CellPainting += OnDataGridViewCellPainting; filterGridView.CellValueNeeded += OnFilterGridViewCellValueNeeded; filterGridView.CellPainting += OnFilterGridViewCellPainting; diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs index 2b8e367a..245a18e7 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs @@ -276,11 +276,11 @@ private void OnDataGridViewCellValuePushed (object sender, DataGridViewCellValue return; } - ILogLine line = _logFileReader.GetLogLine(e.RowIndex); + var line = _logFileReader.GetLogLine(e.RowIndex); var offset = CurrentColumnizer.GetTimeOffset(); CurrentColumnizer.SetTimeOffset(0); ColumnizerCallbackObject.SetLineNum(e.RowIndex); - IColumnizedLogLine cols = CurrentColumnizer.SplitLine(ColumnizerCallbackObject, line); + var cols = CurrentColumnizer.SplitLine(ColumnizerCallbackObject, line); CurrentColumnizer.SetTimeOffset(offset); if (cols.ColumnValues.Length <= e.ColumnIndex - 2) { @@ -392,11 +392,11 @@ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPainti } var lineNum = _filterResultList[e.RowIndex]; - ILogLine line = _logFileReader.GetLogLineWithWait(lineNum).Result; + var line = _logFileReader.GetLogLineWithWait(lineNum).Result; if (line != null) { - HighlightEntry entry = FindFirstNoWordMatchHilightEntry(line); + var entry = FindFirstNoWordMatchHilightEntry(line); e.Graphics.SetClip(e.CellBounds); if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) { @@ -407,8 +407,7 @@ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPainti } else { - var color = Color.FromArgb(255, 170, 170, 170); - brush = new SolidBrush(color); + brush = new SolidBrush(Color.FromArgb(255, 170, 170, 170)); //gray } e.Graphics.FillRectangle(brush, e.CellBounds); @@ -416,7 +415,7 @@ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPainti } else { - Color bgColor = Color.White; + var bgColor = Color.White; // paint direct filter hits with different bg color //if (this.filterParams.SpreadEnabled && this.filterHitList.Contains(lineNum)) //{ @@ -461,7 +460,7 @@ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPainti e.Graphics.FillRectangle(brush, r); brush.Dispose(); - Bookmark bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); + var bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); if (bookmark.Text.Length > 0) { @@ -845,8 +844,8 @@ private void OnDataGridContextMenuStripOpening (object sender, CancelEventArgs e var isAdded = false; if (PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins.Count > 0) { - IList lines = GetSelectedContent(); - foreach (IContextMenuEntry entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins) + var lines = GetSelectedContent(); + foreach (var entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins) { LogExpertCallback callback = new(this); var menuText = entry.GetMenuText(lines.Count, CurrentColumnizer, callback.GetLogLine(lines[0])); @@ -859,7 +858,7 @@ private void OnDataGridContextMenuStripOpening (object sender, CancelEventArgs e menuText = menuText[1..]; } - ToolStripItem item = dataGridContextMenuStrip.Items.Add(menuText, null, OnHandlePluginContextMenu); + var item = dataGridContextMenuStrip.Items.Add(menuText, null, OnHandlePluginContextMenu); item.Tag = new ContextMenuPluginEventArgs(entry, lines, CurrentColumnizer, callback); item.Enabled = !disabled; isAdded = true; @@ -876,13 +875,13 @@ private void OnDataGridContextMenuStripOpening (object sender, CancelEventArgs e if (CurrentColumnizer.IsTimeshiftImplemented()) { - IList list = _parentLogTabWin.GetListOfOpenFiles(); + var list = _parentLogTabWin.GetListOfOpenFiles(); syncTimestampsToToolStripMenuItem.Enabled = true; syncTimestampsToToolStripMenuItem.DropDownItems.Clear(); EventHandler ev = OnHandleSyncContextMenu; Font italicFont = new(syncTimestampsToToolStripMenuItem.Font.FontFamily, syncTimestampsToToolStripMenuItem.Font.Size, FontStyle.Italic); - foreach (WindowFileEntry fileEntry in list) + foreach (var fileEntry in list) { if (fileEntry.LogWindow != this) { @@ -914,7 +913,7 @@ private void OnHandlePluginContextMenu (object sender, EventArgs args) if (sender is ToolStripItem item) { var menuArgs = item.Tag as ContextMenuPluginEventArgs; - IList logLines = menuArgs.LogLines; + var logLines = menuArgs.LogLines; menuArgs.Entry.MenuSelected(logLines.Count, menuArgs.Columnizer, menuArgs.Callback.GetLogLine(logLines[0])); } } @@ -958,7 +957,7 @@ private void OnScrollAllTabsToTimestampToolStripMenuItemClick (object sender, Ev if (currentLine > 0 && currentLine < dataGridView.RowCount) { var lineNum = currentLine; - DateTime timeStamp = GetTimestampForLine(ref lineNum, false); + var timeStamp = GetTimestampForLine(ref lineNum, false); if (timeStamp.Equals(DateTime.MinValue)) // means: invalid { return; @@ -1083,7 +1082,7 @@ private void OnFilterGridViewCellContextMenuStripNeeded (object sender, DataGrid [SupportedOSPlatform("windows")] private void OnColumnContextMenuStripOpening (object sender, CancelEventArgs e) { - Control ctl = columnContextMenuStrip.SourceControl; + var ctl = columnContextMenuStrip.SourceControl; var gridView = ctl as BufferedDataGridView; var frozen = false; if (_freezeStateMap.TryGetValue(ctl, out var value)) @@ -1106,26 +1105,26 @@ private void OnColumnContextMenuStripOpening (object sender, CancelEventArgs e) } - DataGridViewColumn col = gridView.Columns[_selectedCol]; + var col = gridView.Columns[_selectedCol]; moveLeftToolStripMenuItem.Enabled = col != null && col.DisplayIndex > 0; moveRightToolStripMenuItem.Enabled = col != null && col.DisplayIndex < gridView.Columns.Count - 1; if (gridView.Columns.Count - 1 > _selectedCol) { // DataGridViewColumn colRight = gridView.Columns[this.selectedCol + 1]; - DataGridViewColumn colRight = gridView.Columns.GetNextColumn(col, DataGridViewElementStates.None, DataGridViewElementStates.None); + var colRight = gridView.Columns.GetNextColumn(col, DataGridViewElementStates.None, DataGridViewElementStates.None); moveRightToolStripMenuItem.Enabled = colRight != null && colRight.Frozen == col.Frozen; } if (_selectedCol > 0) { //DataGridViewColumn colLeft = gridView.Columns[this.selectedCol - 1]; - DataGridViewColumn colLeft = gridView.Columns.GetPreviousColumn(col, DataGridViewElementStates.None, DataGridViewElementStates.None); + var colLeft = gridView.Columns.GetPreviousColumn(col, DataGridViewElementStates.None, DataGridViewElementStates.None); moveLeftToolStripMenuItem.Enabled = colLeft != null && colLeft.Frozen == col.Frozen; } - DataGridViewColumn colLast = gridView.Columns[gridView.Columns.Count - 1]; + var colLast = gridView.Columns[gridView.Columns.Count - 1]; moveToLastColumnToolStripMenuItem.Enabled = colLast != null && colLast.Frozen == col.Frozen; // Fill context menu with column names @@ -1157,7 +1156,7 @@ private void OnHandleColumnItemContextMenu (object sender, EventArgs args) [SupportedOSPlatform("windows")] private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick (object sender, EventArgs e) { - Control ctl = columnContextMenuStrip.SourceControl; + var ctl = columnContextMenuStrip.SourceControl; var frozen = false; if (_freezeStateMap.TryGetValue(ctl, out var value)) @@ -1178,7 +1177,7 @@ private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick (object sender, private void OnMoveToLastColumnToolStripMenuItemClick (object sender, EventArgs e) { var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - DataGridViewColumn col = gridView.Columns[_selectedCol]; + var col = gridView.Columns[_selectedCol]; if (col != null) { col.DisplayIndex = gridView.Columns.Count - 1; @@ -1189,7 +1188,7 @@ private void OnMoveToLastColumnToolStripMenuItemClick (object sender, EventArgs private void OnMoveLeftToolStripMenuItemClick (object sender, EventArgs e) { var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - DataGridViewColumn col = gridView.Columns[_selectedCol]; + var col = gridView.Columns[_selectedCol]; if (col != null && col.DisplayIndex > 0) { col.DisplayIndex -= 1; @@ -1200,7 +1199,7 @@ private void OnMoveLeftToolStripMenuItemClick (object sender, EventArgs e) private void OnMoveRightToolStripMenuItemClick (object sender, EventArgs e) { var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - DataGridViewColumn col = gridView.Columns[_selectedCol]; + var col = gridView.Columns[_selectedCol]; if (col != null && col.DisplayIndex < gridView.Columns.Count - 1) { col.DisplayIndex = col.DisplayIndex + 1; @@ -1211,7 +1210,7 @@ private void OnMoveRightToolStripMenuItemClick (object sender, EventArgs e) private void OnHideColumnToolStripMenuItemClick (object sender, EventArgs e) { var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - DataGridViewColumn col = gridView.Columns[_selectedCol]; + var col = gridView.Columns[_selectedCol]; col.Visible = false; } @@ -1415,7 +1414,7 @@ private void OnToggleHighlightPanelButtonClick (object sender, EventArgs e) private void OnSaveFilterButtonClick (object sender, EventArgs e) { - FilterParams newParams = _filterParams.Clone(); + var newParams = _filterParams.Clone(); newParams.Color = Color.FromKnownColor(KnownColor.Black); ConfigManager.Settings.FilterList.Add(newParams); OnFilterListChanged(this); @@ -1478,7 +1477,7 @@ private void OnFilterListBoxMouseDoubleClick (object sender, MouseEventArgs e) if (filterListBox.SelectedIndex >= 0) { var filterParams = (FilterParams)filterListBox.Items[filterListBox.SelectedIndex]; - FilterParams newParams = filterParams.Clone(); + var newParams = filterParams.Clone(); //newParams.historyList = ConfigManager.Settings.filterHistoryList; _filterParams = newParams; ReInitFilterParams(_filterParams); diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs index e484a366..b972f7a3 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs @@ -61,7 +61,7 @@ private void CreateDefaultViewStyle () dataGridViewCellStyleMainGrid.SelectionBackColor = SystemColors.Highlight; dataGridViewCellStyleMainGrid.SelectionForeColor = SystemColors.HighlightText; - Color highlightColor = SystemColors.Highlight; + var highlightColor = SystemColors.Highlight; //Color is smaller than 128, means its darker var isDark = (highlightColor.R * 0.2126) + (highlightColor.G * 0.7152) + (highlightColor.B * 0.0722) < 255 / 2; @@ -113,7 +113,7 @@ private bool LoadPersistenceOptions () try { - PersistenceData persistenceData = ForcedPersistenceFileName == null + var persistenceData = ForcedPersistenceFileName == null ? Persister.LoadPersistenceDataOptionsOnly(FileName, Preferences) : Persister.LoadPersistenceDataOptionsOnlyFromFixedFile(ForcedPersistenceFileName); @@ -210,7 +210,7 @@ private void LoadPersistenceData () try { - PersistenceData persistenceData = ForcedPersistenceFileName == null + var persistenceData = ForcedPersistenceFileName == null ? Persister.LoadPersistenceData(FileName, Preferences) : Persister.LoadPersistenceDataFromFixedFile(ForcedPersistenceFileName); @@ -298,9 +298,9 @@ private void RestoreFilters (PersistenceData persistenceData) private void RestoreFilterTabs (PersistenceData persistenceData) { - foreach (FilterTabData data in persistenceData.FilterTabDataList) + foreach (var data in persistenceData.FilterTabDataList) { - FilterParams persistFilterParams = data.FilterParams; + var persistFilterParams = data.FilterParams; ReInitFilterParams(persistFilterParams); List filterResultList = []; //List lastFilterResultList = new List(); @@ -479,7 +479,7 @@ private void SetGuiAfterLoading () SyncTimestampDisplay(); } - Settings settings = ConfigManager.Settings; + var settings = ConfigManager.Settings; ShowLineColumn(!settings.HideLineColumn); } @@ -489,7 +489,7 @@ private void SetGuiAfterLoading () private ILogLineColumnizer FindColumnizer () { - ILogLineColumnizer columnizer = Preferences.MaskPrio + var columnizer = Preferences.MaskPrio ? _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)) ?? _parentLogTabWin.GetColumnizerHistoryEntry(FileName) : _parentLogTabWin.GetColumnizerHistoryEntry(FileName) ?? _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)); @@ -800,7 +800,7 @@ private void CheckFilterAndHighlight (LogEventArgs e) var filterLineAdded = false; for (var i = filterStart; i < e.LineCount; ++i) { - ILogLine line = _logFileReader.GetLogLine(i); + var line = _logFileReader.GetLogLine(i); if (line == null) { return; @@ -823,7 +823,7 @@ private void CheckFilterAndHighlight (LogEventArgs e) //pipeFx.BeginInvoke(i, null, null); ProcessFilterPipes(i); - IList matchingList = FindMatchingHilightEntries(line); + var matchingList = FindMatchingHilightEntries(line); LaunchHighlightPlugins(matchingList, i); GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, out bookmarkComment); if (setBookmark) @@ -868,10 +868,10 @@ private void CheckFilterAndHighlight (LogEventArgs e) for (var i = startLine; i < e.LineCount; ++i) { - ILogLine line = _logFileReader.GetLogLine(i); + var line = _logFileReader.GetLogLine(i); if (line != null) { - IList matchingList = FindMatchingHilightEntries(line); + var matchingList = FindMatchingHilightEntries(line); LaunchHighlightPlugins(matchingList, i); GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, out bookmarkComment); @@ -913,11 +913,11 @@ private void LaunchHighlightPlugins (IList matchingList, int lin LineNum = lineNum }; - foreach (HighlightEntry entry in matchingList) + foreach (var entry in matchingList) { if (entry.IsActionEntry && entry.ActionEntry.PluginName != null) { - IKeywordAction plugin = PluginRegistry.PluginRegistry.Instance.FindKeywordActionPluginByName(entry.ActionEntry.PluginName); + var plugin = PluginRegistry.PluginRegistry.Instance.FindKeywordActionPluginByName(entry.ActionEntry.PluginName); if (plugin != null) { ActionPluginExecuteFx fx = plugin.Execute; @@ -956,7 +956,7 @@ private void SetColumnizerInternal (ILogLineColumnizer columnizer) { _logger.Info("SetColumnizerInternal(): {0}", columnizer.GetName()); - ILogLineColumnizer oldColumnizer = CurrentColumnizer; + var oldColumnizer = CurrentColumnizer; var oldColumnizerIsXmlType = CurrentColumnizer is ILogLineXmlColumnizer; var oldColumnizerIsPreProcess = CurrentColumnizer is IPreProcessColumnizer; var mustReload = false; @@ -990,8 +990,8 @@ private void SetColumnizerInternal (ILogLineColumnizer columnizer) } } - Type oldColType = _filterParams.CurrentColumnizer?.GetType(); - Type newColType = columnizer?.GetType(); + var oldColType = _filterParams.CurrentColumnizer?.GetType(); + var newColType = columnizer?.GetType(); if (oldColType != newColType && _filterParams.ColumnRestrict && _filterParams.IsFilterTail) { @@ -1076,7 +1076,7 @@ private void SetColumnizerInternal (ILogLineColumnizer columnizer) SyncTimestampDisplay(); } - Settings settings = ConfigManager.Settings; + var settings = ConfigManager.Settings; ShowLineColumn(!settings.HideLineColumn); ShowTimeSpread(Preferences.ShowTimeSpread && columnizer.IsTimeshiftImplemented()); } @@ -1133,7 +1133,7 @@ private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, Buffered column ??= Column.EmptyColumn; - IList matchList = FindHighlightMatches(column); + var matchList = FindHighlightMatches(column); // too many entries per line seem to cause problems with the GDI while (matchList.Count > 50) { @@ -1165,8 +1165,8 @@ private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, Buffered //var leftPad = e.CellStyle.Padding.Left; //RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, e.CellBounds.Height); - Rectangle borderWidths = PaintHelper.BorderWidths(e.AdvancedBorderStyle); - Rectangle valBounds = e.CellBounds; + var borderWidths = PaintHelper.BorderWidths(e.AdvancedBorderStyle); + var valBounds = e.CellBounds; valBounds.Offset(borderWidths.X, borderWidths.Y); valBounds.Width -= borderWidths.Right; valBounds.Height -= borderWidths.Bottom; @@ -1177,7 +1177,7 @@ private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, Buffered valBounds.Height -= e.CellStyle.Padding.Vertical; } - TextFormatFlags flags = + var flags = TextFormatFlags.Left | TextFormatFlags.SingleLine | TextFormatFlags.NoPrefix @@ -1193,26 +1193,26 @@ private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, Buffered //TextRenderer.DrawText(e.Graphics, e.Value as String, e.CellStyle.Font, valBounds, Color.FromKnownColor(KnownColor.Black), flags); - Point wordPos = valBounds.Location; + var wordPos = valBounds.Location; Size proposedSize = new(valBounds.Width, valBounds.Height); - Rectangle r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); + var r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); e.Graphics.SetClip(e.CellBounds); - foreach (HighlightMatchEntry matchEntry in matchList) + foreach (var matchEntry in matchList) { - Font font = matchEntry != null && matchEntry.HighlightEntry.IsBold ? BoldFont : NormalFont; + var font = matchEntry != null && matchEntry.HighlightEntry.IsBold ? BoldFont : NormalFont; Brush bgBrush = matchEntry.HighlightEntry.BackgroundColor != Color.Empty ? new SolidBrush(matchEntry.HighlightEntry.BackgroundColor) : null; var matchWord = column.DisplayValue.Substring(matchEntry.StartPos, matchEntry.Length); - Size wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags); + var wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags); wordSize.Height = e.CellBounds.Height; Rectangle wordRect = new(wordPos, wordSize); - Color foreColor = matchEntry.HighlightEntry.ForegroundColor; + var foreColor = matchEntry.HighlightEntry.ForegroundColor; if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected) { if (!noBackgroundFill && bgBrush != null && !matchEntry.HighlightEntry.NoBackground) @@ -1236,7 +1236,7 @@ private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, Buffered /// /// List of all highlight matches for the current cell /// The entry that is used as the default. - /// List of HilightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring. + /// List of HighlightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring. private IList MergeHighlightMatchEntries (IList matchList, HighlightMatchEntry groundEntry) { // Fill an area with lenth of whole text with a default hilight entry @@ -1248,7 +1248,7 @@ private IList MergeHighlightMatchEntries (IList MergeHighlightMatchEntries (IList 0) { - HighlightEntry currentEntry = entryArray[0]; + var currentEntry = entryArray[0]; var lastStartPos = 0; var pos = 0; @@ -1357,7 +1357,7 @@ private IList FindMatchingHilightEntries (ITextValue line) { lock (_currentHighlightGroupLock) { - foreach (HighlightEntry entry in _currentHighlightGroup.HighlightEntryList) + foreach (var entry in _currentHighlightGroup.HighlightEntryList) { if (CheckHighlightEntryMatch(entry, line)) { @@ -1372,11 +1372,11 @@ private IList FindMatchingHilightEntries (ITextValue line) private void GetHighlightEntryMatches (ITextValue line, IList hilightEntryList, IList resultList) { - foreach (HighlightEntry entry in hilightEntryList) + foreach (var entry in hilightEntryList) { if (entry.IsWordMatch) { - MatchCollection matches = entry.Regex.Matches(line.Text); + var matches = entry.Regex.Matches(line.Text); foreach (Match match in matches) { HighlightMatchEntry me = new() @@ -1411,7 +1411,7 @@ private void GetHilightActions (IList matchingList, out bool noL noLed = stopTail = setBookmark = false; bookmarkComment = string.Empty; - foreach (HighlightEntry entry in matchingList) + foreach (var entry in matchingList) { if (entry.IsLedSwitch) { @@ -1503,7 +1503,7 @@ private void SyncTimestampDisplayWorker () if (lineNum >= 0 && lineNum < dataGridView.RowCount) { var refLine = lineNum; - DateTime timeStamp = GetTimestampForLine(ref refLine, true); + var timeStamp = GetTimestampForLine(ref refLine, true); if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel) { _guiStateArgs.Timestamp = timeStamp; @@ -1511,7 +1511,7 @@ private void SyncTimestampDisplayWorker () if (_shouldCallTimeSync) { refLine = lineNum; - DateTime exactTimeStamp = GetTimestampForLine(ref refLine, false); + var exactTimeStamp = GetTimestampForLine(ref refLine, false); SyncOtherWindows(exactTimeStamp); _shouldCallTimeSync = false; } @@ -1529,9 +1529,9 @@ private void SyncTimestampDisplayWorker () } var refLine = row1; - DateTime timeStamp1 = GetTimestampForLine(ref refLine, false); + var timeStamp1 = GetTimestampForLine(ref refLine, false); refLine = row2; - DateTime timeStamp2 = GetTimestampForLine(ref refLine, false); + var timeStamp2 = GetTimestampForLine(ref refLine, false); //TimeSpan span = TimeSpan.FromTicks(timeStamp2.Ticks - timeStamp1.Ticks); DateTime diff; if (timeStamp1.Ticks > timeStamp2.Ticks) @@ -1645,7 +1645,7 @@ private int Search (SearchParams searchParams) } } - ILogLine line = _logFileReader.GetLogLine(lineNum); + var line = _logFileReader.GetLogLine(lineNum); if (line == null) { return -1; @@ -1808,10 +1808,10 @@ private void SelectPrevHighlightLine () while (lineNum > 0) { lineNum--; - ILogLine line = _logFileReader.GetLogLine(lineNum); + var line = _logFileReader.GetLogLine(lineNum); if (line != null) { - HighlightEntry entry = FindHilightEntry(line); + var entry = FindHilightEntry(line); if (entry != null) { SelectLine(lineNum, false, true); @@ -1828,10 +1828,10 @@ private void SelectNextHighlightLine () while (lineNum < _logFileReader.LineCount) { lineNum++; - ILogLine line = _logFileReader.GetLogLine(lineNum); + var line = _logFileReader.GetLogLine(lineNum); if (line != null) { - HighlightEntry entry = FindHilightEntry(line); + var entry = FindHilightEntry(line); if (entry != null) { SelectLine(lineNum, false, true); @@ -1884,7 +1884,7 @@ private void ShiftBookmarks (int offset) private void ShiftRowHeightList (int offset) { SortedList newList = []; - foreach (RowHeightEntry entry in _rowHeightList.Values) + foreach (var entry in _rowHeightList.Values) { var line = entry.LineNum - offset; if (line >= 0) @@ -1901,7 +1901,7 @@ private void ShiftFilterPipes (int offset) { lock (_filterPipeList) { - foreach (FilterPipe pipe in _filterPipeList) + foreach (var pipe in _filterPipeList) { pipe.ShiftLineNums(offset); } @@ -1913,7 +1913,7 @@ private void LoadFilterPipes () { lock (_filterPipeList) { - foreach (FilterPipe pipe in _filterPipeList) + foreach (var pipe in _filterPipeList) { pipe.RecreateTempFile(); } @@ -1932,7 +1932,7 @@ private void DisconnectFilterPipes () { lock (_filterPipeList) { - foreach (FilterPipe pipe in _filterPipeList) + foreach (var pipe in _filterPipeList) { pipe.ClearLineList(); } @@ -2070,7 +2070,7 @@ private async void FilterSearch (string text) _progressEventArgs.Visible = true; SendProgressBarUpdate(); - Settings settings = ConfigManager.Settings; + var settings = ConfigManager.Settings; //FilterFx fx = settings.preferences.multiThreadFilter ? MultiThreadedFilter : new FilterFx(Filter); FilterFxAction = settings.Preferences.MultiThreadFilter ? MultiThreadedFilter : Filter; @@ -2127,7 +2127,7 @@ private void Filter (FilterParams filterParams, List filterResultLines, Lis ColumnizerCallback callback = new(this); while (true) { - ILogLine line = _logFileReader.GetLogLine(lineNum); + var line = _logFileReader.GetLogLine(lineNum); if (line == null) { break; @@ -2227,7 +2227,7 @@ private void AddFilterLine (int lineNum, bool immediate, FilterParams filterPara lock (_filterResultList) { filterHitList.Add(lineNum); - IList filterResult = GetAdditionalFilterResults(filterParams, lineNum, lastFilterLinesList); + var filterResult = GetAdditionalFilterResults(filterParams, lineNum, lastFilterLinesList); filterResultLines.AddRange(filterResult); count = filterResultLines.Count; lastFilterLinesList.AddRange(filterResult); @@ -2753,7 +2753,7 @@ private void WritePipeToTab (FilterPipe pipe, IList lineNumberList, string break; } - ILogLine line = _logFileReader.GetLogLine(i); + var line = _logFileReader.GetLogLine(i); if (CurrentColumnizer is ILogLineXmlColumnizer) { callback.LineNum = i; @@ -2786,7 +2786,7 @@ private void WriteFilterToTabFinished (FilterPipe pipe, string name, Persistence preProcessColumnizer = CurrentColumnizer; } - LogWindow newWin = _parentLogTabWin.AddFilterTab(pipe, title, preProcessColumnizer); + var newWin = _parentLogTabWin.AddFilterTab(pipe, title, preProcessColumnizer); newWin.FilterPipe = pipe; pipe.OwnLogWindow = newWin; if (persistenceData != null) @@ -2818,7 +2818,7 @@ internal void WritePipeTab (IList lineEntryList, string title) }; pipe.Closed += OnPipeDisconnected; pipe.OpenFile(); - foreach (LineEntry entry in lineEntryList) + foreach (var entry in lineEntryList) { pipe.WriteToPipe(entry.LogLine, entry.LineNum); } @@ -2831,7 +2831,7 @@ internal void WritePipeTab (IList lineEntryList, string title) private void FilterRestore (LogWindow newWin, PersistenceData persistenceData) { newWin.WaitForLoadingFinished(); - ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(persistenceData.ColumnizerName, + var columnizer = ColumnizerPicker.FindColumnizerByName(persistenceData.ColumnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); if (columnizer != null) { @@ -2849,7 +2849,7 @@ private void FilterRestore (LogWindow newWin, PersistenceData persistenceData) [SupportedOSPlatform("windows")] private void ProcessFilterPipes (int lineNum) { - ILogLine searchLine = _logFileReader.GetLogLine(lineNum); + var searchLine = _logFileReader.GetLogLine(lineNum); if (searchLine == null) { return; @@ -2862,7 +2862,7 @@ private void ProcessFilterPipes (int lineNum) IList deleteList = []; lock (_filterPipeList) { - foreach (FilterPipe pipe in _filterPipeList) + foreach (var pipe in _filterPipeList) { if (pipe.IsStopped) { @@ -2872,7 +2872,7 @@ private void ProcessFilterPipes (int lineNum) //long startTime = Environment.TickCount; if (Util.TestFilterCondition(pipe.FilterParams, searchLine, callback)) { - IList filterResult = + var filterResult = GetAdditionalFilterResults(pipe.FilterParams, lineNum, pipe.LastLinesHistoryList); pipe.OpenFile(); foreach (var line in filterResult) @@ -2883,7 +2883,7 @@ private void ProcessFilterPipes (int lineNum) pipe.LastLinesHistoryList.RemoveAt(0); } - ILogLine textLine = _logFileReader.GetLogLine(line); + var textLine = _logFileReader.GetLogLine(line); var fileOk = pipe.WriteToPipe(textLine, line); if (!fileOk) { @@ -2899,7 +2899,7 @@ private void ProcessFilterPipes (int lineNum) } } - foreach (FilterPipe pipe in deleteList) + foreach (var pipe in deleteList) { _filterPipeList.Remove(pipe); } @@ -2910,7 +2910,7 @@ private void CopyMarkedLinesToClipboard () { if (_guiStateArgs.CellSelectMode) { - DataObject data = dataGridView.GetClipboardContent(); + var data = dataGridView.GetClipboardContent(); Clipboard.SetDataObject(data); } else @@ -2932,7 +2932,7 @@ private void CopyMarkedLinesToClipboard () foreach (var lineNum in lineNumList) { - ILogLine line = _logFileReader.GetLogLine(lineNum); + var line = _logFileReader.GetLogLine(lineNum); if (xmlColumnizer != null) { callback.LineNum = lineNum; @@ -3087,7 +3087,7 @@ private void ApplyFrozenState (BufferedDataGridView gridView) dict.Add(col.DisplayIndex, col); } - foreach (DataGridViewColumn col in dict.Values) + foreach (var col in dict.Values) { col.Frozen = _freezeStateMap.ContainsKey(gridView) && _freezeStateMap[gridView]; var sel = col.HeaderCell.Selected; @@ -3238,7 +3238,7 @@ private void AddBlockTargetLinesToDict (Dictionary dict, PatternBlock //Well keep this for the moment because there is some other commented code which calls this one private PatternBlock FindExistingBlock (PatternBlock block, List blockList) { - foreach (PatternBlock searchBlock in blockList) + foreach (var searchBlock in blockList) { if (((block.StartLine > searchBlock.StartLine && block.StartLine < searchBlock.EndLine) || (block.EndLine > searchBlock.StartLine && block.EndLine < searchBlock.EndLine)) && @@ -3431,7 +3431,7 @@ private int FindSimilarLine (int srcLine, int startLine, Dictionary pr Regex regex = null; Regex regex2 = null; string msgToFind = null; - CultureInfo culture = CultureInfo.CurrentCulture; + var culture = CultureInfo.CurrentCulture; var num = _logFileReader.LineCount; for (var i = startLine; i < num; ++i) @@ -3489,10 +3489,10 @@ private int FindSimilarLine (int srcLine, int startLine, Dictionary pr private string GetMsgForLine (int i) { - ILogLine line = _logFileReader.GetLogLine(i); - ILogLineColumnizer columnizer = CurrentColumnizer; + var line = _logFileReader.GetLogLine(i); + var columnizer = CurrentColumnizer; ColumnizerCallback callback = new(this); - IColumnizedLogLine cols = columnizer.SplitLine(callback, line); + var cols = columnizer.SplitLine(callback, line); return cols.ColumnValues.Last().FullValue; } @@ -3507,7 +3507,7 @@ private void ChangeRowHeight (bool decrease) if (decrease) { - if (!_rowHeightList.TryGetValue(rowNum, out RowHeightEntry? entry)) + if (!_rowHeightList.TryGetValue(rowNum, out var entry)) { return; } @@ -3523,7 +3523,7 @@ private void ChangeRowHeight (bool decrease) else { RowHeightEntry entry; - if (!_rowHeightList.TryGetValue(rowNum, out RowHeightEntry? value)) + if (!_rowHeightList.TryGetValue(rowNum, out var value)) { entry = new RowHeightEntry { @@ -3552,7 +3552,7 @@ private void ChangeRowHeight (bool decrease) private int GetRowHeight (int rowNum) { - return _rowHeightList.TryGetValue(rowNum, out RowHeightEntry? value) + return _rowHeightList.TryGetValue(rowNum, out var value) ? value.Height : _lineHeight; } @@ -3603,7 +3603,7 @@ private void MarkCurrentFilterRange () _filterParams.RangeSearchText = filterRangeComboBox.Text; ColumnizerCallback callback = new(this); RangeFinder rangeFinder = new(_filterParams, callback); - Core.Entities.Range range = rangeFinder.FindRange(dataGridView.CurrentCellAddress.Y); + var range = rangeFinder.FindRange(dataGridView.CurrentCellAddress.Y); if (range != null) { SetCellSelectionMode(false); @@ -3657,7 +3657,7 @@ private void SetBookmarksForSelectedFilterLines () private void SetDefaultHighlightGroup () { - HighlightGroup group = _parentLogTabWin.FindHighlightGroupByFileMask(FileName); + var group = _parentLogTabWin.FindHighlightGroupByFileMask(FileName); if (group != null) { SetCurrentHighlightGroup(group.GroupName); @@ -3680,7 +3680,7 @@ private void FireCancelHandlers () { lock (_cancelHandlerList) { - foreach (Core.Interface.IBackgroundProcessCancelHandler handler in _cancelHandlerList) + foreach (var handler in _cancelHandlerList) { handler.EscapePressed(); } @@ -3714,7 +3714,7 @@ private void AddSlaveToTimesync (LogWindow slave) var currentLineNum = dataGridView.CurrentCellAddress.Y; var refLine = currentLineNum; - DateTime timeStamp = GetTimestampForLine(ref refLine, true); + var timeStamp = GetTimestampForLine(ref refLine, true); if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel) { TimeSyncList.CurrentTimestamp = timeStamp; @@ -3771,7 +3771,7 @@ private void RemoveAllSearchHighlightEntries () lock (_tempHighlightEntryListLock) { List newList = []; - foreach (HighlightEntry he in _tempHighlightEntryList) + foreach (var he in _tempHighlightEntryList) { if (!he.IsSearchHit) { @@ -3803,7 +3803,7 @@ private DataGridViewColumn GetColumnByName (BufferedDataGridView dataGridView, s private void SelectColumn () { var colName = columnComboBox.SelectedItem as string; - DataGridViewColumn col = GetColumnByName(dataGridView, colName); + var col = GetColumnByName(dataGridView, colName); if (col != null && !col.Frozen) { dataGridView.FirstDisplayedScrollingColumnIndex = col.Index; diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs index cd01695c..8d4d36a0 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs @@ -499,7 +499,7 @@ public void CellPainting (BufferedDataGridView gridView, int rowIndex, DataGridV } } - public void OnDataGridView_CellPainting (object sender, DataGridViewCellPaintingEventArgs e) + public void OnDataGridViewCellPainting (object sender, DataGridViewCellPaintingEventArgs e) { var gridView = (BufferedDataGridView)sender; CellPainting(gridView, e.RowIndex, e); diff --git a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.Designer.cs b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.Designer.cs index bd148048..a40a078f 100644 --- a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.Designer.cs +++ b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.Designer.cs @@ -204,7 +204,7 @@ private void InitializeComponent() this.setRangeButton.TabIndex = 12; this.setRangeButton.Text = "Set range"; this.setRangeButton.UseVisualStyleBackColor = true; - this.setRangeButton.Click += new System.EventHandler(this.setRangeButton_Click); + this.setRangeButton.Click += new System.EventHandler(this.OnSetRangeButtonClick); // // label7 // @@ -224,7 +224,7 @@ private void InitializeComponent() this.recalcButton.TabIndex = 6; this.recalcButton.Text = "Recalc"; this.recalcButton.UseVisualStyleBackColor = true; - this.recalcButton.Click += new System.EventHandler(this.recalcButton_Click); + this.recalcButton.Click += new System.EventHandler(this.OnRecalcButtonClick); // // label6 // @@ -337,11 +337,11 @@ private void InitializeComponent() this.patternHitsDataGridView.Size = new System.Drawing.Size(289, 83); this.patternHitsDataGridView.TabIndex = 1; this.patternHitsDataGridView.VirtualMode = true; - this.patternHitsDataGridView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.patternHitsDataGridView_MouseDoubleClick); - this.patternHitsDataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.patternHitsDataGridView_CellValueNeeded); - this.patternHitsDataGridView.ColumnDividerDoubleClick += new System.Windows.Forms.DataGridViewColumnDividerDoubleClickEventHandler(this.patternHitsDataGridView_ColumnDividerDoubleClick); - this.patternHitsDataGridView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.patternHitsDataGridView_CellPainting); - this.patternHitsDataGridView.CurrentCellChanged += new System.EventHandler(this.patternHitsDataGridView_CurrentCellChanged); + this.patternHitsDataGridView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.OnPatternHitsDataGridViewMouseDoubleClick); + this.patternHitsDataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnPatternHitsDataGridViewCellValueNeeded); + this.patternHitsDataGridView.ColumnDividerDoubleClick += new System.Windows.Forms.DataGridViewColumnDividerDoubleClickEventHandler(this.OnPatternHitsDataGridViewColumnDividerDoubleClick); + this.patternHitsDataGridView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.OnPatternHitsDataGridViewCellPainting); + this.patternHitsDataGridView.CurrentCellChanged += new System.EventHandler(this.OnPatternHitsDataGridViewCurrentCellChanged); // // contentDataGridView // @@ -365,10 +365,10 @@ private void InitializeComponent() this.contentDataGridView.Size = new System.Drawing.Size(491, 83); this.contentDataGridView.TabIndex = 0; this.contentDataGridView.VirtualMode = true; - this.contentDataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.contentDataGridView_CellValueNeeded); - this.contentDataGridView.ColumnDividerDoubleClick += new System.Windows.Forms.DataGridViewColumnDividerDoubleClickEventHandler(this.contentDataGridView_ColumnDividerDoubleClick); - this.contentDataGridView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.contentDataGridView_CellPainting); - this.contentDataGridView.CellMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.contentDataGridView_CellMouseDoubleClick); + this.contentDataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnContentDataGridViewCellValueNeeded); + this.contentDataGridView.ColumnDividerDoubleClick += new System.Windows.Forms.DataGridViewColumnDividerDoubleClickEventHandler(this.OnContentDataGridViewColumnDividerDoubleClick); + this.contentDataGridView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.OnContentDataGridViewCellPainting); + this.contentDataGridView.CellMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.OnContentDataGridViewCellMouseDoubleClick); // // PatternWindow // diff --git a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs index 84614aef..f704e3e8 100644 --- a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs @@ -29,7 +29,7 @@ public PatternWindow () public PatternWindow (LogWindow logWindow) { - this._logWindow = logWindow; + _logWindow = logWindow; InitializeComponent(); recalcButton.Enabled = false; } @@ -68,13 +68,13 @@ public int Weight public void SetBlockList (List flatBlockList, PatternArgs patternArgs) { - this._patternArgs = patternArgs; + _patternArgs = patternArgs; _blockList.Clear(); List singeList = []; //int blockId = -1; for (var i = 0; i < flatBlockList.Count; ++i) { - PatternBlock block = flatBlockList[i]; + var block = flatBlockList[i]; singeList.Add(block); //if (block.blockId != blockId) //{ @@ -105,21 +105,25 @@ public void SetColumnizer (ILogLineColumnizer columnizer) patternHitsDataGridView.Columns[0].Width = 20; contentDataGridView.Columns[0].Width = 20; - DataGridViewTextBoxColumn blockInfoColumn = new(); - blockInfoColumn.HeaderText = "Weight"; - blockInfoColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - blockInfoColumn.Resizable = DataGridViewTriState.False; - blockInfoColumn.DividerWidth = 1; - blockInfoColumn.ReadOnly = true; - blockInfoColumn.Width = 50; - - DataGridViewTextBoxColumn contentInfoColumn = new(); - contentInfoColumn.HeaderText = "Diff"; - contentInfoColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - contentInfoColumn.Resizable = DataGridViewTriState.False; - contentInfoColumn.DividerWidth = 1; - contentInfoColumn.ReadOnly = true; - contentInfoColumn.Width = 50; + DataGridViewTextBoxColumn blockInfoColumn = new() + { + HeaderText = "Weight", + AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet, + Resizable = DataGridViewTriState.False, + DividerWidth = 1, + ReadOnly = true, + Width = 50 + }; + + DataGridViewTextBoxColumn contentInfoColumn = new() + { + HeaderText = "Diff", + AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet, + Resizable = DataGridViewTriState.False, + DividerWidth = 1, + ReadOnly = true, + Width = 50 + }; patternHitsDataGridView.Columns.Insert(1, blockInfoColumn); contentDataGridView.Columns.Insert(1, contentInfoColumn); @@ -128,8 +132,8 @@ public void SetColumnizer (ILogLineColumnizer columnizer) public void SetFont (string fontName, float fontSize) { Font font = new(new FontFamily(fontName), fontSize); - var lineSpacing = font.FontFamily.GetLineSpacing(FontStyle.Regular); - var lineSpacingPixel = font.Size * lineSpacing / font.FontFamily.GetEmHeight(FontStyle.Regular); + //var lineSpacing = font.FontFamily.GetLineSpacing(FontStyle.Regular); + //var lineSpacingPixel = font.Size * lineSpacing / font.FontFamily.GetEmHeight(FontStyle.Regular); patternHitsDataGridView.DefaultCellStyle.Font = font; contentDataGridView.DefaultCellStyle.Font = font; @@ -183,14 +187,16 @@ private int GetLineForContentGrid (int rowIndex) #region Events handler - private void patternHitsDataGridView_CellValueNeeded (object sender, DataGridViewCellValueEventArgs e) + private void OnPatternHitsDataGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e) { if (_currentList == null || e.RowIndex < 0) { return; } + var rowIndex = GetLineForHitGrid(e.RowIndex); var colIndex = e.ColumnIndex; + if (colIndex == 1) { e.Value = _currentList[e.RowIndex].Weigth; @@ -206,7 +212,7 @@ private void patternHitsDataGridView_CellValueNeeded (object sender, DataGridVie } } - private void patternHitsDataGridView_CellPainting (object sender, DataGridViewCellPaintingEventArgs e) + private void OnPatternHitsDataGridViewCellPainting (object sender, DataGridViewCellPaintingEventArgs e) { if (_currentList == null || e.RowIndex < 0) { @@ -217,18 +223,20 @@ private void patternHitsDataGridView_CellPainting (object sender, DataGridViewCe { e.PaintBackground(e.CellBounds, false); var selCount = _patternArgs.EndLine - _patternArgs.StartLine; - var maxWeight = _patternArgs.MaxDiffInBlock * selCount + selCount; + var maxWeight = (_patternArgs.MaxDiffInBlock * selCount) + selCount; + if (maxWeight > 0) { var width = (int)((int)e.Value / (double)maxWeight * e.CellBounds.Width); Rectangle rect = new(e.CellBounds.X, e.CellBounds.Y, width, e.CellBounds.Height); var alpha = 90 + (int)((int)e.Value / (double)maxWeight * 165); - var color = Color.FromArgb(alpha, 170, 180, 150); - Brush brush = new SolidBrush(color); + + Brush brush = new SolidBrush(Color.FromArgb(alpha, 170, 180, 150));//gray green rect.Inflate(-2, -1); e.Graphics.FillRectangle(brush, rect); brush.Dispose(); } + e.PaintContent(e.CellBounds); e.Handled = true; } @@ -240,7 +248,7 @@ private void patternHitsDataGridView_CellPainting (object sender, DataGridViewCe } } - private void patternHitsDataGridView_MouseDoubleClick (object sender, MouseEventArgs e) + private void OnPatternHitsDataGridViewMouseDoubleClick (object sender, MouseEventArgs e) { //if (this.currentList == null || patternHitsDataGridView.CurrentRow == null) // return; @@ -249,7 +257,7 @@ private void patternHitsDataGridView_MouseDoubleClick (object sender, MouseEvent //this.logWindow.SelectLogLine(rowIndex); } - private void patternHitsDataGridView_CurrentCellChanged (object sender, EventArgs e) + private void OnPatternHitsDataGridViewCurrentCellChanged (object sender, EventArgs e) { if (_currentList == null || patternHitsDataGridView.CurrentRow == null) { @@ -269,25 +277,21 @@ private void patternHitsDataGridView_CurrentCellChanged (object sender, EventArg blockLinesLabel.Text = "" + contentDataGridView.RowCount; } - private void contentDataGridView_CellValueNeeded (object sender, DataGridViewCellValueEventArgs e) + private void OnContentDataGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e) { if (_currentBlock == null || e.RowIndex < 0) { return; } + var rowIndex = GetLineForContentGrid(e.RowIndex); var colIndex = e.ColumnIndex; + if (colIndex == 1) { - QualityInfo qi; - if (_currentBlock.QualityInfoList.TryGetValue(rowIndex, out qi)) - { - e.Value = qi.Quality; - } - else - { - e.Value = ""; - } + e.Value = _currentBlock.QualityInfoList.TryGetValue(rowIndex, out var qi) + ? qi.Quality + : string.Empty; } else { @@ -295,33 +299,36 @@ private void contentDataGridView_CellValueNeeded (object sender, DataGridViewCel { colIndex--; // adjust the inserted column } + e.Value = _logWindow.GetCellValue(rowIndex, colIndex); } } - private void contentDataGridView_CellPainting (object sender, DataGridViewCellPaintingEventArgs e) + private void OnContentDataGridViewCellPainting (object sender, DataGridViewCellPaintingEventArgs e) { if (_currentBlock == null || e.RowIndex < 0) { return; } + var gridView = (BufferedDataGridView)sender; var rowIndex = GetLineForContentGrid(e.RowIndex); _logWindow.CellPainting(gridView, rowIndex, e); } - private void contentDataGridView_CellMouseDoubleClick (object sender, DataGridViewCellMouseEventArgs e) + private void OnContentDataGridViewCellMouseDoubleClick (object sender, DataGridViewCellMouseEventArgs e) { if (_currentBlock == null || contentDataGridView.CurrentRow == null) { return; } + var rowIndex = GetLineForContentGrid(contentDataGridView.CurrentRow.Index); _logWindow.SelectLogLine(rowIndex); } - private void recalcButton_Click (object sender, EventArgs e) + private void OnRecalcButtonClick (object sender, EventArgs e) { _patternArgs.Fuzzy = fuzzyKnobControl.Value; _patternArgs.MaxDiffInBlock = maxDiffKnobControl.Value; @@ -332,26 +339,24 @@ private void recalcButton_Click (object sender, EventArgs e) setRangeButton.Enabled = false; } - private void closeButton_Click (object sender, EventArgs e) + private void OnCloseButtonClick (object sender, EventArgs e) { Close(); } - private void contentDataGridView_ColumnDividerDoubleClick (object sender, - DataGridViewColumnDividerDoubleClickEventArgs e) + private void OnContentDataGridViewColumnDividerDoubleClick (object sender, DataGridViewColumnDividerDoubleClickEventArgs e) { e.Handled = true; contentDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); } - private void patternHitsDataGridView_ColumnDividerDoubleClick (object sender, - DataGridViewColumnDividerDoubleClickEventArgs e) + private void OnPatternHitsDataGridViewColumnDividerDoubleClick (object sender, DataGridViewColumnDividerDoubleClickEventArgs e) { e.Handled = true; patternHitsDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); } - private void setRangeButton_Click (object sender, EventArgs e) + private void OnSetRangeButtonClick (object sender, EventArgs e) { _logWindow.PatternStatisticSelectRange(_patternArgs); recalcButton.Enabled = true; diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.Designer.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.Designer.cs index ba25f3c3..4a0cc7fb 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.Designer.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.Designer.cs @@ -34,12 +34,12 @@ private void InitializeComponent() // this.Name = "TimeSpreadingControl"; this.Size = new System.Drawing.Size(26, 324); - this.MouseLeave += new System.EventHandler(this.TimeSpreadingControl_MouseLeave); - this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.TimeSpreadingControl_MouseMove); - this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TimeSpreadingControl_MouseDown); - this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.TimeSpreadingControl_MouseUp); - this.SizeChanged += new System.EventHandler(this.TimeSpreadingControl_SizeChanged); - this.MouseEnter += new System.EventHandler(this.TimeSpreadingControl_MouseEnter); + this.MouseLeave += new System.EventHandler(this.OnTimeSpreadingControlMouseLeave); + this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnTimeSpreadingControlMouseMove); + this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnTimeSpreadingControlMouseDown); + this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnTimeSpreadingControlMouseUp); + this.SizeChanged += new System.EventHandler(this.OnTimeSpreadingControlSizeChanged); + this.MouseEnter += new System.EventHandler(this.OnTimeSpreadingControlMouseEnter); this.ResumeLayout(false); } diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs index 7aea14ed..11d7e81d 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs @@ -65,8 +65,8 @@ internal TimeSpreadCalculator TimeSpreadCalc { //timeSpreadCalc.CalcDone -= timeSpreadCalc_CalcDone; _timeSpreadCalc = value; - _timeSpreadCalc.CalcDone += TimeSpreadCalc_CalcDone; - _timeSpreadCalc.StartCalc += TimeSpreadCalc_StartCalc; + _timeSpreadCalc.CalcDone += OnTimeSpreadCalcCalcDone; + _timeSpreadCalc.StartCalc += OnTimeSpreadCalcStartCalc; } } @@ -82,7 +82,7 @@ protected override void OnPaint (PaintEventArgs e) if (DesignMode) { Brush bgBrush = new SolidBrush(Color.FromKnownColor(KnownColor.LightSkyBlue)); - Rectangle rect = ClientRectangle; + var rect = ClientRectangle; rect.Inflate(0, -_edgeOffset); e.Graphics.FillRectangle(bgBrush, rect); bgBrush.Dispose(); @@ -100,7 +100,7 @@ protected override void OnPaint (PaintEventArgs e) private SpreadEntry GetEntryForMouse (MouseEventArgs e) { - List list = TimeSpreadCalc.DiffList; + var list = TimeSpreadCalc.DiffList; var y = e.Y - _edgeOffset; if (y < 0) { @@ -144,14 +144,14 @@ private void OnLineSelected (SelectLineEventArgs e) #region Events handler - private void TimeSpreadCalc_CalcDone (object sender, EventArgs e) + private void OnTimeSpreadCalcCalcDone (object sender, EventArgs e) { _logger.Debug("timeSpreadCalc_CalcDone()"); lock (_monitor) { Invalidate(); - Rectangle rect = ClientRectangle; + var rect = ClientRectangle; rect.Size = new Size(rect.Width, rect.Height - _edgeOffset * 3); if (rect.Height < 1) @@ -165,7 +165,7 @@ private void TimeSpreadCalc_CalcDone (object sender, EventArgs e) gfx.FillRectangle(bgBrush, rect); bgBrush.Dispose(); - List list = TimeSpreadCalc.DiffList; + var list = TimeSpreadCalc.DiffList; int step; if (list.Count >= _displayHeight) @@ -185,7 +185,7 @@ private void TimeSpreadCalc_CalcDone (object sender, EventArgs e) { for (var i = 0; i < list.Count; i += step) { - SpreadEntry entry = list[i]; + var entry = list[i]; var color = ReverseAlpha ? entry.Value : 255 - entry.Value; if (color > 255) @@ -210,12 +210,12 @@ private void TimeSpreadCalc_CalcDone (object sender, EventArgs e) BeginInvoke(new MethodInvoker(Refresh)); } - private void TimeSpreadCalc_StartCalc (object sender, EventArgs e) + private void OnTimeSpreadCalcStartCalc (object sender, EventArgs e) { lock (_monitor) { Invalidate(); - Rectangle rect = ClientRectangle; + var rect = ClientRectangle; rect.Size = new Size(rect.Width, rect.Height - _edgeOffset * 3); if (rect.Height < 1) @@ -230,9 +230,11 @@ private void TimeSpreadCalc_StartCalc (object sender, EventArgs e) Brush fgBrush = new SolidBrush(ForeColor); //gfx.FillRectangle(bgBrush, rect); - StringFormat format = new(StringFormatFlags.DirectionVertical | StringFormatFlags.NoWrap); - format.LineAlignment = StringAlignment.Center; - format.Alignment = StringAlignment.Center; + StringFormat format = new(StringFormatFlags.DirectionVertical | StringFormatFlags.NoWrap) + { + LineAlignment = StringAlignment.Center, + Alignment = StringAlignment.Center + }; RectangleF rectf = new(rect.Left, rect.Top, rect.Width, rect.Height); @@ -245,7 +247,7 @@ private void TimeSpreadCalc_StartCalc (object sender, EventArgs e) BeginInvoke(new MethodInvoker(Refresh)); } - private void TimeSpreadingControl_SizeChanged (object sender, EventArgs e) + private void OnTimeSpreadingControlSizeChanged (object sender, EventArgs e) { if (TimeSpreadCalc != null) { @@ -254,15 +256,15 @@ private void TimeSpreadingControl_SizeChanged (object sender, EventArgs e) } } - private void TimeSpreadingControl_MouseDown (object sender, MouseEventArgs e) + private void OnTimeSpreadingControlMouseDown (object sender, MouseEventArgs e) { } - private void TimeSpreadingControl_MouseUp (object sender, MouseEventArgs e) + private void OnTimeSpreadingControlMouseUp (object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { - SpreadEntry entry = GetEntryForMouse(e); + var entry = GetEntryForMouse(e); if (entry == null) { return; @@ -272,17 +274,17 @@ private void TimeSpreadingControl_MouseUp (object sender, MouseEventArgs e) } } - private void TimeSpreadingControl_MouseEnter (object sender, EventArgs e) + private void OnTimeSpreadingControlMouseEnter (object sender, EventArgs e) { _toolTip.Active = true; } - private void TimeSpreadingControl_MouseLeave (object sender, EventArgs e) + private void OnTimeSpreadingControlMouseLeave (object sender, EventArgs e) { _toolTip.Active = false; } - private void TimeSpreadingControl_MouseMove (object sender, MouseEventArgs e) + private void OnTimeSpreadingControlMouseMove (object sender, MouseEventArgs e) { if (e.Y == _lastMouseY) { @@ -295,7 +297,7 @@ private void TimeSpreadingControl_MouseMove (object sender, MouseEventArgs e) return; } - SpreadEntry entry = GetEntryForMouse(e); + var entry = GetEntryForMouse(e); if (entry == null) { @@ -303,7 +305,7 @@ private void TimeSpreadingControl_MouseMove (object sender, MouseEventArgs e) } _lastMouseY = e.Y; - var dts = entry.Timestamp.ToString("dd.MM.yyyy HH:mm:ss"); + var dts = $"{entry.Timestamp:dd.MM.yyyy HH:mm:ss}"; _toolTip.SetToolTip(this, "Line " + (entry.LineNum + 1) + "\n" + dts); } diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.Designer.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.Designer.cs index c7310c5f..9467414c 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.Designer.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.Designer.cs @@ -53,14 +53,14 @@ private void InitializeComponent() { this.deleteBookmarkssToolStripMenuItem.Name = "deleteBookmarkssToolStripMenuItem"; this.deleteBookmarkssToolStripMenuItem.Size = new System.Drawing.Size(185, 22); this.deleteBookmarkssToolStripMenuItem.Text = "Delete bookmarks(s)"; - this.deleteBookmarkssToolStripMenuItem.Click += new System.EventHandler(this.deleteBookmarksToolStripMenuItem_Click); + this.deleteBookmarkssToolStripMenuItem.Click += new System.EventHandler(this.OnDeleteBookmarksToolStripMenuItemClick); // // removeCommentsToolStripMenuItem // this.removeCommentsToolStripMenuItem.Name = "removeCommentsToolStripMenuItem"; this.removeCommentsToolStripMenuItem.Size = new System.Drawing.Size(185, 22); this.removeCommentsToolStripMenuItem.Text = "Remove comment(s)"; - this.removeCommentsToolStripMenuItem.Click += new System.EventHandler(this.removeCommentsToolStripMenuItem_Click); + this.removeCommentsToolStripMenuItem.Click += new System.EventHandler(this.OnRemoveCommentsToolStripMenuItemClick); // // bookmarkTextBox // @@ -73,7 +73,7 @@ private void InitializeComponent() { this.bookmarkTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.bookmarkTextBox.Size = new System.Drawing.Size(194, 114); this.bookmarkTextBox.TabIndex = 0; - this.bookmarkTextBox.TextChanged += new System.EventHandler(this.bookmarkTextBox_TextChanged); + this.bookmarkTextBox.TextChanged += new System.EventHandler(this.OnBookmarkTextBoxTextChanged); // // splitContainer1 // @@ -119,17 +119,17 @@ private void InitializeComponent() { this.bookmarkDataGridView.Size = new System.Drawing.Size(517, 158); this.bookmarkDataGridView.TabIndex = 0; this.bookmarkDataGridView.VirtualMode = true; - this.bookmarkDataGridView.Enter += new System.EventHandler(this.bookmarkGridView_Enter); - this.bookmarkDataGridView.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.bookmarkDataGridView_CellDoubleClick); - this.bookmarkDataGridView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.boomarkDataGridView_MouseDoubleClick); - this.bookmarkDataGridView.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.bookmarkDataGridView_PreviewKeyDown); - this.bookmarkDataGridView.Leave += new System.EventHandler(this.bookmarkGridView_Leave); - this.bookmarkDataGridView.ColumnDividerDoubleClick += new System.Windows.Forms.DataGridViewColumnDividerDoubleClickEventHandler(this.boomarkDataGridView_ColumnDividerDoubleClick); - this.bookmarkDataGridView.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(this.bookmarkDataGridView_RowsAdded); - this.bookmarkDataGridView.SelectionChanged += new System.EventHandler(bookmarkDataGridView_SelectionChanged); - this.bookmarkDataGridView.CellToolTipTextNeeded += new System.Windows.Forms.DataGridViewCellToolTipTextNeededEventHandler(this.bookmarkDataGridView_CellToolTipTextNeeded); - this.bookmarkDataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.bookmarkGridView_KeyDown); - this.bookmarkDataGridView.RowsRemoved += new System.Windows.Forms.DataGridViewRowsRemovedEventHandler(this.bookmarkDataGridView_RowsRemoved); + this.bookmarkDataGridView.Enter += new System.EventHandler(this.OnBookmarkGridViewEnter); + this.bookmarkDataGridView.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.OnBookmarkDataGridViewCellDoubleClick); + this.bookmarkDataGridView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.OnBoomarkDataGridViewMouseDoubleClick); + this.bookmarkDataGridView.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.OnBookmarkDataGridViewPreviewKeyDown); + this.bookmarkDataGridView.Leave += new System.EventHandler(this.OnBookmarkGridViewLeave); + this.bookmarkDataGridView.ColumnDividerDoubleClick += new System.Windows.Forms.DataGridViewColumnDividerDoubleClickEventHandler(this.OnBoomarkDataGridViewColumnDividerDoubleClick); + this.bookmarkDataGridView.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(this.OnBookmarkDataGridViewRowsAdded); + this.bookmarkDataGridView.SelectionChanged += new System.EventHandler(OnBookmarkDataGridViewSelectionChanged); + this.bookmarkDataGridView.CellToolTipTextNeeded += new System.Windows.Forms.DataGridViewCellToolTipTextNeededEventHandler(this.OnBookmarkDataGridViewCellToolTipTextNeeded); + this.bookmarkDataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnBookmarkGridViewKeyDown); + this.bookmarkDataGridView.RowsRemoved += new System.Windows.Forms.DataGridViewRowsRemovedEventHandler(this.OnBookmarkDataGridViewRowsRemoved); // // commentColumnCheckBox // @@ -141,7 +141,7 @@ private void InitializeComponent() { this.commentColumnCheckBox.TabIndex = 8; this.commentColumnCheckBox.Text = "Show comment column"; this.commentColumnCheckBox.UseVisualStyleBackColor = true; - this.commentColumnCheckBox.CheckedChanged += new System.EventHandler(this.commentColumnCheckBox_CheckedChanged); + this.commentColumnCheckBox.CheckedChanged += new System.EventHandler(this.OnCommentColumnCheckBoxCheckedChanged); // // label1 // @@ -172,7 +172,7 @@ private void InitializeComponent() { this.ShowInTaskbar = false; this.Text = "Bookmarks"; this.ClientSizeChanged += new System.EventHandler(this.BookmarkWindow_ClientSizeChanged); - this.SizeChanged += new System.EventHandler(this.BookmarkWindow_SizeChanged); + this.SizeChanged += new System.EventHandler(this.OnBookmarkWindowSizeChanged); this.contextMenuStrip1.ResumeLayout(false); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs index 54e0f11e..8a3518fa 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs @@ -19,7 +19,7 @@ internal partial class BookmarkWindow : DockContent, ISharedToolWindow, IBookmar { #region Fields - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); private readonly object paintLock = new(); private IBookmarkData bookmarkData; @@ -379,7 +379,7 @@ private void OnBoomarkDataGridViewCellValueNeeded (object sender, DataGridViewCe } - private void boomarkDataGridView_MouseDoubleClick (object sender, MouseEventArgs e) + private void OnBoomarkDataGridViewMouseDoubleClick (object sender, MouseEventArgs e) { // if (this.bookmarkDataGridView.CurrentRow != null) // { @@ -388,14 +388,14 @@ private void boomarkDataGridView_MouseDoubleClick (object sender, MouseEventArgs // } } - private void boomarkDataGridView_ColumnDividerDoubleClick (object sender, + private void OnBoomarkDataGridViewColumnDividerDoubleClick (object sender, DataGridViewColumnDividerDoubleClickEventArgs e) { e.Handled = true; ResizeColumns(); } - private void bookmarkGridView_KeyDown (object sender, KeyEventArgs e) + private void OnBookmarkGridViewKeyDown (object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { @@ -424,22 +424,22 @@ private void bookmarkGridView_KeyDown (object sender, KeyEventArgs e) } } - private void bookmarkGridView_Enter (object sender, EventArgs e) + private void OnBookmarkGridViewEnter (object sender, EventArgs e) { InvalidateCurrentRow(bookmarkDataGridView); } - private void bookmarkGridView_Leave (object sender, EventArgs e) + private void OnBookmarkGridViewLeave (object sender, EventArgs e) { InvalidateCurrentRow(bookmarkDataGridView); } - private void deleteBookmarksToolStripMenuItem_Click (object sender, EventArgs e) + private void OnDeleteBookmarksToolStripMenuItemClick (object sender, EventArgs e) { DeleteSelectedBookmarks(); } - private void bookmarkTextBox_TextChanged (object sender, EventArgs e) + private void OnBookmarkTextBoxTextChanged (object sender, EventArgs e) { if (!bookmarkTextBox.Enabled) { @@ -462,7 +462,7 @@ private void bookmarkTextBox_TextChanged (object sender, EventArgs e) logView?.RefreshLogView(); } - private void bookmarkDataGridView_SelectionChanged (object sender, EventArgs e) + private void OnBookmarkDataGridViewSelectionChanged (object sender, EventArgs e) { if (bookmarkDataGridView.SelectedRows.Count != 1 || bookmarkDataGridView.SelectedRows[0].Index >= bookmarkData.Bookmarks.Count) @@ -475,7 +475,7 @@ private void bookmarkDataGridView_SelectionChanged (object sender, EventArgs e) } } - private void bookmarkDataGridView_PreviewKeyDown (object sender, PreviewKeyDownEventArgs e) + private void OnBookmarkDataGridViewPreviewKeyDown (object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Tab) { @@ -483,7 +483,7 @@ private void bookmarkDataGridView_PreviewKeyDown (object sender, PreviewKeyDownE } } - private void bookmarkDataGridView_CellToolTipTextNeeded (object sender, + private void OnBookmarkDataGridViewCellToolTipTextNeeded (object sender, DataGridViewCellToolTipTextNeededEventArgs e) { if (e.ColumnIndex != 0 || e.RowIndex <= -1 || e.RowIndex >= bookmarkData.Bookmarks.Count) @@ -499,7 +499,7 @@ private void bookmarkDataGridView_CellToolTipTextNeeded (object sender, } } - private void bookmarkDataGridView_CellDoubleClick (object sender, DataGridViewCellEventArgs e) + private void OnBookmarkDataGridViewCellDoubleClick (object sender, DataGridViewCellEventArgs e) { // Toggle bookmark when double-clicking on the first column if (e.ColumnIndex == 0 && e.RowIndex >= 0 && bookmarkDataGridView.CurrentRow != null) @@ -551,7 +551,7 @@ private void bookmarkDataGridView_CellDoubleClick (object sender, DataGridViewCe } } - private void removeCommentsToolStripMenuItem_Click (object sender, EventArgs e) + private void OnRemoveCommentsToolStripMenuItemClick (object sender, EventArgs e) { if ( MessageBox.Show("Really remove bookmark comments for selected lines?", "LogExpert", @@ -573,7 +573,7 @@ private void removeCommentsToolStripMenuItem_Click (object sender, EventArgs e) } } - private void commentColumnCheckBox_CheckedChanged (object sender, EventArgs e) + private void OnCommentColumnCheckBoxCheckedChanged (object sender, EventArgs e) { ShowCommentColumn(commentColumnCheckBox.Checked); } @@ -607,17 +607,17 @@ private void BookmarkWindow_ClientSizeChanged (object sender, EventArgs e) } } - private void bookmarkDataGridView_RowsAdded (object sender, DataGridViewRowsAddedEventArgs e) + private void OnBookmarkDataGridViewRowsAdded (object sender, DataGridViewRowsAddedEventArgs e) { HideIfNeeded(); } - private void bookmarkDataGridView_RowsRemoved (object sender, DataGridViewRowsRemovedEventArgs e) + private void OnBookmarkDataGridViewRowsRemoved (object sender, DataGridViewRowsRemovedEventArgs e) { HideIfNeeded(); } - private void BookmarkWindow_SizeChanged (object sender, EventArgs e) + private void OnBookmarkWindowSizeChanged (object sender, EventArgs e) { // if (!this.splitContainer1.Visible) // { diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs index 3f91c8ca..886052ac 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs @@ -44,7 +44,7 @@ private void PasteFromClipboard () } var title = "Clipboard"; - LogWindow.LogWindow logWindow = AddTempFileTab(fileName, title); + var logWindow = AddTempFileTab(fileName, title); if (logWindow.Tag is LogWindowData data) { SetTooltipText(logWindow, "Pasted on " + DateTime.Now); @@ -252,7 +252,7 @@ private LogWindow.LogWindow FindWindowForFile (string fileName) { lock (_logWindowList) { - foreach (LogWindow.LogWindow logWindow in _logWindowList) + foreach (var logWindow in _logWindowList) { if (logWindow.FileName.ToUpperInvariant().Equals(fileName.ToUpperInvariant(), StringComparison.Ordinal)) { @@ -274,7 +274,7 @@ private string FindFilenameForSettings (string fileName) { if (fileName.EndsWith(".lxp")) { - PersistenceData persistenceData = Persister.LoadOptionsOnly(fileName); + var persistenceData = Persister.LoadOptionsOnly(fileName); if (persistenceData == null) { return fileName; @@ -282,7 +282,7 @@ private string FindFilenameForSettings (string fileName) if (!string.IsNullOrEmpty(persistenceData.FileName)) { - IFileSystemPlugin fs = PluginRegistry.PluginRegistry.Instance.FindFileSystemForUri(persistenceData.FileName); + var fs = PluginRegistry.PluginRegistry.Instance.FindFileSystemForUri(persistenceData.FileName); if (fs != null && !fs.GetType().Equals(typeof(LocalFileSystem))) { return persistenceData.FileName; @@ -359,7 +359,7 @@ private void ShowHighlightSettingsDialog () PreSelectedGroupName = groupsComboBoxHighlightGroups.Text }; - DialogResult res = dlg.ShowDialog(); + var res = dlg.ShowDialog(); if (res == DialogResult.OK) { @@ -376,7 +376,7 @@ private void FillHighlightComboBox () { var currentGroupName = groupsComboBoxHighlightGroups.Text; groupsComboBoxHighlightGroups.Items.Clear(); - foreach (HighlightGroup group in HighlightGroupList) + foreach (var group in HighlightGroupList) { groupsComboBoxHighlightGroups.Items.Add(group.GroupName); if (group.GroupName.Equals(currentGroupName, StringComparison.Ordinal)) @@ -451,11 +451,11 @@ private void LoadFiles (string[] names, bool invertLogic) return; } - MultiFileOption option = ConfigManager.Settings.Preferences.MultiFileOption; + var option = ConfigManager.Settings.Preferences.MultiFileOption; if (option == MultiFileOption.Ask) { MultiLoadRequestDialog dlg = new(); - DialogResult res = dlg.ShowDialog(); + var res = dlg.ShowDialog(); if (res == DialogResult.Yes) { @@ -492,7 +492,7 @@ private void LoadFiles (string[] names, bool invertLogic) private void SetColumnizerHistoryEntry (string fileName, ILogLineColumnizer columnizer) { - ColumnizerHistoryEntry entry = FindColumnizerHistoryEntry(fileName); + var entry = FindColumnizerHistoryEntry(fileName); if (entry != null) { _ = ConfigManager.Settings.ColumnizerHistoryList.Remove(entry); @@ -509,7 +509,7 @@ private void SetColumnizerHistoryEntry (string fileName, ILogLineColumnizer colu private ColumnizerHistoryEntry FindColumnizerHistoryEntry (string fileName) { - foreach (ColumnizerHistoryEntry entry in ConfigManager.Settings.ColumnizerHistoryList) + foreach (var entry in ConfigManager.Settings.ColumnizerHistoryList) { if (entry.FileName.Equals(fileName, StringComparison.Ordinal)) { @@ -539,7 +539,7 @@ private void ChangeCurrentLogWindow (LogWindow.LogWindow newLogWindow) return; // do nothing if wishing to set the same window } - LogWindow.LogWindow oldLogWindow = _currentLogWindow; + var oldLogWindow = _currentLogWindow; _currentLogWindow = newLogWindow; var titleName = _showInstanceNumbers ? "LogExpert #" + _instanceNumber : "LogExpert"; @@ -714,7 +714,7 @@ private void StatusLineEventWorker (StatusLineEventArgs e) [SupportedOSPlatform("windows")] private Icon CreateLedIcon (int level, bool dirty, int tailState, int syncMode) { - Rectangle iconRect = _leds[0]; + var iconRect = _leds[0]; iconRect.Height = 16; // (DockPanel's damn hardcoded height) // this.leds[this.leds.Length - 1].Bottom; iconRect.Width = iconRect.Right + 6; Bitmap bmp = new(iconRect.Width, iconRect.Height); @@ -724,7 +724,7 @@ private Icon CreateLedIcon (int level, bool dirty, int tailState, int syncMode) for (var i = 0; i < _leds.Length; ++i) { - Rectangle ledRect = _leds[i]; + var ledRect = _leds[i]; ledRect.Offset(0, offsetFromTop); if (level >= _leds.Length - i) @@ -739,7 +739,7 @@ private Icon CreateLedIcon (int level, bool dirty, int tailState, int syncMode) var ledSize = 3; var ledGap = 1; - Rectangle lastLed = _leds[^1]; + var lastLed = _leds[^1]; Rectangle dirtyLed = new(lastLed.Right + 2, lastLed.Bottom - ledSize, ledSize, ledSize); Rectangle tailLed = new(dirtyLed.Location, dirtyLed.Size); tailLed.Offset(0, -(ledSize + ledGap)); @@ -818,7 +818,7 @@ private void FileNotFound (LogWindow.LogWindow logWin) private void FileRespawned (LogWindow.LogWindow logWin) { var data = logWin.Tag as LogWindowData; - Icon icon = GetIcon(0, data); + var icon = GetIcon(0, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, icon); } @@ -831,7 +831,7 @@ private void ShowLedPeak (LogWindow.LogWindow logWin) data.DiffSum = DIFF_MAX; } - Icon icon = GetIcon(data.DiffSum, data); + var icon = GetIcon(data.DiffSum, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, icon); } @@ -872,7 +872,7 @@ private void LedThreadProc () lock (_logWindowList) { - foreach (LogWindow.LogWindow logWindow in _logWindowList) + foreach (var logWindow in _logWindowList) { var data = logWindow.Tag as LogWindowData; if (data.DiffSum > 0) @@ -883,7 +883,7 @@ private void LedThreadProc () data.DiffSum = 0; } - Icon icon = GetIcon(data.DiffSum, data); + var icon = GetIcon(data.DiffSum, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); } } @@ -903,7 +903,7 @@ private void SetTabIcon (LogWindow.LogWindow logWindow, Icon icon) private Icon GetIcon (int diff, LogWindowData data) { - Icon icon = + var icon = _ledIcons[ GetLevelFromDiff(diff), data.Dirty ? 1 : 0, Preferences.ShowTailState ? data.TailState : 3, data.SyncMode @@ -978,7 +978,7 @@ private void NotifyWindowsForChangedPrefs (SettingsFlags flags) lock (_logWindowList) { - foreach (LogWindow.LogWindow logWindow in _logWindowList) + foreach (var logWindow in _logWindowList) { logWindow.PreferencesChanged(fontName, fontSize, setLastColumnWidth, lastColumnWidth, false, flags); } @@ -1031,10 +1031,10 @@ private void SetTabIcons (Preferences preferences) CreateIcons(); lock (_logWindowList) { - foreach (LogWindow.LogWindow logWindow in _logWindowList) + foreach (var logWindow in _logWindowList) { var data = logWindow.Tag as LogWindowData; - Icon icon = GetIcon(data.DiffSum, data); + var icon = GetIcon(data.DiffSum, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); } } @@ -1043,18 +1043,15 @@ private void SetTabIcons (Preferences preferences) [SupportedOSPlatform("windows")] private void SetToolIcon (ToolEntry entry, ToolStripItem item) { - Icon icon = NativeMethods.LoadIconFromExe(entry.IconFile, entry.IconIndex); + var icon = NativeMethods.LoadIconFromExe(entry.IconFile, entry.IconIndex); + if (icon != null) { item.Image = icon.ToBitmap(); - if (item is ToolStripMenuItem) - { - item.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; - } - else - { - item.DisplayStyle = ToolStripItemDisplayStyle.Image; - } + + item.DisplayStyle = item is ToolStripMenuItem + ? ToolStripItemDisplayStyle.ImageAndText + : ToolStripItemDisplayStyle.Image; NativeMethods.DestroyIcon(icon.Handle); icon.Dispose(); @@ -1078,8 +1075,8 @@ private void ToolButtonClick (ToolEntry toolEntry) if (CurrentLogWindow != null) { - ILogLine line = CurrentLogWindow.GetCurrentLine(); - ILogFileInfo info = CurrentLogWindow.GetCurrentFileInfo(); + var line = CurrentLogWindow.GetCurrentLine(); + var info = CurrentLogWindow.GetCurrentFileInfo(); if (line != null && info != null) { ArgParser parser = new(toolEntry.Args); @@ -1112,7 +1109,7 @@ private void StartTool (string cmd, string args, bool sysoutPipe, string columni if (sysoutPipe) { - ILogLineColumnizer columnizer = ColumnizerPicker.DecideColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + var columnizer = ColumnizerPicker.DecideColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); _logger.Info("Starting external tool with sysout redirection: {0} {1}", cmd, args); startInfo.UseShellExecute = false; @@ -1131,7 +1128,7 @@ private void StartTool (string cmd, string args, bool sysoutPipe, string columni SysoutPipe pipe = new(process.StandardOutput); - LogWindow.LogWindow logWin = AddTempFileTab(pipe.FileName, + var logWin = AddTempFileTab(pipe.FileName, CurrentLogWindow.IsTempFile ? CurrentLogWindow.TempTitleName : Util.GetNameFromPath(CurrentLogWindow.FileName) + "->E"); @@ -1163,7 +1160,7 @@ private void CloseAllTabs () IList closeList = []; lock (_logWindowList) { - foreach (DockContent content in dockPanel.Contents) + foreach (var content in dockPanel.Contents.Cast()) { if (content is LogWindow.LogWindow window) { @@ -1172,12 +1169,13 @@ private void CloseAllTabs () } } - foreach (Form form in closeList) + foreach (var form in closeList) { form.Close(); } } + //TODO Reimplement private void SetTabColor (LogWindow.LogWindow logWindow, Color color) { //tabPage.BackLowColor = color; @@ -1191,7 +1189,7 @@ private void SetTabColor (LogWindow.LogWindow logWindow, Color color) [SupportedOSPlatform("windows")] private void LoadProject (string projectFileName, bool restoreLayout) { - ProjectData projectData = ProjectPersister.LoadProjectData(projectFileName); + var projectData = ProjectPersister.LoadProjectData(projectFileName); var hasLayoutData = projectData.TabLayoutXml != null; if (hasLayoutData && restoreLayout && _logWindowList.Count > 0) @@ -1259,7 +1257,7 @@ private void FillToolLauncherBar () externalToolsToolStrip.Items.Clear(); var num = 0; externalToolsToolStrip.SuspendLayout(); - foreach (ToolEntry tool in Preferences.ToolEntries) + foreach (var tool in Preferences.ToolEntries) { if (tool.IsFavourite) { @@ -1354,7 +1352,7 @@ private IDockContent DeserializeDockContent (string persistString) if (persistString.StartsWith(WindowTypes.LogWindow.ToString())) { var fileName = persistString[(WindowTypes.LogWindow.ToString().Length + 1)..]; - LogWindow.LogWindow win = FindWindowForFile(fileName); + var win = FindWindowForFile(fileName); if (win != null) { return win; diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index b438a93a..b186b787 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -11,7 +11,6 @@ namespace LogExpert.UI.Entities; //TOOD: This whole class should be refactored and rethought -//TODO: This class should not knoow ConfigManager? internal static class PaintHelper { #region Fields From b9684ac6a592a49001da22cc6184e56d2c8550c5 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Mon, 16 Jun 2025 12:32:47 +0200 Subject: [PATCH 091/142] optimization --- .../EventArguments/BookmarkEventArgs.cs | 4 +- .../EventHandlers/EventHandlers.cs | 6 +- .../Controls/LogWindow/LogWindow.cs | 48 ++------ .../LogWindow/LogWindowEventHandlers.cs | 4 +- .../Controls/LogWindow/LogWindowPrivate.cs | 10 +- .../LogTabWindow/LogTabWindow.designer.cs | 13 +-- .../LogTabWindow/LogTabWindowEventHandlers.cs | 106 +++++++++++------- .../LogTabWindow/LogTabWindowPrivate.cs | 3 +- .../LogTabWindow/LogTabWindowPublic.cs | 26 ++--- src/LogExpert.UI/LogExpert.UI.csproj | 2 - 10 files changed, 109 insertions(+), 113 deletions(-) diff --git a/src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs b/src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs index 869b34be..d2156111 100644 --- a/src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs +++ b/src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs @@ -1,8 +1,8 @@ -using LogExpert.Core.Entities; +using LogExpert.Core.Entities; namespace LogExpert.Core.EventArguments; -public class BookmarkEventArgs(Bookmark bookmark) : System.EventArgs +public class BookmarkEventArgs (Bookmark bookmark) : EventArgs { #region Properties diff --git a/src/LogExpert.Core/EventHandlers/EventHandlers.cs b/src/LogExpert.Core/EventHandlers/EventHandlers.cs index 63f44923..e9af888e 100644 --- a/src/LogExpert.Core/EventHandlers/EventHandlers.cs +++ b/src/LogExpert.Core/EventHandlers/EventHandlers.cs @@ -1,7 +1,7 @@ -using LogExpert.Core.Entities; +using LogExpert.Core.Entities; using LogExpert.Core.EventArguments; namespace LogExpert.Core.EventHandlers; -public delegate void ConfigChangedEventHandler(object sender, ConfigChangedEventArgs e); -public delegate void FileSizeChangedEventHandler(object sender, LogEventArgs e); +public delegate void ConfigChangedEventHandler (object sender, ConfigChangedEventArgs e); +public delegate void FileSizeChangedEventHandler (object sender, LogEventArgs e); diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index eb2c9b96..e0296d67 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -263,37 +263,13 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp #region Delegates - public delegate void BookmarkAddedEventHandler (object sender, EventArgs e); - - public delegate void BookmarkRemovedEventHandler (object sender, EventArgs e); - - public delegate void BookmarkTextChangedEventHandler (object sender, BookmarkEventArgs e); - - public delegate void ColumnizerChangedEventHandler (object sender, ColumnizerEventArgs e); - - public delegate void CurrentHighlightGroupChangedEventHandler (object sender, CurrentHighlightGroupChangedEventArgs e); - - public delegate void FileNotFoundEventHandler (object sender, EventArgs e); - - public delegate void FileRespawnedEventHandler (object sender, EventArgs e); - - public delegate void FilterListChangedEventHandler (object sender, FilterListChangedEventArgs e); - // used for filterTab restore public delegate void FilterRestoreFx (LogWindow newWin, PersistenceData persistenceData); - public delegate void GuiStateEventHandler (object sender, GuiStateArgs e); - - public delegate void ProgressBarEventHandler (object sender, ProgressEventArgs e); - public delegate void RestoreFiltersFx (PersistenceData persistenceData); public delegate bool ScrollToTimestampFx (DateTime timestamp, bool roundToSeconds, bool triggerSyncCall); - public delegate void StatusLineEventHandler (object sender, StatusLineEventArgs e); - - public delegate void SyncModeChangedEventHandler (object sender, SyncModeEventArgs e); - public delegate void TailFollowedEventHandler (object sender, EventArgs e); #endregion @@ -302,31 +278,31 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp public event FileSizeChangedEventHandler FileSizeChanged; - public event ProgressBarEventHandler ProgressBarUpdate; + public event EventHandler ProgressBarUpdate; - public event StatusLineEventHandler StatusLineEvent; + public event EventHandler StatusLineEvent; - public event GuiStateEventHandler GuiStateUpdate; + public event EventHandler GuiStateUpdate; public event TailFollowedEventHandler TailFollowed; - public event FileNotFoundEventHandler FileNotFound; + public event EventHandler FileNotFound; - public event FileRespawnedEventHandler FileRespawned; + public event EventHandler FileRespawned; - public event FilterListChangedEventHandler FilterListChanged; + public event EventHandler FilterListChanged; - public event CurrentHighlightGroupChangedEventHandler CurrentHighlightGroupChanged; + public event EventHandler CurrentHighlightGroupChanged; - public event BookmarkAddedEventHandler BookmarkAdded; + public event EventHandler BookmarkAdded; - public event BookmarkRemovedEventHandler BookmarkRemoved; + public event EventHandler BookmarkRemoved; - public event BookmarkTextChangedEventHandler BookmarkTextChanged; + public event EventHandler BookmarkTextChanged; - public event ColumnizerChangedEventHandler ColumnizerChanged; + public event EventHandler ColumnizerChanged; - public event SyncModeChangedEventHandler SyncModeChanged; + public event EventHandler SyncModeChanged; #endregion diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs index 245a18e7..75941c23 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs @@ -67,12 +67,12 @@ protected void OnCurrentHighlightListChanged () protected void OnBookmarkAdded () { - BookmarkAdded?.Invoke(this, EventArgs.Empty); + BookmarkAdded?.Invoke(this, (BookmarkEventArgs)EventArgs.Empty); } protected void OnBookmarkRemoved () { - BookmarkRemoved?.Invoke(this, EventArgs.Empty); + BookmarkRemoved?.Invoke(this, (BookmarkEventArgs)EventArgs.Empty); } protected void OnBookmarkTextChanged (Bookmark bookmark) diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs index b972f7a3..2fe5aa81 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs @@ -59,13 +59,13 @@ private void CreateDefaultViewStyle () dataGridViewCellStyleMainGrid.Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); dataGridViewCellStyleMainGrid.ForeColor = SystemColors.ControlText; dataGridViewCellStyleMainGrid.SelectionBackColor = SystemColors.Highlight; - dataGridViewCellStyleMainGrid.SelectionForeColor = SystemColors.HighlightText; + //dataGridViewCellStyleMainGrid.SelectionForeColor = SystemColors.HighlightText; var highlightColor = SystemColors.Highlight; //Color is smaller than 128, means its darker - var isDark = (highlightColor.R * 0.2126) + (highlightColor.G * 0.7152) + (highlightColor.B * 0.0722) < 255 / 2; + var isSelectionBackColorDark = (highlightColor.R * 0.2126) + (highlightColor.G * 0.7152) + (highlightColor.B * 0.0722) < 255 / 2; - if (isDark) + if (isSelectionBackColorDark) { dataGridViewCellStyleMainGrid.SelectionForeColor = Color.White; } @@ -83,9 +83,9 @@ private void CreateDefaultViewStyle () dataGridViewCellStyleFilterGrid.Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); dataGridViewCellStyleFilterGrid.ForeColor = SystemColors.ControlText; dataGridViewCellStyleFilterGrid.SelectionBackColor = SystemColors.Highlight; - dataGridViewCellStyleFilterGrid.SelectionForeColor = SystemColors.HighlightText; + //dataGridViewCellStyleFilterGrid.SelectionForeColor = SystemColors.HighlightText; - if (isDark) + if (isSelectionBackColorDark) { dataGridViewCellStyleFilterGrid.SelectionForeColor = Color.White; } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs index 88684eb7..6dc8e85e 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs @@ -173,7 +173,7 @@ private void InitializeComponent() statusStrip.Location = new System.Drawing.Point(0, 954); statusStrip.Name = "statusStrip"; statusStrip.Padding = new Padding(3, 0, 23, 0); - statusStrip.Size = new System.Drawing.Size(1603, 63); + statusStrip.Size = new System.Drawing.Size(1603, 35); statusStrip.SizingGrip = false; statusStrip.TabIndex = 5; statusStrip.Text = "statusStrip1"; @@ -184,7 +184,7 @@ private void InitializeComponent() labelLines.BorderSides = ToolStripStatusLabelBorderSides.Left | ToolStripStatusLabelBorderSides.Top | ToolStripStatusLabelBorderSides.Right | ToolStripStatusLabelBorderSides.Bottom; labelLines.BorderStyle = Border3DStyle.SunkenOuter; labelLines.Name = "labelLines"; - labelLines.Size = new System.Drawing.Size(26, 58); + labelLines.Size = new System.Drawing.Size(26, 35); labelLines.Text = "0"; // // labelSize @@ -193,7 +193,7 @@ private void InitializeComponent() labelSize.BorderSides = ToolStripStatusLabelBorderSides.Left | ToolStripStatusLabelBorderSides.Top | ToolStripStatusLabelBorderSides.Right | ToolStripStatusLabelBorderSides.Bottom; labelSize.BorderStyle = Border3DStyle.SunkenOuter; labelSize.Name = "labelSize"; - labelSize.Size = new System.Drawing.Size(26, 58); + labelSize.Size = new System.Drawing.Size(26, 35); labelSize.Text = "0"; // // labelCurrentLine @@ -202,18 +202,18 @@ private void InitializeComponent() labelCurrentLine.BorderSides = ToolStripStatusLabelBorderSides.Left | ToolStripStatusLabelBorderSides.Top | ToolStripStatusLabelBorderSides.Right | ToolStripStatusLabelBorderSides.Bottom; labelCurrentLine.BorderStyle = Border3DStyle.SunkenOuter; labelCurrentLine.Name = "labelCurrentLine"; - labelCurrentLine.Size = new System.Drawing.Size(28, 58); + labelCurrentLine.Size = new System.Drawing.Size(28, 35); labelCurrentLine.Text = "L:"; // // loadProgessBar // loadProgessBar.Name = "loadProgessBar"; - loadProgessBar.Size = new System.Drawing.Size(83, 57); + loadProgessBar.Size = new System.Drawing.Size(83, 35); // // labelStatus // labelStatus.Name = "labelStatus"; - labelStatus.Size = new System.Drawing.Size(39, 58); + labelStatus.Size = new System.Drawing.Size(39, 35); labelStatus.Text = "Ready"; // // mainMenuStrip @@ -833,7 +833,6 @@ private void InitializeComponent() dockPanel.Dock = DockStyle.Fill; dockPanel.DockBackColor = System.Drawing.SystemColors.Control; dockPanel.DocumentStyle = DocumentStyle.DockingWindow; - dockPanel.ForeColor = System.Drawing.SystemColors.Control; dockPanel.Location = new System.Drawing.Point(0, 0); dockPanel.Margin = new Padding(0); dockPanel.Name = "dockPanel"; diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs index 16e7ed7e..09c742e3 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs @@ -44,7 +44,7 @@ private void OnLogTabWindowLoad (object sender, EventArgs e) if (ConfigManager.Settings.Preferences.OpenLastFiles && _startupFileNames == null) { - List tmpList = ObjectClone.Clone(ConfigManager.Settings.LastOpenFilesList); + var tmpList = ObjectClone.Clone(ConfigManager.Settings.LastOpenFilesList); foreach (var name in tmpList) { @@ -54,12 +54,16 @@ private void OnLogTabWindowLoad (object sender, EventArgs e) } } } + if (_startupFileNames != null) { LoadFiles(_startupFileNames, false); } - _ledThread = new Thread(LedThreadProc); - _ledThread.IsBackground = true; + + _ledThread = new Thread(LedThreadProc) + { + IsBackground = true + }; _ledThread.Start(); FillHighlightComboBox(); @@ -78,16 +82,16 @@ private void OnLogTabWindowClosing (object sender, CancelEventArgs e) _statusLineEventWakeupHandle.Set(); _ledThread.Join(); - IList deleteLogWindowList = new List(); + IList deleteLogWindowList = []; ConfigManager.Settings.AlwaysOnTop = TopMost && ConfigManager.Settings.Preferences.AllowOnlyOneInstance; SaveLastOpenFilesList(); - foreach (LogWindow.LogWindow logWindow in _logWindowList) + foreach (var logWindow in _logWindowList) { deleteLogWindowList.Add(logWindow); } - foreach (LogWindow.LogWindow logWindow in deleteLogWindowList) + foreach (var logWindow in deleteLogWindowList) { RemoveAndDisposeLogWindow(logWindow, true); } @@ -153,10 +157,12 @@ private void OnSelectFilterToolStripMenuItemClick (object sender, EventArgs e) } CurrentLogWindow.ColumnizerCallbackObject.LineNum = CurrentLogWindow.GetCurrentLineNum(); - FilterSelectorForm form = new(PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers, CurrentLogWindow.CurrentColumnizer, CurrentLogWindow.ColumnizerCallbackObject, ConfigManager); - form.Owner = this; - form.TopMost = TopMost; - DialogResult res = form.ShowDialog(); + FilterSelectorForm form = new(PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers, CurrentLogWindow.CurrentColumnizer, CurrentLogWindow.ColumnizerCallbackObject, ConfigManager) + { + Owner = this, + TopMost = TopMost + }; + var res = form.ShowDialog(); if (res == DialogResult.OK) { @@ -164,7 +170,7 @@ private void OnSelectFilterToolStripMenuItemClick (object sender, EventArgs e) { lock (_logWindowList) { - foreach (LogWindow.LogWindow logWindow in _logWindowList) + foreach (var logWindow in _logWindowList) { if (logWindow.CurrentColumnizer.GetType() != form.SelectedColumnizer.GetType()) { @@ -196,7 +202,7 @@ private void OnSelectFilterToolStripMenuItemClick (object sender, EventArgs e) { lock (_logWindowList) { - foreach (LogWindow.LogWindow logWindow in _logWindowList) + foreach (var logWindow in _logWindowList) { if (logWindow.CurrentColumnizer.GetType() == form.SelectedColumnizer.GetType()) { @@ -217,7 +223,7 @@ private void OnGoToLineToolStripMenuItemClick (object sender, EventArgs e) } GotoLineDialog dlg = new(this); - DialogResult res = dlg.ShowDialog(); + var res = dlg.ShowDialog(); if (res == DialogResult.OK) { var line = dlg.Line - 1; @@ -253,7 +259,8 @@ private void OnLogTabWindowDragEnter (object sender, DragEventArgs e) s += format; s += " , "; } - s = s.Substring(0, s.Length - 3); + + s = s[..^3]; _logger.Info(s); #endif } @@ -280,6 +287,7 @@ private void OnLogWindowDragDrop (object sender, DragEventArgs e) s += format; s += " , "; } + s = s[..^3]; _logger.Debug(s); #endif @@ -310,8 +318,11 @@ private void OnTimeShiftToolStripMenuItemCheckStateChanged (object sender, Event [SupportedOSPlatform("windows")] private void OnAboutToolStripMenuItemClick (object sender, EventArgs e) { - AboutBox aboutBox = new(); - aboutBox.TopMost = TopMost; + AboutBox aboutBox = new() + { + TopMost = TopMost + }; + aboutBox.ShowDialog(); } @@ -338,7 +349,7 @@ private void OnColumnizerChanged (object sender, ColumnizerEventArgs e) _bookmarkWindow?.SetColumnizer(e.Columnizer); } - private void OnBookmarkAdded (object sender, EventArgs e) + private void OnBookmarkAdded (object sender, BookmarkEventArgs e) { _bookmarkWindow.UpdateView(); } @@ -348,7 +359,7 @@ private void OnBookmarkTextChanged (object sender, BookmarkEventArgs e) _bookmarkWindow.BookmarkTextChanged(e.Bookmark); } - private void OnBookmarkRemoved (object sender, EventArgs e) + private void OnBookmarkRemoved (object sender, BookmarkEventArgs e) { _bookmarkWindow.UpdateView(); } @@ -448,7 +459,7 @@ private void OnFileSizeChanged (object sender, LogEventArgs e) { data.Dirty = true; } - Icon icon = GetIcon(diff, data); + var icon = GetIcon(diff, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); } } @@ -468,7 +479,7 @@ private void OnLogWindowFilterListChanged (object sender, FilterListChangedEvent { lock (_logWindowList) { - foreach (LogWindow.LogWindow logWindow in _logWindowList) + foreach (var logWindow in _logWindowList) { if (logWindow != e.LogWindow) { @@ -498,7 +509,7 @@ private void OnTailFollowed (object sender, EventArgs e) { var data = ((LogWindow.LogWindow)sender).Tag as LogWindowData; data.Dirty = false; - Icon icon = GetIcon(data.DiffSum, data); + var icon = GetIcon(data.DiffSum, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); } } @@ -511,7 +522,7 @@ private void OnLogWindowSyncModeChanged (object sender, SyncModeEventArgs e) { var data = ((LogWindow.LogWindow)sender).Tag as LogWindowData; data.SyncMode = e.IsTimeSynced ? 1 : 0; - Icon icon = GetIcon(data.DiffSum, data); + var icon = GetIcon(data.DiffSum, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); } else @@ -574,7 +585,7 @@ private void OnReloadToolStripMenuItemClick (object sender, EventArgs e) if (CurrentLogWindow != null) { var data = CurrentLogWindow.Tag as LogWindowData; - Icon icon = GetIcon(0, data); + var icon = GetIcon(0, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), CurrentLogWindow, icon); CurrentLogWindow.Reload(); } @@ -680,7 +691,7 @@ private void OnHideLineColumnToolStripMenuItemClick (object sender, EventArgs e) ConfigManager.Settings.HideLineColumn = hideLineColumnToolStripMenuItem.Checked; lock (_logWindowList) { - foreach (LogWindow.LogWindow logWin in _logWindowList) + foreach (var logWin in _logWindowList) { logWin.ShowLineColumn(!ConfigManager.Settings.HideLineColumn); } @@ -708,11 +719,12 @@ private void OnCloseOtherTabsToolStripMenuItemClick (object sender, EventArgs e) { if (content != dockPanel.ActiveContent && content is LogWindow.LogWindow) { - closeList.Add(content as Form); + closeList.Add(content); } } } - foreach (Form form in closeList) + + foreach (var form in closeList) { form.Close(); } @@ -729,15 +741,16 @@ private void OnTabColorToolStripMenuItemClick (object sender, EventArgs e) { var logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; - var data = logWindow.Tag as LogWindowData; - - if (data == null) + if (logWindow.Tag is not LogWindowData data) { return; } - ColorDialog dlg = new(); - dlg.Color = data.Color; + ColorDialog dlg = new() + { + Color = data.Color + }; + if (dlg.ShowDialog() == DialogResult.OK) { data.Color = dlg.Color; @@ -745,7 +758,7 @@ private void OnTabColorToolStripMenuItemClick (object sender, EventArgs e) } List delList = []; - foreach (ColorEntry entry in ConfigManager.Settings.FileColors) + foreach (var entry in ConfigManager.Settings.FileColors) { if (entry.FileName.Equals(logWindow.FileName, StringComparison.Ordinal)) { @@ -753,10 +766,11 @@ private void OnTabColorToolStripMenuItemClick (object sender, EventArgs e) } } - foreach (ColorEntry entry in delList) + foreach (var entry in delList) { ConfigManager.Settings.FileColors.Remove(entry); } + ConfigManager.Settings.FileColors.Add(new ColorEntry(logWindow.FileName, dlg.Color)); while (ConfigManager.Settings.FileColors.Count > MAX_COLOR_HISTORY) @@ -777,9 +791,11 @@ private void OnLogTabWindowSizeChanged (object sender, EventArgs e) [SupportedOSPlatform("windows")] private void OnSaveProjectToolStripMenuItemClick (object sender, EventArgs e) { - SaveFileDialog dlg = new(); - dlg.DefaultExt = "lxj"; - dlg.Filter = @"LogExpert session (*.lxj)|*.lxj"; + SaveFileDialog dlg = new() + { + DefaultExt = "lxj", + Filter = @"LogExpert session (*.lxj)|*.lxj" + }; if (dlg.ShowDialog() == DialogResult.OK) { @@ -799,9 +815,11 @@ private void OnSaveProjectToolStripMenuItemClick (object sender, EventArgs e) } } - ProjectData projectData = new(); - projectData.MemberList = fileNames; - projectData.TabLayoutXml = SaveLayout(); + ProjectData projectData = new() + { + MemberList = fileNames, + TabLayoutXml = SaveLayout() + }; ProjectPersister.SaveProjectData(fileName, projectData); } } @@ -809,9 +827,11 @@ private void OnSaveProjectToolStripMenuItemClick (object sender, EventArgs e) [SupportedOSPlatform("windows")] private void OnLoadProjectToolStripMenuItemClick (object sender, EventArgs e) { - OpenFileDialog dlg = new(); - dlg.DefaultExt = "lxj"; - dlg.Filter = @"LogExpert sessions (*.lxj)|*.lxj"; + OpenFileDialog dlg = new() + { + DefaultExt = "lxj", + Filter = @"LogExpert sessions (*.lxj)|*.lxj" + }; if (dlg.ShowDialog() == DialogResult.OK) { @@ -1073,10 +1093,12 @@ private void OnTabRenameToolStripMenuItemClick (object sender, EventArgs e) { TabName = CurrentLogWindow.Text }; + if (DialogResult.OK == dlg.ShowDialog()) { CurrentLogWindow.Text = dlg.TabName; } + dlg.Dispose(); } } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs index 886052ac..da31f049 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs @@ -685,6 +685,7 @@ private void ProgressBarUpdateWorker (ProgressEventArgs e) } [SupportedOSPlatform("windows")] + //TODO Crossthread Exception when a log file has been filtered to a new tab! private void StatusLineEventWorker (StatusLineEventArgs e) { if (e != null) @@ -1160,7 +1161,7 @@ private void CloseAllTabs () IList closeList = []; lock (_logWindowList) { - foreach (var content in dockPanel.Contents.Cast()) + foreach (DockContent content in dockPanel.Contents) { if (content is LogWindow.LogWindow window) { diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs index 56d639ce..3751f2eb 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs @@ -28,7 +28,7 @@ public LogWindow.LogWindow AddTempFileTab (string fileName, string title) [SupportedOSPlatform("windows")] public LogWindow.LogWindow AddFilterTab (FilterPipe pipe, string title, ILogLineColumnizer preProcessColumnizer) { - LogWindow.LogWindow logWin = AddFileTab(pipe.FileName, true, title, false, preProcessColumnizer); + var logWin = AddFileTab(pipe.FileName, true, title, false, preProcessColumnizer); if (pipe.FilterParams.SearchText.Length > 0) { ToolTip tip = new(components); @@ -58,7 +58,7 @@ public LogWindow.LogWindow AddFileTabDeferred (string givenFileName, bool isTemp public LogWindow.LogWindow AddFileTab (string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer, bool doNotAddToDockPanel = false) { var logFileName = FindFilenameForSettings(givenFileName); - LogWindow.LogWindow win = FindWindowForFile(logFileName); + var win = FindWindowForFile(logFileName); if (win != null) { if (!isTempFile) @@ -100,7 +100,7 @@ public LogWindow.LogWindow AddFileTab (string givenFileName, bool isTempFile, st //data.tabPage.BorderColor = this.defaultTabBorderColor; if (!isTempFile) { - foreach (ColorEntry colorEntry in ConfigManager.Settings.FileColors) + foreach (var colorEntry in ConfigManager.Settings.FileColors) { if (colorEntry.FileName.ToUpperInvariant().Equals(logFileName.ToUpperInvariant(), StringComparison.Ordinal)) { @@ -164,7 +164,7 @@ public void OpenSearchDialog () dlg.TopMost = TopMost; SearchParams.HistoryList = ConfigManager.Settings.SearchHistoryList; dlg.SearchParams = SearchParams; - DialogResult res = dlg.ShowDialog(); + var res = dlg.ShowDialog(); if (res == DialogResult.OK && dlg.SearchParams != null && !string.IsNullOrWhiteSpace(dlg.SearchParams.SearchText)) { SearchParams = dlg.SearchParams; @@ -175,10 +175,10 @@ public void OpenSearchDialog () public ILogLineColumnizer GetColumnizerHistoryEntry (string fileName) { - ColumnizerHistoryEntry entry = FindColumnizerHistoryEntry(fileName); + var entry = FindColumnizerHistoryEntry(fileName); if (entry != null) { - foreach (ILogLineColumnizer columnizer in PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers) + foreach (var columnizer in PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers) { if (columnizer.GetName().Equals(entry.ColumnizerName, StringComparison.Ordinal)) { @@ -227,7 +227,7 @@ public void ScrollAllTabsToTimestamp (DateTime timestamp, LogWindow.LogWindow se { lock (_logWindowList) { - foreach (LogWindow.LogWindow logWindow in _logWindowList) + foreach (var logWindow in _logWindowList) { if (logWindow != senderWindow) { @@ -242,7 +242,7 @@ public void ScrollAllTabsToTimestamp (DateTime timestamp, LogWindow.LogWindow se public ILogLineColumnizer FindColumnizerByFileMask (string fileName) { - foreach (ColumnizerMaskEntry entry in ConfigManager.Settings.Preferences.ColumnizerMaskList) + foreach (var entry in ConfigManager.Settings.Preferences.ColumnizerMaskList) { if (entry.Mask != null) { @@ -250,7 +250,7 @@ public ILogLineColumnizer FindColumnizerByFileMask (string fileName) { if (Regex.IsMatch(fileName, entry.Mask)) { - ILogLineColumnizer columnizer = ColumnizerPicker.FindColumnizerByName(entry.ColumnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + var columnizer = ColumnizerPicker.FindColumnizerByName(entry.ColumnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); return columnizer; } } @@ -267,7 +267,7 @@ public ILogLineColumnizer FindColumnizerByFileMask (string fileName) public HighlightGroup FindHighlightGroupByFileMask (string fileName) { - foreach (HighlightMaskEntry entry in ConfigManager.Settings.Preferences.HighlightMaskList) + foreach (var entry in ConfigManager.Settings.Preferences.HighlightMaskList) { if (entry.Mask != null) { @@ -275,7 +275,7 @@ public HighlightGroup FindHighlightGroupByFileMask (string fileName) { if (Regex.IsMatch(fileName, entry.Mask)) { - HighlightGroup group = FindHighlightGroup(entry.HighlightGroupName); + var group = FindHighlightGroup(entry.HighlightGroupName); return group; } } @@ -332,7 +332,7 @@ public void FollowTailChanged (LogWindow.LogWindow logWindow, bool isEnabled, bo if (Preferences.ShowTailState) { - Icon icon = GetIcon(data.DiffSum, data); + var icon = GetIcon(data.DiffSum, data); BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); } } @@ -351,7 +351,7 @@ public IList GetListOfOpenFiles () IList list = []; lock (_logWindowList) { - foreach (LogWindow.LogWindow logWindow in _logWindowList) + foreach (var logWindow in _logWindowList) { list.Add(new WindowFileEntry(logWindow)); } diff --git a/src/LogExpert.UI/LogExpert.UI.csproj b/src/LogExpert.UI/LogExpert.UI.csproj index 145fbbc4..396fd4a3 100644 --- a/src/LogExpert.UI/LogExpert.UI.csproj +++ b/src/LogExpert.UI/LogExpert.UI.csproj @@ -26,9 +26,7 @@ - - From fadcd9a3769198cad7cb088b12ca609e572292cc Mon Sep 17 00:00:00 2001 From: Hirogen Date: Mon, 16 Jun 2025 12:58:24 +0200 Subject: [PATCH 092/142] made splitter moveable, for higher dpi or different Screens --- .../Controls/LogWindow/LogWindow.cs | 2 +- .../Controls/LogWindow/LogWindow.designer.cs | 34 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index e0296d67..0727db36 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -30,7 +30,7 @@ internal partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, IL private const int SPREAD_MAX = 99; private const int PROGRESS_BAR_MODULO = 1000; - private const int FILTER_ADVANCED_SPLITTER_DISTANCE = 150; + private const int FILTER_ADVANCED_SPLITTER_DISTANCE = 110; private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); private readonly Image _advancedButtonImage; diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs index c49e42bf..2aceb815 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs @@ -32,10 +32,10 @@ protected override void Dispose(bool disposing) /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// - private void InitializeComponent() + private void InitializeComponent () { components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LogWindow)); + var resources = new System.ComponentModel.ComponentResourceManager(typeof(LogWindow)); splitContainerLogWindow = new SplitContainer(); tableLayoutPanel1 = new TableLayoutPanel(); columnFinderPanel = new Panel(); @@ -439,7 +439,6 @@ private void InitializeComponent() // advancedFilterSplitContainer // advancedFilterSplitContainer.Dock = DockStyle.Fill; - advancedFilterSplitContainer.IsSplitterFixed = true; advancedFilterSplitContainer.Location = new Point(0, 0); advancedFilterSplitContainer.Margin = new Padding(0); advancedFilterSplitContainer.Name = "advancedFilterSplitContainer"; @@ -448,14 +447,15 @@ private void InitializeComponent() // advancedFilterSplitContainer.Panel1 // advancedFilterSplitContainer.Panel1.Controls.Add(pnlProFilter); - advancedFilterSplitContainer.Panel1MinSize = 100; + advancedFilterSplitContainer.Panel1MinSize = 50; // // advancedFilterSplitContainer.Panel2 // advancedFilterSplitContainer.Panel2.Controls.Add(panelBackgroundAdvancedFilterSplitContainer); - advancedFilterSplitContainer.Panel2MinSize = 200; + advancedFilterSplitContainer.Panel2MinSize = 50; advancedFilterSplitContainer.Size = new Size(1855, 561); - advancedFilterSplitContainer.SplitterDistance = 124; + advancedFilterSplitContainer.SplitterDistance = 110; + advancedFilterSplitContainer.Panel2Collapsed = true; advancedFilterSplitContainer.SplitterWidth = 2; advancedFilterSplitContainer.TabIndex = 2; // @@ -478,7 +478,7 @@ private void InitializeComponent() pnlProFilter.Controls.Add(btnFilterToTab); pnlProFilter.Location = new Point(0, 3); pnlProFilter.Name = "pnlProFilter"; - pnlProFilter.Size = new Size(1852, 117); + pnlProFilter.Size = new Size(1852, 80); pnlProFilter.TabIndex = 0; // // columnButton @@ -575,7 +575,7 @@ private void InitializeComponent() // // pnlProFilterLabel // - pnlProFilterLabel.BackgroundImage = LogExpert.Resources.Resources.Pro_Filter; + pnlProFilterLabel.BackgroundImage = (Image)resources.GetObject("pnlProFilterLabel.BackgroundImage"); pnlProFilterLabel.BackgroundImageLayout = ImageLayout.Center; pnlProFilterLabel.Location = new Point(5, 7); pnlProFilterLabel.Name = "pnlProFilterLabel"; @@ -646,13 +646,13 @@ private void InitializeComponent() panelBackgroundAdvancedFilterSplitContainer.Dock = DockStyle.Fill; panelBackgroundAdvancedFilterSplitContainer.Location = new Point(0, 0); panelBackgroundAdvancedFilterSplitContainer.Name = "panelBackgroundAdvancedFilterSplitContainer"; - panelBackgroundAdvancedFilterSplitContainer.Size = new Size(1855, 435); + panelBackgroundAdvancedFilterSplitContainer.Size = new Size(1855, 474); panelBackgroundAdvancedFilterSplitContainer.TabIndex = 7; // // btnToggleHighlightPanel // btnToggleHighlightPanel.Anchor = AnchorStyles.Top | AnchorStyles.Right; - btnToggleHighlightPanel.Image = LogExpert.Resources.Resources.Arrow_menu_open; + btnToggleHighlightPanel.Image = (Image)resources.GetObject("btnToggleHighlightPanel.Image"); btnToggleHighlightPanel.Location = new Point(1832, 1); btnToggleHighlightPanel.Name = "btnToggleHighlightPanel"; btnToggleHighlightPanel.Size = new Size(20, 21); @@ -679,7 +679,7 @@ private void InitializeComponent() // highlightSplitContainer.Panel2.Controls.Add(highlightSplitContainerBackPanel); highlightSplitContainer.Panel2MinSize = 350; - highlightSplitContainer.Size = new Size(1829, 432); + highlightSplitContainer.Size = new Size(1829, 471); highlightSplitContainer.SplitterDistance = 1475; highlightSplitContainer.TabIndex = 2; // @@ -713,7 +713,7 @@ private void InitializeComponent() filterGridView.ShowCellToolTips = false; filterGridView.ShowEditingIcon = false; filterGridView.ShowRowErrors = false; - filterGridView.Size = new Size(1473, 430); + filterGridView.Size = new Size(1473, 469); filterGridView.TabIndex = 1; filterGridView.VirtualMode = true; filterGridView.CellContextMenuStripNeeded += OnFilterGridViewCellContextMenuStripNeeded; @@ -765,7 +765,7 @@ private void InitializeComponent() highlightSplitContainerBackPanel.Dock = DockStyle.Fill; highlightSplitContainerBackPanel.Location = new Point(0, 0); highlightSplitContainerBackPanel.Name = "highlightSplitContainerBackPanel"; - highlightSplitContainerBackPanel.Size = new Size(348, 430); + highlightSplitContainerBackPanel.Size = new Size(348, 469); highlightSplitContainerBackPanel.TabIndex = 1; // // hideFilterListOnLoadCheckBox @@ -782,7 +782,7 @@ private void InitializeComponent() // // filterDownButton // - filterDownButton.BackgroundImage = LogExpert.Resources.Resources.ArrowDown; + filterDownButton.BackgroundImage = (Image)resources.GetObject("filterDownButton.BackgroundImage"); filterDownButton.BackgroundImageLayout = ImageLayout.Stretch; filterDownButton.Location = new Point(296, 85); filterDownButton.Name = "filterDownButton"; @@ -795,7 +795,7 @@ private void InitializeComponent() // // filterUpButton // - filterUpButton.BackgroundImage = LogExpert.Resources.Resources.ArrowUp; + filterUpButton.BackgroundImage = (Image)resources.GetObject("filterUpButton.BackgroundImage"); filterUpButton.BackgroundImageLayout = ImageLayout.Stretch; filterUpButton.Location = new Point(258, 85); filterUpButton.Name = "filterUpButton"; @@ -850,7 +850,7 @@ private void InitializeComponent() filterListBox.ItemHeight = 25; filterListBox.Location = new Point(0, 0); filterListBox.Name = "filterListBox"; - filterListBox.Size = new Size(252, 430); + filterListBox.Size = new Size(252, 469); filterListBox.TabIndex = 0; helpToolTip.SetToolTip(filterListBox, "Doubleclick to load a saved filter"); filterListBox.DrawItem += OnFilterListBoxDrawItem; @@ -1034,7 +1034,7 @@ private void InitializeComponent() columnContextMenuStrip.ImageScalingSize = new Size(24, 24); columnContextMenuStrip.Items.AddRange(new ToolStripItem[] { freezeLeftColumnsUntilHereToolStripMenuItem, menuToolStripSeparator4, moveToLastColumnToolStripMenuItem, moveLeftToolStripMenuItem, moveRightToolStripMenuItem, menuToolStripSeparator5, hideColumnToolStripMenuItem, restoreColumnsToolStripMenuItem, menuToolStripSeparator6, allColumnsToolStripMenuItem }); columnContextMenuStrip.Name = "columnContextMenuStrip"; - columnContextMenuStrip.Size = new Size(230, 198); + columnContextMenuStrip.Size = new Size(230, 176); columnContextMenuStrip.Opening += OnColumnContextMenuStripOpening; // // freezeLeftColumnsUntilHereToolStripMenuItem From caa6e3ac410d3f930c242bd437636e59b8608d5b Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Mon, 16 Jun 2025 19:47:40 +0300 Subject: [PATCH 093/142] Changed a bit the logic of messages when sending IPC messages --- src/LogExpert/Program.cs | 57 +++++++++++++++------------------------- 1 file changed, 21 insertions(+), 36 deletions(-) diff --git a/src/LogExpert/Program.cs b/src/LogExpert/Program.cs index 3d1fa218..53d6678a 100644 --- a/src/LogExpert/Program.cs +++ b/src/LogExpert/Program.cs @@ -88,7 +88,7 @@ private static void Main(string[] args) // first application instance Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - ILogTabWindow logWin = AbstractLogTabWindow.Create(absoluteFilePaths.Length > 0 ? absoluteFilePaths : null, 1, false, ConfigManager.Instance); + var logWin = AbstractLogTabWindow.Create(absoluteFilePaths.Length > 0 ? absoluteFilePaths : null, 1, false, ConfigManager.Instance); // first instance var wi = WindowsIdentity.GetCurrent(); @@ -194,48 +194,33 @@ private static string[] GenerateAbsoluteFilePaths(string[] remainingArgs) private static void SendMessageToProxy(IpcMessage message, LogExpertProxy proxy) { - //TODO: REFACTOR - switch (message.Type) - { - case IpcMessageType.Load: - { - var payLoad = message.Payload.ToObject(); + var payLoad = message.Payload.ToObject(); - if (CheckPayload(payLoad)) - { - proxy.LoadFiles([.. payLoad.Files]); - } - } - break; - case IpcMessageType.NewWindow: - { - var payLoad = message.Payload.ToObject(); - if (CheckPayload(payLoad)) - { - proxy.NewWindow([.. payLoad.Files]); - } - } - break; - case IpcMessageType.NewWindowOrLockedWindow: - { - var payLoad = message.Payload.ToObject(); - if (CheckPayload(payLoad)) - { - proxy.NewWindowOrLockedWindow([.. payLoad.Files]); - } - } - break; - default: - _logger.Error($"Unknown IPC Message Type {message.Type}"); - break; + if (CheckPayload(payLoad)) + { + switch (message.Type) + { + case IpcMessageType.Load: + proxy.LoadFiles([.. payLoad.Files]); + break; + case IpcMessageType.NewWindow: + proxy.NewWindow([.. payLoad.Files]); + break; + case IpcMessageType.NewWindowOrLockedWindow: + proxy.NewWindowOrLockedWindow([.. payLoad.Files]); + break; + default: + _logger.Error($"Unknown IPC Message Type: {message.Type}; with payload: {payLoad}"); + break; + } } } - private static bool CheckPayload(LoadPayload payLoad) + private static bool CheckPayload (LoadPayload payLoad) { if (payLoad == null) { - _logger.Error("Invalid payload for NewWindow command"); + _logger.Error("Invalid payload command: null"); return false; } From 4d9b4c119da5cbd8b320ad0d6536ccef43400670 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Mon, 16 Jun 2025 20:35:22 +0300 Subject: [PATCH 094/142] CR change --- src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs b/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs index 912201d4..ae276817 100644 --- a/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs +++ b/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs @@ -1,3 +1,4 @@ +using System; using System.Globalization; using System.Text; using System.Text.RegularExpressions; @@ -147,7 +148,7 @@ private void ParseFormatString (string formatString) if (endPos != -1) { _dateTimeFormat = formatString.Substring(datePos + 3, endPos - datePos - 3) - .ToUpper(CultureInfo.InvariantCulture) + .ToUpperInvariant() .Replace('D', 'd') .Replace('Y', 'y'); From e7e1bef801bd151b43fd02b7a4f03893a4c74ba5 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Mon, 16 Jun 2025 20:32:24 +0200 Subject: [PATCH 095/142] update after review --- src/LogExpert.Core/Config/ColorEntry.cs | 10 +-- .../EventArguments/BookmarkEventArgs.cs | 13 ++- src/LogExpert.UI/Controls/ColorComboBox.cs | 41 +++++----- .../LogWindow/LogWindowEventHandlers.cs | 4 +- src/LogExpert.UI/Dialogs/BookmarkWindow.cs | 80 +++++++++---------- .../LogTabWindow/LogTabWindowEventHandlers.cs | 5 +- src/LogExpert.UI/LogExpert.UI.csproj | 1 - 7 files changed, 81 insertions(+), 73 deletions(-) diff --git a/src/LogExpert.Core/Config/ColorEntry.cs b/src/LogExpert.Core/Config/ColorEntry.cs index 521f2ae7..022f98a2 100644 --- a/src/LogExpert.Core/Config/ColorEntry.cs +++ b/src/LogExpert.Core/Config/ColorEntry.cs @@ -7,13 +7,9 @@ namespace LogExpert.Core.Config; [Serializable] -public class ColorEntry (string fileName, Color color) +public class ColorEntry (string FileName, Color Color) { - public Color Color { get; } = color; + public Color Color { get; } = Color; - public string FileName { get; } = fileName; - - #region Fields - - #endregion + public string FileName { get; } = FileName; } \ No newline at end of file diff --git a/src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs b/src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs index d2156111..da0f9e7e 100644 --- a/src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs +++ b/src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs @@ -2,11 +2,20 @@ namespace LogExpert.Core.EventArguments; -public class BookmarkEventArgs (Bookmark bookmark) : EventArgs +public class BookmarkEventArgs : EventArgs { + public BookmarkEventArgs (Bookmark bookmark) + { + Bookmark = bookmark; + } + + public BookmarkEventArgs () { } + + public static new readonly BookmarkEventArgs Empty = new(); + #region Properties - public Bookmark Bookmark { get; } = bookmark; + public Bookmark Bookmark { get; } #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/ColorComboBox.cs b/src/LogExpert.UI/Controls/ColorComboBox.cs index 40ea6d4d..3827b7fe 100644 --- a/src/LogExpert.UI/Controls/ColorComboBox.cs +++ b/src/LogExpert.UI/Controls/ColorComboBox.cs @@ -18,27 +18,30 @@ public ColorComboBox () { DrawMode = DrawMode.OwnerDrawFixed; DrawItem += OnColorComboBoxDrawItem; - // add color presets if (!DesignMode) { - _ = Items.Add(_customColor); - _ = Items.Add(Color.Black); - _ = Items.Add(Color.White); - _ = Items.Add(Color.Gray); - _ = Items.Add(Color.DarkGray); - _ = Items.Add(Color.Blue); - _ = Items.Add(Color.LightBlue); - _ = Items.Add(Color.DarkBlue); - _ = Items.Add(Color.Green); - _ = Items.Add(Color.LightGreen); - _ = Items.Add(Color.DarkGreen); - _ = Items.Add(Color.Olive); - _ = Items.Add(Color.Red); - _ = Items.Add(Color.Pink); - _ = Items.Add(Color.Purple); - _ = Items.Add(Color.IndianRed); - _ = Items.Add(Color.DarkCyan); - _ = Items.Add(Color.Yellow); + Items.AddRange( + [ + _customColor, + Color.Black, + Color.White, + Color.Gray, + Color.DarkGray, + Color.Blue, + Color.LightBlue, + Color.DarkBlue, + Color.Green, + Color.LightGreen, + Color.DarkGreen, + Color.Olive, + Color.Red, + Color.Pink, + Color.Purple, + Color.IndianRed, + Color.DarkCyan, + Color.Yellow + ] + ); } } diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs index 75941c23..fe124965 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs @@ -67,12 +67,12 @@ protected void OnCurrentHighlightListChanged () protected void OnBookmarkAdded () { - BookmarkAdded?.Invoke(this, (BookmarkEventArgs)EventArgs.Empty); + BookmarkAdded?.Invoke(this, BookmarkEventArgs.Empty); } protected void OnBookmarkRemoved () { - BookmarkRemoved?.Invoke(this, (BookmarkEventArgs)EventArgs.Empty); + BookmarkRemoved?.Invoke(this, BookmarkEventArgs.Empty); } protected void OnBookmarkTextChanged (Bookmark bookmark) diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs index 8a3518fa..336d3f7d 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs @@ -22,9 +22,9 @@ internal partial class BookmarkWindow : DockContent, ISharedToolWindow, IBookmar private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); private readonly object paintLock = new(); - private IBookmarkData bookmarkData; - private ILogPaintContextUI logPaintContext; - private ILogView logView; + private IBookmarkData _bookmarkData; + private ILogPaintContextUI _logPaintContext; + private ILogView _logView; #endregion @@ -102,7 +102,7 @@ public void ResizeColumns () public void UpdateView () { - bookmarkDataGridView.RowCount = bookmarkData?.Bookmarks.Count ?? 0; + bookmarkDataGridView.RowCount = _bookmarkData?.Bookmarks.Count ?? 0; ResizeColumns(); bookmarkDataGridView.Refresh(); } @@ -120,7 +120,7 @@ public void BookmarkTextChanged (Bookmark bookmark) return; } - if (bookmarkData.Bookmarks[rowIndex] == bookmark) + if (_bookmarkData.Bookmarks[rowIndex] == bookmark) { bookmarkTextBox.Text = bookmark.Text; } @@ -130,22 +130,22 @@ public void BookmarkTextChanged (Bookmark bookmark) public void SelectBookmark (int lineNum) { - if (bookmarkData.IsBookmarkAtLine(lineNum)) + if (_bookmarkData.IsBookmarkAtLine(lineNum)) { - if (bookmarkDataGridView.Rows.GetRowCount(DataGridViewElementStates.None) < bookmarkData.Bookmarks.Count) + if (bookmarkDataGridView.Rows.GetRowCount(DataGridViewElementStates.None) < _bookmarkData.Bookmarks.Count) { // just for the case... There was an exception but I cannot find the cause UpdateView(); } - var row = bookmarkData.GetBookmarkIndexForLine(lineNum); + var row = _bookmarkData.GetBookmarkIndexForLine(lineNum); bookmarkDataGridView.CurrentCell = bookmarkDataGridView.Rows[row].Cells[0]; } } public void SetBookmarkData (IBookmarkData bookmarkData) { - this.bookmarkData = bookmarkData; + _bookmarkData = bookmarkData; bookmarkDataGridView.RowCount = bookmarkData?.Bookmarks.Count ?? 0; HideIfNeeded(); } @@ -171,16 +171,16 @@ public void SetCurrentFile (IFileViewContext ctx) _logger.Debug($"Current file changed to {ctx.LogView.FileName}"); lock (paintLock) { - logView = ctx.LogView; - logPaintContext = (ILogPaintContextUI)ctx.LogPaintContext; + _logView = ctx.LogView; + _logPaintContext = (ILogPaintContextUI)ctx.LogPaintContext; } SetColumnizer(ctx.LogView.CurrentColumnizer); } else { - logView = null; - logPaintContext = null; + _logView = null; + _logPaintContext = null; } UpdateView(); @@ -270,11 +270,11 @@ private void DeleteSelectedBookmarks () { if (row.Index != -1) { - lineNumList.Add(bookmarkData.Bookmarks[row.Index].LineNum); + lineNumList.Add(_bookmarkData.Bookmarks[row.Index].LineNum); } } - logView?.DeleteBookmarks(lineNumList); + _logView?.DeleteBookmarks(lineNumList); } private static void InvalidateCurrentRow (BufferedDataGridView gridView) @@ -297,7 +297,7 @@ private void CurrentRowChanged (int rowIndex) } else { - var bookmark = bookmarkData.Bookmarks[rowIndex]; + var bookmark = _bookmarkData.Bookmarks[rowIndex]; bookmarkTextBox.Text = bookmark.Text; bookmarkTextBox.Enabled = true; } @@ -319,7 +319,7 @@ private void HideIfNeeded () private void OnBoomarkDataGridViewCellPainting (object sender, DataGridViewCellPaintingEventArgs e) { - if (bookmarkData == null) + if (_bookmarkData == null) { return; } @@ -328,13 +328,13 @@ private void OnBoomarkDataGridViewCellPainting (object sender, DataGridViewCellP { try { - if (e.RowIndex < 0 || e.ColumnIndex < 0 || bookmarkData.Bookmarks.Count <= e.RowIndex) + if (e.RowIndex < 0 || e.ColumnIndex < 0 || _bookmarkData.Bookmarks.Count <= e.RowIndex) { e.Handled = false; return; } - var lineNum = bookmarkData.Bookmarks[e.RowIndex].LineNum; + var lineNum = _bookmarkData.Bookmarks[e.RowIndex].LineNum; // if (e.ColumnIndex == 1) // { @@ -342,7 +342,7 @@ private void OnBoomarkDataGridViewCellPainting (object sender, DataGridViewCellP // } { // else - PaintHelper.CellPainting(logPaintContext, bookmarkDataGridView, lineNum, e); + PaintHelper.CellPainting(_logPaintContext, bookmarkDataGridView, lineNum, e); } } catch (Exception ex) @@ -354,18 +354,18 @@ private void OnBoomarkDataGridViewCellPainting (object sender, DataGridViewCellP private void OnBoomarkDataGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e) { - if (bookmarkData == null) + if (_bookmarkData == null) { return; } - if (e.RowIndex < 0 || e.ColumnIndex < 0 || bookmarkData.Bookmarks.Count <= e.RowIndex) + if (e.RowIndex < 0 || e.ColumnIndex < 0 || _bookmarkData.Bookmarks.Count <= e.RowIndex) { e.Value = string.Empty; return; } - var bookmarkForLine = bookmarkData.Bookmarks[e.RowIndex]; + var bookmarkForLine = _bookmarkData.Bookmarks[e.RowIndex]; var lineNum = bookmarkForLine.LineNum; if (e.ColumnIndex == 1) { @@ -374,7 +374,7 @@ private void OnBoomarkDataGridViewCellValueNeeded (object sender, DataGridViewCe else { var columnIndex = e.ColumnIndex > 1 ? e.ColumnIndex - 1 : e.ColumnIndex; - e.Value = logPaintContext.GetCellValue(lineNum, columnIndex); + e.Value = _logPaintContext.GetCellValue(lineNum, columnIndex); } } @@ -400,10 +400,10 @@ private void OnBookmarkGridViewKeyDown (object sender, KeyEventArgs e) if (e.KeyCode == Keys.Enter) { if (bookmarkDataGridView.CurrentCellAddress.Y >= 0 && - bookmarkDataGridView.CurrentCellAddress.Y < bookmarkData.Bookmarks.Count) + bookmarkDataGridView.CurrentCellAddress.Y < _bookmarkData.Bookmarks.Count) { - var lineNum = bookmarkData.Bookmarks[bookmarkDataGridView.CurrentCellAddress.Y].LineNum; - logView.SelectLogLine(lineNum); + var lineNum = _bookmarkData.Bookmarks[bookmarkDataGridView.CurrentCellAddress.Y].LineNum; + _logView.SelectLogLine(lineNum); } e.Handled = true; @@ -452,20 +452,20 @@ private void OnBookmarkTextBoxTextChanged (object sender, EventArgs e) return; } - if (bookmarkData.Bookmarks.Count <= rowIndex) + if (_bookmarkData.Bookmarks.Count <= rowIndex) { return; } - var bookmark = bookmarkData.Bookmarks[rowIndex]; + var bookmark = _bookmarkData.Bookmarks[rowIndex]; bookmark.Text = bookmarkTextBox.Text; - logView?.RefreshLogView(); + _logView?.RefreshLogView(); } private void OnBookmarkDataGridViewSelectionChanged (object sender, EventArgs e) { if (bookmarkDataGridView.SelectedRows.Count != 1 - || bookmarkDataGridView.SelectedRows[0].Index >= bookmarkData.Bookmarks.Count) + || bookmarkDataGridView.SelectedRows[0].Index >= _bookmarkData.Bookmarks.Count) { CurrentRowChanged(-1); } @@ -486,12 +486,12 @@ private void OnBookmarkDataGridViewPreviewKeyDown (object sender, PreviewKeyDown private void OnBookmarkDataGridViewCellToolTipTextNeeded (object sender, DataGridViewCellToolTipTextNeededEventArgs e) { - if (e.ColumnIndex != 0 || e.RowIndex <= -1 || e.RowIndex >= bookmarkData.Bookmarks.Count) + if (e.ColumnIndex != 0 || e.RowIndex <= -1 || e.RowIndex >= _bookmarkData.Bookmarks.Count) { return; } - var bookmark = bookmarkData.Bookmarks[e.RowIndex]; + var bookmark = _bookmarkData.Bookmarks[e.RowIndex]; if (!string.IsNullOrEmpty(bookmark.Text)) { e.ToolTipText = bookmark.Text; @@ -505,11 +505,11 @@ private void OnBookmarkDataGridViewCellDoubleClick (object sender, DataGridViewC if (e.ColumnIndex == 0 && e.RowIndex >= 0 && bookmarkDataGridView.CurrentRow != null) { var index = bookmarkDataGridView.CurrentRow.Index; - var lineNum = bookmarkData.Bookmarks[bookmarkDataGridView.CurrentRow.Index].LineNum; - bookmarkData.ToggleBookmark(lineNum); + var lineNum = _bookmarkData.Bookmarks[bookmarkDataGridView.CurrentRow.Index].LineNum; + _bookmarkData.ToggleBookmark(lineNum); // we don't ask for confirmation if the bookmark has an associated comment... - var boomarkCount = bookmarkData.Bookmarks.Count; + var boomarkCount = _bookmarkData.Bookmarks.Count; bookmarkDataGridView.RowCount = boomarkCount; if (index < boomarkCount) @@ -546,8 +546,8 @@ private void OnBookmarkDataGridViewCellDoubleClick (object sender, DataGridViewC if (bookmarkDataGridView.CurrentRow != null && e.RowIndex >= 0) { - var lineNum = bookmarkData.Bookmarks[bookmarkDataGridView.CurrentRow.Index].LineNum; - logView.SelectAndEnsureVisible(lineNum, true); + var lineNum = _bookmarkData.Bookmarks[bookmarkDataGridView.CurrentRow.Index].LineNum; + _logView.SelectAndEnsureVisible(lineNum, true); } } @@ -563,13 +563,13 @@ private void OnRemoveCommentsToolStripMenuItemClick (object sender, EventArgs e) { if (row.Index != -1) { - bookmarkData.Bookmarks[row.Index].Text = string.Empty; + _bookmarkData.Bookmarks[row.Index].Text = string.Empty; } } bookmarkTextBox.Text = string.Empty; bookmarkDataGridView.Refresh(); - logView.RefreshLogView(); + _logView.RefreshLogView(); } } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs index 09c742e3..d7124015 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs @@ -756,6 +756,7 @@ private void OnTabColorToolStripMenuItemClick (object sender, EventArgs e) data.Color = dlg.Color; SetTabColor(logWindow, data.Color); } + List delList = []; foreach (var entry in ConfigManager.Settings.FileColors) @@ -768,7 +769,7 @@ private void OnTabColorToolStripMenuItemClick (object sender, EventArgs e) foreach (var entry in delList) { - ConfigManager.Settings.FileColors.Remove(entry); + _ = ConfigManager.Settings.FileColors.Remove(entry); } ConfigManager.Settings.FileColors.Add(new ColorEntry(logWindow.FileName, dlg.Color)); @@ -804,7 +805,7 @@ private void OnSaveProjectToolStripMenuItemClick (object sender, EventArgs e) lock (_logWindowList) { - foreach (DockContent content in dockPanel.Contents) + foreach (DockContent content in dockPanel.Contents.Cast()) { var logWindow = content as LogWindow.LogWindow; var persistenceFileName = logWindow?.SavePersistenceData(true); diff --git a/src/LogExpert.UI/LogExpert.UI.csproj b/src/LogExpert.UI/LogExpert.UI.csproj index 396fd4a3..7e634730 100644 --- a/src/LogExpert.UI/LogExpert.UI.csproj +++ b/src/LogExpert.UI/LogExpert.UI.csproj @@ -27,7 +27,6 @@ - From 18ff4c7c81b33a49e85c9a210320069443bcd339 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Tue, 17 Jun 2025 08:00:45 +0300 Subject: [PATCH 096/142] * Update interface to have a property instead of a function as it serves the same purpose and creates a duplicate implementation in the code. * Changed CreateCopy to Clone implementing ICloneable. * Not sure how the code in LogExpertCallback worked - changed from LogWindow to logWindow --- .../ILogLineColumnizerCallback.cs | 10 +--- src/DefaultPlugins/ProcessLauncher.cs | 2 +- .../Callback/ColumnizerCallback.cs | 53 +++++++------------ .../Classes/Filter/FilterStarter.cs | 4 +- .../Controls/LogWindow/ColumnCache.cs | 2 +- .../Controls/LogWindow/LogExpertCallback.cs | 6 +-- 6 files changed, 27 insertions(+), 50 deletions(-) diff --git a/src/ColumnizerLib/ILogLineColumnizerCallback.cs b/src/ColumnizerLib/ILogLineColumnizerCallback.cs index 2c5f5811..3cdb8988 100644 --- a/src/ColumnizerLib/ILogLineColumnizerCallback.cs +++ b/src/ColumnizerLib/ILogLineColumnizerCallback.cs @@ -17,18 +17,12 @@ public interface ILogLineColumnizerCallback #region Public methods /// - /// This function returns the current line number. That is the line number of the log line + /// This property returns the current line number. That is the line number of the log line /// a ILogLineColumnizer function is called for (e.g. the line that has to be painted). /// /// The current line number starting at 0 - int GetLineNum (); + int LineNum { get; } - /// - /// This function sets the current line number. That is the line number of the log line - /// a ILogLineColumnizer function is called for (e.g. the line that has to be painted). - /// - /// line number to be set - void SetLineNum (int lineNum); /// /// Returns the full file name (path + name) of the current log file. /// diff --git a/src/DefaultPlugins/ProcessLauncher.cs b/src/DefaultPlugins/ProcessLauncher.cs index de439ddf..e2527955 100644 --- a/src/DefaultPlugins/ProcessLauncher.cs +++ b/src/DefaultPlugins/ProcessLauncher.cs @@ -43,7 +43,7 @@ public void Execute (string keyword, string param, ILogExpertCallback callback, parameters = parameters.Replace("%F", callback.GetFileName(), StringComparison.Ordinal); parameters = parameters.Replace("%K", keyword, StringComparison.Ordinal); - var lineNumber = callback.GetLineNum(); //Line Numbers start at 0, but are displayed (+1) + var lineNumber = callback.LineNum; //Line Numbers start at 0, but are displayed (+1) var logline = callback.GetLogLine(lineNumber).FullLine; parameters = parameters.Replace("%L", string.Empty + lineNumber, System.StringComparison.Ordinal); parameters = parameters.Replace("%T", callback.GetTabTitle(), StringComparison.Ordinal); diff --git a/src/LogExpert.Core/Callback/ColumnizerCallback.cs b/src/LogExpert.Core/Callback/ColumnizerCallback.cs index 2d1266b1..9984b359 100644 --- a/src/LogExpert.Core/Callback/ColumnizerCallback.cs +++ b/src/LogExpert.Core/Callback/ColumnizerCallback.cs @@ -2,20 +2,10 @@ namespace LogExpert.Core.Callback; -public class ColumnizerCallback : ILogLineColumnizerCallback, IAutoLogLineColumnizerCallback +public class ColumnizerCallback(ILogWindow logWindow) : ILogLineColumnizerCallback, IAutoLogLineColumnizerCallback, ICloneable { - #region cTor - - public ColumnizerCallback (ILogWindow logWindow) - { - LogWindow = logWindow; - } - - private ColumnizerCallback (ColumnizerCallback original) - { - LogWindow = original.LogWindow; - LineNum = original.GetLineNum(); - } + #region Fields + private readonly ILogWindow _logWindow = logWindow; #endregion @@ -23,48 +13,43 @@ private ColumnizerCallback (ColumnizerCallback original) public int LineNum { get; set; } - protected ILogWindow LogWindow { get; set; } - - protected IPluginRegistry PluginRegistry { get; set; } - #endregion - #region Public methods + #region cTor - public ColumnizerCallback CreateCopy () + private ColumnizerCallback(ColumnizerCallback original) : this(original._logWindow) { - return new ColumnizerCallback(this); + LineNum = original.LineNum; } - public int GetLineNum () - { - return LineNum; - } + #endregion + + #region Public methods - public string GetFileName () + public object Clone() { - return LogWindow.GetCurrentFileName(GetLineNum()); + return new ColumnizerCallback(this); } - public ILogLine GetLogLine (int lineNum) + public string GetFileName() { - return LogWindow.GetLine(lineNum); + return _logWindow.GetCurrentFileName(LineNum); } - public IList GetRegisteredColumnizers () + public ILogLine GetLogLine(int lineNum) { - return PluginRegistry.RegisteredColumnizers; + return _logWindow.GetLine(lineNum); } - public int GetLineCount () + public int GetLineCount() { - return LogWindow.LogFileReader.LineCount; + return _logWindow.LogFileReader.LineCount; } - public void SetLineNum (int lineNum) + public void SetLineNum(int lineNum) { LineNum = lineNum; } #endregion -} +} \ No newline at end of file diff --git a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs index efa6a886..ba6d2177 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs @@ -146,9 +146,7 @@ private Filter DoWork (FilterParams filterParams, int startLine, int maxCount, P // Give every thread own copies of ColumnizerCallback and FilterParams, because the state of the objects changes while filtering FilterParams threadFilterParams = filterParams.CloneWithCurrentColumnizer(); - ColumnizerCallback threadColumnizerCallback = _callback.CreateCopy(); - - Filter filter = new(threadColumnizerCallback); + Filter filter = new((ColumnizerCallback)_callback.Clone()); lock (_filterWorkerList) { _filterWorkerList.Add(filter); diff --git a/src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs b/src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs index 2ac878a7..ab9f0746 100644 --- a/src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs +++ b/src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs @@ -17,7 +17,7 @@ internal class ColumnCache internal IColumnizedLogLine GetColumnsForLine (LogfileReader logFileReader, int lineNumber, ILogLineColumnizer columnizer, ColumnizerCallback columnizerCallback) { - if (_lastColumnizer != columnizer || (_lastLineNumber != lineNumber && _cachedColumns != null) || columnizerCallback.GetLineNum() != lineNumber) + if (_lastColumnizer != columnizer || (_lastLineNumber != lineNumber && _cachedColumns != null) || columnizerCallback.LineNum != lineNumber) { _lastColumnizer = columnizer; _lastLineNumber = lineNumber; diff --git a/src/LogExpert.UI/Controls/LogWindow/LogExpertCallback.cs b/src/LogExpert.UI/Controls/LogWindow/LogExpertCallback.cs index a42320d0..93733053 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogExpertCallback.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogExpertCallback.cs @@ -8,17 +8,17 @@ internal class LogExpertCallback (LogWindow logWindow) : ColumnizerCallback(logW public void AddTempFileTab (string fileName, string title) { - LogWindow.AddTempFileTab(fileName, title); + logWindow.AddTempFileTab(fileName, title); } public void AddPipedTab (IList lineEntryList, string title) { - LogWindow.WritePipeTab(lineEntryList, title); + logWindow.WritePipeTab(lineEntryList, title); } public string GetTabTitle () { - return LogWindow.Text; + return logWindow.Text; } #endregion From 4f4677b06946285988d2c2e78d0713ed7ff5ec54 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Tue, 17 Jun 2025 07:27:55 +0200 Subject: [PATCH 097/142] remove unnecessary chocolatey dependency --- chocolatey/logexpert.portable.nuspec.template | 3 --- 1 file changed, 3 deletions(-) diff --git a/chocolatey/logexpert.portable.nuspec.template b/chocolatey/logexpert.portable.nuspec.template index b6f32b7f..37d36655 100644 --- a/chocolatey/logexpert.portable.nuspec.template +++ b/chocolatey/logexpert.portable.nuspec.template @@ -12,9 +12,6 @@ https://github.com/zarunbal/LogExpert/issues https://github.com/zarunbal/LogExpert/releases/tag/v##version## false - - - LogExpert is a Windows tail program (a GUI replacement for the Unix tail command). Summary of (most) features: From 6b0b6fe89b4ddc6dbd5f119591f9b68ad70c8b7d Mon Sep 17 00:00:00 2001 From: Hirogen Date: Wed, 18 Jun 2025 08:18:02 +0200 Subject: [PATCH 098/142] review comments --- global.json | 2 +- .../EventArguments/BookmarkEventArgs.cs | 13 ++----------- src/LogExpert.UI/Controls/LogWindow/LogWindow.cs | 4 ++-- .../Controls/LogWindow/LogWindowEventHandlers.cs | 4 ++-- .../LogTabWindow/LogTabWindowEventHandlers.cs | 4 ++-- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/global.json b/global.json index b6b5c9f5..04639674 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "9.0.101" + "version": "v8.0.314" } } diff --git a/src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs b/src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs index da0f9e7e..d2156111 100644 --- a/src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs +++ b/src/LogExpert.Core/EventArguments/BookmarkEventArgs.cs @@ -2,20 +2,11 @@ namespace LogExpert.Core.EventArguments; -public class BookmarkEventArgs : EventArgs +public class BookmarkEventArgs (Bookmark bookmark) : EventArgs { - public BookmarkEventArgs (Bookmark bookmark) - { - Bookmark = bookmark; - } - - public BookmarkEventArgs () { } - - public static new readonly BookmarkEventArgs Empty = new(); - #region Properties - public Bookmark Bookmark { get; } + public Bookmark Bookmark { get; } = bookmark; #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index df0a6cad..3b839b1c 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -291,9 +291,9 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp public event EventHandler CurrentHighlightGroupChanged; - public event EventHandler BookmarkAdded; + public event EventHandler BookmarkAdded; - public event EventHandler BookmarkRemoved; + public event EventHandler BookmarkRemoved; public event EventHandler BookmarkTextChanged; diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs index 0b650677..5a2b3ff7 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs @@ -68,12 +68,12 @@ protected void OnCurrentHighlightListChanged () protected void OnBookmarkAdded () { - BookmarkAdded?.Invoke(this, BookmarkEventArgs.Empty); + BookmarkAdded?.Invoke(this, EventArgs.Empty); } protected void OnBookmarkRemoved () { - BookmarkRemoved?.Invoke(this, BookmarkEventArgs.Empty); + BookmarkRemoved?.Invoke(this, EventArgs.Empty); } protected void OnBookmarkTextChanged (Bookmark bookmark) diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs index e78b894e..80956103 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs @@ -350,7 +350,7 @@ private void OnColumnizerChanged (object sender, ColumnizerEventArgs e) _bookmarkWindow?.SetColumnizer(e.Columnizer); } - private void OnBookmarkAdded (object sender, BookmarkEventArgs e) + private void OnBookmarkAdded (object sender, EventArgs e) { _bookmarkWindow.UpdateView(); } @@ -360,7 +360,7 @@ private void OnBookmarkTextChanged (object sender, BookmarkEventArgs e) _bookmarkWindow.BookmarkTextChanged(e.Bookmark); } - private void OnBookmarkRemoved (object sender, BookmarkEventArgs e) + private void OnBookmarkRemoved (object sender, EventArgs e) { _bookmarkWindow.UpdateView(); } From fdf22604873fee9a298c24c093001e04eb6443bf Mon Sep 17 00:00:00 2001 From: Hirogen Date: Wed, 18 Jun 2025 08:56:55 +0200 Subject: [PATCH 099/142] review comments --- .../LogWindow/LogWindowEventHandlers.cs | 43 +----- .../Controls/LogWindow/LogWindowPublic.cs | 144 ++++++------------ .../Controls/LogWindow/PatternWindow.cs | 7 +- src/LogExpert.UI/Dialogs/BookmarkWindow.cs | 25 +-- .../LogTabWindow/LogTabWindowEventHandlers.cs | 11 +- src/LogExpert.UI/Entities/PaintHelper.cs | 63 ++++---- 6 files changed, 93 insertions(+), 200 deletions(-) diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs index 5a2b3ff7..25ffba61 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs @@ -392,6 +392,8 @@ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPainti return; } + + var lineNum = _filterResultList[e.RowIndex]; var line = _logFileReader.GetLogLineWithWait(lineNum).Result; @@ -401,43 +403,17 @@ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPainti e.Graphics.SetClip(e.CellBounds); if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) { - Brush brush; - if (gridView.Focused) - { - brush = new SolidBrush(e.CellStyle.SelectionBackColor); - } - else - { - brush = new SolidBrush(Color.FromArgb(255, 170, 170, 170)); //gray - } - + using var brush = PaintHelper.GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); e.Graphics.FillRectangle(brush, e.CellBounds); - brush.Dispose(); } else { - var bgColor = Color.White; // paint direct filter hits with different bg color //if (this.filterParams.SpreadEnabled && this.filterHitList.Contains(lineNum)) //{ // bgColor = Color.FromArgb(255, 220, 220, 220); //} - if (!DebugOptions.DisableWordHighlight) - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - else - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - - e.CellStyle.BackColor = bgColor; + e.CellStyle.BackColor = PaintHelper.GetBackColorFromHighlightEntry(entry); e.PaintBackground(e.ClipBounds, false); } @@ -454,12 +430,11 @@ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPainti { if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) { - Rectangle r = new(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); + Rectangle r;// = new(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); r = e.CellBounds; r.Inflate(-2, -2); - Brush brush = new SolidBrush(BookmarkColor); + using var brush = new SolidBrush(BookmarkColor); e.Graphics.FillRectangle(brush, r); - brush.Dispose(); var bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); @@ -471,11 +446,9 @@ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPainti Alignment = StringAlignment.Center }; - Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); - Font font = new("Verdana", Preferences.FontSize, FontStyle.Bold); + using var brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); + using var font = new Font("Verdana", Preferences.FontSize, FontStyle.Bold); e.Graphics.DrawString("!", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); - font.Dispose(); - brush2.Dispose(); } } } diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs index 8d4d36a0..692adab8 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs @@ -62,8 +62,10 @@ public void LoadFile (string fileName, EncodingOptions encodingOptions) { isUsingDefaultColumnizer = true; } + PreSelectColumnizer(columnizer); } + SetDefaultHighlightGroup(); } @@ -86,7 +88,7 @@ public void LoadFile (string fileName, EncodingOptions encodingOptions) catch (LogFileException lfe) { _logger.Error(lfe); - MessageBox.Show("Cannot load file\n" + lfe.Message, "LogExpert"); + MessageBox.Show($"Cannot load file\n{lfe.Message}", "LogExpert"); _ = BeginInvoke(new FunctionWith1BoolParam(Close), true); _isLoadError = true; return; @@ -103,14 +105,7 @@ public void LoadFile (string fileName, EncodingOptions encodingOptions) CurrentColumnizer = _forcedColumnizerForLoading; } - if (CurrentColumnizer is IPreProcessColumnizer processColumnizer) - { - _logFileReader.PreProcessColumnizer = processColumnizer; - } - else - { - _logFileReader.PreProcessColumnizer = null; - } + _logFileReader.PreProcessColumnizer = CurrentColumnizer is IPreProcessColumnizer processColumnizer ? processColumnizer : null; RegisterLogFileReaderEvents(); _logger.Info($"Loading logfile: {fileName}"); @@ -141,7 +136,7 @@ public void LoadFilesAsMulti (string[] fileNames, EncodingOptions encodingOption foreach (var name in fileNames) { - _logger.Info("File: {0}", name); + _logger.Info($"File: {name}"); } if (_logFileReader != null) @@ -188,12 +183,9 @@ public string SavePersistenceData (bool force) { var persistenceData = GetPersistenceData(); - if (ForcedPersistenceFileName == null) - { - return Persister.SavePersistenceData(FileName, persistenceData, Preferences); - } - - return Persister.SavePersistenceDataWithFixedName(ForcedPersistenceFileName, persistenceData); + return ForcedPersistenceFileName == null + ? Persister.SavePersistenceData(FileName, persistenceData, Preferences) + : Persister.SavePersistenceDataWithFixedName(ForcedPersistenceFileName, persistenceData); } catch (IOException ex) { @@ -291,7 +283,7 @@ public void CloseLogWindow () if (IsTempFile) { - _logger.Info("Deleting temp file {0}", FileName); + _logger.Info($"Deleting temp file {FileName}"); try { @@ -299,7 +291,7 @@ public void CloseLogWindow () } catch (IOException e) { - _logger.Error(e, "Error while deleting temp file {0}: {1}", FileName, e); + _logger.Error(e, $"Error while deleting temp file {FileName}: {e}"); } } @@ -358,7 +350,7 @@ public IColumn GetCellValue (int rowIndex, int columnIndex) { return new Column { - FullValue = (rowIndex + 1).ToString() // line number + FullValue = $"{rowIndex + 1}" // line number }; } @@ -376,19 +368,14 @@ public IColumn GetCellValue (int rowIndex, int columnIndex) { var value = cols.ColumnValues[columnIndex - 2]; - if (value != null && value.DisplayValue != null) - { - return value; - } - return value; - } - - if (columnIndex == 2) - { - return cols.ColumnValues[^1]; + return value != null && value.DisplayValue != null + ? value + : value; } - return Column.EmptyColumn; + return columnIndex == 2 + ? cols.ColumnValues[^1] + : Column.EmptyColumn; } } catch @@ -416,43 +403,12 @@ public void CellPainting (BufferedDataGridView gridView, int rowIndex, DataGridV if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) { - var backColor = e.CellStyle.SelectionBackColor; - - Brush brush; - - if (gridView.Focused) - { - brush = new SolidBrush(backColor); - } - else - { - brush = new SolidBrush(Color.FromArgb(255, 170, 170, 170)); //gray - } - + using var brush = PaintHelper.GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); e.Graphics.FillRectangle(brush, e.CellBounds); - brush.Dispose(); } else { - var bgColor = Color.White; - - if (!DebugOptions.DisableWordHighlight) - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - else - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - - e.CellStyle.BackColor = bgColor; - + e.CellStyle.BackColor = PaintHelper.GetBackColorFromHighlightEntry(entry); e.PaintBackground(e.ClipBounds, false); } @@ -472,9 +428,9 @@ public void CellPainting (BufferedDataGridView gridView, int rowIndex, DataGridV Rectangle r; // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); r = e.CellBounds; r.Inflate(-2, -2); - Brush brush = new SolidBrush(BookmarkColor); + using var brush = new SolidBrush(BookmarkColor); e.Graphics.FillRectangle(brush, r); - brush.Dispose(); + var bookmark = _bookmarkProvider.GetBookmarkForLine(rowIndex); if (bookmark.Text.Length > 0) @@ -484,12 +440,10 @@ public void CellPainting (BufferedDataGridView gridView, int rowIndex, DataGridV LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }; - Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); //dark orange - Font font = new("Courier New", Preferences.FontSize, FontStyle.Bold); - e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), - format); - font.Dispose(); - brush2.Dispose(); + + using var brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); //dark orange + using var font = new Font("Courier New", Preferences.FontSize, FontStyle.Bold); + e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); } } } @@ -628,14 +582,9 @@ public void StartSearch () GuiStateUpdate(this, _guiStateArgs); var searchParams = _parentLogTabWin.SearchParams; - if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) - { - searchParams.CurrentLine = dataGridView.CurrentCellAddress.Y + 1; - } - else - { - searchParams.CurrentLine = dataGridView.CurrentCellAddress.Y - 1; - } + searchParams.CurrentLine = (searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed + ? dataGridView.CurrentCellAddress.Y + 1 + : dataGridView.CurrentCellAddress.Y - 1; _currentSearchParams = searchParams; // remember for async "not found" messages @@ -1663,14 +1612,9 @@ public void PatternStatisticSelectRange (PatternArgs patternArgs) } else { - if (dataGridView.CurrentCellAddress.Y != -1) - { - patternArgs.StartLine = dataGridView.CurrentCellAddress.Y; - } - else - { - patternArgs.StartLine = 0; - } + patternArgs.StartLine = dataGridView.CurrentCellAddress.Y != -1 + ? dataGridView.CurrentCellAddress.Y + : 0; patternArgs.EndLine = dataGridView.RowCount - 1; } } @@ -1800,19 +1744,14 @@ public void SetCurrentHighlightGroup (string groupName) lock (_currentHighlightGroupLock) { _currentHighlightGroup = _parentLogTabWin.FindHighlightGroup(groupName); - if (_currentHighlightGroup == null) - { - if (_parentLogTabWin.HighlightGroupList.Count > 0) - { - _currentHighlightGroup = _parentLogTabWin.HighlightGroupList[0]; - } - else - { - _currentHighlightGroup = new HighlightGroup(); - } - } + + _currentHighlightGroup ??= _parentLogTabWin.HighlightGroupList.Count > 0 + ? _parentLogTabWin.HighlightGroupList[0] + : new HighlightGroup(); + _guiStateArgs.HighlightGroupName = _currentHighlightGroup.GroupName; } + SendGuiStateUpdate(); BeginInvoke(new MethodInvoker(RefreshAllGrids)); } @@ -1845,7 +1784,7 @@ public void AddOtherWindowToTimesync (LogWindow other) public void AddToTimeSync (LogWindow master) { - _logger.Info("Syncing window for {0} to {1}", Util.GetNameFromPath(FileName), Util.GetNameFromPath(master.FileName)); + _logger.Info($"Syncing window for {Util.GetNameFromPath(FileName)} to {Util.GetNameFromPath(master.FileName)}"); lock (_timeSyncListLock) { if (IsTimeSynced && master.TimeSyncList != TimeSyncList) @@ -1853,10 +1792,12 @@ public void AddToTimeSync (LogWindow master) { FreeFromTimeSync(); } + TimeSyncList = master.TimeSyncList; TimeSyncList.AddWindow(this); ScrollToTimestamp(TimeSyncList.CurrentTimestamp, false, false); } + OnSyncModeChanged(); } @@ -1866,12 +1807,13 @@ public void FreeFromTimeSync () { if (TimeSyncList != null) { - _logger.Info("De-Syncing window for {0}", Util.GetNameFromPath(FileName)); + _logger.Info($"De-Syncing window for {Util.GetNameFromPath(FileName)}"); TimeSyncList.WindowRemoved -= OnTimeSyncListWindowRemoved; TimeSyncList.RemoveWindow(this); TimeSyncList = null; } } + OnSyncModeChanged(); } @@ -1881,4 +1823,4 @@ public void RefreshLogView () } #endregion -} +} \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs index f704e3e8..c8999ac2 100644 --- a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs @@ -72,6 +72,7 @@ public void SetBlockList (List flatBlockList, PatternArgs patternA _blockList.Clear(); List singeList = []; //int blockId = -1; + for (var i = 0; i < flatBlockList.Count; ++i) { var block = flatBlockList[i]; @@ -93,6 +94,7 @@ public void SetBlockList (List flatBlockList, PatternArgs patternA // singeList.Add(block); //} } + _blockList.Add(singeList); Invoke(new MethodInvoker(SetBlockListGuiStuff)); } @@ -231,10 +233,9 @@ private void OnPatternHitsDataGridViewCellPainting (object sender, DataGridViewC Rectangle rect = new(e.CellBounds.X, e.CellBounds.Y, width, e.CellBounds.Height); var alpha = 90 + (int)((int)e.Value / (double)maxWeight * 165); - Brush brush = new SolidBrush(Color.FromArgb(alpha, 170, 180, 150));//gray green + using var brush = new SolidBrush(Color.FromArgb(alpha, 170, 180, 150));//gray green rect.Inflate(-2, -1); e.Graphics.FillRectangle(brush, rect); - brush.Dispose(); } e.PaintContent(e.CellBounds); @@ -360,7 +361,7 @@ private void OnSetRangeButtonClick (object sender, EventArgs e) { _logWindow.PatternStatisticSelectRange(_patternArgs); recalcButton.Enabled = true; - rangeLabel.Text = "Start: " + _patternArgs.StartLine + "\r\nEnd: " + _patternArgs.EndLine; + rangeLabel.Text = $"Start: {_patternArgs.StartLine} \r\nEnd: {_patternArgs.EndLine}"; } #endregion diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs index 336d3f7d..61648116 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs @@ -235,24 +235,10 @@ private void SetFont (string fontName, float fontSize) private void CommentPainting (BufferedDataGridView gridView, DataGridViewCellPaintingEventArgs e) { - var backColor = e.CellStyle.SelectionBackColor; - if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) { - Brush brush; - if (gridView.Focused) - { - // _logger.logDebug("CellPaint Focus"); - brush = new SolidBrush(backColor); - } - else - { - // _logger.logDebug("CellPaint No Focus"); - brush = new SolidBrush(Color.FromArgb(255, 170, 170, 170)); //gray - } - + using var brush = PaintHelper.GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); e.Graphics.FillRectangle(brush, e.CellBounds); - brush.Dispose(); } else { @@ -297,8 +283,7 @@ private void CurrentRowChanged (int rowIndex) } else { - var bookmark = _bookmarkData.Bookmarks[rowIndex]; - bookmarkTextBox.Text = bookmark.Text; + bookmarkTextBox.Text = _bookmarkData.Bookmarks[rowIndex].Text; bookmarkTextBox.Enabled = true; } } @@ -553,12 +538,8 @@ private void OnBookmarkDataGridViewCellDoubleClick (object sender, DataGridViewC private void OnRemoveCommentsToolStripMenuItemClick (object sender, EventArgs e) { - if ( - MessageBox.Show("Really remove bookmark comments for selected lines?", "LogExpert", - MessageBoxButtons.YesNo) == - DialogResult.Yes) + if (MessageBox.Show("Really remove bookmark comments for selected lines?", "LogExpert", MessageBoxButtons.YesNo) == DialogResult.Yes) { - List lineNumList = []; foreach (DataGridViewRow row in bookmarkDataGridView.SelectedRows) { if (row.Index != -1) diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs index 80956103..408bb9cd 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs @@ -79,20 +79,15 @@ private void OnLogTabWindowClosing (object sender, CancelEventArgs e) try { _shouldStop = true; - _statusLineEventHandle.Set(); - _statusLineEventWakeupHandle.Set(); + _ = _statusLineEventHandle.Set(); + _ = _statusLineEventWakeupHandle.Set(); _ledThread.Join(); IList deleteLogWindowList = []; ConfigManager.Settings.AlwaysOnTop = TopMost && ConfigManager.Settings.Preferences.AllowOnlyOneInstance; SaveLastOpenFilesList(); - foreach (var logWindow in _logWindowList) - { - deleteLogWindowList.Add(logWindow); - } - - foreach (var logWindow in deleteLogWindowList) + foreach (var logWindow in _logWindowList.ToArray()) { RemoveAndDisposeLogWindow(logWindow, true); } diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index b0fda7d1..ae67258b 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -40,41 +40,12 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) { - var backColor = e.CellStyle.SelectionBackColor; - Brush brush; - - if (gridView.Focused) - { - brush = new SolidBrush(backColor); - } - else - { - brush = new SolidBrush(Color.FromArgb(255, 170, 170, 170)); //gray - } - + using var brush = GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); e.Graphics.FillRectangle(brush, e.CellBounds); - brush.Dispose(); } else { - var bgColor = Color.White; - - if (!DebugOptions.DisableWordHighlight) - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - else - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - - e.CellStyle.BackColor = bgColor; + e.CellStyle.BackColor = GetBackColorFromHighlightEntry(entry); e.PaintBackground(e.ClipBounds, false); } @@ -119,6 +90,36 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri } } + public static Color GetBackColorFromHighlightEntry (HighlightEntry? entry) + { + var bgColor = Color.White; + + if (!DebugOptions.DisableWordHighlight) + { + if (entry != null) + { + bgColor = entry.BackgroundColor; + } + } + else + { + if (entry != null) + { + bgColor = entry.BackgroundColor; + } + } + + return bgColor; + } + + [SupportedOSPlatform("windows")] + public static Brush GetBrushForFocusedControl (bool focused, Color selectionColor) + { + return focused + ? new SolidBrush(selectionColor) + : new SolidBrush(Color.FromArgb(255, 170, 170, 170)); //Gray + } + [SupportedOSPlatform("windows")] public static DataGridViewTextBoxColumn CreateMarkerColumn () { From 41832fc7825b82951174d8cac9d4fdfdf1d6c8df Mon Sep 17 00:00:00 2001 From: Hirogen Date: Wed, 18 Jun 2025 09:14:09 +0200 Subject: [PATCH 100/142] review comments --- .../LogTabWindow/LogTabWindowEventHandlers.cs | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs index 408bb9cd..b49b1cda 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs @@ -13,8 +13,6 @@ using LogExpert.UI.Dialogs; using LogExpert.UI.Extensions.LogWindow; -using WeifenLuo.WinFormsUI.Docking; - namespace LogExpert.UI.Controls.LogTabWindow; internal partial class LogTabWindow @@ -708,21 +706,17 @@ private void OnCloseThisTabToolStripMenuItemClick (object sender, EventArgs e) [SupportedOSPlatform("windows")] private void OnCloseOtherTabsToolStripMenuItemClick (object sender, EventArgs e) { - IList closeList = []; + List closeList = []; lock (_logWindowList) { - foreach (DockContent content in dockPanel.Contents) - { - if (content != dockPanel.ActiveContent && content is LogWindow.LogWindow) - { - closeList.Add(content); - } - } + closeList = [.. dockPanel.Contents + .OfType() + .Where(content => content != dockPanel.ActiveContent)]; } - foreach (var form in closeList) + foreach (var logWindow in closeList) { - form.Close(); + logWindow.Close(); } } @@ -801,9 +795,8 @@ private void OnSaveProjectToolStripMenuItemClick (object sender, EventArgs e) lock (_logWindowList) { - foreach (DockContent content in dockPanel.Contents.Cast()) + foreach (var logWindow in dockPanel.Contents.OfType()) { - var logWindow = content as LogWindow.LogWindow; var persistenceFileName = logWindow?.SavePersistenceData(true); if (persistenceFileName != null) { From bf9111449a1fc27d38112e890c54375527560a6b Mon Sep 17 00:00:00 2001 From: Hirogen Date: Wed, 18 Jun 2025 09:26:00 +0200 Subject: [PATCH 101/142] small change --- src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs index 692adab8..5904c375 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs @@ -501,20 +501,20 @@ public HighlightEntry FindHighlightEntry (ITextValue line, bool noWordMatches) } } - public IList FindHighlightMatches (ITextValue column) + public IList FindHighlightMatches (ITextValue line) { IList resultList = []; - if (column != null) + if (line != null) { lock (_currentHighlightGroupLock) { - GetHighlightEntryMatches(column, _currentHighlightGroup.HighlightEntryList, resultList); + GetHighlightEntryMatches(line, _currentHighlightGroup.HighlightEntryList, resultList); } lock (_tempHighlightEntryList) { - GetHighlightEntryMatches(column, _tempHighlightEntryList, resultList); + GetHighlightEntryMatches(line, _tempHighlightEntryList, resultList); } } @@ -532,6 +532,7 @@ public void FollowTailChanged (bool isChecked, bool byTrigger) dataGridView.FirstDisplayedScrollingRowIndex = _logFileReader.LineCount - 1; } } + BeginInvoke(new MethodInvoker(dataGridView.Refresh)); //this.dataGridView.Refresh(); _parentLogTabWin.FollowTailChanged(this, isChecked, byTrigger); From fe05430e228ecb72f925173a80f8e69aee127ea5 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Tue, 17 Jun 2025 20:29:01 +0300 Subject: [PATCH 102/142] filter refactoring and warning removal --- src/.editorconfig | 2 +- src/LogExpert.Core/Classes/Filter/Filter.cs | 20 ++++----- .../Classes/Filter/FilterCancelHandler.cs | 2 +- .../Classes/Filter/FilterParams.cs | 41 +++++-------------- .../Classes/Filter/FilterPipe.cs | 2 + .../Classes/Filter/FilterStarter.cs | 41 +++++++++---------- src/LogExpert.Core/Classes/Util.cs | 19 +++++---- .../FilterListChangedEventArgs.cs | 9 ++-- .../Controls/LogWindow/LogWindowPrivate.cs | 6 +-- 9 files changed, 59 insertions(+), 83 deletions(-) diff --git a/src/.editorconfig b/src/.editorconfig index 5f2d7b13..0792babf 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -580,7 +580,7 @@ dotnet_code_quality.CA1001.excluded_type_names_with_derived_types = # CA1002: Do not expose generic lists dotnet_diagnostic.CA1002.severity = suggestion -dotnet_code_quality.CA1002.api_surface = public, internal +dotnet_code_quality.CA1002.api_surface = public # CA1003: Use generic event handler instances dotnet_diagnostic.CA1003.severity = warning diff --git a/src/LogExpert.Core/Classes/Filter/Filter.cs b/src/LogExpert.Core/Classes/Filter/Filter.cs index d1374c79..d7393f13 100644 --- a/src/LogExpert.Core/Classes/Filter/Filter.cs +++ b/src/LogExpert.Core/Classes/Filter/Filter.cs @@ -1,9 +1,9 @@ using LogExpert.Core.Callback; using LogExpert.Core.Classes; -using LogExpert.Core.Classes.Filter; + using NLog; -namespace LogExpert.Classes.Filter; +namespace LogExpert.Core.Classes.Filter; internal delegate void FilterFx (FilterParams filterParams, List filterResultLines, List lastFilterResultLines, List filterHitList); @@ -13,7 +13,7 @@ internal class Filter private const int PROGRESS_BAR_MODULO = 1000; private const int SPREAD_MAX = 50; - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); private readonly ColumnizerCallback _callback; @@ -35,11 +35,8 @@ public Filter (ColumnizerCallback callback) #region Properties public List FilterResultLines { get; } - public List LastFilterLinesList { get; } - public List FilterHitList { get; } - public bool ShouldCancel { get; set; } #endregion @@ -72,7 +69,7 @@ private int DoFilter (FilterParams filterParams, int startLine, int maxCount, Li return count; } - ILogLine line = _callback.GetLogLine(lineNum); + var line = _callback.GetLogLine(lineNum); if (line == null) { @@ -83,7 +80,7 @@ private int DoFilter (FilterParams filterParams, int startLine, int maxCount, Li if (Util.TestFilterCondition(filterParams, line, _callback)) { - AddFilterLine(lineNum, false, filterParams, filterResultLines, lastFilterLinesList, filterHitList); + AddFilterLine(lineNum, filterParams, filterResultLines, lastFilterLinesList, filterHitList); } lineNum++; @@ -99,6 +96,7 @@ private int DoFilter (FilterParams filterParams, int startLine, int maxCount, Li catch (Exception ex) { _logger.Error(ex, "Exception while filtering. Please report to developer"); + throw; //TODO: This information should be handled from the LogExpert project and not from LogExpert.Core. //MessageBox.Show(null, // "Exception while filtering. Please report to developer: \n\n" + ex + "\n\n" + ex.StackTrace, @@ -108,10 +106,10 @@ private int DoFilter (FilterParams filterParams, int startLine, int maxCount, Li return count; } - private void AddFilterLine (int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) + private void AddFilterLine (int lineNum, FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) { filterHitList.Add(lineNum); - IList filterResult = GetAdditionalFilterResults(filterParams, lineNum, lastFilterLinesList); + var filterResult = GetAdditionalFilterResults(filterParams, lineNum, lastFilterLinesList); filterResultLines.AddRange(filterResult); @@ -123,7 +121,6 @@ private void AddFilterLine (int lineNum, bool immediate, FilterParams filterPara } } - /// /// Returns a list with 'additional filter results'. This is the given line number /// and (if back spread and/or fore spread is enabled) some additional lines. @@ -170,6 +167,7 @@ private IList GetAdditionalFilterResults (FilterParams filterParams, int li } } } + return resultList; } diff --git a/src/LogExpert.Core/Classes/Filter/FilterCancelHandler.cs b/src/LogExpert.Core/Classes/Filter/FilterCancelHandler.cs index 8fd32c11..14eea0d3 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterCancelHandler.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterCancelHandler.cs @@ -4,7 +4,7 @@ using NLog; -namespace LogExpert.Classes.Filter; +namespace LogExpert.Core.Classes.Filter; public class FilterCancelHandler : IBackgroundProcessCancelHandler { diff --git a/src/LogExpert.Core/Classes/Filter/FilterParams.cs b/src/LogExpert.Core/Classes/Filter/FilterParams.cs index 4daf42c5..19b11f8e 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterParams.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterParams.cs @@ -1,4 +1,5 @@ using System.Collections; +using System.Collections.ObjectModel; using System.Drawing; using System.Text.Json.Serialization; using System.Text.RegularExpressions; @@ -9,10 +10,6 @@ namespace LogExpert.Core.Classes.Filter; public class FilterParams : ICloneable { #region Fields - - private string _rangeSearchText = string.Empty; - private string _searchText = string.Empty; - //public List historyList = new List(); //public List rangeHistoryList = new List(); @@ -20,27 +17,11 @@ public class FilterParams : ICloneable #region Properties - public string SearchText - { - get => _searchText; - set - { - _searchText = value; - LowerSearchText = _searchText.ToLowerInvariant(); - } - } + public string SearchText { get; set; } - public string RangeSearchText - { - get => _rangeSearchText; - set - { - _rangeSearchText = value; - LowerRangeSearchText = _rangeSearchText.ToLowerInvariant(); - } - } + public string RangeSearchText { get; set; } - public bool SpreadEnabled => SpreadBefore > 0 || SpreadBehind > 0; + //public bool SpreadEnabled => SpreadBefore > 0 || SpreadBehind > 0; public bool IsCaseSensitive { get; set; } @@ -69,7 +50,7 @@ public string RangeSearchText public bool IsRegex { get; set; } // list of columns in which to search - public List ColumnList { get; set; } = []; + public Collection ColumnList { get; } = []; [JsonIgnore] [field: NonSerialized] @@ -91,11 +72,13 @@ public string RangeSearchText [field: NonSerialized] public bool LastResult { get; set; } - [field: NonSerialized] - public string LowerRangeSearchText { get; set; } = string.Empty; + ///Returns RangeSearchText.ToUpperInvariant + [JsonIgnore] + internal string NormalizedRangeSearchText => RangeSearchText.ToUpperInvariant(); - [field: NonSerialized] - public string LowerSearchText { get; set; } = string.Empty; + ///Returns SearchText.ToUpperInvariant + [JsonIgnore] + internal string NormalizedSearchText => SearchText.ToUpperInvariant(); [field: NonSerialized] public Regex RangeRex { get; set; } @@ -125,8 +108,6 @@ public FilterParams CloneWithCurrentColumnizer () public void Init () { LastNonEmptyCols = []; - LowerRangeSearchText = RangeSearchText.ToLowerInvariant(); - LowerSearchText = SearchText.ToLowerInvariant(); LastLine = string.Empty; } diff --git a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs index fa3a5b52..3d67ac2e 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs @@ -74,6 +74,8 @@ public void CloseFile () public bool WriteToPipe (ILogLine textLine, int orgLineNum) { + ArgumentNullException.ThrowIfNull(textLine, nameof(textLine)); + try { lock (_fileNameLock) diff --git a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs index cca2efa2..d4c8e080 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs @@ -1,11 +1,10 @@ using System.Globalization; using LogExpert.Core.Callback; -using LogExpert.Core.Classes.Filter; using NLog; -namespace LogExpert.Classes.Filter; +namespace LogExpert.Core.Classes.Filter; public delegate void ProgressCallback (int lineCount); @@ -101,7 +100,8 @@ public async void DoFilter (FilterParams filterParams, int startLine, int maxCou } _logger.Info(CultureInfo.InvariantCulture, "FilterStarter starts worker for line {0}, lineCount {1}", workStartLine, interval); - await Task.Run(() => DoWork(filterParams, workStartLine, interval, ThreadProgressCallback)).ContinueWith(FilterDoneCallback); + var filter = await Task.Run(() => DoWork(filterParams, workStartLine, interval, ThreadProgressCallback)).ConfigureAwait(false); + FilterDoneCallback(filter); workStartLine += interval; } @@ -109,7 +109,7 @@ public async void DoFilter (FilterParams filterParams, int startLine, int maxCou // wait for worker threads completion if (handles.Length > 0) { - WaitHandle.WaitAll(handles); + _ = WaitHandle.WaitAll(handles); } MergeResults(); @@ -147,46 +147,40 @@ private Filter DoWork (FilterParams filterParams, int startLine, int maxCount, P _logger.Info(CultureInfo.InvariantCulture, "Started Filter worker [{0}] for line {1}", Environment.CurrentManagedThreadId, startLine); // Give every thread own copies of ColumnizerCallback and FilterParams, because the state of the objects changes while filtering - FilterParams threadFilterParams = filterParams.CloneWithCurrentColumnizer(); + var threadFilterParams = filterParams.CloneWithCurrentColumnizer(); Filter filter = new((ColumnizerCallback)_callback.Clone()); lock (_filterWorkerList) { _filterWorkerList.Add(filter); } - if (_shouldStop) + if (!_shouldStop) { - return filter; - } - _ = filter.DoFilter(threadFilterParams, startLine, maxCount, progressCallback); - _logger.Info(CultureInfo.InvariantCulture, "Filter worker [{0}] for line {1} has completed.", Environment.CurrentManagedThreadId, startLine); + _ = filter.DoFilter(threadFilterParams, startLine, maxCount, progressCallback); + _logger.Info(CultureInfo.InvariantCulture, "Filter worker [{0}] for line {1} has completed.", Environment.CurrentManagedThreadId, startLine); - lock (_filterReadyList) - { - _filterReadyList.Add(filter); + lock (_filterReadyList) + { + _filterReadyList.Add(filter); + } } return filter; } - private void FilterDoneCallback (Task filterTask) + private void FilterDoneCallback (Filter filter) { - if (filterTask.IsCompleted) + lock (_filterReadyList) { - Filter filter = filterTask.Result; - - lock (_filterReadyList) - { - _filterReadyList.Add(filter); - } + _filterReadyList.Add(filter); } } private void MergeResults () { _logger.Info(CultureInfo.InvariantCulture, "Merging filter results."); - foreach (Filter filter in _filterReadyList) + foreach (var filter in _filterReadyList) { foreach (var lineNum in filter.FilterHitList) { @@ -195,6 +189,7 @@ private void MergeResults () _filterHitDict.Add(lineNum, lineNum); } } + foreach (var lineNum in filter.FilterResultLines) { if (!_filterResultDict.ContainsKey(lineNum)) @@ -202,6 +197,7 @@ private void MergeResults () _filterResultDict.Add(lineNum, lineNum); } } + foreach (var lineNum in filter.LastFilterLinesList) { if (!_lastFilterLinesDict.ContainsKey(lineNum)) @@ -210,6 +206,7 @@ private void MergeResults () } } } + FilterHitList.AddRange(_filterHitDict.Keys); FilterResultLines.AddRange(_filterResultDict.Keys); LastFilterLinesList.AddRange(_lastFilterLinesDict.Keys); diff --git a/src/LogExpert.Core/Classes/Util.cs b/src/LogExpert.Core/Classes/Util.cs index 14523f5b..c490fe67 100644 --- a/src/LogExpert.Core/Classes/Util.cs +++ b/src/LogExpert.Core/Classes/Util.cs @@ -63,6 +63,9 @@ public static string GetFileSizeAsText (long size) public static bool TestFilterCondition (FilterParams filterParams, ILogLine line, ILogLineColumnizerCallback columnizerCallback) { + ArgumentNullException.ThrowIfNull(filterParams, nameof(filterParams)); + ArgumentNullException.ThrowIfNull(line, nameof(line)); + if (filterParams.LastLine.Equals(line.FullLine, StringComparison.OrdinalIgnoreCase)) { return filterParams.LastResult; @@ -464,24 +467,24 @@ public static void AssertTrue (bool condition, string msg) private static bool TestFilterMatch (FilterParams filterParams, ILogLine line, ILogLineColumnizerCallback columnizerCallback) { - string lowerSearchText; + string normalizedSearchText; string searchText; Regex rex; if (filterParams.IsInRange) { - lowerSearchText = filterParams.LowerRangeSearchText; + normalizedSearchText = filterParams.NormalizedRangeSearchText; searchText = filterParams.RangeSearchText; rex = filterParams.RangeRex; } else { - lowerSearchText = filterParams.LowerSearchText; + normalizedSearchText = filterParams.NormalizedSearchText; searchText = filterParams.SearchText; rex = filterParams.Rex; } - if (searchText == null || lowerSearchText == null || searchText.Length == 0) + if (string.IsNullOrEmpty(searchText)) { return false; } @@ -502,7 +505,7 @@ private static bool TestFilterMatch (FilterParams filterParams, ILogLine line, I var prevValue = (string)filterParams.LastNonEmptyCols[colIndex]; if (prevValue != null) { - if (TestMatchSub(filterParams, prevValue, lowerSearchText, searchText, rex, + if (TestMatchSub(filterParams, prevValue, normalizedSearchText, searchText, rex, filterParams.ExactColumnMatch)) { found = true; @@ -517,7 +520,7 @@ private static bool TestFilterMatch (FilterParams filterParams, ILogLine line, I else { filterParams.LastNonEmptyCols[colIndex] = columns.ColumnValues[colIndex].FullValue; - if (TestMatchSub(filterParams, columns.ColumnValues[colIndex].FullValue, lowerSearchText, + if (TestMatchSub(filterParams, columns.ColumnValues[colIndex].FullValue, normalizedSearchText, searchText, rex, filterParams.ExactColumnMatch)) { @@ -531,7 +534,7 @@ private static bool TestFilterMatch (FilterParams filterParams, ILogLine line, I } else { - return TestMatchSub(filterParams, line.FullLine, lowerSearchText, searchText, rex, false); + return TestMatchSub(filterParams, line.FullLine, normalizedSearchText, searchText, rex, false); } } @@ -550,7 +553,7 @@ private static bool TestMatchSub (FilterParams filterParams, string line, string { if (exactMatch) { - if (line.ToLowerInvariant().Trim().Equals(lowerSearchText, StringComparison.Ordinal)) + if (line.ToUpperInvariant().Trim().Equals(lowerSearchText, StringComparison.Ordinal)) { return true; } diff --git a/src/LogExpert.Core/EventArguments/FilterListChangedEventArgs.cs b/src/LogExpert.Core/EventArguments/FilterListChangedEventArgs.cs index 610bf8f3..0512997a 100644 --- a/src/LogExpert.Core/EventArguments/FilterListChangedEventArgs.cs +++ b/src/LogExpert.Core/EventArguments/FilterListChangedEventArgs.cs @@ -1,13 +1,10 @@ - + using LogExpert.Core.Interface; namespace LogExpert.Core.EventArguments; -public class FilterListChangedEventArgs(ILogWindow logWindow) +//TODO: Move to UI +public class FilterListChangedEventArgs (ILogWindow logWindow) : EventArgs { - #region Properties - public ILogWindow LogWindow { get; } = logWindow; - - #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs index c50fee65..75ef3ae7 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs @@ -3,7 +3,6 @@ using System.Text; using System.Text.RegularExpressions; -using LogExpert.Classes.Filter; using LogExpert.Core.Callback; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Columnizer; @@ -800,7 +799,8 @@ private void CheckFilterAndHighlight (LogEventArgs e) var filterLineAdded = false; for (var i = filterStart; i < e.LineCount; ++i) { - ILogLine line = _logFileReader.GetLogLine(i); + var line = _logFileReader.GetLogLine(i); + //TODO: Why line can equal null here? Prevent this from happening and replace the check with an exception throw if (line == null) { return; @@ -1977,7 +1977,6 @@ private void FilterSearch () if (filterComboBox.Text.Length == 0) { _filterParams.SearchText = string.Empty; - _filterParams.LowerSearchText = string.Empty; _filterParams.IsRangeSearch = false; ClearFilterList(); filterSearchButton.Image = null; @@ -1995,7 +1994,6 @@ private async void FilterSearch (string text) FireCancelHandlers(); // make sure that there's no other filter running (maybe from filter restore) _filterParams.SearchText = text; - _filterParams.LowerSearchText = text.ToLowerInvariant(); ConfigManager.Settings.FilterHistoryList.Remove(text); ConfigManager.Settings.FilterHistoryList.Insert(0, text); var maxHistory = ConfigManager.Settings.Preferences.MaximumFilterEntries; From b007590cf24aabf3cbd2f965330c447ec6502060 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Wed, 18 Jun 2025 23:33:02 +0300 Subject: [PATCH 103/142] Fixed CR issues --- src/LogExpert.Core/Classes/Filter/FilterPipe.cs | 1 + src/LogExpert.Core/Classes/Filter/FilterStarter.cs | 8 -------- src/LogExpert.Core/Classes/Util.cs | 1 + src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs | 2 +- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs index 3d67ac2e..895872c3 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterPipe.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterPipe.cs @@ -72,6 +72,7 @@ public void CloseFile () } } + //TOOD: check if the callers are checking for null before calling public bool WriteToPipe (ILogLine textLine, int orgLineNum) { ArgumentNullException.ThrowIfNull(textLine, nameof(textLine)); diff --git a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs index d4c8e080..f09a881c 100644 --- a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs +++ b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs @@ -85,7 +85,6 @@ public async void DoFilter (FilterParams filterParams, int startLine, int maxCou } var workStartLine = startLine; - List handleList = []; _progressLineCount = 0; _progressCallback = progressCallback; while (workStartLine < startLine + maxCount) @@ -105,13 +104,6 @@ public async void DoFilter (FilterParams filterParams, int startLine, int maxCou workStartLine += interval; } - WaitHandle[] handles = [.. handleList]; - // wait for worker threads completion - if (handles.Length > 0) - { - _ = WaitHandle.WaitAll(handles); - } - MergeResults(); } diff --git a/src/LogExpert.Core/Classes/Util.cs b/src/LogExpert.Core/Classes/Util.cs index c490fe67..17c317ba 100644 --- a/src/LogExpert.Core/Classes/Util.cs +++ b/src/LogExpert.Core/Classes/Util.cs @@ -61,6 +61,7 @@ public static string GetFileSizeAsText (long size) : string.Empty + $"{size / 1048576.0:0.00}" + " MB"; } + //TOOD: check if the callers are checking for null before calling public static bool TestFilterCondition (FilterParams filterParams, ILogLine line, ILogLineColumnizerCallback columnizerCallback) { ArgumentNullException.ThrowIfNull(filterParams, nameof(filterParams)); diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs index 75ef3ae7..7af73210 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs @@ -800,7 +800,7 @@ private void CheckFilterAndHighlight (LogEventArgs e) for (var i = filterStart; i < e.LineCount; ++i) { var line = _logFileReader.GetLogLine(i); - //TODO: Why line can equal null here? Prevent this from happening and replace the check with an exception throw + //TODO: Why line can be equal null here? Need to understand all the situations and handle them correctlly. Prevent this from happening and replace the check with an exception throw if (line == null) { return; From 2fd45c9faa600d8a8aa8896a5abed2538abe693d Mon Sep 17 00:00:00 2001 From: Hirogen Date: Thu, 19 Jun 2025 19:42:11 +0200 Subject: [PATCH 104/142] review comments --- src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs | 4 ++-- .../Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs | 9 +++------ src/LogExpert.UI/Entities/PaintHelper.cs | 1 - 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs index c8999ac2..ea2fa9f8 100644 --- a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs @@ -275,7 +275,7 @@ private void OnPatternHitsDataGridViewCurrentCellChanged (object sender, EventAr contentDataGridView.RowCount = _currentBlock.TargetEnd - _currentBlock.TargetStart + 1; contentDataGridView.Refresh(); contentDataGridView.CurrentCell = contentDataGridView.Rows[0].Cells[0]; - blockLinesLabel.Text = "" + contentDataGridView.RowCount; + blockLinesLabel.Text = $"{contentDataGridView.RowCount}"; } private void OnContentDataGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e) @@ -361,7 +361,7 @@ private void OnSetRangeButtonClick (object sender, EventArgs e) { _logWindow.PatternStatisticSelectRange(_patternArgs); recalcButton.Enabled = true; - rangeLabel.Text = $"Start: {_patternArgs.StartLine} \r\nEnd: {_patternArgs.EndLine}"; + rangeLabel.Text = $"Start: {_patternArgs.StartLine}\nEnd: {_patternArgs.EndLine}"; } #endregion diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs index b49b1cda..587414f2 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs @@ -706,13 +706,10 @@ private void OnCloseThisTabToolStripMenuItemClick (object sender, EventArgs e) [SupportedOSPlatform("windows")] private void OnCloseOtherTabsToolStripMenuItemClick (object sender, EventArgs e) { - List closeList = []; - lock (_logWindowList) - { - closeList = [.. dockPanel.Contents + var closeList = dockPanel.Contents .OfType() - .Where(content => content != dockPanel.ActiveContent)]; - } + .Where(content => content != dockPanel.ActiveContent) + .ToList(); foreach (var logWindow in closeList) { diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index ae67258b..b68c53ca 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -11,7 +11,6 @@ namespace LogExpert.UI.Entities; //TOOD: This whole class should be refactored and rethought -//TODO: This class should not knoow ConfigManager? internal static class PaintHelper { #region Fields From 0bbe6cd799f3c04a6f9607ff6048c453215d98bb Mon Sep 17 00:00:00 2001 From: Hirogen Date: Thu, 19 Jun 2025 20:00:22 +0200 Subject: [PATCH 105/142] more review comments --- global.json | 4 ++-- src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs | 2 +- src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs | 2 +- src/LogExpert.UI/Dialogs/BookmarkWindow.cs | 2 +- src/LogExpert.UI/Entities/PaintHelper.cs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/global.json b/global.json index 04639674..4c686a52 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "v8.0.314" + "version": "9.0.301" } -} +} \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs index 25ffba61..9150a4a2 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs @@ -401,7 +401,7 @@ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPainti { var entry = FindFirstNoWordMatchHilightEntry(line); e.Graphics.SetClip(e.CellBounds); - if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) + if (e.State.HasFlag(DataGridViewElementStates.Selected)) { using var brush = PaintHelper.GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); e.Graphics.FillRectangle(brush, e.CellBounds); diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs index 5904c375..5f1a9832 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs @@ -401,7 +401,7 @@ public void CellPainting (BufferedDataGridView gridView, int rowIndex, DataGridV var entry = FindFirstNoWordMatchHilightEntry(line); e.Graphics.SetClip(e.CellBounds); - if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) + if (e.State.HasFlag(DataGridViewElementStates.Selected)) { using var brush = PaintHelper.GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); e.Graphics.FillRectangle(brush, e.CellBounds); diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs index 61648116..5e6bad97 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs @@ -235,7 +235,7 @@ private void SetFont (string fontName, float fontSize) private void CommentPainting (BufferedDataGridView gridView, DataGridViewCellPaintingEventArgs e) { - if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) + if (e.State.HasFlag(DataGridViewElementStates.Selected)) { using var brush = PaintHelper.GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); e.Graphics.FillRectangle(brush, e.CellBounds); diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index b68c53ca..0454c5cd 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -37,7 +37,7 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri var entry = logPaintCtx.FindHighlightEntry(line, true); e.Graphics.SetClip(e.CellBounds); - if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) + if (e.State.HasFlag(DataGridViewElementStates.Selected)) { using var brush = GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); e.Graphics.FillRectangle(brush, e.CellBounds); From f096885f118dca3c095f919f1ae8bc9bda29d266 Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Thu, 19 Jun 2025 20:57:32 +0200 Subject: [PATCH 106/142] Update test_dotnet.yml dotnet-version changed to 9.0.x --- .github/workflows/test_dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_dotnet.yml b/.github/workflows/test_dotnet.yml index 57c53a4e..7e834ded 100644 --- a/.github/workflows/test_dotnet.yml +++ b/.github/workflows/test_dotnet.yml @@ -19,7 +19,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Restore dependencies run: dotnet restore working-directory: src From 7e8783a31c958dcc2bd22aa557e2fe9137432ed4 Mon Sep 17 00:00:00 2001 From: Randall Flagg Date: Fri, 20 Jun 2025 01:51:37 +0300 Subject: [PATCH 107/142] Organize solution and project files to be more streamlined --- build/Build.cs | 8 +-- build/_build.csproj | 1 - src/AutoColumnizer/AutoColumnizer.csproj | 25 +-------- src/AutoColumnizer/Properties/AssemblyInfo.cs | 6 --- .../ColumnizerLib.UnitTests.csproj | 8 +-- .../Properties/AssemblyInfo.cs | 13 ----- src/ColumnizerLib/ColumnizerLib.csproj | 32 ++---------- src/ColumnizerLib/ColumnizerLib.nuspec | 2 +- src/CsvColumnizer/CsvColumnizer.csproj | 34 ++---------- src/CsvColumnizer/Properties/AssemblyInfo.cs | 6 --- src/DefaultPlugins/DefaultPlugins.csproj | 33 ++---------- src/Directory.Build.props | 32 +++++++++++- .../FlashIconHighlighter.csproj | 33 ++---------- .../GlassfishColumnizer.csproj | 35 ++----------- .../Properties/AssemblyInfo.cs | 6 --- src/JsonColumnizer/JsonColumnizer.csproj | 37 ++----------- src/JsonColumnizer/Properties/AssemblyInfo.cs | 6 --- .../JsonCompactColumnizer.csproj | 36 ++----------- .../Properties/AssemblyInfo.cs | 6 --- .../Log4jXmlColumnizer.csproj | 30 ++--------- src/LogExpert.Core/LogExpert.Core.csproj | 14 ----- src/LogExpert.Core/Properties/AssemblyInfo.cs | 3 ++ .../LogExpert.Resources.csproj | 13 ----- src/LogExpert.Tests/LogExpert.Tests.csproj | 49 +++++++----------- .../Properties/AssemblyInfo.cs | 10 ---- src/LogExpert.UI/LogExpert.UI.csproj | 22 +++----- src/LogExpert.sln | 4 +- src/LogExpert/LogExpert.csproj | 20 ------- src/LogExpert/Properties/AssemblyInfo.cs | 1 - .../LogExpert.PluginRegistry.csproj | 15 +----- .../Properties/AssemblyInfo.cs | 12 ----- .../RegexColumnizer.UnitTests.csproj | 15 +++--- src/RegexColumnizer/RegexColumnizer.csproj | 31 ++--------- .../Columnizer/Properties/AssemblyInfo.cs | 36 ------------- .../Properties/AssemblyInfo.cs | 36 ------------- .../Properties/AssemblyInfo.cs | 6 --- .../SftpFileSystemx64.csproj | 37 +++---------- .../Properties/AssemblyInfo.cs | 6 --- .../SftpFileSystemx86.csproj | 23 ++------ .../{AssemblyVersion.cs => AssemblyInfo.cs} | 25 ++++----- src/Solution Items/Key.Public.snk | Bin 0 -> 160 bytes 41 files changed, 136 insertions(+), 631 deletions(-) delete mode 100644 src/AutoColumnizer/Properties/AssemblyInfo.cs delete mode 100644 src/ColumnizerLib.UnitTests/Properties/AssemblyInfo.cs delete mode 100644 src/CsvColumnizer/Properties/AssemblyInfo.cs delete mode 100644 src/GlassfishColumnizer/Properties/AssemblyInfo.cs delete mode 100644 src/JsonColumnizer/Properties/AssemblyInfo.cs delete mode 100644 src/JsonCompactColumnizer/Properties/AssemblyInfo.cs create mode 100644 src/LogExpert.Core/Properties/AssemblyInfo.cs delete mode 100644 src/LogExpert.Tests/Properties/AssemblyInfo.cs delete mode 100644 src/LogExpert/Properties/AssemblyInfo.cs delete mode 100644 src/RegexColumnizer.UnitTests/Properties/AssemblyInfo.cs delete mode 100644 src/SDK/Columnizer/Columnizer/Properties/AssemblyInfo.cs delete mode 100644 src/SDK/Log4jXmlColumnizer/Properties/AssemblyInfo.cs delete mode 100644 src/SftpFileSystemx64/Properties/AssemblyInfo.cs delete mode 100644 src/SftpFileSystemx86/Properties/AssemblyInfo.cs rename src/Solution Items/{AssemblyVersion.cs => AssemblyInfo.cs} (86%) create mode 100644 src/Solution Items/Key.Public.snk diff --git a/build/Build.cs b/build/Build.cs index fc83e858..0e700887 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -245,9 +245,9 @@ protected override void OnBuildInitialized() { Log.Information($"AssemblyVersion {VersionString}\r\nAssemblyFileVersion {VersionFileString}\r\nAssemblyInformationalVersion {VersionInformationString}"); - AbsolutePath assemblyVersion = SourceDirectory / "Solution Items" / "AssemblyVersion.cs"; + AbsolutePath assemblyInfo = SourceDirectory / "Solution Items" / "AssemblyInfo.cs"; - string text = assemblyVersion.ReadAllText(); + string text = assemblyInfo.ReadAllText(); Regex configurationRegex = AssemblyConfiguration(); Regex assemblyVersionRegex = AssemblyVersion(); Regex assemblyFileVersionRegex = AssemblyFileVersion(); @@ -258,11 +258,11 @@ protected override void OnBuildInitialized() text = assemblyFileVersionRegex.Replace(text, (match) => ReplaceVersionMatch(match, VersionFileString)); text = assemblyInformationalVersionRegex.Replace(text, (match) => ReplaceVersionMatch(match, VersionInformationString)); - Log.Verbose("Content of AssemblyVersion file"); + Log.Verbose("Content of AssemblyInfo.cs file"); Log.Verbose(text); Log.Verbose("End of Content"); - assemblyVersion.WriteAllText(text); + assemblyInfo.WriteAllText(text); SourceDirectory.GlobFiles("**sftp-plugin/*.cs").ForEach(file => { diff --git a/build/_build.csproj b/build/_build.csproj index d11d75f7..d024e268 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -3,7 +3,6 @@ Exe net8.0 - false False CS0649;CS0169 diff --git a/src/AutoColumnizer/AutoColumnizer.csproj b/src/AutoColumnizer/AutoColumnizer.csproj index e77962e3..3f5dd983 100644 --- a/src/AutoColumnizer/AutoColumnizer.csproj +++ b/src/AutoColumnizer/AutoColumnizer.csproj @@ -1,33 +1,10 @@  net8.0 - Library - false + AutoColumnizer - true - ..\Solution Items\Key.snk - false - false $(SolutionDir)..\bin\$(Configuration)\plugins - - False - - - True - - - - - Properties\AssemblyVersion.cs - - - - - - Key.snk - - diff --git a/src/AutoColumnizer/Properties/AssemblyInfo.cs b/src/AutoColumnizer/Properties/AssemblyInfo.cs deleted file mode 100644 index 59b88e6a..00000000 --- a/src/AutoColumnizer/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("b57259a3-4ed7-4f8b-a252-29e799a56b9e")] \ No newline at end of file diff --git a/src/ColumnizerLib.UnitTests/ColumnizerLib.UnitTests.csproj b/src/ColumnizerLib.UnitTests/ColumnizerLib.UnitTests.csproj index 339b9ce6..af5aa1ac 100644 --- a/src/ColumnizerLib.UnitTests/ColumnizerLib.UnitTests.csproj +++ b/src/ColumnizerLib.UnitTests/ColumnizerLib.UnitTests.csproj @@ -1,16 +1,10 @@  net8.0 - Library + true - false ColumnizerLib.UnitTests Microsoft - ColumnizerLib.UnitTests - Copyright © Microsoft 2018 - 1.0.0.0 - 1.0.0.0 - false bin\$(Configuration) diff --git a/src/ColumnizerLib.UnitTests/Properties/AssemblyInfo.cs b/src/ColumnizerLib.UnitTests/Properties/AssemblyInfo.cs deleted file mode 100644 index 5496df04..00000000 --- a/src/ColumnizerLib.UnitTests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("0dbbcbef-4a91-4031-aeab-b7eee802f496")] diff --git a/src/ColumnizerLib/ColumnizerLib.csproj b/src/ColumnizerLib/ColumnizerLib.csproj index c341d269..960aa76e 100644 --- a/src/ColumnizerLib/ColumnizerLib.csproj +++ b/src/ColumnizerLib/ColumnizerLib.csproj @@ -1,35 +1,9 @@  + net8.0 - Library - Properties - LogExpert - false + $(SolutionDir)..\bin\Docs\ColumnizerLib.xml - false - false - $(SolutionDir)..\bin\$(Configuration) - - False - - - True - - - true - - - ..\Solution Items\Key.snk - - - - Properties\AssemblyVersion.cs - - - - - Key.snk - - + diff --git a/src/ColumnizerLib/ColumnizerLib.nuspec b/src/ColumnizerLib/ColumnizerLib.nuspec index 043d6dcf..99e650fe 100644 --- a/src/ColumnizerLib/ColumnizerLib.nuspec +++ b/src/ColumnizerLib/ColumnizerLib.nuspec @@ -11,7 +11,7 @@ false Columnizer Lib for Logexpert plugins See https://github.com/zarunbal/LogExpert/releases/tag/v$version$ - Copyright 2019 + Copyright 2025 LogExpert Columnizer \ No newline at end of file diff --git a/src/CsvColumnizer/CsvColumnizer.csproj b/src/CsvColumnizer/CsvColumnizer.csproj index 070afa9e..4e54cc43 100644 --- a/src/CsvColumnizer/CsvColumnizer.csproj +++ b/src/CsvColumnizer/CsvColumnizer.csproj @@ -2,45 +2,21 @@ net8.0-windows true - Library - false - false + true true - false $(SolutionDir)..\bin\$(Configuration)\plugins true + CsvColumnizer - - False - - - True - - - true - - - ..\Solution Items\Key.snk - - - - Properties\AssemblyVersion.cs - - + - - - Key.snk - - + - - CsvColumnizer - + diff --git a/src/CsvColumnizer/Properties/AssemblyInfo.cs b/src/CsvColumnizer/Properties/AssemblyInfo.cs deleted file mode 100644 index d689fe35..00000000 --- a/src/CsvColumnizer/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("d939a82b-591f-4403-9c9b-7d1f54043019")] \ No newline at end of file diff --git a/src/DefaultPlugins/DefaultPlugins.csproj b/src/DefaultPlugins/DefaultPlugins.csproj index 1b0a14ea..20255a67 100644 --- a/src/DefaultPlugins/DefaultPlugins.csproj +++ b/src/DefaultPlugins/DefaultPlugins.csproj @@ -1,41 +1,14 @@  net8.0 - False - Library - false - LogExpert - false - False - False - false + $(SolutionDir)..\bin\$(Configuration)\plugins - - False - - - True - - - true - - - ..\Solution Items\Key.snk - - - - Properties\AssemblyVersion.cs - - + - - - Key.snk - - + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 11a29ac4..85213014 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -6,5 +6,33 @@ 2.0.0.0-rc1 Hirogen, zarunbal, RandallFlagg, TheNicker Log Expert - - \ No newline at end of file + enable + enable + false + false + ..\Solution Items\Key.snk + false + Properties + LogExpert + false + + true + true + LogExpert + Copyright © LogExpert 2025 + false + false + false + false + + FIX ME - AssemblyTitle! + FIX ME - Description! + + + + + + + + + diff --git a/src/FlashIconHighlighter/FlashIconHighlighter.csproj b/src/FlashIconHighlighter/FlashIconHighlighter.csproj index f86abe7a..50489d9a 100644 --- a/src/FlashIconHighlighter/FlashIconHighlighter.csproj +++ b/src/FlashIconHighlighter/FlashIconHighlighter.csproj @@ -1,41 +1,16 @@  + net8.0-windows true - Library - false - false true true - false $(SolutionDir)..\bin\$(Configuration)\plugins + true - - False - - - True - - - true - - - ..\Solution Items\Key.snk - - - - Properties\AssemblyVersion.cs - - + - - - Key.snk - - - - true - + diff --git a/src/GlassfishColumnizer/GlassfishColumnizer.csproj b/src/GlassfishColumnizer/GlassfishColumnizer.csproj index 5bd15728..23bf3af2 100644 --- a/src/GlassfishColumnizer/GlassfishColumnizer.csproj +++ b/src/GlassfishColumnizer/GlassfishColumnizer.csproj @@ -1,39 +1,14 @@  net8.0 - Library - false - false - false + $(SolutionDir)..\bin\$(Configuration)\plugins + GlassfishColumnizer + Glassfish logfile support for LogExpert - - False - - - True - - - true - - - ..\Solution Items\Key.snk - - - - Properties\AssemblyVersion.cs - - + - - - Key.snk - - - - GlassfishColumnizer - Glassfish logfile support for LogExpert - + diff --git a/src/GlassfishColumnizer/Properties/AssemblyInfo.cs b/src/GlassfishColumnizer/Properties/AssemblyInfo.cs deleted file mode 100644 index 3346c8f5..00000000 --- a/src/GlassfishColumnizer/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("ffea3945-9d17-476d-b565-268f0700704c")] \ No newline at end of file diff --git a/src/JsonColumnizer/JsonColumnizer.csproj b/src/JsonColumnizer/JsonColumnizer.csproj index d53c1966..0092f405 100644 --- a/src/JsonColumnizer/JsonColumnizer.csproj +++ b/src/JsonColumnizer/JsonColumnizer.csproj @@ -1,44 +1,17 @@  net8.0 - false - Library - false - false - false - false - false + $(SolutionDir)..\bin\$(Configuration)\plugins + JsonColumnizer - - False - - - True - - - true - - - ..\Solution Items\Key.snk - - - - Properties\AssemblyVersion.cs - - + - - - Key.snk - - - - JsonColumnizer - + + diff --git a/src/JsonColumnizer/Properties/AssemblyInfo.cs b/src/JsonColumnizer/Properties/AssemblyInfo.cs deleted file mode 100644 index 113a680e..00000000 --- a/src/JsonColumnizer/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("4C0B11AE-BCAF-492C-AFE7-53C9B79148BE")] \ No newline at end of file diff --git a/src/JsonCompactColumnizer/JsonCompactColumnizer.csproj b/src/JsonCompactColumnizer/JsonCompactColumnizer.csproj index 4a9f2836..48c72fcc 100644 --- a/src/JsonCompactColumnizer/JsonCompactColumnizer.csproj +++ b/src/JsonCompactColumnizer/JsonCompactColumnizer.csproj @@ -1,45 +1,17 @@  net8.0 - false - Library - false + JsonColumnizer - false - false - false - false $(SolutionDir)..\bin\$(Configuration)\plugins + JsonCompactColumnizer - - False - - - True - - - true - - - ..\Solution Items\Key.snk - - - - Properties\AssemblyVersion.cs - - + - - - Key.snk - - - - JsonCompactColumnizer - + diff --git a/src/JsonCompactColumnizer/Properties/AssemblyInfo.cs b/src/JsonCompactColumnizer/Properties/AssemblyInfo.cs deleted file mode 100644 index 47c642d5..00000000 --- a/src/JsonCompactColumnizer/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("6D5A3E51-4D0F-452E-8A86-DDCC313F3A7F")] \ No newline at end of file diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.csproj b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.csproj index 189b5254..3008beb6 100644 --- a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.csproj +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.csproj @@ -2,42 +2,20 @@ net8.0-windows true - Library - false - false + true true - false $(SolutionDir)..\bin\$(Configuration)\plugins - - False - - - True - - - true - - - ..\Solution Items\Key.snk - - - - Properties\AssemblyVersion.cs - - + + - - - Key.snk - - + diff --git a/src/LogExpert.Core/LogExpert.Core.csproj b/src/LogExpert.Core/LogExpert.Core.csproj index c31d226e..094d3861 100644 --- a/src/LogExpert.Core/LogExpert.Core.csproj +++ b/src/LogExpert.Core/LogExpert.Core.csproj @@ -2,23 +2,9 @@ net8.0 - enable - enable - false true - True - ..\Solution Items\Key.snk - false - - - - - - - - diff --git a/src/LogExpert.Core/Properties/AssemblyInfo.cs b/src/LogExpert.Core/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..1af21449 --- /dev/null +++ b/src/LogExpert.Core/Properties/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("LogExpert.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100619e9beea345a3bb5e15f55b29ddf40d96e9bb473ae58304fc63dfb3e9c94d8944bb7e45324ee0bef3e345dccba79b0bf64b85a128a7f261861899add639218ddaeb2acc6fcc746d6acb5bb212d375a0967756af192cfdb6cf0bff666a0fe535600abda860d3eafaff4ef1c9b5710181f72d996ca9c29ed64bae4a5fd916dea5")] \ No newline at end of file diff --git a/src/LogExpert.Resources/LogExpert.Resources.csproj b/src/LogExpert.Resources/LogExpert.Resources.csproj index 8786f4f1..553388a5 100644 --- a/src/LogExpert.Resources/LogExpert.Resources.csproj +++ b/src/LogExpert.Resources/LogExpert.Resources.csproj @@ -2,17 +2,8 @@ net8.0 - enable - enable - false - True - ..\Solution Items\Key.snk - - - - PreserveNewest @@ -26,10 +17,6 @@ - - - - diff --git a/src/LogExpert.Tests/LogExpert.Tests.csproj b/src/LogExpert.Tests/LogExpert.Tests.csproj index 8e058cf3..71fdb0dc 100644 --- a/src/LogExpert.Tests/LogExpert.Tests.csproj +++ b/src/LogExpert.Tests/LogExpert.Tests.csproj @@ -1,34 +1,34 @@  + net8.0-windows true - Library + true - false true true - false bin\$(Configuration) true - - - true - - - ..\Solution Items\Key.snk LogExpert.Tests - LogExpert.Tests - Copyright © 2018 - 1.0.0.0 - 1.0.0.0 + + + + + + + + + + - + + PreserveNewest @@ -38,6 +38,9 @@ PreserveNewest + + + PreserveNewest @@ -59,16 +62,6 @@ PreserveNewest - - - - - - - - - - PreserveNewest @@ -78,16 +71,9 @@ PreserveNewest - - PreserveNewest - - - - Key.snk - PreserveNewest @@ -98,4 +84,5 @@ PreserveNewest + diff --git a/src/LogExpert.Tests/Properties/AssemblyInfo.cs b/src/LogExpert.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 756a12ef..00000000 --- a/src/LogExpert.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: ComVisible(false)] - -[assembly: Guid("1ffb09a8-dae4-4deb-aff6-8bae6d01c7ac")] -[assembly: System.Runtime.Versioning.SupportedOSPlatform("windows")] \ No newline at end of file diff --git a/src/LogExpert.UI/LogExpert.UI.csproj b/src/LogExpert.UI/LogExpert.UI.csproj index 145fbbc4..f01a1266 100644 --- a/src/LogExpert.UI/LogExpert.UI.csproj +++ b/src/LogExpert.UI/LogExpert.UI.csproj @@ -1,21 +1,19 @@  - True - ..\Solution Items\Key.snk + true true true - false - enable - enable - false - True net8.0-windows true - + + + + + @@ -24,14 +22,6 @@ - - - - - - - - Always diff --git a/src/LogExpert.sln b/src/LogExpert.sln index d4494be0..e215b839 100644 --- a/src/LogExpert.sln +++ b/src/LogExpert.sln @@ -24,7 +24,9 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DE6375A4-B4C4-4620-8FFB-B9D5A4E21144}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig - Solution Items\AssemblyVersion.cs = Solution Items\AssemblyVersion.cs + Solution Items\AssemblyInfo.cs = Solution Items\AssemblyInfo.cs + Directory.Build.props = Directory.Build.props + Directory.Packages.props = Directory.Packages.props Solution Items\usedComponents.json = Solution Items\usedComponents.json EndProjectSection EndProject diff --git a/src/LogExpert/LogExpert.csproj b/src/LogExpert/LogExpert.csproj index d8c317de..20ea2108 100644 --- a/src/LogExpert/LogExpert.csproj +++ b/src/LogExpert/LogExpert.csproj @@ -1,39 +1,19 @@  - False - False PerMonitorV2 logexpert.ico - ..\Solution Items\Key.snk True $(SolutionDir)..\bin\Docs\LogExpert.xml True True - False Auto - enable - False $(SolutionDir)..\bin\$(Configuration) WinExe - True net8.0-windows False - - False - - - True - - - - Properties\AssemblyVersion.cs - - - Key.snk - Always diff --git a/src/LogExpert/Properties/AssemblyInfo.cs b/src/LogExpert/Properties/AssemblyInfo.cs deleted file mode 100644 index 69e5aee9..00000000 --- a/src/LogExpert/Properties/AssemblyInfo.cs +++ /dev/null @@ -1 +0,0 @@ -[assembly: System.Runtime.Versioning.SupportedOSPlatform("windows")] \ No newline at end of file diff --git a/src/PluginRegistry/LogExpert.PluginRegistry.csproj b/src/PluginRegistry/LogExpert.PluginRegistry.csproj index 63c4fbbe..cf09bc7b 100644 --- a/src/PluginRegistry/LogExpert.PluginRegistry.csproj +++ b/src/PluginRegistry/LogExpert.PluginRegistry.csproj @@ -2,27 +2,14 @@ net8.0 - enable - false - enable - True - ..\Solution Items\Key.snk - - - - - + - - - - diff --git a/src/RegexColumnizer.UnitTests/Properties/AssemblyInfo.cs b/src/RegexColumnizer.UnitTests/Properties/AssemblyInfo.cs deleted file mode 100644 index 323361a8..00000000 --- a/src/RegexColumnizer.UnitTests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("FBFB598D-B94A-4AD3-A355-0D5A618CEEE3")] diff --git a/src/RegexColumnizer.UnitTests/RegexColumnizer.UnitTests.csproj b/src/RegexColumnizer.UnitTests/RegexColumnizer.UnitTests.csproj index 50c96688..be3904ad 100644 --- a/src/RegexColumnizer.UnitTests/RegexColumnizer.UnitTests.csproj +++ b/src/RegexColumnizer.UnitTests/RegexColumnizer.UnitTests.csproj @@ -1,24 +1,21 @@  net8.0-windows - Library + true - false - false + + bin\$(Configuration) true - true + - ..\Solution Items\Key.snk + RegexColumnizer.UnitTests - RegexColumnizer.UnitTests - Copyright © 2023 - 1.0.0.0 - 1.0.0.0 + diff --git a/src/RegexColumnizer/RegexColumnizer.csproj b/src/RegexColumnizer/RegexColumnizer.csproj index 5cbe4fe9..b85e7eac 100644 --- a/src/RegexColumnizer/RegexColumnizer.csproj +++ b/src/RegexColumnizer/RegexColumnizer.csproj @@ -2,37 +2,14 @@ net8.0-windows true - Library - false + true - false true - false $(SolutionDir)..\bin\$(Configuration)\plugins - - False - - - True - - - true - - - ..\Solution Items\Key.snk - - - - Properties\AssemblyVersion.cs - - + - - - Key.snk - - - + + \ No newline at end of file diff --git a/src/SDK/Columnizer/Columnizer/Properties/AssemblyInfo.cs b/src/SDK/Columnizer/Columnizer/Properties/AssemblyInfo.cs deleted file mode 100644 index 29495b39..00000000 --- a/src/SDK/Columnizer/Columnizer/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// Allgemeine Informationen über eine Assembly werden über die folgenden -// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, -// die mit einer Assembly verknüpft sind. -[assembly: AssemblyTitle("Columnizer")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Columnizer")] -[assembly: AssemblyCopyright("Copyright © 2008")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar -// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von -// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. -[assembly: ComVisible(false)] - -// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird -[assembly: Guid("cbf6cfb3-b9b7-4596-aba4-f622e350bed1")] - -// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: -// -// Hauptversion -// Nebenversion -// Buildnummer -// Revision -// -// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern -// übernehmen, indem Sie "*" eingeben: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/SDK/Log4jXmlColumnizer/Properties/AssemblyInfo.cs b/src/SDK/Log4jXmlColumnizer/Properties/AssemblyInfo.cs deleted file mode 100644 index e77e09f6..00000000 --- a/src/SDK/Log4jXmlColumnizer/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// Allgemeine Informationen über eine Assembly werden über die folgenden -// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, -// die mit einer Assembly verknüpft sind. -[assembly: AssemblyTitle("Log4jXmlColumnizer")] -[assembly: AssemblyDescription("XML logfile support for LogExpert")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Log4jXmlColumnizer")] -[assembly: AssemblyCopyright("Copyright © 2009 Hagen Raab")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar -// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von -// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. -[assembly: ComVisible(false)] - -// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird -[assembly: Guid("7e083fad-da9a-4962-870f-0f1676293961")] - -// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: -// -// Hauptversion -// Nebenversion -// Buildnummer -// Revision -// -// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern -// übernehmen, indem Sie "*" eingeben: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/SftpFileSystemx64/Properties/AssemblyInfo.cs b/src/SftpFileSystemx64/Properties/AssemblyInfo.cs deleted file mode 100644 index 458b8d80..00000000 --- a/src/SftpFileSystemx64/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; -[assembly: AssemblyCulture("")] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("6d67894f-87fd-40ad-bbce-0923fd38d0ff")] \ No newline at end of file diff --git a/src/SftpFileSystemx64/SftpFileSystemx64.csproj b/src/SftpFileSystemx64/SftpFileSystemx64.csproj index b9080834..751e2a0c 100644 --- a/src/SftpFileSystemx64/SftpFileSystemx64.csproj +++ b/src/SftpFileSystemx64/SftpFileSystemx64.csproj @@ -2,44 +2,23 @@ net8.0-windows true - Library + SftpFileSystem SftpFileSystem - false - false true true - false $(SolutionDir)..\bin\$(Configuration)\plugins + SftpFileSystem - - False - - - True - - - true - - - ..\Solution Items\Key.snk - - - - Properties\AssemblyVersion.cs - - + - - Key.snk - + + - - - + @@ -47,7 +26,5 @@ - - SftpFileSystem - + diff --git a/src/SftpFileSystemx86/Properties/AssemblyInfo.cs b/src/SftpFileSystemx86/Properties/AssemblyInfo.cs deleted file mode 100644 index 2d342d43..00000000 --- a/src/SftpFileSystemx86/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("3d01e923-5219-488b-b0a7-98521841e680")] \ No newline at end of file diff --git a/src/SftpFileSystemx86/SftpFileSystemx86.csproj b/src/SftpFileSystemx86/SftpFileSystemx86.csproj index b223e8ba..d6794794 100644 --- a/src/SftpFileSystemx86/SftpFileSystemx86.csproj +++ b/src/SftpFileSystemx86/SftpFileSystemx86.csproj @@ -2,23 +2,15 @@ net8.0-windows true - Library + SftpFileSystem SftpFileSystem - false true - false true SftpFileSystemx86 - false $(SolutionDir)..\bin\$(Configuration)\pluginsx86 - - False - - - True - + ConfigData.cs @@ -46,25 +38,20 @@ SftpLogFileInfo.cs - - Properties\AssemblyVersion.cs - + + - - - Key.snk - - + diff --git a/src/Solution Items/AssemblyVersion.cs b/src/Solution Items/AssemblyInfo.cs similarity index 86% rename from src/Solution Items/AssemblyVersion.cs rename to src/Solution Items/AssemblyInfo.cs index c7b9e075..29f6db81 100644 --- a/src/Solution Items/AssemblyVersion.cs +++ b/src/Solution Items/AssemblyInfo.cs @@ -1,12 +1,13 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyProduct("LogExpert")] -[assembly: AssemblyCopyright("Original work Copyright (c) 2008-2011 Hagen Raab\r\nModified work Copyright (c) 2025 Zarunbal|Hirogen and many others")] - -[assembly: AssemblyVersion("1.12.0")] -[assembly: AssemblyFileVersion("1.12.0")] -[assembly: AssemblyInformationalVersion("1.12.0")] - -[assembly: ComVisible(false)] +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyProduct("LogExpert")] +[assembly: AssemblyCopyright("Original work Copyright (c) 2008-2011 Hagen Raab\r\nModified work Copyright (c) 2025 Zarunbal|Hirogen and many others")] + +[assembly: AssemblyVersion("1.12.0")] +[assembly: AssemblyFileVersion("1.12.0")] +[assembly: AssemblyInformationalVersion("1.12.0")] + +[assembly: ComVisible(false)] +//warning CA1824: Mark assemblies with NeutralResourcesLanguageAttribute \ No newline at end of file diff --git a/src/Solution Items/Key.Public.snk b/src/Solution Items/Key.Public.snk new file mode 100644 index 0000000000000000000000000000000000000000..b9d1ac9528be91368a05f36088478e940f068e91 GIT binary patch literal 160 zcmV;R0AK$ABme*efB*oL000060ssI2Bme+XQ$aBR1ONa50097Do}2EYMWef374=&w z-SiEX>AOcd<%0zLW8bss$xVqwyM9G7PT;=t<3-%dr<)7*ONF5*r}ANj7@4isIU$YO z>nhA|%yeyP%UiM%({-ShcUG?%Ed9363;$+n59Kvr3caXc)9U*FPVvdLaRGt%Etzbo O!k*Sku1a6o7T%>(JV|!| literal 0 HcmV?d00001 From f700b5528288db6666bf5e175e0f6b038c2dd9fe Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sat, 21 Jun 2025 18:09:11 +0200 Subject: [PATCH 108/142] recombined all the forms, so they can be refactored better, and there are no longer resx problems when opening a form and visual studio creates a resx file --- .../Extensions/LogLineExtensions.cs | 2 +- .../Controls/LogWindow/LogWindow.cs | 7322 +++++++++++++++++ .../Controls/LogWindow/LogWindow.resx | 109 +- .../LogWindow/LogWindowEventHandlers.cs | 1723 ---- .../LogWindow/LogWindowEventHandlers.resx | 120 - .../Controls/LogWindow/LogWindowPrivate.cs | 3820 --------- .../Controls/LogWindow/LogWindowPublic.cs | 1827 ---- .../Dialogs/LogTabWindow/LogTabWindow.cs | 2787 +++++++ .../LogTabWindow/LogTabWindowEventHandlers.cs | 1094 --- .../LogTabWindow/LogTabWindowPrivate.cs | 1375 ---- .../LogTabWindow/LogTabWindowPublic.cs | 364 - src/LogExpert.UI/LogExpert.UI.csproj | 17 - 12 files changed, 10138 insertions(+), 10422 deletions(-) delete mode 100644 src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs delete mode 100644 src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.resx delete mode 100644 src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs delete mode 100644 src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs delete mode 100644 src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs delete mode 100644 src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs delete mode 100644 src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs diff --git a/src/ColumnizerLib/Extensions/LogLineExtensions.cs b/src/ColumnizerLib/Extensions/LogLineExtensions.cs index de081a34..2cebb987 100644 --- a/src/ColumnizerLib/Extensions/LogLineExtensions.cs +++ b/src/ColumnizerLib/Extensions/LogLineExtensions.cs @@ -1,4 +1,4 @@ -namespace LogExpert.Extensions; +namespace LogExpert.Extensions; //TODO: Move this to LogExpert.UI, change to internal and fix tests public static class LogLineExtensions diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index 3b839b1c..ec8f669d 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -1,7 +1,14 @@ +using System.ComponentModel; +using System.Globalization; using System.Runtime.Versioning; +using System.Text; +using System.Text.RegularExpressions; +using LogExpert.Classes.Filter; using LogExpert.Core.Callback; +using LogExpert.Core.Classes; using LogExpert.Core.Classes.Bookmark; +using LogExpert.Core.Classes.Columnizer; using LogExpert.Core.Classes.Filter; using LogExpert.Core.Classes.Highlight; using LogExpert.Core.Classes.Log; @@ -11,7 +18,10 @@ using LogExpert.Core.EventArguments; using LogExpert.Core.Interface; using LogExpert.Dialogs; +using LogExpert.Extensions; using LogExpert.UI.Dialogs; +using LogExpert.UI.Entities; +using LogExpert.UI.Extensions; using LogExpert.UI.Interface; using NLog; @@ -560,4 +570,7316 @@ void ILogWindow.WritePipeTab (IList lineEntryList, string title) WritePipeTab(lineEntryList, title); } #endif + + #region Event Handlers + + [SupportedOSPlatform("windows")] + private void AutoResizeFilterBox () + { + filterSplitContainer.SplitterDistance = filterComboBox.Left + filterComboBox.GetMaxTextWidth(); + } + + #region Events handler + + protected void OnProgressBarUpdate (ProgressEventArgs e) + { + ProgressBarUpdate?.Invoke(this, e); + } + + protected void OnStatusLine (StatusLineEventArgs e) + { + StatusLineEvent?.Invoke(this, e); + } + + protected void OnGuiState (GuiStateArgs e) + { + GuiStateUpdate?.Invoke(this, e); + } + + protected void OnTailFollowed (EventArgs e) + { + TailFollowed?.Invoke(this, e); + } + + protected void OnFileNotFound (EventArgs e) + { + FileNotFound?.Invoke(this, e); + } + + protected void OnFileRespawned (EventArgs e) + { + FileRespawned?.Invoke(this, e); + } + + protected void OnFilterListChanged (LogWindow source) + { + FilterListChanged?.Invoke(this, new FilterListChangedEventArgs(source)); + } + + protected void OnCurrentHighlightListChanged () + { + CurrentHighlightGroupChanged?.Invoke(this, new CurrentHighlightGroupChangedEventArgs(this, _currentHighlightGroup)); + } + + protected void OnBookmarkAdded () + { + BookmarkAdded?.Invoke(this, EventArgs.Empty); + } + + protected void OnBookmarkRemoved () + { + BookmarkRemoved?.Invoke(this, EventArgs.Empty); + } + + protected void OnBookmarkTextChanged (Bookmark bookmark) + { + BookmarkTextChanged?.Invoke(this, new BookmarkEventArgs(bookmark)); + } + + protected void OnColumnizerChanged (ILogLineColumnizer columnizer) + { + ColumnizerChanged?.Invoke(this, new ColumnizerEventArgs(columnizer)); + } + + protected void OnRegisterCancelHandler (IBackgroundProcessCancelHandler handler) + { + lock (_cancelHandlerList) + { + _cancelHandlerList.Add(handler); + } + } + + protected void OnDeRegisterCancelHandler (IBackgroundProcessCancelHandler handler) + { + lock (_cancelHandlerList) + { + _cancelHandlerList.Remove(handler); + } + } + + [SupportedOSPlatform("windows")] + private void OnLogWindowLoad (object sender, EventArgs e) + { + var setLastColumnWidth = _parentLogTabWin.Preferences.SetLastColumnWidth; + var lastColumnWidth = _parentLogTabWin.Preferences.LastColumnWidth; + var fontName = _parentLogTabWin.Preferences.FontName; + var fontSize = _parentLogTabWin.Preferences.FontSize; + + PreferencesChanged(fontName, fontSize, setLastColumnWidth, lastColumnWidth, true, SettingsFlags.GuiOrColors); + } + + [SupportedOSPlatform("windows")] + private void OnLogWindowDisposed (object sender, EventArgs e) + { + _waitingForClose = true; + _parentLogTabWin.HighlightSettingsChanged -= OnParentHighlightSettingsChanged; + _logFileReader?.DeleteAllContent(); + + FreeFromTimeSync(); + } + + [SupportedOSPlatform("windows")] + private void OnLogFileReaderLoadingStarted (object sender, LoadFileEventArgs e) + { + Invoke(LoadingStarted, e); + } + + [SupportedOSPlatform("windows")] + private void OnLogFileReaderFinishedLoading (object sender, EventArgs e) + { + //Thread.CurrentThread.Name = "FinishedLoading event thread"; + _logger.Info(CultureInfo.InvariantCulture, "Finished loading."); + _isLoading = false; + _isDeadFile = false; + if (!_waitingForClose) + { + Invoke(new MethodInvoker(LoadingFinished)); + Invoke(new MethodInvoker(LoadPersistenceData)); + Invoke(new MethodInvoker(SetGuiAfterLoading)); + _loadingFinishedEvent.Set(); + _externaLoadingFinishedEvent.Set(); + _timeSpreadCalc.SetLineCount(_logFileReader.LineCount); + + if (_reloadMemento != null) + { + Invoke(new PositionAfterReloadFx(PositionAfterReload), _reloadMemento); + } + + if (filterTailCheckBox.Checked) + { + _logger.Info(CultureInfo.InvariantCulture, "Refreshing filter view because of reload."); + Invoke(new MethodInvoker(FilterSearch)); // call on proper thread + } + + HandleChangedFilterList(); + } + + _reloadMemento = null; + } + + [SupportedOSPlatform("windows")] + private void OnLogFileReaderFileNotFound (object sender, EventArgs e) + { + if (!IsDisposed && !Disposing) + { + _logger.Info(CultureInfo.InvariantCulture, "Handling file not found event."); + _isDeadFile = true; + BeginInvoke(new MethodInvoker(LogfileDead)); + } + } + + [SupportedOSPlatform("windows")] + private void OnLogFileReaderRespawned (object sender, EventArgs e) + { + BeginInvoke(new MethodInvoker(LogfileRespawned)); + } + + [SupportedOSPlatform("windows")] + private void OnLogWindowClosing (object sender, CancelEventArgs e) + { + if (Preferences.AskForClose) + { + if (MessageBox.Show("Sure to close?", "LogExpert", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + return; + } + } + + SavePersistenceData(false); + CloseLogWindow(); + } + + [SupportedOSPlatform("windows")] + private void OnDataGridViewColumnDividerDoubleClick (object sender, DataGridViewColumnDividerDoubleClickEventArgs e) + { + e.Handled = true; + AutoResizeColumns(dataGridView); + } + + /** + * Event handler for the Load event from LogfileReader + */ + [SupportedOSPlatform("windows")] + private void OnLogFileReaderLoadFile (object sender, LoadFileEventArgs e) + { + if (e.NewFile) + { + _logger.Info(CultureInfo.InvariantCulture, "File created anew."); + + // File was new created (e.g. rollover) + _isDeadFile = false; + UnRegisterLogFileReaderEvents(); + dataGridView.CurrentCellChanged -= OnDataGridViewCurrentCellChanged; + MethodInvoker invoker = ReloadNewFile; + BeginInvoke(invoker); + //Thread loadThread = new Thread(new ThreadStart(ReloadNewFile)); + //loadThread.Start(); + _logger.Debug(CultureInfo.InvariantCulture, "Reloading invoked."); + } + else if (_isLoading) + { + BeginInvoke(UpdateProgress, e); + } + } + + private void OnFileSizeChanged (object sender, LogEventArgs e) + { + //OnFileSizeChanged(e); // now done in UpdateGrid() + _logger.Info(CultureInfo.InvariantCulture, "Got FileSizeChanged event. prevLines:{0}, curr lines: {1}", e.PrevLineCount, e.LineCount); + + // - now done in the thread that works on the event args list + //if (e.IsRollover) + //{ + // ShiftBookmarks(e.RolloverOffset); + // ShiftFilterPipes(e.RolloverOffset); + //} + + //UpdateGridCallback callback = new UpdateGridCallback(UpdateGrid); + //this.BeginInvoke(callback, new object[] { e }); + lock (_logEventArgsList) + { + _logEventArgsList.Add(e); + _logEventArgsEvent.Set(); + } + } + + [SupportedOSPlatform("windows")] + private void OnDataGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e) + { + var startCount = CurrentColumnizer?.GetColumnCount() ?? 0; + + e.Value = GetCellValue(e.RowIndex, e.ColumnIndex); + + // The new column could be find dynamically. + // Only support add new columns for now. + // TODO: Support reload all columns? + if (CurrentColumnizer != null && CurrentColumnizer.GetColumnCount() > startCount) + { + for (var i = startCount; i < CurrentColumnizer.GetColumnCount(); i++) + { + var colName = CurrentColumnizer.GetColumnNames()[i]; + dataGridView.Columns.Add(PaintHelper.CreateTitleColumn(colName)); + } + } + } + + [SupportedOSPlatform("windows")] + private void OnDataGridViewCellValuePushed (object sender, DataGridViewCellValueEventArgs e) + { + if (!CurrentColumnizer.IsTimeshiftImplemented()) + { + return; + } + + var line = _logFileReader.GetLogLine(e.RowIndex); + var offset = CurrentColumnizer.GetTimeOffset(); + CurrentColumnizer.SetTimeOffset(0); + ColumnizerCallbackObject.SetLineNum(e.RowIndex); + var cols = CurrentColumnizer.SplitLine(ColumnizerCallbackObject, line); + CurrentColumnizer.SetTimeOffset(offset); + if (cols.ColumnValues.Length <= e.ColumnIndex - 2) + { + return; + } + + var oldValue = cols.ColumnValues[e.ColumnIndex - 2].FullValue; + var newValue = (string)e.Value; + //string oldValue = (string) this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; + CurrentColumnizer.PushValue(ColumnizerCallbackObject, e.ColumnIndex - 2, newValue, oldValue); + dataGridView.Refresh(); + TimeSpan timeSpan = new(CurrentColumnizer.GetTimeOffset() * TimeSpan.TicksPerMillisecond); + var span = timeSpan.ToString(); + var index = span.LastIndexOf('.'); + if (index > 0) + { + span = span.Substring(0, index + 4); + } + + SetTimeshiftValue(span); + SendGuiStateUpdate(); + } + + [SupportedOSPlatform("windows")] + private void OnDataGridViewRowHeightInfoNeeded (object sender, DataGridViewRowHeightInfoNeededEventArgs e) + { + e.Height = GetRowHeight(e.RowIndex); + } + + [SupportedOSPlatform("windows")] + private void OnDataGridViewCurrentCellChanged (object sender, EventArgs e) + { + if (dataGridView.CurrentRow != null) + { + _statusEventArgs.CurrentLineNum = dataGridView.CurrentRow.Index + 1; + SendStatusLineUpdate(); + if (syncFilterCheckBox.Checked) + { + SyncFilterGridPos(); + } + + if (CurrentColumnizer.IsTimeshiftImplemented() && Preferences.TimestampControl) + { + SyncTimestampDisplay(); + } + + //MethodInvoker invoker = new MethodInvoker(DisplayCurrentFileOnStatusline); + //invoker.BeginInvoke(null, null); + } + } + + private void OnDataGridViewCellEndEdit (object sender, DataGridViewCellEventArgs e) + { + StatusLineText(string.Empty); + } + + [SupportedOSPlatform("windows")] + private void OnEditControlKeyUp (object sender, KeyEventArgs e) + { + UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); + } + + [SupportedOSPlatform("windows")] + private void OnEditControlKeyPress (object sender, KeyPressEventArgs e) + { + UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); + } + + [SupportedOSPlatform("windows")] + private void OnEditControlClick (object sender, EventArgs e) + { + UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); + } + + [SupportedOSPlatform("windows")] + private void OnEditControlKeyDown (object sender, KeyEventArgs e) + { + UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); + } + + [SupportedOSPlatform("windows")] + private void OnDataGridViewPaint (object sender, PaintEventArgs e) + { + if (ShowBookmarkBubbles) + { + AddBookmarkOverlays(); + } + } + + // ====================================================================================== + // Filter Grid stuff + // ====================================================================================== + + [SupportedOSPlatform("windows")] + private void OnFilterSearchButtonClick (object sender, EventArgs e) + { + FilterSearch(); + } + + [SupportedOSPlatform("windows")] + private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPaintingEventArgs e) + { + var gridView = (BufferedDataGridView)sender; + + if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) + { + e.Handled = false; + return; + } + + + + var lineNum = _filterResultList[e.RowIndex]; + var line = _logFileReader.GetLogLineWithWait(lineNum).Result; + + if (line != null) + { + var entry = FindFirstNoWordMatchHilightEntry(line); + e.Graphics.SetClip(e.CellBounds); + if (e.State.HasFlag(DataGridViewElementStates.Selected)) + { + using var brush = PaintHelper.GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); + e.Graphics.FillRectangle(brush, e.CellBounds); + } + else + { + // paint direct filter hits with different bg color + //if (this.filterParams.SpreadEnabled && this.filterHitList.Contains(lineNum)) + //{ + // bgColor = Color.FromArgb(255, 220, 220, 220); + //} + e.CellStyle.BackColor = PaintHelper.GetBackColorFromHighlightEntry(entry); + e.PaintBackground(e.ClipBounds, false); + } + + if (DebugOptions.DisableWordHighlight) + { + e.PaintContent(e.CellBounds); + } + else + { + PaintCell(e, filterGridView, false, entry); + } + + if (e.ColumnIndex == 0) + { + if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) + { + Rectangle r;// = new(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); + r = e.CellBounds; + r.Inflate(-2, -2); + using var brush = new SolidBrush(BookmarkColor); + e.Graphics.FillRectangle(brush, r); + + var bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); + + if (bookmark.Text.Length > 0) + { + StringFormat format = new() + { + LineAlignment = StringAlignment.Center, + Alignment = StringAlignment.Center + }; + + using var brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); + using var font = new Font("Verdana", Preferences.FontSize, FontStyle.Bold); + e.Graphics.DrawString("!", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); + } + } + } + + e.Paint(e.CellBounds, DataGridViewPaintParts.Border); + e.Handled = true; + } + } + + [SupportedOSPlatform("windows")] + private void OnFilterGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e) + { + if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) + { + e.Value = ""; + return; + } + + var lineNum = _filterResultList[e.RowIndex]; + e.Value = GetCellValue(lineNum, e.ColumnIndex); + } + + [SupportedOSPlatform("windows")] + private void OnFilterGridViewRowHeightInfoNeeded (object sender, DataGridViewRowHeightInfoNeededEventArgs e) + { + e.Height = _lineHeight; + } + + [SupportedOSPlatform("windows")] + private void OnFilterComboBoxKeyDown (object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + FilterSearch(); + } + } + + [SupportedOSPlatform("windows")] + private void OnFilterGridViewColumnDividerDoubleClick (object sender, + DataGridViewColumnDividerDoubleClickEventArgs e) + { + e.Handled = true; + AutoResizeColumnsFx fx = AutoResizeColumns; + BeginInvoke(fx, filterGridView); + } + + [SupportedOSPlatform("windows")] + private void OnFilterGridViewCellDoubleClick (object sender, DataGridViewCellEventArgs e) + { + if (e.ColumnIndex == 0) + { + ToggleBookmark(); + return; + } + + if (filterGridView.CurrentRow != null && e.RowIndex >= 0) + { + var lineNum = _filterResultList[filterGridView.CurrentRow.Index]; + SelectAndEnsureVisible(lineNum, true); + } + } + + [SupportedOSPlatform("windows")] + private void OnRangeCheckBoxCheckedChanged (object sender, EventArgs e) + { + filterRangeComboBox.Enabled = rangeCheckBox.Checked; + CheckForFilterDirty(); + } + + [SupportedOSPlatform("windows")] + private void OnDataGridViewScroll (object sender, ScrollEventArgs e) + { + if (e.ScrollOrientation == ScrollOrientation.VerticalScroll) + { + if (dataGridView.DisplayedRowCount(false) + dataGridView.FirstDisplayedScrollingRowIndex >= dataGridView.RowCount) + { + //this.guiStateArgs.FollowTail = true; + if (!_guiStateArgs.FollowTail) + { + FollowTailChanged(true, false); + } + + OnTailFollowed(EventArgs.Empty); + } + else + { + //this.guiStateArgs.FollowTail = false; + if (_guiStateArgs.FollowTail) + { + FollowTailChanged(false, false); + } + } + + SendGuiStateUpdate(); + } + } + + [SupportedOSPlatform("windows")] + private void OnFilterGridViewKeyDown (object sender, KeyEventArgs e) + { + switch (e.KeyCode) + { + case Keys.Enter: + { + if (filterGridView.CurrentCellAddress.Y >= 0 && filterGridView.CurrentCellAddress.Y < _filterResultList.Count) + { + var lineNum = _filterResultList[filterGridView.CurrentCellAddress.Y]; + SelectLine(lineNum, false, true); + e.Handled = true; + } + + break; + } + case Keys.Tab when e.Modifiers == Keys.None: + dataGridView.Focus(); + e.Handled = true; + break; + } + } + + [SupportedOSPlatform("windows")] + private void OnDataGridViewKeyDown (object sender, KeyEventArgs e) + { + switch (e.KeyCode) + { + case Keys.Tab when e.Modifiers == Keys.None: + { + filterGridView.Focus(); + e.Handled = true; + break; + } + } + + //switch (e.KeyCode) + //{ + // case Keys.Tab when e.Modifiers == Keys.Control: + // //this.parentLogTabWin.SwitchTab(e.Shift); + // break; + //} + + _shouldCallTimeSync = true; + } + + [SupportedOSPlatform("windows")] + private void OnDataGridViewPreviewKeyDown (object sender, PreviewKeyDownEventArgs e) + { + if (e.KeyCode == Keys.Tab && e.Control) + { + e.IsInputKey = true; + } + } + + [SupportedOSPlatform("windows")] + private void OnDataGridViewCellContentDoubleClick (object sender, DataGridViewCellEventArgs e) + { + if (dataGridView.CurrentCell != null) + { + dataGridView.BeginEdit(false); + } + } + + [SupportedOSPlatform("windows")] + private void OnSyncFilterCheckBoxCheckedChanged (object sender, EventArgs e) + { + if (syncFilterCheckBox.Checked) + { + SyncFilterGridPos(); + } + } + + [SupportedOSPlatform("windows")] + private void OnDataGridViewLeave (object sender, EventArgs e) + { + InvalidateCurrentRow(dataGridView); + } + + [SupportedOSPlatform("windows")] + private void OnDataGridViewEnter (object sender, EventArgs e) + { + InvalidateCurrentRow(dataGridView); + } + + [SupportedOSPlatform("windows")] + private void OnFilterGridViewEnter (object sender, EventArgs e) + { + InvalidateCurrentRow(filterGridView); + } + + [SupportedOSPlatform("windows")] + private void OnFilterGridViewLeave (object sender, EventArgs e) + { + InvalidateCurrentRow(filterGridView); + } + + [SupportedOSPlatform("windows")] + private void OnDataGridViewResize (object sender, EventArgs e) + { + if (_logFileReader != null && dataGridView.RowCount > 0 && _guiStateArgs.FollowTail) + { + dataGridView.FirstDisplayedScrollingRowIndex = dataGridView.RowCount - 1; + } + } + + private void OnDataGridViewSelectionChanged (object sender, EventArgs e) + { + UpdateSelectionDisplay(); + } + + [SupportedOSPlatform("windows")] + private void OnSelectionChangedTriggerSignal (object sender, EventArgs e) + { + var selCount = 0; + try + { + _logger.Debug(CultureInfo.InvariantCulture, "Selection changed trigger"); + selCount = dataGridView.SelectedRows.Count; + if (selCount > 1) + { + StatusLineText(selCount + " selected lines"); + } + else + { + if (IsMultiFile) + { + MethodInvoker invoker = DisplayCurrentFileOnStatusline; + invoker.BeginInvoke(null, null); + } + else + { + StatusLineText(""); + } + } + } + catch (Exception ex) + { + _logger.Error(ex, "Error in selectionChangedTrigger_Signal selcount {0}", selCount); + } + } + + [SupportedOSPlatform("windows")] + private void OnFilterKnobControlValueChanged (object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + [SupportedOSPlatform("windows")] + private void OnFilterToTabButtonClick (object sender, EventArgs e) + { + FilterToTab(); + } + + private void OnPipeDisconnected (object sender, EventArgs e) + { + if (sender.GetType() == typeof(FilterPipe)) + { + lock (_filterPipeList) + { + _filterPipeList.Remove((FilterPipe)sender); + if (_filterPipeList.Count == 0) + // reset naming counter to 0 if no more open filter tabs for this source window + { + _filterPipeNameCounter = 0; + } + } + } + } + + [SupportedOSPlatform("windows")] + private void OnAdvancedButtonClick (object sender, EventArgs e) + { + _showAdvanced = !_showAdvanced; + ShowAdvancedFilterPanel(_showAdvanced); + } + + [SupportedOSPlatform("windows")] + private void OnFilterSplitContainerMouseDown (object sender, MouseEventArgs e) + { + ((SplitContainer)sender).IsSplitterFixed = true; + } + + [SupportedOSPlatform("windows")] + private void OnFilterSplitContainerMouseUp (object sender, MouseEventArgs e) + { + ((SplitContainer)sender).IsSplitterFixed = false; + } + + [SupportedOSPlatform("windows")] + private void OnFilterSplitContainerMouseMove (object sender, MouseEventArgs e) + { + var splitContainer = (SplitContainer)sender; + if (splitContainer.IsSplitterFixed) + { + if (e.Button.Equals(MouseButtons.Left)) + { + if (splitContainer.Orientation.Equals(Orientation.Vertical)) + { + if (e.X > 0 && e.X < splitContainer.Width) + { + splitContainer.SplitterDistance = e.X; + splitContainer.Refresh(); + } + } + else + { + if (e.Y > 0 && e.Y < splitContainer.Height) + { + splitContainer.SplitterDistance = e.Y; + splitContainer.Refresh(); + } + } + } + else + { + splitContainer.IsSplitterFixed = false; + } + } + } + + [SupportedOSPlatform("windows")] + private void OnFilterSplitContainerMouseDoubleClick (object sender, MouseEventArgs e) + { + AutoResizeFilterBox(); + } + + #region Context Menu + + [SupportedOSPlatform("windows")] + private void OnDataGridContextMenuStripOpening (object sender, CancelEventArgs e) + { + var lineNum = -1; + if (dataGridView.CurrentRow != null) + { + lineNum = dataGridView.CurrentRow.Index; + } + + if (lineNum == -1) + { + return; + } + + var refLineNum = lineNum; + + copyToTabToolStripMenuItem.Enabled = dataGridView.SelectedCells.Count > 0; + scrollAllTabsToTimestampToolStripMenuItem.Enabled = CurrentColumnizer.IsTimeshiftImplemented() + && + GetTimestampForLine(ref refLineNum, false) != + DateTime.MinValue; + + locateLineInOriginalFileToolStripMenuItem.Enabled = IsTempFile && + FilterPipe != null && + FilterPipe.GetOriginalLineNum(lineNum) != -1; + + markEditModeToolStripMenuItem.Enabled = !dataGridView.CurrentCell.ReadOnly; + + // Remove all "old" plugin entries + var index = dataGridContextMenuStrip.Items.IndexOf(pluginSeparator); + + if (index > 0) + { + for (var i = index + 1; i < dataGridContextMenuStrip.Items.Count;) + { + dataGridContextMenuStrip.Items.RemoveAt(i); + } + } + + // Add plugin entries + var isAdded = false; + if (PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins.Count > 0) + { + var lines = GetSelectedContent(); + foreach (var entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins) + { + LogExpertCallback callback = new(this); + var menuText = entry.GetMenuText(lines.Count, CurrentColumnizer, callback.GetLogLine(lines[0])); + + if (menuText != null) + { + var disabled = menuText.StartsWith('_'); + if (disabled) + { + menuText = menuText[1..]; + } + + var item = dataGridContextMenuStrip.Items.Add(menuText, null, OnHandlePluginContextMenu); + item.Tag = new ContextMenuPluginEventArgs(entry, lines, CurrentColumnizer, callback); + item.Enabled = !disabled; + isAdded = true; + } + } + } + + pluginSeparator.Visible = isAdded; + + // enable/disable Temp Highlight item + tempHighlightsToolStripMenuItem.Enabled = _tempHighlightEntryList.Count > 0; + + markCurrentFilterRangeToolStripMenuItem.Enabled = string.IsNullOrEmpty(filterRangeComboBox.Text) == false; + + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + var list = _parentLogTabWin.GetListOfOpenFiles(); + syncTimestampsToToolStripMenuItem.Enabled = true; + syncTimestampsToToolStripMenuItem.DropDownItems.Clear(); + EventHandler ev = OnHandleSyncContextMenu; + Font italicFont = new(syncTimestampsToToolStripMenuItem.Font.FontFamily, syncTimestampsToToolStripMenuItem.Font.Size, FontStyle.Italic); + + foreach (var fileEntry in list) + { + if (fileEntry.LogWindow != this) + { + var item = syncTimestampsToToolStripMenuItem.DropDownItems.Add(fileEntry.Title, null, ev) as ToolStripMenuItem; + item.Tag = fileEntry; + item.Checked = TimeSyncList != null && TimeSyncList.Contains(fileEntry.LogWindow); + if (fileEntry.LogWindow.TimeSyncList != null && !fileEntry.LogWindow.TimeSyncList.Contains(this)) + { + item.Font = italicFont; + item.ForeColor = Color.Blue; + } + + item.Enabled = fileEntry.LogWindow.CurrentColumnizer.IsTimeshiftImplemented(); + } + } + } + else + { + syncTimestampsToToolStripMenuItem.Enabled = false; + } + + freeThisWindowFromTimeSyncToolStripMenuItem.Enabled = TimeSyncList != null && + TimeSyncList.Count > 1; + } + + [SupportedOSPlatform("windows")] + private void OnHandlePluginContextMenu (object sender, EventArgs args) + { + if (sender is ToolStripItem item) + { + var menuArgs = item.Tag as ContextMenuPluginEventArgs; + var logLines = menuArgs.LogLines; + menuArgs.Entry.MenuSelected(logLines.Count, menuArgs.Columnizer, menuArgs.Callback.GetLogLine(logLines[0])); + } + } + + [SupportedOSPlatform("windows")] + private void OnHandleSyncContextMenu (object sender, EventArgs args) + { + if (sender is ToolStripItem item) + { + var entry = item.Tag as WindowFileEntry; + + if (TimeSyncList != null && TimeSyncList.Contains(entry.LogWindow)) + { + FreeSlaveFromTimesync(entry.LogWindow); + } + else + //AddSlaveToTimesync(entry.LogWindow); + { + AddOtherWindowToTimesync(entry.LogWindow); + } + } + } + + [SupportedOSPlatform("windows")] + private void OnCopyToolStripMenuItemClick (object sender, EventArgs e) + { + CopyMarkedLinesToClipboard(); + } + + private void OnCopyToTabToolStripMenuItemClick (object sender, EventArgs e) + { + CopyMarkedLinesToTab(); + } + + [SupportedOSPlatform("windows")] + private void OnScrollAllTabsToTimestampToolStripMenuItemClick (object sender, EventArgs e) + { + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + var currentLine = dataGridView.CurrentCellAddress.Y; + if (currentLine > 0 && currentLine < dataGridView.RowCount) + { + var lineNum = currentLine; + var timeStamp = GetTimestampForLine(ref lineNum, false); + if (timeStamp.Equals(DateTime.MinValue)) // means: invalid + { + return; + } + + _parentLogTabWin.ScrollAllTabsToTimestamp(timeStamp, this); + } + } + } + + [SupportedOSPlatform("windows")] + private void OnLocateLineInOriginalFileToolStripMenuItemClick (object sender, EventArgs e) + { + if (dataGridView.CurrentRow != null && FilterPipe != null) + { + var lineNum = FilterPipe.GetOriginalLineNum(dataGridView.CurrentRow.Index); + if (lineNum != -1) + { + FilterPipe.LogWindow.SelectLine(lineNum, false, true); + _parentLogTabWin.SelectTab(FilterPipe.LogWindow); + } + } + } + + private void OnToggleBoomarkToolStripMenuItemClick (object sender, EventArgs e) + { + ToggleBookmark(); + } + + [SupportedOSPlatform("windows")] + private void OnMarkEditModeToolStripMenuItemClick (object sender, EventArgs e) + { + StartEditMode(); + } + + private void OnLogWindowSizeChanged (object sender, EventArgs e) + { + //AdjustMinimumGridWith(); + AdjustHighlightSplitterWidth(); + } + + #region BookMarkList + + [SupportedOSPlatform("windows")] + private void OnColumnRestrictCheckBoxCheckedChanged (object sender, EventArgs e) + { + columnButton.Enabled = columnRestrictCheckBox.Checked; + if (columnRestrictCheckBox.Checked) // disable when nothing to filter + { + columnNamesLabel.Visible = true; + _filterParams.ColumnRestrict = true; + columnNamesLabel.Text = CalculateColumnNames(_filterParams); + } + else + { + columnNamesLabel.Visible = false; + } + + CheckForFilterDirty(); + } + + [SupportedOSPlatform("windows")] + private void OnColumnButtonClick (object sender, EventArgs e) + { + _filterParams.CurrentColumnizer = _currentColumnizer; + FilterColumnChooser chooser = new(_filterParams); + if (chooser.ShowDialog() == DialogResult.OK) + { + columnNamesLabel.Text = CalculateColumnNames(_filterParams); + + //CheckForFilterDirty(); //!!!GBro: Indicate to redo the search if search columns were changed + filterSearchButton.Image = _searchButtonImage; + saveFilterButton.Enabled = false; + } + } + + #endregion + + #region Column Header Context Menu + + [SupportedOSPlatform("windows")] + private void OnDataGridViewCellContextMenuStripNeeded (object sender, DataGridViewCellContextMenuStripNeededEventArgs e) + { + if (e.RowIndex >= 0 && e.RowIndex < dataGridView.RowCount && !dataGridView.Rows[e.RowIndex].Selected) + { + SelectLine(e.RowIndex, false, true); + } + else if (e.RowIndex < 0) + { + e.ContextMenuStrip = columnContextMenuStrip; + } + + if (e.ContextMenuStrip == columnContextMenuStrip) + { + _selectedCol = e.ColumnIndex; + } + } + + //private void boomarkDataGridView_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) + //{ + // if (e.RowIndex > 0 && e.RowIndex < this.boomarkDataGridView.RowCount + // && !this.boomarkDataGridView.Rows[e.RowIndex].Selected) + // { + // this.boomarkDataGridView.Rows[e.RowIndex].Selected = true; + // this.boomarkDataGridView.CurrentCell = this.boomarkDataGridView.Rows[e.RowIndex].Cells[0]; + // } + // if (e.ContextMenuStrip == this.columnContextMenuStrip) + // { + // this.selectedCol = e.ColumnIndex; + // } + //} + + [SupportedOSPlatform("windows")] + private void OnFilterGridViewCellContextMenuStripNeeded (object sender, DataGridViewCellContextMenuStripNeededEventArgs e) + { + if (e.ContextMenuStrip == columnContextMenuStrip) + { + _selectedCol = e.ColumnIndex; + } + } + + [SupportedOSPlatform("windows")] + private void OnColumnContextMenuStripOpening (object sender, CancelEventArgs e) + { + var ctl = columnContextMenuStrip.SourceControl; + var gridView = ctl as BufferedDataGridView; + var frozen = false; + if (_freezeStateMap.TryGetValue(ctl, out var value)) + { + frozen = value; + } + + freezeLeftColumnsUntilHereToolStripMenuItem.Checked = frozen; + + if (frozen) + { + freezeLeftColumnsUntilHereToolStripMenuItem.Text = "Frozen"; + } + else + { + if (ctl is BufferedDataGridView) + { + freezeLeftColumnsUntilHereToolStripMenuItem.Text = $"Freeze left columns until here ({gridView.Columns[_selectedCol].HeaderText})"; + } + } + + + var col = gridView.Columns[_selectedCol]; + moveLeftToolStripMenuItem.Enabled = col != null && col.DisplayIndex > 0; + moveRightToolStripMenuItem.Enabled = col != null && col.DisplayIndex < gridView.Columns.Count - 1; + + if (gridView.Columns.Count - 1 > _selectedCol) + { + // DataGridViewColumn colRight = gridView.Columns[this.selectedCol + 1]; + var colRight = gridView.Columns.GetNextColumn(col, DataGridViewElementStates.None, DataGridViewElementStates.None); + moveRightToolStripMenuItem.Enabled = colRight != null && colRight.Frozen == col.Frozen; + } + + if (_selectedCol > 0) + { + //DataGridViewColumn colLeft = gridView.Columns[this.selectedCol - 1]; + var colLeft = gridView.Columns.GetPreviousColumn(col, DataGridViewElementStates.None, DataGridViewElementStates.None); + + moveLeftToolStripMenuItem.Enabled = colLeft != null && colLeft.Frozen == col.Frozen; + } + + var colLast = gridView.Columns[gridView.Columns.Count - 1]; + moveToLastColumnToolStripMenuItem.Enabled = colLast != null && colLast.Frozen == col.Frozen; + + // Fill context menu with column names + // + EventHandler ev = OnHandleColumnItemContextMenu; + allColumnsToolStripMenuItem.DropDownItems.Clear(); + foreach (DataGridViewColumn column in gridView.Columns) + { + if (column.HeaderText.Length > 0) + { + var item = allColumnsToolStripMenuItem.DropDownItems.Add(column.HeaderText, null, ev) as ToolStripMenuItem; + item.Tag = column; + item.Enabled = !column.Frozen; + } + } + } + + [SupportedOSPlatform("windows")] + private void OnHandleColumnItemContextMenu (object sender, EventArgs args) + { + if (sender is ToolStripItem item) + { + var column = item.Tag as DataGridViewColumn; + column.Visible = true; + column.DataGridView.FirstDisplayedScrollingColumnIndex = column.Index; + } + } + + [SupportedOSPlatform("windows")] + private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick (object sender, EventArgs e) + { + var ctl = columnContextMenuStrip.SourceControl; + var frozen = false; + + if (_freezeStateMap.TryGetValue(ctl, out var value)) + { + frozen = value; + } + + frozen = !frozen; + _freezeStateMap[ctl] = frozen; + + if (ctl is BufferedDataGridView gridView) + { + ApplyFrozenState(gridView); + } + } + + [SupportedOSPlatform("windows")] + private void OnMoveToLastColumnToolStripMenuItemClick (object sender, EventArgs e) + { + var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + var col = gridView.Columns[_selectedCol]; + if (col != null) + { + col.DisplayIndex = gridView.Columns.Count - 1; + } + } + + [SupportedOSPlatform("windows")] + private void OnMoveLeftToolStripMenuItemClick (object sender, EventArgs e) + { + var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + var col = gridView.Columns[_selectedCol]; + if (col != null && col.DisplayIndex > 0) + { + col.DisplayIndex -= 1; + } + } + + [SupportedOSPlatform("windows")] + private void OnMoveRightToolStripMenuItemClick (object sender, EventArgs e) + { + var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + var col = gridView.Columns[_selectedCol]; + if (col != null && col.DisplayIndex < gridView.Columns.Count - 1) + { + col.DisplayIndex = col.DisplayIndex + 1; + } + } + + [SupportedOSPlatform("windows")] + private void OnHideColumnToolStripMenuItemClick (object sender, EventArgs e) + { + var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + var col = gridView.Columns[_selectedCol]; + col.Visible = false; + } + + [SupportedOSPlatform("windows")] + private void OnRestoreColumnsToolStripMenuItemClick (object sender, EventArgs e) + { + var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; + foreach (DataGridViewColumn col in gridView.Columns) + { + col.Visible = true; + } + } + + [SupportedOSPlatform("windows")] + private void OnTimeSpreadingControlLineSelected (object sender, SelectLineEventArgs e) + { + SelectLine(e.Line, false, true); + } + + [SupportedOSPlatform("windows")] + private void OnBookmarkCommentToolStripMenuItemClick (object sender, EventArgs e) + { + AddBookmarkAndEditComment(); + } + + [SupportedOSPlatform("windows")] + private void OnHighlightSelectionInLogFileToolStripMenuItemClick (object sender, EventArgs e) + { + if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) + { + var he = new HighlightEntry() + { + SearchText = ctl.SelectedText, + ForegroundColor = Color.Red, + BackgroundColor = Color.Yellow, + IsRegEx = false, + IsCaseSensitive = true, + IsLedSwitch = false, + IsSetBookmark = false, + IsActionEntry = false, + ActionEntry = null, + IsWordMatch = false + }; + + lock (_tempHighlightEntryListLock) + { + _tempHighlightEntryList.Add(he); + } + + dataGridView.CancelEdit(); + dataGridView.EndEdit(); + RefreshAllGrids(); + } + } + + [SupportedOSPlatform("windows")] + private void OnHighlightSelectionInLogFilewordModeToolStripMenuItemClick (object sender, EventArgs e) + { + if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) + { + HighlightEntry he = new() + { + SearchText = ctl.SelectedText, + ForegroundColor = Color.Red, + BackgroundColor = Color.Yellow, + IsRegEx = false, + IsCaseSensitive = true, + IsLedSwitch = false, + IsStopTail = false, + IsSetBookmark = false, + IsActionEntry = false, + ActionEntry = null, + IsWordMatch = true + }; + + lock (_tempHighlightEntryListLock) + { + _tempHighlightEntryList.Add(he); + } + + dataGridView.CancelEdit(); + dataGridView.EndEdit(); + RefreshAllGrids(); + } + } + + [SupportedOSPlatform("windows")] + private void OnEditModeCopyToolStripMenuItemClick (object sender, EventArgs e) + { + if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) + { + if (Util.IsNull(ctl.SelectedText) == false) + { + Clipboard.SetText(ctl.SelectedText); + } + } + } + + [SupportedOSPlatform("windows")] + private void OnRemoveAllToolStripMenuItemClick (object sender, EventArgs e) + { + RemoveTempHighlights(); + } + + [SupportedOSPlatform("windows")] + private void OnMakePermanentToolStripMenuItemClick (object sender, EventArgs e) + { + lock (_tempHighlightEntryListLock) + { + lock (_currentHighlightGroupLock) + { + _currentHighlightGroup.HighlightEntryList.AddRange(_tempHighlightEntryList); + RemoveTempHighlights(); + OnCurrentHighlightListChanged(); + } + } + } + + [SupportedOSPlatform("windows")] + private void OnMarkCurrentFilterRangeToolStripMenuItemClick (object sender, EventArgs e) + { + MarkCurrentFilterRange(); + } + + [SupportedOSPlatform("windows")] + private void OnFilterForSelectionToolStripMenuItemClick (object sender, EventArgs e) + { + if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) + { + splitContainerLogWindow.Panel2Collapsed = false; + ResetFilterControls(); + FilterSearch(ctl.SelectedText); + } + } + + [SupportedOSPlatform("windows")] + private void OnSetSelectedTextAsBookmarkCommentToolStripMenuItemClick (object sender, EventArgs e) + { + if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) + { + AddBookmarkComment(ctl.SelectedText); + } + } + + private void OnDataGridViewCellClick (object sender, DataGridViewCellEventArgs e) + { + _shouldCallTimeSync = true; + } + + [SupportedOSPlatform("windows")] + private void OnDataGridViewCellDoubleClick (object sender, DataGridViewCellEventArgs e) + { + if (e.ColumnIndex == 0) + { + ToggleBookmark(); + } + } + + [SupportedOSPlatform("windows")] + private void OnDataGridViewOverlayDoubleClicked (object sender, OverlayEventArgs e) + { + BookmarkComment(e.BookmarkOverlay.Bookmark); + } + + [SupportedOSPlatform("windows")] + private void OnFilterRegexCheckBoxMouseUp (object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + RegexHelperDialog dlg = new() + { + ExpressionHistoryList = ConfigManager.Settings.RegexHistory.ExpressionHistoryList, + TesttextHistoryList = ConfigManager.Settings.RegexHistory.TesttextHistoryList, + Owner = this, + CaseSensitive = filterCaseSensitiveCheckBox.Checked, + Pattern = filterComboBox.Text + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + ConfigManager.Settings.RegexHistory.ExpressionHistoryList = dlg.ExpressionHistoryList; + ConfigManager.Settings.RegexHistory.TesttextHistoryList = dlg.TesttextHistoryList; + + filterCaseSensitiveCheckBox.Checked = dlg.CaseSensitive; + filterComboBox.Text = dlg.Pattern; + + ConfigManager.Save(SettingsFlags.RegexHistory); + } + } + } + + #endregion + + #region Filter-Highlight + + [SupportedOSPlatform("windows")] + private void OnToggleHighlightPanelButtonClick (object sender, EventArgs e) + { + ToggleHighlightPanel(highlightSplitContainer.Panel2Collapsed); + } + + private void OnSaveFilterButtonClick (object sender, EventArgs e) + { + var newParams = _filterParams.Clone(); + newParams.Color = Color.FromKnownColor(KnownColor.Black); + ConfigManager.Settings.FilterList.Add(newParams); + OnFilterListChanged(this); + } + + [SupportedOSPlatform("windows")] + private void OnDeleteFilterButtonClick (object sender, EventArgs e) + { + var index = filterListBox.SelectedIndex; + if (index >= 0) + { + var filterParams = (FilterParams)filterListBox.Items[index]; + ConfigManager.Settings.FilterList.Remove(filterParams); + OnFilterListChanged(this); + if (filterListBox.Items.Count > 0) + { + filterListBox.SelectedIndex = filterListBox.Items.Count - 1; + } + } + } + + [SupportedOSPlatform("windows")] + private void OnFilterUpButtonClick (object sender, EventArgs e) + { + var i = filterListBox.SelectedIndex; + if (i > 0) + { + var filterParams = (FilterParams)filterListBox.Items[i]; + ConfigManager.Settings.FilterList.RemoveAt(i); + i--; + ConfigManager.Settings.FilterList.Insert(i, filterParams); + OnFilterListChanged(this); + filterListBox.SelectedIndex = i; + } + } + + [SupportedOSPlatform("windows")] + private void OnFilterDownButtonClick (object sender, EventArgs e) + { + var i = filterListBox.SelectedIndex; + if (i < 0) + { + return; + } + + if (i < filterListBox.Items.Count - 1) + { + var filterParams = (FilterParams)filterListBox.Items[i]; + ConfigManager.Settings.FilterList.RemoveAt(i); + i++; + ConfigManager.Settings.FilterList.Insert(i, filterParams); + OnFilterListChanged(this); + filterListBox.SelectedIndex = i; + } + } + + [SupportedOSPlatform("windows")] + private void OnFilterListBoxMouseDoubleClick (object sender, MouseEventArgs e) + { + if (filterListBox.SelectedIndex >= 0) + { + var filterParams = (FilterParams)filterListBox.Items[filterListBox.SelectedIndex]; + var newParams = filterParams.Clone(); + //newParams.historyList = ConfigManager.Settings.filterHistoryList; + _filterParams = newParams; + ReInitFilterParams(_filterParams); + ApplyFilterParams(); + CheckForAdvancedButtonDirty(); + CheckForFilterDirty(); + filterSearchButton.Image = _searchButtonImage; + saveFilterButton.Enabled = false; + if (hideFilterListOnLoadCheckBox.Checked) + { + ToggleHighlightPanel(false); + } + + if (filterOnLoadCheckBox.Checked) + { + FilterSearch(); + } + } + } + + [SupportedOSPlatform("windows")] + private void OnFilterListBoxDrawItem (object sender, DrawItemEventArgs e) + { + e.DrawBackground(); + if (e.Index >= 0) + { + var filterParams = (FilterParams)filterListBox.Items[e.Index]; + Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); + + Brush brush; + + if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) + { + brush = new SolidBrush(filterListBox.BackColor); + } + else + { + brush = new SolidBrush(filterParams.Color); + } + + e.Graphics.DrawString(filterParams.SearchText, e.Font, brush, + new PointF(rectangle.Left, rectangle.Top)); + e.DrawFocusRectangle(); + brush.Dispose(); + } + } + + [SupportedOSPlatform("windows")] + // Color for filter list entry + private void OnColorToolStripMenuItemClick (object sender, EventArgs e) + { + var i = filterListBox.SelectedIndex; + if (i < filterListBox.Items.Count && i >= 0) + { + var filterParams = (FilterParams)filterListBox.Items[i]; + ColorDialog dlg = new() + { + CustomColors = [filterParams.Color.ToArgb()], + Color = filterParams.Color + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + filterParams.Color = dlg.Color; + filterListBox.Refresh(); + } + } + } + + [SupportedOSPlatform("windows")] + private void OnFilterCaseSensitiveCheckBoxCheckedChanged (object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + [SupportedOSPlatform("windows")] + private void OnFilterRegexCheckBoxCheckedChanged (object sender, EventArgs e) + { + fuzzyKnobControl.Enabled = !filterRegexCheckBox.Checked; + fuzzyLabel.Enabled = !filterRegexCheckBox.Checked; + CheckForFilterDirty(); + } + + [SupportedOSPlatform("windows")] + private void OnInvertFilterCheckBoxCheckedChanged (object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + [SupportedOSPlatform("windows")] + private void OnFilterRangeComboBoxTextChanged (object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + [SupportedOSPlatform("windows")] + private void OnFuzzyKnobControlValueChanged (object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + [SupportedOSPlatform("windows")] + private void OnFilterComboBoxTextChanged (object sender, EventArgs e) + { + CheckForFilterDirty(); + } + + [SupportedOSPlatform("windows")] + private void OnSetBookmarksOnSelectedLinesToolStripMenuItemClick (object sender, EventArgs e) + { + SetBookmarksForSelectedFilterLines(); + } + + private void OnParentHighlightSettingsChanged (object sender, EventArgs e) + { + var groupName = _guiStateArgs.HighlightGroupName; + SetCurrentHighlightGroup(groupName); + } + + [SupportedOSPlatform("windows")] + private void OnFilterOnLoadCheckBoxMouseClick (object sender, MouseEventArgs e) + { + HandleChangedFilterOnLoadSetting(); + } + + [SupportedOSPlatform("windows")] + private void OnFilterOnLoadCheckBoxKeyPress (object sender, KeyPressEventArgs e) + { + HandleChangedFilterOnLoadSetting(); + } + + [SupportedOSPlatform("windows")] + private void OnHideFilterListOnLoadCheckBoxMouseClick (object sender, MouseEventArgs e) + { + HandleChangedFilterOnLoadSetting(); + } + + [SupportedOSPlatform("windows")] + private void OnFilterToTabToolStripMenuItemClick (object sender, EventArgs e) + { + FilterToTab(); + } + + private void OnTimeSyncListWindowRemoved (object sender, EventArgs e) + { + var syncList = sender as TimeSyncList; + lock (_timeSyncListLock) + { + if (syncList.Count == 0 || (syncList.Count == 1 && syncList.Contains(this))) + { + if (syncList == TimeSyncList) + { + TimeSyncList = null; + OnSyncModeChanged(); + } + } + } + } + + private void OnFreeThisWindowFromTimeSyncToolStripMenuItemClick (object sender, EventArgs e) + { + FreeFromTimeSync(); + } + + [SupportedOSPlatform("windows")] + private void OnSplitContainerSplitterMoved (object sender, SplitterEventArgs e) + { + advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; + } + + [SupportedOSPlatform("windows")] + private void OnMarkFilterHitsInLogViewToolStripMenuItemClick (object sender, EventArgs e) + { + SearchParams p = new() + { + SearchText = _filterParams.SearchText, + IsRegex = _filterParams.IsRegex, + IsCaseSensitive = _filterParams.IsCaseSensitive + }; + + AddSearchHitHighlightEntry(p); + } + + [SupportedOSPlatform("windows")] + private void OnColumnComboBoxSelectionChangeCommitted (object sender, EventArgs e) + { + SelectColumn(); + } + + [SupportedOSPlatform("windows")] + private void OnColumnComboBoxKeyDown (object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + SelectColumn(); + dataGridView.Focus(); + } + } + + [SupportedOSPlatform("windows")] + private void OnColumnComboBoxPreviewKeyDown (object sender, PreviewKeyDownEventArgs e) + { + if (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt) + { + columnComboBox.DroppedDown = true; + } + + if (e.KeyCode == Keys.Enter) + { + e.IsInputKey = true; + } + } + + [SupportedOSPlatform("windows")] + private void OnBookmarkProviderBookmarkRemoved (object sender, EventArgs e) + { + if (!_isLoading) + { + dataGridView.Refresh(); + filterGridView.Refresh(); + } + } + + [SupportedOSPlatform("windows")] + private void OnBookmarkProviderBookmarkAdded (object sender, EventArgs e) + { + if (!_isLoading) + { + dataGridView.Refresh(); + filterGridView.Refresh(); + } + } + + private void OnBookmarkProviderAllBookmarksRemoved (object sender, EventArgs e) + { + // nothing + } + + private void OnLogWindowLeave (object sender, EventArgs e) + { + InvalidateCurrentRow(); + } + + private void OnLogWindowEnter (object sender, EventArgs e) + { + InvalidateCurrentRow(); + } + + [SupportedOSPlatform("windows")] + private void OnDataGridViewRowUnshared (object sender, DataGridViewRowEventArgs e) + { + if (_logger.IsTraceEnabled) + { + _logger.Trace($"Row unshared line {e.Row.Cells[1].Value}"); + } + } + + #endregion + + #endregion + + #endregion + + [SupportedOSPlatform("windows")] + private void MeasureItem (object sender, MeasureItemEventArgs e) + { + e.ItemHeight = filterListBox.Font.Height; + } + + #endregion + + #region Private Methods + + [SupportedOSPlatform("windows")] + private void RegisterLogFileReaderEvents () + { + _logFileReader.LoadFile += OnLogFileReaderLoadFile; + _logFileReader.LoadingFinished += OnLogFileReaderFinishedLoading; + _logFileReader.LoadingStarted += OnLogFileReaderLoadingStarted; + _logFileReader.FileNotFound += OnLogFileReaderFileNotFound; + _logFileReader.Respawned += OnLogFileReaderRespawned; + // FileSizeChanged is not registered here because it's registered after loading has finished + } + + [SupportedOSPlatform("windows")] + private void UnRegisterLogFileReaderEvents () + { + if (_logFileReader != null) + { + _logFileReader.LoadFile -= OnLogFileReaderLoadFile; + _logFileReader.LoadingFinished -= OnLogFileReaderFinishedLoading; + _logFileReader.LoadingStarted -= OnLogFileReaderLoadingStarted; + _logFileReader.FileNotFound -= OnLogFileReaderFileNotFound; + _logFileReader.Respawned -= OnLogFileReaderRespawned; + _logFileReader.FileSizeChanged -= OnFileSizeChanged; + } + } + + [SupportedOSPlatform("windows")] + private void CreateDefaultViewStyle () + { + DataGridViewCellStyle dataGridViewCellStyleMainGrid = new(); + DataGridViewCellStyle dataGridViewCellStyleFilterGrid = new(); + + dataGridViewCellStyleMainGrid.Alignment = DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyleMainGrid.BackColor = SystemColors.Window; + dataGridViewCellStyleMainGrid.Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); + dataGridViewCellStyleMainGrid.ForeColor = SystemColors.ControlText; + dataGridViewCellStyleMainGrid.SelectionBackColor = SystemColors.Highlight; + //dataGridViewCellStyleMainGrid.SelectionForeColor = SystemColors.HighlightText; + + var highlightColor = SystemColors.Highlight; + //Color is smaller than 128, means its darker + var isSelectionBackColorDark = (highlightColor.R * 0.2126) + (highlightColor.G * 0.7152) + (highlightColor.B * 0.0722) < 255 / 2; + + if (isSelectionBackColorDark) + { + dataGridViewCellStyleMainGrid.SelectionForeColor = Color.White; + } + else + { + dataGridViewCellStyleMainGrid.SelectionForeColor = Color.Black; + + } + + dataGridViewCellStyleMainGrid.WrapMode = DataGridViewTriState.False; + dataGridView.DefaultCellStyle = dataGridViewCellStyleMainGrid; + + dataGridViewCellStyleFilterGrid.Alignment = DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyleFilterGrid.BackColor = SystemColors.Window; + dataGridViewCellStyleFilterGrid.Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); + dataGridViewCellStyleFilterGrid.ForeColor = SystemColors.ControlText; + dataGridViewCellStyleFilterGrid.SelectionBackColor = SystemColors.Highlight; + //dataGridViewCellStyleFilterGrid.SelectionForeColor = SystemColors.HighlightText; + + if (isSelectionBackColorDark) + { + dataGridViewCellStyleFilterGrid.SelectionForeColor = Color.White; + } + else + { + dataGridViewCellStyleFilterGrid.SelectionForeColor = Color.Black; + } + + dataGridViewCellStyleFilterGrid.WrapMode = DataGridViewTriState.False; + filterGridView.DefaultCellStyle = dataGridViewCellStyleFilterGrid; + } + + [SupportedOSPlatform("windows")] + private bool LoadPersistenceOptions () + { + if (InvokeRequired) + { + return (bool)Invoke(new BoolReturnDelegate(LoadPersistenceOptions)); + } + + if (!Preferences.SaveSessions && ForcedPersistenceFileName == null) + { + return false; + } + + try + { + var persistenceData = ForcedPersistenceFileName == null + ? Persister.LoadPersistenceDataOptionsOnly(FileName, Preferences) + : Persister.LoadPersistenceDataOptionsOnlyFromFixedFile(ForcedPersistenceFileName); + + if (persistenceData == null) + { + _logger.Info($"No persistence data for {FileName} found."); + return false; + } + + IsMultiFile = persistenceData.MultiFile; + _multiFileOptions = new MultiFileOptions + { + FormatPattern = persistenceData.MultiFilePattern, + MaxDayTry = persistenceData.MultiFileMaxDays + }; + + if (string.IsNullOrEmpty(_multiFileOptions.FormatPattern)) + { + _multiFileOptions = ObjectClone.Clone(Preferences.MultiFileOptions); + } + + splitContainerLogWindow.SplitterDistance = persistenceData.FilterPosition; + splitContainerLogWindow.Panel2Collapsed = !persistenceData.FilterVisible; + ToggleHighlightPanel(persistenceData.FilterSaveListVisible); + ShowAdvancedFilterPanel(persistenceData.FilterAdvanced); + + if (_reloadMemento == null) + { + PreselectColumnizer(persistenceData.ColumnizerName); + } + + FollowTailChanged(persistenceData.FollowTail, false); + if (persistenceData.TabName != null) + { + Text = persistenceData.TabName; + } + + AdjustHighlightSplitterWidth(); + SetCurrentHighlightGroup(persistenceData.HighlightGroupName); + + if (persistenceData.MultiFileNames.Count > 0) + { + _logger.Info(CultureInfo.InvariantCulture, "Detected MultiFile name list in persistence options"); + _fileNames = new string[persistenceData.MultiFileNames.Count]; + persistenceData.MultiFileNames.CopyTo(_fileNames); + } + else + { + _fileNames = null; + } + + //this.bookmarkWindow.ShowBookmarkCommentColumn = persistenceData.showBookmarkCommentColumn; + SetExplicitEncoding(persistenceData.Encoding); + return true; + } + catch (Exception ex) + { + _logger.Error(ex, "Error loading persistence data: "); + return false; + } + } + + [SupportedOSPlatform("windows")] + private void SetDefaultsFromPrefs () + { + filterTailCheckBox.Checked = Preferences.FilterTail; + syncFilterCheckBox.Checked = Preferences.FilterSync; + FollowTailChanged(Preferences.FollowTail, false); + _multiFileOptions = ObjectClone.Clone(Preferences.MultiFileOptions); + } + + [SupportedOSPlatform("windows")] + private void LoadPersistenceData () + { + if (InvokeRequired) + { + Invoke(new MethodInvoker(LoadPersistenceData)); + return; + } + + if (!Preferences.SaveSessions && !ForcePersistenceLoading && ForcedPersistenceFileName == null) + { + SetDefaultsFromPrefs(); + return; + } + + if (IsTempFile) + { + SetDefaultsFromPrefs(); + return; + } + + ForcePersistenceLoading = false; // force only 1 time (while session load) + + try + { + var persistenceData = ForcedPersistenceFileName == null + ? Persister.LoadPersistenceData(FileName, Preferences) + : Persister.LoadPersistenceDataFromFixedFile(ForcedPersistenceFileName); + + if (persistenceData.LineCount > _logFileReader.LineCount) + { + // outdated persistence data (logfile rollover) + // MessageBox.Show(this, "Persistence data for " + this.FileName + " is outdated. It was discarded.", "Log Expert"); + _logger.Info($"Persistence data for {FileName} is outdated. It was discarded."); + _ = LoadPersistenceOptions(); + return; + } + + _bookmarkProvider.SetBookmarks(persistenceData.BookmarkList); + _rowHeightList = persistenceData.RowHeightList; + try + { + if (persistenceData.CurrentLine >= 0 && persistenceData.CurrentLine < dataGridView.RowCount) + { + SelectLine(persistenceData.CurrentLine, false, true); + } + else + { + if (_logFileReader.LineCount > 0) + { + dataGridView.FirstDisplayedScrollingRowIndex = _logFileReader.LineCount - 1; + SelectLine(_logFileReader.LineCount - 1, false, true); + } + } + + if (persistenceData.FirstDisplayedLine >= 0 && + persistenceData.FirstDisplayedLine < dataGridView.RowCount) + { + dataGridView.FirstDisplayedScrollingRowIndex = persistenceData.FirstDisplayedLine; + } + + if (persistenceData.FollowTail) + { + FollowTailChanged(persistenceData.FollowTail, false); + } + } + catch (ArgumentOutOfRangeException) + { + // FirstDisplayedScrollingRowIndex calculates sometimes the wrong scrolling ranges??? + } + + if (Preferences.SaveFilters) + { + RestoreFilters(persistenceData); + } + } + catch (IOException ex) + { + SetDefaultsFromPrefs(); + _logger.Error(ex, "Error loading bookmarks: "); + } + } + + [SupportedOSPlatform("windows")] + private void RestoreFilters (PersistenceData persistenceData) + { + if (persistenceData.FilterParamsList.Count > 0) + { + _filterParams = persistenceData.FilterParamsList[0]; + ReInitFilterParams(_filterParams); + } + + ApplyFilterParams(); // re-loaded filter settingss + BeginInvoke(new MethodInvoker(FilterSearch)); + try + { + splitContainerLogWindow.SplitterDistance = persistenceData.FilterPosition; + splitContainerLogWindow.Panel2Collapsed = !persistenceData.FilterVisible; + } + catch (InvalidOperationException e) + { + _logger.Error(e, "Error setting splitter distance: "); + } + + ShowAdvancedFilterPanel(persistenceData.FilterAdvanced); + if (_filterPipeList.Count == 0) // don't restore if it's only a reload + { + RestoreFilterTabs(persistenceData); + } + } + + private void RestoreFilterTabs (PersistenceData persistenceData) + { + foreach (var data in persistenceData.FilterTabDataList) + { + var persistFilterParams = data.FilterParams; + ReInitFilterParams(persistFilterParams); + List filterResultList = []; + //List lastFilterResultList = new List(); + List filterHitList = []; + Filter(persistFilterParams, filterResultList, _lastFilterLinesList, filterHitList); + FilterPipe pipe = new(persistFilterParams.Clone(), this); + WritePipeToTab(pipe, filterResultList, data.PersistenceData.TabName, data.PersistenceData); + } + } + + private void ReInitFilterParams (FilterParams filterParams) + { + filterParams.SearchText = filterParams.SearchText; // init "lowerSearchText" + filterParams.RangeSearchText = filterParams.RangeSearchText; // init "lowerRangesearchText" + filterParams.CurrentColumnizer = CurrentColumnizer; + if (filterParams.IsRegex) + { + try + { + filterParams.CreateRegex(); + } + catch (ArgumentException) + { + StatusLineError("Invalid regular expression"); + } + } + } + + private void EnterLoadFileStatus () + { + _logger.Debug(CultureInfo.InvariantCulture, "EnterLoadFileStatus begin"); + + if (InvokeRequired) + { + Invoke(new MethodInvoker(EnterLoadFileStatus)); + return; + } + + _statusEventArgs.StatusText = "Loading file..."; + _statusEventArgs.LineCount = 0; + _statusEventArgs.FileSize = 0; + SendStatusLineUpdate(); + + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = 0; + _progressEventArgs.Value = 0; + _progressEventArgs.Visible = true; + SendProgressBarUpdate(); + + _isLoading = true; + _shouldCancel = true; + ClearFilterList(); + ClearBookmarkList(); + dataGridView.ClearSelection(); + dataGridView.RowCount = 0; + _logger.Debug(CultureInfo.InvariantCulture, "EnterLoadFileStatus end"); + } + + [SupportedOSPlatform("windows")] + private void PositionAfterReload (ReloadMemento reloadMemento) + { + if (_reloadMemento.CurrentLine < dataGridView.RowCount && _reloadMemento.CurrentLine >= 0) + { + dataGridView.CurrentCell = dataGridView.Rows[_reloadMemento.CurrentLine].Cells[0]; + } + + if (_reloadMemento.FirstDisplayedLine < dataGridView.RowCount && _reloadMemento.FirstDisplayedLine >= 0) + { + dataGridView.FirstDisplayedScrollingRowIndex = _reloadMemento.FirstDisplayedLine; + } + } + + [SupportedOSPlatform("windows")] + private void LogfileDead () + { + _logger.Info(CultureInfo.InvariantCulture, "File not found."); + _isDeadFile = true; + + //this.logFileReader.FileSizeChanged -= this.FileSizeChangedHandler; + //if (this.logFileReader != null) + // this.logFileReader.stopMonitoring(); + + dataGridView.Enabled = false; + dataGridView.RowCount = 0; + _progressEventArgs.Visible = false; + _progressEventArgs.Value = _progressEventArgs.MaxValue; + SendProgressBarUpdate(); + _statusEventArgs.FileSize = 0; + _statusEventArgs.LineCount = 0; + _statusEventArgs.CurrentLineNum = 0; + SendStatusLineUpdate(); + _shouldCancel = true; + ClearFilterList(); + ClearBookmarkList(); + + StatusLineText("File not found"); + OnFileNotFound(EventArgs.Empty); + } + + [SupportedOSPlatform("windows")] + private void LogfileRespawned () + { + _logger.Info(CultureInfo.InvariantCulture, "LogfileDead(): Reloading file because it has been respawned."); + _isDeadFile = false; + dataGridView.Enabled = true; + StatusLineText(""); + OnFileRespawned(EventArgs.Empty); + Reload(); + } + + [SupportedOSPlatform("windows")] + private void SetGuiAfterLoading () + { + if (Text.Length == 0) + { + Text = IsTempFile + ? TempTitleName + : Util.GetNameFromPath(FileName); + } + + ShowBookmarkBubbles = Preferences.ShowBubbles; + //if (this.forcedColumnizer == null) + { + ILogLineColumnizer columnizer; + if (_forcedColumnizerForLoading != null) + { + columnizer = _forcedColumnizerForLoading; + _forcedColumnizerForLoading = null; + } + else + { + columnizer = FindColumnizer(); + if (columnizer != null) + { + if (_reloadMemento == null) + { + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + + columnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); + } + } + else + { + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + + // Default Columnizers + columnizer = ColumnizerPicker.CloneColumnizer(ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers), directory); + } + } + + Invoke(new SetColumnizerFx(SetColumnizer), columnizer); + } + + dataGridView.Enabled = true; + DisplayCurrentFileOnStatusline(); + //this.guiStateArgs.FollowTail = this.Preferences.followTail; + _guiStateArgs.MultiFileEnabled = !IsTempFile; + _guiStateArgs.MenuEnabled = true; + _guiStateArgs.CurrentEncoding = _logFileReader.CurrentEncoding; + SendGuiStateUpdate(); + //if (this.dataGridView.RowCount > 0) + // SelectLine(this.dataGridView.RowCount - 1); + //if (this.dataGridView.Columns.Count > 1) + //{ + // this.dataGridView.Columns[this.dataGridView.Columns.Count-1].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; + // this.dataGridView.Columns[this.dataGridView.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; + // AdjustMinimumGridWith(); + //} + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + if (Preferences.TimestampControl) + { + SetTimestampLimits(); + SyncTimestampDisplay(); + } + + var settings = ConfigManager.Settings; + ShowLineColumn(!settings.HideLineColumn); + } + + ShowTimeSpread(Preferences.ShowTimeSpread && CurrentColumnizer.IsTimeshiftImplemented()); + locateLineInOriginalFileToolStripMenuItem.Enabled = FilterPipe != null; + } + + private ILogLineColumnizer FindColumnizer () + { + var columnizer = Preferences.MaskPrio + ? _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)) ?? _parentLogTabWin.GetColumnizerHistoryEntry(FileName) + : _parentLogTabWin.GetColumnizerHistoryEntry(FileName) ?? _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)); + + return columnizer; + } + + private void ReloadNewFile () + { + // prevent "overloads". May occur on very fast rollovers (next rollover before the file is reloaded) + lock (_reloadLock) + { + _reloadOverloadCounter++; + _logger.Info($"ReloadNewFile(): counter = {_reloadOverloadCounter}"); + if (_reloadOverloadCounter <= 1) + { + SavePersistenceData(false); + _loadingFinishedEvent.Reset(); + _externaLoadingFinishedEvent.Reset(); + Thread reloadFinishedThread = new(ReloadFinishedThreadFx) + { + IsBackground = true + }; + reloadFinishedThread.Start(); + LoadFile(FileName, EncodingOptions); + + ClearBookmarkList(); + SavePersistenceData(false); + + //if (this.filterTailCheckBox.Checked) + //{ + // _logger.logDebug("Waiting for loading to be complete."); + // loadingFinishedEvent.WaitOne(); + // _logger.logDebug("Refreshing filter view because of reload."); + // FilterSearch(); + //} + //LoadFilterPipes(); + } + else + { + _logger.Debug(CultureInfo.InvariantCulture, "Preventing reload because of recursive calls."); + } + + _reloadOverloadCounter--; + } + } + + [SupportedOSPlatform("windows")] + private void ReloadFinishedThreadFx () + { + _logger.Info(CultureInfo.InvariantCulture, "Waiting for loading to be complete."); + _loadingFinishedEvent.WaitOne(); + _logger.Info(CultureInfo.InvariantCulture, "Refreshing filter view because of reload."); + Invoke(new MethodInvoker(FilterSearch)); + LoadFilterPipes(); + } + + private void UpdateProgress (LoadFileEventArgs e) + { + try + { + if (e.ReadPos >= e.FileSize) + { + //_logger.Warn(CultureInfo.InvariantCulture, "UpdateProgress(): ReadPos (" + e.ReadPos + ") is greater than file size (" + e.FileSize + "). Aborting Update"); + return; + } + + _statusEventArgs.FileSize = e.ReadPos; + //this.progressEventArgs.Visible = true; + _progressEventArgs.MaxValue = (int)e.FileSize; + _progressEventArgs.Value = (int)e.ReadPos; + SendProgressBarUpdate(); + SendStatusLineUpdate(); + } + catch (Exception ex) + { + _logger.Error(ex, "UpdateProgress(): "); + } + } + + private void LoadingStarted (LoadFileEventArgs e) + { + try + { + _statusEventArgs.FileSize = e.ReadPos; + _statusEventArgs.StatusText = "Loading " + Util.GetNameFromPath(e.FileName); + _progressEventArgs.Visible = true; + _progressEventArgs.MaxValue = (int)e.FileSize; + _progressEventArgs.Value = (int)e.ReadPos; + SendProgressBarUpdate(); + SendStatusLineUpdate(); + } + catch (Exception ex) + { + _logger.Error(ex, "LoadingStarted(): "); + } + } + + private void LoadingFinished () + { + _logger.Info(CultureInfo.InvariantCulture, "File loading complete."); + + StatusLineText(""); + _logFileReader.FileSizeChanged += OnFileSizeChanged; + _isLoading = false; + _shouldCancel = false; + dataGridView.SuspendLayout(); + dataGridView.RowCount = _logFileReader.LineCount; + dataGridView.CurrentCellChanged += OnDataGridViewCurrentCellChanged; + dataGridView.Enabled = true; + dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + dataGridView.ResumeLayout(); + _progressEventArgs.Visible = false; + _progressEventArgs.Value = _progressEventArgs.MaxValue; + SendProgressBarUpdate(); + //if (this.logFileReader.LineCount > 0) + //{ + // this.dataGridView.FirstDisplayedScrollingRowIndex = this.logFileReader.LineCount - 1; + // SelectLine(this.logFileReader.LineCount - 1); + //} + _guiStateArgs.FollowTail = true; + SendGuiStateUpdate(); + _statusEventArgs.LineCount = _logFileReader.LineCount; + _statusEventArgs.FileSize = _logFileReader.FileSize; + SendStatusLineUpdate(); + + var setLastColumnWidth = _parentLogTabWin.Preferences.SetLastColumnWidth; + var lastColumnWidth = _parentLogTabWin.Preferences.LastColumnWidth; + var fontName = _parentLogTabWin.Preferences.FontName; + var fontSize = _parentLogTabWin.Preferences.FontSize; + + PreferencesChanged(fontName, fontSize, setLastColumnWidth, lastColumnWidth, true, SettingsFlags.All); + //LoadPersistenceData(); + } + + private void LogEventWorker () + { + Thread.CurrentThread.Name = "LogEventWorker"; + while (true) + { + _logger.Debug(CultureInfo.InvariantCulture, "Waiting for signal"); + _logEventArgsEvent.WaitOne(); + _logger.Debug(CultureInfo.InvariantCulture, "Wakeup signal received."); + while (true) + { + LogEventArgs e; + var lastLineCount = 0; + lock (_logEventArgsList) + { + _logger.Info(CultureInfo.InvariantCulture, "{0} events in queue", _logEventArgsList.Count); + if (_logEventArgsList.Count == 0) + { + _logEventArgsEvent.Reset(); + break; + } + + e = _logEventArgsList[0]; + _logEventArgsList.RemoveAt(0); + } + + if (e.IsRollover) + { + ShiftBookmarks(e.RolloverOffset); + ShiftRowHeightList(e.RolloverOffset); + ShiftFilterPipes(e.RolloverOffset); + lastLineCount = 0; + } + else + { + if (e.LineCount < lastLineCount) + { + _logger.Error("Line count of event is: {0}, should be greater than last line count: {1}", e.LineCount, lastLineCount); + } + } + + Invoke(UpdateGrid, [e]); + CheckFilterAndHighlight(e); + _timeSpreadCalc.SetLineCount(e.LineCount); + } + } + } + + private void StopLogEventWorkerThread () + { + _logEventArgsEvent.Set(); + cts.Cancel(); + //_logEventHandlerThread.Abort(); + //_logEventHandlerThread.Join(); + } + + private void OnFileSizeChanged (LogEventArgs e) + { + FileSizeChanged?.Invoke(this, e); + } + + private void UpdateGrid (LogEventArgs e) + { + var oldRowCount = dataGridView.RowCount; + var firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex; + + if (dataGridView.CurrentCellAddress.Y >= e.LineCount) + { + //this.dataGridView.Rows[this.dataGridView.CurrentCellAddress.Y].Selected = false; + //this.dataGridView.CurrentCell = this.dataGridView.Rows[0].Cells[0]; + } + + try + { + if (dataGridView.RowCount > e.LineCount) + { + var currentLineNum = dataGridView.CurrentCellAddress.Y; + dataGridView.RowCount = 0; + dataGridView.RowCount = e.LineCount; + if (_guiStateArgs.FollowTail == false) + { + if (currentLineNum >= dataGridView.RowCount) + { + currentLineNum = dataGridView.RowCount - 1; + } + + dataGridView.CurrentCell = dataGridView.Rows[currentLineNum].Cells[0]; + } + } + else + { + dataGridView.RowCount = e.LineCount; + } + + _logger.Debug(CultureInfo.InvariantCulture, "UpdateGrid(): new RowCount={0}", dataGridView.RowCount); + + if (e.IsRollover) + { + // Multifile rollover + // keep selection and view range, if no follow tail mode + if (!_guiStateArgs.FollowTail) + { + var currentLineNum = dataGridView.CurrentCellAddress.Y; + currentLineNum -= e.RolloverOffset; + if (currentLineNum < 0) + { + currentLineNum = 0; + } + + _logger.Debug(CultureInfo.InvariantCulture, "UpdateGrid(): Rollover=true, Rollover offset={0}, currLineNum was {1}, new currLineNum={2}", e.RolloverOffset, dataGridView.CurrentCellAddress.Y, currentLineNum); + firstDisplayedLine -= e.RolloverOffset; + if (firstDisplayedLine < 0) + { + firstDisplayedLine = 0; + } + + dataGridView.FirstDisplayedScrollingRowIndex = firstDisplayedLine; + dataGridView.CurrentCell = dataGridView.Rows[currentLineNum].Cells[0]; + dataGridView.Rows[currentLineNum].Selected = true; + } + } + + _statusEventArgs.LineCount = e.LineCount; + StatusLineFileSize(e.FileSize); + + if (!_isLoading) + { + if (oldRowCount == 0) + { + AdjustMinimumGridWith(); + } + + //CheckFilterAndHighlight(e); + } + + if (_guiStateArgs.FollowTail && dataGridView.RowCount > 0) + { + dataGridView.FirstDisplayedScrollingRowIndex = dataGridView.RowCount - 1; + OnTailFollowed(EventArgs.Empty); + } + + if (Preferences.TimestampControl && !_isLoading) + { + SetTimestampLimits(); + } + } + catch (Exception ex) + { + _logger.Error(ex, "Fehler bei UpdateGrid(): "); + } + + //this.dataGridView.Refresh(); + //this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + } + + private void CheckFilterAndHighlight (LogEventArgs e) + { + var noLed = true; + bool suppressLed; + bool setBookmark; + bool stopTail; + string bookmarkComment; + + if (filterTailCheckBox.Checked || _filterPipeList.Count > 0) + { + var filterStart = e.PrevLineCount; + if (e.IsRollover) + { + ShiftFilterLines(e.RolloverOffset); + filterStart -= e.RolloverOffset; + } + + var firstStopTail = true; + ColumnizerCallback callback = new(this); + var filterLineAdded = false; + for (var i = filterStart; i < e.LineCount; ++i) + { + var line = _logFileReader.GetLogLine(i); + if (line == null) + { + return; + } + + if (filterTailCheckBox.Checked) + { + callback.SetLineNum(i); + if (Util.TestFilterCondition(_filterParams, line, callback)) + { + //AddFilterLineFx addFx = new AddFilterLineFx(AddFilterLine); + //this.Invoke(addFx, new object[] { i, true }); + filterLineAdded = true; + AddFilterLine(i, false, _filterParams, _filterResultList, _lastFilterLinesList, + _filterHitList); + } + } + + //ProcessFilterPipeFx pipeFx = new ProcessFilterPipeFx(ProcessFilterPipes); + //pipeFx.BeginInvoke(i, null, null); + ProcessFilterPipes(i); + + var matchingList = FindMatchingHilightEntries(line); + LaunchHighlightPlugins(matchingList, i); + GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, out bookmarkComment); + if (setBookmark) + { + SetBookmarkFx fx = SetBookmarkFromTrigger; + fx.BeginInvoke(i, bookmarkComment, null, null); + } + + if (stopTail && _guiStateArgs.FollowTail) + { + var wasFollow = _guiStateArgs.FollowTail; + FollowTailChanged(false, true); + if (firstStopTail && wasFollow) + { + Invoke(new SelectLineFx(SelectAndEnsureVisible), [i, false]); + firstStopTail = false; + } + } + + if (!suppressLed) + { + noLed = false; + } + } + + if (filterLineAdded) + { + //AddFilterLineGuiUpdateFx addFx = new AddFilterLineGuiUpdateFx(AddFilterLineGuiUpdate); + //this.Invoke(addFx); + TriggerFilterLineGuiUpdate(); + } + } + else + { + var firstStopTail = true; + var startLine = e.PrevLineCount; + if (e.IsRollover) + { + ShiftFilterLines(e.RolloverOffset); + startLine -= e.RolloverOffset; + } + + for (var i = startLine; i < e.LineCount; ++i) + { + var line = _logFileReader.GetLogLine(i); + if (line != null) + { + var matchingList = FindMatchingHilightEntries(line); + LaunchHighlightPlugins(matchingList, i); + GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, + out bookmarkComment); + if (setBookmark) + { + SetBookmarkFx fx = SetBookmarkFromTrigger; + fx.BeginInvoke(i, bookmarkComment, null, null); + } + + if (stopTail && _guiStateArgs.FollowTail) + { + var wasFollow = _guiStateArgs.FollowTail; + FollowTailChanged(false, true); + if (firstStopTail && wasFollow) + { + Invoke(new SelectLineFx(SelectAndEnsureVisible), [i, false]); + firstStopTail = false; + } + } + + if (!suppressLed) + { + noLed = false; + } + } + } + } + + if (!noLed) + { + OnFileSizeChanged(e); + } + } + + private void LaunchHighlightPlugins (IList matchingList, int lineNum) + { + LogExpertCallback callback = new(this) + { + LineNum = lineNum + }; + + foreach (var entry in matchingList) + { + if (entry.IsActionEntry && entry.ActionEntry.PluginName != null) + { + var plugin = PluginRegistry.PluginRegistry.Instance.FindKeywordActionPluginByName(entry.ActionEntry.PluginName); + if (plugin != null) + { + ActionPluginExecuteFx fx = plugin.Execute; + fx.BeginInvoke(entry.SearchText, entry.ActionEntry.ActionParam, callback, CurrentColumnizer, null, null); + } + } + } + } + + private void PreSelectColumnizer (ILogLineColumnizer columnizer) + { + CurrentColumnizer = columnizer != null + ? (_forcedColumnizerForLoading = columnizer) + : (_forcedColumnizerForLoading = ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers)); + } + + private void SetColumnizer (ILogLineColumnizer columnizer) + { + columnizer = ColumnizerPicker.FindReplacementForAutoColumnizer(FileName, _logFileReader, columnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + + var timeDiff = 0; + if (CurrentColumnizer != null && CurrentColumnizer.IsTimeshiftImplemented()) + { + timeDiff = CurrentColumnizer.GetTimeOffset(); + } + + SetColumnizerInternal(columnizer); + + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + CurrentColumnizer.SetTimeOffset(timeDiff); + } + } + + private void SetColumnizerInternal (ILogLineColumnizer columnizer) + { + _logger.Info(CultureInfo.InvariantCulture, "SetColumnizerInternal(): {0}", columnizer.GetName()); + + var oldColumnizer = CurrentColumnizer; + var oldColumnizerIsXmlType = CurrentColumnizer is ILogLineXmlColumnizer; + var oldColumnizerIsPreProcess = CurrentColumnizer is IPreProcessColumnizer; + var mustReload = false; + + // Check if the filtered columns disappeared, if so must refresh the UI + if (_filterParams.ColumnRestrict) + { + var newColumns = columnizer != null ? columnizer.GetColumnNames() : Array.Empty(); + var colChanged = false; + + if (dataGridView.ColumnCount - 2 == newColumns.Length) // two first columns are 'marker' and 'line number' + { + for (var i = 0; i < newColumns.Length; i++) + { + if (dataGridView.Columns[i].HeaderText != newColumns[i]) + { + colChanged = true; + break; // one change is sufficient + } + } + } + else + { + colChanged = true; + } + + if (colChanged) + { + // Update UI + columnNamesLabel.Text = CalculateColumnNames(_filterParams); + } + } + + var oldColType = _filterParams.CurrentColumnizer?.GetType(); + var newColType = columnizer?.GetType(); + + if (oldColType != newColType && _filterParams.ColumnRestrict && _filterParams.IsFilterTail) + { + _filterParams.ColumnList.Clear(); + } + + if (CurrentColumnizer == null || CurrentColumnizer.GetType() != columnizer.GetType()) + { + CurrentColumnizer = columnizer; + _freezeStateMap.Clear(); + if (_logFileReader != null) + { + if (CurrentColumnizer is IPreProcessColumnizer) + { + _logFileReader.PreProcessColumnizer = (IPreProcessColumnizer)CurrentColumnizer; + } + else + { + _logFileReader.PreProcessColumnizer = null; + } + } + + // always reload when choosing XML columnizers + if (_logFileReader != null && CurrentColumnizer is ILogLineXmlColumnizer) + { + //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() + mustReload = true; + } + + // Reload when choosing no XML columnizer but previous columnizer was XML + if (_logFileReader != null && !(CurrentColumnizer is ILogLineXmlColumnizer) && oldColumnizerIsXmlType) + { + _logFileReader.IsXmlMode = false; + //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() + mustReload = true; + } + + // Reload when previous columnizer was PreProcess and current is not, and vice versa. + // When the current columnizer is a preProcess columnizer, reload in every case. + if (CurrentColumnizer is IPreProcessColumnizer != oldColumnizerIsPreProcess || + CurrentColumnizer is IPreProcessColumnizer) + { + //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() + mustReload = true; + } + } + else + { + CurrentColumnizer = columnizer; + } + + (oldColumnizer as IInitColumnizer)?.DeSelected(new ColumnizerCallback(this)); + + (columnizer as IInitColumnizer)?.Selected(new ColumnizerCallback(this)); + + SetColumnizer(columnizer, dataGridView); + SetColumnizer(columnizer, filterGridView); + _patternWindow?.SetColumnizer(columnizer); + + _guiStateArgs.TimeshiftPossible = columnizer.IsTimeshiftImplemented(); + SendGuiStateUpdate(); + + if (_logFileReader != null) + { + dataGridView.RowCount = _logFileReader.LineCount; + } + + if (_filterResultList != null) + { + filterGridView.RowCount = _filterResultList.Count; + } + + if (mustReload) + { + Reload(); + } + else + { + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + SetTimestampLimits(); + SyncTimestampDisplay(); + } + + var settings = ConfigManager.Settings; + ShowLineColumn(!settings.HideLineColumn); + ShowTimeSpread(Preferences.ShowTimeSpread && columnizer.IsTimeshiftImplemented()); + } + + if (!columnizer.IsTimeshiftImplemented() && IsTimeSynced) + { + FreeFromTimeSync(); + } + + columnComboBox.Items.Clear(); + + foreach (var columnName in columnizer.GetColumnNames()) + { + columnComboBox.Items.Add(columnName); + } + + columnComboBox.SelectedIndex = 0; + + OnColumnizerChanged(CurrentColumnizer); + } + + private void AutoResizeColumns (BufferedDataGridView gridView) + { + try + { + gridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + if (gridView.Columns.Count > 1 && Preferences.SetLastColumnWidth && + gridView.Columns[gridView.Columns.Count - 1].Width < Preferences.LastColumnWidth + ) + { + // It seems that using 'MinimumWidth' instead of 'Width' prevents the DataGridView's NullReferenceExceptions + //gridView.Columns[gridView.Columns.Count - 1].Width = this.Preferences.lastColumnWidth; + gridView.Columns[gridView.Columns.Count - 1].MinimumWidth = Preferences.LastColumnWidth; + } + } + catch (NullReferenceException e) + { + // See https://connect.microsoft.com/VisualStudio/feedback/details/366943/autoresizecolumns-in-datagridview-throws-nullreferenceexception + // possible solution => https://stackoverflow.com/questions/36287553/nullreferenceexception-when-trying-to-set-datagridview-column-width-brings-th + // There are some rare situations with null ref exceptions when resizing columns and on filter finished + // So catch them here. Better than crashing. + _logger.Error(e, "Error while resizing columns: "); + } + } + + private void PaintCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) + { + PaintHighlightedCell(e, gridView, noBackgroundFill, groundEntry); + } + + private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) + { + var column = e.Value as IColumn; + + column ??= Column.EmptyColumn; + + var matchList = FindHighlightMatches(column); + // too many entries per line seem to cause problems with the GDI + while (matchList.Count > 50) + { + matchList.RemoveAt(50); + } + + var he = new HighlightEntry + { + SearchText = column.DisplayValue, + ForegroundColor = groundEntry?.ForegroundColor ?? Color.FromKnownColor(KnownColor.Black), + BackgroundColor = groundEntry?.BackgroundColor ?? Color.Empty, + IsWordMatch = true + }; + + HighlightMatchEntry hme = new() + { + StartPos = 0, + Length = column.DisplayValue.Length, + HighlightEntry = he + }; + + if (groundEntry != null) + { + hme.HighlightEntry.IsBold = groundEntry.IsBold; + } + + matchList = MergeHighlightMatchEntries(matchList, hme); + + //var leftPad = e.CellStyle.Padding.Left; + //RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, e.CellBounds.Height); + + var borderWidths = PaintHelper.BorderWidths(e.AdvancedBorderStyle); + var valBounds = e.CellBounds; + valBounds.Offset(borderWidths.X, borderWidths.Y); + valBounds.Width -= borderWidths.Right; + valBounds.Height -= borderWidths.Bottom; + if (e.CellStyle.Padding != Padding.Empty) + { + valBounds.Offset(e.CellStyle.Padding.Left, e.CellStyle.Padding.Top); + valBounds.Width -= e.CellStyle.Padding.Horizontal; + valBounds.Height -= e.CellStyle.Padding.Vertical; + } + + var flags = + TextFormatFlags.Left + | TextFormatFlags.SingleLine + | TextFormatFlags.NoPrefix + | TextFormatFlags.PreserveGraphicsClipping + | TextFormatFlags.NoPadding + | TextFormatFlags.VerticalCenter + | TextFormatFlags.TextBoxControl + ; + + // | TextFormatFlags.VerticalCenter + // | TextFormatFlags.TextBoxControl + // TextFormatFlags.SingleLine + + //TextRenderer.DrawText(e.Graphics, e.Value as String, e.CellStyle.Font, valBounds, Color.FromKnownColor(KnownColor.Black), flags); + + var wordPos = valBounds.Location; + Size proposedSize = new(valBounds.Width, valBounds.Height); + + var r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); + e.Graphics.SetClip(e.CellBounds); + + foreach (var matchEntry in matchList) + { + var font = matchEntry != null && matchEntry.HighlightEntry.IsBold ? BoldFont : NormalFont; + + Brush bgBrush = matchEntry.HighlightEntry.BackgroundColor != Color.Empty + ? new SolidBrush(matchEntry.HighlightEntry.BackgroundColor) + : null; + + var matchWord = column.DisplayValue.Substring(matchEntry.StartPos, matchEntry.Length); + var wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags); + wordSize.Height = e.CellBounds.Height; + Rectangle wordRect = new(wordPos, wordSize); + + var foreColor = matchEntry.HighlightEntry.ForegroundColor; + if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected) + { + if (!noBackgroundFill && bgBrush != null && !matchEntry.HighlightEntry.NoBackground) + { + e.Graphics.FillRectangle(bgBrush, wordRect); + } + } + + TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, foreColor, flags); + + wordPos.Offset(wordSize.Width, 0); + bgBrush?.Dispose(); + } + } + + /// + /// Builds a list of HilightMatchEntry objects. A HilightMatchEntry spans over a region that is painted with the same foreground and + /// background colors. + /// All regions which don't match a word-mode entry will be painted with the colors of a default entry (groundEntry). This is either the + /// first matching non-word-mode highlight entry or a black-on-white default (if no matching entry was found). + /// + /// List of all highlight matches for the current cell + /// The entry that is used as the default. + /// List of HighlightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring. + private IList MergeHighlightMatchEntries (IList matchList, HighlightMatchEntry groundEntry) + { + // Fill an area with lenth of whole text with a default hilight entry + var entryArray = new HighlightEntry[groundEntry.Length]; + for (var i = 0; i < entryArray.Length; ++i) + { + entryArray[i] = groundEntry.HighlightEntry; + } + + // "overpaint" with all matching word match enries + // Non-word-mode matches will not overpaint because they use the groundEntry + foreach (var me in matchList) + { + var endPos = me.StartPos + me.Length; + for (var i = me.StartPos; i < endPos; ++i) + { + if (me.HighlightEntry.IsWordMatch) + { + entryArray[i] = me.HighlightEntry; + } + else + { + //entryArray[i].ForegroundColor = me.HilightEntry.ForegroundColor; + } + } + } + + // collect areas with same hilight entry and build new highlight match entries for it + IList mergedList = []; + + if (entryArray.Length > 0) + { + var currentEntry = entryArray[0]; + var lastStartPos = 0; + var pos = 0; + + for (; pos < entryArray.Length; ++pos) + { + if (entryArray[pos] != currentEntry) + { + HighlightMatchEntry me = new() + { + StartPos = lastStartPos, + Length = pos - lastStartPos, + HighlightEntry = currentEntry + }; + + mergedList.Add(me); + currentEntry = entryArray[pos]; + lastStartPos = pos; + } + } + + HighlightMatchEntry me2 = new() + { + StartPos = lastStartPos, + Length = pos - lastStartPos, + HighlightEntry = currentEntry + }; + + mergedList.Add(me2); + } + + return mergedList; + } + + /// + /// Returns the first HilightEntry that matches the given line + /// + private HighlightEntry FindHilightEntry (ITextValue line) + { + return FindHighlightEntry(line, false); + } + + private HighlightEntry FindFirstNoWordMatchHilightEntry (ITextValue line) + { + return FindHighlightEntry(line, true); + } + + private bool CheckHighlightEntryMatch (HighlightEntry entry, ITextValue column) + { + if (entry.IsRegEx) + { + //Regex rex = new Regex(entry.SearchText, entry.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); + if (entry.Regex.IsMatch(column.Text)) + { + return true; + } + } + else + { + if (entry.IsCaseSensitive) + { + if (column.Text.Contains(entry.SearchText, StringComparison.Ordinal)) + { + return true; + } + } + else + { + if (column.Text.ToUpperInvariant().Contains(entry.SearchText.ToUpperInvariant(), StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + } + + return false; + } + + /// + /// Returns all HilightEntry entries which matches the given line + /// + private IList FindMatchingHilightEntries (ITextValue line) + { + IList resultList = []; + if (line != null) + { + lock (_currentHighlightGroupLock) + { + foreach (var entry in _currentHighlightGroup.HighlightEntryList) + { + if (CheckHighlightEntryMatch(entry, line)) + { + resultList.Add(entry); + } + } + } + } + + return resultList; + } + + private void GetHighlightEntryMatches (ITextValue line, IList hilightEntryList, IList resultList) + { + foreach (var entry in hilightEntryList) + { + if (entry.IsWordMatch) + { + var matches = entry.Regex.Matches(line.Text); + foreach (Match match in matches) + { + HighlightMatchEntry me = new() + { + HighlightEntry = entry, + StartPos = match.Index, + Length = match.Length + }; + + resultList.Add(me); + } + } + else + { + if (CheckHighlightEntryMatch(entry, line)) + { + HighlightMatchEntry me = new() + { + HighlightEntry = entry, + StartPos = 0, + Length = line.Text.Length + }; + + resultList.Add(me); + } + } + } + } + + private void GetHilightActions (IList matchingList, out bool noLed, out bool stopTail, out bool setBookmark, out string bookmarkComment) + { + noLed = stopTail = setBookmark = false; + bookmarkComment = string.Empty; + + foreach (var entry in matchingList) + { + if (entry.IsLedSwitch) + { + noLed = true; + } + + if (entry.IsSetBookmark) + { + setBookmark = true; + if (!string.IsNullOrEmpty(entry.BookmarkComment)) + { + bookmarkComment += entry.BookmarkComment + "\r\n"; + } + } + + if (entry.IsStopTail) + { + stopTail = true; + } + } + + bookmarkComment = bookmarkComment.TrimEnd(['\r', '\n']); + } + + private void StopTimespreadThread () + { + _timeSpreadCalc.Stop(); + } + + private void StopTimestampSyncThread () + { + _shouldTimestampDisplaySyncingCancel = true; + //_timeShiftSyncWakeupEvent.Set(); + //_timeShiftSyncThread.Abort(); + //_timeShiftSyncThread.Join(); + cts.Cancel(); + } + + [SupportedOSPlatform("windows")] + private void SyncTimestampDisplay () + { + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + if (dataGridView.CurrentRow != null) + { + SyncTimestampDisplay(dataGridView.CurrentRow.Index); + } + } + } + + [SupportedOSPlatform("windows")] + private void SyncTimestampDisplay (int lineNum) + { + _timeShiftSyncLine = lineNum; + _timeShiftSyncTimerEvent.Set(); + _timeShiftSyncWakeupEvent.Set(); + } + + [SupportedOSPlatform("windows")] + private void SyncTimestampDisplayWorker () + { + const int WAIT_TIME = 500; + Thread.CurrentThread.Name = "SyncTimestampDisplayWorker"; + _shouldTimestampDisplaySyncingCancel = false; + _isTimestampDisplaySyncing = true; + + while (!_shouldTimestampDisplaySyncingCancel) + { + _timeShiftSyncWakeupEvent.WaitOne(); + if (_shouldTimestampDisplaySyncingCancel) + { + return; + } + + _timeShiftSyncWakeupEvent.Reset(); + + while (!_shouldTimestampDisplaySyncingCancel) + { + var signaled = _timeShiftSyncTimerEvent.WaitOne(WAIT_TIME, true); + _timeShiftSyncTimerEvent.Reset(); + if (!signaled) + { + break; + } + } + + // timeout with no new Trigger -> update display + var lineNum = _timeShiftSyncLine; + if (lineNum >= 0 && lineNum < dataGridView.RowCount) + { + var refLine = lineNum; + var timeStamp = GetTimestampForLine(ref refLine, true); + if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel) + { + _guiStateArgs.Timestamp = timeStamp; + SendGuiStateUpdate(); + if (_shouldCallTimeSync) + { + refLine = lineNum; + var exactTimeStamp = GetTimestampForLine(ref refLine, false); + SyncOtherWindows(exactTimeStamp); + _shouldCallTimeSync = false; + } + } + } + + // show time difference between 2 selected lines + if (dataGridView.SelectedRows.Count == 2) + { + var row1 = dataGridView.SelectedRows[0].Index; + var row2 = dataGridView.SelectedRows[1].Index; + if (row1 > row2) + { + (row2, row1) = (row1, row2); + } + + var refLine = row1; + var timeStamp1 = GetTimestampForLine(ref refLine, false); + refLine = row2; + var timeStamp2 = GetTimestampForLine(ref refLine, false); + //TimeSpan span = TimeSpan.FromTicks(timeStamp2.Ticks - timeStamp1.Ticks); + DateTime diff; + if (timeStamp1.Ticks > timeStamp2.Ticks) + { + diff = new DateTime(timeStamp1.Ticks - timeStamp2.Ticks); + } + else + { + diff = new DateTime(timeStamp2.Ticks - timeStamp1.Ticks); + } + + StatusLineText("Time diff is " + diff.ToString("HH:mm:ss.fff")); + } + else + { + if (!IsMultiFile && dataGridView.SelectedRows.Count == 1) + { + StatusLineText(string.Empty); + } + } + } + } + + [SupportedOSPlatform("windows")] + private void SyncFilterGridPos () + { + try + { + if (_filterResultList.Count > 0) + { + var index = _filterResultList.BinarySearch(dataGridView.CurrentRow.Index); + if (index < 0) + { + index = ~index; + if (index > 0) + { + --index; + } + } + + if (filterGridView.Rows.GetRowCount(DataGridViewElementStates.None) > 0) // exception no rows + { + filterGridView.CurrentCell = filterGridView.Rows[index].Cells[0]; + } + else + { + filterGridView.CurrentCell = null; + } + } + } + catch (Exception e) + { + _logger.Error(e, "SyncFilterGridPos(): "); + } + } + + private void StatusLineFileSize (long size) + { + _statusEventArgs.FileSize = size; + SendStatusLineUpdate(); + } + + [SupportedOSPlatform("windows")] + private int Search (SearchParams searchParams) + { + if (searchParams.SearchText == null) + { + return -1; + } + + var lineNum = searchParams.IsFromTop && !searchParams.IsFindNext + ? 0 + : searchParams.CurrentLine; + + var lowerSearchText = searchParams.SearchText.ToLowerInvariant(); + var count = 0; + var hasWrapped = false; + + while (true) + { + if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) + { + if (lineNum >= _logFileReader.LineCount) + { + if (hasWrapped) + { + StatusLineError("Not found: " + searchParams.SearchText); + return -1; + } + + lineNum = 0; + count = 0; + hasWrapped = true; + StatusLineError("Started from beginning of file"); + } + } + else + { + if (lineNum < 0) + { + if (hasWrapped) + { + StatusLineError("Not found: " + searchParams.SearchText); + return -1; + } + + count = 0; + lineNum = _logFileReader.LineCount - 1; + hasWrapped = true; + StatusLineError("Started from end of file"); + } + } + + var line = _logFileReader.GetLogLine(lineNum); + if (line == null) + { + return -1; + } + + if (searchParams.IsRegex) + { + Regex rex = new(searchParams.SearchText, searchParams.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); + if (rex.IsMatch(line.FullLine)) + { + return lineNum; + } + } + else + { + if (searchParams.IsCaseSensitive) + { + if (line.FullLine.Contains(searchParams.SearchText, StringComparison.Ordinal)) + { + return lineNum; + } + } + else + { + if (line.FullLine.Contains(lowerSearchText, StringComparison.OrdinalIgnoreCase)) + { + return lineNum; + } + } + } + + if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) + { + lineNum++; + } + else + { + lineNum--; + } + + if (_shouldCancel) + { + return -1; + } + + if (++count % PROGRESS_BAR_MODULO == 0) + { + try + { + if (!Disposing) + { + Invoke(UpdateProgressBar, [count]); + } + } + catch (ObjectDisposedException ex) // can occur when closing the app while searching + { + _logger.Warn(ex); + } + } + } + } + + private void ResetProgressBar () + { + _progressEventArgs.Value = _progressEventArgs.MaxValue; + _progressEventArgs.Visible = false; + SendProgressBarUpdate(); + } + + [SupportedOSPlatform("windows")] + private void SelectLine (int line, bool triggerSyncCall, bool shouldScroll) + { + try + { + _shouldCallTimeSync = triggerSyncCall; + var wasCancelled = _shouldCancel; + _shouldCancel = false; + _isSearching = false; + StatusLineText(string.Empty); + _guiStateArgs.MenuEnabled = true; + + if (wasCancelled) + { + return; + } + + if (line == -1) + { + // Hmm... is that experimental code from early days? + MessageBox.Show(this, "Not found:", "Search result"); + return; + } + + // Prevent ArgumentOutOfRangeException + if (line >= dataGridView.Rows.GetRowCount(DataGridViewElementStates.None)) + { + line = dataGridView.Rows.GetRowCount(DataGridViewElementStates.None) - 1; + } + + dataGridView.Rows[line].Selected = true; + + if (shouldScroll) + { + dataGridView.CurrentCell = dataGridView.Rows[line].Cells[0]; + dataGridView.Focus(); + } + } + catch (ArgumentOutOfRangeException e) + { + _logger.Error(e, "Error while selecting line: "); + } + catch (IndexOutOfRangeException e) + { + // Occures sometimes (but cannot reproduce) + _logger.Error(e, "Error while selecting line: "); + } + } + + [SupportedOSPlatform("windows")] + private void StartEditMode () + { + if (!dataGridView.CurrentCell.ReadOnly) + { + dataGridView.BeginEdit(false); + if (dataGridView.EditingControl != null) + { + if (dataGridView.EditingControl is LogCellEditingControl editControl) + { + editControl.KeyDown += OnEditControlKeyDown; + editControl.KeyPress += OnEditControlKeyPress; + editControl.KeyUp += OnEditControlKeyUp; + editControl.Click += OnEditControlClick; + dataGridView.CellEndEdit += OnDataGridViewCellEndEdit; + editControl.SelectionStart = 0; + } + else + { + _logger.Warn(CultureInfo.InvariantCulture, "Edit control in logWindow was null"); + } + } + } + } + + [SupportedOSPlatform("windows")] + private void UpdateEditColumnDisplay (DataGridViewTextBoxEditingControl editControl) + { + // prevents key events after edit mode has ended + if (dataGridView.EditingControl != null) + { + var pos = editControl.SelectionStart + editControl.SelectionLength; + StatusLineText(" " + pos); + _logger.Debug(CultureInfo.InvariantCulture, "SelStart: {0}, SelLen: {1}", editControl.SelectionStart, editControl.SelectionLength); + } + } + + [SupportedOSPlatform("windows")] + private void SelectPrevHighlightLine () + { + var lineNum = dataGridView.CurrentCellAddress.Y; + while (lineNum > 0) + { + lineNum--; + var line = _logFileReader.GetLogLine(lineNum); + if (line != null) + { + var entry = FindHilightEntry(line); + if (entry != null) + { + SelectLine(lineNum, false, true); + break; + } + } + } + } + + [SupportedOSPlatform("windows")] + private void SelectNextHighlightLine () + { + var lineNum = dataGridView.CurrentCellAddress.Y; + while (lineNum < _logFileReader.LineCount) + { + lineNum++; + var line = _logFileReader.GetLogLine(lineNum); + if (line != null) + { + var entry = FindHilightEntry(line); + if (entry != null) + { + SelectLine(lineNum, false, true); + break; + } + } + } + } + + [SupportedOSPlatform("windows")] + private int FindNextBookmarkIndex (int lineNum) + { + if (lineNum >= dataGridView.RowCount) + { + lineNum = 0; + } + else + { + lineNum++; + } + + return _bookmarkProvider.FindNextBookmarkIndex(lineNum); + } + + [SupportedOSPlatform("windows")] + private int FindPrevBookmarkIndex (int lineNum) + { + if (lineNum <= 0) + { + lineNum = dataGridView.RowCount - 1; + } + else + { + lineNum--; + } + + return _bookmarkProvider.FindPrevBookmarkIndex(lineNum); + } + + /** + * Shift bookmarks after a logfile rollover + */ + + private void ShiftBookmarks (int offset) + { + _bookmarkProvider.ShiftBookmarks(offset); + OnBookmarkRemoved(); + } + + private void ShiftRowHeightList (int offset) + { + SortedList newList = []; + foreach (var entry in _rowHeightList.Values) + { + var line = entry.LineNum - offset; + if (line >= 0) + { + entry.LineNum = line; + newList.Add(line, entry); + } + } + + _rowHeightList = newList; + } + + private void ShiftFilterPipes (int offset) + { + lock (_filterPipeList) + { + foreach (var pipe in _filterPipeList) + { + pipe.ShiftLineNums(offset); + } + } + } + + [SupportedOSPlatform("windows")] + private void LoadFilterPipes () + { + lock (_filterPipeList) + { + foreach (var pipe in _filterPipeList) + { + pipe.RecreateTempFile(); + } + } + + if (_filterPipeList.Count > 0) + { + for (var i = 0; i < dataGridView.RowCount; ++i) + { + ProcessFilterPipes(i); + } + } + } + + private void DisconnectFilterPipes () + { + lock (_filterPipeList) + { + foreach (var pipe in _filterPipeList) + { + pipe.ClearLineList(); + } + } + } + + [SupportedOSPlatform("windows")] + private void ApplyFilterParams () + { + filterComboBox.Text = _filterParams.SearchText; + filterCaseSensitiveCheckBox.Checked = _filterParams.IsCaseSensitive; + filterRegexCheckBox.Checked = _filterParams.IsRegex; + filterTailCheckBox.Checked = _filterParams.IsFilterTail; + invertFilterCheckBox.Checked = _filterParams.IsInvert; + filterKnobBackSpread.Value = _filterParams.SpreadBefore; + filterKnobForeSpread.Value = _filterParams.SpreadBehind; + rangeCheckBox.Checked = _filterParams.IsRangeSearch; + columnRestrictCheckBox.Checked = _filterParams.ColumnRestrict; + fuzzyKnobControl.Value = _filterParams.FuzzyValue; + filterRangeComboBox.Text = _filterParams.RangeSearchText; + } + + [SupportedOSPlatform("windows")] + private void ResetFilterControls () + { + filterComboBox.Text = ""; + filterCaseSensitiveCheckBox.Checked = false; + filterRegexCheckBox.Checked = false; + //this.filterTailCheckBox.Checked = this.Preferences.filterTail; + invertFilterCheckBox.Checked = false; + filterKnobBackSpread.Value = 0; + filterKnobForeSpread.Value = 0; + rangeCheckBox.Checked = false; + columnRestrictCheckBox.Checked = false; + fuzzyKnobControl.Value = 0; + filterRangeComboBox.Text = ""; + } + + [SupportedOSPlatform("windows")] + private void FilterSearch () + { + if (filterComboBox.Text.Length == 0) + { + _filterParams.SearchText = string.Empty; + _filterParams.LowerSearchText = string.Empty; + _filterParams.IsRangeSearch = false; + ClearFilterList(); + filterSearchButton.Image = null; + ResetFilterControls(); + saveFilterButton.Enabled = false; + return; + } + + FilterSearch(filterComboBox.Text); + } + + [SupportedOSPlatform("windows")] + private async void FilterSearch (string text) + { + FireCancelHandlers(); // make sure that there's no other filter running (maybe from filter restore) + + _filterParams.SearchText = text; + _filterParams.LowerSearchText = text.ToLowerInvariant(); + ConfigManager.Settings.FilterHistoryList.Remove(text); + ConfigManager.Settings.FilterHistoryList.Insert(0, text); + var maxHistory = ConfigManager.Settings.Preferences.MaximumFilterEntries; + + if (ConfigManager.Settings.FilterHistoryList.Count > maxHistory) + { + ConfigManager.Settings.FilterHistoryList.RemoveAt(filterComboBox.Items.Count - 1); + } + + filterComboBox.Items.Clear(); + foreach (var item in ConfigManager.Settings.FilterHistoryList) + { + filterComboBox.Items.Add(item); + } + + filterComboBox.Text = text; + + _filterParams.IsRangeSearch = rangeCheckBox.Checked; + _filterParams.RangeSearchText = filterRangeComboBox.Text; + if (_filterParams.IsRangeSearch) + { + ConfigManager.Settings.FilterRangeHistoryList.Remove(filterRangeComboBox.Text); + ConfigManager.Settings.FilterRangeHistoryList.Insert(0, filterRangeComboBox.Text); + if (ConfigManager.Settings.FilterRangeHistoryList.Count > maxHistory) + { + ConfigManager.Settings.FilterRangeHistoryList.RemoveAt(filterRangeComboBox.Items.Count - 1); + } + + filterRangeComboBox.Items.Clear(); + foreach (var item in ConfigManager.Settings.FilterRangeHistoryList) + { + filterRangeComboBox.Items.Add(item); + } + } + + ConfigManager.Save(SettingsFlags.FilterHistory); + + _filterParams.IsCaseSensitive = filterCaseSensitiveCheckBox.Checked; + _filterParams.IsRegex = filterRegexCheckBox.Checked; + _filterParams.IsFilterTail = filterTailCheckBox.Checked; + _filterParams.IsInvert = invertFilterCheckBox.Checked; + if (_filterParams.IsRegex) + { + try + { + _filterParams.CreateRegex(); + } + catch (ArgumentException) + { + StatusLineError("Invalid regular expression"); + return; + } + } + + _filterParams.FuzzyValue = fuzzyKnobControl.Value; + _filterParams.SpreadBefore = filterKnobBackSpread.Value; + _filterParams.SpreadBehind = filterKnobForeSpread.Value; + _filterParams.ColumnRestrict = columnRestrictCheckBox.Checked; + + //ConfigManager.SaveFilterParams(this.filterParams); + ConfigManager.Settings.FilterParams = _filterParams; // wozu eigentlich? sinnlos seit MDI? + + _shouldCancel = false; + _isSearching = true; + StatusLineText("Filtering... Press ESC to cancel"); + filterSearchButton.Enabled = false; + ClearFilterList(); + + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = dataGridView.RowCount; + _progressEventArgs.Value = 0; + _progressEventArgs.Visible = true; + SendProgressBarUpdate(); + + var settings = ConfigManager.Settings; + + //FilterFx fx = settings.preferences.multiThreadFilter ? MultiThreadedFilter : new FilterFx(Filter); + FilterFxAction = settings.Preferences.MultiThreadFilter ? MultiThreadedFilter : Filter; + + //Task.Run(() => fx.Invoke(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList)); + var filterFxActionTask = Task.Run(() => Filter(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList)); + + await filterFxActionTask; + FilterComplete(); + + //fx.BeginInvoke(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList, FilterComplete, null); + CheckForFilterDirty(); + } + + private void MultiThreadedFilter (FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) + { + ColumnizerCallback callback = new(this); + + FilterStarter fs = new(callback, Environment.ProcessorCount + 2) + { + FilterHitList = _filterHitList, + FilterResultLines = _filterResultList, + LastFilterLinesList = _lastFilterLinesList + }; + + var cancelHandler = new FilterCancelHandler(fs); + OnRegisterCancelHandler(cancelHandler); + long startTime = Environment.TickCount; + + fs.DoFilter(filterParams, 0, _logFileReader.LineCount, FilterProgressCallback); + + long endTime = Environment.TickCount; + + _logger.Debug($"Multi threaded filter duration: {endTime - startTime} ms."); + + OnDeRegisterCancelHandler(cancelHandler); + StatusLineText("Filter duration: " + (endTime - startTime) + " ms."); + } + + private void FilterProgressCallback (int lineCount) + { + UpdateProgressBar(lineCount); + } + + [SupportedOSPlatform("windows")] + private void Filter (FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) + { + long startTime = Environment.TickCount; + try + { + filterParams.Reset(); + var lineNum = 0; + //AddFilterLineFx addFx = new AddFilterLineFx(AddFilterLine); + ColumnizerCallback callback = new(this); + while (true) + { + var line = _logFileReader.GetLogLine(lineNum); + if (line == null) + { + break; + } + + callback.LineNum = lineNum; + if (Util.TestFilterCondition(filterParams, line, callback)) + { + AddFilterLine(lineNum, false, filterParams, filterResultLines, lastFilterLinesList, + filterHitList); + } + + lineNum++; + if (lineNum % PROGRESS_BAR_MODULO == 0) + { + UpdateProgressBar(lineNum); + } + + if (_shouldCancel) + { + break; + } + } + } + catch (Exception ex) + { + _logger.Error(ex, "Exception while filtering. Please report to developer: "); + MessageBox.Show(null, $"Exception while filtering. Please report to developer: \n\n{ex}\n\n{ex.StackTrace}", "LogExpert"); + } + + long endTime = Environment.TickCount; + + _logger.Info($"Single threaded filter duration: {endTime - startTime} ms."); + + StatusLineText("Filter duration: " + (endTime - startTime) + " ms."); + } + + /// + /// Returns a list with 'additional filter results'. This is the given line number + /// and (if back spread and/or fore spread is enabled) some additional lines. + /// This function doesn't check the filter condition! + /// + /// + /// + /// + /// + private IList GetAdditionalFilterResults (FilterParams filterParams, int lineNum, IList checkList) + { + IList resultList = []; + //string textLine = this.logFileReader.GetLogLine(lineNum); + //ColumnizerCallback callback = new ColumnizerCallback(this); + //callback.LineNum = lineNum; + + if (filterParams.SpreadBefore == 0 && filterParams.SpreadBehind == 0) + { + resultList.Add(lineNum); + return resultList; + } + + // back spread + for (var i = filterParams.SpreadBefore; i > 0; --i) + { + if (lineNum - i > 0) + { + if (!resultList.Contains(lineNum - i) && !checkList.Contains(lineNum - i)) + { + resultList.Add(lineNum - i); + } + } + } + + // direct filter hit + if (!resultList.Contains(lineNum) && !checkList.Contains(lineNum)) + { + resultList.Add(lineNum); + } + + // after spread + for (var i = 1; i <= filterParams.SpreadBehind; ++i) + { + if (lineNum + i < _logFileReader.LineCount) + { + if (!resultList.Contains(lineNum + i) && !checkList.Contains(lineNum + i)) + { + resultList.Add(lineNum + i); + } + } + } + + return resultList; + } + + [SupportedOSPlatform("windows")] + private void AddFilterLine (int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) + { + int count; + lock (_filterResultList) + { + filterHitList.Add(lineNum); + var filterResult = GetAdditionalFilterResults(filterParams, lineNum, lastFilterLinesList); + filterResultLines.AddRange(filterResult); + count = filterResultLines.Count; + lastFilterLinesList.AddRange(filterResult); + if (lastFilterLinesList.Count > SPREAD_MAX * 2) + { + lastFilterLinesList.RemoveRange(0, lastFilterLinesList.Count - SPREAD_MAX * 2); + } + } + + if (immediate) + { + TriggerFilterLineGuiUpdate(); + } + else if (lineNum % PROGRESS_BAR_MODULO == 0) + { + //FunctionWith1IntParam fx = new FunctionWith1IntParam(UpdateFilterCountLabel); + //this.Invoke(fx, new object[] { count}); + } + } + + [SupportedOSPlatform("windows")] + private void TriggerFilterLineGuiUpdate () + { + //lock (this.filterUpdateThread) + //{ + // this.filterEventCount++; + // this.filterUpdateEvent.Set(); + //} + Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); + } + + //private void FilterUpdateWorker() + //{ + // Thread.CurrentThread.Name = "FilterUpdateWorker"; + // while (true) + // { + // this.filterUpdateEvent.WaitOne(); + // lock (this.filterUpdateThread) + // { + // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); + // this.filterUpdateEvent.Reset(); + // } + + // //_logger.logDebug("FilterUpdateWorker: Waiting for signal"); + // //bool signaled = this.filterUpdateEvent.WaitOne(1000, false); + + // //if (!signaled) + // //{ + // // lock (this.filterUpdateThread) + // // { + // // if (this.filterEventCount > 0) + // // { + // // this.filterEventCount = 0; + // // _logger.logDebug("FilterUpdateWorker: Invoking GUI update because of wait timeout"); + // // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); + // // } + // // } + // //} + // //else + // //{ + // // _logger.logDebug("FilterUpdateWorker: Wakeup signal received."); + // // lock (this.filterUpdateThread) + // // { + // // _logger.logDebug("FilterUpdateWorker: event count: " + this.filterEventCount); + // // if (this.filterEventCount > 100) + // // { + // // this.filterEventCount = 0; + // // _logger.logDebug("FilterUpdateWorker: Invoking GUI update because of event count"); + // // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); + // // } + // // this.filterUpdateEvent.Reset(); + // // } + // //} + // } + //} + + //private void StopFilterUpdateWorkerThread() + //{ + // this.filterUpdateEvent.Set(); + // this.filterUpdateThread.Abort(); + // this.filterUpdateThread.Join(); + //} + + [SupportedOSPlatform("windows")] + private void AddFilterLineGuiUpdate () + { + try + { + lock (_filterResultList) + { + lblFilterCount.Text = "" + _filterResultList.Count; + if (filterGridView.RowCount > _filterResultList.Count) + { + filterGridView.RowCount = 0; // helps to prevent hang ? + } + + filterGridView.RowCount = _filterResultList.Count; + if (filterGridView.RowCount > 0) + { + filterGridView.FirstDisplayedScrollingRowIndex = filterGridView.RowCount - 1; + } + + if (filterGridView.RowCount == 1) + { + // after a file reload adjusted column sizes anew when the first line arrives + //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + AutoResizeColumns(filterGridView); + } + } + } + catch (Exception e) + { + _logger.Error(e, "AddFilterLineGuiUpdate(): "); + } + } + + private void UpdateProgressBar (int value) + { + _progressEventArgs.Value = value; + if (value > _progressEventArgs.MaxValue) + { + // can occur if new lines will be added while filtering + _progressEventArgs.MaxValue = value; + } + + SendProgressBarUpdate(); + } + + [SupportedOSPlatform("windows")] + private void FilterComplete () + { + if (!IsDisposed && !_waitingForClose && !Disposing) + { + Invoke(new MethodInvoker(ResetStatusAfterFilter)); + } + } + + [SupportedOSPlatform("windows")] + private void FilterComplete (IAsyncResult result) + { + if (!IsDisposed && !_waitingForClose && !Disposing) + { + Invoke(new MethodInvoker(ResetStatusAfterFilter)); + } + } + + [SupportedOSPlatform("windows")] + private void ResetStatusAfterFilter () + { + try + { + //StatusLineText(""); + _isSearching = false; + _progressEventArgs.Value = _progressEventArgs.MaxValue; + _progressEventArgs.Visible = false; + SendProgressBarUpdate(); + filterGridView.RowCount = _filterResultList.Count; + //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + AutoResizeColumns(filterGridView); + lblFilterCount.Text = "" + _filterResultList.Count; + if (filterGridView.RowCount > 0) + { + filterGridView.Focus(); + } + + filterSearchButton.Enabled = true; + } + catch (NullReferenceException e) + { + // See https://connect.microsoft.com/VisualStudio/feedback/details/366943/autoresizecolumns-in-datagridview-throws-nullreferenceexception + // There are some rare situations with null ref exceptions when resizing columns and on filter finished + // So catch them here. Better than crashing. + _logger.Error(e, "Error: "); + } + } + + [SupportedOSPlatform("windows")] + private void ClearFilterList () + { + try + { + //this.shouldCancel = true; + lock (_filterResultList) + { + filterGridView.SuspendLayout(); + filterGridView.RowCount = 0; + lblFilterCount.Text = "0"; + _filterResultList = []; + _lastFilterLinesList = []; + _filterHitList = []; + //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + filterGridView.ResumeLayout(); + } + } + catch (Exception ex) + { + _logger.Error(ex, "Wieder dieser sporadische Fehler: "); + + MessageBox.Show(null, ex.StackTrace, "Wieder dieser sporadische Fehler:"); + } + } + + private void ClearBookmarkList () + { + _bookmarkProvider.ClearAllBookmarks(); + } + + /** + * Shift filter list line entries after a logfile rollover + */ + [SupportedOSPlatform("windows")] + private void ShiftFilterLines (int offset) + { + List newFilterList = []; + lock (_filterResultList) + { + foreach (var lineNum in _filterResultList) + { + var line = lineNum - offset; + if (line >= 0) + { + newFilterList.Add(line); + } + } + + _filterResultList = newFilterList; + } + + newFilterList = []; + foreach (var lineNum in _filterHitList) + { + var line = lineNum - offset; + if (line >= 0) + { + newFilterList.Add(line); + } + } + + _filterHitList = newFilterList; + + var count = SPREAD_MAX; + if (_filterResultList.Count < SPREAD_MAX) + { + count = _filterResultList.Count; + } + + _lastFilterLinesList = _filterResultList.GetRange(_filterResultList.Count - count, count); + + //this.filterGridView.RowCount = this.filterResultList.Count; + //this.filterCountLabel.Text = "" + this.filterResultList.Count; + //this.BeginInvoke(new MethodInvoker(this.filterGridView.Refresh)); + //this.BeginInvoke(new MethodInvoker(AddFilterLineGuiUpdate)); + TriggerFilterLineGuiUpdate(); + } + + [SupportedOSPlatform("windows")] + private void CheckForFilterDirty () + { + if (IsFilterSearchDirty(_filterParams)) + { + filterSearchButton.Image = _searchButtonImage; + saveFilterButton.Enabled = false; + } + else + { + filterSearchButton.Image = null; + saveFilterButton.Enabled = true; + } + } + + [SupportedOSPlatform("windows")] + private bool IsFilterSearchDirty (FilterParams filterParams) + { + if (!filterParams.SearchText.Equals(filterComboBox.Text, StringComparison.Ordinal)) + { + return true; + } + + if (filterParams.IsRangeSearch != rangeCheckBox.Checked) + { + return true; + } + + if (filterParams.IsRangeSearch && !filterParams.RangeSearchText.Equals(filterRangeComboBox.Text, StringComparison.Ordinal)) + { + return true; + } + + if (filterParams.IsRegex != filterRegexCheckBox.Checked) + { + return true; + } + + if (filterParams.IsInvert != invertFilterCheckBox.Checked) + { + return true; + } + + if (filterParams.SpreadBefore != filterKnobBackSpread.Value) + { + return true; + } + + if (filterParams.SpreadBehind != filterKnobForeSpread.Value) + { + return true; + } + + if (filterParams.FuzzyValue != fuzzyKnobControl.Value) + { + return true; + } + + if (filterParams.ColumnRestrict != columnRestrictCheckBox.Checked) + { + return true; + } + + if (filterParams.IsCaseSensitive != filterCaseSensitiveCheckBox.Checked) + { + return true; + } + + return false; + } + + [SupportedOSPlatform("windows")] + private void AdjustMinimumGridWith () + { + if (dataGridView.Columns.Count > 1) + { + //this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); + AutoResizeColumns(dataGridView); + + var width = dataGridView.Columns.GetColumnsWidth(DataGridViewElementStates.Visible); + var diff = dataGridView.Width - width; + if (diff > 0) + { + diff -= dataGridView.RowHeadersWidth / 2; + dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].Width += diff; + filterGridView.Columns[filterGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].Width += diff; + } + } + } + + [SupportedOSPlatform("windows")] + private void InvalidateCurrentRow (BufferedDataGridView gridView) + { + if (gridView.CurrentCellAddress.Y > -1) + { + gridView.InvalidateRow(gridView.CurrentCellAddress.Y); + } + } + + private void InvalidateCurrentRow () + { + InvalidateCurrentRow(dataGridView); + InvalidateCurrentRow(filterGridView); + } + + [SupportedOSPlatform("windows")] + private void DisplayCurrentFileOnStatusline () + { + if (_logFileReader.IsMultiFile) + { + try + { + if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index > -1) + { + var fileName = _logFileReader.GetLogFileNameForLine(dataGridView.CurrentRow.Index); + if (fileName != null) + { + StatusLineText(Util.GetNameFromPath(fileName)); + } + } + } + catch (Exception) + { + // TODO: handle this concurrent situation better: + // this.dataGridView.CurrentRow may be null even if checked before. + // This can happen when MultiFile shift deselects the current row because there + // are less lines after rollover than before. + // access to dataGridView-Rows should be locked + } + } + } + + private void UpdateSelectionDisplay () + { + if (_noSelectionUpdates) + { + return; + } + } + + [SupportedOSPlatform("windows")] + private void UpdateFilterHistoryFromSettings () + { + ConfigManager.Settings.FilterHistoryList = ConfigManager.Settings.FilterHistoryList; + filterComboBox.Items.Clear(); + foreach (var item in ConfigManager.Settings.FilterHistoryList) + { + filterComboBox.Items.Add(item); + } + + filterRangeComboBox.Items.Clear(); + foreach (var item in ConfigManager.Settings.FilterRangeHistoryList) + { + filterRangeComboBox.Items.Add(item); + } + } + + private void StatusLineText (string text) + { + _statusEventArgs.StatusText = text; + SendStatusLineUpdate(); + } + + private void StatusLineError (string text) + { + StatusLineText(text); + _isErrorShowing = true; + } + + private void RemoveStatusLineError () + { + StatusLineText(""); + _isErrorShowing = false; + } + + private void SendGuiStateUpdate () + { + OnGuiState(_guiStateArgs); + } + + private void SendProgressBarUpdate () + { + OnProgressBarUpdate(_progressEventArgs); + } + + private void SendStatusLineUpdate () + { + OnStatusLine(_statusEventArgs); + } + + [SupportedOSPlatform("windows")] + private void ShowAdvancedFilterPanel (bool show) + { + if (show) + { + advancedButton.Text = "Hide advanced..."; + advancedButton.Image = null; + } + else + { + advancedButton.Text = "Show advanced..."; + CheckForAdvancedButtonDirty(); + } + + advancedFilterSplitContainer.Panel1Collapsed = !show; + advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; + _showAdvanced = show; + } + + [SupportedOSPlatform("windows")] + private void CheckForAdvancedButtonDirty () + { + advancedButton.Image = IsAdvancedOptionActive() && !_showAdvanced + ? _advancedButtonImage + : null; + } + + [SupportedOSPlatform("windows")] + private void FilterToTab () + { + filterSearchButton.Enabled = false; + Task.Run(() => WriteFilterToTab()); + } + + [SupportedOSPlatform("windows")] + private void WriteFilterToTab () + { + FilterPipe pipe = new(_filterParams.Clone(), this); + lock (_filterResultList) + { + var namePrefix = "->F"; + var title = IsTempFile + ? TempTitleName + namePrefix + ++_filterPipeNameCounter + : Util.GetNameFromPath(FileName) + namePrefix + ++_filterPipeNameCounter; + + WritePipeToTab(pipe, _filterResultList, title, null); + } + } + + [SupportedOSPlatform("windows")] + private void WritePipeToTab (FilterPipe pipe, IList lineNumberList, string name, PersistenceData persistenceData) + { + _logger.Info(CultureInfo.InvariantCulture, "WritePipeToTab(): {0} lines.", lineNumberList.Count); + StatusLineText("Writing to temp file... Press ESC to cancel."); + _guiStateArgs.MenuEnabled = false; + SendGuiStateUpdate(); + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = lineNumberList.Count; + _progressEventArgs.Value = 0; + _progressEventArgs.Visible = true; + Invoke(new MethodInvoker(SendProgressBarUpdate)); + _isSearching = true; + _shouldCancel = false; + + lock (_filterPipeList) + { + _filterPipeList.Add(pipe); + } + + pipe.Closed += OnPipeDisconnected; + var count = 0; + pipe.OpenFile(); + LogExpertCallback callback = new(this); + foreach (var i in lineNumberList) + { + if (_shouldCancel) + { + break; + } + + var line = _logFileReader.GetLogLine(i); + if (CurrentColumnizer is ILogLineXmlColumnizer) + { + callback.LineNum = i; + line = (CurrentColumnizer as ILogLineXmlColumnizer).GetLineTextForClipboard(line, callback); + } + + pipe.WriteToPipe(line, i); + if (++count % PROGRESS_BAR_MODULO == 0) + { + _progressEventArgs.Value = count; + Invoke(new MethodInvoker(SendProgressBarUpdate)); + } + } + + pipe.CloseFile(); + _logger.Info(CultureInfo.InvariantCulture, "WritePipeToTab(): finished"); + Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), pipe, name, persistenceData); + } + + [SupportedOSPlatform("windows")] + private void WriteFilterToTabFinished (FilterPipe pipe, string name, PersistenceData persistenceData) + { + _isSearching = false; + if (!_shouldCancel) + { + var title = name; + ILogLineColumnizer preProcessColumnizer = null; + if (CurrentColumnizer is not ILogLineXmlColumnizer) + { + preProcessColumnizer = CurrentColumnizer; + } + + var newWin = _parentLogTabWin.AddFilterTab(pipe, title, preProcessColumnizer); + newWin.FilterPipe = pipe; + pipe.OwnLogWindow = newWin; + if (persistenceData != null) + { + Task.Run(() => FilterRestore(newWin, persistenceData)); + } + } + + _progressEventArgs.Value = _progressEventArgs.MaxValue; + _progressEventArgs.Visible = false; + SendProgressBarUpdate(); + _guiStateArgs.MenuEnabled = true; + SendGuiStateUpdate(); + StatusLineText(""); + filterSearchButton.Enabled = true; + } + + /// + /// Used to create a new tab and pipe the given content into it. + /// + /// + /// + [SupportedOSPlatform("windows")] + internal void WritePipeTab (IList lineEntryList, string title) + { + FilterPipe pipe = new(new FilterParams(), this) + { + IsStopped = true + }; + pipe.Closed += OnPipeDisconnected; + pipe.OpenFile(); + foreach (var entry in lineEntryList) + { + pipe.WriteToPipe(entry.LogLine, entry.LineNum); + } + + pipe.CloseFile(); + Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), [pipe, title, null]); + } + + [SupportedOSPlatform("windows")] + private void FilterRestore (LogWindow newWin, PersistenceData persistenceData) + { + newWin.WaitForLoadingFinished(); + var columnizer = ColumnizerPicker.FindColumnizerByName(persistenceData.ColumnizerName, + PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + if (columnizer != null) + { + SetColumnizerFx fx = newWin.ForceColumnizer; + newWin.Invoke(fx, [columnizer]); + } + else + { + _logger.Warn($"FilterRestore(): Columnizer {persistenceData.ColumnizerName} not found"); + } + + newWin.BeginInvoke(new RestoreFiltersFx(newWin.RestoreFilters), [persistenceData]); + } + + [SupportedOSPlatform("windows")] + private void ProcessFilterPipes (int lineNum) + { + var searchLine = _logFileReader.GetLogLine(lineNum); + if (searchLine == null) + { + return; + } + + ColumnizerCallback callback = new(this) + { + LineNum = lineNum + }; + IList deleteList = []; + lock (_filterPipeList) + { + foreach (var pipe in _filterPipeList) + { + if (pipe.IsStopped) + { + continue; + } + + //long startTime = Environment.TickCount; + if (Util.TestFilterCondition(pipe.FilterParams, searchLine, callback)) + { + var filterResult = + GetAdditionalFilterResults(pipe.FilterParams, lineNum, pipe.LastLinesHistoryList); + pipe.OpenFile(); + foreach (var line in filterResult) + { + pipe.LastLinesHistoryList.Add(line); + if (pipe.LastLinesHistoryList.Count > SPREAD_MAX * 2) + { + pipe.LastLinesHistoryList.RemoveAt(0); + } + + var textLine = _logFileReader.GetLogLine(line); + var fileOk = pipe.WriteToPipe(textLine, line); + if (!fileOk) + { + deleteList.Add(pipe); + } + } + + pipe.CloseFile(); + } + + //long endTime = Environment.TickCount; + //_logger.logDebug("ProcessFilterPipes(" + lineNum + ") duration: " + ((endTime - startTime))); + } + } + + foreach (var pipe in deleteList) + { + _filterPipeList.Remove(pipe); + } + } + + [SupportedOSPlatform("windows")] + private void CopyMarkedLinesToClipboard () + { + if (_guiStateArgs.CellSelectMode) + { + var data = dataGridView.GetClipboardContent(); + Clipboard.SetDataObject(data); + } + else + { + List lineNumList = []; + foreach (DataGridViewRow row in dataGridView.SelectedRows) + { + if (row.Index != -1) + { + lineNumList.Add(row.Index); + } + } + + lineNumList.Sort(); + StringBuilder clipText = new(); + LogExpertCallback callback = new(this); + + var xmlColumnizer = _currentColumnizer as ILogLineXmlColumnizer; + + foreach (var lineNum in lineNumList) + { + var line = _logFileReader.GetLogLine(lineNum); + if (xmlColumnizer != null) + { + callback.LineNum = lineNum; + line = xmlColumnizer.GetLineTextForClipboard(line, callback); + } + + clipText.AppendLine(line.ToClipBoardText()); + } + + Clipboard.SetText(clipText.ToString()); + } + } + + /// + /// Set an Encoding which shall be used when loading a file. Used before a file is loaded. + /// + /// + private void SetExplicitEncoding (Encoding encoding) + { + EncodingOptions.Encoding = encoding; + } + + [SupportedOSPlatform("windows")] + private void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, bool setLastColumnWidth, int lastColumnWidth) + { + if (dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) > 1) + { + if (setLastColumnWidth) + { + dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].MinimumWidth = lastColumnWidth; + } + else + { + // Workaround for a .NET bug which brings the DataGridView into an unstable state (causing lots of NullReferenceExceptions). + dataGridView.FirstDisplayedScrollingColumnIndex = 0; + + dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].MinimumWidth = 5; // default + } + } + + if (dataGridView.RowCount > 0) + { + dataGridView.UpdateRowHeightInfo(0, true); + } + + dataGridView.Invalidate(); + dataGridView.Refresh(); + AutoResizeColumns(dataGridView); + } + + [SupportedOSPlatform("windows")] + private IList GetSelectedContent () + { + if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) + { + List lineNumList = []; + + foreach (DataGridViewRow row in dataGridView.SelectedRows) + { + if (row.Index != -1) + { + lineNumList.Add(row.Index); + } + } + + lineNumList.Sort(); + return lineNumList; + } + + return []; + } + + /* ======================================================================== + * Timestamp stuff + * =======================================================================*/ + + [SupportedOSPlatform("windows")] + private void SetTimestampLimits () + { + if (!CurrentColumnizer.IsTimeshiftImplemented()) + { + return; + } + + var line = 0; + _guiStateArgs.MinTimestamp = GetTimestampForLineForward(ref line, true); + line = dataGridView.RowCount - 1; + _guiStateArgs.MaxTimestamp = GetTimestampForLine(ref line, true); + SendGuiStateUpdate(); + } + + private void AdjustHighlightSplitterWidth () + { + //int size = this.editHighlightsSplitContainer.Panel2Collapsed ? 600 : 660; + //int distance = this.highlightSplitContainer.Width - size; + //if (distance < 10) + // distance = 10; + //this.highlightSplitContainer.SplitterDistance = distance; + } + + [SupportedOSPlatform("windows")] + private void BookmarkComment (Bookmark bookmark) + { + BookmarkCommentDlg dlg = new() + { + Comment = bookmark.Text + }; + if (dlg.ShowDialog() == DialogResult.OK) + { + bookmark.Text = dlg.Comment; + dataGridView.Refresh(); + OnBookmarkTextChanged(bookmark); + } + } + + /// + /// Indicates which columns we are filtering on + /// + /// + /// + [SupportedOSPlatform("windows")] + private string CalculateColumnNames (FilterParams filter) + { + var names = string.Empty; + + if (filter.ColumnRestrict) + { + foreach (var colIndex in filter.ColumnList) + { + if (colIndex < dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 2) + { + if (names.Length > 0) + { + names += ", "; + } + + names += dataGridView.Columns[2 + colIndex] + .HeaderText; // skip first two columns: marker + line number + } + } + } + + return names; + } + + [SupportedOSPlatform("windows")] + private void ApplyFrozenState (BufferedDataGridView gridView) + { + SortedDictionary dict = []; + foreach (DataGridViewColumn col in gridView.Columns) + { + dict.Add(col.DisplayIndex, col); + } + + foreach (var col in dict.Values) + { + col.Frozen = _freezeStateMap.ContainsKey(gridView) && _freezeStateMap[gridView]; + var sel = col.HeaderCell.Selected; + if (col.Index == _selectedCol) + { + break; + } + } + } + + [SupportedOSPlatform("windows")] + private void ShowTimeSpread (bool show) + { + if (show) + { + tableLayoutPanel1.ColumnStyles[1].Width = 16; + } + else + { + tableLayoutPanel1.ColumnStyles[1].Width = 0; + } + + _timeSpreadCalc.Enabled = show; + } + + [SupportedOSPlatform("windows")] + protected internal void AddTempFileTab (string fileName, string title) + { + _parentLogTabWin.AddTempFileTab(fileName, title); + } + + private void InitPatternWindow () + { + //PatternStatistic(this.patternArgs); + _patternWindow = new PatternWindow(this); + _patternWindow.SetColumnizer(CurrentColumnizer); + //this.patternWindow.SetBlockList(blockList); + _patternWindow.SetFont(Preferences.FontName, Preferences.FontSize); + _patternWindow.Fuzzy = _patternArgs.Fuzzy; + _patternWindow.MaxDiff = _patternArgs.MaxDiffInBlock; + _patternWindow.MaxMisses = _patternArgs.MaxMisses; + _patternWindow.Weight = _patternArgs.MinWeight; + //this.patternWindow.Show(); + } + + [SupportedOSPlatform("windows")] + private void TestStatistic (PatternArgs patternArgs) + { + var beginLine = patternArgs.StartLine; + _logger.Info($"TestStatistics() called with start line {beginLine}"); + + _patternArgs = patternArgs; + + var num = beginLine + 1; //this.dataGridView.RowCount; + + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = dataGridView.RowCount; + _progressEventArgs.Value = beginLine; + _progressEventArgs.Visible = true; + SendProgressBarUpdate(); + + PrepareDict(); + ResetCache(num); + + Dictionary processedLinesDict = []; + List blockList = []; + var blockId = 0; + _isSearching = true; + _shouldCancel = false; + var searchLine = -1; + for (var i = beginLine; i < num && !_shouldCancel; ++i) + { + if (processedLinesDict.ContainsKey(i)) + { + continue; + } + + PatternBlock block; + var maxBlockLen = patternArgs.EndLine - patternArgs.StartLine; + //int searchLine = i + 1; + _logger.Debug(CultureInfo.InvariantCulture, "TestStatistic(): i={0} searchLine={1}", i, searchLine); + //bool firstBlock = true; + searchLine++; + UpdateProgressBar(searchLine); + while (!_shouldCancel && + (block = + DetectBlock(i, searchLine, maxBlockLen, _patternArgs.MaxDiffInBlock, + _patternArgs.MaxMisses, + processedLinesDict)) != null) + { + _logger.Debug(CultureInfo.InvariantCulture, "Found block: {0}", block); + if (block.Weigth >= _patternArgs.MinWeight) + { + //PatternBlock existingBlock = FindExistingBlock(block, blockList); + //if (existingBlock != null) + //{ + // if (block.weigth > existingBlock.weigth) + // { + // blockList.Remove(existingBlock); + // blockList.Add(block); + // } + //} + //else + { + blockList.Add(block); + AddBlockTargetLinesToDict(processedLinesDict, block); + } + block.BlockId = blockId; + //if (firstBlock) + //{ + // addBlockSrcLinesToDict(processedLinesDict, block); + //} + searchLine = block.TargetEnd + 1; + } + else + { + searchLine = block.TargetStart + 1; + } + + UpdateProgressBar(searchLine); + } + + blockId++; + } + + _isSearching = false; + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = 0; + _progressEventArgs.Value = 0; + _progressEventArgs.Visible = false; + SendProgressBarUpdate(); + //if (this.patternWindow.IsDisposed) + //{ + // this.Invoke(new MethodInvoker(CreatePatternWindow)); + //} + _patternWindow.SetBlockList(blockList, _patternArgs); + _logger.Info(CultureInfo.InvariantCulture, "TestStatistics() ended"); + } + + private void AddBlockTargetLinesToDict (Dictionary dict, PatternBlock block) + { + foreach (var lineNum in block.TargetLines.Keys) + { + _ = dict.TryAdd(lineNum, lineNum); + } + } + + //Well keep this for the moment because there is some other commented code which calls this one + private PatternBlock FindExistingBlock (PatternBlock block, List blockList) + { + foreach (var searchBlock in blockList) + { + if (((block.StartLine > searchBlock.StartLine && block.StartLine < searchBlock.EndLine) || + (block.EndLine > searchBlock.StartLine && block.EndLine < searchBlock.EndLine)) && + block.StartLine != searchBlock.StartLine && + block.EndLine != searchBlock.EndLine + ) + { + return searchBlock; + } + } + + return null; + } + + private PatternBlock DetectBlock (int startNum, int startLineToSearch, int maxBlockLen, int maxDiffInBlock, int maxMisses, Dictionary processedLinesDict) + { + var targetLine = FindSimilarLine(startNum, startLineToSearch, processedLinesDict); + if (targetLine == -1) + { + return null; + } + + PatternBlock block = new() + { + StartLine = startNum + }; + var srcLine = block.StartLine; + block.TargetStart = targetLine; + var srcMisses = 0; + block.SrcLines.Add(srcLine, srcLine); + //block.targetLines.Add(targetLine, targetLine); + var len = 0; + QualityInfo qi = new() + { + Quality = block.Weigth + }; + block.QualityInfoList[targetLine] = qi; + + while (!_shouldCancel) + { + srcLine++; + len++; + //if (srcLine >= block.targetStart) + // break; // prevent to search in the own block + if (maxBlockLen > 0 && len > maxBlockLen) + { + break; + } + + var nextTargetLine = FindSimilarLine(srcLine, targetLine + 1, processedLinesDict); + if (nextTargetLine > -1 && nextTargetLine - targetLine - 1 <= maxDiffInBlock) + { + block.Weigth += maxDiffInBlock - (nextTargetLine - targetLine - 1) + 1; + block.EndLine = srcLine; + //block.targetLines.Add(nextTargetLine, nextTargetLine); + block.SrcLines.Add(srcLine, srcLine); + if (nextTargetLine - targetLine > 1) + { + var tempWeight = block.Weigth; + for (var tl = targetLine + 1; tl < nextTargetLine; ++tl) + { + qi = new QualityInfo + { + Quality = --tempWeight + }; + block.QualityInfoList[tl] = qi; + } + } + + targetLine = nextTargetLine; + qi = new QualityInfo + { + Quality = block.Weigth + }; + block.QualityInfoList[targetLine] = qi; + } + else + { + srcMisses++; + block.Weigth--; + targetLine++; + qi = new QualityInfo + { + Quality = block.Weigth + }; + block.QualityInfoList[targetLine] = qi; + if (srcMisses > maxMisses) + { + break; + } + } + } + + block.TargetEnd = targetLine; + qi = new QualityInfo + { + Quality = block.Weigth + }; + + block.QualityInfoList[targetLine] = qi; + + for (var k = block.TargetStart; k <= block.TargetEnd; ++k) + { + block.TargetLines.Add(k, k); + } + + return block; + } + + private void PrepareDict () + { + _lineHashList.Clear(); + Regex regex = new("\\d"); + Regex regex2 = new("\\S"); + + var num = _logFileReader.LineCount; + for (var i = 0; i < num; ++i) + { + var msg = GetMsgForLine(i); + if (msg != null) + { + msg = msg.ToLowerInvariant(); + msg = regex.Replace(msg, "0"); + msg = regex2.Replace(msg, " "); + var chars = msg.ToCharArray(); + var value = 0; + var numOfE = 0; + var numOfA = 0; + var numOfI = 0; + foreach (var t in chars) + { + value += t; + switch (t) + { + case 'e': + numOfE++; + break; + case 'a': + numOfA++; + break; + case 'i': + numOfI++; + break; + } + } + + value += numOfE * 30; + value += numOfA * 20; + value += numOfI * 10; + _lineHashList.Add(value); + } + } + } + + private int FindSimilarLine (int srcLine, int startLine) + { + var value = _lineHashList[srcLine]; + + var num = _lineHashList.Count; + for (var i = startLine; i < num; ++i) + { + if (Math.Abs(_lineHashList[i] - value) < 3) + { + return i; + } + } + + return -1; + } + + // int[,] similarCache; + + private void ResetCache (int num) + { + //this.similarCache = new int[num, num]; + //for (int i = 0; i < num; ++i) + //{ + // for (int j = 0; j < num; j++) + // { + // this.similarCache[i, j] = -1; + // } + //} + } + + private int FindSimilarLine (int srcLine, int startLine, Dictionary processedLinesDict) + { + var threshold = _patternArgs.Fuzzy; + + var prepared = false; + Regex regex = null; + Regex regex2 = null; + string msgToFind = null; + var culture = CultureInfo.CurrentCulture; + + var num = _logFileReader.LineCount; + for (var i = startLine; i < num; ++i) + { + if (processedLinesDict.ContainsKey(i)) + { + continue; + } + + //if (this.similarCache[srcLine, i] != -1) + //{ + // if (this.similarCache[srcLine, i] < threshold) + // { + // return i; + // } + //} + //else + { + if (!prepared) + { + msgToFind = GetMsgForLine(srcLine); + regex = new Regex("\\d"); + regex2 = new Regex("\\W"); + msgToFind = msgToFind.ToLower(culture); + msgToFind = regex.Replace(msgToFind, "0"); + msgToFind = regex2.Replace(msgToFind, " "); + prepared = true; + } + + var msg = GetMsgForLine(i); + if (msg != null) + { + msg = regex.Replace(msg, "0"); + msg = regex2.Replace(msg, " "); + var lenDiff = Math.Abs(msg.Length - msgToFind.Length); + if (lenDiff > threshold) + { + //this.similarCache[srcLine, i] = lenDiff; + continue; + } + + msg = msg.ToLower(culture); + var distance = Util.YetiLevenshtein(msgToFind, msg); + //this.similarCache[srcLine, i] = distance; + if (distance < threshold) + { + return i; + } + } + } + } + + return -1; + } + + private string GetMsgForLine (int i) + { + var line = _logFileReader.GetLogLine(i); + var columnizer = CurrentColumnizer; + ColumnizerCallback callback = new(this); + var cols = columnizer.SplitLine(callback, line); + return cols.ColumnValues.Last().FullValue; + } + + [SupportedOSPlatform("windows")] + private void ChangeRowHeight (bool decrease) + { + var rowNum = dataGridView.CurrentCellAddress.Y; + if (rowNum < 0 || rowNum >= dataGridView.RowCount) + { + return; + } + + if (decrease) + { + if (!_rowHeightList.TryGetValue(rowNum, out var entry)) + { + return; + } + else + { + entry.Height -= _lineHeight; + if (entry.Height <= _lineHeight) + { + _rowHeightList.Remove(rowNum); + } + } + } + else + { + RowHeightEntry entry; + if (!_rowHeightList.TryGetValue(rowNum, out var value)) + { + entry = new RowHeightEntry + { + LineNum = rowNum, + Height = _lineHeight + }; + + _rowHeightList[rowNum] = entry; + } + else + { + entry = value; + } + + entry.Height += _lineHeight; + } + + dataGridView.UpdateRowHeightInfo(rowNum, false); + if (rowNum == dataGridView.RowCount - 1 && _guiStateArgs.FollowTail) + { + dataGridView.FirstDisplayedScrollingRowIndex = rowNum; + } + + dataGridView.Refresh(); + } + + private int GetRowHeight (int rowNum) + { + return _rowHeightList.TryGetValue(rowNum, out var value) + ? value.Height + : _lineHeight; + } + + private void AddBookmarkAtLineSilently (int lineNum) + { + if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) + { + _bookmarkProvider.AddBookmark(new Bookmark(lineNum)); + } + } + + [SupportedOSPlatform("windows")] + private void AddBookmarkAndEditComment () + { + var lineNum = dataGridView.CurrentCellAddress.Y; + if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) + { + ToggleBookmark(); + } + + BookmarkComment(_bookmarkProvider.GetBookmarkForLine(lineNum)); + } + + [SupportedOSPlatform("windows")] + private void AddBookmarkComment (string text) + { + var lineNum = dataGridView.CurrentCellAddress.Y; + Bookmark bookmark; + if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) + { + _bookmarkProvider.AddBookmark(bookmark = new Bookmark(lineNum)); + } + else + { + bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); + } + + bookmark.Text += text; + dataGridView.Refresh(); + filterGridView.Refresh(); + OnBookmarkTextChanged(bookmark); + } + + [SupportedOSPlatform("windows")] + private void MarkCurrentFilterRange () + { + _filterParams.RangeSearchText = filterRangeComboBox.Text; + ColumnizerCallback callback = new(this); + RangeFinder rangeFinder = new(_filterParams, callback); + var range = rangeFinder.FindRange(dataGridView.CurrentCellAddress.Y); + if (range != null) + { + SetCellSelectionMode(false); + _noSelectionUpdates = true; + for (var i = range.StartLine; i <= range.EndLine; ++i) + { + dataGridView.Rows[i].Selected = true; + } + + _noSelectionUpdates = false; + UpdateSelectionDisplay(); + } + } + + [SupportedOSPlatform("windows")] + private void RemoveTempHighlights () + { + lock (_tempHighlightEntryListLock) + { + _tempHighlightEntryList.Clear(); + } + + RefreshAllGrids(); + } + + [SupportedOSPlatform("windows")] + private void ToggleHighlightPanel (bool open) + { + highlightSplitContainer.Panel2Collapsed = !open; + btnToggleHighlightPanel.Image = open + ? new Bitmap(_panelCloseButtonImage, new Size(btnToggleHighlightPanel.Size.Height, btnToggleHighlightPanel.Size.Height)) + : new Bitmap(_panelOpenButtonImage, new Size(btnToggleHighlightPanel.Size.Height, btnToggleHighlightPanel.Size.Height)); + } + + [SupportedOSPlatform("windows")] + private void SetBookmarksForSelectedFilterLines () + { + lock (_filterResultList) + { + foreach (DataGridViewRow row in filterGridView.SelectedRows) + { + var lineNum = _filterResultList[row.Index]; + AddBookmarkAtLineSilently(lineNum); + } + } + + dataGridView.Refresh(); + filterGridView.Refresh(); + OnBookmarkAdded(); + } + + private void SetDefaultHighlightGroup () + { + var group = _parentLogTabWin.FindHighlightGroupByFileMask(FileName); + if (group != null) + { + SetCurrentHighlightGroup(group.GroupName); + } + else + { + SetCurrentHighlightGroup("[Default]"); + } + } + + [SupportedOSPlatform("windows")] + private void HandleChangedFilterOnLoadSetting () + { + _parentLogTabWin.Preferences.IsFilterOnLoad = filterOnLoadCheckBox.Checked; + _parentLogTabWin.Preferences.IsAutoHideFilterList = hideFilterListOnLoadCheckBox.Checked; + OnFilterListChanged(this); + } + + private void FireCancelHandlers () + { + lock (_cancelHandlerList) + { + foreach (var handler in _cancelHandlerList) + { + handler.EscapePressed(); + } + } + } + + private void SyncOtherWindows (DateTime timestamp) + { + lock (_timeSyncListLock) + { + TimeSyncList?.NavigateToTimestamp(timestamp, this); + } + } + + [SupportedOSPlatform("windows")] + private void AddSlaveToTimesync (LogWindow slave) + { + lock (_timeSyncListLock) + { + if (TimeSyncList == null) + { + if (slave.TimeSyncList == null) + { + TimeSyncList = new TimeSyncList(); + TimeSyncList.AddWindow(this); + } + else + { + TimeSyncList = slave.TimeSyncList; + } + + var currentLineNum = dataGridView.CurrentCellAddress.Y; + var refLine = currentLineNum; + var timeStamp = GetTimestampForLine(ref refLine, true); + if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel) + { + TimeSyncList.CurrentTimestamp = timeStamp; + } + + TimeSyncList.WindowRemoved += OnTimeSyncListWindowRemoved; + } + } + + slave.AddToTimeSync(this); + OnSyncModeChanged(); + } + + private void FreeSlaveFromTimesync (LogWindow slave) + { + slave.FreeFromTimeSync(); + } + + private void OnSyncModeChanged () + { + SyncModeChanged?.Invoke(this, new SyncModeEventArgs(IsTimeSynced)); + } + + [SupportedOSPlatform("windows")] + private void AddSearchHitHighlightEntry (SearchParams para) + { + HighlightEntry he = new() + { + SearchText = para.SearchText, + ForegroundColor = Color.Red, + BackgroundColor = Color.Yellow, + IsRegEx = para.IsRegex, + IsCaseSensitive = para.IsCaseSensitive, + IsLedSwitch = false, + IsStopTail = false, + IsSetBookmark = false, + IsActionEntry = false, + ActionEntry = null, + IsWordMatch = true, + IsSearchHit = true + }; + + lock (_tempHighlightEntryListLock) + { + _tempHighlightEntryList.Add(he); + } + + RefreshAllGrids(); + } + + [SupportedOSPlatform("windows")] + private void RemoveAllSearchHighlightEntries () + { + lock (_tempHighlightEntryListLock) + { + List newList = []; + foreach (var he in _tempHighlightEntryList) + { + if (!he.IsSearchHit) + { + newList.Add(he); + } + } + + _tempHighlightEntryList = newList; + } + + RefreshAllGrids(); + } + + [SupportedOSPlatform("windows")] + private DataGridViewColumn GetColumnByName (BufferedDataGridView dataGridView, string name) + { + foreach (DataGridViewColumn col in dataGridView.Columns) + { + if (col.HeaderText.Equals(name, StringComparison.Ordinal)) + { + return col; + } + } + + return null; + } + + [SupportedOSPlatform("windows")] + private void SelectColumn () + { + var colName = columnComboBox.SelectedItem as string; + var col = GetColumnByName(dataGridView, colName); + if (col != null && !col.Frozen) + { + dataGridView.FirstDisplayedScrollingColumnIndex = col.Index; + var currentLine = dataGridView.CurrentCellAddress.Y; + if (currentLine >= 0) + { + dataGridView.CurrentCell = dataGridView.Rows[dataGridView.CurrentCellAddress.Y].Cells[col.Index]; + } + } + } + + #endregion + + #region Public methods + + public void LoadFile (string fileName, EncodingOptions encodingOptions) + { + EnterLoadFileStatus(); + + if (fileName != null) + { + FileName = fileName; + EncodingOptions = encodingOptions; + + if (_logFileReader != null) + { + _logFileReader.StopMonitoringAsync(); + UnRegisterLogFileReaderEvents(); + } + + // + // isUsingDefaultColumnizer is to enable automatically find the best columnizer. + // When a new log file is opened, and no Columnizer can be chose by file mask, + // this flag will enable find a columnizer automatically. + // Current solution is not elegant. + // Since the refactory will involving a lot of work, we can plan it in the future. + // One possible solution is, using raw file stream to read the sample lines to help + // the ColumnizerPicker to determine the priority. + // + var isUsingDefaultColumnizer = false; + if (!LoadPersistenceOptions()) + { + if (!IsTempFile) + { + var columnizer = FindColumnizer(); + if (columnizer != null) + { + if (_reloadMemento == null) + { + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + + columnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); + } + } + else + { + isUsingDefaultColumnizer = true; + } + + PreSelectColumnizer(columnizer); + } + + SetDefaultHighlightGroup(); + } + + // this may be set after loading persistence data + if (_fileNames != null && IsMultiFile) + { + LoadFilesAsMulti(_fileNames, EncodingOptions); + return; + } + + _columnCache = new ColumnCache(); + + try + { + _logFileReader = new(fileName, EncodingOptions, IsMultiFile, Preferences.BufferCount, Preferences.LinesPerBuffer, _multiFileOptions, PluginRegistry.PluginRegistry.Instance) + { + UseNewReader = !Preferences.UseLegacyReader + }; + } + catch (LogFileException lfe) + { + _logger.Error(lfe); + MessageBox.Show($"Cannot load file\n{lfe.Message}", "LogExpert"); + _ = BeginInvoke(new FunctionWith1BoolParam(Close), true); + _isLoadError = true; + return; + } + + if (CurrentColumnizer is ILogLineXmlColumnizer xmlColumnizer) + { + _logFileReader.IsXmlMode = true; + _logFileReader.XmlLogConfig = xmlColumnizer.GetXmlLogConfiguration(); + } + + if (_forcedColumnizerForLoading != null) + { + CurrentColumnizer = _forcedColumnizerForLoading; + } + + _logFileReader.PreProcessColumnizer = CurrentColumnizer is IPreProcessColumnizer processColumnizer ? processColumnizer : null; + + RegisterLogFileReaderEvents(); + _logger.Info($"Loading logfile: {fileName}"); + _logFileReader.StartMonitoring(); + + if (isUsingDefaultColumnizer) + { + if (Preferences.AutoPick) + { + var newColumnizer = ColumnizerPicker.FindBetterColumnizer(FileName, _logFileReader, CurrentColumnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + + if (newColumnizer != null) + { + _logger.Debug($"Picked new columnizer '{newColumnizer}'"); + + PreSelectColumnizer(newColumnizer); + } + } + } + } + } + + public void LoadFilesAsMulti (string[] fileNames, EncodingOptions encodingOptions) + { + _logger.Info("Loading given files as MultiFile:"); + + EnterLoadFileStatus(); + + foreach (var name in fileNames) + { + _logger.Info($"File: {name}"); + } + + if (_logFileReader != null) + { + _logFileReader.StopMonitoring(); + UnRegisterLogFileReaderEvents(); + } + + EncodingOptions = encodingOptions; + _columnCache = new ColumnCache(); + + _logFileReader = new(fileNames, EncodingOptions, Preferences.BufferCount, Preferences.LinesPerBuffer, _multiFileOptions, PluginRegistry.PluginRegistry.Instance) + { + UseNewReader = !Preferences.UseLegacyReader + }; + + RegisterLogFileReaderEvents(); + _logFileReader.StartMonitoring(); + FileName = fileNames[^1]; + _fileNames = fileNames; + IsMultiFile = true; + //if (this.isTempFile) + // this.Text = this.tempTitleName; + //else + // this.Text = Util.GetNameFromPath(this.FileName); + } + + public string SavePersistenceData (bool force) + { + if (!force) + { + if (!Preferences.SaveSessions) + { + return null; + } + } + + if (IsTempFile || _isLoadError) + { + return null; + } + + try + { + var persistenceData = GetPersistenceData(); + + return ForcedPersistenceFileName == null + ? Persister.SavePersistenceData(FileName, persistenceData, Preferences) + : Persister.SavePersistenceDataWithFixedName(ForcedPersistenceFileName, persistenceData); + } + catch (IOException ex) + { + _logger.Error(ex, "Error saving persistence: "); + } + catch (Exception e) + { + MessageBox.Show($"Unexpected error while saving persistence: {e.Message}"); + } + + return null; + } + + public PersistenceData GetPersistenceData () + { + PersistenceData persistenceData = new() + { + BookmarkList = _bookmarkProvider.BookmarkList, + RowHeightList = _rowHeightList, + MultiFile = IsMultiFile, + MultiFilePattern = _multiFileOptions.FormatPattern, + MultiFileMaxDays = _multiFileOptions.MaxDayTry, + CurrentLine = dataGridView.CurrentCellAddress.Y, + FirstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex, + FilterVisible = !splitContainerLogWindow.Panel2Collapsed, + FilterAdvanced = !advancedFilterSplitContainer.Panel1Collapsed, + FilterPosition = splitContainerLogWindow.SplitterDistance, + FollowTail = _guiStateArgs.FollowTail, + FileName = FileName, + TabName = Text, + SessionFileName = SessionFileName, + ColumnizerName = CurrentColumnizer.GetName(), + LineCount = _logFileReader.LineCount + }; + + _filterParams.IsFilterTail = filterTailCheckBox.Checked; // this option doesnt need a press on 'search' + + if (Preferences.SaveFilters) + { + List filterList = [_filterParams]; + persistenceData.FilterParamsList = filterList; + + foreach (var filterPipe in _filterPipeList) + { + FilterTabData data = new() + { + PersistenceData = filterPipe.OwnLogWindow.GetPersistenceData(), + FilterParams = filterPipe.FilterParams + }; + persistenceData.FilterTabDataList.Add(data); + } + } + + if (_currentHighlightGroup != null) + { + persistenceData.HighlightGroupName = _currentHighlightGroup.GroupName; + } + + if (_fileNames != null && IsMultiFile) + { + persistenceData.MultiFileNames.AddRange(_fileNames); + } + + //persistenceData.showBookmarkCommentColumn = this.bookmarkWindow.ShowBookmarkCommentColumn; + persistenceData.FilterSaveListVisible = !highlightSplitContainer.Panel2Collapsed; + persistenceData.Encoding = _logFileReader.CurrentEncoding; + + return persistenceData; + } + + public void Close (bool dontAsk) + { + Preferences.AskForClose = !dontAsk; + Close(); + } + + public void CloseLogWindow () + { + StopTimespreadThread(); + StopTimestampSyncThread(); + StopLogEventWorkerThread(); + _shouldCancel = true; + + if (_logFileReader != null) + { + UnRegisterLogFileReaderEvents(); + _logFileReader.StopMonitoringAsync(); + //this.logFileReader.DeleteAllContent(); + } + + if (_isLoading) + { + _waitingForClose = true; + } + + if (IsTempFile) + { + _logger.Info($"Deleting temp file {FileName}"); + + try + { + File.Delete(FileName); + } + catch (IOException e) + { + _logger.Error(e, $"Error while deleting temp file {FileName}: {e}"); + } + } + + FilterPipe?.CloseAndDisconnect(); + DisconnectFilterPipes(); + } + + public void WaitForLoadingFinished () + { + _externaLoadingFinishedEvent.WaitOne(); + } + + public void ForceColumnizer (ILogLineColumnizer columnizer) + { + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + + _forcedColumnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); + SetColumnizer(_forcedColumnizer); + } + + public void ForceColumnizerForLoading (ILogLineColumnizer columnizer) + { + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + + _forcedColumnizerForLoading = ColumnizerPicker.CloneColumnizer(columnizer, directory); + } + + public void PreselectColumnizer (string columnizerName) + { + //TODO this needs to be refactored + var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; + + var columnizer = ColumnizerPicker.FindColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + PreSelectColumnizer(ColumnizerPicker.CloneColumnizer(columnizer, directory)); + } + + public void ColumnizerConfigChanged () + { + SetColumnizerInternal(CurrentColumnizer); + } + + public void SetColumnizer (ILogLineColumnizer columnizer, BufferedDataGridView gridView) + { + PaintHelper.SetColumnizer(columnizer, gridView); + + gridView.Refresh(); + AutoResizeColumns(gridView); + ApplyFrozenState(gridView); + } + + public IColumn GetCellValue (int rowIndex, int columnIndex) + { + if (columnIndex == 1) + { + return new Column + { + FullValue = $"{rowIndex + 1}" // line number + }; + } + + if (columnIndex == 0) // marker column + { + return Column.EmptyColumn; + } + + try + { + var cols = GetColumnsForLine(rowIndex); + if (cols != null && cols.ColumnValues != null) + { + if (columnIndex <= cols.ColumnValues.Length + 1) + { + var value = cols.ColumnValues[columnIndex - 2]; + + return value != null && value.DisplayValue != null + ? value + : value; + } + + return columnIndex == 2 + ? cols.ColumnValues[^1] + : Column.EmptyColumn; + } + } + catch + { + return Column.EmptyColumn; + } + + return Column.EmptyColumn; + } + + public void CellPainting (BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) + { + if (rowIndex < 0 || e.ColumnIndex < 0) + { + e.Handled = false; + return; + } + + var line = _logFileReader.GetLogLineWithWait(rowIndex).Result; + + if (line != null) + { + var entry = FindFirstNoWordMatchHilightEntry(line); + e.Graphics.SetClip(e.CellBounds); + + if (e.State.HasFlag(DataGridViewElementStates.Selected)) + { + using var brush = PaintHelper.GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); + e.Graphics.FillRectangle(brush, e.CellBounds); + } + else + { + e.CellStyle.BackColor = PaintHelper.GetBackColorFromHighlightEntry(entry); + e.PaintBackground(e.ClipBounds, false); + } + + if (DebugOptions.DisableWordHighlight) + { + e.PaintContent(e.CellBounds); + } + else + { + PaintCell(e, gridView, false, entry); + } + + if (e.ColumnIndex == 0) + { + if (_bookmarkProvider.IsBookmarkAtLine(rowIndex)) + { + Rectangle r; // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); + r = e.CellBounds; + r.Inflate(-2, -2); + using var brush = new SolidBrush(BookmarkColor); + e.Graphics.FillRectangle(brush, r); + + var bookmark = _bookmarkProvider.GetBookmarkForLine(rowIndex); + + if (bookmark.Text.Length > 0) + { + StringFormat format = new() + { + LineAlignment = StringAlignment.Center, + Alignment = StringAlignment.Center + }; + + using var brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); //dark orange + using var font = new Font("Courier New", Preferences.FontSize, FontStyle.Bold); + e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); + } + } + } + + e.Paint(e.CellBounds, DataGridViewPaintParts.Border); + e.Handled = true; + } + } + + public void OnDataGridViewCellPainting (object sender, DataGridViewCellPaintingEventArgs e) + { + var gridView = (BufferedDataGridView)sender; + CellPainting(gridView, e.RowIndex, e); + } + + /// + /// Returns the first HilightEntry that matches the given line + /// + /// + /// + /// + public HighlightEntry FindHighlightEntry (ITextValue line, bool noWordMatches) + { + // first check the temp entries + lock (_tempHighlightEntryListLock) + { + foreach (var entry in _tempHighlightEntryList) + { + if (noWordMatches && entry.IsWordMatch) + { + continue; + } + + if (CheckHighlightEntryMatch(entry, line)) + { + return entry; + } + } + } + + lock (_currentHighlightGroupLock) + { + foreach (var entry in _currentHighlightGroup.HighlightEntryList) + { + if (noWordMatches && entry.IsWordMatch) + { + continue; + } + if (CheckHighlightEntryMatch(entry, line)) + { + return entry; + } + } + return null; + } + } + + public IList FindHighlightMatches (ITextValue line) + { + IList resultList = []; + + if (line != null) + { + lock (_currentHighlightGroupLock) + { + GetHighlightEntryMatches(line, _currentHighlightGroup.HighlightEntryList, resultList); + } + + lock (_tempHighlightEntryList) + { + GetHighlightEntryMatches(line, _tempHighlightEntryList, resultList); + } + } + + return resultList; + } + + public void FollowTailChanged (bool isChecked, bool byTrigger) + { + _guiStateArgs.FollowTail = isChecked; + + if (_guiStateArgs.FollowTail && _logFileReader != null) + { + if (dataGridView.RowCount >= _logFileReader.LineCount && _logFileReader.LineCount > 0) + { + dataGridView.FirstDisplayedScrollingRowIndex = _logFileReader.LineCount - 1; + } + } + + BeginInvoke(new MethodInvoker(dataGridView.Refresh)); + //this.dataGridView.Refresh(); + _parentLogTabWin.FollowTailChanged(this, isChecked, byTrigger); + SendGuiStateUpdate(); + } + + public void TryToTruncate () + { + try + { + if (LockFinder.CheckIfFileIsLocked(Title)) + { + var name = LockFinder.FindLockedProcessName(Title); + StatusLineText($"Truncate failed: file is locked by {name}"); + } + else + { + File.WriteAllText(Title, ""); + } + } + catch (Exception ex) + { + _logger.Warn($"Unexpected issue truncating file: {ex.Message}"); + StatusLineText("Unexpected issue truncating file"); + throw; + } + } + + public void GotoLine (int line) + { + if (line >= 0) + { + if (line < dataGridView.RowCount) + { + SelectLine(line, false, true); + } + else + { + SelectLine(dataGridView.RowCount - 1, false, true); + } + dataGridView.Focus(); + } + } + + public void StartSearch () + { + _guiStateArgs.MenuEnabled = false; + GuiStateUpdate(this, _guiStateArgs); + var searchParams = _parentLogTabWin.SearchParams; + + searchParams.CurrentLine = (searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed + ? dataGridView.CurrentCellAddress.Y + 1 + : dataGridView.CurrentCellAddress.Y - 1; + + _currentSearchParams = searchParams; // remember for async "not found" messages + + _isSearching = true; + _shouldCancel = false; + StatusLineText("Searching... Press ESC to cancel."); + + _progressEventArgs.MinValue = 0; + _progressEventArgs.MaxValue = dataGridView.RowCount; + _progressEventArgs.Value = 0; + _progressEventArgs.Visible = true; + SendProgressBarUpdate(); + + Task.Run(() => Search(searchParams)).ContinueWith(SearchComplete); + + RemoveAllSearchHighlightEntries(); + AddSearchHitHighlightEntry(searchParams); + } + + private void SearchComplete (Task task) + { + if (Disposing) + { + return; + } + + try + { + Invoke(new MethodInvoker(ResetProgressBar)); + var line = task.Result; + _guiStateArgs.MenuEnabled = true; + GuiStateUpdate(this, _guiStateArgs); + if (line == -1) + { + return; + } + + dataGridView.Invoke(new SelectLineFx((line1, triggerSyncCall) => SelectLine(line1, triggerSyncCall, true)), line, true); + } + catch (Exception ex) // in the case the windows is already destroyed + { + _logger.Warn(ex); + } + } + + public void SelectLogLine (int line) + { + Invoke(new SelectLineFx((line1, triggerSyncCall) => SelectLine(line1, triggerSyncCall, true)), line, true); + } + + public void SelectAndEnsureVisible (int line, bool triggerSyncCall) + { + try + { + SelectLine(line, triggerSyncCall, false); + + //if (!this.dataGridView.CurrentRow.Displayed) + if (line < dataGridView.FirstDisplayedScrollingRowIndex || line > dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false)) + { + dataGridView.FirstDisplayedScrollingRowIndex = line; + for (var i = 0; i < 8 && dataGridView.FirstDisplayedScrollingRowIndex > 0 && line < dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false); ++i) + { + dataGridView.FirstDisplayedScrollingRowIndex -= 1; + } + + if (line >= dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false)) + { + dataGridView.FirstDisplayedScrollingRowIndex += 1; + } + } + + dataGridView.CurrentCell = dataGridView.Rows[line].Cells[0]; + } + catch (Exception e) + { + // In rare situations there seems to be an invalid argument exceptions (or something like this). Concrete location isn't visible in stack + // trace because use of Invoke(). So catch it, and log (better than crashing the app). + _logger.Error(e); + } + } + + public void OnLogWindowKeyDown (object sender, KeyEventArgs e) + { + if (_isErrorShowing) + { + RemoveStatusLineError(); + } + + switch (e.KeyCode) + { + case Keys.F3 when _parentLogTabWin.SearchParams?.SearchText == null || _parentLogTabWin.SearchParams.SearchText.Length == 0: + { + return; + } + case Keys.F3: + { + _parentLogTabWin.SearchParams.IsFindNext = true; + _parentLogTabWin.SearchParams.IsShiftF3Pressed = (e.Modifiers & Keys.Shift) == Keys.Shift; + StartSearch(); + break; + } + case Keys.Escape: + { + if (_isSearching) + { + _shouldCancel = true; + } + + FireCancelHandlers(); + RemoveAllSearchHighlightEntries(); + break; + } + case Keys.E when (e.Modifiers & Keys.Control) == Keys.Control: + { + StartEditMode(); + + break; + } + case Keys.Down when e.Modifiers == Keys.Alt: + { + var newLine = _logFileReader.GetNextMultiFileLine(dataGridView.CurrentCellAddress.Y); + + if (newLine != -1) + { + SelectLine(newLine, false, true); + } + + e.Handled = true; + + break; + } + case Keys.Up when e.Modifiers == Keys.Alt: + { + var newLine = _logFileReader.GetPrevMultiFileLine(dataGridView.CurrentCellAddress.Y); + + if (newLine != -1) + { + SelectLine(newLine - 1, false, true); + } + + e.Handled = true; + + break; + } + case Keys.Enter when dataGridView.Focused: + { + ChangeRowHeight(e.Shift); + e.Handled = true; + + break; + } + case Keys.Back when dataGridView.Focused: + { + ChangeRowHeight(true); + e.Handled = true; + + break; + } + case Keys.PageUp when e.Modifiers == Keys.Alt: + { + SelectPrevHighlightLine(); + e.Handled = true; + + break; + } + case Keys.PageDown when e.Modifiers == Keys.Alt: + { + SelectNextHighlightLine(); + e.Handled = true; + + break; + } + case Keys.T when (e.Modifiers & Keys.Control) == Keys.Control && (e.Modifiers & Keys.Shift) == Keys.Shift: + { + FilterToTab(); + break; + } + } + } + + public void AddBookmarkOverlays () + { + const int OVERSCAN = 20; + + var firstLine = dataGridView.FirstDisplayedScrollingRowIndex; + if (firstLine < 0) + { + return; + } + + firstLine -= OVERSCAN; + if (firstLine < 0) + { + firstLine = 0; + } + + var oversizeCount = OVERSCAN; + + for (var i = firstLine; i < dataGridView.RowCount; ++i) + { + if (!dataGridView.Rows[i].Displayed && i > dataGridView.FirstDisplayedScrollingRowIndex) + { + if (oversizeCount-- < 0) + { + break; + } + } + + if (_bookmarkProvider.IsBookmarkAtLine(i)) + { + var bookmark = _bookmarkProvider.GetBookmarkForLine(i); + if (bookmark.Text.Length > 0) + { + //BookmarkOverlay overlay = new BookmarkOverlay(); + var overlay = bookmark.Overlay; + overlay.Bookmark = bookmark; + + Rectangle r; + if (dataGridView.Rows[i].Displayed) + { + r = dataGridView.GetCellDisplayRectangle(0, i, false); + } + else + { + r = dataGridView.GetCellDisplayRectangle(0, dataGridView.FirstDisplayedScrollingRowIndex, false); + //int count = i - this.dataGridView.FirstDisplayedScrollingRowIndex; + var heightSum = 0; + if (dataGridView.FirstDisplayedScrollingRowIndex < i) + { + for (var rn = dataGridView.FirstDisplayedScrollingRowIndex + 1; rn < i; ++rn) + { + //Rectangle rr = this.dataGridView.GetCellDisplayRectangle(0, rn, false); + //heightSum += rr.Height; + heightSum += GetRowHeight(rn); + } + + r.Offset(0, r.Height + heightSum); + } + else + { + for (var rn = dataGridView.FirstDisplayedScrollingRowIndex + 1; rn > i; --rn) + { + //Rectangle rr = this.dataGridView.GetCellDisplayRectangle(0, rn, false); + //heightSum += rr.Height; + heightSum += GetRowHeight(rn); + } + + r.Offset(0, -(r.Height + heightSum)); + } + //r.Offset(0, this.dataGridView.DisplayRectangle.Height); + } + + if (_logger.IsDebugEnabled) + { + _logger.Debug($"AddBookmarkOverlay() r.Location={r.Location.X}, width={r.Width}, scroll_offset={dataGridView.HorizontalScrollingOffset}"); + } + + overlay.Position = r.Location - new Size(dataGridView.HorizontalScrollingOffset, 0); + overlay.Position += new Size(10, r.Height / 2); + dataGridView.AddOverlay(overlay); + } + } + } + } + + public void ToggleBookmark () + { + BufferedDataGridView gridView; + int lineNum; + + if (filterGridView.Focused) + { + gridView = filterGridView; + if (gridView.CurrentCellAddress.Y == -1) + { + return; + } + + lineNum = _filterResultList[gridView.CurrentCellAddress.Y]; + } + else + { + gridView = dataGridView; + if (gridView.CurrentCellAddress.Y == -1) + { + return; + } + lineNum = dataGridView.CurrentCellAddress.Y; + } + + ToggleBookmark(lineNum); + } + + public void ToggleBookmark (int lineNum) + { + if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) + { + var bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); + + if (string.IsNullOrEmpty(bookmark.Text) == false) + { + if (DialogResult.No == MessageBox.Show("There's a comment attached to the bookmark. Really remove the bookmark?", "LogExpert", MessageBoxButtons.YesNo)) + { + return; + } + } + _bookmarkProvider.RemoveBookmarkForLine(lineNum); + } + else + { + _bookmarkProvider.AddBookmark(new Bookmark(lineNum)); + } + dataGridView.Refresh(); + filterGridView.Refresh(); + OnBookmarkAdded(); + } + + public void SetBookmarkFromTrigger (int lineNum, string comment) + { + lock (_bookmarkLock) + { + var line = _logFileReader.GetLogLine(lineNum); + if (line == null) + { + return; + } + var paramParser = new ParamParser(comment); + try + { + comment = paramParser.ReplaceParams(line, lineNum, FileName); + } + catch (ArgumentException) + { + // occurs on invalid regex + } + if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) + { + _bookmarkProvider.RemoveBookmarkForLine(lineNum); + } + _bookmarkProvider.AddBookmark(new Bookmark(lineNum, comment)); + OnBookmarkAdded(); + } + } + + public void JumpNextBookmark () + { + if (_bookmarkProvider.Bookmarks.Count > 0) + { + if (filterGridView.Focused) + { + var index = FindNextBookmarkIndex(_filterResultList[filterGridView.CurrentCellAddress.Y]); + var startIndex = index; + var wrapped = false; + while (true) + { + var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; + if (_filterResultList.Contains(lineNum)) + { + var filterLine = _filterResultList.IndexOf(lineNum); + filterGridView.Rows[filterLine].Selected = true; + filterGridView.CurrentCell = filterGridView.Rows[filterLine].Cells[0]; + break; + } + index++; + if (index > _bookmarkProvider.Bookmarks.Count - 1) + { + index = 0; + wrapped = true; + } + if (index >= startIndex && wrapped) + { + break; + } + } + } + else + { + var index = FindNextBookmarkIndex(dataGridView.CurrentCellAddress.Y); + if (index > _bookmarkProvider.Bookmarks.Count - 1) + { + index = 0; + } + + var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; + SelectLine(lineNum, true, true); + } + } + } + + public void JumpPrevBookmark () + { + if (_bookmarkProvider.Bookmarks.Count > 0) + { + if (filterGridView.Focused) + { + //int index = this.bookmarkList.BinarySearch(this.filterResultList[this.filterGridView.CurrentCellAddress.Y]); + //if (index < 0) + // index = ~index; + //index--; + var index = FindPrevBookmarkIndex(_filterResultList[filterGridView.CurrentCellAddress.Y]); + if (index < 0) + { + index = _bookmarkProvider.Bookmarks.Count - 1; + } + var startIndex = index; + var wrapped = false; + while (true) + { + var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; + if (_filterResultList.Contains(lineNum)) + { + var filterLine = _filterResultList.IndexOf(lineNum); + filterGridView.Rows[filterLine].Selected = true; + filterGridView.CurrentCell = filterGridView.Rows[filterLine].Cells[0]; + break; + } + index--; + if (index < 0) + { + index = _bookmarkProvider.Bookmarks.Count - 1; + wrapped = true; + } + if (index <= startIndex && wrapped) + { + break; + } + } + } + else + { + var index = FindPrevBookmarkIndex(dataGridView.CurrentCellAddress.Y); + if (index < 0) + { + index = _bookmarkProvider.Bookmarks.Count - 1; + } + + var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; + SelectLine(lineNum, false, true); + } + } + } + + public void DeleteBookmarks (List lineNumList) + { + var bookmarksPresent = false; + foreach (var lineNum in lineNumList) + { + if (lineNum != -1) + { + if (_bookmarkProvider.IsBookmarkAtLine(lineNum) && + _bookmarkProvider.GetBookmarkForLine(lineNum).Text.Length > 0) + { + bookmarksPresent = true; + } + } + } + if (bookmarksPresent) + { + if ( + MessageBox.Show("There are some comments in the bookmarks. Really remove bookmarks?", "LogExpert", + MessageBoxButtons.YesNo) == DialogResult.No) + { + return; + } + } + _bookmarkProvider.RemoveBookmarksForLines(lineNumList); + OnBookmarkRemoved(); + } + + public void SetTimeshiftValue (string value) + { + _guiStateArgs.TimeshiftText = value; + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + try + { + if (_guiStateArgs.TimeshiftEnabled) + { + try + { + var text = _guiStateArgs.TimeshiftText; + if (text.StartsWith("+")) + { + text = text.Substring(1); + } + var timeSpan = TimeSpan.Parse(text); + var diff = (int)(timeSpan.Ticks / TimeSpan.TicksPerMillisecond); + CurrentColumnizer.SetTimeOffset(diff); + } + catch (Exception) + { + CurrentColumnizer.SetTimeOffset(0); + } + } + else + { + CurrentColumnizer.SetTimeOffset(0); + } + dataGridView.Refresh(); + filterGridView.Refresh(); + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + SetTimestampLimits(); + SyncTimestampDisplay(); + } + } + catch (FormatException ex) + { + _logger.Error(ex); + } + } + } + + public void ToggleFilterPanel () + { + splitContainerLogWindow.Panel2Collapsed = !splitContainerLogWindow.Panel2Collapsed; + if (!splitContainerLogWindow.Panel2Collapsed) + { + filterComboBox.Focus(); + } + else + { + dataGridView.Focus(); + } + } + + public void LogWindowActivated () + { + if (_guiStateArgs.FollowTail && !_isDeadFile) + { + OnTailFollowed(EventArgs.Empty); + } + + if (Preferences.TimestampControl) + { + SetTimestampLimits(); + SyncTimestampDisplay(); + } + + dataGridView.Focus(); + + SendGuiStateUpdate(); + SendStatusLineUpdate(); + SendProgressBarUpdate(); + } + + public void SetCellSelectionMode (bool isCellMode) + { + if (isCellMode) + { + //possible performance issue, see => https://docs.microsoft.com/en-us/dotnet/desktop/winforms/controls/best-practices-for-scaling-the-windows-forms-datagridview-control?view=netframeworkdesktop-4.8#using-the-selected-cells-rows-and-columns-collections-efficiently + dataGridView.SelectionMode = DataGridViewSelectionMode.CellSelect; + } + else + { + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + } + + _guiStateArgs.CellSelectMode = isCellMode; + } + + public void TimeshiftEnabled (bool isEnabled, string shiftValue) + { + _guiStateArgs.TimeshiftEnabled = isEnabled; + SetTimestampLimits(); + SetTimeshiftValue(shiftValue); + } + + public void CopyMarkedLinesToTab () + { + if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) + { + var lineNumList = new List(); + foreach (DataGridViewRow row in dataGridView.SelectedRows) + { + if (row.Index != -1) + { + lineNumList.Add(row.Index); + } + } + + lineNumList.Sort(); + // create dummy FilterPipe for connecting line numbers to original window + // setting IsStopped to true prevents further filter processing + var pipe = new FilterPipe(new FilterParams(), this) + { + IsStopped = true + }; + WritePipeToTab(pipe, lineNumList, Text + "->C", null); + } + else + { + var fileName = Path.GetTempFileName(); + var fStream = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.Read); + var writer = new StreamWriter(fStream, Encoding.Unicode); + + var data = dataGridView.GetClipboardContent(); + var text = data.GetText(TextDataFormat.Text); + writer.Write(text); + + writer.Close(); + var title = Util.GetNameFromPath(FileName) + "->Clip"; + _parentLogTabWin.AddTempFileTab(fileName, title); + } + } + + /// + /// Change the file encoding. May force a reload if byte count ot preamble lenght differs from previous used encoding. + /// + /// + public void ChangeEncoding (Encoding encoding) + { + _logFileReader.ChangeEncoding(encoding); + EncodingOptions.Encoding = encoding; + if (_guiStateArgs.CurrentEncoding.IsSingleByte != encoding.IsSingleByte || + _guiStateArgs.CurrentEncoding.GetPreamble().Length != encoding.GetPreamble().Length) + { + Reload(); + } + else + { + dataGridView.Refresh(); + SendGuiStateUpdate(); + } + _guiStateArgs.CurrentEncoding = _logFileReader.CurrentEncoding; + } + + public void Reload () + { + SavePersistenceData(false); + + _reloadMemento = new ReloadMemento + { + CurrentLine = dataGridView.CurrentCellAddress.Y, + FirstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex + }; + _forcedColumnizerForLoading = CurrentColumnizer; + + if (_fileNames == null || !IsMultiFile) + { + LoadFile(FileName, EncodingOptions); + } + else + { + LoadFilesAsMulti(_fileNames, EncodingOptions); + } + //if (currentLine < this.dataGridView.RowCount && currentLine >= 0) + // this.dataGridView.CurrentCell = this.dataGridView.Rows[currentLine].Cells[0]; + //if (firstDisplayedLine < this.dataGridView.RowCount && firstDisplayedLine >= 0) + // this.dataGridView.FirstDisplayedScrollingRowIndex = firstDisplayedLine; + + //if (this.filterTailCheckBox.Checked) + //{ + // _logger.logInfo("Refreshing filter view because of reload."); + // FilterSearch(); + //} + } + + public void PreferencesChanged (string fontName, float fontSize, bool setLastColumnWidth, int lastColumnWidth, bool isLoadTime, SettingsFlags flags) + { + if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors) + { + NormalFont = new Font(new FontFamily(fontName), fontSize); + BoldFont = new Font(NormalFont, FontStyle.Bold); + MonospacedFont = new Font("Courier New", Preferences.FontSize, FontStyle.Bold); + + var lineSpacing = NormalFont.FontFamily.GetLineSpacing(FontStyle.Regular); + var lineSpacingPixel = NormalFont.Size * lineSpacing / NormalFont.FontFamily.GetEmHeight(FontStyle.Regular); + + dataGridView.DefaultCellStyle.Font = NormalFont; + filterGridView.DefaultCellStyle.Font = NormalFont; + _lineHeight = NormalFont.Height + 4; + dataGridView.RowTemplate.Height = NormalFont.Height + 4; + + ShowBookmarkBubbles = Preferences.ShowBubbles; + + ApplyDataGridViewPrefs(dataGridView, setLastColumnWidth, lastColumnWidth); + ApplyDataGridViewPrefs(filterGridView, setLastColumnWidth, lastColumnWidth); + + if (Preferences.TimestampControl) + { + SetTimestampLimits(); + SyncTimestampDisplay(); + } + + if (isLoadTime) + { + filterTailCheckBox.Checked = Preferences.FilterTail; + syncFilterCheckBox.Checked = Preferences.FilterSync; + //this.FollowTailChanged(this.Preferences.followTail, false); + } + + _timeSpreadCalc.TimeMode = Preferences.TimeSpreadTimeMode; + timeSpreadingControl.ForeColor = Preferences.TimeSpreadColor; + timeSpreadingControl.ReverseAlpha = Preferences.ReverseAlpha; + + if (CurrentColumnizer.IsTimeshiftImplemented()) + { + timeSpreadingControl.Invoke(new MethodInvoker(timeSpreadingControl.Refresh)); + ShowTimeSpread(Preferences.ShowTimeSpread); + } + + ToggleColumnFinder(Preferences.ShowColumnFinder, false); + } + + if ((flags & SettingsFlags.FilterList) == SettingsFlags.FilterList) + { + HandleChangedFilterList(); + } + + if ((flags & SettingsFlags.FilterHistory) == SettingsFlags.FilterHistory) + { + UpdateFilterHistoryFromSettings(); + + if (isLoadTime) + { + AutoResizeFilterBox(); + } + } + } + + public bool ScrollToTimestamp (DateTime timestamp, bool roundToSeconds, bool triggerSyncCall) + { + if (InvokeRequired) + { + BeginInvoke(new ScrollToTimestampFx(ScrollToTimestampWorker), timestamp, roundToSeconds, triggerSyncCall); + return true; + } + + return ScrollToTimestampWorker(timestamp, roundToSeconds, triggerSyncCall); + } + + public bool ScrollToTimestampWorker (DateTime timestamp, bool roundToSeconds, bool triggerSyncCall) + { + var hasScrolled = false; + if (!CurrentColumnizer.IsTimeshiftImplemented() || dataGridView.RowCount == 0) + { + return false; + } + + //this.Cursor = Cursors.WaitCursor; + var currentLine = dataGridView.CurrentCellAddress.Y; + if (currentLine < 0 || currentLine >= dataGridView.RowCount) + { + currentLine = 0; + } + var foundLine = FindTimestampLine(currentLine, timestamp, roundToSeconds); + if (foundLine >= 0) + { + SelectAndEnsureVisible(foundLine, triggerSyncCall); + hasScrolled = true; + } + //this.Cursor = Cursors.Default; + return hasScrolled; + } + + public int FindTimestampLine (int lineNum, DateTime timestamp, bool roundToSeconds) + { + var foundLine = + FindTimestampLine_Internal(lineNum, 0, dataGridView.RowCount - 1, timestamp, roundToSeconds); + if (foundLine >= 0) + { + // go backwards to the first occurence of the hit + var foundTimestamp = GetTimestampForLine(ref foundLine, roundToSeconds); + while (foundTimestamp.CompareTo(timestamp) == 0 && foundLine >= 0) + { + foundLine--; + foundTimestamp = GetTimestampForLine(ref foundLine, roundToSeconds); + } + if (foundLine < 0) + { + return 0; + } + + foundLine++; + GetTimestampForLineForward(ref foundLine, roundToSeconds); // fwd to next valid timestamp + return foundLine; + } + + return -foundLine; + } + + public int FindTimestampLine_Internal (int lineNum, int rangeStart, int rangeEnd, DateTime timestamp, + bool roundToSeconds) + { + _logger.Debug("FindTimestampLine_Internal(): timestamp={0}, lineNum={1}, rangeStart={2}, rangeEnd={3}", timestamp, lineNum, rangeStart, rangeEnd); + var refLine = lineNum; + var currentTimestamp = GetTimestampForLine(ref refLine, roundToSeconds); + if (currentTimestamp.CompareTo(timestamp) == 0) + { + return lineNum; + } + + if (timestamp < currentTimestamp) + { + //rangeStart = rangeStart; + rangeEnd = lineNum; + } + else + { + rangeStart = lineNum; + //rangeEnd = rangeEnd; + } + + if (rangeEnd - rangeStart <= 0) + { + return -lineNum; + } + + lineNum = ((rangeEnd - rangeStart) / 2) + rangeStart; + // prevent endless loop + if (rangeEnd - rangeStart < 2) + { + currentTimestamp = GetTimestampForLine(ref rangeStart, roundToSeconds); + if (currentTimestamp.CompareTo(timestamp) == 0) + { + return rangeStart; + } + + currentTimestamp = GetTimestampForLine(ref rangeEnd, roundToSeconds); + + return currentTimestamp.CompareTo(timestamp) == 0 + ? rangeEnd + : -lineNum; + } + + return FindTimestampLine_Internal(lineNum, rangeStart, rangeEnd, timestamp, roundToSeconds); + } + + /** + * Get the timestamp for the given line number. If the line + * has no timestamp, the previous line will be checked until a + * timestamp is found. + */ + public DateTime GetTimestampForLine (ref int lineNum, bool roundToSeconds) + { + lock (_currentColumnizerLock) + { + if (!CurrentColumnizer.IsTimeshiftImplemented()) + { + return DateTime.MinValue; + } + + _logger.Debug($"GetTimestampForLine({lineNum}) enter"); + var timeStamp = DateTime.MinValue; + var lookBack = false; + if (lineNum >= 0 && lineNum < dataGridView.RowCount) + { + while (timeStamp.CompareTo(DateTime.MinValue) == 0 && lineNum >= 0) + { + if (_isTimestampDisplaySyncing && _shouldTimestampDisplaySyncingCancel) + { + return DateTime.MinValue; + } + + lookBack = true; + var logLine = _logFileReader.GetLogLine(lineNum); + if (logLine == null) + { + return DateTime.MinValue; + } + + ColumnizerCallbackObject.LineNum = lineNum; + timeStamp = CurrentColumnizer.GetTimestamp(ColumnizerCallbackObject, logLine); + if (roundToSeconds) + { + timeStamp = timeStamp.Subtract(TimeSpan.FromMilliseconds(timeStamp.Millisecond)); + } + + lineNum--; + } + } + + if (lookBack) + { + lineNum++; + } + + _logger.Debug("GetTimestampForLine() leave with lineNum={0}", lineNum); + return timeStamp; + } + } + + /** + * Get the timestamp for the given line number. If the line + * has no timestamp, the next line will be checked until a + * timestamp is found. + */ + public DateTime GetTimestampForLineForward (ref int lineNum, bool roundToSeconds) + { + lock (_currentColumnizerLock) + { + if (!CurrentColumnizer.IsTimeshiftImplemented()) + { + return DateTime.MinValue; + } + + var timeStamp = DateTime.MinValue; + var lookFwd = false; + if (lineNum >= 0 && lineNum < dataGridView.RowCount) + { + while (timeStamp.CompareTo(DateTime.MinValue) == 0 && lineNum < dataGridView.RowCount) + { + lookFwd = true; + var logLine = _logFileReader.GetLogLine(lineNum); + if (logLine == null) + { + timeStamp = DateTime.MinValue; + break; + } + timeStamp = CurrentColumnizer.GetTimestamp(ColumnizerCallbackObject, logLine); + if (roundToSeconds) + { + timeStamp = timeStamp.Subtract(TimeSpan.FromMilliseconds(timeStamp.Millisecond)); + } + lineNum++; + } + } + if (lookFwd) + { + lineNum--; + } + return timeStamp; + } + } + + public void AppFocusLost () + { + InvalidateCurrentRow(dataGridView); + } + + public void AppFocusGained () + { + InvalidateCurrentRow(dataGridView); + } + + public ILogLine GetCurrentLine () + { + if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index != -1) + { + return _logFileReader.GetLogLine(dataGridView.CurrentRow.Index); + } + return null; + } + + public ILogLine GetLine (int lineNum) + { + if (lineNum < 0 || _logFileReader == null || lineNum >= _logFileReader.LineCount) + { + return null; + } + return _logFileReader.GetLogLine(lineNum); + } + + public int GetCurrentLineNum () + { + if (dataGridView.CurrentRow == null) + { + return -1; + } + return dataGridView.CurrentRow.Index; + } + + public int GetRealLineNum () + { + var lineNum = GetCurrentLineNum(); + if (lineNum == -1) + { + return -1; + } + return _logFileReader.GetRealLineNumForVirtualLineNum(lineNum); + } + + public ILogFileInfo GetCurrentFileInfo () + { + if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index != -1) + { + return _logFileReader.GetLogFileInfoForLine(dataGridView.CurrentRow.Index); + } + return null; + } + + /// + /// zero-based + /// + /// + /// + public string GetCurrentFileName (int lineNum) + { + return _logFileReader.GetLogFileNameForLine(lineNum); + } + + // =============== end of bookmark stuff =================================== + + public void ShowLineColumn (bool show) + { + dataGridView.Columns[1].Visible = show; + filterGridView.Columns[1].Visible = show; + } + + // ================================================================= + // Pattern statistics + // ================================================================= + + public void PatternStatistic () + { + InitPatternWindow(); + } + + public void PatternStatisticSelectRange (PatternArgs patternArgs) + { + if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) + { + List lineNumList = []; + foreach (DataGridViewRow row in dataGridView.SelectedRows) + { + if (row.Index != -1) + { + lineNumList.Add(row.Index); + } + } + lineNumList.Sort(); + patternArgs.StartLine = lineNumList[0]; + patternArgs.EndLine = lineNumList[^1]; + } + else + { + patternArgs.StartLine = dataGridView.CurrentCellAddress.Y != -1 + ? dataGridView.CurrentCellAddress.Y + : 0; + patternArgs.EndLine = dataGridView.RowCount - 1; + } + } + + public void PatternStatistic (PatternArgs patternArgs) + { + var fx = new PatternStatisticFx(TestStatistic); + fx.BeginInvoke(patternArgs, null, null); + } + + public void ExportBookmarkList () + { + SaveFileDialog dlg = new() + { + Title = "Choose a file to save bookmarks into", + AddExtension = true, + DefaultExt = "csv", + Filter = "CSV file (*.csv)|*.csv|Bookmark file (*.bmk)|*.bmk", + FilterIndex = 1, + FileName = Path.GetFileNameWithoutExtension(FileName) + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + try + { + BookmarkExporter.ExportBookmarkList(_bookmarkProvider.BookmarkList, FileName, + dlg.FileName); + } + catch (IOException e) + { + _logger.Error(e); + MessageBox.Show("Error while exporting bookmark list: " + e.Message, "LogExpert"); + } + } + } + + public void ImportBookmarkList () + { + OpenFileDialog dlg = new() + { + Title = "Choose a file to load bookmarks from", + AddExtension = true, + DefaultExt = "csv", + Filter = "CSV file (*.csv)|*.csv|Bookmark file (*.bmk)|*.bmk", + FilterIndex = 1, + FileName = Path.GetFileNameWithoutExtension(FileName) + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + try + { + // add to the existing bookmarks + SortedList newBookmarks = []; + BookmarkExporter.ImportBookmarkList(FileName, dlg.FileName, newBookmarks); + + // Add (or replace) to existing bookmark list + var bookmarkAdded = false; + foreach (var b in newBookmarks.Values) + { + if (!_bookmarkProvider.BookmarkList.ContainsKey(b.LineNum)) + { + _bookmarkProvider.BookmarkList.Add(b.LineNum, b); + bookmarkAdded = true; // refresh the list only once at the end + } + else + { + var existingBookmark = _bookmarkProvider.BookmarkList[b.LineNum]; + existingBookmark.Text = + b.Text; // replace existing bookmark for that line, preserving the overlay + OnBookmarkTextChanged(b); + } + } + + // Refresh the lists + if (bookmarkAdded) + { + OnBookmarkAdded(); + } + dataGridView.Refresh(); + filterGridView.Refresh(); + } + catch (IOException e) + { + _logger.Error(e); + MessageBox.Show($"Error while importing bookmark list: {e.Message}", "LogExpert"); + } + } + } + + public bool IsAdvancedOptionActive () + { + return rangeCheckBox.Checked || + fuzzyKnobControl.Value > 0 || + filterKnobBackSpread.Value > 0 || + filterKnobForeSpread.Value > 0 || + invertFilterCheckBox.Checked || + columnRestrictCheckBox.Checked; + } + + public void HandleChangedFilterList () + { + Invoke(new MethodInvoker(HandleChangedFilterListWorker)); + } + + public void HandleChangedFilterListWorker () + { + var index = filterListBox.SelectedIndex; + filterListBox.Items.Clear(); + foreach (var filterParam in ConfigManager.Settings.FilterList) + { + filterListBox.Items.Add(filterParam); + } + filterListBox.Refresh(); + if (index >= 0 && index < filterListBox.Items.Count) + { + filterListBox.SelectedIndex = index; + } + filterOnLoadCheckBox.Checked = Preferences.IsFilterOnLoad; + hideFilterListOnLoadCheckBox.Checked = Preferences.IsAutoHideFilterList; + } + + public void SetCurrentHighlightGroup (string groupName) + { + _guiStateArgs.HighlightGroupName = groupName; + lock (_currentHighlightGroupLock) + { + _currentHighlightGroup = _parentLogTabWin.FindHighlightGroup(groupName); + + _currentHighlightGroup ??= _parentLogTabWin.HighlightGroupList.Count > 0 + ? _parentLogTabWin.HighlightGroupList[0] + : new HighlightGroup(); + + _guiStateArgs.HighlightGroupName = _currentHighlightGroup.GroupName; + } + + SendGuiStateUpdate(); + BeginInvoke(new MethodInvoker(RefreshAllGrids)); + } + + public void SwitchMultiFile (bool enabled) + { + IsMultiFile = enabled; + Reload(); + } + + public void AddOtherWindowToTimesync (LogWindow other) + { + if (other.IsTimeSynced) + { + if (IsTimeSynced) + { + other.FreeFromTimeSync(); + AddSlaveToTimesync(other); + } + else + { + AddToTimeSync(other); + } + } + else + { + AddSlaveToTimesync(other); + } + } + + public void AddToTimeSync (LogWindow master) + { + _logger.Info($"Syncing window for {Util.GetNameFromPath(FileName)} to {Util.GetNameFromPath(master.FileName)}"); + lock (_timeSyncListLock) + { + if (IsTimeSynced && master.TimeSyncList != TimeSyncList) + // already synced but master has different sync list + { + FreeFromTimeSync(); + } + + TimeSyncList = master.TimeSyncList; + TimeSyncList.AddWindow(this); + ScrollToTimestamp(TimeSyncList.CurrentTimestamp, false, false); + } + + OnSyncModeChanged(); + } + + public void FreeFromTimeSync () + { + lock (_timeSyncListLock) + { + if (TimeSyncList != null) + { + _logger.Info($"De-Syncing window for {Util.GetNameFromPath(FileName)}"); + TimeSyncList.WindowRemoved -= OnTimeSyncListWindowRemoved; + TimeSyncList.RemoveWindow(this); + TimeSyncList = null; + } + } + + OnSyncModeChanged(); + } + + public void RefreshLogView () + { + RefreshAllGrids(); + } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.resx b/src/LogExpert.UI/Controls/LogWindow/LogWindow.resx index dd8f0ebb..1af7de15 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.resx +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.resx @@ -1,17 +1,17 @@ - + - @@ -117,57 +117,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 27 - - - 11, 68 - - - 17, 27 - - - 862, 21 - - - - - iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO - vAAADrwBlbxySQAAAM1JREFUOE/dlDsKQkEMRYO1jZU7EAS3YG1h51ZsdSdWIoLrcBla2dhZ2PvhPiYQ - rplMsLDwwBS5n8C8gSfyT0xF5EVnwqEsF1q0FZE9aRsuRWgpopfMdaSDhWb+3ApUQGfBovLNQjCudfWV - syB7o/mD5rcxeFnMV9I6cceig7ewqkM40MwhT1NczxOt5vkWeEcWR5WSLvM8S9WH0WcxKhSWUWYdmQHo - DFi0ZK5qQfbBoocunrFhWJXMk42IOT2Sd4ZcyoJf3N0sOnHgJ7wBih1ZgqnoK8MAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO - vAAADrwBlbxySQAAAM1JREFUOE/dlDsKQkEMRYO1jZU7EAS3YG1h51ZsdSdWIoLrcBla2dhZ2PvhPiYQ - rplMsLDwwBS5n8C8gSfyT0xF5EVnwqEsF1q0FZE9aRsuRWgpopfMdaSDhWb+3ApUQGfBovLNQjCudfWV - syB7o/mD5rcxeFnMV9I6cceig7ewqkM40MwhT1NczxOt5vkWeEcWR5WSLvM8S9WH0WcxKhSWUWYdmQHo - DFi0ZK5qQfbBoocunrFhWJXMk42IOT2Sd4ZcyoJf3N0sOnHgJ7wBih1ZgqnoK8MAAAAASUVORK5CYII= - - - - 261, 21 - - - 467, 21 - - - 658, 21 - - - 70 - - - - AAABAAEAEBAQAAAABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAA - AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// - AAD///8AAAAAAAAAAAAP////////8A/////////wD/AAAAAAD/AP////////8A/wAAAAAA/wD/////// - //AP8ADwAAAP8A////D////wD/AA8AAP//AP///w////8A//APAAAP/wD/////////AP////////8AAA - AAAAAAAAAAAAAAAAAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAIABAAD//wAA - - \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs deleted file mode 100644 index 9150a4a2..00000000 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs +++ /dev/null @@ -1,1723 +0,0 @@ -using System.ComponentModel; -using System.Globalization; -using System.Runtime.Versioning; - -using LogExpert.Core.Classes; -using LogExpert.Core.Classes.Filter; -using LogExpert.Core.Classes.Highlight; -using LogExpert.Core.Config; -using LogExpert.Core.Entities; -using LogExpert.Core.EventArguments; -using LogExpert.Core.Interface; -using LogExpert.Dialogs; -using LogExpert.UI.Dialogs; -using LogExpert.UI.Entities; -using LogExpert.UI.Extensions; - -namespace LogExpert.UI.Controls.LogWindow; - -partial class LogWindow -{ - [SupportedOSPlatform("windows")] - private void AutoResizeFilterBox () - { - filterSplitContainer.SplitterDistance = filterComboBox.Left + filterComboBox.GetMaxTextWidth(); - } - - #region Events handler - - protected void OnProgressBarUpdate (ProgressEventArgs e) - { - ProgressBarUpdate?.Invoke(this, e); - } - - protected void OnStatusLine (StatusLineEventArgs e) - { - StatusLineEvent?.Invoke(this, e); - } - - protected void OnGuiState (GuiStateArgs e) - { - GuiStateUpdate?.Invoke(this, e); - } - - protected void OnTailFollowed (EventArgs e) - { - TailFollowed?.Invoke(this, e); - } - - protected void OnFileNotFound (EventArgs e) - { - FileNotFound?.Invoke(this, e); - } - - protected void OnFileRespawned (EventArgs e) - { - FileRespawned?.Invoke(this, e); - } - - protected void OnFilterListChanged (LogWindow source) - { - FilterListChanged?.Invoke(this, new FilterListChangedEventArgs(source)); - } - - protected void OnCurrentHighlightListChanged () - { - CurrentHighlightGroupChanged?.Invoke(this, new CurrentHighlightGroupChangedEventArgs(this, _currentHighlightGroup)); - } - - protected void OnBookmarkAdded () - { - BookmarkAdded?.Invoke(this, EventArgs.Empty); - } - - protected void OnBookmarkRemoved () - { - BookmarkRemoved?.Invoke(this, EventArgs.Empty); - } - - protected void OnBookmarkTextChanged (Bookmark bookmark) - { - BookmarkTextChanged?.Invoke(this, new BookmarkEventArgs(bookmark)); - } - - protected void OnColumnizerChanged (ILogLineColumnizer columnizer) - { - ColumnizerChanged?.Invoke(this, new ColumnizerEventArgs(columnizer)); - } - - protected void OnRegisterCancelHandler (IBackgroundProcessCancelHandler handler) - { - lock (_cancelHandlerList) - { - _cancelHandlerList.Add(handler); - } - } - - protected void OnDeRegisterCancelHandler (IBackgroundProcessCancelHandler handler) - { - lock (_cancelHandlerList) - { - _cancelHandlerList.Remove(handler); - } - } - - [SupportedOSPlatform("windows")] - private void OnLogWindowLoad (object sender, EventArgs e) - { - var setLastColumnWidth = _parentLogTabWin.Preferences.SetLastColumnWidth; - var lastColumnWidth = _parentLogTabWin.Preferences.LastColumnWidth; - var fontName = _parentLogTabWin.Preferences.FontName; - var fontSize = _parentLogTabWin.Preferences.FontSize; - - PreferencesChanged(fontName, fontSize, setLastColumnWidth, lastColumnWidth, true, SettingsFlags.GuiOrColors); - } - - [SupportedOSPlatform("windows")] - private void OnLogWindowDisposed (object sender, EventArgs e) - { - _waitingForClose = true; - _parentLogTabWin.HighlightSettingsChanged -= OnParentHighlightSettingsChanged; - _logFileReader?.DeleteAllContent(); - - FreeFromTimeSync(); - } - - [SupportedOSPlatform("windows")] - private void OnLogFileReaderLoadingStarted (object sender, LoadFileEventArgs e) - { - Invoke(LoadingStarted, e); - } - - [SupportedOSPlatform("windows")] - private void OnLogFileReaderFinishedLoading (object sender, EventArgs e) - { - //Thread.CurrentThread.Name = "FinishedLoading event thread"; - _logger.Info(CultureInfo.InvariantCulture, "Finished loading."); - _isLoading = false; - _isDeadFile = false; - if (!_waitingForClose) - { - Invoke(new MethodInvoker(LoadingFinished)); - Invoke(new MethodInvoker(LoadPersistenceData)); - Invoke(new MethodInvoker(SetGuiAfterLoading)); - _loadingFinishedEvent.Set(); - _externaLoadingFinishedEvent.Set(); - _timeSpreadCalc.SetLineCount(_logFileReader.LineCount); - - if (_reloadMemento != null) - { - Invoke(new PositionAfterReloadFx(PositionAfterReload), _reloadMemento); - } - - if (filterTailCheckBox.Checked) - { - _logger.Info(CultureInfo.InvariantCulture, "Refreshing filter view because of reload."); - Invoke(new MethodInvoker(FilterSearch)); // call on proper thread - } - - HandleChangedFilterList(); - } - - _reloadMemento = null; - } - - [SupportedOSPlatform("windows")] - private void OnLogFileReaderFileNotFound (object sender, EventArgs e) - { - if (!IsDisposed && !Disposing) - { - _logger.Info(CultureInfo.InvariantCulture, "Handling file not found event."); - _isDeadFile = true; - BeginInvoke(new MethodInvoker(LogfileDead)); - } - } - - [SupportedOSPlatform("windows")] - private void OnLogFileReaderRespawned (object sender, EventArgs e) - { - BeginInvoke(new MethodInvoker(LogfileRespawned)); - } - - [SupportedOSPlatform("windows")] - private void OnLogWindowClosing (object sender, CancelEventArgs e) - { - if (Preferences.AskForClose) - { - if (MessageBox.Show("Sure to close?", "LogExpert", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) - { - e.Cancel = true; - return; - } - } - - SavePersistenceData(false); - CloseLogWindow(); - } - - [SupportedOSPlatform("windows")] - private void OnDataGridViewColumnDividerDoubleClick (object sender, DataGridViewColumnDividerDoubleClickEventArgs e) - { - e.Handled = true; - AutoResizeColumns(dataGridView); - } - - /** - * Event handler for the Load event from LogfileReader - */ - [SupportedOSPlatform("windows")] - private void OnLogFileReaderLoadFile (object sender, LoadFileEventArgs e) - { - if (e.NewFile) - { - _logger.Info(CultureInfo.InvariantCulture, "File created anew."); - - // File was new created (e.g. rollover) - _isDeadFile = false; - UnRegisterLogFileReaderEvents(); - dataGridView.CurrentCellChanged -= OnDataGridViewCurrentCellChanged; - MethodInvoker invoker = ReloadNewFile; - BeginInvoke(invoker); - //Thread loadThread = new Thread(new ThreadStart(ReloadNewFile)); - //loadThread.Start(); - _logger.Debug(CultureInfo.InvariantCulture, "Reloading invoked."); - } - else if (_isLoading) - { - BeginInvoke(UpdateProgress, e); - } - } - - private void OnFileSizeChanged (object sender, LogEventArgs e) - { - //OnFileSizeChanged(e); // now done in UpdateGrid() - _logger.Info(CultureInfo.InvariantCulture, "Got FileSizeChanged event. prevLines:{0}, curr lines: {1}", e.PrevLineCount, e.LineCount); - - // - now done in the thread that works on the event args list - //if (e.IsRollover) - //{ - // ShiftBookmarks(e.RolloverOffset); - // ShiftFilterPipes(e.RolloverOffset); - //} - - //UpdateGridCallback callback = new UpdateGridCallback(UpdateGrid); - //this.BeginInvoke(callback, new object[] { e }); - lock (_logEventArgsList) - { - _logEventArgsList.Add(e); - _logEventArgsEvent.Set(); - } - } - - [SupportedOSPlatform("windows")] - private void OnDataGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e) - { - var startCount = CurrentColumnizer?.GetColumnCount() ?? 0; - - e.Value = GetCellValue(e.RowIndex, e.ColumnIndex); - - // The new column could be find dynamically. - // Only support add new columns for now. - // TODO: Support reload all columns? - if (CurrentColumnizer != null && CurrentColumnizer.GetColumnCount() > startCount) - { - for (var i = startCount; i < CurrentColumnizer.GetColumnCount(); i++) - { - var colName = CurrentColumnizer.GetColumnNames()[i]; - dataGridView.Columns.Add(PaintHelper.CreateTitleColumn(colName)); - } - } - } - - [SupportedOSPlatform("windows")] - private void OnDataGridViewCellValuePushed (object sender, DataGridViewCellValueEventArgs e) - { - if (!CurrentColumnizer.IsTimeshiftImplemented()) - { - return; - } - - var line = _logFileReader.GetLogLine(e.RowIndex); - var offset = CurrentColumnizer.GetTimeOffset(); - CurrentColumnizer.SetTimeOffset(0); - ColumnizerCallbackObject.SetLineNum(e.RowIndex); - var cols = CurrentColumnizer.SplitLine(ColumnizerCallbackObject, line); - CurrentColumnizer.SetTimeOffset(offset); - if (cols.ColumnValues.Length <= e.ColumnIndex - 2) - { - return; - } - - var oldValue = cols.ColumnValues[e.ColumnIndex - 2].FullValue; - var newValue = (string)e.Value; - //string oldValue = (string) this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; - CurrentColumnizer.PushValue(ColumnizerCallbackObject, e.ColumnIndex - 2, newValue, oldValue); - dataGridView.Refresh(); - TimeSpan timeSpan = new(CurrentColumnizer.GetTimeOffset() * TimeSpan.TicksPerMillisecond); - var span = timeSpan.ToString(); - var index = span.LastIndexOf('.'); - if (index > 0) - { - span = span.Substring(0, index + 4); - } - - SetTimeshiftValue(span); - SendGuiStateUpdate(); - } - - [SupportedOSPlatform("windows")] - private void OnDataGridViewRowHeightInfoNeeded (object sender, DataGridViewRowHeightInfoNeededEventArgs e) - { - e.Height = GetRowHeight(e.RowIndex); - } - - [SupportedOSPlatform("windows")] - private void OnDataGridViewCurrentCellChanged (object sender, EventArgs e) - { - if (dataGridView.CurrentRow != null) - { - _statusEventArgs.CurrentLineNum = dataGridView.CurrentRow.Index + 1; - SendStatusLineUpdate(); - if (syncFilterCheckBox.Checked) - { - SyncFilterGridPos(); - } - - if (CurrentColumnizer.IsTimeshiftImplemented() && Preferences.TimestampControl) - { - SyncTimestampDisplay(); - } - - //MethodInvoker invoker = new MethodInvoker(DisplayCurrentFileOnStatusline); - //invoker.BeginInvoke(null, null); - } - } - - private void OnDataGridViewCellEndEdit (object sender, DataGridViewCellEventArgs e) - { - StatusLineText(string.Empty); - } - - [SupportedOSPlatform("windows")] - private void OnEditControlKeyUp (object sender, KeyEventArgs e) - { - UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); - } - - [SupportedOSPlatform("windows")] - private void OnEditControlKeyPress (object sender, KeyPressEventArgs e) - { - UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); - } - - [SupportedOSPlatform("windows")] - private void OnEditControlClick (object sender, EventArgs e) - { - UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); - } - - [SupportedOSPlatform("windows")] - private void OnEditControlKeyDown (object sender, KeyEventArgs e) - { - UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender); - } - - [SupportedOSPlatform("windows")] - private void OnDataGridViewPaint (object sender, PaintEventArgs e) - { - if (ShowBookmarkBubbles) - { - AddBookmarkOverlays(); - } - } - - // ====================================================================================== - // Filter Grid stuff - // ====================================================================================== - - [SupportedOSPlatform("windows")] - private void OnFilterSearchButtonClick (object sender, EventArgs e) - { - FilterSearch(); - } - - [SupportedOSPlatform("windows")] - private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPaintingEventArgs e) - { - var gridView = (BufferedDataGridView)sender; - - if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) - { - e.Handled = false; - return; - } - - - - var lineNum = _filterResultList[e.RowIndex]; - var line = _logFileReader.GetLogLineWithWait(lineNum).Result; - - if (line != null) - { - var entry = FindFirstNoWordMatchHilightEntry(line); - e.Graphics.SetClip(e.CellBounds); - if (e.State.HasFlag(DataGridViewElementStates.Selected)) - { - using var brush = PaintHelper.GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); - e.Graphics.FillRectangle(brush, e.CellBounds); - } - else - { - // paint direct filter hits with different bg color - //if (this.filterParams.SpreadEnabled && this.filterHitList.Contains(lineNum)) - //{ - // bgColor = Color.FromArgb(255, 220, 220, 220); - //} - e.CellStyle.BackColor = PaintHelper.GetBackColorFromHighlightEntry(entry); - e.PaintBackground(e.ClipBounds, false); - } - - if (DebugOptions.DisableWordHighlight) - { - e.PaintContent(e.CellBounds); - } - else - { - PaintCell(e, filterGridView, false, entry); - } - - if (e.ColumnIndex == 0) - { - if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - Rectangle r;// = new(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); - r = e.CellBounds; - r.Inflate(-2, -2); - using var brush = new SolidBrush(BookmarkColor); - e.Graphics.FillRectangle(brush, r); - - var bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); - - if (bookmark.Text.Length > 0) - { - StringFormat format = new() - { - LineAlignment = StringAlignment.Center, - Alignment = StringAlignment.Center - }; - - using var brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); - using var font = new Font("Verdana", Preferences.FontSize, FontStyle.Bold); - e.Graphics.DrawString("!", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); - } - } - } - - e.Paint(e.CellBounds, DataGridViewPaintParts.Border); - e.Handled = true; - } - } - - [SupportedOSPlatform("windows")] - private void OnFilterGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e) - { - if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) - { - e.Value = ""; - return; - } - - var lineNum = _filterResultList[e.RowIndex]; - e.Value = GetCellValue(lineNum, e.ColumnIndex); - } - - [SupportedOSPlatform("windows")] - private void OnFilterGridViewRowHeightInfoNeeded (object sender, DataGridViewRowHeightInfoNeededEventArgs e) - { - e.Height = _lineHeight; - } - - [SupportedOSPlatform("windows")] - private void OnFilterComboBoxKeyDown (object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - FilterSearch(); - } - } - - [SupportedOSPlatform("windows")] - private void OnFilterGridViewColumnDividerDoubleClick (object sender, - DataGridViewColumnDividerDoubleClickEventArgs e) - { - e.Handled = true; - AutoResizeColumnsFx fx = AutoResizeColumns; - BeginInvoke(fx, filterGridView); - } - - [SupportedOSPlatform("windows")] - private void OnFilterGridViewCellDoubleClick (object sender, DataGridViewCellEventArgs e) - { - if (e.ColumnIndex == 0) - { - ToggleBookmark(); - return; - } - - if (filterGridView.CurrentRow != null && e.RowIndex >= 0) - { - var lineNum = _filterResultList[filterGridView.CurrentRow.Index]; - SelectAndEnsureVisible(lineNum, true); - } - } - - [SupportedOSPlatform("windows")] - private void OnRangeCheckBoxCheckedChanged (object sender, EventArgs e) - { - filterRangeComboBox.Enabled = rangeCheckBox.Checked; - CheckForFilterDirty(); - } - - [SupportedOSPlatform("windows")] - private void OnDataGridViewScroll (object sender, ScrollEventArgs e) - { - if (e.ScrollOrientation == ScrollOrientation.VerticalScroll) - { - if (dataGridView.DisplayedRowCount(false) + dataGridView.FirstDisplayedScrollingRowIndex >= dataGridView.RowCount) - { - //this.guiStateArgs.FollowTail = true; - if (!_guiStateArgs.FollowTail) - { - FollowTailChanged(true, false); - } - - OnTailFollowed(EventArgs.Empty); - } - else - { - //this.guiStateArgs.FollowTail = false; - if (_guiStateArgs.FollowTail) - { - FollowTailChanged(false, false); - } - } - - SendGuiStateUpdate(); - } - } - - [SupportedOSPlatform("windows")] - private void OnFilterGridViewKeyDown (object sender, KeyEventArgs e) - { - switch (e.KeyCode) - { - case Keys.Enter: - { - if (filterGridView.CurrentCellAddress.Y >= 0 && filterGridView.CurrentCellAddress.Y < _filterResultList.Count) - { - var lineNum = _filterResultList[filterGridView.CurrentCellAddress.Y]; - SelectLine(lineNum, false, true); - e.Handled = true; - } - - break; - } - case Keys.Tab when e.Modifiers == Keys.None: - dataGridView.Focus(); - e.Handled = true; - break; - } - } - - [SupportedOSPlatform("windows")] - private void OnDataGridViewKeyDown (object sender, KeyEventArgs e) - { - switch (e.KeyCode) - { - case Keys.Tab when e.Modifiers == Keys.None: - { - filterGridView.Focus(); - e.Handled = true; - break; - } - } - - //switch (e.KeyCode) - //{ - // case Keys.Tab when e.Modifiers == Keys.Control: - // //this.parentLogTabWin.SwitchTab(e.Shift); - // break; - //} - - _shouldCallTimeSync = true; - } - - [SupportedOSPlatform("windows")] - private void OnDataGridViewPreviewKeyDown (object sender, PreviewKeyDownEventArgs e) - { - if (e.KeyCode == Keys.Tab && e.Control) - { - e.IsInputKey = true; - } - } - - [SupportedOSPlatform("windows")] - private void OnDataGridViewCellContentDoubleClick (object sender, DataGridViewCellEventArgs e) - { - if (dataGridView.CurrentCell != null) - { - dataGridView.BeginEdit(false); - } - } - - [SupportedOSPlatform("windows")] - private void OnSyncFilterCheckBoxCheckedChanged (object sender, EventArgs e) - { - if (syncFilterCheckBox.Checked) - { - SyncFilterGridPos(); - } - } - - [SupportedOSPlatform("windows")] - private void OnDataGridViewLeave (object sender, EventArgs e) - { - InvalidateCurrentRow(dataGridView); - } - - [SupportedOSPlatform("windows")] - private void OnDataGridViewEnter (object sender, EventArgs e) - { - InvalidateCurrentRow(dataGridView); - } - - [SupportedOSPlatform("windows")] - private void OnFilterGridViewEnter (object sender, EventArgs e) - { - InvalidateCurrentRow(filterGridView); - } - - [SupportedOSPlatform("windows")] - private void OnFilterGridViewLeave (object sender, EventArgs e) - { - InvalidateCurrentRow(filterGridView); - } - - [SupportedOSPlatform("windows")] - private void OnDataGridViewResize (object sender, EventArgs e) - { - if (_logFileReader != null && dataGridView.RowCount > 0 && _guiStateArgs.FollowTail) - { - dataGridView.FirstDisplayedScrollingRowIndex = dataGridView.RowCount - 1; - } - } - - private void OnDataGridViewSelectionChanged (object sender, EventArgs e) - { - UpdateSelectionDisplay(); - } - - [SupportedOSPlatform("windows")] - private void OnSelectionChangedTriggerSignal (object sender, EventArgs e) - { - var selCount = 0; - try - { - _logger.Debug(CultureInfo.InvariantCulture, "Selection changed trigger"); - selCount = dataGridView.SelectedRows.Count; - if (selCount > 1) - { - StatusLineText(selCount + " selected lines"); - } - else - { - if (IsMultiFile) - { - MethodInvoker invoker = DisplayCurrentFileOnStatusline; - invoker.BeginInvoke(null, null); - } - else - { - StatusLineText(""); - } - } - } - catch (Exception ex) - { - _logger.Error(ex, "Error in selectionChangedTrigger_Signal selcount {0}", selCount); - } - } - - [SupportedOSPlatform("windows")] - private void OnFilterKnobControlValueChanged (object sender, EventArgs e) - { - CheckForFilterDirty(); - } - - [SupportedOSPlatform("windows")] - private void OnFilterToTabButtonClick (object sender, EventArgs e) - { - FilterToTab(); - } - - private void OnPipeDisconnected (object sender, EventArgs e) - { - if (sender.GetType() == typeof(FilterPipe)) - { - lock (_filterPipeList) - { - _filterPipeList.Remove((FilterPipe)sender); - if (_filterPipeList.Count == 0) - // reset naming counter to 0 if no more open filter tabs for this source window - { - _filterPipeNameCounter = 0; - } - } - } - } - - [SupportedOSPlatform("windows")] - private void OnAdvancedButtonClick (object sender, EventArgs e) - { - _showAdvanced = !_showAdvanced; - ShowAdvancedFilterPanel(_showAdvanced); - } - - [SupportedOSPlatform("windows")] - private void OnFilterSplitContainerMouseDown (object sender, MouseEventArgs e) - { - ((SplitContainer)sender).IsSplitterFixed = true; - } - - [SupportedOSPlatform("windows")] - private void OnFilterSplitContainerMouseUp (object sender, MouseEventArgs e) - { - ((SplitContainer)sender).IsSplitterFixed = false; - } - - [SupportedOSPlatform("windows")] - private void OnFilterSplitContainerMouseMove (object sender, MouseEventArgs e) - { - var splitContainer = (SplitContainer)sender; - if (splitContainer.IsSplitterFixed) - { - if (e.Button.Equals(MouseButtons.Left)) - { - if (splitContainer.Orientation.Equals(Orientation.Vertical)) - { - if (e.X > 0 && e.X < splitContainer.Width) - { - splitContainer.SplitterDistance = e.X; - splitContainer.Refresh(); - } - } - else - { - if (e.Y > 0 && e.Y < splitContainer.Height) - { - splitContainer.SplitterDistance = e.Y; - splitContainer.Refresh(); - } - } - } - else - { - splitContainer.IsSplitterFixed = false; - } - } - } - - [SupportedOSPlatform("windows")] - private void OnFilterSplitContainerMouseDoubleClick (object sender, MouseEventArgs e) - { - AutoResizeFilterBox(); - } - - #region Context Menu - - [SupportedOSPlatform("windows")] - private void OnDataGridContextMenuStripOpening (object sender, CancelEventArgs e) - { - var lineNum = -1; - if (dataGridView.CurrentRow != null) - { - lineNum = dataGridView.CurrentRow.Index; - } - - if (lineNum == -1) - { - return; - } - - var refLineNum = lineNum; - - copyToTabToolStripMenuItem.Enabled = dataGridView.SelectedCells.Count > 0; - scrollAllTabsToTimestampToolStripMenuItem.Enabled = CurrentColumnizer.IsTimeshiftImplemented() - && - GetTimestampForLine(ref refLineNum, false) != - DateTime.MinValue; - - locateLineInOriginalFileToolStripMenuItem.Enabled = IsTempFile && - FilterPipe != null && - FilterPipe.GetOriginalLineNum(lineNum) != -1; - - markEditModeToolStripMenuItem.Enabled = !dataGridView.CurrentCell.ReadOnly; - - // Remove all "old" plugin entries - var index = dataGridContextMenuStrip.Items.IndexOf(pluginSeparator); - - if (index > 0) - { - for (var i = index + 1; i < dataGridContextMenuStrip.Items.Count;) - { - dataGridContextMenuStrip.Items.RemoveAt(i); - } - } - - // Add plugin entries - var isAdded = false; - if (PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins.Count > 0) - { - var lines = GetSelectedContent(); - foreach (var entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins) - { - LogExpertCallback callback = new(this); - var menuText = entry.GetMenuText(lines.Count, CurrentColumnizer, callback.GetLogLine(lines[0])); - - if (menuText != null) - { - var disabled = menuText.StartsWith('_'); - if (disabled) - { - menuText = menuText[1..]; - } - - var item = dataGridContextMenuStrip.Items.Add(menuText, null, OnHandlePluginContextMenu); - item.Tag = new ContextMenuPluginEventArgs(entry, lines, CurrentColumnizer, callback); - item.Enabled = !disabled; - isAdded = true; - } - } - } - - pluginSeparator.Visible = isAdded; - - // enable/disable Temp Highlight item - tempHighlightsToolStripMenuItem.Enabled = _tempHighlightEntryList.Count > 0; - - markCurrentFilterRangeToolStripMenuItem.Enabled = string.IsNullOrEmpty(filterRangeComboBox.Text) == false; - - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - var list = _parentLogTabWin.GetListOfOpenFiles(); - syncTimestampsToToolStripMenuItem.Enabled = true; - syncTimestampsToToolStripMenuItem.DropDownItems.Clear(); - EventHandler ev = OnHandleSyncContextMenu; - Font italicFont = new(syncTimestampsToToolStripMenuItem.Font.FontFamily, syncTimestampsToToolStripMenuItem.Font.Size, FontStyle.Italic); - - foreach (var fileEntry in list) - { - if (fileEntry.LogWindow != this) - { - var item = syncTimestampsToToolStripMenuItem.DropDownItems.Add(fileEntry.Title, null, ev) as ToolStripMenuItem; - item.Tag = fileEntry; - item.Checked = TimeSyncList != null && TimeSyncList.Contains(fileEntry.LogWindow); - if (fileEntry.LogWindow.TimeSyncList != null && !fileEntry.LogWindow.TimeSyncList.Contains(this)) - { - item.Font = italicFont; - item.ForeColor = Color.Blue; - } - - item.Enabled = fileEntry.LogWindow.CurrentColumnizer.IsTimeshiftImplemented(); - } - } - } - else - { - syncTimestampsToToolStripMenuItem.Enabled = false; - } - - freeThisWindowFromTimeSyncToolStripMenuItem.Enabled = TimeSyncList != null && - TimeSyncList.Count > 1; - } - - [SupportedOSPlatform("windows")] - private void OnHandlePluginContextMenu (object sender, EventArgs args) - { - if (sender is ToolStripItem item) - { - var menuArgs = item.Tag as ContextMenuPluginEventArgs; - var logLines = menuArgs.LogLines; - menuArgs.Entry.MenuSelected(logLines.Count, menuArgs.Columnizer, menuArgs.Callback.GetLogLine(logLines[0])); - } - } - - [SupportedOSPlatform("windows")] - private void OnHandleSyncContextMenu (object sender, EventArgs args) - { - if (sender is ToolStripItem item) - { - var entry = item.Tag as WindowFileEntry; - - if (TimeSyncList != null && TimeSyncList.Contains(entry.LogWindow)) - { - FreeSlaveFromTimesync(entry.LogWindow); - } - else - //AddSlaveToTimesync(entry.LogWindow); - { - AddOtherWindowToTimesync(entry.LogWindow); - } - } - } - - [SupportedOSPlatform("windows")] - private void OnCopyToolStripMenuItemClick (object sender, EventArgs e) - { - CopyMarkedLinesToClipboard(); - } - - private void OnCopyToTabToolStripMenuItemClick (object sender, EventArgs e) - { - CopyMarkedLinesToTab(); - } - - [SupportedOSPlatform("windows")] - private void OnScrollAllTabsToTimestampToolStripMenuItemClick (object sender, EventArgs e) - { - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - var currentLine = dataGridView.CurrentCellAddress.Y; - if (currentLine > 0 && currentLine < dataGridView.RowCount) - { - var lineNum = currentLine; - var timeStamp = GetTimestampForLine(ref lineNum, false); - if (timeStamp.Equals(DateTime.MinValue)) // means: invalid - { - return; - } - - _parentLogTabWin.ScrollAllTabsToTimestamp(timeStamp, this); - } - } - } - - [SupportedOSPlatform("windows")] - private void OnLocateLineInOriginalFileToolStripMenuItemClick (object sender, EventArgs e) - { - if (dataGridView.CurrentRow != null && FilterPipe != null) - { - var lineNum = FilterPipe.GetOriginalLineNum(dataGridView.CurrentRow.Index); - if (lineNum != -1) - { - FilterPipe.LogWindow.SelectLine(lineNum, false, true); - _parentLogTabWin.SelectTab(FilterPipe.LogWindow); - } - } - } - - private void OnToggleBoomarkToolStripMenuItemClick (object sender, EventArgs e) - { - ToggleBookmark(); - } - - [SupportedOSPlatform("windows")] - private void OnMarkEditModeToolStripMenuItemClick (object sender, EventArgs e) - { - StartEditMode(); - } - - private void OnLogWindowSizeChanged (object sender, EventArgs e) - { - //AdjustMinimumGridWith(); - AdjustHighlightSplitterWidth(); - } - - #region BookMarkList - - [SupportedOSPlatform("windows")] - private void OnColumnRestrictCheckBoxCheckedChanged (object sender, EventArgs e) - { - columnButton.Enabled = columnRestrictCheckBox.Checked; - if (columnRestrictCheckBox.Checked) // disable when nothing to filter - { - columnNamesLabel.Visible = true; - _filterParams.ColumnRestrict = true; - columnNamesLabel.Text = CalculateColumnNames(_filterParams); - } - else - { - columnNamesLabel.Visible = false; - } - - CheckForFilterDirty(); - } - - [SupportedOSPlatform("windows")] - private void OnColumnButtonClick (object sender, EventArgs e) - { - _filterParams.CurrentColumnizer = _currentColumnizer; - FilterColumnChooser chooser = new(_filterParams); - if (chooser.ShowDialog() == DialogResult.OK) - { - columnNamesLabel.Text = CalculateColumnNames(_filterParams); - - //CheckForFilterDirty(); //!!!GBro: Indicate to redo the search if search columns were changed - filterSearchButton.Image = _searchButtonImage; - saveFilterButton.Enabled = false; - } - } - - #endregion - - #region Column Header Context Menu - - [SupportedOSPlatform("windows")] - private void OnDataGridViewCellContextMenuStripNeeded (object sender, DataGridViewCellContextMenuStripNeededEventArgs e) - { - if (e.RowIndex >= 0 && e.RowIndex < dataGridView.RowCount && !dataGridView.Rows[e.RowIndex].Selected) - { - SelectLine(e.RowIndex, false, true); - } - else if (e.RowIndex < 0) - { - e.ContextMenuStrip = columnContextMenuStrip; - } - - if (e.ContextMenuStrip == columnContextMenuStrip) - { - _selectedCol = e.ColumnIndex; - } - } - - //private void boomarkDataGridView_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) - //{ - // if (e.RowIndex > 0 && e.RowIndex < this.boomarkDataGridView.RowCount - // && !this.boomarkDataGridView.Rows[e.RowIndex].Selected) - // { - // this.boomarkDataGridView.Rows[e.RowIndex].Selected = true; - // this.boomarkDataGridView.CurrentCell = this.boomarkDataGridView.Rows[e.RowIndex].Cells[0]; - // } - // if (e.ContextMenuStrip == this.columnContextMenuStrip) - // { - // this.selectedCol = e.ColumnIndex; - // } - //} - - [SupportedOSPlatform("windows")] - private void OnFilterGridViewCellContextMenuStripNeeded (object sender, DataGridViewCellContextMenuStripNeededEventArgs e) - { - if (e.ContextMenuStrip == columnContextMenuStrip) - { - _selectedCol = e.ColumnIndex; - } - } - - [SupportedOSPlatform("windows")] - private void OnColumnContextMenuStripOpening (object sender, CancelEventArgs e) - { - var ctl = columnContextMenuStrip.SourceControl; - var gridView = ctl as BufferedDataGridView; - var frozen = false; - if (_freezeStateMap.TryGetValue(ctl, out var value)) - { - frozen = value; - } - - freezeLeftColumnsUntilHereToolStripMenuItem.Checked = frozen; - - if (frozen) - { - freezeLeftColumnsUntilHereToolStripMenuItem.Text = "Frozen"; - } - else - { - if (ctl is BufferedDataGridView) - { - freezeLeftColumnsUntilHereToolStripMenuItem.Text = $"Freeze left columns until here ({gridView.Columns[_selectedCol].HeaderText})"; - } - } - - - var col = gridView.Columns[_selectedCol]; - moveLeftToolStripMenuItem.Enabled = col != null && col.DisplayIndex > 0; - moveRightToolStripMenuItem.Enabled = col != null && col.DisplayIndex < gridView.Columns.Count - 1; - - if (gridView.Columns.Count - 1 > _selectedCol) - { - // DataGridViewColumn colRight = gridView.Columns[this.selectedCol + 1]; - var colRight = gridView.Columns.GetNextColumn(col, DataGridViewElementStates.None, DataGridViewElementStates.None); - moveRightToolStripMenuItem.Enabled = colRight != null && colRight.Frozen == col.Frozen; - } - - if (_selectedCol > 0) - { - //DataGridViewColumn colLeft = gridView.Columns[this.selectedCol - 1]; - var colLeft = gridView.Columns.GetPreviousColumn(col, DataGridViewElementStates.None, DataGridViewElementStates.None); - - moveLeftToolStripMenuItem.Enabled = colLeft != null && colLeft.Frozen == col.Frozen; - } - - var colLast = gridView.Columns[gridView.Columns.Count - 1]; - moveToLastColumnToolStripMenuItem.Enabled = colLast != null && colLast.Frozen == col.Frozen; - - // Fill context menu with column names - // - EventHandler ev = OnHandleColumnItemContextMenu; - allColumnsToolStripMenuItem.DropDownItems.Clear(); - foreach (DataGridViewColumn column in gridView.Columns) - { - if (column.HeaderText.Length > 0) - { - var item = allColumnsToolStripMenuItem.DropDownItems.Add(column.HeaderText, null, ev) as ToolStripMenuItem; - item.Tag = column; - item.Enabled = !column.Frozen; - } - } - } - - [SupportedOSPlatform("windows")] - private void OnHandleColumnItemContextMenu (object sender, EventArgs args) - { - if (sender is ToolStripItem item) - { - var column = item.Tag as DataGridViewColumn; - column.Visible = true; - column.DataGridView.FirstDisplayedScrollingColumnIndex = column.Index; - } - } - - [SupportedOSPlatform("windows")] - private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick (object sender, EventArgs e) - { - var ctl = columnContextMenuStrip.SourceControl; - var frozen = false; - - if (_freezeStateMap.TryGetValue(ctl, out var value)) - { - frozen = value; - } - - frozen = !frozen; - _freezeStateMap[ctl] = frozen; - - if (ctl is BufferedDataGridView gridView) - { - ApplyFrozenState(gridView); - } - } - - [SupportedOSPlatform("windows")] - private void OnMoveToLastColumnToolStripMenuItemClick (object sender, EventArgs e) - { - var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - var col = gridView.Columns[_selectedCol]; - if (col != null) - { - col.DisplayIndex = gridView.Columns.Count - 1; - } - } - - [SupportedOSPlatform("windows")] - private void OnMoveLeftToolStripMenuItemClick (object sender, EventArgs e) - { - var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - var col = gridView.Columns[_selectedCol]; - if (col != null && col.DisplayIndex > 0) - { - col.DisplayIndex -= 1; - } - } - - [SupportedOSPlatform("windows")] - private void OnMoveRightToolStripMenuItemClick (object sender, EventArgs e) - { - var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - var col = gridView.Columns[_selectedCol]; - if (col != null && col.DisplayIndex < gridView.Columns.Count - 1) - { - col.DisplayIndex = col.DisplayIndex + 1; - } - } - - [SupportedOSPlatform("windows")] - private void OnHideColumnToolStripMenuItemClick (object sender, EventArgs e) - { - var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - var col = gridView.Columns[_selectedCol]; - col.Visible = false; - } - - [SupportedOSPlatform("windows")] - private void OnRestoreColumnsToolStripMenuItemClick (object sender, EventArgs e) - { - var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView; - foreach (DataGridViewColumn col in gridView.Columns) - { - col.Visible = true; - } - } - - [SupportedOSPlatform("windows")] - private void OnTimeSpreadingControlLineSelected (object sender, SelectLineEventArgs e) - { - SelectLine(e.Line, false, true); - } - - [SupportedOSPlatform("windows")] - private void OnBookmarkCommentToolStripMenuItemClick (object sender, EventArgs e) - { - AddBookmarkAndEditComment(); - } - - [SupportedOSPlatform("windows")] - private void OnHighlightSelectionInLogFileToolStripMenuItemClick (object sender, EventArgs e) - { - if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) - { - var he = new HighlightEntry() - { - SearchText = ctl.SelectedText, - ForegroundColor = Color.Red, - BackgroundColor = Color.Yellow, - IsRegEx = false, - IsCaseSensitive = true, - IsLedSwitch = false, - IsSetBookmark = false, - IsActionEntry = false, - ActionEntry = null, - IsWordMatch = false - }; - - lock (_tempHighlightEntryListLock) - { - _tempHighlightEntryList.Add(he); - } - - dataGridView.CancelEdit(); - dataGridView.EndEdit(); - RefreshAllGrids(); - } - } - - [SupportedOSPlatform("windows")] - private void OnHighlightSelectionInLogFilewordModeToolStripMenuItemClick (object sender, EventArgs e) - { - if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) - { - HighlightEntry he = new() - { - SearchText = ctl.SelectedText, - ForegroundColor = Color.Red, - BackgroundColor = Color.Yellow, - IsRegEx = false, - IsCaseSensitive = true, - IsLedSwitch = false, - IsStopTail = false, - IsSetBookmark = false, - IsActionEntry = false, - ActionEntry = null, - IsWordMatch = true - }; - - lock (_tempHighlightEntryListLock) - { - _tempHighlightEntryList.Add(he); - } - - dataGridView.CancelEdit(); - dataGridView.EndEdit(); - RefreshAllGrids(); - } - } - - [SupportedOSPlatform("windows")] - private void OnEditModeCopyToolStripMenuItemClick (object sender, EventArgs e) - { - if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) - { - if (Util.IsNull(ctl.SelectedText) == false) - { - Clipboard.SetText(ctl.SelectedText); - } - } - } - - [SupportedOSPlatform("windows")] - private void OnRemoveAllToolStripMenuItemClick (object sender, EventArgs e) - { - RemoveTempHighlights(); - } - - [SupportedOSPlatform("windows")] - private void OnMakePermanentToolStripMenuItemClick (object sender, EventArgs e) - { - lock (_tempHighlightEntryListLock) - { - lock (_currentHighlightGroupLock) - { - _currentHighlightGroup.HighlightEntryList.AddRange(_tempHighlightEntryList); - RemoveTempHighlights(); - OnCurrentHighlightListChanged(); - } - } - } - - [SupportedOSPlatform("windows")] - private void OnMarkCurrentFilterRangeToolStripMenuItemClick (object sender, EventArgs e) - { - MarkCurrentFilterRange(); - } - - [SupportedOSPlatform("windows")] - private void OnFilterForSelectionToolStripMenuItemClick (object sender, EventArgs e) - { - if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) - { - splitContainerLogWindow.Panel2Collapsed = false; - ResetFilterControls(); - FilterSearch(ctl.SelectedText); - } - } - - [SupportedOSPlatform("windows")] - private void OnSetSelectedTextAsBookmarkCommentToolStripMenuItemClick (object sender, EventArgs e) - { - if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl) - { - AddBookmarkComment(ctl.SelectedText); - } - } - - private void OnDataGridViewCellClick (object sender, DataGridViewCellEventArgs e) - { - _shouldCallTimeSync = true; - } - - [SupportedOSPlatform("windows")] - private void OnDataGridViewCellDoubleClick (object sender, DataGridViewCellEventArgs e) - { - if (e.ColumnIndex == 0) - { - ToggleBookmark(); - } - } - - [SupportedOSPlatform("windows")] - private void OnDataGridViewOverlayDoubleClicked (object sender, OverlayEventArgs e) - { - BookmarkComment(e.BookmarkOverlay.Bookmark); - } - - [SupportedOSPlatform("windows")] - private void OnFilterRegexCheckBoxMouseUp (object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Right) - { - RegexHelperDialog dlg = new() - { - ExpressionHistoryList = ConfigManager.Settings.RegexHistory.ExpressionHistoryList, - TesttextHistoryList = ConfigManager.Settings.RegexHistory.TesttextHistoryList, - Owner = this, - CaseSensitive = filterCaseSensitiveCheckBox.Checked, - Pattern = filterComboBox.Text - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - ConfigManager.Settings.RegexHistory.ExpressionHistoryList = dlg.ExpressionHistoryList; - ConfigManager.Settings.RegexHistory.TesttextHistoryList = dlg.TesttextHistoryList; - - filterCaseSensitiveCheckBox.Checked = dlg.CaseSensitive; - filterComboBox.Text = dlg.Pattern; - - ConfigManager.Save(SettingsFlags.RegexHistory); - } - } - } - - #endregion - - #region Filter-Highlight - - [SupportedOSPlatform("windows")] - private void OnToggleHighlightPanelButtonClick (object sender, EventArgs e) - { - ToggleHighlightPanel(highlightSplitContainer.Panel2Collapsed); - } - - private void OnSaveFilterButtonClick (object sender, EventArgs e) - { - var newParams = _filterParams.Clone(); - newParams.Color = Color.FromKnownColor(KnownColor.Black); - ConfigManager.Settings.FilterList.Add(newParams); - OnFilterListChanged(this); - } - - [SupportedOSPlatform("windows")] - private void OnDeleteFilterButtonClick (object sender, EventArgs e) - { - var index = filterListBox.SelectedIndex; - if (index >= 0) - { - var filterParams = (FilterParams)filterListBox.Items[index]; - ConfigManager.Settings.FilterList.Remove(filterParams); - OnFilterListChanged(this); - if (filterListBox.Items.Count > 0) - { - filterListBox.SelectedIndex = filterListBox.Items.Count - 1; - } - } - } - - [SupportedOSPlatform("windows")] - private void OnFilterUpButtonClick (object sender, EventArgs e) - { - var i = filterListBox.SelectedIndex; - if (i > 0) - { - var filterParams = (FilterParams)filterListBox.Items[i]; - ConfigManager.Settings.FilterList.RemoveAt(i); - i--; - ConfigManager.Settings.FilterList.Insert(i, filterParams); - OnFilterListChanged(this); - filterListBox.SelectedIndex = i; - } - } - - [SupportedOSPlatform("windows")] - private void OnFilterDownButtonClick (object sender, EventArgs e) - { - var i = filterListBox.SelectedIndex; - if (i < 0) - { - return; - } - - if (i < filterListBox.Items.Count - 1) - { - var filterParams = (FilterParams)filterListBox.Items[i]; - ConfigManager.Settings.FilterList.RemoveAt(i); - i++; - ConfigManager.Settings.FilterList.Insert(i, filterParams); - OnFilterListChanged(this); - filterListBox.SelectedIndex = i; - } - } - - [SupportedOSPlatform("windows")] - private void OnFilterListBoxMouseDoubleClick (object sender, MouseEventArgs e) - { - if (filterListBox.SelectedIndex >= 0) - { - var filterParams = (FilterParams)filterListBox.Items[filterListBox.SelectedIndex]; - var newParams = filterParams.Clone(); - //newParams.historyList = ConfigManager.Settings.filterHistoryList; - _filterParams = newParams; - ReInitFilterParams(_filterParams); - ApplyFilterParams(); - CheckForAdvancedButtonDirty(); - CheckForFilterDirty(); - filterSearchButton.Image = _searchButtonImage; - saveFilterButton.Enabled = false; - if (hideFilterListOnLoadCheckBox.Checked) - { - ToggleHighlightPanel(false); - } - - if (filterOnLoadCheckBox.Checked) - { - FilterSearch(); - } - } - } - - [SupportedOSPlatform("windows")] - private void OnFilterListBoxDrawItem (object sender, DrawItemEventArgs e) - { - e.DrawBackground(); - if (e.Index >= 0) - { - var filterParams = (FilterParams)filterListBox.Items[e.Index]; - Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); - - Brush brush; - - if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) - { - brush = new SolidBrush(filterListBox.BackColor); - } - else - { - brush = new SolidBrush(filterParams.Color); - } - - e.Graphics.DrawString(filterParams.SearchText, e.Font, brush, - new PointF(rectangle.Left, rectangle.Top)); - e.DrawFocusRectangle(); - brush.Dispose(); - } - } - - [SupportedOSPlatform("windows")] - // Color for filter list entry - private void OnColorToolStripMenuItemClick (object sender, EventArgs e) - { - var i = filterListBox.SelectedIndex; - if (i < filterListBox.Items.Count && i >= 0) - { - var filterParams = (FilterParams)filterListBox.Items[i]; - ColorDialog dlg = new() - { - CustomColors = [filterParams.Color.ToArgb()], - Color = filterParams.Color - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - filterParams.Color = dlg.Color; - filterListBox.Refresh(); - } - } - } - - [SupportedOSPlatform("windows")] - private void OnFilterCaseSensitiveCheckBoxCheckedChanged (object sender, EventArgs e) - { - CheckForFilterDirty(); - } - - [SupportedOSPlatform("windows")] - private void OnFilterRegexCheckBoxCheckedChanged (object sender, EventArgs e) - { - fuzzyKnobControl.Enabled = !filterRegexCheckBox.Checked; - fuzzyLabel.Enabled = !filterRegexCheckBox.Checked; - CheckForFilterDirty(); - } - - [SupportedOSPlatform("windows")] - private void OnInvertFilterCheckBoxCheckedChanged (object sender, EventArgs e) - { - CheckForFilterDirty(); - } - - [SupportedOSPlatform("windows")] - private void OnFilterRangeComboBoxTextChanged (object sender, EventArgs e) - { - CheckForFilterDirty(); - } - - [SupportedOSPlatform("windows")] - private void OnFuzzyKnobControlValueChanged (object sender, EventArgs e) - { - CheckForFilterDirty(); - } - - [SupportedOSPlatform("windows")] - private void OnFilterComboBoxTextChanged (object sender, EventArgs e) - { - CheckForFilterDirty(); - } - - [SupportedOSPlatform("windows")] - private void OnSetBookmarksOnSelectedLinesToolStripMenuItemClick (object sender, EventArgs e) - { - SetBookmarksForSelectedFilterLines(); - } - - private void OnParentHighlightSettingsChanged (object sender, EventArgs e) - { - var groupName = _guiStateArgs.HighlightGroupName; - SetCurrentHighlightGroup(groupName); - } - - [SupportedOSPlatform("windows")] - private void OnFilterOnLoadCheckBoxMouseClick (object sender, MouseEventArgs e) - { - HandleChangedFilterOnLoadSetting(); - } - - [SupportedOSPlatform("windows")] - private void OnFilterOnLoadCheckBoxKeyPress (object sender, KeyPressEventArgs e) - { - HandleChangedFilterOnLoadSetting(); - } - - [SupportedOSPlatform("windows")] - private void OnHideFilterListOnLoadCheckBoxMouseClick (object sender, MouseEventArgs e) - { - HandleChangedFilterOnLoadSetting(); - } - - [SupportedOSPlatform("windows")] - private void OnFilterToTabToolStripMenuItemClick (object sender, EventArgs e) - { - FilterToTab(); - } - - private void OnTimeSyncListWindowRemoved (object sender, EventArgs e) - { - var syncList = sender as TimeSyncList; - lock (_timeSyncListLock) - { - if (syncList.Count == 0 || (syncList.Count == 1 && syncList.Contains(this))) - { - if (syncList == TimeSyncList) - { - TimeSyncList = null; - OnSyncModeChanged(); - } - } - } - } - - private void OnFreeThisWindowFromTimeSyncToolStripMenuItemClick (object sender, EventArgs e) - { - FreeFromTimeSync(); - } - - [SupportedOSPlatform("windows")] - private void OnSplitContainerSplitterMoved (object sender, SplitterEventArgs e) - { - advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; - } - - [SupportedOSPlatform("windows")] - private void OnMarkFilterHitsInLogViewToolStripMenuItemClick (object sender, EventArgs e) - { - SearchParams p = new() - { - SearchText = _filterParams.SearchText, - IsRegex = _filterParams.IsRegex, - IsCaseSensitive = _filterParams.IsCaseSensitive - }; - - AddSearchHitHighlightEntry(p); - } - - [SupportedOSPlatform("windows")] - private void OnColumnComboBoxSelectionChangeCommitted (object sender, EventArgs e) - { - SelectColumn(); - } - - [SupportedOSPlatform("windows")] - private void OnColumnComboBoxKeyDown (object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - SelectColumn(); - dataGridView.Focus(); - } - } - - [SupportedOSPlatform("windows")] - private void OnColumnComboBoxPreviewKeyDown (object sender, PreviewKeyDownEventArgs e) - { - if (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt) - { - columnComboBox.DroppedDown = true; - } - - if (e.KeyCode == Keys.Enter) - { - e.IsInputKey = true; - } - } - - [SupportedOSPlatform("windows")] - private void OnBookmarkProviderBookmarkRemoved (object sender, EventArgs e) - { - if (!_isLoading) - { - dataGridView.Refresh(); - filterGridView.Refresh(); - } - } - - [SupportedOSPlatform("windows")] - private void OnBookmarkProviderBookmarkAdded (object sender, EventArgs e) - { - if (!_isLoading) - { - dataGridView.Refresh(); - filterGridView.Refresh(); - } - } - - private void OnBookmarkProviderAllBookmarksRemoved (object sender, EventArgs e) - { - // nothing - } - - private void OnLogWindowLeave (object sender, EventArgs e) - { - InvalidateCurrentRow(); - } - - private void OnLogWindowEnter (object sender, EventArgs e) - { - InvalidateCurrentRow(); - } - - [SupportedOSPlatform("windows")] - private void OnDataGridViewRowUnshared (object sender, DataGridViewRowEventArgs e) - { - if (_logger.IsTraceEnabled) - { - _logger.Trace($"Row unshared line {e.Row.Cells[1].Value}"); - } - } - - #endregion - - #endregion - - #endregion - - [SupportedOSPlatform("windows")] - private void MeasureItem (object sender, MeasureItemEventArgs e) - { - e.ItemHeight = filterListBox.Font.Height; - } -} diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.resx b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.resx deleted file mode 100644 index 1af7de15..00000000 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs deleted file mode 100644 index cbfd9828..00000000 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs +++ /dev/null @@ -1,3820 +0,0 @@ -using System.Globalization; -using System.Runtime.Versioning; -using System.Text; -using System.Text.RegularExpressions; - -using LogExpert.Classes.Filter; -using LogExpert.Core.Callback; -using LogExpert.Core.Classes; -using LogExpert.Core.Classes.Columnizer; -using LogExpert.Core.Classes.Filter; -using LogExpert.Core.Classes.Highlight; -using LogExpert.Core.Classes.Persister; -using LogExpert.Core.Config; -using LogExpert.Core.Entities; -using LogExpert.Core.EventArguments; -using LogExpert.Dialogs; -using LogExpert.Extensions; -using LogExpert.UI.Entities; - -namespace LogExpert.UI.Controls.LogWindow; - -partial class LogWindow -{ - #region Private Methods - - [SupportedOSPlatform("windows")] - private void RegisterLogFileReaderEvents () - { - _logFileReader.LoadFile += OnLogFileReaderLoadFile; - _logFileReader.LoadingFinished += OnLogFileReaderFinishedLoading; - _logFileReader.LoadingStarted += OnLogFileReaderLoadingStarted; - _logFileReader.FileNotFound += OnLogFileReaderFileNotFound; - _logFileReader.Respawned += OnLogFileReaderRespawned; - // FileSizeChanged is not registered here because it's registered after loading has finished - } - - [SupportedOSPlatform("windows")] - private void UnRegisterLogFileReaderEvents () - { - if (_logFileReader != null) - { - _logFileReader.LoadFile -= OnLogFileReaderLoadFile; - _logFileReader.LoadingFinished -= OnLogFileReaderFinishedLoading; - _logFileReader.LoadingStarted -= OnLogFileReaderLoadingStarted; - _logFileReader.FileNotFound -= OnLogFileReaderFileNotFound; - _logFileReader.Respawned -= OnLogFileReaderRespawned; - _logFileReader.FileSizeChanged -= OnFileSizeChanged; - } - } - - [SupportedOSPlatform("windows")] - private void CreateDefaultViewStyle () - { - DataGridViewCellStyle dataGridViewCellStyleMainGrid = new(); - DataGridViewCellStyle dataGridViewCellStyleFilterGrid = new(); - - dataGridViewCellStyleMainGrid.Alignment = DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyleMainGrid.BackColor = SystemColors.Window; - dataGridViewCellStyleMainGrid.Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - dataGridViewCellStyleMainGrid.ForeColor = SystemColors.ControlText; - dataGridViewCellStyleMainGrid.SelectionBackColor = SystemColors.Highlight; - //dataGridViewCellStyleMainGrid.SelectionForeColor = SystemColors.HighlightText; - - var highlightColor = SystemColors.Highlight; - //Color is smaller than 128, means its darker - var isSelectionBackColorDark = (highlightColor.R * 0.2126) + (highlightColor.G * 0.7152) + (highlightColor.B * 0.0722) < 255 / 2; - - if (isSelectionBackColorDark) - { - dataGridViewCellStyleMainGrid.SelectionForeColor = Color.White; - } - else - { - dataGridViewCellStyleMainGrid.SelectionForeColor = Color.Black; - - } - - dataGridViewCellStyleMainGrid.WrapMode = DataGridViewTriState.False; - dataGridView.DefaultCellStyle = dataGridViewCellStyleMainGrid; - - dataGridViewCellStyleFilterGrid.Alignment = DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyleFilterGrid.BackColor = SystemColors.Window; - dataGridViewCellStyleFilterGrid.Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - dataGridViewCellStyleFilterGrid.ForeColor = SystemColors.ControlText; - dataGridViewCellStyleFilterGrid.SelectionBackColor = SystemColors.Highlight; - //dataGridViewCellStyleFilterGrid.SelectionForeColor = SystemColors.HighlightText; - - if (isSelectionBackColorDark) - { - dataGridViewCellStyleFilterGrid.SelectionForeColor = Color.White; - } - else - { - dataGridViewCellStyleFilterGrid.SelectionForeColor = Color.Black; - } - - dataGridViewCellStyleFilterGrid.WrapMode = DataGridViewTriState.False; - filterGridView.DefaultCellStyle = dataGridViewCellStyleFilterGrid; - } - - [SupportedOSPlatform("windows")] - private bool LoadPersistenceOptions () - { - if (InvokeRequired) - { - return (bool)Invoke(new BoolReturnDelegate(LoadPersistenceOptions)); - } - - if (!Preferences.SaveSessions && ForcedPersistenceFileName == null) - { - return false; - } - - try - { - var persistenceData = ForcedPersistenceFileName == null - ? Persister.LoadPersistenceDataOptionsOnly(FileName, Preferences) - : Persister.LoadPersistenceDataOptionsOnlyFromFixedFile(ForcedPersistenceFileName); - - if (persistenceData == null) - { - _logger.Info($"No persistence data for {FileName} found."); - return false; - } - - IsMultiFile = persistenceData.MultiFile; - _multiFileOptions = new MultiFileOptions - { - FormatPattern = persistenceData.MultiFilePattern, - MaxDayTry = persistenceData.MultiFileMaxDays - }; - - if (string.IsNullOrEmpty(_multiFileOptions.FormatPattern)) - { - _multiFileOptions = ObjectClone.Clone(Preferences.MultiFileOptions); - } - - splitContainerLogWindow.SplitterDistance = persistenceData.FilterPosition; - splitContainerLogWindow.Panel2Collapsed = !persistenceData.FilterVisible; - ToggleHighlightPanel(persistenceData.FilterSaveListVisible); - ShowAdvancedFilterPanel(persistenceData.FilterAdvanced); - - if (_reloadMemento == null) - { - PreselectColumnizer(persistenceData.ColumnizerName); - } - - FollowTailChanged(persistenceData.FollowTail, false); - if (persistenceData.TabName != null) - { - Text = persistenceData.TabName; - } - - AdjustHighlightSplitterWidth(); - SetCurrentHighlightGroup(persistenceData.HighlightGroupName); - - if (persistenceData.MultiFileNames.Count > 0) - { - _logger.Info(CultureInfo.InvariantCulture, "Detected MultiFile name list in persistence options"); - _fileNames = new string[persistenceData.MultiFileNames.Count]; - persistenceData.MultiFileNames.CopyTo(_fileNames); - } - else - { - _fileNames = null; - } - - //this.bookmarkWindow.ShowBookmarkCommentColumn = persistenceData.showBookmarkCommentColumn; - SetExplicitEncoding(persistenceData.Encoding); - return true; - } - catch (Exception ex) - { - _logger.Error(ex, "Error loading persistence data: "); - return false; - } - } - - [SupportedOSPlatform("windows")] - private void SetDefaultsFromPrefs () - { - filterTailCheckBox.Checked = Preferences.FilterTail; - syncFilterCheckBox.Checked = Preferences.FilterSync; - FollowTailChanged(Preferences.FollowTail, false); - _multiFileOptions = ObjectClone.Clone(Preferences.MultiFileOptions); - } - - [SupportedOSPlatform("windows")] - private void LoadPersistenceData () - { - if (InvokeRequired) - { - Invoke(new MethodInvoker(LoadPersistenceData)); - return; - } - - if (!Preferences.SaveSessions && !ForcePersistenceLoading && ForcedPersistenceFileName == null) - { - SetDefaultsFromPrefs(); - return; - } - - if (IsTempFile) - { - SetDefaultsFromPrefs(); - return; - } - - ForcePersistenceLoading = false; // force only 1 time (while session load) - - try - { - var persistenceData = ForcedPersistenceFileName == null - ? Persister.LoadPersistenceData(FileName, Preferences) - : Persister.LoadPersistenceDataFromFixedFile(ForcedPersistenceFileName); - - if (persistenceData.LineCount > _logFileReader.LineCount) - { - // outdated persistence data (logfile rollover) - // MessageBox.Show(this, "Persistence data for " + this.FileName + " is outdated. It was discarded.", "Log Expert"); - _logger.Info($"Persistence data for {FileName} is outdated. It was discarded."); - _ = LoadPersistenceOptions(); - return; - } - - _bookmarkProvider.SetBookmarks(persistenceData.BookmarkList); - _rowHeightList = persistenceData.RowHeightList; - try - { - if (persistenceData.CurrentLine >= 0 && persistenceData.CurrentLine < dataGridView.RowCount) - { - SelectLine(persistenceData.CurrentLine, false, true); - } - else - { - if (_logFileReader.LineCount > 0) - { - dataGridView.FirstDisplayedScrollingRowIndex = _logFileReader.LineCount - 1; - SelectLine(_logFileReader.LineCount - 1, false, true); - } - } - - if (persistenceData.FirstDisplayedLine >= 0 && - persistenceData.FirstDisplayedLine < dataGridView.RowCount) - { - dataGridView.FirstDisplayedScrollingRowIndex = persistenceData.FirstDisplayedLine; - } - - if (persistenceData.FollowTail) - { - FollowTailChanged(persistenceData.FollowTail, false); - } - } - catch (ArgumentOutOfRangeException) - { - // FirstDisplayedScrollingRowIndex calculates sometimes the wrong scrolling ranges??? - } - - if (Preferences.SaveFilters) - { - RestoreFilters(persistenceData); - } - } - catch (IOException ex) - { - SetDefaultsFromPrefs(); - _logger.Error(ex, "Error loading bookmarks: "); - } - } - - [SupportedOSPlatform("windows")] - private void RestoreFilters (PersistenceData persistenceData) - { - if (persistenceData.FilterParamsList.Count > 0) - { - _filterParams = persistenceData.FilterParamsList[0]; - ReInitFilterParams(_filterParams); - } - - ApplyFilterParams(); // re-loaded filter settingss - BeginInvoke(new MethodInvoker(FilterSearch)); - try - { - splitContainerLogWindow.SplitterDistance = persistenceData.FilterPosition; - splitContainerLogWindow.Panel2Collapsed = !persistenceData.FilterVisible; - } - catch (InvalidOperationException e) - { - _logger.Error(e, "Error setting splitter distance: "); - } - - ShowAdvancedFilterPanel(persistenceData.FilterAdvanced); - if (_filterPipeList.Count == 0) // don't restore if it's only a reload - { - RestoreFilterTabs(persistenceData); - } - } - - private void RestoreFilterTabs (PersistenceData persistenceData) - { - foreach (var data in persistenceData.FilterTabDataList) - { - var persistFilterParams = data.FilterParams; - ReInitFilterParams(persistFilterParams); - List filterResultList = []; - //List lastFilterResultList = new List(); - List filterHitList = []; - Filter(persistFilterParams, filterResultList, _lastFilterLinesList, filterHitList); - FilterPipe pipe = new(persistFilterParams.Clone(), this); - WritePipeToTab(pipe, filterResultList, data.PersistenceData.TabName, data.PersistenceData); - } - } - - private void ReInitFilterParams (FilterParams filterParams) - { - filterParams.SearchText = filterParams.SearchText; // init "lowerSearchText" - filterParams.RangeSearchText = filterParams.RangeSearchText; // init "lowerRangesearchText" - filterParams.CurrentColumnizer = CurrentColumnizer; - if (filterParams.IsRegex) - { - try - { - filterParams.CreateRegex(); - } - catch (ArgumentException) - { - StatusLineError("Invalid regular expression"); - } - } - } - - private void EnterLoadFileStatus () - { - _logger.Debug(CultureInfo.InvariantCulture, "EnterLoadFileStatus begin"); - - if (InvokeRequired) - { - Invoke(new MethodInvoker(EnterLoadFileStatus)); - return; - } - - _statusEventArgs.StatusText = "Loading file..."; - _statusEventArgs.LineCount = 0; - _statusEventArgs.FileSize = 0; - SendStatusLineUpdate(); - - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = 0; - _progressEventArgs.Value = 0; - _progressEventArgs.Visible = true; - SendProgressBarUpdate(); - - _isLoading = true; - _shouldCancel = true; - ClearFilterList(); - ClearBookmarkList(); - dataGridView.ClearSelection(); - dataGridView.RowCount = 0; - _logger.Debug(CultureInfo.InvariantCulture, "EnterLoadFileStatus end"); - } - - [SupportedOSPlatform("windows")] - private void PositionAfterReload (ReloadMemento reloadMemento) - { - if (_reloadMemento.CurrentLine < dataGridView.RowCount && _reloadMemento.CurrentLine >= 0) - { - dataGridView.CurrentCell = dataGridView.Rows[_reloadMemento.CurrentLine].Cells[0]; - } - - if (_reloadMemento.FirstDisplayedLine < dataGridView.RowCount && _reloadMemento.FirstDisplayedLine >= 0) - { - dataGridView.FirstDisplayedScrollingRowIndex = _reloadMemento.FirstDisplayedLine; - } - } - - [SupportedOSPlatform("windows")] - private void LogfileDead () - { - _logger.Info(CultureInfo.InvariantCulture, "File not found."); - _isDeadFile = true; - - //this.logFileReader.FileSizeChanged -= this.FileSizeChangedHandler; - //if (this.logFileReader != null) - // this.logFileReader.stopMonitoring(); - - dataGridView.Enabled = false; - dataGridView.RowCount = 0; - _progressEventArgs.Visible = false; - _progressEventArgs.Value = _progressEventArgs.MaxValue; - SendProgressBarUpdate(); - _statusEventArgs.FileSize = 0; - _statusEventArgs.LineCount = 0; - _statusEventArgs.CurrentLineNum = 0; - SendStatusLineUpdate(); - _shouldCancel = true; - ClearFilterList(); - ClearBookmarkList(); - - StatusLineText("File not found"); - OnFileNotFound(EventArgs.Empty); - } - - [SupportedOSPlatform("windows")] - private void LogfileRespawned () - { - _logger.Info(CultureInfo.InvariantCulture, "LogfileDead(): Reloading file because it has been respawned."); - _isDeadFile = false; - dataGridView.Enabled = true; - StatusLineText(""); - OnFileRespawned(EventArgs.Empty); - Reload(); - } - - [SupportedOSPlatform("windows")] - private void SetGuiAfterLoading () - { - if (Text.Length == 0) - { - Text = IsTempFile - ? TempTitleName - : Util.GetNameFromPath(FileName); - } - - ShowBookmarkBubbles = Preferences.ShowBubbles; - //if (this.forcedColumnizer == null) - { - ILogLineColumnizer columnizer; - if (_forcedColumnizerForLoading != null) - { - columnizer = _forcedColumnizerForLoading; - _forcedColumnizerForLoading = null; - } - else - { - columnizer = FindColumnizer(); - if (columnizer != null) - { - if (_reloadMemento == null) - { - //TODO this needs to be refactored - var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - - columnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); - } - } - else - { - //TODO this needs to be refactored - var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - - // Default Columnizers - columnizer = ColumnizerPicker.CloneColumnizer(ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers), directory); - } - } - - Invoke(new SetColumnizerFx(SetColumnizer), columnizer); - } - - dataGridView.Enabled = true; - DisplayCurrentFileOnStatusline(); - //this.guiStateArgs.FollowTail = this.Preferences.followTail; - _guiStateArgs.MultiFileEnabled = !IsTempFile; - _guiStateArgs.MenuEnabled = true; - _guiStateArgs.CurrentEncoding = _logFileReader.CurrentEncoding; - SendGuiStateUpdate(); - //if (this.dataGridView.RowCount > 0) - // SelectLine(this.dataGridView.RowCount - 1); - //if (this.dataGridView.Columns.Count > 1) - //{ - // this.dataGridView.Columns[this.dataGridView.Columns.Count-1].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; - // this.dataGridView.Columns[this.dataGridView.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; - // AdjustMinimumGridWith(); - //} - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - if (Preferences.TimestampControl) - { - SetTimestampLimits(); - SyncTimestampDisplay(); - } - - var settings = ConfigManager.Settings; - ShowLineColumn(!settings.HideLineColumn); - } - - ShowTimeSpread(Preferences.ShowTimeSpread && CurrentColumnizer.IsTimeshiftImplemented()); - locateLineInOriginalFileToolStripMenuItem.Enabled = FilterPipe != null; - } - - private ILogLineColumnizer FindColumnizer () - { - var columnizer = Preferences.MaskPrio - ? _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)) ?? _parentLogTabWin.GetColumnizerHistoryEntry(FileName) - : _parentLogTabWin.GetColumnizerHistoryEntry(FileName) ?? _parentLogTabWin.FindColumnizerByFileMask(Util.GetNameFromPath(FileName)); - - return columnizer; - } - - private void ReloadNewFile () - { - // prevent "overloads". May occur on very fast rollovers (next rollover before the file is reloaded) - lock (_reloadLock) - { - _reloadOverloadCounter++; - _logger.Info($"ReloadNewFile(): counter = {_reloadOverloadCounter}"); - if (_reloadOverloadCounter <= 1) - { - SavePersistenceData(false); - _loadingFinishedEvent.Reset(); - _externaLoadingFinishedEvent.Reset(); - Thread reloadFinishedThread = new(ReloadFinishedThreadFx) - { - IsBackground = true - }; - reloadFinishedThread.Start(); - LoadFile(FileName, EncodingOptions); - - ClearBookmarkList(); - SavePersistenceData(false); - - //if (this.filterTailCheckBox.Checked) - //{ - // _logger.logDebug("Waiting for loading to be complete."); - // loadingFinishedEvent.WaitOne(); - // _logger.logDebug("Refreshing filter view because of reload."); - // FilterSearch(); - //} - //LoadFilterPipes(); - } - else - { - _logger.Debug(CultureInfo.InvariantCulture, "Preventing reload because of recursive calls."); - } - - _reloadOverloadCounter--; - } - } - - [SupportedOSPlatform("windows")] - private void ReloadFinishedThreadFx () - { - _logger.Info(CultureInfo.InvariantCulture, "Waiting for loading to be complete."); - _loadingFinishedEvent.WaitOne(); - _logger.Info(CultureInfo.InvariantCulture, "Refreshing filter view because of reload."); - Invoke(new MethodInvoker(FilterSearch)); - LoadFilterPipes(); - } - - private void UpdateProgress (LoadFileEventArgs e) - { - try - { - if (e.ReadPos >= e.FileSize) - { - //_logger.Warn(CultureInfo.InvariantCulture, "UpdateProgress(): ReadPos (" + e.ReadPos + ") is greater than file size (" + e.FileSize + "). Aborting Update"); - return; - } - - _statusEventArgs.FileSize = e.ReadPos; - //this.progressEventArgs.Visible = true; - _progressEventArgs.MaxValue = (int)e.FileSize; - _progressEventArgs.Value = (int)e.ReadPos; - SendProgressBarUpdate(); - SendStatusLineUpdate(); - } - catch (Exception ex) - { - _logger.Error(ex, "UpdateProgress(): "); - } - } - - private void LoadingStarted (LoadFileEventArgs e) - { - try - { - _statusEventArgs.FileSize = e.ReadPos; - _statusEventArgs.StatusText = "Loading " + Util.GetNameFromPath(e.FileName); - _progressEventArgs.Visible = true; - _progressEventArgs.MaxValue = (int)e.FileSize; - _progressEventArgs.Value = (int)e.ReadPos; - SendProgressBarUpdate(); - SendStatusLineUpdate(); - } - catch (Exception ex) - { - _logger.Error(ex, "LoadingStarted(): "); - } - } - - private void LoadingFinished () - { - _logger.Info(CultureInfo.InvariantCulture, "File loading complete."); - - StatusLineText(""); - _logFileReader.FileSizeChanged += OnFileSizeChanged; - _isLoading = false; - _shouldCancel = false; - dataGridView.SuspendLayout(); - dataGridView.RowCount = _logFileReader.LineCount; - dataGridView.CurrentCellChanged += OnDataGridViewCurrentCellChanged; - dataGridView.Enabled = true; - dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - dataGridView.ResumeLayout(); - _progressEventArgs.Visible = false; - _progressEventArgs.Value = _progressEventArgs.MaxValue; - SendProgressBarUpdate(); - //if (this.logFileReader.LineCount > 0) - //{ - // this.dataGridView.FirstDisplayedScrollingRowIndex = this.logFileReader.LineCount - 1; - // SelectLine(this.logFileReader.LineCount - 1); - //} - _guiStateArgs.FollowTail = true; - SendGuiStateUpdate(); - _statusEventArgs.LineCount = _logFileReader.LineCount; - _statusEventArgs.FileSize = _logFileReader.FileSize; - SendStatusLineUpdate(); - - var setLastColumnWidth = _parentLogTabWin.Preferences.SetLastColumnWidth; - var lastColumnWidth = _parentLogTabWin.Preferences.LastColumnWidth; - var fontName = _parentLogTabWin.Preferences.FontName; - var fontSize = _parentLogTabWin.Preferences.FontSize; - - PreferencesChanged(fontName, fontSize, setLastColumnWidth, lastColumnWidth, true, SettingsFlags.All); - //LoadPersistenceData(); - } - - private void LogEventWorker () - { - Thread.CurrentThread.Name = "LogEventWorker"; - while (true) - { - _logger.Debug(CultureInfo.InvariantCulture, "Waiting for signal"); - _logEventArgsEvent.WaitOne(); - _logger.Debug(CultureInfo.InvariantCulture, "Wakeup signal received."); - while (true) - { - LogEventArgs e; - var lastLineCount = 0; - lock (_logEventArgsList) - { - _logger.Info(CultureInfo.InvariantCulture, "{0} events in queue", _logEventArgsList.Count); - if (_logEventArgsList.Count == 0) - { - _logEventArgsEvent.Reset(); - break; - } - - e = _logEventArgsList[0]; - _logEventArgsList.RemoveAt(0); - } - - if (e.IsRollover) - { - ShiftBookmarks(e.RolloverOffset); - ShiftRowHeightList(e.RolloverOffset); - ShiftFilterPipes(e.RolloverOffset); - lastLineCount = 0; - } - else - { - if (e.LineCount < lastLineCount) - { - _logger.Error("Line count of event is: {0}, should be greater than last line count: {1}", e.LineCount, lastLineCount); - } - } - - Invoke(UpdateGrid, [e]); - CheckFilterAndHighlight(e); - _timeSpreadCalc.SetLineCount(e.LineCount); - } - } - } - - private void StopLogEventWorkerThread () - { - _logEventArgsEvent.Set(); - cts.Cancel(); - //_logEventHandlerThread.Abort(); - //_logEventHandlerThread.Join(); - } - - private void OnFileSizeChanged (LogEventArgs e) - { - FileSizeChanged?.Invoke(this, e); - } - - private void UpdateGrid (LogEventArgs e) - { - var oldRowCount = dataGridView.RowCount; - var firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex; - - if (dataGridView.CurrentCellAddress.Y >= e.LineCount) - { - //this.dataGridView.Rows[this.dataGridView.CurrentCellAddress.Y].Selected = false; - //this.dataGridView.CurrentCell = this.dataGridView.Rows[0].Cells[0]; - } - - try - { - if (dataGridView.RowCount > e.LineCount) - { - var currentLineNum = dataGridView.CurrentCellAddress.Y; - dataGridView.RowCount = 0; - dataGridView.RowCount = e.LineCount; - if (_guiStateArgs.FollowTail == false) - { - if (currentLineNum >= dataGridView.RowCount) - { - currentLineNum = dataGridView.RowCount - 1; - } - - dataGridView.CurrentCell = dataGridView.Rows[currentLineNum].Cells[0]; - } - } - else - { - dataGridView.RowCount = e.LineCount; - } - - _logger.Debug(CultureInfo.InvariantCulture, "UpdateGrid(): new RowCount={0}", dataGridView.RowCount); - - if (e.IsRollover) - { - // Multifile rollover - // keep selection and view range, if no follow tail mode - if (!_guiStateArgs.FollowTail) - { - var currentLineNum = dataGridView.CurrentCellAddress.Y; - currentLineNum -= e.RolloverOffset; - if (currentLineNum < 0) - { - currentLineNum = 0; - } - - _logger.Debug(CultureInfo.InvariantCulture, "UpdateGrid(): Rollover=true, Rollover offset={0}, currLineNum was {1}, new currLineNum={2}", e.RolloverOffset, dataGridView.CurrentCellAddress.Y, currentLineNum); - firstDisplayedLine -= e.RolloverOffset; - if (firstDisplayedLine < 0) - { - firstDisplayedLine = 0; - } - - dataGridView.FirstDisplayedScrollingRowIndex = firstDisplayedLine; - dataGridView.CurrentCell = dataGridView.Rows[currentLineNum].Cells[0]; - dataGridView.Rows[currentLineNum].Selected = true; - } - } - - _statusEventArgs.LineCount = e.LineCount; - StatusLineFileSize(e.FileSize); - - if (!_isLoading) - { - if (oldRowCount == 0) - { - AdjustMinimumGridWith(); - } - - //CheckFilterAndHighlight(e); - } - - if (_guiStateArgs.FollowTail && dataGridView.RowCount > 0) - { - dataGridView.FirstDisplayedScrollingRowIndex = dataGridView.RowCount - 1; - OnTailFollowed(EventArgs.Empty); - } - - if (Preferences.TimestampControl && !_isLoading) - { - SetTimestampLimits(); - } - } - catch (Exception ex) - { - _logger.Error(ex, "Fehler bei UpdateGrid(): "); - } - - //this.dataGridView.Refresh(); - //this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - } - - private void CheckFilterAndHighlight (LogEventArgs e) - { - var noLed = true; - bool suppressLed; - bool setBookmark; - bool stopTail; - string bookmarkComment; - - if (filterTailCheckBox.Checked || _filterPipeList.Count > 0) - { - var filterStart = e.PrevLineCount; - if (e.IsRollover) - { - ShiftFilterLines(e.RolloverOffset); - filterStart -= e.RolloverOffset; - } - - var firstStopTail = true; - ColumnizerCallback callback = new(this); - var filterLineAdded = false; - for (var i = filterStart; i < e.LineCount; ++i) - { - var line = _logFileReader.GetLogLine(i); - if (line == null) - { - return; - } - - if (filterTailCheckBox.Checked) - { - callback.SetLineNum(i); - if (Util.TestFilterCondition(_filterParams, line, callback)) - { - //AddFilterLineFx addFx = new AddFilterLineFx(AddFilterLine); - //this.Invoke(addFx, new object[] { i, true }); - filterLineAdded = true; - AddFilterLine(i, false, _filterParams, _filterResultList, _lastFilterLinesList, - _filterHitList); - } - } - - //ProcessFilterPipeFx pipeFx = new ProcessFilterPipeFx(ProcessFilterPipes); - //pipeFx.BeginInvoke(i, null, null); - ProcessFilterPipes(i); - - var matchingList = FindMatchingHilightEntries(line); - LaunchHighlightPlugins(matchingList, i); - GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, out bookmarkComment); - if (setBookmark) - { - SetBookmarkFx fx = SetBookmarkFromTrigger; - fx.BeginInvoke(i, bookmarkComment, null, null); - } - - if (stopTail && _guiStateArgs.FollowTail) - { - var wasFollow = _guiStateArgs.FollowTail; - FollowTailChanged(false, true); - if (firstStopTail && wasFollow) - { - Invoke(new SelectLineFx(SelectAndEnsureVisible), [i, false]); - firstStopTail = false; - } - } - - if (!suppressLed) - { - noLed = false; - } - } - - if (filterLineAdded) - { - //AddFilterLineGuiUpdateFx addFx = new AddFilterLineGuiUpdateFx(AddFilterLineGuiUpdate); - //this.Invoke(addFx); - TriggerFilterLineGuiUpdate(); - } - } - else - { - var firstStopTail = true; - var startLine = e.PrevLineCount; - if (e.IsRollover) - { - ShiftFilterLines(e.RolloverOffset); - startLine -= e.RolloverOffset; - } - - for (var i = startLine; i < e.LineCount; ++i) - { - var line = _logFileReader.GetLogLine(i); - if (line != null) - { - var matchingList = FindMatchingHilightEntries(line); - LaunchHighlightPlugins(matchingList, i); - GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, - out bookmarkComment); - if (setBookmark) - { - SetBookmarkFx fx = SetBookmarkFromTrigger; - fx.BeginInvoke(i, bookmarkComment, null, null); - } - - if (stopTail && _guiStateArgs.FollowTail) - { - var wasFollow = _guiStateArgs.FollowTail; - FollowTailChanged(false, true); - if (firstStopTail && wasFollow) - { - Invoke(new SelectLineFx(SelectAndEnsureVisible), [i, false]); - firstStopTail = false; - } - } - - if (!suppressLed) - { - noLed = false; - } - } - } - } - - if (!noLed) - { - OnFileSizeChanged(e); - } - } - - private void LaunchHighlightPlugins (IList matchingList, int lineNum) - { - LogExpertCallback callback = new(this) - { - LineNum = lineNum - }; - - foreach (var entry in matchingList) - { - if (entry.IsActionEntry && entry.ActionEntry.PluginName != null) - { - var plugin = PluginRegistry.PluginRegistry.Instance.FindKeywordActionPluginByName(entry.ActionEntry.PluginName); - if (plugin != null) - { - ActionPluginExecuteFx fx = plugin.Execute; - fx.BeginInvoke(entry.SearchText, entry.ActionEntry.ActionParam, callback, CurrentColumnizer, null, null); - } - } - } - } - - private void PreSelectColumnizer (ILogLineColumnizer columnizer) - { - CurrentColumnizer = columnizer != null - ? (_forcedColumnizerForLoading = columnizer) - : (_forcedColumnizerForLoading = ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers)); - } - - private void SetColumnizer (ILogLineColumnizer columnizer) - { - columnizer = ColumnizerPicker.FindReplacementForAutoColumnizer(FileName, _logFileReader, columnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - - var timeDiff = 0; - if (CurrentColumnizer != null && CurrentColumnizer.IsTimeshiftImplemented()) - { - timeDiff = CurrentColumnizer.GetTimeOffset(); - } - - SetColumnizerInternal(columnizer); - - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - CurrentColumnizer.SetTimeOffset(timeDiff); - } - } - - private void SetColumnizerInternal (ILogLineColumnizer columnizer) - { - _logger.Info(CultureInfo.InvariantCulture, "SetColumnizerInternal(): {0}", columnizer.GetName()); - - var oldColumnizer = CurrentColumnizer; - var oldColumnizerIsXmlType = CurrentColumnizer is ILogLineXmlColumnizer; - var oldColumnizerIsPreProcess = CurrentColumnizer is IPreProcessColumnizer; - var mustReload = false; - - // Check if the filtered columns disappeared, if so must refresh the UI - if (_filterParams.ColumnRestrict) - { - var newColumns = columnizer != null ? columnizer.GetColumnNames() : Array.Empty(); - var colChanged = false; - - if (dataGridView.ColumnCount - 2 == newColumns.Length) // two first columns are 'marker' and 'line number' - { - for (var i = 0; i < newColumns.Length; i++) - { - if (dataGridView.Columns[i].HeaderText != newColumns[i]) - { - colChanged = true; - break; // one change is sufficient - } - } - } - else - { - colChanged = true; - } - - if (colChanged) - { - // Update UI - columnNamesLabel.Text = CalculateColumnNames(_filterParams); - } - } - - var oldColType = _filterParams.CurrentColumnizer?.GetType(); - var newColType = columnizer?.GetType(); - - if (oldColType != newColType && _filterParams.ColumnRestrict && _filterParams.IsFilterTail) - { - _filterParams.ColumnList.Clear(); - } - - if (CurrentColumnizer == null || CurrentColumnizer.GetType() != columnizer.GetType()) - { - CurrentColumnizer = columnizer; - _freezeStateMap.Clear(); - if (_logFileReader != null) - { - if (CurrentColumnizer is IPreProcessColumnizer) - { - _logFileReader.PreProcessColumnizer = (IPreProcessColumnizer)CurrentColumnizer; - } - else - { - _logFileReader.PreProcessColumnizer = null; - } - } - - // always reload when choosing XML columnizers - if (_logFileReader != null && CurrentColumnizer is ILogLineXmlColumnizer) - { - //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() - mustReload = true; - } - - // Reload when choosing no XML columnizer but previous columnizer was XML - if (_logFileReader != null && !(CurrentColumnizer is ILogLineXmlColumnizer) && oldColumnizerIsXmlType) - { - _logFileReader.IsXmlMode = false; - //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() - mustReload = true; - } - - // Reload when previous columnizer was PreProcess and current is not, and vice versa. - // When the current columnizer is a preProcess columnizer, reload in every case. - if (CurrentColumnizer is IPreProcessColumnizer != oldColumnizerIsPreProcess || - CurrentColumnizer is IPreProcessColumnizer) - { - //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() - mustReload = true; - } - } - else - { - CurrentColumnizer = columnizer; - } - - (oldColumnizer as IInitColumnizer)?.DeSelected(new ColumnizerCallback(this)); - - (columnizer as IInitColumnizer)?.Selected(new ColumnizerCallback(this)); - - SetColumnizer(columnizer, dataGridView); - SetColumnizer(columnizer, filterGridView); - _patternWindow?.SetColumnizer(columnizer); - - _guiStateArgs.TimeshiftPossible = columnizer.IsTimeshiftImplemented(); - SendGuiStateUpdate(); - - if (_logFileReader != null) - { - dataGridView.RowCount = _logFileReader.LineCount; - } - - if (_filterResultList != null) - { - filterGridView.RowCount = _filterResultList.Count; - } - - if (mustReload) - { - Reload(); - } - else - { - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - SetTimestampLimits(); - SyncTimestampDisplay(); - } - - var settings = ConfigManager.Settings; - ShowLineColumn(!settings.HideLineColumn); - ShowTimeSpread(Preferences.ShowTimeSpread && columnizer.IsTimeshiftImplemented()); - } - - if (!columnizer.IsTimeshiftImplemented() && IsTimeSynced) - { - FreeFromTimeSync(); - } - - columnComboBox.Items.Clear(); - - foreach (var columnName in columnizer.GetColumnNames()) - { - columnComboBox.Items.Add(columnName); - } - - columnComboBox.SelectedIndex = 0; - - OnColumnizerChanged(CurrentColumnizer); - } - - private void AutoResizeColumns (BufferedDataGridView gridView) - { - try - { - gridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - if (gridView.Columns.Count > 1 && Preferences.SetLastColumnWidth && - gridView.Columns[gridView.Columns.Count - 1].Width < Preferences.LastColumnWidth - ) - { - // It seems that using 'MinimumWidth' instead of 'Width' prevents the DataGridView's NullReferenceExceptions - //gridView.Columns[gridView.Columns.Count - 1].Width = this.Preferences.lastColumnWidth; - gridView.Columns[gridView.Columns.Count - 1].MinimumWidth = Preferences.LastColumnWidth; - } - } - catch (NullReferenceException e) - { - // See https://connect.microsoft.com/VisualStudio/feedback/details/366943/autoresizecolumns-in-datagridview-throws-nullreferenceexception - // possible solution => https://stackoverflow.com/questions/36287553/nullreferenceexception-when-trying-to-set-datagridview-column-width-brings-th - // There are some rare situations with null ref exceptions when resizing columns and on filter finished - // So catch them here. Better than crashing. - _logger.Error(e, "Error while resizing columns: "); - } - } - - private void PaintCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) - { - PaintHighlightedCell(e, gridView, noBackgroundFill, groundEntry); - } - - private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) - { - var column = e.Value as IColumn; - - column ??= Column.EmptyColumn; - - var matchList = FindHighlightMatches(column); - // too many entries per line seem to cause problems with the GDI - while (matchList.Count > 50) - { - matchList.RemoveAt(50); - } - - var he = new HighlightEntry - { - SearchText = column.DisplayValue, - ForegroundColor = groundEntry?.ForegroundColor ?? Color.FromKnownColor(KnownColor.Black), - BackgroundColor = groundEntry?.BackgroundColor ?? Color.Empty, - IsWordMatch = true - }; - - HighlightMatchEntry hme = new() - { - StartPos = 0, - Length = column.DisplayValue.Length, - HighlightEntry = he - }; - - if (groundEntry != null) - { - hme.HighlightEntry.IsBold = groundEntry.IsBold; - } - - matchList = MergeHighlightMatchEntries(matchList, hme); - - //var leftPad = e.CellStyle.Padding.Left; - //RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, e.CellBounds.Height); - - var borderWidths = PaintHelper.BorderWidths(e.AdvancedBorderStyle); - var valBounds = e.CellBounds; - valBounds.Offset(borderWidths.X, borderWidths.Y); - valBounds.Width -= borderWidths.Right; - valBounds.Height -= borderWidths.Bottom; - if (e.CellStyle.Padding != Padding.Empty) - { - valBounds.Offset(e.CellStyle.Padding.Left, e.CellStyle.Padding.Top); - valBounds.Width -= e.CellStyle.Padding.Horizontal; - valBounds.Height -= e.CellStyle.Padding.Vertical; - } - - var flags = - TextFormatFlags.Left - | TextFormatFlags.SingleLine - | TextFormatFlags.NoPrefix - | TextFormatFlags.PreserveGraphicsClipping - | TextFormatFlags.NoPadding - | TextFormatFlags.VerticalCenter - | TextFormatFlags.TextBoxControl - ; - - // | TextFormatFlags.VerticalCenter - // | TextFormatFlags.TextBoxControl - // TextFormatFlags.SingleLine - - //TextRenderer.DrawText(e.Graphics, e.Value as String, e.CellStyle.Font, valBounds, Color.FromKnownColor(KnownColor.Black), flags); - - var wordPos = valBounds.Location; - Size proposedSize = new(valBounds.Width, valBounds.Height); - - var r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); - e.Graphics.SetClip(e.CellBounds); - - foreach (var matchEntry in matchList) - { - var font = matchEntry != null && matchEntry.HighlightEntry.IsBold ? BoldFont : NormalFont; - - Brush bgBrush = matchEntry.HighlightEntry.BackgroundColor != Color.Empty - ? new SolidBrush(matchEntry.HighlightEntry.BackgroundColor) - : null; - - var matchWord = column.DisplayValue.Substring(matchEntry.StartPos, matchEntry.Length); - var wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags); - wordSize.Height = e.CellBounds.Height; - Rectangle wordRect = new(wordPos, wordSize); - - var foreColor = matchEntry.HighlightEntry.ForegroundColor; - if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected) - { - if (!noBackgroundFill && bgBrush != null && !matchEntry.HighlightEntry.NoBackground) - { - e.Graphics.FillRectangle(bgBrush, wordRect); - } - } - - TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, foreColor, flags); - - wordPos.Offset(wordSize.Width, 0); - bgBrush?.Dispose(); - } - } - - /// - /// Builds a list of HilightMatchEntry objects. A HilightMatchEntry spans over a region that is painted with the same foreground and - /// background colors. - /// All regions which don't match a word-mode entry will be painted with the colors of a default entry (groundEntry). This is either the - /// first matching non-word-mode highlight entry or a black-on-white default (if no matching entry was found). - /// - /// List of all highlight matches for the current cell - /// The entry that is used as the default. - /// List of HighlightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring. - private IList MergeHighlightMatchEntries (IList matchList, HighlightMatchEntry groundEntry) - { - // Fill an area with lenth of whole text with a default hilight entry - var entryArray = new HighlightEntry[groundEntry.Length]; - for (var i = 0; i < entryArray.Length; ++i) - { - entryArray[i] = groundEntry.HighlightEntry; - } - - // "overpaint" with all matching word match enries - // Non-word-mode matches will not overpaint because they use the groundEntry - foreach (var me in matchList) - { - var endPos = me.StartPos + me.Length; - for (var i = me.StartPos; i < endPos; ++i) - { - if (me.HighlightEntry.IsWordMatch) - { - entryArray[i] = me.HighlightEntry; - } - else - { - //entryArray[i].ForegroundColor = me.HilightEntry.ForegroundColor; - } - } - } - - // collect areas with same hilight entry and build new highlight match entries for it - IList mergedList = []; - - if (entryArray.Length > 0) - { - var currentEntry = entryArray[0]; - var lastStartPos = 0; - var pos = 0; - - for (; pos < entryArray.Length; ++pos) - { - if (entryArray[pos] != currentEntry) - { - HighlightMatchEntry me = new() - { - StartPos = lastStartPos, - Length = pos - lastStartPos, - HighlightEntry = currentEntry - }; - - mergedList.Add(me); - currentEntry = entryArray[pos]; - lastStartPos = pos; - } - } - - HighlightMatchEntry me2 = new() - { - StartPos = lastStartPos, - Length = pos - lastStartPos, - HighlightEntry = currentEntry - }; - - mergedList.Add(me2); - } - - return mergedList; - } - - /// - /// Returns the first HilightEntry that matches the given line - /// - private HighlightEntry FindHilightEntry (ITextValue line) - { - return FindHighlightEntry(line, false); - } - - private HighlightEntry FindFirstNoWordMatchHilightEntry (ITextValue line) - { - return FindHighlightEntry(line, true); - } - - private bool CheckHighlightEntryMatch (HighlightEntry entry, ITextValue column) - { - if (entry.IsRegEx) - { - //Regex rex = new Regex(entry.SearchText, entry.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); - if (entry.Regex.IsMatch(column.Text)) - { - return true; - } - } - else - { - if (entry.IsCaseSensitive) - { - if (column.Text.Contains(entry.SearchText, StringComparison.Ordinal)) - { - return true; - } - } - else - { - if (column.Text.ToUpperInvariant().Contains(entry.SearchText.ToUpperInvariant(), StringComparison.OrdinalIgnoreCase)) - { - return true; - } - } - } - - return false; - } - - /// - /// Returns all HilightEntry entries which matches the given line - /// - private IList FindMatchingHilightEntries (ITextValue line) - { - IList resultList = []; - if (line != null) - { - lock (_currentHighlightGroupLock) - { - foreach (var entry in _currentHighlightGroup.HighlightEntryList) - { - if (CheckHighlightEntryMatch(entry, line)) - { - resultList.Add(entry); - } - } - } - } - - return resultList; - } - - private void GetHighlightEntryMatches (ITextValue line, IList hilightEntryList, IList resultList) - { - foreach (var entry in hilightEntryList) - { - if (entry.IsWordMatch) - { - var matches = entry.Regex.Matches(line.Text); - foreach (Match match in matches) - { - HighlightMatchEntry me = new() - { - HighlightEntry = entry, - StartPos = match.Index, - Length = match.Length - }; - - resultList.Add(me); - } - } - else - { - if (CheckHighlightEntryMatch(entry, line)) - { - HighlightMatchEntry me = new() - { - HighlightEntry = entry, - StartPos = 0, - Length = line.Text.Length - }; - - resultList.Add(me); - } - } - } - } - - private void GetHilightActions (IList matchingList, out bool noLed, out bool stopTail, out bool setBookmark, out string bookmarkComment) - { - noLed = stopTail = setBookmark = false; - bookmarkComment = string.Empty; - - foreach (var entry in matchingList) - { - if (entry.IsLedSwitch) - { - noLed = true; - } - - if (entry.IsSetBookmark) - { - setBookmark = true; - if (!string.IsNullOrEmpty(entry.BookmarkComment)) - { - bookmarkComment += entry.BookmarkComment + "\r\n"; - } - } - - if (entry.IsStopTail) - { - stopTail = true; - } - } - - bookmarkComment = bookmarkComment.TrimEnd(['\r', '\n']); - } - - private void StopTimespreadThread () - { - _timeSpreadCalc.Stop(); - } - - private void StopTimestampSyncThread () - { - _shouldTimestampDisplaySyncingCancel = true; - //_timeShiftSyncWakeupEvent.Set(); - //_timeShiftSyncThread.Abort(); - //_timeShiftSyncThread.Join(); - cts.Cancel(); - } - - [SupportedOSPlatform("windows")] - private void SyncTimestampDisplay () - { - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - if (dataGridView.CurrentRow != null) - { - SyncTimestampDisplay(dataGridView.CurrentRow.Index); - } - } - } - - [SupportedOSPlatform("windows")] - private void SyncTimestampDisplay (int lineNum) - { - _timeShiftSyncLine = lineNum; - _timeShiftSyncTimerEvent.Set(); - _timeShiftSyncWakeupEvent.Set(); - } - - [SupportedOSPlatform("windows")] - private void SyncTimestampDisplayWorker () - { - const int WAIT_TIME = 500; - Thread.CurrentThread.Name = "SyncTimestampDisplayWorker"; - _shouldTimestampDisplaySyncingCancel = false; - _isTimestampDisplaySyncing = true; - - while (!_shouldTimestampDisplaySyncingCancel) - { - _timeShiftSyncWakeupEvent.WaitOne(); - if (_shouldTimestampDisplaySyncingCancel) - { - return; - } - - _timeShiftSyncWakeupEvent.Reset(); - - while (!_shouldTimestampDisplaySyncingCancel) - { - var signaled = _timeShiftSyncTimerEvent.WaitOne(WAIT_TIME, true); - _timeShiftSyncTimerEvent.Reset(); - if (!signaled) - { - break; - } - } - - // timeout with no new Trigger -> update display - var lineNum = _timeShiftSyncLine; - if (lineNum >= 0 && lineNum < dataGridView.RowCount) - { - var refLine = lineNum; - var timeStamp = GetTimestampForLine(ref refLine, true); - if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel) - { - _guiStateArgs.Timestamp = timeStamp; - SendGuiStateUpdate(); - if (_shouldCallTimeSync) - { - refLine = lineNum; - var exactTimeStamp = GetTimestampForLine(ref refLine, false); - SyncOtherWindows(exactTimeStamp); - _shouldCallTimeSync = false; - } - } - } - - // show time difference between 2 selected lines - if (dataGridView.SelectedRows.Count == 2) - { - var row1 = dataGridView.SelectedRows[0].Index; - var row2 = dataGridView.SelectedRows[1].Index; - if (row1 > row2) - { - (row2, row1) = (row1, row2); - } - - var refLine = row1; - var timeStamp1 = GetTimestampForLine(ref refLine, false); - refLine = row2; - var timeStamp2 = GetTimestampForLine(ref refLine, false); - //TimeSpan span = TimeSpan.FromTicks(timeStamp2.Ticks - timeStamp1.Ticks); - DateTime diff; - if (timeStamp1.Ticks > timeStamp2.Ticks) - { - diff = new DateTime(timeStamp1.Ticks - timeStamp2.Ticks); - } - else - { - diff = new DateTime(timeStamp2.Ticks - timeStamp1.Ticks); - } - - StatusLineText("Time diff is " + diff.ToString("HH:mm:ss.fff")); - } - else - { - if (!IsMultiFile && dataGridView.SelectedRows.Count == 1) - { - StatusLineText(string.Empty); - } - } - } - } - - [SupportedOSPlatform("windows")] - private void SyncFilterGridPos () - { - try - { - if (_filterResultList.Count > 0) - { - var index = _filterResultList.BinarySearch(dataGridView.CurrentRow.Index); - if (index < 0) - { - index = ~index; - if (index > 0) - { - --index; - } - } - - if (filterGridView.Rows.GetRowCount(DataGridViewElementStates.None) > 0) // exception no rows - { - filterGridView.CurrentCell = filterGridView.Rows[index].Cells[0]; - } - else - { - filterGridView.CurrentCell = null; - } - } - } - catch (Exception e) - { - _logger.Error(e, "SyncFilterGridPos(): "); - } - } - - private void StatusLineFileSize (long size) - { - _statusEventArgs.FileSize = size; - SendStatusLineUpdate(); - } - - [SupportedOSPlatform("windows")] - private int Search (SearchParams searchParams) - { - if (searchParams.SearchText == null) - { - return -1; - } - - var lineNum = searchParams.IsFromTop && !searchParams.IsFindNext - ? 0 - : searchParams.CurrentLine; - - var lowerSearchText = searchParams.SearchText.ToLowerInvariant(); - var count = 0; - var hasWrapped = false; - - while (true) - { - if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) - { - if (lineNum >= _logFileReader.LineCount) - { - if (hasWrapped) - { - StatusLineError("Not found: " + searchParams.SearchText); - return -1; - } - - lineNum = 0; - count = 0; - hasWrapped = true; - StatusLineError("Started from beginning of file"); - } - } - else - { - if (lineNum < 0) - { - if (hasWrapped) - { - StatusLineError("Not found: " + searchParams.SearchText); - return -1; - } - - count = 0; - lineNum = _logFileReader.LineCount - 1; - hasWrapped = true; - StatusLineError("Started from end of file"); - } - } - - var line = _logFileReader.GetLogLine(lineNum); - if (line == null) - { - return -1; - } - - if (searchParams.IsRegex) - { - Regex rex = new(searchParams.SearchText, searchParams.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); - if (rex.IsMatch(line.FullLine)) - { - return lineNum; - } - } - else - { - if (searchParams.IsCaseSensitive) - { - if (line.FullLine.Contains(searchParams.SearchText, StringComparison.Ordinal)) - { - return lineNum; - } - } - else - { - if (line.FullLine.Contains(lowerSearchText, StringComparison.OrdinalIgnoreCase)) - { - return lineNum; - } - } - } - - if ((searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed) - { - lineNum++; - } - else - { - lineNum--; - } - - if (_shouldCancel) - { - return -1; - } - - if (++count % PROGRESS_BAR_MODULO == 0) - { - try - { - if (!Disposing) - { - Invoke(UpdateProgressBar, [count]); - } - } - catch (ObjectDisposedException ex) // can occur when closing the app while searching - { - _logger.Warn(ex); - } - } - } - } - - private void ResetProgressBar () - { - _progressEventArgs.Value = _progressEventArgs.MaxValue; - _progressEventArgs.Visible = false; - SendProgressBarUpdate(); - } - - [SupportedOSPlatform("windows")] - private void SelectLine (int line, bool triggerSyncCall, bool shouldScroll) - { - try - { - _shouldCallTimeSync = triggerSyncCall; - var wasCancelled = _shouldCancel; - _shouldCancel = false; - _isSearching = false; - StatusLineText(string.Empty); - _guiStateArgs.MenuEnabled = true; - - if (wasCancelled) - { - return; - } - - if (line == -1) - { - // Hmm... is that experimental code from early days? - MessageBox.Show(this, "Not found:", "Search result"); - return; - } - - // Prevent ArgumentOutOfRangeException - if (line >= dataGridView.Rows.GetRowCount(DataGridViewElementStates.None)) - { - line = dataGridView.Rows.GetRowCount(DataGridViewElementStates.None) - 1; - } - - dataGridView.Rows[line].Selected = true; - - if (shouldScroll) - { - dataGridView.CurrentCell = dataGridView.Rows[line].Cells[0]; - dataGridView.Focus(); - } - } - catch (ArgumentOutOfRangeException e) - { - _logger.Error(e, "Error while selecting line: "); - } - catch (IndexOutOfRangeException e) - { - // Occures sometimes (but cannot reproduce) - _logger.Error(e, "Error while selecting line: "); - } - } - - [SupportedOSPlatform("windows")] - private void StartEditMode () - { - if (!dataGridView.CurrentCell.ReadOnly) - { - dataGridView.BeginEdit(false); - if (dataGridView.EditingControl != null) - { - if (dataGridView.EditingControl is LogCellEditingControl editControl) - { - editControl.KeyDown += OnEditControlKeyDown; - editControl.KeyPress += OnEditControlKeyPress; - editControl.KeyUp += OnEditControlKeyUp; - editControl.Click += OnEditControlClick; - dataGridView.CellEndEdit += OnDataGridViewCellEndEdit; - editControl.SelectionStart = 0; - } - else - { - _logger.Warn(CultureInfo.InvariantCulture, "Edit control in logWindow was null"); - } - } - } - } - - [SupportedOSPlatform("windows")] - private void UpdateEditColumnDisplay (DataGridViewTextBoxEditingControl editControl) - { - // prevents key events after edit mode has ended - if (dataGridView.EditingControl != null) - { - var pos = editControl.SelectionStart + editControl.SelectionLength; - StatusLineText(" " + pos); - _logger.Debug(CultureInfo.InvariantCulture, "SelStart: {0}, SelLen: {1}", editControl.SelectionStart, editControl.SelectionLength); - } - } - - [SupportedOSPlatform("windows")] - private void SelectPrevHighlightLine () - { - var lineNum = dataGridView.CurrentCellAddress.Y; - while (lineNum > 0) - { - lineNum--; - var line = _logFileReader.GetLogLine(lineNum); - if (line != null) - { - var entry = FindHilightEntry(line); - if (entry != null) - { - SelectLine(lineNum, false, true); - break; - } - } - } - } - - [SupportedOSPlatform("windows")] - private void SelectNextHighlightLine () - { - var lineNum = dataGridView.CurrentCellAddress.Y; - while (lineNum < _logFileReader.LineCount) - { - lineNum++; - var line = _logFileReader.GetLogLine(lineNum); - if (line != null) - { - var entry = FindHilightEntry(line); - if (entry != null) - { - SelectLine(lineNum, false, true); - break; - } - } - } - } - - [SupportedOSPlatform("windows")] - private int FindNextBookmarkIndex (int lineNum) - { - if (lineNum >= dataGridView.RowCount) - { - lineNum = 0; - } - else - { - lineNum++; - } - - return _bookmarkProvider.FindNextBookmarkIndex(lineNum); - } - - [SupportedOSPlatform("windows")] - private int FindPrevBookmarkIndex (int lineNum) - { - if (lineNum <= 0) - { - lineNum = dataGridView.RowCount - 1; - } - else - { - lineNum--; - } - - return _bookmarkProvider.FindPrevBookmarkIndex(lineNum); - } - - /** - * Shift bookmarks after a logfile rollover - */ - - private void ShiftBookmarks (int offset) - { - _bookmarkProvider.ShiftBookmarks(offset); - OnBookmarkRemoved(); - } - - private void ShiftRowHeightList (int offset) - { - SortedList newList = []; - foreach (var entry in _rowHeightList.Values) - { - var line = entry.LineNum - offset; - if (line >= 0) - { - entry.LineNum = line; - newList.Add(line, entry); - } - } - - _rowHeightList = newList; - } - - private void ShiftFilterPipes (int offset) - { - lock (_filterPipeList) - { - foreach (var pipe in _filterPipeList) - { - pipe.ShiftLineNums(offset); - } - } - } - - [SupportedOSPlatform("windows")] - private void LoadFilterPipes () - { - lock (_filterPipeList) - { - foreach (var pipe in _filterPipeList) - { - pipe.RecreateTempFile(); - } - } - - if (_filterPipeList.Count > 0) - { - for (var i = 0; i < dataGridView.RowCount; ++i) - { - ProcessFilterPipes(i); - } - } - } - - private void DisconnectFilterPipes () - { - lock (_filterPipeList) - { - foreach (var pipe in _filterPipeList) - { - pipe.ClearLineList(); - } - } - } - - [SupportedOSPlatform("windows")] - private void ApplyFilterParams () - { - filterComboBox.Text = _filterParams.SearchText; - filterCaseSensitiveCheckBox.Checked = _filterParams.IsCaseSensitive; - filterRegexCheckBox.Checked = _filterParams.IsRegex; - filterTailCheckBox.Checked = _filterParams.IsFilterTail; - invertFilterCheckBox.Checked = _filterParams.IsInvert; - filterKnobBackSpread.Value = _filterParams.SpreadBefore; - filterKnobForeSpread.Value = _filterParams.SpreadBehind; - rangeCheckBox.Checked = _filterParams.IsRangeSearch; - columnRestrictCheckBox.Checked = _filterParams.ColumnRestrict; - fuzzyKnobControl.Value = _filterParams.FuzzyValue; - filterRangeComboBox.Text = _filterParams.RangeSearchText; - } - - [SupportedOSPlatform("windows")] - private void ResetFilterControls () - { - filterComboBox.Text = ""; - filterCaseSensitiveCheckBox.Checked = false; - filterRegexCheckBox.Checked = false; - //this.filterTailCheckBox.Checked = this.Preferences.filterTail; - invertFilterCheckBox.Checked = false; - filterKnobBackSpread.Value = 0; - filterKnobForeSpread.Value = 0; - rangeCheckBox.Checked = false; - columnRestrictCheckBox.Checked = false; - fuzzyKnobControl.Value = 0; - filterRangeComboBox.Text = ""; - } - - [SupportedOSPlatform("windows")] - private void FilterSearch () - { - if (filterComboBox.Text.Length == 0) - { - _filterParams.SearchText = string.Empty; - _filterParams.LowerSearchText = string.Empty; - _filterParams.IsRangeSearch = false; - ClearFilterList(); - filterSearchButton.Image = null; - ResetFilterControls(); - saveFilterButton.Enabled = false; - return; - } - - FilterSearch(filterComboBox.Text); - } - - [SupportedOSPlatform("windows")] - private async void FilterSearch (string text) - { - FireCancelHandlers(); // make sure that there's no other filter running (maybe from filter restore) - - _filterParams.SearchText = text; - _filterParams.LowerSearchText = text.ToLowerInvariant(); - ConfigManager.Settings.FilterHistoryList.Remove(text); - ConfigManager.Settings.FilterHistoryList.Insert(0, text); - var maxHistory = ConfigManager.Settings.Preferences.MaximumFilterEntries; - - if (ConfigManager.Settings.FilterHistoryList.Count > maxHistory) - { - ConfigManager.Settings.FilterHistoryList.RemoveAt(filterComboBox.Items.Count - 1); - } - - filterComboBox.Items.Clear(); - foreach (var item in ConfigManager.Settings.FilterHistoryList) - { - filterComboBox.Items.Add(item); - } - - filterComboBox.Text = text; - - _filterParams.IsRangeSearch = rangeCheckBox.Checked; - _filterParams.RangeSearchText = filterRangeComboBox.Text; - if (_filterParams.IsRangeSearch) - { - ConfigManager.Settings.FilterRangeHistoryList.Remove(filterRangeComboBox.Text); - ConfigManager.Settings.FilterRangeHistoryList.Insert(0, filterRangeComboBox.Text); - if (ConfigManager.Settings.FilterRangeHistoryList.Count > maxHistory) - { - ConfigManager.Settings.FilterRangeHistoryList.RemoveAt(filterRangeComboBox.Items.Count - 1); - } - - filterRangeComboBox.Items.Clear(); - foreach (var item in ConfigManager.Settings.FilterRangeHistoryList) - { - filterRangeComboBox.Items.Add(item); - } - } - - ConfigManager.Save(SettingsFlags.FilterHistory); - - _filterParams.IsCaseSensitive = filterCaseSensitiveCheckBox.Checked; - _filterParams.IsRegex = filterRegexCheckBox.Checked; - _filterParams.IsFilterTail = filterTailCheckBox.Checked; - _filterParams.IsInvert = invertFilterCheckBox.Checked; - if (_filterParams.IsRegex) - { - try - { - _filterParams.CreateRegex(); - } - catch (ArgumentException) - { - StatusLineError("Invalid regular expression"); - return; - } - } - - _filterParams.FuzzyValue = fuzzyKnobControl.Value; - _filterParams.SpreadBefore = filterKnobBackSpread.Value; - _filterParams.SpreadBehind = filterKnobForeSpread.Value; - _filterParams.ColumnRestrict = columnRestrictCheckBox.Checked; - - //ConfigManager.SaveFilterParams(this.filterParams); - ConfigManager.Settings.FilterParams = _filterParams; // wozu eigentlich? sinnlos seit MDI? - - _shouldCancel = false; - _isSearching = true; - StatusLineText("Filtering... Press ESC to cancel"); - filterSearchButton.Enabled = false; - ClearFilterList(); - - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = dataGridView.RowCount; - _progressEventArgs.Value = 0; - _progressEventArgs.Visible = true; - SendProgressBarUpdate(); - - var settings = ConfigManager.Settings; - - //FilterFx fx = settings.preferences.multiThreadFilter ? MultiThreadedFilter : new FilterFx(Filter); - FilterFxAction = settings.Preferences.MultiThreadFilter ? MultiThreadedFilter : Filter; - - //Task.Run(() => fx.Invoke(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList)); - var filterFxActionTask = Task.Run(() => Filter(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList)); - - await filterFxActionTask; - FilterComplete(); - - //fx.BeginInvoke(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList, FilterComplete, null); - CheckForFilterDirty(); - } - - private void MultiThreadedFilter (FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) - { - ColumnizerCallback callback = new(this); - - FilterStarter fs = new(callback, Environment.ProcessorCount + 2) - { - FilterHitList = _filterHitList, - FilterResultLines = _filterResultList, - LastFilterLinesList = _lastFilterLinesList - }; - - var cancelHandler = new FilterCancelHandler(fs); - OnRegisterCancelHandler(cancelHandler); - long startTime = Environment.TickCount; - - fs.DoFilter(filterParams, 0, _logFileReader.LineCount, FilterProgressCallback); - - long endTime = Environment.TickCount; - - _logger.Debug($"Multi threaded filter duration: {endTime - startTime} ms."); - - OnDeRegisterCancelHandler(cancelHandler); - StatusLineText("Filter duration: " + (endTime - startTime) + " ms."); - } - - private void FilterProgressCallback (int lineCount) - { - UpdateProgressBar(lineCount); - } - - [SupportedOSPlatform("windows")] - private void Filter (FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) - { - long startTime = Environment.TickCount; - try - { - filterParams.Reset(); - var lineNum = 0; - //AddFilterLineFx addFx = new AddFilterLineFx(AddFilterLine); - ColumnizerCallback callback = new(this); - while (true) - { - var line = _logFileReader.GetLogLine(lineNum); - if (line == null) - { - break; - } - - callback.LineNum = lineNum; - if (Util.TestFilterCondition(filterParams, line, callback)) - { - AddFilterLine(lineNum, false, filterParams, filterResultLines, lastFilterLinesList, - filterHitList); - } - - lineNum++; - if (lineNum % PROGRESS_BAR_MODULO == 0) - { - UpdateProgressBar(lineNum); - } - - if (_shouldCancel) - { - break; - } - } - } - catch (Exception ex) - { - _logger.Error(ex, "Exception while filtering. Please report to developer: "); - MessageBox.Show(null, $"Exception while filtering. Please report to developer: \n\n{ex}\n\n{ex.StackTrace}", "LogExpert"); - } - - long endTime = Environment.TickCount; - - _logger.Info($"Single threaded filter duration: {endTime - startTime} ms."); - - StatusLineText("Filter duration: " + (endTime - startTime) + " ms."); - } - - /// - /// Returns a list with 'additional filter results'. This is the given line number - /// and (if back spread and/or fore spread is enabled) some additional lines. - /// This function doesn't check the filter condition! - /// - /// - /// - /// - /// - private IList GetAdditionalFilterResults (FilterParams filterParams, int lineNum, IList checkList) - { - IList resultList = []; - //string textLine = this.logFileReader.GetLogLine(lineNum); - //ColumnizerCallback callback = new ColumnizerCallback(this); - //callback.LineNum = lineNum; - - if (filterParams.SpreadBefore == 0 && filterParams.SpreadBehind == 0) - { - resultList.Add(lineNum); - return resultList; - } - - // back spread - for (var i = filterParams.SpreadBefore; i > 0; --i) - { - if (lineNum - i > 0) - { - if (!resultList.Contains(lineNum - i) && !checkList.Contains(lineNum - i)) - { - resultList.Add(lineNum - i); - } - } - } - - // direct filter hit - if (!resultList.Contains(lineNum) && !checkList.Contains(lineNum)) - { - resultList.Add(lineNum); - } - - // after spread - for (var i = 1; i <= filterParams.SpreadBehind; ++i) - { - if (lineNum + i < _logFileReader.LineCount) - { - if (!resultList.Contains(lineNum + i) && !checkList.Contains(lineNum + i)) - { - resultList.Add(lineNum + i); - } - } - } - - return resultList; - } - - [SupportedOSPlatform("windows")] - private void AddFilterLine (int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList) - { - int count; - lock (_filterResultList) - { - filterHitList.Add(lineNum); - var filterResult = GetAdditionalFilterResults(filterParams, lineNum, lastFilterLinesList); - filterResultLines.AddRange(filterResult); - count = filterResultLines.Count; - lastFilterLinesList.AddRange(filterResult); - if (lastFilterLinesList.Count > SPREAD_MAX * 2) - { - lastFilterLinesList.RemoveRange(0, lastFilterLinesList.Count - SPREAD_MAX * 2); - } - } - - if (immediate) - { - TriggerFilterLineGuiUpdate(); - } - else if (lineNum % PROGRESS_BAR_MODULO == 0) - { - //FunctionWith1IntParam fx = new FunctionWith1IntParam(UpdateFilterCountLabel); - //this.Invoke(fx, new object[] { count}); - } - } - - [SupportedOSPlatform("windows")] - private void TriggerFilterLineGuiUpdate () - { - //lock (this.filterUpdateThread) - //{ - // this.filterEventCount++; - // this.filterUpdateEvent.Set(); - //} - Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); - } - - //private void FilterUpdateWorker() - //{ - // Thread.CurrentThread.Name = "FilterUpdateWorker"; - // while (true) - // { - // this.filterUpdateEvent.WaitOne(); - // lock (this.filterUpdateThread) - // { - // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); - // this.filterUpdateEvent.Reset(); - // } - - // //_logger.logDebug("FilterUpdateWorker: Waiting for signal"); - // //bool signaled = this.filterUpdateEvent.WaitOne(1000, false); - - // //if (!signaled) - // //{ - // // lock (this.filterUpdateThread) - // // { - // // if (this.filterEventCount > 0) - // // { - // // this.filterEventCount = 0; - // // _logger.logDebug("FilterUpdateWorker: Invoking GUI update because of wait timeout"); - // // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); - // // } - // // } - // //} - // //else - // //{ - // // _logger.logDebug("FilterUpdateWorker: Wakeup signal received."); - // // lock (this.filterUpdateThread) - // // { - // // _logger.logDebug("FilterUpdateWorker: event count: " + this.filterEventCount); - // // if (this.filterEventCount > 100) - // // { - // // this.filterEventCount = 0; - // // _logger.logDebug("FilterUpdateWorker: Invoking GUI update because of event count"); - // // this.Invoke(new MethodInvoker(AddFilterLineGuiUpdate)); - // // } - // // this.filterUpdateEvent.Reset(); - // // } - // //} - // } - //} - - //private void StopFilterUpdateWorkerThread() - //{ - // this.filterUpdateEvent.Set(); - // this.filterUpdateThread.Abort(); - // this.filterUpdateThread.Join(); - //} - - [SupportedOSPlatform("windows")] - private void AddFilterLineGuiUpdate () - { - try - { - lock (_filterResultList) - { - lblFilterCount.Text = "" + _filterResultList.Count; - if (filterGridView.RowCount > _filterResultList.Count) - { - filterGridView.RowCount = 0; // helps to prevent hang ? - } - - filterGridView.RowCount = _filterResultList.Count; - if (filterGridView.RowCount > 0) - { - filterGridView.FirstDisplayedScrollingRowIndex = filterGridView.RowCount - 1; - } - - if (filterGridView.RowCount == 1) - { - // after a file reload adjusted column sizes anew when the first line arrives - //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - AutoResizeColumns(filterGridView); - } - } - } - catch (Exception e) - { - _logger.Error(e, "AddFilterLineGuiUpdate(): "); - } - } - - private void UpdateProgressBar (int value) - { - _progressEventArgs.Value = value; - if (value > _progressEventArgs.MaxValue) - { - // can occur if new lines will be added while filtering - _progressEventArgs.MaxValue = value; - } - - SendProgressBarUpdate(); - } - - [SupportedOSPlatform("windows")] - private void FilterComplete () - { - if (!IsDisposed && !_waitingForClose && !Disposing) - { - Invoke(new MethodInvoker(ResetStatusAfterFilter)); - } - } - - [SupportedOSPlatform("windows")] - private void FilterComplete (IAsyncResult result) - { - if (!IsDisposed && !_waitingForClose && !Disposing) - { - Invoke(new MethodInvoker(ResetStatusAfterFilter)); - } - } - - [SupportedOSPlatform("windows")] - private void ResetStatusAfterFilter () - { - try - { - //StatusLineText(""); - _isSearching = false; - _progressEventArgs.Value = _progressEventArgs.MaxValue; - _progressEventArgs.Visible = false; - SendProgressBarUpdate(); - filterGridView.RowCount = _filterResultList.Count; - //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - AutoResizeColumns(filterGridView); - lblFilterCount.Text = "" + _filterResultList.Count; - if (filterGridView.RowCount > 0) - { - filterGridView.Focus(); - } - - filterSearchButton.Enabled = true; - } - catch (NullReferenceException e) - { - // See https://connect.microsoft.com/VisualStudio/feedback/details/366943/autoresizecolumns-in-datagridview-throws-nullreferenceexception - // There are some rare situations with null ref exceptions when resizing columns and on filter finished - // So catch them here. Better than crashing. - _logger.Error(e, "Error: "); - } - } - - [SupportedOSPlatform("windows")] - private void ClearFilterList () - { - try - { - //this.shouldCancel = true; - lock (_filterResultList) - { - filterGridView.SuspendLayout(); - filterGridView.RowCount = 0; - lblFilterCount.Text = "0"; - _filterResultList = []; - _lastFilterLinesList = []; - _filterHitList = []; - //this.filterGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - filterGridView.ResumeLayout(); - } - } - catch (Exception ex) - { - _logger.Error(ex, "Wieder dieser sporadische Fehler: "); - - MessageBox.Show(null, ex.StackTrace, "Wieder dieser sporadische Fehler:"); - } - } - - private void ClearBookmarkList () - { - _bookmarkProvider.ClearAllBookmarks(); - } - - /** - * Shift filter list line entries after a logfile rollover - */ - [SupportedOSPlatform("windows")] - private void ShiftFilterLines (int offset) - { - List newFilterList = []; - lock (_filterResultList) - { - foreach (var lineNum in _filterResultList) - { - var line = lineNum - offset; - if (line >= 0) - { - newFilterList.Add(line); - } - } - - _filterResultList = newFilterList; - } - - newFilterList = []; - foreach (var lineNum in _filterHitList) - { - var line = lineNum - offset; - if (line >= 0) - { - newFilterList.Add(line); - } - } - - _filterHitList = newFilterList; - - var count = SPREAD_MAX; - if (_filterResultList.Count < SPREAD_MAX) - { - count = _filterResultList.Count; - } - - _lastFilterLinesList = _filterResultList.GetRange(_filterResultList.Count - count, count); - - //this.filterGridView.RowCount = this.filterResultList.Count; - //this.filterCountLabel.Text = "" + this.filterResultList.Count; - //this.BeginInvoke(new MethodInvoker(this.filterGridView.Refresh)); - //this.BeginInvoke(new MethodInvoker(AddFilterLineGuiUpdate)); - TriggerFilterLineGuiUpdate(); - } - - [SupportedOSPlatform("windows")] - private void CheckForFilterDirty () - { - if (IsFilterSearchDirty(_filterParams)) - { - filterSearchButton.Image = _searchButtonImage; - saveFilterButton.Enabled = false; - } - else - { - filterSearchButton.Image = null; - saveFilterButton.Enabled = true; - } - } - - [SupportedOSPlatform("windows")] - private bool IsFilterSearchDirty (FilterParams filterParams) - { - if (!filterParams.SearchText.Equals(filterComboBox.Text, StringComparison.Ordinal)) - { - return true; - } - - if (filterParams.IsRangeSearch != rangeCheckBox.Checked) - { - return true; - } - - if (filterParams.IsRangeSearch && !filterParams.RangeSearchText.Equals(filterRangeComboBox.Text, StringComparison.Ordinal)) - { - return true; - } - - if (filterParams.IsRegex != filterRegexCheckBox.Checked) - { - return true; - } - - if (filterParams.IsInvert != invertFilterCheckBox.Checked) - { - return true; - } - - if (filterParams.SpreadBefore != filterKnobBackSpread.Value) - { - return true; - } - - if (filterParams.SpreadBehind != filterKnobForeSpread.Value) - { - return true; - } - - if (filterParams.FuzzyValue != fuzzyKnobControl.Value) - { - return true; - } - - if (filterParams.ColumnRestrict != columnRestrictCheckBox.Checked) - { - return true; - } - - if (filterParams.IsCaseSensitive != filterCaseSensitiveCheckBox.Checked) - { - return true; - } - - return false; - } - - [SupportedOSPlatform("windows")] - private void AdjustMinimumGridWith () - { - if (dataGridView.Columns.Count > 1) - { - //this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); - AutoResizeColumns(dataGridView); - - var width = dataGridView.Columns.GetColumnsWidth(DataGridViewElementStates.Visible); - var diff = dataGridView.Width - width; - if (diff > 0) - { - diff -= dataGridView.RowHeadersWidth / 2; - dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].Width += diff; - filterGridView.Columns[filterGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].Width += diff; - } - } - } - - [SupportedOSPlatform("windows")] - private void InvalidateCurrentRow (BufferedDataGridView gridView) - { - if (gridView.CurrentCellAddress.Y > -1) - { - gridView.InvalidateRow(gridView.CurrentCellAddress.Y); - } - } - - private void InvalidateCurrentRow () - { - InvalidateCurrentRow(dataGridView); - InvalidateCurrentRow(filterGridView); - } - - [SupportedOSPlatform("windows")] - private void DisplayCurrentFileOnStatusline () - { - if (_logFileReader.IsMultiFile) - { - try - { - if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index > -1) - { - var fileName = _logFileReader.GetLogFileNameForLine(dataGridView.CurrentRow.Index); - if (fileName != null) - { - StatusLineText(Util.GetNameFromPath(fileName)); - } - } - } - catch (Exception) - { - // TODO: handle this concurrent situation better: - // this.dataGridView.CurrentRow may be null even if checked before. - // This can happen when MultiFile shift deselects the current row because there - // are less lines after rollover than before. - // access to dataGridView-Rows should be locked - } - } - } - - private void UpdateSelectionDisplay () - { - if (_noSelectionUpdates) - { - return; - } - } - - [SupportedOSPlatform("windows")] - private void UpdateFilterHistoryFromSettings () - { - ConfigManager.Settings.FilterHistoryList = ConfigManager.Settings.FilterHistoryList; - filterComboBox.Items.Clear(); - foreach (var item in ConfigManager.Settings.FilterHistoryList) - { - filterComboBox.Items.Add(item); - } - - filterRangeComboBox.Items.Clear(); - foreach (var item in ConfigManager.Settings.FilterRangeHistoryList) - { - filterRangeComboBox.Items.Add(item); - } - } - - private void StatusLineText (string text) - { - _statusEventArgs.StatusText = text; - SendStatusLineUpdate(); - } - - private void StatusLineError (string text) - { - StatusLineText(text); - _isErrorShowing = true; - } - - private void RemoveStatusLineError () - { - StatusLineText(""); - _isErrorShowing = false; - } - - private void SendGuiStateUpdate () - { - OnGuiState(_guiStateArgs); - } - - private void SendProgressBarUpdate () - { - OnProgressBarUpdate(_progressEventArgs); - } - - private void SendStatusLineUpdate () - { - OnStatusLine(_statusEventArgs); - } - - [SupportedOSPlatform("windows")] - private void ShowAdvancedFilterPanel (bool show) - { - if (show) - { - advancedButton.Text = "Hide advanced..."; - advancedButton.Image = null; - } - else - { - advancedButton.Text = "Show advanced..."; - CheckForAdvancedButtonDirty(); - } - - advancedFilterSplitContainer.Panel1Collapsed = !show; - advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE; - _showAdvanced = show; - } - - [SupportedOSPlatform("windows")] - private void CheckForAdvancedButtonDirty () - { - advancedButton.Image = IsAdvancedOptionActive() && !_showAdvanced - ? _advancedButtonImage - : null; - } - - [SupportedOSPlatform("windows")] - private void FilterToTab () - { - filterSearchButton.Enabled = false; - Task.Run(() => WriteFilterToTab()); - } - - [SupportedOSPlatform("windows")] - private void WriteFilterToTab () - { - FilterPipe pipe = new(_filterParams.Clone(), this); - lock (_filterResultList) - { - var namePrefix = "->F"; - var title = IsTempFile - ? TempTitleName + namePrefix + ++_filterPipeNameCounter - : Util.GetNameFromPath(FileName) + namePrefix + ++_filterPipeNameCounter; - - WritePipeToTab(pipe, _filterResultList, title, null); - } - } - - [SupportedOSPlatform("windows")] - private void WritePipeToTab (FilterPipe pipe, IList lineNumberList, string name, PersistenceData persistenceData) - { - _logger.Info(CultureInfo.InvariantCulture, "WritePipeToTab(): {0} lines.", lineNumberList.Count); - StatusLineText("Writing to temp file... Press ESC to cancel."); - _guiStateArgs.MenuEnabled = false; - SendGuiStateUpdate(); - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = lineNumberList.Count; - _progressEventArgs.Value = 0; - _progressEventArgs.Visible = true; - Invoke(new MethodInvoker(SendProgressBarUpdate)); - _isSearching = true; - _shouldCancel = false; - - lock (_filterPipeList) - { - _filterPipeList.Add(pipe); - } - - pipe.Closed += OnPipeDisconnected; - var count = 0; - pipe.OpenFile(); - LogExpertCallback callback = new(this); - foreach (var i in lineNumberList) - { - if (_shouldCancel) - { - break; - } - - var line = _logFileReader.GetLogLine(i); - if (CurrentColumnizer is ILogLineXmlColumnizer) - { - callback.LineNum = i; - line = (CurrentColumnizer as ILogLineXmlColumnizer).GetLineTextForClipboard(line, callback); - } - - pipe.WriteToPipe(line, i); - if (++count % PROGRESS_BAR_MODULO == 0) - { - _progressEventArgs.Value = count; - Invoke(new MethodInvoker(SendProgressBarUpdate)); - } - } - - pipe.CloseFile(); - _logger.Info(CultureInfo.InvariantCulture, "WritePipeToTab(): finished"); - Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), pipe, name, persistenceData); - } - - [SupportedOSPlatform("windows")] - private void WriteFilterToTabFinished (FilterPipe pipe, string name, PersistenceData persistenceData) - { - _isSearching = false; - if (!_shouldCancel) - { - var title = name; - ILogLineColumnizer preProcessColumnizer = null; - if (CurrentColumnizer is not ILogLineXmlColumnizer) - { - preProcessColumnizer = CurrentColumnizer; - } - - var newWin = _parentLogTabWin.AddFilterTab(pipe, title, preProcessColumnizer); - newWin.FilterPipe = pipe; - pipe.OwnLogWindow = newWin; - if (persistenceData != null) - { - Task.Run(() => FilterRestore(newWin, persistenceData)); - } - } - - _progressEventArgs.Value = _progressEventArgs.MaxValue; - _progressEventArgs.Visible = false; - SendProgressBarUpdate(); - _guiStateArgs.MenuEnabled = true; - SendGuiStateUpdate(); - StatusLineText(""); - filterSearchButton.Enabled = true; - } - - /// - /// Used to create a new tab and pipe the given content into it. - /// - /// - /// - [SupportedOSPlatform("windows")] - internal void WritePipeTab (IList lineEntryList, string title) - { - FilterPipe pipe = new(new FilterParams(), this) - { - IsStopped = true - }; - pipe.Closed += OnPipeDisconnected; - pipe.OpenFile(); - foreach (var entry in lineEntryList) - { - pipe.WriteToPipe(entry.LogLine, entry.LineNum); - } - - pipe.CloseFile(); - Invoke(new WriteFilterToTabFinishedFx(WriteFilterToTabFinished), [pipe, title, null]); - } - - [SupportedOSPlatform("windows")] - private void FilterRestore (LogWindow newWin, PersistenceData persistenceData) - { - newWin.WaitForLoadingFinished(); - var columnizer = ColumnizerPicker.FindColumnizerByName(persistenceData.ColumnizerName, - PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - if (columnizer != null) - { - SetColumnizerFx fx = newWin.ForceColumnizer; - newWin.Invoke(fx, [columnizer]); - } - else - { - _logger.Warn($"FilterRestore(): Columnizer {persistenceData.ColumnizerName} not found"); - } - - newWin.BeginInvoke(new RestoreFiltersFx(newWin.RestoreFilters), [persistenceData]); - } - - [SupportedOSPlatform("windows")] - private void ProcessFilterPipes (int lineNum) - { - var searchLine = _logFileReader.GetLogLine(lineNum); - if (searchLine == null) - { - return; - } - - ColumnizerCallback callback = new(this) - { - LineNum = lineNum - }; - IList deleteList = []; - lock (_filterPipeList) - { - foreach (var pipe in _filterPipeList) - { - if (pipe.IsStopped) - { - continue; - } - - //long startTime = Environment.TickCount; - if (Util.TestFilterCondition(pipe.FilterParams, searchLine, callback)) - { - var filterResult = - GetAdditionalFilterResults(pipe.FilterParams, lineNum, pipe.LastLinesHistoryList); - pipe.OpenFile(); - foreach (var line in filterResult) - { - pipe.LastLinesHistoryList.Add(line); - if (pipe.LastLinesHistoryList.Count > SPREAD_MAX * 2) - { - pipe.LastLinesHistoryList.RemoveAt(0); - } - - var textLine = _logFileReader.GetLogLine(line); - var fileOk = pipe.WriteToPipe(textLine, line); - if (!fileOk) - { - deleteList.Add(pipe); - } - } - - pipe.CloseFile(); - } - - //long endTime = Environment.TickCount; - //_logger.logDebug("ProcessFilterPipes(" + lineNum + ") duration: " + ((endTime - startTime))); - } - } - - foreach (var pipe in deleteList) - { - _filterPipeList.Remove(pipe); - } - } - - [SupportedOSPlatform("windows")] - private void CopyMarkedLinesToClipboard () - { - if (_guiStateArgs.CellSelectMode) - { - var data = dataGridView.GetClipboardContent(); - Clipboard.SetDataObject(data); - } - else - { - List lineNumList = []; - foreach (DataGridViewRow row in dataGridView.SelectedRows) - { - if (row.Index != -1) - { - lineNumList.Add(row.Index); - } - } - - lineNumList.Sort(); - StringBuilder clipText = new(); - LogExpertCallback callback = new(this); - - var xmlColumnizer = _currentColumnizer as ILogLineXmlColumnizer; - - foreach (var lineNum in lineNumList) - { - var line = _logFileReader.GetLogLine(lineNum); - if (xmlColumnizer != null) - { - callback.LineNum = lineNum; - line = xmlColumnizer.GetLineTextForClipboard(line, callback); - } - - clipText.AppendLine(line.ToClipBoardText()); - } - - Clipboard.SetText(clipText.ToString()); - } - } - - /// - /// Set an Encoding which shall be used when loading a file. Used before a file is loaded. - /// - /// - private void SetExplicitEncoding (Encoding encoding) - { - EncodingOptions.Encoding = encoding; - } - - [SupportedOSPlatform("windows")] - private void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, bool setLastColumnWidth, int lastColumnWidth) - { - if (dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) > 1) - { - if (setLastColumnWidth) - { - dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].MinimumWidth = lastColumnWidth; - } - else - { - // Workaround for a .NET bug which brings the DataGridView into an unstable state (causing lots of NullReferenceExceptions). - dataGridView.FirstDisplayedScrollingColumnIndex = 0; - - dataGridView.Columns[dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 1].MinimumWidth = 5; // default - } - } - - if (dataGridView.RowCount > 0) - { - dataGridView.UpdateRowHeightInfo(0, true); - } - - dataGridView.Invalidate(); - dataGridView.Refresh(); - AutoResizeColumns(dataGridView); - } - - [SupportedOSPlatform("windows")] - private IList GetSelectedContent () - { - if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) - { - List lineNumList = []; - - foreach (DataGridViewRow row in dataGridView.SelectedRows) - { - if (row.Index != -1) - { - lineNumList.Add(row.Index); - } - } - - lineNumList.Sort(); - return lineNumList; - } - - return []; - } - - /* ======================================================================== - * Timestamp stuff - * =======================================================================*/ - - [SupportedOSPlatform("windows")] - private void SetTimestampLimits () - { - if (!CurrentColumnizer.IsTimeshiftImplemented()) - { - return; - } - - var line = 0; - _guiStateArgs.MinTimestamp = GetTimestampForLineForward(ref line, true); - line = dataGridView.RowCount - 1; - _guiStateArgs.MaxTimestamp = GetTimestampForLine(ref line, true); - SendGuiStateUpdate(); - } - - private void AdjustHighlightSplitterWidth () - { - //int size = this.editHighlightsSplitContainer.Panel2Collapsed ? 600 : 660; - //int distance = this.highlightSplitContainer.Width - size; - //if (distance < 10) - // distance = 10; - //this.highlightSplitContainer.SplitterDistance = distance; - } - - [SupportedOSPlatform("windows")] - private void BookmarkComment (Bookmark bookmark) - { - BookmarkCommentDlg dlg = new() - { - Comment = bookmark.Text - }; - if (dlg.ShowDialog() == DialogResult.OK) - { - bookmark.Text = dlg.Comment; - dataGridView.Refresh(); - OnBookmarkTextChanged(bookmark); - } - } - - /// - /// Indicates which columns we are filtering on - /// - /// - /// - [SupportedOSPlatform("windows")] - private string CalculateColumnNames (FilterParams filter) - { - var names = string.Empty; - - if (filter.ColumnRestrict) - { - foreach (var colIndex in filter.ColumnList) - { - if (colIndex < dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 2) - { - if (names.Length > 0) - { - names += ", "; - } - - names += dataGridView.Columns[2 + colIndex] - .HeaderText; // skip first two columns: marker + line number - } - } - } - - return names; - } - - [SupportedOSPlatform("windows")] - private void ApplyFrozenState (BufferedDataGridView gridView) - { - SortedDictionary dict = []; - foreach (DataGridViewColumn col in gridView.Columns) - { - dict.Add(col.DisplayIndex, col); - } - - foreach (var col in dict.Values) - { - col.Frozen = _freezeStateMap.ContainsKey(gridView) && _freezeStateMap[gridView]; - var sel = col.HeaderCell.Selected; - if (col.Index == _selectedCol) - { - break; - } - } - } - - [SupportedOSPlatform("windows")] - private void ShowTimeSpread (bool show) - { - if (show) - { - tableLayoutPanel1.ColumnStyles[1].Width = 16; - } - else - { - tableLayoutPanel1.ColumnStyles[1].Width = 0; - } - - _timeSpreadCalc.Enabled = show; - } - - [SupportedOSPlatform("windows")] - protected internal void AddTempFileTab (string fileName, string title) - { - _parentLogTabWin.AddTempFileTab(fileName, title); - } - - private void InitPatternWindow () - { - //PatternStatistic(this.patternArgs); - _patternWindow = new PatternWindow(this); - _patternWindow.SetColumnizer(CurrentColumnizer); - //this.patternWindow.SetBlockList(blockList); - _patternWindow.SetFont(Preferences.FontName, Preferences.FontSize); - _patternWindow.Fuzzy = _patternArgs.Fuzzy; - _patternWindow.MaxDiff = _patternArgs.MaxDiffInBlock; - _patternWindow.MaxMisses = _patternArgs.MaxMisses; - _patternWindow.Weight = _patternArgs.MinWeight; - //this.patternWindow.Show(); - } - - [SupportedOSPlatform("windows")] - private void TestStatistic (PatternArgs patternArgs) - { - var beginLine = patternArgs.StartLine; - _logger.Info($"TestStatistics() called with start line {beginLine}"); - - _patternArgs = patternArgs; - - var num = beginLine + 1; //this.dataGridView.RowCount; - - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = dataGridView.RowCount; - _progressEventArgs.Value = beginLine; - _progressEventArgs.Visible = true; - SendProgressBarUpdate(); - - PrepareDict(); - ResetCache(num); - - Dictionary processedLinesDict = []; - List blockList = []; - var blockId = 0; - _isSearching = true; - _shouldCancel = false; - var searchLine = -1; - for (var i = beginLine; i < num && !_shouldCancel; ++i) - { - if (processedLinesDict.ContainsKey(i)) - { - continue; - } - - PatternBlock block; - var maxBlockLen = patternArgs.EndLine - patternArgs.StartLine; - //int searchLine = i + 1; - _logger.Debug(CultureInfo.InvariantCulture, "TestStatistic(): i={0} searchLine={1}", i, searchLine); - //bool firstBlock = true; - searchLine++; - UpdateProgressBar(searchLine); - while (!_shouldCancel && - (block = - DetectBlock(i, searchLine, maxBlockLen, _patternArgs.MaxDiffInBlock, - _patternArgs.MaxMisses, - processedLinesDict)) != null) - { - _logger.Debug(CultureInfo.InvariantCulture, "Found block: {0}", block); - if (block.Weigth >= _patternArgs.MinWeight) - { - //PatternBlock existingBlock = FindExistingBlock(block, blockList); - //if (existingBlock != null) - //{ - // if (block.weigth > existingBlock.weigth) - // { - // blockList.Remove(existingBlock); - // blockList.Add(block); - // } - //} - //else - { - blockList.Add(block); - AddBlockTargetLinesToDict(processedLinesDict, block); - } - block.BlockId = blockId; - //if (firstBlock) - //{ - // addBlockSrcLinesToDict(processedLinesDict, block); - //} - searchLine = block.TargetEnd + 1; - } - else - { - searchLine = block.TargetStart + 1; - } - - UpdateProgressBar(searchLine); - } - - blockId++; - } - - _isSearching = false; - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = 0; - _progressEventArgs.Value = 0; - _progressEventArgs.Visible = false; - SendProgressBarUpdate(); - //if (this.patternWindow.IsDisposed) - //{ - // this.Invoke(new MethodInvoker(CreatePatternWindow)); - //} - _patternWindow.SetBlockList(blockList, _patternArgs); - _logger.Info(CultureInfo.InvariantCulture, "TestStatistics() ended"); - } - - private void AddBlockTargetLinesToDict (Dictionary dict, PatternBlock block) - { - foreach (var lineNum in block.TargetLines.Keys) - { - _ = dict.TryAdd(lineNum, lineNum); - } - } - - //Well keep this for the moment because there is some other commented code which calls this one - private PatternBlock FindExistingBlock (PatternBlock block, List blockList) - { - foreach (var searchBlock in blockList) - { - if (((block.StartLine > searchBlock.StartLine && block.StartLine < searchBlock.EndLine) || - (block.EndLine > searchBlock.StartLine && block.EndLine < searchBlock.EndLine)) && - block.StartLine != searchBlock.StartLine && - block.EndLine != searchBlock.EndLine - ) - { - return searchBlock; - } - } - - return null; - } - - private PatternBlock DetectBlock (int startNum, int startLineToSearch, int maxBlockLen, int maxDiffInBlock, int maxMisses, Dictionary processedLinesDict) - { - var targetLine = FindSimilarLine(startNum, startLineToSearch, processedLinesDict); - if (targetLine == -1) - { - return null; - } - - PatternBlock block = new() - { - StartLine = startNum - }; - var srcLine = block.StartLine; - block.TargetStart = targetLine; - var srcMisses = 0; - block.SrcLines.Add(srcLine, srcLine); - //block.targetLines.Add(targetLine, targetLine); - var len = 0; - QualityInfo qi = new() - { - Quality = block.Weigth - }; - block.QualityInfoList[targetLine] = qi; - - while (!_shouldCancel) - { - srcLine++; - len++; - //if (srcLine >= block.targetStart) - // break; // prevent to search in the own block - if (maxBlockLen > 0 && len > maxBlockLen) - { - break; - } - - var nextTargetLine = FindSimilarLine(srcLine, targetLine + 1, processedLinesDict); - if (nextTargetLine > -1 && nextTargetLine - targetLine - 1 <= maxDiffInBlock) - { - block.Weigth += maxDiffInBlock - (nextTargetLine - targetLine - 1) + 1; - block.EndLine = srcLine; - //block.targetLines.Add(nextTargetLine, nextTargetLine); - block.SrcLines.Add(srcLine, srcLine); - if (nextTargetLine - targetLine > 1) - { - var tempWeight = block.Weigth; - for (var tl = targetLine + 1; tl < nextTargetLine; ++tl) - { - qi = new QualityInfo - { - Quality = --tempWeight - }; - block.QualityInfoList[tl] = qi; - } - } - - targetLine = nextTargetLine; - qi = new QualityInfo - { - Quality = block.Weigth - }; - block.QualityInfoList[targetLine] = qi; - } - else - { - srcMisses++; - block.Weigth--; - targetLine++; - qi = new QualityInfo - { - Quality = block.Weigth - }; - block.QualityInfoList[targetLine] = qi; - if (srcMisses > maxMisses) - { - break; - } - } - } - - block.TargetEnd = targetLine; - qi = new QualityInfo - { - Quality = block.Weigth - }; - - block.QualityInfoList[targetLine] = qi; - - for (var k = block.TargetStart; k <= block.TargetEnd; ++k) - { - block.TargetLines.Add(k, k); - } - - return block; - } - - private void PrepareDict () - { - _lineHashList.Clear(); - Regex regex = new("\\d"); - Regex regex2 = new("\\S"); - - var num = _logFileReader.LineCount; - for (var i = 0; i < num; ++i) - { - var msg = GetMsgForLine(i); - if (msg != null) - { - msg = msg.ToLowerInvariant(); - msg = regex.Replace(msg, "0"); - msg = regex2.Replace(msg, " "); - var chars = msg.ToCharArray(); - var value = 0; - var numOfE = 0; - var numOfA = 0; - var numOfI = 0; - foreach (var t in chars) - { - value += t; - switch (t) - { - case 'e': - numOfE++; - break; - case 'a': - numOfA++; - break; - case 'i': - numOfI++; - break; - } - } - - value += numOfE * 30; - value += numOfA * 20; - value += numOfI * 10; - _lineHashList.Add(value); - } - } - } - - private int FindSimilarLine (int srcLine, int startLine) - { - var value = _lineHashList[srcLine]; - - var num = _lineHashList.Count; - for (var i = startLine; i < num; ++i) - { - if (Math.Abs(_lineHashList[i] - value) < 3) - { - return i; - } - } - - return -1; - } - - // int[,] similarCache; - - private void ResetCache (int num) - { - //this.similarCache = new int[num, num]; - //for (int i = 0; i < num; ++i) - //{ - // for (int j = 0; j < num; j++) - // { - // this.similarCache[i, j] = -1; - // } - //} - } - - private int FindSimilarLine (int srcLine, int startLine, Dictionary processedLinesDict) - { - var threshold = _patternArgs.Fuzzy; - - var prepared = false; - Regex regex = null; - Regex regex2 = null; - string msgToFind = null; - var culture = CultureInfo.CurrentCulture; - - var num = _logFileReader.LineCount; - for (var i = startLine; i < num; ++i) - { - if (processedLinesDict.ContainsKey(i)) - { - continue; - } - - //if (this.similarCache[srcLine, i] != -1) - //{ - // if (this.similarCache[srcLine, i] < threshold) - // { - // return i; - // } - //} - //else - { - if (!prepared) - { - msgToFind = GetMsgForLine(srcLine); - regex = new Regex("\\d"); - regex2 = new Regex("\\W"); - msgToFind = msgToFind.ToLower(culture); - msgToFind = regex.Replace(msgToFind, "0"); - msgToFind = regex2.Replace(msgToFind, " "); - prepared = true; - } - - var msg = GetMsgForLine(i); - if (msg != null) - { - msg = regex.Replace(msg, "0"); - msg = regex2.Replace(msg, " "); - var lenDiff = Math.Abs(msg.Length - msgToFind.Length); - if (lenDiff > threshold) - { - //this.similarCache[srcLine, i] = lenDiff; - continue; - } - - msg = msg.ToLower(culture); - var distance = Util.YetiLevenshtein(msgToFind, msg); - //this.similarCache[srcLine, i] = distance; - if (distance < threshold) - { - return i; - } - } - } - } - - return -1; - } - - private string GetMsgForLine (int i) - { - var line = _logFileReader.GetLogLine(i); - var columnizer = CurrentColumnizer; - ColumnizerCallback callback = new(this); - var cols = columnizer.SplitLine(callback, line); - return cols.ColumnValues.Last().FullValue; - } - - [SupportedOSPlatform("windows")] - private void ChangeRowHeight (bool decrease) - { - var rowNum = dataGridView.CurrentCellAddress.Y; - if (rowNum < 0 || rowNum >= dataGridView.RowCount) - { - return; - } - - if (decrease) - { - if (!_rowHeightList.TryGetValue(rowNum, out var entry)) - { - return; - } - else - { - entry.Height -= _lineHeight; - if (entry.Height <= _lineHeight) - { - _rowHeightList.Remove(rowNum); - } - } - } - else - { - RowHeightEntry entry; - if (!_rowHeightList.TryGetValue(rowNum, out var value)) - { - entry = new RowHeightEntry - { - LineNum = rowNum, - Height = _lineHeight - }; - - _rowHeightList[rowNum] = entry; - } - else - { - entry = value; - } - - entry.Height += _lineHeight; - } - - dataGridView.UpdateRowHeightInfo(rowNum, false); - if (rowNum == dataGridView.RowCount - 1 && _guiStateArgs.FollowTail) - { - dataGridView.FirstDisplayedScrollingRowIndex = rowNum; - } - - dataGridView.Refresh(); - } - - private int GetRowHeight (int rowNum) - { - return _rowHeightList.TryGetValue(rowNum, out var value) - ? value.Height - : _lineHeight; - } - - private void AddBookmarkAtLineSilently (int lineNum) - { - if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - _bookmarkProvider.AddBookmark(new Bookmark(lineNum)); - } - } - - [SupportedOSPlatform("windows")] - private void AddBookmarkAndEditComment () - { - var lineNum = dataGridView.CurrentCellAddress.Y; - if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - ToggleBookmark(); - } - - BookmarkComment(_bookmarkProvider.GetBookmarkForLine(lineNum)); - } - - [SupportedOSPlatform("windows")] - private void AddBookmarkComment (string text) - { - var lineNum = dataGridView.CurrentCellAddress.Y; - Bookmark bookmark; - if (!_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - _bookmarkProvider.AddBookmark(bookmark = new Bookmark(lineNum)); - } - else - { - bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); - } - - bookmark.Text += text; - dataGridView.Refresh(); - filterGridView.Refresh(); - OnBookmarkTextChanged(bookmark); - } - - [SupportedOSPlatform("windows")] - private void MarkCurrentFilterRange () - { - _filterParams.RangeSearchText = filterRangeComboBox.Text; - ColumnizerCallback callback = new(this); - RangeFinder rangeFinder = new(_filterParams, callback); - var range = rangeFinder.FindRange(dataGridView.CurrentCellAddress.Y); - if (range != null) - { - SetCellSelectionMode(false); - _noSelectionUpdates = true; - for (var i = range.StartLine; i <= range.EndLine; ++i) - { - dataGridView.Rows[i].Selected = true; - } - - _noSelectionUpdates = false; - UpdateSelectionDisplay(); - } - } - - [SupportedOSPlatform("windows")] - private void RemoveTempHighlights () - { - lock (_tempHighlightEntryListLock) - { - _tempHighlightEntryList.Clear(); - } - - RefreshAllGrids(); - } - - [SupportedOSPlatform("windows")] - private void ToggleHighlightPanel (bool open) - { - highlightSplitContainer.Panel2Collapsed = !open; - btnToggleHighlightPanel.Image = open - ? new Bitmap(_panelCloseButtonImage, new Size(btnToggleHighlightPanel.Size.Height, btnToggleHighlightPanel.Size.Height)) - : new Bitmap(_panelOpenButtonImage, new Size(btnToggleHighlightPanel.Size.Height, btnToggleHighlightPanel.Size.Height)); - } - - [SupportedOSPlatform("windows")] - private void SetBookmarksForSelectedFilterLines () - { - lock (_filterResultList) - { - foreach (DataGridViewRow row in filterGridView.SelectedRows) - { - var lineNum = _filterResultList[row.Index]; - AddBookmarkAtLineSilently(lineNum); - } - } - - dataGridView.Refresh(); - filterGridView.Refresh(); - OnBookmarkAdded(); - } - - private void SetDefaultHighlightGroup () - { - var group = _parentLogTabWin.FindHighlightGroupByFileMask(FileName); - if (group != null) - { - SetCurrentHighlightGroup(group.GroupName); - } - else - { - SetCurrentHighlightGroup("[Default]"); - } - } - - [SupportedOSPlatform("windows")] - private void HandleChangedFilterOnLoadSetting () - { - _parentLogTabWin.Preferences.IsFilterOnLoad = filterOnLoadCheckBox.Checked; - _parentLogTabWin.Preferences.IsAutoHideFilterList = hideFilterListOnLoadCheckBox.Checked; - OnFilterListChanged(this); - } - - private void FireCancelHandlers () - { - lock (_cancelHandlerList) - { - foreach (var handler in _cancelHandlerList) - { - handler.EscapePressed(); - } - } - } - - private void SyncOtherWindows (DateTime timestamp) - { - lock (_timeSyncListLock) - { - TimeSyncList?.NavigateToTimestamp(timestamp, this); - } - } - - [SupportedOSPlatform("windows")] - private void AddSlaveToTimesync (LogWindow slave) - { - lock (_timeSyncListLock) - { - if (TimeSyncList == null) - { - if (slave.TimeSyncList == null) - { - TimeSyncList = new TimeSyncList(); - TimeSyncList.AddWindow(this); - } - else - { - TimeSyncList = slave.TimeSyncList; - } - - var currentLineNum = dataGridView.CurrentCellAddress.Y; - var refLine = currentLineNum; - var timeStamp = GetTimestampForLine(ref refLine, true); - if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel) - { - TimeSyncList.CurrentTimestamp = timeStamp; - } - - TimeSyncList.WindowRemoved += OnTimeSyncListWindowRemoved; - } - } - - slave.AddToTimeSync(this); - OnSyncModeChanged(); - } - - private void FreeSlaveFromTimesync (LogWindow slave) - { - slave.FreeFromTimeSync(); - } - - private void OnSyncModeChanged () - { - SyncModeChanged?.Invoke(this, new SyncModeEventArgs(IsTimeSynced)); - } - - [SupportedOSPlatform("windows")] - private void AddSearchHitHighlightEntry (SearchParams para) - { - HighlightEntry he = new() - { - SearchText = para.SearchText, - ForegroundColor = Color.Red, - BackgroundColor = Color.Yellow, - IsRegEx = para.IsRegex, - IsCaseSensitive = para.IsCaseSensitive, - IsLedSwitch = false, - IsStopTail = false, - IsSetBookmark = false, - IsActionEntry = false, - ActionEntry = null, - IsWordMatch = true, - IsSearchHit = true - }; - - lock (_tempHighlightEntryListLock) - { - _tempHighlightEntryList.Add(he); - } - - RefreshAllGrids(); - } - - [SupportedOSPlatform("windows")] - private void RemoveAllSearchHighlightEntries () - { - lock (_tempHighlightEntryListLock) - { - List newList = []; - foreach (var he in _tempHighlightEntryList) - { - if (!he.IsSearchHit) - { - newList.Add(he); - } - } - - _tempHighlightEntryList = newList; - } - - RefreshAllGrids(); - } - - [SupportedOSPlatform("windows")] - private DataGridViewColumn GetColumnByName (BufferedDataGridView dataGridView, string name) - { - foreach (DataGridViewColumn col in dataGridView.Columns) - { - if (col.HeaderText.Equals(name, StringComparison.Ordinal)) - { - return col; - } - } - - return null; - } - - [SupportedOSPlatform("windows")] - private void SelectColumn () - { - var colName = columnComboBox.SelectedItem as string; - var col = GetColumnByName(dataGridView, colName); - if (col != null && !col.Frozen) - { - dataGridView.FirstDisplayedScrollingColumnIndex = col.Index; - var currentLine = dataGridView.CurrentCellAddress.Y; - if (currentLine >= 0) - { - dataGridView.CurrentCell = dataGridView.Rows[dataGridView.CurrentCellAddress.Y].Cells[col.Index]; - } - } - } - - #endregion - -} \ No newline at end of file diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs deleted file mode 100644 index 5f1a9832..00000000 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs +++ /dev/null @@ -1,1827 +0,0 @@ -using System.Text; - -using LogExpert.Core.Classes; -using LogExpert.Core.Classes.Columnizer; -using LogExpert.Core.Classes.Filter; -using LogExpert.Core.Classes.Highlight; -using LogExpert.Core.Classes.Persister; -using LogExpert.Core.Config; -using LogExpert.Core.Entities; -using LogExpert.Core.EventArguments; -using LogExpert.Dialogs; -using LogExpert.UI.Entities; -using LogExpert.UI.Extensions; - -namespace LogExpert.UI.Controls.LogWindow; - -partial class LogWindow -{ - #region Public methods - - public void LoadFile (string fileName, EncodingOptions encodingOptions) - { - EnterLoadFileStatus(); - - if (fileName != null) - { - FileName = fileName; - EncodingOptions = encodingOptions; - - if (_logFileReader != null) - { - _logFileReader.StopMonitoringAsync(); - UnRegisterLogFileReaderEvents(); - } - - // - // isUsingDefaultColumnizer is to enable automatically find the best columnizer. - // When a new log file is opened, and no Columnizer can be chose by file mask, - // this flag will enable find a columnizer automatically. - // Current solution is not elegant. - // Since the refactory will involving a lot of work, we can plan it in the future. - // One possible solution is, using raw file stream to read the sample lines to help - // the ColumnizerPicker to determine the priority. - // - var isUsingDefaultColumnizer = false; - if (!LoadPersistenceOptions()) - { - if (!IsTempFile) - { - var columnizer = FindColumnizer(); - if (columnizer != null) - { - if (_reloadMemento == null) - { - //TODO this needs to be refactored - var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - - columnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); - } - } - else - { - isUsingDefaultColumnizer = true; - } - - PreSelectColumnizer(columnizer); - } - - SetDefaultHighlightGroup(); - } - - // this may be set after loading persistence data - if (_fileNames != null && IsMultiFile) - { - LoadFilesAsMulti(_fileNames, EncodingOptions); - return; - } - - _columnCache = new ColumnCache(); - - try - { - _logFileReader = new(fileName, EncodingOptions, IsMultiFile, Preferences.BufferCount, Preferences.LinesPerBuffer, _multiFileOptions, PluginRegistry.PluginRegistry.Instance) - { - UseNewReader = !Preferences.UseLegacyReader - }; - } - catch (LogFileException lfe) - { - _logger.Error(lfe); - MessageBox.Show($"Cannot load file\n{lfe.Message}", "LogExpert"); - _ = BeginInvoke(new FunctionWith1BoolParam(Close), true); - _isLoadError = true; - return; - } - - if (CurrentColumnizer is ILogLineXmlColumnizer xmlColumnizer) - { - _logFileReader.IsXmlMode = true; - _logFileReader.XmlLogConfig = xmlColumnizer.GetXmlLogConfiguration(); - } - - if (_forcedColumnizerForLoading != null) - { - CurrentColumnizer = _forcedColumnizerForLoading; - } - - _logFileReader.PreProcessColumnizer = CurrentColumnizer is IPreProcessColumnizer processColumnizer ? processColumnizer : null; - - RegisterLogFileReaderEvents(); - _logger.Info($"Loading logfile: {fileName}"); - _logFileReader.StartMonitoring(); - - if (isUsingDefaultColumnizer) - { - if (Preferences.AutoPick) - { - var newColumnizer = ColumnizerPicker.FindBetterColumnizer(FileName, _logFileReader, CurrentColumnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - - if (newColumnizer != null) - { - _logger.Debug($"Picked new columnizer '{newColumnizer}'"); - - PreSelectColumnizer(newColumnizer); - } - } - } - } - } - - public void LoadFilesAsMulti (string[] fileNames, EncodingOptions encodingOptions) - { - _logger.Info("Loading given files as MultiFile:"); - - EnterLoadFileStatus(); - - foreach (var name in fileNames) - { - _logger.Info($"File: {name}"); - } - - if (_logFileReader != null) - { - _logFileReader.StopMonitoring(); - UnRegisterLogFileReaderEvents(); - } - - EncodingOptions = encodingOptions; - _columnCache = new ColumnCache(); - - _logFileReader = new(fileNames, EncodingOptions, Preferences.BufferCount, Preferences.LinesPerBuffer, _multiFileOptions, PluginRegistry.PluginRegistry.Instance) - { - UseNewReader = !Preferences.UseLegacyReader - }; - - RegisterLogFileReaderEvents(); - _logFileReader.StartMonitoring(); - FileName = fileNames[^1]; - _fileNames = fileNames; - IsMultiFile = true; - //if (this.isTempFile) - // this.Text = this.tempTitleName; - //else - // this.Text = Util.GetNameFromPath(this.FileName); - } - - public string SavePersistenceData (bool force) - { - if (!force) - { - if (!Preferences.SaveSessions) - { - return null; - } - } - - if (IsTempFile || _isLoadError) - { - return null; - } - - try - { - var persistenceData = GetPersistenceData(); - - return ForcedPersistenceFileName == null - ? Persister.SavePersistenceData(FileName, persistenceData, Preferences) - : Persister.SavePersistenceDataWithFixedName(ForcedPersistenceFileName, persistenceData); - } - catch (IOException ex) - { - _logger.Error(ex, "Error saving persistence: "); - } - catch (Exception e) - { - MessageBox.Show($"Unexpected error while saving persistence: {e.Message}"); - } - - return null; - } - - public PersistenceData GetPersistenceData () - { - PersistenceData persistenceData = new() - { - BookmarkList = _bookmarkProvider.BookmarkList, - RowHeightList = _rowHeightList, - MultiFile = IsMultiFile, - MultiFilePattern = _multiFileOptions.FormatPattern, - MultiFileMaxDays = _multiFileOptions.MaxDayTry, - CurrentLine = dataGridView.CurrentCellAddress.Y, - FirstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex, - FilterVisible = !splitContainerLogWindow.Panel2Collapsed, - FilterAdvanced = !advancedFilterSplitContainer.Panel1Collapsed, - FilterPosition = splitContainerLogWindow.SplitterDistance, - FollowTail = _guiStateArgs.FollowTail, - FileName = FileName, - TabName = Text, - SessionFileName = SessionFileName, - ColumnizerName = CurrentColumnizer.GetName(), - LineCount = _logFileReader.LineCount - }; - - _filterParams.IsFilterTail = filterTailCheckBox.Checked; // this option doesnt need a press on 'search' - - if (Preferences.SaveFilters) - { - List filterList = [_filterParams]; - persistenceData.FilterParamsList = filterList; - - foreach (var filterPipe in _filterPipeList) - { - FilterTabData data = new() - { - PersistenceData = filterPipe.OwnLogWindow.GetPersistenceData(), - FilterParams = filterPipe.FilterParams - }; - persistenceData.FilterTabDataList.Add(data); - } - } - - if (_currentHighlightGroup != null) - { - persistenceData.HighlightGroupName = _currentHighlightGroup.GroupName; - } - - if (_fileNames != null && IsMultiFile) - { - persistenceData.MultiFileNames.AddRange(_fileNames); - } - - //persistenceData.showBookmarkCommentColumn = this.bookmarkWindow.ShowBookmarkCommentColumn; - persistenceData.FilterSaveListVisible = !highlightSplitContainer.Panel2Collapsed; - persistenceData.Encoding = _logFileReader.CurrentEncoding; - - return persistenceData; - } - - public void Close (bool dontAsk) - { - Preferences.AskForClose = !dontAsk; - Close(); - } - - public void CloseLogWindow () - { - StopTimespreadThread(); - StopTimestampSyncThread(); - StopLogEventWorkerThread(); - _shouldCancel = true; - - if (_logFileReader != null) - { - UnRegisterLogFileReaderEvents(); - _logFileReader.StopMonitoringAsync(); - //this.logFileReader.DeleteAllContent(); - } - - if (_isLoading) - { - _waitingForClose = true; - } - - if (IsTempFile) - { - _logger.Info($"Deleting temp file {FileName}"); - - try - { - File.Delete(FileName); - } - catch (IOException e) - { - _logger.Error(e, $"Error while deleting temp file {FileName}: {e}"); - } - } - - FilterPipe?.CloseAndDisconnect(); - DisconnectFilterPipes(); - } - - public void WaitForLoadingFinished () - { - _externaLoadingFinishedEvent.WaitOne(); - } - - public void ForceColumnizer (ILogLineColumnizer columnizer) - { - //TODO this needs to be refactored - var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - - _forcedColumnizer = ColumnizerPicker.CloneColumnizer(columnizer, directory); - SetColumnizer(_forcedColumnizer); - } - - public void ForceColumnizerForLoading (ILogLineColumnizer columnizer) - { - //TODO this needs to be refactored - var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - - _forcedColumnizerForLoading = ColumnizerPicker.CloneColumnizer(columnizer, directory); - } - - public void PreselectColumnizer (string columnizerName) - { - //TODO this needs to be refactored - var directory = ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir; - - var columnizer = ColumnizerPicker.FindColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - PreSelectColumnizer(ColumnizerPicker.CloneColumnizer(columnizer, directory)); - } - - public void ColumnizerConfigChanged () - { - SetColumnizerInternal(CurrentColumnizer); - } - - public void SetColumnizer (ILogLineColumnizer columnizer, BufferedDataGridView gridView) - { - PaintHelper.SetColumnizer(columnizer, gridView); - - gridView.Refresh(); - AutoResizeColumns(gridView); - ApplyFrozenState(gridView); - } - - public IColumn GetCellValue (int rowIndex, int columnIndex) - { - if (columnIndex == 1) - { - return new Column - { - FullValue = $"{rowIndex + 1}" // line number - }; - } - - if (columnIndex == 0) // marker column - { - return Column.EmptyColumn; - } - - try - { - var cols = GetColumnsForLine(rowIndex); - if (cols != null && cols.ColumnValues != null) - { - if (columnIndex <= cols.ColumnValues.Length + 1) - { - var value = cols.ColumnValues[columnIndex - 2]; - - return value != null && value.DisplayValue != null - ? value - : value; - } - - return columnIndex == 2 - ? cols.ColumnValues[^1] - : Column.EmptyColumn; - } - } - catch - { - return Column.EmptyColumn; - } - - return Column.EmptyColumn; - } - - public void CellPainting (BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) - { - if (rowIndex < 0 || e.ColumnIndex < 0) - { - e.Handled = false; - return; - } - - var line = _logFileReader.GetLogLineWithWait(rowIndex).Result; - - if (line != null) - { - var entry = FindFirstNoWordMatchHilightEntry(line); - e.Graphics.SetClip(e.CellBounds); - - if (e.State.HasFlag(DataGridViewElementStates.Selected)) - { - using var brush = PaintHelper.GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); - e.Graphics.FillRectangle(brush, e.CellBounds); - } - else - { - e.CellStyle.BackColor = PaintHelper.GetBackColorFromHighlightEntry(entry); - e.PaintBackground(e.ClipBounds, false); - } - - if (DebugOptions.DisableWordHighlight) - { - e.PaintContent(e.CellBounds); - } - else - { - PaintCell(e, gridView, false, entry); - } - - if (e.ColumnIndex == 0) - { - if (_bookmarkProvider.IsBookmarkAtLine(rowIndex)) - { - Rectangle r; // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); - r = e.CellBounds; - r.Inflate(-2, -2); - using var brush = new SolidBrush(BookmarkColor); - e.Graphics.FillRectangle(brush, r); - - var bookmark = _bookmarkProvider.GetBookmarkForLine(rowIndex); - - if (bookmark.Text.Length > 0) - { - StringFormat format = new() - { - LineAlignment = StringAlignment.Center, - Alignment = StringAlignment.Center - }; - - using var brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); //dark orange - using var font = new Font("Courier New", Preferences.FontSize, FontStyle.Bold); - e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); - } - } - } - - e.Paint(e.CellBounds, DataGridViewPaintParts.Border); - e.Handled = true; - } - } - - public void OnDataGridViewCellPainting (object sender, DataGridViewCellPaintingEventArgs e) - { - var gridView = (BufferedDataGridView)sender; - CellPainting(gridView, e.RowIndex, e); - } - - /// - /// Returns the first HilightEntry that matches the given line - /// - /// - /// - /// - public HighlightEntry FindHighlightEntry (ITextValue line, bool noWordMatches) - { - // first check the temp entries - lock (_tempHighlightEntryListLock) - { - foreach (var entry in _tempHighlightEntryList) - { - if (noWordMatches && entry.IsWordMatch) - { - continue; - } - - if (CheckHighlightEntryMatch(entry, line)) - { - return entry; - } - } - } - - lock (_currentHighlightGroupLock) - { - foreach (var entry in _currentHighlightGroup.HighlightEntryList) - { - if (noWordMatches && entry.IsWordMatch) - { - continue; - } - if (CheckHighlightEntryMatch(entry, line)) - { - return entry; - } - } - return null; - } - } - - public IList FindHighlightMatches (ITextValue line) - { - IList resultList = []; - - if (line != null) - { - lock (_currentHighlightGroupLock) - { - GetHighlightEntryMatches(line, _currentHighlightGroup.HighlightEntryList, resultList); - } - - lock (_tempHighlightEntryList) - { - GetHighlightEntryMatches(line, _tempHighlightEntryList, resultList); - } - } - - return resultList; - } - - public void FollowTailChanged (bool isChecked, bool byTrigger) - { - _guiStateArgs.FollowTail = isChecked; - - if (_guiStateArgs.FollowTail && _logFileReader != null) - { - if (dataGridView.RowCount >= _logFileReader.LineCount && _logFileReader.LineCount > 0) - { - dataGridView.FirstDisplayedScrollingRowIndex = _logFileReader.LineCount - 1; - } - } - - BeginInvoke(new MethodInvoker(dataGridView.Refresh)); - //this.dataGridView.Refresh(); - _parentLogTabWin.FollowTailChanged(this, isChecked, byTrigger); - SendGuiStateUpdate(); - } - - public void TryToTruncate () - { - try - { - if (LockFinder.CheckIfFileIsLocked(Title)) - { - var name = LockFinder.FindLockedProcessName(Title); - StatusLineText($"Truncate failed: file is locked by {name}"); - } - else - { - File.WriteAllText(Title, ""); - } - } - catch (Exception ex) - { - _logger.Warn($"Unexpected issue truncating file: {ex.Message}"); - StatusLineText("Unexpected issue truncating file"); - throw; - } - } - - public void GotoLine (int line) - { - if (line >= 0) - { - if (line < dataGridView.RowCount) - { - SelectLine(line, false, true); - } - else - { - SelectLine(dataGridView.RowCount - 1, false, true); - } - dataGridView.Focus(); - } - } - - public void StartSearch () - { - _guiStateArgs.MenuEnabled = false; - GuiStateUpdate(this, _guiStateArgs); - var searchParams = _parentLogTabWin.SearchParams; - - searchParams.CurrentLine = (searchParams.IsForward || searchParams.IsFindNext) && !searchParams.IsShiftF3Pressed - ? dataGridView.CurrentCellAddress.Y + 1 - : dataGridView.CurrentCellAddress.Y - 1; - - _currentSearchParams = searchParams; // remember for async "not found" messages - - _isSearching = true; - _shouldCancel = false; - StatusLineText("Searching... Press ESC to cancel."); - - _progressEventArgs.MinValue = 0; - _progressEventArgs.MaxValue = dataGridView.RowCount; - _progressEventArgs.Value = 0; - _progressEventArgs.Visible = true; - SendProgressBarUpdate(); - - Task.Run(() => Search(searchParams)).ContinueWith(SearchComplete); - - RemoveAllSearchHighlightEntries(); - AddSearchHitHighlightEntry(searchParams); - } - - private void SearchComplete (Task task) - { - if (Disposing) - { - return; - } - - try - { - Invoke(new MethodInvoker(ResetProgressBar)); - var line = task.Result; - _guiStateArgs.MenuEnabled = true; - GuiStateUpdate(this, _guiStateArgs); - if (line == -1) - { - return; - } - - dataGridView.Invoke(new SelectLineFx((line1, triggerSyncCall) => SelectLine(line1, triggerSyncCall, true)), line, true); - } - catch (Exception ex) // in the case the windows is already destroyed - { - _logger.Warn(ex); - } - } - - public void SelectLogLine (int line) - { - Invoke(new SelectLineFx((line1, triggerSyncCall) => SelectLine(line1, triggerSyncCall, true)), line, true); - } - - public void SelectAndEnsureVisible (int line, bool triggerSyncCall) - { - try - { - SelectLine(line, triggerSyncCall, false); - - //if (!this.dataGridView.CurrentRow.Displayed) - if (line < dataGridView.FirstDisplayedScrollingRowIndex || line > dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false)) - { - dataGridView.FirstDisplayedScrollingRowIndex = line; - for (var i = 0; i < 8 && dataGridView.FirstDisplayedScrollingRowIndex > 0 && line < dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false); ++i) - { - dataGridView.FirstDisplayedScrollingRowIndex -= 1; - } - - if (line >= dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false)) - { - dataGridView.FirstDisplayedScrollingRowIndex += 1; - } - } - - dataGridView.CurrentCell = dataGridView.Rows[line].Cells[0]; - } - catch (Exception e) - { - // In rare situations there seems to be an invalid argument exceptions (or something like this). Concrete location isn't visible in stack - // trace because use of Invoke(). So catch it, and log (better than crashing the app). - _logger.Error(e); - } - } - - public void OnLogWindowKeyDown (object sender, KeyEventArgs e) - { - if (_isErrorShowing) - { - RemoveStatusLineError(); - } - - switch (e.KeyCode) - { - case Keys.F3 when _parentLogTabWin.SearchParams?.SearchText == null || _parentLogTabWin.SearchParams.SearchText.Length == 0: - { - return; - } - case Keys.F3: - { - _parentLogTabWin.SearchParams.IsFindNext = true; - _parentLogTabWin.SearchParams.IsShiftF3Pressed = (e.Modifiers & Keys.Shift) == Keys.Shift; - StartSearch(); - break; - } - case Keys.Escape: - { - if (_isSearching) - { - _shouldCancel = true; - } - - FireCancelHandlers(); - RemoveAllSearchHighlightEntries(); - break; - } - case Keys.E when (e.Modifiers & Keys.Control) == Keys.Control: - { - StartEditMode(); - - break; - } - case Keys.Down when e.Modifiers == Keys.Alt: - { - var newLine = _logFileReader.GetNextMultiFileLine(dataGridView.CurrentCellAddress.Y); - - if (newLine != -1) - { - SelectLine(newLine, false, true); - } - - e.Handled = true; - - break; - } - case Keys.Up when e.Modifiers == Keys.Alt: - { - var newLine = _logFileReader.GetPrevMultiFileLine(dataGridView.CurrentCellAddress.Y); - - if (newLine != -1) - { - SelectLine(newLine - 1, false, true); - } - - e.Handled = true; - - break; - } - case Keys.Enter when dataGridView.Focused: - { - ChangeRowHeight(e.Shift); - e.Handled = true; - - break; - } - case Keys.Back when dataGridView.Focused: - { - ChangeRowHeight(true); - e.Handled = true; - - break; - } - case Keys.PageUp when e.Modifiers == Keys.Alt: - { - SelectPrevHighlightLine(); - e.Handled = true; - - break; - } - case Keys.PageDown when e.Modifiers == Keys.Alt: - { - SelectNextHighlightLine(); - e.Handled = true; - - break; - } - case Keys.T when (e.Modifiers & Keys.Control) == Keys.Control && (e.Modifiers & Keys.Shift) == Keys.Shift: - { - FilterToTab(); - break; - } - } - } - - public void AddBookmarkOverlays () - { - const int OVERSCAN = 20; - - var firstLine = dataGridView.FirstDisplayedScrollingRowIndex; - if (firstLine < 0) - { - return; - } - - firstLine -= OVERSCAN; - if (firstLine < 0) - { - firstLine = 0; - } - - var oversizeCount = OVERSCAN; - - for (var i = firstLine; i < dataGridView.RowCount; ++i) - { - if (!dataGridView.Rows[i].Displayed && i > dataGridView.FirstDisplayedScrollingRowIndex) - { - if (oversizeCount-- < 0) - { - break; - } - } - - if (_bookmarkProvider.IsBookmarkAtLine(i)) - { - var bookmark = _bookmarkProvider.GetBookmarkForLine(i); - if (bookmark.Text.Length > 0) - { - //BookmarkOverlay overlay = new BookmarkOverlay(); - var overlay = bookmark.Overlay; - overlay.Bookmark = bookmark; - - Rectangle r; - if (dataGridView.Rows[i].Displayed) - { - r = dataGridView.GetCellDisplayRectangle(0, i, false); - } - else - { - r = dataGridView.GetCellDisplayRectangle(0, dataGridView.FirstDisplayedScrollingRowIndex, false); - //int count = i - this.dataGridView.FirstDisplayedScrollingRowIndex; - var heightSum = 0; - if (dataGridView.FirstDisplayedScrollingRowIndex < i) - { - for (var rn = dataGridView.FirstDisplayedScrollingRowIndex + 1; rn < i; ++rn) - { - //Rectangle rr = this.dataGridView.GetCellDisplayRectangle(0, rn, false); - //heightSum += rr.Height; - heightSum += GetRowHeight(rn); - } - - r.Offset(0, r.Height + heightSum); - } - else - { - for (var rn = dataGridView.FirstDisplayedScrollingRowIndex + 1; rn > i; --rn) - { - //Rectangle rr = this.dataGridView.GetCellDisplayRectangle(0, rn, false); - //heightSum += rr.Height; - heightSum += GetRowHeight(rn); - } - - r.Offset(0, -(r.Height + heightSum)); - } - //r.Offset(0, this.dataGridView.DisplayRectangle.Height); - } - - if (_logger.IsDebugEnabled) - { - _logger.Debug($"AddBookmarkOverlay() r.Location={r.Location.X}, width={r.Width}, scroll_offset={dataGridView.HorizontalScrollingOffset}"); - } - - overlay.Position = r.Location - new Size(dataGridView.HorizontalScrollingOffset, 0); - overlay.Position += new Size(10, r.Height / 2); - dataGridView.AddOverlay(overlay); - } - } - } - } - - public void ToggleBookmark () - { - BufferedDataGridView gridView; - int lineNum; - - if (filterGridView.Focused) - { - gridView = filterGridView; - if (gridView.CurrentCellAddress.Y == -1) - { - return; - } - - lineNum = _filterResultList[gridView.CurrentCellAddress.Y]; - } - else - { - gridView = dataGridView; - if (gridView.CurrentCellAddress.Y == -1) - { - return; - } - lineNum = dataGridView.CurrentCellAddress.Y; - } - - ToggleBookmark(lineNum); - } - - public void ToggleBookmark (int lineNum) - { - if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - var bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); - - if (string.IsNullOrEmpty(bookmark.Text) == false) - { - if (DialogResult.No == MessageBox.Show("There's a comment attached to the bookmark. Really remove the bookmark?", "LogExpert", MessageBoxButtons.YesNo)) - { - return; - } - } - _bookmarkProvider.RemoveBookmarkForLine(lineNum); - } - else - { - _bookmarkProvider.AddBookmark(new Bookmark(lineNum)); - } - dataGridView.Refresh(); - filterGridView.Refresh(); - OnBookmarkAdded(); - } - - public void SetBookmarkFromTrigger (int lineNum, string comment) - { - lock (_bookmarkLock) - { - var line = _logFileReader.GetLogLine(lineNum); - if (line == null) - { - return; - } - var paramParser = new ParamParser(comment); - try - { - comment = paramParser.ReplaceParams(line, lineNum, FileName); - } - catch (ArgumentException) - { - // occurs on invalid regex - } - if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - _bookmarkProvider.RemoveBookmarkForLine(lineNum); - } - _bookmarkProvider.AddBookmark(new Bookmark(lineNum, comment)); - OnBookmarkAdded(); - } - } - - public void JumpNextBookmark () - { - if (_bookmarkProvider.Bookmarks.Count > 0) - { - if (filterGridView.Focused) - { - var index = FindNextBookmarkIndex(_filterResultList[filterGridView.CurrentCellAddress.Y]); - var startIndex = index; - var wrapped = false; - while (true) - { - var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; - if (_filterResultList.Contains(lineNum)) - { - var filterLine = _filterResultList.IndexOf(lineNum); - filterGridView.Rows[filterLine].Selected = true; - filterGridView.CurrentCell = filterGridView.Rows[filterLine].Cells[0]; - break; - } - index++; - if (index > _bookmarkProvider.Bookmarks.Count - 1) - { - index = 0; - wrapped = true; - } - if (index >= startIndex && wrapped) - { - break; - } - } - } - else - { - var index = FindNextBookmarkIndex(dataGridView.CurrentCellAddress.Y); - if (index > _bookmarkProvider.Bookmarks.Count - 1) - { - index = 0; - } - - var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; - SelectLine(lineNum, true, true); - } - } - } - - public void JumpPrevBookmark () - { - if (_bookmarkProvider.Bookmarks.Count > 0) - { - if (filterGridView.Focused) - { - //int index = this.bookmarkList.BinarySearch(this.filterResultList[this.filterGridView.CurrentCellAddress.Y]); - //if (index < 0) - // index = ~index; - //index--; - var index = FindPrevBookmarkIndex(_filterResultList[filterGridView.CurrentCellAddress.Y]); - if (index < 0) - { - index = _bookmarkProvider.Bookmarks.Count - 1; - } - var startIndex = index; - var wrapped = false; - while (true) - { - var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; - if (_filterResultList.Contains(lineNum)) - { - var filterLine = _filterResultList.IndexOf(lineNum); - filterGridView.Rows[filterLine].Selected = true; - filterGridView.CurrentCell = filterGridView.Rows[filterLine].Cells[0]; - break; - } - index--; - if (index < 0) - { - index = _bookmarkProvider.Bookmarks.Count - 1; - wrapped = true; - } - if (index <= startIndex && wrapped) - { - break; - } - } - } - else - { - var index = FindPrevBookmarkIndex(dataGridView.CurrentCellAddress.Y); - if (index < 0) - { - index = _bookmarkProvider.Bookmarks.Count - 1; - } - - var lineNum = _bookmarkProvider.Bookmarks[index].LineNum; - SelectLine(lineNum, false, true); - } - } - } - - public void DeleteBookmarks (List lineNumList) - { - var bookmarksPresent = false; - foreach (var lineNum in lineNumList) - { - if (lineNum != -1) - { - if (_bookmarkProvider.IsBookmarkAtLine(lineNum) && - _bookmarkProvider.GetBookmarkForLine(lineNum).Text.Length > 0) - { - bookmarksPresent = true; - } - } - } - if (bookmarksPresent) - { - if ( - MessageBox.Show("There are some comments in the bookmarks. Really remove bookmarks?", "LogExpert", - MessageBoxButtons.YesNo) == DialogResult.No) - { - return; - } - } - _bookmarkProvider.RemoveBookmarksForLines(lineNumList); - OnBookmarkRemoved(); - } - - public void SetTimeshiftValue (string value) - { - _guiStateArgs.TimeshiftText = value; - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - try - { - if (_guiStateArgs.TimeshiftEnabled) - { - try - { - var text = _guiStateArgs.TimeshiftText; - if (text.StartsWith("+")) - { - text = text.Substring(1); - } - var timeSpan = TimeSpan.Parse(text); - var diff = (int)(timeSpan.Ticks / TimeSpan.TicksPerMillisecond); - CurrentColumnizer.SetTimeOffset(diff); - } - catch (Exception) - { - CurrentColumnizer.SetTimeOffset(0); - } - } - else - { - CurrentColumnizer.SetTimeOffset(0); - } - dataGridView.Refresh(); - filterGridView.Refresh(); - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - SetTimestampLimits(); - SyncTimestampDisplay(); - } - } - catch (FormatException ex) - { - _logger.Error(ex); - } - } - } - - public void ToggleFilterPanel () - { - splitContainerLogWindow.Panel2Collapsed = !splitContainerLogWindow.Panel2Collapsed; - if (!splitContainerLogWindow.Panel2Collapsed) - { - filterComboBox.Focus(); - } - else - { - dataGridView.Focus(); - } - } - - public void LogWindowActivated () - { - if (_guiStateArgs.FollowTail && !_isDeadFile) - { - OnTailFollowed(EventArgs.Empty); - } - - if (Preferences.TimestampControl) - { - SetTimestampLimits(); - SyncTimestampDisplay(); - } - - dataGridView.Focus(); - - SendGuiStateUpdate(); - SendStatusLineUpdate(); - SendProgressBarUpdate(); - } - - public void SetCellSelectionMode (bool isCellMode) - { - if (isCellMode) - { - //possible performance issue, see => https://docs.microsoft.com/en-us/dotnet/desktop/winforms/controls/best-practices-for-scaling-the-windows-forms-datagridview-control?view=netframeworkdesktop-4.8#using-the-selected-cells-rows-and-columns-collections-efficiently - dataGridView.SelectionMode = DataGridViewSelectionMode.CellSelect; - } - else - { - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - } - - _guiStateArgs.CellSelectMode = isCellMode; - } - - public void TimeshiftEnabled (bool isEnabled, string shiftValue) - { - _guiStateArgs.TimeshiftEnabled = isEnabled; - SetTimestampLimits(); - SetTimeshiftValue(shiftValue); - } - - public void CopyMarkedLinesToTab () - { - if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) - { - var lineNumList = new List(); - foreach (DataGridViewRow row in dataGridView.SelectedRows) - { - if (row.Index != -1) - { - lineNumList.Add(row.Index); - } - } - - lineNumList.Sort(); - // create dummy FilterPipe for connecting line numbers to original window - // setting IsStopped to true prevents further filter processing - var pipe = new FilterPipe(new FilterParams(), this) - { - IsStopped = true - }; - WritePipeToTab(pipe, lineNumList, Text + "->C", null); - } - else - { - var fileName = Path.GetTempFileName(); - var fStream = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.Read); - var writer = new StreamWriter(fStream, Encoding.Unicode); - - var data = dataGridView.GetClipboardContent(); - var text = data.GetText(TextDataFormat.Text); - writer.Write(text); - - writer.Close(); - var title = Util.GetNameFromPath(FileName) + "->Clip"; - _parentLogTabWin.AddTempFileTab(fileName, title); - } - } - - /// - /// Change the file encoding. May force a reload if byte count ot preamble lenght differs from previous used encoding. - /// - /// - public void ChangeEncoding (Encoding encoding) - { - _logFileReader.ChangeEncoding(encoding); - EncodingOptions.Encoding = encoding; - if (_guiStateArgs.CurrentEncoding.IsSingleByte != encoding.IsSingleByte || - _guiStateArgs.CurrentEncoding.GetPreamble().Length != encoding.GetPreamble().Length) - { - Reload(); - } - else - { - dataGridView.Refresh(); - SendGuiStateUpdate(); - } - _guiStateArgs.CurrentEncoding = _logFileReader.CurrentEncoding; - } - - public void Reload () - { - SavePersistenceData(false); - - _reloadMemento = new ReloadMemento - { - CurrentLine = dataGridView.CurrentCellAddress.Y, - FirstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex - }; - _forcedColumnizerForLoading = CurrentColumnizer; - - if (_fileNames == null || !IsMultiFile) - { - LoadFile(FileName, EncodingOptions); - } - else - { - LoadFilesAsMulti(_fileNames, EncodingOptions); - } - //if (currentLine < this.dataGridView.RowCount && currentLine >= 0) - // this.dataGridView.CurrentCell = this.dataGridView.Rows[currentLine].Cells[0]; - //if (firstDisplayedLine < this.dataGridView.RowCount && firstDisplayedLine >= 0) - // this.dataGridView.FirstDisplayedScrollingRowIndex = firstDisplayedLine; - - //if (this.filterTailCheckBox.Checked) - //{ - // _logger.logInfo("Refreshing filter view because of reload."); - // FilterSearch(); - //} - } - - public void PreferencesChanged (string fontName, float fontSize, bool setLastColumnWidth, int lastColumnWidth, bool isLoadTime, SettingsFlags flags) - { - if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors) - { - NormalFont = new Font(new FontFamily(fontName), fontSize); - BoldFont = new Font(NormalFont, FontStyle.Bold); - MonospacedFont = new Font("Courier New", Preferences.FontSize, FontStyle.Bold); - - var lineSpacing = NormalFont.FontFamily.GetLineSpacing(FontStyle.Regular); - var lineSpacingPixel = NormalFont.Size * lineSpacing / NormalFont.FontFamily.GetEmHeight(FontStyle.Regular); - - dataGridView.DefaultCellStyle.Font = NormalFont; - filterGridView.DefaultCellStyle.Font = NormalFont; - _lineHeight = NormalFont.Height + 4; - dataGridView.RowTemplate.Height = NormalFont.Height + 4; - - ShowBookmarkBubbles = Preferences.ShowBubbles; - - ApplyDataGridViewPrefs(dataGridView, setLastColumnWidth, lastColumnWidth); - ApplyDataGridViewPrefs(filterGridView, setLastColumnWidth, lastColumnWidth); - - if (Preferences.TimestampControl) - { - SetTimestampLimits(); - SyncTimestampDisplay(); - } - - if (isLoadTime) - { - filterTailCheckBox.Checked = Preferences.FilterTail; - syncFilterCheckBox.Checked = Preferences.FilterSync; - //this.FollowTailChanged(this.Preferences.followTail, false); - } - - _timeSpreadCalc.TimeMode = Preferences.TimeSpreadTimeMode; - timeSpreadingControl.ForeColor = Preferences.TimeSpreadColor; - timeSpreadingControl.ReverseAlpha = Preferences.ReverseAlpha; - - if (CurrentColumnizer.IsTimeshiftImplemented()) - { - timeSpreadingControl.Invoke(new MethodInvoker(timeSpreadingControl.Refresh)); - ShowTimeSpread(Preferences.ShowTimeSpread); - } - - ToggleColumnFinder(Preferences.ShowColumnFinder, false); - } - - if ((flags & SettingsFlags.FilterList) == SettingsFlags.FilterList) - { - HandleChangedFilterList(); - } - - if ((flags & SettingsFlags.FilterHistory) == SettingsFlags.FilterHistory) - { - UpdateFilterHistoryFromSettings(); - - if (isLoadTime) - { - AutoResizeFilterBox(); - } - } - } - - public bool ScrollToTimestamp (DateTime timestamp, bool roundToSeconds, bool triggerSyncCall) - { - if (InvokeRequired) - { - BeginInvoke(new ScrollToTimestampFx(ScrollToTimestampWorker), timestamp, roundToSeconds, triggerSyncCall); - return true; - } - - return ScrollToTimestampWorker(timestamp, roundToSeconds, triggerSyncCall); - } - - public bool ScrollToTimestampWorker (DateTime timestamp, bool roundToSeconds, bool triggerSyncCall) - { - var hasScrolled = false; - if (!CurrentColumnizer.IsTimeshiftImplemented() || dataGridView.RowCount == 0) - { - return false; - } - - //this.Cursor = Cursors.WaitCursor; - var currentLine = dataGridView.CurrentCellAddress.Y; - if (currentLine < 0 || currentLine >= dataGridView.RowCount) - { - currentLine = 0; - } - var foundLine = FindTimestampLine(currentLine, timestamp, roundToSeconds); - if (foundLine >= 0) - { - SelectAndEnsureVisible(foundLine, triggerSyncCall); - hasScrolled = true; - } - //this.Cursor = Cursors.Default; - return hasScrolled; - } - - public int FindTimestampLine (int lineNum, DateTime timestamp, bool roundToSeconds) - { - var foundLine = - FindTimestampLine_Internal(lineNum, 0, dataGridView.RowCount - 1, timestamp, roundToSeconds); - if (foundLine >= 0) - { - // go backwards to the first occurence of the hit - var foundTimestamp = GetTimestampForLine(ref foundLine, roundToSeconds); - while (foundTimestamp.CompareTo(timestamp) == 0 && foundLine >= 0) - { - foundLine--; - foundTimestamp = GetTimestampForLine(ref foundLine, roundToSeconds); - } - if (foundLine < 0) - { - return 0; - } - - foundLine++; - GetTimestampForLineForward(ref foundLine, roundToSeconds); // fwd to next valid timestamp - return foundLine; - } - - return -foundLine; - } - - public int FindTimestampLine_Internal (int lineNum, int rangeStart, int rangeEnd, DateTime timestamp, - bool roundToSeconds) - { - _logger.Debug("FindTimestampLine_Internal(): timestamp={0}, lineNum={1}, rangeStart={2}, rangeEnd={3}", timestamp, lineNum, rangeStart, rangeEnd); - var refLine = lineNum; - var currentTimestamp = GetTimestampForLine(ref refLine, roundToSeconds); - if (currentTimestamp.CompareTo(timestamp) == 0) - { - return lineNum; - } - - if (timestamp < currentTimestamp) - { - //rangeStart = rangeStart; - rangeEnd = lineNum; - } - else - { - rangeStart = lineNum; - //rangeEnd = rangeEnd; - } - - if (rangeEnd - rangeStart <= 0) - { - return -lineNum; - } - - lineNum = ((rangeEnd - rangeStart) / 2) + rangeStart; - // prevent endless loop - if (rangeEnd - rangeStart < 2) - { - currentTimestamp = GetTimestampForLine(ref rangeStart, roundToSeconds); - if (currentTimestamp.CompareTo(timestamp) == 0) - { - return rangeStart; - } - - currentTimestamp = GetTimestampForLine(ref rangeEnd, roundToSeconds); - - return currentTimestamp.CompareTo(timestamp) == 0 - ? rangeEnd - : -lineNum; - } - - return FindTimestampLine_Internal(lineNum, rangeStart, rangeEnd, timestamp, roundToSeconds); - } - - /** - * Get the timestamp for the given line number. If the line - * has no timestamp, the previous line will be checked until a - * timestamp is found. - */ - public DateTime GetTimestampForLine (ref int lineNum, bool roundToSeconds) - { - lock (_currentColumnizerLock) - { - if (!CurrentColumnizer.IsTimeshiftImplemented()) - { - return DateTime.MinValue; - } - - _logger.Debug($"GetTimestampForLine({lineNum}) enter"); - var timeStamp = DateTime.MinValue; - var lookBack = false; - if (lineNum >= 0 && lineNum < dataGridView.RowCount) - { - while (timeStamp.CompareTo(DateTime.MinValue) == 0 && lineNum >= 0) - { - if (_isTimestampDisplaySyncing && _shouldTimestampDisplaySyncingCancel) - { - return DateTime.MinValue; - } - - lookBack = true; - var logLine = _logFileReader.GetLogLine(lineNum); - if (logLine == null) - { - return DateTime.MinValue; - } - - ColumnizerCallbackObject.LineNum = lineNum; - timeStamp = CurrentColumnizer.GetTimestamp(ColumnizerCallbackObject, logLine); - if (roundToSeconds) - { - timeStamp = timeStamp.Subtract(TimeSpan.FromMilliseconds(timeStamp.Millisecond)); - } - - lineNum--; - } - } - - if (lookBack) - { - lineNum++; - } - - _logger.Debug("GetTimestampForLine() leave with lineNum={0}", lineNum); - return timeStamp; - } - } - - /** - * Get the timestamp for the given line number. If the line - * has no timestamp, the next line will be checked until a - * timestamp is found. - */ - public DateTime GetTimestampForLineForward (ref int lineNum, bool roundToSeconds) - { - lock (_currentColumnizerLock) - { - if (!CurrentColumnizer.IsTimeshiftImplemented()) - { - return DateTime.MinValue; - } - - var timeStamp = DateTime.MinValue; - var lookFwd = false; - if (lineNum >= 0 && lineNum < dataGridView.RowCount) - { - while (timeStamp.CompareTo(DateTime.MinValue) == 0 && lineNum < dataGridView.RowCount) - { - lookFwd = true; - var logLine = _logFileReader.GetLogLine(lineNum); - if (logLine == null) - { - timeStamp = DateTime.MinValue; - break; - } - timeStamp = CurrentColumnizer.GetTimestamp(ColumnizerCallbackObject, logLine); - if (roundToSeconds) - { - timeStamp = timeStamp.Subtract(TimeSpan.FromMilliseconds(timeStamp.Millisecond)); - } - lineNum++; - } - } - if (lookFwd) - { - lineNum--; - } - return timeStamp; - } - } - - public void AppFocusLost () - { - InvalidateCurrentRow(dataGridView); - } - - public void AppFocusGained () - { - InvalidateCurrentRow(dataGridView); - } - - public ILogLine GetCurrentLine () - { - if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index != -1) - { - return _logFileReader.GetLogLine(dataGridView.CurrentRow.Index); - } - return null; - } - - public ILogLine GetLine (int lineNum) - { - if (lineNum < 0 || _logFileReader == null || lineNum >= _logFileReader.LineCount) - { - return null; - } - return _logFileReader.GetLogLine(lineNum); - } - - public int GetCurrentLineNum () - { - if (dataGridView.CurrentRow == null) - { - return -1; - } - return dataGridView.CurrentRow.Index; - } - - public int GetRealLineNum () - { - var lineNum = GetCurrentLineNum(); - if (lineNum == -1) - { - return -1; - } - return _logFileReader.GetRealLineNumForVirtualLineNum(lineNum); - } - - public ILogFileInfo GetCurrentFileInfo () - { - if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index != -1) - { - return _logFileReader.GetLogFileInfoForLine(dataGridView.CurrentRow.Index); - } - return null; - } - - /// - /// zero-based - /// - /// - /// - public string GetCurrentFileName (int lineNum) - { - return _logFileReader.GetLogFileNameForLine(lineNum); - } - - // =============== end of bookmark stuff =================================== - - public void ShowLineColumn (bool show) - { - dataGridView.Columns[1].Visible = show; - filterGridView.Columns[1].Visible = show; - } - - // ================================================================= - // Pattern statistics - // ================================================================= - - public void PatternStatistic () - { - InitPatternWindow(); - } - - public void PatternStatisticSelectRange (PatternArgs patternArgs) - { - if (dataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) - { - List lineNumList = []; - foreach (DataGridViewRow row in dataGridView.SelectedRows) - { - if (row.Index != -1) - { - lineNumList.Add(row.Index); - } - } - lineNumList.Sort(); - patternArgs.StartLine = lineNumList[0]; - patternArgs.EndLine = lineNumList[^1]; - } - else - { - patternArgs.StartLine = dataGridView.CurrentCellAddress.Y != -1 - ? dataGridView.CurrentCellAddress.Y - : 0; - patternArgs.EndLine = dataGridView.RowCount - 1; - } - } - - public void PatternStatistic (PatternArgs patternArgs) - { - var fx = new PatternStatisticFx(TestStatistic); - fx.BeginInvoke(patternArgs, null, null); - } - - public void ExportBookmarkList () - { - SaveFileDialog dlg = new() - { - Title = "Choose a file to save bookmarks into", - AddExtension = true, - DefaultExt = "csv", - Filter = "CSV file (*.csv)|*.csv|Bookmark file (*.bmk)|*.bmk", - FilterIndex = 1, - FileName = Path.GetFileNameWithoutExtension(FileName) - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - try - { - BookmarkExporter.ExportBookmarkList(_bookmarkProvider.BookmarkList, FileName, - dlg.FileName); - } - catch (IOException e) - { - _logger.Error(e); - MessageBox.Show("Error while exporting bookmark list: " + e.Message, "LogExpert"); - } - } - } - - public void ImportBookmarkList () - { - OpenFileDialog dlg = new() - { - Title = "Choose a file to load bookmarks from", - AddExtension = true, - DefaultExt = "csv", - Filter = "CSV file (*.csv)|*.csv|Bookmark file (*.bmk)|*.bmk", - FilterIndex = 1, - FileName = Path.GetFileNameWithoutExtension(FileName) - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - try - { - // add to the existing bookmarks - SortedList newBookmarks = []; - BookmarkExporter.ImportBookmarkList(FileName, dlg.FileName, newBookmarks); - - // Add (or replace) to existing bookmark list - var bookmarkAdded = false; - foreach (var b in newBookmarks.Values) - { - if (!_bookmarkProvider.BookmarkList.ContainsKey(b.LineNum)) - { - _bookmarkProvider.BookmarkList.Add(b.LineNum, b); - bookmarkAdded = true; // refresh the list only once at the end - } - else - { - var existingBookmark = _bookmarkProvider.BookmarkList[b.LineNum]; - existingBookmark.Text = - b.Text; // replace existing bookmark for that line, preserving the overlay - OnBookmarkTextChanged(b); - } - } - - // Refresh the lists - if (bookmarkAdded) - { - OnBookmarkAdded(); - } - dataGridView.Refresh(); - filterGridView.Refresh(); - } - catch (IOException e) - { - _logger.Error(e); - MessageBox.Show($"Error while importing bookmark list: {e.Message}", "LogExpert"); - } - } - } - - public bool IsAdvancedOptionActive () - { - return rangeCheckBox.Checked || - fuzzyKnobControl.Value > 0 || - filterKnobBackSpread.Value > 0 || - filterKnobForeSpread.Value > 0 || - invertFilterCheckBox.Checked || - columnRestrictCheckBox.Checked; - } - - public void HandleChangedFilterList () - { - Invoke(new MethodInvoker(HandleChangedFilterListWorker)); - } - - public void HandleChangedFilterListWorker () - { - var index = filterListBox.SelectedIndex; - filterListBox.Items.Clear(); - foreach (var filterParam in ConfigManager.Settings.FilterList) - { - filterListBox.Items.Add(filterParam); - } - filterListBox.Refresh(); - if (index >= 0 && index < filterListBox.Items.Count) - { - filterListBox.SelectedIndex = index; - } - filterOnLoadCheckBox.Checked = Preferences.IsFilterOnLoad; - hideFilterListOnLoadCheckBox.Checked = Preferences.IsAutoHideFilterList; - } - - public void SetCurrentHighlightGroup (string groupName) - { - _guiStateArgs.HighlightGroupName = groupName; - lock (_currentHighlightGroupLock) - { - _currentHighlightGroup = _parentLogTabWin.FindHighlightGroup(groupName); - - _currentHighlightGroup ??= _parentLogTabWin.HighlightGroupList.Count > 0 - ? _parentLogTabWin.HighlightGroupList[0] - : new HighlightGroup(); - - _guiStateArgs.HighlightGroupName = _currentHighlightGroup.GroupName; - } - - SendGuiStateUpdate(); - BeginInvoke(new MethodInvoker(RefreshAllGrids)); - } - - public void SwitchMultiFile (bool enabled) - { - IsMultiFile = enabled; - Reload(); - } - - public void AddOtherWindowToTimesync (LogWindow other) - { - if (other.IsTimeSynced) - { - if (IsTimeSynced) - { - other.FreeFromTimeSync(); - AddSlaveToTimesync(other); - } - else - { - AddToTimeSync(other); - } - } - else - { - AddSlaveToTimesync(other); - } - } - - public void AddToTimeSync (LogWindow master) - { - _logger.Info($"Syncing window for {Util.GetNameFromPath(FileName)} to {Util.GetNameFromPath(master.FileName)}"); - lock (_timeSyncListLock) - { - if (IsTimeSynced && master.TimeSyncList != TimeSyncList) - // already synced but master has different sync list - { - FreeFromTimeSync(); - } - - TimeSyncList = master.TimeSyncList; - TimeSyncList.AddWindow(this); - ScrollToTimestamp(TimeSyncList.CurrentTimestamp, false, false); - } - - OnSyncModeChanged(); - } - - public void FreeFromTimeSync () - { - lock (_timeSyncListLock) - { - if (TimeSyncList != null) - { - _logger.Info($"De-Syncing window for {Util.GetNameFromPath(FileName)}"); - TimeSyncList.WindowRemoved -= OnTimeSyncListWindowRemoved; - TimeSyncList.RemoveWindow(this); - TimeSyncList = null; - } - } - - OnSyncModeChanged(); - } - - public void RefreshLogView () - { - RefreshAllGrids(); - } - - #endregion -} \ No newline at end of file diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs index 88889378..2eb2d0f7 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs @@ -1,14 +1,32 @@ +using System.ComponentModel; +using System.Diagnostics; +using System.Globalization; using System.Reflection; using System.Runtime.Versioning; +using System.Security; using System.Text; +using System.Text.RegularExpressions; +using LogExpert.Core.Classes; +using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Classes.Filter; +using LogExpert.Core.Classes.Persister; using LogExpert.Core.Config; using LogExpert.Core.Entities; +using LogExpert.Core.Enums; +using LogExpert.Core.EventArguments; using LogExpert.Core.Interface; using LogExpert.Dialogs; +using LogExpert.PluginRegistry.FileSystem; +using LogExpert.UI.Dialogs; +using LogExpert.UI.Entities; +using LogExpert.UI.Extensions; +using LogExpert.UI.Extensions.LogWindow; using NLog; +using WeifenLuo.WinFormsUI.Docking; + namespace LogExpert.UI.Controls.LogTabWindow; // Data shared over all LogTabWindow instances @@ -261,4 +279,2773 @@ private class LogWindowData #endregion } + + #region Public methods + + [SupportedOSPlatform("windows")] + public LogWindow.LogWindow AddTempFileTab (string fileName, string title) + { + return AddFileTab(fileName, true, title, false, null); + } + + [SupportedOSPlatform("windows")] + public LogWindow.LogWindow AddFilterTab (FilterPipe pipe, string title, ILogLineColumnizer preProcessColumnizer) + { + var logWin = AddFileTab(pipe.FileName, true, title, false, preProcessColumnizer); + if (pipe.FilterParams.SearchText.Length > 0) + { + ToolTip tip = new(components); + + tip.SetToolTip(logWin, + "Filter: \"" + pipe.FilterParams.SearchText + "\"" + + (pipe.FilterParams.IsInvert ? " (Invert match)" : "") + + (pipe.FilterParams.ColumnRestrict ? "\nColumn restrict" : "") + ); + + tip.AutomaticDelay = 10; + tip.AutoPopDelay = 5000; + var data = logWin.Tag as LogWindowData; + data.ToolTip = tip; + } + + return logWin; + } + + [SupportedOSPlatform("windows")] + public LogWindow.LogWindow AddFileTabDeferred (string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer) + { + return AddFileTab(givenFileName, isTempFile, title, forcePersistenceLoading, preProcessColumnizer, true); + } + + [SupportedOSPlatform("windows")] + public LogWindow.LogWindow AddFileTab (string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer, bool doNotAddToDockPanel = false) + { + var logFileName = FindFilenameForSettings(givenFileName); + var win = FindWindowForFile(logFileName); + if (win != null) + { + if (!isTempFile) + { + AddToFileHistory(givenFileName); + } + + SelectTab(win); + return win; + } + + EncodingOptions encodingOptions = new(); + FillDefaultEncodingFromSettings(encodingOptions); + LogWindow.LogWindow logWindow = new(this, logFileName, isTempFile, forcePersistenceLoading, ConfigManager) + { + GivenFileName = givenFileName + }; + + if (preProcessColumnizer != null) + { + logWindow.ForceColumnizerForLoading(preProcessColumnizer); + } + + if (isTempFile) + { + logWindow.TempTitleName = title; + encodingOptions.Encoding = new UnicodeEncoding(false, false); + } + + AddLogWindow(logWindow, title, doNotAddToDockPanel); + if (!isTempFile) + { + AddToFileHistory(givenFileName); + } + + var data = logWindow.Tag as LogWindowData; + data.Color = _defaultTabColor; + SetTabColor(logWindow, _defaultTabColor); + //data.tabPage.BorderColor = this.defaultTabBorderColor; + if (!isTempFile) + { + foreach (var colorEntry in ConfigManager.Settings.FileColors) + { + if (colorEntry.FileName.ToUpperInvariant().Equals(logFileName.ToUpperInvariant(), StringComparison.Ordinal)) + { + data.Color = colorEntry.Color; + SetTabColor(logWindow, colorEntry.Color); + break; + } + } + } + + if (!isTempFile) + { + SetTooltipText(logWindow, logFileName); + } + + if (givenFileName.EndsWith(".lxp", StringComparison.Ordinal)) + { + logWindow.ForcedPersistenceFileName = givenFileName; + } + + // this.BeginInvoke(new LoadFileDelegate(logWindow.LoadFile), new object[] { logFileName, encoding }); + Task.Run(() => logWindow.LoadFile(logFileName, encodingOptions)); + return logWindow; + } + + [SupportedOSPlatform("windows")] + public LogWindow.LogWindow AddMultiFileTab (string[] fileNames) + { + if (fileNames.Length < 1) + { + return null; + } + + LogWindow.LogWindow logWindow = new(this, fileNames[^1], false, false, ConfigManager); + AddLogWindow(logWindow, fileNames[^1], false); + multiFileToolStripMenuItem.Checked = true; + multiFileEnabledStripMenuItem.Checked = true; + EncodingOptions encodingOptions = new(); + FillDefaultEncodingFromSettings(encodingOptions); + BeginInvoke(new LoadMultiFilesDelegate(logWindow.LoadFilesAsMulti), fileNames, encodingOptions); + AddToFileHistory(fileNames[0]); + return logWindow; + } + + [SupportedOSPlatform("windows")] + public void LoadFiles (string[] fileNames) + { + Invoke(new AddFileTabsDelegate(AddFileTabs), [fileNames]); + } + + [SupportedOSPlatform("windows")] + public void OpenSearchDialog () + { + if (CurrentLogWindow == null) + { + return; + } + + SearchDialog dlg = new(); + AddOwnedForm(dlg); + dlg.TopMost = TopMost; + SearchParams.HistoryList = ConfigManager.Settings.SearchHistoryList; + dlg.SearchParams = SearchParams; + var res = dlg.ShowDialog(); + if (res == DialogResult.OK && dlg.SearchParams != null && !string.IsNullOrWhiteSpace(dlg.SearchParams.SearchText)) + { + SearchParams = dlg.SearchParams; + SearchParams.IsFindNext = false; + CurrentLogWindow.StartSearch(); + } + } + + public ILogLineColumnizer GetColumnizerHistoryEntry (string fileName) + { + var entry = FindColumnizerHistoryEntry(fileName); + if (entry != null) + { + foreach (var columnizer in PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers) + { + if (columnizer.GetName().Equals(entry.ColumnizerName, StringComparison.Ordinal)) + { + return columnizer; + } + } + + ConfigManager.Settings.ColumnizerHistoryList.Remove(entry); // no valid name -> remove entry + } + + return null; + } + + public void SwitchTab (bool shiftPressed) + { + var index = dockPanel.Contents.IndexOf(dockPanel.ActiveContent); + if (shiftPressed) + { + index--; + if (index < 0) + { + index = dockPanel.Contents.Count - 1; + } + + if (index < 0) + { + return; + } + } + else + { + index++; + if (index >= dockPanel.Contents.Count) + { + index = 0; + } + } + + if (index < dockPanel.Contents.Count) + { + (dockPanel.Contents[index] as DockContent).Activate(); + } + } + + public void ScrollAllTabsToTimestamp (DateTime timestamp, LogWindow.LogWindow senderWindow) + { + lock (_logWindowList) + { + foreach (var logWindow in _logWindowList) + { + if (logWindow != senderWindow) + { + if (logWindow.ScrollToTimestamp(timestamp, false, false)) + { + ShowLedPeak(logWindow); + } + } + } + } + } + + public ILogLineColumnizer FindColumnizerByFileMask (string fileName) + { + foreach (var entry in ConfigManager.Settings.Preferences.ColumnizerMaskList) + { + if (entry.Mask != null) + { + try + { + if (Regex.IsMatch(fileName, entry.Mask)) + { + var columnizer = ColumnizerPicker.FindColumnizerByName(entry.ColumnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + return columnizer; + } + } + catch (ArgumentException e) + { + _logger.Error(e, "RegEx-error while finding columnizer: "); + // occurs on invalid regex patterns + } + } + } + + return null; + } + + public HighlightGroup FindHighlightGroupByFileMask (string fileName) + { + foreach (var entry in ConfigManager.Settings.Preferences.HighlightMaskList) + { + if (entry.Mask != null) + { + try + { + if (Regex.IsMatch(fileName, entry.Mask)) + { + var group = FindHighlightGroup(entry.HighlightGroupName); + return group; + } + } + catch (ArgumentException e) + { + _logger.Error(e, "RegEx-error while finding columnizer: "); + // occurs on invalid regex patterns + } + } + } + + return null; + } + + public void SelectTab (ILogWindow logWindow) + { + logWindow.Activate(); + } + + [SupportedOSPlatform("windows")] + public void SetForeground () + { + NativeMethods.SetForegroundWindow(Handle); + if (WindowState == FormWindowState.Minimized) + { + if (_wasMaximized) + { + WindowState = FormWindowState.Maximized; + } + else + { + WindowState = FormWindowState.Normal; + } + } + } + + // called from LogWindow when follow tail was changed + [SupportedOSPlatform("windows")] + public void FollowTailChanged (LogWindow.LogWindow logWindow, bool isEnabled, bool offByTrigger) + { + if (logWindow.Tag is not LogWindowData data) + { + return; + } + + if (isEnabled) + { + data.TailState = 0; + } + else + { + data.TailState = offByTrigger ? 2 : 1; + } + + if (Preferences.ShowTailState) + { + var icon = GetIcon(data.DiffSum, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); + } + } + + [SupportedOSPlatform("windows")] + public void NotifySettingsChanged (object sender, SettingsFlags flags) + { + if (sender != this) + { + NotifyWindowsForChangedPrefs(flags); + } + } + + public IList GetListOfOpenFiles () + { + IList list = []; + lock (_logWindowList) + { + foreach (var logWindow in _logWindowList) + { + list.Add(new WindowFileEntry(logWindow)); + } + } + + return list; + } + + #endregion + + #region Private Methods + + /// + /// Creates a temp file with the text content of the clipboard and opens the temp file in a new tab. + /// + [SupportedOSPlatform("windows")] + private void PasteFromClipboard () + { + if (Clipboard.ContainsText()) + { + var text = Clipboard.GetText(); + var fileName = Path.GetTempFileName(); + + using (FileStream fStream = new(fileName, FileMode.Append, FileAccess.Write, FileShare.Read)) + using (StreamWriter writer = new(fStream, Encoding.Unicode)) + { + writer.Write(text); + writer.Close(); + } + + var title = "Clipboard"; + var logWindow = AddTempFileTab(fileName, title); + if (logWindow.Tag is LogWindowData data) + { + SetTooltipText(logWindow, "Pasted on " + DateTime.Now); + } + } + } + + [SupportedOSPlatform("windows")] + private void InitToolWindows () + { + InitBookmarkWindow(); + } + + [SupportedOSPlatform("windows")] + private void DestroyToolWindows () + { + DestroyBookmarkWindow(); + } + + [SupportedOSPlatform("windows")] + private void InitBookmarkWindow () + { + _bookmarkWindow = new BookmarkWindow + { + HideOnClose = true, + ShowHint = DockState.DockBottom + }; + + var setLastColumnWidth = ConfigManager.Settings.Preferences.SetLastColumnWidth; + var lastColumnWidth = ConfigManager.Settings.Preferences.LastColumnWidth; + var fontName = ConfigManager.Settings.Preferences.FontName; + var fontSize = ConfigManager.Settings.Preferences.FontSize; + + _bookmarkWindow.PreferencesChanged(fontName, fontSize, setLastColumnWidth, lastColumnWidth, SettingsFlags.All); + _bookmarkWindow.VisibleChanged += OnBookmarkWindowVisibleChanged; + _firstBookmarkWindowShow = true; + } + + [SupportedOSPlatform("windows")] + private void DestroyBookmarkWindow () + { + _bookmarkWindow.HideOnClose = false; + _bookmarkWindow.Close(); + } + + private void SaveLastOpenFilesList () + { + ConfigManager.Settings.LastOpenFilesList.Clear(); + foreach (DockContent content in dockPanel.Contents) + { + if (content is LogWindow.LogWindow logWin) + { + if (!logWin.IsTempFile) + { + ConfigManager.Settings.LastOpenFilesList.Add(logWin.GivenFileName); + } + } + } + } + + [SupportedOSPlatform("windows")] + private void SaveWindowPosition () + { + SuspendLayout(); + if (WindowState == FormWindowState.Normal) + { + ConfigManager.Settings.AppBounds = Bounds; + ConfigManager.Settings.IsMaximized = false; + } + else + { + ConfigManager.Settings.AppBoundsFullscreen = Bounds; + ConfigManager.Settings.IsMaximized = true; + WindowState = FormWindowState.Normal; + ConfigManager.Settings.AppBounds = Bounds; + } + + ResumeLayout(); + } + + private void SetTooltipText (LogWindow.LogWindow logWindow, string logFileName) + { + logWindow.ToolTipText = logFileName; + } + + private void FillDefaultEncodingFromSettings (EncodingOptions encodingOptions) + { + if (ConfigManager.Settings.Preferences.DefaultEncoding != null) + { + try + { + encodingOptions.DefaultEncoding = Encoding.GetEncoding(ConfigManager.Settings.Preferences.DefaultEncoding); + } + catch (ArgumentException) + { + _logger.Warn(CultureInfo.InvariantCulture, "Encoding " + ConfigManager.Settings.Preferences.DefaultEncoding + " is not a valid encoding"); + encodingOptions.DefaultEncoding = null; + } + } + } + + [SupportedOSPlatform("windows")] + private void AddFileTabs (string[] fileNames) + { + foreach (var fileName in fileNames) + { + if (!string.IsNullOrEmpty(fileName)) + { + if (fileName.EndsWith(".lxj")) + { + LoadProject(fileName, false); + } + else + { + AddFileTab(fileName, false, null, false, null); + } + } + } + + Activate(); + } + + [SupportedOSPlatform("windows")] + private void AddLogWindow (LogWindow.LogWindow logWindow, string title, bool doNotAddToPanel) + { + logWindow.CloseButton = true; + logWindow.TabPageContextMenuStrip = tabContextMenuStrip; + SetTooltipText(logWindow, title); + logWindow.DockAreas = DockAreas.Document | DockAreas.Float; + + if (!doNotAddToPanel) + { + logWindow.Show(dockPanel); + } + + LogWindowData data = new() + { + DiffSum = 0 + }; + + logWindow.Tag = data; + + lock (_logWindowList) + { + _logWindowList.Add(logWindow); + } + + logWindow.FileSizeChanged += OnFileSizeChanged; + logWindow.TailFollowed += OnTailFollowed; + logWindow.Disposed += OnLogWindowDisposed; + logWindow.FileNotFound += OnLogWindowFileNotFound; + logWindow.FileRespawned += OnLogWindowFileRespawned; + logWindow.FilterListChanged += OnLogWindowFilterListChanged; + logWindow.CurrentHighlightGroupChanged += OnLogWindowCurrentHighlightGroupChanged; + logWindow.SyncModeChanged += OnLogWindowSyncModeChanged; + + logWindow.Visible = true; + } + + [SupportedOSPlatform("windows")] + private void DisconnectEventHandlers (LogWindow.LogWindow logWindow) + { + logWindow.FileSizeChanged -= OnFileSizeChanged; + logWindow.TailFollowed -= OnTailFollowed; + logWindow.Disposed -= OnLogWindowDisposed; + logWindow.FileNotFound -= OnLogWindowFileNotFound; + logWindow.FileRespawned -= OnLogWindowFileRespawned; + logWindow.FilterListChanged -= OnLogWindowFilterListChanged; + logWindow.CurrentHighlightGroupChanged -= OnLogWindowCurrentHighlightGroupChanged; + logWindow.SyncModeChanged -= OnLogWindowSyncModeChanged; + + var data = logWindow.Tag as LogWindowData; + //data.tabPage.MouseClick -= tabPage_MouseClick; + //data.tabPage.TabDoubleClick -= tabPage_TabDoubleClick; + //data.tabPage.ContextMenuStrip = null; + //data.tabPage = null; + } + + [SupportedOSPlatform("windows")] + private void AddToFileHistory (string fileName) + { + bool FindName (string s) => s.ToUpperInvariant().Equals(fileName.ToUpperInvariant(), StringComparison.Ordinal); + + var index = ConfigManager.Settings.FileHistoryList.FindIndex(FindName); + + if (index != -1) + { + ConfigManager.Settings.FileHistoryList.RemoveAt(index); + } + + ConfigManager.Settings.FileHistoryList.Insert(0, fileName); + + while (ConfigManager.Settings.FileHistoryList.Count > MAX_FILE_HISTORY) + { + ConfigManager.Settings.FileHistoryList.RemoveAt(ConfigManager.Settings.FileHistoryList.Count - 1); + } + + ConfigManager.Save(SettingsFlags.FileHistory); + + FillHistoryMenu(); + } + + [SupportedOSPlatform("windows")] + private LogWindow.LogWindow FindWindowForFile (string fileName) + { + lock (_logWindowList) + { + foreach (var logWindow in _logWindowList) + { + if (logWindow.FileName.ToUpperInvariant().Equals(fileName.ToUpperInvariant(), StringComparison.Ordinal)) + { + return logWindow; + } + } + } + + return null; + } + + /// + /// Checks if the file name is a settings file. If so, the contained logfile name + /// is returned. If not, the given file name is returned unchanged. + /// + /// + /// + private string FindFilenameForSettings (string fileName) + { + if (fileName.EndsWith(".lxp")) + { + var persistenceData = Persister.LoadOptionsOnly(fileName); + if (persistenceData == null) + { + return fileName; + } + + if (!string.IsNullOrEmpty(persistenceData.FileName)) + { + var fs = PluginRegistry.PluginRegistry.Instance.FindFileSystemForUri(persistenceData.FileName); + if (fs != null && !fs.GetType().Equals(typeof(LocalFileSystem))) + { + return persistenceData.FileName; + } + + // On relative paths the URI check (and therefore the file system plugin check) will fail. + // So fs == null and fs == LocalFileSystem are handled here like normal files. + if (Path.IsPathRooted(persistenceData.FileName)) + { + return persistenceData.FileName; + } + + // handle relative paths in .lxp files + var dir = Path.GetDirectoryName(fileName); + return Path.Combine(dir, persistenceData.FileName); + } + } + + return fileName; + } + + [SupportedOSPlatform("windows")] + private void FillHistoryMenu () + { + ToolStripDropDown strip = new ToolStripDropDownMenu(); + + foreach (var file in ConfigManager.Settings.FileHistoryList) + { + ToolStripItem item = new ToolStripMenuItem(file); + strip.Items.Add(item); + } + + strip.ItemClicked += OnHistoryItemClicked; + strip.MouseUp += OnStripMouseUp; + lastUsedToolStripMenuItem.DropDown = strip; + } + + [SupportedOSPlatform("windows")] + private void RemoveLogWindow (LogWindow.LogWindow logWindow) + { + lock (_logWindowList) + { + _logWindowList.Remove(logWindow); + } + + DisconnectEventHandlers(logWindow); + } + + [SupportedOSPlatform("windows")] + private void RemoveAndDisposeLogWindow (LogWindow.LogWindow logWindow, bool dontAsk) + { + if (CurrentLogWindow == logWindow) + { + ChangeCurrentLogWindow(null); + } + + lock (_logWindowList) + { + _logWindowList.Remove(logWindow); + } + + logWindow.Close(dontAsk); + } + + [SupportedOSPlatform("windows")] + private void ShowHighlightSettingsDialog () + { + HighlightDialog dlg = new(ConfigManager) + { + KeywordActionList = PluginRegistry.PluginRegistry.Instance.RegisteredKeywordActions, + Owner = this, + TopMost = TopMost, + HighlightGroupList = HighlightGroupList, + PreSelectedGroupName = groupsComboBoxHighlightGroups.Text + }; + + var res = dlg.ShowDialog(); + + if (res == DialogResult.OK) + { + HighlightGroupList = dlg.HighlightGroupList; + FillHighlightComboBox(); + ConfigManager.Settings.Preferences.HighlightGroupList = HighlightGroupList; + ConfigManager.Save(SettingsFlags.HighlightSettings); + OnHighlightSettingsChanged(); + } + } + + [SupportedOSPlatform("windows")] + private void FillHighlightComboBox () + { + var currentGroupName = groupsComboBoxHighlightGroups.Text; + groupsComboBoxHighlightGroups.Items.Clear(); + foreach (var group in HighlightGroupList) + { + groupsComboBoxHighlightGroups.Items.Add(group.GroupName); + if (group.GroupName.Equals(currentGroupName, StringComparison.Ordinal)) + { + groupsComboBoxHighlightGroups.Text = group.GroupName; + } + } + } + + [SupportedOSPlatform("windows")] + private void OpenFileDialog () + { + OpenFileDialog openFileDialog = new(); + + if (CurrentLogWindow != null) + { + FileInfo info = new(CurrentLogWindow.FileName); + openFileDialog.InitialDirectory = info.DirectoryName; + } + else + { + if (!string.IsNullOrEmpty(ConfigManager.Settings.LastDirectory)) + { + openFileDialog.InitialDirectory = ConfigManager.Settings.LastDirectory; + } + else + { + try + { + openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + } + catch (SecurityException e) + { + _logger.Warn(e, "Insufficient rights for GetFolderPath(): "); + // no initial directory if insufficient rights + } + } + } + + openFileDialog.Multiselect = true; + + if (DialogResult.OK == openFileDialog.ShowDialog(this)) + { + FileInfo info = new(openFileDialog.FileName); + if (info.Directory.Exists) + { + ConfigManager.Settings.LastDirectory = info.DirectoryName; + ConfigManager.Save(SettingsFlags.FileHistory); + } + + if (info.Exists) + { + LoadFiles(openFileDialog.FileNames, false); + } + } + } + + [SupportedOSPlatform("windows")] + private void LoadFiles (string[] names, bool invertLogic) + { + Array.Sort(names); + + if (names.Length == 1) + { + if (names[0].EndsWith(".lxj")) + { + LoadProject(names[0], true); + return; + } + + AddFileTab(names[0], false, null, false, null); + return; + } + + var option = ConfigManager.Settings.Preferences.MultiFileOption; + if (option == MultiFileOption.Ask) + { + MultiLoadRequestDialog dlg = new(); + var res = dlg.ShowDialog(); + + if (res == DialogResult.Yes) + { + option = MultiFileOption.SingleFiles; + } + else if (res == DialogResult.No) + { + option = MultiFileOption.MultiFile; + } + else + { + return; + } + } + else + { + if (invertLogic) + { + option = option == MultiFileOption.SingleFiles + ? MultiFileOption.MultiFile + : MultiFileOption.SingleFiles; + } + } + + if (option == MultiFileOption.SingleFiles) + { + AddFileTabs(names); + } + else + { + AddMultiFileTab(names); + } + } + + private void SetColumnizerHistoryEntry (string fileName, ILogLineColumnizer columnizer) + { + var entry = FindColumnizerHistoryEntry(fileName); + if (entry != null) + { + _ = ConfigManager.Settings.ColumnizerHistoryList.Remove(entry); + + } + + ConfigManager.Settings.ColumnizerHistoryList.Add(new ColumnizerHistoryEntry(fileName, columnizer.GetName())); + + if (ConfigManager.Settings.ColumnizerHistoryList.Count > MAX_COLUMNIZER_HISTORY) + { + ConfigManager.Settings.ColumnizerHistoryList.RemoveAt(0); + } + } + + private ColumnizerHistoryEntry FindColumnizerHistoryEntry (string fileName) + { + foreach (var entry in ConfigManager.Settings.ColumnizerHistoryList) + { + if (entry.FileName.Equals(fileName, StringComparison.Ordinal)) + { + return entry; + } + } + + return null; + } + + [SupportedOSPlatform("windows")] + private void ToggleMultiFile () + { + if (CurrentLogWindow != null) + { + CurrentLogWindow.SwitchMultiFile(!CurrentLogWindow.IsMultiFile); + multiFileToolStripMenuItem.Checked = CurrentLogWindow.IsMultiFile; + multiFileEnabledStripMenuItem.Checked = CurrentLogWindow.IsMultiFile; + } + } + + [SupportedOSPlatform("windows")] + private void ChangeCurrentLogWindow (LogWindow.LogWindow newLogWindow) + { + if (newLogWindow == _currentLogWindow) + { + return; // do nothing if wishing to set the same window + } + + var oldLogWindow = _currentLogWindow; + _currentLogWindow = newLogWindow; + var titleName = _showInstanceNumbers ? "LogExpert #" + _instanceNumber : "LogExpert"; + + if (oldLogWindow != null) + { + oldLogWindow.StatusLineEvent -= OnStatusLineEvent; + oldLogWindow.ProgressBarUpdate -= OnProgressBarUpdate; + oldLogWindow.GuiStateUpdate -= OnGuiStateUpdate; + oldLogWindow.ColumnizerChanged -= OnColumnizerChanged; + oldLogWindow.BookmarkAdded -= OnBookmarkAdded; + oldLogWindow.BookmarkRemoved -= OnBookmarkRemoved; + oldLogWindow.BookmarkTextChanged -= OnBookmarkTextChanged; + DisconnectToolWindows(oldLogWindow); + } + + if (newLogWindow != null) + { + newLogWindow.StatusLineEvent += OnStatusLineEvent; + newLogWindow.ProgressBarUpdate += OnProgressBarUpdate; + newLogWindow.GuiStateUpdate += OnGuiStateUpdate; + newLogWindow.ColumnizerChanged += OnColumnizerChanged; + newLogWindow.BookmarkAdded += OnBookmarkAdded; + newLogWindow.BookmarkRemoved += OnBookmarkRemoved; + newLogWindow.BookmarkTextChanged += OnBookmarkTextChanged; + + Text = newLogWindow.IsTempFile + ? titleName + @" - " + newLogWindow.TempTitleName + : titleName + @" - " + newLogWindow.FileName; + + multiFileToolStripMenuItem.Checked = CurrentLogWindow.IsMultiFile; + multiFileToolStripMenuItem.Enabled = true; + multiFileEnabledStripMenuItem.Checked = CurrentLogWindow.IsMultiFile; + cellSelectModeToolStripMenuItem.Checked = true; + cellSelectModeToolStripMenuItem.Enabled = true; + closeFileToolStripMenuItem.Enabled = true; + searchToolStripMenuItem.Enabled = true; + filterToolStripMenuItem.Enabled = true; + goToLineToolStripMenuItem.Enabled = true; + //ConnectToolWindows(newLogWindow); + } + else + { + Text = titleName; + multiFileToolStripMenuItem.Checked = false; + multiFileEnabledStripMenuItem.Checked = false; + checkBoxFollowTail.Checked = false; + mainMenuStrip.Enabled = true; + timeshiftToolStripMenuItem.Enabled = false; + timeshiftToolStripMenuItem.Checked = false; + timeshiftMenuTextBox.Text = ""; + timeshiftMenuTextBox.Enabled = false; + multiFileToolStripMenuItem.Enabled = false; + cellSelectModeToolStripMenuItem.Checked = false; + cellSelectModeToolStripMenuItem.Enabled = false; + closeFileToolStripMenuItem.Enabled = false; + searchToolStripMenuItem.Enabled = false; + filterToolStripMenuItem.Enabled = false; + goToLineToolStripMenuItem.Enabled = false; + dragControlDateTime.Visible = false; + } + } + + private void ConnectToolWindows (LogWindow.LogWindow logWindow) + { + ConnectBookmarkWindow(logWindow); + } + + private void ConnectBookmarkWindow (LogWindow.LogWindow logWindow) + { + FileViewContext ctx = new(logWindow, logWindow); + _bookmarkWindow.SetBookmarkData(logWindow.BookmarkData); + _bookmarkWindow.SetCurrentFile(ctx); + } + + private void DisconnectToolWindows (LogWindow.LogWindow logWindow) + { + DisconnectBookmarkWindow(logWindow); + } + + private void DisconnectBookmarkWindow (LogWindow.LogWindow logWindow) + { + _bookmarkWindow.SetBookmarkData(null); + _bookmarkWindow.SetCurrentFile(null); + } + + [SupportedOSPlatform("windows")] + private void GuiStateUpdateWorker (GuiStateArgs e) + { + _skipEvents = true; + checkBoxFollowTail.Checked = e.FollowTail; + mainMenuStrip.Enabled = e.MenuEnabled; + timeshiftToolStripMenuItem.Enabled = e.TimeshiftPossible; + timeshiftToolStripMenuItem.Checked = e.TimeshiftEnabled; + timeshiftMenuTextBox.Text = e.TimeshiftText; + timeshiftMenuTextBox.Enabled = e.TimeshiftEnabled; + multiFileToolStripMenuItem.Enabled = e.MultiFileEnabled; // disabled for temp files + multiFileToolStripMenuItem.Checked = e.IsMultiFileActive; + multiFileEnabledStripMenuItem.Checked = e.IsMultiFileActive; + cellSelectModeToolStripMenuItem.Checked = e.CellSelectMode; + RefreshEncodingMenuBar(e.CurrentEncoding); + + if (e.TimeshiftPossible && ConfigManager.Settings.Preferences.TimestampControl) + { + dragControlDateTime.MinDateTime = e.MinTimestamp; + dragControlDateTime.MaxDateTime = e.MaxTimestamp; + dragControlDateTime.DateTime = e.Timestamp; + dragControlDateTime.Visible = true; + dragControlDateTime.Enabled = true; + dragControlDateTime.Refresh(); + } + else + { + dragControlDateTime.Visible = false; + dragControlDateTime.Enabled = false; + } + + toolStripButtonBubbles.Checked = e.ShowBookmarkBubbles; + groupsComboBoxHighlightGroups.Text = e.HighlightGroupName; + columnFinderToolStripMenuItem.Checked = e.ColumnFinderVisible; + + _skipEvents = false; + } + + [SupportedOSPlatform("windows")] + private void ProgressBarUpdateWorker (ProgressEventArgs e) + { + if (e.Value <= e.MaxValue && e.Value >= e.MinValue) + { + try + { + loadProgessBar.Minimum = e.MinValue; + loadProgessBar.Maximum = e.MaxValue; + loadProgessBar.Value = e.Value; + loadProgessBar.Visible = e.Visible; + } + catch (Exception ex) + { + _logger.Error(ex, "Error during ProgressBarUpdateWorker value {0}, min {1}, max {2}, visible {3}", e.Value, e.MinValue, e.MaxValue, e.Visible); + } + + Invoke(new System.Windows.Forms.MethodInvoker(statusStrip.Refresh)); + } + } + + [SupportedOSPlatform("windows")] + //TODO Crossthread Exception when a log file has been filtered to a new tab! + private void StatusLineEventWorker (StatusLineEventArgs e) + { + if (e != null) + { + //_logger.logDebug("StatusLineEvent: text = " + e.StatusText); + labelStatus.Text = e.StatusText; + labelStatus.Size = TextRenderer.MeasureText(labelStatus.Text, labelStatus.Font); + labelLines.Text = $" {e.LineCount} lines"; + labelLines.Size = TextRenderer.MeasureText(labelLines.Text, labelLines.Font); + labelSize.Text = Util.GetFileSizeAsText(e.FileSize); + labelSize.Size = TextRenderer.MeasureText(labelSize.Text, labelSize.Font); + labelCurrentLine.Text = $"Line: {e.CurrentLineNum}"; + labelCurrentLine.Size = TextRenderer.MeasureText(labelCurrentLine.Text, labelCurrentLine.Font); + if (statusStrip.InvokeRequired) + { + statusStrip.BeginInvoke(new System.Windows.Forms.MethodInvoker(statusStrip.Refresh)); + } + else + { + statusStrip.Refresh(); + } + } + } + + // tailState: 0,1,2 = on/off/off by Trigger + // syncMode: 0 = normal (no), 1 = time synced + [SupportedOSPlatform("windows")] + private Icon CreateLedIcon (int level, bool dirty, int tailState, int syncMode) + { + var iconRect = _leds[0]; + iconRect.Height = 16; // (DockPanel's damn hardcoded height) // this.leds[this.leds.Length - 1].Bottom; + iconRect.Width = iconRect.Right + 6; + Bitmap bmp = new(iconRect.Width, iconRect.Height); + var gfx = Graphics.FromImage(bmp); + + var offsetFromTop = 4; + + for (var i = 0; i < _leds.Length; ++i) + { + var ledRect = _leds[i]; + ledRect.Offset(0, offsetFromTop); + + if (level >= _leds.Length - i) + { + gfx.FillRectangle(_ledBrushes[i], ledRect); + } + else + { + gfx.FillRectangle(_offLedBrush, ledRect); + } + } + + var ledSize = 3; + var ledGap = 1; + var lastLed = _leds[^1]; + Rectangle dirtyLed = new(lastLed.Right + 2, lastLed.Bottom - ledSize, ledSize, ledSize); + Rectangle tailLed = new(dirtyLed.Location, dirtyLed.Size); + tailLed.Offset(0, -(ledSize + ledGap)); + Rectangle syncLed = new(tailLed.Location, dirtyLed.Size); + syncLed.Offset(0, -(ledSize + ledGap)); + + syncLed.Offset(0, offsetFromTop); + tailLed.Offset(0, offsetFromTop); + dirtyLed.Offset(0, offsetFromTop); + + if (dirty) + { + gfx.FillRectangle(_dirtyLedBrush, dirtyLed); + } + else + { + gfx.FillRectangle(_offLedBrush, dirtyLed); + } + + // tailMode 4 means: don't show + if (tailState < 3) + { + gfx.FillRectangle(_tailLedBrush[tailState], tailLed); + } + + if (syncMode == 1) + { + gfx.FillRectangle(_syncLedBrush, syncLed); + } + //else + //{ + // gfx.FillRectangle(this.offLedBrush, syncLed); + //} + + // see http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=345656 + // GetHicon() creates an unmanaged handle which must be destroyed. The Clone() workaround creates + // a managed copy of icon. then the unmanaged win32 handle is destroyed + var iconHandle = bmp.GetHicon(); + var icon = Icon.FromHandle(iconHandle).Clone() as Icon; + NativeMethods.DestroyIcon(iconHandle); + + gfx.Dispose(); + bmp.Dispose(); + return icon; + } + + [SupportedOSPlatform("windows")] + private void CreateIcons () + { + for (var syncMode = 0; syncMode <= 1; syncMode++) // LED indicating time synced tabs + { + for (var tailMode = 0; tailMode < 4; tailMode++) + { + for (var i = 0; i < 6; ++i) + { + _ledIcons[i, 0, tailMode, syncMode] = CreateLedIcon(i, false, tailMode, syncMode); + } + + for (var i = 0; i < 6; ++i) + { + _ledIcons[i, 1, tailMode, syncMode] = CreateLedIcon(i, true, tailMode, syncMode); + } + } + } + } + + [SupportedOSPlatform("windows")] + private void FileNotFound (LogWindow.LogWindow logWin) + { + var data = logWin.Tag as LogWindowData; + BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, _deadIcon); + dragControlDateTime.Visible = false; + } + + [SupportedOSPlatform("windows")] + private void FileRespawned (LogWindow.LogWindow logWin) + { + var data = logWin.Tag as LogWindowData; + var icon = GetIcon(0, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, icon); + } + + [SupportedOSPlatform("windows")] + private void ShowLedPeak (LogWindow.LogWindow logWin) + { + var data = logWin.Tag as LogWindowData; + lock (data) + { + data.DiffSum = DIFF_MAX; + } + + var icon = GetIcon(data.DiffSum, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, icon); + } + + private int GetLevelFromDiff (int diff) + { + if (diff > 60) + { + diff = 60; + } + + var level = diff / 10; + if (diff > 0 && level == 0) + { + level = 2; + } + else if (level == 0) + { + level = 1; + } + + return level - 1; + } + + [SupportedOSPlatform("windows")] + private void LedThreadProc () + { + Thread.CurrentThread.Name = "LED Thread"; + while (!_shouldStop) + { + try + { + Thread.Sleep(200); + } + catch + { + return; + } + + lock (_logWindowList) + { + foreach (var logWindow in _logWindowList) + { + var data = logWindow.Tag as LogWindowData; + if (data.DiffSum > 0) + { + data.DiffSum -= 10; + if (data.DiffSum < 0) + { + data.DiffSum = 0; + } + + var icon = GetIcon(data.DiffSum, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); + } + } + } + } + } + + [SupportedOSPlatform("windows")] + private void SetTabIcon (LogWindow.LogWindow logWindow, Icon icon) + { + if (logWindow != null) + { + logWindow.Icon = icon; + logWindow.DockHandler.Pane?.TabStripControl.Invalidate(false); + } + } + + private Icon GetIcon (int diff, LogWindowData data) + { + var icon = + _ledIcons[ + GetLevelFromDiff(diff), data.Dirty ? 1 : 0, Preferences.ShowTailState ? data.TailState : 3, + data.SyncMode + ]; + return icon; + } + + [SupportedOSPlatform("windows")] + private void RefreshEncodingMenuBar (Encoding encoding) + { + toolStripEncodingASCIIItem.Checked = false; + toolStripEncodingANSIItem.Checked = false; + toolStripEncodingUTF8Item.Checked = false; + toolStripEncodingUTF16Item.Checked = false; + toolStripEncodingISO88591Item.Checked = false; + + if (encoding == null) + { + return; + } + + if (encoding is ASCIIEncoding) + { + toolStripEncodingASCIIItem.Checked = true; + } + else if (encoding.Equals(Encoding.Default)) + { + toolStripEncodingANSIItem.Checked = true; + } + else if (encoding is UTF8Encoding) + { + toolStripEncodingUTF8Item.Checked = true; + } + else if (encoding is UnicodeEncoding) + { + toolStripEncodingUTF16Item.Checked = true; + } + else if (encoding.Equals(Encoding.GetEncoding("iso-8859-1"))) + { + toolStripEncodingISO88591Item.Checked = true; + } + + toolStripEncodingANSIItem.Text = Encoding.Default.HeaderName; + } + + [SupportedOSPlatform("windows")] + private void OpenSettings (int tabToOpen) + { + SettingsDialog dlg = new(ConfigManager.Settings.Preferences, this, tabToOpen, ConfigManager) + { + TopMost = TopMost + }; + + if (DialogResult.OK == dlg.ShowDialog()) + { + ConfigManager.Settings.Preferences = dlg.Preferences; + ConfigManager.Save(SettingsFlags.Settings); + NotifyWindowsForChangedPrefs(SettingsFlags.Settings); + } + } + + [SupportedOSPlatform("windows")] + private void NotifyWindowsForChangedPrefs (SettingsFlags flags) + { + _logger.Info(CultureInfo.InvariantCulture, "The preferences have changed"); + ApplySettings(ConfigManager.Settings, flags); + + var setLastColumnWidth = ConfigManager.Settings.Preferences.SetLastColumnWidth; + var lastColumnWidth = ConfigManager.Settings.Preferences.LastColumnWidth; + var fontName = ConfigManager.Settings.Preferences.FontName; + var fontSize = ConfigManager.Settings.Preferences.FontSize; + + lock (_logWindowList) + { + foreach (var logWindow in _logWindowList) + { + logWindow.PreferencesChanged(fontName, fontSize, setLastColumnWidth, lastColumnWidth, false, flags); + } + } + + _bookmarkWindow.PreferencesChanged(fontName, fontSize, setLastColumnWidth, lastColumnWidth, flags); + + HighlightGroupList = ConfigManager.Settings.Preferences.HighlightGroupList; + if ((flags & SettingsFlags.HighlightSettings) == SettingsFlags.HighlightSettings) + { + OnHighlightSettingsChanged(); + } + } + + [SupportedOSPlatform("windows")] + private void ApplySettings (Settings settings, SettingsFlags flags) + { + if ((flags & SettingsFlags.WindowPosition) == SettingsFlags.WindowPosition) + { + TopMost = alwaysOnTopToolStripMenuItem.Checked = settings.AlwaysOnTop; + dragControlDateTime.DragOrientation = settings.Preferences.TimestampControlDragOrientation; + hideLineColumnToolStripMenuItem.Checked = settings.HideLineColumn; + } + + if ((flags & SettingsFlags.FileHistory) == SettingsFlags.FileHistory) + { + FillHistoryMenu(); + } + + if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors) + { + SetTabIcons(settings.Preferences); + } + + if ((flags & SettingsFlags.ToolSettings) == SettingsFlags.ToolSettings) + { + FillToolLauncherBar(); + } + + if ((flags & SettingsFlags.HighlightSettings) == SettingsFlags.HighlightSettings) + { + FillHighlightComboBox(); + } + } + + [SupportedOSPlatform("windows")] + private void SetTabIcons (Preferences preferences) + { + _tailLedBrush[0] = new SolidBrush(preferences.ShowTailColor); + CreateIcons(); + lock (_logWindowList) + { + foreach (var logWindow in _logWindowList) + { + var data = logWindow.Tag as LogWindowData; + var icon = GetIcon(data.DiffSum, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); + } + } + } + + [SupportedOSPlatform("windows")] + private void SetToolIcon (ToolEntry entry, ToolStripItem item) + { + var icon = NativeMethods.LoadIconFromExe(entry.IconFile, entry.IconIndex); + + if (icon != null) + { + item.Image = icon.ToBitmap(); + + item.DisplayStyle = item is ToolStripMenuItem + ? ToolStripItemDisplayStyle.ImageAndText + : ToolStripItemDisplayStyle.Image; + + NativeMethods.DestroyIcon(icon.Handle); + icon.Dispose(); + } + + if (!string.IsNullOrEmpty(entry.Cmd)) + { + item.ToolTipText = entry.Name; + } + } + + [SupportedOSPlatform("windows")] + private void ToolButtonClick (ToolEntry toolEntry) + { + if (string.IsNullOrEmpty(toolEntry.Cmd)) + { + //TODO TabIndex => To Enum + OpenSettings(2); + return; + } + + if (CurrentLogWindow != null) + { + var line = CurrentLogWindow.GetCurrentLine(); + var info = CurrentLogWindow.GetCurrentFileInfo(); + if (line != null && info != null) + { + ArgParser parser = new(toolEntry.Args); + var argLine = parser.BuildArgs(line, CurrentLogWindow.GetRealLineNum() + 1, info, this); + if (argLine != null) + { + StartTool(toolEntry.Cmd, argLine, toolEntry.Sysout, toolEntry.ColumnizerName, toolEntry.WorkingDir); + } + } + } + } + + [SupportedOSPlatform("windows")] + private void StartTool (string cmd, string args, bool sysoutPipe, string columnizerName, string workingDir) + { + if (string.IsNullOrEmpty(cmd)) + { + return; + } + + Process process = new(); + ProcessStartInfo startInfo = new(cmd, args); + if (!Util.IsNull(workingDir)) + { + startInfo.WorkingDirectory = workingDir; + } + + process.StartInfo = startInfo; + process.EnableRaisingEvents = true; + + if (sysoutPipe) + { + var columnizer = ColumnizerPicker.DecideColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); + + _logger.Info(CultureInfo.InvariantCulture, "Starting external tool with sysout redirection: {0} {1}", cmd, args); + startInfo.UseShellExecute = false; + startInfo.RedirectStandardOutput = true; + //process.OutputDataReceived += pipe.DataReceivedEventHandler; + try + { + _ = process.Start(); + } + catch (Win32Exception e) + { + _logger.Error(e); + MessageBox.Show(e.Message); + return; + } + + SysoutPipe pipe = new(process.StandardOutput); + + var logWin = AddTempFileTab(pipe.FileName, + CurrentLogWindow.IsTempFile + ? CurrentLogWindow.TempTitleName + : Util.GetNameFromPath(CurrentLogWindow.FileName) + "->E"); + logWin.ForceColumnizer(columnizer); + + process.Exited += pipe.ProcessExitedEventHandler; + //process.BeginOutputReadLine(); + } + else + { + _logger.Info(CultureInfo.InvariantCulture, "Starting external tool: {0} {1}", cmd, args); + + try + { + startInfo.UseShellExecute = false; + _ = process.Start(); + } + catch (Exception e) + { + _logger.Error(e); + MessageBox.Show(e.Message); + } + } + } + + [SupportedOSPlatform("windows")] + private void CloseAllTabs () + { + IList closeList = []; + lock (_logWindowList) + { + foreach (DockContent content in dockPanel.Contents) + { + if (content is LogWindow.LogWindow window) + { + closeList.Add(window); + } + } + } + + foreach (var form in closeList) + { + form.Close(); + } + } + + //TODO Reimplement + private void SetTabColor (LogWindow.LogWindow logWindow, Color color) + { + //tabPage.BackLowColor = color; + //tabPage.BackLowColorDisabled = Color.FromArgb(255, + // Math.Max(0, color.R - 50), + // Math.Max(0, color.G - 50), + // Math.Max(0, color.B - 50) + // ); + } + + [SupportedOSPlatform("windows")] + private void LoadProject (string projectFileName, bool restoreLayout) + { + var projectData = ProjectPersister.LoadProjectData(projectFileName); + var hasLayoutData = projectData.TabLayoutXml != null; + + if (hasLayoutData && restoreLayout && _logWindowList.Count > 0) + { + ProjectLoadDlg dlg = new(); + if (DialogResult.Cancel != dlg.ShowDialog()) + { + switch (dlg.ProjectLoadResult) + { + case ProjectLoadDlgResult.IgnoreLayout: + hasLayoutData = false; + break; + case ProjectLoadDlgResult.CloseTabs: + CloseAllTabs(); + break; + case ProjectLoadDlgResult.NewWindow: + LogExpertProxy.NewWindow([projectFileName]); + return; + } + } + } + + if (projectData != null) + { + foreach (var fileName in projectData.MemberList) + { + if (hasLayoutData) + { + AddFileTabDeferred(fileName, false, null, true, null); + } + else + { + AddFileTab(fileName, false, null, true, null); + } + } + + if (hasLayoutData && restoreLayout) + { + // Re-creating tool (non-document) windows is needed because the DockPanel control would throw strange errors + DestroyToolWindows(); + InitToolWindows(); + RestoreLayout(projectData.TabLayoutXml); + } + } + } + + [SupportedOSPlatform("windows")] + private void ApplySelectedHighlightGroup () + { + var groupName = groupsComboBoxHighlightGroups.Text; + CurrentLogWindow?.SetCurrentHighlightGroup(groupName); + } + + [SupportedOSPlatform("windows")] + private void FillToolLauncherBar () + { + char[] labels = + [ + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', + 'U', 'V', 'W', 'X', 'Y', 'Z' + ]; + toolsToolStripMenuItem.DropDownItems.Clear(); + toolsToolStripMenuItem.DropDownItems.Add(configureToolStripMenuItem); + toolsToolStripMenuItem.DropDownItems.Add(configureToolStripSeparator); + externalToolsToolStrip.Items.Clear(); + var num = 0; + externalToolsToolStrip.SuspendLayout(); + foreach (var tool in Preferences.ToolEntries) + { + if (tool.IsFavourite) + { + ToolStripButton button = new("" + labels[num % 26]) + { + Alignment = ToolStripItemAlignment.Left, + Tag = tool + }; + + SetToolIcon(tool, button); + externalToolsToolStrip.Items.Add(button); + } + + num++; + ToolStripMenuItem menuItem = new(tool.Name) + { + Tag = tool + }; + + SetToolIcon(tool, menuItem); + toolsToolStripMenuItem.DropDownItems.Add(menuItem); + } + + externalToolsToolStrip.ResumeLayout(); + + externalToolsToolStrip.Visible = num > 0; // do not show bar if no tool uses it + } + + private void RunGC () + { + _logger.Info($"Running GC. Used mem before: {GC.GetTotalMemory(false):N0}"); + GC.Collect(); + _logger.Info($"GC done. Used mem after: {GC.GetTotalMemory(true):N0}"); + } + + private void DumpGCInfo () + { + _logger.Info($"-------- GC info -----------\r\nUsed mem: {GC.GetTotalMemory(false):N0}"); + for (var i = 0; i < GC.MaxGeneration; ++i) + { + _logger.Info($"Generation {i} collect count: {GC.CollectionCount(i)}"); + } + + _logger.Info(CultureInfo.InvariantCulture, "----------------------------"); + } + + private void ThrowExceptionFx () + { + throw new Exception("This is a test exception thrown by an async delegate"); + } + + private void ThrowExceptionThreadFx () + { + throw new Exception("This is a test exception thrown by a background thread"); + } + + private string SaveLayout () + { + using MemoryStream memStream = new(2000); + using StreamReader r = new(memStream); + dockPanel.SaveAsXml(memStream, Encoding.UTF8, true); + + memStream.Seek(0, SeekOrigin.Begin); + var resultXml = r.ReadToEnd(); + + r.Close(); + + return resultXml; + } + + [SupportedOSPlatform("windows")] + private void RestoreLayout (string layoutXml) + { + using MemoryStream memStream = new(2000); + using StreamWriter w = new(memStream); + w.Write(layoutXml); + w.Flush(); + + memStream.Seek(0, SeekOrigin.Begin); + + dockPanel.LoadFromXml(memStream, DeserializeDockContent, true); + } + + [SupportedOSPlatform("windows")] + private IDockContent DeserializeDockContent (string persistString) + { + if (persistString.Equals(WindowTypes.BookmarkWindow.ToString(), StringComparison.Ordinal)) + { + return _bookmarkWindow; + } + + if (persistString.StartsWith(WindowTypes.LogWindow.ToString())) + { + var fileName = persistString[(WindowTypes.LogWindow.ToString().Length + 1)..]; + var win = FindWindowForFile(fileName); + if (win != null) + { + return win; + } + + _logger.Warn($"Layout data contains non-existing LogWindow for {fileName}"); + } + + return null; + } + + private void OnHighlightSettingsChanged () + { + HighlightSettingsChanged?.Invoke(this, EventArgs.Empty); + } + + #endregion + + #region Events handler + + private void OnBookmarkWindowVisibleChanged (object sender, EventArgs e) + { + _firstBookmarkWindowShow = false; + } + + private void OnLogTabWindowLoad (object sender, EventArgs e) + { + ApplySettings(ConfigManager.Settings, SettingsFlags.All); + if (ConfigManager.Settings.IsMaximized) + { + Bounds = ConfigManager.Settings.AppBoundsFullscreen; + WindowState = FormWindowState.Maximized; + Bounds = ConfigManager.Settings.AppBounds; + } + else + { + if (ConfigManager.Settings.AppBounds.Right > 0) + { + Bounds = ConfigManager.Settings.AppBounds; + } + } + + if (ConfigManager.Settings.Preferences.OpenLastFiles && _startupFileNames == null) + { + var tmpList = ObjectClone.Clone(ConfigManager.Settings.LastOpenFilesList); + + foreach (var name in tmpList) + { + if (string.IsNullOrEmpty(name) == false) + { + AddFileTab(name, false, null, false, null); + } + } + } + + if (_startupFileNames != null) + { + LoadFiles(_startupFileNames, false); + } + + _ledThread = new Thread(LedThreadProc) + { + IsBackground = true + }; + _ledThread.Start(); + + FillHighlightComboBox(); + FillToolLauncherBar(); +#if !DEBUG + debugToolStripMenuItem.Visible = false; +#endif + } + + private void OnLogTabWindowClosing (object sender, CancelEventArgs e) + { + try + { + _shouldStop = true; + _ = _statusLineEventHandle.Set(); + _ = _statusLineEventWakeupHandle.Set(); + _ledThread.Join(); + + IList deleteLogWindowList = []; + ConfigManager.Settings.AlwaysOnTop = TopMost && ConfigManager.Settings.Preferences.AllowOnlyOneInstance; + SaveLastOpenFilesList(); + + foreach (var logWindow in _logWindowList.ToArray()) + { + RemoveAndDisposeLogWindow(logWindow, true); + } + + DestroyBookmarkWindow(); + + ConfigManager.Instance.ConfigChanged -= OnConfigChanged; + + SaveWindowPosition(); + ConfigManager.Save(SettingsFlags.WindowPosition | SettingsFlags.FileHistory); + } + catch (Exception) + { + // ignore error (can occur then multipe instances are closed simultaneously or if the + // window was not constructed completely because of errors) + } + finally + { + LogExpertProxy?.WindowClosed(this); + } + } + + private void OnStripMouseUp (object sender, MouseEventArgs e) + { + if (sender is ToolStripDropDown dropDown) + { + AddFileTab(dropDown.Text, false, null, false, null); + } + } + + private void OnHistoryItemClicked (object sender, ToolStripItemClickedEventArgs e) + { + if (string.IsNullOrEmpty(e.ClickedItem.Text) == false) + { + AddFileTab(e.ClickedItem.Text, false, null, false, null); + } + } + + private void OnLogWindowDisposed (object sender, EventArgs e) + { + var logWindow = sender as LogWindow.LogWindow; + + if (sender == CurrentLogWindow) + { + ChangeCurrentLogWindow(null); + } + + RemoveLogWindow(logWindow); + + logWindow.Tag = null; + } + + private void OnExitToolStripMenuItemClick (object sender, EventArgs e) + { + Close(); + } + + private void OnSelectFilterToolStripMenuItemClick (object sender, EventArgs e) + { + if (CurrentLogWindow == null) + { + return; + } + + CurrentLogWindow.ColumnizerCallbackObject.LineNum = CurrentLogWindow.GetCurrentLineNum(); + FilterSelectorForm form = new(PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers, CurrentLogWindow.CurrentColumnizer, CurrentLogWindow.ColumnizerCallbackObject, ConfigManager) + { + Owner = this, + TopMost = TopMost + }; + var res = form.ShowDialog(); + + if (res == DialogResult.OK) + { + if (form.ApplyToAll) + { + lock (_logWindowList) + { + foreach (var logWindow in _logWindowList) + { + if (logWindow.CurrentColumnizer.GetType() != form.SelectedColumnizer.GetType()) + { + //logWindow.SetColumnizer(form.SelectedColumnizer); + SetColumnizerFx fx = logWindow.ForceColumnizer; + logWindow.Invoke(fx, form.SelectedColumnizer); + SetColumnizerHistoryEntry(logWindow.FileName, form.SelectedColumnizer); + } + else + { + if (form.IsConfigPressed) + { + logWindow.ColumnizerConfigChanged(); + } + } + } + } + } + else + { + if (CurrentLogWindow.CurrentColumnizer.GetType() != form.SelectedColumnizer.GetType()) + { + SetColumnizerFx fx = CurrentLogWindow.ForceColumnizer; + CurrentLogWindow.Invoke(fx, form.SelectedColumnizer); + SetColumnizerHistoryEntry(CurrentLogWindow.FileName, form.SelectedColumnizer); + } + + if (form.IsConfigPressed) + { + lock (_logWindowList) + { + foreach (var logWindow in _logWindowList) + { + if (logWindow.CurrentColumnizer.GetType() == form.SelectedColumnizer.GetType()) + { + logWindow.ColumnizerConfigChanged(); + } + } + } + } + } + } + } + + private void OnGoToLineToolStripMenuItemClick (object sender, EventArgs e) + { + if (CurrentLogWindow == null) + { + return; + } + + GotoLineDialog dlg = new(this); + var res = dlg.ShowDialog(); + if (res == DialogResult.OK) + { + var line = dlg.Line - 1; + if (line >= 0) + { + CurrentLogWindow.GotoLine(line); + } + } + } + + private void OnHighlightingToolStripMenuItemClick (object sender, EventArgs e) + { + ShowHighlightSettingsDialog(); + } + + private void OnSearchToolStripMenuItemClick (object sender, EventArgs e) + { + OpenSearchDialog(); + } + + private void OnOpenToolStripMenuItemClick (object sender, EventArgs e) + { + OpenFileDialog(); + } + + private void OnLogTabWindowDragEnter (object sender, DragEventArgs e) + { +#if DEBUG + var formats = e.Data.GetFormats(); + var s = "Dragging something over LogExpert. Formats: "; + foreach (var format in formats) + { + s += format; + s += " , "; + } + + s = s[..^3]; + _logger.Info(s); +#endif + } + + private void OnLogWindowDragOver (object sender, DragEventArgs e) + { + if (!e.Data.GetDataPresent(DataFormats.FileDrop)) + { + e.Effect = DragDropEffects.None; + } + else + { + e.Effect = DragDropEffects.Copy; + } + } + + private void OnLogWindowDragDrop (object sender, DragEventArgs e) + { +#if DEBUG + var formats = e.Data.GetFormats(); + var s = "Dropped formats: "; + foreach (var format in formats) + { + s += format; + s += " , "; + } + + s = s[..^3]; + _logger.Debug(s); +#endif + + if (e.Data.GetDataPresent(DataFormats.FileDrop)) + { + var o = e.Data.GetData(DataFormats.FileDrop); + if (o is string[] names) + { + LoadFiles(names, (e.KeyState & 4) == 4); // (shift pressed?) + e.Effect = DragDropEffects.Copy; + } + } + } + + [SupportedOSPlatform("windows")] + private void OnTimeShiftToolStripMenuItemCheckStateChanged (object sender, EventArgs e) + { + if (!_skipEvents && CurrentLogWindow != null) + { + CurrentLogWindow.SetTimeshiftValue(timeshiftMenuTextBox.Text); + timeshiftMenuTextBox.Enabled = timeshiftToolStripMenuItem.Checked; + CurrentLogWindow.TimeshiftEnabled(timeshiftToolStripMenuItem.Checked, + timeshiftMenuTextBox.Text); + } + } + + [SupportedOSPlatform("windows")] + private void OnAboutToolStripMenuItemClick (object sender, EventArgs e) + { + AboutBox aboutBox = new() + { + TopMost = TopMost + }; + + aboutBox.ShowDialog(); + } + + private void OnFilterToolStripMenuItemClick (object sender, EventArgs e) + { + CurrentLogWindow?.ToggleFilterPanel(); + } + + [SupportedOSPlatform("windows")] + private void OnMultiFileToolStripMenuItemClick (object sender, EventArgs e) + { + ToggleMultiFile(); + fileToolStripMenuItem.HideDropDown(); + } + + [SupportedOSPlatform("windows")] + private void OnGuiStateUpdate (object sender, GuiStateArgs e) + { + BeginInvoke(GuiStateUpdateWorker, e); + } + + private void OnColumnizerChanged (object sender, ColumnizerEventArgs e) + { + _bookmarkWindow?.SetColumnizer(e.Columnizer); + } + + private void OnBookmarkAdded (object sender, EventArgs e) + { + _bookmarkWindow.UpdateView(); + } + + private void OnBookmarkTextChanged (object sender, BookmarkEventArgs e) + { + _bookmarkWindow.BookmarkTextChanged(e.Bookmark); + } + + private void OnBookmarkRemoved (object sender, EventArgs e) + { + _bookmarkWindow.UpdateView(); + } + + private void OnProgressBarUpdate (object sender, ProgressEventArgs e) + { + Invoke(ProgressBarUpdateWorker, e); + } + + private void OnStatusLineEvent (object sender, StatusLineEventArgs e) + { + StatusLineEventWorker(e); + } + + private void OnFollowTailCheckBoxClick (object sender, EventArgs e) + { + CurrentLogWindow?.FollowTailChanged(checkBoxFollowTail.Checked, false); + } + + private void OnLogTabWindowKeyDown (object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.W && e.Control) + { + CurrentLogWindow?.Close(); + } + else if (e.KeyCode == Keys.Tab && e.Control) + { + SwitchTab(e.Shift); + } + else + { + CurrentLogWindow?.OnLogWindowKeyDown(sender, e); + } + } + + private void OnCloseFileToolStripMenuItemClick (object sender, EventArgs e) + { + CurrentLogWindow?.Close(); + } + + [SupportedOSPlatform("windows")] + private void OnCellSelectModeToolStripMenuItemClick (object sender, EventArgs e) + { + CurrentLogWindow?.SetCellSelectionMode(cellSelectModeToolStripMenuItem.Checked); + } + + private void OnCopyMarkedLinesIntoNewTabToolStripMenuItemClick (object sender, EventArgs e) + { + CurrentLogWindow?.CopyMarkedLinesToTab(); + } + + private void OnTimeShiftMenuTextBoxKeyDown (object sender, KeyEventArgs e) + { + if (CurrentLogWindow == null) + { + return; + } + + if (e.KeyCode == Keys.Enter) + { + e.Handled = true; + CurrentLogWindow.SetTimeshiftValue(timeshiftMenuTextBox.Text); + } + } + + [SupportedOSPlatform("windows")] + private void OnAlwaysOnTopToolStripMenuItemClick (object sender, EventArgs e) + { + TopMost = alwaysOnTopToolStripMenuItem.Checked; + } + + private void OnFileSizeChanged (object sender, LogEventArgs e) + { + if (sender.GetType().IsAssignableFrom(typeof(LogWindow.LogWindow))) + { + var diff = e.LineCount - e.PrevLineCount; + if (diff < 0) + { + return; + } + + if (((LogWindow.LogWindow)sender).Tag is LogWindowData data) + { + lock (data) + { + data.DiffSum += diff; + if (data.DiffSum > DIFF_MAX) + { + data.DiffSum = DIFF_MAX; + } + } + + //if (this.dockPanel.ActiveContent != null && + // this.dockPanel.ActiveContent != sender || data.tailState != 0) + if (CurrentLogWindow != null && + CurrentLogWindow != sender || data.TailState != 0) + { + data.Dirty = true; + } + var icon = GetIcon(diff, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); + } + } + } + + private void OnLogWindowFileNotFound (object sender, EventArgs e) + { + Invoke(new FileNotFoundDelegate(FileNotFound), sender); + } + + private void OnLogWindowFileRespawned (object sender, EventArgs e) + { + Invoke(new FileRespawnedDelegate(FileRespawned), sender); + } + + private void OnLogWindowFilterListChanged (object sender, FilterListChangedEventArgs e) + { + lock (_logWindowList) + { + foreach (var logWindow in _logWindowList) + { + if (logWindow != e.LogWindow) + { + logWindow.HandleChangedFilterList(); + } + } + } + ConfigManager.Save(SettingsFlags.FilterList); + } + + private void OnLogWindowCurrentHighlightGroupChanged (object sender, CurrentHighlightGroupChangedEventArgs e) + { + OnHighlightSettingsChanged(); + ConfigManager.Settings.Preferences.HighlightGroupList = HighlightGroupList; + ConfigManager.Save(SettingsFlags.HighlightSettings); + } + + private void OnTailFollowed (object sender, EventArgs e) + { + if (dockPanel.ActiveContent == null) + { + return; + } + if (sender.GetType().IsAssignableFrom(typeof(LogWindow.LogWindow))) + { + if (dockPanel.ActiveContent == sender) + { + var data = ((LogWindow.LogWindow)sender).Tag as LogWindowData; + data.Dirty = false; + var icon = GetIcon(data.DiffSum, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); + } + } + } + + [SupportedOSPlatform("windows")] + private void OnLogWindowSyncModeChanged (object sender, SyncModeEventArgs e) + { + if (!Disposing) + { + var data = ((LogWindow.LogWindow)sender).Tag as LogWindowData; + data.SyncMode = e.IsTimeSynced ? 1 : 0; + var icon = GetIcon(data.DiffSum, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); + } + else + { + _logger.Warn(CultureInfo.InvariantCulture, "Received SyncModeChanged event while disposing. Event ignored."); + } + } + + [SupportedOSPlatform("windows")] + private void OnToggleBookmarkToolStripMenuItemClick (object sender, EventArgs e) + { + CurrentLogWindow?.ToggleBookmark(); + } + + [SupportedOSPlatform("windows")] + private void OnJumpToNextToolStripMenuItemClick (object sender, EventArgs e) + { + CurrentLogWindow?.JumpNextBookmark(); + } + + [SupportedOSPlatform("windows")] + private void OnJumpToPrevToolStripMenuItemClick (object sender, EventArgs e) + { + CurrentLogWindow?.JumpPrevBookmark(); + } + + [SupportedOSPlatform("windows")] + private void OnASCIIToolStripMenuItemClick (object sender, EventArgs e) + { + CurrentLogWindow?.ChangeEncoding(Encoding.ASCII); + } + + [SupportedOSPlatform("windows")] + private void OnANSIToolStripMenuItemClick (object sender, EventArgs e) + { + CurrentLogWindow?.ChangeEncoding(Encoding.Default); + } + + [SupportedOSPlatform("windows")] + private void OnUTF8ToolStripMenuItemClick (object sender, EventArgs e) + { + CurrentLogWindow?.ChangeEncoding(new UTF8Encoding(false)); + } + + [SupportedOSPlatform("windows")] + private void OnUTF16ToolStripMenuItemClick (object sender, EventArgs e) + { + CurrentLogWindow?.ChangeEncoding(Encoding.Unicode); + } + + [SupportedOSPlatform("windows")] + private void OnISO88591ToolStripMenuItemClick (object sender, EventArgs e) + { + CurrentLogWindow?.ChangeEncoding(Encoding.GetEncoding("iso-8859-1")); + } + + [SupportedOSPlatform("windows")] + private void OnReloadToolStripMenuItemClick (object sender, EventArgs e) + { + if (CurrentLogWindow != null) + { + var data = CurrentLogWindow.Tag as LogWindowData; + var icon = GetIcon(0, data); + BeginInvoke(new SetTabIconDelegate(SetTabIcon), CurrentLogWindow, icon); + CurrentLogWindow.Reload(); + } + } + + [SupportedOSPlatform("windows")] + private void OnSettingsToolStripMenuItemClick (object sender, EventArgs e) + { + OpenSettings(0); + } + + [SupportedOSPlatform("windows")] + private void OnDateTimeDragControlValueDragged (object sender, EventArgs e) + { + if (CurrentLogWindow != null) + { + //this.CurrentLogWindow.ScrollToTimestamp(this.dateTimeDragControl.DateTime); + } + } + + [SupportedOSPlatform("windows")] + private void OnDateTimeDragControlValueChanged (object sender, EventArgs e) + { + CurrentLogWindow?.ScrollToTimestamp(dragControlDateTime.DateTime, true, true); + } + + [SupportedOSPlatform("windows")] + private void OnLogTabWindowDeactivate (object sender, EventArgs e) + { + CurrentLogWindow?.AppFocusLost(); + } + + [SupportedOSPlatform("windows")] + private void OnLogTabWindowActivated (object sender, EventArgs e) + { + CurrentLogWindow?.AppFocusGained(); + } + + [SupportedOSPlatform("windows")] + private void OnShowBookmarkListToolStripMenuItemClick (object sender, EventArgs e) + { + if (_bookmarkWindow.Visible) + { + _bookmarkWindow.Hide(); + } + else + { + // strange: on very first Show() now bookmarks are displayed. after a hide it will work. + if (_firstBookmarkWindowShow) + { + _bookmarkWindow.Show(dockPanel); + _bookmarkWindow.Hide(); + } + + _bookmarkWindow.Show(dockPanel); + } + } + + [SupportedOSPlatform("windows")] + private void OnToolStripButtonOpenClick (object sender, EventArgs e) + { + OpenFileDialog(); + } + + [SupportedOSPlatform("windows")] + private void OnToolStripButtonSearchClick (object sender, EventArgs e) + { + OpenSearchDialog(); + } + + [SupportedOSPlatform("windows")] + private void OnToolStripButtonFilterClick (object sender, EventArgs e) + { + CurrentLogWindow?.ToggleFilterPanel(); + } + + [SupportedOSPlatform("windows")] + private void OnToolStripButtonBookmarkClick (object sender, EventArgs e) + { + CurrentLogWindow?.ToggleBookmark(); + } + + [SupportedOSPlatform("windows")] + private void OnToolStripButtonUpClick (object sender, EventArgs e) + { + CurrentLogWindow?.JumpPrevBookmark(); + } + + [SupportedOSPlatform("windows")] + private void OnToolStripButtonDownClick (object sender, EventArgs e) + { + CurrentLogWindow?.JumpNextBookmark(); + } + + [SupportedOSPlatform("windows")] + private void OnShowHelpToolStripMenuItemClick (object sender, EventArgs e) + { + Help.ShowHelp(this, "LogExpert.chm"); + } + + private void OnHideLineColumnToolStripMenuItemClick (object sender, EventArgs e) + { + ConfigManager.Settings.HideLineColumn = hideLineColumnToolStripMenuItem.Checked; + lock (_logWindowList) + { + foreach (var logWin in _logWindowList) + { + logWin.ShowLineColumn(!ConfigManager.Settings.HideLineColumn); + } + } + _bookmarkWindow.LineColumnVisible = ConfigManager.Settings.HideLineColumn; + } + + // ================================================================== + // Tab context menu stuff + // ================================================================== + + [SupportedOSPlatform("windows")] + private void OnCloseThisTabToolStripMenuItemClick (object sender, EventArgs e) + { + (dockPanel.ActiveContent as LogWindow.LogWindow).Close(); + } + + [SupportedOSPlatform("windows")] + private void OnCloseOtherTabsToolStripMenuItemClick (object sender, EventArgs e) + { + var closeList = dockPanel.Contents + .OfType() + .Where(content => content != dockPanel.ActiveContent) + .ToList(); + + foreach (var logWindow in closeList) + { + logWindow.Close(); + } + } + + [SupportedOSPlatform("windows")] + private void OnCloseAllTabsToolStripMenuItemClick (object sender, EventArgs e) + { + CloseAllTabs(); + } + + [SupportedOSPlatform("windows")] + private void OnTabColorToolStripMenuItemClick (object sender, EventArgs e) + { + var logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; + + if (logWindow.Tag is not LogWindowData data) + { + return; + } + + ColorDialog dlg = new() + { + Color = data.Color + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + data.Color = dlg.Color; + SetTabColor(logWindow, data.Color); + } + + List delList = []; + + foreach (var entry in ConfigManager.Settings.FileColors) + { + if (entry.FileName.Equals(logWindow.FileName, StringComparison.Ordinal)) + { + delList.Add(entry); + } + } + + foreach (var entry in delList) + { + _ = ConfigManager.Settings.FileColors.Remove(entry); + } + + ConfigManager.Settings.FileColors.Add(new ColorEntry(logWindow.FileName, dlg.Color)); + + while (ConfigManager.Settings.FileColors.Count > MAX_COLOR_HISTORY) + { + ConfigManager.Settings.FileColors.RemoveAt(0); + } + } + + [SupportedOSPlatform("windows")] + private void OnLogTabWindowSizeChanged (object sender, EventArgs e) + { + if (WindowState != FormWindowState.Minimized) + { + _wasMaximized = WindowState == FormWindowState.Maximized; + } + } + + [SupportedOSPlatform("windows")] + private void OnSaveProjectToolStripMenuItemClick (object sender, EventArgs e) + { + SaveFileDialog dlg = new() + { + DefaultExt = "lxj", + Filter = @"LogExpert session (*.lxj)|*.lxj" + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + var fileName = dlg.FileName; + List fileNames = []; + + lock (_logWindowList) + { + foreach (var logWindow in dockPanel.Contents.OfType()) + { + var persistenceFileName = logWindow?.SavePersistenceData(true); + if (persistenceFileName != null) + { + fileNames.Add(persistenceFileName); + } + } + } + + ProjectData projectData = new() + { + MemberList = fileNames, + TabLayoutXml = SaveLayout() + }; + ProjectPersister.SaveProjectData(fileName, projectData); + } + } + + [SupportedOSPlatform("windows")] + private void OnLoadProjectToolStripMenuItemClick (object sender, EventArgs e) + { + OpenFileDialog dlg = new() + { + DefaultExt = "lxj", + Filter = @"LogExpert sessions (*.lxj)|*.lxj" + }; + + if (dlg.ShowDialog() == DialogResult.OK) + { + var projectFileName = dlg.FileName; + LoadProject(projectFileName, true); + } + } + + [SupportedOSPlatform("windows")] + private void OnToolStripButtonBubblesClick (object sender, EventArgs e) + { + if (CurrentLogWindow != null) + { + CurrentLogWindow.ShowBookmarkBubbles = toolStripButtonBubbles.Checked; + } + } + + [SupportedOSPlatform("windows")] + private void OnCopyPathToClipboardToolStripMenuItemClick (object sender, EventArgs e) + { + var logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; + Clipboard.SetText(logWindow.Title); + } + + private void OnFindInExplorerToolStripMenuItemClick (object sender, EventArgs e) + { + var logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; + + Process explorer = new(); + explorer.StartInfo.FileName = "explorer.exe"; + explorer.StartInfo.Arguments = "/e,/select," + logWindow.Title; + explorer.StartInfo.UseShellExecute = false; + explorer.Start(); + } + + private void TruncateFileToolStripMenuItem_Click (object sender, EventArgs e) + { + CurrentLogWindow?.TryToTruncate(); + } + + private void OnExportBookmarksToolStripMenuItemClick (object sender, EventArgs e) + { + CurrentLogWindow?.ExportBookmarkList(); + } + + [SupportedOSPlatform("windows")] + private void OnHighlightGroupsComboBoxDropDownClosed (object sender, EventArgs e) + { + ApplySelectedHighlightGroup(); + } + + [SupportedOSPlatform("windows")] + private void OnHighlightGroupsComboBoxSelectedIndexChanged (object sender, EventArgs e) + { + ApplySelectedHighlightGroup(); + } + + [SupportedOSPlatform("windows")] + private void OnHighlightGroupsComboBoxMouseUp (object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + ShowHighlightSettingsDialog(); + } + } + + + private void OnConfigChanged (object sender, ConfigChangedEventArgs e) + { + if (LogExpertProxy != null) + { + NotifySettingsChanged(null, e.Flags); + } + } + + [SupportedOSPlatform("windows")] + private void OnDumpLogBufferInfoToolStripMenuItemClick (object sender, EventArgs e) + { +#if DEBUG + CurrentLogWindow?.DumpBufferInfo(); +#endif + } + + [SupportedOSPlatform("windows")] + private void OnDumpBufferDiagnosticToolStripMenuItemClick (object sender, EventArgs e) + { +#if DEBUG + CurrentLogWindow?.DumpBufferDiagnostic(); +#endif + } + + private void OnRunGCToolStripMenuItemClick (object sender, EventArgs e) + { + RunGC(); + } + + private void OnGCInfoToolStripMenuItemClick (object sender, EventArgs e) + { + DumpGCInfo(); + } + + [SupportedOSPlatform("windows")] + private void OnToolsToolStripMenuItemDropDownItemClicked (object sender, ToolStripItemClickedEventArgs e) + { + if (e.ClickedItem.Tag is ToolEntry tag) + { + ToolButtonClick(tag); + } + } + + [SupportedOSPlatform("windows")] + private void OnExternalToolsToolStripItemClicked (object sender, ToolStripItemClickedEventArgs e) + { + ToolButtonClick(e.ClickedItem.Tag as ToolEntry); + } + + [SupportedOSPlatform("windows")] + private void OnConfigureToolStripMenuItemClick (object sender, EventArgs e) + { + OpenSettings(2); + } + + private void OnThrowExceptionGUIThreadToolStripMenuItemClick (object sender, EventArgs e) + { + throw new Exception("This is a test exception thrown by the GUI thread"); + } + + private void OnThrowExceptionBackgroundThToolStripMenuItemClick (object sender, EventArgs e) + { + ExceptionFx fx = ThrowExceptionFx; + fx.BeginInvoke(null, null); + } + + private void OnThrowExceptionBackgroundThreadToolStripMenuItemClick (object sender, EventArgs e) + { + Thread thread = new(ThrowExceptionThreadFx) + { + IsBackground = true + }; + + thread.Start(); + } + + private void OnWarnToolStripMenuItemClick (object sender, EventArgs e) + { + //_logger.GetLogger().LogLevel = _logger.Level.WARN; + } + + private void OnInfoToolStripMenuItemClick (object sender, EventArgs e) + { + //_logger.Get_logger().LogLevel = _logger.Level.INFO; + } + + private void OnDebugToolStripMenuItemClick (object sender, EventArgs e) + { + //_logger.Get_logger().LogLevel = _logger.Level.DEBUG; + } + + private void OnLogLevelToolStripMenuItemClick (object sender, EventArgs e) + { + } + + private void OnLogLevelToolStripMenuItemDropDownOpening (object sender, EventArgs e) + { + //warnToolStripMenuItem.Checked = _logger.Get_logger().LogLevel == _logger.Level.WARN; + //infoToolStripMenuItem.Checked = _logger.Get_logger().LogLevel == _logger.Level.INFO; + //debugToolStripMenuItem1.Checked = _logger.Get_logger().LogLevel == _logger.Level.DEBUG; + } + + [SupportedOSPlatform("windows")] + private void OnDisableWordHighlightModeToolStripMenuItemClick (object sender, EventArgs e) + { + DebugOptions.DisableWordHighlight = disableWordHighlightModeToolStripMenuItem.Checked; + CurrentLogWindow?.RefreshAllGrids(); + } + + [SupportedOSPlatform("windows")] + private void OnMultiFileMaskToolStripMenuItemClick (object sender, EventArgs e) + { + CurrentLogWindow?.ChangeMultifileMask(); + } + + [SupportedOSPlatform("windows")] + private void OnMultiFileEnabledStripMenuItemClick (object sender, EventArgs e) + { + ToggleMultiFile(); + } + + [SupportedOSPlatform("windows")] + private void OnLockInstanceToolStripMenuItemClick (object sender, EventArgs e) + { + AbstractLogTabWindow.StaticData.CurrentLockedMainWindow = lockInstanceToolStripMenuItem.Checked ? null : this; + } + + [SupportedOSPlatform("windows")] + private void OnOptionToolStripMenuItemDropDownOpening (object sender, EventArgs e) + { + lockInstanceToolStripMenuItem.Enabled = !ConfigManager.Settings.Preferences.AllowOnlyOneInstance; + lockInstanceToolStripMenuItem.Checked = AbstractLogTabWindow.StaticData.CurrentLockedMainWindow == this; + } + + [SupportedOSPlatform("windows")] + private void OnFileToolStripMenuItemDropDownOpening (object sender, EventArgs e) + { + newFromClipboardToolStripMenuItem.Enabled = Clipboard.ContainsText(); + } + + [SupportedOSPlatform("windows")] + private void OnNewFromClipboardToolStripMenuItemClick (object sender, EventArgs e) + { + PasteFromClipboard(); + } + + [SupportedOSPlatform("windows")] + private void OnOpenURIToolStripMenuItemClick (object sender, EventArgs e) + { + OpenUriDialog dlg = new() + { + UriHistory = ConfigManager.Settings.UriHistoryList + }; + + if (DialogResult.OK == dlg.ShowDialog()) + { + if (dlg.Uri.Trim().Length > 0) + { + ConfigManager.Settings.UriHistoryList = dlg.UriHistory; + ConfigManager.Save(SettingsFlags.FileHistory); + LoadFiles([dlg.Uri], false); + } + } + } + + [SupportedOSPlatform("windows")] + private void OnColumnFinderToolStripMenuItemClick (object sender, EventArgs e) + { + if (CurrentLogWindow != null && !_skipEvents) + { + CurrentLogWindow.ToggleColumnFinder(columnFinderToolStripMenuItem.Checked, true); + } + } + + [SupportedOSPlatform("windows")] + private void OnDockPanelActiveContentChanged (object sender, EventArgs e) + { + if (dockPanel.ActiveContent is LogWindow.LogWindow window) + { + CurrentLogWindow = window; + CurrentLogWindow.LogWindowActivated(); + ConnectToolWindows(CurrentLogWindow); + } + } + + [SupportedOSPlatform("windows")] + private void OnTabRenameToolStripMenuItemClick (object sender, EventArgs e) + { + if (CurrentLogWindow != null) + { + TabRenameDialog dlg = new() + { + TabName = CurrentLogWindow.Text + }; + + if (DialogResult.OK == dlg.ShowDialog()) + { + CurrentLogWindow.Text = dlg.TabName; + } + + dlg.Dispose(); + } + } + + #endregion } \ No newline at end of file diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs deleted file mode 100644 index 587414f2..00000000 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs +++ /dev/null @@ -1,1094 +0,0 @@ -using System.ComponentModel; -using System.Diagnostics; -using System.Globalization; -using System.Runtime.Versioning; -using System.Text; - -using LogExpert.Core.Classes; -using LogExpert.Core.Classes.Persister; -using LogExpert.Core.Config; -using LogExpert.Core.Entities; -using LogExpert.Core.EventArguments; -using LogExpert.Dialogs; -using LogExpert.UI.Dialogs; -using LogExpert.UI.Extensions.LogWindow; - -namespace LogExpert.UI.Controls.LogTabWindow; - -internal partial class LogTabWindow -{ - #region Events handler - - private void OnBookmarkWindowVisibleChanged (object sender, EventArgs e) - { - _firstBookmarkWindowShow = false; - } - - private void OnLogTabWindowLoad (object sender, EventArgs e) - { - ApplySettings(ConfigManager.Settings, SettingsFlags.All); - if (ConfigManager.Settings.IsMaximized) - { - Bounds = ConfigManager.Settings.AppBoundsFullscreen; - WindowState = FormWindowState.Maximized; - Bounds = ConfigManager.Settings.AppBounds; - } - else - { - if (ConfigManager.Settings.AppBounds.Right > 0) - { - Bounds = ConfigManager.Settings.AppBounds; - } - } - - if (ConfigManager.Settings.Preferences.OpenLastFiles && _startupFileNames == null) - { - var tmpList = ObjectClone.Clone(ConfigManager.Settings.LastOpenFilesList); - - foreach (var name in tmpList) - { - if (string.IsNullOrEmpty(name) == false) - { - AddFileTab(name, false, null, false, null); - } - } - } - - if (_startupFileNames != null) - { - LoadFiles(_startupFileNames, false); - } - - _ledThread = new Thread(LedThreadProc) - { - IsBackground = true - }; - _ledThread.Start(); - - FillHighlightComboBox(); - FillToolLauncherBar(); -#if !DEBUG - debugToolStripMenuItem.Visible = false; -#endif - } - - private void OnLogTabWindowClosing (object sender, CancelEventArgs e) - { - try - { - _shouldStop = true; - _ = _statusLineEventHandle.Set(); - _ = _statusLineEventWakeupHandle.Set(); - _ledThread.Join(); - - IList deleteLogWindowList = []; - ConfigManager.Settings.AlwaysOnTop = TopMost && ConfigManager.Settings.Preferences.AllowOnlyOneInstance; - SaveLastOpenFilesList(); - - foreach (var logWindow in _logWindowList.ToArray()) - { - RemoveAndDisposeLogWindow(logWindow, true); - } - - DestroyBookmarkWindow(); - - ConfigManager.Instance.ConfigChanged -= OnConfigChanged; - - SaveWindowPosition(); - ConfigManager.Save(SettingsFlags.WindowPosition | SettingsFlags.FileHistory); - } - catch (Exception) - { - // ignore error (can occur then multipe instances are closed simultaneously or if the - // window was not constructed completely because of errors) - } - finally - { - LogExpertProxy?.WindowClosed(this); - } - } - - private void OnStripMouseUp (object sender, MouseEventArgs e) - { - if (sender is ToolStripDropDown dropDown) - { - AddFileTab(dropDown.Text, false, null, false, null); - } - } - - private void OnHistoryItemClicked (object sender, ToolStripItemClickedEventArgs e) - { - if (string.IsNullOrEmpty(e.ClickedItem.Text) == false) - { - AddFileTab(e.ClickedItem.Text, false, null, false, null); - } - } - - private void OnLogWindowDisposed (object sender, EventArgs e) - { - var logWindow = sender as LogWindow.LogWindow; - - if (sender == CurrentLogWindow) - { - ChangeCurrentLogWindow(null); - } - - RemoveLogWindow(logWindow); - - logWindow.Tag = null; - } - - private void OnExitToolStripMenuItemClick (object sender, EventArgs e) - { - Close(); - } - - private void OnSelectFilterToolStripMenuItemClick (object sender, EventArgs e) - { - if (CurrentLogWindow == null) - { - return; - } - - CurrentLogWindow.ColumnizerCallbackObject.LineNum = CurrentLogWindow.GetCurrentLineNum(); - FilterSelectorForm form = new(PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers, CurrentLogWindow.CurrentColumnizer, CurrentLogWindow.ColumnizerCallbackObject, ConfigManager) - { - Owner = this, - TopMost = TopMost - }; - var res = form.ShowDialog(); - - if (res == DialogResult.OK) - { - if (form.ApplyToAll) - { - lock (_logWindowList) - { - foreach (var logWindow in _logWindowList) - { - if (logWindow.CurrentColumnizer.GetType() != form.SelectedColumnizer.GetType()) - { - //logWindow.SetColumnizer(form.SelectedColumnizer); - SetColumnizerFx fx = logWindow.ForceColumnizer; - logWindow.Invoke(fx, form.SelectedColumnizer); - SetColumnizerHistoryEntry(logWindow.FileName, form.SelectedColumnizer); - } - else - { - if (form.IsConfigPressed) - { - logWindow.ColumnizerConfigChanged(); - } - } - } - } - } - else - { - if (CurrentLogWindow.CurrentColumnizer.GetType() != form.SelectedColumnizer.GetType()) - { - SetColumnizerFx fx = CurrentLogWindow.ForceColumnizer; - CurrentLogWindow.Invoke(fx, form.SelectedColumnizer); - SetColumnizerHistoryEntry(CurrentLogWindow.FileName, form.SelectedColumnizer); - } - - if (form.IsConfigPressed) - { - lock (_logWindowList) - { - foreach (var logWindow in _logWindowList) - { - if (logWindow.CurrentColumnizer.GetType() == form.SelectedColumnizer.GetType()) - { - logWindow.ColumnizerConfigChanged(); - } - } - } - } - } - } - } - - private void OnGoToLineToolStripMenuItemClick (object sender, EventArgs e) - { - if (CurrentLogWindow == null) - { - return; - } - - GotoLineDialog dlg = new(this); - var res = dlg.ShowDialog(); - if (res == DialogResult.OK) - { - var line = dlg.Line - 1; - if (line >= 0) - { - CurrentLogWindow.GotoLine(line); - } - } - } - - private void OnHighlightingToolStripMenuItemClick (object sender, EventArgs e) - { - ShowHighlightSettingsDialog(); - } - - private void OnSearchToolStripMenuItemClick (object sender, EventArgs e) - { - OpenSearchDialog(); - } - - private void OnOpenToolStripMenuItemClick (object sender, EventArgs e) - { - OpenFileDialog(); - } - - private void OnLogTabWindowDragEnter (object sender, DragEventArgs e) - { -#if DEBUG - var formats = e.Data.GetFormats(); - var s = "Dragging something over LogExpert. Formats: "; - foreach (var format in formats) - { - s += format; - s += " , "; - } - - s = s[..^3]; - _logger.Info(s); -#endif - } - - private void OnLogWindowDragOver (object sender, DragEventArgs e) - { - if (!e.Data.GetDataPresent(DataFormats.FileDrop)) - { - e.Effect = DragDropEffects.None; - } - else - { - e.Effect = DragDropEffects.Copy; - } - } - - private void OnLogWindowDragDrop (object sender, DragEventArgs e) - { -#if DEBUG - var formats = e.Data.GetFormats(); - var s = "Dropped formats: "; - foreach (var format in formats) - { - s += format; - s += " , "; - } - - s = s[..^3]; - _logger.Debug(s); -#endif - - if (e.Data.GetDataPresent(DataFormats.FileDrop)) - { - var o = e.Data.GetData(DataFormats.FileDrop); - if (o is string[] names) - { - LoadFiles(names, (e.KeyState & 4) == 4); // (shift pressed?) - e.Effect = DragDropEffects.Copy; - } - } - } - - [SupportedOSPlatform("windows")] - private void OnTimeShiftToolStripMenuItemCheckStateChanged (object sender, EventArgs e) - { - if (!_skipEvents && CurrentLogWindow != null) - { - CurrentLogWindow.SetTimeshiftValue(timeshiftMenuTextBox.Text); - timeshiftMenuTextBox.Enabled = timeshiftToolStripMenuItem.Checked; - CurrentLogWindow.TimeshiftEnabled(timeshiftToolStripMenuItem.Checked, - timeshiftMenuTextBox.Text); - } - } - - [SupportedOSPlatform("windows")] - private void OnAboutToolStripMenuItemClick (object sender, EventArgs e) - { - AboutBox aboutBox = new() - { - TopMost = TopMost - }; - - aboutBox.ShowDialog(); - } - - private void OnFilterToolStripMenuItemClick (object sender, EventArgs e) - { - CurrentLogWindow?.ToggleFilterPanel(); - } - - [SupportedOSPlatform("windows")] - private void OnMultiFileToolStripMenuItemClick (object sender, EventArgs e) - { - ToggleMultiFile(); - fileToolStripMenuItem.HideDropDown(); - } - - [SupportedOSPlatform("windows")] - private void OnGuiStateUpdate (object sender, GuiStateArgs e) - { - BeginInvoke(GuiStateUpdateWorker, e); - } - - private void OnColumnizerChanged (object sender, ColumnizerEventArgs e) - { - _bookmarkWindow?.SetColumnizer(e.Columnizer); - } - - private void OnBookmarkAdded (object sender, EventArgs e) - { - _bookmarkWindow.UpdateView(); - } - - private void OnBookmarkTextChanged (object sender, BookmarkEventArgs e) - { - _bookmarkWindow.BookmarkTextChanged(e.Bookmark); - } - - private void OnBookmarkRemoved (object sender, EventArgs e) - { - _bookmarkWindow.UpdateView(); - } - - private void OnProgressBarUpdate (object sender, ProgressEventArgs e) - { - Invoke(ProgressBarUpdateWorker, e); - } - - private void OnStatusLineEvent (object sender, StatusLineEventArgs e) - { - StatusLineEventWorker(e); - } - - private void OnFollowTailCheckBoxClick (object sender, EventArgs e) - { - CurrentLogWindow?.FollowTailChanged(checkBoxFollowTail.Checked, false); - } - - private void OnLogTabWindowKeyDown (object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.W && e.Control) - { - CurrentLogWindow?.Close(); - } - else if (e.KeyCode == Keys.Tab && e.Control) - { - SwitchTab(e.Shift); - } - else - { - CurrentLogWindow?.OnLogWindowKeyDown(sender, e); - } - } - - private void OnCloseFileToolStripMenuItemClick (object sender, EventArgs e) - { - CurrentLogWindow?.Close(); - } - - [SupportedOSPlatform("windows")] - private void OnCellSelectModeToolStripMenuItemClick (object sender, EventArgs e) - { - CurrentLogWindow?.SetCellSelectionMode(cellSelectModeToolStripMenuItem.Checked); - } - - private void OnCopyMarkedLinesIntoNewTabToolStripMenuItemClick (object sender, EventArgs e) - { - CurrentLogWindow?.CopyMarkedLinesToTab(); - } - - private void OnTimeShiftMenuTextBoxKeyDown (object sender, KeyEventArgs e) - { - if (CurrentLogWindow == null) - { - return; - } - - if (e.KeyCode == Keys.Enter) - { - e.Handled = true; - CurrentLogWindow.SetTimeshiftValue(timeshiftMenuTextBox.Text); - } - } - - [SupportedOSPlatform("windows")] - private void OnAlwaysOnTopToolStripMenuItemClick (object sender, EventArgs e) - { - TopMost = alwaysOnTopToolStripMenuItem.Checked; - } - - private void OnFileSizeChanged (object sender, LogEventArgs e) - { - if (sender.GetType().IsAssignableFrom(typeof(LogWindow.LogWindow))) - { - var diff = e.LineCount - e.PrevLineCount; - if (diff < 0) - { - return; - } - - if (((LogWindow.LogWindow)sender).Tag is LogWindowData data) - { - lock (data) - { - data.DiffSum += diff; - if (data.DiffSum > DIFF_MAX) - { - data.DiffSum = DIFF_MAX; - } - } - - //if (this.dockPanel.ActiveContent != null && - // this.dockPanel.ActiveContent != sender || data.tailState != 0) - if (CurrentLogWindow != null && - CurrentLogWindow != sender || data.TailState != 0) - { - data.Dirty = true; - } - var icon = GetIcon(diff, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); - } - } - } - - private void OnLogWindowFileNotFound (object sender, EventArgs e) - { - Invoke(new FileNotFoundDelegate(FileNotFound), sender); - } - - private void OnLogWindowFileRespawned (object sender, EventArgs e) - { - Invoke(new FileRespawnedDelegate(FileRespawned), sender); - } - - private void OnLogWindowFilterListChanged (object sender, FilterListChangedEventArgs e) - { - lock (_logWindowList) - { - foreach (var logWindow in _logWindowList) - { - if (logWindow != e.LogWindow) - { - logWindow.HandleChangedFilterList(); - } - } - } - ConfigManager.Save(SettingsFlags.FilterList); - } - - private void OnLogWindowCurrentHighlightGroupChanged (object sender, CurrentHighlightGroupChangedEventArgs e) - { - OnHighlightSettingsChanged(); - ConfigManager.Settings.Preferences.HighlightGroupList = HighlightGroupList; - ConfigManager.Save(SettingsFlags.HighlightSettings); - } - - private void OnTailFollowed (object sender, EventArgs e) - { - if (dockPanel.ActiveContent == null) - { - return; - } - if (sender.GetType().IsAssignableFrom(typeof(LogWindow.LogWindow))) - { - if (dockPanel.ActiveContent == sender) - { - var data = ((LogWindow.LogWindow)sender).Tag as LogWindowData; - data.Dirty = false; - var icon = GetIcon(data.DiffSum, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); - } - } - } - - [SupportedOSPlatform("windows")] - private void OnLogWindowSyncModeChanged (object sender, SyncModeEventArgs e) - { - if (!Disposing) - { - var data = ((LogWindow.LogWindow)sender).Tag as LogWindowData; - data.SyncMode = e.IsTimeSynced ? 1 : 0; - var icon = GetIcon(data.DiffSum, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), (LogWindow.LogWindow)sender, icon); - } - else - { - _logger.Warn(CultureInfo.InvariantCulture, "Received SyncModeChanged event while disposing. Event ignored."); - } - } - - [SupportedOSPlatform("windows")] - private void OnToggleBookmarkToolStripMenuItemClick (object sender, EventArgs e) - { - CurrentLogWindow?.ToggleBookmark(); - } - - [SupportedOSPlatform("windows")] - private void OnJumpToNextToolStripMenuItemClick (object sender, EventArgs e) - { - CurrentLogWindow?.JumpNextBookmark(); - } - - [SupportedOSPlatform("windows")] - private void OnJumpToPrevToolStripMenuItemClick (object sender, EventArgs e) - { - CurrentLogWindow?.JumpPrevBookmark(); - } - - [SupportedOSPlatform("windows")] - private void OnASCIIToolStripMenuItemClick (object sender, EventArgs e) - { - CurrentLogWindow?.ChangeEncoding(Encoding.ASCII); - } - - [SupportedOSPlatform("windows")] - private void OnANSIToolStripMenuItemClick (object sender, EventArgs e) - { - CurrentLogWindow?.ChangeEncoding(Encoding.Default); - } - - [SupportedOSPlatform("windows")] - private void OnUTF8ToolStripMenuItemClick (object sender, EventArgs e) - { - CurrentLogWindow?.ChangeEncoding(new UTF8Encoding(false)); - } - - [SupportedOSPlatform("windows")] - private void OnUTF16ToolStripMenuItemClick (object sender, EventArgs e) - { - CurrentLogWindow?.ChangeEncoding(Encoding.Unicode); - } - - [SupportedOSPlatform("windows")] - private void OnISO88591ToolStripMenuItemClick (object sender, EventArgs e) - { - CurrentLogWindow?.ChangeEncoding(Encoding.GetEncoding("iso-8859-1")); - } - - [SupportedOSPlatform("windows")] - private void OnReloadToolStripMenuItemClick (object sender, EventArgs e) - { - if (CurrentLogWindow != null) - { - var data = CurrentLogWindow.Tag as LogWindowData; - var icon = GetIcon(0, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), CurrentLogWindow, icon); - CurrentLogWindow.Reload(); - } - } - - [SupportedOSPlatform("windows")] - private void OnSettingsToolStripMenuItemClick (object sender, EventArgs e) - { - OpenSettings(0); - } - - [SupportedOSPlatform("windows")] - private void OnDateTimeDragControlValueDragged (object sender, EventArgs e) - { - if (CurrentLogWindow != null) - { - //this.CurrentLogWindow.ScrollToTimestamp(this.dateTimeDragControl.DateTime); - } - } - - [SupportedOSPlatform("windows")] - private void OnDateTimeDragControlValueChanged (object sender, EventArgs e) - { - CurrentLogWindow?.ScrollToTimestamp(dragControlDateTime.DateTime, true, true); - } - - [SupportedOSPlatform("windows")] - private void OnLogTabWindowDeactivate (object sender, EventArgs e) - { - CurrentLogWindow?.AppFocusLost(); - } - - [SupportedOSPlatform("windows")] - private void OnLogTabWindowActivated (object sender, EventArgs e) - { - CurrentLogWindow?.AppFocusGained(); - } - - [SupportedOSPlatform("windows")] - private void OnShowBookmarkListToolStripMenuItemClick (object sender, EventArgs e) - { - if (_bookmarkWindow.Visible) - { - _bookmarkWindow.Hide(); - } - else - { - // strange: on very first Show() now bookmarks are displayed. after a hide it will work. - if (_firstBookmarkWindowShow) - { - _bookmarkWindow.Show(dockPanel); - _bookmarkWindow.Hide(); - } - - _bookmarkWindow.Show(dockPanel); - } - } - - [SupportedOSPlatform("windows")] - private void OnToolStripButtonOpenClick (object sender, EventArgs e) - { - OpenFileDialog(); - } - - [SupportedOSPlatform("windows")] - private void OnToolStripButtonSearchClick (object sender, EventArgs e) - { - OpenSearchDialog(); - } - - [SupportedOSPlatform("windows")] - private void OnToolStripButtonFilterClick (object sender, EventArgs e) - { - CurrentLogWindow?.ToggleFilterPanel(); - } - - [SupportedOSPlatform("windows")] - private void OnToolStripButtonBookmarkClick (object sender, EventArgs e) - { - CurrentLogWindow?.ToggleBookmark(); - } - - [SupportedOSPlatform("windows")] - private void OnToolStripButtonUpClick (object sender, EventArgs e) - { - CurrentLogWindow?.JumpPrevBookmark(); - } - - [SupportedOSPlatform("windows")] - private void OnToolStripButtonDownClick (object sender, EventArgs e) - { - CurrentLogWindow?.JumpNextBookmark(); - } - - [SupportedOSPlatform("windows")] - private void OnShowHelpToolStripMenuItemClick (object sender, EventArgs e) - { - Help.ShowHelp(this, "LogExpert.chm"); - } - - private void OnHideLineColumnToolStripMenuItemClick (object sender, EventArgs e) - { - ConfigManager.Settings.HideLineColumn = hideLineColumnToolStripMenuItem.Checked; - lock (_logWindowList) - { - foreach (var logWin in _logWindowList) - { - logWin.ShowLineColumn(!ConfigManager.Settings.HideLineColumn); - } - } - _bookmarkWindow.LineColumnVisible = ConfigManager.Settings.HideLineColumn; - } - - // ================================================================== - // Tab context menu stuff - // ================================================================== - - [SupportedOSPlatform("windows")] - private void OnCloseThisTabToolStripMenuItemClick (object sender, EventArgs e) - { - (dockPanel.ActiveContent as LogWindow.LogWindow).Close(); - } - - [SupportedOSPlatform("windows")] - private void OnCloseOtherTabsToolStripMenuItemClick (object sender, EventArgs e) - { - var closeList = dockPanel.Contents - .OfType() - .Where(content => content != dockPanel.ActiveContent) - .ToList(); - - foreach (var logWindow in closeList) - { - logWindow.Close(); - } - } - - [SupportedOSPlatform("windows")] - private void OnCloseAllTabsToolStripMenuItemClick (object sender, EventArgs e) - { - CloseAllTabs(); - } - - [SupportedOSPlatform("windows")] - private void OnTabColorToolStripMenuItemClick (object sender, EventArgs e) - { - var logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; - - if (logWindow.Tag is not LogWindowData data) - { - return; - } - - ColorDialog dlg = new() - { - Color = data.Color - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - data.Color = dlg.Color; - SetTabColor(logWindow, data.Color); - } - - List delList = []; - - foreach (var entry in ConfigManager.Settings.FileColors) - { - if (entry.FileName.Equals(logWindow.FileName, StringComparison.Ordinal)) - { - delList.Add(entry); - } - } - - foreach (var entry in delList) - { - _ = ConfigManager.Settings.FileColors.Remove(entry); - } - - ConfigManager.Settings.FileColors.Add(new ColorEntry(logWindow.FileName, dlg.Color)); - - while (ConfigManager.Settings.FileColors.Count > MAX_COLOR_HISTORY) - { - ConfigManager.Settings.FileColors.RemoveAt(0); - } - } - - [SupportedOSPlatform("windows")] - private void OnLogTabWindowSizeChanged (object sender, EventArgs e) - { - if (WindowState != FormWindowState.Minimized) - { - _wasMaximized = WindowState == FormWindowState.Maximized; - } - } - - [SupportedOSPlatform("windows")] - private void OnSaveProjectToolStripMenuItemClick (object sender, EventArgs e) - { - SaveFileDialog dlg = new() - { - DefaultExt = "lxj", - Filter = @"LogExpert session (*.lxj)|*.lxj" - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - var fileName = dlg.FileName; - List fileNames = []; - - lock (_logWindowList) - { - foreach (var logWindow in dockPanel.Contents.OfType()) - { - var persistenceFileName = logWindow?.SavePersistenceData(true); - if (persistenceFileName != null) - { - fileNames.Add(persistenceFileName); - } - } - } - - ProjectData projectData = new() - { - MemberList = fileNames, - TabLayoutXml = SaveLayout() - }; - ProjectPersister.SaveProjectData(fileName, projectData); - } - } - - [SupportedOSPlatform("windows")] - private void OnLoadProjectToolStripMenuItemClick (object sender, EventArgs e) - { - OpenFileDialog dlg = new() - { - DefaultExt = "lxj", - Filter = @"LogExpert sessions (*.lxj)|*.lxj" - }; - - if (dlg.ShowDialog() == DialogResult.OK) - { - var projectFileName = dlg.FileName; - LoadProject(projectFileName, true); - } - } - - [SupportedOSPlatform("windows")] - private void OnToolStripButtonBubblesClick (object sender, EventArgs e) - { - if (CurrentLogWindow != null) - { - CurrentLogWindow.ShowBookmarkBubbles = toolStripButtonBubbles.Checked; - } - } - - [SupportedOSPlatform("windows")] - private void OnCopyPathToClipboardToolStripMenuItemClick (object sender, EventArgs e) - { - var logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; - Clipboard.SetText(logWindow.Title); - } - - private void OnFindInExplorerToolStripMenuItemClick (object sender, EventArgs e) - { - var logWindow = dockPanel.ActiveContent as LogWindow.LogWindow; - - Process explorer = new(); - explorer.StartInfo.FileName = "explorer.exe"; - explorer.StartInfo.Arguments = "/e,/select," + logWindow.Title; - explorer.StartInfo.UseShellExecute = false; - explorer.Start(); - } - - private void TruncateFileToolStripMenuItem_Click (object sender, EventArgs e) - { - CurrentLogWindow?.TryToTruncate(); - } - - private void OnExportBookmarksToolStripMenuItemClick (object sender, EventArgs e) - { - CurrentLogWindow?.ExportBookmarkList(); - } - - [SupportedOSPlatform("windows")] - private void OnHighlightGroupsComboBoxDropDownClosed (object sender, EventArgs e) - { - ApplySelectedHighlightGroup(); - } - - [SupportedOSPlatform("windows")] - private void OnHighlightGroupsComboBoxSelectedIndexChanged (object sender, EventArgs e) - { - ApplySelectedHighlightGroup(); - } - - [SupportedOSPlatform("windows")] - private void OnHighlightGroupsComboBoxMouseUp (object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Right) - { - ShowHighlightSettingsDialog(); - } - } - - - private void OnConfigChanged (object sender, ConfigChangedEventArgs e) - { - if (LogExpertProxy != null) - { - NotifySettingsChanged(null, e.Flags); - } - } - - [SupportedOSPlatform("windows")] - private void OnDumpLogBufferInfoToolStripMenuItemClick (object sender, EventArgs e) - { -#if DEBUG - CurrentLogWindow?.DumpBufferInfo(); -#endif - } - - [SupportedOSPlatform("windows")] - private void OnDumpBufferDiagnosticToolStripMenuItemClick (object sender, EventArgs e) - { -#if DEBUG - CurrentLogWindow?.DumpBufferDiagnostic(); -#endif - } - - private void OnRunGCToolStripMenuItemClick (object sender, EventArgs e) - { - RunGC(); - } - - private void OnGCInfoToolStripMenuItemClick (object sender, EventArgs e) - { - DumpGCInfo(); - } - - [SupportedOSPlatform("windows")] - private void OnToolsToolStripMenuItemDropDownItemClicked (object sender, ToolStripItemClickedEventArgs e) - { - if (e.ClickedItem.Tag is ToolEntry tag) - { - ToolButtonClick(tag); - } - } - - [SupportedOSPlatform("windows")] - private void OnExternalToolsToolStripItemClicked (object sender, ToolStripItemClickedEventArgs e) - { - ToolButtonClick(e.ClickedItem.Tag as ToolEntry); - } - - [SupportedOSPlatform("windows")] - private void OnConfigureToolStripMenuItemClick (object sender, EventArgs e) - { - OpenSettings(2); - } - - private void OnThrowExceptionGUIThreadToolStripMenuItemClick (object sender, EventArgs e) - { - throw new Exception("This is a test exception thrown by the GUI thread"); - } - - private void OnThrowExceptionBackgroundThToolStripMenuItemClick (object sender, EventArgs e) - { - ExceptionFx fx = ThrowExceptionFx; - fx.BeginInvoke(null, null); - } - - private void OnThrowExceptionBackgroundThreadToolStripMenuItemClick (object sender, EventArgs e) - { - Thread thread = new(ThrowExceptionThreadFx) - { - IsBackground = true - }; - - thread.Start(); - } - - private void OnWarnToolStripMenuItemClick (object sender, EventArgs e) - { - //_logger.GetLogger().LogLevel = _logger.Level.WARN; - } - - private void OnInfoToolStripMenuItemClick (object sender, EventArgs e) - { - //_logger.Get_logger().LogLevel = _logger.Level.INFO; - } - - private void OnDebugToolStripMenuItemClick (object sender, EventArgs e) - { - //_logger.Get_logger().LogLevel = _logger.Level.DEBUG; - } - - private void OnLogLevelToolStripMenuItemClick (object sender, EventArgs e) - { - } - - private void OnLogLevelToolStripMenuItemDropDownOpening (object sender, EventArgs e) - { - //warnToolStripMenuItem.Checked = _logger.Get_logger().LogLevel == _logger.Level.WARN; - //infoToolStripMenuItem.Checked = _logger.Get_logger().LogLevel == _logger.Level.INFO; - //debugToolStripMenuItem1.Checked = _logger.Get_logger().LogLevel == _logger.Level.DEBUG; - } - - [SupportedOSPlatform("windows")] - private void OnDisableWordHighlightModeToolStripMenuItemClick (object sender, EventArgs e) - { - DebugOptions.DisableWordHighlight = disableWordHighlightModeToolStripMenuItem.Checked; - CurrentLogWindow?.RefreshAllGrids(); - } - - [SupportedOSPlatform("windows")] - private void OnMultiFileMaskToolStripMenuItemClick (object sender, EventArgs e) - { - CurrentLogWindow?.ChangeMultifileMask(); - } - - [SupportedOSPlatform("windows")] - private void OnMultiFileEnabledStripMenuItemClick (object sender, EventArgs e) - { - ToggleMultiFile(); - } - - [SupportedOSPlatform("windows")] - private void OnLockInstanceToolStripMenuItemClick (object sender, EventArgs e) - { - AbstractLogTabWindow.StaticData.CurrentLockedMainWindow = lockInstanceToolStripMenuItem.Checked ? null : this; - } - - [SupportedOSPlatform("windows")] - private void OnOptionToolStripMenuItemDropDownOpening (object sender, EventArgs e) - { - lockInstanceToolStripMenuItem.Enabled = !ConfigManager.Settings.Preferences.AllowOnlyOneInstance; - lockInstanceToolStripMenuItem.Checked = AbstractLogTabWindow.StaticData.CurrentLockedMainWindow == this; - } - - [SupportedOSPlatform("windows")] - private void OnFileToolStripMenuItemDropDownOpening (object sender, EventArgs e) - { - newFromClipboardToolStripMenuItem.Enabled = Clipboard.ContainsText(); - } - - [SupportedOSPlatform("windows")] - private void OnNewFromClipboardToolStripMenuItemClick (object sender, EventArgs e) - { - PasteFromClipboard(); - } - - [SupportedOSPlatform("windows")] - private void OnOpenURIToolStripMenuItemClick (object sender, EventArgs e) - { - OpenUriDialog dlg = new() - { - UriHistory = ConfigManager.Settings.UriHistoryList - }; - - if (DialogResult.OK == dlg.ShowDialog()) - { - if (dlg.Uri.Trim().Length > 0) - { - ConfigManager.Settings.UriHistoryList = dlg.UriHistory; - ConfigManager.Save(SettingsFlags.FileHistory); - LoadFiles([dlg.Uri], false); - } - } - } - - [SupportedOSPlatform("windows")] - private void OnColumnFinderToolStripMenuItemClick (object sender, EventArgs e) - { - if (CurrentLogWindow != null && !_skipEvents) - { - CurrentLogWindow.ToggleColumnFinder(columnFinderToolStripMenuItem.Checked, true); - } - } - - [SupportedOSPlatform("windows")] - private void OnDockPanelActiveContentChanged (object sender, EventArgs e) - { - if (dockPanel.ActiveContent is LogWindow.LogWindow window) - { - CurrentLogWindow = window; - CurrentLogWindow.LogWindowActivated(); - ConnectToolWindows(CurrentLogWindow); - } - } - - [SupportedOSPlatform("windows")] - private void OnTabRenameToolStripMenuItemClick (object sender, EventArgs e) - { - if (CurrentLogWindow != null) - { - TabRenameDialog dlg = new() - { - TabName = CurrentLogWindow.Text - }; - - if (DialogResult.OK == dlg.ShowDialog()) - { - CurrentLogWindow.Text = dlg.TabName; - } - - dlg.Dispose(); - } - } - - #endregion -} \ No newline at end of file diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs deleted file mode 100644 index 4a4760c9..00000000 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs +++ /dev/null @@ -1,1375 +0,0 @@ -using System.ComponentModel; -using System.Diagnostics; -using System.Globalization; -using System.Runtime.Versioning; -using System.Security; -using System.Text; - -using LogExpert.Core.Classes; -using LogExpert.Core.Classes.Columnizer; -using LogExpert.Core.Classes.Persister; -using LogExpert.Core.Config; -using LogExpert.Core.Entities; -using LogExpert.Core.Enums; -using LogExpert.Core.EventArguments; -using LogExpert.Dialogs; -using LogExpert.PluginRegistry.FileSystem; -using LogExpert.UI.Dialogs; -using LogExpert.UI.Entities; -using LogExpert.UI.Extensions; - -using WeifenLuo.WinFormsUI.Docking; - -namespace LogExpert.UI.Controls.LogTabWindow; - -internal partial class LogTabWindow -{ - #region Private Methods - - /// - /// Creates a temp file with the text content of the clipboard and opens the temp file in a new tab. - /// - [SupportedOSPlatform("windows")] - private void PasteFromClipboard () - { - if (Clipboard.ContainsText()) - { - var text = Clipboard.GetText(); - var fileName = Path.GetTempFileName(); - - using (FileStream fStream = new(fileName, FileMode.Append, FileAccess.Write, FileShare.Read)) - using (StreamWriter writer = new(fStream, Encoding.Unicode)) - { - writer.Write(text); - writer.Close(); - } - - var title = "Clipboard"; - var logWindow = AddTempFileTab(fileName, title); - if (logWindow.Tag is LogWindowData data) - { - SetTooltipText(logWindow, "Pasted on " + DateTime.Now); - } - } - } - - [SupportedOSPlatform("windows")] - private void InitToolWindows () - { - InitBookmarkWindow(); - } - - [SupportedOSPlatform("windows")] - private void DestroyToolWindows () - { - DestroyBookmarkWindow(); - } - - [SupportedOSPlatform("windows")] - private void InitBookmarkWindow () - { - _bookmarkWindow = new BookmarkWindow - { - HideOnClose = true, - ShowHint = DockState.DockBottom - }; - - var setLastColumnWidth = ConfigManager.Settings.Preferences.SetLastColumnWidth; - var lastColumnWidth = ConfigManager.Settings.Preferences.LastColumnWidth; - var fontName = ConfigManager.Settings.Preferences.FontName; - var fontSize = ConfigManager.Settings.Preferences.FontSize; - - _bookmarkWindow.PreferencesChanged(fontName, fontSize, setLastColumnWidth, lastColumnWidth, SettingsFlags.All); - _bookmarkWindow.VisibleChanged += OnBookmarkWindowVisibleChanged; - _firstBookmarkWindowShow = true; - } - - [SupportedOSPlatform("windows")] - private void DestroyBookmarkWindow () - { - _bookmarkWindow.HideOnClose = false; - _bookmarkWindow.Close(); - } - - private void SaveLastOpenFilesList () - { - ConfigManager.Settings.LastOpenFilesList.Clear(); - foreach (DockContent content in dockPanel.Contents) - { - if (content is LogWindow.LogWindow logWin) - { - if (!logWin.IsTempFile) - { - ConfigManager.Settings.LastOpenFilesList.Add(logWin.GivenFileName); - } - } - } - } - - [SupportedOSPlatform("windows")] - private void SaveWindowPosition () - { - SuspendLayout(); - if (WindowState == FormWindowState.Normal) - { - ConfigManager.Settings.AppBounds = Bounds; - ConfigManager.Settings.IsMaximized = false; - } - else - { - ConfigManager.Settings.AppBoundsFullscreen = Bounds; - ConfigManager.Settings.IsMaximized = true; - WindowState = FormWindowState.Normal; - ConfigManager.Settings.AppBounds = Bounds; - } - - ResumeLayout(); - } - - private void SetTooltipText (LogWindow.LogWindow logWindow, string logFileName) - { - logWindow.ToolTipText = logFileName; - } - - private void FillDefaultEncodingFromSettings (EncodingOptions encodingOptions) - { - if (ConfigManager.Settings.Preferences.DefaultEncoding != null) - { - try - { - encodingOptions.DefaultEncoding = Encoding.GetEncoding(ConfigManager.Settings.Preferences.DefaultEncoding); - } - catch (ArgumentException) - { - _logger.Warn(CultureInfo.InvariantCulture, "Encoding " + ConfigManager.Settings.Preferences.DefaultEncoding + " is not a valid encoding"); - encodingOptions.DefaultEncoding = null; - } - } - } - - [SupportedOSPlatform("windows")] - private void AddFileTabs (string[] fileNames) - { - foreach (var fileName in fileNames) - { - if (!string.IsNullOrEmpty(fileName)) - { - if (fileName.EndsWith(".lxj")) - { - LoadProject(fileName, false); - } - else - { - AddFileTab(fileName, false, null, false, null); - } - } - } - - Activate(); - } - - [SupportedOSPlatform("windows")] - private void AddLogWindow (LogWindow.LogWindow logWindow, string title, bool doNotAddToPanel) - { - logWindow.CloseButton = true; - logWindow.TabPageContextMenuStrip = tabContextMenuStrip; - SetTooltipText(logWindow, title); - logWindow.DockAreas = DockAreas.Document | DockAreas.Float; - - if (!doNotAddToPanel) - { - logWindow.Show(dockPanel); - } - - LogWindowData data = new() - { - DiffSum = 0 - }; - - logWindow.Tag = data; - - lock (_logWindowList) - { - _logWindowList.Add(logWindow); - } - - logWindow.FileSizeChanged += OnFileSizeChanged; - logWindow.TailFollowed += OnTailFollowed; - logWindow.Disposed += OnLogWindowDisposed; - logWindow.FileNotFound += OnLogWindowFileNotFound; - logWindow.FileRespawned += OnLogWindowFileRespawned; - logWindow.FilterListChanged += OnLogWindowFilterListChanged; - logWindow.CurrentHighlightGroupChanged += OnLogWindowCurrentHighlightGroupChanged; - logWindow.SyncModeChanged += OnLogWindowSyncModeChanged; - - logWindow.Visible = true; - } - - [SupportedOSPlatform("windows")] - private void DisconnectEventHandlers (LogWindow.LogWindow logWindow) - { - logWindow.FileSizeChanged -= OnFileSizeChanged; - logWindow.TailFollowed -= OnTailFollowed; - logWindow.Disposed -= OnLogWindowDisposed; - logWindow.FileNotFound -= OnLogWindowFileNotFound; - logWindow.FileRespawned -= OnLogWindowFileRespawned; - logWindow.FilterListChanged -= OnLogWindowFilterListChanged; - logWindow.CurrentHighlightGroupChanged -= OnLogWindowCurrentHighlightGroupChanged; - logWindow.SyncModeChanged -= OnLogWindowSyncModeChanged; - - var data = logWindow.Tag as LogWindowData; - //data.tabPage.MouseClick -= tabPage_MouseClick; - //data.tabPage.TabDoubleClick -= tabPage_TabDoubleClick; - //data.tabPage.ContextMenuStrip = null; - //data.tabPage = null; - } - - [SupportedOSPlatform("windows")] - private void AddToFileHistory (string fileName) - { - bool FindName (string s) => s.ToUpperInvariant().Equals(fileName.ToUpperInvariant(), StringComparison.Ordinal); - - var index = ConfigManager.Settings.FileHistoryList.FindIndex(FindName); - - if (index != -1) - { - ConfigManager.Settings.FileHistoryList.RemoveAt(index); - } - - ConfigManager.Settings.FileHistoryList.Insert(0, fileName); - - while (ConfigManager.Settings.FileHistoryList.Count > MAX_FILE_HISTORY) - { - ConfigManager.Settings.FileHistoryList.RemoveAt(ConfigManager.Settings.FileHistoryList.Count - 1); - } - - ConfigManager.Save(SettingsFlags.FileHistory); - - FillHistoryMenu(); - } - - [SupportedOSPlatform("windows")] - private LogWindow.LogWindow FindWindowForFile (string fileName) - { - lock (_logWindowList) - { - foreach (var logWindow in _logWindowList) - { - if (logWindow.FileName.ToUpperInvariant().Equals(fileName.ToUpperInvariant(), StringComparison.Ordinal)) - { - return logWindow; - } - } - } - - return null; - } - - /// - /// Checks if the file name is a settings file. If so, the contained logfile name - /// is returned. If not, the given file name is returned unchanged. - /// - /// - /// - private string FindFilenameForSettings (string fileName) - { - if (fileName.EndsWith(".lxp")) - { - var persistenceData = Persister.LoadOptionsOnly(fileName); - if (persistenceData == null) - { - return fileName; - } - - if (!string.IsNullOrEmpty(persistenceData.FileName)) - { - var fs = PluginRegistry.PluginRegistry.Instance.FindFileSystemForUri(persistenceData.FileName); - if (fs != null && !fs.GetType().Equals(typeof(LocalFileSystem))) - { - return persistenceData.FileName; - } - - // On relative paths the URI check (and therefore the file system plugin check) will fail. - // So fs == null and fs == LocalFileSystem are handled here like normal files. - if (Path.IsPathRooted(persistenceData.FileName)) - { - return persistenceData.FileName; - } - - // handle relative paths in .lxp files - var dir = Path.GetDirectoryName(fileName); - return Path.Combine(dir, persistenceData.FileName); - } - } - - return fileName; - } - - [SupportedOSPlatform("windows")] - private void FillHistoryMenu () - { - ToolStripDropDown strip = new ToolStripDropDownMenu(); - - foreach (var file in ConfigManager.Settings.FileHistoryList) - { - ToolStripItem item = new ToolStripMenuItem(file); - strip.Items.Add(item); - } - - strip.ItemClicked += OnHistoryItemClicked; - strip.MouseUp += OnStripMouseUp; - lastUsedToolStripMenuItem.DropDown = strip; - } - - [SupportedOSPlatform("windows")] - private void RemoveLogWindow (LogWindow.LogWindow logWindow) - { - lock (_logWindowList) - { - _logWindowList.Remove(logWindow); - } - - DisconnectEventHandlers(logWindow); - } - - [SupportedOSPlatform("windows")] - private void RemoveAndDisposeLogWindow (LogWindow.LogWindow logWindow, bool dontAsk) - { - if (CurrentLogWindow == logWindow) - { - ChangeCurrentLogWindow(null); - } - - lock (_logWindowList) - { - _logWindowList.Remove(logWindow); - } - - logWindow.Close(dontAsk); - } - - [SupportedOSPlatform("windows")] - private void ShowHighlightSettingsDialog () - { - HighlightDialog dlg = new(ConfigManager) - { - KeywordActionList = PluginRegistry.PluginRegistry.Instance.RegisteredKeywordActions, - Owner = this, - TopMost = TopMost, - HighlightGroupList = HighlightGroupList, - PreSelectedGroupName = groupsComboBoxHighlightGroups.Text - }; - - var res = dlg.ShowDialog(); - - if (res == DialogResult.OK) - { - HighlightGroupList = dlg.HighlightGroupList; - FillHighlightComboBox(); - ConfigManager.Settings.Preferences.HighlightGroupList = HighlightGroupList; - ConfigManager.Save(SettingsFlags.HighlightSettings); - OnHighlightSettingsChanged(); - } - } - - [SupportedOSPlatform("windows")] - private void FillHighlightComboBox () - { - var currentGroupName = groupsComboBoxHighlightGroups.Text; - groupsComboBoxHighlightGroups.Items.Clear(); - foreach (var group in HighlightGroupList) - { - groupsComboBoxHighlightGroups.Items.Add(group.GroupName); - if (group.GroupName.Equals(currentGroupName, StringComparison.Ordinal)) - { - groupsComboBoxHighlightGroups.Text = group.GroupName; - } - } - } - - [SupportedOSPlatform("windows")] - private void OpenFileDialog () - { - OpenFileDialog openFileDialog = new(); - - if (CurrentLogWindow != null) - { - FileInfo info = new(CurrentLogWindow.FileName); - openFileDialog.InitialDirectory = info.DirectoryName; - } - else - { - if (!string.IsNullOrEmpty(ConfigManager.Settings.LastDirectory)) - { - openFileDialog.InitialDirectory = ConfigManager.Settings.LastDirectory; - } - else - { - try - { - openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); - } - catch (SecurityException e) - { - _logger.Warn(e, "Insufficient rights for GetFolderPath(): "); - // no initial directory if insufficient rights - } - } - } - - openFileDialog.Multiselect = true; - - if (DialogResult.OK == openFileDialog.ShowDialog(this)) - { - FileInfo info = new(openFileDialog.FileName); - if (info.Directory.Exists) - { - ConfigManager.Settings.LastDirectory = info.DirectoryName; - ConfigManager.Save(SettingsFlags.FileHistory); - } - - if (info.Exists) - { - LoadFiles(openFileDialog.FileNames, false); - } - } - } - - [SupportedOSPlatform("windows")] - private void LoadFiles (string[] names, bool invertLogic) - { - Array.Sort(names); - - if (names.Length == 1) - { - if (names[0].EndsWith(".lxj")) - { - LoadProject(names[0], true); - return; - } - - AddFileTab(names[0], false, null, false, null); - return; - } - - var option = ConfigManager.Settings.Preferences.MultiFileOption; - if (option == MultiFileOption.Ask) - { - MultiLoadRequestDialog dlg = new(); - var res = dlg.ShowDialog(); - - if (res == DialogResult.Yes) - { - option = MultiFileOption.SingleFiles; - } - else if (res == DialogResult.No) - { - option = MultiFileOption.MultiFile; - } - else - { - return; - } - } - else - { - if (invertLogic) - { - option = option == MultiFileOption.SingleFiles - ? MultiFileOption.MultiFile - : MultiFileOption.SingleFiles; - } - } - - if (option == MultiFileOption.SingleFiles) - { - AddFileTabs(names); - } - else - { - AddMultiFileTab(names); - } - } - - private void SetColumnizerHistoryEntry (string fileName, ILogLineColumnizer columnizer) - { - var entry = FindColumnizerHistoryEntry(fileName); - if (entry != null) - { - _ = ConfigManager.Settings.ColumnizerHistoryList.Remove(entry); - - } - - ConfigManager.Settings.ColumnizerHistoryList.Add(new ColumnizerHistoryEntry(fileName, columnizer.GetName())); - - if (ConfigManager.Settings.ColumnizerHistoryList.Count > MAX_COLUMNIZER_HISTORY) - { - ConfigManager.Settings.ColumnizerHistoryList.RemoveAt(0); - } - } - - private ColumnizerHistoryEntry FindColumnizerHistoryEntry (string fileName) - { - foreach (var entry in ConfigManager.Settings.ColumnizerHistoryList) - { - if (entry.FileName.Equals(fileName, StringComparison.Ordinal)) - { - return entry; - } - } - - return null; - } - - [SupportedOSPlatform("windows")] - private void ToggleMultiFile () - { - if (CurrentLogWindow != null) - { - CurrentLogWindow.SwitchMultiFile(!CurrentLogWindow.IsMultiFile); - multiFileToolStripMenuItem.Checked = CurrentLogWindow.IsMultiFile; - multiFileEnabledStripMenuItem.Checked = CurrentLogWindow.IsMultiFile; - } - } - - [SupportedOSPlatform("windows")] - private void ChangeCurrentLogWindow (LogWindow.LogWindow newLogWindow) - { - if (newLogWindow == _currentLogWindow) - { - return; // do nothing if wishing to set the same window - } - - var oldLogWindow = _currentLogWindow; - _currentLogWindow = newLogWindow; - var titleName = _showInstanceNumbers ? "LogExpert #" + _instanceNumber : "LogExpert"; - - if (oldLogWindow != null) - { - oldLogWindow.StatusLineEvent -= OnStatusLineEvent; - oldLogWindow.ProgressBarUpdate -= OnProgressBarUpdate; - oldLogWindow.GuiStateUpdate -= OnGuiStateUpdate; - oldLogWindow.ColumnizerChanged -= OnColumnizerChanged; - oldLogWindow.BookmarkAdded -= OnBookmarkAdded; - oldLogWindow.BookmarkRemoved -= OnBookmarkRemoved; - oldLogWindow.BookmarkTextChanged -= OnBookmarkTextChanged; - DisconnectToolWindows(oldLogWindow); - } - - if (newLogWindow != null) - { - newLogWindow.StatusLineEvent += OnStatusLineEvent; - newLogWindow.ProgressBarUpdate += OnProgressBarUpdate; - newLogWindow.GuiStateUpdate += OnGuiStateUpdate; - newLogWindow.ColumnizerChanged += OnColumnizerChanged; - newLogWindow.BookmarkAdded += OnBookmarkAdded; - newLogWindow.BookmarkRemoved += OnBookmarkRemoved; - newLogWindow.BookmarkTextChanged += OnBookmarkTextChanged; - - Text = newLogWindow.IsTempFile - ? titleName + @" - " + newLogWindow.TempTitleName - : titleName + @" - " + newLogWindow.FileName; - - multiFileToolStripMenuItem.Checked = CurrentLogWindow.IsMultiFile; - multiFileToolStripMenuItem.Enabled = true; - multiFileEnabledStripMenuItem.Checked = CurrentLogWindow.IsMultiFile; - cellSelectModeToolStripMenuItem.Checked = true; - cellSelectModeToolStripMenuItem.Enabled = true; - closeFileToolStripMenuItem.Enabled = true; - searchToolStripMenuItem.Enabled = true; - filterToolStripMenuItem.Enabled = true; - goToLineToolStripMenuItem.Enabled = true; - //ConnectToolWindows(newLogWindow); - } - else - { - Text = titleName; - multiFileToolStripMenuItem.Checked = false; - multiFileEnabledStripMenuItem.Checked = false; - checkBoxFollowTail.Checked = false; - mainMenuStrip.Enabled = true; - timeshiftToolStripMenuItem.Enabled = false; - timeshiftToolStripMenuItem.Checked = false; - timeshiftMenuTextBox.Text = ""; - timeshiftMenuTextBox.Enabled = false; - multiFileToolStripMenuItem.Enabled = false; - cellSelectModeToolStripMenuItem.Checked = false; - cellSelectModeToolStripMenuItem.Enabled = false; - closeFileToolStripMenuItem.Enabled = false; - searchToolStripMenuItem.Enabled = false; - filterToolStripMenuItem.Enabled = false; - goToLineToolStripMenuItem.Enabled = false; - dragControlDateTime.Visible = false; - } - } - - private void ConnectToolWindows (LogWindow.LogWindow logWindow) - { - ConnectBookmarkWindow(logWindow); - } - - private void ConnectBookmarkWindow (LogWindow.LogWindow logWindow) - { - FileViewContext ctx = new(logWindow, logWindow); - _bookmarkWindow.SetBookmarkData(logWindow.BookmarkData); - _bookmarkWindow.SetCurrentFile(ctx); - } - - private void DisconnectToolWindows (LogWindow.LogWindow logWindow) - { - DisconnectBookmarkWindow(logWindow); - } - - private void DisconnectBookmarkWindow (LogWindow.LogWindow logWindow) - { - _bookmarkWindow.SetBookmarkData(null); - _bookmarkWindow.SetCurrentFile(null); - } - - [SupportedOSPlatform("windows")] - private void GuiStateUpdateWorker (GuiStateArgs e) - { - _skipEvents = true; - checkBoxFollowTail.Checked = e.FollowTail; - mainMenuStrip.Enabled = e.MenuEnabled; - timeshiftToolStripMenuItem.Enabled = e.TimeshiftPossible; - timeshiftToolStripMenuItem.Checked = e.TimeshiftEnabled; - timeshiftMenuTextBox.Text = e.TimeshiftText; - timeshiftMenuTextBox.Enabled = e.TimeshiftEnabled; - multiFileToolStripMenuItem.Enabled = e.MultiFileEnabled; // disabled for temp files - multiFileToolStripMenuItem.Checked = e.IsMultiFileActive; - multiFileEnabledStripMenuItem.Checked = e.IsMultiFileActive; - cellSelectModeToolStripMenuItem.Checked = e.CellSelectMode; - RefreshEncodingMenuBar(e.CurrentEncoding); - - if (e.TimeshiftPossible && ConfigManager.Settings.Preferences.TimestampControl) - { - dragControlDateTime.MinDateTime = e.MinTimestamp; - dragControlDateTime.MaxDateTime = e.MaxTimestamp; - dragControlDateTime.DateTime = e.Timestamp; - dragControlDateTime.Visible = true; - dragControlDateTime.Enabled = true; - dragControlDateTime.Refresh(); - } - else - { - dragControlDateTime.Visible = false; - dragControlDateTime.Enabled = false; - } - - toolStripButtonBubbles.Checked = e.ShowBookmarkBubbles; - groupsComboBoxHighlightGroups.Text = e.HighlightGroupName; - columnFinderToolStripMenuItem.Checked = e.ColumnFinderVisible; - - _skipEvents = false; - } - - [SupportedOSPlatform("windows")] - private void ProgressBarUpdateWorker (ProgressEventArgs e) - { - if (e.Value <= e.MaxValue && e.Value >= e.MinValue) - { - try - { - loadProgessBar.Minimum = e.MinValue; - loadProgessBar.Maximum = e.MaxValue; - loadProgessBar.Value = e.Value; - loadProgessBar.Visible = e.Visible; - } - catch (Exception ex) - { - _logger.Error(ex, "Error during ProgressBarUpdateWorker value {0}, min {1}, max {2}, visible {3}", e.Value, e.MinValue, e.MaxValue, e.Visible); - } - - Invoke(new MethodInvoker(statusStrip.Refresh)); - } - } - - [SupportedOSPlatform("windows")] - //TODO Crossthread Exception when a log file has been filtered to a new tab! - private void StatusLineEventWorker (StatusLineEventArgs e) - { - if (e != null) - { - //_logger.logDebug("StatusLineEvent: text = " + e.StatusText); - labelStatus.Text = e.StatusText; - labelStatus.Size = TextRenderer.MeasureText(labelStatus.Text, labelStatus.Font); - labelLines.Text = $" {e.LineCount} lines"; - labelLines.Size = TextRenderer.MeasureText(labelLines.Text, labelLines.Font); - labelSize.Text = Util.GetFileSizeAsText(e.FileSize); - labelSize.Size = TextRenderer.MeasureText(labelSize.Text, labelSize.Font); - labelCurrentLine.Text = $"Line: {e.CurrentLineNum}"; - labelCurrentLine.Size = TextRenderer.MeasureText(labelCurrentLine.Text, labelCurrentLine.Font); - if (statusStrip.InvokeRequired) - { - statusStrip.BeginInvoke(new MethodInvoker(statusStrip.Refresh)); - } - else - { - statusStrip.Refresh(); - } - } - } - - // tailState: 0,1,2 = on/off/off by Trigger - // syncMode: 0 = normal (no), 1 = time synced - [SupportedOSPlatform("windows")] - private Icon CreateLedIcon (int level, bool dirty, int tailState, int syncMode) - { - var iconRect = _leds[0]; - iconRect.Height = 16; // (DockPanel's damn hardcoded height) // this.leds[this.leds.Length - 1].Bottom; - iconRect.Width = iconRect.Right + 6; - Bitmap bmp = new(iconRect.Width, iconRect.Height); - var gfx = Graphics.FromImage(bmp); - - var offsetFromTop = 4; - - for (var i = 0; i < _leds.Length; ++i) - { - var ledRect = _leds[i]; - ledRect.Offset(0, offsetFromTop); - - if (level >= _leds.Length - i) - { - gfx.FillRectangle(_ledBrushes[i], ledRect); - } - else - { - gfx.FillRectangle(_offLedBrush, ledRect); - } - } - - var ledSize = 3; - var ledGap = 1; - var lastLed = _leds[^1]; - Rectangle dirtyLed = new(lastLed.Right + 2, lastLed.Bottom - ledSize, ledSize, ledSize); - Rectangle tailLed = new(dirtyLed.Location, dirtyLed.Size); - tailLed.Offset(0, -(ledSize + ledGap)); - Rectangle syncLed = new(tailLed.Location, dirtyLed.Size); - syncLed.Offset(0, -(ledSize + ledGap)); - - syncLed.Offset(0, offsetFromTop); - tailLed.Offset(0, offsetFromTop); - dirtyLed.Offset(0, offsetFromTop); - - if (dirty) - { - gfx.FillRectangle(_dirtyLedBrush, dirtyLed); - } - else - { - gfx.FillRectangle(_offLedBrush, dirtyLed); - } - - // tailMode 4 means: don't show - if (tailState < 3) - { - gfx.FillRectangle(_tailLedBrush[tailState], tailLed); - } - - if (syncMode == 1) - { - gfx.FillRectangle(_syncLedBrush, syncLed); - } - //else - //{ - // gfx.FillRectangle(this.offLedBrush, syncLed); - //} - - // see http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=345656 - // GetHicon() creates an unmanaged handle which must be destroyed. The Clone() workaround creates - // a managed copy of icon. then the unmanaged win32 handle is destroyed - var iconHandle = bmp.GetHicon(); - var icon = Icon.FromHandle(iconHandle).Clone() as Icon; - NativeMethods.DestroyIcon(iconHandle); - - gfx.Dispose(); - bmp.Dispose(); - return icon; - } - - [SupportedOSPlatform("windows")] - private void CreateIcons () - { - for (var syncMode = 0; syncMode <= 1; syncMode++) // LED indicating time synced tabs - { - for (var tailMode = 0; tailMode < 4; tailMode++) - { - for (var i = 0; i < 6; ++i) - { - _ledIcons[i, 0, tailMode, syncMode] = CreateLedIcon(i, false, tailMode, syncMode); - } - - for (var i = 0; i < 6; ++i) - { - _ledIcons[i, 1, tailMode, syncMode] = CreateLedIcon(i, true, tailMode, syncMode); - } - } - } - } - - [SupportedOSPlatform("windows")] - private void FileNotFound (LogWindow.LogWindow logWin) - { - var data = logWin.Tag as LogWindowData; - BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, _deadIcon); - dragControlDateTime.Visible = false; - } - - [SupportedOSPlatform("windows")] - private void FileRespawned (LogWindow.LogWindow logWin) - { - var data = logWin.Tag as LogWindowData; - var icon = GetIcon(0, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, icon); - } - - [SupportedOSPlatform("windows")] - private void ShowLedPeak (LogWindow.LogWindow logWin) - { - var data = logWin.Tag as LogWindowData; - lock (data) - { - data.DiffSum = DIFF_MAX; - } - - var icon = GetIcon(data.DiffSum, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWin, icon); - } - - private int GetLevelFromDiff (int diff) - { - if (diff > 60) - { - diff = 60; - } - - var level = diff / 10; - if (diff > 0 && level == 0) - { - level = 2; - } - else if (level == 0) - { - level = 1; - } - - return level - 1; - } - - [SupportedOSPlatform("windows")] - private void LedThreadProc () - { - Thread.CurrentThread.Name = "LED Thread"; - while (!_shouldStop) - { - try - { - Thread.Sleep(200); - } - catch - { - return; - } - - lock (_logWindowList) - { - foreach (var logWindow in _logWindowList) - { - var data = logWindow.Tag as LogWindowData; - if (data.DiffSum > 0) - { - data.DiffSum -= 10; - if (data.DiffSum < 0) - { - data.DiffSum = 0; - } - - var icon = GetIcon(data.DiffSum, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); - } - } - } - } - } - - [SupportedOSPlatform("windows")] - private void SetTabIcon (LogWindow.LogWindow logWindow, Icon icon) - { - if (logWindow != null) - { - logWindow.Icon = icon; - logWindow.DockHandler.Pane?.TabStripControl.Invalidate(false); - } - } - - private Icon GetIcon (int diff, LogWindowData data) - { - var icon = - _ledIcons[ - GetLevelFromDiff(diff), data.Dirty ? 1 : 0, Preferences.ShowTailState ? data.TailState : 3, - data.SyncMode - ]; - return icon; - } - - [SupportedOSPlatform("windows")] - private void RefreshEncodingMenuBar (Encoding encoding) - { - toolStripEncodingASCIIItem.Checked = false; - toolStripEncodingANSIItem.Checked = false; - toolStripEncodingUTF8Item.Checked = false; - toolStripEncodingUTF16Item.Checked = false; - toolStripEncodingISO88591Item.Checked = false; - - if (encoding == null) - { - return; - } - - if (encoding is ASCIIEncoding) - { - toolStripEncodingASCIIItem.Checked = true; - } - else if (encoding.Equals(Encoding.Default)) - { - toolStripEncodingANSIItem.Checked = true; - } - else if (encoding is UTF8Encoding) - { - toolStripEncodingUTF8Item.Checked = true; - } - else if (encoding is UnicodeEncoding) - { - toolStripEncodingUTF16Item.Checked = true; - } - else if (encoding.Equals(Encoding.GetEncoding("iso-8859-1"))) - { - toolStripEncodingISO88591Item.Checked = true; - } - - toolStripEncodingANSIItem.Text = Encoding.Default.HeaderName; - } - - [SupportedOSPlatform("windows")] - private void OpenSettings (int tabToOpen) - { - SettingsDialog dlg = new(ConfigManager.Settings.Preferences, this, tabToOpen, ConfigManager) - { - TopMost = TopMost - }; - - if (DialogResult.OK == dlg.ShowDialog()) - { - ConfigManager.Settings.Preferences = dlg.Preferences; - ConfigManager.Save(SettingsFlags.Settings); - NotifyWindowsForChangedPrefs(SettingsFlags.Settings); - } - } - - [SupportedOSPlatform("windows")] - private void NotifyWindowsForChangedPrefs (SettingsFlags flags) - { - _logger.Info(CultureInfo.InvariantCulture, "The preferences have changed"); - ApplySettings(ConfigManager.Settings, flags); - - var setLastColumnWidth = ConfigManager.Settings.Preferences.SetLastColumnWidth; - var lastColumnWidth = ConfigManager.Settings.Preferences.LastColumnWidth; - var fontName = ConfigManager.Settings.Preferences.FontName; - var fontSize = ConfigManager.Settings.Preferences.FontSize; - - lock (_logWindowList) - { - foreach (var logWindow in _logWindowList) - { - logWindow.PreferencesChanged(fontName, fontSize, setLastColumnWidth, lastColumnWidth, false, flags); - } - } - - _bookmarkWindow.PreferencesChanged(fontName, fontSize, setLastColumnWidth, lastColumnWidth, flags); - - HighlightGroupList = ConfigManager.Settings.Preferences.HighlightGroupList; - if ((flags & SettingsFlags.HighlightSettings) == SettingsFlags.HighlightSettings) - { - OnHighlightSettingsChanged(); - } - } - - [SupportedOSPlatform("windows")] - private void ApplySettings (Settings settings, SettingsFlags flags) - { - if ((flags & SettingsFlags.WindowPosition) == SettingsFlags.WindowPosition) - { - TopMost = alwaysOnTopToolStripMenuItem.Checked = settings.AlwaysOnTop; - dragControlDateTime.DragOrientation = settings.Preferences.TimestampControlDragOrientation; - hideLineColumnToolStripMenuItem.Checked = settings.HideLineColumn; - } - - if ((flags & SettingsFlags.FileHistory) == SettingsFlags.FileHistory) - { - FillHistoryMenu(); - } - - if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors) - { - SetTabIcons(settings.Preferences); - } - - if ((flags & SettingsFlags.ToolSettings) == SettingsFlags.ToolSettings) - { - FillToolLauncherBar(); - } - - if ((flags & SettingsFlags.HighlightSettings) == SettingsFlags.HighlightSettings) - { - FillHighlightComboBox(); - } - } - - [SupportedOSPlatform("windows")] - private void SetTabIcons (Preferences preferences) - { - _tailLedBrush[0] = new SolidBrush(preferences.ShowTailColor); - CreateIcons(); - lock (_logWindowList) - { - foreach (var logWindow in _logWindowList) - { - var data = logWindow.Tag as LogWindowData; - var icon = GetIcon(data.DiffSum, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); - } - } - } - - [SupportedOSPlatform("windows")] - private void SetToolIcon (ToolEntry entry, ToolStripItem item) - { - var icon = NativeMethods.LoadIconFromExe(entry.IconFile, entry.IconIndex); - - if (icon != null) - { - item.Image = icon.ToBitmap(); - - item.DisplayStyle = item is ToolStripMenuItem - ? ToolStripItemDisplayStyle.ImageAndText - : ToolStripItemDisplayStyle.Image; - - NativeMethods.DestroyIcon(icon.Handle); - icon.Dispose(); - } - - if (!string.IsNullOrEmpty(entry.Cmd)) - { - item.ToolTipText = entry.Name; - } - } - - [SupportedOSPlatform("windows")] - private void ToolButtonClick (ToolEntry toolEntry) - { - if (string.IsNullOrEmpty(toolEntry.Cmd)) - { - //TODO TabIndex => To Enum - OpenSettings(2); - return; - } - - if (CurrentLogWindow != null) - { - var line = CurrentLogWindow.GetCurrentLine(); - var info = CurrentLogWindow.GetCurrentFileInfo(); - if (line != null && info != null) - { - ArgParser parser = new(toolEntry.Args); - var argLine = parser.BuildArgs(line, CurrentLogWindow.GetRealLineNum() + 1, info, this); - if (argLine != null) - { - StartTool(toolEntry.Cmd, argLine, toolEntry.Sysout, toolEntry.ColumnizerName, toolEntry.WorkingDir); - } - } - } - } - - [SupportedOSPlatform("windows")] - private void StartTool (string cmd, string args, bool sysoutPipe, string columnizerName, string workingDir) - { - if (string.IsNullOrEmpty(cmd)) - { - return; - } - - Process process = new(); - ProcessStartInfo startInfo = new(cmd, args); - if (!Util.IsNull(workingDir)) - { - startInfo.WorkingDirectory = workingDir; - } - - process.StartInfo = startInfo; - process.EnableRaisingEvents = true; - - if (sysoutPipe) - { - var columnizer = ColumnizerPicker.DecideColumnizerByName(columnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - - _logger.Info(CultureInfo.InvariantCulture, "Starting external tool with sysout redirection: {0} {1}", cmd, args); - startInfo.UseShellExecute = false; - startInfo.RedirectStandardOutput = true; - //process.OutputDataReceived += pipe.DataReceivedEventHandler; - try - { - _ = process.Start(); - } - catch (Win32Exception e) - { - _logger.Error(e); - MessageBox.Show(e.Message); - return; - } - - SysoutPipe pipe = new(process.StandardOutput); - - var logWin = AddTempFileTab(pipe.FileName, - CurrentLogWindow.IsTempFile - ? CurrentLogWindow.TempTitleName - : Util.GetNameFromPath(CurrentLogWindow.FileName) + "->E"); - logWin.ForceColumnizer(columnizer); - - process.Exited += pipe.ProcessExitedEventHandler; - //process.BeginOutputReadLine(); - } - else - { - _logger.Info(CultureInfo.InvariantCulture, "Starting external tool: {0} {1}", cmd, args); - - try - { - startInfo.UseShellExecute = false; - _ = process.Start(); - } - catch (Exception e) - { - _logger.Error(e); - MessageBox.Show(e.Message); - } - } - } - - [SupportedOSPlatform("windows")] - private void CloseAllTabs () - { - IList closeList = []; - lock (_logWindowList) - { - foreach (DockContent content in dockPanel.Contents) - { - if (content is LogWindow.LogWindow window) - { - closeList.Add(window); - } - } - } - - foreach (var form in closeList) - { - form.Close(); - } - } - - //TODO Reimplement - private void SetTabColor (LogWindow.LogWindow logWindow, Color color) - { - //tabPage.BackLowColor = color; - //tabPage.BackLowColorDisabled = Color.FromArgb(255, - // Math.Max(0, color.R - 50), - // Math.Max(0, color.G - 50), - // Math.Max(0, color.B - 50) - // ); - } - - [SupportedOSPlatform("windows")] - private void LoadProject (string projectFileName, bool restoreLayout) - { - var projectData = ProjectPersister.LoadProjectData(projectFileName); - var hasLayoutData = projectData.TabLayoutXml != null; - - if (hasLayoutData && restoreLayout && _logWindowList.Count > 0) - { - ProjectLoadDlg dlg = new(); - if (DialogResult.Cancel != dlg.ShowDialog()) - { - switch (dlg.ProjectLoadResult) - { - case ProjectLoadDlgResult.IgnoreLayout: - hasLayoutData = false; - break; - case ProjectLoadDlgResult.CloseTabs: - CloseAllTabs(); - break; - case ProjectLoadDlgResult.NewWindow: - LogExpertProxy.NewWindow([projectFileName]); - return; - } - } - } - - if (projectData != null) - { - foreach (var fileName in projectData.MemberList) - { - if (hasLayoutData) - { - AddFileTabDeferred(fileName, false, null, true, null); - } - else - { - AddFileTab(fileName, false, null, true, null); - } - } - - if (hasLayoutData && restoreLayout) - { - // Re-creating tool (non-document) windows is needed because the DockPanel control would throw strange errors - DestroyToolWindows(); - InitToolWindows(); - RestoreLayout(projectData.TabLayoutXml); - } - } - } - - [SupportedOSPlatform("windows")] - private void ApplySelectedHighlightGroup () - { - var groupName = groupsComboBoxHighlightGroups.Text; - CurrentLogWindow?.SetCurrentHighlightGroup(groupName); - } - - [SupportedOSPlatform("windows")] - private void FillToolLauncherBar () - { - char[] labels = - [ - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', - 'U', 'V', 'W', 'X', 'Y', 'Z' - ]; - toolsToolStripMenuItem.DropDownItems.Clear(); - toolsToolStripMenuItem.DropDownItems.Add(configureToolStripMenuItem); - toolsToolStripMenuItem.DropDownItems.Add(configureToolStripSeparator); - externalToolsToolStrip.Items.Clear(); - var num = 0; - externalToolsToolStrip.SuspendLayout(); - foreach (var tool in Preferences.ToolEntries) - { - if (tool.IsFavourite) - { - ToolStripButton button = new("" + labels[num % 26]) - { - Alignment = ToolStripItemAlignment.Left, - Tag = tool - }; - - SetToolIcon(tool, button); - externalToolsToolStrip.Items.Add(button); - } - - num++; - ToolStripMenuItem menuItem = new(tool.Name) - { - Tag = tool - }; - - SetToolIcon(tool, menuItem); - toolsToolStripMenuItem.DropDownItems.Add(menuItem); - } - - externalToolsToolStrip.ResumeLayout(); - - externalToolsToolStrip.Visible = num > 0; // do not show bar if no tool uses it - } - - private void RunGC () - { - _logger.Info($"Running GC. Used mem before: {GC.GetTotalMemory(false):N0}"); - GC.Collect(); - _logger.Info($"GC done. Used mem after: {GC.GetTotalMemory(true):N0}"); - } - - private void DumpGCInfo () - { - _logger.Info($"-------- GC info -----------\r\nUsed mem: {GC.GetTotalMemory(false):N0}"); - for (var i = 0; i < GC.MaxGeneration; ++i) - { - _logger.Info($"Generation {i} collect count: {GC.CollectionCount(i)}"); - } - - _logger.Info(CultureInfo.InvariantCulture, "----------------------------"); - } - - private void ThrowExceptionFx () - { - throw new Exception("This is a test exception thrown by an async delegate"); - } - - private void ThrowExceptionThreadFx () - { - throw new Exception("This is a test exception thrown by a background thread"); - } - - private string SaveLayout () - { - using MemoryStream memStream = new(2000); - using StreamReader r = new(memStream); - dockPanel.SaveAsXml(memStream, Encoding.UTF8, true); - - memStream.Seek(0, SeekOrigin.Begin); - var resultXml = r.ReadToEnd(); - - r.Close(); - - return resultXml; - } - - [SupportedOSPlatform("windows")] - private void RestoreLayout (string layoutXml) - { - using MemoryStream memStream = new(2000); - using StreamWriter w = new(memStream); - w.Write(layoutXml); - w.Flush(); - - memStream.Seek(0, SeekOrigin.Begin); - - dockPanel.LoadFromXml(memStream, DeserializeDockContent, true); - } - - [SupportedOSPlatform("windows")] - private IDockContent DeserializeDockContent (string persistString) - { - if (persistString.Equals(WindowTypes.BookmarkWindow.ToString(), StringComparison.Ordinal)) - { - return _bookmarkWindow; - } - - if (persistString.StartsWith(WindowTypes.LogWindow.ToString())) - { - var fileName = persistString[(WindowTypes.LogWindow.ToString().Length + 1)..]; - var win = FindWindowForFile(fileName); - if (win != null) - { - return win; - } - - _logger.Warn($"Layout data contains non-existing LogWindow for {fileName}"); - } - - return null; - } - - private void OnHighlightSettingsChanged () - { - HighlightSettingsChanged?.Invoke(this, EventArgs.Empty); - } - - #endregion -} \ No newline at end of file diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs deleted file mode 100644 index 3751f2eb..00000000 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPublic.cs +++ /dev/null @@ -1,364 +0,0 @@ -using System.Runtime.Versioning; -using System.Text; -using System.Text.RegularExpressions; - -using LogExpert.Core.Classes.Columnizer; -using LogExpert.Core.Classes.Filter; -using LogExpert.Core.Config; -using LogExpert.Core.Entities; -using LogExpert.Core.Interface; -using LogExpert.Dialogs; -using LogExpert.UI.Entities; -using LogExpert.UI.Extensions; - -using WeifenLuo.WinFormsUI.Docking; - -namespace LogExpert.UI.Controls.LogTabWindow; - -internal partial class LogTabWindow -{ - #region Public methods - - [SupportedOSPlatform("windows")] - public LogWindow.LogWindow AddTempFileTab (string fileName, string title) - { - return AddFileTab(fileName, true, title, false, null); - } - - [SupportedOSPlatform("windows")] - public LogWindow.LogWindow AddFilterTab (FilterPipe pipe, string title, ILogLineColumnizer preProcessColumnizer) - { - var logWin = AddFileTab(pipe.FileName, true, title, false, preProcessColumnizer); - if (pipe.FilterParams.SearchText.Length > 0) - { - ToolTip tip = new(components); - - tip.SetToolTip(logWin, - "Filter: \"" + pipe.FilterParams.SearchText + "\"" + - (pipe.FilterParams.IsInvert ? " (Invert match)" : "") + - (pipe.FilterParams.ColumnRestrict ? "\nColumn restrict" : "") - ); - - tip.AutomaticDelay = 10; - tip.AutoPopDelay = 5000; - var data = logWin.Tag as LogWindowData; - data.ToolTip = tip; - } - - return logWin; - } - - [SupportedOSPlatform("windows")] - public LogWindow.LogWindow AddFileTabDeferred (string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer) - { - return AddFileTab(givenFileName, isTempFile, title, forcePersistenceLoading, preProcessColumnizer, true); - } - - [SupportedOSPlatform("windows")] - public LogWindow.LogWindow AddFileTab (string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer, bool doNotAddToDockPanel = false) - { - var logFileName = FindFilenameForSettings(givenFileName); - var win = FindWindowForFile(logFileName); - if (win != null) - { - if (!isTempFile) - { - AddToFileHistory(givenFileName); - } - - SelectTab(win); - return win; - } - - EncodingOptions encodingOptions = new(); - FillDefaultEncodingFromSettings(encodingOptions); - LogWindow.LogWindow logWindow = new(this, logFileName, isTempFile, forcePersistenceLoading, ConfigManager) - { - GivenFileName = givenFileName - }; - - if (preProcessColumnizer != null) - { - logWindow.ForceColumnizerForLoading(preProcessColumnizer); - } - - if (isTempFile) - { - logWindow.TempTitleName = title; - encodingOptions.Encoding = new UnicodeEncoding(false, false); - } - - AddLogWindow(logWindow, title, doNotAddToDockPanel); - if (!isTempFile) - { - AddToFileHistory(givenFileName); - } - - var data = logWindow.Tag as LogWindowData; - data.Color = _defaultTabColor; - SetTabColor(logWindow, _defaultTabColor); - //data.tabPage.BorderColor = this.defaultTabBorderColor; - if (!isTempFile) - { - foreach (var colorEntry in ConfigManager.Settings.FileColors) - { - if (colorEntry.FileName.ToUpperInvariant().Equals(logFileName.ToUpperInvariant(), StringComparison.Ordinal)) - { - data.Color = colorEntry.Color; - SetTabColor(logWindow, colorEntry.Color); - break; - } - } - } - - if (!isTempFile) - { - SetTooltipText(logWindow, logFileName); - } - - if (givenFileName.EndsWith(".lxp", StringComparison.Ordinal)) - { - logWindow.ForcedPersistenceFileName = givenFileName; - } - - // this.BeginInvoke(new LoadFileDelegate(logWindow.LoadFile), new object[] { logFileName, encoding }); - Task.Run(() => logWindow.LoadFile(logFileName, encodingOptions)); - return logWindow; - } - - [SupportedOSPlatform("windows")] - public LogWindow.LogWindow AddMultiFileTab (string[] fileNames) - { - if (fileNames.Length < 1) - { - return null; - } - - LogWindow.LogWindow logWindow = new(this, fileNames[^1], false, false, ConfigManager); - AddLogWindow(logWindow, fileNames[^1], false); - multiFileToolStripMenuItem.Checked = true; - multiFileEnabledStripMenuItem.Checked = true; - EncodingOptions encodingOptions = new(); - FillDefaultEncodingFromSettings(encodingOptions); - BeginInvoke(new LoadMultiFilesDelegate(logWindow.LoadFilesAsMulti), fileNames, encodingOptions); - AddToFileHistory(fileNames[0]); - return logWindow; - } - - [SupportedOSPlatform("windows")] - public void LoadFiles (string[] fileNames) - { - Invoke(new AddFileTabsDelegate(AddFileTabs), [fileNames]); - } - - [SupportedOSPlatform("windows")] - public void OpenSearchDialog () - { - if (CurrentLogWindow == null) - { - return; - } - - SearchDialog dlg = new(); - AddOwnedForm(dlg); - dlg.TopMost = TopMost; - SearchParams.HistoryList = ConfigManager.Settings.SearchHistoryList; - dlg.SearchParams = SearchParams; - var res = dlg.ShowDialog(); - if (res == DialogResult.OK && dlg.SearchParams != null && !string.IsNullOrWhiteSpace(dlg.SearchParams.SearchText)) - { - SearchParams = dlg.SearchParams; - SearchParams.IsFindNext = false; - CurrentLogWindow.StartSearch(); - } - } - - public ILogLineColumnizer GetColumnizerHistoryEntry (string fileName) - { - var entry = FindColumnizerHistoryEntry(fileName); - if (entry != null) - { - foreach (var columnizer in PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers) - { - if (columnizer.GetName().Equals(entry.ColumnizerName, StringComparison.Ordinal)) - { - return columnizer; - } - } - - ConfigManager.Settings.ColumnizerHistoryList.Remove(entry); // no valid name -> remove entry - } - - return null; - } - - public void SwitchTab (bool shiftPressed) - { - var index = dockPanel.Contents.IndexOf(dockPanel.ActiveContent); - if (shiftPressed) - { - index--; - if (index < 0) - { - index = dockPanel.Contents.Count - 1; - } - - if (index < 0) - { - return; - } - } - else - { - index++; - if (index >= dockPanel.Contents.Count) - { - index = 0; - } - } - - if (index < dockPanel.Contents.Count) - { - (dockPanel.Contents[index] as DockContent).Activate(); - } - } - - public void ScrollAllTabsToTimestamp (DateTime timestamp, LogWindow.LogWindow senderWindow) - { - lock (_logWindowList) - { - foreach (var logWindow in _logWindowList) - { - if (logWindow != senderWindow) - { - if (logWindow.ScrollToTimestamp(timestamp, false, false)) - { - ShowLedPeak(logWindow); - } - } - } - } - } - - public ILogLineColumnizer FindColumnizerByFileMask (string fileName) - { - foreach (var entry in ConfigManager.Settings.Preferences.ColumnizerMaskList) - { - if (entry.Mask != null) - { - try - { - if (Regex.IsMatch(fileName, entry.Mask)) - { - var columnizer = ColumnizerPicker.FindColumnizerByName(entry.ColumnizerName, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers); - return columnizer; - } - } - catch (ArgumentException e) - { - _logger.Error(e, "RegEx-error while finding columnizer: "); - // occurs on invalid regex patterns - } - } - } - - return null; - } - - public HighlightGroup FindHighlightGroupByFileMask (string fileName) - { - foreach (var entry in ConfigManager.Settings.Preferences.HighlightMaskList) - { - if (entry.Mask != null) - { - try - { - if (Regex.IsMatch(fileName, entry.Mask)) - { - var group = FindHighlightGroup(entry.HighlightGroupName); - return group; - } - } - catch (ArgumentException e) - { - _logger.Error(e, "RegEx-error while finding columnizer: "); - // occurs on invalid regex patterns - } - } - } - - return null; - } - - public void SelectTab (ILogWindow logWindow) - { - logWindow.Activate(); - } - - [SupportedOSPlatform("windows")] - public void SetForeground () - { - NativeMethods.SetForegroundWindow(Handle); - if (WindowState == FormWindowState.Minimized) - { - if (_wasMaximized) - { - WindowState = FormWindowState.Maximized; - } - else - { - WindowState = FormWindowState.Normal; - } - } - } - - // called from LogWindow when follow tail was changed - [SupportedOSPlatform("windows")] - public void FollowTailChanged (LogWindow.LogWindow logWindow, bool isEnabled, bool offByTrigger) - { - if (logWindow.Tag is not LogWindowData data) - { - return; - } - - if (isEnabled) - { - data.TailState = 0; - } - else - { - data.TailState = offByTrigger ? 2 : 1; - } - - if (Preferences.ShowTailState) - { - var icon = GetIcon(data.DiffSum, data); - BeginInvoke(new SetTabIconDelegate(SetTabIcon), logWindow, icon); - } - } - - [SupportedOSPlatform("windows")] - public void NotifySettingsChanged (object sender, SettingsFlags flags) - { - if (sender != this) - { - NotifyWindowsForChangedPrefs(flags); - } - } - - public IList GetListOfOpenFiles () - { - IList list = []; - lock (_logWindowList) - { - foreach (var logWindow in _logWindowList) - { - list.Add(new WindowFileEntry(logWindow)); - } - } - - return list; - } - - #endregion -} \ No newline at end of file diff --git a/src/LogExpert.UI/LogExpert.UI.csproj b/src/LogExpert.UI/LogExpert.UI.csproj index 7e634730..eb79da96 100644 --- a/src/LogExpert.UI/LogExpert.UI.csproj +++ b/src/LogExpert.UI/LogExpert.UI.csproj @@ -24,11 +24,6 @@ - - - - - Always @@ -40,18 +35,6 @@ Form - - True - True - Resources.resx - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - From 6aacad73c4f92f8b1b31e3f206217d02f7225b09 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sat, 21 Jun 2025 18:17:14 +0200 Subject: [PATCH 109/142] replace resources --- .../Controls/LogWindow/LogWindow.cs | 4 +-- src/LogExpert.UI/Dialogs/AboutBox.cs | 18 +++++------ .../Dialogs/LogTabWindow/LogTabWindow.cs | 2 +- .../LogTabWindow/LogTabWindow.designer.cs | 32 +++++++++---------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index ec8f669d..eb565541 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -231,8 +231,8 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp dataGridView.EditModeMenuStrip = editModeContextMenuStrip; markEditModeToolStripMenuItem.Enabled = true; - _panelOpenButtonImage = Resources.Resources.Arrow_menu_open; - _panelCloseButtonImage = Resources.Resources.Arrow_menu_close; + _panelOpenButtonImage = Resources.Arrow_menu_open; + _panelCloseButtonImage = Resources.Arrow_menu_close; var settings = configManager.Settings; diff --git a/src/LogExpert.UI/Dialogs/AboutBox.cs b/src/LogExpert.UI/Dialogs/AboutBox.cs index 471d836f..e0f0d016 100644 --- a/src/LogExpert.UI/Dialogs/AboutBox.cs +++ b/src/LogExpert.UI/Dialogs/AboutBox.cs @@ -1,11 +1,11 @@ -using LogExpert.Core.Classes; - -using Newtonsoft.Json; - using System.Diagnostics; using System.Reflection; using System.Runtime.Versioning; +using LogExpert.Core.Classes; + +using Newtonsoft.Json; + namespace LogExpert.UI.Dialogs; [SupportedOSPlatform("windows")] @@ -19,7 +19,7 @@ internal partial class AboutBox : Form #region cTor - public AboutBox() + public AboutBox () { InitializeComponent(); @@ -38,7 +38,7 @@ public AboutBox() //Name, Version, License, Download, Source - private void LoadUsedComponents() + private void LoadUsedComponents () { var json = File.ReadAllText($"{Application.StartupPath}files\\json\\usedComponents.json"); var usedComponents = JsonConvert.DeserializeObject(json); @@ -47,9 +47,9 @@ private void LoadUsedComponents() } - private void LoadResources() + private void LoadResources () { - logoPictureBox.Image = Resources.Resources.LogLover; + logoPictureBox.Image = Resources.LogLover; } #endregion @@ -139,7 +139,7 @@ public string AssemblyCopyright #region Events handler - private void OnLinkLabelURLClicked(object sender, LinkLabelLinkClickedEventArgs e) + private void OnLinkLabelURLClicked (object sender, LinkLabelLinkClickedEventArgs e) { var target = string.Empty; diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs index 2eb2d0f7..d6000dcc 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs @@ -168,7 +168,7 @@ public LogTabWindow (string[] fileNames, int instanceNumber, bool showInstanceNu // get a list of resource names from the manifest var resNames = a.GetManifestResourceNames(); - Bitmap bmp = Resources.Resources.Deceased; + Bitmap bmp = Resources.Deceased; _deadIcon = Icon.FromHandle(bmp.GetHicon()); bmp.Dispose(); Closing += OnLogTabWindowClosing; diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs index 6dc8e85e..2b322b27 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs @@ -240,7 +240,7 @@ private void InitializeComponent() // openToolStripMenuItem // openToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; - openToolStripMenuItem.Image = LogExpert.Resources.Resources.File_open; + openToolStripMenuItem.Image = LogExpert.Resources.File_open; openToolStripMenuItem.Name = "openToolStripMenuItem"; openToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.O; openToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -258,7 +258,7 @@ private void InitializeComponent() // // closeFileToolStripMenuItem // - closeFileToolStripMenuItem.Image = LogExpert.Resources.Resources.Close; + closeFileToolStripMenuItem.Image = LogExpert.Resources.Close; closeFileToolStripMenuItem.Name = "closeFileToolStripMenuItem"; closeFileToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.F4; closeFileToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -267,7 +267,7 @@ private void InitializeComponent() // // reloadToolStripMenuItem // - reloadToolStripMenuItem.Image = LogExpert.Resources.Resources.Restart_alt; + reloadToolStripMenuItem.Image = LogExpert.Resources.Restart_alt; reloadToolStripMenuItem.Name = "reloadToolStripMenuItem"; reloadToolStripMenuItem.ShortcutKeys = Keys.F5; reloadToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -359,7 +359,7 @@ private void InitializeComponent() // // exitToolStripMenuItem // - exitToolStripMenuItem.Image = LogExpert.Resources.Resources.Exit; + exitToolStripMenuItem.Image = LogExpert.Resources.Exit; exitToolStripMenuItem.Name = "exitToolStripMenuItem"; exitToolStripMenuItem.ShortcutKeys = Keys.Alt | Keys.F4; exitToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -391,7 +391,7 @@ private void InitializeComponent() // // filterToolStripMenuItem // - filterToolStripMenuItem.Image = LogExpert.Resources.Resources.Filter; + filterToolStripMenuItem.Image = LogExpert.Resources.Filter; filterToolStripMenuItem.Name = "filterToolStripMenuItem"; filterToolStripMenuItem.ShortcutKeys = Keys.F4; filterToolStripMenuItem.Size = new System.Drawing.Size(189, 30); @@ -409,7 +409,7 @@ private void InitializeComponent() // toggleBookmarkToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; toggleBookmarkToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - toggleBookmarkToolStripMenuItem.Image = LogExpert.Resources.Resources.Bookmark_add; + toggleBookmarkToolStripMenuItem.Image = LogExpert.Resources.Bookmark_add; toggleBookmarkToolStripMenuItem.Name = "toggleBookmarkToolStripMenuItem"; toggleBookmarkToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.F2; toggleBookmarkToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -420,7 +420,7 @@ private void InitializeComponent() // jumpToNextToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; jumpToNextToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - jumpToNextToolStripMenuItem.Image = LogExpert.Resources.Resources.ArrowDown; + jumpToNextToolStripMenuItem.Image = LogExpert.Resources.ArrowDown; jumpToNextToolStripMenuItem.Name = "jumpToNextToolStripMenuItem"; jumpToNextToolStripMenuItem.ShortcutKeys = Keys.F2; jumpToNextToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -431,7 +431,7 @@ private void InitializeComponent() // jumpToPrevToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; jumpToPrevToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - jumpToPrevToolStripMenuItem.Image = LogExpert.Resources.Resources.ArrowUp; + jumpToPrevToolStripMenuItem.Image = LogExpert.Resources.ArrowUp; jumpToPrevToolStripMenuItem.Name = "jumpToPrevToolStripMenuItem"; jumpToPrevToolStripMenuItem.ShortcutKeys = Keys.Shift | Keys.F2; jumpToPrevToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -585,7 +585,7 @@ private void InitializeComponent() // // settingsToolStripMenuItem // - settingsToolStripMenuItem.Image = LogExpert.Resources.Resources.Settings; + settingsToolStripMenuItem.Image = LogExpert.Resources.Settings; settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; settingsToolStripMenuItem.Size = new System.Drawing.Size(224, 30); settingsToolStripMenuItem.Text = "Settings..."; @@ -914,7 +914,7 @@ private void InitializeComponent() // toolStripButtonOpen // toolStripButtonOpen.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonOpen.Image = LogExpert.Resources.Resources.File_open; + toolStripButtonOpen.Image = LogExpert.Resources.File_open; toolStripButtonOpen.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonOpen.Name = "toolStripButtonOpen"; toolStripButtonOpen.Size = new System.Drawing.Size(28, 28); @@ -930,7 +930,7 @@ private void InitializeComponent() // toolStripButtonSearch // toolStripButtonSearch.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonSearch.Image = LogExpert.Resources.Resources.Search; + toolStripButtonSearch.Image = LogExpert.Resources.Search; toolStripButtonSearch.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonSearch.Name = "toolStripButtonSearch"; toolStripButtonSearch.Size = new System.Drawing.Size(28, 28); @@ -941,7 +941,7 @@ private void InitializeComponent() // toolStripButtonFilter // toolStripButtonFilter.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonFilter.Image = LogExpert.Resources.Resources.Filter; + toolStripButtonFilter.Image = LogExpert.Resources.Filter; toolStripButtonFilter.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonFilter.Name = "toolStripButtonFilter"; toolStripButtonFilter.Size = new System.Drawing.Size(28, 28); @@ -958,7 +958,7 @@ private void InitializeComponent() // toolStripButtonBookmark // toolStripButtonBookmark.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonBookmark.Image = LogExpert.Resources.Resources.Bookmark_add; + toolStripButtonBookmark.Image = LogExpert.Resources.Bookmark_add; toolStripButtonBookmark.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonBookmark.Name = "toolStripButtonBookmark"; toolStripButtonBookmark.Size = new System.Drawing.Size(28, 28); @@ -969,7 +969,7 @@ private void InitializeComponent() // toolStripButtonUp // toolStripButtonUp.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonUp.Image = LogExpert.Resources.Resources.ArrowUp; + toolStripButtonUp.Image = LogExpert.Resources.ArrowUp; toolStripButtonUp.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonUp.Name = "toolStripButtonUp"; toolStripButtonUp.Size = new System.Drawing.Size(28, 28); @@ -980,7 +980,7 @@ private void InitializeComponent() // toolStripButtonDown // toolStripButtonDown.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonDown.Image = LogExpert.Resources.Resources.ArrowDown; + toolStripButtonDown.Image = LogExpert.Resources.ArrowDown; toolStripButtonDown.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonDown.Name = "toolStripButtonDown"; toolStripButtonDown.Size = new System.Drawing.Size(28, 28); @@ -997,7 +997,7 @@ private void InitializeComponent() // toolStripButtonBubbles.CheckOnClick = true; toolStripButtonBubbles.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonBubbles.Image = LogExpert.Resources.Resources.bookmark_bubbles; + toolStripButtonBubbles.Image = LogExpert.Resources.bookmark_bubbles; toolStripButtonBubbles.ImageAlign = System.Drawing.ContentAlignment.BottomCenter; toolStripButtonBubbles.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonBubbles.Name = "toolStripButtonBubbles"; From 8ec80fb41f7852efd5e7db5daa6d6f3f4bfae6af Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sat, 21 Jun 2025 18:26:00 +0200 Subject: [PATCH 110/142] review comments --- .../Controls/LogWindow/LogWindow.cs | 19 ++++++++++--------- src/LogExpert.UI/Dialogs/BookmarkWindow.cs | 5 ++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index eb565541..f757d24f 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -985,11 +985,12 @@ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPainti { if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) { - Rectangle r;// = new(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); - r = e.CellBounds; - r.Inflate(-2, -2); + //This was the OLD rect, left for future Information + //(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); + var rect = e.CellBounds; + rect.Inflate(-2, -2); using var brush = new SolidBrush(BookmarkColor); - e.Graphics.FillRectangle(brush, r); + e.Graphics.FillRectangle(brush, rect); var bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); @@ -1003,7 +1004,7 @@ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPainti using var brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); using var font = new Font("Verdana", Preferences.FontSize, FontStyle.Bold); - e.Graphics.DrawString("!", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); + e.Graphics.DrawString("!", font, brush2, new RectangleF(rect.Left, rect.Top, rect.Width, rect.Height), format); } } } @@ -1018,7 +1019,7 @@ private void OnFilterGridViewCellValueNeeded (object sender, DataGridViewCellVal { if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) { - e.Value = ""; + e.Value = string.Empty; return; } @@ -1118,7 +1119,7 @@ private void OnFilterGridViewKeyDown (object sender, KeyEventArgs e) break; } case Keys.Tab when e.Modifiers == Keys.None: - dataGridView.Focus(); + _ = dataGridView.Focus(); e.Handled = true; break; } @@ -1131,7 +1132,7 @@ private void OnDataGridViewKeyDown (object sender, KeyEventArgs e) { case Keys.Tab when e.Modifiers == Keys.None: { - filterGridView.Focus(); + _ = filterGridView.Focus(); e.Handled = true; break; } @@ -1161,7 +1162,7 @@ private void OnDataGridViewCellContentDoubleClick (object sender, DataGridViewCe { if (dataGridView.CurrentCell != null) { - dataGridView.BeginEdit(false); + _ = dataGridView.BeginEdit(false); } } diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs index 5e6bad97..a78c6c49 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs @@ -204,8 +204,7 @@ protected override void OnPaint (PaintEventArgs e) { if (!splitContainer1.Visible) { - var r = ClientRectangle; - e.Graphics.FillRectangle(SystemBrushes.ControlLight, r); + e.Graphics.FillRectangle(SystemBrushes.ControlLight, ClientRectangle); StringFormat sf = new() { @@ -213,7 +212,7 @@ protected override void OnPaint (PaintEventArgs e) LineAlignment = StringAlignment.Center }; - e.Graphics.DrawString("No bookmarks in current file", SystemFonts.DialogFont, SystemBrushes.WindowText, r, sf); + e.Graphics.DrawString("No bookmarks in current file", SystemFonts.DialogFont, SystemBrushes.WindowText, ClientRectangle, sf); } else { From 669b7847b4eda328a0e82ce2c4c9d1792e359732 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sat, 21 Jun 2025 18:32:20 +0200 Subject: [PATCH 111/142] update usedComponents --- src/usedPackages.json | Bin 19146 -> 13280 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/usedPackages.json b/src/usedPackages.json index 0b67f10b2fc9b9957a774a5c81d82743691baf4b..291e04bf08c1763d7c827cedc6715aab14ff5122 100644 GIT binary patch delta 106 zcmX>#mGMFPhAHfuOSopRPF9c>+5AiPnJ~XQgB3#z5V|vDGL$f6Z2oQ7$c8RB`L|*F uWCtm^$@{eUHhWnLu}uzgieNOI>?oW(xxkTcvy5{S3l}c~7eg!qhy(x?H69uO delta 1122 zcmb`GOKTHR6vxkKUTsa9H^dk+k%CI&JldwQg4md98lth9EJSpXPCIF_Z9*C`8^P>c zh#*Jzx^XRxU%*8{y0YNj$5(J8UHPBM6DjQ`TxK};-gEBxopb;9XLbLb@ae6SzuW!% zetgRK?Rzl}RB4OWNum{MVAjO9N>54Wd)@@Egu`RA*qbGVB);oim+O5m z4W3&aU(#_xgLX-#!G7nIFWwA`FWO0=i zz*VLVtcvixk4|J^WzdBtZSW75964?`Vlf7zL1A*h_#chX%8@5F*svdqRJ>;)} zqM^tiZ7fFS%*8+%Nm@uJ(M?n42w!6%1i73~3g!j$(!Jt~E>EF~eTlYFmSz>Xi@9z^ zn~~c<(CHZ Date: Sun, 22 Jun 2025 02:13:08 +0300 Subject: [PATCH 112/142] Removed Resources from the namespace for a better readability --- src/LogExpert.Resources/Resources.Designer.cs | 4 +-- .../Controls/LogWindow/LogWindow.cs | 4 +-- .../Controls/LogWindow/LogWindow.designer.cs | 8 ++--- src/LogExpert.UI/Dialogs/AboutBox.cs | 2 +- .../Dialogs/LogTabWindow/LogTabWindow.cs | 2 +- .../LogTabWindow/LogTabWindow.designer.cs | 32 +++++++++---------- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/LogExpert.Resources/Resources.Designer.cs b/src/LogExpert.Resources/Resources.Designer.cs index 81aaf6ae..fbcf8bd2 100644 --- a/src/LogExpert.Resources/Resources.Designer.cs +++ b/src/LogExpert.Resources/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace LogExpert.Resources { +namespace LogExpert { using System; @@ -39,7 +39,7 @@ internal Resources() { public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LogExpert.Resources.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LogExpert.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index cbaea090..3ddab4fb 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -222,8 +222,8 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp dataGridView.EditModeMenuStrip = editModeContextMenuStrip; markEditModeToolStripMenuItem.Enabled = true; - _panelOpenButtonImage = Resources.Resources.Arrow_menu_open; - _panelCloseButtonImage = Resources.Resources.Arrow_menu_close; + _panelOpenButtonImage = Resources.Arrow_menu_open; + _panelCloseButtonImage = Resources.Arrow_menu_close; Settings settings = configManager.Settings; diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs index 27d15a90..69d1ead2 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs @@ -576,7 +576,7 @@ private void InitializeComponent() // // pnlProFilterLabel // - pnlProFilterLabel.BackgroundImage = LogExpert.Resources.Resources.Pro_Filter; + pnlProFilterLabel.BackgroundImage = LogExpert.Resources.Pro_Filter; pnlProFilterLabel.BackgroundImageLayout = ImageLayout.Center; pnlProFilterLabel.Location = new Point(5, 7); pnlProFilterLabel.Name = "pnlProFilterLabel"; @@ -653,7 +653,7 @@ private void InitializeComponent() // btnToggleHighlightPanel // btnToggleHighlightPanel.Anchor = AnchorStyles.Top | AnchorStyles.Right; - btnToggleHighlightPanel.Image = LogExpert.Resources.Resources.Arrow_menu_open; + btnToggleHighlightPanel.Image = LogExpert.Resources.Arrow_menu_open; btnToggleHighlightPanel.Location = new Point(1832, 1); btnToggleHighlightPanel.Name = "btnToggleHighlightPanel"; btnToggleHighlightPanel.Size = new Size(20, 21); @@ -783,7 +783,7 @@ private void InitializeComponent() // // filterDownButton // - filterDownButton.BackgroundImage = LogExpert.Resources.Resources.ArrowDown; + filterDownButton.BackgroundImage = LogExpert.Resources.ArrowDown; filterDownButton.BackgroundImageLayout = ImageLayout.Stretch; filterDownButton.Location = new Point(296, 85); filterDownButton.Name = "filterDownButton"; @@ -796,7 +796,7 @@ private void InitializeComponent() // // filterUpButton // - filterUpButton.BackgroundImage = LogExpert.Resources.Resources.ArrowUp; + filterUpButton.BackgroundImage = LogExpert.Resources.ArrowUp; filterUpButton.BackgroundImageLayout = ImageLayout.Stretch; filterUpButton.Location = new Point(258, 85); filterUpButton.Name = "filterUpButton"; diff --git a/src/LogExpert.UI/Dialogs/AboutBox.cs b/src/LogExpert.UI/Dialogs/AboutBox.cs index 471d836f..24b75108 100644 --- a/src/LogExpert.UI/Dialogs/AboutBox.cs +++ b/src/LogExpert.UI/Dialogs/AboutBox.cs @@ -49,7 +49,7 @@ private void LoadUsedComponents() private void LoadResources() { - logoPictureBox.Image = Resources.Resources.LogLover; + logoPictureBox.Image = Resources.LogLover; } #endregion diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs index 6ae4d6e3..8283eee2 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs @@ -154,7 +154,7 @@ public LogTabWindow (string[] fileNames, int instanceNumber, bool showInstanceNu // get a list of resource names from the manifest var resNames = a.GetManifestResourceNames(); - Bitmap bmp = Resources.Resources.Deceased; + Bitmap bmp = Resources.Deceased; _deadIcon = Icon.FromHandle(bmp.GetHicon()); bmp.Dispose(); Closing += OnLogTabWindowClosing; diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs index 3821a872..0e39c347 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.designer.cs @@ -241,7 +241,7 @@ private void InitializeComponent() // openToolStripMenuItem // openToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; - openToolStripMenuItem.Image = LogExpert.Resources.Resources.File_open; + openToolStripMenuItem.Image = LogExpert.Resources.File_open; openToolStripMenuItem.Name = "openToolStripMenuItem"; openToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.O; openToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -259,7 +259,7 @@ private void InitializeComponent() // // closeFileToolStripMenuItem // - closeFileToolStripMenuItem.Image = LogExpert.Resources.Resources.Close; + closeFileToolStripMenuItem.Image = LogExpert.Resources.Close; closeFileToolStripMenuItem.Name = "closeFileToolStripMenuItem"; closeFileToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.F4; closeFileToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -268,7 +268,7 @@ private void InitializeComponent() // // reloadToolStripMenuItem // - reloadToolStripMenuItem.Image = LogExpert.Resources.Resources.Restart_alt; + reloadToolStripMenuItem.Image = LogExpert.Resources.Restart_alt; reloadToolStripMenuItem.Name = "reloadToolStripMenuItem"; reloadToolStripMenuItem.ShortcutKeys = Keys.F5; reloadToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -360,7 +360,7 @@ private void InitializeComponent() // // exitToolStripMenuItem // - exitToolStripMenuItem.Image = LogExpert.Resources.Resources.Exit; + exitToolStripMenuItem.Image = LogExpert.Resources.Exit; exitToolStripMenuItem.Name = "exitToolStripMenuItem"; exitToolStripMenuItem.ShortcutKeys = Keys.Alt | Keys.F4; exitToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -392,7 +392,7 @@ private void InitializeComponent() // // filterToolStripMenuItem // - filterToolStripMenuItem.Image = LogExpert.Resources.Resources.Filter; + filterToolStripMenuItem.Image = LogExpert.Resources.Filter; filterToolStripMenuItem.Name = "filterToolStripMenuItem"; filterToolStripMenuItem.ShortcutKeys = Keys.F4; filterToolStripMenuItem.Size = new System.Drawing.Size(189, 30); @@ -410,7 +410,7 @@ private void InitializeComponent() // toggleBookmarkToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; toggleBookmarkToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - toggleBookmarkToolStripMenuItem.Image = LogExpert.Resources.Resources.Bookmark_add; + toggleBookmarkToolStripMenuItem.Image = LogExpert.Resources.Bookmark_add; toggleBookmarkToolStripMenuItem.Name = "toggleBookmarkToolStripMenuItem"; toggleBookmarkToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.F2; toggleBookmarkToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -421,7 +421,7 @@ private void InitializeComponent() // jumpToNextToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; jumpToNextToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - jumpToNextToolStripMenuItem.Image = LogExpert.Resources.Resources.ArrowDown; + jumpToNextToolStripMenuItem.Image = LogExpert.Resources.ArrowDown; jumpToNextToolStripMenuItem.Name = "jumpToNextToolStripMenuItem"; jumpToNextToolStripMenuItem.ShortcutKeys = Keys.F2; jumpToNextToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -432,7 +432,7 @@ private void InitializeComponent() // jumpToPrevToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; jumpToPrevToolStripMenuItem.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - jumpToPrevToolStripMenuItem.Image = LogExpert.Resources.Resources.ArrowUp; + jumpToPrevToolStripMenuItem.Image = LogExpert.Resources.ArrowUp; jumpToPrevToolStripMenuItem.Name = "jumpToPrevToolStripMenuItem"; jumpToPrevToolStripMenuItem.ShortcutKeys = Keys.Shift | Keys.F2; jumpToPrevToolStripMenuItem.Size = new System.Drawing.Size(253, 30); @@ -586,7 +586,7 @@ private void InitializeComponent() // // settingsToolStripMenuItem // - settingsToolStripMenuItem.Image = LogExpert.Resources.Resources.Settings; + settingsToolStripMenuItem.Image = LogExpert.Resources.Settings; settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; settingsToolStripMenuItem.Size = new System.Drawing.Size(224, 30); settingsToolStripMenuItem.Text = "Settings..."; @@ -916,7 +916,7 @@ private void InitializeComponent() // toolStripButtonOpen // toolStripButtonOpen.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonOpen.Image = LogExpert.Resources.Resources.File_open; + toolStripButtonOpen.Image = LogExpert.Resources.File_open; toolStripButtonOpen.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonOpen.Name = "toolStripButtonOpen"; toolStripButtonOpen.Size = new System.Drawing.Size(28, 28); @@ -932,7 +932,7 @@ private void InitializeComponent() // toolStripButtonSearch // toolStripButtonSearch.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonSearch.Image = LogExpert.Resources.Resources.Search; + toolStripButtonSearch.Image = LogExpert.Resources.Search; toolStripButtonSearch.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonSearch.Name = "toolStripButtonSearch"; toolStripButtonSearch.Size = new System.Drawing.Size(28, 28); @@ -943,7 +943,7 @@ private void InitializeComponent() // toolStripButtonFilter // toolStripButtonFilter.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonFilter.Image = LogExpert.Resources.Resources.Filter; + toolStripButtonFilter.Image = LogExpert.Resources.Filter; toolStripButtonFilter.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonFilter.Name = "toolStripButtonFilter"; toolStripButtonFilter.Size = new System.Drawing.Size(28, 28); @@ -960,7 +960,7 @@ private void InitializeComponent() // toolStripButtonBookmark // toolStripButtonBookmark.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonBookmark.Image = LogExpert.Resources.Resources.Bookmark_add; + toolStripButtonBookmark.Image = LogExpert.Resources.Bookmark_add; toolStripButtonBookmark.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonBookmark.Name = "toolStripButtonBookmark"; toolStripButtonBookmark.Size = new System.Drawing.Size(28, 28); @@ -971,7 +971,7 @@ private void InitializeComponent() // toolStripButtonUp // toolStripButtonUp.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonUp.Image = LogExpert.Resources.Resources.ArrowUp; + toolStripButtonUp.Image = LogExpert.Resources.ArrowUp; toolStripButtonUp.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonUp.Name = "toolStripButtonUp"; toolStripButtonUp.Size = new System.Drawing.Size(28, 28); @@ -982,7 +982,7 @@ private void InitializeComponent() // toolStripButtonDown // toolStripButtonDown.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonDown.Image = LogExpert.Resources.Resources.ArrowDown; + toolStripButtonDown.Image = LogExpert.Resources.ArrowDown; toolStripButtonDown.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonDown.Name = "toolStripButtonDown"; toolStripButtonDown.Size = new System.Drawing.Size(28, 28); @@ -999,7 +999,7 @@ private void InitializeComponent() // toolStripButtonBubbles.CheckOnClick = true; toolStripButtonBubbles.DisplayStyle = ToolStripItemDisplayStyle.Image; - toolStripButtonBubbles.Image = LogExpert.Resources.Resources.bookmark_bubbles; + toolStripButtonBubbles.Image = LogExpert.Resources.bookmark_bubbles; toolStripButtonBubbles.ImageAlign = System.Drawing.ContentAlignment.BottomCenter; toolStripButtonBubbles.ImageTransparentColor = System.Drawing.Color.Magenta; toolStripButtonBubbles.Name = "toolStripButtonBubbles"; From 2e12d7e8efc2059569798d22bc0ee71e46c2d6b0 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 22 Jun 2025 09:19:33 +0200 Subject: [PATCH 113/142] build not working --- src/LogExpert.Core/Config/Settings.cs | 2 +- src/LogExpert.Core/Entities/SearchParams.cs | 2 +- .../Controls/LogWindow/LogWindow.cs | 47 +++++++------------ .../Dialogs/LogTabWindow/LogTabWindow.cs | 1 + src/LogExpert.UI/Dialogs/SearchDialog.cs | 2 +- 5 files changed, 21 insertions(+), 33 deletions(-) diff --git a/src/LogExpert.Core/Config/Settings.cs b/src/LogExpert.Core/Config/Settings.cs index 51375e41..7ba088cf 100644 --- a/src/LogExpert.Core/Config/Settings.cs +++ b/src/LogExpert.Core/Config/Settings.cs @@ -1,7 +1,7 @@ using System.Drawing; using LogExpert.Core.Classes.Filter; -using LogExpert.Core.Entities; +using LogExpert.Entities; namespace LogExpert.Core.Config; diff --git a/src/LogExpert.Core/Entities/SearchParams.cs b/src/LogExpert.Core/Entities/SearchParams.cs index ed4b2748..2a5167db 100644 --- a/src/LogExpert.Core/Entities/SearchParams.cs +++ b/src/LogExpert.Core/Entities/SearchParams.cs @@ -1,4 +1,4 @@ -namespace LogExpert.Core.Entities; +namespace LogExpert.Entities; [Serializable] public class SearchParams diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index f757d24f..82f6f7ba 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -4,7 +4,6 @@ using System.Text; using System.Text.RegularExpressions; -using LogExpert.Classes.Filter; using LogExpert.Core.Callback; using LogExpert.Core.Classes; using LogExpert.Core.Classes.Bookmark; @@ -18,6 +17,7 @@ using LogExpert.Core.EventArguments; using LogExpert.Core.Interface; using LogExpert.Dialogs; +using LogExpert.Entities; using LogExpert.Extensions; using LogExpert.UI.Dialogs; using LogExpert.UI.Entities; @@ -3738,18 +3738,18 @@ private void SyncTimestampDisplayWorker () while (!_shouldTimestampDisplaySyncingCancel) { - _timeShiftSyncWakeupEvent.WaitOne(); + _ = _timeShiftSyncWakeupEvent.WaitOne(); if (_shouldTimestampDisplaySyncingCancel) { return; } - _timeShiftSyncWakeupEvent.Reset(); + _ = _timeShiftSyncWakeupEvent.Reset(); while (!_shouldTimestampDisplaySyncingCancel) { var signaled = _timeShiftSyncTimerEvent.WaitOne(WAIT_TIME, true); - _timeShiftSyncTimerEvent.Reset(); + _ = _timeShiftSyncTimerEvent.Reset(); if (!signaled) { break; @@ -3791,17 +3791,11 @@ private void SyncTimestampDisplayWorker () refLine = row2; var timeStamp2 = GetTimestampForLine(ref refLine, false); //TimeSpan span = TimeSpan.FromTicks(timeStamp2.Ticks - timeStamp1.Ticks); - DateTime diff; - if (timeStamp1.Ticks > timeStamp2.Ticks) - { - diff = new DateTime(timeStamp1.Ticks - timeStamp2.Ticks); - } - else - { - diff = new DateTime(timeStamp2.Ticks - timeStamp1.Ticks); - } + var diff = timeStamp1.Ticks > timeStamp2.Ticks + ? new DateTime(timeStamp1.Ticks - timeStamp2.Ticks) + : new DateTime(timeStamp2.Ticks - timeStamp1.Ticks); - StatusLineText("Time diff is " + diff.ToString("HH:mm:ss.fff")); + StatusLineText($"Time diff is {diff:HH:mm:ss.fff}"); } else { @@ -3830,14 +3824,9 @@ private void SyncFilterGridPos () } } - if (filterGridView.Rows.GetRowCount(DataGridViewElementStates.None) > 0) // exception no rows - { - filterGridView.CurrentCell = filterGridView.Rows[index].Cells[0]; - } - else - { - filterGridView.CurrentCell = null; - } + filterGridView.CurrentCell = filterGridView.Rows.GetRowCount(DataGridViewElementStates.None) > 0 + ? filterGridView.Rows[index].Cells[0] + : null; } } catch (Exception e) @@ -4008,7 +3997,7 @@ private void SelectLine (int line, bool triggerSyncCall, bool shouldScroll) if (shouldScroll) { dataGridView.CurrentCell = dataGridView.Rows[line].Cells[0]; - dataGridView.Focus(); + _ = dataGridView.Focus(); } } catch (ArgumentOutOfRangeException e) @@ -4027,7 +4016,7 @@ private void StartEditMode () { if (!dataGridView.CurrentCell.ReadOnly) { - dataGridView.BeginEdit(false); + _ = dataGridView.BeginEdit(false); if (dataGridView.EditingControl != null) { if (dataGridView.EditingControl is LogCellEditingControl editControl) @@ -4235,7 +4224,6 @@ private void FilterSearch () if (filterComboBox.Text.Length == 0) { _filterParams.SearchText = string.Empty; - _filterParams.LowerSearchText = string.Empty; _filterParams.IsRangeSearch = false; ClearFilterList(); filterSearchButton.Image = null; @@ -4253,8 +4241,7 @@ private async void FilterSearch (string text) FireCancelHandlers(); // make sure that there's no other filter running (maybe from filter restore) _filterParams.SearchText = text; - _filterParams.LowerSearchText = text.ToLowerInvariant(); - ConfigManager.Settings.FilterHistoryList.Remove(text); + _ = ConfigManager.Settings.FilterHistoryList.Remove(text); ConfigManager.Settings.FilterHistoryList.Insert(0, text); var maxHistory = ConfigManager.Settings.Preferences.MaximumFilterEntries; @@ -4266,7 +4253,7 @@ private async void FilterSearch (string text) filterComboBox.Items.Clear(); foreach (var item in ConfigManager.Settings.FilterHistoryList) { - filterComboBox.Items.Add(item); + _ = filterComboBox.Items.Add(item); } filterComboBox.Text = text; @@ -4275,7 +4262,7 @@ private async void FilterSearch (string text) _filterParams.RangeSearchText = filterRangeComboBox.Text; if (_filterParams.IsRangeSearch) { - ConfigManager.Settings.FilterRangeHistoryList.Remove(filterRangeComboBox.Text); + _ = ConfigManager.Settings.FilterRangeHistoryList.Remove(filterRangeComboBox.Text); ConfigManager.Settings.FilterRangeHistoryList.Insert(0, filterRangeComboBox.Text); if (ConfigManager.Settings.FilterRangeHistoryList.Count > maxHistory) { @@ -4285,7 +4272,7 @@ private async void FilterSearch (string text) filterRangeComboBox.Items.Clear(); foreach (var item in ConfigManager.Settings.FilterRangeHistoryList) { - filterRangeComboBox.Items.Add(item); + _ = filterRangeComboBox.Items.Add(item); } } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs index d6000dcc..b27cd020 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs @@ -17,6 +17,7 @@ using LogExpert.Core.EventArguments; using LogExpert.Core.Interface; using LogExpert.Dialogs; +using LogExpert.Entities; using LogExpert.PluginRegistry.FileSystem; using LogExpert.UI.Dialogs; using LogExpert.UI.Entities; diff --git a/src/LogExpert.UI/Dialogs/SearchDialog.cs b/src/LogExpert.UI/Dialogs/SearchDialog.cs index 9ae87f17..a12294ed 100644 --- a/src/LogExpert.UI/Dialogs/SearchDialog.cs +++ b/src/LogExpert.UI/Dialogs/SearchDialog.cs @@ -1,7 +1,7 @@ using System.Runtime.Versioning; using System.Text.RegularExpressions; -using LogExpert.Core.Entities; +using LogExpert.Entities; using LogExpert.UI.Dialogs; namespace LogExpert.Dialogs; From 2d3c361f92a0ad7c30c914deb8485c6a27f748e4 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Mon, 23 Jun 2025 12:03:15 +0200 Subject: [PATCH 114/142] optimizations for debugging --- .../Classes/Log/LogfileReader.cs | 6 +- src/LogExpert.Core/Classes/SpreadEntry.cs | 4 +- .../Controls/BufferedDataGridView.cs | 4 +- .../Controls/LogWindow/LogWindow.cs | 158 ++++++------------ .../Controls/LogWindow/PatternWindow.cs | 4 +- .../LogWindow/TimeSpreadCalculator.cs | 128 ++++++-------- .../LogWindow/TimeSpreadigControl.Designer.cs | 3 +- .../Controls/LogWindow/TimeSpreadigControl.cs | 33 ++-- .../Dialogs/LogTabWindow/HighlightDialog.cs | 13 +- src/LogExpert.UI/Entities/PaintHelper.cs | 106 +++++++++--- 10 files changed, 220 insertions(+), 239 deletions(-) diff --git a/src/LogExpert.Core/Classes/Log/LogfileReader.cs b/src/LogExpert.Core/Classes/Log/LogfileReader.cs index 445ffd1e..d7f887a4 100644 --- a/src/LogExpert.Core/Classes/Log/LogfileReader.cs +++ b/src/LogExpert.Core/Classes/Log/LogfileReader.cs @@ -1785,13 +1785,13 @@ private void DumpBufferInfos (LogBuffer buffer) #endregion - public void Dispose() + public void Dispose () { Dispose(true); GC.SuppressFinalize(this); // Suppress finalization (not needed but best practice) } - protected virtual void Dispose(bool disposing) + protected virtual void Dispose (bool disposing) { if (!_disposed) { @@ -1808,7 +1808,7 @@ protected virtual void Dispose(bool disposing) //TODO: Seems that this can be deleted. Need to verify. ~LogfileReader () { - Dispose (false); + Dispose(false); } protected virtual void OnFileSizeChanged (LogEventArgs e) diff --git a/src/LogExpert.Core/Classes/SpreadEntry.cs b/src/LogExpert.Core/Classes/SpreadEntry.cs index 090c4847..c6fce9d8 100644 --- a/src/LogExpert.Core/Classes/SpreadEntry.cs +++ b/src/LogExpert.Core/Classes/SpreadEntry.cs @@ -1,4 +1,4 @@ -namespace LogExpert.Core.Classes; +namespace LogExpert.Core.Classes; public class SpreadEntry { @@ -16,7 +16,7 @@ public class SpreadEntry #region cTor - public SpreadEntry(int lineNum, int diff, DateTime timestamp) + public SpreadEntry (int lineNum, int diff, DateTime timestamp) { LineNum = lineNum; Diff = diff; diff --git a/src/LogExpert.UI/Controls/BufferedDataGridView.cs b/src/LogExpert.UI/Controls/BufferedDataGridView.cs index 7597b2e2..563cacdd 100644 --- a/src/LogExpert.UI/Controls/BufferedDataGridView.cs +++ b/src/LogExpert.UI/Controls/BufferedDataGridView.cs @@ -291,7 +291,7 @@ private void OnControlKeyDown (object sender, KeyEventArgs e) { if (EditingControl is LogCellEditingControl editControl) { - editControl.EditingControlDataGridView.EndEdit(); + _ = editControl.EditingControlDataGridView.EndEdit(); var line = editControl.EditingControlDataGridView.CurrentCellAddress.Y; if (e.KeyCode == Keys.Up) { @@ -313,7 +313,7 @@ private void OnControlKeyDown (object sender, KeyEventArgs e) var scrollIndex = editControl.EditingControlDataGridView.HorizontalScrollingOffset; var selStart = editControl.SelectionStart; editControl.EditingControlDataGridView.CurrentCell = editControl.EditingControlDataGridView.Rows[line].Cells[col]; - editControl.EditingControlDataGridView.BeginEdit(false); + _ = editControl.EditingControlDataGridView.BeginEdit(false); editControl.SelectionStart = selStart; editControl.ScrollToCaret(); editControl.EditingControlDataGridView.HorizontalScrollingOffset = scrollIndex; diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index 82f6f7ba..e41c1b17 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -155,7 +155,7 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp CreateDefaultViewStyle(); - columnNamesLabel.Text = ""; // no filtering on columns by default + columnNamesLabel.Text = string.Empty; // no filtering on columns by default _parentLogTabWin = parent; IsTempFile = isTempFile; @@ -202,7 +202,7 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp _filterParams = new FilterParams(); foreach (var item in configManager.Settings.FilterHistoryList) { - filterComboBox.Items.Add(item); + _ = filterComboBox.Items.Add(item); } filterComboBox.DropDownHeight = filterComboBox.ItemHeight * configManager.Settings.Preferences.MaximumFilterEntriesDisplayed; @@ -264,8 +264,6 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp ResumeLayout(); } - - #endregion #region Delegates @@ -800,7 +798,7 @@ private void OnFileSizeChanged (object sender, LogEventArgs e) lock (_logEventArgsList) { _logEventArgsList.Add(e); - _logEventArgsEvent.Set(); + _ = _logEventArgsEvent.Set(); } } @@ -819,7 +817,7 @@ private void OnDataGridViewCellValueNeeded (object sender, DataGridViewCellValue for (var i = startCount; i < CurrentColumnizer.GetColumnCount(); i++) { var colName = CurrentColumnizer.GetColumnNames()[i]; - dataGridView.Columns.Add(PaintHelper.CreateTitleColumn(colName)); + _ = dataGridView.Columns.Add(PaintHelper.CreateTitleColumn(colName)); } } } @@ -853,7 +851,7 @@ private void OnDataGridViewCellValuePushed (object sender, DataGridViewCellValue var index = span.LastIndexOf('.'); if (index > 0) { - span = span.Substring(0, index + 4); + span = span[..(index + 4)]; } SetTimeshiftValue(span); @@ -947,8 +945,6 @@ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPainti return; } - - var lineNum = _filterResultList[e.RowIndex]; var line = _logFileReader.GetLogLineWithWait(lineNum).Result; @@ -956,18 +952,19 @@ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPainti { var entry = FindFirstNoWordMatchHilightEntry(line); e.Graphics.SetClip(e.CellBounds); + if (e.State.HasFlag(DataGridViewElementStates.Selected)) { + if (e.CellStyle.SelectionForeColor != Color.White) + { + e.CellStyle.SelectionForeColor = PaintHelper.GetForeColorBasedOnBackColor(e.CellStyle.SelectionBackColor); + } + using var brush = PaintHelper.GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); e.Graphics.FillRectangle(brush, e.CellBounds); } else { - // paint direct filter hits with different bg color - //if (this.filterParams.SpreadEnabled && this.filterHitList.Contains(lineNum)) - //{ - // bgColor = Color.FromArgb(255, 220, 220, 220); - //} e.CellStyle.BackColor = PaintHelper.GetBackColorFromHighlightEntry(entry); e.PaintBackground(e.ClipBounds, false); } @@ -978,7 +975,7 @@ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPainti } else { - PaintCell(e, filterGridView, false, entry); + PaintCell(e, entry); } if (e.ColumnIndex == 0) @@ -2037,21 +2034,12 @@ private void OnFilterListBoxDrawItem (object sender, DrawItemEventArgs e) var filterParams = (FilterParams)filterListBox.Items[e.Index]; Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); - Brush brush; - - if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) - { - brush = new SolidBrush(filterListBox.BackColor); - } - else - { - brush = new SolidBrush(filterParams.Color); - } + using var brush = (e.State & DrawItemState.Selected) == DrawItemState.Selected + ? new SolidBrush(filterListBox.BackColor) + : new SolidBrush(filterParams.Color); - e.Graphics.DrawString(filterParams.SearchText, e.Font, brush, - new PointF(rectangle.Left, rectangle.Top)); + e.Graphics.DrawString(filterParams.SearchText, e.Font, brush, new PointF(rectangle.Left, rectangle.Top)); e.DrawFocusRectangle(); - brush.Dispose(); } } @@ -2203,7 +2191,7 @@ private void OnColumnComboBoxKeyDown (object sender, KeyEventArgs e) if (e.KeyCode == Keys.Enter) { SelectColumn(); - dataGridView.Focus(); + _ = dataGridView.Focus(); } } @@ -2259,10 +2247,10 @@ private void OnLogWindowEnter (object sender, EventArgs e) [SupportedOSPlatform("windows")] private void OnDataGridViewRowUnshared (object sender, DataGridViewRowEventArgs e) { - if (_logger.IsTraceEnabled) - { - _logger.Trace($"Row unshared line {e.Row.Cells[1].Value}"); - } + //if (_logger.IsTraceEnabled) + //{ + // _logger.Trace($"Row unshared line {e.Row.Cells[1].Value}"); + //} } #endregion @@ -2281,6 +2269,16 @@ private void MeasureItem (object sender, MeasureItemEventArgs e) #region Private Methods + [SupportedOSPlatform("windows")] + private void CreateDefaultViewStyle () + { + + dataGridView.DefaultCellStyle = PaintHelper.GetDataGridViewCellStyle(); + filterGridView.DefaultCellStyle = PaintHelper.GetDataGridViewCellStyle(); + dataGridView.RowsDefaultCellStyle = PaintHelper.GetDataGridDefaultRowStyle(); + filterGridView.RowsDefaultCellStyle = PaintHelper.GetDataGridDefaultRowStyle(); + } + [SupportedOSPlatform("windows")] private void RegisterLogFileReaderEvents () { @@ -2306,56 +2304,6 @@ private void UnRegisterLogFileReaderEvents () } } - [SupportedOSPlatform("windows")] - private void CreateDefaultViewStyle () - { - DataGridViewCellStyle dataGridViewCellStyleMainGrid = new(); - DataGridViewCellStyle dataGridViewCellStyleFilterGrid = new(); - - dataGridViewCellStyleMainGrid.Alignment = DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyleMainGrid.BackColor = SystemColors.Window; - dataGridViewCellStyleMainGrid.Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - dataGridViewCellStyleMainGrid.ForeColor = SystemColors.ControlText; - dataGridViewCellStyleMainGrid.SelectionBackColor = SystemColors.Highlight; - //dataGridViewCellStyleMainGrid.SelectionForeColor = SystemColors.HighlightText; - - var highlightColor = SystemColors.Highlight; - //Color is smaller than 128, means its darker - var isSelectionBackColorDark = (highlightColor.R * 0.2126) + (highlightColor.G * 0.7152) + (highlightColor.B * 0.0722) < 255 / 2; - - if (isSelectionBackColorDark) - { - dataGridViewCellStyleMainGrid.SelectionForeColor = Color.White; - } - else - { - dataGridViewCellStyleMainGrid.SelectionForeColor = Color.Black; - - } - - dataGridViewCellStyleMainGrid.WrapMode = DataGridViewTriState.False; - dataGridView.DefaultCellStyle = dataGridViewCellStyleMainGrid; - - dataGridViewCellStyleFilterGrid.Alignment = DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyleFilterGrid.BackColor = SystemColors.Window; - dataGridViewCellStyleFilterGrid.Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - dataGridViewCellStyleFilterGrid.ForeColor = SystemColors.ControlText; - dataGridViewCellStyleFilterGrid.SelectionBackColor = SystemColors.Highlight; - //dataGridViewCellStyleFilterGrid.SelectionForeColor = SystemColors.HighlightText; - - if (isSelectionBackColorDark) - { - dataGridViewCellStyleFilterGrid.SelectionForeColor = Color.White; - } - else - { - dataGridViewCellStyleFilterGrid.SelectionForeColor = Color.Black; - } - - dataGridViewCellStyleFilterGrid.WrapMode = DataGridViewTriState.False; - filterGridView.DefaultCellStyle = dataGridViewCellStyleFilterGrid; - } - [SupportedOSPlatform("windows")] private bool LoadPersistenceOptions () { @@ -3083,7 +3031,7 @@ private void CheckFilterAndHighlight (LogEventArgs e) var matchingList = FindMatchingHilightEntries(line); LaunchHighlightPlugins(matchingList, i); - GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, out bookmarkComment); + GetHighlightActions(matchingList, out suppressLed, out stopTail, out setBookmark, out bookmarkComment); if (setBookmark) { SetBookmarkFx fx = SetBookmarkFromTrigger; @@ -3131,7 +3079,7 @@ private void CheckFilterAndHighlight (LogEventArgs e) { var matchingList = FindMatchingHilightEntries(line); LaunchHighlightPlugins(matchingList, i); - GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, + GetHighlightActions(matchingList, out suppressLed, out stopTail, out setBookmark, out bookmarkComment); if (setBookmark) { @@ -3380,12 +3328,12 @@ private void AutoResizeColumns (BufferedDataGridView gridView) } } - private void PaintCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) + private void PaintCell (DataGridViewCellPaintingEventArgs e, HighlightEntry groundEntry) { - PaintHighlightedCell(e, gridView, noBackgroundFill, groundEntry); + PaintHighlightedCell(e, groundEntry); } - private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) + private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, HighlightEntry groundEntry) { var column = e.Value as IColumn; @@ -3454,14 +3402,13 @@ private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, Buffered var wordPos = valBounds.Location; Size proposedSize = new(valBounds.Width, valBounds.Height); - var r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); e.Graphics.SetClip(e.CellBounds); foreach (var matchEntry in matchList) { var font = matchEntry != null && matchEntry.HighlightEntry.IsBold ? BoldFont : NormalFont; - Brush bgBrush = matchEntry.HighlightEntry.BackgroundColor != Color.Empty + using var bgBrush = matchEntry.HighlightEntry.BackgroundColor != Color.Empty ? new SolidBrush(matchEntry.HighlightEntry.BackgroundColor) : null; @@ -3471,18 +3418,16 @@ private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, Buffered Rectangle wordRect = new(wordPos, wordSize); var foreColor = matchEntry.HighlightEntry.ForegroundColor; - if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected) + if (e.State.HasFlag(DataGridViewElementStates.Selected)) { - if (!noBackgroundFill && bgBrush != null && !matchEntry.HighlightEntry.NoBackground) + if (bgBrush != null && !matchEntry.HighlightEntry.NoBackground) { e.Graphics.FillRectangle(bgBrush, wordRect); } } TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, foreColor, flags); - wordPos.Offset(wordSize.Width, 0); - bgBrush?.Dispose(); } } @@ -3664,7 +3609,7 @@ private void GetHighlightEntryMatches (ITextValue line, IList hi } } - private void GetHilightActions (IList matchingList, out bool noLed, out bool stopTail, out bool setBookmark, out string bookmarkComment) + private void GetHighlightActions (IList matchingList, out bool noLed, out bool stopTail, out bool setBookmark, out string bookmarkComment) { noLed = stopTail = setBookmark = false; bookmarkComment = string.Empty; @@ -3724,8 +3669,8 @@ private void SyncTimestampDisplay () private void SyncTimestampDisplay (int lineNum) { _timeShiftSyncLine = lineNum; - _timeShiftSyncTimerEvent.Set(); - _timeShiftSyncWakeupEvent.Set(); + _ = _timeShiftSyncTimerEvent.Set(); + _ = _timeShiftSyncWakeupEvent.Set(); } [SupportedOSPlatform("windows")] @@ -5285,6 +5230,7 @@ private void BookmarkComment (Bookmark bookmark) { Comment = bookmark.Text }; + if (dlg.ShowDialog() == DialogResult.OK) { bookmark.Text = dlg.Comment; @@ -6432,7 +6378,7 @@ public IColumn GetCellValue (int rowIndex, int columnIndex) return Column.EmptyColumn; } - public void CellPainting (BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) + public void CellPainting (bool focused, int rowIndex, DataGridViewCellPaintingEventArgs e) { if (rowIndex < 0 || e.ColumnIndex < 0) { @@ -6449,7 +6395,12 @@ public void CellPainting (BufferedDataGridView gridView, int rowIndex, DataGridV if (e.State.HasFlag(DataGridViewElementStates.Selected)) { - using var brush = PaintHelper.GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); + if (e.CellStyle.SelectionForeColor != Color.White) + { + e.CellStyle.SelectionForeColor = PaintHelper.GetForeColorBasedOnBackColor(e.CellStyle.SelectionBackColor); + } + + using var brush = PaintHelper.GetBrushForFocusedControl(focused, e.CellStyle.SelectionBackColor); e.Graphics.FillRectangle(brush, e.CellBounds); } else @@ -6464,15 +6415,16 @@ public void CellPainting (BufferedDataGridView gridView, int rowIndex, DataGridV } else { - PaintCell(e, gridView, false, entry); + PaintCell(e, entry); } if (e.ColumnIndex == 0) { if (_bookmarkProvider.IsBookmarkAtLine(rowIndex)) { - Rectangle r; // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); - r = e.CellBounds; + //keeping this comment, because it's the original code + // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); + var r = e.CellBounds; r.Inflate(-2, -2); using var brush = new SolidBrush(BookmarkColor); e.Graphics.FillRectangle(brush, r); @@ -6502,7 +6454,7 @@ public void CellPainting (BufferedDataGridView gridView, int rowIndex, DataGridV public void OnDataGridViewCellPainting (object sender, DataGridViewCellPaintingEventArgs e) { var gridView = (BufferedDataGridView)sender; - CellPainting(gridView, e.RowIndex, e); + CellPainting(gridView.Focused, e.RowIndex, e); } /// diff --git a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs index ea2fa9f8..94b5c5c4 100644 --- a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs @@ -245,7 +245,7 @@ private void OnPatternHitsDataGridViewCellPainting (object sender, DataGridViewC { var gridView = (BufferedDataGridView)sender; var rowIndex = GetLineForHitGrid(e.RowIndex); - _logWindow.CellPainting(gridView, rowIndex, e); + _logWindow.CellPainting(gridView.Focused, rowIndex, e); } } @@ -314,7 +314,7 @@ private void OnContentDataGridViewCellPainting (object sender, DataGridViewCellP var gridView = (BufferedDataGridView)sender; var rowIndex = GetLineForContentGrid(e.RowIndex); - _logWindow.CellPainting(gridView, rowIndex, e); + _logWindow.CellPainting(gridView.Focused, rowIndex, e); } private void OnContentDataGridViewCellMouseDoubleClick (object sender, DataGridViewCellMouseEventArgs e) diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs index 791e6797..9c91fce3 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs @@ -1,15 +1,11 @@ +using System.Globalization; + using LogExpert.Core.Callback; using LogExpert.Core.Classes; using LogExpert.Core.Interface; using NLog; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; - namespace LogExpert.UI.Controls.LogWindow; internal class TimeSpreadCalculator @@ -39,10 +35,8 @@ internal class TimeSpreadCalculator private DateTime _endTimestamp; private int _lineCount; private int _maxDiff; - private TimeSpan _maxSpan; private bool _shouldStop; - private CancellationTokenSource cts = new(); - + private readonly CancellationTokenSource _cts = new(); private DateTime _startTimestamp; private bool _timeMode = true; @@ -54,28 +48,20 @@ internal class TimeSpreadCalculator #region cTor - public TimeSpreadCalculator(ILogWindow logWindow) + public TimeSpreadCalculator (ILogWindow logWindow) { _logWindow = logWindow; _callback = new ColumnizerCallback(_logWindow); - Task.Run(WorkerFx, cts.Token); + _ = Task.Run(WorkerFx, _cts.Token); } #endregion - #region Delegates - - public delegate void CalcDoneEventHandler(object sender, EventArgs e); - - public delegate void StartCalcEventHandler(object sender, EventArgs e); - - #endregion - #region Events - public event CalcDoneEventHandler CalcDone; - public event StartCalcEventHandler StartCalc; + public EventHandler CalcDone; + public EventHandler StartCalc; #endregion @@ -89,8 +75,8 @@ public bool Enabled _enabled = value; if (_enabled) { - _calcEvent.Set(); - _lineCountEvent.Set(); + _ = _calcEvent.Set(); + _ = _lineCountEvent.Set(); } } } @@ -103,8 +89,8 @@ public bool TimeMode _timeMode = value; if (_enabled) { - _calcEvent.Set(); - _lineCountEvent.Set(); + _ = _calcEvent.Set(); + _ = _lineCountEvent.Set(); } } } @@ -129,8 +115,9 @@ public int Contrast } else { - CalcValuesViaLines(_timePerLine, _maxSpan); + _ = CalcValuesViaLines(_timePerLine); } + OnCalcDone(EventArgs.Empty); } @@ -143,30 +130,31 @@ public int Contrast #region Public methods - public void Stop() + public void Stop () { _shouldStop = true; - _lineCountEvent.Set(); - cts.Cancel(); + _ = _lineCountEvent.Set(); + + _cts.Cancel(); } - public void SetLineCount(int count) + public void SetLineCount (int count) { _lineCount = count; if (Enabled) { - _calcEvent.Set(); - _lineCountEvent.Set(); + _ = _calcEvent.Set(); + _ = _lineCountEvent.Set(); } } - public void SetDisplayHeight(int height) + public void SetDisplayHeight (int height) { _displayHeight = height; if (Enabled) { - _calcEvent.Set(); - _lineCountEvent.Set(); + _ = _calcEvent.Set(); + _ = _lineCountEvent.Set(); } } @@ -174,7 +162,7 @@ public void SetDisplayHeight(int height) #region Private Methods - private void WorkerFx() + private void WorkerFx () { //Thread.CurrentThread.Name = "TimeSpreadCalculator Worker"; //Thread.CurrentThread.Priority = ThreadPriority.BelowNormal; @@ -182,7 +170,7 @@ private void WorkerFx() while (!_shouldStop) { // wait for wakeup - _lineCountEvent.WaitOne(); + _ = _lineCountEvent.WaitOne(); while (!_shouldStop) { @@ -200,17 +188,19 @@ private void WorkerFx() { DoCalc(); } + break; } _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator: signalled. no calc."); - _calcEvent.Reset(); + _ = _calcEvent.Reset(); } - _lineCountEvent.Reset(); + + _ = _lineCountEvent.Reset(); } } - private void DoCalc() + private void DoCalc () { OnStartCalc(EventArgs.Empty); _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator.DoCalc() begin"); @@ -231,20 +221,13 @@ private void DoCalc() if (_startTimestamp != DateTime.MinValue && _endTimestamp != DateTime.MinValue) { - TimeSpan overallSpan = _endTimestamp - _startTimestamp; + var overallSpan = _endTimestamp - _startTimestamp; var overallSpanMillis = (int)(overallSpan.Ticks / TimeSpan.TicksPerMillisecond); _timePerLine = (int)Math.Round(overallSpanMillis / (double)_lineCount); - DateTime oldTime = _logWindow.GetTimestampForLineForward(ref lineNum, false); - int step; - - if (_lineCount > _displayHeight) - { - step = (int)Math.Round(_lineCount / (double)_displayHeight); - } - else - { - step = 1; - } + var oldTime = _logWindow.GetTimestampForLineForward(ref lineNum, false); + var step = _lineCount > _displayHeight + ? (int)Math.Round(_lineCount / (double)_displayHeight) + : 1; _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator.DoCalc() collecting data for {0} lines with step size {1}", lastLineNum, step); @@ -255,10 +238,10 @@ private void DoCalc() for (var i = lineNum; i < lastLineNum; i += step) { var currLineNum = i; - DateTime time = _logWindow.GetTimestampForLineForward(ref currLineNum, false); + var time = _logWindow.GetTimestampForLineForward(ref currLineNum, false); if (time != DateTime.MinValue) { - TimeSpan span = time - oldTime; + var span = time - oldTime; maxList.Add(span); timePerLineSum += (int)(span.Ticks / TimeSpan.TicksPerMillisecond); newDiffList.Add(new SpreadEntry(i, 0, time)); @@ -270,14 +253,13 @@ private void DoCalc() if (maxList.Count > 3) { maxList.Sort(); - _maxSpan = maxList[^3]; } lock (_diffListLock) { DiffList = newDiffList; _timePerLine = (int)Math.Round(timePerLineSum / ((double)(lastLineNum + 1) / step)); - CalcValuesViaLines(_timePerLine, _maxSpan); + _ = CalcValuesViaLines(_timePerLine); OnCalcDone(EventArgs.Empty); _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator.DoCalc() end"); } @@ -285,7 +267,7 @@ private void DoCalc() } //TODO Refactor this method - private void DoCalc_via_Time() + private void DoCalc_via_Time () { OnStartCalc(EventArgs.Empty); _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator.DoCalc_via_Time() begin"); @@ -304,25 +286,16 @@ private void DoCalc_via_Time() if (_startTimestamp != DateTime.MinValue && _endTimestamp != DateTime.MinValue) { - TimeSpan overallSpan = _endTimestamp - _startTimestamp; + var overallSpan = _endTimestamp - _startTimestamp; var overallSpanMillis = overallSpan.Ticks / TimeSpan.TicksPerMillisecond; //int timePerLine = (int)Math.Round((double)overallSpanMillis / (double)this.lineCount); - long step; - - if (overallSpanMillis > _displayHeight) - { - step = (long)Math.Round(overallSpanMillis / (double)_displayHeight); - } - else - { - step = 1; - } + var step = overallSpanMillis > _displayHeight ? (long)Math.Round(overallSpanMillis / (double)_displayHeight) : 1; _logger.Debug(CultureInfo.InvariantCulture, "TimeSpreadCalculator.DoCalc_via_Time() time range is {0} ms", overallSpanMillis); lineNum = 0; - DateTime searchTimeStamp = _startTimestamp; + var searchTimeStamp = _startTimestamp; var oldLineNum = lineNum; var loopCount = 0; var lineDiffSum = 0; @@ -395,17 +368,17 @@ private void DoCalc_via_Time() } } - private DateTime CalcValuesViaLines(int timePerLine, TimeSpan maxSpan) + private DateTime CalcValuesViaLines (int timePerLine) { - DateTime oldTime = DateTime.MinValue; + var oldTime = DateTime.MinValue; if (DiffList.Count > 0) { oldTime = DiffList[0].Timestamp; - foreach (SpreadEntry entry in DiffList) + foreach (var entry in DiffList) { - TimeSpan span = entry.Timestamp - oldTime; + var span = entry.Timestamp - oldTime; double diffFromAverage = (int)(span.Ticks / TimeSpan.TicksPerMillisecond) - timePerLine; if (diffFromAverage < 0) @@ -422,9 +395,9 @@ private DateTime CalcValuesViaLines(int timePerLine, TimeSpan maxSpan) return oldTime; } - private void CalcValuesViaTime(int maxDiff, double average) + private void CalcValuesViaTime (int maxDiff, double average) { - foreach (SpreadEntry entry in DiffList) + foreach (var entry in DiffList) { var lineDiff = entry.Diff; var diffFromAverage = entry.Diff - average; @@ -433,6 +406,7 @@ private void CalcValuesViaTime(int maxDiff, double average) { diffFromAverage = 0; } + var value = (int)(diffFromAverage / maxDiff * _contrast); entry.Value = 255 - value; @@ -440,12 +414,12 @@ private void CalcValuesViaTime(int maxDiff, double average) } } - private void OnCalcDone(EventArgs e) + private void OnCalcDone (EventArgs e) { CalcDone?.Invoke(this, e); } - private void OnStartCalc(EventArgs e) + private void OnStartCalc (EventArgs e) { StartCalc?.Invoke(this, e); } diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.Designer.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.Designer.cs index 4a0cc7fb..48595990 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.Designer.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.Designer.cs @@ -1,4 +1,4 @@ -namespace LogExpert.UI.Controls.LogWindow +namespace LogExpert.UI.Controls.LogWindow { partial class TimeSpreadingControl { @@ -17,6 +17,7 @@ protected override void Dispose(bool disposing) { components.Dispose(); } + base.Dispose(disposing); } diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs index ad0150e9..41c94c8d 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs @@ -12,7 +12,7 @@ namespace LogExpert.UI.Controls.LogWindow; [SupportedOSPlatform("windows")] internal partial class TimeSpreadingControl : UserControl { - private static readonly ILogger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); #region Fields @@ -45,13 +45,11 @@ public TimeSpreadingControl () #region Delegates - public delegate void LineSelectedEventHandler (object sender, SelectLineEventArgs e); - #endregion #region Events - public event LineSelectedEventHandler LineSelected; + public EventHandler LineSelected; #endregion @@ -82,11 +80,10 @@ protected override void OnPaint (PaintEventArgs e) { if (DesignMode) { - Brush bgBrush = new SolidBrush(Color.FromKnownColor(KnownColor.LightSkyBlue)); + using var bgBrush = new SolidBrush(Color.FromKnownColor(KnownColor.LightSkyBlue)); var rect = ClientRectangle; rect.Inflate(0, -_edgeOffset); e.Graphics.FillRectangle(bgBrush, rect); - bgBrush.Dispose(); } else { @@ -107,7 +104,7 @@ private SpreadEntry GetEntryForMouse (MouseEventArgs e) { y = 0; } - else if (y >= ClientRectangle.Height - _edgeOffset * 3) + else if (y >= ClientRectangle.Height - (_edgeOffset * 3)) { y = list.Count - 1; } @@ -153,7 +150,7 @@ private void OnTimeSpreadCalcCalcDone (object sender, EventArgs e) { Invalidate(); var rect = ClientRectangle; - rect.Size = new Size(rect.Width, rect.Height - _edgeOffset * 3); + rect.Size = new Size(rect.Width, rect.Height - (_edgeOffset * 3)); if (rect.Height < 1) { @@ -161,10 +158,9 @@ private void OnTimeSpreadCalcCalcDone (object sender, EventArgs e) } _bitmap = new Bitmap(rect.Width, rect.Height); - var gfx = Graphics.FromImage(_bitmap); - Brush bgBrush = new SolidBrush(BackColor); + using var gfx = Graphics.FromImage(_bitmap); + using var bgBrush = new SolidBrush(BackColor); gfx.FillRectangle(bgBrush, rect); - bgBrush.Dispose(); var list = TimeSpreadCalc.DiffList; int step; @@ -199,10 +195,8 @@ private void OnTimeSpreadCalcCalcDone (object sender, EventArgs e) color = 0; } - Brush brush = new SolidBrush(Color.FromArgb(color, ForeColor)); - //Brush brush = new SolidBrush(Color.FromArgb(color, color, color, color)); + using var brush = new SolidBrush(Color.FromArgb(color, ForeColor)); gfx.FillRectangle(brush, fillRect); - brush.Dispose(); fillRect.Offset(0, _rectHeight); } } @@ -217,7 +211,7 @@ private void OnTimeSpreadCalcStartCalc (object sender, EventArgs e) { Invalidate(); var rect = ClientRectangle; - rect.Size = new Size(rect.Width, rect.Height - _edgeOffset * 3); + rect.Size = new Size(rect.Width, rect.Height - (_edgeOffset * 3)); if (rect.Height < 1) { @@ -227,8 +221,8 @@ private void OnTimeSpreadCalcStartCalc (object sender, EventArgs e) //this.bmp = new Bitmap(rect.Width, rect.Height); var gfx = Graphics.FromImage(_bitmap); - Brush bgBrush = new SolidBrush(BackColor); - Brush fgBrush = new SolidBrush(ForeColor); + using var bgBrush = new SolidBrush(BackColor); + using var fgBrush = new SolidBrush(ForeColor); //gfx.FillRectangle(bgBrush, rect); StringFormat format = new(StringFormatFlags.DirectionVertical | StringFormatFlags.NoWrap) @@ -240,9 +234,6 @@ private void OnTimeSpreadCalcStartCalc (object sender, EventArgs e) RectangleF rectf = new(rect.Left, rect.Top, rect.Width, rect.Height); gfx.DrawString("Calculating time spread view...", Font, fgBrush, rectf, format); - - bgBrush.Dispose(); - fgBrush.Dispose(); } BeginInvoke(new MethodInvoker(Refresh)); @@ -252,7 +243,7 @@ private void OnTimeSpreadingControlSizeChanged (object sender, EventArgs e) { if (TimeSpreadCalc != null) { - _displayHeight = ClientRectangle.Height - _edgeOffset * 3; + _displayHeight = ClientRectangle.Height - (_edgeOffset * 3); TimeSpreadCalc.SetDisplayHeight(_displayHeight); } } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs index fa1e3b01..88d846e0 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs @@ -412,13 +412,18 @@ private void OnHighlightListBoxDrawItem (object sender, DrawItemEventArgs e) var entry = (HighlightEntry)listBoxHighlight.Items[e.Index]; Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); - if ((e.State & DrawItemState.Selected) != DrawItemState.Selected) + var selected = (e.State & DrawItemState.Selected) == DrawItemState.Selected; + + using var brush = selected + ? new SolidBrush(entry.BackgroundColor) + : new SolidBrush(entry.ForegroundColor); + + if (selected) { - e.Graphics.FillRectangle(new SolidBrush(entry.BackgroundColor), rectangle); + e.Graphics.FillRectangle(brush, rectangle); } - e.Graphics.DrawString(entry.SearchText, e.Font, new SolidBrush(entry.ForegroundColor), - new PointF(rectangle.Left, rectangle.Top)); + e.Graphics.DrawString(entry.SearchText, e.Font, brush, new PointF(rectangle.Left, rectangle.Top)); e.DrawFocusRectangle(); } diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index 0454c5cd..07401790 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -39,6 +39,11 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri if (e.State.HasFlag(DataGridViewElementStates.Selected)) { + if (e.CellStyle.SelectionForeColor != Color.White) + { + e.CellStyle.SelectionForeColor = GetForeColorBasedOnBackColor(e.CellStyle.SelectionBackColor); + } + using var brush = GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); e.Graphics.FillRectangle(brush, e.CellBounds); } @@ -62,12 +67,12 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri var bookmark = logPaintCtx.GetBookmarkForLine(rowIndex); if (bookmark != null) { - Rectangle r; // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); - r = e.CellBounds; + //keep this is the old initialisation of r => new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); + var r = e.CellBounds; r.Inflate(-2, -2); - Brush brush = new SolidBrush(logPaintCtx.BookmarkColor); + using var brush = new SolidBrush(logPaintCtx.BookmarkColor); e.Graphics.FillRectangle(brush, r); - brush.Dispose(); + if (bookmark.Text.Length > 0) { StringFormat format = new() @@ -76,10 +81,9 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri Alignment = StringAlignment.Center }; - Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); - var font = logPaintCtx.MonospacedFont; + using var brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); + using var font = logPaintCtx.MonospacedFont; e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); - brush2.Dispose(); } } } @@ -124,7 +128,7 @@ public static DataGridViewTextBoxColumn CreateMarkerColumn () { DataGridViewTextBoxColumn markerColumn = new() { - HeaderText = "", + HeaderText = string.Empty, AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet, Resizable = DataGridViewTriState.False, DividerWidth = 1, @@ -233,6 +237,50 @@ private static void AutoResizeColumns (BufferedDataGridView gridView, bool setLa } } + /// + /// This returns Black or White based on the color that is given + /// If the color is smaller than 128 it means its a darker color and white should be the fore color, + /// if the color is bigger than 128 it means its a lighter color and black should be the fore color + /// + /// lighter or darker back color + /// White or Black based on the given back color + public static Color GetForeColorBasedOnBackColor (Color backColor) + { + var isSelectionBackColorDark = (backColor.R * 0.2126) + (backColor.G * 0.7152) + (backColor.B * 0.0722) < 255 / 2; + + return isSelectionBackColorDark ? Color.White : Color.Black; + } + + [SupportedOSPlatform("windows")] + public static DataGridViewCellStyle GetDataGridViewCellStyle () + { + return new() + { + Alignment = DataGridViewContentAlignment.MiddleLeft, + BackColor = SystemColors.Window, + Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0), + ForeColor = Color.White, + SelectionBackColor = SystemColors.Highlight, + SelectionForeColor = GetForeColorBasedOnBackColor(SystemColors.Highlight), + WrapMode = DataGridViewTriState.False + }; + } + + [SupportedOSPlatform("windows")] + public static DataGridViewCellStyle GetDataGridDefaultRowStyle () + { + return new DataGridViewCellStyle + { + Alignment = DataGridViewContentAlignment.MiddleLeft, + BackColor = SystemColors.Window, + Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0), + ForeColor = Color.Black, + SelectionBackColor = SystemColors.Highlight, + SelectionForeColor = GetForeColorBasedOnBackColor(SystemColors.Highlight), + WrapMode = DataGridViewTriState.False + }; + } + [SupportedOSPlatform("windows")] public static void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, bool setLastColumnWidht, int lastColumnWidth) { @@ -266,26 +314,38 @@ public static Rectangle BorderWidths (DataGridViewAdvancedBorderStyle advancedBo { Rectangle rect = new() { - X = advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1 + X = advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.None + ? 0 + : 1 }; + if (advancedBorderStyle.Left is DataGridViewAdvancedCellBorderStyle.OutsetDouble or DataGridViewAdvancedCellBorderStyle.InsetDouble) { rect.X++; } - rect.Y = advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; + rect.Y = advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.None + ? 0 + : 1; + if (advancedBorderStyle.Top is DataGridViewAdvancedCellBorderStyle.OutsetDouble or DataGridViewAdvancedCellBorderStyle.InsetDouble) { rect.Y++; } - rect.Width = advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; + rect.Width = advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.None + ? 0 + : 1; + if (advancedBorderStyle.Right is DataGridViewAdvancedCellBorderStyle.OutsetDouble or DataGridViewAdvancedCellBorderStyle.InsetDouble) { rect.Width++; } - rect.Height = advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.None ? 0 : 1; + rect.Height = advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.None + ? 0 + : 1; + if (advancedBorderStyle.Bottom is DataGridViewAdvancedCellBorderStyle.OutsetDouble or DataGridViewAdvancedCellBorderStyle.InsetDouble) { @@ -334,8 +394,8 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr { SearchText = column.FullValue, //TODO change to white if the background color is darker - ForegroundColor = groundEntry?.ForegroundColor ?? Color.FromKnownColor(KnownColor.Black), BackgroundColor = groundEntry?.BackgroundColor ?? Color.Empty, + ForegroundColor = groundEntry?.ForegroundColor ?? Color.FromKnownColor(KnownColor.Black), IsRegEx = false, IsCaseSensitive = false, IsLedSwitch = false, @@ -351,13 +411,12 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr } } - var leftPad = e.CellStyle.Padding.Left; - RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, e.CellBounds.Height); var borderWidths = BorderWidths(e.AdvancedBorderStyle); var valBounds = e.CellBounds; valBounds.Offset(borderWidths.X, borderWidths.Y); valBounds.Width -= borderWidths.Right; valBounds.Height -= borderWidths.Bottom; + if (e.CellStyle.Padding != Padding.Empty) { valBounds.Offset(e.CellStyle.Padding.Left, e.CellStyle.Padding.Top); @@ -383,16 +442,15 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr var wordPos = valBounds.Location; Size proposedSize = new(valBounds.Width, valBounds.Height); - var r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); e.Graphics.SetClip(e.CellBounds); foreach (var matchEntry in matchList) { - var font = matchEntry != null && matchEntry.HighlightEntry.IsBold + using var font = matchEntry != null && matchEntry.HighlightEntry.IsBold ? logPaintCtx.BoldFont : logPaintCtx.NormalFont; - Brush bgBrush = matchEntry.HighlightEntry.BackgroundColor != Color.Empty + using var bgBrush = matchEntry.HighlightEntry.BackgroundColor != Color.Empty ? new SolidBrush(matchEntry.HighlightEntry.BackgroundColor) : null; @@ -428,11 +486,9 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, foreColor, flags); wordPos.Offset(wordSize.Width, 0); - bgBrush?.Dispose(); } } - /// /// Builds a list of HilightMatchEntry objects. A HilightMatchEntry spans over a region that is painted with the same foreground and /// background colors. @@ -480,24 +536,26 @@ private static IList MergeHighlightMatchEntries (IList Date: Mon, 23 Jun 2025 13:07:03 +0200 Subject: [PATCH 115/142] small optimizations --- src/LogExpert.UI/Controls/LogWindow/LogWindow.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index e41c1b17..f0024bed 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -3208,11 +3208,12 @@ private void SetColumnizerInternal (ILogLineColumnizer columnizer) { CurrentColumnizer = columnizer; _freezeStateMap.Clear(); + if (_logFileReader != null) { - if (CurrentColumnizer is IPreProcessColumnizer) + if (CurrentColumnizer is IPreProcessColumnizer columnizer1) { - _logFileReader.PreProcessColumnizer = (IPreProcessColumnizer)CurrentColumnizer; + _logFileReader.PreProcessColumnizer = columnizer1; } else { @@ -3237,7 +3238,7 @@ private void SetColumnizerInternal (ILogLineColumnizer columnizer) // Reload when previous columnizer was PreProcess and current is not, and vice versa. // When the current columnizer is a preProcess columnizer, reload in every case. - if (CurrentColumnizer is IPreProcessColumnizer != oldColumnizerIsPreProcess || + if ((CurrentColumnizer is IPreProcessColumnizer) != oldColumnizerIsPreProcess || CurrentColumnizer is IPreProcessColumnizer) { //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() @@ -3390,8 +3391,7 @@ private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, Highligh | TextFormatFlags.PreserveGraphicsClipping | TextFormatFlags.NoPadding | TextFormatFlags.VerticalCenter - | TextFormatFlags.TextBoxControl - ; + | TextFormatFlags.TextBoxControl; // | TextFormatFlags.VerticalCenter // | TextFormatFlags.TextBoxControl @@ -6395,9 +6395,9 @@ public void CellPainting (bool focused, int rowIndex, DataGridViewCellPaintingEv if (e.State.HasFlag(DataGridViewElementStates.Selected)) { - if (e.CellStyle.SelectionForeColor != Color.White) + if (e.CellStyle.ForeColor != Color.White) { - e.CellStyle.SelectionForeColor = PaintHelper.GetForeColorBasedOnBackColor(e.CellStyle.SelectionBackColor); + e.CellStyle.ForeColor = PaintHelper.GetForeColorBasedOnBackColor(e.CellStyle.SelectionBackColor); } using var brush = PaintHelper.GetBrushForFocusedControl(focused, e.CellStyle.SelectionBackColor); @@ -6490,11 +6490,13 @@ public HighlightEntry FindHighlightEntry (ITextValue line, bool noWordMatches) { continue; } + if (CheckHighlightEntryMatch(entry, line)) { return entry; } } + return null; } } From 6b076cb1ac52336ca8f793fb380e727fc442d8aa Mon Sep 17 00:00:00 2001 From: Hirogen Date: Mon, 23 Jun 2025 13:17:15 +0200 Subject: [PATCH 116/142] finally fixing the wrong text color problem --- src/LogExpert.UI/Controls/LogWindow/LogWindow.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index f0024bed..ef901a46 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -3418,13 +3418,20 @@ private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, Highligh Rectangle wordRect = new(wordPos, wordSize); var foreColor = matchEntry.HighlightEntry.ForegroundColor; - if (e.State.HasFlag(DataGridViewElementStates.Selected)) + if (!e.State.HasFlag(DataGridViewElementStates.Selected)) { if (bgBrush != null && !matchEntry.HighlightEntry.NoBackground) { e.Graphics.FillRectangle(bgBrush, wordRect); } } + else + { + if (foreColor.Equals(Color.Black)) + { + foreColor = Color.White; + } + } TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, foreColor, flags); wordPos.Offset(wordSize.Width, 0); From f9b7b42e455722bcabf480b956b6d6ffb3911a76 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Mon, 23 Jun 2025 13:34:27 +0200 Subject: [PATCH 117/142] wrong HighlightDialog dialog --- .../Dialogs/LogTabWindow/HighlightDialog.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs index 88d846e0..c48a91cd 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs @@ -6,6 +6,7 @@ using LogExpert.Core.Interface; using LogExpert.UI.Controls; using LogExpert.UI.Dialogs; +using LogExpert.UI.Entities; using NLog; @@ -412,18 +413,16 @@ private void OnHighlightListBoxDrawItem (object sender, DrawItemEventArgs e) var entry = (HighlightEntry)listBoxHighlight.Items[e.Index]; Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); - var selected = (e.State & DrawItemState.Selected) == DrawItemState.Selected; + var selected = e.State.HasFlag(DrawItemState.Selected); - using var brush = selected - ? new SolidBrush(entry.BackgroundColor) - : new SolidBrush(entry.ForegroundColor); + var forgroundColor = selected ? PaintHelper.GetForeColorBasedOnBackColor(entry.ForegroundColor) : entry.ForegroundColor; - if (selected) + if (!selected) { - e.Graphics.FillRectangle(brush, rectangle); + e.Graphics.FillRectangle(new SolidBrush(entry.BackgroundColor), rectangle); } - e.Graphics.DrawString(entry.SearchText, e.Font, brush, new PointF(rectangle.Left, rectangle.Top)); + e.Graphics.DrawString(entry.SearchText, e.Font, new SolidBrush(forgroundColor), new PointF(rectangle.Left, rectangle.Top)); e.DrawFocusRectangle(); } From 32eeda04f7a8567178b325484971df2323d0af66 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Mon, 23 Jun 2025 13:37:40 +0200 Subject: [PATCH 118/142] removed no longer needed debug code --- src/LogExpert.UI/Controls/LogWindow/LogWindow.cs | 10 ---------- .../Dialogs/LogTabWindow/HighlightDialog.cs | 5 +++-- src/LogExpert.UI/Entities/PaintHelper.cs | 5 ----- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index ef901a46..5496ffcc 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -955,11 +955,6 @@ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPainti if (e.State.HasFlag(DataGridViewElementStates.Selected)) { - if (e.CellStyle.SelectionForeColor != Color.White) - { - e.CellStyle.SelectionForeColor = PaintHelper.GetForeColorBasedOnBackColor(e.CellStyle.SelectionBackColor); - } - using var brush = PaintHelper.GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); e.Graphics.FillRectangle(brush, e.CellBounds); } @@ -6402,11 +6397,6 @@ public void CellPainting (bool focused, int rowIndex, DataGridViewCellPaintingEv if (e.State.HasFlag(DataGridViewElementStates.Selected)) { - if (e.CellStyle.ForeColor != Color.White) - { - e.CellStyle.ForeColor = PaintHelper.GetForeColorBasedOnBackColor(e.CellStyle.SelectionBackColor); - } - using var brush = PaintHelper.GetBrushForFocusedControl(focused, e.CellStyle.SelectionBackColor); e.Graphics.FillRectangle(brush, e.CellBounds); } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs index c48a91cd..adadc7da 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs @@ -414,8 +414,9 @@ private void OnHighlightListBoxDrawItem (object sender, DrawItemEventArgs e) Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); var selected = e.State.HasFlag(DrawItemState.Selected); - - var forgroundColor = selected ? PaintHelper.GetForeColorBasedOnBackColor(entry.ForegroundColor) : entry.ForegroundColor; + var forgroundColor = selected + ? PaintHelper.GetForeColorBasedOnBackColor(entry.ForegroundColor) + : entry.ForegroundColor; if (!selected) { diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index 07401790..acefeab5 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -39,11 +39,6 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri if (e.State.HasFlag(DataGridViewElementStates.Selected)) { - if (e.CellStyle.SelectionForeColor != Color.White) - { - e.CellStyle.SelectionForeColor = GetForeColorBasedOnBackColor(e.CellStyle.SelectionBackColor); - } - using var brush = GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); e.Graphics.FillRectangle(brush, e.CellBounds); } From b37e37399d4b2874b0230c72ef05aa09b52fdc13 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Mon, 23 Jun 2025 16:18:37 +0200 Subject: [PATCH 119/142] remove duplicated code from cellpainting in LogWindow, prepare to move the code to the PaintHelper and remove the duplicated code --- src/LogExpert.Core/Interface/ILogWindow.cs | 11 +- .../Controls/LogWindow/LogWindow.cs | 192 ++++++------------ .../Controls/LogWindow/PatternWindow.cs | 4 +- .../LogWindow/TimeSpreadCalculator.cs | 2 +- src/LogExpert.UI/Dialogs/BookmarkWindow.cs | 8 +- .../Dialogs/LogTabWindow/LogTabWindow.cs | 2 +- src/LogExpert.UI/Entities/PaintHelper.cs | 19 +- 7 files changed, 87 insertions(+), 151 deletions(-) diff --git a/src/LogExpert.Core/Interface/ILogWindow.cs b/src/LogExpert.Core/Interface/ILogWindow.cs index a0181219..c165b347 100644 --- a/src/LogExpert.Core/Interface/ILogWindow.cs +++ b/src/LogExpert.Core/Interface/ILogWindow.cs @@ -1,6 +1,5 @@ using LogExpert.Core.Classes.Log; using LogExpert.Core.Classes.Persister; -using LogExpert.Core.Entities; namespace LogExpert.Core.Interface; @@ -11,15 +10,17 @@ public interface ILogWindow ILogLine GetLine (int lineNum); + ILogLine GetLogLineWithWait (int lineNum); + //TODO Find a way to not use a referenced int (https://github.com/LogExperts/LogExpert/issues/404) - DateTime GetTimestampForLineForward (ref int lineNum, bool v); + DateTime GetTimestampForLineForward (ref int lineNum, bool roundToSeconds); //TODO Find a way to not use a referenced int (https://github.com/LogExperts/LogExpert/issues/404) - DateTime GetTimestampForLine (ref int lastLineNum, bool v); + DateTime GetTimestampForLine (ref int lastLineNum, bool roundToSeconds); - int FindTimestampLine_Internal (int lineNum1, int lineNum2, int lastLineNum, DateTime searchTimeStamp, bool v); + int FindTimestampLineInternal (int lineNum, int rangeStart, int rangeEnd, DateTime timestamp, bool roundToSeconds); - void SelectLine (int lineNum, bool v1, bool v2); + void SelectLine (int lineNum, bool triggerSyncCall, bool shouldScroll); PersistenceData GetPersistenceData (); diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index 5496ffcc..26c2123b 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -119,7 +119,7 @@ internal partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, IL private int _lineHeight; - internal LogfileReader _logFileReader; + private LogfileReader _logFileReader; private MultiFileOptions _multiFileOptions = new(); private bool _noSelectionUpdates; private PatternArgs _patternArgs = new(); @@ -339,6 +339,10 @@ public bool ShowBookmarkBubbles } } + public int CurrentLineNum => dataGridView.CurrentRow == null + ? -1 + : dataGridView.CurrentRow.Index; + public string FileName { get; private set; } public string SessionFileName { get; set; } @@ -408,6 +412,11 @@ public ILogLine GetLogLine (int lineNum) return _logFileReader.GetLogLine(lineNum); } + public ILogLine GetLogLineWithWait (int lineNum) + { + return _logFileReader.GetLogLineWithWait(lineNum).Result; + } + public Bookmark GetBookmarkForLine (int lineNum) { return _bookmarkProvider.GetBookmarkForLine(lineNum); @@ -551,9 +560,9 @@ internal void DumpBufferDiagnostic () } [SupportedOSPlatform("windows")] - void ILogWindow.SelectLine (int lineNum, bool v1, bool v2) + void ILogWindow.SelectLine (int lineNum, bool triggerSyncCall, bool shouldScroll) { - SelectLine(lineNum, v1, v2); + SelectLine(lineNum, triggerSyncCall, shouldScroll); } [SupportedOSPlatform("windows")] @@ -938,72 +947,7 @@ private void OnFilterSearchButtonClick (object sender, EventArgs e) private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPaintingEventArgs e) { var gridView = (BufferedDataGridView)sender; - - if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex) - { - e.Handled = false; - return; - } - - var lineNum = _filterResultList[e.RowIndex]; - var line = _logFileReader.GetLogLineWithWait(lineNum).Result; - - if (line != null) - { - var entry = FindFirstNoWordMatchHilightEntry(line); - e.Graphics.SetClip(e.CellBounds); - - if (e.State.HasFlag(DataGridViewElementStates.Selected)) - { - using var brush = PaintHelper.GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); - e.Graphics.FillRectangle(brush, e.CellBounds); - } - else - { - e.CellStyle.BackColor = PaintHelper.GetBackColorFromHighlightEntry(entry); - e.PaintBackground(e.ClipBounds, false); - } - - if (DebugOptions.DisableWordHighlight) - { - e.PaintContent(e.CellBounds); - } - else - { - PaintCell(e, entry); - } - - if (e.ColumnIndex == 0) - { - if (_bookmarkProvider.IsBookmarkAtLine(lineNum)) - { - //This was the OLD rect, left for future Information - //(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); - var rect = e.CellBounds; - rect.Inflate(-2, -2); - using var brush = new SolidBrush(BookmarkColor); - e.Graphics.FillRectangle(brush, rect); - - var bookmark = _bookmarkProvider.GetBookmarkForLine(lineNum); - - if (bookmark.Text.Length > 0) - { - StringFormat format = new() - { - LineAlignment = StringAlignment.Center, - Alignment = StringAlignment.Center - }; - - using var brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); - using var font = new Font("Verdana", Preferences.FontSize, FontStyle.Bold); - e.Graphics.DrawString("!", font, brush2, new RectangleF(rect.Left, rect.Top, rect.Width, rect.Height), format); - } - } - } - - e.Paint(e.CellBounds, DataGridViewPaintParts.Border); - e.Handled = true; - } + CellPainting(gridView.Focused, e.RowIndex, e.ColumnIndex, true, e); } [SupportedOSPlatform("windows")] @@ -3910,7 +3854,7 @@ private void ResetProgressBar () } [SupportedOSPlatform("windows")] - private void SelectLine (int line, bool triggerSyncCall, bool shouldScroll) + private void SelectLine (int lineNum, bool triggerSyncCall, bool shouldScroll) { try { @@ -3926,7 +3870,7 @@ private void SelectLine (int line, bool triggerSyncCall, bool shouldScroll) return; } - if (line == -1) + if (lineNum == -1) { // Hmm... is that experimental code from early days? MessageBox.Show(this, "Not found:", "Search result"); @@ -3934,16 +3878,16 @@ private void SelectLine (int line, bool triggerSyncCall, bool shouldScroll) } // Prevent ArgumentOutOfRangeException - if (line >= dataGridView.Rows.GetRowCount(DataGridViewElementStates.None)) + if (lineNum >= dataGridView.Rows.GetRowCount(DataGridViewElementStates.None)) { - line = dataGridView.Rows.GetRowCount(DataGridViewElementStates.None) - 1; + lineNum = dataGridView.Rows.GetRowCount(DataGridViewElementStates.None) - 1; } - dataGridView.Rows[line].Selected = true; + dataGridView.Rows[lineNum].Selected = true; if (shouldScroll) { - dataGridView.CurrentCell = dataGridView.Rows[line].Cells[0]; + dataGridView.CurrentCell = dataGridView.Rows[lineNum].Cells[0]; _ = dataGridView.Focus(); } } @@ -4738,12 +4682,7 @@ private bool IsFilterSearchDirty (FilterParams filterParams) return true; } - if (filterParams.IsCaseSensitive != filterCaseSensitiveCheckBox.Checked) - { - return true; - } - - return false; + return filterParams.IsCaseSensitive != filterCaseSensitiveCheckBox.Checked; } [SupportedOSPlatform("windows")] @@ -6380,14 +6319,19 @@ public IColumn GetCellValue (int rowIndex, int columnIndex) return Column.EmptyColumn; } - public void CellPainting (bool focused, int rowIndex, DataGridViewCellPaintingEventArgs e) + public void CellPainting (bool focused, int rowIndex, int columnIndex, bool isFilteredGridView, DataGridViewCellPaintingEventArgs e) { - if (rowIndex < 0 || e.ColumnIndex < 0) + if (rowIndex < 0 || columnIndex < 0 || (isFilteredGridView && _filterResultList.Count <= rowIndex)) { e.Handled = false; return; } + if (isFilteredGridView) + { + rowIndex = _filterResultList[rowIndex]; + } + var line = _logFileReader.GetLogLineWithWait(rowIndex).Result; if (line != null) @@ -6415,16 +6359,16 @@ public void CellPainting (bool focused, int rowIndex, DataGridViewCellPaintingEv PaintCell(e, entry); } - if (e.ColumnIndex == 0) + if (columnIndex == 0) { if (_bookmarkProvider.IsBookmarkAtLine(rowIndex)) { //keeping this comment, because it's the original code // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6); - var r = e.CellBounds; - r.Inflate(-2, -2); + var rect = e.CellBounds; + rect.Inflate(-2, -2); using var brush = new SolidBrush(BookmarkColor); - e.Graphics.FillRectangle(brush, r); + e.Graphics.FillRectangle(brush, rect); var bookmark = _bookmarkProvider.GetBookmarkForLine(rowIndex); @@ -6436,9 +6380,13 @@ public void CellPainting (bool focused, int rowIndex, DataGridViewCellPaintingEv Alignment = StringAlignment.Center }; + //Todo Add this as a Settings Option + var fontName = isFilteredGridView ? "Verdana" : "Courier New"; + var stringToDraw = isFilteredGridView ? "!" : "i"; + using var brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0)); //dark orange - using var font = new Font("Courier New", Preferences.FontSize, FontStyle.Bold); - e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format); + using var font = new Font(fontName, Preferences.FontSize, FontStyle.Bold); + e.Graphics.DrawString(stringToDraw, font, brush2, new RectangleF(rect.Left, rect.Top, rect.Width, rect.Height), format); } } } @@ -6451,7 +6399,7 @@ public void CellPainting (bool focused, int rowIndex, DataGridViewCellPaintingEv public void OnDataGridViewCellPainting (object sender, DataGridViewCellPaintingEventArgs e) { var gridView = (BufferedDataGridView)sender; - CellPainting(gridView.Focused, e.RowIndex, e); + CellPainting(gridView.Focused, e.RowIndex, e.ColumnIndex, false, e); } /// @@ -6570,7 +6518,8 @@ public void GotoLine (int line) { SelectLine(dataGridView.RowCount - 1, false, true); } - dataGridView.Focus(); + + _ = dataGridView.Focus(); } } @@ -7341,8 +7290,7 @@ public bool ScrollToTimestampWorker (DateTime timestamp, bool roundToSeconds, bo public int FindTimestampLine (int lineNum, DateTime timestamp, bool roundToSeconds) { - var foundLine = - FindTimestampLine_Internal(lineNum, 0, dataGridView.RowCount - 1, timestamp, roundToSeconds); + var foundLine = FindTimestampLineInternal(lineNum, 0, dataGridView.RowCount - 1, timestamp, roundToSeconds); if (foundLine >= 0) { // go backwards to the first occurence of the hit @@ -7365,10 +7313,9 @@ public int FindTimestampLine (int lineNum, DateTime timestamp, bool roundToSecon return -foundLine; } - public int FindTimestampLine_Internal (int lineNum, int rangeStart, int rangeEnd, DateTime timestamp, - bool roundToSeconds) + public int FindTimestampLineInternal (int lineNum, int rangeStart, int rangeEnd, DateTime timestamp, bool roundToSeconds) { - _logger.Debug("FindTimestampLine_Internal(): timestamp={0}, lineNum={1}, rangeStart={2}, rangeEnd={3}", timestamp, lineNum, rangeStart, rangeEnd); + _logger.Debug($"FindTimestampLine_Internal(): timestamp={timestamp}, lineNum={lineNum}, rangeStart={rangeStart}, rangeEnd={rangeEnd}"); var refLine = lineNum; var currentTimestamp = GetTimestampForLine(ref refLine, roundToSeconds); if (currentTimestamp.CompareTo(timestamp) == 0) @@ -7409,7 +7356,7 @@ public int FindTimestampLine_Internal (int lineNum, int rangeStart, int rangeEnd : -lineNum; } - return FindTimestampLine_Internal(lineNum, rangeStart, rangeEnd, timestamp, roundToSeconds); + return FindTimestampLineInternal(lineNum, rangeStart, rangeEnd, timestamp, roundToSeconds); } /** @@ -7461,7 +7408,7 @@ public DateTime GetTimestampForLine (ref int lineNum, bool roundToSeconds) lineNum++; } - _logger.Debug("GetTimestampForLine() leave with lineNum={0}", lineNum); + _logger.Debug($"GetTimestampForLine() leave with lineNum={lineNum}"); return timeStamp; } } @@ -7488,23 +7435,29 @@ public DateTime GetTimestampForLineForward (ref int lineNum, bool roundToSeconds { lookFwd = true; var logLine = _logFileReader.GetLogLine(lineNum); + if (logLine == null) { timeStamp = DateTime.MinValue; break; } + timeStamp = CurrentColumnizer.GetTimestamp(ColumnizerCallbackObject, logLine); + if (roundToSeconds) { timeStamp = timeStamp.Subtract(TimeSpan.FromMilliseconds(timeStamp.Millisecond)); } + lineNum++; } } + if (lookFwd) { lineNum--; } + return timeStamp; } } @@ -7521,48 +7474,31 @@ public void AppFocusGained () public ILogLine GetCurrentLine () { - if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index != -1) - { - return _logFileReader.GetLogLine(dataGridView.CurrentRow.Index); - } - return null; + return dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index != -1 + ? _logFileReader.GetLogLine(dataGridView.CurrentRow.Index) + : null; } public ILogLine GetLine (int lineNum) { - if (lineNum < 0 || _logFileReader == null || lineNum >= _logFileReader.LineCount) - { - return null; - } - return _logFileReader.GetLogLine(lineNum); - } - - public int GetCurrentLineNum () - { - if (dataGridView.CurrentRow == null) - { - return -1; - } - return dataGridView.CurrentRow.Index; + return lineNum < 0 || _logFileReader == null || lineNum >= _logFileReader.LineCount + ? null + : _logFileReader.GetLogLine(lineNum); } public int GetRealLineNum () { - var lineNum = GetCurrentLineNum(); - if (lineNum == -1) - { - return -1; - } - return _logFileReader.GetRealLineNumForVirtualLineNum(lineNum); + var lineNum = CurrentLineNum; + return lineNum == -1 + ? -1 + : _logFileReader.GetRealLineNumForVirtualLineNum(lineNum); } public ILogFileInfo GetCurrentFileInfo () { - if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index != -1) - { - return _logFileReader.GetLogFileInfoForLine(dataGridView.CurrentRow.Index); - } - return null; + return dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index != -1 + ? _logFileReader.GetLogFileInfoForLine(dataGridView.CurrentRow.Index) + : null; } /// diff --git a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs index 94b5c5c4..7e784b6d 100644 --- a/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/PatternWindow.cs @@ -245,7 +245,7 @@ private void OnPatternHitsDataGridViewCellPainting (object sender, DataGridViewC { var gridView = (BufferedDataGridView)sender; var rowIndex = GetLineForHitGrid(e.RowIndex); - _logWindow.CellPainting(gridView.Focused, rowIndex, e); + _logWindow.CellPainting(gridView.Focused, rowIndex, e.ColumnIndex, false, e); } } @@ -314,7 +314,7 @@ private void OnContentDataGridViewCellPainting (object sender, DataGridViewCellP var gridView = (BufferedDataGridView)sender; var rowIndex = GetLineForContentGrid(e.RowIndex); - _logWindow.CellPainting(gridView.Focused, rowIndex, e); + _logWindow.CellPainting(gridView.Focused, rowIndex, e.ColumnIndex, false, e); } private void OnContentDataGridViewCellMouseDoubleClick (object sender, DataGridViewCellMouseEventArgs e) diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs index 9c91fce3..ab326b5d 100644 --- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs +++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs @@ -306,7 +306,7 @@ private void DoCalc_via_Time () while (searchTimeStamp.CompareTo(_endTimestamp) <= 0) { - lineNum = _logWindow.FindTimestampLine_Internal(lineNum, lineNum, lastLineNum, searchTimeStamp, false); + lineNum = _logWindow.FindTimestampLineInternal(lineNum, lineNum, lastLineNum, searchTimeStamp, false); if (lineNum < 0) { lineNum = -lineNum; diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs index a78c6c49..6b08cef7 100644 --- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs +++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs @@ -324,10 +324,10 @@ private void OnBoomarkDataGridViewCellPainting (object sender, DataGridViewCellP // { // CommentPainting(this.bookmarkDataGridView, lineNum, e); // } - { - // else - PaintHelper.CellPainting(_logPaintContext, bookmarkDataGridView, lineNum, e); - } + //{ + // else + PaintHelper.CellPainting(_logPaintContext, bookmarkDataGridView.Focused, lineNum, e.ColumnIndex, e); + //} } catch (Exception ex) { diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs index b27cd020..1d305985 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs @@ -2108,7 +2108,7 @@ private void OnSelectFilterToolStripMenuItemClick (object sender, EventArgs e) return; } - CurrentLogWindow.ColumnizerCallbackObject.LineNum = CurrentLogWindow.GetCurrentLineNum(); + CurrentLogWindow.ColumnizerCallbackObject.LineNum = CurrentLogWindow.CurrentLineNum; FilterSelectorForm form = new(PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers, CurrentLogWindow.CurrentColumnizer, CurrentLogWindow.ColumnizerCallbackObject, ConfigManager) { Owner = this, diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index acefeab5..d3d67ba9 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -22,9 +22,9 @@ internal static class PaintHelper #region Public methods [SupportedOSPlatform("windows")] - public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e) + public static void CellPainting (ILogPaintContextUI logPaintCtx, bool focused, int rowIndex, int columnIndex, DataGridViewCellPaintingEventArgs e) { - if (rowIndex < 0 || e.ColumnIndex < 0) + if (rowIndex < 0 || columnIndex < 0) { e.Handled = false; return; @@ -39,7 +39,7 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri if (e.State.HasFlag(DataGridViewElementStates.Selected)) { - using var brush = GetBrushForFocusedControl(gridView.Focused, e.CellStyle.SelectionBackColor); + using var brush = GetBrushForFocusedControl(focused, e.CellStyle.SelectionBackColor); e.Graphics.FillRectangle(brush, e.CellBounds); } else @@ -54,7 +54,7 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri } else { - PaintCell(logPaintCtx, e, gridView, false, entry); + PaintCell(logPaintCtx, e, entry); } if (e.ColumnIndex == 0) @@ -358,13 +358,13 @@ public static Rectangle BorderWidths (DataGridViewAdvancedBorderStyle advancedBo #region Private Methods [SupportedOSPlatform("windows")] - private static void PaintCell (ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) + private static void PaintCell (ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, HighlightEntry groundEntry) { - PaintHighlightedCell(logPaintCtx, e, gridView, noBackgroundFill, groundEntry); + PaintHighlightedCell(logPaintCtx, e, groundEntry); } [SupportedOSPlatform("windows")] - private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) + private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, HighlightEntry groundEntry) { var value = e.Value ?? string.Empty; @@ -463,9 +463,9 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr Rectangle wordRect = new(wordPos, wordSize); var foreColor = matchEntry.HighlightEntry.ForegroundColor; - if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected) + if (!e.State.HasFlag(DataGridViewElementStates.Selected)) { - if (!noBackgroundFill && bgBrush != null && !matchEntry.HighlightEntry.NoBackground) + if (bgBrush != null && !matchEntry.HighlightEntry.NoBackground) { e.Graphics.FillRectangle(bgBrush, wordRect); } @@ -479,7 +479,6 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr } TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, foreColor, flags); - wordPos.Offset(wordSize.Width, 0); } } From c783fef5e5860637e08d56661e493f31f9776dea Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Mon, 23 Jun 2025 16:44:53 +0200 Subject: [PATCH 120/142] Update src/LogExpert.UI/Entities/PaintHelper.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/LogExpert.UI/Entities/PaintHelper.cs | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index d3d67ba9..46382a8a 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -90,24 +90,7 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, bool focused, i public static Color GetBackColorFromHighlightEntry (HighlightEntry? entry) { - var bgColor = Color.White; - - if (!DebugOptions.DisableWordHighlight) - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - else - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - - return bgColor; + return entry?.BackgroundColor ?? Color.White; } [SupportedOSPlatform("windows")] From d8d78277a74a4608777560436c762cc46bf347a4 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Mon, 23 Jun 2025 17:10:31 +0200 Subject: [PATCH 121/142] updating nuget packages --- src/Directory.Packages.props | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 4fff1524..40ab2a8c 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -6,7 +6,7 @@ - + @@ -16,20 +16,20 @@ - + - + - + - - + + \ No newline at end of file From 1739f759382fcf3c347100a4c0ad9737d5a3da0d Mon Sep 17 00:00:00 2001 From: Hirogen Date: Mon, 23 Jun 2025 17:12:08 +0200 Subject: [PATCH 122/142] update nuget and .net SDK version --- build/_build.csproj | 6 +++--- global.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/_build.csproj b/build/_build.csproj index d024e268..d5eadde9 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -11,14 +11,14 @@ - - + + all runtime; build; native; contentfiles; analyzers - + diff --git a/global.json b/global.json index b6b5c9f5..2808b362 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "9.0.101" + "version": "9.0.301" } } From 5c05a5084a0e0ac3c89830e2a1f1862ca1bde024 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Wed, 25 Jun 2025 17:03:20 +0200 Subject: [PATCH 123/142] review comments --- src/ColumnizerLib/ITextValue.cs | 2 +- .../Controls/LogWindow/LogWindow.cs | 22 ++--- .../Dialogs/LogTabWindow/HighlightDialog.cs | 20 +++-- src/LogExpert.UI/Entities/PaintHelper.cs | 90 +++++-------------- 4 files changed, 45 insertions(+), 89 deletions(-) diff --git a/src/ColumnizerLib/ITextValue.cs b/src/ColumnizerLib/ITextValue.cs index 80b36fe9..b072fb91 100644 --- a/src/ColumnizerLib/ITextValue.cs +++ b/src/ColumnizerLib/ITextValue.cs @@ -1,4 +1,4 @@ -namespace LogExpert; +namespace LogExpert; public interface ITextValue { diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index 5496ffcc..0c8488a3 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -2267,7 +2267,6 @@ private void MeasureItem (object sender, MeasureItemEventArgs e) [SupportedOSPlatform("windows")] private void CreateDefaultViewStyle () { - dataGridView.DefaultCellStyle = PaintHelper.GetDataGridViewCellStyle(); filterGridView.DefaultCellStyle = PaintHelper.GetDataGridViewCellStyle(); dataGridView.RowsDefaultCellStyle = PaintHelper.GetDataGridDefaultRowStyle(); @@ -3206,14 +3205,9 @@ private void SetColumnizerInternal (ILogLineColumnizer columnizer) if (_logFileReader != null) { - if (CurrentColumnizer is IPreProcessColumnizer columnizer1) - { - _logFileReader.PreProcessColumnizer = columnizer1; - } - else - { - _logFileReader.PreProcessColumnizer = null; - } + _logFileReader.PreProcessColumnizer = CurrentColumnizer is IPreProcessColumnizer columnizer1 + ? columnizer1 + : null; } // always reload when choosing XML columnizers @@ -3413,18 +3407,18 @@ private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, Highligh Rectangle wordRect = new(wordPos, wordSize); var foreColor = matchEntry.HighlightEntry.ForegroundColor; - if (!e.State.HasFlag(DataGridViewElementStates.Selected)) + if (e.State.HasFlag(DataGridViewElementStates.Selected)) { - if (bgBrush != null && !matchEntry.HighlightEntry.NoBackground) + if (foreColor.Equals(Color.Black)) { - e.Graphics.FillRectangle(bgBrush, wordRect); + foreColor = Color.White; } } else { - if (foreColor.Equals(Color.Black)) + if (bgBrush != null && !matchEntry.HighlightEntry.NoBackground) { - foreColor = Color.White; + e.Graphics.FillRectangle(bgBrush, wordRect); } } diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs index adadc7da..d772f4da 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/HighlightDialog.cs @@ -413,17 +413,23 @@ private void OnHighlightListBoxDrawItem (object sender, DrawItemEventArgs e) var entry = (HighlightEntry)listBoxHighlight.Items[e.Index]; Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); - var selected = e.State.HasFlag(DrawItemState.Selected); - var forgroundColor = selected - ? PaintHelper.GetForeColorBasedOnBackColor(entry.ForegroundColor) - : entry.ForegroundColor; + SolidBrush foregroundBrush; - if (!selected) + if (e.State.HasFlag(DrawItemState.Selected)) { - e.Graphics.FillRectangle(new SolidBrush(entry.BackgroundColor), rectangle); + foregroundBrush = new SolidBrush(PaintHelper.GetForeColorBasedOnBackColor(entry.ForegroundColor)); + } + else + { + using var backgroundBrush = new SolidBrush(entry.BackgroundColor); + e.Graphics.FillRectangle(backgroundBrush, rectangle); + foregroundBrush = new SolidBrush(entry.ForegroundColor); } - e.Graphics.DrawString(entry.SearchText, e.Font, new SolidBrush(forgroundColor), new PointF(rectangle.Left, rectangle.Top)); + using (foregroundBrush) + { + e.Graphics.DrawString(entry.SearchText, e.Font, foregroundBrush, new PointF(rectangle.Left, rectangle.Top)); + } e.DrawFocusRectangle(); } diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index acefeab5..ed0c2283 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -90,24 +90,7 @@ public static void CellPainting (ILogPaintContextUI logPaintCtx, BufferedDataGri public static Color GetBackColorFromHighlightEntry (HighlightEntry? entry) { - var bgColor = Color.White; - - if (!DebugOptions.DisableWordHighlight) - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - else - { - if (entry != null) - { - bgColor = entry.BackgroundColor; - } - } - - return bgColor; + return entry?.BackgroundColor ?? Color.White; } [SupportedOSPlatform("windows")] @@ -305,52 +288,24 @@ public static void ApplyDataGridViewPrefs (BufferedDataGridView dataGridView, bo } [SupportedOSPlatform("windows")] - public static Rectangle BorderWidths (DataGridViewAdvancedBorderStyle advancedBorderStyle) + public static Rectangle BorderWidths (DataGridViewAdvancedBorderStyle style) { - Rectangle rect = new() - { - X = advancedBorderStyle.Left == DataGridViewAdvancedCellBorderStyle.None - ? 0 - : 1 - }; - - if (advancedBorderStyle.Left is DataGridViewAdvancedCellBorderStyle.OutsetDouble or DataGridViewAdvancedCellBorderStyle.InsetDouble) - { - rect.X++; - } - - rect.Y = advancedBorderStyle.Top == DataGridViewAdvancedCellBorderStyle.None - ? 0 - : 1; - - if (advancedBorderStyle.Top is DataGridViewAdvancedCellBorderStyle.OutsetDouble or DataGridViewAdvancedCellBorderStyle.InsetDouble) - { - rect.Y++; - } - - rect.Width = advancedBorderStyle.Right == DataGridViewAdvancedCellBorderStyle.None - ? 0 - : 1; - - if (advancedBorderStyle.Right is DataGridViewAdvancedCellBorderStyle.OutsetDouble or DataGridViewAdvancedCellBorderStyle.InsetDouble) - { - rect.Width++; - } - - rect.Height = advancedBorderStyle.Bottom == DataGridViewAdvancedCellBorderStyle.None - ? 0 - : 1; + return new Rectangle( + GetBorderSize(style.Left), + GetBorderSize(style.Top), + GetBorderSize(style.Right), + GetBorderSize(style.Bottom)); + } - if (advancedBorderStyle.Bottom is DataGridViewAdvancedCellBorderStyle.OutsetDouble or - DataGridViewAdvancedCellBorderStyle.InsetDouble) + [SupportedOSPlatform("windows")] + private static int GetBorderSize (DataGridViewAdvancedCellBorderStyle borderStyle) + { + return borderStyle switch { - rect.Height++; - } - - //rect.Width += this.owningColumn.DividerWidth; - //rect.Height += this.owningRow.DividerHeight; - - return rect; + DataGridViewAdvancedCellBorderStyle.None => 0, + DataGridViewAdvancedCellBorderStyle.InsetDouble or DataGridViewAdvancedCellBorderStyle.OutsetDouble => 2, + _ => 1 + }; } #endregion @@ -366,9 +321,10 @@ private static void PaintCell (ILogPaintContextUI logPaintCtx, DataGridViewCellP [SupportedOSPlatform("windows")] private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry) { + //TODO Refactor if possible since Column is ITextValue var value = e.Value ?? string.Empty; - var matchList = logPaintCtx.FindHighlightMatches(value as ILogLine); + var matchList = logPaintCtx.FindHighlightMatches(value as ITextValue); // too many entries per line seem to cause problems with the GDI while (matchList.Count > 50) { @@ -463,18 +419,18 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr Rectangle wordRect = new(wordPos, wordSize); var foreColor = matchEntry.HighlightEntry.ForegroundColor; - if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected) + if (e.State.HasFlag(DataGridViewElementStates.Selected)) { - if (!noBackgroundFill && bgBrush != null && !matchEntry.HighlightEntry.NoBackground) + if (foreColor.Equals(Color.Black)) { - e.Graphics.FillRectangle(bgBrush, wordRect); + foreColor = Color.White; } } else { - if (foreColor.Equals(Color.Black)) + if (!noBackgroundFill && bgBrush != null && !matchEntry.HighlightEntry.NoBackground) { - foreColor = Color.White; + e.Graphics.FillRectangle(bgBrush, wordRect); } } From e71f7a0eb7983212cb0ec32254a5e4f83398a6f4 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Thu, 26 Jun 2025 11:25:05 +0200 Subject: [PATCH 124/142] only top level packages --- src/Directory.Packages.props | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 40ab2a8c..d357ea89 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -5,31 +5,22 @@ $(NoWarn);NU1507 - + - - - - - - - - + - - + + - + - - \ No newline at end of file From f3a94e9537529a3592fbb4e2efb8e6ba82ca4134 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Thu, 26 Jun 2025 14:47:53 +0200 Subject: [PATCH 125/142] added todo --- src/LogExpert.UI/Entities/PaintHelper.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/LogExpert.UI/Entities/PaintHelper.cs b/src/LogExpert.UI/Entities/PaintHelper.cs index d4b660a1..b58b26a4 100644 --- a/src/LogExpert.UI/Entities/PaintHelper.cs +++ b/src/LogExpert.UI/Entities/PaintHelper.cs @@ -229,6 +229,7 @@ public static Color GetForeColorBasedOnBackColor (Color backColor) return isSelectionBackColorDark ? Color.White : Color.Black; } + //TODO Make this configurable => this should close https://github.com/LogExperts/LogExpert/issues/85 [SupportedOSPlatform("windows")] public static DataGridViewCellStyle GetDataGridViewCellStyle () { @@ -244,6 +245,7 @@ public static DataGridViewCellStyle GetDataGridViewCellStyle () }; } + //TODO Make this configurable => this should close https://github.com/LogExperts/LogExpert/issues/85 [SupportedOSPlatform("windows")] public static DataGridViewCellStyle GetDataGridDefaultRowStyle () { @@ -321,7 +323,7 @@ private static void PaintCell (ILogPaintContextUI logPaintCtx, DataGridViewCellP [SupportedOSPlatform("windows")] private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, HighlightEntry groundEntry) { - //TODO Refactor if possible since Column is ITextValue + //TODO Refactor if possible since Column is ITextValue var value = e.Value ?? string.Empty; var matchList = logPaintCtx.FindHighlightMatches(value as ITextValue); @@ -428,7 +430,7 @@ private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGr } else { - if (bgBrush != null && !matchEntry.HighlightEntry.NoBackground) + if (bgBrush != null && !matchEntry.HighlightEntry.NoBackground) { e.Graphics.FillRectangle(bgBrush, wordRect); } From 26d0507caab307c2a453426e3c5334347250fcb8 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Fri, 4 Jul 2025 09:37:43 +0200 Subject: [PATCH 126/142] version for nuget packages and chocolatley --- README.md | 8 ++++---- chocolatey/logexpert.portable.nuspec.template | 17 ++++++++++------- src/ColumnizerLib/ColumnizerLib.nuspec | 11 ++++++----- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 602c4873..8821a046 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Summary of (most) features: * Portable (all options / settings saved in application startup directory) # Download -Follow the [Link](https://github.com/zarunbal/LogExpert/releases/latest) and download the latest package. Just extract it where you want and execute the application or download the Setup and install it +Follow the [Link](https://github.com/LogExperts/LogExpert/releases/latest) and download the latest package. Just extract it where you want and execute the application or download the Setup and install it Or Install via chocolatey @@ -62,7 +62,7 @@ Please checkout the wiki for FAQ / HELP / Informations / Examples - dont use AutoScaleMode for single GUI controls like Buttons etc. - dont use AutoScaleDimensions for single GUI controls like Buttons etc. -https://github.com/zarunbal/LogExpert/wiki +https://github.com/LogExperts/LogExpert/wiki # Discord Server https://discord.gg/SjxkuckRe9 @@ -71,8 +71,8 @@ https://discord.gg/SjxkuckRe9 ### Contributors This project exists thanks to all the people who contribute. - - + + Made with [contrib.rocks](https://contrib.rocks). diff --git a/chocolatey/logexpert.portable.nuspec.template b/chocolatey/logexpert.portable.nuspec.template index 37d36655..76aacacf 100644 --- a/chocolatey/logexpert.portable.nuspec.template +++ b/chocolatey/logexpert.portable.nuspec.template @@ -4,13 +4,13 @@ logexpert ##version## LogExpert - Zarunbal Previous:Hagen Raab - Zarunbal - https://cdn.rawgit.com/zarunbal/LogExpert/v##version##/LICENSE - https://github.com/zarunbal/LogExpert/tree/master/chocolatey - https://github.com/zarunbal/LogExpert - https://github.com/zarunbal/LogExpert/issues - https://github.com/zarunbal/LogExpert/releases/tag/v##version## + Zarunbal, Hagen Raab, Hirogen, RandallFlagg and others + Zarunbal, Hirogen + https://cdn.rawgit.com/LogExperts/LogExpert/v##version##/LICENSE + https://github.com/LogExperts/LogExpert/tree/master/chocolatey + https://github.com/LogExperts/LogExpert/ + https://github.com/LogExperts/LogExpert//issues + https://github.com/LogExperts/LogExpert//releases/tag/v##version## false LogExpert is a Windows tail program (a GUI replacement for the Unix tail command). @@ -37,6 +37,9 @@ Summary of (most) features: LogExpert is log file viewing for the Pros. Original work Copyright (c) 2011 Hagen Raab, Modified work Copyright (c) 2017 Zarunbal LogExpert windows tail logging viewer troubleshooting + + + diff --git a/src/ColumnizerLib/ColumnizerLib.nuspec b/src/ColumnizerLib/ColumnizerLib.nuspec index 99e650fe..1bb86a32 100644 --- a/src/ColumnizerLib/ColumnizerLib.nuspec +++ b/src/ColumnizerLib/ColumnizerLib.nuspec @@ -4,13 +4,14 @@ LogExpert.ColumnizerLib $version$ LogExpert ColumnizerLib - Zarunbal Previous:Hagen Raab - Zarunbal - MIT - https://github.com/zarunbal/LogExpert + Zarunbal, Hagen Raab, Hirogen, RandallFlagg and others + Zarunbal, Hirogen + https://cdn.rawgit.com/LogExperts/LogExpert/v##version##/LICENSE + https://github.com/Logexperts/LogExpert false + https://github.com/LogExperts/LogExpert//issues + https://github.com/LogExperts/LogExpert//releases/tag/v##version## Columnizer Lib for Logexpert plugins - See https://github.com/zarunbal/LogExpert/releases/tag/v$version$ Copyright 2025 LogExpert Columnizer From d1ceb7a76d27408ac0e4c92cc52c3a2bb6691ad2 Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Fri, 4 Jul 2025 09:45:27 +0200 Subject: [PATCH 127/142] Update src/ColumnizerLib/ColumnizerLib.nuspec Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/ColumnizerLib/ColumnizerLib.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ColumnizerLib/ColumnizerLib.nuspec b/src/ColumnizerLib/ColumnizerLib.nuspec index 1bb86a32..13e281e6 100644 --- a/src/ColumnizerLib/ColumnizerLib.nuspec +++ b/src/ColumnizerLib/ColumnizerLib.nuspec @@ -9,7 +9,7 @@ https://cdn.rawgit.com/LogExperts/LogExpert/v##version##/LICENSE https://github.com/Logexperts/LogExpert false - https://github.com/LogExperts/LogExpert//issues + https://github.com/LogExperts/LogExpert/issues https://github.com/LogExperts/LogExpert//releases/tag/v##version## Columnizer Lib for Logexpert plugins Copyright 2025 From 0dc319040769d9e71de827a2f71ad7829eabcec5 Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Fri, 4 Jul 2025 09:45:38 +0200 Subject: [PATCH 128/142] Update chocolatey/logexpert.portable.nuspec.template Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- chocolatey/logexpert.portable.nuspec.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chocolatey/logexpert.portable.nuspec.template b/chocolatey/logexpert.portable.nuspec.template index 76aacacf..487f25ee 100644 --- a/chocolatey/logexpert.portable.nuspec.template +++ b/chocolatey/logexpert.portable.nuspec.template @@ -9,7 +9,7 @@ https://cdn.rawgit.com/LogExperts/LogExpert/v##version##/LICENSE https://github.com/LogExperts/LogExpert/tree/master/chocolatey https://github.com/LogExperts/LogExpert/ - https://github.com/LogExperts/LogExpert//issues + https://github.com/LogExperts/LogExpert/issues https://github.com/LogExperts/LogExpert//releases/tag/v##version## false LogExpert is a Windows tail program (a GUI replacement for the Unix tail command). From 15b4879c3752b9822cd78c81a454aea748b83882 Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Fri, 4 Jul 2025 09:45:46 +0200 Subject: [PATCH 129/142] Update chocolatey/logexpert.portable.nuspec.template Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- chocolatey/logexpert.portable.nuspec.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chocolatey/logexpert.portable.nuspec.template b/chocolatey/logexpert.portable.nuspec.template index 487f25ee..e708a483 100644 --- a/chocolatey/logexpert.portable.nuspec.template +++ b/chocolatey/logexpert.portable.nuspec.template @@ -10,7 +10,7 @@ https://github.com/LogExperts/LogExpert/tree/master/chocolatey https://github.com/LogExperts/LogExpert/ https://github.com/LogExperts/LogExpert/issues - https://github.com/LogExperts/LogExpert//releases/tag/v##version## + https://github.com/LogExperts/LogExpert/releases/tag/v##version## false LogExpert is a Windows tail program (a GUI replacement for the Unix tail command). From f0709a461cc1e75c27c85cc576178c4194ee31b4 Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Fri, 4 Jul 2025 09:50:32 +0200 Subject: [PATCH 130/142] Update src/ColumnizerLib/ColumnizerLib.nuspec Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/ColumnizerLib/ColumnizerLib.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ColumnizerLib/ColumnizerLib.nuspec b/src/ColumnizerLib/ColumnizerLib.nuspec index 13e281e6..224622b4 100644 --- a/src/ColumnizerLib/ColumnizerLib.nuspec +++ b/src/ColumnizerLib/ColumnizerLib.nuspec @@ -6,7 +6,7 @@ LogExpert ColumnizerLib Zarunbal, Hagen Raab, Hirogen, RandallFlagg and others Zarunbal, Hirogen - https://cdn.rawgit.com/LogExperts/LogExpert/v##version##/LICENSE + https://raw.githubusercontent.com/LogExperts/LogExpert/v##version##/LICENSE https://github.com/Logexperts/LogExpert false https://github.com/LogExperts/LogExpert/issues From 00ad4b5c54399b55e48e6accf4e0232d859bdb32 Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Fri, 4 Jul 2025 09:50:51 +0200 Subject: [PATCH 131/142] Update src/ColumnizerLib/ColumnizerLib.nuspec Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/ColumnizerLib/ColumnizerLib.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ColumnizerLib/ColumnizerLib.nuspec b/src/ColumnizerLib/ColumnizerLib.nuspec index 224622b4..ba4c5ed9 100644 --- a/src/ColumnizerLib/ColumnizerLib.nuspec +++ b/src/ColumnizerLib/ColumnizerLib.nuspec @@ -7,7 +7,7 @@ Zarunbal, Hagen Raab, Hirogen, RandallFlagg and others Zarunbal, Hirogen https://raw.githubusercontent.com/LogExperts/LogExpert/v##version##/LICENSE - https://github.com/Logexperts/LogExpert + https://github.com/LogExperts/LogExpert false https://github.com/LogExperts/LogExpert/issues https://github.com/LogExperts/LogExpert//releases/tag/v##version## From 78ced91ae5b303b11c240615c39e463bafe6ed76 Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Fri, 4 Jul 2025 09:51:00 +0200 Subject: [PATCH 132/142] Update src/ColumnizerLib/ColumnizerLib.nuspec Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/ColumnizerLib/ColumnizerLib.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ColumnizerLib/ColumnizerLib.nuspec b/src/ColumnizerLib/ColumnizerLib.nuspec index ba4c5ed9..5acba82a 100644 --- a/src/ColumnizerLib/ColumnizerLib.nuspec +++ b/src/ColumnizerLib/ColumnizerLib.nuspec @@ -10,7 +10,7 @@ https://github.com/LogExperts/LogExpert false https://github.com/LogExperts/LogExpert/issues - https://github.com/LogExperts/LogExpert//releases/tag/v##version## + https://github.com/LogExperts/LogExpert/releases/tag/v##version## Columnizer Lib for Logexpert plugins Copyright 2025 LogExpert Columnizer From 414efea592def6687da939f59e627b6d502fc999 Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Fri, 4 Jul 2025 09:51:06 +0200 Subject: [PATCH 133/142] Update chocolatey/logexpert.portable.nuspec.template Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- chocolatey/logexpert.portable.nuspec.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chocolatey/logexpert.portable.nuspec.template b/chocolatey/logexpert.portable.nuspec.template index e708a483..98f9c7d4 100644 --- a/chocolatey/logexpert.portable.nuspec.template +++ b/chocolatey/logexpert.portable.nuspec.template @@ -6,7 +6,7 @@ LogExpert Zarunbal, Hagen Raab, Hirogen, RandallFlagg and others Zarunbal, Hirogen - https://cdn.rawgit.com/LogExperts/LogExpert/v##version##/LICENSE + https://raw.githubusercontent.com/LogExperts/LogExpert/v##version##/LICENSE https://github.com/LogExperts/LogExpert/tree/master/chocolatey https://github.com/LogExperts/LogExpert/ https://github.com/LogExperts/LogExpert/issues From 6f6be24d51e19adddf2177de753daf9e6b5acfda Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Fri, 4 Jul 2025 10:02:00 +0200 Subject: [PATCH 134/142] Update chocolatey/logexpert.portable.nuspec.template Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- chocolatey/logexpert.portable.nuspec.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chocolatey/logexpert.portable.nuspec.template b/chocolatey/logexpert.portable.nuspec.template index 98f9c7d4..de0df86d 100644 --- a/chocolatey/logexpert.portable.nuspec.template +++ b/chocolatey/logexpert.portable.nuspec.template @@ -8,7 +8,7 @@ Zarunbal, Hirogen https://raw.githubusercontent.com/LogExperts/LogExpert/v##version##/LICENSE https://github.com/LogExperts/LogExpert/tree/master/chocolatey - https://github.com/LogExperts/LogExpert/ + https://github.com/LogExperts/LogExpert https://github.com/LogExperts/LogExpert/issues https://github.com/LogExperts/LogExpert/releases/tag/v##version## false From 10a8c1c54b75850e0875e416c100f517298f93c2 Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Fri, 4 Jul 2025 10:07:14 +0200 Subject: [PATCH 135/142] Update src/ColumnizerLib/ColumnizerLib.nuspec Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/ColumnizerLib/ColumnizerLib.nuspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ColumnizerLib/ColumnizerLib.nuspec b/src/ColumnizerLib/ColumnizerLib.nuspec index 5acba82a..dccbf314 100644 --- a/src/ColumnizerLib/ColumnizerLib.nuspec +++ b/src/ColumnizerLib/ColumnizerLib.nuspec @@ -6,11 +6,11 @@ LogExpert ColumnizerLib Zarunbal, Hagen Raab, Hirogen, RandallFlagg and others Zarunbal, Hirogen - https://raw.githubusercontent.com/LogExperts/LogExpert/v##version##/LICENSE + https://raw.githubusercontent.com/LogExperts/LogExpert/v$version$/LICENSE https://github.com/LogExperts/LogExpert false https://github.com/LogExperts/LogExpert/issues - https://github.com/LogExperts/LogExpert/releases/tag/v##version## + https://github.com/LogExperts/LogExpert/releases/tag/v$version$ Columnizer Lib for Logexpert plugins Copyright 2025 LogExpert Columnizer From 004d7d2fafb37e7e463bb6178fb81b7de66126a0 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Fri, 4 Jul 2025 10:12:38 +0200 Subject: [PATCH 136/142] nuspec --- src/ColumnizerLib/ColumnizerLib.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ColumnizerLib/ColumnizerLib.nuspec b/src/ColumnizerLib/ColumnizerLib.nuspec index dccbf314..0a242fbf 100644 --- a/src/ColumnizerLib/ColumnizerLib.nuspec +++ b/src/ColumnizerLib/ColumnizerLib.nuspec @@ -6,7 +6,7 @@ LogExpert ColumnizerLib Zarunbal, Hagen Raab, Hirogen, RandallFlagg and others Zarunbal, Hirogen - https://raw.githubusercontent.com/LogExperts/LogExpert/v$version$/LICENSE + MIT https://github.com/LogExperts/LogExpert false https://github.com/LogExperts/LogExpert/issues From 130492ad3118884a2a6b2968ac0f933488a2db19 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Fri, 4 Jul 2025 13:00:32 +0200 Subject: [PATCH 137/142] ssh works again, removed no longer used files --- .../Classes/Log/LogfileReader.cs | 124 +++++----- .../Classes/Log/RolloverFilenameBuilder.cs | 3 +- .../Interface/IConfigManager.cs | 22 +- src/LogExpert.Tests/BufferShiftTest.cs | 17 +- src/LogExpert.Tests/CSVColumnizerTest.cs | 9 +- src/LogExpert.Tests/ColumnizerPickerTest.cs | 17 +- src/LogExpert.Tests/JsonColumnizerTest.cs | 9 +- .../JsonCompactColumnizerTest.cs | 10 +- .../RolloverHandlerTestBase.cs | 7 +- .../SquareBracketColumnizerTest.cs | 10 +- .../Controls/LogWindow/LogWindow.cs | 20 +- .../Dialogs/LogTabWindow/LogTabWindow.cs | 3 +- src/SftpFileSystemx64/CredentialCache.cs | 14 +- src/SftpFileSystemx64/Credentials.cs | 26 +- src/SftpFileSystemx64/SftpFileSystem.cs | 10 +- .../SftpFileSystemSSHDotNET.cs | 225 ----------------- .../SftpFileSystemx64.csproj | 9 +- src/SftpFileSystemx64/SftpLogFileInfo.cs | 50 ++-- .../SftpLogFileInfoSSHDotNET.cs | 231 ------------------ .../SftpLogFileInfoSharpSSH.cs | 139 ----------- src/SftpFileSystemx64/SftpStreamSharpSSH.cs | 104 -------- src/SftpFileSystemx64/SharpSshUserInfo.cs | 51 ---- .../SftpFileSystemx86.csproj | 7 +- src/Solution Items/AssemblyInfo.cs | 6 +- 24 files changed, 163 insertions(+), 960 deletions(-) delete mode 100644 src/SftpFileSystemx64/SftpFileSystemSSHDotNET.cs delete mode 100644 src/SftpFileSystemx64/SftpLogFileInfoSSHDotNET.cs delete mode 100644 src/SftpFileSystemx64/SftpLogFileInfoSharpSSH.cs delete mode 100644 src/SftpFileSystemx64/SftpStreamSharpSSH.cs delete mode 100644 src/SftpFileSystemx64/SharpSshUserInfo.cs diff --git a/src/LogExpert.Core/Classes/Log/LogfileReader.cs b/src/LogExpert.Core/Classes/Log/LogfileReader.cs index d7f887a4..424e1c34 100644 --- a/src/LogExpert.Core/Classes/Log/LogfileReader.cs +++ b/src/LogExpert.Core/Classes/Log/LogfileReader.cs @@ -154,7 +154,7 @@ public int LineCount { _currLineCount = 0; AcquireBufferListReaderLock(); - foreach (LogBuffer buffer in _bufferList) + foreach (var buffer in _bufferList) { _currLineCount += buffer.LineCount; } @@ -218,7 +218,7 @@ public void ReadFiles () ReleaseBufferListWriterLock(); try { - foreach (ILogFileInfo info in _logFileInfoList) + foreach (var info in _logFileInfoList) { //info.OpenFile(); ReadToBufferList(info, 0, LineCount); @@ -226,7 +226,7 @@ public void ReadFiles () if (_logFileInfoList.Count > 0) { - ILogFileInfo info = _logFileInfoList[_logFileInfoList.Count - 1]; + var info = _logFileInfoList[_logFileInfoList.Count - 1]; _fileLength = info.Length; _watchedILogFileInfo = info; } @@ -263,19 +263,19 @@ public int ShiftBuffers () lock (_monitor) { RolloverFilenameHandler rolloverHandler = new(_watchedILogFileInfo, _multiFileOptions); - LinkedList fileNameList = rolloverHandler.GetNameList(_pluginRegistry); + var fileNameList = rolloverHandler.GetNameList(_pluginRegistry); ResetBufferCache(); IList lostILogFileInfoList = []; IList readNewILogFileInfoList = []; IList newFileInfoList = []; - IEnumerator enumerator = _logFileInfoList.GetEnumerator(); + var enumerator = _logFileInfoList.GetEnumerator(); while (enumerator.MoveNext()) { - ILogFileInfo logFileInfo = enumerator.Current; + var logFileInfo = enumerator.Current; var fileName = logFileInfo.FullName; _logger.Debug(CultureInfo.InvariantCulture, "Testing file {0}", fileName); - LinkedListNode node = fileNameList.Find(fileName); + var node = fileNameList.Find(fileName); if (node == null) { _logger.Warn(CultureInfo.InvariantCulture, "File {0} not found", fileName); @@ -285,7 +285,7 @@ public int ShiftBuffers () if (node.Previous != null) { fileName = node.Previous.Value; - ILogFileInfo newILogFileInfo = GetLogFileInfo(fileName); + var newILogFileInfo = GetLogFileInfo(fileName); _logger.Debug(CultureInfo.InvariantCulture, "{0} exists\r\nOld size={1}, new size={2}", fileName, logFileInfo.OriginalLength, newILogFileInfo.Length); // is the new file the same as the old buffer info? if (newILogFileInfo.Length == logFileInfo.OriginalLength) @@ -335,10 +335,10 @@ public int ShiftBuffers () if (lostILogFileInfoList.Count > 0) { _logger.Info(CultureInfo.InvariantCulture, "Deleting buffers for lost files"); - foreach (ILogFileInfo ILogFileInfo in lostILogFileInfoList) + foreach (var ILogFileInfo in lostILogFileInfoList) { //this.ILogFileInfoList.Remove(ILogFileInfo); - LogBuffer lastBuffer = DeleteBuffersForInfo(ILogFileInfo, false); + var lastBuffer = DeleteBuffersForInfo(ILogFileInfo, false); if (lastBuffer != null) { offset += lastBuffer.StartLine + lastBuffer.LineCount; @@ -347,7 +347,7 @@ public int ShiftBuffers () _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); _logger.Info(CultureInfo.InvariantCulture, "Adjusting StartLine values in {0} buffers by offset {1}", _bufferList.Count, offset); - foreach (LogBuffer buffer in _bufferList) + foreach (var buffer in _bufferList) { SetNewStartLineForBuffer(buffer, buffer.StartLine - offset); } @@ -363,7 +363,7 @@ public int ShiftBuffers () // Read anew all buffers following a buffer info that couldn't be matched with the corresponding existing file _logger.Info(CultureInfo.InvariantCulture, "Deleting buffers for files that must be re-read"); - foreach (ILogFileInfo ILogFileInfo in readNewILogFileInfoList) + foreach (var ILogFileInfo in readNewILogFileInfoList) { DeleteBuffersForInfo(ILogFileInfo, true); //this.ILogFileInfoList.Remove(ILogFileInfo); @@ -373,7 +373,7 @@ public int ShiftBuffers () DeleteBuffersForInfo(_watchedILogFileInfo, true); var startLine = LineCount - 1; _logger.Info(CultureInfo.InvariantCulture, "Re-Reading files"); - foreach (ILogFileInfo ILogFileInfo in readNewILogFileInfoList) + foreach (var ILogFileInfo in readNewILogFileInfoList) { //ILogFileInfo.OpenFile(); ReadToBufferList(ILogFileInfo, 0, LineCount); @@ -456,7 +456,7 @@ public async Task GetLogLineWithWait (int lineNum) public string GetLogFileNameForLine (int lineNum) { AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); + var logBuffer = GetBufferForLine(lineNum); var fileName = logBuffer?.FileInfo.FullName; ReleaseBufferListReaderLock(); return fileName; @@ -470,8 +470,8 @@ public string GetLogFileNameForLine (int lineNum) public ILogFileInfo GetLogFileInfoForLine (int lineNum) { AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); - ILogFileInfo info = logBuffer?.FileInfo; + var logBuffer = GetBufferForLine(lineNum); + var info = logBuffer?.FileInfo; ReleaseBufferListReaderLock(); return info; } @@ -486,7 +486,7 @@ public int GetNextMultiFileLine (int lineNum) { var result = -1; AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); + var logBuffer = GetBufferForLine(lineNum); if (logBuffer != null) { var index = _bufferList.IndexOf(logBuffer); @@ -511,7 +511,7 @@ public int GetPrevMultiFileLine (int lineNum) { var result = -1; AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); + var logBuffer = GetBufferForLine(lineNum); if (logBuffer != null) { var index = _bufferList.IndexOf(logBuffer); @@ -544,7 +544,7 @@ public int GetPrevMultiFileLine (int lineNum) public int GetRealLineNumForVirtualLineNum (int lineNum) { AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); + var logBuffer = GetBufferForLine(lineNum); var result = -1; if (logBuffer != null) { @@ -627,7 +627,7 @@ public void DeleteAllContent () _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); _disposeLock.AcquireWriterLock(Timeout.Infinite); - foreach (LogBuffer logBuffer in _bufferList) + foreach (var logBuffer in _bufferList) { if (!logBuffer.IsDisposed) { @@ -685,7 +685,7 @@ public IList GetBufferList () public void LogBufferInfoForLine (int lineNum) { AcquireBufferListReaderLock(); - LogBuffer buffer = GetBufferForLine(lineNum); + var buffer = GetBufferForLine(lineNum); if (buffer == null) { ReleaseBufferListReaderLock(); @@ -721,7 +721,7 @@ public void LogBufferDiagnostic () long minDispose = int.MaxValue; for (var i = 0; i < _bufferList.Count; ++i) { - LogBuffer buffer = _bufferList[i]; + var buffer = _bufferList[i]; _disposeLock.AcquireReaderLock(Timeout.Infinite); if (buffer.StartLine != lineNum) { @@ -750,7 +750,7 @@ public void LogBufferDiagnostic () private ILogFileInfo AddFile (string fileName) { _logger.Info(CultureInfo.InvariantCulture, "Adding file to ILogFileInfoList: " + fileName); - ILogFileInfo info = GetLogFileInfo(fileName); + var info = GetLogFileInfo(fileName); _logFileInfoList.Add(info); return info; } @@ -766,7 +766,7 @@ private Task GetLogLineInternal (int lineNum) } AcquireBufferListReaderLock(); - LogBuffer logBuffer = GetBufferForLine(lineNum); + var logBuffer = GetBufferForLine(lineNum); if (logBuffer == null) { ReleaseBufferListReaderLock(); @@ -778,7 +778,7 @@ private Task GetLogLineInternal (int lineNum) _disposeLock.AcquireReaderLock(Timeout.Infinite); if (logBuffer.IsDisposed) { - LockCookie cookie = _disposeLock.UpgradeToWriterLock(Timeout.Infinite); + var cookie = _disposeLock.UpgradeToWriterLock(Timeout.Infinite); lock (logBuffer.FileInfo) { ReReadBuffer(logBuffer); @@ -787,7 +787,7 @@ private Task GetLogLineInternal (int lineNum) _disposeLock.DowngradeFromWriterLock(ref cookie); } - ILogLine line = logBuffer.GetLineOfBlock(lineNum - logBuffer.StartLine); + var line = logBuffer.GetLineOfBlock(lineNum - logBuffer.StartLine); _disposeLock.ReleaseReaderLock(); ReleaseBufferListReaderLock(); @@ -838,8 +838,8 @@ private void CloseFiles () private ILogFileInfo GetLogFileInfo (string fileNameOrUri) //TODO: I changed to static { //TODO this must be fixed and should be given to the logfilereader not just called (https://github.com/LogExperts/LogExpert/issues/402) - IFileSystemPlugin fs = _pluginRegistry.FindFileSystemForUri(fileNameOrUri) ?? throw new LogFileException("No file system plugin found for " + fileNameOrUri); - ILogFileInfo logFileInfo = fs.GetLogfileInfo(fileNameOrUri); + var fs = _pluginRegistry.FindFileSystemForUri(fileNameOrUri) ?? throw new LogFileException("No file system plugin found for " + fileNameOrUri); + var logFileInfo = fs.GetLogfileInfo(fileNameOrUri); return logFileInfo ?? throw new LogFileException("Cannot find " + fileNameOrUri); } @@ -868,7 +868,7 @@ private LogBuffer DeleteBuffersForInfo (ILogFileInfo ILogFileInfo, bool matchNam _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); if (matchNamesOnly) { - foreach (LogBuffer buffer in _bufferList) + foreach (var buffer in _bufferList) { if (buffer.FileInfo.FullName.Equals(ILogFileInfo.FullName, StringComparison.Ordinal)) { @@ -879,7 +879,7 @@ private LogBuffer DeleteBuffersForInfo (ILogFileInfo ILogFileInfo, bool matchNam } else { - foreach (LogBuffer buffer in _bufferList) + foreach (var buffer in _bufferList) { if (buffer.FileInfo == ILogFileInfo) { @@ -889,7 +889,7 @@ private LogBuffer DeleteBuffersForInfo (ILogFileInfo ILogFileInfo, bool matchNam } } - foreach (LogBuffer buffer in deleteList) + foreach (var buffer in deleteList) { RemoveFromBufferList(buffer); } @@ -924,10 +924,10 @@ private void ReadToBufferList (ILogFileInfo logFileInfo, long filePos, int start { try { - using Stream fileStream = logFileInfo.OpenStream(); + using var fileStream = logFileInfo.OpenStream(); try { - using ILogStreamReader reader = GetLogStreamReader(fileStream, EncodingOptions, UseNewReader); + using var reader = GetLogStreamReader(fileStream, EncodingOptions, UseNewReader); reader.Position = filePos; _fileLength = logFileInfo.Length; @@ -941,7 +941,7 @@ private void ReadToBufferList (ILogFileInfo logFileInfo, long filePos, int start StartLine = startLine, StartPos = filePos }; - LockCookie cookie = UpgradeBufferListLockToWriter(); + var cookie = UpgradeBufferListLockToWriter(); AddBufferToList(logBuffer); DowngradeBufferListLockFromWriter(ref cookie); } @@ -956,7 +956,7 @@ private void ReadToBufferList (ILogFileInfo logFileInfo, long filePos, int start StartLine = startLine, StartPos = filePos }; - LockCookie cookie = UpgradeBufferListLockToWriter(); + var cookie = UpgradeBufferListLockToWriter(); AddBufferToList(logBuffer); DowngradeBufferListLockFromWriter(ref cookie); } @@ -964,7 +964,7 @@ private void ReadToBufferList (ILogFileInfo logFileInfo, long filePos, int start _disposeLock.AcquireReaderLock(Timeout.Infinite); if (logBuffer.IsDisposed) { - LockCookie cookie = _disposeLock.UpgradeToWriterLock(Timeout.Infinite); + var cookie = _disposeLock.UpgradeToWriterLock(Timeout.Infinite); ReReadBuffer(logBuffer); _disposeLock.DowngradeFromWriterLock(ref cookie); } @@ -1058,13 +1058,13 @@ private void AddBufferToList (LogBuffer logBuffer) private void UpdateLruCache (LogBuffer logBuffer) { _lruCacheDictLock.AcquireReaderLock(Timeout.Infinite); - if (_lruCacheDict.TryGetValue(logBuffer.StartLine, out LogBufferCacheEntry cacheEntry)) + if (_lruCacheDict.TryGetValue(logBuffer.StartLine, out var cacheEntry)) { cacheEntry.Touch(); } else { - LockCookie cookie = _lruCacheDictLock.UpgradeToWriterLock(Timeout.Infinite); + var cookie = _lruCacheDictLock.UpgradeToWriterLock(Timeout.Infinite); if (!_lruCacheDict.TryGetValue(logBuffer.StartLine, out cacheEntry) ) // #536: re-test, because multiple threads may have been waiting for _writer lock { @@ -1081,7 +1081,7 @@ private void UpdateLruCache (LogBuffer logBuffer) _logger.Info(CultureInfo.InvariantCulture, "Added buffer:"); DumpBufferInfos(logBuffer); - if (_lruCacheDict.TryGetValue(logBuffer.StartLine, out LogBufferCacheEntry existingEntry)) + if (_lruCacheDict.TryGetValue(logBuffer.StartLine, out var existingEntry)) { _logger.Info(CultureInfo.InvariantCulture, "Existing buffer: "); DumpBufferInfos(existingEntry.LogBuffer); @@ -1145,7 +1145,7 @@ private void GarbageCollectLruCache () #endif SortedList useSorterList = []; // sort by usage counter - foreach (LogBufferCacheEntry entry in _lruCacheDict.Values) + foreach (var entry in _lruCacheDict.Values) { if (!useSorterList.ContainsKey(entry.LastUseTimeStamp)) { @@ -1163,7 +1163,7 @@ private void GarbageCollectLruCache () } var startLine = useSorterList.Values[i]; - LogBufferCacheEntry entry = _lruCacheDict[startLine]; + var entry = _lruCacheDict[startLine]; _lruCacheDict.Remove(startLine); entry.LogBuffer.DisposeContent(); } @@ -1287,7 +1287,7 @@ private void ClearLru () _logger.Info(CultureInfo.InvariantCulture, "Clearing LRU cache."); _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite); _disposeLock.AcquireWriterLock(Timeout.Infinite); - foreach (LogBufferCacheEntry entry in _lruCacheDict.Values) + foreach (var entry in _lruCacheDict.Values) { entry.LogBuffer.DisposeContent(); } @@ -1319,7 +1319,7 @@ private void ReReadBuffer (LogBuffer logBuffer) try { - ILogStreamReader reader = GetLogStreamReader(fileStream, EncodingOptions, UseNewReader); + var reader = GetLogStreamReader(fileStream, EncodingOptions, UseNewReader); var filePos = logBuffer.StartPos; reader.Position = logBuffer.StartPos; @@ -1432,7 +1432,7 @@ private void GetLineFinishedCallback (ILogLine line) private LogBuffer GetFirstBufferForFileByLogBuffer (LogBuffer logBuffer) { - ILogFileInfo info = logBuffer.FileInfo; + var info = logBuffer.FileInfo; AcquireBufferListReaderLock(); var index = _bufferList.IndexOf(logBuffer); if (index == -1) @@ -1441,7 +1441,7 @@ private LogBuffer GetFirstBufferForFileByLogBuffer (LogBuffer logBuffer) return null; } - LogBuffer resultBuffer = logBuffer; + var resultBuffer = logBuffer; while (true) { index--; @@ -1575,7 +1575,21 @@ private void FireChangeEvent () LineCount = 0; try { - if (!IsMultiFile) + if (IsMultiFile) + { + var offset = ShiftBuffers(); + //this.currFileSize = newSize; // removed because ShiftBuffers() calls ReadToBuffer() which will set the actual read size + args.FileSize = newSize; + args.LineCount = LineCount; + args.IsRollover = true; + args.RolloverOffset = offset; + _isDeleted = false; + if (!_shouldStop) + { + OnFileSizeChanged(args); + } + } + else { // ReloadBufferList(); // removed because reloading is triggered by owning LogWindow // Trigger "new file" handling (reload) @@ -1593,20 +1607,6 @@ private void FireChangeEvent () _isDeleted = false; } - else - { - var offset = ShiftBuffers(); - //this.currFileSize = newSize; // removed because ShiftBuffers() calls ReadToBuffer() which will set the actual read size - args.FileSize = newSize; - args.LineCount = LineCount; - args.IsRollover = true; - args.RolloverOffset = offset; - _isDeleted = false; - if (!_shouldStop) - { - OnFileSizeChanged(args); - } - } } catch (FileNotFoundException e) { @@ -1626,7 +1626,7 @@ private void FireChangeEvent () private ILogStreamReader GetLogStreamReader (Stream stream, EncodingOptions encodingOptions, bool useNewReader) { - ILogStreamReader reader = CreateLogStreamReader(stream, encodingOptions, useNewReader); + var reader = CreateLogStreamReader(stream, encodingOptions, useNewReader); return IsXmlMode ? new XmlBlockSplitter(new XmlLogReader(reader), XmlLogConfig) : reader; } @@ -1735,7 +1735,7 @@ private LockCookie UpgradeBufferListLockToWriter () { try { - LockCookie cookie = _bufferListLock.UpgradeToWriterLock(10000); + var cookie = _bufferListLock.UpgradeToWriterLock(10000); #if DEBUG && TRACE_LOCKS StackTrace st = new StackTrace(true); StackFrame callerFrame = st.GetFrame(2); diff --git a/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs b/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs index ae276817..3d43806f 100644 --- a/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs +++ b/src/LogExpert.Core/Classes/Log/RolloverFilenameBuilder.cs @@ -1,4 +1,3 @@ -using System; using System.Globalization; using System.Text; using System.Text.RegularExpressions; @@ -83,11 +82,13 @@ public void SetFileName (string fileName) { } } + _indexGroup = match.Groups["index"]; if (_indexGroup.Success) { Index = _indexGroup.Value.Length > 0 ? int.Parse(_indexGroup.Value) : 0; } + _condGroup = match.Groups["cond"]; } } diff --git a/src/LogExpert.Core/Interface/IConfigManager.cs b/src/LogExpert.Core/Interface/IConfigManager.cs index d921e9b4..93a079dd 100644 --- a/src/LogExpert.Core/Interface/IConfigManager.cs +++ b/src/LogExpert.Core/Interface/IConfigManager.cs @@ -1,4 +1,4 @@ -using LogExpert.Core.Config; +using LogExpert.Core.Config; using LogExpert.Core.EventArguments; namespace LogExpert.Core.Interface; @@ -7,14 +7,24 @@ namespace LogExpert.Core.Interface; public interface IConfigManager { Settings Settings { get; } + string PortableModeDir { get; } + string ConfigDir { get; } + IConfigManager Instance { get; } + string PortableModeSettingsFileName { get; } - void Export(FileInfo fileInfo, SettingsFlags highlightSettings); - void Export(FileInfo fileInfo); - void Import(FileInfo fileInfo, ExportImportFlags importFlags); - void ImportHighlightSettings(FileInfo fileInfo, ExportImportFlags importFlags); + + void Export (FileInfo fileInfo, SettingsFlags highlightSettings); + + void Export (FileInfo fileInfo); + + void Import (FileInfo fileInfo, ExportImportFlags importFlags); + + void ImportHighlightSettings (FileInfo fileInfo, ExportImportFlags importFlags); + event EventHandler ConfigChanged; //TODO: All handlers that are public shoulld be in Core - void Save(SettingsFlags flags); + + void Save (SettingsFlags flags); } \ No newline at end of file diff --git a/src/LogExpert.Tests/BufferShiftTest.cs b/src/LogExpert.Tests/BufferShiftTest.cs index 985f3a5d..df3f027e 100644 --- a/src/LogExpert.Tests/BufferShiftTest.cs +++ b/src/LogExpert.Tests/BufferShiftTest.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using System.Text; using LogExpert.Core.Classes.Log; @@ -35,7 +33,9 @@ public void TestShiftBuffers1 () MaxDayTry = 0, FormatPattern = "*$J(.)" }; + LinkedList files = CreateTestFilesWithoutDate(); + EncodingOptions encodingOptions = new() { Encoding = Encoding.Default @@ -57,6 +57,7 @@ public void TestShiftBuffers1 () Assert.That(li.FullName, Is.EqualTo(fileName)); enumerator.MoveNext(); } + var oldCount = lil.Count; // Simulate rollover @@ -68,6 +69,7 @@ public void TestShiftBuffers1 () reader.ShiftBuffers(); lil = reader.GetLogFileInfoList(); + Assert.That(lil.Count, Is.EqualTo(oldCount + 1)); Assert.That(reader.LineCount, Is.EqualTo(linesPerFile * lil.Count)); @@ -77,6 +79,7 @@ public void TestShiftBuffers1 () Assert.That(lil.Count, Is.EqualTo(files.Count)); enumerator = files.GetEnumerator(); enumerator.MoveNext(); + foreach (LogFileInfo li in lil) { var fileName = enumerator.Current; @@ -89,8 +92,10 @@ public void TestShiftBuffers1 () // enumerator = files.GetEnumerator(); enumerator.MoveNext(); + IList logBuffers = reader.GetBufferList(); var startLine = 0; + foreach (LogBuffer logBuffer in logBuffers) { Assert.That(enumerator.Current, Is.EqualTo(logBuffer.FileInfo.FullName)); @@ -106,20 +111,22 @@ public void TestShiftBuffers1 () enumerator.MoveNext(); // move to 2nd entry. The first file now contains 2nd file's content (because rollover) logBuffers = reader.GetBufferList(); int i; + for (i = 0; i < logBuffers.Count - 2; ++i) { LogBuffer logBuffer = logBuffers[i]; ILogLine line = logBuffer.GetLineOfBlock(0); - Assert.That(line.FullLine.Contains(enumerator.Current, System.StringComparison.Ordinal)); + Assert.That(line.FullLine.Contains(enumerator.Current, StringComparison.Ordinal)); enumerator.MoveNext(); } + enumerator.MoveNext(); // the last 2 files now contain the content of the previously watched file for (; i < logBuffers.Count; ++i) { LogBuffer logBuffer = logBuffers[i]; ILogLine line = logBuffer.GetLineOfBlock(0); - Assert.That(line.FullLine.Contains(enumerator.Current, System.StringComparison.Ordinal)); + Assert.That(line.FullLine.Contains(enumerator.Current, StringComparison.Ordinal)); } oldCount = lil.Count; @@ -142,6 +149,6 @@ public void TestShiftBuffers1 () ILogLine firstLine = reader.GetLogLine(0); var names = new string[files.Count]; files.CopyTo(names, 0); - Assert.That(firstLine.FullLine.Contains(names[2], System.StringComparison.Ordinal)); + Assert.That(firstLine.FullLine.Contains(names[2], StringComparison.Ordinal)); } } \ No newline at end of file diff --git a/src/LogExpert.Tests/CSVColumnizerTest.cs b/src/LogExpert.Tests/CSVColumnizerTest.cs index 1c9ccce1..e1a2aa54 100644 --- a/src/LogExpert.Tests/CSVColumnizerTest.cs +++ b/src/LogExpert.Tests/CSVColumnizerTest.cs @@ -1,11 +1,8 @@ -using LogExpert.Core.Classes.Log; +using LogExpert.Core.Classes.Log; using LogExpert.Core.Entities; using NUnit.Framework; -using System; -using System.IO; - namespace LogExpert.Tests; [TestFixture] @@ -14,11 +11,11 @@ public class CSVColumnizerTest [TestCase(@".\TestData\organizations-10000.csv", new[] { "Index", "Organization Id", "Name", "Website", "Country", "Description", "Founded", "Industry", "Number of employees" })] [TestCase(@".\TestData\organizations-1000.csv", new[] { "Index", "Organization Id", "Name", "Website", "Country", "Description", "Founded", "Industry", "Number of employees" })] [TestCase(@".\TestData\people-10000.csv", new[] { "Index", "User Id", "First Name", "Last Name", "Sex", "Email", "Phone", "Date of birth", "Job Title" })] - public void Instantiat_CSVFile_BuildCorrectColumnizer(string filename, string[] expectedHeaders) + public void Instantiat_CSVFile_BuildCorrectColumnizer (string filename, string[] expectedHeaders) { CsvColumnizer.CsvColumnizer csvColumnizer = new(); var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename); - LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); + LogfileReader reader = new(path, new EncodingOptions(), false, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); reader.ReadFiles(); ILogLine line = reader.GetLogLine(0); IColumnizedLogLine logline = new ColumnizedLogLine(); diff --git a/src/LogExpert.Tests/ColumnizerPickerTest.cs b/src/LogExpert.Tests/ColumnizerPickerTest.cs index f6204673..c802d062 100644 --- a/src/LogExpert.Tests/ColumnizerPickerTest.cs +++ b/src/LogExpert.Tests/ColumnizerPickerTest.cs @@ -1,11 +1,12 @@ -using JsonColumnizer; +using JsonColumnizer; + using LogExpert.Core.Classes.Columnizer; using LogExpert.Core.Classes.Log; using LogExpert.Core.Entities; + using Moq; + using NUnit.Framework; -using System; -using System.IO; namespace LogExpert.Tests; @@ -19,7 +20,7 @@ public class ColumnizerPickerTest [TestCase("Square Bracket Columnizer", "30/08/2018 08:51:42.712 [TRACE] hello", "30/08/2018 08:51:42.712 [DATAIO][] world", null, null, null)] [TestCase("Square Bracket Columnizer", "", "30/08/2018 08:51:42.712 [TRACE] hello", "30/08/2018 08:51:42.712 [TRACE] hello", "[DATAIO][b][c] world", null)] [TestCase("Timestamp Columnizer", "30/08/2018 08:51:42.712 no bracket 1", "30/08/2018 08:51:42.712 no bracket 2", "30/08/2018 08:51:42.712 [TRACE] with bracket 1", "30/08/2018 08:51:42.712 [TRACE] with bracket 2", "no bracket 3")] - public void FindColumnizer_ReturnCorrectColumnizer(string expectedColumnizerName, string line0, string line1, string line2, string line3, string line4) + public void FindColumnizer_ReturnCorrectColumnizer (string expectedColumnizerName, string line0, string line1, string line2, string line3, string line4) { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test"); @@ -62,11 +63,11 @@ public void FindColumnizer_ReturnCorrectColumnizer(string expectedColumnizerName [TestCase(@".\TestData\JsonColumnizerTest_01.txt", typeof(JsonCompactColumnizer))] [TestCase(@".\TestData\SquareBracketColumnizerTest_02.txt", typeof(SquareBracketColumnizer))] - public void FindReplacementForAutoColumnizer_ValidTextFile_ReturnCorrectColumnizer( + public void FindReplacementForAutoColumnizer_ValidTextFile_ReturnCorrectColumnizer ( string fileName, Type columnizerType) { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); + LogfileReader reader = new(path, new EncodingOptions(), false, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); reader.ReadFiles(); Mock autoColumnizer = new(); @@ -80,7 +81,7 @@ public void FindReplacementForAutoColumnizer_ValidTextFile_ReturnCorrectColumniz } [TestCase(@".\TestData\FileNotExists.txt", typeof(DefaultLogfileColumnizer))] - public void DecideColumnizerByName_WhenReaderIsNotReady_ReturnCorrectColumnizer( + public void DecideColumnizerByName_WhenReaderIsNotReady_ReturnCorrectColumnizer ( string fileName, Type columnizerType) { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); @@ -94,7 +95,7 @@ public void DecideColumnizerByName_WhenReaderIsNotReady_ReturnCorrectColumnizer( [TestCase(@"Invalid Name", typeof(DefaultLogfileColumnizer))] [TestCase(@"JSON Columnizer", typeof(JsonColumnizer.JsonColumnizer))] - public void DecideColumnizerByName_ValidTextFile_ReturnCorrectColumnizer( + public void DecideColumnizerByName_ValidTextFile_ReturnCorrectColumnizer ( string columnizerName, Type columnizerType) { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, columnizerName); diff --git a/src/LogExpert.Tests/JsonColumnizerTest.cs b/src/LogExpert.Tests/JsonColumnizerTest.cs index 87e5c369..aae3663b 100644 --- a/src/LogExpert.Tests/JsonColumnizerTest.cs +++ b/src/LogExpert.Tests/JsonColumnizerTest.cs @@ -1,22 +1,19 @@ -using LogExpert.Core.Classes.Log; +using LogExpert.Core.Classes.Log; using LogExpert.Core.Entities; using NUnit.Framework; -using System; -using System.IO; - namespace LogExpert.Tests; [TestFixture] public class JsonColumnizerTest { [TestCase(@".\TestData\JsonColumnizerTest_01.txt", "time @m level")] - public void GetColumnNames_HappyFile_ColumnNameMatches(string fileName, string expectedHeaders) + public void GetColumnNames_HappyFile_ColumnNameMatches (string fileName, string expectedHeaders) { var jsonColumnizer = new JsonColumnizer.JsonColumnizer(); var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - LogfileReader reader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); + LogfileReader reader = new(path, new EncodingOptions(), false, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); reader.ReadFiles(); ILogLine line = reader.GetLogLine(0); diff --git a/src/LogExpert.Tests/JsonCompactColumnizerTest.cs b/src/LogExpert.Tests/JsonCompactColumnizerTest.cs index 5811be64..970b7ff4 100644 --- a/src/LogExpert.Tests/JsonCompactColumnizerTest.cs +++ b/src/LogExpert.Tests/JsonCompactColumnizerTest.cs @@ -1,12 +1,8 @@ -using LogExpert.Core.Classes.Log; +using LogExpert.Core.Classes.Log; using LogExpert.Core.Entities; using NUnit.Framework; -using System; -using System.Collections.Generic; -using System.IO; - namespace LogExpert.Tests; [TestFixture] @@ -16,11 +12,11 @@ public class JsonCompactColumnizerTest // As long as the json file contains one of the pre-defined key, it's perfectly supported. [TestCase(@".\TestData\JsonCompactColumnizerTest_02.json", Priority.PerfectlySupport)] [TestCase(@".\TestData\JsonCompactColumnizerTest_03.json", Priority.WellSupport)] - public void GetPriority_HappyFile_PriorityMatches(string fileName, Priority priority) + public void GetPriority_HappyFile_PriorityMatches (string fileName, Priority priority) { var jsonCompactColumnizer = new JsonColumnizer.JsonCompactColumnizer(); var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - LogfileReader logFileReader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); + LogfileReader logFileReader = new(path, new EncodingOptions(), false, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); logFileReader.ReadFiles(); List loglines = new() { diff --git a/src/LogExpert.Tests/RolloverHandlerTestBase.cs b/src/LogExpert.Tests/RolloverHandlerTestBase.cs index 445a1579..26a08906 100644 --- a/src/LogExpert.Tests/RolloverHandlerTestBase.cs +++ b/src/LogExpert.Tests/RolloverHandlerTestBase.cs @@ -1,7 +1,3 @@ -using System; -using System.Collections.Generic; -using System.IO; - using LogExpert.Core.Classes.Log; namespace LogExpert.Tests; @@ -60,6 +56,7 @@ protected LinkedList RolloverSimulation (LinkedList files, strin LinkedList.Enumerator nextEnumerator = fileList.GetEnumerator(); nextEnumerator.MoveNext(); // move on 2nd entry enumerator.MoveNext(); + while (nextEnumerator.MoveNext()) { File.Move(nextEnumerator.Current, enumerator.Current); @@ -98,7 +95,7 @@ protected string CreateFile (DirectoryInfo dInfo, string fileName) { for (var i = 1; i <= lineCount; ++i) { - writer.WriteLine("Line number " + i.ToString("D3") + " of File " + fullName); + writer.WriteLine($"Line number {i:D3} of File {fullName}"); } writer.Flush(); diff --git a/src/LogExpert.Tests/SquareBracketColumnizerTest.cs b/src/LogExpert.Tests/SquareBracketColumnizerTest.cs index 49f5db6c..2f952833 100644 --- a/src/LogExpert.Tests/SquareBracketColumnizerTest.cs +++ b/src/LogExpert.Tests/SquareBracketColumnizerTest.cs @@ -1,13 +1,9 @@ -using LogExpert.Core.Classes.Columnizer; +using LogExpert.Core.Classes.Columnizer; using LogExpert.Core.Classes.Log; using LogExpert.Core.Entities; using NUnit.Framework; -using System; -using System.Collections.Generic; -using System.IO; - namespace LogExpert.Tests; [TestFixture] @@ -17,12 +13,12 @@ public class SquareBracketColumnizerTest [TestCase(@".\TestData\SquareBracketColumnizerTest_02.txt", 5)] [TestCase(@".\TestData\SquareBracketColumnizerTest_03.txt", 6)] [TestCase(@".\TestData\SquareBracketColumnizerTest_05.txt", 3)] - public void GetPriority_HappyFile_ColumnCountMatches(string fileName, int count) + public void GetPriority_HappyFile_ColumnCountMatches (string fileName, int count) { SquareBracketColumnizer squareBracketColumnizer = new(); var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - LogfileReader logFileReader = new(path, new EncodingOptions(), true, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); + LogfileReader logFileReader = new(path, new EncodingOptions(), false, 40, 50, new MultiFileOptions(), PluginRegistry.PluginRegistry.Instance); logFileReader.ReadFiles(); List loglines = new() { diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index ba4eac84..6d96f5b8 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -558,6 +558,7 @@ internal void DumpBufferDiagnostic () { _logFileReader.LogBufferDiagnostic(); } +#endif [SupportedOSPlatform("windows")] void ILogWindow.SelectLine (int lineNum, bool triggerSyncCall, bool shouldScroll) @@ -576,7 +577,7 @@ void ILogWindow.WritePipeTab (IList lineEntryList, string title) { WritePipeTab(lineEntryList, title); } -#endif + #region Event Handlers @@ -4848,7 +4849,7 @@ private void WriteFilterToTab () } [SupportedOSPlatform("windows")] - private void WritePipeToTab (FilterPipe pipe, IList lineNumberList, string name, PersistenceData persistenceData) + private void WritePipeToTab (FilterPipe pipe, List lineNumberList, string name, PersistenceData persistenceData) { _logger.Info(CultureInfo.InvariantCulture, "WritePipeToTab(): {0} lines.", lineNumberList.Count); StatusLineText("Writing to temp file... Press ESC to cancel."); @@ -4941,6 +4942,7 @@ internal void WritePipeTab (IList lineEntryList, string title) { IsStopped = true }; + pipe.Closed += OnPipeDisconnected; pipe.OpenFile(); foreach (var entry in lineEntryList) @@ -5227,14 +5229,9 @@ private void ApplyFrozenState (BufferedDataGridView gridView) [SupportedOSPlatform("windows")] private void ShowTimeSpread (bool show) { - if (show) - { - tableLayoutPanel1.ColumnStyles[1].Width = 16; - } - else - { - tableLayoutPanel1.ColumnStyles[1].Width = 0; - } + tableLayoutPanel1.ColumnStyles[1].Width = show + ? 16 + : 0; _timeSpreadCalc.Enabled = show; } @@ -5242,7 +5239,7 @@ private void ShowTimeSpread (bool show) [SupportedOSPlatform("windows")] protected internal void AddTempFileTab (string fileName, string title) { - _parentLogTabWin.AddTempFileTab(fileName, title); + _ = _parentLogTabWin.AddTempFileTab(fileName, title); } private void InitPatternWindow () @@ -5391,6 +5388,7 @@ private PatternBlock DetectBlock (int startNum, int startLineToSearch, int maxBl { StartLine = startNum }; + var srcLine = block.StartLine; block.TargetStart = targetLine; var srcMisses = 0; diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs index 1d305985..b75a674c 100644 --- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs +++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs @@ -2249,7 +2249,8 @@ private void OnLogWindowDragDrop (object sender, DragEventArgs e) var o = e.Data.GetData(DataFormats.FileDrop); if (o is string[] names) { - LoadFiles(names, (e.KeyState & 4) == 4); // (shift pressed?) + // (shift pressed) https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.drageventargs.keystate + LoadFiles(names, (e.KeyState & 4) == 4); e.Effect = DragDropEffects.Copy; } } diff --git a/src/SftpFileSystemx64/CredentialCache.cs b/src/SftpFileSystemx64/CredentialCache.cs index dc48ff33..c377efc2 100644 --- a/src/SftpFileSystemx64/CredentialCache.cs +++ b/src/SftpFileSystemx64/CredentialCache.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; - namespace SftpFileSystem; internal class CredentialCache @@ -14,7 +12,7 @@ internal class CredentialCache private void RemoveCredentials (string host, string user) { - Credentials credentials = GetCredentials(host, user); + var credentials = GetCredentials(host, user); if (credentials != null) { _credList.Remove(credentials); @@ -27,9 +25,9 @@ internal IList GetUsersForHost (string host) { IList result = []; - foreach (Credentials cred in _credList) + foreach (var cred in _credList) { - if (cred.Host.Equals(host, System.StringComparison.Ordinal)) + if (cred.Host.Equals(host, StringComparison.Ordinal)) { result.Add(cred.UserName); } @@ -40,9 +38,9 @@ internal IList GetUsersForHost (string host) internal Credentials GetCredentials (string host, string user) { - foreach (Credentials cred in _credList) + foreach (var cred in _credList) { - if (cred.Host.Equals(host, System.StringComparison.Ordinal) && cred.UserName.Equals(user, System.StringComparison.Ordinal)) + if (cred.Host.Equals(host, StringComparison.Ordinal) && cred.UserName.Equals(user, StringComparison.Ordinal)) { return cred; } @@ -56,4 +54,4 @@ internal void Add (Credentials cred) RemoveCredentials(cred.Host, cred.UserName); _credList.Add(cred); } -} +} \ No newline at end of file diff --git a/src/SftpFileSystemx64/Credentials.cs b/src/SftpFileSystemx64/Credentials.cs index fbd7cecf..bffc2155 100644 --- a/src/SftpFileSystemx64/Credentials.cs +++ b/src/SftpFileSystemx64/Credentials.cs @@ -1,25 +1,3 @@ -namespace SftpFileSystem; +namespace SftpFileSystem; -internal class Credentials -{ - #region Ctor - - internal Credentials(string host, string userName, string password) - { - Host = host; - UserName = userName; - Password = password; - } - - #endregion - - #region Properties / Indexers - - public string Host { get; } - - public string Password { get; } - - public string UserName { get; } - - #endregion -} +internal record Credentials (string Host, string UserName, string Password); diff --git a/src/SftpFileSystemx64/SftpFileSystem.cs b/src/SftpFileSystemx64/SftpFileSystem.cs index 4d43af87..a8583f3d 100644 --- a/src/SftpFileSystemx64/SftpFileSystem.cs +++ b/src/SftpFileSystemx64/SftpFileSystem.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; using System.Globalization; -using System.IO; -using System.Windows.Forms; using System.Xml.Serialization; using LogExpert; @@ -19,7 +15,7 @@ public class SftpFileSystem (IFileSystemCallback callback) : IFileSystemPlugin, private ConfigDialog _configDialog; private volatile PrivateKeyFile _privateKeyFile; - private object _lock = new object(); + private readonly object _lock = new(); #endregion @@ -187,7 +183,7 @@ internal Credentials GetCredentials (Uri uri, bool cacheAllowed, bool hidePasswo } } - IList usersForHost = CredentialsCache.GetUsersForHost(uri.Host); + var usersForHost = CredentialsCache.GetUsersForHost(uri.Host); if (userName == null && cacheAllowed) { if (usersForHost.Count == 1) @@ -198,7 +194,7 @@ internal Credentials GetCredentials (Uri uri, bool cacheAllowed, bool hidePasswo if (userName != null && password == null && cacheAllowed) { - Credentials cred = CredentialsCache.GetCredentials(uri.Host, userName); + var cred = CredentialsCache.GetCredentials(uri.Host, userName); if (cred != null) { return cred; diff --git a/src/SftpFileSystemx64/SftpFileSystemSSHDotNET.cs b/src/SftpFileSystemx64/SftpFileSystemSSHDotNET.cs deleted file mode 100644 index 7a253d56..00000000 --- a/src/SftpFileSystemx64/SftpFileSystemSSHDotNET.cs +++ /dev/null @@ -1,225 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using System.Xml.Serialization; -using System.IO; -using Renci.SshNet; -using LogExpert; - -namespace SftpFileSystem -{ - public class SftpFileSystem : IFileSystemPlugin, ILogExpertPluginConfigurator - { - #region Fields - - private readonly ILogExpertLogger _logger; - - private ConfigDialog _configDialog; - private volatile PrivateKeyFile _privateKeyFile; - - #endregion - - #region cTor - - public SftpFileSystem(IFileSystemCallback callback) - { - _logger = callback.GetLogger(); - CredentialsCache = new CredentialCache(); - } - - #endregion - - #region Properties - - private CredentialCache CredentialsCache { get; } - - public string Text => "SFTP plugin"; - - public string Description => "Can read log files directly from SFTP server."; - - public ConfigData ConfigData { get; private set; } = new ConfigData(); - - public PrivateKeyFile PrivateKeyFile { get => _privateKeyFile; set => _privateKeyFile = value; } - - #endregion - - #region Public methods - - public bool CanHandleUri(string uriString) - { - try - { - Uri uri = new Uri(uriString); - return uri.Scheme.Equals("sftp", StringComparison.InvariantCultureIgnoreCase); - } - catch (Exception e) - { - _logger.LogError(e.Message); - return false; - } - } - - public ILogFileInfo GetLogfileInfo(string uriString) - { - try - { - Uri uri = new Uri(uriString.Replace('\\', '/')); - return new SftpLogFileInfo(this, uri, _logger); - } - catch (Exception e) - { - _logger.LogError(e.Message); - return null; - } - } - - public bool HasEmbeddedForm() - { - return true; - } - - public void HideConfigForm() - { - ConfigData = _configDialog.ConfigData; - _configDialog.Hide(); - _configDialog.Dispose(); - } - - public void LoadConfig(string configDir) - { - XmlSerializer xml = new XmlSerializer(ConfigData.GetType()); - - FileInfo configFile = new FileInfo(configDir + "\\" + "sftpfilesystem.cfg"); - - if (!configFile.Exists) - { - return; - } - - FileStream fs = null; - - try - { - fs = configFile.OpenRead(); - - ConfigData = (ConfigData) xml.Deserialize(fs); - } - catch (IOException e) - { - _logger.LogError(e.Message); - } - finally - { - fs?.Flush(); - fs?.Close(); - fs?.Dispose(); - } - } - - public void SaveConfig(string configDir) - { - _logger.Info("Saving SFTP config"); - XmlSerializer xml = new XmlSerializer(ConfigData.GetType()); - - FileStream fs = null; - - try - { - fs = new FileStream(configDir + "\\" + "sftpfilesystem.cfg", FileMode.Create); - xml.Serialize(fs, ConfigData); - fs.Close(); - } - catch (IOException e) - { - _logger.LogError(e.Message); - } - finally - { - fs?.Flush(); - fs?.Close(); - fs?.Dispose(); - } - } - - public void ShowConfigDialog(Form owner) - { - throw new NotImplementedException(); - } - - public void ShowConfigForm(Panel parentPanel) - { - _configDialog = new ConfigDialog(ConfigData); - _configDialog.Parent = parentPanel; - _configDialog.Show(); - } - - public void StartConfig() - { - } - - #endregion - - #region Internals - - internal Credentials GetCredentials(Uri uri, bool cacheAllowed, bool hidePasswordField) - { - // Synchronized access to the GetCredentials() method prevents multiple login dialogs when loading multiple files at once - // (e.g. on startup). So the user only needs to enter credentials once for the same host. - lock (this) - { - string userName = null; - string password = null; - if (uri.UserInfo != null && uri.UserInfo.Length > 0) - { - string[] split = uri.UserInfo.Split(new char[] {':'}); - if (split.Length > 0) - { - userName = split[0]; - } - - if (split.Length > 1) - { - password = split[1]; - } - } - - IList usersForHost = CredentialsCache.GetUsersForHost(uri.Host); - if (userName == null && cacheAllowed) - { - if (usersForHost.Count == 1) - { - userName = usersForHost[0]; - } - } - - if (userName != null && password == null && cacheAllowed) - { - Credentials cred = CredentialsCache.GetCredentials(uri.Host, userName); - if (cred != null) - { - return cred; - } - } - - if (userName == null || password == null) - { - LoginDialog dlg = new LoginDialog(uri.Host, usersForHost, hidePasswordField); - dlg.UserName = userName; - if (DialogResult.OK == dlg.ShowDialog()) - { - password = dlg.Password; - userName = dlg.UserName; - } - - dlg.Dispose(); - } - - Credentials credentials = new Credentials(uri.Host, userName, password); - CredentialsCache.Add(credentials); - return credentials; - } - } - - #endregion - } -} \ No newline at end of file diff --git a/src/SftpFileSystemx64/SftpFileSystemx64.csproj b/src/SftpFileSystemx64/SftpFileSystemx64.csproj index 751e2a0c..2627ca27 100644 --- a/src/SftpFileSystemx64/SftpFileSystemx64.csproj +++ b/src/SftpFileSystemx64/SftpFileSystemx64.csproj @@ -7,6 +7,7 @@ SftpFileSystem true true + true $(SolutionDir)..\bin\$(Configuration)\plugins SftpFileSystem @@ -19,12 +20,4 @@ - - - - - - - - diff --git a/src/SftpFileSystemx64/SftpLogFileInfo.cs b/src/SftpFileSystemx64/SftpLogFileInfo.cs index 5784dc9c..b31ce3b7 100644 --- a/src/SftpFileSystemx64/SftpLogFileInfo.cs +++ b/src/SftpFileSystemx64/SftpLogFileInfo.cs @@ -1,8 +1,3 @@ -using System; -using System.IO; -using System.Threading; -using System.Windows.Forms; - using LogExpert; using Renci.SshNet; @@ -10,7 +5,7 @@ namespace SftpFileSystem; -internal class SftpLogFileInfo : ILogFileInfo +public class SftpLogFileInfo : ILogFileInfo { #region Static/Constants //TODO Add to Options @@ -33,10 +28,10 @@ internal class SftpLogFileInfo : ILogFileInfo #region Ctor - internal SftpLogFileInfo (SftpFileSystem sftpFileSystem, Uri fileUri, ILogExpertLogger logger) + public SftpLogFileInfo (SftpFileSystem sftpFileSystem, Uri fileUri, ILogExpertLogger logger) { _logger = logger; - SftpFileSystem sftFileSystem = sftpFileSystem; + var sftFileSystem = sftpFileSystem; Uri = fileUri; _remoteFileName = Uri.PathAndQuery; @@ -51,7 +46,7 @@ internal SftpLogFileInfo (SftpFileSystem sftpFileSystem, Uri fileUri, ILogExpert while (sftFileSystem.PrivateKeyFile == null) { PrivateKeyPasswordDialog dlg = new(); - DialogResult dialogResult = dlg.ShowDialog(); + var dialogResult = dlg.ShowDialog(); if (dialogResult == DialogResult.Cancel) { cancelled = true; @@ -74,7 +69,7 @@ internal SftpLogFileInfo (SftpFileSystem sftpFileSystem, Uri fileUri, ILogExpert if (cancelled == false) { success = false; - Credentials credentials = sftFileSystem.GetCredentials(Uri, true, true); + var credentials = sftFileSystem.GetCredentials(Uri, true, true); while (success == false) { //Add ConnectionInfo object @@ -89,7 +84,7 @@ internal SftpLogFileInfo (SftpFileSystem sftpFileSystem, Uri fileUri, ILogExpert if (success == false) { FailedKeyDialog dlg = new(); - DialogResult res = dlg.ShowDialog(); + var res = dlg.ShowDialog(); dlg.Dispose(); if (res == DialogResult.Cancel) { @@ -111,7 +106,7 @@ internal SftpLogFileInfo (SftpFileSystem sftpFileSystem, Uri fileUri, ILogExpert if (success == false) { // username/password auth - Credentials credentials = sftFileSystem.GetCredentials(Uri, true, false); + var credentials = sftFileSystem.GetCredentials(Uri, true, false); _sftp = new SftpClient(Uri.Host, port, credentials.UserName, credentials.Password); if (_sftp == null) @@ -153,12 +148,9 @@ public string DirectoryName { var full = FullName; var i = full.LastIndexOf(DirectorySeparatorChar); - if (i != -1) - { - return full.Substring(0, i); - } - - return "."; + return i != -1 + ? full[..i] + : "."; } } @@ -188,7 +180,7 @@ public string FileName { var full = FullName; var i = full.LastIndexOf(DirectorySeparatorChar); - return full.Substring(i + 1); + return full[(i + 1)..]; } } @@ -209,18 +201,12 @@ public int PollInterval { get { - TimeSpan diff = DateTime.Now - _lastChange; - if (diff.TotalSeconds < 4) - { - return 400; - } - - if (diff.TotalSeconds < 30) - { - return (int)diff.TotalSeconds * 100; - } - - return 5000; + var diff = DateTime.Now - _lastChange; + return diff.TotalSeconds < 4 + ? 400 + : diff.TotalSeconds < 30 + ? (int)diff.TotalSeconds * 100 + : 5000; } } @@ -261,4 +247,4 @@ public Stream OpenStream () } #endregion -} +} \ No newline at end of file diff --git a/src/SftpFileSystemx64/SftpLogFileInfoSSHDotNET.cs b/src/SftpFileSystemx64/SftpLogFileInfoSSHDotNET.cs deleted file mode 100644 index 78705afc..00000000 --- a/src/SftpFileSystemx64/SftpLogFileInfoSSHDotNET.cs +++ /dev/null @@ -1,231 +0,0 @@ -using LogExpert; - -using Renci.SshNet; -using Renci.SshNet.Sftp; - -using System; -using System.IO; -using System.Windows.Forms; - -namespace SftpFileSystem -{ - internal class SftpLogFileInfo : ILogFileInfo - { - - private const int RetryCount = 20; - private const int RetrySleep = 250; - private readonly ILogExpertLogger _logger; - private readonly string _remoteFileName; - - private readonly SftpClient _sftp; - private readonly object _sshKeyMonitor = new object(); - private DateTime _lastChange = DateTime.Now; - private long _lastLength; - - internal SftpLogFileInfo(SftpFileSystemSSHDotNET sftpFileSystem, Uri fileUri, ILogExpertLogger logger) - { - _logger = logger; - SftpFileSystemSSHDotNET sftFileSystem = sftpFileSystem; - Uri = fileUri; - _remoteFileName = Uri.PathAndQuery; - - int port = Uri.Port != -1 ? Uri.Port : 22; - - bool success = false; - bool cancelled = false; - if (sftFileSystem.ConfigData.UseKeyfile) - { - lock (_sshKeyMonitor) // prevent multiple password dialogs when opening multiple files at once - { - while (sftFileSystem.PrivateKeyFile == null) - { - PrivateKeyPasswordDialog dlg = new PrivateKeyPasswordDialog(); - DialogResult dialogResult = dlg.ShowDialog(); - if (dialogResult == DialogResult.Cancel) - { - cancelled = true; - break; - } - - PrivateKeyFile privateKeyFile = new PrivateKeyFile(sftFileSystem.ConfigData.KeyFile, dlg.Password); - - if (privateKeyFile != null) - { - sftFileSystem.PrivateKeyFile = privateKeyFile; - } - else - { - MessageBox.Show("Loading key file failed"); - } - } - } - - if (cancelled == false) - { - success = false; - Credentials credentials = sftFileSystem.GetCredentials(Uri, true, true); - while (success == false) - { - //Add ConnectionInfo object - _sftp = new SftpClient(Uri.Host, credentials.UserName, new[] { sftFileSystem.PrivateKeyFile }); - - if (_sftp != null) - { - _sftp.Connect(); - success = true; - } - - if (success == false) - { - FailedKeyDialog dlg = new FailedKeyDialog(); - DialogResult res = dlg.ShowDialog(); - dlg.Dispose(); - if (res == DialogResult.Cancel) - { - return; - } - - if (res == DialogResult.OK) - { - break; // go to user/pw auth - } - - // retries with disabled cache - credentials = sftFileSystem.GetCredentials(Uri, false, true); - } - } - } - } - - if (success == false) - { - // username/password auth - Credentials credentials = sftFileSystem.GetCredentials(Uri, true, false); - _sftp = new SftpClient(Uri.Host, port, credentials.UserName, credentials.Password); - - if (_sftp == null) - { - // first fail -> try again with disabled cache - credentials = sftFileSystem.GetCredentials(Uri, false, false); - _sftp = new SftpClient(Uri.Host, port, credentials.UserName, credentials.Password); - - if (_sftp == null) - { - // 2nd fail -> abort - MessageBox.Show("Authentication failed!"); - //MessageBox.Show(sftp.LastErrorText); - return; - } - } - else - { - _sftp.Connect(); - } - } - - if (_sftp.IsConnected == false) - { - MessageBox.Show("Sftp is not connected"); - return; - } - - OriginalLength = _lastLength = Length; - } - - public string FullName => Uri.ToString(); - - public string FileName - { - get - { - string full = FullName; - int i = full.LastIndexOf(DirectorySeparatorChar); - return full.Substring(i + 1); - } - } - - public string DirectoryName - { - get - { - string full = FullName; - int i = full.LastIndexOf(DirectorySeparatorChar); - if (i != -1) - { - return full.Substring(0, i); - } - - return "."; - } - } - - public char DirectorySeparatorChar => '/'; - - public Uri Uri { get; } - - public long Length - { - get - { - SftpFile file = _sftp.Get(_remoteFileName); - return file.Attributes.Size; - } - } - - public long OriginalLength { get; } - - public bool FileExists - { - get - { - try - { - SftpFile file = _sftp.Get(_remoteFileName); - long len = file.Attributes.Size; - return len != -1; - } - catch (Exception e) - { - _logger.LogError(e.Message); - return false; - } - } - } - - public int PollInterval - { - get - { - TimeSpan diff = DateTime.Now - _lastChange; - if (diff.TotalSeconds < 4) - { - return 400; - } - - if (diff.TotalSeconds < 30) - { - return (int)diff.TotalSeconds * 100; - } - - return 5000; - } - } - - public bool FileHasChanged() - { - if (Length != _lastLength) - { - _lastLength = Length; - _lastChange = DateTime.Now; - return true; - } - - return false; - } - - public Stream OpenStream() - { - return _sftp.OpenRead(_remoteFileName); - } - } -} diff --git a/src/SftpFileSystemx64/SftpLogFileInfoSharpSSH.cs b/src/SftpFileSystemx64/SftpLogFileInfoSharpSSH.cs deleted file mode 100644 index 5a13f323..00000000 --- a/src/SftpFileSystemx64/SftpLogFileInfoSharpSSH.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using LogExpert; -using Tamir.SharpSsh.jsch; -using System.Windows.Forms; - -namespace SftpFileSystem -{ - class SftpLogFileInfoSharpSSH : ILogFileInfo - { - private long originalFileLength = -1; - - private Uri uri; - private string remoteFileName; - - private ChannelSftp sftpChannel; - - internal SftpLogFileInfoSharpSSH(Uri uri) - { - this.uri = uri; - this.remoteFileName = uri.PathAndQuery; - - string userName = null; - string password = null; - if (uri.UserInfo != null && uri.UserInfo.Length > 0) - { - string[] split = uri.UserInfo.Split(new char[] { ':' }); - if (split.Length > 0) - userName = split[0]; - if (split.Length > 1) - password = split[1]; - } - if (userName == null || password == null) - { - IList userNames = new List(); - LoginDialog dlg = new LoginDialog(uri.Host, userNames); - dlg.UserName = userName; - if (DialogResult.OK == dlg.ShowDialog()) - { - password = dlg.Password; - userName = dlg.UserName; - } - } - - UserInfo userInfo = new SharpSshUserInfo(userName, password); - JSch jsch = new JSch(); - int port = uri.Port != -1 ? uri.Port : 22; - Session session = jsch.getSession(userName, this.uri.Host, port); - session.setUserInfo(userInfo); - session.connect(); - Channel channel = session.openChannel("sftp"); - channel.connect(); - this.sftpChannel = (ChannelSftp)channel; - SftpATTRS sftpAttrs = this.sftpChannel.lstat(this.remoteFileName); - this.originalFileLength = sftpAttrs.getSize(); - - } - - #region ILogFileInfo Member - - public System.IO.Stream OpenStream() - { - throw new NotImplementedException(); - } - - public string FileName - { - get { return this.remoteFileName; } - } - - public long Length - { - get - { - SftpATTRS sftpAttrs = this.sftpChannel.lstat(this.remoteFileName); - return sftpAttrs.getSize(); - } - } - - public long OriginalLength - { - get { return this.originalFileLength; } - } - - public bool FileExists - { - get - { - try - { - SftpATTRS sftpAttrs = this.sftpChannel.lstat(this.remoteFileName); - return true; - } - catch (SftpException e) - { - return false; - } - } - } - - #endregion - - #region ILogFileInfo Member - - - public string FullName - { - get { throw new NotImplementedException(); } - } - - public string DirectoryName - { - get { throw new NotImplementedException(); } - } - - public char DirectorySeparatorChar - { - get { throw new NotImplementedException(); } - } - - public Uri Uri - { - get { throw new NotImplementedException(); } - } - - public int PollInterval - { - get { throw new NotImplementedException(); } - } - - public bool FileHasChanged() - { - throw new NotImplementedException(); - } - - #endregion - } -} diff --git a/src/SftpFileSystemx64/SftpStreamSharpSSH.cs b/src/SftpFileSystemx64/SftpStreamSharpSSH.cs deleted file mode 100644 index 8162f664..00000000 --- a/src/SftpFileSystemx64/SftpStreamSharpSSH.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System; -using System.IO; -using Tamir.SharpSsh.jsch; - -namespace SftpFileSystem -{ - class SftpStreamSharpSSH : Stream - { - private ChannelSftp sftpChannel; - private long currentPos; - private string remoteFileName; - - internal SftpStreamSharpSSH(ChannelSftp sftpChannel, string remoteFileName) - { - this.sftpChannel = sftpChannel; - this.currentPos = 0; - this.remoteFileName = remoteFileName; - } - - public override bool CanRead - { - get { return true; } - } - - public override bool CanSeek - { - get { return true; } - } - - public override bool CanWrite - { - get { return false; } - } - - public override void Flush() - { - throw new NotImplementedException(); - } - - public override long Length - { - get - { - SftpATTRS sftpAttrs = this.sftpChannel.lstat(this.remoteFileName); - return sftpAttrs.getSize(); - } - } - - public override long Position - { - get { return this.currentPos; } - set - { - this.currentPos = value; - } - } - - public override int Read(byte[] buffer, int offset, int count) - { - Tamir.SharpSsh.java.io.OutputStream os = new Tamir.SharpSsh.java.io.OutputStream(); - - this.sftpChannel.get(Tamir.SharpSsh.java.String(this.remoteFileName), os, null, ChannelSftp.RESUME, - this.currentPos); - - this.currentPos += bytes.Length; - Array.Copy(bytes, 0, buffer, offset, bytes.Length); - return bytes.Length; - } - - public override long Seek(long offset, SeekOrigin origin) - { - if (origin == SeekOrigin.Begin) - { - this.Position = offset; - } - else if (origin == SeekOrigin.Current) - { - this.Position += offset; - } - else if (origin == SeekOrigin.End) - { - this.Position = this.Length - offset; - } - return this.Position; - } - - public override void SetLength(long value) - { - throw new NotImplementedException(); - } - - public override void Write(byte[] buffer, int offset, int count) - { - throw new NotImplementedException(); - } - - public override void Close() - { - base.Close(); - this.sftp.CloseHandle(this.handle); - } - - } -} \ No newline at end of file diff --git a/src/SftpFileSystemx64/SharpSshUserInfo.cs b/src/SftpFileSystemx64/SharpSshUserInfo.cs deleted file mode 100644 index 95dc2497..00000000 --- a/src/SftpFileSystemx64/SharpSshUserInfo.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tamir.SharpSsh.jsch; -using System.Windows.Forms; - -namespace SftpFileSystem -{ - internal class SharpSshUserInfo : UserInfo - { - private String password; - private String userName; - - internal SharpSshUserInfo(string userName, string password) - { - this.userName = userName; - this.password = password; - } - - - public String getPassword() { return password; } - - public bool promptYesNo(String str) - { - DialogResult returnVal = MessageBox.Show( - str, - "LogExpert", - MessageBoxButtons.YesNo, - MessageBoxIcon.Warning); - return (returnVal == DialogResult.Yes); - } - - public String getPassphrase() { return null; } - - public bool promptPassphrase(String message) { return true; } - - public bool promptPassword(String message) - { - return true; - } - - public void showMessage(String message) - { - MessageBox.Show( - message, - "LogExpert", - MessageBoxButtons.OK, - MessageBoxIcon.Asterisk); - } - } -} diff --git a/src/SftpFileSystemx86/SftpFileSystemx86.csproj b/src/SftpFileSystemx86/SftpFileSystemx86.csproj index d6794794..eb96b544 100644 --- a/src/SftpFileSystemx86/SftpFileSystemx86.csproj +++ b/src/SftpFileSystemx86/SftpFileSystemx86.csproj @@ -7,6 +7,7 @@ SftpFileSystem true true + true SftpFileSystemx86 $(SolutionDir)..\bin\$(Configuration)\pluginsx86 @@ -48,11 +49,11 @@ - - + - + + diff --git a/src/Solution Items/AssemblyInfo.cs b/src/Solution Items/AssemblyInfo.cs index 29f6db81..d27ce7a1 100644 --- a/src/Solution Items/AssemblyInfo.cs +++ b/src/Solution Items/AssemblyInfo.cs @@ -5,9 +5,9 @@ [assembly: AssemblyProduct("LogExpert")] [assembly: AssemblyCopyright("Original work Copyright (c) 2008-2011 Hagen Raab\r\nModified work Copyright (c) 2025 Zarunbal|Hirogen and many others")] -[assembly: AssemblyVersion("1.12.0")] -[assembly: AssemblyFileVersion("1.12.0")] -[assembly: AssemblyInformationalVersion("1.12.0")] +[assembly: AssemblyVersion("1.20.0")] +[assembly: AssemblyFileVersion("1.20.0")] +[assembly: AssemblyInformationalVersion("1.20.0")] [assembly: ComVisible(false)] //warning CA1824: Mark assemblies with NeutralResourcesLanguageAttribute \ No newline at end of file From 3dc40db7f6bae0f638d8dd35606e814f29756fa4 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 6 Jul 2025 11:09:48 +0200 Subject: [PATCH 138/142] new version 1.20.0 --- src/Directory.Build.props | 27 +++++++++++++++---- .../Controls/LogWindow/LogWindow.cs | 1 - src/LogExpert.sln | 1 + 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 85213014..efb7cc54 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,9 +1,9 @@ 8.2.0 - 2.0.0.0 - 2.0.0.0 - 2.0.0.0-rc1 + 1.20.0.0 + 1.20.0.0 + 1.20.0.0 Hirogen, zarunbal, RandallFlagg, TheNicker Log Expert enable @@ -25,8 +25,25 @@ false false - FIX ME - AssemblyTitle! - FIX ME - Description! + LogExpert + + LogExpert is a Windows tail program (a GUI replacement for the Unix tail command). + + Summary of (most) features: + + * Tail mode + * MDI-Interface with Tabs + * Search function (including RegEx) + * Bookmarks + * A very flexible filter view and possibility to filter to tab + * Highlighting lines via search criteria + * Triggers (e.g. create Bookmark or execute a plugin) via search criteria + * Columnizers: Plugins which split log lines into columns + * Unicode support + * log4j XML file support + * 3rd party plugin support + * Plugin API for more log file data sources + diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs index 6d96f5b8..271af9a6 100644 --- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs +++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs @@ -578,7 +578,6 @@ void ILogWindow.WritePipeTab (IList lineEntryList, string title) WritePipeTab(lineEntryList, title); } - #region Event Handlers [SupportedOSPlatform("windows")] diff --git a/src/LogExpert.sln b/src/LogExpert.sln index e215b839..21ba9ceb 100644 --- a/src/LogExpert.sln +++ b/src/LogExpert.sln @@ -27,6 +27,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Solution Items\AssemblyInfo.cs = Solution Items\AssemblyInfo.cs Directory.Build.props = Directory.Build.props Directory.Packages.props = Directory.Packages.props + ..\GitVersion.yml = ..\GitVersion.yml Solution Items\usedComponents.json = Solution Items\usedComponents.json EndProjectSection EndProject From 82667df5ea259cb1fcff14613e99aceb058a39c3 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 6 Jul 2025 11:33:53 +0200 Subject: [PATCH 139/142] update aboutbox for better readability of the json --- src/LogExpert.UI/Dialogs/AboutBox.Designer.cs | 5 +- src/LogExpert.UI/Dialogs/AboutBox.cs | 50 +++++++------------ 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/src/LogExpert.UI/Dialogs/AboutBox.Designer.cs b/src/LogExpert.UI/Dialogs/AboutBox.Designer.cs index 03671028..c303fc7c 100644 --- a/src/LogExpert.UI/Dialogs/AboutBox.Designer.cs +++ b/src/LogExpert.UI/Dialogs/AboutBox.Designer.cs @@ -1,4 +1,4 @@ -using System.Runtime.Versioning; +using System.Runtime.Versioning; namespace LogExpert.UI.Dialogs; @@ -27,7 +27,7 @@ protected override void Dispose(bool disposing) /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// - private void InitializeComponent() + private void InitializeComponent () { tableLayoutPanel = new TableLayoutPanel(); logoPictureBox = new PictureBox(); @@ -158,6 +158,7 @@ private void InitializeComponent() // usedComponentsDataGrid.AllowUserToAddRows = false; usedComponentsDataGrid.AllowUserToDeleteRows = false; + usedComponentsDataGrid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; usedComponentsDataGrid.BackgroundColor = SystemColors.Control; usedComponentsDataGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; usedComponentsDataGrid.Dock = DockStyle.Fill; diff --git a/src/LogExpert.UI/Dialogs/AboutBox.cs b/src/LogExpert.UI/Dialogs/AboutBox.cs index e0f0d016..37afa730 100644 --- a/src/LogExpert.UI/Dialogs/AboutBox.cs +++ b/src/LogExpert.UI/Dialogs/AboutBox.cs @@ -24,7 +24,7 @@ public AboutBox () InitializeComponent(); LoadResources(); - + usedComponentsDataGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; _assembly = Assembly.GetExecutingAssembly(); Text = $@"About {AssemblyTitle}"; @@ -32,7 +32,7 @@ public AboutBox () labelVersion.Text = AssemblyVersion; labelCopyright.Text = AssemblyCopyright; var link = "https://github.com/LogExperts/LogExpert"; - linkLabelURL.Links.Add(new LinkLabel.Link(0, link.Length, link)); + _ = linkLabelURL.Links.Add(new LinkLabel.Link(0, link.Length, link)); LoadUsedComponents(); } @@ -44,6 +44,7 @@ private void LoadUsedComponents () var usedComponents = JsonConvert.DeserializeObject(json); usedComponents = usedComponents?.OrderBy(x => x.PackageId).ToArray(); usedComponentsDataGrid.DataSource = usedComponents; + } @@ -64,7 +65,7 @@ public string AssemblyTitle if (attributes.Length > 0) { var titleAttribute = (AssemblyTitleAttribute)attributes[0]; - if (titleAttribute.Title != string.Empty) + if (!string.IsNullOrEmpty(titleAttribute.Title)) { return titleAttribute.Title; } @@ -77,20 +78,11 @@ public string AssemblyVersion { get { - AssemblyName assembly = _assembly.GetName(); - - if (assembly.Version != null) - { - var version = $"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}.{assembly.Version.Revision}"; - if (assembly.Version.Revision >= 9000) - { - version += " Testrelease"; - } - - return version; - } + var assembly = _assembly.GetName(); - return "0.0.0.0"; + return assembly.Version != null + ? $"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}.{assembly.Version.Revision}" + : "0.0.0.0"; } } @@ -101,11 +93,9 @@ public string AssemblyDescription { var attributes = _assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); - if (attributes.Length == 0) - { - return string.Empty; - } - return ((AssemblyDescriptionAttribute)attributes[0]).Description; + return attributes.Length == 0 + ? string.Empty + : ((AssemblyDescriptionAttribute)attributes[0]).Description; } } @@ -114,11 +104,9 @@ public string AssemblyProduct get { var attributes = _assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false); - if (attributes.Length == 0) - { - return string.Empty; - } - return ((AssemblyProductAttribute)attributes[0]).Product; + return attributes.Length == 0 + ? string.Empty + : ((AssemblyProductAttribute)attributes[0]).Product; } } @@ -127,11 +115,9 @@ public string AssemblyCopyright get { var attributes = _assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); - if (attributes.Length == 0) - { - return string.Empty; - } - return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + return attributes.Length == 0 + ? string.Empty + : ((AssemblyCopyrightAttribute)attributes[0]).Copyright; } } @@ -148,7 +134,7 @@ private void OnLinkLabelURLClicked (object sender, LinkLabelLinkClickedEventArgs target = e.Link.LinkData as string; } - Process.Start(new ProcessStartInfo + _ = Process.Start(new ProcessStartInfo { UseShellExecute = true, FileName = target, From a96f6fe1a84de455830f29864c485c75346f84b5 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 6 Jul 2025 11:43:21 +0200 Subject: [PATCH 140/142] update used packages --- src/usedPackages.json | Bin 13280 -> 13280 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/usedPackages.json b/src/usedPackages.json index 291e04bf08c1763d7c827cedc6715aab14ff5122..0b48bbdee1a507cd9c3b1ad9e53391c4827bbbde 100644 GIT binary patch delta 156 zcmaEm{vdtB1r}CA20aFY$$OJb9N=%w_?#MQlK0 w6y>ES7qHq)=F*j!{76q^@&P`v%>lZT7=h*l3M6lK)30FyGkrG;7+qil0PB=64FCWD delta 150 zcmaEm{vdtB1(wN4szIBTSeLO*zQ7VR*+5@xvH^D;qsiopg4&yJaqnSdG@g8sB@iUB z`5$iv2eT=I-sFvv!JGGpePd!a26Frb{3mB=@NE{7^5bSTWUzz^?NW-_ETFcCjoAb! vpeQXlxq#JXGMBCl(CCfanwtZ3CowXbP7V}E-t4Ad!!-GXu-|3@qYI1x2L3PC From b5ef59cca204012cc203f5d1acf89adb041f3497 Mon Sep 17 00:00:00 2001 From: Hirogen Date: Sun, 6 Jul 2025 11:45:36 +0200 Subject: [PATCH 141/142] update link --- lib/3rdparty.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/3rdparty.txt b/lib/3rdparty.txt index be26adc5..140f0a8a 100644 --- a/lib/3rdparty.txt +++ b/lib/3rdparty.txt @@ -8,7 +8,7 @@ Released under "MIT X11 license" DockPanel Suite: ---------------- -http://sourceforge.net/projects/dockpanelsuite/ +https://github.com/dockpanelsuite/dockpanelsuite Copyright (c) 2007 Weifen Luo (email: weifenluo@yahoo.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. From 0139f1191e8141a06be402fa3168951c0990a2bd Mon Sep 17 00:00:00 2001 From: Patrick Bruner Date: Sun, 6 Jul 2025 11:50:29 +0200 Subject: [PATCH 142/142] Update src/Directory.Build.props Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index efb7cc54..76e48ec8 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,6 +1,6 @@ - 8.2.0 + 1.20.0.0 1.20.0.0 1.20.0.0 1.20.0.0